Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .claude/skills/codemap/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ codemap serve --port 9471 # HTTP API for non-MCP integrations

Before deeper Codemap analysis in a repo:

1. Check `.codemap/config.json`.
1. Check `.codemap/config.json`. A repo with no `.codemap/` folder was never set up: leave it that way unless the user asks (codemap keeps its state outside the repo).
2. If it is missing, clearly boilerplate, or obviously too noisy for the stack, run `codemap skill show config-setup` and follow it.
3. After writing or improving config, rerun `codemap .` and `codemap --deps`.

Expand Down Expand Up @@ -107,6 +107,9 @@ Skills matched: hub-safety, refactor - run `codemap skill show <name>` for guida
- **Intent categories**: refactor, bugfix, feature, explore, test, docs
- **Risk levels**: low (no hubs), medium (1 hub), high (2+ hubs or 8+ importers)
- **Skills are pull-based**: only names are shown, run `codemap skill show` for full body
- **Suggestions** print only for a named file with dependency evidence; otherwise the marker has `"suggestions":[]`

The edit hooks print hub facts only (hub warning, dependents, `Imported by N`, `Imports N hub(s)`) and stay silent for files outside the project. A subagent gets the top-level directories and the hub list at start, since it never sees the session-start tree.

## Builtin Skills

Expand Down
4 changes: 2 additions & 2 deletions .claude/skills/config-setup/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description: Set up or tune .codemap/config.json so Codemap focuses on code-rele

A score of 100 means a hook found the config missing, empty, malformed, or boilerplate. Fix it first; it takes under a minute and every later Codemap answer depends on it.

1. Run `codemap config show` to see the current state. If it says missing, run `codemap config init` (most commands now do this for you).
1. Run `codemap config show` to see the current state. If it says missing, codemap is running on auto-detected filters kept outside the repo; run `codemap config init` to write a committable `.codemap/config.json`.
2. Write or tune `.codemap/config.json` using the workflow below: keep source extensions in `only`, add `exclude` for real noise, set `depth` if the tree is wide.
3. Rerun `codemap .` and confirm the tree is dominated by source, not assets.
4. Verify one known cross-file dependency still resolves with `codemap --importers <file>`.
Expand All @@ -22,7 +22,7 @@ Write or improve `.codemap/config.json` so future Codemap calls stay focused on

## Use this when

1. `.codemap/config.json` is missing
1. `.codemap/config.json` is missing in a repo the user has set up (`.codemap/` exists), or the user asked to set codemap up. Never create `.codemap/` in a repo the user has not asked to set up.
2. The existing config looks like a bare bootstrap instead of a real project policy
3. Codemap output is dominated by assets, fixtures, generated files, vendor trees, PDFs, screenshots, models, or training data
4. The project stack is obvious, but Codemap is not prioritizing the right parts of the repo
Expand Down
10 changes: 6 additions & 4 deletions .claude/skills/handoff/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ The prefix file count and size-based handoff budgets honor the active

## Artifacts written

In the per-user state dir, never in the repo; `codemap doctor` prints its path on the `state dir:` line.

| File | Content |
|------|---------|
| `.codemap/handoff.latest.json` | Full artifact (all layers) |
| `.codemap/handoff.prefix.json` | Stable prefix snapshot |
| `.codemap/handoff.delta.json` | Dynamic delta snapshot |
| `.codemap/handoff.metrics.log` | Append-only metrics stream |
| `handoff.latest.json` | Full artifact (all layers) |
| `handoff.prefix.json` | Stable prefix snapshot |
| `handoff.delta.json` | Dynamic delta snapshot |
| `handoff.metrics.log` | Append-only metrics stream |
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Treat codemap as part of the execution loop, not as optional reference material:
- Before editing any file: `codemap --importers <file>`
- Before refactors, moves, or dependency-heavy changes: `codemap --deps`
- Before summarizing, reviewing, or committing: `codemap --diff`
- If a codemap hook prints `Next codemap:` or `Run now:`, do that before continuing
- If a codemap hook warns that a file is a hub, read its dependents list before editing

Use `rg` for exact string lookup after codemap has established structure or blast radius.

Expand Down
2 changes: 1 addition & 1 deletion blast_radius.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ func buildBlastRadiusBundle(absRoot, ref string, limits blastRadiusLimits) (blas
return blastRadiusBundle{}, &blastRadiusDiffError{ref: ref, err: err}
}

cmd.EnsureProjectConfig(absRoot)
cmd.EnsureAutoConfig(absRoot)
cfg := config.Load(absRoot)
filters := scanner.Filters{Only: cfg.Only, Exclude: cfg.Exclude, MaxFiles: cfg.MaxFiles}
gitCache := scanner.NewGitIgnoreCache(absRoot)
Expand Down
28 changes: 19 additions & 9 deletions cmd/agent_edits.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (
"strings"
"time"

"codemap/internal/gitexclude"
"codemap/internal/projectpath"
"codemap/internal/runtimefile"
)

// The watch daemon sees every write on disk — including git merges, checkouts,
Expand All @@ -34,8 +35,14 @@ type agentEdits struct {
bySession map[string]map[string]bool // session id -> paths
}

// agentEditsPath is agent_edits.jsonl in the project's state dir; "" when
// there is no usable state dir.
func agentEditsPath(root string) string {
return filepath.Join(root, ".codemap", agentEditsFile)
selection, err := projectpath.SelectRuntime(root)
if err != nil {
return ""
}
return filepath.Join(selection.RuntimeDir, agentEditsFile)
}

// normalizeAgentEditPath converts hook-provided paths (often absolute, with
Expand All @@ -56,8 +63,12 @@ func recordAgentEdit(root, sessionID, path string, now time.Time) error {
if strings.TrimSpace(path) == "" {
return nil
}
if err := gitexclude.MkdirAll(filepath.Join(root, ".codemap"), 0o755); err != nil {
return err
if _, inRoot := projectRelPath(root, path); !inRoot {
return nil
}
logPath := agentEditsPath(root)
if logPath == "" {
return nil
}
record := agentEditRecord{
Path: normalizeAgentEditPath(root, path),
Expand All @@ -68,9 +79,8 @@ func recordAgentEdit(root, sessionID, path string, now time.Time) error {
if err != nil {
return err
}
logPath := agentEditsPath(root)
compactAgentEdits(logPath, now)
f, err := os.OpenFile(logPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644)
f, err := runtimefile.OpenAppend(logPath, 0o600)
if err != nil {
return err
}
Expand All @@ -89,7 +99,7 @@ func compactAgentEdits(logPath string, now time.Time) {
if err != nil || info.Size() <= agentEditsMaxBytes {
return
}
data, err := os.ReadFile(logPath)
data, err := runtimefile.Read(logPath)
if err != nil {
return
}
Expand All @@ -107,7 +117,7 @@ func compactAgentEdits(logPath string, now time.Time) {
kept.Write(scanner.Bytes())
kept.WriteByte('\n')
}
_ = writeFileAtomic(logPath, kept.Bytes(), 0o644)
_ = runtimefile.WriteAtomic(logPath, kept.Bytes(), 0o600)
}

// loadAgentEdits reads records at or after `since`. Missing or malformed logs
Expand All @@ -117,7 +127,7 @@ func loadAgentEdits(root string, since time.Time) agentEdits {
paths: make(map[string]bool),
bySession: make(map[string]map[string]bool),
}
data, err := os.ReadFile(agentEditsPath(root))
data, err := runtimefile.Read(agentEditsPath(root))
if err != nil {
return edits
}
Expand Down
Loading
Loading