@agent-wiki/mcp 0.17.9

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 (217) hide show
  1. package/.claude-plugin/plugin.json +7 -0
  2. package/README.md +171 -0
  3. package/architecture.svg +58 -0
  4. package/dist/atlassian.d.ts +63 -0
  5. package/dist/atlassian.d.ts.map +1 -0
  6. package/dist/atlassian.js +596 -0
  7. package/dist/atlassian.js.map +1 -0
  8. package/dist/cli.d.ts +11 -0
  9. package/dist/cli.d.ts.map +1 -0
  10. package/dist/cli.js +391 -0
  11. package/dist/cli.js.map +1 -0
  12. package/dist/cobol/__tests__/call-boundary-lineage.test.d.ts +2 -0
  13. package/dist/cobol/__tests__/call-boundary-lineage.test.d.ts.map +1 -0
  14. package/dist/cobol/__tests__/call-boundary-lineage.test.js +505 -0
  15. package/dist/cobol/__tests__/call-boundary-lineage.test.js.map +1 -0
  16. package/dist/cobol/__tests__/code-analysis.test.d.ts +2 -0
  17. package/dist/cobol/__tests__/code-analysis.test.d.ts.map +1 -0
  18. package/dist/cobol/__tests__/code-analysis.test.js +465 -0
  19. package/dist/cobol/__tests__/code-analysis.test.js.map +1 -0
  20. package/dist/cobol/__tests__/db2-table-lineage.test.d.ts +2 -0
  21. package/dist/cobol/__tests__/db2-table-lineage.test.d.ts.map +1 -0
  22. package/dist/cobol/__tests__/db2-table-lineage.test.js +182 -0
  23. package/dist/cobol/__tests__/db2-table-lineage.test.js.map +1 -0
  24. package/dist/cobol/__tests__/evidence-mapping.test.d.ts +2 -0
  25. package/dist/cobol/__tests__/evidence-mapping.test.d.ts.map +1 -0
  26. package/dist/cobol/__tests__/evidence-mapping.test.js +49 -0
  27. package/dist/cobol/__tests__/evidence-mapping.test.js.map +1 -0
  28. package/dist/cobol/__tests__/extractors.test.d.ts +2 -0
  29. package/dist/cobol/__tests__/extractors.test.d.ts.map +1 -0
  30. package/dist/cobol/__tests__/extractors.test.js +189 -0
  31. package/dist/cobol/__tests__/extractors.test.js.map +1 -0
  32. package/dist/cobol/__tests__/field-lineage.test.d.ts +2 -0
  33. package/dist/cobol/__tests__/field-lineage.test.d.ts.map +1 -0
  34. package/dist/cobol/__tests__/field-lineage.test.js +329 -0
  35. package/dist/cobol/__tests__/field-lineage.test.js.map +1 -0
  36. package/dist/cobol/__tests__/graph.test.d.ts +2 -0
  37. package/dist/cobol/__tests__/graph.test.d.ts.map +1 -0
  38. package/dist/cobol/__tests__/graph.test.js +456 -0
  39. package/dist/cobol/__tests__/graph.test.js.map +1 -0
  40. package/dist/cobol/__tests__/integration.test.d.ts +2 -0
  41. package/dist/cobol/__tests__/integration.test.d.ts.map +1 -0
  42. package/dist/cobol/__tests__/integration.test.js +971 -0
  43. package/dist/cobol/__tests__/integration.test.js.map +1 -0
  44. package/dist/cobol/__tests__/lexer.test.d.ts +2 -0
  45. package/dist/cobol/__tests__/lexer.test.d.ts.map +1 -0
  46. package/dist/cobol/__tests__/lexer.test.js +111 -0
  47. package/dist/cobol/__tests__/lexer.test.js.map +1 -0
  48. package/dist/cobol/__tests__/parser.test.d.ts +2 -0
  49. package/dist/cobol/__tests__/parser.test.d.ts.map +1 -0
  50. package/dist/cobol/__tests__/parser.test.js +180 -0
  51. package/dist/cobol/__tests__/parser.test.js.map +1 -0
  52. package/dist/cobol/__tests__/variable-tracer.test.d.ts +2 -0
  53. package/dist/cobol/__tests__/variable-tracer.test.d.ts.map +1 -0
  54. package/dist/cobol/__tests__/variable-tracer.test.js +256 -0
  55. package/dist/cobol/__tests__/variable-tracer.test.js.map +1 -0
  56. package/dist/cobol/__tests__/wiki-gen.test.d.ts +2 -0
  57. package/dist/cobol/__tests__/wiki-gen.test.d.ts.map +1 -0
  58. package/dist/cobol/__tests__/wiki-gen.test.js +76 -0
  59. package/dist/cobol/__tests__/wiki-gen.test.js.map +1 -0
  60. package/dist/cobol/call-boundary-lineage.d.ts +49 -0
  61. package/dist/cobol/call-boundary-lineage.d.ts.map +1 -0
  62. package/dist/cobol/call-boundary-lineage.js +159 -0
  63. package/dist/cobol/call-boundary-lineage.js.map +1 -0
  64. package/dist/cobol/db2-table-lineage.d.ts +45 -0
  65. package/dist/cobol/db2-table-lineage.d.ts.map +1 -0
  66. package/dist/cobol/db2-table-lineage.js +127 -0
  67. package/dist/cobol/db2-table-lineage.js.map +1 -0
  68. package/dist/cobol/evidence-mapping.d.ts +31 -0
  69. package/dist/cobol/evidence-mapping.d.ts.map +1 -0
  70. package/dist/cobol/evidence-mapping.js +27 -0
  71. package/dist/cobol/evidence-mapping.js.map +1 -0
  72. package/dist/cobol/extractors.d.ts +88 -0
  73. package/dist/cobol/extractors.d.ts.map +1 -0
  74. package/dist/cobol/extractors.js +297 -0
  75. package/dist/cobol/extractors.js.map +1 -0
  76. package/dist/cobol/field-lineage.d.ts +101 -0
  77. package/dist/cobol/field-lineage.d.ts.map +1 -0
  78. package/dist/cobol/field-lineage.js +603 -0
  79. package/dist/cobol/field-lineage.js.map +1 -0
  80. package/dist/cobol/graph.d.ts +182 -0
  81. package/dist/cobol/graph.d.ts.map +1 -0
  82. package/dist/cobol/graph.js +453 -0
  83. package/dist/cobol/graph.js.map +1 -0
  84. package/dist/cobol/lexer.d.ts +15 -0
  85. package/dist/cobol/lexer.d.ts.map +1 -0
  86. package/dist/cobol/lexer.js +251 -0
  87. package/dist/cobol/lexer.js.map +1 -0
  88. package/dist/cobol/parser.d.ts +13 -0
  89. package/dist/cobol/parser.d.ts.map +1 -0
  90. package/dist/cobol/parser.js +584 -0
  91. package/dist/cobol/parser.js.map +1 -0
  92. package/dist/cobol/plugin.d.ts +23 -0
  93. package/dist/cobol/plugin.d.ts.map +1 -0
  94. package/dist/cobol/plugin.js +507 -0
  95. package/dist/cobol/plugin.js.map +1 -0
  96. package/dist/cobol/types.d.ts +73 -0
  97. package/dist/cobol/types.d.ts.map +1 -0
  98. package/dist/cobol/types.js +9 -0
  99. package/dist/cobol/types.js.map +1 -0
  100. package/dist/cobol/variable-tracer.d.ts +31 -0
  101. package/dist/cobol/variable-tracer.d.ts.map +1 -0
  102. package/dist/cobol/variable-tracer.js +361 -0
  103. package/dist/cobol/variable-tracer.js.map +1 -0
  104. package/dist/cobol/wiki-gen.d.ts +18 -0
  105. package/dist/cobol/wiki-gen.d.ts.map +1 -0
  106. package/dist/cobol/wiki-gen.js +222 -0
  107. package/dist/cobol/wiki-gen.js.map +1 -0
  108. package/dist/code-analysis.d.ts +160 -0
  109. package/dist/code-analysis.d.ts.map +1 -0
  110. package/dist/code-analysis.js +53 -0
  111. package/dist/code-analysis.js.map +1 -0
  112. package/dist/evidence-search.d.ts +43 -0
  113. package/dist/evidence-search.d.ts.map +1 -0
  114. package/dist/evidence-search.js +112 -0
  115. package/dist/evidence-search.js.map +1 -0
  116. package/dist/evidence-search.test.d.ts +2 -0
  117. package/dist/evidence-search.test.d.ts.map +1 -0
  118. package/dist/evidence-search.test.js +98 -0
  119. package/dist/evidence-search.test.js.map +1 -0
  120. package/dist/evidence.d.ts +32 -0
  121. package/dist/evidence.d.ts.map +1 -0
  122. package/dist/evidence.js +16 -0
  123. package/dist/evidence.js.map +1 -0
  124. package/dist/evidence.test.d.ts +2 -0
  125. package/dist/evidence.test.d.ts.map +1 -0
  126. package/dist/evidence.test.js +51 -0
  127. package/dist/evidence.test.js.map +1 -0
  128. package/dist/extraction.d.ts +40 -0
  129. package/dist/extraction.d.ts.map +1 -0
  130. package/dist/extraction.js +283 -0
  131. package/dist/extraction.js.map +1 -0
  132. package/dist/extraction.test.d.ts +5 -0
  133. package/dist/extraction.test.d.ts.map +1 -0
  134. package/dist/extraction.test.js +137 -0
  135. package/dist/extraction.test.js.map +1 -0
  136. package/dist/index.d.ts +38 -0
  137. package/dist/index.d.ts.map +1 -0
  138. package/dist/index.js +35 -0
  139. package/dist/index.js.map +1 -0
  140. package/dist/queue.d.ts +52 -0
  141. package/dist/queue.d.ts.map +1 -0
  142. package/dist/queue.js +139 -0
  143. package/dist/queue.js.map +1 -0
  144. package/dist/queue.test.d.ts +2 -0
  145. package/dist/queue.test.d.ts.map +1 -0
  146. package/dist/queue.test.js +161 -0
  147. package/dist/queue.test.js.map +1 -0
  148. package/dist/search.d.ts +163 -0
  149. package/dist/search.d.ts.map +1 -0
  150. package/dist/search.js +653 -0
  151. package/dist/search.js.map +1 -0
  152. package/dist/search.test.d.ts +6 -0
  153. package/dist/search.test.d.ts.map +1 -0
  154. package/dist/search.test.js +551 -0
  155. package/dist/search.test.js.map +1 -0
  156. package/dist/server.d.ts +33 -0
  157. package/dist/server.d.ts.map +1 -0
  158. package/dist/server.js +2530 -0
  159. package/dist/server.js.map +1 -0
  160. package/dist/server.test.d.ts +8 -0
  161. package/dist/server.test.d.ts.map +1 -0
  162. package/dist/server.test.js +2397 -0
  163. package/dist/server.test.js.map +1 -0
  164. package/dist/version.d.ts +2 -0
  165. package/dist/version.d.ts.map +1 -0
  166. package/dist/version.js +5 -0
  167. package/dist/version.js.map +1 -0
  168. package/dist/wiki.d.ts +496 -0
  169. package/dist/wiki.d.ts.map +1 -0
  170. package/dist/wiki.js +2677 -0
  171. package/dist/wiki.js.map +1 -0
  172. package/dist/wiki.test.d.ts +8 -0
  173. package/dist/wiki.test.d.ts.map +1 -0
  174. package/dist/wiki.test.js +1881 -0
  175. package/dist/wiki.test.js.map +1 -0
  176. package/docs/code-analysis-plugins.md +169 -0
  177. package/docs/configuration.md +135 -0
  178. package/docs/diagrams/cobol-analysis-flow.png +0 -0
  179. package/docs/diagrams/cobol-analysis-flow.svg +156 -0
  180. package/docs/evidence-envelope.md +176 -0
  181. package/docs/graph-1.gif +0 -0
  182. package/docs/legacy-code-knowledge-compiler-prd.md +511 -0
  183. package/docs/product-direction.md +120 -0
  184. package/docs/request-optimization.md +201 -0
  185. package/docs/search.md +266 -0
  186. package/docs/tools.md +269 -0
  187. package/graph-viewer/dist/cli.d.ts +3 -0
  188. package/graph-viewer/dist/cli.d.ts.map +1 -0
  189. package/graph-viewer/dist/cli.js +97 -0
  190. package/graph-viewer/dist/cli.js.map +1 -0
  191. package/graph-viewer/dist/graph.d.ts +14 -0
  192. package/graph-viewer/dist/graph.d.ts.map +1 -0
  193. package/graph-viewer/dist/graph.js +96 -0
  194. package/graph-viewer/dist/graph.js.map +1 -0
  195. package/graph-viewer/dist/index.d.ts +6 -0
  196. package/graph-viewer/dist/index.d.ts.map +1 -0
  197. package/graph-viewer/dist/index.js +4 -0
  198. package/graph-viewer/dist/index.js.map +1 -0
  199. package/graph-viewer/dist/parse.d.ts +10 -0
  200. package/graph-viewer/dist/parse.d.ts.map +1 -0
  201. package/graph-viewer/dist/parse.js +62 -0
  202. package/graph-viewer/dist/parse.js.map +1 -0
  203. package/graph-viewer/dist/server.d.ts +15 -0
  204. package/graph-viewer/dist/server.d.ts.map +1 -0
  205. package/graph-viewer/dist/server.js +168 -0
  206. package/graph-viewer/dist/server.js.map +1 -0
  207. package/graph-viewer/dist/types.d.ts +48 -0
  208. package/graph-viewer/dist/types.d.ts.map +1 -0
  209. package/graph-viewer/dist/types.js +2 -0
  210. package/graph-viewer/dist/types.js.map +1 -0
  211. package/graph-viewer/public/app.js +525 -0
  212. package/graph-viewer/public/index.html +68 -0
  213. package/graph-viewer/public/style.css +68 -0
  214. package/package.json +73 -0
  215. package/skills/aceclaw/SKILL.md +173 -0
  216. package/skills/agent-wiki/SKILL.md +184 -0
  217. package/skills/agent-wiki/references/tools-reference.md +368 -0
@@ -0,0 +1,511 @@
1
+ # PRD: Legacy Code Knowledge Compiler
2
+
3
+ ## Status
4
+
5
+ Draft
6
+
7
+ ## Summary
8
+
9
+ Build a vertical product line inside `agent-wiki` that compiles legacy systems
10
+ into a durable, queryable, evidence-backed knowledge base. The initial focus is
11
+ COBOL-centric systems and adjacent operational artifacts such as copybooks, JCL,
12
+ batch structure, file interfaces, and database usage.
13
+
14
+ This product line should turn a pile of legacy assets into:
15
+
16
+ - structured wiki pages
17
+ - machine-readable dependency and lineage graphs
18
+ - grounded retrieval surfaces
19
+ - impact-analysis outputs
20
+ - explicit uncertainty signals where understanding is incomplete
21
+
22
+ ## Problem
23
+
24
+ Legacy systems are usually maintained through:
25
+
26
+ - fragmented documents
27
+ - code-level tribal knowledge
28
+ - batch scripts and deployment artifacts
29
+ - institutional memory trapped in senior engineers
30
+
31
+ Teams struggle with:
32
+
33
+ - onboarding new maintainers
34
+ - estimating change impact
35
+ - identifying shared copybooks and common data structures
36
+ - tracing field movement across programs and jobs
37
+ - modernization and migration planning
38
+ - answering audit and operations questions with evidence
39
+
40
+ Generic search and generic code assistants help at the margin, but they often
41
+ fail at two things that matter most in this space:
42
+
43
+ - grounding answers in system structure and source evidence
44
+ - surfacing uncertainty when the system model is incomplete
45
+
46
+ ## Product Goal
47
+
48
+ Create a compiler-like pipeline that transforms raw legacy system assets into a
49
+ knowledge model that supports:
50
+
51
+ - system understanding
52
+ - maintenance
53
+ - change impact analysis
54
+ - modernization planning
55
+ - auditability
56
+
57
+ ## Users
58
+
59
+ Primary users:
60
+
61
+ - legacy application maintainers
62
+ - modernization teams
63
+ - enterprise architects
64
+ - platform and reliability teams supporting batch systems
65
+ - consulting and outsourcing teams inheriting systems
66
+
67
+ Secondary users:
68
+
69
+ - engineering managers
70
+ - audit and risk partners
71
+ - internal documentation and knowledge management teams
72
+
73
+ ## Initial Scope
74
+
75
+ The first supported vertical is COBOL-based systems.
76
+
77
+ In scope for the first major phase:
78
+
79
+ - COBOL programs
80
+ - COBOL copybooks
81
+ - procedure sections and paragraphs
82
+ - variables and data items
83
+ - CALL / PERFORM / COPY relationships
84
+ - generated program and copybook wiki pages
85
+ - aggregate call graph pages
86
+ - variable trace queries
87
+
88
+ Next-in-scope after core COBOL:
89
+
90
+ - JCL jobs and steps
91
+ - job-to-program invocation mapping
92
+ - dataset / file usage
93
+ - DB2 and CICS references where detectable
94
+ - batch flow aggregation
95
+
96
+ Out of scope for the initial phase:
97
+
98
+ - broad multi-language support beyond one deep wedge
99
+ - source-to-source code migration
100
+ - automatic code rewriting
101
+ - full runtime observability ingestion
102
+
103
+ ## Product Thesis
104
+
105
+ The product is not a code summarizer.
106
+
107
+ It is a knowledge compiler for legacy systems.
108
+
109
+ That means:
110
+
111
+ 1. parse source artifacts deterministically
112
+ 2. normalize them into a stable intermediate model
113
+ 3. resolve cross-file and cross-runtime relationships
114
+ 4. emit human-readable knowledge pages and machine-readable graph outputs
115
+ 5. expose confidence gaps, unresolved references, and unsupported claims
116
+
117
+ ## Core Use Cases
118
+
119
+ ### 1. Understand a program quickly
120
+
121
+ A maintainer should be able to ingest a COBOL program and get:
122
+
123
+ - structure
124
+ - paragraphs and sections
125
+ - copybook dependencies
126
+ - key data items
127
+ - likely call targets
128
+ - related wiki pages
129
+
130
+ ### 2. Trace a field or variable
131
+
132
+ A user should be able to ask:
133
+
134
+ - where is `WS-TOTAL-SALARY` read and written?
135
+ - which procedures mutate a control field?
136
+ - where is a particular record layout shared?
137
+
138
+ ### 3. Build a system map
139
+
140
+ A team should be able to compile multiple programs and produce:
141
+
142
+ - call graph
143
+ - shared copybook graph
144
+ - job/step/program graph
145
+ - file and table usage map
146
+
147
+ ### 4. Estimate change impact
148
+
149
+ A user should be able to ask:
150
+
151
+ - if I change this copybook, what programs are affected?
152
+ - if I modify this field, what downstream jobs or reports might break?
153
+ - what batch steps depend on this program?
154
+
155
+ ### 5. Support modernization work
156
+
157
+ A team should be able to use the compiled knowledge base to identify:
158
+
159
+ - tightly coupled areas
160
+ - shared schemas and copybooks
161
+ - dead or low-visibility programs
162
+ - migration candidates and risk clusters
163
+
164
+ ## User Value
165
+
166
+ The system should reduce time and uncertainty in:
167
+
168
+ - onboarding
169
+ - incident response
170
+ - maintenance planning
171
+ - impact analysis
172
+ - modernization discovery
173
+
174
+ The strongest value proposition is not convenience. It is reduced risk with
175
+ traceable evidence.
176
+
177
+ ## Current Starting Point
178
+
179
+ The current `agent-wiki` codebase already provides:
180
+
181
+ - a plugin architecture for code analysis
182
+ - a COBOL parser and normalized model path
183
+ - variable tracing
184
+ - wiki page generation for programs and copybooks
185
+ - aggregate call graph generation
186
+ - raw source storage and provenance
187
+ - wiki generation and search surfaces
188
+
189
+ This PRD extends that foundation into a deeper vertical product.
190
+
191
+ ## Product Requirements
192
+
193
+ ### A. Deterministic extraction first
194
+
195
+ The core facts must come from deterministic parsing and resolution wherever
196
+ possible.
197
+
198
+ Examples:
199
+
200
+ - program IDs
201
+ - sections and paragraphs
202
+ - data items
203
+ - CALL / PERFORM / COPY relationships
204
+ - file and table references where parseable
205
+
206
+ Agent synthesis may add summaries and semantic grouping, but it must not be the
207
+ sole source of core structural facts.
208
+
209
+ ### B. Stable intermediate model
210
+
211
+ The compiler must maintain a normalized, machine-readable model across files and
212
+ artifacts, not only emit Markdown pages.
213
+
214
+ The model should eventually represent entities such as:
215
+
216
+ - program
217
+ - copybook
218
+ - job
219
+ - step
220
+ - file or dataset
221
+ - table
222
+ - field
223
+ - procedure
224
+ - dependency edge
225
+
226
+ ### C. Cross-artifact resolution
227
+
228
+ The system must move beyond single-file analysis.
229
+
230
+ It should resolve:
231
+
232
+ - copybook reuse across programs
233
+ - program invocation across jobs and steps
234
+ - field definitions shared across copybooks and records
235
+ - file and table access patterns across the system
236
+
237
+ ### D. Evidence-backed outputs
238
+
239
+ Every generated page or impact result should retain links to its sources:
240
+
241
+ - raw source file
242
+ - source location where feasible
243
+ - generated model artifact
244
+
245
+ ### E. Uncertainty visibility
246
+
247
+ The system must explicitly surface:
248
+
249
+ - unresolved call targets
250
+ - unresolved copybook references
251
+ - ambiguous field mappings
252
+ - inferred relationships with lower confidence
253
+
254
+ This is important both for trust and for agent behavior.
255
+
256
+ ## Functional Requirements
257
+
258
+ ### Phase 1: COBOL core compiler — **delivered**
259
+
260
+ - Parse `.cbl`, `.cob`, `.cpy` (fixed-format with alphanumeric sequence areas + free-format)
261
+ - Normalize program structure into `CobolCodeModel` and the language-agnostic `NormalizedCodeModel`
262
+ - Generate program and copybook wiki pages with External Dependencies blocks (DB2 / CICS / file access)
263
+ - Build aggregate call graph page (`wiki/cobol/call-graph.md`)
264
+ - Support variable tracing and intra-program dataflow edges (MOVE/COMPUTE/EXEC SQL host vars/CALL USING)
265
+ - Persist parse and model artifacts to `raw/parsed/cobol/`, with load-time schema migration for older artifacts
266
+
267
+ ### Phase 2: Batch/runtime compiler — **not started**
268
+
269
+ - Parse JCL jobs and steps
270
+ - Map job step -> invoked program
271
+ - Extract datasets and file references
272
+ - Generate batch-flow wiki pages
273
+ - Build job/program/file relationship graph
274
+
275
+ ### Phase 3: Data usage and lineage — **delivered for COBOL side**
276
+
277
+ - Identify read/write access patterns to files and tables (DB2 + file access classification)
278
+ - Link fields across copybooks and programs through three lineage families:
279
+ - shared copybook field reuse (deterministic + inferred)
280
+ - `CALL ... USING` boundary flow (caller WORKING-STORAGE ↔ callee LINKAGE positional matching with structural evidence)
281
+ - cross-program flow via shared DB2 tables (writer/reader pairs with host-variable evidence)
282
+ - Surface deterministic vs inferred vs high-confidence evidence per entry
283
+ - Cross-file lineage relying on JCL-mediated dataflow remains pending Phase 2
284
+
285
+ ### Phase 4: Impact analysis surface — **delivered**
286
+
287
+ - Query affected programs for a changed copybook (`code_query` `impact`, `kind: copybook`)
288
+ - Query affected callers for a changed program (`code_query` `impact`, `kind: program`)
289
+ - Query likely downstream artifacts for a changed field via `code_query` `field_lineage`
290
+ - Return evidence chains, depth grouping, and unresolved/lower-confidence markers
291
+ - Job-level impact (changed program → affected jobs) remains pending Phase 2
292
+
293
+ ## Non-Functional Requirements
294
+
295
+ - outputs must remain Git-native and inspectable
296
+ - compiled knowledge must be regenerable from raw sources
297
+ - browser visualization must remain optional, not foundational
298
+ - the system should degrade gracefully when resolution is incomplete
299
+ - source evidence must survive summarization
300
+
301
+ ## Experience Principles
302
+
303
+ - show the system model, not just prose summaries
304
+ - make evidence and uncertainty visible
305
+ - prioritize maintenance and impact workflows over decorative visualization
306
+ - prefer deterministic correctness over aggressive synthesis
307
+
308
+ ## Differentiation
309
+
310
+ This product line differs from generic code assistants by emphasizing:
311
+
312
+ - compiler-style extraction, not just Q&A
313
+ - durable knowledge artifacts, not transient chat output
314
+ - evidence-backed system maps
315
+ - explicit abstention when evidence is weak
316
+ - deep vertical support in a legacy domain
317
+
318
+ ## Technical Moat
319
+
320
+ The moat comes from accumulated vertical depth, not from a single feature.
321
+
322
+ Expected moat layers:
323
+
324
+ 1. parsers and resolution logic for legacy artifacts
325
+ 2. normalized intermediate models and graph schema
326
+ 3. impact-analysis logic and heuristics
327
+ 4. grounded retrieval and uncertainty signaling
328
+ 5. evaluation corpus built from real legacy systems
329
+
330
+ Over time, each new customer or corpus should improve:
331
+
332
+ - parsing coverage
333
+ - resolution quality
334
+ - lineage quality
335
+ - impact-analysis accuracy
336
+ - benchmark depth
337
+
338
+ ## Risks
339
+
340
+ ### 1. Shallow multi-language expansion
341
+
342
+ Trying to support many ecosystems too early would weaken the wedge.
343
+
344
+ Mitigation:
345
+
346
+ - go deep on COBOL first
347
+ - only expand once one vertical loop is strong
348
+
349
+ ### 2. Over-reliance on LLM summaries
350
+
351
+ This would reduce trust.
352
+
353
+ Mitigation:
354
+
355
+ - deterministic extraction first
356
+ - label inferred or synthesized conclusions clearly
357
+
358
+ ### 3. Attractive but low-value UI work
359
+
360
+ Graphs are useful, but not the core moat.
361
+
362
+ Mitigation:
363
+
364
+ - invest first in resolution, lineage, and impact APIs
365
+
366
+ ### 4. Weak evaluation discipline
367
+
368
+ Without strong evals, the system may feel plausible without being reliable.
369
+
370
+ Mitigation:
371
+
372
+ - add corpus-driven tests and accuracy measures early
373
+
374
+ ## Success Metrics
375
+
376
+ Product metrics:
377
+
378
+ - time-to-understand for a new program
379
+ - time-to-answer common impact questions
380
+ - number of compiled artifacts per system
381
+ - coverage of ingested legacy assets
382
+
383
+ Quality metrics:
384
+
385
+ - parse success rate
386
+ - unresolved reference rate
387
+ - variable trace accuracy
388
+ - call graph precision and recall on benchmark corpora
389
+ - impact-analysis accuracy on known change scenarios
390
+
391
+ Adoption metrics:
392
+
393
+ - number of systems compiled
394
+ - repeated use in maintenance and modernization workflows
395
+ - retained usage by consulting or internal platform teams
396
+
397
+ ## Roadmap
398
+
399
+ ### Delivered
400
+
401
+ - COBOL parser and extractor: programs, copybooks, sections, paragraphs, data items including LINKAGE, `CALL ... USING` arguments, `EXEC SQL`, `EXEC CICS`, file access modes
402
+ - Lexer handles fixed-format with alphanumeric sequence areas (mainframe change-control prefixes like `XX0001` / `XX0002`) plus free-format
403
+ - Per-file wiki pages with External Dependencies sections (DB2 / CICS / file access tables) and aggregate `system-map.md` / `call-graph.md`
404
+ - Cross-file knowledge graph with 5 node types and 8+ edge types (CALLS, COPIES, READS_WRITES, db2-table, cics-program / -transaction / -map / -file, file-access)
405
+ - `code_query` impact surface: depth-bounded traversal, unresolved/lower-confidence markers, evidence chains
406
+ - Field lineage families:
407
+ - shared copybook field reuse (deterministic + inferred high-confidence + ambiguous)
408
+ - cross-program flow at `CALL ... USING` boundaries (deterministic + name-suffix-tiered high)
409
+ - cross-program flow via shared DB2 tables (writer/reader pairs with host variables)
410
+ - Schema migration on artifact load so older parsed `.model.json` files keep working without re-parse
411
+
412
+ ### In flight / near term
413
+
414
+ - JCL parsing (job, step, dataset, proc include)
415
+ - Job step → program linking via the graph layer
416
+ - Batch flow wiki pages
417
+ - Evaluation fixtures and accuracy metrics on a real-corpus benchmark
418
+
419
+ ### Deferred (with rationale)
420
+
421
+ - DB2 column-level lineage (would require a SQL parser; deferred per scoping in #67)
422
+ - Dataset-mediated cross-program lineage (corpus dogfood found 0 candidates; reopen on real demand)
423
+ - Program-variant identity (multiple files declaring the same `PROGRAM-ID`; quality-of-life, not blocking — see closed #75)
424
+ - Modernization-oriented summary pages and reports
425
+ - Retrieval-side abstain / evidence-sufficiency signals on compiler outputs
426
+
427
+ ## Open Questions (Resolved)
428
+
429
+ ### 1. Should JCL live inside the COBOL plugin family or become its own plugin?
430
+
431
+ **Decision: Independent plugin.**
432
+
433
+ JCL is a job/batch orchestration layer; COBOL is a program logic layer — their
434
+ concerns are fundamentally different. The only shared surface is cross-references
435
+ (job step → program), which are modeled as graph edges (`EXECUTES`) rather than
436
+ internal plugin coupling. This keeps each plugin focused:
437
+
438
+ - `cobol` plugin: parse programs, copybooks, sections, variables, CALL graph
439
+ - `jcl` plugin: parse jobs, steps, DD statements, dataset references, proc includes
440
+
441
+ Cross-artifact links are resolved at the **graph layer**, not inside either plugin.
442
+
443
+ ### 2. What is the minimum viable graph schema for cross-artifact impact analysis?
444
+
445
+ **Decision: 5 node types + 4 edge types.**
446
+
447
+ Nodes:
448
+
449
+ | Node Type | Source | Example |
450
+ |-------------|---------------|--------------------------------|
451
+ | `Program` | COBOL parser | SAMPLE-A, SAMPLE-E |
452
+ | `Copybook` | COBOL parser | WSGESCOM, TABELLE665 |
453
+ | `Job` | JCL parser | NIGHTLY-SETTLE |
454
+ | `Step` | JCL parser | STEP010 |
455
+ | `Dataset` | JCL parser | HLQ.PROD.TRANS.FILE |
456
+
457
+ Edges:
458
+
459
+ | Edge Type | From → To | Source |
460
+ |----------------|-------------------|---------------------|
461
+ | `CALLS` | Program → Program | CALL statement |
462
+ | `COPIES` | Program → Copybook| COPY statement |
463
+ | `EXECUTES` | Step → Program | EXEC PGM= |
464
+ | `READS/WRITES` | Step → Dataset | DD statement (DISP) |
465
+
466
+ Field-level lineage (column → column) is deferred to Phase 3.
467
+
468
+ ### 3. How should inferred relationships be labeled and scored?
469
+
470
+ **Decision: Three-tier confidence model with provenance.**
471
+
472
+ | Confidence Level | Meaning | Example |
473
+ |--------------------|------------------------------------------------|----------------------------------------------|
474
+ | `deterministic` | Parsed directly from source — no inference | `CALL 'SAMPLE-A'` → static call edge |
475
+ | `inferred-high` | Dynamic but target is resolvable/unique | `CALL WS-PGM` where WS-PGM is set once |
476
+ | `inferred-low` | Heuristic match, naming convention, or guess | Variable name similarity across copybooks |
477
+
478
+ Every edge carries two metadata fields:
479
+ - `confidence`: one of the three tiers above
480
+ - `evidence`: source file + line number (or reasoning trace for inferred)
481
+
482
+ Wiki pages and graph views surface confidence visually — `inferred-low` edges
483
+ are rendered as dashed lines with a warning indicator.
484
+
485
+ ### 4. When should summaries be generated automatically versus on demand?
486
+
487
+ **Decision: Deterministic facts auto-generate; business interpretation on demand.**
488
+
489
+ | Category | Generation | Method | Label |
490
+ |-------------------------|------------|---------------|-----------------|
491
+ | Program structure | Automatic | Parser | `deterministic` |
492
+ | Call graph / copy tree | Automatic | Parser | `deterministic` |
493
+ | Variable trace | Automatic | Parser | `deterministic` |
494
+ | Section control flow | Automatic | Parser | `deterministic` |
495
+ | Business purpose | On demand | LLM synthesis | `synthesized` |
496
+ | Migration risk summary | On demand | LLM synthesis | `synthesized` |
497
+
498
+ Auto-generated pages are idempotent — re-running the compiler on the same source
499
+ produces identical output. On-demand summaries are explicitly labeled
500
+ `synthesized` in frontmatter and body, so consumers always know the provenance.
501
+
502
+ ## Decision
503
+
504
+ `Legacy Code Knowledge Compiler` is the preferred vertical wedge for deepening
505
+ `agent-wiki`.
506
+
507
+ The immediate execution strategy is:
508
+
509
+ - stay narrow
510
+ - go deep on COBOL and adjacent runtime artifacts
511
+ - build deterministic cross-artifact knowledge before broadening to more languages
@@ -0,0 +1,120 @@
1
+ # Product Direction
2
+
3
+ ## Summary
4
+
5
+ `agent-wiki` is evolving from a Markdown-based agent memory tool into a
6
+ knowledge compiler for agents: a system that ingests raw source material,
7
+ compiles it into durable knowledge, keeps that knowledge inspectable, and
8
+ surfaces where it is weak, stale, or incomplete.
9
+
10
+ The product should stay grounded in a few core properties:
11
+
12
+ - plain Markdown remains the durable human-readable surface
13
+ - raw sources remain immutable and traceable
14
+ - knowledge pages remain mutable and improvable
15
+ - retrieval should become more explicit about weak evidence and unknowns
16
+ - vertical compilers should deepen the system where generic wiki tooling is weak
17
+
18
+ ## Product Thesis
19
+
20
+ Most agent tooling still treats knowledge as either:
21
+
22
+ - transient context assembled at query time, or
23
+ - a thin notes layer with weak guarantees about provenance and correctness
24
+
25
+ `agent-wiki` should occupy a different position:
26
+
27
+ > a compiler for durable, inspectable, self-improving agent knowledge
28
+
29
+ This means the product is not only a storage surface. It is a pipeline that:
30
+
31
+ 1. ingests source material
32
+ 2. extracts structure
33
+ 3. compiles structured knowledge pages and graphs
34
+ 4. detects gaps, contradictions, and stale regions
35
+ 5. supports grounded retrieval and explicit abstention when evidence is weak
36
+
37
+ ## Current Foundations
38
+
39
+ The current codebase already has the right primitives:
40
+
41
+ - immutable `raw/` source layer with provenance
42
+ - mutable `wiki/` layer with structured Markdown pages
43
+ - `raw_coverage` to expose uncompiled source material
44
+ - `wiki_admin` to detect structural risk signals and rebuild compiled views
45
+ - `knowledge_ingest` to support compile loops without multiplying public tools
46
+ - `wiki_search` plus batched `wiki_read` to move retrieval closer to grounded reading
47
+ - pluggable code analysis with an initial COBOL implementation
48
+ - a standalone graph viewer for live knowledge visualization
49
+
50
+ These are more than utility features. Together they point toward a knowledge
51
+ compilation system rather than a simple note-taking tool.
52
+
53
+ ## Chosen Wedge
54
+
55
+ The preferred near-term wedge is:
56
+
57
+ ## Legacy Code Knowledge Compiler
58
+
59
+ This wedge is attractive because it has:
60
+
61
+ - high pain and high budget
62
+ - messy, fragmented, partially undocumented source material
63
+ - strong need for provenance and impact analysis
64
+ - poor fit for naive LLM summarization or generic RAG
65
+
66
+ The initial focus should be deep, not broad:
67
+
68
+ - start with COBOL
69
+ - then add runtime and batch context such as JCL
70
+ - then add data lineage and impact analysis
71
+
72
+ This wedge is a better path to technical moat than trying to compete as a
73
+ general-purpose knowledge base for every use case at once.
74
+
75
+ ## Why This Wedge Can Create Moat
76
+
77
+ The moat does not come from a single feature like search, graph view, or wiki
78
+ editing. It comes from the combination of:
79
+
80
+ - domain-specific parsers and resolvers
81
+ - stable intermediate knowledge models
82
+ - deterministic graph construction
83
+ - evidence-backed wiki and graph outputs
84
+ - impact analysis over real system structure
85
+ - evaluation corpora and accuracy benchmarks accumulated over time
86
+
87
+ Over time, this can become difficult to replace because each new project
88
+ improves parsing rules, resolution heuristics, lineage logic, and test corpora.
89
+
90
+ ## Non-Goals For Now
91
+
92
+ The near-term goal is not:
93
+
94
+ - becoming a generic IDE replacement
95
+ - optimizing for pretty visualization over grounded knowledge
96
+ - supporting many legacy languages shallowly
97
+ - relying on LLM judgment for core factual extraction
98
+
99
+ The product should prefer deterministic extraction first, agent synthesis second.
100
+
101
+ ## Directional Priorities
102
+
103
+ Near-term priorities:
104
+
105
+ 1. improve retrieval trust signals: weak evidence, abstain, evidence sufficiency
106
+ 2. deepen the compile loop: coverage, freshness, contradiction, next-best work
107
+ 3. build the legacy code compiler wedge around COBOL and adjacent artifacts
108
+ 4. establish evaluation around groundedness and compiler accuracy
109
+
110
+ ## What Success Looks Like
111
+
112
+ Success is not "the agent has a wiki."
113
+
114
+ Success is:
115
+
116
+ - a system can be ingested from raw operational artifacts and source code
117
+ - the resulting knowledge is inspectable and traceable
118
+ - users can ask impact and architecture questions with grounded answers
119
+ - the system knows when its evidence is weak
120
+ - maintenance, migration, and onboarding effort materially decrease