ruvnet-kb-first 5.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 +674 -0
- package/SKILL.md +740 -0
- package/bin/kb-first.js +123 -0
- package/install/init-project.sh +435 -0
- package/install/install-global.sh +257 -0
- package/install/kb-first-autodetect.sh +108 -0
- package/install/kb-first-command.md +80 -0
- package/install/kb-first-skill.md +262 -0
- package/package.json +87 -0
- package/phases/00-assessment.md +529 -0
- package/phases/01-storage.md +194 -0
- package/phases/01.5-hooks-setup.md +521 -0
- package/phases/02-kb-creation.md +413 -0
- package/phases/03-persistence.md +125 -0
- package/phases/04-visualization.md +170 -0
- package/phases/05-integration.md +114 -0
- package/phases/06-scaffold.md +130 -0
- package/phases/07-build.md +493 -0
- package/phases/08-verification.md +597 -0
- package/phases/09-security.md +512 -0
- package/phases/10-documentation.md +613 -0
- package/phases/11-deployment.md +670 -0
- package/phases/testing.md +713 -0
- package/scripts/1.5-hooks-verify.sh +252 -0
- package/scripts/8.1-code-scan.sh +58 -0
- package/scripts/8.2-import-check.sh +42 -0
- package/scripts/8.3-source-returns.sh +52 -0
- package/scripts/8.4-startup-verify.sh +65 -0
- package/scripts/8.5-fallback-check.sh +63 -0
- package/scripts/8.6-attribution.sh +56 -0
- package/scripts/8.7-confidence.sh +56 -0
- package/scripts/8.8-gap-logging.sh +70 -0
- package/scripts/9-security-audit.sh +202 -0
- package/scripts/init-project.sh +395 -0
- package/scripts/verify-enforcement.sh +167 -0
- package/src/commands/hooks.js +361 -0
- package/src/commands/init.js +315 -0
- package/src/commands/phase.js +372 -0
- package/src/commands/score.js +380 -0
- package/src/commands/status.js +193 -0
- package/src/commands/verify.js +286 -0
- package/src/index.js +56 -0
- package/src/mcp-server.js +412 -0
- package/templates/attention-router.ts +534 -0
- package/templates/code-analysis.ts +683 -0
- package/templates/federated-kb-learner.ts +649 -0
- package/templates/gnn-engine.ts +1091 -0
- package/templates/intentions.md +277 -0
- package/templates/kb-client.ts +905 -0
- package/templates/schema.sql +303 -0
- package/templates/sona-config.ts +312 -0
package/package.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ruvnet-kb-first",
|
|
3
|
+
"version": "5.0.0",
|
|
4
|
+
"description": "RuvNet KB-First Application Builder - Build intelligent applications on expert knowledge",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"ruvnet-kb-first": "./bin/kb-first.js",
|
|
9
|
+
"kb-first": "./bin/kb-first.js"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"dev": "tsc --watch",
|
|
14
|
+
"start": "node bin/kb-first.js",
|
|
15
|
+
"mcp": "node src/mcp-server.js",
|
|
16
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
17
|
+
"lint": "eslint src/ templates/",
|
|
18
|
+
"kb:init": "node bin/kb-first.js init",
|
|
19
|
+
"kb:score": "node bin/kb-first.js score",
|
|
20
|
+
"kb:verify": "node bin/kb-first.js verify",
|
|
21
|
+
"kb:status": "node bin/kb-first.js status",
|
|
22
|
+
"prepublishOnly": "echo 'Publishing ruvnet-kb-first...'"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"kb-first",
|
|
26
|
+
"knowledge-base",
|
|
27
|
+
"claude",
|
|
28
|
+
"claude-code",
|
|
29
|
+
"gnn",
|
|
30
|
+
"graph-neural-network",
|
|
31
|
+
"attention-routing",
|
|
32
|
+
"sona",
|
|
33
|
+
"vector-search",
|
|
34
|
+
"mcp",
|
|
35
|
+
"mcp-server",
|
|
36
|
+
"ai-agents",
|
|
37
|
+
"expert-system",
|
|
38
|
+
"ruvector"
|
|
39
|
+
],
|
|
40
|
+
"author": "rUv",
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/ruvnet/kb-first-builder.git"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/ruvnet/kb-first-builder#readme",
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/ruvnet/kb-first-builder/issues"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"agentic-flow": "^2.0.1-alpha.43",
|
|
52
|
+
"chalk": "^5.3.0",
|
|
53
|
+
"claude-flow": "^2.7.47",
|
|
54
|
+
"commander": "^12.0.0",
|
|
55
|
+
"dotenv": "^16.3.0",
|
|
56
|
+
"glob": "^10.3.0",
|
|
57
|
+
"inquirer": "^9.2.0",
|
|
58
|
+
"ora": "^8.0.0",
|
|
59
|
+
"pg": "^8.11.3",
|
|
60
|
+
"ruv-swarm": "^1.0.20",
|
|
61
|
+
"ruvector": "^0.1.82"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@types/node": "^20.10.0",
|
|
65
|
+
"@types/pg": "^8.10.9",
|
|
66
|
+
"typescript": "^5.3.0",
|
|
67
|
+
"eslint": "^8.55.0",
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "^6.13.0",
|
|
69
|
+
"@typescript-eslint/parser": "^6.13.0",
|
|
70
|
+
"jest": "^29.7.0",
|
|
71
|
+
"@types/jest": "^29.5.11"
|
|
72
|
+
},
|
|
73
|
+
"engines": {
|
|
74
|
+
"node": ">=18.0.0"
|
|
75
|
+
},
|
|
76
|
+
"files": [
|
|
77
|
+
"bin/",
|
|
78
|
+
"src/",
|
|
79
|
+
"dist/",
|
|
80
|
+
"phases/",
|
|
81
|
+
"templates/",
|
|
82
|
+
"scripts/",
|
|
83
|
+
"install/",
|
|
84
|
+
"README.md",
|
|
85
|
+
"SKILL.md"
|
|
86
|
+
]
|
|
87
|
+
}
|
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
Updated: 2026-01-01 20:30:00 EST | Version 2.0.0
|
|
2
|
+
Created: 2026-01-01 19:00:00 EST
|
|
3
|
+
|
|
4
|
+
# Phase 0: Assessment (Mandatory for All Projects)
|
|
5
|
+
|
|
6
|
+
## Purpose
|
|
7
|
+
|
|
8
|
+
**MANDATORY for ALL projects.** This phase ensures Claude understands exactly what you want to build before writing any code or making any changes.
|
|
9
|
+
|
|
10
|
+
- **Greenfield:** Read intentions, confirm understanding, align on vision
|
|
11
|
+
- **Brownfield:** Read entire application, analyze, present transformation plan
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## ⛔ THIS PHASE IS NOT OPTIONAL
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
⛔ DO NOT PROCEED TO PHASE 1 WITHOUT COMPLETING PHASE 0
|
|
19
|
+
⛔ DO NOT ASSUME YOU UNDERSTAND THE PROJECT
|
|
20
|
+
⛔ DO NOT SKIP USER CONFIRMATION
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Sub-Phases
|
|
26
|
+
|
|
27
|
+
| Sub-Phase | Name | Output | Gate |
|
|
28
|
+
|-----------|------|--------|------|
|
|
29
|
+
| 0.1 | Detect Application Type | greenfield/brownfield | Required |
|
|
30
|
+
| 0.2 | **Greenfield:** Read Intentions | Project understanding | Required if greenfield |
|
|
31
|
+
| 0.3 | **Brownfield:** Full Application Analysis | Complete assessment | Required if brownfield |
|
|
32
|
+
| 0.4 | Present Vision (IS/SHOULD/COULD) | Analysis document | Required |
|
|
33
|
+
| 0.5 | Get User Feedback | Alignment confirmed | Required |
|
|
34
|
+
| 0.6 | Get User Confirmation | Explicit "PROCEED" | ⛔ HARD GATE |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 0.1 Detect Application Type
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
#!/bin/bash
|
|
42
|
+
# scripts/detect-app-type.sh
|
|
43
|
+
|
|
44
|
+
echo "=== Application Type Detection ==="
|
|
45
|
+
|
|
46
|
+
SCORE=0
|
|
47
|
+
|
|
48
|
+
# Check for existing source code
|
|
49
|
+
if [ -d "src" ] || [ -d "lib" ] || [ -d "app" ]; then
|
|
50
|
+
echo "✓ Source directory exists"
|
|
51
|
+
SCORE=$((SCORE + 1))
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
# Check for existing KB schema
|
|
55
|
+
if psql "$DATABASE_URL" -c "SELECT 1 FROM kb_nodes LIMIT 1" 2>/dev/null; then
|
|
56
|
+
echo "✓ KB tables exist with data"
|
|
57
|
+
SCORE=$((SCORE + 1))
|
|
58
|
+
fi
|
|
59
|
+
|
|
60
|
+
# Check for existing package.json
|
|
61
|
+
if [ -f "package.json" ]; then
|
|
62
|
+
echo "✓ package.json exists"
|
|
63
|
+
SCORE=$((SCORE + 1))
|
|
64
|
+
fi
|
|
65
|
+
|
|
66
|
+
# Check for domain logic
|
|
67
|
+
if [ -d "src/domain" ] || [ -d "lib/domain" ]; then
|
|
68
|
+
echo "✓ Domain logic directory exists"
|
|
69
|
+
SCORE=$((SCORE + 1))
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
echo ""
|
|
73
|
+
if [ $SCORE -ge 2 ]; then
|
|
74
|
+
echo "🟠 BROWNFIELD APPLICATION DETECTED"
|
|
75
|
+
echo " Phase 0 sub-phases 0.2-0.6 are MANDATORY"
|
|
76
|
+
echo " DO NOT SKIP TO PHASE 1"
|
|
77
|
+
else
|
|
78
|
+
echo "🟢 GREENFIELD APPLICATION"
|
|
79
|
+
echo " Proceed directly to Phase 1"
|
|
80
|
+
fi
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Gate:** Application type determined.
|
|
84
|
+
- If **greenfield** → Continue to 0.2 (Read Intentions)
|
|
85
|
+
- If **brownfield** → Continue to 0.3 (Full Application Analysis)
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 0.2 Greenfield: Read Intentions
|
|
90
|
+
|
|
91
|
+
For greenfield projects, Claude must understand what you want to build before proceeding.
|
|
92
|
+
|
|
93
|
+
### Option A: PROJECT_INTENTIONS.md Exists
|
|
94
|
+
|
|
95
|
+
If the file `PROJECT_INTENTIONS.md` exists in the project root:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
#!/bin/bash
|
|
99
|
+
# Check for intentions file
|
|
100
|
+
if [ -f "PROJECT_INTENTIONS.md" ]; then
|
|
101
|
+
echo "✓ PROJECT_INTENTIONS.md found"
|
|
102
|
+
echo "Reading intentions..."
|
|
103
|
+
cat PROJECT_INTENTIONS.md
|
|
104
|
+
fi
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Claude will:
|
|
108
|
+
1. Read the entire intentions file
|
|
109
|
+
2. Parse all sections (project overview, intelligence pattern, requirements, etc.)
|
|
110
|
+
3. Generate a summary for user confirmation
|
|
111
|
+
4. **Present back to user** what was understood
|
|
112
|
+
|
|
113
|
+
### Option B: No Intentions File - Interactive Discovery
|
|
114
|
+
|
|
115
|
+
If no intentions file exists, Claude will ask structured questions:
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
╔═══════════════════════════════════════════════════════════╗
|
|
119
|
+
║ GREENFIELD PROJECT DISCOVERY ║
|
|
120
|
+
╠═══════════════════════════════════════════════════════════╣
|
|
121
|
+
║ ║
|
|
122
|
+
║ I need to understand what you want to build. ║
|
|
123
|
+
║ ║
|
|
124
|
+
║ Please answer these questions: ║
|
|
125
|
+
║ ║
|
|
126
|
+
║ 1. PROJECT NAME: What is this project called? ║
|
|
127
|
+
║ ║
|
|
128
|
+
║ 2. ONE-LINER: In one sentence, what does it do? ║
|
|
129
|
+
║ ║
|
|
130
|
+
║ 3. PROBLEM: What problem does this solve? ║
|
|
131
|
+
║ ║
|
|
132
|
+
║ 4. USERS: Who will use this application? ║
|
|
133
|
+
║ ║
|
|
134
|
+
║ 5. INTELLIGENCE PATTERN: Which fits best? ║
|
|
135
|
+
║ [ ] Decision Web (GNN) - interconnected variables ║
|
|
136
|
+
║ [ ] Combinatorial Routing - query routing to experts ║
|
|
137
|
+
║ [ ] Scenario Learning (SONA) - "what worked for X?" ║
|
|
138
|
+
║ [ ] Continuous Optimization - ongoing adaptation ║
|
|
139
|
+
║ [ ] Unsure - let me analyze and recommend ║
|
|
140
|
+
║ ║
|
|
141
|
+
║ 6. CORE FEATURES: What MUST it do? (list 3-5) ║
|
|
142
|
+
║ ║
|
|
143
|
+
║ 7. DEPLOYMENT: Where will it run? ║
|
|
144
|
+
║ [ ] Local [ ] Docker [ ] Vercel [ ] Railway ║
|
|
145
|
+
║ ║
|
|
146
|
+
╚═══════════════════════════════════════════════════════════╝
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Creating Intentions File
|
|
150
|
+
|
|
151
|
+
After interactive discovery, Claude will generate `PROJECT_INTENTIONS.md`:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# Generate from user responses
|
|
155
|
+
cat > PROJECT_INTENTIONS.md << 'EOF'
|
|
156
|
+
# Project Intentions
|
|
157
|
+
|
|
158
|
+
Updated: $(date) | Version 1.0.0
|
|
159
|
+
Created: $(date)
|
|
160
|
+
|
|
161
|
+
## 1. Project Overview
|
|
162
|
+
...
|
|
163
|
+
EOF
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Gate:** Intentions understood. Continue to 0.4 (Present Vision).
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## 0.3 Brownfield: Full Application Analysis
|
|
171
|
+
|
|
172
|
+
For existing applications, Claude MUST read and understand the entire codebase before proposing changes.
|
|
173
|
+
|
|
174
|
+
### Step 1: Comprehensive Codebase Read
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
#!/bin/bash
|
|
178
|
+
# scripts/analyze-application.sh
|
|
179
|
+
|
|
180
|
+
echo "=== FULL APPLICATION ANALYSIS ==="
|
|
181
|
+
echo "Reading entire codebase..."
|
|
182
|
+
|
|
183
|
+
# Structure overview
|
|
184
|
+
echo ""
|
|
185
|
+
echo "## Directory Structure"
|
|
186
|
+
find . -type d -not -path './node_modules/*' -not -path './.git/*' | head -50
|
|
187
|
+
|
|
188
|
+
# Source files
|
|
189
|
+
echo ""
|
|
190
|
+
echo "## Source Files"
|
|
191
|
+
find . -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" | wc -l
|
|
192
|
+
echo "TypeScript/JavaScript files found"
|
|
193
|
+
|
|
194
|
+
# Package dependencies
|
|
195
|
+
echo ""
|
|
196
|
+
echo "## Dependencies"
|
|
197
|
+
if [ -f "package.json" ]; then
|
|
198
|
+
jq '.dependencies, .devDependencies' package.json 2>/dev/null || cat package.json
|
|
199
|
+
fi
|
|
200
|
+
|
|
201
|
+
# Database schema
|
|
202
|
+
echo ""
|
|
203
|
+
echo "## Database Schema"
|
|
204
|
+
if [ -n "$DATABASE_URL" ]; then
|
|
205
|
+
psql "$DATABASE_URL" -c "\dt" 2>/dev/null
|
|
206
|
+
fi
|
|
207
|
+
|
|
208
|
+
# Entry points
|
|
209
|
+
echo ""
|
|
210
|
+
echo "## Entry Points"
|
|
211
|
+
find . -name "index.ts" -o -name "index.js" -o -name "main.ts" -o -name "app.ts" 2>/dev/null
|
|
212
|
+
|
|
213
|
+
# Domain logic
|
|
214
|
+
echo ""
|
|
215
|
+
echo "## Domain Logic"
|
|
216
|
+
if [ -d "src/domain" ]; then
|
|
217
|
+
ls -la src/domain/
|
|
218
|
+
fi
|
|
219
|
+
|
|
220
|
+
# API routes
|
|
221
|
+
echo ""
|
|
222
|
+
echo "## API Routes"
|
|
223
|
+
find . -name "*.ts" -exec grep -l "router\|app.get\|app.post" {} \; 2>/dev/null | head -20
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Step 2: Read Every Domain File
|
|
227
|
+
|
|
228
|
+
Claude MUST read every file in domain logic directories:
|
|
229
|
+
|
|
230
|
+
```
|
|
231
|
+
Files to read completely:
|
|
232
|
+
- src/domain/*.ts (ALL files)
|
|
233
|
+
- src/services/*.ts (ALL files)
|
|
234
|
+
- src/api/*.ts (ALL files)
|
|
235
|
+
- src/components/*.tsx (ALL files)
|
|
236
|
+
- src/lib/*.ts (ALL files)
|
|
237
|
+
- Configuration files (tsconfig, package.json, etc.)
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Step 3: Analyze Current Architecture
|
|
241
|
+
|
|
242
|
+
```
|
|
243
|
+
For each domain function, identify:
|
|
244
|
+
1. What it does (purpose)
|
|
245
|
+
2. What data it uses (sources)
|
|
246
|
+
3. Whether it queries KB or uses hardcoded values
|
|
247
|
+
4. What it returns (structure)
|
|
248
|
+
5. How it handles errors
|
|
249
|
+
6. Dependencies on other functions
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Step 4: Score Existing KB
|
|
253
|
+
|
|
254
|
+
#### KB Quality Score Formula (0-100)
|
|
255
|
+
|
|
256
|
+
```
|
|
257
|
+
KB_SCORE = EXPERT_COVERAGE + DEPTH + COMPLETENESS + ATTRIBUTION + CONFIDENCE
|
|
258
|
+
|
|
259
|
+
Where:
|
|
260
|
+
- EXPERT_COVERAGE (25 pts): (unique_experts_cited / 100) * 25
|
|
261
|
+
- DEPTH (25 pts): Based on average node depth (4+ = 25pts)
|
|
262
|
+
- COMPLETENESS (25 pts): (1 - (gaps_unfilled / total_topics)) * 25
|
|
263
|
+
- ATTRIBUTION (15 pts): (nodes_with_sources / total_nodes) * 15
|
|
264
|
+
- CONFIDENCE (10 pts): avg_confidence_score * 10
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Step 5: Score App Compliance
|
|
268
|
+
|
|
269
|
+
#### App Compliance Score Formula (0-100)
|
|
270
|
+
|
|
271
|
+
```
|
|
272
|
+
APP_SCORE = KB_IMPORTS + SOURCE_RETURNS + NO_HARDCODE + STARTUP_VERIFY + NO_FALLBACKS
|
|
273
|
+
|
|
274
|
+
Where:
|
|
275
|
+
- KB_IMPORTS (20 pts): Domain files importing KB
|
|
276
|
+
- SOURCE_RETURNS (20 pts): Functions returning kbSources
|
|
277
|
+
- NO_HARDCODE (20 pts): No hardcoded magic values
|
|
278
|
+
- STARTUP_VERIFY (20 pts): KB verification at startup
|
|
279
|
+
- NO_FALLBACKS (20 pts): No fallback defaults
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
**Gate:** Full analysis complete. Continue to 0.4.
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## 0.4 Present Vision (IS / SHOULD / COULD)
|
|
287
|
+
|
|
288
|
+
After understanding the project (greenfield or brownfield), Claude presents a structured analysis.
|
|
289
|
+
|
|
290
|
+
### For Greenfield Projects
|
|
291
|
+
|
|
292
|
+
```
|
|
293
|
+
╔═══════════════════════════════════════════════════════════╗
|
|
294
|
+
║ PROJECT UNDERSTANDING ║
|
|
295
|
+
╠═══════════════════════════════════════════════════════════╣
|
|
296
|
+
║ ║
|
|
297
|
+
║ 📋 WHAT YOU WANT TO BUILD: ║
|
|
298
|
+
║ [Summary of intentions/discovery] ║
|
|
299
|
+
║ ║
|
|
300
|
+
║ 🎯 WHAT IT SHOULD BE: ║
|
|
301
|
+
║ - Architecture: [recommended pattern] ║
|
|
302
|
+
║ - KB Structure: [domain taxonomy] ║
|
|
303
|
+
║ - Intelligence: [recommended pattern] ║
|
|
304
|
+
║ - Scale: [expected load handling] ║
|
|
305
|
+
║ ║
|
|
306
|
+
║ 🚀 WHAT IT COULD BE (with KB-First): ║
|
|
307
|
+
║ - Expert-sourced responses with citations ║
|
|
308
|
+
║ - Gap detection for knowledge expansion ║
|
|
309
|
+
║ - Confidence scoring on all outputs ║
|
|
310
|
+
║ - [domain-specific capabilities] ║
|
|
311
|
+
║ ║
|
|
312
|
+
║ 📊 RECOMMENDED PHASES: ║
|
|
313
|
+
║ [List of phases this project needs] ║
|
|
314
|
+
║ ║
|
|
315
|
+
╚═══════════════════════════════════════════════════════════╝
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### For Brownfield Projects
|
|
319
|
+
|
|
320
|
+
```
|
|
321
|
+
╔═══════════════════════════════════════════════════════════╗
|
|
322
|
+
║ BROWNFIELD ANALYSIS ║
|
|
323
|
+
╠═══════════════════════════════════════════════════════════╣
|
|
324
|
+
║ ║
|
|
325
|
+
║ 📋 WHAT IT IS NOW: ║
|
|
326
|
+
║ - Purpose: [detected purpose from code analysis] ║
|
|
327
|
+
║ - Architecture: [current architecture] ║
|
|
328
|
+
║ - KB State: [current KB score] / 100 ║
|
|
329
|
+
║ - App Compliance: [current app score] / 100 ║
|
|
330
|
+
║ - Key Functions: [list of domain functions found] ║
|
|
331
|
+
║ - Dependencies: [external services/APIs] ║
|
|
332
|
+
║ - Issues Found: ║
|
|
333
|
+
║ • [hardcoded values] ║
|
|
334
|
+
║ • [missing KB integration] ║
|
|
335
|
+
║ • [no source attribution] ║
|
|
336
|
+
║ ║
|
|
337
|
+
║ 🎯 WHAT IT SHOULD BE: ║
|
|
338
|
+
║ - KB Score: ≥98/100 ║
|
|
339
|
+
║ - App Compliance: ≥98/100 ║
|
|
340
|
+
║ - All values from KB, not hardcoded ║
|
|
341
|
+
║ - Source attribution on every response ║
|
|
342
|
+
║ - KB verification at startup ║
|
|
343
|
+
║ - Gap logging for missing knowledge ║
|
|
344
|
+
║ ║
|
|
345
|
+
║ 🚀 WHAT IT COULD BE (with transformation): ║
|
|
346
|
+
║ - [enhanced capability 1 based on domain] ║
|
|
347
|
+
║ - [enhanced capability 2] ║
|
|
348
|
+
║ - [enhanced capability 3] ║
|
|
349
|
+
║ - Expert knowledge with confidence scores ║
|
|
350
|
+
║ - Self-improving through gap detection ║
|
|
351
|
+
║ ║
|
|
352
|
+
║ 📊 TRANSFORMATION SCOPE: ║
|
|
353
|
+
║ - KB Gap: [X] points to close ║
|
|
354
|
+
║ - App Gap: [X] points to close ║
|
|
355
|
+
║ - Phases Required: [list] ║
|
|
356
|
+
║ - Estimated Effort: [XS/S/M/L/XL] ║
|
|
357
|
+
║ ║
|
|
358
|
+
╚═══════════════════════════════════════════════════════════╝
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
**Gate:** Vision presented. Continue to 0.5.
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
## 0.5 Get User Feedback
|
|
366
|
+
|
|
367
|
+
⛔ **DO NOT PROCEED WITHOUT USER RESPONSE**
|
|
368
|
+
|
|
369
|
+
```
|
|
370
|
+
╔═══════════════════════════════════════════════════════════╗
|
|
371
|
+
║ ⚠️ FEEDBACK REQUIRED ⚠️ ║
|
|
372
|
+
╠═══════════════════════════════════════════════════════════╣
|
|
373
|
+
║ ║
|
|
374
|
+
║ Based on my analysis above: ║
|
|
375
|
+
║ ║
|
|
376
|
+
║ 1. Does my understanding match your expectations? ║
|
|
377
|
+
║ ║
|
|
378
|
+
║ 2. Is the "WHAT IT SHOULD BE" vision correct? ║
|
|
379
|
+
║ ║
|
|
380
|
+
║ 3. Are there capabilities I missed in "WHAT IT COULD BE"?║
|
|
381
|
+
║ ║
|
|
382
|
+
║ 4. Any concerns about the transformation scope? ║
|
|
383
|
+
║ ║
|
|
384
|
+
║ Please provide your feedback before I proceed. ║
|
|
385
|
+
║ ║
|
|
386
|
+
╚═══════════════════════════════════════════════════════════╝
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
Claude MUST:
|
|
390
|
+
1. Wait for user feedback
|
|
391
|
+
2. Address any corrections
|
|
392
|
+
3. Update the vision if needed
|
|
393
|
+
4. Re-present if significant changes
|
|
394
|
+
|
|
395
|
+
**Gate:** User feedback incorporated. Continue to 0.6.
|
|
396
|
+
|
|
397
|
+
---
|
|
398
|
+
|
|
399
|
+
## 0.6 Get User Confirmation
|
|
400
|
+
|
|
401
|
+
### ⛔ HARD GATE - DO NOT PROCEED WITHOUT EXPLICIT CONFIRMATION
|
|
402
|
+
|
|
403
|
+
```
|
|
404
|
+
╔═══════════════════════════════════════════════════════════╗
|
|
405
|
+
║ ⛔ CONFIRMATION REQUIRED ⛔ ║
|
|
406
|
+
╠═══════════════════════════════════════════════════════════╣
|
|
407
|
+
║ ║
|
|
408
|
+
║ I will now execute the KB-First transformation: ║
|
|
409
|
+
║ ║
|
|
410
|
+
║ [For Brownfield] ║
|
|
411
|
+
║ Before Score: ║
|
|
412
|
+
║ KB Quality: [X]/100 ║
|
|
413
|
+
║ App Compliance: [X]/100 ║
|
|
414
|
+
║ ║
|
|
415
|
+
║ After Score (Target): ║
|
|
416
|
+
║ KB Quality: 98/100 ║
|
|
417
|
+
║ App Compliance: 98/100 ║
|
|
418
|
+
║ ║
|
|
419
|
+
║ [For Greenfield] ║
|
|
420
|
+
║ Target: ║
|
|
421
|
+
║ KB Quality: ≥98/100 ║
|
|
422
|
+
║ App Compliance: ≥98/100 ║
|
|
423
|
+
║ Full source attribution ║
|
|
424
|
+
║ Expert-backed responses ║
|
|
425
|
+
║ ║
|
|
426
|
+
║ Phases to Execute: [list] ║
|
|
427
|
+
║ ║
|
|
428
|
+
╠═══════════════════════════════════════════════════════════╣
|
|
429
|
+
║ ║
|
|
430
|
+
║ Type "PROCEED" to begin transformation ║
|
|
431
|
+
║ Type "ABORT" to stop ║
|
|
432
|
+
║ ║
|
|
433
|
+
╚═══════════════════════════════════════════════════════════╝
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
**Gate:** User types "PROCEED" → Continue to Phase 1
|
|
437
|
+
|
|
438
|
+
---
|
|
439
|
+
|
|
440
|
+
## Swarm Configuration for Phase 0
|
|
441
|
+
|
|
442
|
+
```yaml
|
|
443
|
+
phase_0_swarm:
|
|
444
|
+
topology: star # Coordinator orchestrates assessors
|
|
445
|
+
strategy: parallel
|
|
446
|
+
maxAgents: 4
|
|
447
|
+
|
|
448
|
+
agents:
|
|
449
|
+
- type: coordinator
|
|
450
|
+
name: assessment-coordinator
|
|
451
|
+
capabilities:
|
|
452
|
+
- orchestrate_assessment
|
|
453
|
+
- aggregate_scores
|
|
454
|
+
- generate_report
|
|
455
|
+
|
|
456
|
+
- type: analyst
|
|
457
|
+
name: kb-scorer
|
|
458
|
+
capabilities:
|
|
459
|
+
- query_database
|
|
460
|
+
- calculate_kb_score
|
|
461
|
+
- identify_kb_gaps
|
|
462
|
+
|
|
463
|
+
- type: analyst
|
|
464
|
+
name: app-scorer
|
|
465
|
+
capabilities:
|
|
466
|
+
- analyze_source_code
|
|
467
|
+
- calculate_app_score
|
|
468
|
+
- identify_violations
|
|
469
|
+
|
|
470
|
+
- type: specialist
|
|
471
|
+
name: gap-reporter
|
|
472
|
+
capabilities:
|
|
473
|
+
- aggregate_gaps
|
|
474
|
+
- prioritize_issues
|
|
475
|
+
- estimate_effort
|
|
476
|
+
|
|
477
|
+
parallel_execution:
|
|
478
|
+
- [kb-scorer, app-scorer] # Run in parallel
|
|
479
|
+
- [gap-reporter] # After both complete
|
|
480
|
+
- [coordinator] # Final aggregation
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
---
|
|
484
|
+
|
|
485
|
+
## Exit Criteria
|
|
486
|
+
|
|
487
|
+
### For Greenfield Projects
|
|
488
|
+
|
|
489
|
+
```
|
|
490
|
+
[ ] PROJECT_INTENTIONS.md exists OR interactive discovery completed
|
|
491
|
+
[ ] Claude has presented project understanding back to user
|
|
492
|
+
[ ] User has provided feedback on the vision
|
|
493
|
+
[ ] Vision updated based on feedback (if needed)
|
|
494
|
+
[ ] User explicitly typed "PROCEED"
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
### For Brownfield Projects
|
|
498
|
+
|
|
499
|
+
```
|
|
500
|
+
[ ] Full codebase read (every domain file)
|
|
501
|
+
[ ] KB quality score calculated (0-100)
|
|
502
|
+
[ ] App compliance score calculated (0-100)
|
|
503
|
+
[ ] IS/SHOULD/COULD analysis presented to user
|
|
504
|
+
[ ] User has provided feedback on the analysis
|
|
505
|
+
[ ] Vision updated based on feedback (if needed)
|
|
506
|
+
[ ] User explicitly typed "PROCEED"
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
**Only proceed to Phase 1 when ALL applicable boxes are checked.**
|
|
510
|
+
|
|
511
|
+
---
|
|
512
|
+
|
|
513
|
+
## Delta Tracking
|
|
514
|
+
|
|
515
|
+
After Phase 8 completion, return to Phase 0 scores for comparison:
|
|
516
|
+
|
|
517
|
+
```
|
|
518
|
+
╔═══════════════════════════════════════════════════════════╗
|
|
519
|
+
║ TRANSFORMATION COMPLETE ║
|
|
520
|
+
╠═══════════════════════════════════════════════════════════╣
|
|
521
|
+
║ BEFORE AFTER DELTA ║
|
|
522
|
+
║ KB Quality: 47/100 98/100 +51 ✓ ║
|
|
523
|
+
║ App Compliance: 32/100 99/100 +67 ✓ ║
|
|
524
|
+
║ ║
|
|
525
|
+
║ Phases Completed: 8/8 ║
|
|
526
|
+
║ Total Duration: 6 days ║
|
|
527
|
+
║ Effort Estimate Accuracy: 85% (estimated L, actual L) ║
|
|
528
|
+
╚═══════════════════════════════════════════════════════════╝
|
|
529
|
+
```
|