@documentation-robotics/cli 0.1.0 → 0.1.5

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 (510) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +466 -693
  3. package/dist/analysis/data-model-analyzer.js +189 -0
  4. package/dist/analysis/data-model-analyzer.js.map +7 -0
  5. package/dist/analysis/index.js +3 -0
  6. package/dist/analysis/index.js.map +7 -0
  7. package/dist/analysis/relationship-classifier.js +181 -0
  8. package/dist/analysis/relationship-classifier.js.map +7 -0
  9. package/dist/analyzers/base-analyzer.js +1 -0
  10. package/dist/analyzers/base-analyzer.js.map +7 -0
  11. package/dist/analyzers/call-graph-utils.js +39 -0
  12. package/dist/analyzers/call-graph-utils.js.map +7 -0
  13. package/dist/analyzers/cbm-analyzer.js +1205 -0
  14. package/dist/analyzers/cbm-analyzer.js.map +7 -0
  15. package/dist/analyzers/heuristic-utils.js +55 -0
  16. package/dist/analyzers/heuristic-utils.js.map +7 -0
  17. package/dist/analyzers/mapping-loader.js +146 -0
  18. package/dist/analyzers/mapping-loader.js.map +7 -0
  19. package/dist/analyzers/registry.js +124 -0
  20. package/dist/analyzers/registry.js.map +7 -0
  21. package/dist/analyzers/session-state.js +176 -0
  22. package/dist/analyzers/session-state.js.map +7 -0
  23. package/dist/analyzers/stdio-client.js +206 -0
  24. package/dist/analyzers/stdio-client.js.map +7 -0
  25. package/dist/analyzers/types.js +15 -0
  26. package/dist/analyzers/types.js.map +7 -0
  27. package/dist/analyzers/verify-engine.js +209 -0
  28. package/dist/analyzers/verify-engine.js.map +7 -0
  29. package/dist/analyzers/verify-ignore.js +130 -0
  30. package/dist/analyzers/verify-ignore.js.map +7 -0
  31. package/dist/analyzers/version.js +8 -0
  32. package/dist/analyzers/version.js.map +7 -0
  33. package/dist/audit/ai/runner.js +41 -0
  34. package/dist/audit/ai/runner.js.map +7 -0
  35. package/dist/audit/differential-analyzer.js +183 -0
  36. package/dist/audit/differential-analyzer.js.map +7 -0
  37. package/dist/audit/index.js +32 -0
  38. package/dist/audit/index.js.map +7 -0
  39. package/dist/audit/nodes/ai/evaluator.js +49 -0
  40. package/dist/audit/nodes/ai/evaluator.js.map +7 -0
  41. package/dist/audit/nodes/ai/parser.js +55 -0
  42. package/dist/audit/nodes/ai/parser.js.map +7 -0
  43. package/dist/audit/nodes/ai/prompts.js +103 -0
  44. package/dist/audit/nodes/ai/prompts.js.map +7 -0
  45. package/dist/audit/nodes/analysis/node-completeness-checker.js +32 -0
  46. package/dist/audit/nodes/analysis/node-completeness-checker.js.map +7 -0
  47. package/dist/audit/nodes/analysis/node-definition-analyzer.js +47 -0
  48. package/dist/audit/nodes/analysis/node-definition-analyzer.js.map +7 -0
  49. package/dist/audit/nodes/analysis/node-overlap-detector.js +79 -0
  50. package/dist/audit/nodes/analysis/node-overlap-detector.js.map +7 -0
  51. package/dist/audit/nodes/model/orchestrator.js +82 -0
  52. package/dist/audit/nodes/model/orchestrator.js.map +7 -0
  53. package/dist/audit/nodes/spec/loader.js +116 -0
  54. package/dist/audit/nodes/spec/loader.js.map +7 -0
  55. package/dist/audit/nodes/spec/orchestrator.js +68 -0
  56. package/dist/audit/nodes/spec/orchestrator.js.map +7 -0
  57. package/dist/audit/nodes/types.js +1 -0
  58. package/dist/audit/nodes/types.js.map +7 -0
  59. package/dist/audit/pipeline/index.js +5 -0
  60. package/dist/audit/pipeline/index.js.map +7 -0
  61. package/dist/audit/pipeline/pipeline-orchestrator.js +218 -0
  62. package/dist/audit/pipeline/pipeline-orchestrator.js.map +7 -0
  63. package/dist/audit/relationships/ai/evaluator.js +235 -0
  64. package/dist/audit/relationships/ai/evaluator.js.map +7 -0
  65. package/dist/audit/relationships/ai/parser.js +197 -0
  66. package/dist/audit/relationships/ai/parser.js.map +7 -0
  67. package/dist/audit/relationships/ai/prompts.js +274 -0
  68. package/dist/audit/relationships/ai/prompts.js.map +7 -0
  69. package/dist/audit/relationships/analysis/balance-assessor.js +115 -0
  70. package/dist/audit/relationships/analysis/balance-assessor.js.map +7 -0
  71. package/dist/audit/relationships/analysis/coverage-analyzer.js +99 -0
  72. package/dist/audit/relationships/analysis/coverage-analyzer.js.map +7 -0
  73. package/dist/audit/relationships/analysis/duplicate-detector.js +95 -0
  74. package/dist/audit/relationships/analysis/duplicate-detector.js.map +7 -0
  75. package/dist/audit/relationships/analysis/gap-analyzer.js +99 -0
  76. package/dist/audit/relationships/analysis/gap-analyzer.js.map +7 -0
  77. package/dist/audit/relationships/analysis/layer-templates.js +294 -0
  78. package/dist/audit/relationships/analysis/layer-templates.js.map +7 -0
  79. package/dist/audit/relationships/graph/connectivity.js +129 -0
  80. package/dist/audit/relationships/graph/connectivity.js.map +7 -0
  81. package/dist/audit/relationships/graph/relationship-graph.js +179 -0
  82. package/dist/audit/relationships/graph/relationship-graph.js.map +7 -0
  83. package/dist/audit/relationships/model/balance-assessor.js +49 -0
  84. package/dist/audit/relationships/model/balance-assessor.js.map +7 -0
  85. package/dist/audit/relationships/model/coverage-analyzer.js +34 -0
  86. package/dist/audit/relationships/model/coverage-analyzer.js.map +7 -0
  87. package/dist/audit/relationships/model/duplicate-detector.js +68 -0
  88. package/dist/audit/relationships/model/duplicate-detector.js.map +7 -0
  89. package/dist/audit/relationships/model/gap-analyzer.js +41 -0
  90. package/dist/audit/relationships/model/gap-analyzer.js.map +7 -0
  91. package/dist/audit/relationships/model/orchestrator.js +126 -0
  92. package/dist/audit/relationships/model/orchestrator.js.map +7 -0
  93. package/dist/audit/relationships/spec/orchestrator.js +157 -0
  94. package/dist/audit/relationships/spec/orchestrator.js.map +7 -0
  95. package/dist/audit/reports/index.js +5 -0
  96. package/dist/audit/reports/index.js.map +7 -0
  97. package/dist/audit/reports/report-generator.js +118 -0
  98. package/dist/audit/reports/report-generator.js.map +7 -0
  99. package/dist/audit/snapshot-storage.js +163 -0
  100. package/dist/audit/snapshot-storage.js.map +7 -0
  101. package/dist/audit/types.js +21 -0
  102. package/dist/audit/types.js.map +7 -0
  103. package/dist/cli.js +223 -92
  104. package/dist/cli.js.map +3 -3
  105. package/dist/coding-agents/agents/claude-code.js +147 -0
  106. package/dist/coding-agents/agents/claude-code.js.map +7 -0
  107. package/dist/coding-agents/agents/index.js +5 -0
  108. package/dist/coding-agents/agents/index.js.map +7 -0
  109. package/dist/coding-agents/agents/types.js +1 -0
  110. package/dist/coding-agents/agents/types.js.map +7 -0
  111. package/dist/coding-agents/base-chat-client.js +45 -0
  112. package/dist/coding-agents/base-chat-client.js.map +7 -0
  113. package/dist/coding-agents/chat-utils.js +23 -0
  114. package/dist/coding-agents/chat-utils.js.map +7 -0
  115. package/dist/coding-agents/claude-code-client.js +246 -0
  116. package/dist/coding-agents/claude-code-client.js.map +7 -0
  117. package/dist/coding-agents/copilot-client.js +209 -0
  118. package/dist/coding-agents/copilot-client.js.map +7 -0
  119. package/dist/commands/add.js +95 -33
  120. package/dist/commands/add.js.map +2 -2
  121. package/dist/commands/analyzer.js +511 -0
  122. package/dist/commands/analyzer.js.map +7 -0
  123. package/dist/commands/audit-diff.js +49 -0
  124. package/dist/commands/audit-diff.js.map +7 -0
  125. package/dist/commands/audit-snapshots.js +62 -0
  126. package/dist/commands/audit-snapshots.js.map +7 -0
  127. package/dist/commands/audit.js +81 -0
  128. package/dist/commands/audit.js.map +7 -0
  129. package/dist/commands/catalog.js +248 -0
  130. package/dist/commands/catalog.js.map +7 -0
  131. package/dist/commands/changeset.js +577 -66
  132. package/dist/commands/changeset.js.map +2 -2
  133. package/dist/commands/chat.js +106 -83
  134. package/dist/commands/chat.js.map +2 -2
  135. package/dist/commands/claude.js +74 -0
  136. package/dist/commands/claude.js.map +7 -0
  137. package/dist/commands/conformance.js +71 -68
  138. package/dist/commands/conformance.js.map +2 -2
  139. package/dist/commands/copilot.js +75 -0
  140. package/dist/commands/copilot.js.map +7 -0
  141. package/dist/commands/delete.js +125 -11
  142. package/dist/commands/delete.js.map +3 -3
  143. package/dist/commands/discover-logic.js +44 -0
  144. package/dist/commands/discover-logic.js.map +7 -0
  145. package/dist/commands/docs.js +87 -0
  146. package/dist/commands/docs.js.map +7 -0
  147. package/dist/commands/element.js +14 -20
  148. package/dist/commands/element.js.map +2 -2
  149. package/dist/commands/export.js +13 -3
  150. package/dist/commands/export.js.map +2 -2
  151. package/dist/commands/import.js +51 -0
  152. package/dist/commands/import.js.map +7 -0
  153. package/dist/commands/info.js +30 -24
  154. package/dist/commands/info.js.map +2 -2
  155. package/dist/commands/init.js +27 -11
  156. package/dist/commands/init.js.map +2 -2
  157. package/dist/commands/list.js +63 -13
  158. package/dist/commands/list.js.map +3 -3
  159. package/dist/commands/relationship.js +225 -37
  160. package/dist/commands/relationship.js.map +2 -2
  161. package/dist/commands/report.js +54 -0
  162. package/dist/commands/report.js.map +7 -0
  163. package/dist/commands/reports.js +45 -0
  164. package/dist/commands/reports.js.map +7 -0
  165. package/dist/commands/schema.js +135 -0
  166. package/dist/commands/schema.js.map +7 -0
  167. package/dist/commands/search.js +40 -12
  168. package/dist/commands/search.js.map +2 -2
  169. package/dist/commands/show.js +58 -27
  170. package/dist/commands/show.js.map +2 -2
  171. package/dist/commands/stats.js +35 -0
  172. package/dist/commands/stats.js.map +7 -0
  173. package/dist/commands/trace.js +39 -16
  174. package/dist/commands/trace.js.map +2 -2
  175. package/dist/commands/update.js +141 -14
  176. package/dist/commands/update.js.map +2 -2
  177. package/dist/commands/upgrade.js +210 -46
  178. package/dist/commands/upgrade.js.map +3 -3
  179. package/dist/commands/validate.js +142 -23
  180. package/dist/commands/validate.js.map +3 -3
  181. package/dist/commands/version.js +8 -12
  182. package/dist/commands/version.js.map +2 -2
  183. package/dist/commands/visualize.js +155 -25
  184. package/dist/commands/visualize.js.map +2 -2
  185. package/dist/core/base-snapshot-manager.js +84 -0
  186. package/dist/core/base-snapshot-manager.js.map +7 -0
  187. package/dist/core/changeset-exporter.js +305 -0
  188. package/dist/core/changeset-exporter.js.map +7 -0
  189. package/dist/core/changeset-validator.js +41 -0
  190. package/dist/core/changeset-validator.js.map +7 -0
  191. package/dist/core/changeset.js +88 -173
  192. package/dist/core/changeset.js.map +2 -2
  193. package/dist/core/dependency-tracker.js +4 -2
  194. package/dist/core/dependency-tracker.js.map +2 -2
  195. package/dist/core/element.js +98 -27
  196. package/dist/core/element.js.map +2 -2
  197. package/dist/core/golden-copy-cache.js +290 -0
  198. package/dist/core/golden-copy-cache.js.map +7 -0
  199. package/dist/core/graph-model.js +266 -0
  200. package/dist/core/graph-model.js.map +7 -0
  201. package/dist/core/layer.js +159 -16
  202. package/dist/core/layer.js.map +2 -2
  203. package/dist/core/layers.js +32 -0
  204. package/dist/core/layers.js.map +7 -0
  205. package/dist/core/manifest.js +32 -11
  206. package/dist/core/manifest.js.map +2 -2
  207. package/dist/core/migration-registry.js +56 -1
  208. package/dist/core/migration-registry.js.map +2 -2
  209. package/dist/core/model.js +424 -217
  210. package/dist/core/model.js.map +3 -3
  211. package/dist/core/mutation-handler.js +179 -0
  212. package/dist/core/mutation-handler.js.map +7 -0
  213. package/dist/core/reference-registry.js +29 -21
  214. package/dist/core/reference-registry.js.map +2 -2
  215. package/dist/core/relationship-catalog.js +189 -0
  216. package/dist/core/relationship-catalog.js.map +7 -0
  217. package/dist/core/relationship-registry.js.map +2 -2
  218. package/dist/core/relationships.js.map +1 -1
  219. package/dist/core/report-data-model.js +285 -0
  220. package/dist/core/report-data-model.js.map +7 -0
  221. package/dist/core/spec-data-service.js +185 -0
  222. package/dist/core/spec-data-service.js.map +7 -0
  223. package/dist/core/spec-loader-types.js +1 -0
  224. package/dist/core/spec-loader-types.js.map +7 -0
  225. package/dist/core/spec-loader.js +234 -0
  226. package/dist/core/spec-loader.js.map +7 -0
  227. package/dist/core/staged-changeset-storage.js +282 -0
  228. package/dist/core/staged-changeset-storage.js.map +7 -0
  229. package/dist/core/staging-area.js +1002 -0
  230. package/dist/core/staging-area.js.map +7 -0
  231. package/dist/core/stats-collector.js +169 -0
  232. package/dist/core/stats-collector.js.map +7 -0
  233. package/dist/core/virtual-projection.js +443 -0
  234. package/dist/core/virtual-projection.js.map +7 -0
  235. package/dist/export/archimate-exporter.js +99 -60
  236. package/dist/export/archimate-exporter.js.map +2 -2
  237. package/dist/export/audit-formatters.js +479 -0
  238. package/dist/export/audit-formatters.js.map +7 -0
  239. package/dist/export/diff-formatters.js +99 -0
  240. package/dist/export/diff-formatters.js.map +7 -0
  241. package/dist/export/export-manager.js.map +2 -2
  242. package/dist/export/graphml-exporter.js +44 -27
  243. package/dist/export/graphml-exporter.js.map +2 -2
  244. package/dist/export/index.js +4 -0
  245. package/dist/export/index.js.map +2 -2
  246. package/dist/export/json-schema-exporter.js +55 -42
  247. package/dist/export/json-schema-exporter.js.map +2 -2
  248. package/dist/export/markdown-exporter.js +92 -70
  249. package/dist/export/markdown-exporter.js.map +2 -2
  250. package/dist/export/markdown-generator.js +248 -0
  251. package/dist/export/markdown-generator.js.map +7 -0
  252. package/dist/export/markdown-utils.js +30 -0
  253. package/dist/export/markdown-utils.js.map +7 -0
  254. package/dist/export/mermaid-markdown-exporter.js +37 -0
  255. package/dist/export/mermaid-markdown-exporter.js.map +7 -0
  256. package/dist/export/openapi-exporter.js +119 -71
  257. package/dist/export/openapi-exporter.js.map +2 -2
  258. package/dist/export/plantuml-exporter.js +104 -39
  259. package/dist/export/plantuml-exporter.js.map +2 -2
  260. package/dist/export/report-formatters.js +111 -0
  261. package/dist/export/report-formatters.js.map +7 -0
  262. package/dist/export/stats-formatters.js +98 -0
  263. package/dist/export/stats-formatters.js.map +7 -0
  264. package/dist/export/types.js +2 -14
  265. package/dist/export/types.js.map +2 -2
  266. package/dist/export/verify-formatters.js +153 -0
  267. package/dist/export/verify-formatters.js.map +7 -0
  268. package/dist/generated/compiled-validators.js +17 -0
  269. package/dist/generated/compiled-validators.js.map +7 -0
  270. package/dist/generated/index.js +31 -0
  271. package/dist/generated/index.js.map +7 -0
  272. package/dist/generated/layer-registry.js +190 -0
  273. package/dist/generated/layer-registry.js.map +7 -0
  274. package/dist/generated/layer-types.js +7 -0
  275. package/dist/generated/layer-types.js.map +7 -0
  276. package/dist/generated/node-types.js +1719 -0
  277. package/dist/generated/node-types.js.map +7 -0
  278. package/dist/generated/relationship-index.js +14552 -0
  279. package/dist/generated/relationship-index.js.map +7 -0
  280. package/dist/import/archimate-importer.js +166 -0
  281. package/dist/import/archimate-importer.js.map +7 -0
  282. package/dist/import/index.js +47 -0
  283. package/dist/import/index.js.map +7 -0
  284. package/dist/import/openapi-importer.js +143 -0
  285. package/dist/import/openapi-importer.js.map +7 -0
  286. package/dist/import/types.js +1 -0
  287. package/dist/import/types.js.map +7 -0
  288. package/dist/integrations/base-manager.js +311 -0
  289. package/dist/integrations/base-manager.js.map +7 -0
  290. package/dist/integrations/claude-manager.js +360 -0
  291. package/dist/integrations/claude-manager.js.map +7 -0
  292. package/dist/integrations/claude_code/agents/dr-advisor.md +253 -0
  293. package/dist/integrations/claude_code/agents/dr-architect.md +278 -0
  294. package/dist/integrations/claude_code/agents/dr-extractor.md +286 -0
  295. package/dist/integrations/claude_code/commands/dr-changeset.md +657 -0
  296. package/dist/integrations/claude_code/commands/dr-design.md +373 -0
  297. package/dist/integrations/claude_code/commands/dr-info.md +132 -0
  298. package/dist/integrations/claude_code/commands/dr-init.md +251 -0
  299. package/dist/integrations/claude_code/commands/dr-map.md +936 -0
  300. package/dist/integrations/claude_code/commands/dr-model.md +493 -0
  301. package/dist/integrations/claude_code/commands/dr-relate.md +814 -0
  302. package/dist/integrations/claude_code/commands/dr-sync.md +279 -0
  303. package/dist/integrations/claude_code/commands/dr-validate.md +654 -0
  304. package/dist/integrations/claude_code/commands/dr-verify.md +559 -0
  305. package/dist/integrations/claude_code/docs/END_TO_END_WALKTHROUGH.md +903 -0
  306. package/dist/integrations/claude_code/docs/QUICK_START.md +271 -0
  307. package/dist/integrations/claude_code/docs/README.md +347 -0
  308. package/dist/integrations/claude_code/skills/dr_01_motivation_layer/SKILL.md +550 -0
  309. package/dist/integrations/claude_code/skills/dr_02_business_layer/SKILL.md +620 -0
  310. package/dist/integrations/claude_code/skills/dr_03_security_layer/SKILL.md +642 -0
  311. package/dist/integrations/claude_code/skills/dr_04_application_layer/SKILL.md +911 -0
  312. package/dist/integrations/claude_code/skills/dr_05_technology_layer/SKILL.md +836 -0
  313. package/dist/integrations/claude_code/skills/dr_06_api_layer/SKILL.md +933 -0
  314. package/dist/integrations/claude_code/skills/dr_07_data_model_layer/SKILL.md +210 -0
  315. package/dist/integrations/claude_code/skills/dr_08_dataset_layer/SKILL.md +319 -0
  316. package/dist/integrations/claude_code/skills/dr_09_ux_layer/SKILL.md +319 -0
  317. package/dist/integrations/claude_code/skills/dr_10_navigation_layer/SKILL.md +318 -0
  318. package/dist/integrations/claude_code/skills/dr_11_apm_layer/SKILL.md +273 -0
  319. package/dist/integrations/claude_code/skills/dr_12_testing_layer/SKILL.md +273 -0
  320. package/dist/integrations/claude_code/skills/dr_changeset_reviewer/SKILL.md +187 -0
  321. package/dist/integrations/claude_code/skills/dr_codebase_memory/SKILL.md +590 -0
  322. package/dist/integrations/claude_code/skills/dr_engineering_guide/SKILL.md +295 -0
  323. package/dist/integrations/copilot-manager.js +328 -0
  324. package/dist/integrations/copilot-manager.js.map +7 -0
  325. package/dist/integrations/github_copilot/agents/dr-advisor.md +243 -0
  326. package/dist/integrations/github_copilot/agents/dr-architect.md +1567 -0
  327. package/dist/integrations/github_copilot/skills/dr_01_motivation_layer/SKILL.md +491 -0
  328. package/dist/integrations/github_copilot/skills/dr_02_business_layer/SKILL.md +539 -0
  329. package/dist/integrations/github_copilot/skills/dr_03_security_layer/SKILL.md +667 -0
  330. package/dist/integrations/github_copilot/skills/dr_04_application_layer/SKILL.md +670 -0
  331. package/dist/integrations/github_copilot/skills/dr_05_technology_layer/SKILL.md +660 -0
  332. package/dist/integrations/github_copilot/skills/dr_06_api_layer/SKILL.md +855 -0
  333. package/dist/integrations/github_copilot/skills/dr_07_data_model_layer/SKILL.md +171 -0
  334. package/dist/integrations/github_copilot/skills/dr_08_dataset_layer/SKILL.md +216 -0
  335. package/dist/integrations/github_copilot/skills/dr_09_ux_layer/SKILL.md +230 -0
  336. package/dist/integrations/github_copilot/skills/dr_10_navigation_layer/SKILL.md +228 -0
  337. package/dist/integrations/github_copilot/skills/dr_11_apm_layer/SKILL.md +234 -0
  338. package/dist/integrations/github_copilot/skills/dr_12_testing_layer/SKILL.md +230 -0
  339. package/dist/integrations/github_copilot/skills/dr_changeset_reviewer/SKILL.md +187 -0
  340. package/dist/integrations/hash-utils.js +51 -0
  341. package/dist/integrations/hash-utils.js.map +7 -0
  342. package/dist/integrations/types.js +16 -0
  343. package/dist/integrations/types.js.map +7 -0
  344. package/dist/reports/model-layer-report-generator.js +278 -0
  345. package/dist/reports/model-layer-report-generator.js.map +7 -0
  346. package/dist/reports/model-report-data.js +57 -0
  347. package/dist/reports/model-report-data.js.map +7 -0
  348. package/dist/reports/model-report-orchestrator.js +103 -0
  349. package/dist/reports/model-report-orchestrator.js.map +7 -0
  350. package/dist/schemas/bundled/analyzers/cbm.json +595 -0
  351. package/dist/schemas/bundled/analyzers/manifest.json +9 -0
  352. package/dist/schemas/bundled/api.json +3411 -0
  353. package/dist/schemas/bundled/apm.json +2371 -0
  354. package/dist/schemas/bundled/application.json +1253 -0
  355. package/dist/schemas/bundled/base.json +1622 -0
  356. package/dist/schemas/bundled/business.json +1279 -0
  357. package/dist/schemas/bundled/data-model.json +1298 -0
  358. package/dist/schemas/bundled/data-store.json +2025 -0
  359. package/dist/schemas/bundled/manifest.json +93 -0
  360. package/dist/schemas/bundled/motivation.json +1360 -0
  361. package/dist/schemas/bundled/navigation.json +1874 -0
  362. package/dist/schemas/bundled/security.json +3488 -0
  363. package/dist/schemas/bundled/technology.json +2067 -0
  364. package/dist/schemas/bundled/testing.json +3120 -0
  365. package/dist/schemas/bundled/ux.json +3592 -0
  366. package/dist/server/schemas.js +202 -0
  367. package/dist/server/schemas.js.map +7 -0
  368. package/dist/server/server.js +1336 -252
  369. package/dist/server/server.js.map +3 -3
  370. package/dist/server/telemetry-middleware.js +22 -15
  371. package/dist/server/telemetry-middleware.js.map +2 -2
  372. package/dist/server-entry.js +65 -0
  373. package/dist/server-entry.js.map +7 -0
  374. package/dist/telemetry/config.js +89 -0
  375. package/dist/telemetry/config.js.map +7 -0
  376. package/dist/telemetry/console-interceptor.js.map +1 -1
  377. package/dist/telemetry/detect.js +24 -0
  378. package/dist/telemetry/detect.js.map +7 -0
  379. package/dist/telemetry/fetch-otlp-exporter.js +112 -0
  380. package/dist/telemetry/fetch-otlp-exporter.js.map +7 -0
  381. package/dist/telemetry/index.js +153 -3
  382. package/dist/telemetry/index.js.map +2 -2
  383. package/dist/telemetry/resilient-exporter.js +22 -8
  384. package/dist/telemetry/resilient-exporter.js.map +2 -2
  385. package/dist/telemetry/resilient-log-exporter.js +17 -8
  386. package/dist/telemetry/resilient-log-exporter.js.map +2 -2
  387. package/dist/telemetry/test-instrumentation.js.map +2 -2
  388. package/dist/types/index.js +84 -0
  389. package/dist/types/index.js.map +3 -3
  390. package/dist/types/source-reference.js +1 -0
  391. package/dist/types/source-reference.js.map +7 -0
  392. package/dist/utils/chat-logger.js +292 -0
  393. package/dist/utils/chat-logger.js.map +7 -0
  394. package/dist/utils/claude-stream.js +8 -0
  395. package/dist/utils/claude-stream.js.map +7 -0
  396. package/dist/utils/date-utils.js +7 -0
  397. package/dist/utils/date-utils.js.map +7 -0
  398. package/dist/utils/element-utils.js.map +1 -1
  399. package/dist/utils/errors.js +88 -15
  400. package/dist/utils/errors.js.map +3 -3
  401. package/dist/utils/export-python-annotations.js +82 -0
  402. package/dist/utils/export-python-annotations.js.map +7 -0
  403. package/dist/utils/file-io.js +7 -2
  404. package/dist/utils/file-io.js.map +2 -2
  405. package/dist/utils/file-lock.js +156 -0
  406. package/dist/utils/file-lock.js.map +7 -0
  407. package/dist/utils/id-generator.js +18 -0
  408. package/dist/utils/id-generator.js.map +7 -0
  409. package/dist/utils/layer-name-formatter.js +16 -0
  410. package/dist/utils/layer-name-formatter.js.map +7 -0
  411. package/dist/utils/markdown-anchor.js +7 -0
  412. package/dist/utils/markdown-anchor.js.map +7 -0
  413. package/dist/utils/markdown-link.js +12 -0
  414. package/dist/utils/markdown-link.js.map +7 -0
  415. package/dist/utils/markdown-table.js +17 -0
  416. package/dist/utils/markdown-table.js.map +7 -0
  417. package/dist/utils/mermaid-utils.js +11 -0
  418. package/dist/utils/mermaid-utils.js.map +7 -0
  419. package/dist/utils/project-paths.js.map +2 -2
  420. package/dist/utils/source-reference.js +52 -0
  421. package/dist/utils/source-reference.js.map +7 -0
  422. package/dist/utils/spec-installer.js +40 -53
  423. package/dist/utils/spec-installer.js.map +2 -2
  424. package/dist/utils/spec-version.js +5 -1
  425. package/dist/utils/spec-version.js.map +2 -2
  426. package/dist/utils/string-utils.js +12 -0
  427. package/dist/utils/string-utils.js.map +7 -0
  428. package/dist/utils/table-formatting.js +19 -0
  429. package/dist/utils/table-formatting.js.map +7 -0
  430. package/dist/validators/index.js +4 -0
  431. package/dist/validators/index.js.map +2 -2
  432. package/dist/validators/naming-validator.js +20 -23
  433. package/dist/validators/naming-validator.js.map +2 -2
  434. package/dist/validators/reference-validator.js +23 -38
  435. package/dist/validators/reference-validator.js.map +2 -2
  436. package/dist/validators/relationship-schema-validator.js +243 -0
  437. package/dist/validators/relationship-schema-validator.js.map +7 -0
  438. package/dist/validators/schema-validator.js +168 -68
  439. package/dist/validators/schema-validator.js.map +2 -2
  440. package/dist/validators/semantic-validator.js +36 -60
  441. package/dist/validators/semantic-validator.js.map +2 -2
  442. package/dist/validators/types.js.map +2 -2
  443. package/dist/validators/validation-formatter.js +159 -0
  444. package/dist/validators/validation-formatter.js.map +7 -0
  445. package/dist/validators/validator.js +24 -38
  446. package/dist/validators/validator.js.map +2 -2
  447. package/dist/viewer/README.md +139 -0
  448. package/dist/viewer/assets/main-CY0Xufuj.css +1 -0
  449. package/dist/viewer/assets/main-DtgErnwF.js +81 -0
  450. package/dist/viewer/assets/vendor-CxKvDp2x.js +17 -0
  451. package/dist/viewer/favicon.svg +11 -0
  452. package/dist/viewer/fonts/inter/Inter-Black.woff2 +0 -0
  453. package/dist/viewer/fonts/inter/Inter-Bold.woff2 +0 -0
  454. package/dist/viewer/fonts/inter/Inter-ExtraBold.woff2 +0 -0
  455. package/dist/viewer/fonts/inter/Inter-Light.woff2 +0 -0
  456. package/dist/viewer/fonts/inter/Inter-Medium.woff2 +0 -0
  457. package/dist/viewer/fonts/inter/Inter-Regular.woff2 +0 -0
  458. package/dist/viewer/fonts/inter/Inter-SemiBold.woff2 +0 -0
  459. package/dist/viewer/fonts/jetbrains-mono/JetBrainsMono-Medium.woff2 +0 -0
  460. package/dist/viewer/fonts/jetbrains-mono/JetBrainsMono-Regular.woff2 +0 -0
  461. package/dist/viewer/fonts/jetbrains-mono/JetBrainsMono-SemiBold.woff2 +0 -0
  462. package/dist/viewer/index.html +15 -0
  463. package/dist/viewer/manifest.json +99 -0
  464. package/dist/viewer/version.json +1 -0
  465. package/package.json +37 -13
  466. package/PYTHON_CLI_PARITY.md +0 -265
  467. package/PYTHON_CLI_STRUCTURE_UPDATE.md +0 -246
  468. package/biome.json +0 -42
  469. package/bunfig.toml +0 -3
  470. package/dist/ai/claude-client.js +0 -71
  471. package/dist/ai/claude-client.js.map +0 -7
  472. package/dist/ai/context-provider.js +0 -129
  473. package/dist/ai/context-provider.js.map +0 -7
  474. package/dist/ai/tools.js +0 -231
  475. package/dist/ai/tools.js.map +0 -7
  476. package/dist/commands/migrate.js +0 -36
  477. package/dist/commands/migrate.js.map +0 -7
  478. package/dist/commands/project.js +0 -74
  479. package/dist/commands/project.js.map +0 -7
  480. package/dist/core/active-changeset.js +0 -52
  481. package/dist/core/active-changeset.js.map +0 -7
  482. package/dist/core/projection-engine.js +0 -288
  483. package/dist/core/projection-engine.js.map +0 -7
  484. package/dist/schemas/bundled/01-motivation-layer.schema.json +0 -942
  485. package/dist/schemas/bundled/02-business-layer.schema.json +0 -1293
  486. package/dist/schemas/bundled/03-security-layer.schema.json +0 -2177
  487. package/dist/schemas/bundled/04-application-layer.schema.json +0 -1328
  488. package/dist/schemas/bundled/05-technology-layer.schema.json +0 -1465
  489. package/dist/schemas/bundled/06-api-layer.schema.json +0 -1743
  490. package/dist/schemas/bundled/07-data-model-layer.schema.json +0 -1253
  491. package/dist/schemas/bundled/08-datastore-layer.schema.json +0 -892
  492. package/dist/schemas/bundled/09-ux-layer.schema.json +0 -1506
  493. package/dist/schemas/bundled/10-navigation-layer.schema.json +0 -843
  494. package/dist/schemas/bundled/11-apm-observability-layer.schema.json +0 -1430
  495. package/dist/schemas/bundled/12-testing-layer.schema.json +0 -1091
  496. package/dist/schemas/bundled/common/layer-extensions.schema.json +0 -266
  497. package/dist/schemas/bundled/common/predicates.schema.json +0 -493
  498. package/dist/schemas/bundled/common/relationships.schema.json +0 -791
  499. package/dist/schemas/bundled/common/source-references.schema.json +0 -71
  500. package/dist/schemas/bundled/link-registry.json +0 -1839
  501. package/dist/schemas/bundled/link-registry.schema.json +0 -339
  502. package/dist/schemas/bundled/relationship-catalog.json +0 -1302
  503. package/dist/schemas/bundled/relationship-type.schema.json +0 -221
  504. package/dist/utils/model-path.js +0 -22
  505. package/dist/utils/model-path.js.map +0 -7
  506. package/docs/TEST-INSTRUMENTATION.md +0 -405
  507. package/docs/telemetry.md +0 -427
  508. package/test-debug.js +0 -33
  509. package/test-special.mjs +0 -46
  510. package/test_runner.ts +0 -7
@@ -0,0 +1,936 @@
1
+ ---
2
+ description: Analyze an existing codebase and automatically generate a Documentation Robotics architecture model
3
+ argument-hint: "<path> [--layers <layers>] [--tech <technology>] [--recipe | --targeted]"
4
+ ---
5
+
6
+ # Extract Architecture Model from Codebase
7
+
8
+ Analyze an existing codebase and automatically generate a Documentation Robotics architecture model.
9
+
10
+ ## What This Command Does
11
+
12
+ 1. Analyzes code structure (files, directories, imports)
13
+ 2. Identifies architectural elements (services, components, APIs, data)
14
+ 3. Creates corresponding DR model elements across specified layers
15
+ 4. Establishes cross-layer references
16
+ 5. Validates the extracted model
17
+ 6. Provides extraction report with confidence scores
18
+
19
+ ## Two Modes: Recipe vs. Targeted
20
+
21
+ **Recipe Mode** (default for new/empty models): Extracts all 12 layers in a prescribed bottom-up order with validation checkpoints between each layer. Best for building a complete model from scratch — ensures no layers are skipped and lower layers (infrastructure, data) are populated before higher layers (business, motivation) are inferred.
22
+
23
+ **Targeted Mode** (default if `--layers` is specified or model has existing elements): Extracts specific layers without step-by-step checkpoints. Best for focused extraction or incremental additions to an existing model.
24
+
25
+ ## Usage
26
+
27
+ ```
28
+ /dr-map <path> [--layers <layers>] [--tech <technology>]
29
+ ```
30
+
31
+ ## Instructions for Claude Code
32
+
33
+ This command launches a specialized model extraction agent to analyze code and generate the architecture model. Follow this workflow:
34
+
35
+ ### Step 1: Validate Prerequisites
36
+
37
+ Check that a DR model exists:
38
+
39
+ ```bash
40
+ ls -la documentation-robotics/model/manifest.yaml 2>/dev/null
41
+ ```
42
+
43
+ If no model exists:
44
+
45
+ - Inform user: "No DR model found. Initialize one first?"
46
+ - Offer to run: `/dr-init <project-name>`
47
+ - Wait for model creation before continuing
48
+
49
+ Also check if the model is empty (no elements yet) and no `--layers` flag was provided:
50
+
51
+ ```bash
52
+ dr list motivation --json 2>/dev/null
53
+ ```
54
+
55
+ If model has 0 elements and no `--layers` flag: offer **Recipe Mode** vs. **Targeted Mode**.
56
+
57
+ ```
58
+ I see this is a new model with no existing elements.
59
+
60
+ I can extract in two ways:
61
+
62
+ 1. Recipe Mode (recommended) — Walks through all 12 layers in the correct
63
+ architectural order, with checkpoints to review and validate each layer
64
+ before proceeding. Takes longer but produces a complete, well-structured model.
65
+
66
+ 2. Targeted Mode — Extract specific layers only.
67
+ Which layers would you like? (e.g., application, api, data-model)
68
+
69
+ Which would you prefer?
70
+ ```
71
+
72
+ If user selects Recipe Mode: follow the **Recipe Mode Workflow** section below.
73
+ If user selects Targeted Mode or `--layers` is specified: continue to Step 2.
74
+
75
+ ---
76
+
77
+ ### Recipe Mode Workflow
78
+
79
+ In recipe mode, extract all layers in the prescribed bottom-up order. The ordering ensures infrastructure and data layers are populated before business and motivation layers are inferred from them. Each layer is extracted, validated, and reviewed before proceeding to the next.
80
+
81
+ **Prescribed Extraction Order:**
82
+
83
+ | Order | Layer | What to Detect |
84
+ | ----- | --------------- | ---------------------------------------------------------------------------------------------- |
85
+ | 1 | Technology (5) | Frameworks, platforms, infra deps (package.json, requirements.txt, Dockerfiles, K8s manifests) |
86
+ | 2 | Data Store (8) | DB schemas, tables, migrations (.sql files, migration scripts, ORM table configs) |
87
+ | 3 | Data Model (7) | Entity classes, JSON schemas, type defs (ORM models, Pydantic, TypeScript interfaces) |
88
+ | 4 | Application (4) | Services, components, orchestrators (@Service classes, business logic modules) |
89
+ | 5 | API (6) | REST endpoints, OpenAPI specs, route handlers (@route decorators, router files) |
90
+ | 6 | UX (9) | UI components, screens, forms — skip automatically if no frontend detected |
91
+ | 7 | Navigation (10) | Routing, menu structures — skip automatically if no frontend detected |
92
+ | 8 | APM (11) | Monitoring instrumentation, metrics, spans (OpenTelemetry, Datadog, custom metrics) |
93
+ | 9 | Testing (12) | Test files, strategies, coverage patterns (_.test._, _.spec._, test directories) |
94
+ | 10 | Business (2) | Infer from application services + domain naming patterns |
95
+ | 11 | Security (3) | Auth patterns, RBAC, middleware (auth middleware, policy files, permission decorators) |
96
+ | 12 | Motivation (1) | Infer from README, docs/, comments, OKR references |
97
+
98
+ **Prerequisite checks before specific layers:**
99
+
100
+ - **Before API (6)**: If Application layer has no services yet, warn: "API operations typically expose application services. Proceeding without application services may result in incomplete cross-layer references."
101
+ - **Before Business (2)**: If Application layer has fewer than 3 services, warn: "Business services are inferred from application services. Consider adding more application services first for better coverage."
102
+ - **Before Motivation (1)**: Scan README.md and docs/ before extracting — "Checking README.md and docs/ for goals, principles, and requirements..."
103
+
104
+ **Between-layer checkpoint (repeat after each layer):**
105
+
106
+ After extracting each layer:
107
+
108
+ 1. **Wire intra-layer relationships** for elements just created in this layer:
109
+ - Run `dr relationship add` for element pairs within this layer that are semantically connected
110
+ - Use shared `source_file` as the primary signal for high-confidence pairs
111
+ - Only attempt relationship schema combinations that are valid per `dr schema relationship <type>`
112
+ - Aim to wire at least the highest-confidence pairs before moving on
113
+
114
+ 2. **Wire cross-layer references to already-populated lower layers** (if applicable):
115
+ - If a just-extracted element references a type that already exists in a lower layer, wire it now
116
+ - Example: when extracting API layer, wire `api.operation →[references]→ application.applicationservice` for elements already in the Application layer
117
+ - This eliminates a significant portion of the inter-layer pass in `/dr-relate`
118
+
119
+ 3. **Pause and display checkpoint:**
120
+
121
+ ```
122
+ Checkpoint: [Layer Name] Layer Complete
123
+ ==========================================
124
+ Extracted N elements:
125
+ - [element-id-1] (from [source-file:line])
126
+ - [element-id-2] (from [source-file:line])
127
+ ...
128
+
129
+ Validation: ✓ Passed
130
+ — or —
131
+ ⚠ N warnings, M errors: [brief description]
132
+
133
+ What would you like to do?
134
+ [c] Continue to next layer ([Next Layer Name])
135
+ [a] Add a missing element (describe it and I'll create it)
136
+ [s] Skip to a specific layer
137
+ [r] Re-extract this layer with different parameters
138
+ [q] Finish here (model saved, resume later with /dr-map)
139
+ ```
140
+
141
+ **After completing all layers:**
142
+
143
+ ```
144
+ Recipe Extraction Complete!
145
+ ============================
146
+ [layer list with element counts and status]
147
+
148
+ Total: N elements across M layers
149
+ ```
150
+
151
+ Proceed immediately to Steps 6–6c (validation → connectivity → code alignment → synthesis). Do not prompt the user for next steps here — the completion protocol handles that.
152
+
153
+ ---
154
+
155
+ ### Step 2: Gather Information
156
+
157
+ **Required:**
158
+
159
+ - **Path**: Directory to analyze (provided by user or current directory)
160
+
161
+ **Optional:**
162
+
163
+ - **Layers**: Which layers to extract (default: business, application, api, data-model)
164
+ - **Technology**: Tech stack hints (e.g., "Python FastAPI", "Node.js Express", "Java Spring")
165
+
166
+ **Examples:**
167
+
168
+ ```
169
+ /dr-map ./src
170
+ /dr-map ./src/api --layers application,api
171
+ /dr-map ./backend --tech "Python FastAPI PostgreSQL"
172
+ ```
173
+
174
+ If user didn't specify layers or tech, ask:
175
+
176
+ ```
177
+ I'll analyze the codebase at ./src
178
+
179
+ Quick questions:
180
+ 1. Which layers should I extract?
181
+ - All relevant (recommended)
182
+ - Specific layers: business, application, api, data-model, etc.
183
+
184
+ 2. Technology stack (optional, helps with analysis):
185
+ - Auto-detect
186
+ - Manual: e.g., "Python FastAPI, PostgreSQL, Redis"
187
+ ```
188
+
189
+ ### Step 3: Preliminary Code Analysis
190
+
191
+ Before launching the full extraction agent, do a quick scan:
192
+
193
+ ```bash
194
+ # Detect languages
195
+ find <path> -type f -name "*.py" -o -name "*.js" -o -name "*.ts" -o -name "*.java" -o -name "*.go" | head -20
196
+
197
+ # Check for common files
198
+ ls -la <path> | grep -E "(package\.json|requirements\.txt|pom\.xml|go\.mod|Cargo\.toml)"
199
+
200
+ # Look for API definitions
201
+ find <path> -type f -name "*api*" -o -name "*route*" -o -name "*controller*" | head -10
202
+
203
+ # Check for database files
204
+ find <path> -type f -name "*model*" -o -name "*schema*" -o -name "*.sql" | head -10
205
+
206
+ # Detect graph visualization libraries (React Flow, Cytoscape, D3, etc.)
207
+ grep -l "@xyflow\|react-flow\|d3\|cytoscape\|vis-network" <path>/package.json 2>/dev/null
208
+
209
+ # If React Flow detected, expand scan to include graph subsystem directories:
210
+ find <path>/src/core/nodes -type f -name "*.tsx" 2>/dev/null | head -20
211
+ find <path>/src/core/edges -type f -name "*.tsx" 2>/dev/null | head -10
212
+ find <path>/src/core/layout -type f 2>/dev/null | head -10
213
+ ls <path>/src/core/nodes/nodeConfig.json 2>/dev/null
214
+ ```
215
+
216
+ Show user what you found:
217
+
218
+ ```
219
+ Preliminary scan of ./src:
220
+
221
+ Detected:
222
+ ✓ Language: Python (45 .py files)
223
+ ✓ Framework: FastAPI (found fastapi imports)
224
+ ✓ API: 8 route files detected
225
+ ✓ Database: SQLAlchemy models found (12 files)
226
+ ✓ Tests: npm test structure detected
227
+
228
+ [If React Flow detected, also show:]
229
+ ✓ Graph Visualization: React Flow detected (@xyflow/react)
230
+ → Will scan src/core/nodes/ for custom node types
231
+ → Will scan src/core/edges/ for custom edge types
232
+ → Will scan src/core/layout/ for layout engines
233
+ → Will check for nodeConfig.json configuration registry
234
+
235
+ Estimated extraction:
236
+ - Business services: ~5
237
+ - Application services: ~8
238
+ - API operations: ~35
239
+ - Data models: ~12
240
+
241
+ This will take approximately 2-3 minutes.
242
+ Proceed with extraction?
243
+ ```
244
+
245
+ ### Check Analyzer Availability
246
+
247
+ The extraction workflow can consult the dr-analyzer if one is installed and active.
248
+
249
+ **Check analyzer status:**
250
+
251
+ Run the following command and save the result (it will guide the extraction agent):
252
+
253
+ ```bash
254
+ dr analyzer status --json 2>/dev/null
255
+ ```
256
+
257
+ **If analyzer is active and indexed:**
258
+
259
+ Fetch all three pre-briefs to temporary files:
260
+
261
+ ```bash
262
+ dr analyzer endpoints --json > /tmp/dr-analyzer-endpoints.json 2>/dev/null
263
+ dr analyzer services --json --layer application > /tmp/dr-analyzer-services.json 2>/dev/null
264
+ dr analyzer datastores --json > /tmp/dr-analyzer-datastores.json 2>/dev/null
265
+ ```
266
+
267
+ Inform user:
268
+
269
+ ```
270
+ ✓ Analyzer is active and indexed
271
+ → Endpoints summary saved for extraction
272
+ → Services summary saved for extraction
273
+ → Datastores summary saved for extraction
274
+ → Extraction will cross-reference these for high-confidence mappings
275
+ ```
276
+
277
+ **If analyzer is installed but not indexed:**
278
+
279
+ Show:
280
+
281
+ ```
282
+ ⚠ Analyzer is installed but has not indexed the codebase yet.
283
+
284
+ Option 1: Index the codebase now (recommended for better extraction)
285
+ Run: dr analyzer index
286
+
287
+ Option 2: Continue without analyzer (uses code inspection only)
288
+ Proceed with /dr-map
289
+ ```
290
+
291
+ Ask user: "Would you like to run `dr analyzer index` now? (Y/n)"
292
+
293
+ If yes: Run `dr analyzer index` and proceed to fetch pre-briefs (as above).
294
+ If no: Continue to Step 4 without pre-briefs (pre-brief files will be marked 'not available').
295
+
296
+ **If no analyzer is installed:**
297
+
298
+ Show once:
299
+
300
+ ```
301
+ ℹ Extraction will use code inspection only.
302
+
303
+ Tip: Installing an analyzer like codebase-memory-mcp would add graph-based evidence
304
+ for more confident mappings. See `dr analyzer discover` for setup options.
305
+ ```
306
+
307
+ Continue to Step 4 (no blocking).
308
+
309
+ ### Step 3b: Capture Baseline Element Counts
310
+
311
+ **Before launching any extraction**, record the current element count per layer. This is the authoritative "before" snapshot — do this now, not inside the extraction agent, to avoid counting elements added mid-execution.
312
+
313
+ ```bash
314
+ dr list --json 2>/dev/null | jq -r 'group_by(.layer) | map("\(.[0].layer): \(length)") | .[]'
315
+ ```
316
+
317
+ Store the output as `BASELINE_COUNTS`. Pass it verbatim into the extraction agent's prompt so the final summary report can display accurate Before / After / Net-new columns.
318
+
319
+ ---
320
+
321
+ ### Step 4: Launch Extraction Agent
322
+
323
+ Use the Task tool to launch the specialized extraction agent:
324
+
325
+ ````python
326
+ Task(
327
+ subagent_type="dr-architect",
328
+ prompt=f"""Extract Documentation Robotics model from codebase.
329
+
330
+ **Source Path:** {path}
331
+ **Target Layers:** {layers}
332
+ **Technology:** {technology}
333
+ **Baseline Element Counts (captured before extraction):** {baseline_counts}
334
+
335
+ **Analyzer Pre-Brief (if available):**
336
+
337
+ If the analyzer was active during Step 3, the following files contain pre-analysis summaries:
338
+ - Endpoints: /tmp/dr-analyzer-endpoints.json (if file exists, use it; otherwise 'not available')
339
+ - Services: /tmp/dr-analyzer-services.json (if file exists, use it; otherwise 'not available')
340
+ - Datastores: /tmp/dr-analyzer-datastores.json (if file exists, use it; otherwise 'not available')
341
+
342
+ **How to use the pre-briefs:**
343
+
344
+ 1. **Endpoints Checklist (High Confidence):** Treat the endpoints summary as an authoritative checklist for the API layer. Each candidate endpoint in the brief must either:
345
+ - Produce a corresponding `api.operation` element you create, OR
346
+ - Include a documented rejection reason if it should be skipped (e.g., "internal utility, not a user-facing operation")
347
+
348
+ 2. **Services and Datastores (Suggestions):** Use the services and datastores summaries as suggestions, but rely on code inspection as your primary signal. Verify each candidate against actual code before creating elements.
349
+
350
+ 3. **Source Preservation:** For all elements you create from analyzer pre-briefs, **preserve the exact `source_file` and `source_symbol` values** from the brief in your `dr add` commands. Use `source_start_line` as navigational context to locate the correct part of the file, but do not pass it as a CLI flag (no `--source-start-line` parameter exists). These source file and symbol fields are mandatory for traceability.
351
+
352
+ **Your Task:**
353
+ 1. Analyze the codebase structure
354
+ 2. Identify architectural elements:
355
+ - Services and components
356
+ - API endpoints and operations
357
+ - Data models and schemas
358
+ - Database tables (if applicable)
359
+ - Business capabilities (infer from code)
360
+
361
+ 3. Create DR model elements with **mandatory source provenance**:
362
+ - Use `dr add` commands for each element
363
+ - **Always** pass `--source-file <relative-path>` pointing to the file the element was extracted from (relative to the repository root, e.g. `src/services/OrderService.ts`)
364
+ - Pass `--source-symbol <name>` when the element maps to a specific class, function, or exported symbol
365
+ - Pass `--source-provenance extracted` for all elements identified directly from code; use `inferred` for elements reasoned from patterns rather than a specific file
366
+ - Establish cross-layer references (realizes, exposes, stores, etc.)
367
+ - Set appropriate properties (criticality, descriptions, etc.)
368
+
369
+ Source provenance is not optional metadata — it is the traceability link that makes the model useful:
370
+ - `/dr-sync` uses `source_reference` to detect drift when code changes
371
+ - `dr validate` can verify referenced files still exist
372
+ - Without provenance, the model is a snapshot with no connection back to the code that produced it
373
+
374
+ Example `dr add` invocations with provenance:
375
+ ```bash
376
+ dr add application service "Order Service" \
377
+ --description "Handles order lifecycle" \
378
+ --source-file "src/services/OrderService.ts" \
379
+ --source-symbol "OrderService" \
380
+ --source-provenance extracted
381
+
382
+ dr add api operation "Create Order" \
383
+ --description "POST /api/v1/orders" \
384
+ --source-file "src/routes/orders.ts" \
385
+ --source-symbol "createOrder" \
386
+ --source-provenance extracted
387
+
388
+ dr add business capability "Order Management" \
389
+ --description "Inferred from OrderService and order routes" \
390
+ --source-provenance inferred
391
+ ````
392
+
393
+ 4. Validate the extracted model:
394
+ - Run `dr validate` after extraction
395
+ - Fix any obvious issues
396
+
397
+ 5. Provide extraction report:
398
+ - Elements created per layer
399
+ - Source files referenced (list unique files)
400
+ - Confidence scores (high/medium/low)
401
+ - Warnings about uncertain mappings or missing provenance
402
+ - Recommendations for manual review
403
+
404
+ **Analysis Guidelines:**
405
+
406
+ For Business Layer:
407
+
408
+ - Infer business services from high-level modules/packages
409
+ - Look for domain concepts in naming
410
+ - Group related functionality
411
+
412
+ For Application Layer:
413
+
414
+ - Map classes/modules to components
415
+ - Services exposed via APIs become application services
416
+ - Set criticality based on usage patterns
417
+
418
+ For API Layer:
419
+
420
+ - Extract REST/GraphQL endpoints
421
+ - Map HTTP methods to operations
422
+ - Extract request/response schemas
423
+
424
+ For Data Model Layer:
425
+
426
+ - Parse ORM models (SQLAlchemy, TypeORM, JPA, etc.)
427
+ - Extract JSON schemas if present
428
+ - Document relationships
429
+
430
+ For React Flow Applications (when `@xyflow/react` detected in package.json):
431
+
432
+ - Scan `src/core/nodes/` or similar for custom node components → `ux.librarycomponent` (type: graph-node)
433
+ - Look for a unified/shared node component that is configuration-driven → single `ux.librarycomponent` entry (do NOT create one per node type)
434
+ - Scan `src/core/edges/` for custom edge types → `ux.librarycomponent` (type: graph-edge)
435
+ - Scan `src/core/layout/engines/` for LayoutEngine class implementations → `application.applicationcomponent` (type: internal)
436
+ - Look for standalone layout utility files (e.g., `verticalLayerLayout.ts`) → `application.applicationfunction`
437
+ - Check for `nodeConfig.json` or similar configuration registry → `data-model.objectschema`
438
+
439
+ **Output Format:**
440
+
441
+ Provide a detailed report:
442
+
443
+ ```
444
+
445
+ # Extraction Complete
446
+
447
+ Summary:
448
+
449
+ - Business services: X created
450
+ - Application services: Y created
451
+ - API operations: Z created
452
+ - Data models: N created
453
+
454
+ Details by Layer:
455
+ [... detailed breakdown ...]
456
+
457
+ Confidence Assessment:
458
+
459
+ - High confidence: X% of elements
460
+ - Medium confidence: Y% of elements
461
+ - Low confidence: Z% of elements
462
+
463
+ Validation Results:
464
+ [... validation output ...]
465
+
466
+ Recommendations:
467
+
468
+ 1. Review low-confidence mappings
469
+ 2. Add business goal references
470
+ 3. Consider adding security policies
471
+ [... more recommendations ...]
472
+
473
+ ```
474
+
475
+ **Important:**
476
+
477
+ - Create realistic, meaningful descriptions
478
+ - Use proper kebab-case for IDs
479
+ - **Every `dr add` call must include `--source-file` and `--source-provenance`** — elements without provenance are untraceable and will fail the `source_files_exist` assertion in the test suite
480
+ - Establish cross-layer references where clear
481
+ - Flag uncertain mappings for review
482
+ - Run validation and fix obvious errors
483
+ """
484
+ )
485
+
486
+ ````
487
+
488
+ ### Step 5: Process Agent Results
489
+
490
+ When the agent completes, read the current element counts (the "after" state) and display the report. Use `BASELINE_COUNTS` (captured in Step 3b) for the Before column — do NOT re-derive it from within the agent's output, which may reflect an intermediate state.
491
+
492
+ ```bash
493
+ dr list --json 2>/dev/null | jq -r 'group_by(.layer) | map("\(.[0].layer): \(length)") | .[]'
494
+ ````
495
+
496
+ ```
497
+
498
+ # Extraction Complete
499
+
500
+ Created Elements (Before → After, Net-new):
501
+ ├─ Business Layer: N → M (+X services)
502
+ ├─ Application Layer: N → M (+X services, +Y components)
503
+ ├─ API Layer: N → M (+X operations)
504
+ └─ Data Model Layer: N → M (+X schemas)
505
+
506
+ Cross-Layer References:
507
+ ✓ 8 realizes references (app → business)
508
+ ✓ 35 exposes references (app → api)
509
+ ✓ 12 stores references (data-store → data model)
510
+
511
+ Connectivity: [orphan count reported automatically in Step 6b]
512
+
513
+ Validation: ⚠️ 2 warnings, 0 errors
514
+
515
+ Confidence:
516
+ ✓ High: 85% (very confident in these mappings)
517
+ ⚠ Medium: 12% (review recommended)
518
+ ❌ Low: 3% (manual review needed)
519
+
520
+ Files Modified:
521
+
522
+ - documentation-robotics/model/02_business/services.yaml (3 elements)
523
+ - documentation-robotics/model/04_application/services.yaml (8 elements)
524
+ - documentation-robotics/model/04_application/components.yaml (3 elements)
525
+ - documentation-robotics/model/06_api/operations.yaml (25 elements)
526
+ - documentation-robotics/model/07_data-model/schemas.yaml (12 elements)
527
+
528
+ ```
529
+
530
+ ### Step 6: Schema Validation
531
+
532
+ Run strict schema validation:
533
+
534
+ ```bash
535
+ dr validate --strict
536
+ ```
537
+
538
+ **If there are schema errors:** Stop. Report them, fix them, and re-validate before proceeding. Do not move to Step 6b until errors are 0.
539
+
540
+ **If only warnings:** Note them — they will appear in the Step 6c synthesis — and continue. Do not ask the user to address warnings now.
541
+
542
+ ```
543
+ Schema Validation
544
+ =================
545
+ ✓ 0 errors, 2 warnings
546
+ ⚠ application.service.order-service — no security policy assigned
547
+ ⚠ application.service.payment-service — critical service, no monitoring
548
+ ```
549
+
550
+ ### Step 6b: Connectivity — Wire Orphans
551
+
552
+ Check which extracted elements are not yet connected to the rest of the model:
553
+
554
+ ```bash
555
+ dr validate --orphans
556
+ ```
557
+
558
+ Parse the output. Report the count and layer breakdown:
559
+
560
+ ```
561
+ Connectivity
562
+ ============
563
+ 8 orphaned elements (not yet wired):
564
+ api (5 orphans): 4 connectable, 1 dead-end
565
+ application (2 orphans): 2 connectable
566
+ business (1 orphan): 1 connectable
567
+ ```
568
+
569
+ **If connectable orphans exist**, run the `/dr-relate --orphans` workflow inline immediately — do not ask the user first. Follow the `/dr-relate` instructions for orphan mode: work through connectable orphans layer by layer, skip dead-ends, re-validate at the end.
570
+
571
+ After wiring, re-run `dr validate --orphans` and report the final state:
572
+
573
+ ```
574
+ Connectivity (after wiring)
575
+ ===========================
576
+ ✓ 7 orphans wired
577
+ 1 dead-end remaining: api.info.x (needs: api.contact, api.license)
578
+ ```
579
+
580
+ **If no orphans:** Report "✓ All elements connected" and proceed.
581
+
582
+ ### Step 6c: Code Alignment (External Grounding)
583
+
584
+ Check whether an analyzer is available — **regardless of whether it was used during extraction**:
585
+
586
+ ```bash
587
+ dr analyzer status 2>/dev/null
588
+ ```
589
+
590
+ **If an analyzer is available and indexed**, run a cross-model verification across all extracted layers:
591
+
592
+ ```bash
593
+ dr analyzer verify --json 2>/dev/null
594
+ ```
595
+
596
+ Parse the JSON output and present the three-bucket summary:
597
+
598
+ ```
599
+ Code Alignment Assessment
600
+ =========================
601
+ Source: codebase-memory (indexed 6 minutes ago)
602
+
603
+ ✓ matched (in model + in code): 38 elements
604
+ ⚠ model-only (in model, not in code): 2 elements ← review for drift
605
+ ? graph-only (in code, not in model): 7 elements ← suspected gaps
606
+
607
+ Gaps by layer:
608
+ api (5): POST /orders/bulk, DELETE /orders/{id}, GET /orders/export, ...
609
+ application (1): OrderBatchProcessor
610
+ data-store (1): order_audit_log table
611
+
612
+ Run /dr-verify to review and resolve each gap interactively.
613
+ ```
614
+
615
+ **If no analyzer is available:** Skip this step silently.
616
+
617
+ ### Step 6d: Completion Synthesis
618
+
619
+ Produce a single unified summary that consolidates Steps 6–6c:
620
+
621
+ ```
622
+ /dr-map Complete
623
+ ================
624
+ Extracted: 74 elements across 9 layers
625
+ Relationships: 142 wired | 1 dead-end orphan remaining
626
+ Code coverage: 38/45 confirmed by analyzer (84%) | 7 gaps detected
627
+
628
+ What needs attention:
629
+ ? 7 elements in code not yet in model → run /dr-verify to process
630
+ ! 1 dead-end orphan (api.info.x) → needs api.contact or api.license to wire
631
+ ⚠ 2 semantic warnings → held for enhancement step below
632
+ ```
633
+
634
+ Omit the "Code coverage" line if no analyzer was available. Omit "What needs attention" if the model is fully clean.
635
+
636
+ ### Step 7: Post-Extraction Enhancements
637
+
638
+ After the structural assessment above is complete, offer targeted enhancements based on what was found. Only offer an enhancement if the relevant signal was actually seen during extraction.
639
+
640
+ **If critical or public services exist without security policies:**
641
+
642
+ ```
643
+ ⚠ 2 services lack security policies.
644
+ Add authentication schemes now? (OAuth2 for public APIs, JWT for internal)
645
+ [Y/N]
646
+ ```
647
+
648
+ **If critical services exist without APM coverage:**
649
+
650
+ ```
651
+ ⚠ 1 critical service has no monitoring.
652
+ Add standard APM metrics? (availability, latency P95, error rate)
653
+ [Y/N]
654
+ ```
655
+
656
+ **If motivation layer is empty or thin (< 3 elements):**
657
+
658
+ ```
659
+ The motivation layer has few elements — business goals were hard to infer.
660
+ Add goals manually with /dr-model, or skip for now?
661
+ [M]anual [S]kip
662
+ ```
663
+
664
+ ## Analysis Patterns by Technology
665
+
666
+ ### Python FastAPI
667
+
668
+ **Look for:**
669
+
670
+ - `@app.get/post/put/delete` decorators → API operations
671
+ - `class Model(Base)` → Data models (SQLAlchemy)
672
+ - `class Service` → Application services
673
+ - `pydantic.BaseModel` → Request/response schemas
674
+
675
+ **Example extraction:**
676
+
677
+ ```python
678
+ # In routes/orders.py
679
+ @app.post("/api/v1/orders")
680
+ def create_order(order: OrderCreate):
681
+ return order_service.create(order)
682
+
683
+ # Extracts to:
684
+ # - api.operation.create-order (path: /api/v1/orders, method: POST)
685
+ # - application.service.order-service (if referenced)
686
+ # - data-model.objectschema.order-create (from Pydantic model)
687
+ ```
688
+
689
+ ### Node.js Express
690
+
691
+ **Look for:**
692
+
693
+ - `router.get/post/put/delete()` → API operations
694
+ - `class Service` or exported functions → Application services
695
+ - `mongoose.Schema` or TypeORM entities → Data models
696
+ - `export interface` → Type definitions
697
+
698
+ **Example extraction:**
699
+
700
+ ```typescript
701
+ // In routes/orders.ts
702
+ router.post('/api/v1/orders', async (req, res) => {
703
+ const order = await OrderService.create(req.body);
704
+ res.json(order);
705
+ });
706
+
707
+ // Extracts to:
708
+ # - api.operation.create-order
709
+ # - application.service.order-service
710
+ ```
711
+
712
+ ### Java Spring Boot
713
+
714
+ **Look for:**
715
+
716
+ - `@RestController` classes → Application services + API operations
717
+ - `@Service` classes → Application services
718
+ - `@Entity` classes → Data models
719
+ - `@Table` annotations → Database tables
720
+
721
+ **Example extraction:**
722
+
723
+ ```java
724
+ @RestController
725
+ @RequestMapping("/api/v1/orders")
726
+ public class OrderController {
727
+ @PostMapping
728
+ public Order createOrder(@RequestBody OrderRequest request) {
729
+ return orderService.create(request);
730
+ }
731
+ }
732
+
733
+ // Extracts to:
734
+ # - api.operation.create-order
735
+ # - application.service.order-controller
736
+ # - data-model.objectschema.order-request
737
+ ```
738
+
739
+ ## Handling Edge Cases
740
+
741
+ ### Large Codebases (>100 files)
742
+
743
+ ```
744
+ This is a large codebase (500+ files).
745
+
746
+ Options:
747
+ 1. Extract all (may take 5-10 minutes)
748
+ 2. Extract specific directories:
749
+ - ./src/api → API layer only
750
+ - ./src/services → Application layer
751
+ - ./src/models → Data model layer
752
+ 3. Extract incrementally (one layer at a time)
753
+
754
+ Which approach?
755
+ ```
756
+
757
+ ### Monorepo
758
+
759
+ ```
760
+ Detected monorepo structure:
761
+
762
+ packages/
763
+ ├── api/
764
+ ├── web/
765
+ ├── mobile/
766
+ └── shared/
767
+
768
+ Should I:
769
+ 1. Extract entire monorepo
770
+ 2. Extract specific package(s)
771
+ 3. Create separate models per package
772
+ ```
773
+
774
+ ### Missing Information
775
+
776
+ ```
777
+ Extraction complete with gaps:
778
+
779
+ Could not determine:
780
+ ❌ Business capabilities (no clear domain structure)
781
+ ❌ Service criticality (no indicators found)
782
+ ❌ Security requirements (no auth code found)
783
+
784
+ Recommendations:
785
+ 1. Manually add business services: /dr-model
786
+ 2. Review and set criticality levels
787
+ 3. Add security policies for public endpoints
788
+ ```
789
+
790
+ ### Conflicting Patterns
791
+
792
+ ```
793
+ Found conflicting patterns:
794
+
795
+ Issue: Multiple services named "OrderService"
796
+ - src/api/orders/service.py (REST API)
797
+ - src/jobs/order_processor.py (Background job)
798
+ - src/admin/order_admin.py (Admin interface)
799
+
800
+ Created as:
801
+ - application.service.order-api
802
+ - application.service.order-processor
803
+ - application.service.order-admin
804
+
805
+ Please review and adjust if needed.
806
+ ```
807
+
808
+ ## Error Handling
809
+
810
+ ### Error: Path not found
811
+
812
+ ```
813
+ Error: Directory ./src not found
814
+
815
+ Please check the path and try again:
816
+ /dr-map <correct-path>
817
+ ```
818
+
819
+ ### Error: No code files found
820
+
821
+ ```
822
+ Warning: No recognizable code files found in ./src
823
+
824
+ Supported languages:
825
+ - Python (.py)
826
+ - JavaScript/TypeScript (.js, .ts)
827
+ - Java (.java)
828
+ - Go (.go)
829
+ - C# (.cs)
830
+
831
+ Is this the correct directory?
832
+ ```
833
+
834
+ ### Error: Extraction failed
835
+
836
+ ```
837
+ Error: Extraction agent encountered an error
838
+
839
+ Last successful step: Analyzed 45 files
840
+ Issue: [error details]
841
+
842
+ Options:
843
+ 1. Retry extraction
844
+ 2. Extract specific layer only
845
+ 3. Manual extraction with /dr-model
846
+ ```
847
+
848
+ ## Example Interactions
849
+
850
+ ### Example 1: Simple Extraction
851
+
852
+ ```
853
+ User: /dr-map ./src/api
854
+
855
+ You:
856
+ Scanning ./src/api...
857
+
858
+ Found:
859
+ - Python FastAPI application
860
+ - 8 route files
861
+ - 25 endpoints
862
+ - 12 Pydantic models
863
+
864
+ Launching extraction agent...
865
+
866
+ [Agent runs...]
867
+
868
+ ✓ Extraction complete!
869
+
870
+ Created:
871
+ - 8 application services
872
+ - 25 API operations
873
+ - 12 data models
874
+
875
+ Validation: ✓ Passed
876
+
877
+ Next: Review documentation-robotics/model/04_application/ and documentation-robotics/model/06_api/
878
+ ```
879
+
880
+ ### Example 2: With Technology Hints
881
+
882
+ ```
883
+ User: /dr-map ./backend --tech "Python FastAPI PostgreSQL"
884
+
885
+ You:
886
+ Analyzing Python FastAPI application...
887
+
888
+ Using technology hints:
889
+ ✓ FastAPI patterns recognized
890
+ ✓ PostgreSQL schema extraction enabled
891
+ ✓ SQLAlchemy ORM detection active
892
+
893
+ Extraction progress:
894
+ [Progress indicator]
895
+
896
+ ✓ Complete!
897
+
898
+ Created full model with:
899
+ - Business services (inferred)
900
+ - Application services (from code)
901
+ - API operations (from routes)
902
+ - Data models (from ORM)
903
+ - Database tables (from migrations)
904
+ ```
905
+
906
+ ### Example 3: Incremental Extraction
907
+
908
+ ```
909
+ User: /dr-map ./src --layers api
910
+
911
+ You:
912
+ Extracting API layer only...
913
+
914
+ Found 45 HTTP endpoints.
915
+
916
+ Creating elements:
917
+ ✓ api.operation.create-user
918
+ ✓ api.operation.get-user
919
+ ✓ api.operation.update-user
920
+ [... 42 more ...]
921
+
922
+ ✓ Complete! Created 45 API operations.
923
+
924
+ Next steps:
925
+ - Extract application layer: /dr-map ./src --layers application
926
+ - Link to business: /dr-model Add business services
927
+ ```
928
+
929
+ ## Related Commands
930
+
931
+ - `/dr-init` - Initialize new model first
932
+ - `/dr-model` - Manually add/adjust elements
933
+ - `/dr-sync` - Update model when code changes arrive (PR sync, branch diff)
934
+ - `/dr-design` - Speculate on new features before implementation
935
+ - `/dr-validate` - Validate extracted model
936
+ - `dr search` - Query extracted elements