@ludecker/aaac 1.0.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 (110) hide show
  1. package/README.md +60 -0
  2. package/package.json +38 -0
  3. package/src/cli.mjs +138 -0
  4. package/src/generators/generate-commands.mjs +165 -0
  5. package/src/generators/generate-graph-commands.mjs +63 -0
  6. package/src/generators/generate-graph.mjs +242 -0
  7. package/src/lib/copy.mjs +36 -0
  8. package/src/lib/install.mjs +76 -0
  9. package/src/lib/paths.mjs +54 -0
  10. package/templates/cursor/aaac/capabilities/registry.json +106 -0
  11. package/templates/cursor/aaac/contract-schema.md +66 -0
  12. package/templates/cursor/aaac/contracts/commands/create-module.yaml +28 -0
  13. package/templates/cursor/aaac/contracts/commands/fix-bug.yaml +32 -0
  14. package/templates/cursor/aaac/contracts/commands/update-module.yaml +28 -0
  15. package/templates/cursor/aaac/contracts/skills/impact-analysis.yaml +17 -0
  16. package/templates/cursor/aaac/contracts/skills/investigation-lite.yaml +17 -0
  17. package/templates/cursor/aaac/contracts/skills/investigation.yaml +17 -0
  18. package/templates/cursor/aaac/contracts/skills/validation.yaml +14 -0
  19. package/templates/cursor/aaac/dependencies.yaml +14 -0
  20. package/templates/cursor/aaac/dispatch.md +135 -0
  21. package/templates/cursor/aaac/fitness-functions.yaml +34 -0
  22. package/templates/cursor/aaac/governance/gates.json +39 -0
  23. package/templates/cursor/aaac/graph.project.yaml +161 -0
  24. package/templates/cursor/aaac/layers.md +93 -0
  25. package/templates/cursor/aaac/lifecycle/lifecycle.json +78 -0
  26. package/templates/cursor/aaac/lifecycle/phases.json +19 -0
  27. package/templates/cursor/aaac/ontology.json +219 -0
  28. package/templates/cursor/aaac/ontology.md +90 -0
  29. package/templates/cursor/aaac/project.config.json +3 -0
  30. package/templates/cursor/aaac/run/RUN.md +72 -0
  31. package/templates/cursor/aaac/run/schema.json +83 -0
  32. package/templates/cursor/aaac/state/checkpoints/README.md +20 -0
  33. package/templates/cursor/agents/boundary-review.md +11 -0
  34. package/templates/cursor/agents/check-capability-trace.md +18 -0
  35. package/templates/cursor/agents/dependency-analysis.md +11 -0
  36. package/templates/cursor/agents/discovery-boundaries.md +11 -0
  37. package/templates/cursor/agents/discovery-inventory.md +14 -0
  38. package/templates/cursor/agents/discovery-ssot.md +11 -0
  39. package/templates/cursor/agents/fallow-check-changed.md +9 -0
  40. package/templates/cursor/agents/impact-analysis.md +22 -0
  41. package/templates/cursor/agents/plan-layer-map.md +11 -0
  42. package/templates/cursor/agents/plan-state-machines.md +11 -0
  43. package/templates/cursor/agents/release-git.md +36 -0
  44. package/templates/cursor/agents/system-decomposition.md +11 -0
  45. package/templates/cursor/agents/unit-test-run.md +19 -0
  46. package/templates/cursor/policies/implementation.md +8 -0
  47. package/templates/cursor/policies/master-rules.md +7 -0
  48. package/templates/cursor/skills/shared/api/SKILL.md +26 -0
  49. package/templates/cursor/skills/shared/architecture/SKILL.md +25 -0
  50. package/templates/cursor/skills/shared/architecture/orchestrator/SKILL.md +21 -0
  51. package/templates/cursor/skills/shared/architecture/refactor-analysis.md +302 -0
  52. package/templates/cursor/skills/shared/check/SKILL.md +47 -0
  53. package/templates/cursor/skills/shared/component/SKILL.md +24 -0
  54. package/templates/cursor/skills/shared/dependency-graph/SKILL.md +38 -0
  55. package/templates/cursor/skills/shared/discovery/SKILL.md +29 -0
  56. package/templates/cursor/skills/shared/documentation/SKILL.md +21 -0
  57. package/templates/cursor/skills/shared/documentation/orchestrator/SKILL.md +26 -0
  58. package/templates/cursor/skills/shared/documentation/orchestrator/contract.yaml +20 -0
  59. package/templates/cursor/skills/shared/documentation/write-arch-doc.md +168 -0
  60. package/templates/cursor/skills/shared/domain/SKILL.md +24 -0
  61. package/templates/cursor/skills/shared/execution/SKILL.md +34 -0
  62. package/templates/cursor/skills/shared/fitness-functions/SKILL.md +42 -0
  63. package/templates/cursor/skills/shared/governance/implementation/SKILL.md +424 -0
  64. package/templates/cursor/skills/shared/impact-analysis/SKILL.md +44 -0
  65. package/templates/cursor/skills/shared/integration/SKILL.md +22 -0
  66. package/templates/cursor/skills/shared/investigation/SKILL.md +46 -0
  67. package/templates/cursor/skills/shared/investigation/orchestrator/SKILL.md +22 -0
  68. package/templates/cursor/skills/shared/investigation-lite/SKILL.md +38 -0
  69. package/templates/cursor/skills/shared/migration/SKILL.md +22 -0
  70. package/templates/cursor/skills/shared/model/SKILL.md +22 -0
  71. package/templates/cursor/skills/shared/module-authoring/SKILL.md +29 -0
  72. package/templates/cursor/skills/shared/module-authoring/authoring-template.md +9 -0
  73. package/templates/cursor/skills/shared/planning/SKILL.md +30 -0
  74. package/templates/cursor/skills/shared/platform-release/SKILL.md +46 -0
  75. package/templates/cursor/skills/shared/platform-release/orchestrator/SKILL.md +51 -0
  76. package/templates/cursor/skills/shared/platform-release/orchestrator/contract.yaml +29 -0
  77. package/templates/cursor/skills/shared/platform-release/ship-procedure.md +31 -0
  78. package/templates/cursor/skills/shared/remove/SKILL.md +28 -0
  79. package/templates/cursor/skills/shared/reporting/SKILL.md +43 -0
  80. package/templates/cursor/skills/shared/rollback/SKILL.md +46 -0
  81. package/templates/cursor/skills/shared/root-cause/SKILL.md +24 -0
  82. package/templates/cursor/skills/shared/run/SKILL.md +64 -0
  83. package/templates/cursor/skills/shared/schema/SKILL.md +24 -0
  84. package/templates/cursor/skills/shared/testing/SKILL.md +24 -0
  85. package/templates/cursor/skills/shared/testing/orchestrator/SKILL.md +22 -0
  86. package/templates/cursor/skills/shared/validation/SKILL.md +56 -0
  87. package/templates/cursor/skills/shared/verbs/_dispatch-utils.md +90 -0
  88. package/templates/cursor/skills/shared/verbs/_lifecycle.md +87 -0
  89. package/templates/cursor/skills/shared/verbs/_object-skills.md +60 -0
  90. package/templates/cursor/skills/shared/verbs/check/orchestrator/SKILL.md +22 -0
  91. package/templates/cursor/skills/shared/verbs/check/orchestrator/contract.yaml +24 -0
  92. package/templates/cursor/skills/shared/verbs/create/orchestrator/SKILL.md +39 -0
  93. package/templates/cursor/skills/shared/verbs/create/orchestrator/contract.yaml +34 -0
  94. package/templates/cursor/skills/shared/verbs/fix/orchestrator/SKILL.md +33 -0
  95. package/templates/cursor/skills/shared/verbs/fix/orchestrator/contract.yaml +38 -0
  96. package/templates/cursor/skills/shared/verbs/release/orchestrator/SKILL.md +29 -0
  97. package/templates/cursor/skills/shared/verbs/release/orchestrator/contract.yaml +25 -0
  98. package/templates/cursor/skills/shared/verbs/remove/orchestrator/SKILL.md +25 -0
  99. package/templates/cursor/skills/shared/verbs/remove/orchestrator/contract.yaml +32 -0
  100. package/templates/cursor/skills/shared/verbs/review/orchestrator/SKILL.md +24 -0
  101. package/templates/cursor/skills/shared/verbs/review/orchestrator/contract.yaml +25 -0
  102. package/templates/cursor/skills/shared/verbs/test/orchestrator/SKILL.md +24 -0
  103. package/templates/cursor/skills/shared/verbs/test/orchestrator/contract.yaml +25 -0
  104. package/templates/cursor/skills/shared/verbs/update/orchestrator/SKILL.md +34 -0
  105. package/templates/cursor/skills/shared/verbs/update/orchestrator/contract.yaml +34 -0
  106. package/templates/cursor/skills/shared/verification/SKILL.md +28 -0
  107. package/templates/cursor/skills/shared/workflow/SKILL.md +25 -0
  108. package/templates/docs/agentic_architecture.md +131 -0
  109. package/templates/docs/architecture.md +5 -0
  110. package/templates/docs/master_rules.md +5 -0
@@ -0,0 +1,302 @@
1
+ ---
2
+ name: refactor
3
+ description: Analyze code for SOLID violations, code smells, and master-rules compliance; suggest targeted, low-risk refactorings. Use when the user asks to refactor, review architecture, reduce complexity, extract modules, or runs /refactor on a file, directory, or module.
4
+ argument-hint: "<file_or_module> [--focus srp|ocp|lsp|isp|dip] [--threshold low|medium|high]"
5
+ effort: medium
6
+ disable-model-invocation: true
7
+ ---
8
+
9
+ # SOLID Refactoring Assistant
10
+
11
+ Analyze code for SOLID violations and suggest targeted improvements.
12
+
13
+ **Mandatory:** Read [docs/master_rules.md](../../docs/master_rules.md) (especially §19 Module Size Budgets) before analysis. Master rules are non-negotiable — if a SOLID suggestion conflicts with them, the master rules win.
14
+
15
+ ## Purpose
16
+
17
+ Identify refactoring opportunities based on:
18
+ - SOLID principle violations
19
+ - Code smells and anti-patterns
20
+ - Complexity metrics
21
+ - Duplication detection
22
+ - Master rules compliance (SSOT, layer separation, no inline components/styles, explicit state machines, validation at boundaries)
23
+
24
+ ## Parse Arguments
25
+
26
+ From `$ARGUMENTS` (or the user's message), resolve:
27
+
28
+ | Input | Scope |
29
+ |-------|-------|
30
+ | Single file path | Deep file analysis |
31
+ | Directory path | Cross-file pattern detection |
32
+ | `--focus=<principle>` | Filter findings to one SOLID letter |
33
+ | `--threshold=high` | Only report high-impact issues (large files, mixed layers, critical smells) |
34
+
35
+ Default target: path the user named, or the file/module under discussion.
36
+
37
+ ## Instructions
38
+
39
+ ### Step 1: Scope Analysis
40
+
41
+ Determine the refactoring scope from user input:
42
+ - Single file: Deep analysis
43
+ - Directory: Pattern detection across files
44
+ - Function/class: Focused extraction suggestions
45
+
46
+ ```bash
47
+ TARGET="${1:-.}"
48
+ if [ -f "$TARGET" ]; then
49
+ wc -l "$TARGET"
50
+ echo "Single file analysis"
51
+ elif [ -d "$TARGET" ]; then
52
+ find "$TARGET" -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.py" \) | wc -l
53
+ echo "Directory analysis"
54
+ fi
55
+ ```
56
+
57
+ Also read the target with codebase tools (Grep, Read) — do not rely on shell alone.
58
+
59
+ ### Step 2: SOLID Violations Detection
60
+
61
+ #### S - Single Responsibility
62
+
63
+ Look for:
64
+ - Files over budget (see Master Rules §19: routes 200, components 250, lib 300, openrouter 350)
65
+ - Functions over 80 lines (or nested callbacks over 40)
66
+ - Classes with > 10 methods
67
+ - Mixed concerns (data + UI + business logic)
68
+
69
+ **Master rules overlay:**
70
+ - UI doing fetch, business logic, or state orchestration (Rule 2)
71
+ - Domain logic in components or route handlers
72
+ - Duplicated state (local + store, multiple stores) (Rule 1)
73
+ - Side effects during render (Rules 8, 14)
74
+ - Files that violate "one truth" by mirroring server data
75
+
76
+ ```bash
77
+ find "$TARGET" -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" \) -exec wc -l {} + 2>/dev/null | sort -rn | head -10
78
+ ```
79
+
80
+ #### O - Open/Closed Principle
81
+
82
+ Look for:
83
+ - Switch/case statements on types
84
+ - Repeated if/else type checking
85
+ - Direct modifications vs extensions
86
+
87
+ **Master rules overlay:**
88
+ - Feature behavior extended by editing core modules instead of adding strategy/handler modules (Rule 3)
89
+ - Hardcoded branching that should live in schemas or configuration (Rule 4)
90
+
91
+ #### L - Liskov Substitution
92
+
93
+ Look for:
94
+ - Overridden methods that throw "not implemented"
95
+ - Type checks before method calls
96
+ - Empty method overrides
97
+
98
+ #### I - Interface Segregation
99
+
100
+ Look for:
101
+ - Large interfaces (> 10 methods)
102
+ - Classes implementing unused interface methods
103
+ - Fat service classes
104
+
105
+ **Master rules overlay:**
106
+ - Props/interfaces forcing consumers to depend on unused fields
107
+ - "God" context or store slices consumed wholesale
108
+
109
+ #### D - Dependency Inversion
110
+
111
+ Look for:
112
+ - Direct instantiation of dependencies (`new Service()`)
113
+ - Hardcoded class references
114
+ - Missing dependency injection
115
+
116
+ **Master rules overlay:**
117
+ - Infrastructure (API, DB) imported directly into UI
118
+ - Utilities with hidden side effects (Rule 14)
119
+ - Missing validation at boundaries — trust of raw input/API data (Rule 13)
120
+
121
+ ### Step 3: Master Rules Smell Pass
122
+
123
+ After SOLID, scan for these project-specific violations:
124
+
125
+ | Rule | Smell | Where to look |
126
+ |------|-------|---------------|
127
+ | 1 SSOT | Duplicated constants, mirrored state | `src/app/store/`, component local state |
128
+ | 2 Layers | Business logic in `src/app/components/` | Components with fetch, transforms, rules |
129
+ | 4 No hardcoding | Magic strings/numbers/IDs | Inline literals, layout numbers |
130
+ | 5–6 UI | Inline `style={}`, nested component defs | `src/app/components/` |
131
+ | 8 Flow | Circular imports, UI-triggered indirect mutations | Import graph, event handlers |
132
+ | 9 State machines | Ad-hoc boolean flags for complex flows | `useState` clusters, string unions without machine |
133
+ | 10 Async | Non-cancellable effects, overlapping requests | `useEffect`, route handlers |
134
+ | 13 Boundaries | Missing Zod/schema parse on API I/O | `server/routes/`, `src/app/api.ts` |
135
+ | 16 Errors | Swallowed errors, silent fallbacks | empty `catch`, `?.` chains without logging |
136
+ | 19 Logging | Bare `console.log`, missing structured logs | `server/`, async paths |
137
+ | 20 Testing | Changed behavior without tests | Colocated `*.test.ts` |
138
+
139
+ Map each finding to the rule number in output.
140
+
141
+ ### Step 4: Code Smells
142
+
143
+ Use Grep/Read (preferred) or:
144
+
145
+ ```bash
146
+ # Long parameter lists (5+ comma-separated params — heuristic)
147
+ rg -n "function [^(]+\([^)]*,[^)]*,[^)]*,[^)]*," "$TARGET" 2>/dev/null | head -10
148
+
149
+ # Deep nesting (8+ spaces / 2+ tab levels — heuristic)
150
+ rg -n "^\s{16,}\S" "$TARGET" 2>/dev/null | head -10
151
+ ```
152
+
153
+ Also check:
154
+ - Duplicate logic blocks (similar functions, copy-pasted handlers)
155
+ - Long methods and deep nesting
156
+ - Magic numbers/strings (Rule 4)
157
+ - Missing early returns
158
+
159
+ For duplication at repo scale, optionally suggest running the `fallow` skill if the user wants static analysis.
160
+
161
+ ### Step 5: Complexity Assessment
162
+
163
+ For each issue found, assess:
164
+ - **Impact**: How much code is affected?
165
+ - **Risk**: What could break?
166
+ - **Effort**: Lines to change, tests needed?
167
+ - **Master rule**: Which rule(s) does fixing this satisfy?
168
+
169
+ Prioritize: clarity and predictability over clever abstractions (Rule 22).
170
+
171
+ ## Output Format
172
+
173
+ Use this template exactly:
174
+
175
+ ---
176
+
177
+ ### 🔧 Refactoring Analysis
178
+
179
+ **Target**: [file/directory]
180
+ **Lines Analyzed**: [count]
181
+ **Focus**: [all | srp | ocp | lsp | isp | dip]
182
+ **Threshold**: [low | medium | high]
183
+
184
+ ### 📊 SOLID Scorecard
185
+
186
+ | Principle | Status | Issues Found |
187
+ |-----------|--------|--------------|
188
+ | Single Responsibility | 🟡/🟢/🔴 | [summary] |
189
+ | Open/Closed | 🟡/🟢/🔴 | [summary] |
190
+ | Liskov Substitution | 🟡/🟢/🔴 | [summary] |
191
+ | Interface Segregation | 🟡/🟢/🔴 | [summary] |
192
+ | Dependency Inversion | 🟡/🟢/🔴 | [summary] |
193
+
194
+ ### 📐 Master Rules Scorecard
195
+
196
+ | Area | Status | Top violations |
197
+ |------|--------|----------------|
198
+ | SSOT & layers | 🟡/🟢/🔴 | [e.g. UI fetching in component] |
199
+ | UI discipline | 🟡/🟢/🔴 | [e.g. inline components] |
200
+ | Boundaries & errors | 🟡/🟢/🔴 | [e.g. unvalidated API body] |
201
+ | Async & state | 🟡/🟢/🔴 | [e.g. ad-hoc flags vs state machine] |
202
+ | Testing & logging | 🟡/🟢/🔴 | [e.g. no tests for changed module] |
203
+
204
+ ### 🎯 Priority Refactorings
205
+
206
+ #### 1. [Highest Impact] - [Short title]
207
+
208
+ **Violation**: [SOLID principle + Rule #]
209
+ **Current**: [what the code does today, with path:line]
210
+ **Suggested**:
211
+ ```
212
+ [Before structure]
213
+ ↓ [Extract | Move | Replace pattern]
214
+ [After structure]
215
+ ```
216
+ **Risk**: [Low | Medium | High] — [why]
217
+ **Tests Needed**: [what to add/update]
218
+
219
+ #### 2. [Second Priority] - [Short title]
220
+
221
+ **Location**: `path/file.ts:line`
222
+ **Current**:
223
+ ```typescript
224
+ // minimal illustrative snippet
225
+ ```
226
+ **Suggested**: [concrete pattern — strategy, extract module, move to domain, etc.]
227
+ **Risk**: [Low | Medium | High]
228
+
229
+ (Include 3–5 items max unless `--threshold=low`.)
230
+
231
+ ### 📝 Code Smells
232
+
233
+ | Smell | Location | Rule/SOLID | Severity |
234
+ |-------|----------|------------|----------|
235
+ | Long Method | `api.ts:calculateTotal` (120 lines) | SRP | 🟠 High |
236
+ | Duplicate Code | `utils/*.ts` | SSOT (Rule 1) | 🟡 Medium |
237
+ | Deep Nesting | `parser.ts:parse` | — | 🟡 Medium |
238
+
239
+ ### 🚀 Quick Wins (Low Risk, High Value)
240
+
241
+ 1. [Concrete, scoped action]
242
+ 2. [Concrete, scoped action]
243
+ 3. [Concrete, scoped action]
244
+
245
+ ### ⚠️ Technical Debt Notes
246
+
247
+ - [Items to defer — document why per Rule 21 if suggesting exceptions]
248
+
249
+ ---
250
+
251
+ ## Refactoring Safety Checklist
252
+
253
+ Before applying suggestions:
254
+
255
+ - [ ] Tests exist for affected code (Rule 20)
256
+ - [ ] Create feature branch
257
+ - [ ] Commit current state (only when user asks)
258
+ - [ ] Apply **one** refactoring at a time
259
+ - [ ] Run tests after each change
260
+ - [ ] Review diff before committing
261
+ - [ ] No scope creep — minimal diff (user preference)
262
+ - [ ] Document any intentional rule exception (Rule 21)
263
+
264
+ ## Applying Refactorings
265
+
266
+ When the user asks to implement (not just analyze):
267
+
268
+ 1. Read surrounding code; match existing conventions
269
+ 2. Preserve layer boundaries: UI → state → domain → infrastructure
270
+ 3. Centralize schemas and validation at boundaries
271
+ 4. Extract to new files (no inline components)
272
+ 5. Add/update behavioral tests, not implementation-detail tests
273
+ 6. Use structured logging on new async paths (Rule 19)
274
+
275
+ ## Usage
276
+
277
+ **Analyze specific file:**
278
+ ```
279
+ /refactor src/services/user.ts
280
+ ```
281
+
282
+ **Analyze directory:**
283
+ ```
284
+ /refactor src/api/
285
+ ```
286
+
287
+ **Focus on specific principle:**
288
+ ```
289
+ /refactor --focus=srp src/services/
290
+ ```
291
+
292
+ **With complexity threshold:**
293
+ ```
294
+ /refactor --threshold=high
295
+ ```
296
+
297
+ ## References
298
+
299
+ - [docs/master_rules.md](../../docs/master_rules.md) — project non-negotiables
300
+ - Martin Fowler's Refactoring Catalog
301
+ - Clean Code by Robert C. Martin
302
+ - SOLID principles by Robert C. Martin
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: shared-check
3
+ description: >-
4
+ Fast readonly validate/inspect — can X do Y, how does it work. All check-* commands.
5
+ Not user-facing.
6
+ disable-model-invocation: true
7
+ ---
8
+
9
+ # Shared capability check
10
+
11
+ ## When
12
+
13
+ Orchestrator phase `check_swarm`. **Readonly** — no file edits.
14
+
15
+ Lighter than [discovery](../discovery/SKILL.md) (no full 4–6 agent sweep) and narrower than [architecture](../architecture/SKILL.md) (no SOLID/size review).
16
+
17
+ ## Frame
18
+
19
+ ```
20
+ Question: can it do X? / how does Y work?
21
+ Scope: domain slug, path hint, or symbols from intent
22
+ Success: yes | no | partial + conditions
23
+ ```
24
+
25
+ ## Swarm (mandatory)
26
+
27
+ Launch **3** parallel `Task` subagents (`explore`, `readonly: true`) in **one message**:
28
+
29
+ | Agent spec | Angle |
30
+ |------------|-------|
31
+ | [discovery-inventory.md](../../../agents/discovery-inventory.md) | Relevant files, routes, tests |
32
+ | [discovery-ssot.md](../../../agents/discovery-ssot.md) | State and data ownership |
33
+ | [check-capability-trace.md](../../../agents/check-capability-trace.md) | Entry → logic → persistence trace |
34
+
35
+ Optional **4th** agent (second wave, only if intent names external system): `discovery-boundaries.md` for integration edges.
36
+
37
+ ## Merge
38
+
39
+ Parent synthesizes one brief:
40
+
41
+ 1. **Answer** — yes / no / partial (one sentence)
42
+ 2. **How it works** — 3–7 steps, layman first
43
+ 3. **Evidence** — `path:line` list
44
+ 4. **Gaps** — what was not confirmed
45
+ 5. **Confidence** — high | medium | low
46
+
47
+ Spot-check every `path:line` claim before reporting.
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: shared-component
3
+ description: >-
4
+ UI components, views, pages, forms, hooks-as-UI. Object component (code layer).
5
+ Not user-facing.
6
+ disable-model-invocation: true
7
+ ---
8
+
9
+ # Shared component
10
+
11
+ ## Scope
12
+
13
+ - `src/app/components/`, routes-as-views, layout composition
14
+ - Props-driven components; token/class styling only (no inline styles)
15
+ - One component per file; no inline component definitions
16
+
17
+ ## Execution focus
18
+
19
+ - Reuse design system primitives; match existing patterns
20
+ - Accessibility and test ids for interactive flows
21
+
22
+ ## Review focus
23
+
24
+ - Re-render boundaries, prop drilling, separation from state layer
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: shared-dependency-graph
3
+ description: >-
4
+ Resolve dependency graph before execute using dependencies.yaml and inventory.
5
+ Not user-facing.
6
+ disable-model-invocation: true
7
+ ---
8
+
9
+ # Dependency graph validation
10
+
11
+ **When:** Verb lifecycle phase `dependency_graph` — before execute.
12
+
13
+ ## SSOT
14
+
15
+ [dependencies.yaml](../../../aaac/dependencies.yaml) — domain and object edges.
16
+
17
+ ## Procedure
18
+
19
+ 1. Resolve target domain slug (if present) → `domains.<slug>.depends_on`
20
+ 2. Resolve command object → `objects.<object>.<domain>` or `objects.<object>.default`
21
+ 3. Merge with domain inventory Section 3 file map
22
+ 4. Spawn readonly [dependency-analysis.md](../../../agents/dependency-analysis.md) to confirm no hidden imports/coupling
23
+
24
+ ## Output
25
+
26
+ ```yaml
27
+ target: cms | ui | database | ...
28
+ depends_on: [resolved list]
29
+ depended_by: [consumers that may break]
30
+ graph_valid: true | false
31
+ violations: [layer boundary or circular deps — empty if valid]
32
+ ```
33
+
34
+ If `graph_valid: false` → **STOP** — fix plan or request clarification.
35
+
36
+ ## Note
37
+
38
+ Inventory documents what exists; this phase **reasons** over edges. Both are required.
@@ -0,0 +1,29 @@
1
+ ---
2
+ name: shared-discovery
3
+ description: >-
4
+ Readonly discovery swarm for AAAC orchestrators. Spawns parallel subagents
5
+ per .cursor/agents/discovery-*.md. Use only via graph — not user-facing.
6
+ disable-model-invocation: true
7
+ ---
8
+
9
+ # Shared discovery
10
+
11
+ ## When
12
+
13
+ Orchestrator phase `discovery_swarm`. **Readonly** — no file edits.
14
+
15
+ ## Swarm (mandatory)
16
+
17
+ Launch **4–6** parallel `Task` subagents (`explore`, `readonly: true`) in **one message**:
18
+
19
+ | Agent spec | Angle |
20
+ |------------|-------|
21
+ | [discovery-inventory.md](../../../agents/discovery-inventory.md) | Files, routes, tests |
22
+ | [discovery-boundaries.md](../../../agents/discovery-boundaries.md) | In/out of scope |
23
+ | [discovery-ssot.md](../../../agents/discovery-ssot.md) | State ownership |
24
+
25
+ Add domain-specific angles from inventory skill. Max **8** agents total; second wave ≤2 for critical gaps.
26
+
27
+ ## Output
28
+
29
+ Merged brief for `planning`: findings, evidence, gaps, confidence. Parent spot-checks `path:line` claims.
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: shared-documentation
3
+ description: >-
4
+ Plain-language architecture docs to docs/. Readonly investigation until write.
5
+ Used by update-doc orchestrator. Not user-facing.
6
+ disable-model-invocation: true
7
+ ---
8
+
9
+ # Shared documentation
10
+
11
+ ## Spec
12
+
13
+ Follow [write-arch-doc.md](write-arch-doc.md) exactly.
14
+
15
+ ## Swarm
16
+
17
+ Use [discovery](../discovery/SKILL.md) with product-language angles (purpose, lifecycle, flow, boundaries). **Readonly** until writing `docs/architecture_<slug>.md`.
18
+
19
+ ## Output
20
+
21
+ `docs/architecture_<slug>.md` — no code changes unless user also invoked a code command.
@@ -0,0 +1,26 @@
1
+ ---
2
+ name: update-doc-orchestrator
3
+ description: >-
4
+ Orchestrates update-doc: plain-language module architecture docs. Internal only.
5
+ disable-model-invocation: true
6
+ ---
7
+
8
+ # update-doc orchestrator
9
+
10
+ ## Parse
11
+
12
+ - **Domain:** slug or product name → `docs/architecture_<slug>.md`
13
+ - **Intent:** quoted string in `$ARGUMENTS`
14
+
15
+ ## Phases
16
+
17
+ 1. Frame module brief (product name, scope, unknowns)
18
+ 2. [discovery](../SKILL.md) swarm — readonly
19
+ 3. [documentation](../SKILL.md) — write/replace doc per write-arch-doc.md
20
+ 4. [reporting](../reporting/SKILL.md)
21
+
22
+ **Hard rule:** No application code changes.
23
+
24
+ ## contract.yaml
25
+
26
+ See [contract.yaml](contract.yaml).
@@ -0,0 +1,20 @@
1
+ name: update-doc-orchestrator
2
+ purpose: Write or refresh plain-language architecture doc for a product module
3
+ inputs:
4
+ domain:
5
+ required: true
6
+ intent:
7
+ required: true
8
+ outputs:
9
+ report:
10
+ type: markdown
11
+ success_criteria:
12
+ - docs/architecture_<slug>.md follows write-arch-doc.md
13
+ - investigation was readonly until write
14
+ failure_conditions:
15
+ - ambiguous module name without user clarification
16
+ dependencies:
17
+ skills: [discovery, documentation, reporting]
18
+ policies: [master-rules]
19
+ verification:
20
+ - doc_structure_check
@@ -0,0 +1,168 @@
1
+ # Write Architecture Doc (Plain Language)
2
+
3
+ **Audience:** Anyone who uses or cares about the product — not developers. Product owners, designers, support, new team members, stakeholders.
4
+
5
+ **Goal:** After reading, the reader can explain *what this part of the platform does*, *why it exists*, and *how it behaves in everyday use* — without reading code.
6
+
7
+ **Mandatory:** Every architecture doc produced by `/architecture` MUST follow this guide exactly.
8
+
9
+ ---
10
+
11
+ ## Output Location & Naming
12
+
13
+ | Rule | Value |
14
+ |------|-------|
15
+ | Folder | `docs/` at repo root |
16
+ | Pattern | `docs/architecture_<slug>.md` |
17
+ | Slug | Lowercase, underscores, derived from module name (e.g. `Question Suggestion Engine` → `architecture_question_suggestion_engine.md`) |
18
+ | Format | Plain Markdown (`.md`), not MDX |
19
+ | Update | If the file exists, rewrite it with current facts — do not create duplicates |
20
+
21
+ ---
22
+
23
+ ## Required Document Structure
24
+
25
+ Use this template. **Do not skip sections.** **Do not add developer sections** (no file paths, no API tables, no code snippets except Mermaid).
26
+
27
+ ```markdown
28
+ # [Human-Friendly Module Name]
29
+
30
+ > One sentence: what this is and the main benefit it gives users.
31
+
32
+ ## Introduction
33
+
34
+ [2–4 short paragraphs. Plain language only.
35
+
36
+ - What problem does this solve?
37
+ - Who interacts with it (directly or indirectly)?
38
+ - Why does the platform need it?
39
+ - What would be missing if it did not exist?]
40
+
41
+ ## At a Glance
42
+
43
+ | | |
44
+ |---|---|
45
+ | **Purpose** | … |
46
+ | **When it runs** | … |
47
+ | **Who notices it** | … |
48
+ | **What it produces** | … |
49
+
50
+ ## How the Pieces Fit Together
51
+
52
+ [Mermaid diagram — see rules below]
53
+
54
+ ## How It Works
55
+
56
+ [Numbered steps, 5–10 max. Each step = one clear action or decision in plain language.
57
+
58
+ Example tone: "When you open a requirement, the system checks whether more questions would help clarify it."
59
+
60
+ NOT: "The RequirementFocusMachine dispatches REQUEST_SUGGESTION."]
61
+
62
+ 1. …
63
+ 2. …
64
+ 3. …
65
+
66
+ ## Key Ideas
67
+
68
+ [3–6 bullets. Define terms the reader might hear in conversation — in everyday words.
69
+
70
+ Format: **Term** — plain definition]
71
+
72
+ ## Common Situations
73
+
74
+ [3–5 short scenarios: "When X happens, Y occurs."
75
+
76
+ Helps the reader predict behavior. Include at least one "nothing happens" or "it waits" case if applicable.]
77
+
78
+ ## Connected Parts
79
+
80
+ [Bullet list of other platform areas this module talks to or depends on — use product names, not code module names.
81
+
82
+ Example: "Requirements — needs a requirement to exist before suggesting questions"]
83
+
84
+ ## Limits & Boundaries
85
+
86
+ [What this part does **not** do. Prevents wrong assumptions. 3–5 bullets.]
87
+ ```
88
+
89
+ ---
90
+
91
+ ## Mermaid Diagram Rules
92
+
93
+ **Purpose:** Show flow and relationships so a non-technical reader can follow the story visually.
94
+
95
+ | Rule | Detail |
96
+ |------|--------|
97
+ | Type | Prefer `flowchart TD` or `flowchart LR` |
98
+ | Labels | User/product language only — "User opens requirement", "AI suggests questions", "Questions appear in list" |
99
+ | Nodes | 4–10 nodes; merge tiny steps rather than exploding detail |
100
+ | Forbidden in labels | File names, function names, HTTP verbs, database terms, acronyms without gloss |
101
+ | Direction | `TD` for timelines; `LR` for left-to-right pipelines |
102
+ | Styling | No custom colors or classes unless essential for clarity |
103
+
104
+ **Good example:**
105
+
106
+ ```mermaid
107
+ flowchart TD
108
+ A[User focuses on a requirement] --> B{Need more clarity?}
109
+ B -->|Yes| C[AI reads requirement context]
110
+ C --> D[Draft questions generated]
111
+ D --> E[New questions appear for review]
112
+ B -->|No| F[Nothing suggested]
113
+ ```
114
+
115
+ **Bad example:** nodes like `POST /suggest/:id` or `requirementFocusMachine.ts`.
116
+
117
+ Place the diagram under `## How the Pieces Fit Together` with a one-sentence caption above it explaining what the reader is looking at.
118
+
119
+ ---
120
+
121
+ ## Plain Language Rules
122
+
123
+ 1. **Short sentences** — average 15 words; one idea per sentence
124
+ 2. **Active voice** — "The system suggests questions" not "Questions are suggested by the system"
125
+ 3. **No jargon** — if a technical word is unavoidable, define it immediately in parentheses
126
+ 4. **No code** — no `backticked` identifiers, paths, env vars, or stack names in body text
127
+ 5. **Concrete over abstract** — describe what the user sees and what changes
128
+ 6. **Honest uncertainty** — use "usually", "may", "in most cases" when behavior varies
129
+ 7. **Second person sparingly** — "you" is fine for user-facing flows; "the team" for internal behavior
130
+
131
+ ### Banned → Preferred
132
+
133
+ | Avoid | Use instead |
134
+ |-------|-------------|
135
+ | dispatch, invoke, persist | send, run, save |
136
+ | state machine, slice, hook | workflow, memory, automatic handler |
137
+ | endpoint, payload | request, information sent |
138
+ | dedupe, hydrate | remove duplicates, load |
139
+ | frontend / backend | app / server (only if needed) |
140
+
141
+ ---
142
+
143
+ ## Accuracy Rules
144
+
145
+ - Every claim must come from swarm investigation evidence — **never invent behavior**
146
+ - If the swarm could not verify something, omit it or say "Behavior may vary depending on setup"
147
+ - Prefer describing **observable outcomes** over internal mechanism guesses
148
+ - When two agents disagree, the doc writer must verify in code before stating either version
149
+
150
+ ---
151
+
152
+ ## Quality Checklist (before saving)
153
+
154
+ - [ ] A non-developer can read the Introduction alone and understand the purpose
155
+ - [ ] Mermaid diagram uses zero code terms in node labels
156
+ - [ ] No file paths, class names, or API routes in the document body
157
+ - [ ] "How It Works" steps match actual product behavior verified by the swarm
158
+ - [ ] "Limits & Boundaries" clarifies what this module does not do
159
+ - [ ] Filename matches `docs/architecture_<slug>.md`
160
+ - [ ] Document is self-contained — reader does not need `docs/architecture.md` first
161
+
162
+ ---
163
+
164
+ ## Reference Example (tone only — do not copy content)
165
+
166
+ **Introduction opening:** "The Question Suggestion Engine helps teams fill gaps in a requirement by proposing questions they might not have thought to ask. When someone is working on a requirement, the platform can automatically offer new questions based on what is already written and answered."
167
+
168
+ **Step example:** "4. If the suggested question is not already on the list, it appears alongside existing questions so the user can accept, edit, or ignore it."