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
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KB-First Verify Command
|
|
3
|
+
*
|
|
4
|
+
* Runs verification checks for KB-First compliance.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import ora from 'ora';
|
|
9
|
+
import { existsSync, readFileSync, chmodSync } from 'fs';
|
|
10
|
+
import { join } from 'path';
|
|
11
|
+
import { execFileSync } from 'child_process';
|
|
12
|
+
|
|
13
|
+
const PHASE_SCRIPTS = {
|
|
14
|
+
0: [], // Assessment - no scripts
|
|
15
|
+
1: [], // KB Design - no scripts
|
|
16
|
+
1.5: ['1.5-hooks-verify.sh'],
|
|
17
|
+
2: [], // Schema - no scripts
|
|
18
|
+
3: [], // Population - no scripts
|
|
19
|
+
4: [], // Scoring - no scripts
|
|
20
|
+
5: [], // Integration - no scripts
|
|
21
|
+
6: [], // Testing - no scripts
|
|
22
|
+
7: [], // Optimization - no scripts
|
|
23
|
+
8: [
|
|
24
|
+
'8.1-code-scan.sh',
|
|
25
|
+
'8.2-import-check.sh',
|
|
26
|
+
'8.3-source-returns.sh',
|
|
27
|
+
'8.4-startup-verify.sh',
|
|
28
|
+
'8.5-fallback-check.sh',
|
|
29
|
+
'8.6-attribution.sh',
|
|
30
|
+
'8.7-confidence.sh',
|
|
31
|
+
'8.8-gap-logging.sh'
|
|
32
|
+
],
|
|
33
|
+
9: ['9-security-audit.sh'],
|
|
34
|
+
10: [], // Documentation - no scripts
|
|
35
|
+
11: [] // Deployment - no scripts
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export async function verifyCommand(options) {
|
|
39
|
+
const cwd = process.cwd();
|
|
40
|
+
|
|
41
|
+
console.log('');
|
|
42
|
+
console.log(chalk.cyan('Running KB-First Verification Checks...'));
|
|
43
|
+
console.log('');
|
|
44
|
+
|
|
45
|
+
// Check if project is initialized
|
|
46
|
+
const configPath = join(cwd, '.ruvector', 'config.json');
|
|
47
|
+
if (!existsSync(configPath)) {
|
|
48
|
+
console.log(chalk.red('Error: Not a KB-First project.'));
|
|
49
|
+
console.log(chalk.gray('Run: kb-first init'));
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const scriptsDir = join(cwd, 'scripts');
|
|
54
|
+
|
|
55
|
+
if (options.phase) {
|
|
56
|
+
// Run specific phase verification
|
|
57
|
+
const phase = parseFloat(options.phase);
|
|
58
|
+
await verifyPhase(cwd, scriptsDir, phase, options.verbose);
|
|
59
|
+
} else if (options.all) {
|
|
60
|
+
// Run all verification scripts
|
|
61
|
+
await verifyAll(cwd, scriptsDir, options.verbose);
|
|
62
|
+
} else {
|
|
63
|
+
// Run basic verification
|
|
64
|
+
await verifyBasic(cwd, options.verbose);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function runScript(scriptPath, cwd, verbose) {
|
|
69
|
+
// Make script executable
|
|
70
|
+
chmodSync(scriptPath, 0o755);
|
|
71
|
+
|
|
72
|
+
// Run using bash with execFileSync (safe - no shell interpolation)
|
|
73
|
+
const result = execFileSync('/bin/bash', [scriptPath], {
|
|
74
|
+
cwd,
|
|
75
|
+
stdio: verbose ? 'inherit' : 'pipe',
|
|
76
|
+
timeout: 60000,
|
|
77
|
+
encoding: 'utf-8'
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function verifyPhase(cwd, scriptsDir, phase, verbose) {
|
|
84
|
+
console.log(chalk.white(`Verifying Phase ${phase}...`));
|
|
85
|
+
console.log('');
|
|
86
|
+
|
|
87
|
+
const scripts = PHASE_SCRIPTS[phase];
|
|
88
|
+
|
|
89
|
+
if (!scripts || scripts.length === 0) {
|
|
90
|
+
console.log(chalk.yellow(`No verification scripts for Phase ${phase}.`));
|
|
91
|
+
console.log(chalk.gray('Phase verification is manual or done via scoring.'));
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let passed = 0;
|
|
96
|
+
let failed = 0;
|
|
97
|
+
|
|
98
|
+
for (const script of scripts) {
|
|
99
|
+
const scriptPath = join(scriptsDir, script);
|
|
100
|
+
|
|
101
|
+
if (!existsSync(scriptPath)) {
|
|
102
|
+
console.log(chalk.yellow(` Skip: ${script} (not found)`));
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const spinner = ora(`Running ${script}...`).start();
|
|
107
|
+
|
|
108
|
+
try {
|
|
109
|
+
if (verbose) {
|
|
110
|
+
spinner.stop();
|
|
111
|
+
console.log(chalk.gray(`\n $ ./${script}\n`));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
await runScript(scriptPath, cwd, verbose);
|
|
115
|
+
|
|
116
|
+
spinner.succeed(`${script}`);
|
|
117
|
+
passed++;
|
|
118
|
+
} catch (error) {
|
|
119
|
+
spinner.fail(`${script}`);
|
|
120
|
+
failed++;
|
|
121
|
+
|
|
122
|
+
if (verbose && error.stdout) {
|
|
123
|
+
console.log(chalk.gray(error.stdout.toString()));
|
|
124
|
+
}
|
|
125
|
+
if (verbose && error.stderr) {
|
|
126
|
+
console.log(chalk.red(error.stderr.toString()));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Summary
|
|
132
|
+
console.log('');
|
|
133
|
+
console.log(chalk.white('═══════════════════════════════════════════════════════════════'));
|
|
134
|
+
console.log(` Phase ${phase} Verification: ${passed} passed, ${failed} failed`);
|
|
135
|
+
console.log(chalk.white('═══════════════════════════════════════════════════════════════'));
|
|
136
|
+
console.log('');
|
|
137
|
+
|
|
138
|
+
if (failed === 0) {
|
|
139
|
+
console.log(chalk.green(` ✅ Phase ${phase} verification PASSED`));
|
|
140
|
+
} else {
|
|
141
|
+
console.log(chalk.red(` ❌ Phase ${phase} verification FAILED`));
|
|
142
|
+
console.log(chalk.gray(' Fix failures before proceeding to next phase.'));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async function verifyAll(cwd, scriptsDir, verbose) {
|
|
147
|
+
console.log(chalk.white('Running ALL verification scripts...'));
|
|
148
|
+
console.log('');
|
|
149
|
+
|
|
150
|
+
let totalPassed = 0;
|
|
151
|
+
let totalFailed = 0;
|
|
152
|
+
|
|
153
|
+
for (const [phase, scripts] of Object.entries(PHASE_SCRIPTS)) {
|
|
154
|
+
if (scripts.length === 0) continue;
|
|
155
|
+
|
|
156
|
+
console.log(chalk.cyan(`\n--- Phase ${phase} ---\n`));
|
|
157
|
+
|
|
158
|
+
for (const script of scripts) {
|
|
159
|
+
const scriptPath = join(scriptsDir, script);
|
|
160
|
+
|
|
161
|
+
if (!existsSync(scriptPath)) {
|
|
162
|
+
console.log(chalk.yellow(` Skip: ${script} (not found)`));
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const spinner = ora(`Running ${script}...`).start();
|
|
167
|
+
|
|
168
|
+
try {
|
|
169
|
+
await runScript(scriptPath, cwd, verbose);
|
|
170
|
+
|
|
171
|
+
spinner.succeed(`${script}`);
|
|
172
|
+
totalPassed++;
|
|
173
|
+
} catch (error) {
|
|
174
|
+
spinner.fail(`${script}`);
|
|
175
|
+
totalFailed++;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Summary
|
|
181
|
+
console.log('');
|
|
182
|
+
console.log(chalk.white('═══════════════════════════════════════════════════════════════'));
|
|
183
|
+
console.log(` Total Verification: ${totalPassed} passed, ${totalFailed} failed`);
|
|
184
|
+
console.log(chalk.white('═══════════════════════════════════════════════════════════════'));
|
|
185
|
+
console.log('');
|
|
186
|
+
|
|
187
|
+
if (totalFailed === 0) {
|
|
188
|
+
console.log(chalk.green(' ✅ All verifications PASSED'));
|
|
189
|
+
} else {
|
|
190
|
+
console.log(chalk.red(` ❌ ${totalFailed} verification(s) FAILED`));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
async function verifyBasic(cwd, verbose) {
|
|
195
|
+
console.log(chalk.white('Running basic KB-First verification...'));
|
|
196
|
+
console.log('');
|
|
197
|
+
|
|
198
|
+
const checks = [];
|
|
199
|
+
|
|
200
|
+
// 1. Check .ruvector directory
|
|
201
|
+
checks.push({
|
|
202
|
+
name: 'Configuration',
|
|
203
|
+
pass: existsSync(join(cwd, '.ruvector', 'config.json')),
|
|
204
|
+
details: '.ruvector/config.json exists'
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
// 2. Check hooks
|
|
208
|
+
const hooksDir = join(cwd, '.ruvector', 'hooks');
|
|
209
|
+
checks.push({
|
|
210
|
+
name: 'Hooks Directory',
|
|
211
|
+
pass: existsSync(hooksDir),
|
|
212
|
+
details: '.ruvector/hooks/ exists'
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// 3. Check phases directory
|
|
216
|
+
checks.push({
|
|
217
|
+
name: 'Phase Documentation',
|
|
218
|
+
pass: existsSync(join(cwd, 'phases')),
|
|
219
|
+
details: 'phases/ directory exists'
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// 4. Check scripts directory
|
|
223
|
+
checks.push({
|
|
224
|
+
name: 'Verification Scripts',
|
|
225
|
+
pass: existsSync(join(cwd, 'scripts')),
|
|
226
|
+
details: 'scripts/ directory exists'
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
// 5. Check src/kb directory
|
|
230
|
+
checks.push({
|
|
231
|
+
name: 'KB Source',
|
|
232
|
+
pass: existsSync(join(cwd, 'src', 'kb')),
|
|
233
|
+
details: 'src/kb/ directory exists'
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
// 6. Check for README
|
|
237
|
+
checks.push({
|
|
238
|
+
name: 'README',
|
|
239
|
+
pass: existsSync(join(cwd, 'README.md')),
|
|
240
|
+
details: 'README.md exists'
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
// 7. Check .gitignore includes .env
|
|
244
|
+
const gitignorePath = join(cwd, '.gitignore');
|
|
245
|
+
let hasEnvInGitignore = false;
|
|
246
|
+
if (existsSync(gitignorePath)) {
|
|
247
|
+
const content = readFileSync(gitignorePath, 'utf-8');
|
|
248
|
+
hasEnvInGitignore = content.includes('.env');
|
|
249
|
+
}
|
|
250
|
+
checks.push({
|
|
251
|
+
name: 'Security (.env)',
|
|
252
|
+
pass: hasEnvInGitignore,
|
|
253
|
+
details: '.env in .gitignore'
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
// Output results
|
|
257
|
+
let passed = 0;
|
|
258
|
+
let failed = 0;
|
|
259
|
+
|
|
260
|
+
for (const check of checks) {
|
|
261
|
+
if (check.pass) {
|
|
262
|
+
console.log(chalk.green(` ✅ ${check.name}: ${check.details}`));
|
|
263
|
+
passed++;
|
|
264
|
+
} else {
|
|
265
|
+
console.log(chalk.red(` ❌ ${check.name}: ${check.details}`));
|
|
266
|
+
failed++;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Summary
|
|
271
|
+
console.log('');
|
|
272
|
+
console.log(chalk.white('═══════════════════════════════════════════════════════════════'));
|
|
273
|
+
console.log(` Basic Verification: ${passed}/${checks.length} checks passed`);
|
|
274
|
+
console.log(chalk.white('═══════════════════════════════════════════════════════════════'));
|
|
275
|
+
console.log('');
|
|
276
|
+
|
|
277
|
+
if (failed === 0) {
|
|
278
|
+
console.log(chalk.green(' ✅ Basic verification PASSED'));
|
|
279
|
+
console.log('');
|
|
280
|
+
console.log(chalk.gray(' Run kb-first verify --all for comprehensive checks'));
|
|
281
|
+
} else {
|
|
282
|
+
console.log(chalk.yellow(` ⚠️ ${failed} check(s) need attention`));
|
|
283
|
+
console.log('');
|
|
284
|
+
console.log(chalk.gray(' Run kb-first init to set up missing components'));
|
|
285
|
+
}
|
|
286
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RuvNet KB-First Application Builder
|
|
3
|
+
*
|
|
4
|
+
* Build intelligent applications on expert knowledge bases.
|
|
5
|
+
*
|
|
6
|
+
* @module ruvnet-kb-first
|
|
7
|
+
* @version 5.0.0
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// Export commands for programmatic use
|
|
11
|
+
export { initCommand } from './commands/init.js';
|
|
12
|
+
export { scoreCommand } from './commands/score.js';
|
|
13
|
+
export { verifyCommand } from './commands/verify.js';
|
|
14
|
+
export { hooksCommand } from './commands/hooks.js';
|
|
15
|
+
export { statusCommand } from './commands/status.js';
|
|
16
|
+
export { phaseCommand } from './commands/phase.js';
|
|
17
|
+
|
|
18
|
+
// Export MCP server
|
|
19
|
+
export { startMCPServer } from './mcp-server.js';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* KB-First configuration defaults
|
|
23
|
+
*/
|
|
24
|
+
export const KB_FIRST_DEFAULTS = {
|
|
25
|
+
version: '5.0.0',
|
|
26
|
+
minConfidence: 0.5,
|
|
27
|
+
gapLogging: true,
|
|
28
|
+
phases: 12,
|
|
29
|
+
subphases: 57
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Phase definitions
|
|
34
|
+
*/
|
|
35
|
+
export const PHASES = [
|
|
36
|
+
{ num: 0, name: 'Assessment', subphases: 5 },
|
|
37
|
+
{ num: 1, name: 'KB Design', subphases: 5 },
|
|
38
|
+
{ num: 1.5, name: 'Hooks Setup', subphases: 4 },
|
|
39
|
+
{ num: 2, name: 'Schema Definition', subphases: 4 },
|
|
40
|
+
{ num: 3, name: 'KB Population', subphases: 5 },
|
|
41
|
+
{ num: 4, name: 'Scoring & Gaps', subphases: 5 },
|
|
42
|
+
{ num: 5, name: 'Integration', subphases: 4 },
|
|
43
|
+
{ num: 6, name: 'Testing', subphases: 5 },
|
|
44
|
+
{ num: 7, name: 'Optimization', subphases: 4 },
|
|
45
|
+
{ num: 8, name: 'Verification', subphases: 8 },
|
|
46
|
+
{ num: 9, name: 'Security', subphases: 6 },
|
|
47
|
+
{ num: 10, name: 'Documentation', subphases: 6 },
|
|
48
|
+
{ num: 11, name: 'Deployment', subphases: 6 }
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Calculate total subphases
|
|
53
|
+
*/
|
|
54
|
+
export function getTotalSubphases() {
|
|
55
|
+
return PHASES.reduce((sum, p) => sum + p.subphases, 0);
|
|
56
|
+
}
|