Skip to content

feat(#497): sequant init --agent codex — .agents/skills symlink, .codex hooks wrapper, doctor, README - #1066

Merged
admarble merged 9 commits into
mainfrom
feature/1059-feat-497-sequant-init-agent-codex-agents-skills-sy
Sep 16, 2026
Merged

admarble merged 9 commits into
mainfrom
feature/1059-feat-497-sequant-init-agent-codex-agents-skills-sy

Conversation

@admarble

@admarble admarble commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • sequant init --agent codex provisions a relative .agents/skills -> ../.claude/skills symlink and a .codex/config.toml hooks wrapper (from templates/codex/config.toml) pointing at the existing, unmodified .claude/hooks/pre-tool.sh / post-tool.sh.
  • doctor gains a codex block mirroring the opencode block: binary check, CODEX_MIN_VERSION floor (imported from src/lib/workflow/drivers/codex.ts, not redefined), and auth check (CODEX_API_KEY or codex login status).
  • README gains a Codex subsection (install, auth, symlink, trust requirement, why --dangerously-bypass-hook-trust is safe here) and both init output and README state the exact trust_level = "trusted" TOML needed for project-layer hooks to load.
  • sequant update/sync preserve the symlink in both symlink and copy modes.
  • codex is sent the skill invocation — $spec 1 — not the Claude Code prose template, via a new optional AgentDriver.buildSkillPrompt. run 1 --agent codex --dry-run prints it, and init --agent <name> persists run.agent so doctor runs that driver's checks.

AC Verification

AC Description Status Evidence
AC-1 .agents/skills relative symlink, idempotent ✅ src/commands/init.codex.integration.test.ts
AC-2 .codex/config.toml hooks wrapper from one template; .claude/hooks/*.sh unchanged ✅ src/commands/init.codex.integration.test.ts, templates/codex/config.toml
AC-3 Recorded codex PreToolUse payload compatible with existing hook (gate, mutation-verified) ✅ __tests__/pre-tool-hook.integration.test.ts (497 AC-3)
AC-4 doctor checks codex binary, CODEX_MIN_VERSION, auth ✅ src/commands/doctor.test.ts
AC-5 init output + README state exact trust_level = "trusted" TOML ✅ src/commands/init.test.ts
AC-6 sequant update preserves symlink (symlink + copy modes) ✅ src/commands/init.codex.integration.test.ts
AC-7 README Codex subsection (install/auth/symlink/trust/rationale) ✅ README.md
AC-8 run 1 --agent codex --dry-run resolves driver, prints $spec 1 ✅ src/commands/cli.integration.test.ts (AC's exact command, no --verbose), src/lib/workflow/phase-executor.test.ts

Mutation-verified gate tests

Re-recorded after QA on #1059 rejected the first AC-3 record: it named no test file (the repo's own classifyMutationMarker splits failedTest on > and returned test_not_in_diff), and it mutated the shared .claude/hooks/pre-tool.sh guard rather than the codex fixture the gate actually asserts — which ~30 pre-existing force-push tests already cover. AC-5 had no record at all. Each mutation below started from a clean tree (git status --short | wc -l = 0) and was restored to a clean tree afterwards.

Mutation-verified: AC-1 — deleted the isDirectory() guard in writeCodexSkillsSymlink; src/commands/init.codex.integration.test.ts > AC-1: --force replaces a stray file but never a real directory failed (EEXIST from the bare unlink), 7 other tests in the file still passed; restored.

Mutation-verified: AC-3 — dropped tool_input.command from the recorded codex payload fixture (tool_input: { command } → tool_input: {}), so the envelope no longer carries the command where the hook reads it; __tests__/pre-tool-hook.integration.test.ts > 497 AC-3: blocks git push --force via the codex PreToolUse payload shape (exit 2, HOOK_BLOCKED) failed (exit 0, expected 2) across all three HOOK_COPIES parameterizations, 3 failed / 3 passed within the AC-3 block and nothing outside it; restored, 6 passed.

Mutation-verified: AC-5 — removed the CODEX_TRUST_LEVEL_TOML line from init's completion notice; exactly src/commands/init.test.ts > prints the exact trust_level TOML requirement when --agent codex failed (1 failed, 1 passed in the AC-5 block); restored.

Mutation-verified: AC-8 — reverted CodexDriver.buildSkillPrompt to the Claude Code slash form (/${skill} ${issue}); exactly the three AC-8 tests failed — src/lib/workflow/phase-executor.test.ts > 1059 AC-8 sends codex the $ invocation, not the prose template, its AGENTS.md sibling, and the cli.integration.test.ts dry-run case; restored, suite green.

QA round 2 — AC-8 fixed at the driver layer

QA round 2 blocked on AC-8: the codex path emitted Run the /spec 1 workflow. (the registry's Claude-shaped prose template) and nothing ever emitted $spec 1, so the .agents/skills symlink this issue exists to create was never exercised. The probe rules out the obvious shape — "Drop CODEX_PHASE_PROMPTS / driverOverrides.codex" — because the invocation is one syntax rule for every phase, not eight rewritten prompts. So:

  • AgentDriver gains an optional buildSkillPrompt(skill, issue); CodexDriver returns `$${skill} ${issue}`. Drivers that leave it undefined keep today's template.
  • AGENTS.md is not prepended to a skill invocation — codex reads AGENTS.md from the repo itself, and inlining it would bury the invocation the prompt exists to carry.
  • The dry run prints the invocation in the driver's own syntax, unconditionally, replacing a hard-coded /${phase} ${issue} that described a command codex would never run. Same reasoning as feat: add opencode agent driver — first backend that can inherit the full skill methodology #862 AC-3 for the driver name.
  • The AC-8 test now runs the AC's command verbatim (no --verbose) and asserts $spec 1, plus not.toContain("/spec 1").

The first cut of this broke two contracts the suite already pinned — #862 AC-3 (getDriver throws on an unknown name, and a dry run must still print a plan) and #863 (every getDriver call on a phase path carries the configured driver settings). Both were caught by their existing tests and fixed in 51518732: the lookup takes DriverOptions from the execution config and never throws.

QA round 3 — AC_MET_BUT_NOT_A_PLUS, four gaps fixed

  • createSymlink's return value was discarded. It answers EPERM/EACCES (Windows without privileges) with false rather than throwing — the case its other consumer, copyTemplates, handles by falling back to a copy. writeCodexSkillsSymlink returned "created" regardless, so init would print ✔ Symlinked .agents/skills -> ../.claude/skills with no symlink on disk and codex skill discovery would fail silently. New "unsupported" status and a warning naming the cause. No copy fallback here: a copied skill tree goes stale the moment .claude/skills changes.
  • The Windows limitation is now noted in the README's Codex subsection and in writeCodexSkillsSymlink's JSDoc, which the issue's Non-goals explicitly ask for ("note as a limitation, do not solve").
  • The F4 settings fix is now pinned — init.test.ts mocks createDefaultSettings, so nothing asserted that initCommand forwards options.agent, and nothing covered the new conditional "agent" line. Both are tested now (src/lib/settings.agent-key.test.ts).
  • resolveDriverName's JSDoc restored — the previous commit inserted a new doc block between it and its function.

QA also rebased this branch onto origin/main mid-review, rewriting seven already-pushed commits. That was undone: the branch was reset to its pushed state and main merged in (35dc1109), per the repo's merge-not-rebase rule. Content is identical either way.

Mutation-verified: AC-1 (symlink refusal) — dropped the createSymlink return-value check so the function reported "created" unconditionally; exactly src/commands/init.codex.integration.test.ts > AC-1: reports unsupported rather than success when the OS refuses the symlink failed, the other 8 tests in the file passed; restored.

QA follow-ups applied

  • writeCodexSkillsSymlink(dir, true) threw EEXIST on a real directory at .agents/skills (removeFileOrSymlink is a bare unlink), aborting init before .codex/config.toml was written. A directory is now reported as skipped-foreign and left intact — --force still replaces a stray file — with the new AC-1 test above.
  • An idempotent re-run printed Symlinked .agents/skills -> ..., claiming work it had not done; it now reports the no-op.
  • [Unreleased] gained the init/doctor/README entry.
  • F4: init --agent <name> now persists run.agent in .sequant/settings.json (createDefaultSettings(agent)), so doctor runs the configured driver's checks after the documented setup path. Verified by hand in a scratch repo: a plain init --agent codex now yields both the codex CLI and codex auth checks, which were previously absent — the README's claim that doctor checks codex auth was true only if the user hand-edited settings.json.

Documented, not fixed (out of this issue's scope): templates/codex/ has no direct templateDestination null-routing test; getCodexVersion / isCodexAuthenticated call execSync without a timeout (the same pattern as the pre-existing getOpencodeVersion); AC-2's literal grep now returns 3 rather than 1, the extra hits being a JSDoc comment describing the check and the test asserting it (the substantive "one real TOML template" requirement holds, and the test filters to /templates/ first); and AC-6's stated verify command -t "497 AC-6" selects #1058's tests — this issue's are named 1059 AC-6, so the correct command is npx vitest run src/commands/init.codex.integration.test.ts.

Test plan

  • npm run build
  • npm run lint
  • npm test (full suite, foreground, re-run after the round-3 fixes) — 318 files, 6432 passed, 0 failed, 1 expected fail, 3 skipped. The three failures the original run called "pre-existing" never recurred.
  • sequant init --agent codex + sequant doctor run by hand in a scratch repo (F4)
  • AC-3 mutation-verified (see above)

Closes #1059

t added 5 commits September 15, 2026 17:45
codex provisioning (symlink+config.toml), doctor checks, README, tests

Entire-Checkpoint: 424c8f4691d1
QA on #1059 found `writeCodexSkillsSymlink(dir, true)` throws EEXIST on a real
directory at .agents/skills: removeFileOrSymlink is a bare unlink. The throw
aborts init before .codex/config.toml is written. Treat a directory as
skipped-foreign — recursively deleting a directory the user created is not a
cost --force should imply — and report an idempotent re-run as the no-op it is
rather than claiming it symlinked anything.
t added 4 commits September 15, 2026 20:24
…at init

AC-8 requires the codex dry run to print $spec 1; the path emitted the Claude
Code prose template (Run the /spec 1 workflow.), which codex never resolves —
so the .agents/skills symlink this issue adds was never exercised. The probe
settled the fix at the driver layer rather than as per-phase driverOverrides
("Prompt is $<phase> <issue> — the skill name, not a rewritten prompt"), so
AgentDriver gains an optional buildSkillPrompt; CodexDriver returns $<skill>
<issue> and AGENTS.md is not prepended to it (codex reads AGENTS.md itself).
The dry run now prints the invocation in the driver's own syntax instead of a
hard-coded slash form, unconditionally — which backend runs what is part of the
plan, the same reasoning as #862 AC-3.

init --agent <name> now persists run.agent, so doctor runs that driver's checks
after the documented setup path; the README's claim that doctor checks codex
auth was previously true only if the user hand-edited settings.json.
The first cut of buildSkillPrompt called getDriver(agent) bare inside
getPhasePrompt, which broke two contracts the suite already pinned: #862 AC-3
(a dry run with an unknown driver still prints a plan — getDriver throws on an
unknown name) and #863 (every getDriver call on a phase path carries the
configured driver settings). The lookup now takes DriverOptions from the
execution config and swallows construction failures, leaving the real error to
the execution path that follows.
…ng success

QA round 3: createSymlink returns false on EPERM/EACCES rather than throwing
(the Windows-without-privileges case copyTemplates answers with a copy
fallback), and writeCodexSkillsSymlink discarded it — init would print
'Symlinked .agents/skills -> ../.claude/skills' with no symlink on disk and
codex skill discovery would fail silently. A copy fallback is not available
here: a copied skill tree goes stale the moment .claude/skills changes. New
'unsupported' status, a warning that names the Windows cause, and the Windows
limitation noted in the README and the JSDoc, as the issue's Non-goals ask.

Also pins the F4 settings fix (init forwards --agent; generateSettingsJsonc
emits run.agent) and restores resolveDriverName's JSDoc, which the previous
commit left attached to the wrong function.
@admarble
admarble merged commit 59bd9a8 into main Sep 16, 2026
8 checks passed
@admarble
admarble deleted the feature/1059-feat-497-sequant-init-agent-codex-agents-skills-sy branch September 16, 2026 05:27
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.

feat(#497): sequant init --agent codex — .agents/skills symlink, .codex hooks wrapper, doctor, README

1 participant