purecontext-mcp 1.1.7 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/AGENT_INSTRUCTIONS.md +393 -0
  2. package/AGENT_INSTRUCTIONS_SHORT.md +53 -0
  3. package/AST-SEARCH.md +274 -0
  4. package/CHANGELOG.md +62 -0
  5. package/CODE-INTELLIGENCE.md +369 -0
  6. package/HEALTH-DASHBOARDS.md +241 -0
  7. package/README.md +7 -0
  8. package/REFACTORING-SAFELY.md +279 -0
  9. package/UNDERSTANDING-RELATIONSHIPS.md +240 -0
  10. package/USER-GUIDE.md +14 -0
  11. package/VISUALIZING-CODE.md +199 -0
  12. package/WORKFLOW-TECH-DEBT.md +286 -0
  13. package/dist/core/db/dep-store.d.ts +75 -0
  14. package/dist/core/db/dep-store.d.ts.map +1 -1
  15. package/dist/core/db/dep-store.js +277 -0
  16. package/dist/core/db/dep-store.js.map +1 -1
  17. package/dist/core/db/schema.d.ts.map +1 -1
  18. package/dist/core/db/schema.js +12 -0
  19. package/dist/core/db/schema.js.map +1 -1
  20. package/dist/core/index-manager.js +1 -1
  21. package/dist/core/index-manager.js.map +1 -1
  22. package/dist/core/token-tracker.d.ts +0 -9
  23. package/dist/core/token-tracker.d.ts.map +1 -1
  24. package/dist/core/token-tracker.js +0 -21
  25. package/dist/core/token-tracker.js.map +1 -1
  26. package/dist/core/types.d.ts +5 -0
  27. package/dist/core/types.d.ts.map +1 -1
  28. package/dist/graph/diagram-renderer.d.ts +83 -0
  29. package/dist/graph/diagram-renderer.d.ts.map +1 -0
  30. package/dist/graph/diagram-renderer.js +294 -0
  31. package/dist/graph/diagram-renderer.js.map +1 -0
  32. package/dist/graph/graph-traversal.d.ts +92 -0
  33. package/dist/graph/graph-traversal.d.ts.map +1 -1
  34. package/dist/graph/graph-traversal.js +440 -2
  35. package/dist/graph/graph-traversal.js.map +1 -1
  36. package/dist/server/http-server.d.ts.map +1 -1
  37. package/dist/server/http-server.js +30 -1
  38. package/dist/server/http-server.js.map +1 -1
  39. package/dist/server/mcp-server.d.ts.map +1 -1
  40. package/dist/server/mcp-server.js +145 -0
  41. package/dist/server/mcp-server.js.map +1 -1
  42. package/dist/server/tools/_meta.d.ts +0 -2
  43. package/dist/server/tools/_meta.d.ts.map +1 -1
  44. package/dist/server/tools/_meta.js +1 -4
  45. package/dist/server/tools/_meta.js.map +1 -1
  46. package/dist/server/tools/check-delete-safe.d.ts +50 -0
  47. package/dist/server/tools/check-delete-safe.d.ts.map +1 -0
  48. package/dist/server/tools/check-delete-safe.js +308 -0
  49. package/dist/server/tools/check-delete-safe.js.map +1 -0
  50. package/dist/server/tools/check-move-safe.d.ts +44 -0
  51. package/dist/server/tools/check-move-safe.d.ts.map +1 -0
  52. package/dist/server/tools/check-move-safe.js +266 -0
  53. package/dist/server/tools/check-move-safe.js.map +1 -0
  54. package/dist/server/tools/check-rename-safe.d.ts +48 -0
  55. package/dist/server/tools/check-rename-safe.d.ts.map +1 -0
  56. package/dist/server/tools/check-rename-safe.js +218 -0
  57. package/dist/server/tools/check-rename-safe.js.map +1 -0
  58. package/dist/server/tools/diff-health-radar.d.ts +44 -0
  59. package/dist/server/tools/diff-health-radar.d.ts.map +1 -0
  60. package/dist/server/tools/diff-health-radar.js +192 -0
  61. package/dist/server/tools/diff-health-radar.js.map +1 -0
  62. package/dist/server/tools/find-cycles.d.ts +31 -0
  63. package/dist/server/tools/find-cycles.d.ts.map +1 -0
  64. package/dist/server/tools/find-cycles.js +85 -0
  65. package/dist/server/tools/find-cycles.js.map +1 -0
  66. package/dist/server/tools/find-implementations.d.ts +47 -0
  67. package/dist/server/tools/find-implementations.d.ts.map +1 -0
  68. package/dist/server/tools/find-implementations.js +167 -0
  69. package/dist/server/tools/find-implementations.js.map +1 -0
  70. package/dist/server/tools/find-untested-symbols.d.ts +52 -0
  71. package/dist/server/tools/find-untested-symbols.d.ts.map +1 -0
  72. package/dist/server/tools/find-untested-symbols.js +308 -0
  73. package/dist/server/tools/find-untested-symbols.js.map +1 -0
  74. package/dist/server/tools/get-architecture-snapshot.d.ts +43 -0
  75. package/dist/server/tools/get-architecture-snapshot.d.ts.map +1 -0
  76. package/dist/server/tools/get-architecture-snapshot.js +292 -0
  77. package/dist/server/tools/get-architecture-snapshot.js.map +1 -0
  78. package/dist/server/tools/get-call-hierarchy.d.ts +43 -0
  79. package/dist/server/tools/get-call-hierarchy.d.ts.map +1 -0
  80. package/dist/server/tools/get-call-hierarchy.js +119 -0
  81. package/dist/server/tools/get-call-hierarchy.js.map +1 -0
  82. package/dist/server/tools/get-class-hierarchy.d.ts +36 -0
  83. package/dist/server/tools/get-class-hierarchy.d.ts.map +1 -0
  84. package/dist/server/tools/get-class-hierarchy.js +125 -0
  85. package/dist/server/tools/get-class-hierarchy.js.map +1 -0
  86. package/dist/server/tools/get-complexity-hotspots.d.ts +50 -0
  87. package/dist/server/tools/get-complexity-hotspots.d.ts.map +1 -0
  88. package/dist/server/tools/get-complexity-hotspots.js +282 -0
  89. package/dist/server/tools/get-complexity-hotspots.js.map +1 -0
  90. package/dist/server/tools/get-coupling-map.d.ts +39 -0
  91. package/dist/server/tools/get-coupling-map.d.ts.map +1 -0
  92. package/dist/server/tools/get-coupling-map.js +107 -0
  93. package/dist/server/tools/get-coupling-map.js.map +1 -0
  94. package/dist/server/tools/get-debt-report.d.ts +44 -0
  95. package/dist/server/tools/get-debt-report.d.ts.map +1 -0
  96. package/dist/server/tools/get-debt-report.js +606 -0
  97. package/dist/server/tools/get-debt-report.js.map +1 -0
  98. package/dist/server/tools/get-entry-points.d.ts +79 -0
  99. package/dist/server/tools/get-entry-points.d.ts.map +1 -0
  100. package/dist/server/tools/get-entry-points.js +362 -0
  101. package/dist/server/tools/get-entry-points.js.map +1 -0
  102. package/dist/server/tools/get-public-api.d.ts +53 -0
  103. package/dist/server/tools/get-public-api.d.ts.map +1 -0
  104. package/dist/server/tools/get-public-api.js +218 -0
  105. package/dist/server/tools/get-public-api.js.map +1 -0
  106. package/dist/server/tools/get-savings-stats.d.ts.map +1 -1
  107. package/dist/server/tools/get-savings-stats.js +1 -3
  108. package/dist/server/tools/get-savings-stats.js.map +1 -1
  109. package/dist/server/tools/get-test-coverage-map.d.ts +66 -0
  110. package/dist/server/tools/get-test-coverage-map.d.ts.map +1 -0
  111. package/dist/server/tools/get-test-coverage-map.js +588 -0
  112. package/dist/server/tools/get-test-coverage-map.js.map +1 -0
  113. package/dist/server/tools/get-todos.d.ts +51 -0
  114. package/dist/server/tools/get-todos.d.ts.map +1 -0
  115. package/dist/server/tools/get-todos.js +180 -0
  116. package/dist/server/tools/get-todos.js.map +1 -0
  117. package/dist/server/tools/get-type-graph.d.ts +73 -0
  118. package/dist/server/tools/get-type-graph.d.ts.map +1 -0
  119. package/dist/server/tools/get-type-graph.js +437 -0
  120. package/dist/server/tools/get-type-graph.js.map +1 -0
  121. package/dist/server/tools/health-radar.d.ts +50 -0
  122. package/dist/server/tools/health-radar.d.ts.map +1 -0
  123. package/dist/server/tools/health-radar.js +426 -0
  124. package/dist/server/tools/health-radar.js.map +1 -0
  125. package/dist/server/tools/plan-refactoring.d.ts +74 -0
  126. package/dist/server/tools/plan-refactoring.d.ts.map +1 -0
  127. package/dist/server/tools/plan-refactoring.js +644 -0
  128. package/dist/server/tools/plan-refactoring.js.map +1 -0
  129. package/dist/server/tools/render-call-graph.d.ts +40 -0
  130. package/dist/server/tools/render-call-graph.d.ts.map +1 -0
  131. package/dist/server/tools/render-call-graph.js +215 -0
  132. package/dist/server/tools/render-call-graph.js.map +1 -0
  133. package/dist/server/tools/render-class-hierarchy.d.ts +42 -0
  134. package/dist/server/tools/render-class-hierarchy.d.ts.map +1 -0
  135. package/dist/server/tools/render-class-hierarchy.js +265 -0
  136. package/dist/server/tools/render-class-hierarchy.js.map +1 -0
  137. package/dist/server/tools/render-dep-matrix.d.ts +38 -0
  138. package/dist/server/tools/render-dep-matrix.d.ts.map +1 -0
  139. package/dist/server/tools/render-dep-matrix.js +186 -0
  140. package/dist/server/tools/render-dep-matrix.js.map +1 -0
  141. package/dist/server/tools/render-diagram.d.ts +47 -0
  142. package/dist/server/tools/render-diagram.d.ts.map +1 -0
  143. package/dist/server/tools/render-diagram.js +266 -0
  144. package/dist/server/tools/render-diagram.js.map +1 -0
  145. package/dist/server/tools/render-import-graph.d.ts +41 -0
  146. package/dist/server/tools/render-import-graph.d.ts.map +1 -0
  147. package/dist/server/tools/render-import-graph.js +158 -0
  148. package/dist/server/tools/render-import-graph.js.map +1 -0
  149. package/dist/server/tools/search-ast.d.ts +55 -0
  150. package/dist/server/tools/search-ast.d.ts.map +1 -0
  151. package/dist/server/tools/search-ast.js +279 -0
  152. package/dist/server/tools/search-ast.js.map +1 -0
  153. package/dist/server/tools/search-by-complexity.d.ts +92 -0
  154. package/dist/server/tools/search-by-complexity.d.ts.map +1 -0
  155. package/dist/server/tools/search-by-complexity.js +268 -0
  156. package/dist/server/tools/search-by-complexity.js.map +1 -0
  157. package/dist/server/tools/search-by-decorator.d.ts +48 -0
  158. package/dist/server/tools/search-by-decorator.d.ts.map +1 -0
  159. package/dist/server/tools/search-by-decorator.js +518 -0
  160. package/dist/server/tools/search-by-decorator.js.map +1 -0
  161. package/dist/server/tools/search-by-signature.d.ts +56 -0
  162. package/dist/server/tools/search-by-signature.d.ts.map +1 -0
  163. package/dist/server/tools/search-by-signature.js +200 -0
  164. package/dist/server/tools/search-by-signature.js.map +1 -0
  165. package/dist/ui/assets/BlastRadius-QdgESOL8.js +1 -0
  166. package/dist/ui/assets/{DependencyGraph-CDtBHM0U.js → DependencyGraph-BSMhzwWV.js} +6 -6
  167. package/dist/ui/assets/{NotFound-Cdt6X8pl.js → NotFound-CipFP_s1.js} +1 -1
  168. package/dist/ui/assets/RepoDetail-Dfp5z5Kq.js +1 -0
  169. package/dist/ui/assets/{RepoList-B9LaZvob.js → RepoList-BKtST3hB.js} +1 -1
  170. package/dist/ui/assets/{Search-CLqv2KGV.js → Search-DzhGDViy.js} +1 -1
  171. package/dist/ui/assets/{SymbolView-BlbDR1DU.js → SymbolView-ryVEwAHG.js} +1 -1
  172. package/dist/ui/assets/{index-DADf5y_L.css → index-Ny8gn9F0.css} +1 -1
  173. package/dist/ui/assets/{index-i3Q1XbEh.js → index-nX2chMqi.js} +6 -6
  174. package/dist/ui/assets/{useSearch-mbMk6-M1.js → useSearch-BnBCRKui.js} +1 -1
  175. package/dist/ui/index.html +2 -2
  176. package/dist/version.d.ts +1 -1
  177. package/dist/version.js +1 -1
  178. package/docs/dev/jcodemunch-gap-analysis.md +198 -0
  179. package/package.json +9 -1
  180. package/user-manual.md +2466 -0
  181. package/dist/ui/assets/BlastRadius-BDZWhEk-.js +0 -1
  182. package/dist/ui/assets/RepoDetail-M6WaYbZ3.js +0 -1
@@ -0,0 +1,369 @@
1
+ # Code Intelligence
2
+
3
+ Some questions about a codebase can't be answered by searching for a specific name or looking at a single file. They require the server to reason about the whole codebase at once: *where does this application start?*, *what does this library expose?*, *which functions have no tests?*, *where are all the outstanding TODO items?*
4
+
5
+ PureContext's code intelligence tools answer these whole-codebase questions without requiring you to read through files manually.
6
+
7
+ ---
8
+
9
+ ## Finding entry points
10
+
11
+ Every application has a starting point — and often more than one. A Node.js service has a `bootstrap()` call. A CLI tool has argument parsing. A serverless function has Lambda handlers. A test suite has test runner entry points.
12
+
13
+ **Scenario:** You've just been handed a codebase you've never seen before. Your first question: how does this thing actually start?
14
+
15
+ > "Where does this application start? Show me all the entry points."
16
+
17
+ ```
18
+ get_entry_points(repoId) →
19
+
20
+ Entry Points (8 found):
21
+
22
+ HIGH CONFIDENCE:
23
+ main() src/index.ts main_function
24
+ reason: "function named main at module root"
25
+
26
+ bootstrap() src/server.ts server_startup
27
+ reason: "calls app.listen(), server startup pattern"
28
+
29
+ handler() src/lambda/api.ts lambda_handler
30
+ reason: "exported 'handler' in file matching /lambda/"
31
+
32
+ handler() src/lambda/events.ts lambda_handler
33
+ reason: "exported 'handler' in file matching /lambda/"
34
+
35
+ MEDIUM CONFIDENCE:
36
+ run() src/cli/index.ts cli_handler
37
+ reason: "calls process.argv, process.exit — CLI pattern"
38
+
39
+ workerMain() src/workers/index.ts server_startup
40
+ reason: "calls queue.process() — worker startup pattern"
41
+
42
+ LOW CONFIDENCE:
43
+ setup() test/setup.ts test_suite
44
+ reason: "matched test file pattern, exports setup function"
45
+
46
+ seed() scripts/seed.ts script
47
+ reason: "script file with no importers"
48
+ ```
49
+
50
+ Eight entry points: two Lambda handlers, a main server, a CLI, a worker, and a seeding script. In 30 seconds you understand the full deployment surface of the application.
51
+
52
+ **Filtering by type:**
53
+
54
+ > "Show me only the Lambda handlers."
55
+
56
+ ```
57
+ get_entry_points(repoId, kind: "lambda_handler", minConfidence: "high") →
58
+ [only the two confirmed Lambda handlers]
59
+ ```
60
+
61
+ **Use with `get_call_hierarchy`** to trace the full execution path from an entry point:
62
+
63
+ ```
64
+ get_entry_points(repoId, kind: "server_startup") → bootstrap()
65
+ get_call_hierarchy(symbolId: "bootstrap-id", direction: "callees", maxDepth: 3)
66
+ → full initialization sequence
67
+ ```
68
+
69
+ ---
70
+
71
+ ## Auditing the public API surface
72
+
73
+ Libraries, shared packages, and microservice clients expose a public API. Over time, that API grows — and often includes symbols that were never meant to be public.
74
+
75
+ **Scenario:** You're preparing a major version release. You want to document the public API and identify exports that aren't actually used by any consumer.
76
+
77
+ > "What does this package export? Show me the full public API surface."
78
+
79
+ ```
80
+ get_public_api(repoId) →
81
+
82
+ Public API Surface — 3 files, 47 exports
83
+
84
+ src/index.ts (31 exports):
85
+ createClient() function default export "Create a new PureContext client"
86
+ IndexManager class "Manages index lifecycle"
87
+ SearchEngine class "Symbol and semantic search"
88
+ SymbolRecord type "Core symbol type"
89
+ SymbolKind type "Union of all symbol kinds"
90
+ ImportRecord type "Import edge type"
91
+ ...
92
+
93
+ src/config.ts (9 exports):
94
+ loadConfig() function "Load and validate config.json"
95
+ ConfigSchema type "JSON Schema for config"
96
+ DEFAULT_CONFIG const "Default configuration values"
97
+ ...
98
+
99
+ src/errors.ts (7 exports):
100
+ PureContextError class "Base error class"
101
+ IndexNotFoundError class "Repo not indexed"
102
+ ...
103
+
104
+ Total: 47 exported symbols
105
+ ```
106
+
107
+ **Finding dead exports — things you export but nobody uses:**
108
+
109
+ ```
110
+ get_public_api(repoId) → 47 exports
111
+ find_dead_code(repoId) → 12 exports have no importers
112
+
113
+ These 12 are exported but never imported:
114
+ LegacyParser src/index.ts (deprecated)
115
+ debugMode src/config.ts (internal flag leaked into public API)
116
+ InternalQueue src/index.ts (should have been private)
117
+ ...
118
+ ```
119
+
120
+ Twelve symbols that are publicly exported but consumed by nobody — prime candidates for removal before the major release.
121
+
122
+ **Filtering the API by kind or file:**
123
+
124
+ ```
125
+ get_public_api(repoId, kind: "function") → only exported functions
126
+ get_public_api(repoId, filePath: "src/auth/") → exports from auth module only
127
+ get_public_api(repoId, includeMembers: true) → includes public methods of exported classes
128
+ ```
129
+
130
+ ---
131
+
132
+ ## Tracking TODOs and technical debt comments
133
+
134
+ Every codebase has outstanding work buried in comments. `get_todos` surfaces all of it in one place.
135
+
136
+ **Scenario:** Before a release, you want a complete list of every `FIXME` and `TODO` in the codebase.
137
+
138
+ > "Show me all FIXMEs and TODOs in the codebase, grouped by file."
139
+
140
+ ```
141
+ get_todos(repoId, tags: ["FIXME", "TODO"], groupByFile: true) →
142
+
143
+ 30 items found across 18 files
144
+
145
+ src/auth/oauth2.ts (3):
146
+ TODO:42 Replace JWT_SECRET with dedicated OAUTH_STATE_SECRET before merge
147
+ FIXME:67 Race condition: concurrent refreshes can invalidate each other's tokens
148
+ TODO:89 Add retry logic for failed OAuth state validation
149
+
150
+ src/billing/processor.ts (4):
151
+ FIXME:23 chargePayment doesn't handle partial auth — card could be charged twice
152
+ TODO:45 Add idempotency key support
153
+ TODO:67 Move tax calculation to a separate service
154
+ TODO:134 Handle PaymentIntent.cancelled status
155
+
156
+ src/core/database.ts (2):
157
+ FIXME:45 Connection pool exhaustion under load — needs backpressure
158
+ TODO:78 Add query timeout configuration
159
+
160
+ ... (15 more files)
161
+
162
+ Summary by tag:
163
+ TODO: 24 items
164
+ FIXME: 6 items
165
+ ```
166
+
167
+ Two of those FIXMEs describe potential bugs — a race condition in OAuth token refresh and a double-charge risk in billing. Those belong on the release blocker list.
168
+
169
+ **Filtering by tag:**
170
+
171
+ ```
172
+ get_todos(repoId, tags: ["FIXME", "BUG"])
173
+ → only bugs and fixes — use before a release
174
+
175
+ get_todos(repoId, tags: ["HACK"])
176
+ → all acknowledged hacks — useful for tech debt planning
177
+
178
+ get_todos(repoId, tags: ["TODO", "OPTIMIZE"])
179
+ → performance improvement backlog
180
+ ```
181
+
182
+ **Filtering by assignee:**
183
+
184
+ ```
185
+ get_todos(repoId, assignee: "alice")
186
+ → only items assigned to alice: TODO(alice): ...
187
+
188
+ get_todos(repoId, filePath: "src/auth/", tags: ["FIXME"])
189
+ → all FIXMEs in the auth module
190
+ ```
191
+
192
+ ---
193
+
194
+ ## Finding complexity hotspots
195
+
196
+ When you have limited refactoring time, you want to focus on the files that will give you the most improvement per hour. `get_complexity_hotspots` ranks files by their complexity concentration — not just the worst individual function, but files with many complex symbols clustered together.
197
+
198
+ **Scenario:** You're allocating sprint capacity to reduce complexity. Which files should you tackle first?
199
+
200
+ > "Which files in src/ have the highest complexity concentration? I want to prioritize my refactoring backlog."
201
+
202
+ ```
203
+ get_complexity_hotspots(repoId, scope: "src/", topN: 8) →
204
+
205
+ Complexity Hotspots:
206
+
207
+ 1. src/legacy/UserManager.ts hotspot: 94/100
208
+ avg complexity: 11.4 max: 23 symbols: 34
209
+ Top offenders:
210
+ processAuthRequest() complexity: 23 120 lines
211
+ handlePermissions() complexity: 19 98 lines
212
+ validateUserData() complexity: 14 67 lines
213
+
214
+ 2. src/billing/processor.ts hotspot: 78/100
215
+ avg complexity: 8.7 max: 18 symbols: 14
216
+ Top offenders:
217
+ chargePayment() complexity: 18 89 lines
218
+ applyDiscounts() complexity: 12 54 lines
219
+
220
+ 3. src/api/routes/legacy.ts hotspot: 67/100
221
+ avg complexity: 7.1 max: 15 symbols: 21
222
+ Top offenders:
223
+ handleLegacyRequest() complexity: 15 78 lines
224
+
225
+ 4. src/core/parser.ts hotspot: 61/100
226
+ avg complexity: 6.8 max: 12 symbols: 9
227
+ ...
228
+ ```
229
+
230
+ `UserManager.ts` has the worst hotspot score — nearly every function in it is complex. `billing/processor.ts` is second, with two high-complexity functions in a smaller file. These two files are your sprint targets.
231
+
232
+ **Scoping to a directory and filtering out simple functions:**
233
+
234
+ ```
235
+ get_complexity_hotspots(repoId, scope: "src/api/", topN: 5, minComplexity: 5)
236
+ → hotspots in the API directory, only counting functions with complexity ≥ 5
237
+ ```
238
+
239
+ ---
240
+
241
+ ## Visualizing the type hierarchy
242
+
243
+ For TypeScript codebases with significant type hierarchies — domain models, plugin interfaces, ORM entities — `get_type_graph` shows how all the types relate to each other.
244
+
245
+ **Scenario:** You're onboarding a new developer to work on the domain model. You want to give them a visual overview of the type relationships before they start.
246
+
247
+ > "Show me a Mermaid diagram of the type hierarchy in src/domain/."
248
+
249
+ ```
250
+ get_type_graph(repoId, scope: "src/domain/", format: "mermaid") →
251
+
252
+ ```mermaid
253
+ classDiagram
254
+ Entity <|-- UserEntity
255
+ Entity <|-- OrderEntity
256
+ Entity <|-- ProductEntity
257
+ UserEntity --> Address : uses
258
+ UserEntity --> UserRole : uses
259
+ OrderEntity --> OrderItem : uses
260
+ OrderEntity --> PaymentStatus : uses
261
+ Repository~T~ <|.. UserRepository
262
+ Repository~T~ <|.. OrderRepository
263
+ Repository~T~ <|.. ProductRepository
264
+ ```
265
+ ```
266
+
267
+ Paste into any Mermaid renderer and the team can see the full domain model at a glance. Generated from live code — never stale.
268
+
269
+ **Focusing on one type's connected types:**
270
+
271
+ ```
272
+ get_type_graph(repoId, rootSymbol: "UserEntity", maxDepth: 2) →
273
+ [UserEntity and everything it directly relates to, up to 2 hops]
274
+ ```
275
+
276
+ **JSON output for programmatic use:**
277
+
278
+ ```
279
+ get_type_graph(repoId, scope: "src/domain/", format: "json") →
280
+ {
281
+ "nodes": [
282
+ { "id": "...", "name": "UserEntity", "kind": "class", "filePath": "..." },
283
+ { "id": "...", "name": "Repository", "kind": "interface", "filePath": "..." },
284
+ ...
285
+ ],
286
+ "edges": [
287
+ { "source": "UserEntity-id", "target": "Entity-id", "relationship": "extends" },
288
+ { "source": "UserRepository-id", "target": "Repository-id", "relationship": "implements" },
289
+ ...
290
+ ]
291
+ }
292
+ ```
293
+
294
+ Use this to feed into custom diagram tools, documentation generators, or architecture review scripts.
295
+
296
+ ---
297
+
298
+ ## Finding untested symbols
299
+
300
+ `find_untested_symbols` identifies functions, methods, and classes whose names don't appear in any test file — a heuristic for missing test coverage without needing a coverage report.
301
+
302
+ **Scenario:** Before a release, you want to know which business-critical functions have no tests at all.
303
+
304
+ > "Which functions in src/billing/ have no test coverage?"
305
+
306
+ ```
307
+ find_untested_symbols(repoId, scope: "src/billing/", kinds: ["function", "method"]) →
308
+
309
+ Untested Symbols — 12 found (sorted by priority):
310
+
311
+ HIGH PRIORITY (complex and untested):
312
+ chargePayment() src/billing/processor.ts complexity: 18 lines: 89
313
+ applyRefund() src/billing/refunds.ts complexity: 12 lines: 67
314
+ calculateProration() src/billing/proration.ts complexity: 9 lines: 45
315
+
316
+ MEDIUM PRIORITY:
317
+ formatInvoiceLine() src/billing/invoice.ts complexity: 4 lines: 23
318
+ getNextBillingDate() src/billing/schedule.ts complexity: 3 lines: 18
319
+ ... (5 more)
320
+
321
+ LOW PRIORITY:
322
+ formatCurrency() src/billing/format.ts complexity: 1 lines: 4
323
+ ... (4 more)
324
+ ```
325
+
326
+ The three high-priority items — `chargePayment`, `applyRefund`, `calculateProration` — are complex, untested, and handle money. These are your release blockers.
327
+
328
+ **Getting exact coverage with a coverage report:**
329
+
330
+ For more precision, use `get_test_coverage_map` instead:
331
+
332
+ > "Parse our vitest coverage report and show me which billing functions are uncovered."
333
+
334
+ ```
335
+ get_test_coverage_map(repoId,
336
+ coveragePath: "/project/coverage/coverage-final.json",
337
+ scope: "src/billing/",
338
+ includeUncoveredOnly: true) →
339
+
340
+ Coverage Summary: 67% (41 of 61 symbols covered)
341
+
342
+ Uncovered Symbols:
343
+ chargePayment() src/billing/processor.ts 0 calls 0% statements
344
+ applyRefund() src/billing/refunds.ts 0 calls 0% statements
345
+ handlePartialAuth() src/billing/processor.ts 0 calls 0% statements
346
+ ...
347
+
348
+ File Coverage:
349
+ src/billing/processor.ts statements: 45% functions: 33% branches: 38%
350
+ src/billing/refunds.ts statements: 52% functions: 50% branches: 44%
351
+ src/billing/invoice.ts statements: 91% functions: 88% branches: 84%
352
+ ```
353
+
354
+ Line-accurate coverage linked to indexed symbols. Supports Istanbul/NYC (`coverage-final.json`) and V8/c8 formats.
355
+
356
+ ---
357
+
358
+ ## Choosing between coverage tools
359
+
360
+ | Situation | Use |
361
+ |-----------|-----|
362
+ | No coverage file available — quick estimate | `find_untested_symbols` |
363
+ | You have a coverage report — need line accuracy | `get_test_coverage_map` |
364
+ | Find the most complex untested functions | `find_untested_symbols` (sorted by complexity) |
365
+ | See statement/branch/function % per file | `get_test_coverage_map` |
366
+
367
+ ---
368
+
369
+ → Reference: [MCP Tools Reference](docs/06-tools-reference.md) — `get_entry_points`, `get_public_api`, `get_todos`, `get_complexity_hotspots`, `get_type_graph`, `find_untested_symbols`, `get_test_coverage_map`
@@ -0,0 +1,241 @@
1
+ # Health Dashboards & Debt Reporting
2
+
3
+ Technical debt accumulates the same way in every codebase: gradually, then suddenly. Individual decisions that seemed reasonable at the time compound into a system that's expensive to change and risky to touch. By the time it's a crisis, you're already deep in it.
4
+
5
+ PureContext gives you three complementary tools for measuring, tracking, and acting on code health over time.
6
+
7
+ ---
8
+
9
+ ## Health radar: five-axis scoring at a glance
10
+
11
+ `health_radar` scores your codebase on five dimensions, each 0–100 where 100 is perfectly healthy. It's designed for a quick read — dashboard views, CI gates, and pre-meeting overviews.
12
+
13
+ **Scenario:** Before a quarterly architecture review, you want a snapshot of where the codebase stands.
14
+
15
+ > "Give me a health overview of the entire codebase before we start our planning session."
16
+
17
+ ```
18
+ health_radar(repoId) →
19
+
20
+ Health Radar — purecontext-mcp
21
+
22
+ complexity 72 ██████████████░░░░░░ Good
23
+ avg. cyclomatic: 3.4 peak: 18 (src/legacy/UserManager.ts)
24
+
25
+ coupling 51 ██████████░░░░░░░░░░ Warning
26
+ 23 files with fan-out > 10 (threshold: < 10)
27
+
28
+ maintainability 78 ███████████████░░░░░ Good
29
+ 3 god classes found 11 dead exports
30
+
31
+ documentation 34 ██████░░░░░░░░░░░░░░ Poor
32
+ 34% of exported symbols have meaningful summaries
33
+
34
+ stability 63 ████████████░░░░░░░░ Fair
35
+ (churn data available — 8 high-churn files flagged)
36
+
37
+ Overall Health: 60 Grade: C
38
+
39
+ Summary: 312 files, 4,218 symbols, 7 high-risk files
40
+ ```
41
+
42
+ Five numbers give you the complete picture in under 30 seconds. Complexity and maintainability are green. Coupling is borderline. Documentation is a problem. Stability is fair but has hot spots.
43
+
44
+ **Scoping to a subsystem:**
45
+
46
+ > "How healthy is just the authentication module?"
47
+
48
+ ```
49
+ health_radar(repoId, scope: "src/auth/") →
50
+ [same five axes, computed only for files under src/auth/]
51
+ ```
52
+
53
+ Use this to compare health across services, or to track the health of a specific domain area you're actively working on.
54
+
55
+ **Excluding git data:**
56
+
57
+ ```
58
+ health_radar(repoId, includeStability: false)
59
+ ```
60
+
61
+ The stability axis requires git history. If git metadata isn't available (e.g., a freshly cloned repo without full history), set `includeStability: false` to score only the four static axes.
62
+
63
+ ---
64
+
65
+ ## Comparing health between two versions
66
+
67
+ `diff_health_radar` runs health radar on two repos and computes the delta. The most common use is before/after comparison, but it works for any two indexed repos.
68
+
69
+ **Scenario 1: Validating a refactoring sprint.**
70
+
71
+ Your team spent two weeks addressing coupling and documentation issues. You want proof that it worked.
72
+
73
+ > "Compare the health of the codebase now vs. the snapshot we indexed before the sprint."
74
+
75
+ ```
76
+ diff_health_radar(baseRepoId: "pre-sprint-id", headRepoId: "post-sprint-id") →
77
+
78
+ Comparison: pre-sprint → post-sprint
79
+
80
+ complexity 72 → 74 Δ +2 stable
81
+ coupling 51 → 67 Δ +16 ▲ improved
82
+ maintainability 78 → 82 Δ +4 stable
83
+ documentation 34 → 61 Δ +27 ▲ improved significantly
84
+ stability 63 → 65 Δ +2 stable
85
+
86
+ Overall: 60 → 70 Δ +10 trend: improved
87
+
88
+ Improvements: coupling, documentation
89
+ Regressions: none
90
+ ```
91
+
92
+ Coupling improved from 51 to 67 — a meaningful change. Documentation went from 34 to 61 — a dramatic improvement from the doc-writing effort. No regressions. The sprint achieved its goals.
93
+
94
+ **Scenario 2: PR health review.**
95
+
96
+ > "Does this PR improve or worsen the codebase health?"
97
+
98
+ ```
99
+ # 1. Index main branch
100
+ index_folder(path: "/projects/app", ...) → baseRepoId: "main-index"
101
+
102
+ # 2. Index the feature branch
103
+ index_folder(path: "/projects/app-pr-feature-x", ...) → headRepoId: "pr-index"
104
+
105
+ # 3. Compare
106
+ diff_health_radar(baseRepoId: "main-index", headRepoId: "pr-index") →
107
+
108
+ coupling 65 → 61 Δ -4 ▼ degraded
109
+ documentation 61 → 58 Δ -3 ▼ degraded slightly
110
+
111
+ Regressions: coupling, documentation
112
+ trend: degraded
113
+ ```
114
+
115
+ The PR adds coupling and removes documentation coverage. Flag it in the review — the delta is small but the direction is wrong.
116
+
117
+ ---
118
+
119
+ ## Debt reports: from score to action
120
+
121
+ Health radar gives you scores. `get_debt_report` gives you the full breakdown with ranked files and prioritized action items.
122
+
123
+ **Scenario:** You have a C-grade codebase and limited sprint capacity. You want to know exactly where to invest to get the most improvement per hour of work.
124
+
125
+ > "Generate a technical debt report for the whole codebase. I want to know where to focus first."
126
+
127
+ ```
128
+ get_debt_report(repoId, topN: 5) →
129
+
130
+ Technical Debt Report
131
+
132
+ Overall Debt Score: 43/100 Grade: C
133
+
134
+ ┌─────────────────────┬────────┬──────────────────────────────────────────┐
135
+ │ Category │ Score │ Top Issues │
136
+ ├─────────────────────┼────────┼──────────────────────────────────────────┤
137
+ │ Complexity │ 38 │ 12 functions with cyclomatic > 10 │
138
+ │ Structural │ 61 │ 3 circular deps, 8 high-coupling files │
139
+ │ Maintainability │ 29 │ 2 god classes, 41 dead exports │
140
+ │ Volatility │ 44 │ 5 high-churn files with complexity > 8 │
141
+ └─────────────────────┴────────┴──────────────────────────────────────────┘
142
+
143
+ Top Debt Files:
144
+
145
+ 1. src/legacy/UserManager.ts score: 87
146
+ - cyclomatic complexity avg: 11.4 (34 methods, 4 > 20 complexity)
147
+ - fan-out: 28 (imports 28 different files)
148
+ - 0 exports have documentation
149
+ - modified 47× in the last 6 months (highest churn)
150
+
151
+ 2. src/utils/helpers.ts score: 74
152
+ - 45 symbols across 8 unrelated domains (low cohesion)
153
+ - fan-in: 41 files depend on it (high blast radius)
154
+ - 12 dead exports
155
+
156
+ 3. src/core/billing.ts score: 68
157
+ - circular dependency with src/utils/currency.ts
158
+ - 3 functions with complexity > 12
159
+ - high churn: modified 31× in 6 months
160
+
161
+ 4. src/api/routes/legacy.ts score: 62
162
+ - 7 functions with complexity > 8
163
+ - no test references found for 4 exported functions
164
+
165
+ 5. src/models/user.ts score: 58
166
+ - imported by 34 files (stable hub — risky to change)
167
+ - 6 dead exports (possibly orphaned during a migration)
168
+
169
+ Prioritized Action Items:
170
+
171
+ HIGH ROI:
172
+ • Extract UserManager.ts into focused service classes
173
+ Reason: highest debt score + highest churn = highest risk
174
+ Estimated impact: −15 pts on complexity, −8 pts on structural debt
175
+
176
+ • Split helpers.ts by domain into 8 focused utility modules
177
+ Reason: eliminates 41-file blast radius + removes dead code
178
+ Estimated impact: −12 pts on structural, −5 pts on maintainability
179
+
180
+ • Break billing.ts ↔ currency.ts circular dependency
181
+ Reason: blocking independent testing of both modules
182
+ Estimated impact: −8 pts on structural debt
183
+
184
+ MEDIUM ROI:
185
+ • Add documentation to top 20 exported symbols in core/
186
+ Reason: documentation score is pulling down the overall grade
187
+ Estimated impact: +10 pts on documentation axis in health_radar
188
+
189
+ • Delete 41 dead exports (run find_dead_code for the full list)
190
+ Reason: reduces cognitive load + clarifies the public API surface
191
+ ```
192
+
193
+ The report tells you exactly what to work on: `UserManager.ts` is the highest-priority target (highest debt, highest churn — the most dangerous file in the codebase). `helpers.ts` second. The circular dependency third.
194
+
195
+ **Narrowing to a subsystem:**
196
+
197
+ ```
198
+ get_debt_report(repoId, scope: "src/core/", topN: 10)
199
+ → debt analysis restricted to files under src/core/
200
+ ```
201
+
202
+ **For CI integration:**
203
+
204
+ Run `get_debt_report` in CI and fail the pipeline if the overall debt score exceeds a threshold. Pair it with `diff_health_radar` to catch individual PRs that increase debt.
205
+
206
+ ---
207
+
208
+ ## Using the three tools together
209
+
210
+ The three tools answer different questions and work best together:
211
+
212
+ | Tool | When to use | Output |
213
+ |------|------------|--------|
214
+ | `health_radar` | Quick status check: "where are we?" | 5 scores + grade |
215
+ | `diff_health_radar` | Before/after comparison: "did we improve?" | Per-axis deltas |
216
+ | `get_debt_report` | Action planning: "what do we do first?" | Ranked files + action items |
217
+
218
+ **A monthly rhythm that works:**
219
+
220
+ ```
221
+ 1st of the month:
222
+ health_radar(repoId)
223
+ → log the scores to track the trend over time
224
+
225
+ Start of sprint:
226
+ get_debt_report(repoId, topN: 10)
227
+ → pick the highest-ROI items for this sprint
228
+
229
+ End of sprint:
230
+ diff_health_radar(baseRepoId: "month-start", headRepoId: "current")
231
+ → measure the sprint's impact on each axis
232
+
233
+ PR merges:
234
+ diff_health_radar(baseRepoId: "main", headRepoId: "feature")
235
+ → catch regressions at the PR level, not the monthly level
236
+ ```
237
+
238
+ ---
239
+
240
+ → Reference: [MCP Tools Reference](docs/06-tools-reference.md) — `health_radar`, `diff_health_radar`, `get_debt_report`
241
+ → See also: [Code Health & Architecture Analysis](CODE-HEALTH.md) — quality metrics, anti-pattern detection
package/README.md CHANGED
@@ -44,10 +44,16 @@ The guide explains what PureContext does, why each feature exists, and how to us
44
44
  | [Navigating a New Codebase](NAVIGATING-NEW-CODE.md) | Day one on an unfamiliar project |
45
45
  | [Finding Code](FINDING-CODE.md) | Three search modes with examples |
46
46
  | [Making Changes Safely](SAFE-CHANGES.md) | Blast radius and dependency analysis |
47
+ | [Understanding Code Relationships](UNDERSTANDING-RELATIONSHIPS.md) | Call hierarchies, cycles, coupling, implementations |
48
+ | [Refactoring Safely](REFACTORING-SAFELY.md) | Pre-flight checks before rename, delete, or move |
47
49
  | [Understanding Code History](CODE-HISTORY.md) | Symbol-level git history and churn |
48
50
  | [The Web UI](WEB-UI.md) | Visual graph, heatmap, symbol timeline |
49
51
  | [AI Summaries](AI-SUMMARIES.md) | Better search on undocumented codebases |
50
52
  | [Code Health & Architecture Analysis](CODE-HEALTH.md) | Quality metrics, anti-patterns, arch docs |
53
+ | [Health Dashboards & Debt Reporting](HEALTH-DASHBOARDS.md) | Health radar, debt scores, PR health diffs |
54
+ | [Visualizing Code Structure](VISUALIZING-CODE.md) | Mermaid/DOT diagrams, architecture snapshots |
55
+ | [AST-Level Search](AST-SEARCH.md) | Node types, signatures, decorators, complexity |
56
+ | [Code Intelligence](CODE-INTELLIGENCE.md) | Entry points, public API, TODOs, coverage |
51
57
  | [Using PureContext with a Team](TEAM-SETUP.md) | Shared server, enterprise setup |
52
58
 
53
59
  **Real-world workflows:**
@@ -57,6 +63,7 @@ The guide explains what PureContext does, why each feature exists, and how to us
57
63
  | [Onboarding to a New Codebase](WORKFLOW-ONBOARDING.md) | First day on a 6,000-file microservices platform |
58
64
  | [Refactoring Legacy Code](WORKFLOW-REFACTORING.md) | Replacing auth in a 6-year-old Django monolith |
59
65
  | [Reviewing a Pull Request](WORKFLOW-PR-REVIEW.md) | 40-file PR, 45 minutes, two real bugs found |
66
+ | [Running a Tech Debt Sprint](WORKFLOW-TECH-DEBT.md) | Two-week debt reduction: assess, plan, execute, measure |
60
67
 
61
68
  → [Full guide index](USER-GUIDE.md)
62
69