Skip to content

feat(codexcli): add PostCompact hook event and preserve prompt frontmatter - #1895

Merged
dyoshikawa merged 1 commit into
mainfrom
resolve-scrap-issue-1879-codex-postcompact
Jun 16, 2026
Merged

feat(codexcli): add PostCompact hook event and preserve prompt frontmatter#1895
dyoshikawa merged 1 commit into
mainfrom
resolve-scrap-issue-1879-codex-postcompact

Conversation

@dyoshikawa

Copy link
Copy Markdown
Owner

Summary

Follow up on Codex CLI upstream updates from issue #1879.

Part A — PostCompact hook event

Codex CLI documents a PostCompact hook event that runs after Codex compacts the conversation, with the matcher applied to the trigger (manual / auto). This is distinct from the already-supported PreCompact.

  • Added postCompact to the canonical HookEvent union.
  • Added postCompact to CODEXCLI_HOOK_EVENTS (after preCompact).
  • Added postCompact: "PostCompact" to CANONICAL_TO_CODEXCLI_EVENT_NAMES; the reverse map is derived automatically. No other tool documents this event, so no other tool map was touched.
  • The hooks processor and codexcli-hooks.ts read these constants generically, so no further wiring was needed.

Part B — preserve description / argument-hint on Codex CLI custom prompts (fully implemented)

Codex custom prompts support description: and argument-hint: frontmatter, which the adapter previously discarded on both generate and import. The adapter now models its frontmatter with z.looseObject (consistent with claudecode-command.ts), reads these fields in fromFile, re-emits them in fromRulesyncCommand, and round-trips description (canonical) and argument-hint (under the codexcli section) in toRulesyncCommand. Prompts without metadata stay as plain Markdown bodies (no empty frontmatter is emitted).

Files changed

  • src/types/hooks.ts — add postCompact event + Codex CLI mapping
  • src/types/hooks.test.ts — Codex CLI event-naming + map-completeness tests
  • src/features/hooks/codexcli-hooks.test.tspostCompactPostCompact round-trip tests
  • src/features/commands/codexcli-command.ts — frontmatter support for description / argument-hint
  • src/features/commands/codexcli-command.test.ts — frontmatter round-trip tests
  • docs/reference/file-formats.mdpostCompact matrix row (Codex CLI only) + codexcli command frontmatter example
  • skills/rulesync/file-formats.md — auto-synced from docs/

Validation evidence

Checks

pnpm cicheck is fully green: format, oxlint, typecheck, 6409 tests passing, skill-docs sync, cspell, secretlint all clean.

Closes #1879

Related issue: #1879

🤖 Generated with Claude Code

…atter

Part A: add the PostCompact Codex CLI hook event (matcher applied to trigger: manual/auto), distinct from PreCompact. Wire it through the canonical HookEvent union, CODEXCLI_HOOK_EVENTS, and the Codex CLI event-name maps.

Part B: preserve description and argument-hint frontmatter on Codex CLI custom prompts across generate and import, modeling frontmatter with z.looseObject like other command adapters.

Closes #1879

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dyoshikawa
dyoshikawa merged commit eba74b8 into main Jun 16, 2026
9 checks passed
@dyoshikawa

Copy link
Copy Markdown
Owner Author

@dyoshikawa Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Follow up Codex CLI upstream updates: PostCompact hook event and prompt frontmatter (description/argument-hint)

2 participants