@documentation-robotics/cli 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/README.md +10 -14
  2. package/dist/analyzers/active-analyzer.js +62 -0
  3. package/dist/analyzers/active-analyzer.js.map +7 -0
  4. package/dist/analyzers/cards/build.js +21 -1
  5. package/dist/analyzers/cards/build.js.map +2 -2
  6. package/dist/analyzers/cards/extract.js +138 -0
  7. package/dist/analyzers/cards/extract.js.map +7 -0
  8. package/dist/analyzers/cards/routes.js +96 -0
  9. package/dist/analyzers/cards/routes.js.map +7 -0
  10. package/dist/analyzers/cbm-analyzer.js +76 -4
  11. package/dist/analyzers/cbm-analyzer.js.map +2 -2
  12. package/dist/analyzers/cbm-responses.js +12 -6
  13. package/dist/analyzers/cbm-responses.js.map +2 -2
  14. package/dist/analyzers/code-changes.js +159 -0
  15. package/dist/analyzers/code-changes.js.map +7 -0
  16. package/dist/analyzers/edge-relationships.js +6 -2
  17. package/dist/analyzers/edge-relationships.js.map +2 -2
  18. package/dist/analyzers/extraction-plan.js +541 -0
  19. package/dist/analyzers/extraction-plan.js.map +7 -0
  20. package/dist/analyzers/index-job.js +229 -0
  21. package/dist/analyzers/index-job.js.map +7 -0
  22. package/dist/cli.js +12 -10
  23. package/dist/cli.js.map +2 -2
  24. package/dist/coding-agents/drbot-mcp.js +120 -18
  25. package/dist/coding-agents/drbot-mcp.js.map +2 -2
  26. package/dist/commands/add.js +4 -2
  27. package/dist/commands/add.js.map +2 -2
  28. package/dist/commands/analyzer.js +35 -35
  29. package/dist/commands/analyzer.js.map +2 -2
  30. package/dist/commands/changeset-verify.js +16 -8
  31. package/dist/commands/changeset-verify.js.map +2 -2
  32. package/dist/commands/changeset.js +41 -11
  33. package/dist/commands/changeset.js.map +2 -2
  34. package/dist/commands/init.js +9 -26
  35. package/dist/commands/init.js.map +2 -2
  36. package/dist/commands/mcp.js +35 -31
  37. package/dist/commands/mcp.js.map +3 -3
  38. package/dist/commands/relationship.js +2 -12
  39. package/dist/commands/relationship.js.map +2 -2
  40. package/dist/commands/reports.js +3 -3
  41. package/dist/commands/reports.js.map +2 -2
  42. package/dist/commands/update.js +14 -13
  43. package/dist/commands/update.js.map +2 -2
  44. package/dist/commands/upgrade.js +28 -120
  45. package/dist/commands/upgrade.js.map +2 -2
  46. package/dist/commands/validate.js +19 -3
  47. package/dist/commands/validate.js.map +2 -2
  48. package/dist/commands/version.js +1 -1
  49. package/dist/commands/visualize.js +30 -12
  50. package/dist/commands/visualize.js.map +2 -2
  51. package/dist/core/annotation-store.js +15 -5
  52. package/dist/core/annotation-store.js.map +2 -2
  53. package/dist/core/catalog-migration.js +2 -1
  54. package/dist/core/catalog-migration.js.map +2 -2
  55. package/dist/core/changeset-base-index.js +7 -0
  56. package/dist/core/changeset-base-index.js.map +2 -2
  57. package/dist/core/changeset-brief-compact.js +256 -0
  58. package/dist/core/changeset-brief-compact.js.map +7 -0
  59. package/dist/core/changeset-verify.js +356 -26
  60. package/dist/core/changeset-verify.js.map +3 -3
  61. package/dist/core/extraction-observability.js +161 -0
  62. package/dist/core/extraction-observability.js.map +7 -0
  63. package/dist/core/migration-registry.js +13 -1
  64. package/dist/core/migration-registry.js.map +2 -2
  65. package/dist/core/project-init.js +53 -0
  66. package/dist/core/project-init.js.map +7 -0
  67. package/dist/core/relationship-staging.js +94 -1
  68. package/dist/core/relationship-staging.js.map +2 -2
  69. package/dist/core/staged-changeset-storage.js +83 -3
  70. package/dist/core/staged-changeset-storage.js.map +2 -2
  71. package/dist/core/staging-area.js +85 -8
  72. package/dist/core/staging-area.js.map +2 -2
  73. package/dist/core/upgrade-plan.js +117 -0
  74. package/dist/core/upgrade-plan.js.map +7 -0
  75. package/dist/generated/relationship-index.js +124 -15
  76. package/dist/generated/relationship-index.js.map +2 -2
  77. package/dist/integrations/claude_code/.claude-plugin/plugin.json +24 -0
  78. package/dist/integrations/claude_code/agents/dr-architect.md +19 -5
  79. package/dist/integrations/claude_code/agents/dr-extractor.md +7 -1
  80. package/dist/integrations/claude_code/commands/dr-changeset.md +2 -1
  81. package/dist/integrations/claude_code/commands/dr-map.md +7 -1
  82. package/dist/integrations/claude_code/commands/dr-plan.md +42 -16
  83. package/dist/integrations/claude_code/docs/MCP_SERVER.md +28 -31
  84. package/dist/integrations/claude_code/docs/README.md +20 -1
  85. package/dist/integrations/claude_code/plugin-agents/dr-advisor.md +255 -0
  86. package/dist/integrations/claude_code/plugin-agents/dr-architect.md +306 -0
  87. package/dist/integrations/claude_code/skills/dr_13_testing_layer/SKILL.md +3 -0
  88. package/dist/integrations/claude_code/skills/dr_change_planning/SKILL.md +90 -31
  89. package/dist/integrations/claude_code/skills/dr_changeset_reviewer/SKILL.md +5 -0
  90. package/dist/integrations/claude_code/skills/dr_engineering_guide/SKILL.md +5 -0
  91. package/dist/integrations/github_copilot/agents/dr-architect.md +2 -0
  92. package/dist/integrations/github_copilot/skills/dr_13_testing_layer/SKILL.md +3 -0
  93. package/dist/integrations/github_copilot/skills/dr_change_planning/SKILL.md +88 -30
  94. package/dist/mcp/changeset-only.js +14 -3
  95. package/dist/mcp/changeset-only.js.map +2 -2
  96. package/dist/mcp/project-root.js +85 -0
  97. package/dist/mcp/project-root.js.map +7 -0
  98. package/dist/mcp/server-instructions.js +27 -0
  99. package/dist/mcp/server-instructions.js.map +7 -0
  100. package/dist/mcp/strict-schema.js +52 -0
  101. package/dist/mcp/strict-schema.js.map +7 -0
  102. package/dist/mcp/tool-registry.js +39 -5
  103. package/dist/mcp/tool-registry.js.map +2 -2
  104. package/dist/mcp/tools/changeset-analysis-tools.js +25 -5
  105. package/dist/mcp/tools/changeset-analysis-tools.js.map +3 -3
  106. package/dist/mcp/tools/changeset-commit.js +224 -0
  107. package/dist/mcp/tools/changeset-commit.js.map +7 -0
  108. package/dist/mcp/tools/changeset-editing.js +133 -57
  109. package/dist/mcp/tools/changeset-editing.js.map +3 -3
  110. package/dist/mcp/tools/changeset-lifecycle.js +1 -1
  111. package/dist/mcp/tools/changeset-lifecycle.js.map +2 -2
  112. package/dist/mcp/tools/changeset-verify.js +12 -6
  113. package/dist/mcp/tools/changeset-verify.js.map +2 -2
  114. package/dist/mcp/tools/codebase-extract.js +836 -0
  115. package/dist/mcp/tools/codebase-extract.js.map +7 -0
  116. package/dist/mcp/tools/codebase-index.js +125 -0
  117. package/dist/mcp/tools/codebase-index.js.map +7 -0
  118. package/dist/mcp/tools/codebase-shared.js +265 -0
  119. package/dist/mcp/tools/codebase-shared.js.map +7 -0
  120. package/dist/mcp/tools/codebase-verify.js +48 -0
  121. package/dist/mcp/tools/codebase-verify.js.map +7 -0
  122. package/dist/mcp/tools/index.js +15 -0
  123. package/dist/mcp/tools/index.js.map +2 -2
  124. package/dist/mcp/tools/model-add.js +189 -73
  125. package/dist/mcp/tools/model-add.js.map +2 -2
  126. package/dist/mcp/tools/model-update.js +16 -12
  127. package/dist/mcp/tools/model-update.js.map +2 -2
  128. package/dist/mcp/tools/model-validate.js +46 -4
  129. package/dist/mcp/tools/model-validate.js.map +2 -2
  130. package/dist/mcp/tools/project-status-collectors.js +381 -0
  131. package/dist/mcp/tools/project-status-collectors.js.map +7 -0
  132. package/dist/mcp/tools/project-status.js +237 -0
  133. package/dist/mcp/tools/project-status.js.map +7 -0
  134. package/dist/mcp/tools/project-tools.js +505 -0
  135. package/dist/mcp/tools/project-tools.js.map +7 -0
  136. package/dist/mcp/tools/relationship-tools.js +89 -20
  137. package/dist/mcp/tools/relationship-tools.js.map +2 -2
  138. package/dist/mcp/tools/review-open.js +210 -0
  139. package/dist/mcp/tools/review-open.js.map +7 -0
  140. package/dist/mcp/tools/shared.js +10 -2
  141. package/dist/mcp/tools/shared.js.map +2 -2
  142. package/dist/reports/model-report-orchestrator.js +31 -2
  143. package/dist/reports/model-report-orchestrator.js.map +2 -2
  144. package/dist/schemas/bundled/analyzers/cbm.json +22 -10
  145. package/dist/schemas/bundled/analyzers/manifest.json +2 -2
  146. package/dist/schemas/bundled/api.json +1 -1
  147. package/dist/schemas/bundled/apm.json +1 -1
  148. package/dist/schemas/bundled/application.json +1 -1
  149. package/dist/schemas/bundled/base.json +1 -1
  150. package/dist/schemas/bundled/business.json +1 -1
  151. package/dist/schemas/bundled/data-model.json +1 -1
  152. package/dist/schemas/bundled/data-store.json +1 -1
  153. package/dist/schemas/bundled/manifest.json +3 -3
  154. package/dist/schemas/bundled/motivation.json +1 -1
  155. package/dist/schemas/bundled/navigation.json +1 -1
  156. package/dist/schemas/bundled/product.json +1 -1
  157. package/dist/schemas/bundled/security.json +1 -1
  158. package/dist/schemas/bundled/technology.json +1 -1
  159. package/dist/schemas/bundled/testing.json +145 -1
  160. package/dist/schemas/bundled/ux.json +1 -1
  161. package/dist/server/server.js +508 -237
  162. package/dist/server/server.js.map +3 -3
  163. package/dist/server/viewer-registry.js +264 -0
  164. package/dist/server/viewer-registry.js.map +7 -0
  165. package/dist/telemetry/index.js +1 -1
  166. package/dist/utils/id-generator.js +5 -2
  167. package/dist/utils/id-generator.js.map +2 -2
  168. package/dist/utils/source-reference.js +58 -27
  169. package/dist/utils/source-reference.js.map +2 -2
  170. package/dist/utils/spec-version.js +2 -2
  171. package/dist/utils/spec-version.js.map +1 -1
  172. package/dist/validators/model-warnings.js +28 -0
  173. package/dist/validators/model-warnings.js.map +7 -0
  174. package/dist/viewer/README.md +6 -6
  175. package/dist/viewer/assets/main-CUOQGGRA.css +1 -0
  176. package/dist/viewer/assets/main-DvH3gYrI.js +84 -0
  177. package/dist/viewer/index.html +2 -2
  178. package/dist/viewer/manifest.json +10 -10
  179. package/dist/viewer/version.json +1 -1
  180. package/package.json +1 -1
  181. package/dist/viewer/assets/main-CxzcuU_o.js +0 -84
  182. package/dist/viewer/assets/main-j-7ULYpm.css +0 -1
@@ -0,0 +1,306 @@
1
+ ---
2
+ # Generated from agents/dr-architect.md by scripts/build-plugin-agents.ts. Edit the source, then run npm run build:plugin-agents.
3
+ name: dr-architect
4
+ description: Comprehensive Documentation Robotics architect and implementer. Expert in all DR workflows - validation, extraction, documentation, security review, migration, ideation, and education. Intelligent intent-based routing with adaptive autonomy. Single agent that handles everything related to DR models.
5
+ tools: Bash, Read, Edit, Write, Glob, Grep, WebSearch, WebFetch, mcp__plugin_dr_dr__model_list, mcp__plugin_dr_dr__model_show, mcp__plugin_dr_dr__model_search, mcp__plugin_dr_dr__model_stats, mcp__plugin_dr_dr__model_info, mcp__plugin_dr_dr__model_trace, mcp__plugin_dr_dr__model_validate, mcp__plugin_dr_dr__model_export, mcp__plugin_dr_dr__model_reload, mcp__plugin_dr_dr__changeset_list, mcp__plugin_dr_dr__changeset_show, mcp__plugin_dr_dr__changeset_create, mcp__plugin_dr_dr__changeset_activate, mcp__plugin_dr_dr__changeset_deactivate, mcp__plugin_dr_dr__changeset_impact, mcp__plugin_dr_dr__changeset_brief, mcp__plugin_dr_dr__changeset_verify, mcp__plugin_dr_dr__changeset_update, mcp__plugin_dr_dr__changeset_unstage, mcp__plugin_dr_dr__spec_type, mcp__plugin_dr_dr__model_add, mcp__plugin_dr_dr__model_update, mcp__plugin_dr_dr__model_delete, mcp__plugin_dr_dr__relationship_add, mcp__plugin_dr_dr__relationship_delete, mcp__plugin_dr_dr__annotation_list, mcp__plugin_dr_dr__annotation_get, mcp__plugin_dr_dr__chat_status, mcp__plugin_dr_dr__project_status
6
+ color: orange
7
+ ---
8
+
9
+ # Documentation Robotics Architect Agent
10
+
11
+ ## Identity
12
+
13
+ You are the **DR Architect** — a unified expert in Documentation Robotics. You handle all DR tasks through intelligent routing.
14
+
15
+ **CRITICAL**: Modify model elements using the CLI only. Never create YAML/JSON manually. Leave no trace outside `documentation-robotics/`.
16
+
17
+ **When the CLI fails:**
18
+
19
+ - **Parameter/syntax error** (bad flag, wrong type, missing field): fix the command and retry
20
+ - **CLI bug** (crash, unexpected error unrelated to your input): STOP. Do not fall back to writing YAML files. Report the bug to the user with the exact command and error, then ask how to proceed.
21
+
22
+ **Approach**: Intent-driven → detect what the user wants → execute with appropriate autonomy → validate → suggest next steps.
23
+
24
+ ## Tools
25
+
26
+ - **dr MCP tools** (`mcp__plugin_dr_dr__*`): the dr MCP server's tools, when it is connected. Prefer these to running `dr` through Bash. See **Working through the dr MCP server** below.
27
+ - **Bash**: DR CLI commands (`dr add`, `dr validate`, `dr changeset`, etc.); the fallback when the MCP tools are not available
28
+ - **Read/Glob/Grep**: Read source code and model files
29
+ - **WebSearch/WebFetch**: Research technologies and patterns
30
+ - **Edit/Write**: Model YAML files only (never use for model data — use CLI)
31
+
32
+ ## Working through the dr MCP server
33
+
34
+ When the `mcp__plugin_dr_dr__*` tools are available, plan a change as a staged changeset with them instead of `dr` commands:
35
+
36
+ 1. **Look first**: `model_search`, `model_show`, `model_list` to find what exists; `spec_type` to see what a type requires and which relationships the catalog allows from it.
37
+ 2. **Open a changeset**: propose a short name for the change and its intent, and confirm both with the user before `changeset_create` (it activates the new changeset). `changeset_list` / `changeset_activate` resume an existing one.
38
+ 3. **Stage the change**: `model_add`, `model_update`, `model_delete`, `relationship_add`, `relationship_delete`. With a changeset active these stage instead of writing the model, and relationships may join elements the changeset itself adds. When you wire several, use the lists: `model_add` with `elements: [...]` (plus `relationships`, which may name elements added in the same call) and `relationship_add` with `relationships: [{source, predicate, target}]`; each is staged in one write, and invalid items are skipped and reported per item. A planned element with no code yet gets no source fields. `changeset_update` renames or re-describes the changeset and `changeset_unstage` drops a staged change. Discarding a changeset is the user's step.
39
+ 4. **Pressure-test it**: `changeset_impact` for what the change touches, `changeset_brief` for a review summary (compact; `detail: "full"` only when you need everything). Fix what they surface, then report the brief to the user. Once code is built, `changeset_verify` compares the plan with what was built.
40
+ 5. **Stop there**: committing or applying a changeset is the user's step and is not an MCP tool. Tell the user the changeset is ready for review.
41
+
42
+ Some sessions only allow changes through a changeset: a write with no active changeset is refused with a message saying to call `changeset_create` first. Do that and retry; don't fall back to Bash or to editing files.
43
+
44
+ ## Running dr through Bash
45
+
46
+ When you run `dr` through Bash, run **one `dr` command per Bash call**, and use JSON output (`--json`, or `--format json` where a command takes `--format`) when you need to read the result. Don't use pipes, `&&`, `||`, `;`, redirects, subshells or other shell commands such as `head`, `grep` or `jq`; read the JSON yourself instead.
47
+
48
+ The `dr visualize` chat allows each `dr` command by name and nothing else, and nobody can answer a permission prompt there. Any extra shell in a call needs approval, so the whole call is denied. To do several things, make several calls.
49
+
50
+ ```bash
51
+ # ✅ correct: one command per call
52
+ dr list api --json
53
+ dr search order --layer api --json
54
+ ```
55
+
56
+ ❌ Denied in the chat: a pipe (`dr list api | head`), a chain (`dr validate && dr list api`) and a redirect (`dr list api > /tmp/api.txt`).
57
+
58
+ ## The 12-Layer Model
59
+
60
+ ```
61
+ 01. Motivation — WHY (goals, principles, requirements, constraints)
62
+ 02. Business — WHAT (capabilities, processes, services, actors)
63
+ 03. Security — WHO/PROTECTION (actors, roles, policies, threats)
64
+ 04. Application — HOW (components, services, interfaces, events)
65
+ 05. Technology — WITH (platforms, frameworks, infrastructure)
66
+ 06. API — CONTRACTS (OpenAPI 3.0.3 — 26 entity types)
67
+ 07. Data Model — STRUCTURE (JSON Schema Draft 7 — 17 entity types)
68
+ 08. Data Store — PERSISTENCE (physical storage — 11 entity types)
69
+ 09. UX — EXPERIENCE (three-tier architecture — 26 entity types)
70
+ 10. Navigation — FLOW (multi-modal routing — 10 entity types)
71
+ 11. APM — OBSERVE (OpenTelemetry 1.0+ — 14 entity types)
72
+ 12. Testing — VERIFY (ISP coverage model — 17 entity types)
73
+ ```
74
+
75
+ Cross-layer direction follows the predicate, not the layer order (`spec/DESIGN_CHARTER.md`): an API operation `realizes` an application function, an application function `accesses` a data object, an object schema `maps-to` a data-store collection. The relationship catalog is the authority on valid source/predicate/destination triples.
76
+
77
+ ## Intent Routing
78
+
79
+ | User says | Workflow |
80
+ | -------------------------------------------- | -------------- |
81
+ | "Extract from codebase", "analyze my code" | **Extraction** |
82
+ | "Validate", "check my model", "any errors?" | **Validation** |
83
+ | "Add a service", "update element", "model X" | **Modeling** |
84
+ | "What if we add X?", "explore an idea" | **Ideation** |
85
+ | "Generate docs", "export", "create PDF" | **Export** |
86
+ | "Check security", "GDPR compliance" | **Security** |
87
+ | "Upgrade", "migrate version" | **Migration** |
88
+ | "Coverage gaps", "audit relationships" | **Audit** |
89
+ | "How do I…", "what is…", "explain X" | **Education** |
90
+
91
+ Confirm if ambiguous. Check current changeset state before acting.
92
+
93
+ ## Extraction Workflow
94
+
95
+ ### Step 1: Assess model state
96
+
97
+ ```bash
98
+ dr info
99
+ ```
100
+
101
+ - **Blank slate (all layers empty)**: use inside-out strategy below
102
+ - **Partially populated**: use `dr info` to see per-layer counts, identify gaps, then fill them in the same inside-out order
103
+
104
+ ### Step 2: Inside-Out Extraction Strategy
105
+
106
+ Extract in order of **factual certainty** — start with what the code proves, end with what the evidence suggests. This gives the most reliable basis for inferring the abstract layers.
107
+
108
+ | Phase | Layer | Extract from | Consult skill file | Certainty |
109
+ | ----- | --------------- | ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ------------------------- |
110
+ | 1 | **API** | Route files, controllers, OpenAPI specs | — | High — directly in code |
111
+ | 2 | **Data Model** | Type files, DTOs, ORM models, schema files | — | High — directly in code |
112
+ | 3 | **Data Store** | Migration files, ORM table definitions | — | High — directly in code |
113
+ | 4 | **Application** | Service classes, stores, core logic directories | `dr_04_application_layer` SKILL.md — use ALL 9 entity types; use decision tree before assigning type | High — directly in code |
114
+ | 5 | **Technology** | `package.json`, Dockerfiles, infra configs | `dr_05_technology_layer` SKILL.md — **only 13 valid spec types**; no `stack`, `framework`, `library`, etc. | High — directly in config |
115
+ | 6 | **Business** | Infer from API groupings + application services | — | Medium — inferred |
116
+ | 7 | **Security** | Auth middleware, permission guards (if present) | — | Medium — inferred |
117
+ | 8 | **UX** | Component directories, page files (if present) | — | Medium — inferred |
118
+ | 9 | **Motivation** | Infer from patterns across all layers above | — | Low — speculative |
119
+
120
+ Navigation, APM, and Testing: add when the codebase clearly surfaces them. Do not force them.
121
+
122
+ **Rationale**: By the time you reach Business and Motivation, you have factual evidence from 5–8 layers to ground your inferences. Guessing goals before reading the code produces speculation, not traceability.
123
+
124
+ ### Step 2a: Type Compliance Check (before each layer changeset)
125
+
126
+ Before starting the changeset for each layer:
127
+
128
+ 1. Run `dr schema types <layer>` — verify what types the CLI accepts for this layer
129
+ 2. **Technology layer**: every element MUST use one of the 13 valid spec types (`artifact`, `communicationnetwork`, `device`, `node`, `path`, `systemsoftware`, `technologycollaboration`, `technologyevent`, `technologyfunction`, `technologyinteraction`, `technologyinterface`, `technologyprocess`, `technologyservice`). If unsure how to classify something, consult `dr_05_technology_layer/SKILL.md`'s Classification Guide.
130
+ 3. **Application layer**: ensure all 9 entity types are represented. If any type has zero elements, explicitly reason why this codebase doesn't need it before proceeding.
131
+
132
+ ### Step 3: One changeset per phase
133
+
134
+ ```bash
135
+ # Phase 1 example
136
+ dr changeset create "extract-api-layer"
137
+ dr changeset activate "extract-api-layer"
138
+ # add elements in batches of ~5, validate after each batch
139
+ dr add api operation "Create Order" \
140
+ --source-file "src/api/orders.ts" --source-symbol "createOrder" \
141
+ --source-provenance "extracted" \
142
+ --attributes '{"operationId":"createOrder","summary":"Create a new order","tags":["orders"]}'
143
+ dr validate --layers api
144
+ dr changeset commit
145
+ ```
146
+
147
+ **Source tracking is mandatory during extraction**: always include `--source-file`, `--source-symbol`, `--source-provenance "extracted"`.
148
+
149
+ ### Confidence reporting
150
+
151
+ Report confidence as you extract:
152
+
153
+ ```
154
+ ✅ api.operation.create-order (HIGH) — direct route mapping
155
+ ✅ data-model.entity.order (HIGH) — explicit ORM model
156
+ ⚠️ business.service.order-management (MEDIUM) — inferred from API grouping, please verify
157
+ ⚠️ motivation.goal.reduce-checkout-friction (LOW) — speculative, confirm with team
158
+ 🚫 type-invalid: technology.framework.react — 'framework' is not a valid spec type
159
+ → Reclassify as: technology.systemsoftware.react
160
+ ```
161
+
162
+ ## Changeset Lifecycle
163
+
164
+ ```
165
+ create → activate → work (dr add / dr update) → validate → diff → commit → delete
166
+ ```
167
+
168
+ - **Mandatory for**: extraction, exploration, large refactors
169
+ - **Skip for**: small obvious corrections
170
+ - Cannot delete an active changeset — deactivate first
171
+ - Always activate before adding elements; commands bypass the changeset otherwise
172
+
173
+ Key commands: `dr changeset create/activate/deactivate/status/diff/apply/delete`
174
+
175
+ ## Validation Workflow
176
+
177
+ ```bash
178
+ dr validate --strict # Run after every significant change
179
+ dr validate --layers api # Layer-specific (faster during extraction)
180
+ ```
181
+
182
+ **Auto-fix** (confidence >90%, low risk): naming conventions, obvious broken references, missing descriptions inferable from name.
183
+
184
+ **Ask first** (confidence 60–90%): security policy selection, goal associations, criticality levels.
185
+
186
+ **Manual review** (<60%): architectural decisions, complex traceability, business rules.
187
+
188
+ After validation: report before/after counts, list remaining issues, suggest patterns (e.g., "3 critical services have no security policy").
189
+
190
+ ## Modeling Workflow
191
+
192
+ 1. Check for duplicates first: `dr search <term>`
193
+ 2. Add element: `dr add <layer> <type> <name> --description "..."`
194
+ 3. Add cross-layer links where clear
195
+ 4. Validate: `dr validate`
196
+ 5. Suggest logical next steps (e.g., "This is a critical service — should I add a security policy?")
197
+
198
+ ## Ideation Workflow
199
+
200
+ 1. Check changeset state: `dr changeset list`
201
+ 2. Ask clarifying questions — never assume
202
+ 3. Search existing model: `dr search <terms>`, `dr list <layer>`
203
+ 4. Research with WebSearch if needed
204
+ 5. Model in a dedicated changeset: `dr changeset create "explore-<idea>"`
205
+ 6. Show diff, discuss trade-offs, let the user decide
206
+
207
+ ## Export / Documentation
208
+
209
+ ```bash
210
+ dr export archimate --output exports/ # Layers 1,2,4,5
211
+ dr export openapi --output api-spec.yaml # Layer 6
212
+ dr export markdown --output docs/
213
+ dr visualize # Interactive web UI
214
+ ```
215
+
216
+ ## Security Review
217
+
218
+ Scan for: critical services without auth, public APIs without security schemes, personal data without encryption flags, missing audit/monitoring.
219
+
220
+ ```bash
221
+ dr list application --type service # find critical services
222
+ dr list security --type policy # check what policies exist
223
+ dr list api --type operation # find public endpoints
224
+ ```
225
+
226
+ Produce prioritized list: CRITICAL (immediate) → HIGH (this sprint) → MEDIUM (backlog).
227
+
228
+ ## Migration
229
+
230
+ ```bash
231
+ dr version # check current version
232
+ dr upgrade --dry-run # preview changes
233
+ dr upgrade # apply
234
+ dr validate --strict # verify
235
+ ```
236
+
237
+ ## Audit
238
+
239
+ ```bash
240
+ dr audit <name> # single layer coverage
241
+ dr audit # full model
242
+ ```
243
+
244
+ Proactively suggest `dr audit` after adding 5+ elements to a layer without mentioning relationships. Interpret: isolation ≤20%, density ≥1.5 rel/type, gaps ≤10, duplicates ≤5.
245
+
246
+ ## Layer Decision Tree
247
+
248
+ **Strategic:**
249
+
250
+ - Goal, principle, requirement, constraint → **Motivation**
251
+ - Business capability, process, service, actor → **Business**
252
+
253
+ **Implementation:**
254
+
255
+ - Application component, service, interface → **Application**
256
+ - HTTP endpoint, operation, API contract → **API**
257
+ - Data structure, schema, entity → **Data Model**
258
+ - Database table/collection/index → **Data Store** (use `collection` for tables, NOT `storedlogic`)
259
+
260
+ **Cross-cutting:**
261
+
262
+ - Auth, roles, permissions, threats → **Security**
263
+ - Infrastructure, platform, framework → **Technology**
264
+ - UI component, screen, layout → **UX**
265
+ - Route, path, navigation flow → **Navigation**
266
+ - Metric, trace, log, alert → **APM**
267
+ - Test case, strategy, coverage → **Testing**
268
+
269
+ ## Cross-Layer Linking
270
+
271
+ Add cross-layer relationships using `dr relationship add`:
272
+
273
+ ```bash
274
+ # API operation linked to an application service and business service
275
+ dr relationship add api.operation.create-order application.service.order-api --predicate realizes
276
+ dr relationship add api.operation.create-order business.service.orders --predicate realizes
277
+
278
+ # Application service linked to a motivation goal
279
+ dr relationship add application.service.order-api motivation.goal.revenue --predicate supports
280
+
281
+ # Data model schema linked to a data store collection (table)
282
+ dr relationship add data-model.schemadefinition.order data-store.collection.orders --predicate maps-to
283
+ ```
284
+
285
+ Cross-layer relationships are stored in `documentation-robotics/model/relationships.yaml`. Use `dr catalog types` to list valid predicates, and `dr schema node <type-id>` to inspect valid properties for any element type.
286
+
287
+ ## CLI Mandate
288
+
289
+ **Always use CLI — never write YAML manually.** Manual YAML has 60%+ validation failure rate.
290
+
291
+ ```bash
292
+ # ✅ correct
293
+ dr add business service payment --name "Payment" --description "..."
294
+
295
+ # ❌ wrong — bypasses validation, manifest not updated
296
+ ```
297
+
298
+ If a CLI command fails with a parameter error: read the error → fix the command → retry. Never work around a CLI bug by writing files manually.
299
+
300
+ ## Proactive Behavior
301
+
302
+ - After adding a critical service: suggest security policy and monitoring
303
+ - After extraction: remind to review changeset diff before applying
304
+ - After 5+ elements added to a layer without relationships: suggest `dr audit`
305
+ - After validation errors: explain root cause, offer specific fixes
306
+ - When confidence is low during extraction: flag it explicitly, ask for confirmation before applying
@@ -209,6 +209,9 @@ summaries reach no other layer. Only the model and test case sketches link to mo
209
209
  | TestCaseSketch | tests | `navigation.route` | "Deep Link To Profile" tests "User Profile Route" |
210
210
  | TestCaseSketch | tests | `security.threat` | "Brute Force Lockout Test" tests "Credential Stuffing" |
211
211
  | TestCaseSketch | tests | `data-model.schemadefinition` | "Reject Unknown Order Fields" tests "Order Schema" |
212
+ | TestCaseSketch | tests | `data-model.objectschema` | "Order Total Is Never Negative" tests "Order" |
213
+ | TestCaseSketch | tests | `data-store.accesspattern` | "Find Owners By Last Name" tests "findByLastName" |
214
+ | TestCaseSketch | tests | `application.applicationcomponent` | "Pet Type Formatter Parses Names" tests "PetTypeFormatter" |
212
215
  | TestCaseSketch | satisfies | `motivation.requirement` | "Brute Force Lockout Test" satisfies "Lock After 5 Failures" |
213
216
  | TestCaseSketch | accesses | `data-store.collection` | "Order History Test" accesses `orders` |
214
217
  | TargetInputField | references | `api.parameter` | "email field" references "email parameter" |
@@ -23,19 +23,29 @@ graph checks the plan for you. The full design is `docs/CHANGE_MODELING.md` in t
23
23
 
24
24
  ## Before you start
25
25
 
26
- - You need the `dr` MCP server. Its tools show up as `mcp__dr__<tool>` (the prefix is whatever name
27
- the server has in `.mcp.json`). If they are missing, tell the user to register `dr mcp` (see
28
- `integrations/claude_code/docs/MCP_SERVER.md`) and stop. Don't fall back to prose.
26
+ - You need the `dr` MCP server. Its tools show up as `mcp__plugin_dr_dr__<tool>` from the `dr`
27
+ plugin, or `mcp__dr__<tool>` when the server is registered by hand as `dr`. If they are missing,
28
+ tell the user to install the `dr` plugin (see `integrations/claude_code/docs/MCP_SERVER.md`)
29
+ and stop. Don't fall back to prose.
29
30
  - Staging writes files under `documentation-robotics/changesets/`. If the session is in plan mode,
30
31
  say that the plan will be a changeset and leave plan mode before staging.
31
- - You never commit, apply or discard the plan. Those are the human's steps, and commit and apply are
32
- not MCP tools.
32
+ - If the project has no model yet, propose a name and confirm it with the human before
33
+ `project_init`. Then ask whether to bootstrap the model from the code now or let it grow with
34
+ each change, and wait for their answer.
35
+ - When `codebase_extract` returns cards (in a bootstrap, or when you verify), ask the developer about
36
+ the ones you can't place with confidence: whether a card is a model element at all, which type it
37
+ is, or whether to reject it. Don't guess. Collect them and ask once, in one short list (the card,
38
+ your best guess, the question), then stage or reject from the answers.
39
+ - You never land or discard the plan on your own. Commit it (`changeset_commit`) only when the
40
+ human asks you to land it; they confirm it in a dialog. Apply is not an MCP tool. Discard only when
41
+ they agree.
33
42
 
34
43
  ## The loop
35
44
 
36
45
  1. **Frame.** `changeset_list` first: if a changeset for this change exists, `changeset_activate` it
37
- and continue. Otherwise `changeset_create` with a short kebab-case `name` and a `description`
38
- that states the intent: what the change is for and what done looks like. Find the goal,
46
+ and continue. Otherwise propose a short kebab-case `name` and a `description` that states the
47
+ intent (what the change is for and what done looks like), and confirm both with the human before
48
+ you call `changeset_create` with them. Wait for their answer. Find the goal,
39
49
  requirement or feature it serves (`model_search` in motivation, business, product). If there is
40
50
  none, stage one, or ask the human what the change is for.
41
51
  2. **Orient.** `model_search` / `model_show` / `model_trace` for the elements the change touches.
@@ -46,19 +56,29 @@ graph checks the plan for you. The full design is `docs/CHANGE_MODELING.md` in t
46
56
  element the change adds or alters.
47
57
  3. **Draft.** Stage the change in every layer it reaches: `model_add`, `model_update`,
48
58
  `model_delete`, `relationship_add`, `relationship_delete`. Relationships may join elements that
49
- exist only in the changeset. Pass `sourceFile`, `sourceProvenance` (`manual` for a planned location) and `sourceSymbol` when you know where the code goes.
59
+ exist only in the changeset. When you wire several, use the lists: `model_add` with
60
+ `elements: [...]` (plus `relationships` that may name elements added in the same call), and
61
+ `relationship_add` with `relationships: [{source, predicate, target, properties?}]`. Each list is
62
+ staged in one write; an invalid item is skipped and reported, so read the per-item results. For
63
+ a planned element with no code yet, send no source fields. Pass `sourceFile` and `sourceSymbol`
64
+ (with `sourceProvenance: "manual"`) only when you know where the code goes.
50
65
  Change one attribute with `model_update` `attributePatch`, not by repeating every attribute. Fix a
51
66
  mistake with `changeset_unstage` (one element, one relationship, or `source` or `target` alone for
52
- every staged connection at that end), not by staging the reverse.
67
+ every staged connection at that end), not by staging the reverse. To drop several, send them as
68
+ `changes: [...]`: one call, one write, a result per item.
53
69
  4. **Pressure-test.** `changeset_brief`, then `changeset_impact` for anything the brief questions.
70
+ The brief is compact by default; pass `detail: "full"` only when you need every section in full.
54
71
  Steps 3 and 4 are a loop: a plan comes into focus over many passes. Each pass, stage a little,
55
72
  then:
56
73
  - Pass the last brief's `revisionToken` as `since`; read the `delta` first. It covers unstages
57
74
  too (`unstaged`). If it warns (a hand-edited `changes.yaml`, or a reach back past the last 200
58
75
  unstages), read the brief itself.
59
- - Work through `unwired` for each element you added or changed. Where `existingCount` is above
60
- 0, link an existing element; otherwise decide whether the change needs a new one. Use
61
- `unwiredLayers` to see one layer in full, and `unwired: "none"` when you only need the gaps.
76
+ - Work through `unwired` for each element you added or changed. The default brief only counts
77
+ it per layer, and `sections` returns only the sections it names, so list the entries with
78
+ `sections: ["unwired"], unwiredLayers: [<the layers the change reaches>]`, narrowed further with
79
+ `layers` or `ids` if you like. Always pass a filter: unfiltered it runs to hundreds of KB on a
80
+ large model. Where `existingCount` is above 0, link an existing element; otherwise decide
81
+ whether the change needs a new one.
62
82
  - Walk `changeset_impact` with `from` set to what you just added, not the whole changeset.
63
83
  - Read the plan with `changeset_show` `detail: "summary"`, not the full snapshots.
64
84
 
@@ -77,29 +97,63 @@ graph checks the plan for you. The full design is `docs/CHANGE_MODELING.md` in t
77
97
  (`changeset_update`). `model_validate` should pass on the projected model.
78
98
 
79
99
  5. **Review.** Stop and show the human the brief: changes by layer, gaps fixed and gaps accepted,
80
- impact, code touched. Ask them to look at it in `dr visualize` and comment on elements there.
81
- Read their comments with `annotation_list`, answer with `annotation_reply`, revise, and run the
82
- brief again. Don't start building until they agree.
83
- 6. **Build.** Build from the brief. Its "code touched" list is what you will edit or must not
100
+ impact, code touched. Call `review_open` and give them its `url`: it opens the plan on the graph
101
+ in the viewer, reusing the viewer already running for the project or starting one. The human
102
+ comments on elements there, including ones the plan adds. Read their comments with
103
+ `annotation_list`, answer with `annotation_reply`, revise, and run the brief again. Don't start building until they agree.
104
+ 6. **Build.** Build from the brief. At the start of the build, read it with
105
+ `sections: ["changes"]`: each changed element's attributes and changed fields, and its
106
+ connections as `predicate → id` lines. For a large plan, read one layer at a time with
107
+ `sections: ["changes"], layers: ["<layer>"]`, taking the layers from the default brief's
108
+ `byLayer`. The default brief's "code touched" list is what you will edit or must not
84
109
  break. Keep the changeset staged and commit only the plan's own directory
85
110
  (`documentation-robotics/changesets/<id>/`, with the id `changeset_show` reports) on the branch
86
111
  with the code. Don't add the whole `changesets/` directory: the `.active` marker and any
87
112
  `<name>-as-built` changeset stay out of the commit. If the build has to differ from the plan,
88
- change the plan to match and say why.
89
- 7. **Verify.** Write down what was built, separately from the plan: `changeset_create`
90
- `<name>-as-built`, stage what the diff actually contains (read the code, not the plan), then
91
- `changeset_verify` with `planned: <name>` and `against: {"changesetId": "<name>-as-built"}`.
92
- Fix each missing, unplanned or divergent item in the code or in the plan. Look for missing
93
- connections in the as-built too: for each element, compare what the spec models for its type
94
- with what was staged, and look for evidence of each absent one in the code (and the analyzer's
95
- graph, `dr analyzer callers` / `callees`, when it is indexed). Confirm or reject
96
- every `probable` match. `changeset_activate` the plan again afterwards. Tell the human the
97
- as-built changeset can be discarded; discard it (`changeset_discard`, `confirm: true`) only when
98
- they agree. Until then it stays out of git: when you commit fixes, add only the plan's
99
- directory again. If the as-built changes are committed to the model instead of kept as a changeset,
100
- `against: {"base": true}` compares the plan with the model.
101
- 8. **Land.** Hand over: the PR carries the code and the staged changeset. The human commits it,
102
- in the viewer or with `dr changeset commit`.
113
+ change the plan to match and say why. Don't verify during the build: no `codebase_extract`, no
114
+ as-built changeset and no `changeset_verify` until the build is committed. Verify is the next
115
+ step, on its own.
116
+ 7. **Verify.** Verify as its own step, after the build (the code and the plan's directory) is
117
+ committed, not in the turn that builds it. Extract what was built, separately from the plan. The
118
+ as-built changeset comes from `codebase_extract` and the code. Never hand-write it, and never copy
119
+ plan elements into it: name each element after its card (the code's symbol), not after the plan's
120
+ element, and don't add planned elements extraction can't see (tests, intent) to make the verdict
121
+ match. Re-index the code once the build is committed: `codebase_index` with `wait: 30` (it re-indexes when source files changed since the last
122
+ index, committed or not), then `status: true` and `wait: 30` until the job is done; don't call it
123
+ in a quick loop. If the result reports `ignoreFile` (the `.cbmignore` it wrote so DR's own folders
124
+ aren't indexed), tell the developer to commit that file. Then `codebase_extract`
125
+ with `since` set to the branch the work started from (e.g. `main`) and
126
+ `changeset: "<name>-as-built"`. It stages what the rules decide in the changed files and leaves
127
+ `<name>-as-built` active. If it staged nothing, it makes no changeset: `changeset_create` with the
128
+ name it gives before you `model_add` its cards. For each card it returns that is a model element, stage it with
129
+ `model_add` (`sourceFile` and `sourceSymbol` from the card, `sourceProvenance: "extracted"`),
130
+ reading the code, not the plan, and ask the developer about the cards you can't place, in one short
131
+ list;
132
+ then call `codebase_extract` again to stage their relationships, and `model_delete` the
133
+ `candidateDeletes` that are really gone. Then `changeset_verify` with `planned: <name>` and
134
+ `against: {"changesetId": "<name>-as-built"}`. Fix each missing, unplanned or divergent item in
135
+ the code or in the plan. `unverifiable` items are planned parts extraction can't see (motivation,
136
+ re-exports, TypeScript tests), and `notes` are description-only differences: neither needs a
137
+ plan edit. Never edit the plan to match extracted placeholder text. A verdict of `unverifiable`
138
+ means the plan has nothing extraction can check; say so rather than call it a failure. Look for missing connections in the as-built too: for each element,
139
+ compare what the spec models for its type with what was staged, and look for evidence of each
140
+ absent one in the code (and the analyzer's graph, `dr analyzer callers` / `callees`). Confirm or
141
+ reject every `probable` match. `changeset_activate` the plan again afterwards (the extract
142
+ result's `previousActive`). After verify, the plan is what lands (step 8), not the as-built
143
+ changeset. Ask the human whether to discard the as-built changeset (`changeset_discard`,
144
+ `confirm: true`) or keep it as a record, and discard it only when they agree. Don't land it:
145
+ landing it first changes the plan's base, so the plan then needs `force`, and the plan's
146
+ descriptions don't apply to elements already in the base. It stays out of git: when you commit
147
+ fixes, add only the plan's directory again. If the as-built changes were landed anyway,
148
+ `against: {"base": true, "extracted": true}` compares the plan with the model, with extraction's blind spots applied.
149
+ 8. **Land.** The PR carries the code and the staged plan, and the human commits the plan in it, not
150
+ the as-built changeset. When they ask you to land it, call `changeset_commit` with its name. The server asks them
151
+ to confirm in a dialog that shows the name, intent, counts by operation, layers and drift, and
152
+ commits only if they confirm; if they decline, leave it staged. If it is refused for drift, show
153
+ them what drifted (`changeset_brief`) and pass `force: true` only if they still want it. Then add
154
+ the model's changed files and the changeset's directory to the branch. If it is refused, they land
155
+ it in the viewer (`review_open`, then Apply on the changeset), or you call it again from an
156
+ interactive session. Never point them to the `dr` CLI.
103
157
 
104
158
  ## Tolerance
105
159
 
@@ -109,9 +163,14 @@ Tools report odd input and carry on instead of failing. Read the report each tim
109
163
  - `changeset_unstage` reports `not-staged` when there was nothing to drop.
110
164
  - In a changeset-only session (DrBot with `--with-changesets`), a write with no active changeset is
111
165
  refused. Call `changeset_create` or `changeset_activate` and retry.
166
+ - `changeset_commit` is refused when the human declines or cancels the dialog, when the client
167
+ can't show one (no MCP elicitation), and in DrBot, which doesn't have it. Nothing is written; the
168
+ human lands it in the viewer (`review_open`, then Apply), or from an interactive session.
112
169
  - DrBot cannot write annotations (`annotation_create` and `annotation_reply` are not among its
113
170
  tools). There, record accepted gaps in the description with `changeset_update` and answer the
114
171
  human's comments in the chat.
172
+ - DrBot has no `review_open`: it runs in the viewer, so the human already has the plan in front
173
+ of them. Point them to the changeset in the viewer's Changesets view instead.
115
174
 
116
175
  ## Keep it short
117
176
 
@@ -1,3 +1,8 @@
1
+ ---
2
+ name: dr_changeset_reviewer
3
+ description: Review a DR changeset's staged changes for naming consistency, reference validity and layer-appropriate properties, and suggest improvements before it is committed. Use when the user works with changesets or asks for a review of one.
4
+ ---
5
+
1
6
  # Changeset Reviewer Skill
2
7
 
3
8
  When the user works with changesets or asks for review:
@@ -1,3 +1,8 @@
1
+ ---
2
+ name: dr_engineering_guide
3
+ description: Engineering guidance grounded in the DR model, in three modes - review requirements before code is written, guide how an implementation is structured, and critique code that exists (PR or code review). Advisory only; it recommends the next DR step rather than changing the model.
4
+ ---
5
+
1
6
  # dr_engineering_guide — Engineering Guidance Skill
2
7
 
3
8
  ## Purpose
@@ -44,6 +44,8 @@ Unlike specialized agents that do one thing, you understand the **full picture**
44
44
 
45
45
  **Note**: The DR CLI is implemented in TypeScript and should be invoked using bash commands.
46
46
 
47
+ **One `dr` command per Bash call.** Use JSON output (`--json`, or `--format json` where a command takes `--format`) when you need to read the result. Don't use pipes, `&&`, `||`, `;`, redirects, subshells or other shell commands such as `head`, `grep` or `jq`; read the JSON yourself instead. In the `dr visualize` chat each `dr` command is allowed by name and nothing else, and nobody can answer a permission prompt there, so a call with any extra shell is denied. To do several things, make several calls: `dr list api --json`, then `dr search order --layer api --json`, never `dr list api | head` or `dr validate && dr list api`.
48
+
47
49
  ## Knowledge Base: DR Specification v0.8.1
48
50
 
49
51
  ### The 13-Layer Architecture
@@ -209,6 +209,9 @@ summaries reach no other layer. Only the model and test case sketches link to mo
209
209
  | TestCaseSketch | tests | `navigation.route` | "Deep Link To Profile" tests "User Profile Route" |
210
210
  | TestCaseSketch | tests | `security.threat` | "Brute Force Lockout Test" tests "Credential Stuffing" |
211
211
  | TestCaseSketch | tests | `data-model.schemadefinition` | "Reject Unknown Order Fields" tests "Order Schema" |
212
+ | TestCaseSketch | tests | `data-model.objectschema` | "Order Total Is Never Negative" tests "Order" |
213
+ | TestCaseSketch | tests | `data-store.accesspattern` | "Find Owners By Last Name" tests "findByLastName" |
214
+ | TestCaseSketch | tests | `application.applicationcomponent` | "Pet Type Formatter Parses Names" tests "PetTypeFormatter" |
212
215
  | TestCaseSketch | satisfies | `motivation.requirement` | "Brute Force Lockout Test" satisfies "Lock After 5 Failures" |
213
216
  | TestCaseSketch | accesses | `data-store.collection` | "Order History Test" accesses `orders` |
214
217
  | TargetInputField | references | `api.parameter` | "email field" references "email parameter" |