cmp-standards 3.5.1 → 3.7.1
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/README.md +399 -633
- package/dist/analytics/CrossProjectAnalytics.js +65 -65
- package/dist/cli/index.js +255 -12
- package/dist/cli/index.js.map +1 -1
- package/dist/dashboard/tokens.js +173 -173
- package/dist/db/cloud.d.ts +1 -0
- package/dist/db/cloud.d.ts.map +1 -1
- package/dist/db/migrations.js +256 -256
- package/dist/db/turso-client.js +2 -2
- package/dist/db/upstash-client.d.ts +9 -0
- package/dist/db/upstash-client.d.ts.map +1 -1
- package/dist/db/upstash-client.js +11 -0
- package/dist/db/upstash-client.js.map +1 -1
- package/dist/eslint/rules/no-async-useeffect.js +6 -6
- package/dist/experts/ExpertVotePersistence.js +9 -9
- package/dist/hooks/auto-learning-hook.d.ts +48 -0
- package/dist/hooks/auto-learning-hook.d.ts.map +1 -0
- package/dist/hooks/auto-learning-hook.js +258 -0
- package/dist/hooks/auto-learning-hook.js.map +1 -0
- package/dist/hooks/cloud-post-tool-use.d.ts.map +1 -1
- package/dist/hooks/cloud-post-tool-use.js +72 -10
- package/dist/hooks/cloud-post-tool-use.js.map +1 -1
- package/dist/hooks/cloud-pre-tool-use.d.ts +12 -9
- package/dist/hooks/cloud-pre-tool-use.d.ts.map +1 -1
- package/dist/hooks/cloud-pre-tool-use.js +227 -99
- package/dist/hooks/cloud-pre-tool-use.js.map +1 -1
- package/dist/hooks/cloud-session-start.js +5 -5
- package/dist/hooks/fast-session-start.d.ts +24 -0
- package/dist/hooks/fast-session-start.d.ts.map +1 -0
- package/dist/hooks/fast-session-start.js +354 -0
- package/dist/hooks/fast-session-start.js.map +1 -0
- package/dist/hooks/resilient-hook-runner.d.ts +78 -0
- package/dist/hooks/resilient-hook-runner.d.ts.map +1 -0
- package/dist/hooks/resilient-hook-runner.js +201 -0
- package/dist/hooks/resilient-hook-runner.js.map +1 -0
- package/dist/hooks/session-end.js +14 -14
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -1
- package/dist/patterns/registry.js +90 -90
- package/dist/schema/codewiki-types.d.ts +10 -10
- package/dist/schema/docs-types.d.ts +8 -8
- package/dist/schema/ecosystem-types.d.ts +12 -12
- package/dist/services/BootstrapService.d.ts +123 -0
- package/dist/services/BootstrapService.d.ts.map +1 -0
- package/dist/services/BootstrapService.js +309 -0
- package/dist/services/BootstrapService.js.map +1 -0
- package/dist/services/CodeWikiIndexer.js +3 -3
- package/dist/services/ContextGenerator.js +7 -7
- package/dist/services/FeedbackCollector.js +11 -11
- package/dist/services/GitIntegration.js +9 -9
- package/dist/services/HookVerifier.js +70 -70
- package/dist/services/KnowledgeGapDetector.d.ts +122 -0
- package/dist/services/KnowledgeGapDetector.d.ts.map +1 -0
- package/dist/services/KnowledgeGapDetector.js +530 -0
- package/dist/services/KnowledgeGapDetector.js.map +1 -0
- package/dist/services/ProjectScaffold.d.ts.map +1 -1
- package/dist/services/ProjectScaffold.js +79 -78
- package/dist/services/ProjectScaffold.js.map +1 -1
- package/dist/services/auto-evolution-trigger.d.ts +101 -0
- package/dist/services/auto-evolution-trigger.d.ts.map +1 -0
- package/dist/services/auto-evolution-trigger.js +359 -0
- package/dist/services/auto-evolution-trigger.js.map +1 -0
- package/dist/services/cloud-memory-service.d.ts +101 -0
- package/dist/services/cloud-memory-service.d.ts.map +1 -0
- package/dist/services/cloud-memory-service.js +363 -0
- package/dist/services/cloud-memory-service.js.map +1 -0
- package/dist/services/index.d.ts +4 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +6 -0
- package/dist/services/index.js.map +1 -1
- package/dist/services/knowledge-graph.d.ts +121 -0
- package/dist/services/knowledge-graph.d.ts.map +1 -0
- package/dist/services/knowledge-graph.js +446 -0
- package/dist/services/knowledge-graph.js.map +1 -0
- package/dist/services/memory-keeper-client.d.ts +106 -0
- package/dist/services/memory-keeper-client.d.ts.map +1 -0
- package/dist/services/memory-keeper-client.js +319 -0
- package/dist/services/memory-keeper-client.js.map +1 -0
- package/dist/services/memory-router.d.ts +25 -0
- package/dist/services/memory-router.d.ts.map +1 -1
- package/dist/services/memory-router.js +236 -98
- package/dist/services/memory-router.js.map +1 -1
- package/dist/services/pattern-learning.d.ts +79 -0
- package/dist/services/pattern-learning.d.ts.map +1 -0
- package/dist/services/pattern-learning.js +312 -0
- package/dist/services/pattern-learning.js.map +1 -0
- package/dist/services/pattern-tracker.js +95 -95
- package/dist/services/semantic-search.js +2 -2
- package/dist/services/skill-learning-bridge.d.ts +100 -0
- package/dist/services/skill-learning-bridge.d.ts.map +1 -0
- package/dist/services/skill-learning-bridge.js +331 -0
- package/dist/services/skill-learning-bridge.js.map +1 -0
- package/dist/services/unified-memory-router.d.ts +123 -0
- package/dist/services/unified-memory-router.d.ts.map +1 -0
- package/dist/services/unified-memory-router.js +555 -0
- package/dist/services/unified-memory-router.js.map +1 -0
- package/package.json +124 -116
- package/standards/README.md +94 -50
- package/standards/experts/expert-routing.md +215 -215
- package/standards/general/code-quality.md +86 -86
- package/standards/general/ecosystem.md +243 -0
- package/standards/general/learning-loop.md +192 -0
- package/standards/general/memory-usage.md +205 -205
- package/standards/general/project-onboarding.md +339 -0
- package/standards/general/sync-workflow.md +235 -235
- package/standards/general/workflow.md +82 -82
- package/standards/hooks/mandatory-tracking.md +446 -446
- package/standards/infrastructure/cloud-database.md +287 -287
- package/standards/mcp/server-design.md +243 -243
- package/standards/mcp/tool-patterns.md +354 -354
- package/standards/skills/skill-structure.md +286 -286
- package/standards/skills/workflow-design.md +323 -323
- package/standards/tools/tool-design.md +297 -297
- package/templates/agents/architecture-expert.md +61 -61
- package/templates/agents/database-expert.md +62 -62
- package/templates/agents/documentation-expert.md +57 -57
- package/templates/agents/ecosystem-expert.md +104 -0
- package/templates/agents/memory-expert.md +88 -88
- package/templates/agents/performance-expert.md +61 -61
- package/templates/agents/security-expert.md +59 -59
- package/templates/agents/ux-expert.md +63 -63
- package/templates/agents/worker.md +75 -75
- package/templates/ai-skills/SKILL_TEMPLATE.md +55 -55
- package/templates/claude-settings.json +72 -72
- package/templates/commands/experts.md +138 -138
- package/templates/hooks/README.md +158 -158
- package/templates/hooks/project.config.json.template +77 -77
- package/templates/hooks/settings.local.json.template +57 -57
- package/templates/hooks.config.json +21 -0
- package/templates/memory-config.json +56 -56
- package/templates/memory-config.schema.json +212 -212
- package/templates/settings.json +58 -58
- package/templates/skills/continue.md +205 -205
- package/templates/workflows/business-improvement.md +264 -264
- package/templates/workflows/expert-review.md +153 -153
- package/templates/workflows/internal-app.md +245 -245
- package/templates/workflows/sync-docs.md +187 -187
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file BootstrapService - Project Initialization Orchestrator
|
|
3
|
+
* @description Coordinates the full bootstrap process for new CMP projects
|
|
4
|
+
*
|
|
5
|
+
* Bootstrap Phases:
|
|
6
|
+
* 1. SCAFFOLD - Create .claude/ directory structure, agents, commands, hooks
|
|
7
|
+
* 2. INDEX - Run CodeWikiIndexer to index project codebase
|
|
8
|
+
* 3. DOCS - Run DocsGenerator to create project documentation
|
|
9
|
+
* 4. SYNC - Fetch ecosystem patterns via CrossProjectSyncService
|
|
10
|
+
* 5. GAPS - Analyze knowledge gaps via KnowledgeGapDetector
|
|
11
|
+
*
|
|
12
|
+
* Features:
|
|
13
|
+
* - Parallel execution where possible
|
|
14
|
+
* - Progress reporting with callbacks
|
|
15
|
+
* - Resumable (can skip completed phases)
|
|
16
|
+
* - Per-phase error handling (failures don't block other phases)
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const bootstrap = new BootstrapService('/path/to/project')
|
|
21
|
+
* const result = await bootstrap.run({
|
|
22
|
+
* system: 'PANEL',
|
|
23
|
+
* onProgress: (phase, status) => console.log(`${phase}: ${status}`)
|
|
24
|
+
* })
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
import { type ProjectScanResult } from './ProjectScanner.js';
|
|
28
|
+
import { type ScaffoldResult } from './ProjectScaffold.js';
|
|
29
|
+
import { type IndexResult } from './CodeWikiIndexer.js';
|
|
30
|
+
import { type GenerateResult } from './DocsGenerator.js';
|
|
31
|
+
import { type GapAnalysis } from './KnowledgeGapDetector.js';
|
|
32
|
+
import type { DevSystem } from '../types/index.js';
|
|
33
|
+
export type BootstrapPhase = 'scan' | 'scaffold' | 'index' | 'docs' | 'sync' | 'gaps';
|
|
34
|
+
export interface BootstrapOptions {
|
|
35
|
+
/** System identifier (PANEL, SWARMSCALE, etc.) */
|
|
36
|
+
system: DevSystem;
|
|
37
|
+
/** Project name (defaults to detected from package.json) */
|
|
38
|
+
projectName?: string;
|
|
39
|
+
/** Which phases to run (defaults to all) */
|
|
40
|
+
phases?: BootstrapPhase[];
|
|
41
|
+
/** Force overwrite existing files */
|
|
42
|
+
force?: boolean;
|
|
43
|
+
/** Skip agents installation */
|
|
44
|
+
skipAgents?: boolean;
|
|
45
|
+
/** Skip commands installation */
|
|
46
|
+
skipCommands?: boolean;
|
|
47
|
+
/** Skip hooks installation */
|
|
48
|
+
skipHooks?: boolean;
|
|
49
|
+
/** Index depth for CodeWikiIndexer */
|
|
50
|
+
indexDepth?: 'quick' | 'standard' | 'thorough';
|
|
51
|
+
/** Progress callback */
|
|
52
|
+
onProgress?: (phase: BootstrapPhase, status: string, progress?: number) => void;
|
|
53
|
+
/** Verbose output */
|
|
54
|
+
verbose?: boolean;
|
|
55
|
+
}
|
|
56
|
+
export interface PhaseResult {
|
|
57
|
+
phase: BootstrapPhase;
|
|
58
|
+
success: boolean;
|
|
59
|
+
durationMs: number;
|
|
60
|
+
error?: string;
|
|
61
|
+
data?: unknown;
|
|
62
|
+
}
|
|
63
|
+
export interface BootstrapResult {
|
|
64
|
+
success: boolean;
|
|
65
|
+
projectPath: string;
|
|
66
|
+
system: DevSystem;
|
|
67
|
+
phases: PhaseResult[];
|
|
68
|
+
totalDurationMs: number;
|
|
69
|
+
scan?: ProjectScanResult;
|
|
70
|
+
scaffold?: ScaffoldResult;
|
|
71
|
+
index?: IndexResult;
|
|
72
|
+
docs?: GenerateResult;
|
|
73
|
+
gaps?: GapAnalysis;
|
|
74
|
+
summary: BootstrapSummary;
|
|
75
|
+
}
|
|
76
|
+
export interface BootstrapSummary {
|
|
77
|
+
filesCreated: number;
|
|
78
|
+
filesIndexed: number;
|
|
79
|
+
patternsImported: number;
|
|
80
|
+
knowledgeGaps: number;
|
|
81
|
+
recommendations: string[];
|
|
82
|
+
}
|
|
83
|
+
export declare class BootstrapService {
|
|
84
|
+
private projectPath;
|
|
85
|
+
private scanner;
|
|
86
|
+
private options?;
|
|
87
|
+
private scanResult?;
|
|
88
|
+
constructor(projectPath?: string);
|
|
89
|
+
/**
|
|
90
|
+
* Run the full bootstrap process
|
|
91
|
+
*/
|
|
92
|
+
run(options: BootstrapOptions): Promise<BootstrapResult>;
|
|
93
|
+
/**
|
|
94
|
+
* Run a single phase with error handling and timing
|
|
95
|
+
*/
|
|
96
|
+
private runPhase;
|
|
97
|
+
/**
|
|
98
|
+
* Report progress to callback and optionally console
|
|
99
|
+
*/
|
|
100
|
+
private reportProgress;
|
|
101
|
+
/**
|
|
102
|
+
* Calculate bootstrap summary
|
|
103
|
+
*/
|
|
104
|
+
private calculateSummary;
|
|
105
|
+
/**
|
|
106
|
+
* Print final summary
|
|
107
|
+
*/
|
|
108
|
+
private printSummary;
|
|
109
|
+
/**
|
|
110
|
+
* Logging helper
|
|
111
|
+
*/
|
|
112
|
+
private log;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Create a BootstrapService instance
|
|
116
|
+
*/
|
|
117
|
+
export declare function createBootstrapService(projectPath?: string): BootstrapService;
|
|
118
|
+
/**
|
|
119
|
+
* Convenience function to run bootstrap directly
|
|
120
|
+
*/
|
|
121
|
+
export declare function bootstrap(projectPath: string, options: BootstrapOptions): Promise<BootstrapResult>;
|
|
122
|
+
export default BootstrapService;
|
|
123
|
+
//# sourceMappingURL=BootstrapService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BootstrapService.d.ts","sourceRoot":"","sources":["../../src/services/BootstrapService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAAkB,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAC5E,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACxE,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAEvE,OAAO,EAAwB,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAClF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAMlD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;AAErF,MAAM,WAAW,gBAAgB;IAC/B,kDAAkD;IAClD,MAAM,EAAE,SAAS,CAAA;IACjB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,cAAc,EAAE,CAAA;IACzB,qCAAqC;IACrC,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,+BAA+B;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,iCAAiC;IACjC,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,8BAA8B;IAC9B,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,sCAAsC;IACtC,UAAU,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,UAAU,CAAA;IAC9C,wBAAwB;IACxB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,C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;IACH,OAAO,CAAC,gBAAgB;IAuCxB;;OAEG;IACH,OAAO,CAAC,YAAY;IA6CpB;;OAEG;IACH,OAAO,CAAC,GAAG;CAmBZ;AAMD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAE7E;AAED;;GAEG;AACH,wBAAsB,SAAS,CAC7B,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,CAG1B;AAED,eAAe,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file BootstrapService - Project Initialization Orchestrator
|
|
3
|
+
* @description Coordinates the full bootstrap process for new CMP projects
|
|
4
|
+
*
|
|
5
|
+
* Bootstrap Phases:
|
|
6
|
+
* 1. SCAFFOLD - Create .claude/ directory structure, agents, commands, hooks
|
|
7
|
+
* 2. INDEX - Run CodeWikiIndexer to index project codebase
|
|
8
|
+
* 3. DOCS - Run DocsGenerator to create project documentation
|
|
9
|
+
* 4. SYNC - Fetch ecosystem patterns via CrossProjectSyncService
|
|
10
|
+
* 5. GAPS - Analyze knowledge gaps via KnowledgeGapDetector
|
|
11
|
+
*
|
|
12
|
+
* Features:
|
|
13
|
+
* - Parallel execution where possible
|
|
14
|
+
* - Progress reporting with callbacks
|
|
15
|
+
* - Resumable (can skip completed phases)
|
|
16
|
+
* - Per-phase error handling (failures don't block other phases)
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const bootstrap = new BootstrapService('/path/to/project')
|
|
21
|
+
* const result = await bootstrap.run({
|
|
22
|
+
* system: 'PANEL',
|
|
23
|
+
* onProgress: (phase, status) => console.log(`${phase}: ${status}`)
|
|
24
|
+
* })
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
import chalk from 'chalk';
|
|
28
|
+
import { ProjectScanner } from './ProjectScanner.js';
|
|
29
|
+
import { ProjectScaffold } from './ProjectScaffold.js';
|
|
30
|
+
import { CodeWikiIndexer } from './CodeWikiIndexer.js';
|
|
31
|
+
import { DocsGenerator } from './DocsGenerator.js';
|
|
32
|
+
import { CrossProjectSyncService } from './cross-project-sync.js';
|
|
33
|
+
import { KnowledgeGapDetector } from './KnowledgeGapDetector.js';
|
|
34
|
+
// =============================================================================
|
|
35
|
+
// Bootstrap Service
|
|
36
|
+
// =============================================================================
|
|
37
|
+
export class BootstrapService {
|
|
38
|
+
projectPath;
|
|
39
|
+
scanner;
|
|
40
|
+
options;
|
|
41
|
+
scanResult;
|
|
42
|
+
constructor(projectPath = process.cwd()) {
|
|
43
|
+
this.projectPath = projectPath;
|
|
44
|
+
this.scanner = new ProjectScanner(projectPath);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Run the full bootstrap process
|
|
48
|
+
*/
|
|
49
|
+
async run(options) {
|
|
50
|
+
this.options = options;
|
|
51
|
+
const startTime = Date.now();
|
|
52
|
+
const phases = [];
|
|
53
|
+
const allPhases = options.phases || ['scan', 'scaffold', 'index', 'docs', 'sync', 'gaps'];
|
|
54
|
+
// Results storage
|
|
55
|
+
let scaffoldResult;
|
|
56
|
+
let indexResult;
|
|
57
|
+
let docsResult;
|
|
58
|
+
let gapAnalysis;
|
|
59
|
+
this.log('header', `Bootstrap: ${options.system}`);
|
|
60
|
+
this.log('info', `Project: ${this.projectPath}`);
|
|
61
|
+
this.log('info', `Phases: ${allPhases.join(' → ')}`);
|
|
62
|
+
console.log();
|
|
63
|
+
// Phase 1: SCAN
|
|
64
|
+
if (allPhases.includes('scan')) {
|
|
65
|
+
const result = await this.runPhase('scan', async () => {
|
|
66
|
+
this.scanResult = await this.scanner.scan();
|
|
67
|
+
return this.scanResult;
|
|
68
|
+
});
|
|
69
|
+
phases.push(result);
|
|
70
|
+
}
|
|
71
|
+
// Phase 2: SCAFFOLD
|
|
72
|
+
if (allPhases.includes('scaffold')) {
|
|
73
|
+
const result = await this.runPhase('scaffold', async () => {
|
|
74
|
+
const scaffold = new ProjectScaffold(this.projectPath);
|
|
75
|
+
scaffoldResult = await scaffold.scaffold({
|
|
76
|
+
system: options.system,
|
|
77
|
+
projectName: options.projectName || this.scanResult?.name,
|
|
78
|
+
force: options.force,
|
|
79
|
+
skipAgents: options.skipAgents,
|
|
80
|
+
skipHooks: options.skipHooks,
|
|
81
|
+
skipCommands: options.skipCommands,
|
|
82
|
+
});
|
|
83
|
+
return scaffoldResult;
|
|
84
|
+
});
|
|
85
|
+
phases.push(result);
|
|
86
|
+
}
|
|
87
|
+
// Phase 3: INDEX (can run in parallel with docs if scaffold done)
|
|
88
|
+
if (allPhases.includes('index')) {
|
|
89
|
+
const result = await this.runPhase('index', async () => {
|
|
90
|
+
const indexer = new CodeWikiIndexer(options.system, this.projectPath);
|
|
91
|
+
indexResult = await indexer.index({
|
|
92
|
+
projectId: options.system,
|
|
93
|
+
rootDir: this.projectPath,
|
|
94
|
+
depth: options.indexDepth || 'standard',
|
|
95
|
+
});
|
|
96
|
+
return indexResult;
|
|
97
|
+
});
|
|
98
|
+
phases.push(result);
|
|
99
|
+
}
|
|
100
|
+
// Phase 4: DOCS (depends on index)
|
|
101
|
+
if (allPhases.includes('docs')) {
|
|
102
|
+
const result = await this.runPhase('docs', async () => {
|
|
103
|
+
const generator = new DocsGenerator({
|
|
104
|
+
system: options.system,
|
|
105
|
+
generateSimpleExplanation: true,
|
|
106
|
+
});
|
|
107
|
+
docsResult = await generator.generate();
|
|
108
|
+
return docsResult;
|
|
109
|
+
});
|
|
110
|
+
phases.push(result);
|
|
111
|
+
}
|
|
112
|
+
// Phase 5: SYNC (ecosystem patterns - can run independently)
|
|
113
|
+
if (allPhases.includes('sync')) {
|
|
114
|
+
const result = await this.runPhase('sync', async () => {
|
|
115
|
+
const syncService = new CrossProjectSyncService();
|
|
116
|
+
const patterns = await syncService.getEcosystemPatterns();
|
|
117
|
+
const shared = await syncService.getSharedMemories();
|
|
118
|
+
return {
|
|
119
|
+
patternsFound: patterns.length,
|
|
120
|
+
sharedMemories: shared.length,
|
|
121
|
+
systems: [...new Set(shared.map(m => m.system))],
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
phases.push(result);
|
|
125
|
+
}
|
|
126
|
+
// Phase 6: GAPS (knowledge gap analysis)
|
|
127
|
+
if (allPhases.includes('gaps')) {
|
|
128
|
+
const result = await this.runPhase('gaps', async () => {
|
|
129
|
+
const detector = new KnowledgeGapDetector(options.system, this.projectPath);
|
|
130
|
+
gapAnalysis = await detector.analyze();
|
|
131
|
+
return gapAnalysis;
|
|
132
|
+
});
|
|
133
|
+
phases.push(result);
|
|
134
|
+
}
|
|
135
|
+
// Calculate summary
|
|
136
|
+
const summary = this.calculateSummary(phases, scaffoldResult, indexResult, gapAnalysis);
|
|
137
|
+
// Final output
|
|
138
|
+
const totalDurationMs = Date.now() - startTime;
|
|
139
|
+
const success = phases.every(p => p.success);
|
|
140
|
+
this.printSummary(summary, phases, totalDurationMs);
|
|
141
|
+
return {
|
|
142
|
+
success,
|
|
143
|
+
projectPath: this.projectPath,
|
|
144
|
+
system: options.system,
|
|
145
|
+
phases,
|
|
146
|
+
totalDurationMs,
|
|
147
|
+
scan: this.scanResult,
|
|
148
|
+
scaffold: scaffoldResult,
|
|
149
|
+
index: indexResult,
|
|
150
|
+
docs: docsResult,
|
|
151
|
+
gaps: gapAnalysis,
|
|
152
|
+
summary,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Run a single phase with error handling and timing
|
|
157
|
+
*/
|
|
158
|
+
async runPhase(phase, fn) {
|
|
159
|
+
const start = Date.now();
|
|
160
|
+
this.reportProgress(phase, 'starting');
|
|
161
|
+
try {
|
|
162
|
+
const data = await fn();
|
|
163
|
+
const durationMs = Date.now() - start;
|
|
164
|
+
this.reportProgress(phase, `completed (${durationMs}ms)`);
|
|
165
|
+
return {
|
|
166
|
+
phase,
|
|
167
|
+
success: true,
|
|
168
|
+
durationMs,
|
|
169
|
+
data,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
const durationMs = Date.now() - start;
|
|
174
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
175
|
+
this.reportProgress(phase, `failed: ${errorMessage}`);
|
|
176
|
+
return {
|
|
177
|
+
phase,
|
|
178
|
+
success: false,
|
|
179
|
+
durationMs,
|
|
180
|
+
error: errorMessage,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Report progress to callback and optionally console
|
|
186
|
+
*/
|
|
187
|
+
reportProgress(phase, status, progress) {
|
|
188
|
+
const phaseLabels = {
|
|
189
|
+
scan: '🔍 Scan',
|
|
190
|
+
scaffold: '🏗️ Scaffold',
|
|
191
|
+
index: '📑 Index',
|
|
192
|
+
docs: '📖 Docs',
|
|
193
|
+
sync: '🔄 Sync',
|
|
194
|
+
gaps: '🔎 Gaps',
|
|
195
|
+
};
|
|
196
|
+
if (this.options?.verbose) {
|
|
197
|
+
console.log(chalk.dim(` ${phaseLabels[phase]}: ${status}`));
|
|
198
|
+
}
|
|
199
|
+
this.options?.onProgress?.(phase, status, progress);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Calculate bootstrap summary
|
|
203
|
+
*/
|
|
204
|
+
calculateSummary(phases, scaffold, index, gaps) {
|
|
205
|
+
const recommendations = [];
|
|
206
|
+
// Add recommendations based on results
|
|
207
|
+
if (gaps?.gaps) {
|
|
208
|
+
if (gaps.gaps.length > 5) {
|
|
209
|
+
recommendations.push('Consider running /knowledge to fill knowledge gaps');
|
|
210
|
+
}
|
|
211
|
+
if (gaps.gaps.some(g => g.severity === 'critical')) {
|
|
212
|
+
recommendations.push('Critical knowledge gaps detected - review immediately');
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (index?.stats?.errorsEncountered && index.stats.errorsEncountered > 0) {
|
|
216
|
+
recommendations.push(`${index.stats.errorsEncountered} files had indexing errors - review logs`);
|
|
217
|
+
}
|
|
218
|
+
const failedPhases = phases.filter(p => !p.success);
|
|
219
|
+
if (failedPhases.length > 0) {
|
|
220
|
+
recommendations.push(`Re-run failed phases: ${failedPhases.map(p => p.phase).join(', ')}`);
|
|
221
|
+
}
|
|
222
|
+
// Always recommend running experts
|
|
223
|
+
recommendations.push('Run /experts on critical files for code review');
|
|
224
|
+
return {
|
|
225
|
+
filesCreated: scaffold?.created?.length ?? 0,
|
|
226
|
+
filesIndexed: index?.stats?.filesIndexed ?? 0,
|
|
227
|
+
patternsImported: 0, // Would need sync result
|
|
228
|
+
knowledgeGaps: gaps?.gaps?.length ?? 0,
|
|
229
|
+
recommendations,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Print final summary
|
|
234
|
+
*/
|
|
235
|
+
printSummary(summary, phases, totalDurationMs) {
|
|
236
|
+
console.log();
|
|
237
|
+
console.log(chalk.cyan('─'.repeat(50)));
|
|
238
|
+
console.log(chalk.cyan('📊 Bootstrap Summary'));
|
|
239
|
+
console.log();
|
|
240
|
+
// Phase results
|
|
241
|
+
for (const phase of phases) {
|
|
242
|
+
const icon = phase.success ? chalk.green('✓') : chalk.red('✗');
|
|
243
|
+
const time = chalk.dim(`(${phase.durationMs}ms)`);
|
|
244
|
+
console.log(` ${icon} ${phase.phase} ${time}`);
|
|
245
|
+
if (phase.error) {
|
|
246
|
+
console.log(chalk.red(` └─ ${phase.error}`));
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
console.log();
|
|
250
|
+
// Stats
|
|
251
|
+
console.log(chalk.white(' Files created:'), chalk.cyan(summary.filesCreated));
|
|
252
|
+
console.log(chalk.white(' Files indexed:'), chalk.cyan(summary.filesIndexed));
|
|
253
|
+
console.log(chalk.white(' Knowledge gaps:'), summary.knowledgeGaps > 0
|
|
254
|
+
? chalk.yellow(summary.knowledgeGaps)
|
|
255
|
+
: chalk.green(summary.knowledgeGaps));
|
|
256
|
+
console.log();
|
|
257
|
+
// Recommendations
|
|
258
|
+
if (summary.recommendations.length > 0) {
|
|
259
|
+
console.log(chalk.white(' Recommendations:'));
|
|
260
|
+
for (const rec of summary.recommendations) {
|
|
261
|
+
console.log(chalk.dim(` • ${rec}`));
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
console.log();
|
|
265
|
+
console.log(chalk.cyan('─'.repeat(50)));
|
|
266
|
+
console.log(chalk.dim(` Total time: ${(totalDurationMs / 1000).toFixed(2)}s`));
|
|
267
|
+
console.log();
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Logging helper
|
|
271
|
+
*/
|
|
272
|
+
log(type, message) {
|
|
273
|
+
switch (type) {
|
|
274
|
+
case 'header':
|
|
275
|
+
console.log(chalk.cyan(`\n🚀 ${message}\n`));
|
|
276
|
+
break;
|
|
277
|
+
case 'info':
|
|
278
|
+
console.log(chalk.dim(` ${message}`));
|
|
279
|
+
break;
|
|
280
|
+
case 'success':
|
|
281
|
+
console.log(chalk.green(` ✓ ${message}`));
|
|
282
|
+
break;
|
|
283
|
+
case 'error':
|
|
284
|
+
console.log(chalk.red(` ✗ ${message}`));
|
|
285
|
+
break;
|
|
286
|
+
case 'warn':
|
|
287
|
+
console.log(chalk.yellow(` ⚠ ${message}`));
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
// =============================================================================
|
|
293
|
+
// Factory Function
|
|
294
|
+
// =============================================================================
|
|
295
|
+
/**
|
|
296
|
+
* Create a BootstrapService instance
|
|
297
|
+
*/
|
|
298
|
+
export function createBootstrapService(projectPath) {
|
|
299
|
+
return new BootstrapService(projectPath);
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Convenience function to run bootstrap directly
|
|
303
|
+
*/
|
|
304
|
+
export async function bootstrap(projectPath, options) {
|
|
305
|
+
const service = new BootstrapService(projectPath);
|
|
306
|
+
return service.run(options);
|
|
307
|
+
}
|
|
308
|
+
export default BootstrapService;
|
|
309
|
+
//# sourceMappingURL=BootstrapService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BootstrapService.js","sourceRoot":"","sources":["../../src/services/BootstrapService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,cAAc,EAA0B,MAAM,qBAAqB,CAAA;AAC5E,OAAO,EAAE,eAAe,EAAuB,MAAM,sBAAsB,CAAA;AAC3E,OAAO,EAAE,eAAe,EAAoB,MAAM,sBAAsB,CAAA;AACxE,OAAO,EAAE,aAAa,EAAuB,MAAM,oBAAoB,CAAA;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,EAAE,oBAAoB,EAAoB,MAAM,2BAA2B,CAAA;AA8DlF,gFAAgF;AAChF,oBAAoB;AACpB,gFAAgF;AAEhF,MAAM,OAAO,gBAAgB;IACnB,WAAW,CAAQ;IACnB,OAAO,CAAgB;IACvB,OAAO,CAAmB;IAC1B,UAAU,CAAoB;IAEtC,YAAY,cAAsB,OAAO,CAAC,GAAG,EAAE;QAC7C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,OAAO,GAAG,IAAI,cAAc,CAAC,WAAW,CAAC,CAAA;IAChD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CAAC,OAAyB;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAC5B,MAAM,MAAM,GAAkB,EAAE,CAAA;QAChC,MAAM,SAAS,GAAqB,OAAO,CAAC,MAAM,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;QAE3G,kBAAkB;QAClB,I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BAC3C,MAAK;QACT,CAAC;IACH,CAAC;CACF;AAED,gFAAgF;AAChF,mBAAmB;AACnB,gFAAgF;AAEhF;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,WAAoB;IACzD,OAAO,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAA;AAC1C,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,WAAmB,EACnB,OAAyB;IAEzB,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAA;IACjD,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;AAC7B,CAAC;AAED,eAAe,gBAAgB,CAAA"}
|
|
@@ -705,7 +705,7 @@ export class CodeWikiIndexer {
|
|
|
705
705
|
// Build insert statements for metadata
|
|
706
706
|
for (const item of collected.metadata) {
|
|
707
707
|
statements.push({
|
|
708
|
-
sql: `INSERT INTO items (id, type, status, system, content, created_at, updated_at)
|
|
708
|
+
sql: `INSERT INTO items (id, type, status, system, content, created_at, updated_at)
|
|
709
709
|
VALUES (?, ?, ?, ?, ?, ?, ?)`,
|
|
710
710
|
args: [item.id, 'file_metadata', 'active', this.system, JSON.stringify(item.content), now, now],
|
|
711
711
|
});
|
|
@@ -713,7 +713,7 @@ export class CodeWikiIndexer {
|
|
|
713
713
|
// Build insert statements for structures
|
|
714
714
|
for (const item of collected.structures) {
|
|
715
715
|
statements.push({
|
|
716
|
-
sql: `INSERT INTO items (id, type, status, system, content, created_at, updated_at)
|
|
716
|
+
sql: `INSERT INTO items (id, type, status, system, content, created_at, updated_at)
|
|
717
717
|
VALUES (?, ?, ?, ?, ?, ?, ?)`,
|
|
718
718
|
args: [item.id, 'code_structure', 'active', this.system, JSON.stringify(item.content), now, now],
|
|
719
719
|
});
|
|
@@ -721,7 +721,7 @@ export class CodeWikiIndexer {
|
|
|
721
721
|
// Build insert statements for dependencies
|
|
722
722
|
for (const item of collected.dependencies) {
|
|
723
723
|
statements.push({
|
|
724
|
-
sql: `INSERT INTO items (id, type, status, system, content, created_at, updated_at)
|
|
724
|
+
sql: `INSERT INTO items (id, type, status, system, content, created_at, updated_at)
|
|
725
725
|
VALUES (?, ?, ?, ?, ?, ?, ?)`,
|
|
726
726
|
args: [item.id, 'code_dependency', 'active', this.system, JSON.stringify(item.content), now, now],
|
|
727
727
|
});
|
|
@@ -42,13 +42,13 @@ export class ContextGenerator {
|
|
|
42
42
|
if (content.includes(splitMarker)) {
|
|
43
43
|
content = content.split(splitMarker)[0];
|
|
44
44
|
}
|
|
45
|
-
const freshContext = `
|
|
46
|
-
${splitMarker}
|
|
47
|
-
### Active Tasks
|
|
48
|
-
${tasksMd || "- No active tasks."}
|
|
49
|
-
|
|
50
|
-
### Recent Memories
|
|
51
|
-
${memoriesMd || "- No recent memories."}
|
|
45
|
+
const freshContext = `
|
|
46
|
+
${splitMarker}
|
|
47
|
+
### Active Tasks
|
|
48
|
+
${tasksMd || "- No active tasks."}
|
|
49
|
+
|
|
50
|
+
### Recent Memories
|
|
51
|
+
${memoriesMd || "- No recent memories."}
|
|
52
52
|
`;
|
|
53
53
|
await fs.writeFile(filePath, content + freshContext, "utf-8");
|
|
54
54
|
return true;
|
|
@@ -130,10 +130,10 @@ class FeedbackCollectorService {
|
|
|
130
130
|
try {
|
|
131
131
|
const db = turso.getClient();
|
|
132
132
|
const result = await db.execute({
|
|
133
|
-
sql: `SELECT id, content FROM items
|
|
134
|
-
WHERE system = ? AND type = 'memory' AND status = 'active'
|
|
135
|
-
ORDER BY COALESCE(json_extract(content, '$.feedbackScore'), 0.5) DESC,
|
|
136
|
-
COALESCE(json_extract(content, '$.accessCount'), 0) DESC
|
|
133
|
+
sql: `SELECT id, content FROM items
|
|
134
|
+
WHERE system = ? AND type = 'memory' AND status = 'active'
|
|
135
|
+
ORDER BY COALESCE(json_extract(content, '$.feedbackScore'), 0.5) DESC,
|
|
136
|
+
COALESCE(json_extract(content, '$.accessCount'), 0) DESC
|
|
137
137
|
LIMIT ?`,
|
|
138
138
|
args: [system, limit]
|
|
139
139
|
});
|
|
@@ -161,10 +161,10 @@ class FeedbackCollectorService {
|
|
|
161
161
|
try {
|
|
162
162
|
const db = turso.getClient();
|
|
163
163
|
const result = await db.execute({
|
|
164
|
-
sql: `SELECT id, content FROM items
|
|
165
|
-
WHERE system = ? AND type = 'memory' AND status = 'active'
|
|
166
|
-
AND COALESCE(json_extract(content, '$.feedbackScore'), 0.5) < ?
|
|
167
|
-
ORDER BY json_extract(content, '$.feedbackScore') ASC
|
|
164
|
+
sql: `SELECT id, content FROM items
|
|
165
|
+
WHERE system = ? AND type = 'memory' AND status = 'active'
|
|
166
|
+
AND COALESCE(json_extract(content, '$.feedbackScore'), 0.5) < ?
|
|
167
|
+
ORDER BY json_extract(content, '$.feedbackScore') ASC
|
|
168
168
|
LIMIT ?`,
|
|
169
169
|
args: [system, threshold, limit]
|
|
170
170
|
});
|
|
@@ -193,9 +193,9 @@ class FeedbackCollectorService {
|
|
|
193
193
|
try {
|
|
194
194
|
const db = turso.getClient();
|
|
195
195
|
const result = await db.execute({
|
|
196
|
-
sql: `UPDATE items SET status = 'archived', updated_at = datetime('now')
|
|
197
|
-
WHERE system = ? AND type = 'memory' AND status = 'active'
|
|
198
|
-
AND COALESCE(json_extract(content, '$.feedbackScore'), 0.5) < ?
|
|
196
|
+
sql: `UPDATE items SET status = 'archived', updated_at = datetime('now')
|
|
197
|
+
WHERE system = ? AND type = 'memory' AND status = 'active'
|
|
198
|
+
AND COALESCE(json_extract(content, '$.feedbackScore'), 0.5) < ?
|
|
199
199
|
AND created_at < datetime('now', '-' || ? || ' days')`,
|
|
200
200
|
args: [system, threshold, minAge]
|
|
201
201
|
});
|
|
@@ -325,15 +325,15 @@ export class GitIntegrationService {
|
|
|
325
325
|
const yaml = Object.entries(frontmatter)
|
|
326
326
|
.map(([k, v]) => `${k}: ${JSON.stringify(v)}`)
|
|
327
327
|
.join('\n');
|
|
328
|
-
return `---
|
|
329
|
-
${yaml}
|
|
330
|
-
---
|
|
331
|
-
|
|
332
|
-
# ${content.title}
|
|
333
|
-
|
|
334
|
-
${content.body ?? ''}
|
|
335
|
-
|
|
336
|
-
${content.relatedFiles?.length ? `\n## Related Files\n\n${content.relatedFiles.map(f => `- ${f}`).join('\n')}` : ''}
|
|
328
|
+
return `---
|
|
329
|
+
${yaml}
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
# ${content.title}
|
|
333
|
+
|
|
334
|
+
${content.body ?? ''}
|
|
335
|
+
|
|
336
|
+
${content.relatedFiles?.length ? `\n## Related Files\n\n${content.relatedFiles.map(f => `- ${f}`).join('\n')}` : ''}
|
|
337
337
|
`;
|
|
338
338
|
}
|
|
339
339
|
parseMemoryFile(content) {
|