guardian-framework 0.1.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 (216) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +463 -0
  3. package/dist/cli.js +12958 -0
  4. package/dist/exports.js +12765 -0
  5. package/package.json +61 -0
  6. package/templates/languages/go-patterns.md +411 -0
  7. package/templates/languages/java-patterns.md +545 -0
  8. package/templates/languages/python-patterns.md +312 -0
  9. package/templates/languages/rust-patterns.md +232 -0
  10. package/templates/languages/typescript-patterns.md +313 -0
  11. package/templates/pi/INDEX.md +437 -0
  12. package/templates/pi/agent/AGENTS.md +166 -0
  13. package/templates/pi/agents/architecture-coordinator.md +40 -0
  14. package/templates/pi/agents/architecture-validator.md +36 -0
  15. package/templates/pi/agents/bootstrap-implementer.md +37 -0
  16. package/templates/pi/agents/issue-factory.md +31 -0
  17. package/templates/pi/agents/operations-validator.md +32 -0
  18. package/templates/pi/agents/security-validator.md +33 -0
  19. package/templates/pi/architecture/CHANGELOG.md +78 -0
  20. package/templates/pi/architecture/decisions/ADR-template.md +76 -0
  21. package/templates/pi/architecture/diagrams/system-overview.md +159 -0
  22. package/templates/pi/architecture/modules/module-template.md +152 -0
  23. package/templates/pi/context/checklists.md +91 -0
  24. package/templates/pi/context/domain-workflow.md +180 -0
  25. package/templates/pi/context/output-formats.md +135 -0
  26. package/templates/pi/context/patterns-base.md +47 -0
  27. package/templates/pi/context/patterns.md +38 -0
  28. package/templates/pi/context/project.md +88 -0
  29. package/templates/pi/domain/exploration.md +93 -0
  30. package/templates/pi/domain/ubiquitous-language.md +24 -0
  31. package/templates/pi/extensions/architect-lib/generators.ts +528 -0
  32. package/templates/pi/extensions/architect-lib/helpers.ts +344 -0
  33. package/templates/pi/extensions/architect-lib/types.ts +117 -0
  34. package/templates/pi/extensions/architect.ts +1425 -0
  35. package/templates/pi/extensions/ask-user-question.ts +579 -0
  36. package/templates/pi/extensions/bash-guard.ts +556 -0
  37. package/templates/pi/extensions/config-reload.ts +115 -0
  38. package/templates/pi/extensions/coordinator.ts +304 -0
  39. package/templates/pi/extensions/curator.ts +543 -0
  40. package/templates/pi/extensions/domain-explorer.ts +990 -0
  41. package/templates/pi/extensions/filechanges.ts +656 -0
  42. package/templates/pi/extensions/goal-loop.ts +717 -0
  43. package/templates/pi/extensions/hooks.ts +452 -0
  44. package/templates/pi/extensions/kanban.ts +547 -0
  45. package/templates/pi/extensions/pipeline.ts +1246 -0
  46. package/templates/pi/extensions/plan-mode.ts +209 -0
  47. package/templates/pi/extensions/project-scaffolder.ts +284 -0
  48. package/templates/pi/extensions/read-only-mode.ts +192 -0
  49. package/templates/pi/extensions/redaction.ts +128 -0
  50. package/templates/pi/extensions/session-persistence.ts +174 -0
  51. package/templates/pi/extensions/slash-commands.ts +229 -0
  52. package/templates/pi/extensions/snippets.ts +201 -0
  53. package/templates/pi/extensions/validation-runner.ts +100 -0
  54. package/templates/pi/github/agents/architecture-coordinator.agent.md +27 -0
  55. package/templates/pi/github/agents/architecture-validator.agent.md +20 -0
  56. package/templates/pi/github/agents/bootstrap-implementer.agent.md +20 -0
  57. package/templates/pi/github/agents/epic-planner.agent.md +70 -0
  58. package/templates/pi/github/agents/issue-factory.agent.md +20 -0
  59. package/templates/pi/github/agents/operations-validator.agent.md +20 -0
  60. package/templates/pi/github/agents/security-validator.agent.md +20 -0
  61. package/templates/pi/github/copilot/settings.json +16 -0
  62. package/templates/pi/github/copilot-instructions.md +155 -0
  63. package/templates/pi/github/instructions/architecture.instructions.md +71 -0
  64. package/templates/pi/github/instructions/validation.instructions.md +69 -0
  65. package/templates/pi/github/workflows/01-planning-workflow.md +75 -0
  66. package/templates/pi/github/workflows/02-issue-generation-workflow.md +69 -0
  67. package/templates/pi/github/workflows/03-implementation-workflow.md +80 -0
  68. package/templates/pi/github/workflows/04-validation-workflow.md +68 -0
  69. package/templates/pi/preflight_report.json +99 -0
  70. package/templates/pi/prompts/blueprint-update.md +262 -0
  71. package/templates/pi/prompts/blueprint-validate.md +218 -0
  72. package/templates/pi/prompts/bug-fix.md +50 -0
  73. package/templates/pi/prompts/ci-blueprint.md +131 -0
  74. package/templates/pi/prompts/context-refresh.md +258 -0
  75. package/templates/pi/prompts/epic-plan.md +356 -0
  76. package/templates/pi/prompts/epic-template.md +186 -0
  77. package/templates/pi/prompts/feature-development.md +131 -0
  78. package/templates/pi/prompts/git-issues.md +243 -0
  79. package/templates/pi/prompts/hotfix.md +71 -0
  80. package/templates/pi/prompts/issue-closeout.md +342 -0
  81. package/templates/pi/prompts/issue-draft.md +218 -0
  82. package/templates/pi/prompts/issue-implementation-series.md +173 -0
  83. package/templates/pi/prompts/issue-merge.md +372 -0
  84. package/templates/pi/prompts/issue-template-set.md +392 -0
  85. package/templates/pi/prompts/issue-template.md +207 -0
  86. package/templates/pi/prompts/pattern-extract.md +269 -0
  87. package/templates/pi/prompts/plan-to-issues.md +430 -0
  88. package/templates/pi/prompts/refactoring.md +82 -0
  89. package/templates/pi/prompts/scope-analyzer.md +254 -0
  90. package/templates/pi/prompts/sync-check.md +230 -0
  91. package/templates/pi/scripts/categorize-issues.sh +171 -0
  92. package/templates/pi/scripts/ci/check_architecture_conformance.sh +748 -0
  93. package/templates/pi/scripts/ci/check_planning_packet.py +228 -0
  94. package/templates/pi/scripts/ci/run_hardening_stages.sh +264 -0
  95. package/templates/pi/scripts/ci/run_preflight.sh +649 -0
  96. package/templates/pi/scripts/ci/run_stage.sh +193 -0
  97. package/templates/pi/scripts/ci/stage_docs_policy.sh +82 -0
  98. package/templates/pi/scripts/ci/stage_integration.sh +3 -0
  99. package/templates/pi/scripts/ci/stage_lint.sh +130 -0
  100. package/templates/pi/scripts/ci/stage_migration_verify.sh +3 -0
  101. package/templates/pi/scripts/ci/stage_package_build.sh +3 -0
  102. package/templates/pi/scripts/ci/stage_release_readiness.sh +3 -0
  103. package/templates/pi/scripts/ci/stage_remaining.sh +242 -0
  104. package/templates/pi/scripts/ci/stage_security.sh +3 -0
  105. package/templates/pi/scripts/ci/stage_static_analysis.sh +114 -0
  106. package/templates/pi/scripts/ci/stage_unit.sh +119 -0
  107. package/templates/pi/scripts/ci/validate_agent_output.py +181 -0
  108. package/templates/pi/scripts/ci/validate_agent_output.sh +243 -0
  109. package/templates/pi/scripts/create-feature-branch.sh +136 -0
  110. package/templates/pi/scripts/create-mr.sh +117 -0
  111. package/templates/pi/scripts/fetch-issues.sh +131 -0
  112. package/templates/pi/scripts/generate-architecture.sh +161 -0
  113. package/templates/pi/scripts/git/close-epic.sh +69 -0
  114. package/templates/pi/scripts/git/close-issue.sh +35 -0
  115. package/templates/pi/scripts/git/create-tracking-issue.sh +174 -0
  116. package/templates/pi/scripts/git/link-issue-to-epic.sh +51 -0
  117. package/templates/pi/scripts/git/update-tracking-issue.sh +66 -0
  118. package/templates/pi/scripts/languages/go/validate-architecture.sh +139 -0
  119. package/templates/pi/scripts/languages/go/validate-canonical.sh +129 -0
  120. package/templates/pi/scripts/languages/go/validate-ci.sh +132 -0
  121. package/templates/pi/scripts/languages/go/validate-integration.sh +156 -0
  122. package/templates/pi/scripts/languages/go/validate-operations.sh +146 -0
  123. package/templates/pi/scripts/languages/go/validate-security.sh +135 -0
  124. package/templates/pi/scripts/languages/go/validate-tests.sh +125 -0
  125. package/templates/pi/scripts/languages/java/validate-annotations.sh +185 -0
  126. package/templates/pi/scripts/languages/java/validate-architecture.sh +159 -0
  127. package/templates/pi/scripts/languages/java/validate-canonical.sh +114 -0
  128. package/templates/pi/scripts/languages/java/validate-ci.sh +269 -0
  129. package/templates/pi/scripts/languages/java/validate-integration.sh +149 -0
  130. package/templates/pi/scripts/languages/java/validate-operations.sh +142 -0
  131. package/templates/pi/scripts/languages/java/validate-security.sh +174 -0
  132. package/templates/pi/scripts/languages/java/validate-spring-architecture.sh +227 -0
  133. package/templates/pi/scripts/languages/java/validate-tests.sh +159 -0
  134. package/templates/pi/scripts/languages/python/validate-architecture.sh +99 -0
  135. package/templates/pi/scripts/languages/python/validate-canonical.sh +124 -0
  136. package/templates/pi/scripts/languages/python/validate-ci.sh +130 -0
  137. package/templates/pi/scripts/languages/python/validate-integration.sh +119 -0
  138. package/templates/pi/scripts/languages/python/validate-operations.sh +107 -0
  139. package/templates/pi/scripts/languages/python/validate-security.sh +68 -0
  140. package/templates/pi/scripts/languages/python/validate-tests.sh +102 -0
  141. package/templates/pi/scripts/languages/rust/validate-architecture.sh +188 -0
  142. package/templates/pi/scripts/languages/rust/validate-canonical.sh +146 -0
  143. package/templates/pi/scripts/languages/rust/validate-ci.sh +147 -0
  144. package/templates/pi/scripts/languages/rust/validate-integration.sh +149 -0
  145. package/templates/pi/scripts/languages/rust/validate-operations.sh +154 -0
  146. package/templates/pi/scripts/languages/rust/validate-security.sh +153 -0
  147. package/templates/pi/scripts/languages/rust/validate-tests.sh +150 -0
  148. package/templates/pi/scripts/languages/typescript/validate-architecture.sh +157 -0
  149. package/templates/pi/scripts/languages/typescript/validate-canonical.sh +135 -0
  150. package/templates/pi/scripts/languages/typescript/validate-ci.sh +244 -0
  151. package/templates/pi/scripts/languages/typescript/validate-integration.sh +166 -0
  152. package/templates/pi/scripts/languages/typescript/validate-operations.sh +162 -0
  153. package/templates/pi/scripts/languages/typescript/validate-security.sh +169 -0
  154. package/templates/pi/scripts/languages/typescript/validate-tests.sh +158 -0
  155. package/templates/pi/scripts/merge-mr.sh +95 -0
  156. package/templates/pi/scripts/mr-validation.sh +228 -0
  157. package/templates/pi/scripts/validate-architecture-readiness.sh +153 -0
  158. package/templates/pi/scripts/validate-architecture.sh +22 -0
  159. package/templates/pi/scripts/validate-canonical.sh +22 -0
  160. package/templates/pi/scripts/validate-ci.sh +37 -0
  161. package/templates/pi/scripts/validate-integration.sh +22 -0
  162. package/templates/pi/scripts/validate-operations.sh +22 -0
  163. package/templates/pi/scripts/validate-security.sh +22 -0
  164. package/templates/pi/scripts/validate-tests.sh +22 -0
  165. package/templates/pi/scripts/validate-ubiquitous-language.sh +291 -0
  166. package/templates/pi/scripts/validation-cache.sh +139 -0
  167. package/templates/pi/skills/agents/architecture-coordinator.md +178 -0
  168. package/templates/pi/skills/agents/architecture-generator.md +79 -0
  169. package/templates/pi/skills/agents/architecture-validator.md +74 -0
  170. package/templates/pi/skills/agents/ci-mr-validator.md +46 -0
  171. package/templates/pi/skills/agents/code-developer.md +76 -0
  172. package/templates/pi/skills/agents/commit.md +46 -0
  173. package/templates/pi/skills/agents/curator.md +71 -0
  174. package/templates/pi/skills/agents/debug.md +59 -0
  175. package/templates/pi/skills/agents/documentation-maintainer.md +36 -0
  176. package/templates/pi/skills/agents/goal-loop.md +125 -0
  177. package/templates/pi/skills/agents/hooks.md +122 -0
  178. package/templates/pi/skills/agents/integration-validator.md +35 -0
  179. package/templates/pi/skills/agents/issue-creator.md +75 -0
  180. package/templates/pi/skills/agents/issue-factory.md +143 -0
  181. package/templates/pi/skills/agents/kanban.md +85 -0
  182. package/templates/pi/skills/agents/land.md +59 -0
  183. package/templates/pi/skills/agents/operations-validator.md +43 -0
  184. package/templates/pi/skills/agents/pipeline.md +113 -0
  185. package/templates/pi/skills/agents/plan-mode.md +77 -0
  186. package/templates/pi/skills/agents/pull.md +40 -0
  187. package/templates/pi/skills/agents/push.md +41 -0
  188. package/templates/pi/skills/agents/security-validator.md +85 -0
  189. package/templates/pi/skills/agents/session-persistence.md +119 -0
  190. package/templates/pi/skills/agents/slash-commands.md +117 -0
  191. package/templates/pi/skills/agents/snippets.md +99 -0
  192. package/templates/pi/skills/agents/subagent-registry.md +78 -0
  193. package/templates/pi/skills/agents/test-validator.md +42 -0
  194. package/templates/pi/skills/validators/architecture-validator.md +43 -0
  195. package/templates/pi/skills/validators/ci-validator.md +27 -0
  196. package/templates/pi/skills/validators/context-compaction.md +73 -0
  197. package/templates/pi/skills/validators/integration-validator.md +38 -0
  198. package/templates/pi/skills/validators/model-registry.md +96 -0
  199. package/templates/pi/skills/validators/operations-validator.md +34 -0
  200. package/templates/pi/skills/validators/security-guards.md +72 -0
  201. package/templates/pi/skills/validators/security-validator.md +41 -0
  202. package/templates/pi/skills/validators/system-prompt-tiers.md +69 -0
  203. package/templates/pi/skills/validators/test-validator.md +33 -0
  204. package/templates/pi/types.ts +62 -0
  205. package/templates/pi/validators/README.md +93 -0
  206. package/templates/pi/validators/default.toml +209 -0
  207. package/templates/pi/validators/spring.toml +142 -0
  208. package/templates/pi/workpad.md +53 -0
  209. package/templates/project/java/Dockerfile +14 -0
  210. package/templates/project/java/README.md +40 -0
  211. package/templates/project/java/pom.xml +132 -0
  212. package/templates/project/typescript/Dockerfile +15 -0
  213. package/templates/project/typescript/README.md +29 -0
  214. package/templates/project/typescript/package.json +23 -0
  215. package/templates/project/typescript/tsconfig.json +21 -0
  216. package/templates/workflow.md +123 -0
@@ -0,0 +1,258 @@
1
+ # Context Refresh Workflow
2
+
3
+ **Purpose:** Analyze current codebase state and update `.pi/context/` files to reflect actual patterns, commands, and facts.
4
+
5
+ ---
6
+
7
+ ## Prerequisites
8
+
9
+ - `.pi/` blueprint exists
10
+ - Codebase has implementation code
11
+ - `guardian.manifest.json` exists
12
+
13
+ ---
14
+
15
+ ## Canonical Reference Requirement
16
+
17
+ **Implementation files should include canonical reference:**
18
+
19
+ ```typescript
20
+ /**
21
+ * Canonical Reference: .pi/context/patterns.md#section-name
22
+ * Blueprint Alignment: [pattern-name]
23
+ * Implements: [feature/spec reference]
24
+ */
25
+ ```
26
+
27
+ ---
28
+
29
+ ## Workflow Steps
30
+
31
+ ### 1. Analyze Current Build System
32
+
33
+ Extract actual build/test/lint commands:
34
+
35
+ ```bash
36
+ # Read package.json or equivalent
37
+ cat package.json | jq '.scripts'
38
+
39
+ # Or for Cargo.toml
40
+ cat Cargo.toml | grep -A10 "\[build\]"
41
+
42
+ # Or for pyproject.toml
43
+ cat pyproject.toml | grep -A10 "\[tool"
44
+ ```
45
+
46
+ **Update project.md:**
47
+ ```markdown
48
+ ## Commands
49
+
50
+ ### Build
51
+ ```bash
52
+ [actual build command from package.json]
53
+ ```
54
+
55
+ ### Test
56
+ ```bash
57
+ [actual test command]
58
+ ```
59
+
60
+ ### Lint
61
+ ```bash
62
+ [actual lint command]
63
+ ```
64
+ ```
65
+
66
+ ### 2. Extract Live Code Patterns
67
+
68
+ Analyze existing code for patterns:
69
+
70
+ ```bash
71
+ # Find common patterns in TypeScript
72
+ grep -r "export function" src/ | head -20
73
+ grep -r "export class" src/ | head -20
74
+ grep -r "interface " src/ | head -20
75
+
76
+ # Find error handling patterns
77
+ grep -r "throw new" src/ | head -20
78
+ grep -r "Result<" src/ | head -10
79
+ ```
80
+
81
+ **Pattern Extraction Template:**
82
+
83
+ ```markdown
84
+ ## Pattern: [Name]
85
+
86
+ ### Context
87
+ [When to use this pattern]
88
+
89
+ ### Code Template
90
+ ```typescript
91
+ [Extracted pattern code]
92
+ ```
93
+
94
+ ### Files Using This Pattern
95
+ - src/lib/foo.ts
96
+ - src/commands/bar.ts
97
+ ```
98
+
99
+ ### 3. Dependency Analysis
100
+
101
+ Extract actual dependencies:
102
+
103
+ ```bash
104
+ # npm/bun
105
+ cat package.json | jq '.dependencies'
106
+ cat package.json | jq '.devDependencies'
107
+
108
+ # Cargo
109
+ cat Cargo.toml | grep -A50 "dependencies"
110
+
111
+ # pip
112
+ cat requirements.txt
113
+ ```
114
+
115
+ **Update project.md dependencies section**
116
+
117
+ ### 4. Architecture Snapshot
118
+
119
+ Document current architecture:
120
+
121
+ ```bash
122
+ # Directory structure
123
+ find src -type d | head -20
124
+
125
+ # File counts
126
+ find src -name "*.ts" | wc -l
127
+ find src -name "*.test.ts" | wc -l
128
+
129
+ # Layer analysis
130
+ ls -la src/lib/
131
+ ls -la src/commands/
132
+ ```
133
+
134
+ **Architecture Documentation:**
135
+
136
+ ```markdown
137
+ ## Architecture Snapshot (Generated [date])
138
+
139
+ ### Structure
140
+ ```
141
+ src/
142
+ ├── lib/ # [N] files
143
+ ├── commands/ # [N] files
144
+ └── index.ts # Entry point
145
+ ```
146
+
147
+ ### Key Modules
148
+ - [Module]: [Purpose]
149
+ - [Module]: [Purpose]
150
+ ```
151
+
152
+ ### 5. Quality Gate Verification
153
+
154
+ Test actual quality commands:
155
+
156
+ ```bash
157
+ # Run and capture actual output
158
+ [build command] && echo "✅ Build works"
159
+ [test command] && echo "✅ Tests work"
160
+ [lint command] && echo "✅ Lint works"
161
+ ```
162
+
163
+ **Update quality gates if commands differ from blueprint**
164
+
165
+ ### 6. Pattern Library Update
166
+
167
+ Update `.pi/context/patterns.md` with extracted patterns:
168
+
169
+ ```markdown
170
+ ## Patterns Library (Refreshed [date])
171
+
172
+ ### Error Handling Patterns
173
+
174
+ #### Result Type Pattern
175
+ [Extracted from actual code]
176
+
177
+ #### Custom Error Pattern
178
+ [Extracted from actual code]
179
+
180
+ ### Logging Patterns
181
+ [Extracted patterns]
182
+
183
+ ### Atomic Operations Patterns
184
+ [Extracted patterns]
185
+ ```
186
+
187
+ ### 7. Validation: Canonical References in Code
188
+
189
+ Check implementation files have canonical references:
190
+
191
+ ```bash
192
+ for file in src/**/*.ts; do
193
+ if grep -q "Canonical Reference:" "$file"; then
194
+ echo "✅ $file has canonical reference"
195
+ # Verify reference points to valid blueprint section
196
+ ref=$(grep "Canonical Reference:" "$file" | head -1 | grep -o '.pi/[^:]*')
197
+ if [ -f "$ref" ]; then
198
+ echo " → Valid: $ref"
199
+ else
200
+ echo " → INVALID: $ref"
201
+ fi
202
+ else
203
+ echo "⚠️ $file missing canonical reference"
204
+ fi
205
+ done
206
+ ```
207
+
208
+ ---
209
+
210
+ ## Output Summary
211
+
212
+ ```markdown
213
+ ## Context Refresh Report
214
+
215
+ ### Commands Updated
216
+ - Build: [old] → [new]
217
+ - Test: [unchanged]
218
+ - Lint: [old] → [new]
219
+
220
+ ### Patterns Extracted
221
+ - [N] new patterns found
222
+ - [M] patterns updated
223
+ - [K] stale patterns removed
224
+
225
+ ### Dependencies
226
+ - Added: [list]
227
+ - Removed: [list]
228
+ - Changed: [list]
229
+
230
+ ### Architecture Changes
231
+ - [Changes to structure]
232
+
233
+ ### Canonical Reference Coverage
234
+ - Files with reference: [X]/[Y]
235
+ - Missing references: [list]
236
+
237
+ ### Files Updated
238
+ - .pi/context/project.md
239
+ - .pi/context/patterns.md
240
+ ```
241
+
242
+ ---
243
+
244
+ ## Acceptance Criteria
245
+
246
+ - [ ] Build/test/lint commands verified and updated
247
+ - [ ] Code patterns extracted and documented
248
+ - [ ] Dependencies list accurate
249
+ - [ ] Architecture snapshot current
250
+ - [ ] Quality gates tested
251
+ - [ ] Canonical references in code checked
252
+ - [ ] Context files updated in blueprint
253
+
254
+ ---
255
+
256
+ ## Next Workflow
257
+
258
+ After refresh, run `/sync-check` then `guardian generate`
@@ -0,0 +1,356 @@
1
+ # Epic Plan Workflow
2
+
3
+ **Purpose:** Plan epics for multi-module projects. Supports cross-module overview planning and module-specific slice planning from architecture documents.
4
+
5
+ ---
6
+
7
+ ## Usage Modes
8
+
9
+ | Mode | Command | When to Use |
10
+ |------|---------|-------------|
11
+ | **Overview** | `/epic-plan --overview` | Plan epics across ALL modules (backend + frontend + infra, etc.) |
12
+ | **Module Slice** | `/epic-plan --module <name> <input-doc>` | Plan the next slice for a specific module using its architecture doc |
13
+ | **Free-Form** | `/epic-plan <feature-description>` | Quick plan for a specific feature (legacy mode) |
14
+
15
+ ---
16
+
17
+ ## Mode 1: Epic Overview (All Modules)
18
+
19
+ **Command:** `/epic-plan --overview`
20
+
21
+ ### Step 1: Discover Modules
22
+
23
+ Scan for all architecture documents:
24
+
25
+ ```bash
26
+ # Find all architecture docs
27
+ find .pi/architecture/modules -name "*.md" -type f 2>/dev/null
28
+ find .pi -name "*-architecture.md" -type f 2>/dev/null
29
+ ls .pi/architecture/modules/ 2>/dev/null
30
+ ```
31
+
32
+ **Identify each module:**
33
+ - Backend (e.g., `backend-architecture.md`, API services, data layer)
34
+ - Frontend (e.g., `frontend-architecture.md`, UI, client-side logic)
35
+ - Infrastructure (e.g., `infra-architecture.md`, deployment, CI/CD, monitoring)
36
+ - Shared/Cross-cutting (e.g., auth, config, contracts)
37
+
38
+ ### Step 2: Load Each Module's Architecture
39
+
40
+ For each discovered module:
41
+ 1. Read its architecture document
42
+ 2. Read its module doc in `.pi/architecture/modules/`
43
+ 3. Check `.pi/architecture/CHANGELOG.md` for pending changes
44
+ 4. Identify current state: what's built, what's planned, what's blocked
45
+
46
+ ### Step 3: Map Cross-Module Dependencies
47
+
48
+ Build a dependency matrix:
49
+
50
+ ```markdown
51
+ ## Cross-Module Dependency Map
52
+
53
+ | Module | Depends On | Provides To | Shared Contracts |
54
+ |--------|-----------|-------------|------------------|
55
+ | Backend | — | Frontend (API), Infra (health checks) | API schema, auth tokens |
56
+ | Frontend | Backend (API) | — | UI component library |
57
+ | Infra | Backend, Frontend | All (deploy, monitor) | Docker configs, CI pipelines |
58
+ ```
59
+
60
+ ### Step 4: Plan Cross-Module Epics
61
+
62
+ For each epic, identify which modules are involved and in what order:
63
+
64
+ ```markdown
65
+ ## Epic Overview: [EPIC_NAME]
66
+
67
+ ### Goal
68
+ [What this epic achieves across the full system]
69
+
70
+ ### Module Breakdown
71
+
72
+ | Module | Scope | Key Changes | Dependencies | Order |
73
+ |--------|-------|-------------|--------------|-------|
74
+ | Backend | Moderate | New API endpoint, data model | None | 1st |
75
+ | Frontend | Simple | UI component for new data | Backend API contract | 2nd |
76
+ | Infra | Minimal | Health check update | Backend endpoint | 3rd |
77
+
78
+ ### Cross-Module Risks
79
+ - **Contract drift:** Backend and Frontend must agree on API schema before either starts
80
+ - **Deployment order:** Backend must deploy before Frontend can use new endpoint
81
+ - **Rollback:** All modules must be rolled back together if issues arise
82
+
83
+ ### Epic Sequence
84
+ 1. **[EPIC-001] Backend API** — Implement data model + endpoint + tests
85
+ 2. **[EPIC-002] Frontend Integration** — Build UI component, connect to API
86
+ 3. **[EPIC-003] Infra Hardening** — Update health checks, monitoring, deploy
87
+
88
+ ### Issue Breakdown (All Modules)
89
+
90
+ #### EPIC-001: Backend API
91
+ 1. **[Issue]** Define API contract (OpenAPI/schema) — Scope: simple
92
+ 2. **[Issue]** Implement data model + migration — Scope: moderate
93
+ 3. **[Issue]** Implement endpoint + validation — Scope: moderate
94
+ 4. **[Issue]** Write integration tests — Scope: moderate
95
+
96
+ #### EPIC-002: Frontend Integration
97
+ 1. **[Issue]** Generate API client from contract — Scope: simple
98
+ 2. **[Issue]** Build UI component — Scope: moderate
99
+ 3. **[Issue]** Wire up to backend + error handling — Scope: simple
100
+
101
+ #### EPIC-003: Infra Hardening
102
+ 1. **[Issue]** Update health check endpoint — Scope: simple
103
+ 2. **[Issue]** Add monitoring alert for new endpoint — Scope: simple
104
+ ```
105
+
106
+ ### Step 5: Deterministic Packet Validation
107
+
108
+ Before validator review, validate the planning packet structure:
109
+
110
+ ```bash
111
+ python scripts/ci/check_planning_packet.py --input=planning_packet.md
112
+ ```
113
+
114
+ If packet validation fails, fix the structure before proceeding to validators.
115
+
116
+ ### Step 6: Validator Review (All Modules)
117
+
118
+ Run validators against the full epic plan:
119
+
120
+ - **Architecture Validator:** Check cross-module boundaries, dependency direction, contract stability
121
+ - **Security Validator:** Check data flow across modules, auth boundaries, external service interactions
122
+ - **Operations Validator:** Check deployment order, rollback strategy, observability across modules
123
+
124
+ ### Step 6: Decision
125
+
126
+ As **architecture-coordinator**:
127
+ - If all APPROVED → proceed to `/issue-draft` for each epic in sequence
128
+ - If any CONDITIONAL → address recommendations, re-validate
129
+ - If any REJECTED → revise epic plan, re-validate
130
+
131
+ ---
132
+
133
+ ## Mode 2: Module Slice Planning
134
+
135
+ **Command:** `/epic-plan --module <name> <input-doc>`
136
+
137
+ Example: `/epic-plan --module frontend docs/frontend-architecture.md`
138
+
139
+ ### Step 1: Load the Module Architecture
140
+
141
+ Read the specified architecture document:
142
+
143
+ ```bash
144
+ cat <input-doc>
145
+ cat .pi/architecture/modules/<module-name>.md 2>/dev/null
146
+ cat .pi/architecture/CHANGELOG.md 2>/dev/null
147
+ ```
148
+
149
+ **Extract from the architecture doc:**
150
+ - Current state: what exists today
151
+ - Planned changes: what the doc says should be built
152
+ - Components: the building blocks and their responsibilities
153
+ - Dependencies: what this module needs from other modules
154
+ - Contracts: APIs, interfaces, data schemas this module exposes or consumes
155
+
156
+ ### Step 2: Assess Implementation Gap
157
+
158
+ Compare current state vs. planned state:
159
+
160
+ ```markdown
161
+ ## Implementation Gap: <module-name>
162
+
163
+ | Component | Current State | Target State | Gap Size |
164
+ |-----------|--------------|--------------|----------|
165
+ | [Component A] | Partially implemented | Complete | Moderate |
166
+ | [Component B] | Not started | Required | Large |
167
+ | [Component C] | Complete | Complete | None |
168
+ | [Component D] | Needs refactor | Redesigned | Moderate |
169
+ ```
170
+
171
+ ### Step 3: Check Pending Changes
172
+
173
+ Check `.pi/architecture/CHANGELOG.md` for any pending architecture changes that affect this module:
174
+
175
+ - Are there pending ADRs that impact this module?
176
+ - Are there recent changes that create follow-up work?
177
+ - Are there superseded decisions that need cleanup?
178
+
179
+ ### Step 4: Slice the Next Epic
180
+
181
+ Based on the gap analysis and pending changes, propose the next slice:
182
+
183
+ **Slicing Criteria:**
184
+ - **Cohesion:** Issues in the epic should touch related components
185
+ - **Independence:** Epic should be implementable without waiting on other modules (or have clear contracts)
186
+ - **Value:** Epic should deliver measurable progress toward the architecture goal
187
+ - **Risk:** Don't cluster high-risk items; spread complexity across epics
188
+
189
+ **Output Format:**
190
+
191
+ ```markdown
192
+ ## Epic Slice: [EPIC_NAME] — [Module]
193
+
194
+ ### Source Architecture
195
+ [input-doc path] — [section/heading that drives this epic]
196
+
197
+ ### Summary
198
+ [2-3 sentence description of what this slice accomplishes for the module]
199
+
200
+ ### Architecture Slice
201
+ [Which components/interfaces this epic touches]
202
+
203
+ ### Estimated Scope
204
+ - Files: [X]
205
+ - Lines: [Y]
206
+ - Validators Required: [list]
207
+
208
+ ### Issue Breakdown
209
+ 1. **[Issue 1 Title]** — [Description] — Scope: [simple/moderate/complex] — Component: [name]
210
+ 2. **[Issue 2 Title]** — [Description] — Scope: [simple/moderate/complex] — Component: [name]
211
+ 3. **[Issue 3 Title]** — [Description] — Scope: [simple/moderate/complex] — Component: [name]
212
+
213
+ ### Cross-Module Dependencies
214
+ | Dependency | Module | Status | Notes |
215
+ |-----------|--------|--------|-------|
216
+ | [API contract] | Backend | ✅ Ready / ⏳ Pending / ❌ Blocked | [details] |
217
+ | [UI component] | Frontend | ✅ Ready / ⏳ Pending / ❌ Blocked | [details] |
218
+
219
+ ### Risk Assessment
220
+ - **Architecture Risk:** [Low/Medium/High] — [reason]
221
+ - **Security Risk:** [Low/Medium/High] — [reason]
222
+ - **Operations Risk:** [Low/Medium/High] — [reason]
223
+
224
+ ### Pending Architecture Changes
225
+ [List any CHANGELOG items that must be addressed in or after this epic]
226
+ ```
227
+
228
+ ### Step 5: Validator Review
229
+
230
+ Run validators scoped to this module:
231
+
232
+ **Architecture Validator:**
233
+ ```
234
+ /architecture-validator
235
+
236
+ Review epic slice for <module-name>:
237
+ 1. Compliance with <input-doc> architecture decisions
238
+ 2. Component boundary correctness
239
+ 3. Dependency direction (should flow inward)
240
+ 4. Interface stability with other modules
241
+ ```
242
+
243
+ **Security Validator:** (if module touches auth, data, or external services)
244
+ ```
245
+ /security-validator
246
+
247
+ Review epic slice for <module-name>:
248
+ 1. Data flow security
249
+ 2. Authentication/authorization changes
250
+ 3. External service interactions
251
+ 4. Sensitive data handling
252
+ ```
253
+
254
+ **Operations Validator:** (if module affects deployment, monitoring, or performance)
255
+ ```
256
+ /operations-validator
257
+
258
+ Review epic slice for <module-name>:
259
+ 1. Observability impact
260
+ 2. Deployment complexity
261
+ 3. Rollback strategy
262
+ 4. Performance implications
263
+ ```
264
+
265
+ ### Step 6: Decision
266
+
267
+ As **architecture-coordinator**:
268
+ - If all APPROVED → proceed to `/issue-draft`
269
+ - If any CONDITIONAL → address recommendations, re-validate
270
+ - If any REJECTED → revise epic slice, re-validate
271
+
272
+ ---
273
+
274
+ ## Mode 3: Free-Form (Legacy)
275
+
276
+ **Command:** `/epic-plan <feature-description>`
277
+
278
+ Quick planning for a specific feature without module context. Use only for simple, single-module features.
279
+
280
+ ### Steps
281
+ 1. Analyze the feature description against current architecture
282
+ 2. Identify which module(s) are affected
283
+ 3. Propose an epic with issue breakdown
284
+ 4. Run validators
285
+ 5. Decision: approve, condition, or reject
286
+
287
+ ---
288
+
289
+ ## Validator Response Format
290
+
291
+ All validators output:
292
+
293
+ ```markdown
294
+ ## [Validator Name] Review
295
+
296
+ ### Scope
297
+ [Modules/components reviewed]
298
+
299
+ ### Status: ✅ APPROVED / ⚠️ CONDITIONAL / ❌ REJECTED
300
+
301
+ ### Findings
302
+ - [Finding 1]
303
+ - [Finding 2]
304
+
305
+ ### Recommendations
306
+ - [Recommendation 1]
307
+ - [Recommendation 2]
308
+
309
+ ### Required Changes (if CONDITIONAL/REJECTED)
310
+ - [Change 1]
311
+ - [Change 2]
312
+ ```
313
+
314
+ ---
315
+
316
+ ## Acceptance Criteria
317
+
318
+ ### For Overview Mode
319
+ - [ ] All modules discovered and architecture docs loaded
320
+ - [ ] Cross-module dependency map documented
321
+ - [ ] Epic sequence ordered by dependency
322
+ - [ ] All validators reviewed cross-module risks
323
+ - [ ] Epic overview ready for `/issue-draft` (sequential epics)
324
+
325
+ ### For Module Slice Mode
326
+ - [ ] Input architecture document loaded and analyzed
327
+ - [ ] Implementation gap assessed
328
+ - [ ] Pending architecture changes identified
329
+ - [ ] Epic slice proposed with issue breakdown
330
+ - [ ] Cross-module dependencies documented
331
+ - [ ] All validators reviewed module-specific risks
332
+ - [ ] Epic slice ready for `/issue-draft`
333
+
334
+ ### For Free-Form Mode
335
+ - [ ] Feature analyzed against architecture
336
+ - [ ] Affected modules identified
337
+ - [ ] Epic proposed with issue breakdown
338
+ - [ ] Validators reviewed
339
+ - [ ] Epic ready for `/issue-draft`
340
+
341
+ ---
342
+
343
+ ## Git Repository Tool
344
+
345
+ Use the configured repository tool (`{{REPOTOOL}}`):
346
+
347
+ - **gh** (GitHub): `gh issue list`, `gh issue create`, `gh issue view`, `gh epic list`
348
+ - **glab** (GitLab): `glab issue list`, `glab issue create`, `glab issue view`, `glab epic list`
349
+
350
+ Check existing epics/issues before proposing new ones to avoid duplicates.
351
+
352
+ ---
353
+
354
+ ## Next Workflow
355
+
356
+ After approval, run: `/issue-draft`