codemap icon indicating copy to clipboard operation
codemap copied to clipboard

hooks: UserPromptSubmit nags config-setup in non-git dirs (e.g. $HOME); add a root allowlist

Open JordanCoin opened this issue 1 month ago • 0 comments

What happens

codemap 4.6.0, when Claude Code starts in a directory that isn't a git repo (for example $HOME):

  • The SessionStart hook says it's skipping: 📍 Not a git repository - skipping project context.
  • The UserPromptSubmit hook still runs on every prompt anyway. Each time it emits the intent/skills comments, check-deps suggestions, and this blocking line:
🛑 Codemap setup is not finished. Before continuing the user's task: run `codemap skill show config-setup`, tune .codemap/config.json, rerun `codemap .`, then proceed.

This tells the agent to create .codemap/config.json in a directory that is not a project. In $HOME it means writing config into the home directory. The agent has to ignore the same instruction on every turn of the session.

Expected

If codemap has decided a directory isn't a project, every hook should stay quiet for that session, not just SessionStart.

Proposal

  1. Gate the prompt hooks the same way SessionStart is gated. When there is no git repo and no .codemap/config.json, emit nothing: no 🛑, no suggestions.
  2. Add an allowlist (and optionally a denylist) of roots in user-level config, for example ~/.config/codemap/config.json:
    { "roots": { "allow": ["~/code", "~/work"], "deny": ["~", "/tmp"] } }
    
    Hooks only fire inside allowed roots. A denied path such as $HOME itself never triggers setup nags, even if someone runs git init there.
  3. Make the config-setup 🛑 advisory outside a repo. It should never be phrased as a blocking "before continuing the user's task" instruction when there's no project to configure.

Repro

cd ~                        # not a git repo
claude                      # with codemap hooks installed
# SessionStart: "Not a git repository - skipping project context"
# send any prompt -> UserPromptSubmit emits the config-setup 🛑

JordanCoin avatar Oct 28 '26 18:10 JordanCoin