Skip to content

Commit e2a92db

Browse files
Bordaclaude
andcommitted
refine(codemap): rename skills scan-codebase, query-code & fix Win CI
- Rename /codemap:scan → /codemap:scan-codebase and /codemap:query → /codemap:query-code to eliminate routing ambiguity with generic names - Propagate new names across integration/SKILL.md (8 refs), calibrate/modes/skills.md, preflight-helpers.md, develop/skills/review, oss/skills/review, develop/README.md, codemap/README.md (section headings, TOC, anchors, examples) - Update bin/ scripts (scan-stats, check_index_freshness, check_injection, scan-query, codemap-resolve) and their tests - codemap 0.4.2 → 0.5.0 (X-class: user-visible invocation rename); foundry 0.22.1 → 0.22.2 (Y-class: haiku rule addition from prior session) --- Co-authored-by: Claude Code <noreply@anthropic.com>
1 parent dac119c commit e2a92db

59 files changed

Lines changed: 283 additions & 193 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎plugins/codemap/.claude-plugin/plugin.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
"license": "MIT",
1818
"name": "codemap",
1919
"repository": "https://github.com/Borda/AI-Rig",
20-
"version": "0.4.2"
20+
"version": "0.5.0"
2121
}

‎plugins/codemap/README.md‎

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ ______________________________________________________________________
2020
- [Quick start](#quick-start)
2121
- [Skills reference](#skills-reference)
2222
- [integration](#integration)
23-
- [scan](#scan)
24-
- [query](#query)
23+
- [scan-codebase](#scan-codebase)
24+
- [query-code](#query-code)
2525
- [How it works](#how-it-works)
2626
- [Configuration](#configuration)
2727
- [Troubleshooting](#troubleshooting)
@@ -87,7 +87,7 @@ Zero codemap timeouts. Plain-arm agents hit the 300-second hard timeout on sever
8787
>
8888
> codemap injects a rich dependency graph into every agent prompt. On weaker models or tasks with large blast-radius graphs, this extra context can overwhelm the model and cause it to fall back to grep-heavy loops — performing *worse* than plain arm. The benchmark labels this failure mode `degenerate_grep_loop`.
8989
>
90-
> Good integration requires three things: (1) **skill-first protocol** — the agent calls `/codemap:query` before any Grep/Glob; (2) **bounded call budget** — max 3 codemap queries per task; (3) **hard stop on `exhaustive: true`** — when the index says the list is complete, write the answer immediately, no more tool calls. Skipping any of these — especially ignoring the exhaustive flag — is the primary cause of regressions that flip the codemap benefit into a liability. Use `/codemap:integration init` to wire integration correctly rather than injecting context manually.
90+
> Good integration requires three things: (1) **skill-first protocol** — the agent calls `/codemap:query-code` before any Grep/Glob; (2) **bounded call budget** — max 3 codemap queries per task; (3) **hard stop on `exhaustive: true`** — when the index says the list is complete, write the answer immediately, no more tool calls. Skipping any of these — especially ignoring the exhaustive flag — is the primary cause of regressions that flip the codemap benefit into a liability. Use `/codemap:integration init` to wire integration correctly rather than injecting context manually.
9191
9292
______________________________________________________________________
9393

@@ -157,7 +157,7 @@ Two commands — then forget about codemap and just use your normal skills.
157157
**Step 1 — build the index:**
158158

159159
```text
160-
/codemap:scan
160+
/codemap:scan-codebase
161161
```
162162

163163
Output:
@@ -196,7 +196,7 @@ That is it. Now run your normal skills — codemap works silently in the backgro
196196
/oss:review # reviewer gets structural context on changed modules
197197
```
198198

199-
If you ever want to explore structure manually, `/codemap:query` is there for you — but most users rarely need it.
199+
If you ever want to explore structure manually, `/codemap:query-code` is there for you — but most users rarely need it.
200200

201201
______________________________________________________________________
202202

@@ -230,7 +230,7 @@ Each check prints `✓`, `✗`, or `⚠` with a one-line remediation hint if nee
230230

231231
Interactive onboarding for the current project:
232232

233-
1. Builds the index if it is missing (offers to run `/codemap:scan`)
233+
1. Builds the index if it is missing (offers to run `/codemap:scan-codebase`)
234234
2. Discovers all installed skills and agents across all plugins
235235
3. Scores candidates by value tier (High / Medium / Low / Skip) based on whether structural context would help them
236236
4. Presents a recommendation table and asks which to wire in
@@ -275,9 +275,9 @@ run `scan-query central --top 5` (and `scan-query rdeps <target_module>` when a
275275
**before** any Glob/Grep exploration for structural information. Skip silently if the index is absent.
276276
```
277277

278-
### scan
278+
### scan-codebase
279279

280-
**Trigger**: `/codemap:scan`
280+
**Trigger**: `/codemap:scan-codebase`
281281

282282
Builds the structural index by running `ast.parse` across every `.py` file in the project. Writes the index to `.cache/scan/<project>.json`. Reports how many modules were indexed, how many were degraded (parse errors), and which five modules have the highest blast radius.
283283

@@ -303,28 +303,28 @@ Run a full scan once when you first set up the project. After that, `--increment
303303
#### Example
304304

305305
```text
306-
/codemap:scan
306+
/codemap:scan-codebase
307307
```
308308

309309
```text
310-
/codemap:scan --incremental
310+
/codemap:scan-codebase --incremental
311311
```
312312

313313
______________________________________________________________________
314314

315-
<a id="query"></a>
315+
<a id="query-code"></a>
316316

317317
<details>
318318

319319
<summary>
320320

321-
### query — full subcommand reference
321+
### query-code — full subcommand reference
322322

323323
</summary>
324324

325-
### query
325+
### query-code
326326

327-
**Trigger**: `/codemap:query <subcommand> [args]`
327+
**Trigger**: `/codemap:query-code <subcommand> [args]`
328328

329329
**Auto-invokes when:** user asks about module relationships, dependency graph, callers/callees, or blast radius; phrases: "what depends on", "who calls", "imports of", "blast radius of". Requires codemap index to exist (skill self-checks and no-ops gracefully if absent).
330330

@@ -357,7 +357,7 @@ Retrieve function or class source by name instead of reading the full file — d
357357

358358
#### Function-level call graph queries (v3 index)
359359

360-
These require a v3 index built by `/codemap:scan`. If your index is older (v2), the commands return a clear upgrade message.
360+
These require a v3 index built by `/codemap:scan-codebase`. If your index is older (v2), the commands return a clear upgrade message.
361361

362362
| Subcommand | What it answers |
363363
| ---------------------- | ------------------------------------------------------ |
@@ -382,28 +382,28 @@ Use `module::function` format for qualified names, for example `mypackage.auth::
382382

383383
```text
384384
# Before refactoring auth.py — understand full blast radius
385-
/codemap:query rdeps myproject.auth
385+
/codemap:query-code rdeps myproject.auth
386386
387387
# Before adding a dependency to models.py — see what already imports it
388-
/codemap:query central --top 5
388+
/codemap:query-code central --top 5
389389
390390
# Check if api and db are already coupled before adding a direct import
391-
/codemap:query path myproject.api myproject.db
391+
/codemap:query-code path myproject.api myproject.db
392392
393393
# Read just the validate_token function without loading the whole file
394-
/codemap:query symbol validate_token
394+
/codemap:query-code symbol validate_token
395395
396396
# Find all functions whose name starts with "validate" (unlimited results)
397-
/codemap:query find-symbol "^validate" --limit 0
397+
/codemap:query-code find-symbol "^validate" --limit 0
398398
399399
# Check transitive impact of changing fetch_user at the function level
400-
/codemap:query fn-blast myproject.db::fetch_user
400+
/codemap:query-code fn-blast myproject.db::fetch_user
401401
402402
# Exclude test modules from blast-radius analysis
403-
/codemap:query central --exclude-tests --top 10
403+
/codemap:query-code central --exclude-tests --top 10
404404
405405
# Query a specific index file (monorepo with multiple projects)
406-
/codemap:query central --index /path/to/.cache/scan/subproject.json
406+
/codemap:query-code central --index /path/to/.cache/scan/subproject.json
407407
```
408408

409409
</details>
@@ -473,7 +473,7 @@ The index is always written to `.cache/scan/<project>.json` at the project root.
473473
If your Python source is not at the git root, pass `--root`:
474474

475475
```text
476-
/codemap:scan --root src/mypackage
476+
/codemap:scan-codebase --root src/mypackage
477477
```
478478

479479
Or from the terminal:
@@ -505,21 +505,21 @@ ______________________________________________________________________
505505
The index has not been built for this project yet. Run:
506506

507507
```text
508-
/codemap:scan
508+
/codemap:scan-codebase
509509
```
510510

511511
### Stale index warning
512512

513513
`scan-query` detected that Python files were committed after the index was built. Run an incremental rebuild:
514514

515515
```text
516-
/codemap:scan --incremental
516+
/codemap:scan-codebase --incremental
517517
```
518518

519519
Or a full rebuild if you have made large structural changes:
520520

521521
```text
522-
/codemap:scan
522+
/codemap:scan-codebase
523523
```
524524

525525
### scan-query not found in the terminal
@@ -562,7 +562,7 @@ Generated files (e.g. protobuf output) are expected to degrade. They are not par
562562
The function-level call graph queries (`fn-deps`, `fn-rdeps`, `fn-central`, `fn-blast`) require a v3 index. Your current index is older. Rebuild:
563563

564564
```text
565-
/codemap:scan
565+
/codemap:scan-codebase
566566
```
567567

568568
### The develop plugin does not seem to use codemap

‎plugins/codemap/bin/check_index_freshness.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,13 @@ def format_status(scanned_at: str | None, scan_time: datetime | None, now: datet
132132
"""
133133
if scan_time is None:
134134
if not scanned_at:
135-
return "⚠ freshness: scanned_at missing — index may be corrupted\n → Re-run /codemap:scan\n"
136-
return f"⚠ freshness: could not parse scanned_at timestamp ({scanned_at}) — run /codemap:scan\n"
135+
return "⚠ freshness: scanned_at missing — index may be corrupted\n → Re-run /codemap:scan-codebase\n"
136+
return f"⚠ freshness: could not parse scanned_at timestamp ({scanned_at}) — run /codemap:scan-codebase\n"
137137

138138
days = age_days(scan_time, now)
139139
scan_date = (scanned_at or "")[:10]
140140
if days > STALE_THRESHOLD_DAYS:
141-
return f"⚠ freshness: {days} day(s) ago ({scan_date})\n → Run /codemap:scan to refresh\n"
141+
return f"⚠ freshness: {days} day(s) ago ({scan_date})\n → Run /codemap:scan-codebase to refresh\n"
142142
return f"✓ freshness: {days} day(s) ago ({scan_date})\n"
143143

144144

‎plugins/codemap/bin/check_injection.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def resolve_plugin_root(explicit: str | None) -> Path | None:
103103
if _is_plausible_plugin_dir(candidate):
104104
return candidate
105105
# Reject silently → fall through to auto-discovery (preserves prior UX for missing paths).
106-
home = Path(os.path.expanduser("~"))
106+
home = Path(os.environ.get("HOME") or os.path.expanduser("~"))
107107
candidates = sorted(
108108
home.joinpath(".claude/plugins/cache").glob(DEFAULT_CACHE_GLOB),
109109
key=lambda p: p.stat().st_mtime if p.exists() else 0.0,
@@ -231,7 +231,7 @@ def build_audit_lines(cache: Path) -> list[str]:
231231
"",
232232
"--- check complete ---",
233233
"If any check failed:",
234-
" • /codemap:scan — build or refresh the index",
234+
" • /codemap:scan-codebase — build or refresh the index",
235235
" • /codemap:integration init — add injection to more skills/agents",
236236
" • /codemap:integration check — re-run after fixes",
237237
]

‎plugins/codemap/bin/scan-query‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def load_index(path: Path) -> dict:
145145
path: filesystem path to the index JSON file.
146146
"""
147147
if not path.exists():
148-
_exit_error(f"Index not found at {path}. Run /codemap:scan first.")
148+
_exit_error(f"Index not found at {path}. Run /codemap:scan-codebase first.")
149149
with path.open() as f:
150150
return json.load(f)
151151

@@ -239,15 +239,15 @@ def warn_if_stale(index: dict) -> None:
239239
n = len(stale_files)
240240
print(
241241
f"⚠ codemap index stale — {n} file(s) changed since last scan."
242-
" Run /codemap:scan --incremental to update.",
242+
" Run /codemap:scan-codebase --incremental to update.",
243243
file=sys.stderr,
244244
)
245245
return
246246
# v2 index fallback: timestamp-based check
247247
scanned_at = index.get("scanned_at", "")
248248
if scanned_at and check_staleness(scanned_at):
249249
print(
250-
"⚠ codemap index may be stale — Python files changed since last scan. Re-run /codemap:scan.",
250+
"⚠ codemap index may be stale — Python files changed since last scan. Re-run /codemap:scan-codebase.",
251251
file=sys.stderr,
252252
)
253253

@@ -351,7 +351,7 @@ def _require_call_graph(index: dict) -> None:
351351
index: parsed codemap index dict to check for v3 call graph support.
352352
"""
353353
if not _has_call_graph(index):
354-
_exit_error("Index is v2 — call graph not available. Re-run /codemap:scan to upgrade.")
354+
_exit_error("Index is v2 — call graph not available. Re-run /codemap:scan-codebase to upgrade.")
355355

356356

357357
def _current_git_sha() -> str | None:
@@ -406,7 +406,7 @@ def _coverage(index: dict) -> dict:
406406
note = (
407407
f"All {total} indexed modules were searched. "
408408
"⚠ Index may be stale — source files changed since last scan. "
409-
"Re-run /codemap:scan to update before relying on this result."
409+
"Re-run /codemap:scan-codebase to update before relying on this result."
410410
)
411411
exhaustive = False
412412
else:
@@ -613,7 +613,7 @@ def cmd_symbol(index: dict, name: str, limit: int = 20, exclude_tests: bool = Fa
613613
matches.append((m, sym))
614614

615615
if not matches:
616-
_exit_error(f"Symbol '{name}' not found. Try /codemap:query find-symbol <pattern> to search.")
616+
_exit_error(f"Symbol '{name}' not found. Try /codemap:query-code find-symbol <pattern> to search.")
617617

618618
if limit > 0:
619619
matches = matches[:limit]

‎plugins/codemap/bin/scan-stats.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _load_index(root: str) -> dict:
4747
try:
4848
size = os.path.getsize(index_path)
4949
except FileNotFoundError:
50-
print(f"Index not found: {index_path} — run /codemap:scan first")
50+
print(f"Index not found: {index_path} — run /codemap:scan-codebase first")
5151
sys.exit(1)
5252
if size > MAX_INDEX_SIZE:
5353
print(f"Index too large ({size} bytes; max {MAX_INDEX_SIZE}): {index_path}")
@@ -56,7 +56,7 @@ def _load_index(root: str) -> dict:
5656
with open(index_path) as f:
5757
return json.load(f)
5858
except FileNotFoundError:
59-
print(f"Index not found: {index_path} — run /codemap:scan first")
59+
print(f"Index not found: {index_path} — run /codemap:scan-codebase first")
6060
sys.exit(1)
6161

6262

‎plugins/codemap/skills/integration/SKILL.md‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Two modes: use `init` first-time to onboard, then `check` regularly to verify. D
1414
- **`check`** — fast diagnostic: finds `scan-query`, verifies index exists and fresh, runs smoke test, audits which skill files have injection block. Prints `✓`/`✗`/`⚠` per check with one-line remediation hints. Pure bash — no model reasoning needed for happy path.
1515
- **`init`** — interactive onboarding: builds index if missing, discovers all installed skills and agents, scores by how much codemap would help, presents recommendation table, asks which to wire in, inserts correct injection block into each selected file.
1616

17-
NOT for: building or rebuilding index (use `/codemap:scan`); running structural query (use `/codemap:query`).
17+
NOT for: building or rebuilding index (use `/codemap:scan-codebase`); running structural query (use `/codemap:query-code`).
1818

1919
Arguments: `check` (no args) or `init [--approve]` — `--approve` auto-applies all ★ recommendations non-interactively.
2020

@@ -71,7 +71,7 @@ if [ "$C1_STATUS" = "failed" ]; then
7171
fi
7272
# PROJ/INDEX resolution — also used in Step I1 (init mode); keep in sync
7373
# NOTE: uses single-strategy basename lookup; scan-query uses three-strategy walk-up
74-
# If index not found here but scan-query works, run with explicit --index flag or re-run /codemap:scan from project root
74+
# If index not found here but scan-query works, run with explicit --index flag or re-run /codemap:scan-codebase from project root
7575
# bash 3.2 compatible — mapfile is bash 4+ only; macOS ships bash 3.2
7676
_idx=()
7777
while IFS= read -r line; do
@@ -87,7 +87,7 @@ if [ -f "$INDEX" ]; then
8787
printf "✓ index: exists\n"
8888
else
8989
printf "✗ index: not found\n"
90-
printf " → Run /codemap:scan to build the index\n"
90+
printf " → Run /codemap:scan-codebase to build the index\n"
9191
echo "failed" > "${TMPDIR:-/tmp}/codemap-c1-status"
9292
exit 1
9393
fi
@@ -124,11 +124,11 @@ AGE=$(echo "$SMOKE_RESULT" | jq -r '.age_hours')
124124
if [ "$OK" != "true" ]; then
125125
ERR=$(echo "$SMOKE_RESULT" | jq -r '.error // "unknown"')
126126
printf "✗ smoke test: %s\n" "$ERR"
127-
printf " → Re-run /codemap:scan to rebuild index\n"
127+
printf " → Re-run /codemap:scan-codebase to rebuild index\n"
128128
else
129129
printf "✓ smoke test: index valid (mtime-age=%sh)\n" "$AGE"
130130
if [ "$STALE" = "true" ]; then
131-
printf " ⚠ Index older than freshness threshold — run /codemap:scan to update\n"
131+
printf " ⚠ Index older than freshness threshold — run /codemap:scan-codebase to update\n"
132132
fi
133133
fi
134134
```
@@ -170,14 +170,14 @@ Use `AskUserQuestion`:
170170
No codemap index found for project: $PROJ
171171
172172
a) Build now ★ — scans all .py files via ast.parse (Python only), <60s on most projects
173-
b) Skip — I'll run /codemap:scan later (recommendations will be generic, no module-count weighting)
173+
b) Skip — I'll run /codemap:scan-codebase later (recommendations will be generic, no module-count weighting)
174174
```
175175

176176
If **a** (or auto-approved): verify binary exists first, then run scanner:
177177

178178
```bash
179179
# timeout: 5000
180-
[ -x "${CLAUDE_PLUGIN_ROOT:-plugins/codemap}/bin/scan-index" ] || { printf "✗ scan-index not found at ${CLAUDE_PLUGIN_ROOT:-plugins/codemap}/bin/scan-index\nTry: /codemap:scan to install and rebuild.\n"; exit 1; }
180+
[ -x "${CLAUDE_PLUGIN_ROOT:-plugins/codemap}/bin/scan-index" ] || { printf "✗ scan-index not found at ${CLAUDE_PLUGIN_ROOT:-plugins/codemap}/bin/scan-index\nTry: /codemap:scan-codebase to install and rebuild.\n"; exit 1; }
181181
# timeout: 360000
182182
${CLAUDE_PLUGIN_ROOT:-plugins/codemap}/bin/scan-index
183183
```
@@ -305,7 +305,7 @@ Use `AskUserQuestion`:
305305
Install post-commit git hook for automatic incremental rebuild?
306306
307307
a) Install ★ — runs scan-index --incremental in background after every commit; index stays current with zero developer action
308-
b) Skip — I'll run /codemap:scan or /codemap:scan --incremental manually
308+
b) Skip — I'll run /codemap:scan-codebase or /codemap:scan-codebase --incremental manually
309309
```
310310

311311
### I5b — Write hook file

0 commit comments

Comments
 (0)