diff --git a/CHANGELOG.md b/CHANGELOG.md index ebf6d73..b61264d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to srcwalk are documented here. ## Unreleased +### Changed +- Extended `show -C/--context-lines` to line ranges, resolved sections, and comma-separated show/section targets; comma-separated multi reads clamp each target to 10 context lines. +- Updated discover next-step guidance to prefer confirmed `context` targets when structural candidates exist and raw `show : -C 10` reads for text hits. +- Reframed the embedded agent guide as an evidence contract with explicit `srcwalk`-before-`rg` routing and comma-separated literal OR discovery guidance. + ## [1.0.0] - 2026-05-24 ### Highlights diff --git a/README.md b/README.md index 8d80c80..0e3f26e 100644 --- a/README.md +++ b/README.md @@ -343,7 +343,7 @@ Scopes on this page: src/evidence (2), src/commands (0) (~101 tokens) > Next: 25 more matches available. Continue with --offset 2 --limit 2. -> Next: drill into any hit with `srcwalk :`. +> Next: choose a confirmed context target above, or read raw hit evidence with `srcwalk show : -C 10`. --- # Search: "Anchor" in 2 scopes — 2 matches (1 definitions, 1 usages) @@ -381,7 +381,7 @@ Scopes on this page: src/evidence (2), src/commands (0) (~418 tokens) > Next: 38 more matches available. Continue with --offset 2 --limit 2. -> Next: drill into any hit with `srcwalk :`. +> Next: choose a confirmed context target above, or read raw hit evidence with `srcwalk show : -C 10`. ``` diff --git a/skills/srcwalk/GUIDE.md b/skills/srcwalk/GUIDE.md index d664a18..ffef562 100644 --- a/skills/srcwalk/GUIDE.md +++ b/skills/srcwalk/GUIDE.md @@ -1,11 +1,33 @@ -# srcwalk — agent routing policy +# srcwalk — agent evidence contract -Use srcwalk before shell search for code navigation. Keep `--scope` narrow. -Use raw `rg` only for final text confirmation. +Default to srcwalk first for code-structure work. It is the contract for finding exact code evidence, next reads, and bounded claims before shell search. + +Keep `--scope` narrow. Use raw `rg`, `read`, `fd`, or shell filesystem tools only for final text/regex confirmation, filesystem metadata, generated-output cleanup, or when srcwalk lacks structural support. If you bypass srcwalk for a code claim, say why. + +## Contract + +1. Start from intent, not files: orient with `overview`, find candidates with `discover`, then pick one exact target. +2. Follow srcwalk evidence: run `context`, `show`, `trace`, `deps`, `assess`, `review`, or `compare` from paths, ranges, symbols, and `> Next:` commands. +3. Cite bounded evidence: base conclusions on srcwalk path:line/range output and preserve its `source`, `kind`, `confidence`, and `caveat` limits. +4. Do not overclaim: text/file hits are literal evidence; structural hits are navigation evidence; neither proves runtime behavior, security, correctness, aliases, types, or dynamic dispatch unless explicitly supported. +5. Verify after edits: use `srcwalk review --staged` or the relevant srcwalk route before tests; use `rg` only for final raw text or regex confirmation. + +Do not infer definitions, usages, callers, dependencies, or code paths from shell path lists or broad grep alone. + +## Before grep/rg + +Stop if you are about to do this for code navigation: + +- `rg "functionName"` -> use `srcwalk discover 'functionName' --scope `. +- `rg "functionName\("` -> use `srcwalk trace callers functionName --scope `. +- `rg "^import|^use"` -> use `srcwalk deps `. +- `srcwalk show ` without discovery -> use `srcwalk discover --scope ` first, unless you already know the exact file evidence you need. + +Why: grep gives raw text matches that often require extra filtering. srcwalk gives scoped candidates, typed evidence, and exact next commands. Use `rg` after srcwalk when you need raw regex confirmation. ## Default workflow -Use this command flow for broad, unfamiliar, or risky code tasks: +Use the smallest subset of this flow that proves the task. For broad, unfamiliar, or risky code work, start here: ```text request / bug / feature question @@ -35,115 +57,82 @@ When output includes `source`, `kind`, `confidence`, or `caveat`, treat them as ## Routes -### Orient an unfamiliar area +### Orient and choose a target -Do not start orientation with shell `tree`, shell `find`, repeated `ls`, or repo-wide `rg`. +Do not start broad code navigation with shell `tree`, shell `find`, repeated `ls`, or repo-wide `rg`. ```bash srcwalk overview --scope -``` - -Use auto depth first. Do not pass `--depth` first. Explicit `--depth N` is strict. - -`[relations]` are static local dependency groups, not runtime calls. -`[outbound deps]` imports targets outside `--scope`. - -Drill down with candidate intake, then context. - -```bash +srcwalk overview --scope --symbols srcwalk discover --scope srcwalk discover '' --as file --scope -srcwalk discover --as text --scope +srcwalk discover 'foo,bar,baz' --match any --as text --scope +srcwalk discover --as access --scope srcwalk context --scope ``` -`discover` searches only inside `--scope`; narrow scopes can hide definitions. +Use auto overview depth first; explicit `--depth N` is strict. `[relations]` are static local dependency groups, not runtime calls. `[outbound deps]` imports targets outside `--scope`. -`--filter kind: