amazingteam 3.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 (164) hide show
  1. package/.ai-team/agents/architect.md +144 -0
  2. package/.ai-team/agents/ci-analyst.md +188 -0
  3. package/.ai-team/agents/developer.md +176 -0
  4. package/.ai-team/agents/planner.md +355 -0
  5. package/.ai-team/agents/qa.md +189 -0
  6. package/.ai-team/agents/reviewer.md +211 -0
  7. package/.ai-team/agents/triage.md +146 -0
  8. package/.ai-team/commands/ci-analyze.md +116 -0
  9. package/.ai-team/commands/design.md +100 -0
  10. package/.ai-team/commands/implement.md +108 -0
  11. package/.ai-team/commands/release-check.md +142 -0
  12. package/.ai-team/commands/review.md +142 -0
  13. package/.ai-team/commands/test.md +115 -0
  14. package/.ai-team/commands/triage.md +138 -0
  15. package/.ai-team/memory/architect/architecture_notes.md +67 -0
  16. package/.ai-team/memory/architect/design_rationale.md +113 -0
  17. package/.ai-team/memory/architect/module_map.md +84 -0
  18. package/.ai-team/memory/ci-analyst/failure_patterns.md +102 -0
  19. package/.ai-team/memory/ci-analyst/runbook_references.md +87 -0
  20. package/.ai-team/memory/developer/bug_investigation.md +102 -0
  21. package/.ai-team/memory/developer/build_issues.md +115 -0
  22. package/.ai-team/memory/developer/implementation_notes.md +83 -0
  23. package/.ai-team/memory/failures/failure_library.md +103 -0
  24. package/.ai-team/memory/planner/decomposition_notes.md +82 -0
  25. package/.ai-team/memory/planner/flow_rules.md +86 -0
  26. package/.ai-team/memory/planner/github_issue_patterns.md +229 -0
  27. package/.ai-team/memory/qa/regression_cases.md +101 -0
  28. package/.ai-team/memory/qa/test_strategy.md +138 -0
  29. package/.ai-team/memory/qa/validation_notes.md +110 -0
  30. package/.ai-team/memory/reviewer/quality_rules.md +105 -0
  31. package/.ai-team/memory/reviewer/recurring_risks.md +109 -0
  32. package/.ai-team/memory/reviewer/review_notes.md +124 -0
  33. package/.ai-team/memory/triage/classification_heuristics.md +82 -0
  34. package/.ai-team/memory/triage/debug_notes.md +87 -0
  35. package/.ai-team/opencode.template.jsonc +216 -0
  36. package/.ai-team/skills/bugfix-playbook/skill.md +174 -0
  37. package/.ai-team/skills/ci-failure-analysis/skill.md +176 -0
  38. package/.ai-team/skills/issue-triage/skill.md +163 -0
  39. package/.ai-team/skills/regression-checklist/skill.md +176 -0
  40. package/.ai-team/skills/release-readiness-check/skill.md +216 -0
  41. package/.ai-team/skills/repo-architecture-reader/skill.md +139 -0
  42. package/.ai-team/skills/safe-refactor-checklist/skill.md +215 -0
  43. package/.ai-team/skills/task-breakdown-and-dispatch/skill.md +151 -0
  44. package/.ai-team/skills/test-first-feature-dev/skill.md +205 -0
  45. package/.ai-team/workflows/ci.yml +81 -0
  46. package/.ai-team/workflows/nightly-ai-maintenance.yml +129 -0
  47. package/.ai-team/workflows/opencode.yml +33 -0
  48. package/.ai-team/workflows/pr-check.yml +41 -0
  49. package/.foundation/foundation.lock +38 -0
  50. package/.foundation/local-overrides.md +97 -0
  51. package/.foundation/upgrade-history.md +38 -0
  52. package/.opencode/agents/architect.md +38 -0
  53. package/.opencode/agents/ci-analyst.md +38 -0
  54. package/.opencode/agents/developer.md +43 -0
  55. package/.opencode/agents/planner.md +47 -0
  56. package/.opencode/agents/qa.md +34 -0
  57. package/.opencode/agents/reviewer.md +38 -0
  58. package/.opencode/agents/triage.md +37 -0
  59. package/.opencode/commands/auto.md +264 -0
  60. package/.opencode/commands/breakdown-issue.md +94 -0
  61. package/.opencode/commands/ci-analyze.md +15 -0
  62. package/.opencode/commands/close-parent-task.md +122 -0
  63. package/.opencode/commands/design.md +15 -0
  64. package/.opencode/commands/dispatch-next.md +102 -0
  65. package/.opencode/commands/implement.md +16 -0
  66. package/.opencode/commands/release-check.md +16 -0
  67. package/.opencode/commands/resume.md +88 -0
  68. package/.opencode/commands/review.md +15 -0
  69. package/.opencode/commands/show-blockers.md +97 -0
  70. package/.opencode/commands/summarize-parent.md +121 -0
  71. package/.opencode/commands/test.md +15 -0
  72. package/.opencode/commands/triage.md +109 -0
  73. package/.opencode/skills/bugfix-playbook/SKILL.md +81 -0
  74. package/.opencode/skills/ci-failure-analysis/SKILL.md +94 -0
  75. package/.opencode/skills/issue-triage/SKILL.md +80 -0
  76. package/.opencode/skills/regression-checklist/SKILL.md +81 -0
  77. package/.opencode/skills/release-readiness-check/SKILL.md +81 -0
  78. package/.opencode/skills/repo-architecture-reader/SKILL.md +65 -0
  79. package/.opencode/skills/safe-refactor-checklist/SKILL.md +76 -0
  80. package/.opencode/skills/task-breakdown-and-dispatch/SKILL.md +255 -0
  81. package/.opencode/skills/test-first-feature-dev/SKILL.md +78 -0
  82. package/AGENTS.md +879 -0
  83. package/CHANGELOG.md +261 -0
  84. package/LICENSE +21 -0
  85. package/README.md +1215 -0
  86. package/VERSION +1 -0
  87. package/action/__tests__/downloader.test.js +251 -0
  88. package/action/__tests__/merger.test.js +156 -0
  89. package/action/__tests__/path-resolver.test.js +199 -0
  90. package/action/__tests__/validator.test.js +310 -0
  91. package/action/action.yml +61 -0
  92. package/action/index.js +223 -0
  93. package/action/lib/downloader.js +344 -0
  94. package/action/lib/merger.js +170 -0
  95. package/action/lib/path-resolver.js +176 -0
  96. package/action/lib/setup.js +286 -0
  97. package/action/lib/validator.js +324 -0
  98. package/cli/__tests__/cli.test.js +270 -0
  99. package/cli/amazingteam.cjs +225 -0
  100. package/cli/commands/check-update.cjs +159 -0
  101. package/cli/commands/init.cjs +412 -0
  102. package/cli/commands/local.cjs +264 -0
  103. package/cli/commands/migrate.cjs +316 -0
  104. package/cli/commands/status.cjs +241 -0
  105. package/cli/commands/upgrade.cjs +213 -0
  106. package/cli/commands/validate.cjs +259 -0
  107. package/cli/commands/version.cjs +59 -0
  108. package/cli/sync.cjs +237 -0
  109. package/dist/index.js +35 -0
  110. package/docs/architecture/overview.md +138 -0
  111. package/docs/blocker_resolution_design.md +372 -0
  112. package/docs/bootstrap-model.md +356 -0
  113. package/docs/config-reference.md +458 -0
  114. package/docs/how-to-use.md +178 -0
  115. package/docs/migration-to-v3.md +355 -0
  116. package/docs/overlay-guide.md +156 -0
  117. package/docs/patterns/README.md +67 -0
  118. package/docs/quick-start-v3.md +330 -0
  119. package/docs/releases/README.md +64 -0
  120. package/docs/runbooks/ci/README.md +62 -0
  121. package/docs/runbooks/ci/build-debug.md +120 -0
  122. package/docs/runbooks/ci/flaky-tests.md +127 -0
  123. package/docs/runbooks/getting-started.md +81 -0
  124. package/docs/upgrade-policy.md +188 -0
  125. package/docs/versioning.md +199 -0
  126. package/overlays/README.md +30 -0
  127. package/overlays/ai-agent-product/.ai-team/skills/llm-integration/skill.md +99 -0
  128. package/overlays/ai-agent-product/docs/ai-agent-architecture.md +68 -0
  129. package/overlays/ai-agent-product/overlay.yaml +26 -0
  130. package/overlays/cpp-qt-desktop/.ai-team/skills/qt-signals-slots/skill.md +60 -0
  131. package/overlays/cpp-qt-desktop/docs/qt-conventions.md +64 -0
  132. package/overlays/cpp-qt-desktop/overlay.yaml +22 -0
  133. package/overlays/python-backend/.ai-team/skills/python-testing/skill.md +90 -0
  134. package/overlays/python-backend/docs/python-style.md +78 -0
  135. package/overlays/python-backend/overlay.yaml +22 -0
  136. package/overlays/web-fullstack/.ai-team/skills/frontend-testing/skill.md +70 -0
  137. package/overlays/web-fullstack/docs/frontend-conventions.md +68 -0
  138. package/overlays/web-fullstack/overlay.yaml +26 -0
  139. package/package.json +84 -0
  140. package/presets/default.yaml +161 -0
  141. package/presets/go.yaml +43 -0
  142. package/presets/python.yaml +43 -0
  143. package/presets/typescript.yaml +40 -0
  144. package/schemas/config.schema.json +239 -0
  145. package/scripts/diff_foundation_vs_project.sh +134 -0
  146. package/scripts/generate_docs.sh +200 -0
  147. package/scripts/init_project.sh +455 -0
  148. package/scripts/plan_upgrade.sh +268 -0
  149. package/scripts/upgrade_foundation.sh +365 -0
  150. package/scripts/validate-foundation.cjs +278 -0
  151. package/scripts/validate_foundation.sh +192 -0
  152. package/scripts/validate_project_setup.sh +171 -0
  153. package/tasks/README.md +94 -0
  154. package/tasks/_template/analysis.md +76 -0
  155. package/tasks/_template/design.md +121 -0
  156. package/tasks/_template/implementation.md +121 -0
  157. package/tasks/_template/release.md +119 -0
  158. package/tasks/_template/review.md +131 -0
  159. package/tasks/_template/subtasks/task.yaml +24 -0
  160. package/tasks/_template/task.yaml +75 -0
  161. package/tasks/_template/validation.md +128 -0
  162. package/templates/amazingteam.yml +81 -0
  163. package/templates/gitignore +14 -0
  164. package/templates/opencode.jsonc +216 -0
@@ -0,0 +1,372 @@
1
+ # Issue Blocker Resolution Design
2
+
3
+ ## Overview
4
+
5
+ This document defines the process for handling blockers encountered during automated workflow execution.
6
+
7
+ ## Problem Handling Flow
8
+
9
+ ```
10
+ Workflow Execution
11
+
12
+ ▼ (Encounter Problem)
13
+ ┌───────────────┐
14
+ │ Problem Detect│
15
+ └───────┬───────┘
16
+
17
+
18
+ ┌───────────────┐
19
+ │ Dispatch │
20
+ │ to CI Analyst │
21
+ │ (Diagnose) │
22
+ └───────┬───────┘
23
+
24
+
25
+ ┌───────────────┐
26
+ │ Classification│
27
+ │ & Analysis │
28
+ └───────┬───────┘
29
+
30
+
31
+ ┌────┴────┐
32
+ │Decision │
33
+ └────┬────┘
34
+
35
+ ┌────┴────────────────┐
36
+ ↓ ↓
37
+ Can Resolve Cannot Resolve
38
+ Now │
39
+ │ ▼
40
+ │ ┌────────────────┐
41
+ │ │ Create Sub-issue│
42
+ │ │ (Blocker) │
43
+ │ └───────┬────────┘
44
+ │ │
45
+ │ ▼
46
+ │ ┌────┴────┐
47
+ │ │ Needs │
48
+ │ │ Human? │
49
+ │ └────┬────┘
50
+ │ │
51
+ │ ┌────────┴────────┐
52
+ │ ↓ ↓
53
+ │ Yes No
54
+ │ │ │
55
+ │ ▼ ▼
56
+ │ ┌─────────────┐ ┌─────────────┐
57
+ │ │ Notify Human│ │ Auto-resolve│
58
+ │ │ (Wait) │ │ Sub-issue │
59
+ │ └──────┬──────┘ └──────┬──────┘
60
+ │ │ │
61
+ │ │ ▼
62
+ │ │ Sub-issue Done
63
+ │ │ │
64
+ │ └────────┬────────┘
65
+ │ │
66
+ └────────────────────┤
67
+
68
+ Resume Original Task
69
+ ```
70
+
71
+ ## Blocker Categories
72
+
73
+ ### Category 1: Auto-Resolvable
74
+
75
+ | Blocker Type | Description | Resolution |
76
+ |--------------|-------------|------------|
77
+ | Code Error | Syntax, type errors | Auto-fix by Developer |
78
+ | Missing Import | Import statement missing | Auto-add import |
79
+ | Test Failure | Logic error in test | Auto-fix test |
80
+ | Lint Error | Style violation | Auto-fix with linter |
81
+ | Missing Dependency | Package not installed | Auto-install |
82
+ | Config Error | Wrong configuration | Auto-correct |
83
+
84
+ ### Category 2: Sub-issue Resolvable (AI)
85
+
86
+ | Blocker Type | Description | Action |
87
+ |--------------|-------------|--------|
88
+ | Complex Bug | Requires investigation | Create sub-issue, auto-resolve |
89
+ | API Change | External API changed | Create sub-issue, adapt code |
90
+ | Performance Issue | Slow performance | Create sub-issue, optimize |
91
+ | Missing Feature | Prerequisite not implemented | Create sub-issue, implement |
92
+
93
+ ### Category 3: Human Required
94
+
95
+ | Blocker Type | Description | Action |
96
+ |--------------|-------------|--------|
97
+ | Permission Denied | No access to resource | Notify human, wait |
98
+ | Secret Missing | API key or credential needed | Notify human, wait |
99
+ | Architecture Decision | Major design choice | Notify human, wait |
100
+ | External Dependency | Third-party service down | Notify human, wait |
101
+ | Business Logic Unclear | Requirements ambiguous | Notify human, wait |
102
+ | Security Issue | Potential vulnerability | Notify human, wait |
103
+
104
+ ## Decision Matrix
105
+
106
+ ```
107
+ ┌─────────────────────────────────────────────────────────────────┐
108
+ │ BLOCKER RESOLUTION MATRIX │
109
+ ├─────────────────┬───────────────┬─────────────┬────────────────┤
110
+ │ Factor │ Low │ Medium │ High │
111
+ ├─────────────────┼───────────────┼─────────────┼────────────────┤
112
+ │ Complexity │ Auto-fix now │ Sub-issue │ Notify Human │
113
+ │ Risk │ Auto-fix now │ Sub-issue │ Notify Human │
114
+ │ External Dep │ Sub-issue │ Sub-issue │ Notify Human │
115
+ │ Permission │ Sub-issue │ Notify Human│ Notify Human │
116
+ │ Business Impact │ Auto-fix now │ Sub-issue │ Notify Human │
117
+ └─────────────────┴───────────────┴─────────────┴────────────────┘
118
+ ```
119
+
120
+ ## Process Details
121
+
122
+ ### Step 1: Problem Detection
123
+
124
+ When workflow encounters an error:
125
+ 1. Capture error context
126
+ 2. Save current workflow state
127
+ 3. Pause workflow execution
128
+ 4. Dispatch to CI Analyst
129
+
130
+ ### Step 2: Diagnosis (CI Analyst)
131
+
132
+ CI Analyst performs:
133
+ 1. Analyze error logs
134
+ 2. Identify root cause
135
+ 3. Classify blocker type
136
+ 4. Determine resolution path
137
+ 5. Estimate resolution effort
138
+
139
+ Output:
140
+ ```markdown
141
+ ## Blocker Analysis
142
+
143
+ - **Type**: [code/infra/permission/external/unknown]
144
+ - **Severity**: [low/medium/high/critical]
145
+ - **Complexity**: [simple/moderate/complex]
146
+ - **Risk Level**: [low/medium/high]
147
+ - **Can Auto-Resolve**: [yes/no/partial]
148
+ - **Needs Human**: [yes/no]
149
+
150
+ ### Root Cause
151
+ [Description]
152
+
153
+ ### Recommended Action
154
+ - [ ] Auto-fix now
155
+ - [ ] Create sub-issue (AI resolve)
156
+ - [ ] Create sub-issue (Human required)
157
+ - [ ] Notify human immediately
158
+ ```
159
+
160
+ ### Step 3: Resolution Path
161
+
162
+ #### Path A: Auto-Resolve Now
163
+
164
+ For simple, low-risk blockers:
165
+ 1. Developer fixes the issue
166
+ 2. Continue workflow immediately
167
+ 3. Log the fix
168
+
169
+ #### Path B: Create Sub-issue (AI Resolve)
170
+
171
+ For moderate complexity blockers:
172
+ 1. Create blocker sub-issue
173
+ 2. Execute sub-issue resolution
174
+ 3. Verify fix
175
+ 4. Continue original workflow
176
+
177
+ #### Path C: Notify Human
178
+
179
+ For blockers requiring human intervention:
180
+ 1. Create blocker sub-issue
181
+ 2. Send notification
182
+ 3. Pause workflow
183
+ 4. Wait for human resolution
184
+ 5. Resume after human input
185
+
186
+ ## Sub-issue Creation
187
+
188
+ ### Blocker Sub-issue Template
189
+
190
+ ```bash
191
+ gh issue create \
192
+ --title "[Blocker] {blocker_description}" \
193
+ --body "## Parent Issue
194
+ #{parent_issue_id}
195
+
196
+ ## Blocking Reason
197
+ {why this blocks the workflow}
198
+
199
+ ## Analysis
200
+ - **Type**: {type}
201
+ - **Severity**: {severity}
202
+ - **Complexity**: {complexity}
203
+
204
+ ## Root Cause
205
+ {root_cause}
206
+
207
+ ## Recommended Resolution
208
+ {suggested_fix}
209
+
210
+ ## Requires Human
211
+ {yes/no}
212
+
213
+ ## Reason for Human Involvement
214
+ {if yes, explain why AI cannot resolve}
215
+
216
+ ## Acceptance Criteria
217
+ - [ ] Blocker resolved
218
+ - [ ] Workflow can resume
219
+
220
+ ## Impact
221
+ - **Blocked Issue**: #{parent_issue_id}
222
+ - **Blocked Workflow Phase**: {phase}
223
+ - **Time Sensitive**: {yes/no}" \
224
+ --label "type:blocker,priority:{priority}"
225
+ ```
226
+
227
+ ## Human Notification
228
+
229
+ ### Notification Channels
230
+
231
+ | Channel | When to Use |
232
+ |---------|-------------|
233
+ | Issue Comment | Always (primary) |
234
+ | Email | Critical blockers, time-sensitive |
235
+ | Slack/Teams | Critical blockers requiring immediate attention |
236
+
237
+ ### Notification Template
238
+
239
+ ```markdown
240
+ ## ⚠️ Workflow Blocked - Human Attention Required
241
+
242
+ **Issue**: #{issue_id} - {issue_title}
243
+ **Blocker**: #{blocker_issue_id} - {blocker_title}
244
+
245
+ ### Summary
246
+ {brief description of the blocker}
247
+
248
+ ### Why Human is Needed
249
+ {explanation of why AI cannot resolve}
250
+
251
+ ### Suggested Actions
252
+ 1. {action_1}
253
+ 2. {action_2}
254
+
255
+ ### Resume Command
256
+ After resolving the blocker, comment:
257
+ ```
258
+ /oc /resume
259
+ ```
260
+
261
+ ### Time Sensitivity
262
+ {critical/high/medium/low}
263
+
264
+ ---
265
+ *This is an automated notification from the AI Team workflow.*
266
+ ```
267
+
268
+ ## Resume Workflow
269
+
270
+ After blocker resolution:
271
+ 1. Verify blocker is resolved
272
+ 2. Restore workflow state
273
+ 3. Continue from last successful step
274
+ 4. Log resolution
275
+
276
+ ### Resume Command
277
+
278
+ ```markdown
279
+ /oc /resume
280
+
281
+ # Or with additional context
282
+ /oc /resume
283
+ The permission issue has been fixed. Please continue.
284
+ ```
285
+
286
+ ## Examples
287
+
288
+ ### Example 1: Auto-Resolvable
289
+
290
+ ```
291
+ Error: Cannot find module './utils'
292
+
293
+ CI Analyst Diagnosis:
294
+ - Type: code
295
+ - Severity: low
296
+ - Can Auto-Resolve: yes
297
+ - Action: Add missing import
298
+
299
+ Resolution: Developer adds import, workflow continues.
300
+ ```
301
+
302
+ ### Example 2: Sub-issue (AI Resolve)
303
+
304
+ ```
305
+ Error: API endpoint /v2/users not found
306
+
307
+ CI Analyst Diagnosis:
308
+ - Type: external
309
+ - Severity: medium
310
+ - Can Auto-Resolve: no (requires code change)
311
+ - Needs Human: no
312
+ - Action: Create sub-issue to update API endpoint
313
+
314
+ Resolution:
315
+ 1. Create sub-issue #205: Update API endpoint to /v3/users
316
+ 2. Developer implements fix
317
+ 3. Tests pass
318
+ 4. Resume original workflow
319
+ ```
320
+
321
+ ### Example 3: Human Required
322
+
323
+ ```
324
+ Error: Permission denied: Cannot push to protected branch 'main'
325
+
326
+ CI Analyst Diagnosis:
327
+ - Type: permission
328
+ - Severity: high
329
+ - Can Auto-Resolve: no
330
+ - Needs Human: yes (branch protection rules)
331
+ - Action: Notify human
332
+
333
+ Resolution:
334
+ 1. Create blocker sub-issue #206
335
+ 2. Post notification on parent issue
336
+ 3. Send email if critical
337
+ 4. Wait for human to:
338
+ - Temporarily disable branch protection
339
+ - OR grant required permissions
340
+ - OR provide alternative approach
341
+ 5. Human comments `/oc /resume`
342
+ 6. Continue workflow
343
+ ```
344
+
345
+ ## Integration with /auto Command
346
+
347
+ The `/auto` command integrates blocker handling:
348
+
349
+ ```markdown
350
+ ## /auto Command Flow with Blockers
351
+
352
+ 1. Triage → Design → Implement
353
+ 2. If blocker encountered:
354
+ a. Pause
355
+ b. Dispatch to CI Analyst
356
+ c. Diagnose
357
+ d. Resolve (auto/sub-issue/human)
358
+ e. Resume
359
+ 3. Continue: Test → Create PR
360
+ ```
361
+
362
+ ## Metrics
363
+
364
+ Track blocker metrics for improvement:
365
+
366
+ | Metric | Description |
367
+ |--------|-------------|
368
+ | Blocker Rate | Blockers per issue |
369
+ | Auto-Resolve Rate | % auto-resolved |
370
+ | Human Intervention Rate | % requiring human |
371
+ | Avg Resolution Time | Time to unblock |
372
+ | Common Blocker Types | Most frequent blockers |
@@ -0,0 +1,356 @@
1
+ # Bootstrap Model
2
+
3
+ This document describes the self-bootstrap capability of AI Team Foundation.
4
+
5
+ ## Philosophy
6
+
7
+ The foundation repository supports **controlled operational bootstrap**, not uncontrolled autonomous mutation.
8
+
9
+ ### The Foundation Should Be Able To
10
+
11
+ - Initialize new downstream projects
12
+ - Validate its own integrity
13
+ - Validate downstream project setup
14
+ - Plan controlled upgrades
15
+ - Apply safe, reviewable upgrades
16
+ - Generate operational documentation
17
+
18
+ ### The Foundation Should NOT Automatically
19
+
20
+ - Rewrite its own core governance
21
+ - Rewrite durable truth documents casually
22
+ - Upgrade all downstream projects without approval
23
+ - Merge downstream customizations back into foundation
24
+ - Overwrite protected project-specific configuration
25
+
26
+ ## Capability Categories
27
+
28
+ ### 1. Initialization Capability
29
+
30
+ **Purpose**: Create new downstream project repositories from the foundation.
31
+
32
+ **Responsibilities**:
33
+ - Copy base structure
34
+ - Apply selected overlay (if any)
35
+ - Initialize `.ai-team/`, `.github/`, `docs/`, `tasks/`
36
+ - Create foundation lock metadata
37
+
38
+ **Script**: `scripts/init_project.sh`
39
+
40
+ **When to Use**:
41
+ - Starting a new project
42
+ - Creating a project from a specific overlay
43
+
44
+ ---
45
+
46
+ ### 2. Validation Capability
47
+
48
+ **Purpose**: Check structural completeness and policy compliance.
49
+
50
+ **Responsibilities**:
51
+ - Verify required directories
52
+ - Verify required templates
53
+ - Verify agent/skill/command files
54
+ - Verify version metadata
55
+
56
+ **Scripts**:
57
+ - `scripts/validate_foundation.sh` - Validate foundation itself
58
+ - `scripts/validate_project_setup.sh` - Validate downstream project
59
+
60
+ **When to Use**:
61
+ - After initialization
62
+ - After upgrade
63
+ - In CI pipeline
64
+ - Before release
65
+
66
+ ---
67
+
68
+ ### 3. Upgrade Planning Capability
69
+
70
+ **Purpose**: Compare downstream project with foundation release.
71
+
72
+ **Responsibilities**:
73
+ - Detect missing files
74
+ - Detect outdated templates
75
+ - Detect local overrides
76
+ - Classify upgrade risk
77
+ - Generate upgrade report
78
+
79
+ **Script**: `scripts/plan_upgrade.sh`
80
+
81
+ **When to Use**:
82
+ - When new foundation version is released
83
+ - Before applying upgrades
84
+ - To audit project drift
85
+
86
+ ---
87
+
88
+ ### 4. Controlled Upgrade Capability
89
+
90
+ **Purpose**: Apply upgrades after review and approval.
91
+
92
+ **Responsibilities**:
93
+ - Create missing directories
94
+ - Add new template files
95
+ - Patch allowed files
96
+ - Preserve local overrides
97
+ - Log upgrade history
98
+
99
+ **Script**: `scripts/upgrade_foundation.sh`
100
+
101
+ **Approval Gates**:
102
+ - Class A: May be automatic
103
+ - Class B: Requires review
104
+ - Class C: Requires explicit approval
105
+
106
+ ---
107
+
108
+ ### 5. Documentation Generation Capability
109
+
110
+ **Purpose**: Generate operational documentation.
111
+
112
+ **Responsibilities**:
113
+ - Generate structure docs
114
+ - Generate role/skill inventories
115
+ - Generate version docs
116
+
117
+ **Script**: `scripts/generate_docs.sh`
118
+
119
+ **When to Use**:
120
+ - After major changes
121
+ - For documentation updates
122
+ - To audit current state
123
+
124
+ ---
125
+
126
+ ## Operating Modes
127
+
128
+ ### Mode A: init
129
+
130
+ Initialize a new project.
131
+
132
+ ```bash
133
+ ./scripts/init_project.sh my-project
134
+ ./scripts/init_project.sh -o python-backend my-api
135
+ ```
136
+
137
+ **Behavior**:
138
+ - Creates new scaffold
139
+ - Applies base templates
140
+ - Applies selected overlay
141
+ - Creates lock metadata
142
+ - Does NOT touch business code
143
+
144
+ ---
145
+
146
+ ### Mode B: validate
147
+
148
+ Validate structure (read-only).
149
+
150
+ ```bash
151
+ ./scripts/validate_foundation.sh
152
+ ./scripts/validate_project_setup.sh /path/to/project
153
+ ```
154
+
155
+ **Behavior**:
156
+ - Read-only
157
+ - No changes applied
158
+ - Returns validation report
159
+ - Identifies missing or inconsistent elements
160
+
161
+ ---
162
+
163
+ ### Mode C: plan-upgrade
164
+
165
+ Analyze upgrade requirements (read-only).
166
+
167
+ ```bash
168
+ ./scripts/plan_upgrade.sh /path/to/project
169
+ ```
170
+
171
+ **Behavior**:
172
+ - Read-only
173
+ - Compares against foundation version
174
+ - Classifies changes
175
+ - Generates upgrade report
176
+ - Identifies conflicts
177
+
178
+ ---
179
+
180
+ ### Mode D: apply-upgrade
181
+
182
+ Perform controlled upgrade.
183
+
184
+ ```bash
185
+ ./scripts/upgrade_foundation.sh /path/to/project
186
+ ./scripts/upgrade_foundation.sh --dry-run /path/to/project
187
+ ```
188
+
189
+ **Behavior**:
190
+ - Applies only allowed changes
191
+ - Preserves local overrides
192
+ - Stops on protected conflicts
193
+ - Writes upgrade history
194
+ - Updates lock metadata
195
+
196
+ ---
197
+
198
+ ## File Classification
199
+
200
+ ### Class A: Auto-Generatable
201
+
202
+ Safe to create or replace automatically.
203
+
204
+ **Examples**:
205
+ - Empty directory placeholders
206
+ - Task templates
207
+ - Issue templates
208
+ - Base workflow drafts
209
+ - Missing skill skeletons
210
+
211
+ **Upgrade Policy**: May be automatically created/replaced.
212
+
213
+ ---
214
+
215
+ ### Class B: Review Required
216
+
217
+ Can receive update proposals, but not silently overwritten.
218
+
219
+ **Examples**:
220
+ - `AGENTS.md`
221
+ - Agent prompt files
222
+ - Command files
223
+ - Skill definitions
224
+ - Workflow files
225
+
226
+ **Upgrade Policy**: Generate diff, human reviews, then apply.
227
+
228
+ ---
229
+
230
+ ### Class C: Protected
231
+
232
+ Must not be changed automatically without explicit approval.
233
+
234
+ **Examples**:
235
+ - `docs/architecture/`
236
+ - `docs/decisions/`
237
+ - Governance policy
238
+ - Standards policy
239
+
240
+ **Upgrade Policy**: Human-reviewed only. Never auto-modified.
241
+
242
+ ---
243
+
244
+ ## Approval Gates
245
+
246
+ ### Gate 1: Additive Scaffold
247
+
248
+ **Examples**:
249
+ - Create missing folder
250
+ - Create missing template file
251
+
252
+ **Approval**: May be automatic
253
+
254
+ ---
255
+
256
+ ### Gate 2: Patch Proposal
257
+
258
+ **Examples**:
259
+ - Update `AGENTS.md`
260
+ - Update agent prompts
261
+ - Update workflow templates
262
+
263
+ **Approval**: Generate diff → Human review → Apply
264
+
265
+ ---
266
+
267
+ ### Gate 3: Protected Knowledge
268
+
269
+ **Examples**:
270
+ - Update `docs/architecture/`
271
+ - Update `docs/decisions/`
272
+ - Update governance policy
273
+
274
+ **Approval**: Human approval required before any write
275
+
276
+ ---
277
+
278
+ ### Gate 4: Multi-Project Rollout
279
+
280
+ **Examples**:
281
+ - Applying new foundation version to many projects
282
+
283
+ **Approval**: Per-project or explicitly approved batch process only
284
+
285
+ ---
286
+
287
+ ## Safe Operations
288
+
289
+ ✅ **Allowed**:
290
+ - Create missing directories
291
+ - Create missing template files
292
+ - Generate documentation
293
+ - Validate repository structure
294
+ - Compare versions
295
+ - Generate upgrade plans
296
+ - Apply additive upgrades to safe file classes
297
+ - Update lock metadata
298
+ - Update upgrade history
299
+
300
+ ❌ **Blocked by Default**:
301
+ - Rewrite durable truth docs automatically
302
+ - Overwrite local project overrides without confirmation
303
+ - Rewrite role policy arbitrarily
304
+ - Rewrite foundation governance without approval
305
+ - Mass-upgrade all downstream projects automatically
306
+ - Auto-merge downstream changes back into foundation
307
+
308
+ ---
309
+
310
+ ## Anti-Patterns
311
+
312
+ ### Anti-Pattern 1: Infinite Self-Rewrite
313
+
314
+ The foundation automatically rewrites its own governance and role policies.
315
+
316
+ **Why Bad**: Destroys stability and traceability.
317
+
318
+ ---
319
+
320
+ ### Anti-Pattern 2: Automatic Global Rollout
321
+
322
+ A new foundation version pushes itself to every downstream project automatically.
323
+
324
+ **Why Bad**: Different projects have different risks and customizations.
325
+
326
+ ---
327
+
328
+ ### Anti-Pattern 3: Foundation as Business Repo
329
+
330
+ The foundation stores real project tasks and project-specific memory.
331
+
332
+ **Why Bad**: Breaks reusability.
333
+
334
+ ---
335
+
336
+ ### Anti-Pattern 4: No Lock File
337
+
338
+ Downstream projects do not record which foundation version they use.
339
+
340
+ **Why Bad**: Upgrades become chaotic.
341
+
342
+ ---
343
+
344
+ ### Anti-Pattern 5: No File Classification
345
+
346
+ All files are treated as equally safe to overwrite.
347
+
348
+ **Why Bad**: Critical governance or customized files get damaged.
349
+
350
+ ---
351
+
352
+ ## Summary
353
+
354
+ **The foundation should be self-bootstrapping, but not self-governing without human oversight.**
355
+
356
+ This is the correct balance for a reusable AI team foundation product.