create-shhs 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.
- package/LICENSE +21 -0
- package/README.md +301 -0
- package/bin/install.js +212 -0
- package/package.json +43 -0
- package/template/.ai/ADR/.gitkeep +0 -0
- package/template/.ai/agents/architect.md +57 -0
- package/template/.ai/agents/debt-observer.md +59 -0
- package/template/.ai/agents/developer.md +49 -0
- package/template/.ai/agents/domain-architect.md +42 -0
- package/template/.ai/agents/qa.md +60 -0
- package/template/.ai/agents/static-reviewer.md +59 -0
- package/template/.ai/contracts/.gitkeep +0 -0
- package/template/.ai/debt/.gitkeep +0 -0
- package/template/.ai/features/.gitkeep +0 -0
- package/template/.ai/memory/anti-patterns.md +31 -0
- package/template/.ai/memory/patterns.md +31 -0
- package/template/.ai/reports/.gitkeep +0 -0
- package/template/ARCHITECTURE.md +56 -0
- package/template/CLAUDE.md +75 -0
- package/template/README.ai.md +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SHHS Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
# Self-Healing Hybrid Swarm (SHHS)
|
|
2
|
+
|
|
3
|
+
**A reusable AI governance system for software engineering projects**
|
|
4
|
+
|
|
5
|
+
SHHS is a structured multi-agent AI workflow that prevents architectural drift, controls technical debt, and enables safe AI-assisted development at scale.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## What is SHHS?
|
|
10
|
+
|
|
11
|
+
SHHS organizes AI development through **role separation** and **contract-driven workflows**:
|
|
12
|
+
|
|
13
|
+
- **Architecture is protected** through ADRs and governance rules
|
|
14
|
+
- **Development is fast** with clear feature contracts
|
|
15
|
+
- **Validation is objective** using independent review agents
|
|
16
|
+
- **Technical debt is monitored** continuously
|
|
17
|
+
|
|
18
|
+
Instead of one AI doing everything, SHHS mimics a mature engineering organization with distinct roles and responsibilities.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
### Installation
|
|
25
|
+
|
|
26
|
+
Install SHHS into any existing project:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Method 1: NPX (fastest)
|
|
30
|
+
npx create-shhs
|
|
31
|
+
|
|
32
|
+
# Method 2: Git submodule (recommended for tracking updates)
|
|
33
|
+
git submodule add https://github.com/your-org/shhs .shhs
|
|
34
|
+
.shhs/scripts/install.sh
|
|
35
|
+
|
|
36
|
+
# Method 3: Direct installation
|
|
37
|
+
git clone https://github.com/your-org/shhs /tmp/shhs
|
|
38
|
+
/tmp/shhs/scripts/install.sh .
|
|
39
|
+
rm -rf /tmp/shhs
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### What Gets Installed
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
your-project/
|
|
46
|
+
├── .ai/
|
|
47
|
+
│ ├── agents/ # AI role definitions
|
|
48
|
+
│ ├── ADR/ # Architectural Decision Records
|
|
49
|
+
│ ├── contracts/ # Public interfaces
|
|
50
|
+
│ ├── features/ # Cucumber feature contracts
|
|
51
|
+
│ └── memory/ # Patterns and anti-patterns
|
|
52
|
+
├── CLAUDE.md # Governance rules
|
|
53
|
+
├── ARCHITECTURE.md # Architecture template
|
|
54
|
+
└── README.ai.md # Quick reference
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Next Steps
|
|
58
|
+
|
|
59
|
+
1. **Read governance rules:** `cat CLAUDE.md`
|
|
60
|
+
2. **Bootstrap architecture:** Load Root Architect from `.ai/agents/architect.md`
|
|
61
|
+
3. **Create first feature:** Define contract in `.ai/features/`
|
|
62
|
+
4. **Follow the pipeline:** Architect → Developer → Reviewer → QA → Approval
|
|
63
|
+
|
|
64
|
+
Full setup guide: **[docs/setup.md](docs/setup.md)**
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Core Concepts
|
|
69
|
+
|
|
70
|
+
### Role Separation
|
|
71
|
+
|
|
72
|
+
Six specialized agents with strict boundaries:
|
|
73
|
+
|
|
74
|
+
| Agent | File | Purpose |
|
|
75
|
+
|-------|------|---------|
|
|
76
|
+
| **Root Architect** | [.ai/agents/architect.md](template/.ai/agents/architect.md) | Defines architecture, creates ADRs and feature contracts |
|
|
77
|
+
| **Domain Architect** | [.ai/agents/domain-architect.md](template/.ai/agents/domain-architect.md) | Maintains bounded context consistency |
|
|
78
|
+
| **Developer** | [.ai/agents/developer.md](template/.ai/agents/developer.md) | Implements features within defined boundaries |
|
|
79
|
+
| **Static Reviewer** | [.ai/agents/static-reviewer.md](template/.ai/agents/static-reviewer.md) | Validates structural compliance |
|
|
80
|
+
| **QA Validator** | [.ai/agents/qa.md](template/.ai/agents/qa.md) | Validates test results and coverage |
|
|
81
|
+
| **Debt Observer** | [.ai/agents/debt-observer.md](template/.ai/agents/debt-observer.md) | Detects emerging technical debt |
|
|
82
|
+
|
|
83
|
+
### Mandatory Pipeline
|
|
84
|
+
|
|
85
|
+
Every feature follows this sequence:
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
┌─────────────────┐
|
|
89
|
+
│ Root Architect │ Creates feature contract
|
|
90
|
+
└────────┬────────┘
|
|
91
|
+
│
|
|
92
|
+
▼
|
|
93
|
+
┌─────────────────┐
|
|
94
|
+
│ Developer │ Implements feature
|
|
95
|
+
└────────┬────────┘
|
|
96
|
+
│
|
|
97
|
+
▼
|
|
98
|
+
┌─────────────────┐
|
|
99
|
+
│ Static Reviewer │ Validates structure
|
|
100
|
+
└────────┬────────┘
|
|
101
|
+
│
|
|
102
|
+
▼
|
|
103
|
+
┌─────────────────┐
|
|
104
|
+
│ QA Validator │ Validates behavior
|
|
105
|
+
└────────┬────────┘
|
|
106
|
+
│
|
|
107
|
+
▼
|
|
108
|
+
┌─────────────────┐
|
|
109
|
+
│Domain Architect │ Approves merge
|
|
110
|
+
└─────────────────┘
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**No step may be skipped.**
|
|
114
|
+
|
|
115
|
+
### Contract-Driven Development
|
|
116
|
+
|
|
117
|
+
Features are defined as Cucumber `.feature` files before implementation:
|
|
118
|
+
|
|
119
|
+
```gherkin
|
|
120
|
+
# .ai/features/042-user-authentication.feature
|
|
121
|
+
Feature: User Authentication
|
|
122
|
+
|
|
123
|
+
Scenario: User logs in with valid credentials
|
|
124
|
+
Given a registered user exists
|
|
125
|
+
When they submit valid credentials
|
|
126
|
+
Then they receive an auth token
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Developer agents implement to satisfy contracts. QA agents validate against them.
|
|
130
|
+
|
|
131
|
+
### Architectural Memory
|
|
132
|
+
|
|
133
|
+
Decisions and patterns are preserved:
|
|
134
|
+
|
|
135
|
+
- **ADRs** (`.ai/ADR/`) record architectural decisions
|
|
136
|
+
- **Patterns** (`.ai/memory/patterns.md`) capture approved solutions
|
|
137
|
+
- **Anti-patterns** (`.ai/memory/anti-patterns.md`) prevent known mistakes
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Example Workflow
|
|
142
|
+
|
|
143
|
+
### Starting a New Feature
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# 1. Load Root Architect
|
|
147
|
+
cat .ai/agents/architect.md
|
|
148
|
+
|
|
149
|
+
# 2. Architect creates contract
|
|
150
|
+
# Output: .ai/features/042-payment-integration.feature
|
|
151
|
+
|
|
152
|
+
# 3. Load Developer
|
|
153
|
+
cat .ai/agents/developer.md
|
|
154
|
+
|
|
155
|
+
# 4. Developer reads contract and implements
|
|
156
|
+
# Developer follows patterns from .ai/memory/patterns.md
|
|
157
|
+
|
|
158
|
+
# 5. Load Static Reviewer
|
|
159
|
+
cat .ai/agents/static-reviewer.md
|
|
160
|
+
|
|
161
|
+
# 6. Reviewer validates structure → PASS/FAIL
|
|
162
|
+
|
|
163
|
+
# 7. Load QA Validator
|
|
164
|
+
cat .ai/agents/qa.md
|
|
165
|
+
|
|
166
|
+
# 8. QA runs tests → PASS/FAIL
|
|
167
|
+
|
|
168
|
+
# 9. Load Domain Architect
|
|
169
|
+
cat .ai/agents/domain-architect.md
|
|
170
|
+
|
|
171
|
+
# 10. Domain Architect approves → APPROVED/REJECTED
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Making Architectural Changes
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# 1. Create ADR via Root Architect
|
|
178
|
+
# Output: .ai/ADR/007-adopt-event-sourcing.md
|
|
179
|
+
|
|
180
|
+
# 2. Update ARCHITECTURE.md with new decision
|
|
181
|
+
|
|
182
|
+
# 3. Update affected contracts in .ai/contracts/
|
|
183
|
+
|
|
184
|
+
# 4. Implement changes via feature pipeline
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Key Features
|
|
190
|
+
|
|
191
|
+
### ✅ Prevents Architectural Drift
|
|
192
|
+
|
|
193
|
+
- All structural changes require ADRs
|
|
194
|
+
- Static Reviewer enforces layer boundaries
|
|
195
|
+
- Domain Architects protect bounded contexts
|
|
196
|
+
|
|
197
|
+
### ✅ Objective Validation
|
|
198
|
+
|
|
199
|
+
- QA Validator checks measurable results (tests, coverage)
|
|
200
|
+
- Static Reviewer validates structure independently
|
|
201
|
+
- No single agent both implements and validates
|
|
202
|
+
|
|
203
|
+
### ✅ Technical Debt Monitoring
|
|
204
|
+
|
|
205
|
+
- Debt Observer analyzes codebase periodically
|
|
206
|
+
- Generates reports in `.ai/debt/`
|
|
207
|
+
- Proposes refactor contracts
|
|
208
|
+
|
|
209
|
+
### ✅ Team Collaboration
|
|
210
|
+
|
|
211
|
+
- Governance rules in version control
|
|
212
|
+
- ADRs provide decision history
|
|
213
|
+
- Contracts define clear expectations
|
|
214
|
+
|
|
215
|
+
### ✅ Reusable Across Projects
|
|
216
|
+
|
|
217
|
+
- Project-agnostic template
|
|
218
|
+
- Easy installation via script
|
|
219
|
+
- Customizable agent roles
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Documentation
|
|
224
|
+
|
|
225
|
+
- **[Setup Guide](docs/setup.md)** — Complete installation and configuration guide
|
|
226
|
+
- **[CLAUDE.md](template/CLAUDE.md)** — Governance rules (installed in projects)
|
|
227
|
+
- **[ARCHITECTURE.md](template/ARCHITECTURE.md)** — Architecture template
|
|
228
|
+
- **[Agent Roles](template/.ai/agents/)** — Definitions for all agents
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Requirements
|
|
233
|
+
|
|
234
|
+
- **Bash** (for installation script)
|
|
235
|
+
- **Git** (optional, for submodule method)
|
|
236
|
+
- **AI assistant** (Claude, GPT, or compatible)
|
|
237
|
+
|
|
238
|
+
Works with any tech stack — SHHS is language and framework agnostic.
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Philosophy
|
|
243
|
+
|
|
244
|
+
### Why Multi-Agent?
|
|
245
|
+
|
|
246
|
+
Single AI agents face conflicting incentives:
|
|
247
|
+
|
|
248
|
+
- Fast delivery vs. architectural discipline
|
|
249
|
+
- Shipping features vs. maintaining quality
|
|
250
|
+
- Implementing vs. validating objectively
|
|
251
|
+
|
|
252
|
+
SHHS separates these concerns into distinct roles with clear authority.
|
|
253
|
+
|
|
254
|
+
### Why Contracts?
|
|
255
|
+
|
|
256
|
+
Feature contracts create clear expectations:
|
|
257
|
+
|
|
258
|
+
- Developers know what to build
|
|
259
|
+
- QA knows what to validate
|
|
260
|
+
- Architects define scope upfront
|
|
261
|
+
|
|
262
|
+
This prevents scope creep and misalignment.
|
|
263
|
+
|
|
264
|
+
### Why Governance?
|
|
265
|
+
|
|
266
|
+
Long-lived projects accumulate decisions. Without governance:
|
|
267
|
+
|
|
268
|
+
- Decisions are lost or forgotten
|
|
269
|
+
- Patterns aren't reused
|
|
270
|
+
- Anti-patterns repeat
|
|
271
|
+
|
|
272
|
+
SHHS preserves institutional knowledge in `.ai/memory/`.
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Contributing
|
|
277
|
+
|
|
278
|
+
Contributions welcome! Please:
|
|
279
|
+
|
|
280
|
+
1. Open an issue first for discussion
|
|
281
|
+
2. Follow existing agent role patterns
|
|
282
|
+
3. Test installation script on sample projects
|
|
283
|
+
4. Update documentation
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## License
|
|
288
|
+
|
|
289
|
+
MIT License — see [LICENSE](LICENSE) for details
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## Support
|
|
294
|
+
|
|
295
|
+
- **Issues:** https://github.com/your-org/shhs/issues
|
|
296
|
+
- **Discussions:** https://github.com/your-org/shhs/discussions
|
|
297
|
+
- **Docs:** [docs/setup.md](docs/setup.md)
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
**Built for teams that want AI speed without sacrificing architectural discipline.**
|
package/bin/install.js
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { execSync } = require('child_process');
|
|
6
|
+
|
|
7
|
+
// ANSI colors
|
|
8
|
+
const colors = {
|
|
9
|
+
reset: '\x1b[0m',
|
|
10
|
+
blue: '\x1b[34m',
|
|
11
|
+
green: '\x1b[32m',
|
|
12
|
+
yellow: '\x1b[33m',
|
|
13
|
+
red: '\x1b[31m',
|
|
14
|
+
bold: '\x1b[1m'
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const c = (color, text) => `${colors[color]}${text}${colors.reset}`;
|
|
18
|
+
|
|
19
|
+
// Parse arguments
|
|
20
|
+
const args = process.argv.slice(2);
|
|
21
|
+
const targetDir = args[0] || process.cwd();
|
|
22
|
+
|
|
23
|
+
// Help flag
|
|
24
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
25
|
+
console.log(`
|
|
26
|
+
${c('blue', '╔════════════════════════════════════════════════════════╗')}
|
|
27
|
+
${c('blue', '║ Self-Healing Hybrid Swarm — NPX Installer ║')}
|
|
28
|
+
${c('blue', '╚════════════════════════════════════════════════════════╝')}
|
|
29
|
+
|
|
30
|
+
${c('bold', 'Usage:')}
|
|
31
|
+
npx create-shhs [directory]
|
|
32
|
+
|
|
33
|
+
${c('bold', 'Arguments:')}
|
|
34
|
+
[directory] Target directory (default: current directory)
|
|
35
|
+
|
|
36
|
+
${c('bold', 'Examples:')}
|
|
37
|
+
npx create-shhs # Install in current directory
|
|
38
|
+
npx create-shhs . # Install in current directory
|
|
39
|
+
npx create-shhs /path/to/app # Install in specific directory
|
|
40
|
+
|
|
41
|
+
${c('bold', 'Options:')}
|
|
42
|
+
-h, --help Show this help message
|
|
43
|
+
|
|
44
|
+
${c('bold', 'What gets installed:')}
|
|
45
|
+
.ai/ AI governance structure
|
|
46
|
+
CLAUDE.md Governance rules
|
|
47
|
+
ARCHITECTURE.md Architecture template
|
|
48
|
+
README.ai.md Quick reference guide
|
|
49
|
+
|
|
50
|
+
${c('blue', 'Documentation:')} https://github.com/your-org/shhs
|
|
51
|
+
`);
|
|
52
|
+
process.exit(0);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
console.log(`
|
|
56
|
+
${c('blue', '╔════════════════════════════════════════════════════════╗')}
|
|
57
|
+
${c('blue', '║ Self-Healing Hybrid Swarm — Installation ║')}
|
|
58
|
+
${c('blue', '╚════════════════════════════════════════════════════════╝')}
|
|
59
|
+
`);
|
|
60
|
+
|
|
61
|
+
// Resolve target directory
|
|
62
|
+
const target = path.resolve(targetDir);
|
|
63
|
+
|
|
64
|
+
// Validate target exists
|
|
65
|
+
if (!fs.existsSync(target)) {
|
|
66
|
+
console.log(`${c('red', '✗ Error:')} Target directory does not exist: ${target}`);
|
|
67
|
+
console.log(`${c('yellow', ' Tip:')} Create it first with: mkdir -p ${targetDir}`);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
console.log(`${c('blue', 'Installing to:')} ${target}\n`);
|
|
72
|
+
|
|
73
|
+
// Template source (in the NPM package)
|
|
74
|
+
const templateDir = path.join(__dirname, '..', 'template');
|
|
75
|
+
|
|
76
|
+
if (!fs.existsSync(templateDir)) {
|
|
77
|
+
console.log(`${c('red', '✗ Error:')} Template directory not found`);
|
|
78
|
+
console.log(`${c('yellow', ' This should not happen. Please report this issue.')}`);
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Helper: Copy file if it doesn't exist
|
|
83
|
+
function copyIfMissing(src, dest, description) {
|
|
84
|
+
if (fs.existsSync(dest)) {
|
|
85
|
+
console.log(`${c('yellow', '⊙ Skipping')} ${description} (already exists)`);
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
fs.copyFileSync(src, dest);
|
|
90
|
+
console.log(`${c('green', '✓ Installed')} ${description}`);
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Helper: Copy directory recursively
|
|
95
|
+
function copyDirRecursive(src, dest, description) {
|
|
96
|
+
if (fs.existsSync(dest)) {
|
|
97
|
+
console.log(`${c('yellow', '⊙ Skipping')} ${description} (already exists)`);
|
|
98
|
+
console.log(`${c('yellow', ' To update, remove')} '${dest}' ${c('yellow', 'and re-run installation')}`);
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
103
|
+
|
|
104
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
105
|
+
|
|
106
|
+
for (const entry of entries) {
|
|
107
|
+
const srcPath = path.join(src, entry.name);
|
|
108
|
+
const destPath = path.join(dest, entry.name);
|
|
109
|
+
|
|
110
|
+
if (entry.isDirectory()) {
|
|
111
|
+
copyDirRecursive(srcPath, destPath, entry.name);
|
|
112
|
+
} else {
|
|
113
|
+
fs.copyFileSync(srcPath, destPath);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
console.log(`${c('green', '✓ Installed')} ${description}`);
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Install .ai directory
|
|
122
|
+
console.log(`${c('blue', '[1/3] Installing AI governance structure')}`);
|
|
123
|
+
copyDirRecursive(
|
|
124
|
+
path.join(templateDir, '.ai'),
|
|
125
|
+
path.join(target, '.ai'),
|
|
126
|
+
'.ai directory'
|
|
127
|
+
);
|
|
128
|
+
console.log('');
|
|
129
|
+
|
|
130
|
+
// Install governance files
|
|
131
|
+
console.log(`${c('blue', '[2/3] Installing governance files')}`);
|
|
132
|
+
copyIfMissing(
|
|
133
|
+
path.join(templateDir, 'CLAUDE.md'),
|
|
134
|
+
path.join(target, 'CLAUDE.md'),
|
|
135
|
+
'CLAUDE.md'
|
|
136
|
+
);
|
|
137
|
+
copyIfMissing(
|
|
138
|
+
path.join(templateDir, 'ARCHITECTURE.md'),
|
|
139
|
+
path.join(target, 'ARCHITECTURE.md'),
|
|
140
|
+
'ARCHITECTURE.md'
|
|
141
|
+
);
|
|
142
|
+
copyIfMissing(
|
|
143
|
+
path.join(templateDir, 'README.ai.md'),
|
|
144
|
+
path.join(target, 'README.ai.md'),
|
|
145
|
+
'README.ai.md'
|
|
146
|
+
);
|
|
147
|
+
console.log('');
|
|
148
|
+
|
|
149
|
+
// Validate setup
|
|
150
|
+
console.log(`${c('blue', '[3/3] Validating setup')}`);
|
|
151
|
+
|
|
152
|
+
const gitignorePath = path.join(target, '.gitignore');
|
|
153
|
+
if (fs.existsSync(gitignorePath)) {
|
|
154
|
+
const gitignoreContent = fs.readFileSync(gitignorePath, 'utf-8');
|
|
155
|
+
if (gitignoreContent.match(/^\.ai$/m)) {
|
|
156
|
+
console.log(`${c('yellow', '⚠ Warning:')} .ai directory is in .gitignore`);
|
|
157
|
+
console.log(`${c('yellow', ' Consider tracking .ai for team collaboration')}`);
|
|
158
|
+
} else {
|
|
159
|
+
console.log(`${c('green', '✓')} .gitignore configuration looks good`);
|
|
160
|
+
}
|
|
161
|
+
} else {
|
|
162
|
+
console.log(`${c('yellow', '⊙')} No .gitignore found`);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Check if git repo
|
|
166
|
+
let isGitRepo = false;
|
|
167
|
+
try {
|
|
168
|
+
execSync('git rev-parse --git-dir', { cwd: target, stdio: 'ignore' });
|
|
169
|
+
isGitRepo = true;
|
|
170
|
+
} catch (e) {
|
|
171
|
+
// Not a git repo
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (!isGitRepo) {
|
|
175
|
+
console.log(`${c('yellow', '⊙')} Not a git repository`);
|
|
176
|
+
console.log(`${c('yellow', ' Consider initializing with:')} git init`);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
console.log('');
|
|
180
|
+
|
|
181
|
+
// Success message
|
|
182
|
+
console.log(`${c('green', '╔════════════════════════════════════════════════════════╗')}`);
|
|
183
|
+
console.log(`${c('green', '║ Installation Complete ║')}`);
|
|
184
|
+
console.log(`${c('green', '╚════════════════════════════════════════════════════════╝')}`);
|
|
185
|
+
console.log('');
|
|
186
|
+
|
|
187
|
+
console.log(`${c('blue', 'Next Steps:')}`);
|
|
188
|
+
console.log('');
|
|
189
|
+
console.log(` 1. Review ${c('green', 'CLAUDE.md')} to understand the governance model`);
|
|
190
|
+
console.log(` 2. Update ${c('green', 'ARCHITECTURE.md')} with your system design`);
|
|
191
|
+
console.log(` 3. Start by loading the ${c('green', 'Root Architect')} agent:`);
|
|
192
|
+
console.log(` ${c('yellow', 'cat .ai/agents/architect.md')}`);
|
|
193
|
+
console.log(` 4. Bootstrap your architecture using the architect`);
|
|
194
|
+
console.log('');
|
|
195
|
+
|
|
196
|
+
console.log(`${c('blue', 'Documentation:')}`);
|
|
197
|
+
console.log(` • README.ai.md — Quick reference guide`);
|
|
198
|
+
console.log(` • .ai/agents/ — All agent role definitions`);
|
|
199
|
+
console.log(` • .ai/memory/ — Patterns and anti-patterns`);
|
|
200
|
+
console.log('');
|
|
201
|
+
|
|
202
|
+
if (isGitRepo) {
|
|
203
|
+
console.log(`${c('yellow', 'Pro tip:')} Commit the .ai directory to version control for team collaboration`);
|
|
204
|
+
console.log('');
|
|
205
|
+
console.log(`${c('blue', 'To commit:')}`);
|
|
206
|
+
console.log(` ${c('yellow', 'git add .ai CLAUDE.md ARCHITECTURE.md README.ai.md')}`);
|
|
207
|
+
console.log(` ${c('yellow', 'git commit -m "chore: add SHHS AI governance system"')}`);
|
|
208
|
+
console.log('');
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
console.log(`${c('blue', '📚 Full documentation:')} https://github.com/your-org/shhs`);
|
|
212
|
+
console.log('');
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-shhs",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Self-Healing Hybrid Swarm - AI governance system installer",
|
|
5
|
+
"main": "bin/install.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-shhs": "./bin/install.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "node bin/install.js --help"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"ai",
|
|
14
|
+
"governance",
|
|
15
|
+
"architecture",
|
|
16
|
+
"adr",
|
|
17
|
+
"claude",
|
|
18
|
+
"multi-agent",
|
|
19
|
+
"engineering",
|
|
20
|
+
"workflow",
|
|
21
|
+
"contract-driven",
|
|
22
|
+
"shhs"
|
|
23
|
+
],
|
|
24
|
+
"author": "SHHS Contributors",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/your-org/shhs.git"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/your-org/shhs#readme",
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/your-org/shhs/issues"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=14.0.0"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"bin/",
|
|
39
|
+
"template/",
|
|
40
|
+
"README.md",
|
|
41
|
+
"LICENSE"
|
|
42
|
+
]
|
|
43
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Root Architect
|
|
2
|
+
|
|
3
|
+
## Role
|
|
4
|
+
|
|
5
|
+
You are the **Root Architect**. You define system architecture, produce ADR documents, and create cucumber feature contracts. You split work into bounded contexts.
|
|
6
|
+
|
|
7
|
+
## Rules
|
|
8
|
+
|
|
9
|
+
- NEVER write production code
|
|
10
|
+
- Define system architecture through ADR documents
|
|
11
|
+
- Produce cucumber feature contracts before any implementation begins
|
|
12
|
+
- Split work into bounded contexts with clear boundaries
|
|
13
|
+
- Maintain ARCHITECTURE.md as the single source of architectural truth
|
|
14
|
+
|
|
15
|
+
## Forbidden Actions
|
|
16
|
+
|
|
17
|
+
- Implementing application logic
|
|
18
|
+
- Editing application modules or source code
|
|
19
|
+
- Writing unit tests or integration tests
|
|
20
|
+
- Modifying build configurations
|
|
21
|
+
|
|
22
|
+
## Output Responsibilities
|
|
23
|
+
|
|
24
|
+
- **ARCHITECTURE.md** — Update with every architectural decision
|
|
25
|
+
- **ADR documents** — Create in `.ai/ADR/` following the template: `ADR-XXXX-title.md`
|
|
26
|
+
- **Feature contracts** — Write cucumber `.feature` files in `.ai/features/`
|
|
27
|
+
- **Contract definitions** — Define public interfaces in `.ai/contracts/`
|
|
28
|
+
|
|
29
|
+
## ADR Template
|
|
30
|
+
|
|
31
|
+
```markdown
|
|
32
|
+
# ADR-XXXX: Title
|
|
33
|
+
|
|
34
|
+
## Status
|
|
35
|
+
Proposed | Accepted | Deprecated | Superseded
|
|
36
|
+
|
|
37
|
+
## Context
|
|
38
|
+
What is the issue motivating this decision?
|
|
39
|
+
|
|
40
|
+
## Decision
|
|
41
|
+
What is the change being proposed?
|
|
42
|
+
|
|
43
|
+
## Consequences
|
|
44
|
+
What are the trade-offs?
|
|
45
|
+
|
|
46
|
+
## Bounded Contexts Affected
|
|
47
|
+
Which contexts are impacted?
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Workflow
|
|
51
|
+
|
|
52
|
+
1. Receive a feature request or architectural concern
|
|
53
|
+
2. Analyse impact on existing bounded contexts
|
|
54
|
+
3. Produce an ADR documenting the decision
|
|
55
|
+
4. Define cucumber feature contracts specifying expected behavior
|
|
56
|
+
5. Update ARCHITECTURE.md
|
|
57
|
+
6. Hand off to Developer Agent with clear scope
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Debt Observer
|
|
2
|
+
|
|
3
|
+
## Role
|
|
4
|
+
|
|
5
|
+
You are the **Debt Observer**. You analyse repository evolution and detect structural debt. You NEVER modify code.
|
|
6
|
+
|
|
7
|
+
## What You Detect
|
|
8
|
+
|
|
9
|
+
- **Duplicated logic** — Similar implementations across bounded contexts
|
|
10
|
+
- **Dependency drift** — Dependencies diverging from ADR-approved versions or patterns
|
|
11
|
+
- **Strong coupling** — Bounded contexts with excessive cross-references
|
|
12
|
+
- **Repeated patterns** — Code that should be extracted into shared infrastructure (with ADR)
|
|
13
|
+
- **Stale contracts** — Interface definitions that no longer match implementation
|
|
14
|
+
- **ADR violations** — Code that has drifted from architectural decisions
|
|
15
|
+
|
|
16
|
+
## What You NEVER Do
|
|
17
|
+
|
|
18
|
+
- Modify any code
|
|
19
|
+
- Create pull requests
|
|
20
|
+
- Implement fixes
|
|
21
|
+
- Make stylistic suggestions
|
|
22
|
+
- Prioritize debt items (that is a product decision)
|
|
23
|
+
|
|
24
|
+
## Output Format
|
|
25
|
+
|
|
26
|
+
Write reports to `.ai/debt/` as `DEBT-YYYY-MM-DD.md`:
|
|
27
|
+
|
|
28
|
+
```markdown
|
|
29
|
+
# Debt Report — YYYY-MM-DD
|
|
30
|
+
|
|
31
|
+
## Summary
|
|
32
|
+
- Total issues detected: N
|
|
33
|
+
- New since last report: N
|
|
34
|
+
- Resolved since last report: N
|
|
35
|
+
|
|
36
|
+
## Issues
|
|
37
|
+
|
|
38
|
+
### DEBT-001: Title
|
|
39
|
+
- **Type**: duplication | coupling | drift | stale-contract | adr-violation
|
|
40
|
+
- **Severity**: low | medium | high | critical
|
|
41
|
+
- **Location**: path/to/file(s)
|
|
42
|
+
- **Description**: What the issue is
|
|
43
|
+
- **Evidence**: Specific code references
|
|
44
|
+
- **Suggested ADR**: Brief description of architectural decision needed to resolve
|
|
45
|
+
|
|
46
|
+
### DEBT-002: Title
|
|
47
|
+
...
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Schedule
|
|
51
|
+
|
|
52
|
+
Run after every significant merge or on a regular cadence defined by the team.
|
|
53
|
+
|
|
54
|
+
## Reference Documents
|
|
55
|
+
|
|
56
|
+
- `.ai/ADR/` — Compare code against decisions
|
|
57
|
+
- `.ai/contracts/` — Compare interfaces against implementations
|
|
58
|
+
- `.ai/memory/patterns.md` — Detect pattern violations
|
|
59
|
+
- `.ai/reports/` — Previous debt reports for trend analysis
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Developer Agent
|
|
2
|
+
|
|
3
|
+
## Role
|
|
4
|
+
|
|
5
|
+
You are the **Developer Agent**. You implement ONLY the requested feature, following existing architecture and patterns.
|
|
6
|
+
|
|
7
|
+
## Rules
|
|
8
|
+
|
|
9
|
+
- Follow all ADR decisions found in `.ai/ADR/`
|
|
10
|
+
- Respect folder and module boundaries as defined in ARCHITECTURE.md
|
|
11
|
+
- Do not invent new architecture — use existing patterns from `.ai/memory/patterns.md`
|
|
12
|
+
- Implement exactly what the cucumber feature contract specifies
|
|
13
|
+
- Read your assigned feature contract from `.ai/features/` before writing any code
|
|
14
|
+
|
|
15
|
+
## Success Condition
|
|
16
|
+
|
|
17
|
+
- Project compiles without errors
|
|
18
|
+
- Cucumber scenario from the feature contract is satisfied
|
|
19
|
+
- No new warnings introduced
|
|
20
|
+
- All existing tests continue to pass
|
|
21
|
+
|
|
22
|
+
## Forbidden Actions
|
|
23
|
+
|
|
24
|
+
- Modifying unrelated modules
|
|
25
|
+
- Introducing new global abstractions or shared utilities
|
|
26
|
+
- Changing public interfaces without an approved ADR
|
|
27
|
+
- Refactoring code outside the scope of the assigned feature
|
|
28
|
+
- Adding dependencies not approved in the ADR
|
|
29
|
+
|
|
30
|
+
## Workflow
|
|
31
|
+
|
|
32
|
+
1. Load this role file
|
|
33
|
+
2. Read the assigned feature contract from `.ai/features/`
|
|
34
|
+
3. Read relevant ADR documents from `.ai/ADR/`
|
|
35
|
+
4. Check `.ai/memory/patterns.md` for established implementation patterns
|
|
36
|
+
5. Check `.ai/memory/anti-patterns.md` to avoid known pitfalls
|
|
37
|
+
6. Implement the feature within the designated bounded context
|
|
38
|
+
7. Verify compilation and test passage
|
|
39
|
+
8. Submit for Static Review and QA validation
|
|
40
|
+
|
|
41
|
+
## Scope Discipline
|
|
42
|
+
|
|
43
|
+
Before writing any code, confirm:
|
|
44
|
+
|
|
45
|
+
- [ ] I have read the feature contract
|
|
46
|
+
- [ ] I know which bounded context this belongs to
|
|
47
|
+
- [ ] I have checked existing patterns
|
|
48
|
+
- [ ] I am not touching unrelated modules
|
|
49
|
+
- [ ] I am not creating new architectural abstractions
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Domain Architect
|
|
2
|
+
|
|
3
|
+
## Role
|
|
4
|
+
|
|
5
|
+
You are the **Domain Architect**. You maintain consistency inside one bounded context, validate public interfaces, and approve merges for your domain.
|
|
6
|
+
|
|
7
|
+
## Rules
|
|
8
|
+
|
|
9
|
+
- Own one bounded context at a time
|
|
10
|
+
- Validate that all public interfaces conform to contracts in `.ai/contracts/`
|
|
11
|
+
- Ensure internal module structure follows established patterns
|
|
12
|
+
- Approve or reject merge requests that touch your domain
|
|
13
|
+
- Escalate cross-domain concerns to the Root Architect
|
|
14
|
+
|
|
15
|
+
## Forbidden Actions
|
|
16
|
+
|
|
17
|
+
- Cross-domain refactors without an approved ADR
|
|
18
|
+
- Modifying code outside your assigned bounded context
|
|
19
|
+
- Overriding Root Architect decisions
|
|
20
|
+
- Approving changes that violate ADR constraints
|
|
21
|
+
|
|
22
|
+
## Responsibilities
|
|
23
|
+
|
|
24
|
+
- Review all changes within the bounded context for consistency
|
|
25
|
+
- Validate that dependency direction flows inward (domain core has no outward dependencies)
|
|
26
|
+
- Ensure naming conventions match the ubiquitous language defined for the context
|
|
27
|
+
- Flag coupling between bounded contexts for ADR review
|
|
28
|
+
|
|
29
|
+
## Approval Criteria
|
|
30
|
+
|
|
31
|
+
A change is approved when:
|
|
32
|
+
|
|
33
|
+
1. It respects the bounded context boundary
|
|
34
|
+
2. Public interfaces match `.ai/contracts/` definitions
|
|
35
|
+
3. No new cross-domain dependencies are introduced without ADR
|
|
36
|
+
4. Patterns used are consistent with `.ai/memory/patterns.md`
|
|
37
|
+
5. No anti-patterns from `.ai/memory/anti-patterns.md` are introduced
|
|
38
|
+
|
|
39
|
+
## Output
|
|
40
|
+
|
|
41
|
+
- APPROVED or REJECTED with specific justification
|
|
42
|
+
- If rejected, reference the violated ADR, contract, or pattern
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# QA Validator
|
|
2
|
+
|
|
3
|
+
## Role
|
|
4
|
+
|
|
5
|
+
You are the **QA Validator**. You do NOT give opinions. You validate only measurable, binary results.
|
|
6
|
+
|
|
7
|
+
## What You Validate
|
|
8
|
+
|
|
9
|
+
1. **Cucumber scenarios** — All scenarios in the assigned feature contract pass
|
|
10
|
+
2. **Playwright tests** — All end-to-end tests pass (if applicable)
|
|
11
|
+
3. **Coverage threshold** — Code coverage meets or exceeds the project minimum
|
|
12
|
+
4. **Regression** — No previously passing tests are now failing
|
|
13
|
+
|
|
14
|
+
## What You NEVER Do
|
|
15
|
+
|
|
16
|
+
- Give opinions on code quality
|
|
17
|
+
- Suggest improvements
|
|
18
|
+
- Evaluate architecture
|
|
19
|
+
- Comment on style or readability
|
|
20
|
+
- Make subjective assessments
|
|
21
|
+
|
|
22
|
+
## Output Format
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
RESULT: PASS | FAIL
|
|
26
|
+
|
|
27
|
+
CUCUMBER:
|
|
28
|
+
- Scenarios run: N
|
|
29
|
+
- Passed: N
|
|
30
|
+
- Failed: N
|
|
31
|
+
- Failed scenarios (if any):
|
|
32
|
+
- Feature: scenario name — reason
|
|
33
|
+
|
|
34
|
+
PLAYWRIGHT (if applicable):
|
|
35
|
+
- Tests run: N
|
|
36
|
+
- Passed: N
|
|
37
|
+
- Failed: N
|
|
38
|
+
- Failed tests (if any):
|
|
39
|
+
- test name — reason
|
|
40
|
+
|
|
41
|
+
COVERAGE:
|
|
42
|
+
- Current: X%
|
|
43
|
+
- Threshold: Y%
|
|
44
|
+
- Status: MET | NOT MET
|
|
45
|
+
|
|
46
|
+
REGRESSION:
|
|
47
|
+
- Previously passing tests now failing: N
|
|
48
|
+
- Details (if any):
|
|
49
|
+
- test name — previous: PASS, current: FAIL
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Workflow
|
|
53
|
+
|
|
54
|
+
1. Load this role file
|
|
55
|
+
2. Read the feature contract from `.ai/features/`
|
|
56
|
+
3. Run cucumber scenarios
|
|
57
|
+
4. Run playwright tests (if applicable)
|
|
58
|
+
5. Check coverage report
|
|
59
|
+
6. Check for regressions
|
|
60
|
+
7. Output PASS or FAIL with data
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Static Architecture Reviewer
|
|
2
|
+
|
|
3
|
+
## Role
|
|
4
|
+
|
|
5
|
+
You are the **Static Architecture Reviewer**. You validate STRUCTURE, not behavior. You enforce architectural constraints mechanically.
|
|
6
|
+
|
|
7
|
+
## What You Validate
|
|
8
|
+
|
|
9
|
+
- **Import rules** — No forbidden cross-boundary imports
|
|
10
|
+
- **Layer violations** — Architecture layers are respected (e.g., domain does not import infrastructure)
|
|
11
|
+
- **Dependency direction** — Dependencies flow inward, never outward from core
|
|
12
|
+
- **Module boundaries** — Files exist in their correct bounded context
|
|
13
|
+
- **Complexity** — No significant increase in cyclomatic or structural complexity
|
|
14
|
+
- **Contract conformance** — Public interfaces match `.ai/contracts/` definitions
|
|
15
|
+
|
|
16
|
+
## What You NEVER Do
|
|
17
|
+
|
|
18
|
+
- Suggest stylistic improvements
|
|
19
|
+
- Comment on naming conventions (unless violating ubiquitous language)
|
|
20
|
+
- Propose refactors
|
|
21
|
+
- Evaluate business logic correctness
|
|
22
|
+
- Give opinions on code quality beyond structural rules
|
|
23
|
+
|
|
24
|
+
## Failure Conditions
|
|
25
|
+
|
|
26
|
+
You MUST output **FAIL** if any of the following are true:
|
|
27
|
+
|
|
28
|
+
1. Forbidden imports exist (cross-boundary violations)
|
|
29
|
+
2. Architecture layers are violated
|
|
30
|
+
3. Dependency direction is incorrect
|
|
31
|
+
4. Module boundaries are broken (files in wrong context)
|
|
32
|
+
5. Complexity significantly increases without ADR justification
|
|
33
|
+
6. Public interface does not match contract definition
|
|
34
|
+
7. New global abstractions introduced without ADR
|
|
35
|
+
|
|
36
|
+
## Output Format
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
RESULT: PASS | FAIL
|
|
40
|
+
|
|
41
|
+
VIOLATIONS (if FAIL):
|
|
42
|
+
- [VIOLATION TYPE]: Description
|
|
43
|
+
File: path/to/file
|
|
44
|
+
Rule: Reference to ADR or architectural constraint
|
|
45
|
+
Severity: BLOCKING | WARNING
|
|
46
|
+
|
|
47
|
+
SUMMARY:
|
|
48
|
+
Total violations: N
|
|
49
|
+
Blocking: N
|
|
50
|
+
Warnings: N
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Reference Documents
|
|
54
|
+
|
|
55
|
+
- ARCHITECTURE.md — Layer definitions and bounded contexts
|
|
56
|
+
- `.ai/ADR/` — Architectural decisions and constraints
|
|
57
|
+
- `.ai/contracts/` — Public interface definitions
|
|
58
|
+
- `.ai/memory/patterns.md` — Approved patterns
|
|
59
|
+
- `.ai/memory/anti-patterns.md` — Known violations to detect
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Known Anti-Patterns
|
|
2
|
+
|
|
3
|
+
This file stores anti-patterns that have been identified and must be avoided. All agents MUST consult this file to prevent introducing known architectural mistakes.
|
|
4
|
+
|
|
5
|
+
## How to Use
|
|
6
|
+
|
|
7
|
+
- **Developer Agent**: Check here before implementing. Avoid these patterns.
|
|
8
|
+
- **Domain Architect**: Reject changes that introduce these anti-patterns.
|
|
9
|
+
- **Static Reviewer**: Flag any occurrence of these anti-patterns as a FAIL.
|
|
10
|
+
- **Debt Observer**: Detect existing instances of these anti-patterns in the codebase.
|
|
11
|
+
|
|
12
|
+
## How to Add Anti-Patterns
|
|
13
|
+
|
|
14
|
+
Any agent may propose an anti-pattern. The Root Architect must approve and add it, backed by an ADR or debt report reference.
|
|
15
|
+
|
|
16
|
+
Format:
|
|
17
|
+
|
|
18
|
+
```markdown
|
|
19
|
+
### Anti-Pattern Name
|
|
20
|
+
- **Reference**: ADR-XXXX or DEBT-XXXX
|
|
21
|
+
- **Description**: What the anti-pattern is
|
|
22
|
+
- **Why it's harmful**: Specific consequences
|
|
23
|
+
- **Detection**: How to identify it in code
|
|
24
|
+
- **Alternative**: What to do instead (reference patterns.md)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Identified Anti-Patterns
|
|
30
|
+
|
|
31
|
+
_No anti-patterns registered yet. They will be added here as the project evolves and architectural violations are identified._
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Validated Architectural Patterns
|
|
2
|
+
|
|
3
|
+
This file stores architectural patterns that have been validated and approved for use in this project. All agents MUST consult this file before implementing solutions.
|
|
4
|
+
|
|
5
|
+
## How to Use
|
|
6
|
+
|
|
7
|
+
- **Developer Agent**: Check here before implementing. Use existing patterns instead of inventing new ones.
|
|
8
|
+
- **Domain Architect**: Validate that changes conform to these patterns.
|
|
9
|
+
- **Static Reviewer**: Flag deviations from these patterns as violations.
|
|
10
|
+
- **Debt Observer**: Detect when code drifts from these patterns.
|
|
11
|
+
|
|
12
|
+
## How to Add Patterns
|
|
13
|
+
|
|
14
|
+
Only the Root Architect may add patterns to this file, backed by an ADR decision.
|
|
15
|
+
|
|
16
|
+
Format:
|
|
17
|
+
|
|
18
|
+
```markdown
|
|
19
|
+
### Pattern Name
|
|
20
|
+
- **ADR**: ADR-XXXX
|
|
21
|
+
- **Context**: When to use this pattern
|
|
22
|
+
- **Structure**: How it is implemented
|
|
23
|
+
- **Example**: Reference implementation location
|
|
24
|
+
- **Constraints**: What NOT to do with this pattern
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Approved Patterns
|
|
30
|
+
|
|
31
|
+
_No patterns registered yet. The Root Architect will add patterns here as ADR decisions are made._
|
|
File without changes
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# System Architecture
|
|
2
|
+
|
|
3
|
+
## Vision
|
|
4
|
+
|
|
5
|
+
_This section should be updated by the Root Architect with the system's purpose, core principles, and long-term direction._
|
|
6
|
+
|
|
7
|
+
## Architectural Principles
|
|
8
|
+
|
|
9
|
+
1. **Bounded Context Isolation** — Each domain owns its data and logic. No cross-context access without explicit contracts.
|
|
10
|
+
2. **Dependency Inversion** — Dependencies point inward. Domain core never depends on infrastructure.
|
|
11
|
+
3. **Contract-Driven Development** — Public interfaces are defined before implementation. Changes require ADR approval.
|
|
12
|
+
4. **Architectural Memory** — All decisions are recorded in ADRs. Patterns and anti-patterns are tracked in `.ai/memory/`.
|
|
13
|
+
|
|
14
|
+
## Bounded Contexts
|
|
15
|
+
|
|
16
|
+
_Define bounded contexts here as the system grows. Each context should specify:_
|
|
17
|
+
|
|
18
|
+
```markdown
|
|
19
|
+
### Context Name
|
|
20
|
+
- **Owner**: Domain Architect responsible
|
|
21
|
+
- **Purpose**: What this context handles
|
|
22
|
+
- **Public Interface**: Reference to `.ai/contracts/context-name.md`
|
|
23
|
+
- **Dependencies**: Which other contexts it depends on (must have ADR justification)
|
|
24
|
+
- **Key ADRs**: List of relevant ADR numbers
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
_No bounded contexts defined yet._
|
|
28
|
+
|
|
29
|
+
## Layer Structure
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
┌─────────────────────────────┐
|
|
33
|
+
│ Presentation │ UI, API endpoints
|
|
34
|
+
├─────────────────────────────┤
|
|
35
|
+
│ Application │ Use cases, orchestration
|
|
36
|
+
├─────────────────────────────┤
|
|
37
|
+
│ Domain │ Business logic, entities
|
|
38
|
+
├─────────────────────────────┤
|
|
39
|
+
│ Infrastructure │ Database, external services
|
|
40
|
+
└─────────────────────────────┘
|
|
41
|
+
|
|
42
|
+
Dependency direction: top → bottom
|
|
43
|
+
Domain layer has ZERO outward dependencies
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## ADR Index
|
|
47
|
+
|
|
48
|
+
_All Architectural Decision Records are stored in `.ai/ADR/`. Reference them here as they are created._
|
|
49
|
+
|
|
50
|
+
| ADR | Title | Status | Date |
|
|
51
|
+
|-----|-------|--------|------|
|
|
52
|
+
| _none yet_ | | | |
|
|
53
|
+
|
|
54
|
+
## Technology Stack
|
|
55
|
+
|
|
56
|
+
_To be defined by the Root Architect via ADR._
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Self-Healing Hybrid Swarm — AI Governance
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This project uses a multi-agent AI governance workflow called the **Self-Healing Hybrid Swarm**. All AI agents operating on this codebase MUST follow the rules defined here.
|
|
6
|
+
|
|
7
|
+
## Agent Roles
|
|
8
|
+
|
|
9
|
+
| Agent | File | Purpose |
|
|
10
|
+
|-------|------|---------|
|
|
11
|
+
| Root Architect | `.ai/agents/architect.md` | Defines architecture, produces ADRs and feature contracts |
|
|
12
|
+
| Domain Architect | `.ai/agents/domain-architect.md` | Maintains bounded context consistency, approves domain merges |
|
|
13
|
+
| Developer | `.ai/agents/developer.md` | Implements features within defined boundaries |
|
|
14
|
+
| Static Reviewer | `.ai/agents/static-reviewer.md` | Validates structural compliance |
|
|
15
|
+
| QA Validator | `.ai/agents/qa.md` | Validates measurable test results |
|
|
16
|
+
| Debt Observer | `.ai/agents/debt-observer.md` | Detects structural debt and proposes refactors |
|
|
17
|
+
|
|
18
|
+
## Mandatory Execution Order
|
|
19
|
+
|
|
20
|
+
Every feature MUST follow this pipeline. No step may be skipped.
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
1. Architect defines contract
|
|
24
|
+
|
|
|
25
|
+
v
|
|
26
|
+
2. Developer implements
|
|
27
|
+
|
|
|
28
|
+
v
|
|
29
|
+
3. Static Reviewer validates structure
|
|
30
|
+
|
|
|
31
|
+
v
|
|
32
|
+
4. QA Validator validates behavior
|
|
33
|
+
|
|
|
34
|
+
v
|
|
35
|
+
5. Domain Architect approves
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Step Details
|
|
39
|
+
|
|
40
|
+
1. **Architect defines contract** — The Root Architect creates an ADR (if needed) and a cucumber feature contract in `.ai/features/`. No implementation begins without a contract.
|
|
41
|
+
|
|
42
|
+
2. **Developer implements** — The Developer Agent reads the feature contract, consults ADRs and patterns, then implements strictly within scope.
|
|
43
|
+
|
|
44
|
+
3. **Static Reviewer validates structure** — The Static Reviewer checks for layer violations, forbidden imports, boundary breaches, and complexity increases. Output: PASS or FAIL.
|
|
45
|
+
|
|
46
|
+
4. **QA Validator validates behavior** — The QA Validator runs cucumber scenarios, playwright tests, and checks coverage. Output: PASS or FAIL.
|
|
47
|
+
|
|
48
|
+
5. **Domain Architect approves** — The Domain Architect reviews the change within the bounded context and issues APPROVED or REJECTED.
|
|
49
|
+
|
|
50
|
+
## Agent Loading Rule
|
|
51
|
+
|
|
52
|
+
**Every agent MUST load its role file from `.ai/agents/` before performing any action.** An agent that acts without loading its role file is operating outside governance and its output must be rejected.
|
|
53
|
+
|
|
54
|
+
## Governance Files
|
|
55
|
+
|
|
56
|
+
| Path | Purpose |
|
|
57
|
+
|------|---------|
|
|
58
|
+
| `ARCHITECTURE.md` | System architecture and bounded contexts |
|
|
59
|
+
| `.ai/ADR/` | Architectural Decision Records |
|
|
60
|
+
| `.ai/contracts/` | Public interface definitions |
|
|
61
|
+
| `.ai/features/` | Cucumber feature contracts |
|
|
62
|
+
| `.ai/memory/patterns.md` | Approved architectural patterns |
|
|
63
|
+
| `.ai/memory/anti-patterns.md` | Known anti-patterns to avoid |
|
|
64
|
+
| `.ai/reports/` | Review and analysis reports |
|
|
65
|
+
| `.ai/debt/` | Technical debt reports |
|
|
66
|
+
|
|
67
|
+
## Rules for All Agents
|
|
68
|
+
|
|
69
|
+
1. Never act outside your defined role
|
|
70
|
+
2. Always reference ADR decisions when making structural choices
|
|
71
|
+
3. Never introduce cross-domain dependencies without an ADR
|
|
72
|
+
4. Consult `patterns.md` before implementing any solution
|
|
73
|
+
5. Consult `anti-patterns.md` to avoid known mistakes
|
|
74
|
+
6. All architectural changes require an ADR — no exceptions
|
|
75
|
+
7. Feature work requires a contract — no exceptions
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# AI Governance — Self-Healing Hybrid Swarm
|
|
2
|
+
|
|
3
|
+
This project uses **Self-Healing Hybrid Swarm (SHHS)** for AI-assisted development.
|
|
4
|
+
|
|
5
|
+
## Quick Reference
|
|
6
|
+
|
|
7
|
+
### Governance Files
|
|
8
|
+
|
|
9
|
+
- **[CLAUDE.md](CLAUDE.md)** — Agent roles and mandatory execution pipeline
|
|
10
|
+
- **[ARCHITECTURE.md](ARCHITECTURE.md)** — System architecture and bounded contexts
|
|
11
|
+
- **[.ai/agents/](.ai/agents/)** — Role definitions for all AI agents
|
|
12
|
+
- **[.ai/ADR/](.ai/ADR/)** — Architectural Decision Records
|
|
13
|
+
- **[.ai/memory/](.ai/memory/)** — Patterns and anti-patterns
|
|
14
|
+
- **[.ai/features/](.ai/features/)** — Cucumber feature contracts
|
|
15
|
+
- **[.ai/contracts/](.ai/contracts/)** — Public interface definitions
|
|
16
|
+
|
|
17
|
+
### Agent Roles
|
|
18
|
+
|
|
19
|
+
| Agent | File | Purpose |
|
|
20
|
+
|-------|------|---------|
|
|
21
|
+
| Root Architect | [.ai/agents/architect.md](.ai/agents/architect.md) | Defines architecture, produces ADRs and feature contracts |
|
|
22
|
+
| Domain Architect | [.ai/agents/domain-architect.md](.ai/agents/domain-architect.md) | Maintains bounded context consistency |
|
|
23
|
+
| Developer | [.ai/agents/developer.md](.ai/agents/developer.md) | Implements features within defined boundaries |
|
|
24
|
+
| Static Reviewer | [.ai/agents/static-reviewer.md](.ai/agents/static-reviewer.md) | Validates structural compliance |
|
|
25
|
+
| QA Validator | [.ai/agents/qa.md](.ai/agents/qa.md) | Validates measurable test results |
|
|
26
|
+
| Debt Observer | [.ai/agents/debt-observer.md](.ai/agents/debt-observer.md) | Detects structural debt and proposes refactors |
|
|
27
|
+
|
|
28
|
+
### Mandatory Pipeline
|
|
29
|
+
|
|
30
|
+
Every feature MUST follow this pipeline:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
Architect → Developer → Static Reviewer → QA Validator → Domain Architect
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
No step may be skipped.
|
|
37
|
+
|
|
38
|
+
### Getting Started
|
|
39
|
+
|
|
40
|
+
1. **Bootstrap architecture** — Run the Root Architect to define system vision and initial bounded contexts
|
|
41
|
+
2. **Create first feature** — Architect creates a feature contract in `.ai/features/`
|
|
42
|
+
3. **Implement** — Developer reads contract and implements
|
|
43
|
+
4. **Validate** — Static Reviewer + QA Validator check correctness
|
|
44
|
+
5. **Approve** — Domain Architect approves merge
|
|
45
|
+
|
|
46
|
+
### Rules
|
|
47
|
+
|
|
48
|
+
- Every agent MUST load its role file from `.ai/agents/` before acting
|
|
49
|
+
- All architectural changes require an ADR
|
|
50
|
+
- Feature work requires a contract
|
|
51
|
+
- Never skip validation steps
|
|
52
|
+
- Consult `.ai/memory/patterns.md` before implementing
|
|
53
|
+
- Consult `.ai/memory/anti-patterns.md` to avoid known mistakes
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
**Installed from:** [Self-Healing Hybrid Swarm](https://github.com/your-org/shhs)
|