Skip to content

[codex] Add transition-based codemap hook guidance#62

Open
JordanCoin wants to merge 1 commit intomainfrom
codex/transition-hook-guidance
Open

[codex] Add transition-based codemap hook guidance#62
JordanCoin wants to merge 1 commit intomainfrom
codex/transition-hook-guidance

Conversation

@JordanCoin
Copy link
Copy Markdown
Owner

Summary

This changes codemap’s hook guidance from generic protocol nudges to concrete transition-time commands.

  • add Next codemap: command suggestions during prompt-submit based on intent and mentioned files
  • make pre-edit and post-edit guidance phase-aware with Run now: / Re-check with: commands for risky files
  • update tests and docs so the new hook output is covered and documented

Why

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 ./cmd
  • go test ./...

@JordanCoin JordanCoin marked this pull request as ready for review March 29, 2026 03:34
Copilot AI review requested due to automatic review settings March 29, 2026 03:35
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +1570 to +1573
if len(steps) == 0 {
return
}

Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
if len(steps) == 0 {
return
}

Copilot uses AI. Check for mistakes.
Comment on lines 1548 to +1552
fmt.Println()
}

showFileCodemapActions(filePath, len(importers), len(hubImports) > 0, phase)

Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +878 to +879
if len(intent.Files) > 0 || intent.Scope != "single-file" {
add("codemap --deps", "feature work tends to cross existing dependencies")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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.

2 participants