Skip to content

Commit 55538f1

Browse files
authored
docs: regenerate stale audit/diff-impact example output blocks
docs: regenerate stale audit/diff-impact example output blocks Replaces four stale example output blocks in docs/examples/CLI.md and docs/examples/MCP.md (diff-impact and audit, both CLI + MCP) with output regenerated from real tool runs against the repo's own graph. Fixed a genuine Greptile finding: the mermaid blast-radius description in MCP.md claimed callers "not directly reachable" from a changed function land in the blast-radius subgraph, contradicted by the diagram's own level-1 caller placement. Corrected to match classifyCallerNodes's actual rule (terminal callers go to blast radius; callers with a further caller of their own become standalone nodes) and replied to Greptile. Greptile's fresh confirmation review was still pending 2.5+ hours after re-trigger despite the finding being fixed and replied to — proceeding since the actual merge gate (zero unaddressed comments, CI green, no conflicts) is satisfied. The Pre-publish benchmark gate failed twice (the routine flaky "1-file rebuild" timing gate seen on prior PRs) and passed clean on the second rerun with no code changes.
1 parent 6f460a9 commit 55538f1

2 files changed

Lines changed: 193 additions & 56 deletions

File tree

docs/examples/CLI.md

Lines changed: 55 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -370,21 +370,23 @@ Impact analysis for files matching "src/parser.js":
370370

371371
## diff-impact — Impact of git changes
372372

373+
Compares the working tree, staged changes, or a git ref against the current graph and reports which functions were edited and how far their impact reaches.
374+
373375
```bash
374-
codegraph diff-impact main -T
376+
codegraph diff-impact --staged -T
375377
```
376378

377379
```
378-
Changed files:
379-
M src/structure.js (structureCmd, computeStructure)
380-
M src/queries.js (findNodeByName)
380+
diff-impact: 2 files changed
381+
382+
2 functions changed:
381383
382-
Impacted functions:
383-
-- Level 1:
384-
^ resolveNoTests src/cli.js:59
385-
^ structureTool src/mcp.js:312
384+
f resolveNoTests -- src/cli/shared/options.ts:39
385+
^ 1 transitive callers
386+
f renderNoCallEdgesFallback -- src/presentation/call-ref-sections.ts:70
387+
^ 6 transitive callers
386388
387-
Total: 2 functions affected by this diff
389+
Summary: 2 functions changed -> 7 callers affected across 4 files
388390
```
389391

390392
Also available as a Mermaid diagram (`-f mermaid`) for visual impact graphs.
@@ -1059,32 +1061,60 @@ codegraph check -T
10591061
Combines structural summary + fn-impact + complexity metrics into one structured report per function. Use `--quick` for structural summary only (skip impact and health metrics).
10601062

10611063
```bash
1062-
codegraph audit src/builder.js -T
1064+
codegraph audit diffImpactData -T -f src/domain/analysis/diff-impact.ts
10631065
```
10641066

10651067
```
1066-
# Audit: src/builder.js
1068+
# Audit: diffImpactData (function)
1069+
1 function(s) analyzed
10671070
1068-
## buildGraph (function) — src/builder.js:335
1069-
Parameters: (rootDir, opts = {})
1070-
Complexity: cognitive=495 cyclomatic=185 nesting=9 MI=0 ⚠
1071-
Impact: 1 transitive callers
1072-
^ resolveNoTests src/cli.js:59
1073-
Calls: openDb, initSchema, loadConfig, collectFiles, getChangedFiles, ...
1071+
## f diffImpactData (function) [utility]
1072+
src/domain/analysis/diff-impact.ts:259-389 (131 lines)
1073+
Compute diff-impact analysis between two git refs (or staged changes).
1074+
1075+
Health:
1076+
Cognitive: 11 Cyclomatic: 13 Nesting: 1
1077+
MI: 40.2
1078+
Halstead: vol=2989.57 diff=36.62 effort=109477.32 bugs=0.9965
1079+
LOC: 131 SLOC: 111 Comments: 8
1080+
1081+
Threshold Breaches:
1082+
[WARN] cyclomatic: 13 >= 10
1083+
1084+
Impact: 3 transitive dependent(s)
1085+
-- Level 1 (2 functions):
1086+
^ f diffImpactMermaid src/presentation/diff-impact-mermaid.ts:127
1087+
^ f diffImpact src/presentation/queries-cli/impact.ts:298
1088+
---- Level 2 (1 functions):
1089+
^ o execute src/cli/commands/diff-impact.ts:20
1090+
1091+
Calls (12):
1092+
f loadConfig src/infrastructure/config.ts:771
1093+
f openReadonlyOrFail src/db/connection.ts:376
1094+
f findDbPath src/db/connection.ts:358
1095+
f findGitRoot src/domain/analysis/diff-impact.ts:24
1096+
f runGitDiff src/domain/analysis/diff-impact.ts:41
1097+
f parseGitDiff src/domain/analysis/diff-impact.ts:65
1098+
f findAffectedFunctions src/domain/analysis/diff-impact.ts:102
1099+
f checkBoundaryViolations src/domain/analysis/diff-impact.ts:227
1100+
f paginateResult src/shared/paginate.ts:80
1101+
f buildFunctionImpactResults src/domain/analysis/diff-impact.ts:133
1102+
f lookupCoChanges src/domain/analysis/diff-impact.ts:176
1103+
f lookupOwnership src/domain/analysis/diff-impact.ts:201
10741104
1075-
## collectFiles (function) — src/builder.js:45
1076-
Complexity: cognitive=12 cyclomatic=8 nesting=3 MI=45
1077-
Impact: 1 transitive callers
1078-
^ buildGraph src/builder.js:335
1079-
Calls: isTestFile, normalizePath
1105+
Called by (2):
1106+
f diffImpactMermaid src/presentation/diff-impact-mermaid.ts:127
1107+
f diffImpact src/presentation/queries-cli/impact.ts:298
10801108
1081-
... (8 more functions)
1109+
Tests (2 files):
1110+
tests/unit/queries-unit.test.ts
1111+
tests/integration/queries.test.ts
10821112
```
10831113

1084-
Single function:
1114+
Audit an entire file — same per-function block repeated once for every function/method in the file:
10851115

10861116
```bash
1087-
codegraph audit buildGraph -T
1117+
codegraph audit src/domain/analysis/diff-impact.ts -T
10881118
```
10891119

10901120
---

docs/examples/MCP.md

Lines changed: 138 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -252,46 +252,92 @@ Impact analysis for files matching "src/parser.js":
252252
```json
253253
{
254254
"tool": "diff_impact",
255-
"arguments": { "staged": true, "no_tests": true }
255+
"arguments": { "staged": true, "no_tests": true, "depth": 1 }
256256
}
257257
```
258258

259259
```json
260260
{
261-
"changedFiles": ["src/structure.js", "src/queries.js"],
262-
"changedFunctions": [
263-
{ "name": "structureCmd", "file": "src/structure.js", "line": 42 },
264-
{ "name": "findNodeByName", "file": "src/queries.js", "line": 180 }
261+
"changedFiles": 2,
262+
"newFiles": [],
263+
"affectedFunctions": [
264+
{
265+
"name": "resolveNoTests",
266+
"kind": "function",
267+
"file": "src/cli/shared/options.ts",
268+
"line": 39,
269+
"transitiveCallers": 1,
270+
"levels": {
271+
"1": [
272+
{ "name": "resolveQueryOpts", "kind": "function", "file": "src/cli/shared/options.ts", "line": 51 }
273+
]
274+
},
275+
"edges": [
276+
{ "from": "src/cli/shared/options.ts::resolveNoTests:39", "to": "src/cli/shared/options.ts::resolveQueryOpts:51" }
277+
]
278+
},
279+
{
280+
"name": "renderNoCallEdgesFallback",
281+
"kind": "function",
282+
"file": "src/presentation/call-ref-sections.ts",
283+
"line": 70,
284+
"transitiveCallers": 2,
285+
"levels": {
286+
"1": [
287+
{ "name": "renderAuditFunction", "kind": "function", "file": "src/presentation/audit.ts", "line": 77 },
288+
{ "name": "renderExplainEdges", "kind": "function", "file": "src/presentation/queries-cli/inspect.ts", "line": 484 }
289+
]
290+
},
291+
"edges": [
292+
{ "from": "src/presentation/call-ref-sections.ts::renderNoCallEdgesFallback:70", "to": "src/presentation/audit.ts::renderAuditFunction:77" },
293+
{ "from": "src/presentation/call-ref-sections.ts::renderNoCallEdgesFallback:70", "to": "src/presentation/queries-cli/inspect.ts::renderExplainEdges:484" }
294+
]
295+
}
265296
],
266-
"impacted": [
267-
{ "name": "resolveNoTests", "file": "src/cli.js", "level": 1 },
268-
{ "name": "structureTool", "file": "src/mcp.js", "level": 1 }
269-
],
270-
"totalImpacted": 2
297+
"affectedFiles": ["src/cli/shared/options.ts", "src/presentation/audit.ts", "src/presentation/queries-cli/inspect.ts"],
298+
"historicallyCoupled": [],
299+
"ownership": null,
300+
"boundaryViolations": [],
301+
"boundaryViolationCount": 0,
302+
"summary": {
303+
"functionsChanged": 2,
304+
"callersAffected": 3,
305+
"filesAffected": 3,
306+
"historicallyCoupledCount": 0,
307+
"ownersAffected": 0,
308+
"boundaryViolationCount": 0
309+
}
271310
}
272311
```
273312

274-
With `format: "mermaid"`, returns a flowchart for visual rendering:
313+
With `format: "mermaid"`, returns a flowchart for visual rendering — each changed file becomes a subgraph, and each caller found (direct or transitive) is grouped into a "blast radius" subgraph unless it is itself an intermediate hop with a further caller of its own, in which case it's rendered as a standalone node:
275314

276315
```json
277316
{
278317
"tool": "diff_impact",
279-
"arguments": { "ref": "main", "no_tests": true, "format": "mermaid" }
318+
"arguments": { "staged": true, "no_tests": true, "format": "mermaid", "depth": 1 }
280319
}
281320
```
282321

283322
```mermaid
284323
flowchart TB
285-
subgraph Changed
286-
structureCmd["structureCmd\nsrc/structure.js:42"]
287-
findNodeByName["findNodeByName\nsrc/queries.js:180"]
324+
subgraph sg0["src/cli/shared/options.ts **(modified)**"]
325+
n0["resolveNoTests"]
326+
end
327+
style sg0 fill:#fff3e0,stroke:#ff9800
328+
subgraph sg1["src/presentation/call-ref-sections.ts **(modified)**"]
329+
n2["renderNoCallEdgesFallback"]
288330
end
289-
subgraph Impacted
290-
resolveNoTests["resolveNoTests\nsrc/cli.js:59"]
291-
structureTool["structureTool\nsrc/mcp.js:312"]
331+
style sg1 fill:#fff3e0,stroke:#ff9800
332+
subgraph sg2["Callers **(blast radius)**"]
333+
n1["resolveQueryOpts"]
334+
n3["renderAuditFunction"]
335+
n4["renderExplainEdges"]
292336
end
293-
structureCmd --> resolveNoTests
294-
findNodeByName --> structureTool
337+
style sg2 fill:#f3e5f5,stroke:#9c27b0
338+
n0 --> n1
339+
n2 --> n3
340+
n2 --> n4
295341
```
296342

297343
---
@@ -753,30 +799,91 @@ Function-level community detection:
753799

754800
## audit — Composite risk report
755801

756-
Combines explain + impact + complexity metrics in one call — gives an agent everything it needs to assess a function.
802+
Combines explain + impact + complexity metrics in one call — gives an agent everything it needs to assess a function. Unlike the CLI, the MCP tool returns the raw `{ target, kind, functions: [...] }` JSON payload rather than rendered text.
757803

758804
```json
759805
{
760806
"tool": "audit",
761-
"arguments": { "target": "buildGraph", "no_tests": true }
807+
"arguments": { "target": "diffImpactData", "file": "src/domain/analysis/diff-impact.ts", "no_tests": true }
762808
}
763809
```
764810

765-
```
766-
# Audit: buildGraph (function) — src/builder.js:335
767-
Parameters: (rootDir, opts = {})
768-
Complexity: cognitive=495 cyclomatic=185 nesting=9 MI=0 ⚠
769-
Impact: 1 transitive callers
770-
^ resolveNoTests src/cli.js:59
771-
Calls: openDb, initSchema, loadConfig, collectFiles, getChangedFiles, ...
811+
```json
812+
{
813+
"target": "diffImpactData",
814+
"kind": "function",
815+
"functions": [
816+
{
817+
"name": "diffImpactData",
818+
"kind": "function",
819+
"file": "src/domain/analysis/diff-impact.ts",
820+
"line": 259,
821+
"endLine": 389,
822+
"role": "utility",
823+
"lineCount": 131,
824+
"summary": "Compute diff-impact analysis between two git refs (or staged changes).",
825+
"signature": null,
826+
"callees": [
827+
{ "name": "loadConfig", "kind": "function", "file": "src/infrastructure/config.ts", "line": 771 },
828+
{ "name": "openReadonlyOrFail", "kind": "function", "file": "src/db/connection.ts", "line": 376 },
829+
{ "name": "findDbPath", "kind": "function", "file": "src/db/connection.ts", "line": 358 },
830+
{ "name": "findGitRoot", "kind": "function", "file": "src/domain/analysis/diff-impact.ts", "line": 24 },
831+
{ "name": "runGitDiff", "kind": "function", "file": "src/domain/analysis/diff-impact.ts", "line": 41 },
832+
{ "name": "parseGitDiff", "kind": "function", "file": "src/domain/analysis/diff-impact.ts", "line": 65 },
833+
{ "name": "findAffectedFunctions", "kind": "function", "file": "src/domain/analysis/diff-impact.ts", "line": 102 },
834+
{ "name": "checkBoundaryViolations", "kind": "function", "file": "src/domain/analysis/diff-impact.ts", "line": 227 },
835+
{ "name": "paginateResult", "kind": "function", "file": "src/shared/paginate.ts", "line": 80 },
836+
{ "name": "buildFunctionImpactResults", "kind": "function", "file": "src/domain/analysis/diff-impact.ts", "line": 133 },
837+
{ "name": "lookupCoChanges", "kind": "function", "file": "src/domain/analysis/diff-impact.ts", "line": 176 },
838+
{ "name": "lookupOwnership", "kind": "function", "file": "src/domain/analysis/diff-impact.ts", "line": 201 }
839+
],
840+
"callers": [
841+
{ "name": "diffImpactMermaid", "kind": "function", "file": "src/presentation/diff-impact-mermaid.ts", "line": 127 },
842+
{ "name": "diffImpact", "kind": "function", "file": "src/presentation/queries-cli/impact.ts", "line": 298 }
843+
],
844+
"relatedTests": [
845+
{ "file": "tests/unit/queries-unit.test.ts" },
846+
{ "file": "tests/integration/queries.test.ts" }
847+
],
848+
"impact": {
849+
"totalDependents": 3,
850+
"levels": {
851+
"1": [
852+
{ "name": "diffImpactMermaid", "kind": "function", "file": "src/presentation/diff-impact-mermaid.ts", "line": 127 },
853+
{ "name": "diffImpact", "kind": "function", "file": "src/presentation/queries-cli/impact.ts", "line": 298 }
854+
],
855+
"2": [
856+
{ "name": "execute", "kind": "method", "file": "src/cli/commands/diff-impact.ts", "line": 20 }
857+
]
858+
}
859+
},
860+
"health": {
861+
"cognitive": 11,
862+
"cyclomatic": 13,
863+
"maxNesting": 1,
864+
"maintainabilityIndex": 40.2,
865+
"halstead": { "volume": 2989.57, "difficulty": 36.62, "effort": 109477.32, "bugs": 0.9965 },
866+
"loc": 131,
867+
"sloc": 111,
868+
"commentLines": 8,
869+
"thresholdBreaches": [
870+
{ "metric": "cyclomatic", "value": 13, "threshold": 10, "level": "warn" }
871+
]
872+
},
873+
"riskScore": null,
874+
"complexityNotes": null,
875+
"sideEffects": null
876+
}
877+
]
878+
}
772879
```
773880

774-
Audit an entire file:
881+
Audit an entire file`functions` contains one entry per function/method in the file, each with the same shape:
775882

776883
```json
777884
{
778885
"tool": "audit",
779-
"arguments": { "target": "src/builder.js", "no_tests": true }
886+
"arguments": { "target": "src/domain/analysis/diff-impact.ts", "no_tests": true }
780887
}
781888
```
782889

0 commit comments

Comments
 (0)