@documentation-robotics/cli 0.1.0 → 0.1.7

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 +208 -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 +162 -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 +42 -16
  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,933 @@
1
+ ---
2
+ name: LAYER_06_API
3
+ description: Expert knowledge for API Layer modeling in Documentation Robotics
4
+ triggers:
5
+ [
6
+ "OpenAPI",
7
+ "REST API",
8
+ "endpoint",
9
+ "operation",
10
+ "swagger",
11
+ "API specification",
12
+ "HTTP method",
13
+ "request",
14
+ "response"
15
+ ]
16
+ version: 0.8.3
17
+ ---
18
+
19
+ # API Layer Skill
20
+
21
+ **Layer Number:** 06
22
+ **Specification:** Metadata Model Spec v0.8.3
23
+ **Purpose:** Defines REST API contracts using OpenAPI 3.0, specifying endpoints, operations, request/response schemas, and security requirements.
24
+
25
+ ---
26
+
27
+ ## Layer Overview
28
+
29
+ The API Layer captures **API contracts**:
30
+
31
+ - **OPERATIONS** - HTTP methods on paths (GET, POST, PUT, DELETE, PATCH)
32
+ - **SCHEMAS** - Request/response data structures
33
+ - **SECURITY** - Authentication and authorization schemes
34
+ - **DOCUMENTATION** - API metadata, descriptions, examples
35
+ - **INTEGRATION** - Links to business services, application services, data models
36
+
37
+ This layer uses **OpenAPI 3.0.3** (de facto industry standard) with custom extensions for cross-layer traceability.
38
+
39
+ **Central Entity:** The **Operation** (HTTP method on a path) is the core modeling unit.
40
+
41
+ ---
42
+
43
+ ## Entity Types
44
+
45
+ > **CLI Introspection:** Run `dr schema types api` for the authoritative, always-current list of node types.
46
+ > Run `dr schema node <type-id>` for full attribute details on any type.
47
+
48
+ ### Core OpenAPI Entities (13 entities)
49
+
50
+ | Entity Type | Description |
51
+ | ------------------- | ------------------------------------------------------------------------------------------- |
52
+ | **OpenAPIDocument** | Root of an OpenAPI specification file (version 3.0.3) |
53
+ | **Info** | Metadata about the API (title, description, version, contact, license) |
54
+ | **Server** | Server where the API is available (with URL and variables) |
55
+ | **Paths** | Available API endpoints and operations |
56
+ | **PathItem** | Operations available on a path |
57
+ | **Operation** | Single API operation (HTTP method on a path) - **CENTRAL ENTITY** |
58
+ | **Parameter** | Parameter for an operation (locations: query, header, path, cookie) |
59
+ | **RequestBody** | Request payload for an operation |
60
+ | **Responses** | Possible responses from an operation |
61
+ | **Response** | Single response definition with status code |
62
+ | **MediaType** | Media type and schema for request/response body |
63
+ | **Components** | Reusable component definitions (schemas, responses, parameters, examples, security schemes) |
64
+ | **Schema** | Data type definition (JSON Schema subset) |
65
+
66
+ ### Metadata Entities (11 entities)
67
+
68
+ | Entity Type | Description |
69
+ | ------------------------- | ---------------------------------------------------------------------- |
70
+ | **Tag** | Metadata label for grouping operations |
71
+ | **ExternalDocumentation** | Reference to external documentation |
72
+ | **Contact** | Contact information for API owner |
73
+ | **License** | Legal license for API |
74
+ | **ServerVariable** | Variable placeholder in server URL templates |
75
+ | **Header** | HTTP header parameters for requests/responses |
76
+ | **Link** | Relationship between API responses and subsequent operations (HATEOAS) |
77
+ | **Callback** | Webhook or callback URL pattern |
78
+ | **Example** | Sample values for documentation and testing |
79
+ | **Encoding** | Serialization details for multipart content |
80
+ | **SecurityScheme** | Security mechanism (types: apiKey, http, oauth2, openIdConnect) |
81
+
82
+ ### Supporting Entities (3 entities)
83
+
84
+ | Entity Type | Description |
85
+ | -------------- | ------------------------------------------------------------------------------------------- |
86
+ | **OAuthFlows** | Configuration for OAuth 2.0 flows |
87
+ | **OAuthFlow** | Single OAuth 2.0 flow definition (authorizationCode, implicit, password, clientCredentials) |
88
+ | **RateLimit** | Rate limiting policy for an operation (requests per window, key strategy, action on breach) |
89
+
90
+ ---
91
+
92
+ ## Type Decision Tree
93
+
94
+ For each construct encountered, ask "what is this?" and assign the first matching type.
95
+
96
+ ```
97
+ Root OpenAPI specification file/object? → api.openapidocument
98
+ API-level metadata (title, description, version)? → api.info
99
+ Contact information for the API owner? → api.contact
100
+ Legal license declaration? → api.license
101
+ Server/host where the API is available (URL)? → api.server
102
+ Variable placeholder in a server URL template (e.g., {version})? → api.servervariable
103
+ Container of all URL paths (the `paths:` block)? → api.paths
104
+ A specific URL path with its available HTTP methods? → api.pathitem
105
+ A single HTTP method on a path (GET, POST, PUT, DELETE, PATCH)? → api.operation
106
+ A parameter — query, path, header, or cookie? → api.parameter
107
+ ↳ NOTE: request bodies are NOT parameters → use api.requestbody
108
+ Request payload/body for an operation? → api.requestbody
109
+ Container of all possible responses for an operation? → api.responses
110
+ ↳ NOTE: not a single response — use api.response for each status code
111
+ A single response for a specific HTTP status code? → api.response
112
+ Media type + schema pair (e.g., application/json with schema)? → api.mediatype
113
+ Data structure / schema definition (JSON Schema subset)? → api.schema
114
+ HTTP header for a request or response? → api.header
115
+ Grouping label used to organize operations? → api.tag
116
+ Reference to external documentation (URL)? → api.externaldocumentation
117
+ Container for reusable definitions (schemas, responses, params)? → api.components
118
+ Security mechanism definition (apiKey, http, oauth2)? → api.securityscheme
119
+ Container of all OAuth 2.0 flow types for a security scheme? → api.oauthflows
120
+ ↳ NOTE: the individual flows inside are NOT api.oauthflows
121
+ A single OAuth 2.0 flow (authorizationCode, implicit, etc.)? → api.oauthflow
122
+ HATEOAS link from a response to a subsequent operation? → api.link
123
+ Webhook / callback URL pattern triggered by an operation? → api.callback
124
+ Sample value for documentation or testing? → api.example
125
+ Serialization details for multipart form content? → api.encoding
126
+ Rate limiting policy (requests per window, key strategy)? → api.ratelimit
127
+ ```
128
+
129
+ ---
130
+
131
+ ## Common Misclassifications
132
+
133
+ | Misclassification | Correct Classification | Why |
134
+ | ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
135
+ | Using `api.response.*` for the set of all responses | `api.responses.*` is the container; `api.response.*` is a single status code response | `responses` is the plural container; `response` is one entry within it |
136
+ | Using `api.oauthflows.*` for a single flow | `api.oauthflow.*` — each flow variant (authorizationCode, implicit, etc.) is its own node | `oauthflows` is the multi-flow container; `oauthflow` is one flow definition |
137
+ | Modeling schemas inline as `api.mediatype.*` | Schemas are `api.schema.*`; `mediatype` just pairs a content type with a schema reference | MediaType is the content-type envelope; Schema is the data structure inside it |
138
+ | Using `api.parameter.*` for the request body | Request bodies are `api.requestbody.*`; parameters are query/path/header/cookie values only | The OpenAPI spec distinguishes body from parameters explicitly |
139
+ | Using `api.schema.*` for an entire API endpoint | Endpoints are `api.pathitem.*` + `api.operation.*`; schemas are data type definitions only | Schema ≠ endpoint |
140
+ | Putting rate limit config as a property on `api.operation.*` | `api.ratelimit.*` is a dedicated node type for rate limiting policies | Model rate limits as first-class nodes so they can be referenced and reasoned about independently |
141
+ | Using `api.components.*` to represent every reusable object | `api.components.*` is the container; individual reusables (schemas, parameters, etc.) are their own typed nodes composed under it | Components is a structural container, not a substitute for specific types |
142
+
143
+ ---
144
+
145
+ ## Intra-Layer Relationships
146
+
147
+ ### Composition Relationships (Part cannot exist without whole)
148
+
149
+ | Source | Predicate | Target | Example |
150
+ | --------------- | --------- | -------------- | --------------------------------- |
151
+ | OpenAPIDocument | composes | Info | Document has metadata |
152
+ | OpenAPIDocument | composes | Paths | Document defines endpoints |
153
+ | OpenAPIDocument | composes | Components | Document has reusable components |
154
+ | Paths | composes | PathItem | Paths contain path items |
155
+ | PathItem | composes | Operation | Path has HTTP methods |
156
+ | PathItem | composes | Parameter | Path-level parameters |
157
+ | Operation | composes | Parameter | Operation-specific parameters |
158
+ | Operation | composes | RequestBody | Request payload definition |
159
+ | Operation | composes | Responses | Response definitions |
160
+ | Responses | composes | Response | Individual status responses |
161
+ | RequestBody | composes | MediaType | Request content types |
162
+ | Response | composes | MediaType | Response content types |
163
+ | Response | composes | Header | Response headers |
164
+ | Response | composes | Link | HATEOAS links |
165
+ | MediaType | composes | Schema | Data structure |
166
+ | MediaType | composes | Example | Sample data |
167
+ | MediaType | composes | Encoding | Serialization details |
168
+ | Components | composes | Schema | Reusable schemas |
169
+ | Components | composes | Response | Reusable responses |
170
+ | Components | composes | Parameter | Reusable parameters |
171
+ | Components | composes | Example | Reusable examples |
172
+ | Components | composes | RequestBody | Reusable request bodies |
173
+ | Components | composes | Header | Reusable headers |
174
+ | Components | composes | SecurityScheme | Security definitions |
175
+ | Components | composes | Link | Reusable links |
176
+ | Components | composes | Callback | Reusable callbacks |
177
+ | Info | composes | Contact | API owner contact |
178
+ | Info | composes | License | API license |
179
+ | SecurityScheme | composes | OAuthFlows | OAuth2 configuration |
180
+ | OAuthFlows | composes | OAuthFlow | Individual OAuth2 flow definition |
181
+
182
+ ### Aggregation Relationships (Part can exist independently)
183
+
184
+ | Source | Predicate | Target | Example |
185
+ | --------------- | ---------- | ------------------- | ------------------------ |
186
+ | OpenAPIDocument | aggregates | Server | API deployment servers |
187
+ | OpenAPIDocument | aggregates | Tag | Operation tags |
188
+ | OpenAPIDocument | aggregates | SecurityRequirement | Global security |
189
+ | Server | aggregates | ServerVariable | URL template variables |
190
+ | PathItem | aggregates | Parameter | Shared parameters |
191
+ | Operation | aggregates | Callback | Webhooks |
192
+ | Operation | aggregates | SecurityRequirement | Operation-level security |
193
+
194
+ ### Reference Relationships
195
+
196
+ | Source | Predicate | Target | Example |
197
+ | --------------- | ---------- | --------------------- | -------------------------------------- |
198
+ | Schema | references | Schema | Schema $ref to another schema |
199
+ | Parameter | references | Schema | Parameter uses schema |
200
+ | Header | references | Schema | Header uses schema |
201
+ | Link | references | Operation | Link points to operation (operationId) |
202
+ | Callback | references | PathItem | Callback references path definition |
203
+ | Operation | references | Tag | Operation tagged for grouping |
204
+ | Tag | references | ExternalDocumentation | Tag links to external docs |
205
+ | OpenAPIDocument | references | ExternalDocumentation | Document links to external docs |
206
+ | Encoding | references | Header | Encoding uses headers |
207
+
208
+ ### Specialization Relationships
209
+
210
+ | Source | Predicate | Target | Example |
211
+ | ------ | ----------- | ------ | ---------------------------------------- |
212
+ | Schema | specializes | Schema | Schema inheritance (allOf, oneOf, anyOf) |
213
+
214
+ ### Behavioral Relationships
215
+
216
+ | Source | Predicate | Target | Example |
217
+ | -------------- | --------- | --------- | ---------------------------------- |
218
+ | Operation | triggers | Callback | Operation invokes webhook |
219
+ | SecurityScheme | serves | Operation | Security scheme protects operation |
220
+
221
+ ### Association Relationships
222
+
223
+ | Source | Predicate | Target | Example |
224
+ | ------- | --------------- | --------------- | -------------------- |
225
+ | Contact | associated-with | OpenAPIDocument | Contact info for API |
226
+ | License | associated-with | OpenAPIDocument | Legal license |
227
+
228
+ ---
229
+
230
+ ## Cross-Layer References
231
+
232
+ ### Outgoing References (API → Other Layers)
233
+
234
+ OpenAPI specification includes **custom extensions** (x-\* properties) for cross-layer traceability:
235
+
236
+ Cross-layer links to Business and Application layers use `dr relationship add`:
237
+
238
+ ```bash
239
+ dr relationship add api.<type>.<name> business.<type>.<name> --predicate realizes
240
+ dr relationship add api.<type>.<name> application.<type>.<name> --predicate realizes
241
+ ```
242
+
243
+ Use `dr catalog types` to list all valid predicates.
244
+
245
+ OpenAPI **x-\* properties** (set via `--properties`) are used for same-element metadata:
246
+
247
+ | Target Layer | Extension Property | Example |
248
+ | ------------------------ | ------------------------------- | --------------------------------------------------- |
249
+ | **Layer 1 (Motivation)** | `x-supports-goals` | Operation supports business goals |
250
+ | **Layer 1 (Motivation)** | `x-fulfills-requirements` | Operation fulfills functional requirements |
251
+ | **Layer 1 (Motivation)** | `x-governed-by-principles` | Operation follows architectural principles |
252
+ | **Layer 1 (Motivation)** | `x-constrained-by` | Operation subject to constraints (GDPR, HIPAA, SOX) |
253
+ | **Layer 7 (Data Model)** | `schema.$ref` | Schema references JSON Schema definition |
254
+ | **Layer 3 (Security)** | `x-security-resource` | Operation protected by SecureResource |
255
+ | **Layer 3 (Security)** | `x-required-permissions` | Operation requires specific permissions |
256
+ | **Layer 3 (Security)** | `x-rate-limit` | Rate limiting configuration |
257
+ | **Layer 11 (APM)** | `x-apm-business-metrics` | Operation tracked by business metrics |
258
+ | **Layer 11 (APM)** | `x-apm-sla-target-latency` | Expected response time (e.g., "100ms") |
259
+ | **Layer 11 (APM)** | `x-apm-sla-target-availability` | Expected availability (e.g., "99.9%") |
260
+ | **Layer 11 (APM)** | `x-apm-trace` | Distributed tracing enabled |
261
+ | **Layer 11 (APM)** | `x-apm-criticality` | Business criticality (critical, high, medium, low) |
262
+
263
+ ### Incoming References (Lower Layers → API)
264
+
265
+ Lower layers reference API layer to show implementation and data structure.
266
+
267
+ ---
268
+
269
+ ## Codebase Detection Patterns
270
+
271
+ ### Pattern 1: FastAPI Python
272
+
273
+ ```python
274
+ from fastapi import FastAPI, HTTPException
275
+ from pydantic import BaseModel
276
+
277
+ app = FastAPI(
278
+ title="User Management API", # OpenAPIDocument: Info.title
279
+ description="API for managing user accounts", # Info.description
280
+ version="1.0.0" # Info.version
281
+ )
282
+
283
+ class UserCreateRequest(BaseModel): # Schema (RequestBody)
284
+ username: str
285
+ email: str
286
+ full_name: str
287
+
288
+ class UserResponse(BaseModel): # Schema (Response)
289
+ user_id: str
290
+ username: str
291
+ email: str
292
+ created_at: datetime
293
+
294
+ @app.post(
295
+ "/api/users", # PathItem + Operation (POST)
296
+ response_model=UserResponse, # Response schema
297
+ status_code=201, # Response status
298
+ tags=["Users"], # Tag
299
+ summary="Create a new user", # Operation.summary
300
+ description="Creates a new user account with the provided details" # Operation.description
301
+ )
302
+ async def create_user(user: UserCreateRequest) -> UserResponse: # RequestBody + Response
303
+ """
304
+ x-apm-sla-target-latency: 200ms
305
+ x-required-permissions: users.write
306
+ """
307
+ pass
308
+ ```
309
+
310
+ **Maps to:**
311
+
312
+ - OpenAPIDocument: "User Management API"
313
+ - PathItem: "/api/users"
314
+ - Operation: "POST /api/users"
315
+ - RequestBody: MediaType (application/json) with Schema (UserCreateRequest)
316
+ - Response: 201 with Schema (UserResponse)
317
+ - Tag: "Users"
318
+
319
+ ### Pattern 2: Express.js TypeScript
320
+
321
+ ```typescript
322
+ import express from "express";
323
+ import { body, param, query, validationResult } from "express-validator";
324
+
325
+ const router = express.Router();
326
+
327
+ /**
328
+ * @openapi
329
+ * /api/orders/{orderId}:
330
+ * get:
331
+ * summary: Get order by ID
332
+ * description: Retrieves a single order by its unique identifier
333
+ * tags:
334
+ * - Orders
335
+ * parameters:
336
+ * - name: orderId
337
+ * in: path
338
+ * required: true
339
+ * schema:
340
+ * type: string
341
+ * format: uuid
342
+ * responses:
343
+ * 200:
344
+ * description: Order found
345
+ * content:
346
+ * application/json:
347
+ * schema:
348
+ * $ref: '#/components/schemas/Order'
349
+ * 404:
350
+ * description: Order not found
351
+ * x-apm-sla-target-latency: 100ms
352
+ * x-apm-criticality: high
353
+ */
354
+ router.get(
355
+ "/api/orders/:orderId",
356
+ param("orderId").isUUID(),
357
+ async (req, res) => {
358
+ // Implementation
359
+ }
360
+ );
361
+ ```
362
+
363
+ **Maps to:**
364
+
365
+ - PathItem: "/api/orders/{orderId}"
366
+ - Operation: "GET /api/orders/{orderId}"
367
+ - Parameter: "orderId" (in: path, type: string, format: uuid)
368
+ - Response: 200 with schema reference
369
+ - Response: 404 error response
370
+ - Custom extensions: x-apm-sla-target-latency, x-apm-criticality
371
+
372
+ ### Pattern 3: Spring Boot Java
373
+
374
+ ```java
375
+ @RestController
376
+ @RequestMapping("/api/products")
377
+ @Tag(name = "Products", description = "Product management operations")
378
+ public class ProductController {
379
+
380
+ @Operation(
381
+ summary = "List products",
382
+ description = "Returns a paginated list of products",
383
+ extensions = {
384
+ @Extension(name = "x-apm-sla-target-latency", properties = @ExtensionProperty(name = "latency", value = "150ms")),
385
+ @Extension(name = "x-required-permissions", properties = @ExtensionProperty(name = "permissions", value = "products.read"))
386
+ }
387
+ )
388
+ @ApiResponses({
389
+ @ApiResponse(
390
+ responseCode = "200",
391
+ description = "Products retrieved successfully",
392
+ content = @Content(
393
+ mediaType = "application/json",
394
+ schema = @Schema(implementation = ProductListResponse.class)
395
+ )
396
+ )
397
+ })
398
+ @GetMapping
399
+ public ResponseEntity<ProductListResponse> listProducts(
400
+ @Parameter(description = "Page number", example = "1") @RequestParam(defaultValue = "1") int page,
401
+ @Parameter(description = "Page size", example = "20") @RequestParam(defaultValue = "20") int size
402
+ ) {
403
+ // Implementation
404
+ }
405
+ }
406
+ ```
407
+
408
+ **Maps to:**
409
+
410
+ - PathItem: "/api/products"
411
+ - Operation: "GET /api/products"
412
+ - Parameters: "page" (query), "size" (query)
413
+ - Response: 200 with ProductListResponse schema
414
+ - Tag: "Products"
415
+ - Custom extensions
416
+
417
+ ### Pattern 4: OpenAPI YAML Definition
418
+
419
+ ```yaml
420
+ openapi: 3.0.3
421
+ info:
422
+ title: Payment Processing API
423
+ description: API for processing customer payments
424
+ version: 2.1.0
425
+ contact:
426
+ name: API Support
427
+ email: api-support@example.com
428
+ license:
429
+ name: MIT
430
+ url: https://opensource.org/licenses/MIT
431
+ x-governed-by-principles:
432
+ - motivation/principle/api-first-design
433
+ - motivation/principle/security-by-design
434
+
435
+ servers:
436
+ - url: https://api.example.com/v2
437
+ description: Production server
438
+ - url: https://staging-api.example.com/v2
439
+ description: Staging server
440
+
441
+ paths:
442
+ /payments:
443
+ post:
444
+ summary: Process payment
445
+ description: Processes a payment transaction
446
+ operationId: processPayment
447
+ tags:
448
+ - Payments
449
+ security:
450
+ - oauth2: [payments.write]
451
+ requestBody:
452
+ required: true
453
+ content:
454
+ application/json:
455
+ schema:
456
+ $ref: "#/components/schemas/PaymentRequest"
457
+ examples:
458
+ credit-card:
459
+ $ref: "#/components/examples/CreditCardPayment"
460
+ responses:
461
+ "201":
462
+ description: Payment processed successfully
463
+ content:
464
+ application/json:
465
+ schema:
466
+ $ref: "#/components/schemas/PaymentResponse"
467
+ "400":
468
+ $ref: "#/components/responses/BadRequest"
469
+ "401":
470
+ $ref: "#/components/responses/Unauthorized"
471
+ x-apm-sla-target-latency: 500ms
472
+ x-apm-sla-target-availability: 99.99%
473
+ x-apm-criticality: critical
474
+ x-required-permissions:
475
+ - payments.write
476
+ x-rate-limit:
477
+ requests: 100
478
+ window: 60s
479
+
480
+ components:
481
+ schemas:
482
+ PaymentRequest:
483
+ type: object
484
+ required:
485
+ - amount
486
+ - currency
487
+ - payment_method
488
+ properties:
489
+ amount:
490
+ type: number
491
+ format: double
492
+ minimum: 0.01
493
+ example: 99.99
494
+ currency:
495
+ type: string
496
+ enum: [USD, EUR, GBP]
497
+ example: USD
498
+ payment_method:
499
+ $ref: "#/components/schemas/PaymentMethod"
500
+
501
+ PaymentResponse:
502
+ type: object
503
+ properties:
504
+ transaction_id:
505
+ type: string
506
+ format: uuid
507
+ status:
508
+ type: string
509
+ enum: [pending, completed, failed]
510
+ timestamp:
511
+ type: string
512
+ format: date-time
513
+
514
+ securitySchemes:
515
+ oauth2:
516
+ type: oauth2
517
+ flows:
518
+ authorizationCode:
519
+ authorizationUrl: https://auth.example.com/oauth/authorize
520
+ tokenUrl: https://auth.example.com/oauth/token
521
+ scopes:
522
+ payments.read: Read payment information
523
+ payments.write: Process payments
524
+
525
+ responses:
526
+ BadRequest:
527
+ description: Invalid request
528
+ content:
529
+ application/json:
530
+ schema:
531
+ $ref: "#/components/schemas/Error"
532
+
533
+ examples:
534
+ CreditCardPayment:
535
+ value:
536
+ amount: 99.99
537
+ currency: USD
538
+ payment_method:
539
+ type: credit_card
540
+ card_number: "4111111111111111"
541
+ ```
542
+
543
+ ---
544
+
545
+ ## Modeling Workflow
546
+
547
+ ### Step 1: Create OpenAPI Document
548
+
549
+ ```bash
550
+ # Create the API specification document
551
+ dr add api openapidocument "payment-api" \
552
+ --description "API for processing customer payments"
553
+
554
+ # Add API metadata
555
+ # NOTE: api.info requires a companion api.openapidocument to avoid orphan warnings.
556
+ # Always create api.openapidocument first, then link api.info to it via composes.
557
+ dr add api info "payment-api-info" \
558
+ --description "API metadata and contact information"
559
+
560
+ dr relationship add api.openapidocument.payment-api \
561
+ api.info.payment-api-info --predicate composes
562
+
563
+ # Link to motivation layer
564
+ dr relationship add api.openapidocument.payment-api \
565
+ motivation.principle.api-first-design --predicate governed-by
566
+ ```
567
+
568
+ ### Step 2: Define Servers
569
+
570
+ ```bash
571
+ # Production server
572
+ dr add api server "production-server" \
573
+ --description "Production API server"
574
+
575
+ # Staging server
576
+ dr add api server "staging-server" \
577
+ --description "Staging API server"
578
+ ```
579
+
580
+ ### Step 3: Define Security Schemes
581
+
582
+ ```bash
583
+ # OAuth2 security
584
+ dr add api securityscheme "oauth2-auth" \
585
+ --description "OAuth2 authorization code flow"
586
+
587
+ # API Key security
588
+ dr add api securityscheme "api-key-auth" \
589
+ --description "API key authentication"
590
+ ```
591
+
592
+ ### Step 4: Define Schemas (Data Models)
593
+
594
+ ```bash
595
+ # Request schema
596
+ dr add api schema "payment-request" \
597
+ --description "Payment request payload"
598
+
599
+ # Response schema
600
+ dr add api schema "payment-response" \
601
+ --description "Payment processing response"
602
+
603
+ # Link to data model layer
604
+ dr relationship add api.schema.payment-request \
605
+ data-model.schema.payment-request --predicate references
606
+ ```
607
+
608
+ ### Step 5: Define Operations (Core Entities)
609
+
610
+ ```bash
611
+ # POST operation
612
+ dr add api operation "process-payment" \
613
+ --description "Processes a payment transaction"
614
+
615
+ # Add APM and security extensions
616
+ dr add api operation "process-payment" \
617
+
618
+ # Link to business layer via relationship
619
+ dr relationship add api.operation.process-payment business.service.payment-processing --predicate realizes
620
+
621
+ # GET operation
622
+ dr add api operation "get-payment" \
623
+ --description "Retrieves payment details by ID"
624
+ ```
625
+
626
+ ### Step 6: Define Parameters
627
+
628
+ ```bash
629
+ # Path parameter
630
+ dr add api parameter "payment-id-param" \
631
+ --description "Payment transaction ID"
632
+
633
+ # Query parameter
634
+ dr add api parameter "status-filter" \
635
+ --description "Filter payments by status"
636
+
637
+ # Link parameter to operation
638
+ dr relationship add api.operation.get-payment \
639
+ api.parameter.payment-id-param --predicate has-parameter
640
+ ```
641
+
642
+ ### Step 7: Define Request/Response Bodies
643
+
644
+ ```bash
645
+ # Request body
646
+ dr add api requestbody "payment-request-body" \
647
+ --description "Payment request payload"
648
+
649
+ # Link request body to schema
650
+ dr relationship add api.requestbody.payment-request-body \
651
+ api.schema.payment-request --predicate uses-schema
652
+
653
+ # Response
654
+ dr add api response "payment-success-response" \
655
+ --description "Successful payment response"
656
+
657
+ # Link response to schema
658
+ dr relationship add api.response.payment-success-response \
659
+ api.schema.payment-response --predicate uses-schema
660
+ ```
661
+
662
+ ### Step 8: Define Tags for Organization
663
+
664
+ ```bash
665
+ # Add tags
666
+ dr add api tag "payments" \
667
+ --description "Payment processing operations"
668
+
669
+ dr add api tag "refunds" \
670
+ --description "Refund operations"
671
+
672
+ # Tag operations
673
+ dr relationship add api.operation.process-payment \
674
+ api.tag.payments --predicate tagged-with
675
+ ```
676
+
677
+ ### Step 9: Cross-Layer Integration
678
+
679
+ ```bash
680
+ # Link to business layer
681
+ dr relationship add api.operation.process-payment \
682
+ business.service.payment-processing --predicate realizes
683
+
684
+ # Link to application layer
685
+ dr relationship add api.openapidocument.payment-api \
686
+ application.service.payment-api --predicate realizes
687
+
688
+ # Link to security layer
689
+ dr relationship add api.operation.process-payment \
690
+ security.secure-resource.payment-api --predicate protected-by
691
+
692
+ # Link to motivation layer
693
+ dr relationship add api.operation.process-payment \
694
+ motivation.goal.reduce-checkout-time --predicate supports
695
+
696
+ # Link to APM layer
697
+ dr relationship add api.operation.process-payment \
698
+ apm.metric.payment-processing-latency --predicate tracked-by
699
+ ```
700
+
701
+ ### Step 10: Validate and Export
702
+
703
+ ```bash
704
+ # Validate API layer
705
+ dr validate --layers api
706
+
707
+ # Export to OpenAPI YAML
708
+ dr export openapi --output payment-api.yaml
709
+
710
+ # Validate exported OpenAPI with external tools
711
+ spectral lint payment-api.yaml
712
+ ```
713
+
714
+ ---
715
+
716
+ ## Operation-Level SLA Patterns
717
+
718
+ Different operations have different SLA targets:
719
+
720
+ ```yaml
721
+ # Search operation: fast response
722
+ x-apm-sla-target-latency: "50ms"
723
+ x-apm-sla-target-availability: "99.9%"
724
+ x-apm-criticality: "high"
725
+
726
+ # Write operation: moderate latency
727
+ x-apm-sla-target-latency: "200ms"
728
+ x-apm-sla-target-availability: "99.95%"
729
+ x-apm-criticality: "critical"
730
+
731
+ # Batch operation: longer latency acceptable
732
+ x-apm-sla-target-latency: "10s"
733
+ x-apm-sla-target-availability: "99.5%"
734
+ x-apm-criticality: "medium"
735
+
736
+ # Reporting: can be slower
737
+ x-apm-sla-target-latency: "5s"
738
+ x-apm-sla-target-availability: "99%"
739
+ x-apm-criticality: "low"
740
+ ```
741
+
742
+ ---
743
+
744
+ ## Best Practices
745
+
746
+ 1. **Operation is the Central Entity** - Model operations, not just paths
747
+ 2. **Use OpenAPI 3.0.3** - Latest stable version with broad tooling support
748
+ 3. **Tag Operations** - Organize operations by domain or resource
749
+ 4. **Define Reusable Components** - Schemas, responses, parameters in Components section
750
+ 5. **Document Examples** - Include request/response examples for testing and documentation
751
+ 6. **Security at Operation Level** - Different operations can have different security requirements
752
+ 7. **Link to Business Services** - Use `dr relationship add` to link API operations to business services for traceability
753
+ 8. **Define SLA Targets** - Use x-apm-sla-target-\* for monitoring
754
+ 9. **Version APIs Properly** - Use semantic versioning (major.minor.patch)
755
+ 10. **Generate from Code** - Use FastAPI, NestJS decorators, or Springdoc to auto-generate OpenAPI specs
756
+
757
+ ---
758
+
759
+ ## OpenAPI Tooling Ecosystem
760
+
761
+ ### Generation Tools
762
+
763
+ - **FastAPI** (Python) - Auto-generates OpenAPI from Python decorators
764
+ - **NestJS** (TypeScript) - Swagger module for OpenAPI generation
765
+ - **Springdoc** (Java) - OpenAPI 3 for Spring Boot applications
766
+ - **Express + swagger-jsdoc** (Node.js) - Generate from JSDoc comments
767
+
768
+ ### Validation Tools
769
+
770
+ - **Spectral** - OpenAPI linter and validator
771
+ - **openapi-validator** - IBM's OpenAPI validator
772
+ - **swagger-cli** - Validate and bundle OpenAPI specs
773
+
774
+ ### Documentation Tools
775
+
776
+ - **Swagger UI** - Interactive API documentation
777
+ - **Redoc** - Clean, customizable API documentation
778
+ - **Postman** - Import OpenAPI for API testing
779
+
780
+ ### Code Generation Tools
781
+
782
+ - **OpenAPI Generator** - Generate client SDKs and server stubs
783
+ - **swagger-codegen** - Legacy code generation tool
784
+ - **oapi-codegen** (Go) - Generate Go server/client from OpenAPI
785
+
786
+ ---
787
+
788
+ ## Validation Tips
789
+
790
+ | Issue | Cause | Fix |
791
+ | -------------------- | -------------------------------------- | ----------------------------------------------------------------------------- |
792
+ | Missing Operations | Paths defined but no operations | Add HTTP methods (GET, POST, etc.) |
793
+ | Unlinked Schemas | Schemas not referenced by operations | Link schemas to request/response bodies |
794
+ | Missing Security | Operations lack security requirements | Add securitySchemes and apply to operations |
795
+ | No Cross-Layer Links | API not linked to business/application | Run `dr relationship add <api-element> <target-element> --predicate realizes` |
796
+ | Missing SLA Targets | Operations lack performance targets | Add x-apm-sla-target-\* extensions |
797
+ | Untagged Operations | Operations not organized by tags | Add tags for grouping |
798
+ | No Examples | Schemas lack examples | Add example values for documentation |
799
+ | Invalid OpenAPI | Spec doesn't validate | Use Spectral or openapi-validator |
800
+
801
+ ---
802
+
803
+ ## Quick Reference
804
+
805
+ **Add Commands:**
806
+
807
+ ```bash
808
+ dr add api openapidocument <name>
809
+ dr add api operation <name>
810
+ dr add api schema <name>
811
+ dr add api parameter <name>
812
+ dr add api securityscheme <name>
813
+ dr add api tag <name>
814
+ ```
815
+
816
+ **Relationship Commands:**
817
+
818
+ ```bash
819
+ dr relationship add <operation> <schema> --predicate uses-schema
820
+ dr relationship add <operation> <parameter> --predicate has-parameter
821
+ dr relationship add <operation> <tag> --predicate tagged-with
822
+ dr relationship add <schema> <schema> --predicate references
823
+ ```
824
+
825
+ **Cross-Layer Commands:**
826
+
827
+ ```bash
828
+ dr relationship add <api-operation> <business-service> --predicate realizes
829
+ dr relationship add <api-openapidocument> <application-service> --predicate realizes
830
+ dr relationship add <api-schema> <data-model-schema> --predicate references
831
+ dr relationship add <api-operation> <security-resource> --predicate protected-by
832
+ dr relationship add <api-operation> <motivation-goal> --predicate supports
833
+ ```
834
+
835
+ **Export Commands:**
836
+
837
+ ```bash
838
+ dr export openapi --output api-spec.yaml
839
+ dr export openapi --layers api --output api-spec.json
840
+ ```
841
+
842
+ **Validation Commands:**
843
+
844
+ ```bash
845
+ dr validate --layers api
846
+ spectral lint api-spec.yaml
847
+ swagger-cli validate api-spec.yaml
848
+ ```
849
+
850
+ ---
851
+
852
+ ## Custom Extension Reference
853
+
854
+ Documentation Robotics defines custom OpenAPI extensions for cross-layer traceability:
855
+
856
+ ```yaml
857
+ # Motivation Layer Links
858
+ x-supports-goals: [motivation/goal/id1, motivation/goal/id2]
859
+ x-fulfills-requirements: [motivation/requirement/id1]
860
+ x-governed-by-principles: [motivation/principle/id1]
861
+ x-constrained-by: [motivation/constraint/id1]
862
+
863
+ # Business and Application Layer Links — use dr relationship add (not x-* properties)
864
+ # dr relationship add api.<type>.<name> business.<type>.<name> --predicate realizes
865
+ # dr relationship add api.<type>.<name> application.<type>.<name> --predicate realizes
866
+
867
+ # Security Layer Links
868
+ x-security-resource: security/secure-resource/id
869
+ x-required-permissions: [users.read, users.write]
870
+ x-rate-limit:
871
+ requests: 100
872
+ window: 60s
873
+
874
+ # APM Layer Links
875
+ x-apm-business-metrics: [apm/metric/id1]
876
+ x-apm-sla-target-latency: "100ms"
877
+ x-apm-sla-target-availability: "99.9%"
878
+ x-apm-trace: true
879
+ x-apm-criticality: "high" # critical, high, medium, low
880
+ ```
881
+
882
+ These extensions enable full traceability from API operations to business goals, requirements, security controls, and monitoring metrics.
883
+
884
+ ---
885
+
886
+ ## Coverage Completeness Checklist
887
+
888
+ Before declaring API layer extraction complete, verify each type was considered:
889
+
890
+ - [ ] **api.openapidocument** — Root OpenAPI specification document
891
+ - [ ] **api.info** — API metadata (title, version, description)
892
+ - [ ] **api.contact** — Contact information for the API owner
893
+ - [ ] **api.license** — Legal license for the API
894
+ - [ ] **api.server** — Server URLs where the API is available
895
+ - [ ] **api.servervariable** — Variable placeholders in server URL templates
896
+ - [ ] **api.paths** — Container of all API endpoint paths
897
+ - [ ] **api.pathitem** — Operations available on a specific URL path
898
+ - [ ] **api.operation** — Individual HTTP operations (GET, POST, PUT, DELETE, PATCH) — CENTRAL ENTITY
899
+ - [ ] **api.parameter** — Query, path, header, or cookie parameters
900
+ - [ ] **api.requestbody** — Request payload for an operation
901
+ - [ ] **api.responses** — Container of all possible responses for an operation
902
+ - [ ] **api.response** — Single response definition for a specific HTTP status code
903
+ - [ ] **api.mediatype** — Media type + schema pair for request/response bodies
904
+ - [ ] **api.schema** — Data type definitions (JSON Schema subset)
905
+ - [ ] **api.header** — HTTP header parameters
906
+ - [ ] **api.tag** — Grouping labels for organizing operations
907
+ - [ ] **api.externaldocumentation** — References to external documentation
908
+ - [ ] **api.components** — Container for reusable API component definitions
909
+ - [ ] **api.securityscheme** — Security mechanism definitions (apiKey, http, oauth2, openIdConnect)
910
+ - [ ] **api.oauthflows** — OAuth 2.0 flows configuration container
911
+ - [ ] **api.oauthflow** — Single OAuth 2.0 flow (authorizationCode, implicit, password, clientCredentials)
912
+ - [ ] **api.link** — HATEOAS links from responses to subsequent operations
913
+ - [ ] **api.callback** — Webhook / callback URL patterns
914
+ - [ ] **api.example** — Sample values for documentation and testing
915
+ - [ ] **api.encoding** — Serialization details for multipart content
916
+ - [ ] **api.ratelimit** — Rate limiting policies (requests per window, key strategy)
917
+
918
+ If any type has ZERO elements, explicitly decide:
919
+ "This type doesn't apply to this codebase" with reasoning.
920
+
921
+ ---
922
+
923
+ ## Summary
924
+
925
+ The API Layer is the **contract layer** - it defines HOW external consumers interact with your system. Every operation should:
926
+
927
+ 1. Be linked to a business service (traceability)
928
+ 2. Have clear request/response schemas
929
+ 3. Define security requirements
930
+ 4. Specify SLA targets for monitoring
931
+ 5. Include examples for documentation and testing
932
+
933
+ Use OpenAPI 3.0.3 as the foundation, leverage auto-generation tools from your framework, and extend with custom properties for full cross-layer integration.