[codex] Add transition-based codemap hook guidance#62
[codex] Add transition-based codemap hook guidance#62JordanCoin wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Updates codemap’s Claude hook output to provide phase-aware, actionable “next commands” (e.g., codemap --importers, codemap --deps) at key transitions like prompt submit and before/after edits, aligning the hooks with an execution-loop workflow.
Changes:
- Add “Next codemap:” guidance on prompt submit based on classified intent + mentioned files.
- Make pre-/post-edit hook output phase-aware (“Before editing” / “After editing”) and include “Run now:” / “Re-check with:” command suggestions.
- Update docs and tests to cover and document the new guidance blocks.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/HOOKS.md | Documents the updated hook output, including phase-aware and prompt-submit “Next codemap” command guidance. |
| cmd/hooks_more_test.go | Adjusts tests to assert the new hook output strings for pre-edit/post-edit and prompt-submit guidance. |
| cmd/hooks.go | Implements intent-driven “Next codemap” planning and phase-aware pre/post-edit action guidance output. |
| README.md | Updates high-level README description to reflect transition-point command emission. |
| CLAUDE.md | Updates repo usage guidance to treat codemap commands as part of the execution loop. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if len(steps) == 0 { | ||
| return | ||
| } | ||
|
|
There was a problem hiding this comment.
showFileCodemapActions always seeds steps with one element, so if len(steps) == 0 { return } is unreachable. Remove the dead check, or only append the initial step when you actually want to emit guidance.
| if len(steps) == 0 { | |
| return | |
| } |
| fmt.Println() | ||
| } | ||
|
|
||
| showFileCodemapActions(filePath, len(importers), len(hubImports) > 0, phase) | ||
|
|
There was a problem hiding this comment.
showFileCodemapActions(...) is invoked unconditionally, so pre/post-edit hooks will now emit "Run now/Re-check with" guidance even when the file has 0 importers and does not import any hubs. That adds noise/token cost and doesn’t match the PR description’s framing of phase-aware guidance for risky files. Consider gating this call (or early-returning inside showFileCodemapActions) unless importerCount > 0 or importsHub (or some other explicit risk predicate).
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3e5d5d2b06
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if len(intent.Files) > 0 || intent.Scope != "single-file" { | ||
| add("codemap --deps", "feature work tends to cross existing dependencies") |
There was a problem hiding this comment.
Gate
codemap --deps suggestion when no files are mentioned
In planCodemapNextSteps, feature prompts with no detected files always add codemap --deps because the condition uses intent.Scope != "single-file"; computeScope returns "unknown" when no files are present, so this branch is always true. In practice, generic prompts like “add X feature” will now trigger a full dependency guidance step even before any target file/package is known, which adds noisy and often expensive advice on every such prompt.
Useful? React with 👍 / 👎.
Summary
This changes codemap’s hook guidance from generic protocol nudges to concrete transition-time commands.
Next codemap:command suggestions during prompt-submit based on intent and mentioned filesRun now:/Re-check with:commands for risky filesWhy
Claude was treating codemap as orientation help instead of part of the execution loop. The existing hook output described risk, but it did not consistently turn that into an explicit next action at the moment a risky edit was about to happen.
Validation
go test ./cmdgo test ./...