@weavelogic/knowledge-graph-agent 0.11.2 → 0.11.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-orchestrator.d.ts","sourceRoot":"","sources":["../../src/cultivation/migration-orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAWH;;GAEG;AACH,UAAU,gBAAgB;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACpC,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,UAAU,gBAAgB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,UAAU,oBAAoB;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,UAAU,cAAc;IACtB,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,eAAe,EAAE,MAAM,EAAE,CAAC;KAC3B,CAAC;IACF,IAAI,EAAE,gBAAgB,EAAE,CAAC;IACzB,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,WAAW,EAAE,oBAAoB,EAAE,CAAC;CACrC;AAaD;;GAEG;AACH,UAAU,eAAe;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,M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;IA6B5B;;OAEG;YACW,eAAe;IA6B7B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAuF7B;;OAEG;IACH,OAAO,CAAC,qBAAqB;
|
|
1
|
+
{"version":3,"file":"migration-orchestrator.d.ts","sourceRoot":"","sources":["../../src/cultivation/migration-orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAWH;;GAEG;AACH,UAAU,gBAAgB;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACpC,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,UAAU,gBAAgB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,UAAU,oBAAoB;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,UAAU,cAAc;IACtB,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,eAAe,EAAE,MAAM,EAAE,CAAC;KAC3B,CAAC;IACF,IAAI,EAAE,gBAAgB,EAAE,CAAC;IACzB,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,WAAW,EAAE,oBAAoB,EAAE,CAAC;CACrC;AAaD;;GAEG;AACH,UAAU,eAAe;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE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6B7B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAuF7B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAuE7B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAwC9B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAuF9B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IA2B7B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAgC9B;;OAEG;YACW,YAAY;IA4B1B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAwCxB;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAWzB;;OAEG;YACW,MAAM;IAoDpB;;OAEG;YACW,oBAAoB;IA+FlC;;OAEG;IACH,OAAO,CAAC,cAAc;IAmBtB;;OAEG;IACH,OAAO,CAAC,YAAY;IAapB;;OAEG;YACW,cAAc;IAM5B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA+BxB;;OAEG;IACH,OAAO,CAAC,aAAa;IAerB;;OAEG;IACH,OAAO,CAAC,GAAG;CAQZ;AAED,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -307,8 +307,8 @@ class MigrationOrchestrator {
|
|
|
307
307
|
agents.push({
|
|
308
308
|
name: "Gap Filler - High Priority",
|
|
309
309
|
type: "gap-filler",
|
|
310
|
-
task: "Fill high-priority documentation gaps with comprehensive content",
|
|
311
|
-
context: this.buildGapFillerContext(highPriorityGaps, docsContext),
|
|
310
|
+
task: "Fill high-priority documentation gaps with comprehensive, project-specific content",
|
|
311
|
+
context: this.buildGapFillerContext(highPriorityGaps, docsContext, analysis),
|
|
312
312
|
outputFile: "gap-implementations.md"
|
|
313
313
|
});
|
|
314
314
|
}
|
|
@@ -317,8 +317,8 @@ class MigrationOrchestrator {
|
|
|
317
317
|
agents.push({
|
|
318
318
|
name: "Gap Filler - Medium Priority",
|
|
319
319
|
type: "gap-filler",
|
|
320
|
-
task: "Fill medium-priority documentation gaps",
|
|
321
|
-
context: this.buildGapFillerContext(mediumPriorityGaps, docsContext)
|
|
320
|
+
task: "Fill medium-priority documentation gaps with project-specific content",
|
|
321
|
+
context: this.buildGapFillerContext(mediumPriorityGaps, docsContext, analysis)
|
|
322
322
|
});
|
|
323
323
|
}
|
|
324
324
|
const questionsByCategory = /* @__PURE__ */ new Map();
|
|
@@ -347,8 +347,8 @@ class MigrationOrchestrator {
|
|
|
347
347
|
agents.push({
|
|
348
348
|
name: "MOC Builder",
|
|
349
349
|
type: "moc-builder",
|
|
350
|
-
task: "Populate empty MOC (Map of Content) files with
|
|
351
|
-
context: this.buildMOCBuilderContext(mocGaps, docsContext)
|
|
350
|
+
task: "Populate empty MOC (Map of Content) files with project-specific structure and links",
|
|
351
|
+
context: this.buildMOCBuilderContext(mocGaps, docsContext, analysis)
|
|
352
352
|
});
|
|
353
353
|
}
|
|
354
354
|
if (analysis.connections.length > 0) {
|
|
@@ -371,8 +371,44 @@ class MigrationOrchestrator {
|
|
|
371
371
|
/**
|
|
372
372
|
* Build context for gap filler agent
|
|
373
373
|
*/
|
|
374
|
-
buildGapFillerContext(gaps, docsContext) {
|
|
375
|
-
let context = "##
|
|
374
|
+
buildGapFillerContext(gaps, docsContext, analysis) {
|
|
375
|
+
let context = "## Project Context\n\n";
|
|
376
|
+
if (analysis.vision.purpose) {
|
|
377
|
+
context += `### Project Purpose
|
|
378
|
+
${analysis.vision.purpose}
|
|
379
|
+
|
|
380
|
+
`;
|
|
381
|
+
}
|
|
382
|
+
if (analysis.vision.goals.length > 0) {
|
|
383
|
+
context += `### Key Goals
|
|
384
|
+
`;
|
|
385
|
+
for (const goal of analysis.vision.goals.slice(0, 5)) {
|
|
386
|
+
context += `- ${goal}
|
|
387
|
+
`;
|
|
388
|
+
}
|
|
389
|
+
context += "\n";
|
|
390
|
+
}
|
|
391
|
+
context += "## Key Technical Documentation\n\n";
|
|
392
|
+
const keyDocPatterns = [
|
|
393
|
+
"test_strategy",
|
|
394
|
+
"technical",
|
|
395
|
+
"architecture",
|
|
396
|
+
"wasm",
|
|
397
|
+
"rust",
|
|
398
|
+
"original_spec",
|
|
399
|
+
"integration",
|
|
400
|
+
"primitives",
|
|
401
|
+
"requirements"
|
|
402
|
+
];
|
|
403
|
+
for (const [docPath, docContent] of docsContext) {
|
|
404
|
+
const lowerPath = docPath.toLowerCase();
|
|
405
|
+
if (keyDocPatterns.some((pattern) => lowerPath.includes(pattern))) {
|
|
406
|
+
context += `### ${docPath}
|
|
407
|
+
`;
|
|
408
|
+
context += docContent.slice(0, 4e3) + "\n\n";
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
context += "## Documentation Gaps to Fill\n\n";
|
|
376
412
|
for (const gap of gaps) {
|
|
377
413
|
context += `### ${gap.section}
|
|
378
414
|
`;
|
|
@@ -398,12 +434,15 @@ class MigrationOrchestrator {
|
|
|
398
434
|
context += "\n---\n\n";
|
|
399
435
|
}
|
|
400
436
|
context += "\n## Instructions\n";
|
|
437
|
+
context += "CRITICAL: Use the project context and technical documentation above to fill each gap.\n";
|
|
438
|
+
context += "Do NOT generate generic placeholder content. Use the ACTUAL project details.\n\n";
|
|
401
439
|
context += "For each gap, create comprehensive documentation that:\n";
|
|
402
|
-
context += "1. Addresses the specific issue
|
|
403
|
-
context += "2.
|
|
404
|
-
context += "3.
|
|
405
|
-
context += "4.
|
|
406
|
-
context += "5.
|
|
440
|
+
context += "1. Addresses the specific issue using REAL project details from the context above\n";
|
|
441
|
+
context += "2. References specific technologies, architectures, and implementations mentioned in the technical docs\n";
|
|
442
|
+
context += "3. Follows the existing documentation style\n";
|
|
443
|
+
context += "4. Includes proper wiki-links [[like-this]] to existing documents\n";
|
|
444
|
+
context += "5. Has appropriate frontmatter (title, type, tags)\n";
|
|
445
|
+
context += "6. Contains concrete, project-specific information - NOT generic placeholders\n";
|
|
407
446
|
return context;
|
|
408
447
|
}
|
|
409
448
|
/**
|
|
@@ -453,8 +492,24 @@ ${q.question}
|
|
|
453
492
|
/**
|
|
454
493
|
* Build context for MOC builder agent
|
|
455
494
|
*/
|
|
456
|
-
buildMOCBuilderContext(gaps, docsContext) {
|
|
457
|
-
let context = "##
|
|
495
|
+
buildMOCBuilderContext(gaps, docsContext, analysis) {
|
|
496
|
+
let context = "## Project Context\n\n";
|
|
497
|
+
if (analysis.vision.purpose) {
|
|
498
|
+
context += `### Project Purpose
|
|
499
|
+
${analysis.vision.purpose}
|
|
500
|
+
|
|
501
|
+
`;
|
|
502
|
+
}
|
|
503
|
+
if (analysis.vision.goals.length > 0) {
|
|
504
|
+
context += `### Key Goals
|
|
505
|
+
`;
|
|
506
|
+
for (const goal of analysis.vision.goals.slice(0, 5)) {
|
|
507
|
+
context += `- ${goal}
|
|
508
|
+
`;
|
|
509
|
+
}
|
|
510
|
+
context += "\n";
|
|
511
|
+
}
|
|
512
|
+
context += "## MOC Files to Populate\n\n";
|
|
458
513
|
const mocFiles = Array.from(docsContext.keys()).filter(
|
|
459
514
|
(k) => k.includes("_MOC.md") || k.includes("MOC.md")
|
|
460
515
|
);
|
|
@@ -486,14 +541,32 @@ ${q.question}
|
|
|
486
541
|
const docsInDir = Array.from(docsContext.keys()).filter((k) => dirname(k) === dir);
|
|
487
542
|
context += `- ${dir}/ (${docsInDir.length} docs)
|
|
488
543
|
`;
|
|
544
|
+
for (const doc of docsInDir.slice(0, 10)) {
|
|
545
|
+
context += ` - ${basename(doc)}
|
|
546
|
+
`;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
context += "\n### Key Technical Documentation (for reference)\n";
|
|
550
|
+
const keyDocs = Array.from(docsContext.entries()).filter(([path]) => {
|
|
551
|
+
const lower = path.toLowerCase();
|
|
552
|
+
return lower.includes("test_strategy") || lower.includes("wasm") || lower.includes("architecture") || lower.includes("original_spec");
|
|
553
|
+
}).slice(0, 3);
|
|
554
|
+
for (const [path, content] of keyDocs) {
|
|
555
|
+
context += `
|
|
556
|
+
#### ${path}
|
|
557
|
+
`;
|
|
558
|
+
context += content.slice(0, 2e3) + "\n";
|
|
489
559
|
}
|
|
490
560
|
context += "\n## Instructions\n";
|
|
561
|
+
context += "CRITICAL: Create MOCs that reflect the ACTUAL project content, not generic placeholders.\n";
|
|
562
|
+
context += "Use the project context and technical documentation above.\n\n";
|
|
491
563
|
context += "For each empty/stub MOC file:\n";
|
|
492
|
-
context += "1. Create a proper introduction
|
|
564
|
+
context += "1. Create a proper introduction describing what the section covers IN THIS PROJECT\n";
|
|
493
565
|
context += "2. List all documents in that directory with [[wiki-links]]\n";
|
|
494
566
|
context += "3. Organize by subcategory if applicable\n";
|
|
495
|
-
context += "4. Add brief descriptions for each linked document\n";
|
|
567
|
+
context += "4. Add brief, PROJECT-SPECIFIC descriptions for each linked document\n";
|
|
496
568
|
context += "5. Include navigation links to parent/sibling MOCs\n";
|
|
569
|
+
context += "6. Reference actual technologies and concepts from the project (e.g., Rust WASM, knowledge graph)\n";
|
|
497
570
|
return context;
|
|
498
571
|
}
|
|
499
572
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-orchestrator.js","sources":["../../src/cultivation/migration-orchestrator.ts"],"sourcesContent":["/**\n * Migration Orchestrator - Implements Analysis Recommendations\n *\n * Uses claude-flow swarms to implement suggestions from cultivation analysis:\n * - Fill documentation gaps identified by Gap Analyst\n * - Answer research questions with specialized agents\n * - Build knowledge graph connections\n * - Create missing MOC files and documentation\n *\n * @module cultivation/migration-orchestrator\n */\n\nimport { existsSync, readFileSync, writeFileSync, mkdirSync, readdirSync, statSync } from 'fs';\nimport { join, dirname, basename, relative } from 'path';\nimport { GoogleGenerativeAI } from '@google/generative-ai';\nimport matter from 'gray-matter';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Parsed gap from analysis\n */\ninterface DocumentationGap {\n section: string;\n description: string;\n recommendation: string;\n priority: 'high' | 'medium' | 'low';\n relatedDocs: string[];\n}\n\n/**\n * Parsed research question from analysis\n */\ninterface ResearchQuestion {\n question: string;\n context: string;\n importance: string;\n suggestedResources: string[];\n category: string;\n}\n\n/**\n * Parsed connection suggestion from analysis\n */\ninterface ConnectionSuggestion {\n source: string;\n target: string;\n relationship: string;\n reason: string;\n}\n\n/**\n * Parsed analysis results\n */\ninterface ParsedAnalysis {\n vision: {\n purpose: string;\n goals: string[];\n recommendations: string[];\n };\n gaps: DocumentationGap[];\n questions: ResearchQuestion[];\n connections: ConnectionSuggestion[];\n}\n\n/**\n * Agent configuration for migration\n */\ninterface MigrationAgent {\n name: string;\n type: 'gap-filler' | 'researcher' | 'moc-builder' | 'connector' | 'integrator';\n task: string;\n context: string;\n outputFile?: string;\n}\n\n/**\n * Migration result\n */\ninterface MigrationResult {\n success: boolean;\n agentsUsed: number;\n documentsCreated: number;\n documentsUpdated: number;\n connectionsAdded: number;\n questionsAnswered: number;\n gapsFilled: number;\n errors: string[];\n warnings: string[];\n duration: number;\n}\n\n/**\n * Orchestrator options\n */\ninterface OrchestratorOptions {\n projectRoot: string;\n docsPath: string;\n analysisDir: string;\n verbose?: boolean;\n dryRun?: boolean;\n useVectorSearch?: boolean;\n maxAgents?: number;\n}\n\n// ============================================================================\n// Migration Orchestrator\n// ============================================================================\n\n/**\n * Orchestrates the migration from analysis to implemented documentation\n */\nexport class MigrationOrchestrator {\n private projectRoot: string;\n private docsPath: string;\n private analysisDir: string;\n private verbose: boolean;\n private dryRun: boolean;\n private useVectorSearch: boolean;\n private maxAgents: number;\n private geminiClient: GoogleGenerativeAI | null = null;\n\n constructor(options: OrchestratorOptions) {\n this.projectRoot = options.projectRoot;\n this.docsPath = options.docsPath;\n this.analysisDir = options.analysisDir;\n this.verbose = options.verbose ?? false;\n this.dryRun = options.dryRun ?? false;\n this.useVectorSearch = options.useVectorSearch ?? false;\n this.maxAgents = options.maxAgents ?? 8;\n\n // Initialize Gemini client if available\n const apiKey = process.env.GOOGLE_GEMINI_API_KEY ||\n process.env.GOOGLE_AI_API_KEY ||\n process.env.GEMINI_API_KEY ||\n process.env.GOOGLE_API_KEY;\n if (apiKey) {\n this.geminiClient = new GoogleGenerativeAI(apiKey);\n }\n }\n\n /**\n * Check availability status\n */\n async getAvailabilityStatus(): Promise<{ available: boolean; reason: string }> {\n if (this.geminiClient) {\n return { available: true, reason: 'Using Gemini API' };\n }\n\n // Check for Anthropic API\n if (process.env.ANTHROPIC_API_KEY) {\n return { available: true, reason: 'Using Anthropic API' };\n }\n\n return {\n available: false,\n reason: 'No API key found. Set GOOGLE_GEMINI_API_KEY or ANTHROPIC_API_KEY'\n };\n }\n\n /**\n * Run the migration process\n */\n async migrate(): Promise<MigrationResult> {\n const startTime = Date.now();\n const result: MigrationResult = {\n success: false,\n agentsUsed: 0,\n documentsCreated: 0,\n documentsUpdated: 0,\n connectionsAdded: 0,\n questionsAnswered: 0,\n gapsFilled: 0,\n errors: [],\n warnings: [],\n duration: 0\n };\n\n try {\n this.log('info', 'Starting migration orchestration', {\n analysisDir: this.analysisDir,\n docsPath: this.docsPath\n });\n\n // Step 1: Parse analysis files\n const analysis = await this.parseAnalysisFiles();\n this.log('info', 'Parsed analysis files', {\n gaps: analysis.gaps.length,\n questions: analysis.questions.length,\n connections: analysis.connections.length\n });\n\n // Step 2: Load existing documentation context\n const docsContext = await this.loadDocsContext();\n this.log('info', 'Loaded documentation context', {\n totalDocs: docsContext.size,\n keyDocs: Array.from(docsContext.keys()).slice(0, 5)\n });\n\n // Step 3: Create migration agents based on analysis\n const agents = this.createMigrationAgents(analysis, docsContext);\n this.log('info', 'Created migration agents', { agents: agents.length });\n\n // Step 4: Execute agents\n for (const agent of agents) {\n try {\n const agentResult = await this.executeAgent(agent, analysis, docsContext);\n result.agentsUsed++;\n\n if (agentResult.documentsCreated) {\n result.documentsCreated += agentResult.documentsCreated;\n }\n if (agentResult.documentsUpdated) {\n result.documentsUpdated += agentResult.documentsUpdated;\n }\n if (agentResult.gapsFilled) {\n result.gapsFilled += agentResult.gapsFilled;\n }\n if (agentResult.questionsAnswered) {\n result.questionsAnswered += agentResult.questionsAnswered;\n }\n if (agentResult.connectionsAdded) {\n result.connectionsAdded += agentResult.connectionsAdded;\n }\n } catch (error) {\n const msg = error instanceof Error ? error.message : String(error);\n result.errors.push(`Agent ${agent.name} failed: ${msg}`);\n this.log('error', `Agent ${agent.name} failed`, { error: msg });\n }\n }\n\n // Step 5: Update MOC files with new connections\n if (result.documentsCreated > 0 || result.connectionsAdded > 0) {\n await this.updateMOCFiles(analysis.connections);\n }\n\n result.success = result.errors.length === 0;\n result.duration = Date.now() - startTime;\n\n this.log('info', 'Migration complete', {\n success: result.success,\n documentsCreated: result.documentsCreated,\n gapsFilled: result.gapsFilled,\n duration: result.duration\n });\n\n return result;\n\n } catch (error) {\n const msg = error instanceof Error ? error.message : String(error);\n result.errors.push(`Migration failed: ${msg}`);\n result.duration = Date.now() - startTime;\n return result;\n }\n }\n\n /**\n * Parse all analysis files from the analysis directory\n */\n private async parseAnalysisFiles(): Promise<ParsedAnalysis> {\n const analysisPath = join(this.projectRoot, this.docsPath, this.analysisDir);\n const result: ParsedAnalysis = {\n vision: { purpose: '', goals: [], recommendations: [] },\n gaps: [],\n questions: [],\n connections: []\n };\n\n if (!existsSync(analysisPath)) {\n throw new Error(`Analysis directory not found: ${analysisPath}`);\n }\n\n // Parse vision-synthesis.md\n const visionFile = join(analysisPath, 'vision-synthesis.md');\n if (existsSync(visionFile)) {\n result.vision = this.parseVisionFile(readFileSync(visionFile, 'utf-8'));\n }\n\n // Parse documentation-gaps.md\n const gapsFile = join(analysisPath, 'documentation-gaps.md');\n if (existsSync(gapsFile)) {\n result.gaps = this.parseGapsFile(readFileSync(gapsFile, 'utf-8'));\n }\n\n // Parse research-questions.md\n const questionsFile = join(analysisPath, 'research-questions.md');\n if (existsSync(questionsFile)) {\n result.questions = this.parseQuestionsFile(readFileSync(questionsFile, 'utf-8'));\n }\n\n // Parse knowledge-connections.md\n const connectionsFile = join(analysisPath, 'knowledge-connections.md');\n if (existsSync(connectionsFile)) {\n result.connections = this.parseConnectionsFile(readFileSync(connectionsFile, 'utf-8'));\n }\n\n return result;\n }\n\n /**\n * Parse vision synthesis file\n */\n private parseVisionFile(content: string): ParsedAnalysis['vision'] {\n const vision: ParsedAnalysis['vision'] = {\n purpose: '',\n goals: [],\n recommendations: []\n };\n\n // Extract purpose from \"Core Purpose\" or \"Problem Statement\" sections\n const purposeMatch = content.match(/## (?:Core Purpose|Problem Statement)[^#]*?\\n([\\s\\S]*?)(?=\\n##|\\n\\*\\*|$)/i);\n if (purposeMatch) {\n vision.purpose = purposeMatch[1].trim().slice(0, 500);\n }\n\n // Extract goals/metrics\n const goalsMatch = content.match(/## (?:Key Success Metrics|Goals)[^#]*?\\n([\\s\\S]*?)(?=\\n##|$)/i);\n if (goalsMatch) {\n const goalLines = goalsMatch[1].match(/\\*\\s+\\*\\*[^*]+\\*\\*/g) || [];\n vision.goals = goalLines.map(g => g.replace(/\\*+/g, '').trim()).slice(0, 10);\n }\n\n // Extract recommendations\n const recsMatch = content.match(/## (?:Actionable Recommendations|Recommendations)[^#]*?\\n([\\s\\S]*?)(?=\\n##|```|$)/i);\n if (recsMatch) {\n const recLines = recsMatch[1].match(/\\d+\\.\\s+\\*\\*[^*]+\\*\\*[^*\\n]*/g) || [];\n vision.recommendations = recLines.map(r => r.replace(/\\d+\\.\\s*\\*\\*|\\*\\*/g, '').trim()).slice(0, 10);\n }\n\n return vision;\n }\n\n /**\n * Parse documentation gaps file\n */\n private parseGapsFile(content: string): DocumentationGap[] {\n const gaps: DocumentationGap[] = [];\n\n // Find all sections with observations/recommendations\n const sections = content.split(/###\\s+\\d+\\.\\s+/);\n\n for (const section of sections.slice(1)) {\n const titleMatch = section.match(/^([^\\n]+)/);\n const title = titleMatch ? titleMatch[1].trim() : 'Unknown Section';\n\n // Extract observations\n const obsMatches = section.matchAll(/\\*\\*Observation:\\*\\*\\s*([^\\n]+)/g);\n for (const match of obsMatches) {\n const observation = match[1].trim();\n\n // Find related recommendation\n const recMatch = section.match(/\\*\\*Recommendation:\\*\\*\\s*([^\\n]+)/);\n const recommendation = recMatch ? recMatch[1].trim() : '';\n\n // Extract wiki-links as related docs\n const wikiLinks = observation.match(/\\[\\[[^\\]]+\\]\\]/g) || [];\n const relatedDocs = wikiLinks.map(l => l.replace(/\\[\\[|\\]\\]/g, ''));\n\n gaps.push({\n section: title,\n description: observation,\n recommendation,\n priority: this.inferPriority(observation, recommendation),\n relatedDocs\n });\n }\n\n // Extract findings as gaps\n const findingMatches = section.matchAll(/\\*\\*Finding:\\*\\*\\s*([^\\n]+)/g);\n for (const match of findingMatches) {\n const finding = match[1].trim();\n const wikiLinks = finding.match(/\\[\\[[^\\]]+\\]\\]/g) || [];\n\n gaps.push({\n section: title,\n description: finding,\n recommendation: '',\n priority: 'medium',\n relatedDocs: wikiLinks.map(l => l.replace(/\\[\\[|\\]\\]/g, ''))\n });\n }\n }\n\n return gaps;\n }\n\n /**\n * Escape special regex characters in a string\n */\n private escapeRegex(str: string): string {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n }\n\n /**\n * Parse research questions file\n */\n private parseQuestionsFile(content: string): ResearchQuestion[] {\n const questions: ResearchQuestion[] = [];\n\n // Find all Question: entries\n const questionMatches = content.matchAll(/(?:Question:|####\\s+\\d+\\.\\d+\\s+)([^\\n]+)\\n([\\s\\S]*?)(?=\\n(?:Question:|####|\\*\\*Importance|\\*\\*Suggested|###|$))/g);\n\n for (const match of questionMatches) {\n const questionText = match[1].replace(/^Question:\\s*/, '').trim();\n const context = match[2].trim();\n\n // Escape special regex characters in question text before using in RegExp\n const safeQuestionShort = this.escapeRegex(questionText.slice(0, 50));\n const safeQuestionVeryShort = this.escapeRegex(questionText.slice(0, 30));\n\n // Extract importance\n const importanceMatch = content.match(new RegExp(`${safeQuestionShort}[\\\\s\\\\S]*?\\\\*\\\\*Importance:\\\\*\\\\*\\\\s*([^\\\\n]+)`));\n const importance = importanceMatch ? importanceMatch[1].trim() : '';\n\n // Extract suggested resources\n const resourcesMatch = content.match(new RegExp(`${safeQuestionShort}[\\\\s\\\\S]*?\\\\*\\\\*Suggested Resources:\\\\*\\\\*\\\\s*([^\\\\n]+)`));\n const resources = resourcesMatch ? resourcesMatch[1].split(',').map(r => r.trim()) : [];\n\n // Determine category from section header\n const categoryMatch = content.match(new RegExp(`### \\\\d+\\\\. ([^\\\\n]+)[\\\\s\\\\S]*?${safeQuestionVeryShort}`));\n const category = categoryMatch ? categoryMatch[1].trim() : 'General';\n\n questions.push({\n question: questionText,\n context,\n importance,\n suggestedResources: resources,\n category\n });\n }\n\n return questions;\n }\n\n /**\n * Parse knowledge connections file\n */\n private parseConnectionsFile(content: string): ConnectionSuggestion[] {\n const connections: ConnectionSuggestion[] = [];\n\n // Find relationship patterns like: [source] --RELATIONSHIP--> [target]\n const relationshipMatches = content.matchAll(/\\[([^\\]]+)\\]\\s*--([A-Z_-]+)-->\\s*\\[([^\\]]+)\\](?::\\s*([^\\n]+))?/g);\n\n for (const match of relationshipMatches) {\n connections.push({\n source: match[1].trim(),\n target: match[3].trim(),\n relationship: match[2].trim(),\n reason: match[4]?.trim() || ''\n });\n }\n\n // Also find wiki-link based suggestions\n const wikiMatches = content.matchAll(/\\[\\[([^\\]]+)\\]\\]\\s*(?:to|→|->|--)\\s*\\[\\[([^\\]]+)\\]\\]/g);\n for (const match of wikiMatches) {\n connections.push({\n source: match[1].trim(),\n target: match[2].trim(),\n relationship: 'RELATED-TO',\n reason: ''\n });\n }\n\n return connections;\n }\n\n /**\n * Load all documentation as context\n */\n private async loadDocsContext(): Promise<Map<string, string>> {\n const context = new Map<string, string>();\n const docsDir = join(this.projectRoot, this.docsPath);\n\n if (!existsSync(docsDir)) {\n return context;\n }\n\n const loadDir = (dir: string) => {\n const entries = readdirSync(dir);\n for (const entry of entries) {\n const fullPath = join(dir, entry);\n const stat = statSync(fullPath);\n\n if (stat.isDirectory() && !entry.startsWith('.') && entry !== 'analysis') {\n loadDir(fullPath);\n } else if (entry.endsWith('.md')) {\n const relativePath = relative(docsDir, fullPath);\n const content = readFileSync(fullPath, 'utf-8');\n // Limit content size for context\n context.set(relativePath, content.slice(0, 15000));\n }\n }\n };\n\n loadDir(docsDir);\n return context;\n }\n\n /**\n * Create migration agents based on analysis\n */\n private createMigrationAgents(\n analysis: ParsedAnalysis,\n docsContext: Map<string, string>\n ): MigrationAgent[] {\n const agents: MigrationAgent[] = [];\n\n // High priority gaps get dedicated gap-filler agents\n const highPriorityGaps = analysis.gaps.filter(g => g.priority === 'high');\n if (highPriorityGaps.length > 0) {\n agents.push({\n name: 'Gap Filler - High Priority',\n type: 'gap-filler',\n task: 'Fill high-priority documentation gaps with comprehensive content',\n context: this.buildGapFillerContext(highPriorityGaps, docsContext),\n outputFile: 'gap-implementations.md'\n });\n }\n\n // Medium priority gaps\n const mediumPriorityGaps = analysis.gaps.filter(g => g.priority === 'medium');\n if (mediumPriorityGaps.length > 0) {\n agents.push({\n name: 'Gap Filler - Medium Priority',\n type: 'gap-filler',\n task: 'Fill medium-priority documentation gaps',\n context: this.buildGapFillerContext(mediumPriorityGaps, docsContext)\n });\n }\n\n // Research agents for questions by category\n const questionsByCategory = new Map<string, ResearchQuestion[]>();\n for (const q of analysis.questions) {\n const cat = q.category || 'General';\n if (!questionsByCategory.has(cat)) {\n questionsByCategory.set(cat, []);\n }\n questionsByCategory.get(cat)!.push(q);\n }\n\n for (const [category, questions] of questionsByCategory) {\n if (questions.length > 0) {\n agents.push({\n name: `Researcher - ${category}`,\n type: 'researcher',\n task: `Research and answer questions about ${category}`,\n context: this.buildResearcherContext(questions, docsContext),\n outputFile: `research-${category.toLowerCase().replace(/\\s+/g, '-')}.md`\n });\n }\n }\n\n // MOC builder for empty stub MOCs\n const mocGaps = analysis.gaps.filter(g =>\n g.description.toLowerCase().includes('moc') ||\n g.description.toLowerCase().includes('stub')\n );\n if (mocGaps.length > 0) {\n agents.push({\n name: 'MOC Builder',\n type: 'moc-builder',\n task: 'Populate empty MOC (Map of Content) files with proper structure and links',\n context: this.buildMOCBuilderContext(mocGaps, docsContext)\n });\n }\n\n // Connection builder\n if (analysis.connections.length > 0) {\n agents.push({\n name: 'Connection Builder',\n type: 'connector',\n task: 'Build knowledge graph connections by adding wiki-links to documents',\n context: this.buildConnectorContext(analysis.connections, docsContext)\n });\n }\n\n // Integrator agent to ensure consistency\n agents.push({\n name: 'Documentation Integrator',\n type: 'integrator',\n task: 'Ensure all new documentation is consistent and properly integrated',\n context: this.buildIntegratorContext(analysis, docsContext),\n outputFile: 'integration-summary.md'\n });\n\n return agents.slice(0, this.maxAgents);\n }\n\n /**\n * Build context for gap filler agent\n */\n private buildGapFillerContext(gaps: DocumentationGap[], docsContext: Map<string, string>): string {\n let context = '## Documentation Gaps to Fill\\n\\n';\n\n for (const gap of gaps) {\n context += `### ${gap.section}\\n`;\n context += `**Issue:** ${gap.description}\\n`;\n if (gap.recommendation) {\n context += `**Recommendation:** ${gap.recommendation}\\n`;\n }\n context += `**Priority:** ${gap.priority}\\n`;\n\n // Add related doc content\n for (const relatedDoc of gap.relatedDocs.slice(0, 2)) {\n const docKey = Array.from(docsContext.keys()).find(k =>\n k.toLowerCase().includes(relatedDoc.toLowerCase().replace(/\\s+/g, '-'))\n );\n if (docKey) {\n context += `\\n**Related: ${relatedDoc}**\\n`;\n context += docsContext.get(docKey)?.slice(0, 2000) + '\\n';\n }\n }\n context += '\\n---\\n\\n';\n }\n\n context += '\\n## Instructions\\n';\n context += 'For each gap, create comprehensive documentation that:\\n';\n context += '1. Addresses the specific issue identified\\n';\n context += '2. Follows the existing documentation style\\n';\n context += '3. Includes proper wiki-links [[like-this]]\\n';\n context += '4. Has appropriate frontmatter (title, type, tags)\\n';\n context += '5. Integrates with existing documentation structure\\n';\n\n return context;\n }\n\n /**\n * Build context for researcher agent\n */\n private buildResearcherContext(questions: ResearchQuestion[], docsContext: Map<string, string>): string {\n let context = '## Research Questions to Answer\\n\\n';\n\n for (const q of questions) {\n context += `### Question\\n${q.question}\\n\\n`;\n if (q.importance) {\n context += `**Importance:** ${q.importance}\\n`;\n }\n if (q.context) {\n context += `**Context:** ${q.context}\\n`;\n }\n if (q.suggestedResources.length > 0) {\n context += `**Resources:** ${q.suggestedResources.join(', ')}\\n`;\n }\n context += '\\n---\\n\\n';\n }\n\n // Add relevant documentation context\n context += '\\n## Available Documentation Context\\n\\n';\n const relevantDocs = this.findRelevantDocs(\n questions.map(q => q.question).join(' '),\n docsContext,\n 5\n );\n for (const [path, content] of relevantDocs) {\n context += `### ${path}\\n`;\n context += content.slice(0, 3000) + '\\n\\n';\n }\n\n context += '\\n## Instructions\\n';\n context += 'For each research question:\\n';\n context += '1. Analyze the available documentation\\n';\n context += '2. Synthesize a well-researched answer\\n';\n context += '3. Cite sources using [[wiki-links]]\\n';\n context += '4. Identify any remaining unknowns\\n';\n context += '5. Suggest best practices based on the knowledge graph\\n';\n\n return context;\n }\n\n /**\n * Build context for MOC builder agent\n */\n private buildMOCBuilderContext(gaps: DocumentationGap[], docsContext: Map<string, string>): string {\n let context = '## MOC Files to Populate\\n\\n';\n\n // Find all MOC files\n const mocFiles = Array.from(docsContext.keys()).filter(k =>\n k.includes('_MOC.md') || k.includes('MOC.md')\n );\n\n context += '### Current MOC Files\\n';\n for (const mocFile of mocFiles) {\n const content = docsContext.get(mocFile) || '';\n const isEmpty = content.length < 200 || content.includes('stub');\n context += `- ${mocFile} ${isEmpty ? '(EMPTY/STUB)' : '(has content)'}\\n`;\n }\n\n context += '\\n### Gap Analysis Related to MOCs\\n';\n for (const gap of gaps) {\n context += `- ${gap.section}: ${gap.description}\\n`;\n if (gap.recommendation) {\n context += ` Recommendation: ${gap.recommendation}\\n`;\n }\n }\n\n // Add directory structure\n context += '\\n### Documentation Structure\\n';\n const directories = new Set<string>();\n for (const path of docsContext.keys()) {\n const dir = dirname(path);\n if (dir !== '.') {\n directories.add(dir);\n }\n }\n for (const dir of directories) {\n const docsInDir = Array.from(docsContext.keys()).filter(k => dirname(k) === dir);\n context += `- ${dir}/ (${docsInDir.length} docs)\\n`;\n }\n\n context += '\\n## Instructions\\n';\n context += 'For each empty/stub MOC file:\\n';\n context += '1. Create a proper introduction for the section\\n';\n context += '2. List all documents in that directory with [[wiki-links]]\\n';\n context += '3. Organize by subcategory if applicable\\n';\n context += '4. Add brief descriptions for each linked document\\n';\n context += '5. Include navigation links to parent/sibling MOCs\\n';\n\n return context;\n }\n\n /**\n * Build context for connector agent\n */\n private buildConnectorContext(connections: ConnectionSuggestion[], docsContext: Map<string, string>): string {\n let context = '## Suggested Knowledge Graph Connections\\n\\n';\n\n for (const conn of connections) {\n context += `- [${conn.source}] --${conn.relationship}--> [${conn.target}]`;\n if (conn.reason) {\n context += `: ${conn.reason}`;\n }\n context += '\\n';\n }\n\n context += '\\n## Existing Documents\\n';\n for (const [path] of Array.from(docsContext.entries()).slice(0, 30)) {\n context += `- [[${path.replace('.md', '')}]]\\n`;\n }\n\n context += '\\n## Instructions\\n';\n context += 'For each suggested connection:\\n';\n context += '1. Find the source document\\n';\n context += '2. Add appropriate wiki-link [[target]] to the source\\n';\n context += '3. Consider adding reciprocal links where appropriate\\n';\n context += '4. Use \"See also\" or \"Related\" sections for connections\\n';\n context += '5. Ensure the link context is meaningful\\n';\n\n return context;\n }\n\n /**\n * Build context for integrator agent\n */\n private buildIntegratorContext(analysis: ParsedAnalysis, docsContext: Map<string, string>): string {\n let context = '## Integration Context\\n\\n';\n\n context += '### Project Vision\\n';\n context += analysis.vision.purpose + '\\n\\n';\n\n context += '### Goals\\n';\n for (const goal of analysis.vision.goals) {\n context += `- ${goal}\\n`;\n }\n\n context += '\\n### Key Recommendations\\n';\n for (const rec of analysis.vision.recommendations) {\n context += `- ${rec}\\n`;\n }\n\n context += '\\n### Statistics\\n';\n context += `- Total documents: ${docsContext.size}\\n`;\n context += `- Gaps identified: ${analysis.gaps.length}\\n`;\n context += `- Questions to answer: ${analysis.questions.length}\\n`;\n context += `- Connections to build: ${analysis.connections.length}\\n`;\n\n context += '\\n## Instructions\\n';\n context += 'Create an integration summary that:\\n';\n context += '1. Lists all changes made during migration\\n';\n context += '2. Highlights any remaining gaps\\n';\n context += '3. Suggests next steps for documentation improvement\\n';\n context += '4. Provides a quality assessment\\n';\n\n return context;\n }\n\n /**\n * Execute a single migration agent\n */\n private async executeAgent(\n agent: MigrationAgent,\n analysis: ParsedAnalysis,\n docsContext: Map<string, string>\n ): Promise<{\n documentsCreated?: number;\n documentsUpdated?: number;\n gapsFilled?: number;\n questionsAnswered?: number;\n connectionsAdded?: number;\n }> {\n this.log('info', `Executing agent: ${agent.name}`, { type: agent.type });\n\n const prompt = this.buildAgentPrompt(agent);\n const response = await this.callAI(prompt, agent.type);\n\n if (!response) {\n throw new Error('No response from AI');\n }\n\n // Parse response and create/update documents\n const result = await this.processAgentResponse(agent, response, docsContext);\n\n this.log('info', `Agent ${agent.name} completed`, result);\n\n return result;\n }\n\n /**\n * Build prompt for agent\n */\n private buildAgentPrompt(agent: MigrationAgent): string {\n return `# ${agent.name}\n\n## Task\n${agent.task}\n\n${agent.context}\n\n## Output Format\nProvide your response in markdown format with clear sections.\nFor each document to create or update, use this format:\n\n\\`\\`\\`document\n---\npath: relative/path/to/file.md\naction: create|update\n---\n# Document Title\n\nDocument content here with [[wiki-links]] to other documents.\n\\`\\`\\`\n\nFor research answers, use:\n\\`\\`\\`answer\n## Question\nThe original question\n\n## Answer\nYour researched answer with [[citations]]\n\n## Best Practices\n- Recommendation 1\n- Recommendation 2\n\n## Remaining Unknowns\n- Any unresolved items\n\\`\\`\\`\n`;\n }\n\n /**\n * Select the best model based on task complexity\n * - Research and gap-filling tasks use the most capable model\n * - Simpler tasks use faster models\n */\n private selectGeminiModel(agentType: MigrationAgent['type']): string {\n // Use the most capable model for complex reasoning tasks\n const complexTasks = ['gap-filler', 'researcher'];\n if (complexTasks.includes(agentType)) {\n // gemini-2.5-pro for complex planning/research tasks\n return 'gemini-2.5-pro';\n }\n // Use fast model for simpler tasks (gemini-2.5-flash is better than 2.0-flash)\n return 'gemini-2.5-flash';\n }\n\n /**\n * Call AI (Gemini or fallback)\n */\n private async callAI(prompt: string, agentType: MigrationAgent['type']): Promise<string | null> {\n if (this.geminiClient) {\n const modelName = this.selectGeminiModel(agentType);\n try {\n this.log('info', `Using model: ${modelName}`, { agentType });\n const model = this.geminiClient.getGenerativeModel({ model: modelName });\n const result = await model.generateContent(prompt);\n return result.response.text();\n } catch (error) {\n // Fallback to gemini-2.5-flash if the pro model fails\n if (modelName !== 'gemini-2.5-flash') {\n this.log('warn', `${modelName} failed, falling back to gemini-2.5-flash`, { error: String(error) });\n try {\n const fallbackModel = this.geminiClient.getGenerativeModel({ model: 'gemini-2.5-flash' });\n const result = await fallbackModel.generateContent(prompt);\n return result.response.text();\n } catch (fallbackError) {\n this.log('error', 'Gemini fallback also failed', { error: String(fallbackError) });\n }\n } else {\n this.log('error', 'Gemini API call failed', { error: String(error) });\n }\n return null;\n }\n }\n\n // Fallback to Anthropic if available\n if (process.env.ANTHROPIC_API_KEY) {\n try {\n const { default: Anthropic } = await import('@anthropic-ai/sdk');\n const client = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });\n // Use opus for complex tasks, sonnet for simpler ones\n const complexTasks = ['gap-filler', 'researcher'];\n const model = complexTasks.includes(agentType)\n ? 'claude-sonnet-4-20250514' // Best available\n : 'claude-sonnet-4-20250514';\n const message = await client.messages.create({\n model,\n max_tokens: 8000,\n messages: [{ role: 'user', content: prompt }]\n });\n const textBlock = message.content.find(b => b.type === 'text');\n return textBlock ? textBlock.text : null;\n } catch (error) {\n this.log('error', 'Anthropic API call failed', { error: String(error) });\n return null;\n }\n }\n\n return null;\n }\n\n /**\n * Process agent response and create/update documents\n */\n private async processAgentResponse(\n agent: MigrationAgent,\n response: string,\n docsContext: Map<string, string>\n ): Promise<{\n documentsCreated?: number;\n documentsUpdated?: number;\n gapsFilled?: number;\n questionsAnswered?: number;\n connectionsAdded?: number;\n }> {\n const result = {\n documentsCreated: 0,\n documentsUpdated: 0,\n gapsFilled: 0,\n questionsAnswered: 0,\n connectionsAdded: 0\n };\n\n // Extract document blocks\n const documentMatches = response.matchAll(/```document\\n---\\npath:\\s*([^\\n]+)\\naction:\\s*(\\w+)\\n---\\n([\\s\\S]*?)```/g);\n\n for (const match of documentMatches) {\n const path = match[1].trim();\n const action = match[2].trim();\n const content = match[3].trim();\n\n if (this.dryRun) {\n this.log('info', `[DRY RUN] Would ${action}: ${path}`);\n continue;\n }\n\n const fullPath = join(this.projectRoot, this.docsPath, path);\n\n // Ensure directory exists\n const dir = dirname(fullPath);\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n\n // Write document\n const finalContent = this.addFrontmatter(content, path, agent.type);\n writeFileSync(fullPath, finalContent, 'utf-8');\n\n if (action === 'create') {\n result.documentsCreated++;\n if (agent.type === 'gap-filler') {\n result.gapsFilled++;\n }\n } else {\n result.documentsUpdated++;\n }\n\n // Count connections added\n const wikiLinks = content.match(/\\[\\[[^\\]]+\\]\\]/g) || [];\n result.connectionsAdded += wikiLinks.length;\n }\n\n // Extract answer blocks\n const answerMatches = response.matchAll(/```answer\\n([\\s\\S]*?)```/g);\n for (const match of answerMatches) {\n result.questionsAnswered++;\n\n // Save answer to research output file\n if (agent.outputFile && !this.dryRun) {\n const outputPath = join(this.projectRoot, this.docsPath, 'analysis', agent.outputFile);\n const existing = existsSync(outputPath) ? readFileSync(outputPath, 'utf-8') : '';\n const newContent = existing + '\\n\\n---\\n\\n' + match[1].trim();\n writeFileSync(outputPath, newContent, 'utf-8');\n }\n }\n\n // If agent has output file and no document blocks, save raw response\n if (agent.outputFile && result.documentsCreated === 0 && !this.dryRun) {\n const outputPath = join(this.projectRoot, this.docsPath, 'analysis', agent.outputFile);\n const frontmatter = `---\ntitle: \"${agent.name}\"\ntype: migration-output\ngenerator: migration-orchestrator\nagent: ${agent.type}\ncreated: ${new Date().toISOString()}\n---\n\n# ${agent.name}\n\n> Generated by MigrationOrchestrator\n\n`;\n writeFileSync(outputPath, frontmatter + response, 'utf-8');\n result.documentsCreated++;\n }\n\n return result;\n }\n\n /**\n * Add frontmatter to document if not present\n */\n private addFrontmatter(content: string, path: string, agentType: string): string {\n if (content.startsWith('---')) {\n return content;\n }\n\n const title = basename(path, '.md').replace(/-/g, ' ').replace(/_/g, ' ');\n const type = this.inferDocType(path);\n\n return `---\ntitle: \"${title}\"\ntype: ${type}\ngenerator: migration-orchestrator\nagent: ${agentType}\ncreated: ${new Date().toISOString()}\n---\n\n${content}`;\n }\n\n /**\n * Infer document type from path\n */\n private inferDocType(path: string): string {\n if (path.includes('concepts')) return 'concept';\n if (path.includes('components')) return 'component';\n if (path.includes('services')) return 'service';\n if (path.includes('features')) return 'feature';\n if (path.includes('guides')) return 'guide';\n if (path.includes('references')) return 'reference';\n if (path.includes('standards')) return 'standard';\n if (path.includes('integrations')) return 'integration';\n if (path.includes('MOC')) return 'moc';\n return 'document';\n }\n\n /**\n * Update MOC files with new connections\n */\n private async updateMOCFiles(connections: ConnectionSuggestion[]): Promise<void> {\n // This would update MOC files with new links\n // For now, we'll let the MOC builder agent handle this\n this.log('info', 'MOC files updated with new connections', { count: connections.length });\n }\n\n /**\n * Find relevant docs based on query\n */\n private findRelevantDocs(\n query: string,\n docsContext: Map<string, string>,\n limit: number\n ): Map<string, string> {\n const relevant = new Map<string, string>();\n const queryWords = query.toLowerCase().split(/\\s+/).filter(w => w.length > 3);\n\n // Simple keyword matching (would use vector search if available)\n const scored = Array.from(docsContext.entries()).map(([path, content]) => {\n let score = 0;\n const lowerContent = content.toLowerCase();\n for (const word of queryWords) {\n if (lowerContent.includes(word)) {\n score++;\n }\n }\n return { path, content, score };\n });\n\n scored.sort((a, b) => b.score - a.score);\n\n for (const item of scored.slice(0, limit)) {\n if (item.score > 0) {\n relevant.set(item.path, item.content);\n }\n }\n\n return relevant;\n }\n\n /**\n * Infer priority from description\n */\n private inferPriority(description: string, recommendation: string): 'high' | 'medium' | 'low' {\n const text = (description + ' ' + recommendation).toLowerCase();\n\n if (text.includes('critical') || text.includes('missing') || text.includes('empty') ||\n text.includes('stub') || text.includes('required')) {\n return 'high';\n }\n\n if (text.includes('should') || text.includes('recommend') || text.includes('consider')) {\n return 'medium';\n }\n\n return 'low';\n }\n\n /**\n * Log message\n */\n private log(level: 'info' | 'warn' | 'error', message: string, data?: Record<string, unknown>): void {\n if (!this.verbose && level === 'info') return;\n\n const timestamp = new Date().toISOString().split('T')[1].split('.')[0];\n const prefix = level === 'error' ? '❌' : level === 'warn' ? '⚠️' : '📋';\n\n console.log(`[${timestamp}] ${prefix} [migration] ${message}`, data ? JSON.stringify(data) : '');\n }\n}\n\nexport type { MigrationResult, OrchestratorOptions, ParsedAnalysis };\n"],"names":[],"mappings":";;;AAkHO,MAAM,sBAAsB;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAA0C;AAAA,EAElD,YAAY,SAA8B;AACxC,SAAK,cAAc,QAAQ;AAC3B,SAAK,WAAW,QAAQ;AACxB,SAAK,cAAc,QAAQ;AAC3B,SAAK,UAAU,QAAQ,WAAW;AAClC,SAAK,SAAS,QAAQ,UAAU;AAChC,SAAK,kBAAkB,QAAQ,mBAAmB;AAClD,SAAK,YAAY,QAAQ,aAAa;AAGtC,UAAM,SAAS,QAAQ,IAAI,yBACZ,QAAQ,IAAI,qBACZ,QAAQ,IAAI,kBACZ,QAAQ,IAAI;AAC3B,QAAI,QAAQ;AACV,WAAK,eAAe,IAAI,mBAAmB,MAAM;AAAA,IACnD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,wBAAyE;AAC7E,QAAI,KAAK,cAAc;AACrB,aAAO,EAAE,WAAW,MAAM,QAAQ,mBAAA;AAAA,IACpC;AAGA,QAAI,QAAQ,IAAI,mBAAmB;AACjC,aAAO,EAAE,WAAW,MAAM,QAAQ,sBAAA;AAAA,IACpC;AAEA,WAAO;AAAA,MACL,WAAW;AAAA,MACX,QAAQ;AAAA,IAAA;AAAA,EAEZ;AAAA;AAAA;AAAA;A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K;AAEvC,eAAW,QAAQ,OAAO,MAAM,GAAG,KAAK,GAAG;AACzC,UAAI,KAAK,QAAQ,GAAG;AAClB,iBAAS,IAAI,KAAK,MAAM,KAAK,OAAO;AAAA,MACtC;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKQ,cAAc,aAAqB,gBAAmD;AAC5F,UAAM,QAAQ,cAAc,MAAM,gBAAgB,YAAA;AAElD,QAAI,KAAK,SAAS,UAAU,KAAK,KAAK,SAAS,SAAS,KAAK,KAAK,SAAS,OAAO,KAC9E,KAAK,SAAS,MAAM,KAAK,KAAK,SAAS,UAAU,GAAG;AACtD,aAAO;AAAA,IACT;AAEA,QAAI,KAAK,SAAS,QAAQ,KAAK,KAAK,SAAS,WAAW,KAAK,KAAK,SAAS,UAAU,GAAG;AACtF,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKQ,IAAI,OAAkC,SAAiB,MAAsC;AACnG,QAAI,CAAC,KAAK,WAAW,UAAU,OAAQ;AAEvC,UAAM,aAAY,oBAAI,KAAA,GAAO,cAAc,MAAM,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC;AACrE,UAAM,SAAS,UAAU,UAAU,MAAM,UAAU,SAAS,OAAO;AAEnE,YAAQ,IAAI,IAAI,SAAS,KAAK,MAAM,gBAAgB,OAAO,IAAI,OAAO,KAAK,UAAU,IAAI,IAAI,EAAE;AAAA,EACjG;AACF;"}
|
|
1
|
+
{"version":3,"file":"migration-orchestrator.js","sources":["../../src/cultivation/migration-orchestrator.ts"],"sourcesContent":["/**\n * Migration Orchestrator - Implements Analysis Recommendations\n *\n * Uses claude-flow swarms to implement suggestions from cultivation analysis:\n * - Fill documentation gaps identified by Gap Analyst\n * - Answer research questions with specialized agents\n * - Build knowledge graph connections\n * - Create missing MOC files and documentation\n *\n * @module cultivation/migration-orchestrator\n */\n\nimport { existsSync, readFileSync, writeFileSync, mkdirSync, readdirSync, statSync } from 'fs';\nimport { join, dirname, basename, relative } from 'path';\nimport { GoogleGenerativeAI } from '@google/generative-ai';\nimport matter from 'gray-matter';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Parsed gap from analysis\n */\ninterface DocumentationGap {\n section: string;\n description: string;\n recommendation: string;\n priority: 'high' | 'medium' | 'low';\n relatedDocs: string[];\n}\n\n/**\n * Parsed research question from analysis\n */\ninterface ResearchQuestion {\n question: string;\n context: string;\n importance: string;\n suggestedResources: string[];\n category: string;\n}\n\n/**\n * Parsed connection suggestion from analysis\n */\ninterface ConnectionSuggestion {\n source: string;\n target: string;\n relationship: string;\n reason: string;\n}\n\n/**\n * Parsed analysis results\n */\ninterface ParsedAnalysis {\n vision: {\n purpose: string;\n goals: string[];\n recommendations: string[];\n };\n gaps: DocumentationGap[];\n questions: ResearchQuestion[];\n connections: ConnectionSuggestion[];\n}\n\n/**\n * Agent configuration for migration\n */\ninterface MigrationAgent {\n name: string;\n type: 'gap-filler' | 'researcher' | 'moc-builder' | 'connector' | 'integrator';\n task: string;\n context: string;\n outputFile?: string;\n}\n\n/**\n * Migration result\n */\ninterface MigrationResult {\n success: boolean;\n agentsUsed: number;\n documentsCreated: number;\n documentsUpdated: number;\n connectionsAdded: number;\n questionsAnswered: number;\n gapsFilled: number;\n errors: string[];\n warnings: string[];\n duration: number;\n}\n\n/**\n * Orchestrator options\n */\ninterface OrchestratorOptions {\n projectRoot: string;\n docsPath: string;\n analysisDir: string;\n verbose?: boolean;\n dryRun?: boolean;\n useVectorSearch?: boolean;\n maxAgents?: number;\n}\n\n// ============================================================================\n// Migration Orchestrator\n// ============================================================================\n\n/**\n * Orchestrates the migration from analysis to implemented documentation\n */\nexport class MigrationOrchestrator {\n private projectRoot: string;\n private docsPath: string;\n private analysisDir: string;\n private verbose: boolean;\n private dryRun: boolean;\n private useVectorSearch: boolean;\n private maxAgents: number;\n private geminiClient: GoogleGenerativeAI | null = null;\n\n constructor(options: OrchestratorOptions) {\n this.projectRoot = options.projectRoot;\n this.docsPath = options.docsPath;\n this.analysisDir = options.analysisDir;\n this.verbose = options.verbose ?? false;\n this.dryRun = options.dryRun ?? false;\n this.useVectorSearch = options.useVectorSearch ?? false;\n this.maxAgents = options.maxAgents ?? 8;\n\n // Initialize Gemini client if available\n const apiKey = process.env.GOOGLE_GEMINI_API_KEY ||\n process.env.GOOGLE_AI_API_KEY ||\n process.env.GEMINI_API_KEY ||\n process.env.GOOGLE_API_KEY;\n if (apiKey) {\n this.geminiClient = new GoogleGenerativeAI(apiKey);\n }\n }\n\n /**\n * Check availability status\n */\n async getAvailabilityStatus(): Promise<{ available: boolean; reason: string }> {\n if (this.geminiClient) {\n return { available: true, reason: 'Using Gemini API' };\n }\n\n // Check for Anthropic API\n if (process.env.ANTHROPIC_API_KEY) {\n return { available: true, reason: 'Using Anthropic API' };\n }\n\n return {\n available: false,\n reason: 'No API key found. Set GOOGLE_GEMINI_API_KEY or ANTHROPIC_API_KEY'\n };\n }\n\n /**\n * Run the migration process\n */\n async migrate(): Promise<MigrationResult> {\n const startTime = Date.now();\n const result: MigrationResult = {\n success: false,\n agentsUsed: 0,\n documentsCreated: 0,\n documentsUpdated: 0,\n connectionsAdded: 0,\n questionsAnswered: 0,\n gapsFilled: 0,\n errors: [],\n warnings: [],\n duration: 0\n };\n\n try {\n this.log('info', 'Starting migration orchestration', {\n analysisDir: this.analysisDir,\n docsPath: this.docsPath\n });\n\n // Step 1: Parse analysis files\n const analysis = await this.parseAnalysisFiles();\n this.log('info', 'Parsed analysis files', {\n gaps: analysis.gaps.length,\n questions: analysis.questions.length,\n connections: analysis.connections.length\n });\n\n // Step 2: Load existing documentation context\n const docsContext = await this.loadDocsContext();\n this.log('info', 'Loaded documentation context', {\n totalDocs: docsContext.size,\n keyDocs: Array.from(docsContext.keys()).slice(0, 5)\n });\n\n // Step 3: Create migration agents based on analysis\n const agents = this.createMigrationAgents(analysis, docsContext);\n this.log('info', 'Created migration agents', { agents: agents.length });\n\n // Step 4: Execute agents\n for (const agent of agents) {\n try {\n const agentResult = await this.executeAgent(agent, analysis, docsContext);\n result.agentsUsed++;\n\n if (agentResult.documentsCreated) {\n result.documentsCreated += agentResult.documentsCreated;\n }\n if (agentResult.documentsUpdated) {\n result.documentsUpdated += agentResult.documentsUpdated;\n }\n if (agentResult.gapsFilled) {\n result.gapsFilled += agentResult.gapsFilled;\n }\n if (agentResult.questionsAnswered) {\n result.questionsAnswered += agentResult.questionsAnswered;\n }\n if (agentResult.connectionsAdded) {\n result.connectionsAdded += agentResult.connectionsAdded;\n }\n } catch (error) {\n const msg = error instanceof Error ? error.message : String(error);\n result.errors.push(`Agent ${agent.name} failed: ${msg}`);\n this.log('error', `Agent ${agent.name} failed`, { error: msg });\n }\n }\n\n // Step 5: Update MOC files with new connections\n if (result.documentsCreated > 0 || result.connectionsAdded > 0) {\n await this.updateMOCFiles(analysis.connections);\n }\n\n result.success = result.errors.length === 0;\n result.duration = Date.now() - startTime;\n\n this.log('info', 'Migration complete', {\n success: result.success,\n documentsCreated: result.documentsCreated,\n gapsFilled: result.gapsFilled,\n duration: result.duration\n });\n\n return result;\n\n } catch (error) {\n const msg = error instanceof Error ? error.message : String(error);\n result.errors.push(`Migration failed: ${msg}`);\n result.duration = Date.now() - startTime;\n return result;\n }\n }\n\n /**\n * Parse all analysis files from the analysis directory\n */\n private async parseAnalysisFiles(): Promise<ParsedAnalysis> {\n const analysisPath = join(this.projectRoot, this.docsPath, this.analysisDir);\n const result: ParsedAnalysis = {\n vision: { purpose: '', goals: [], recommendations: [] },\n gaps: [],\n questions: [],\n connections: []\n };\n\n if (!existsSync(analysisPath)) {\n throw new Error(`Analysis directory not found: ${analysisPath}`);\n }\n\n // Parse vision-synthesis.md\n const visionFile = join(analysisPath, 'vision-synthesis.md');\n if (existsSync(visionFile)) {\n result.vision = this.parseVisionFile(readFileSync(visionFile, 'utf-8'));\n }\n\n // Parse documentation-gaps.md\n const gapsFile = join(analysisPath, 'documentation-gaps.md');\n if (existsSync(gapsFile)) {\n result.gaps = this.parseGapsFile(readFileSync(gapsFile, 'utf-8'));\n }\n\n // Parse research-questions.md\n const questionsFile = join(analysisPath, 'research-questions.md');\n if (existsSync(questionsFile)) {\n result.questions = this.parseQuestionsFile(readFileSync(questionsFile, 'utf-8'));\n }\n\n // Parse knowledge-connections.md\n const connectionsFile = join(analysisPath, 'knowledge-connections.md');\n if (existsSync(connectionsFile)) {\n result.connections = this.parseConnectionsFile(readFileSync(connectionsFile, 'utf-8'));\n }\n\n return result;\n }\n\n /**\n * Parse vision synthesis file\n */\n private parseVisionFile(content: string): ParsedAnalysis['vision'] {\n const vision: ParsedAnalysis['vision'] = {\n purpose: '',\n goals: [],\n recommendations: []\n };\n\n // Extract purpose from \"Core Purpose\" or \"Problem Statement\" sections\n const purposeMatch = content.match(/## (?:Core Purpose|Problem Statement)[^#]*?\\n([\\s\\S]*?)(?=\\n##|\\n\\*\\*|$)/i);\n if (purposeMatch) {\n vision.purpose = purposeMatch[1].trim().slice(0, 500);\n }\n\n // Extract goals/metrics\n const goalsMatch = content.match(/## (?:Key Success Metrics|Goals)[^#]*?\\n([\\s\\S]*?)(?=\\n##|$)/i);\n if (goalsMatch) {\n const goalLines = goalsMatch[1].match(/\\*\\s+\\*\\*[^*]+\\*\\*/g) || [];\n vision.goals = goalLines.map(g => g.replace(/\\*+/g, '').trim()).slice(0, 10);\n }\n\n // Extract recommendations\n const recsMatch = content.match(/## (?:Actionable Recommendations|Recommendations)[^#]*?\\n([\\s\\S]*?)(?=\\n##|```|$)/i);\n if (recsMatch) {\n const recLines = recsMatch[1].match(/\\d+\\.\\s+\\*\\*[^*]+\\*\\*[^*\\n]*/g) || [];\n vision.recommendations = recLines.map(r => r.replace(/\\d+\\.\\s*\\*\\*|\\*\\*/g, '').trim()).slice(0, 10);\n }\n\n return vision;\n }\n\n /**\n * Parse documentation gaps file\n */\n private parseGapsFile(content: string): DocumentationGap[] {\n const gaps: DocumentationGap[] = [];\n\n // Find all sections with observations/recommendations\n const sections = content.split(/###\\s+\\d+\\.\\s+/);\n\n for (const section of sections.slice(1)) {\n const titleMatch = section.match(/^([^\\n]+)/);\n const title = titleMatch ? titleMatch[1].trim() : 'Unknown Section';\n\n // Extract observations\n const obsMatches = section.matchAll(/\\*\\*Observation:\\*\\*\\s*([^\\n]+)/g);\n for (const match of obsMatches) {\n const observation = match[1].trim();\n\n // Find related recommendation\n const recMatch = section.match(/\\*\\*Recommendation:\\*\\*\\s*([^\\n]+)/);\n const recommendation = recMatch ? recMatch[1].trim() : '';\n\n // Extract wiki-links as related docs\n const wikiLinks = observation.match(/\\[\\[[^\\]]+\\]\\]/g) || [];\n const relatedDocs = wikiLinks.map(l => l.replace(/\\[\\[|\\]\\]/g, ''));\n\n gaps.push({\n section: title,\n description: observation,\n recommendation,\n priority: this.inferPriority(observation, recommendation),\n relatedDocs\n });\n }\n\n // Extract findings as gaps\n const findingMatches = section.matchAll(/\\*\\*Finding:\\*\\*\\s*([^\\n]+)/g);\n for (const match of findingMatches) {\n const finding = match[1].trim();\n const wikiLinks = finding.match(/\\[\\[[^\\]]+\\]\\]/g) || [];\n\n gaps.push({\n section: title,\n description: finding,\n recommendation: '',\n priority: 'medium',\n relatedDocs: wikiLinks.map(l => l.replace(/\\[\\[|\\]\\]/g, ''))\n });\n }\n }\n\n return gaps;\n }\n\n /**\n * Escape special regex characters in a string\n */\n private escapeRegex(str: string): string {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n }\n\n /**\n * Parse research questions file\n */\n private parseQuestionsFile(content: string): ResearchQuestion[] {\n const questions: ResearchQuestion[] = [];\n\n // Find all Question: entries\n const questionMatches = content.matchAll(/(?:Question:|####\\s+\\d+\\.\\d+\\s+)([^\\n]+)\\n([\\s\\S]*?)(?=\\n(?:Question:|####|\\*\\*Importance|\\*\\*Suggested|###|$))/g);\n\n for (const match of questionMatches) {\n const questionText = match[1].replace(/^Question:\\s*/, '').trim();\n const context = match[2].trim();\n\n // Escape special regex characters in question text before using in RegExp\n const safeQuestionShort = this.escapeRegex(questionText.slice(0, 50));\n const safeQuestionVeryShort = this.escapeRegex(questionText.slice(0, 30));\n\n // Extract importance\n const importanceMatch = content.match(new RegExp(`${safeQuestionShort}[\\\\s\\\\S]*?\\\\*\\\\*Importance:\\\\*\\\\*\\\\s*([^\\\\n]+)`));\n const importance = importanceMatch ? importanceMatch[1].trim() : '';\n\n // Extract suggested resources\n const resourcesMatch = content.match(new RegExp(`${safeQuestionShort}[\\\\s\\\\S]*?\\\\*\\\\*Suggested Resources:\\\\*\\\\*\\\\s*([^\\\\n]+)`));\n const resources = resourcesMatch ? resourcesMatch[1].split(',').map(r => r.trim()) : [];\n\n // Determine category from section header\n const categoryMatch = content.match(new RegExp(`### \\\\d+\\\\. ([^\\\\n]+)[\\\\s\\\\S]*?${safeQuestionVeryShort}`));\n const category = categoryMatch ? categoryMatch[1].trim() : 'General';\n\n questions.push({\n question: questionText,\n context,\n importance,\n suggestedResources: resources,\n category\n });\n }\n\n return questions;\n }\n\n /**\n * Parse knowledge connections file\n */\n private parseConnectionsFile(content: string): ConnectionSuggestion[] {\n const connections: ConnectionSuggestion[] = [];\n\n // Find relationship patterns like: [source] --RELATIONSHIP--> [target]\n const relationshipMatches = content.matchAll(/\\[([^\\]]+)\\]\\s*--([A-Z_-]+)-->\\s*\\[([^\\]]+)\\](?::\\s*([^\\n]+))?/g);\n\n for (const match of relationshipMatches) {\n connections.push({\n source: match[1].trim(),\n target: match[3].trim(),\n relationship: match[2].trim(),\n reason: match[4]?.trim() || ''\n });\n }\n\n // Also find wiki-link based suggestions\n const wikiMatches = content.matchAll(/\\[\\[([^\\]]+)\\]\\]\\s*(?:to|→|->|--)\\s*\\[\\[([^\\]]+)\\]\\]/g);\n for (const match of wikiMatches) {\n connections.push({\n source: match[1].trim(),\n target: match[2].trim(),\n relationship: 'RELATED-TO',\n reason: ''\n });\n }\n\n return connections;\n }\n\n /**\n * Load all documentation as context\n */\n private async loadDocsContext(): Promise<Map<string, string>> {\n const context = new Map<string, string>();\n const docsDir = join(this.projectRoot, this.docsPath);\n\n if (!existsSync(docsDir)) {\n return context;\n }\n\n const loadDir = (dir: string) => {\n const entries = readdirSync(dir);\n for (const entry of entries) {\n const fullPath = join(dir, entry);\n const stat = statSync(fullPath);\n\n if (stat.isDirectory() && !entry.startsWith('.') && entry !== 'analysis') {\n loadDir(fullPath);\n } else if (entry.endsWith('.md')) {\n const relativePath = relative(docsDir, fullPath);\n const content = readFileSync(fullPath, 'utf-8');\n // Limit content size for context\n context.set(relativePath, content.slice(0, 15000));\n }\n }\n };\n\n loadDir(docsDir);\n return context;\n }\n\n /**\n * Create migration agents based on analysis\n */\n private createMigrationAgents(\n analysis: ParsedAnalysis,\n docsContext: Map<string, string>\n ): MigrationAgent[] {\n const agents: MigrationAgent[] = [];\n\n // High priority gaps get dedicated gap-filler agents\n const highPriorityGaps = analysis.gaps.filter(g => g.priority === 'high');\n if (highPriorityGaps.length > 0) {\n agents.push({\n name: 'Gap Filler - High Priority',\n type: 'gap-filler',\n task: 'Fill high-priority documentation gaps with comprehensive, project-specific content',\n context: this.buildGapFillerContext(highPriorityGaps, docsContext, analysis),\n outputFile: 'gap-implementations.md'\n });\n }\n\n // Medium priority gaps\n const mediumPriorityGaps = analysis.gaps.filter(g => g.priority === 'medium');\n if (mediumPriorityGaps.length > 0) {\n agents.push({\n name: 'Gap Filler - Medium Priority',\n type: 'gap-filler',\n task: 'Fill medium-priority documentation gaps with project-specific content',\n context: this.buildGapFillerContext(mediumPriorityGaps, docsContext, analysis)\n });\n }\n\n // Research agents for questions by category\n const questionsByCategory = new Map<string, ResearchQuestion[]>();\n for (const q of analysis.questions) {\n const cat = q.category || 'General';\n if (!questionsByCategory.has(cat)) {\n questionsByCategory.set(cat, []);\n }\n questionsByCategory.get(cat)!.push(q);\n }\n\n for (const [category, questions] of questionsByCategory) {\n if (questions.length > 0) {\n agents.push({\n name: `Researcher - ${category}`,\n type: 'researcher',\n task: `Research and answer questions about ${category}`,\n context: this.buildResearcherContext(questions, docsContext),\n outputFile: `research-${category.toLowerCase().replace(/\\s+/g, '-')}.md`\n });\n }\n }\n\n // MOC builder for empty stub MOCs\n const mocGaps = analysis.gaps.filter(g =>\n g.description.toLowerCase().includes('moc') ||\n g.description.toLowerCase().includes('stub')\n );\n if (mocGaps.length > 0) {\n agents.push({\n name: 'MOC Builder',\n type: 'moc-builder',\n task: 'Populate empty MOC (Map of Content) files with project-specific structure and links',\n context: this.buildMOCBuilderContext(mocGaps, docsContext, analysis)\n });\n }\n\n // Connection builder\n if (analysis.connections.length > 0) {\n agents.push({\n name: 'Connection Builder',\n type: 'connector',\n task: 'Build knowledge graph connections by adding wiki-links to documents',\n context: this.buildConnectorContext(analysis.connections, docsContext)\n });\n }\n\n // Integrator agent to ensure consistency\n agents.push({\n name: 'Documentation Integrator',\n type: 'integrator',\n task: 'Ensure all new documentation is consistent and properly integrated',\n context: this.buildIntegratorContext(analysis, docsContext),\n outputFile: 'integration-summary.md'\n });\n\n return agents.slice(0, this.maxAgents);\n }\n\n /**\n * Build context for gap filler agent\n */\n private buildGapFillerContext(\n gaps: DocumentationGap[],\n docsContext: Map<string, string>,\n analysis: ParsedAnalysis\n ): string {\n let context = '## Project Context\\n\\n';\n\n // Include the project vision/purpose so gaps are filled with relevant content\n if (analysis.vision.purpose) {\n context += `### Project Purpose\\n${analysis.vision.purpose}\\n\\n`;\n }\n if (analysis.vision.goals.length > 0) {\n context += `### Key Goals\\n`;\n for (const goal of analysis.vision.goals.slice(0, 5)) {\n context += `- ${goal}\\n`;\n }\n context += '\\n';\n }\n\n // Include key technical documentation for context\n context += '## Key Technical Documentation\\n\\n';\n const keyDocPatterns = [\n 'test_strategy', 'technical', 'architecture', 'wasm', 'rust',\n 'original_spec', 'integration', 'primitives', 'requirements'\n ];\n\n for (const [docPath, docContent] of docsContext) {\n const lowerPath = docPath.toLowerCase();\n if (keyDocPatterns.some(pattern => lowerPath.includes(pattern))) {\n context += `### ${docPath}\\n`;\n context += docContent.slice(0, 4000) + '\\n\\n';\n }\n }\n\n context += '## Documentation Gaps to Fill\\n\\n';\n\n for (const gap of gaps) {\n context += `### ${gap.section}\\n`;\n context += `**Issue:** ${gap.description}\\n`;\n if (gap.recommendation) {\n context += `**Recommendation:** ${gap.recommendation}\\n`;\n }\n context += `**Priority:** ${gap.priority}\\n`;\n\n // Add related doc content\n for (const relatedDoc of gap.relatedDocs.slice(0, 2)) {\n const docKey = Array.from(docsContext.keys()).find(k =>\n k.toLowerCase().includes(relatedDoc.toLowerCase().replace(/\\s+/g, '-'))\n );\n if (docKey) {\n context += `\\n**Related: ${relatedDoc}**\\n`;\n context += docsContext.get(docKey)?.slice(0, 2000) + '\\n';\n }\n }\n context += '\\n---\\n\\n';\n }\n\n context += '\\n## Instructions\\n';\n context += 'CRITICAL: Use the project context and technical documentation above to fill each gap.\\n';\n context += 'Do NOT generate generic placeholder content. Use the ACTUAL project details.\\n\\n';\n context += 'For each gap, create comprehensive documentation that:\\n';\n context += '1. Addresses the specific issue using REAL project details from the context above\\n';\n context += '2. References specific technologies, architectures, and implementations mentioned in the technical docs\\n';\n context += '3. Follows the existing documentation style\\n';\n context += '4. Includes proper wiki-links [[like-this]] to existing documents\\n';\n context += '5. Has appropriate frontmatter (title, type, tags)\\n';\n context += '6. Contains concrete, project-specific information - NOT generic placeholders\\n';\n\n return context;\n }\n\n /**\n * Build context for researcher agent\n */\n private buildResearcherContext(questions: ResearchQuestion[], docsContext: Map<string, string>): string {\n let context = '## Research Questions to Answer\\n\\n';\n\n for (const q of questions) {\n context += `### Question\\n${q.question}\\n\\n`;\n if (q.importance) {\n context += `**Importance:** ${q.importance}\\n`;\n }\n if (q.context) {\n context += `**Context:** ${q.context}\\n`;\n }\n if (q.suggestedResources.length > 0) {\n context += `**Resources:** ${q.suggestedResources.join(', ')}\\n`;\n }\n context += '\\n---\\n\\n';\n }\n\n // Add relevant documentation context\n context += '\\n## Available Documentation Context\\n\\n';\n const relevantDocs = this.findRelevantDocs(\n questions.map(q => q.question).join(' '),\n docsContext,\n 5\n );\n for (const [path, content] of relevantDocs) {\n context += `### ${path}\\n`;\n context += content.slice(0, 3000) + '\\n\\n';\n }\n\n context += '\\n## Instructions\\n';\n context += 'For each research question:\\n';\n context += '1. Analyze the available documentation\\n';\n context += '2. Synthesize a well-researched answer\\n';\n context += '3. Cite sources using [[wiki-links]]\\n';\n context += '4. Identify any remaining unknowns\\n';\n context += '5. Suggest best practices based on the knowledge graph\\n';\n\n return context;\n }\n\n /**\n * Build context for MOC builder agent\n */\n private buildMOCBuilderContext(\n gaps: DocumentationGap[],\n docsContext: Map<string, string>,\n analysis: ParsedAnalysis\n ): string {\n let context = '## Project Context\\n\\n';\n\n // Include the project vision so MOCs reflect actual project content\n if (analysis.vision.purpose) {\n context += `### Project Purpose\\n${analysis.vision.purpose}\\n\\n`;\n }\n if (analysis.vision.goals.length > 0) {\n context += `### Key Goals\\n`;\n for (const goal of analysis.vision.goals.slice(0, 5)) {\n context += `- ${goal}\\n`;\n }\n context += '\\n';\n }\n\n context += '## MOC Files to Populate\\n\\n';\n\n // Find all MOC files\n const mocFiles = Array.from(docsContext.keys()).filter(k =>\n k.includes('_MOC.md') || k.includes('MOC.md')\n );\n\n context += '### Current MOC Files\\n';\n for (const mocFile of mocFiles) {\n const content = docsContext.get(mocFile) || '';\n const isEmpty = content.length < 200 || content.includes('stub');\n context += `- ${mocFile} ${isEmpty ? '(EMPTY/STUB)' : '(has content)'}\\n`;\n }\n\n context += '\\n### Gap Analysis Related to MOCs\\n';\n for (const gap of gaps) {\n context += `- ${gap.section}: ${gap.description}\\n`;\n if (gap.recommendation) {\n context += ` Recommendation: ${gap.recommendation}\\n`;\n }\n }\n\n // Add directory structure with document names\n context += '\\n### Documentation Structure\\n';\n const directories = new Set<string>();\n for (const path of docsContext.keys()) {\n const dir = dirname(path);\n if (dir !== '.') {\n directories.add(dir);\n }\n }\n for (const dir of directories) {\n const docsInDir = Array.from(docsContext.keys()).filter(k => dirname(k) === dir);\n context += `- ${dir}/ (${docsInDir.length} docs)\\n`;\n for (const doc of docsInDir.slice(0, 10)) {\n context += ` - ${basename(doc)}\\n`;\n }\n }\n\n // Include key technical docs for context\n context += '\\n### Key Technical Documentation (for reference)\\n';\n const keyDocs = Array.from(docsContext.entries())\n .filter(([path]) => {\n const lower = path.toLowerCase();\n return lower.includes('test_strategy') || lower.includes('wasm') ||\n lower.includes('architecture') || lower.includes('original_spec');\n })\n .slice(0, 3);\n\n for (const [path, content] of keyDocs) {\n context += `\\n#### ${path}\\n`;\n context += content.slice(0, 2000) + '\\n';\n }\n\n context += '\\n## Instructions\\n';\n context += 'CRITICAL: Create MOCs that reflect the ACTUAL project content, not generic placeholders.\\n';\n context += 'Use the project context and technical documentation above.\\n\\n';\n context += 'For each empty/stub MOC file:\\n';\n context += '1. Create a proper introduction describing what the section covers IN THIS PROJECT\\n';\n context += '2. List all documents in that directory with [[wiki-links]]\\n';\n context += '3. Organize by subcategory if applicable\\n';\n context += '4. Add brief, PROJECT-SPECIFIC descriptions for each linked document\\n';\n context += '5. Include navigation links to parent/sibling MOCs\\n';\n context += '6. Reference actual technologies and concepts from the project (e.g., Rust WASM, knowledge graph)\\n';\n\n return context;\n }\n\n /**\n * Build context for connector agent\n */\n private buildConnectorContext(connections: ConnectionSuggestion[], docsContext: Map<string, string>): string {\n let context = '## Suggested Knowledge Graph Connections\\n\\n';\n\n for (const conn of connections) {\n context += `- [${conn.source}] --${conn.relationship}--> [${conn.target}]`;\n if (conn.reason) {\n context += `: ${conn.reason}`;\n }\n context += '\\n';\n }\n\n context += '\\n## Existing Documents\\n';\n for (const [path] of Array.from(docsContext.entries()).slice(0, 30)) {\n context += `- [[${path.replace('.md', '')}]]\\n`;\n }\n\n context += '\\n## Instructions\\n';\n context += 'For each suggested connection:\\n';\n context += '1. Find the source document\\n';\n context += '2. Add appropriate wiki-link [[target]] to the source\\n';\n context += '3. Consider adding reciprocal links where appropriate\\n';\n context += '4. Use \"See also\" or \"Related\" sections for connections\\n';\n context += '5. Ensure the link context is meaningful\\n';\n\n return context;\n }\n\n /**\n * Build context for integrator agent\n */\n private buildIntegratorContext(analysis: ParsedAnalysis, docsContext: Map<string, string>): string {\n let context = '## Integration Context\\n\\n';\n\n context += '### Project Vision\\n';\n context += analysis.vision.purpose + '\\n\\n';\n\n context += '### Goals\\n';\n for (const goal of analysis.vision.goals) {\n context += `- ${goal}\\n`;\n }\n\n context += '\\n### Key Recommendations\\n';\n for (const rec of analysis.vision.recommendations) {\n context += `- ${rec}\\n`;\n }\n\n context += '\\n### Statistics\\n';\n context += `- Total documents: ${docsContext.size}\\n`;\n context += `- Gaps identified: ${analysis.gaps.length}\\n`;\n context += `- Questions to answer: ${analysis.questions.length}\\n`;\n context += `- Connections to build: ${analysis.connections.length}\\n`;\n\n context += '\\n## Instructions\\n';\n context += 'Create an integration summary that:\\n';\n context += '1. Lists all changes made during migration\\n';\n context += '2. Highlights any remaining gaps\\n';\n context += '3. Suggests next steps for documentation improvement\\n';\n context += '4. Provides a quality assessment\\n';\n\n return context;\n }\n\n /**\n * Execute a single migration agent\n */\n private async executeAgent(\n agent: MigrationAgent,\n analysis: ParsedAnalysis,\n docsContext: Map<string, string>\n ): Promise<{\n documentsCreated?: number;\n documentsUpdated?: number;\n gapsFilled?: number;\n questionsAnswered?: number;\n connectionsAdded?: number;\n }> {\n this.log('info', `Executing agent: ${agent.name}`, { type: agent.type });\n\n const prompt = this.buildAgentPrompt(agent);\n const response = await this.callAI(prompt, agent.type);\n\n if (!response) {\n throw new Error('No response from AI');\n }\n\n // Parse response and create/update documents\n const result = await this.processAgentResponse(agent, response, docsContext);\n\n this.log('info', `Agent ${agent.name} completed`, result);\n\n return result;\n }\n\n /**\n * Build prompt for agent\n */\n private buildAgentPrompt(agent: MigrationAgent): string {\n return `# ${agent.name}\n\n## Task\n${agent.task}\n\n${agent.context}\n\n## Output Format\nProvide your response in markdown format with clear sections.\nFor each document to create or update, use this format:\n\n\\`\\`\\`document\n---\npath: relative/path/to/file.md\naction: create|update\n---\n# Document Title\n\nDocument content here with [[wiki-links]] to other documents.\n\\`\\`\\`\n\nFor research answers, use:\n\\`\\`\\`answer\n## Question\nThe original question\n\n## Answer\nYour researched answer with [[citations]]\n\n## Best Practices\n- Recommendation 1\n- Recommendation 2\n\n## Remaining Unknowns\n- Any unresolved items\n\\`\\`\\`\n`;\n }\n\n /**\n * Select the best model based on task complexity\n * - Research and gap-filling tasks use the most capable model\n * - Simpler tasks use faster models\n */\n private selectGeminiModel(agentType: MigrationAgent['type']): string {\n // Use the most capable model for complex reasoning tasks\n const complexTasks = ['gap-filler', 'researcher'];\n if (complexTasks.includes(agentType)) {\n // gemini-2.5-pro for complex planning/research tasks\n return 'gemini-2.5-pro';\n }\n // Use fast model for simpler tasks (gemini-2.5-flash is better than 2.0-flash)\n return 'gemini-2.5-flash';\n }\n\n /**\n * Call AI (Gemini or fallback)\n */\n private async callAI(prompt: string, agentType: MigrationAgent['type']): Promise<string | null> {\n if (this.geminiClient) {\n const modelName = this.selectGeminiModel(agentType);\n try {\n this.log('info', `Using model: ${modelName}`, { agentType });\n const model = this.geminiClient.getGenerativeModel({ model: modelName });\n const result = await model.generateContent(prompt);\n return result.response.text();\n } catch (error) {\n // Fallback to gemini-2.5-flash if the pro model fails\n if (modelName !== 'gemini-2.5-flash') {\n this.log('warn', `${modelName} failed, falling back to gemini-2.5-flash`, { error: String(error) });\n try {\n const fallbackModel = this.geminiClient.getGenerativeModel({ model: 'gemini-2.5-flash' });\n const result = await fallbackModel.generateContent(prompt);\n return result.response.text();\n } catch (fallbackError) {\n this.log('error', 'Gemini fallback also failed', { error: String(fallbackError) });\n }\n } else {\n this.log('error', 'Gemini API call failed', { error: String(error) });\n }\n return null;\n }\n }\n\n // Fallback to Anthropic if available\n if (process.env.ANTHROPIC_API_KEY) {\n try {\n const { default: Anthropic } = await import('@anthropic-ai/sdk');\n const client = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });\n // Use opus for complex tasks, sonnet for simpler ones\n const complexTasks = ['gap-filler', 'researcher'];\n const model = complexTasks.includes(agentType)\n ? 'claude-sonnet-4-20250514' // Best available\n : 'claude-sonnet-4-20250514';\n const message = await client.messages.create({\n model,\n max_tokens: 8000,\n messages: [{ role: 'user', content: prompt }]\n });\n const textBlock = message.content.find(b => b.type === 'text');\n return textBlock ? textBlock.text : null;\n } catch (error) {\n this.log('error', 'Anthropic API call failed', { error: String(error) });\n return null;\n }\n }\n\n return null;\n }\n\n /**\n * Process agent response and create/update documents\n */\n private async processAgentResponse(\n agent: MigrationAgent,\n response: string,\n docsContext: Map<string, string>\n ): Promise<{\n documentsCreated?: number;\n documentsUpdated?: number;\n gapsFilled?: number;\n questionsAnswered?: number;\n connectionsAdded?: number;\n }> {\n const result = {\n documentsCreated: 0,\n documentsUpdated: 0,\n gapsFilled: 0,\n questionsAnswered: 0,\n connectionsAdded: 0\n };\n\n // Extract document blocks\n const documentMatches = response.matchAll(/```document\\n---\\npath:\\s*([^\\n]+)\\naction:\\s*(\\w+)\\n---\\n([\\s\\S]*?)```/g);\n\n for (const match of documentMatches) {\n const path = match[1].trim();\n const action = match[2].trim();\n const content = match[3].trim();\n\n if (this.dryRun) {\n this.log('info', `[DRY RUN] Would ${action}: ${path}`);\n continue;\n }\n\n const fullPath = join(this.projectRoot, this.docsPath, path);\n\n // Ensure directory exists\n const dir = dirname(fullPath);\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n\n // Write document\n const finalContent = this.addFrontmatter(content, path, agent.type);\n writeFileSync(fullPath, finalContent, 'utf-8');\n\n if (action === 'create') {\n result.documentsCreated++;\n if (agent.type === 'gap-filler') {\n result.gapsFilled++;\n }\n } else {\n result.documentsUpdated++;\n }\n\n // Count connections added\n const wikiLinks = content.match(/\\[\\[[^\\]]+\\]\\]/g) || [];\n result.connectionsAdded += wikiLinks.length;\n }\n\n // Extract answer blocks\n const answerMatches = response.matchAll(/```answer\\n([\\s\\S]*?)```/g);\n for (const match of answerMatches) {\n result.questionsAnswered++;\n\n // Save answer to research output file\n if (agent.outputFile && !this.dryRun) {\n const outputPath = join(this.projectRoot, this.docsPath, 'analysis', agent.outputFile);\n const existing = existsSync(outputPath) ? readFileSync(outputPath, 'utf-8') : '';\n const newContent = existing + '\\n\\n---\\n\\n' + match[1].trim();\n writeFileSync(outputPath, newContent, 'utf-8');\n }\n }\n\n // If agent has output file and no document blocks, save raw response\n if (agent.outputFile && result.documentsCreated === 0 && !this.dryRun) {\n const outputPath = join(this.projectRoot, this.docsPath, 'analysis', agent.outputFile);\n const frontmatter = `---\ntitle: \"${agent.name}\"\ntype: migration-output\ngenerator: migration-orchestrator\nagent: ${agent.type}\ncreated: ${new Date().toISOString()}\n---\n\n# ${agent.name}\n\n> Generated by MigrationOrchestrator\n\n`;\n writeFileSync(outputPath, frontmatter + response, 'utf-8');\n result.documentsCreated++;\n }\n\n return result;\n }\n\n /**\n * Add frontmatter to document if not present\n */\n private addFrontmatter(content: string, path: string, agentType: string): string {\n if (content.startsWith('---')) {\n return content;\n }\n\n const title = basename(path, '.md').replace(/-/g, ' ').replace(/_/g, ' ');\n const type = this.inferDocType(path);\n\n return `---\ntitle: \"${title}\"\ntype: ${type}\ngenerator: migration-orchestrator\nagent: ${agentType}\ncreated: ${new Date().toISOString()}\n---\n\n${content}`;\n }\n\n /**\n * Infer document type from path\n */\n private inferDocType(path: string): string {\n if (path.includes('concepts')) return 'concept';\n if (path.includes('components')) return 'component';\n if (path.includes('services')) return 'service';\n if (path.includes('features')) return 'feature';\n if (path.includes('guides')) return 'guide';\n if (path.includes('references')) return 'reference';\n if (path.includes('standards')) return 'standard';\n if (path.includes('integrations')) return 'integration';\n if (path.includes('MOC')) return 'moc';\n return 'document';\n }\n\n /**\n * Update MOC files with new connections\n */\n private async updateMOCFiles(connections: ConnectionSuggestion[]): Promise<void> {\n // This would update MOC files with new links\n // For now, we'll let the MOC builder agent handle this\n this.log('info', 'MOC files updated with new connections', { count: connections.length });\n }\n\n /**\n * Find relevant docs based on query\n */\n private findRelevantDocs(\n query: string,\n docsContext: Map<string, string>,\n limit: number\n ): Map<string, string> {\n const relevant = new Map<string, string>();\n const queryWords = query.toLowerCase().split(/\\s+/).filter(w => w.length > 3);\n\n // Simple keyword matching (would use vector search if available)\n const scored = Array.from(docsContext.entries()).map(([path, content]) => {\n let score = 0;\n const lowerContent = content.toLowerCase();\n for (const word of queryWords) {\n if (lowerContent.includes(word)) {\n score++;\n }\n }\n return { path, content, score };\n });\n\n scored.sort((a, b) => b.score - a.score);\n\n for (const item of scored.slice(0, limit)) {\n if (item.score > 0) {\n relevant.set(item.path, item.content);\n }\n }\n\n return relevant;\n }\n\n /**\n * Infer priority from description\n */\n private inferPriority(description: string, recommendation: string): 'high' | 'medium' | 'low' {\n const text = (description + ' ' + recommendation).toLowerCase();\n\n if (text.includes('critical') || text.includes('missing') || text.includes('empty') ||\n text.includes('stub') || text.includes('required')) {\n return 'high';\n }\n\n if (text.includes('should') || text.includes('recommend') || text.includes('consider')) {\n return 'medium';\n }\n\n return 'low';\n }\n\n /**\n * Log message\n */\n private log(level: 'info' | 'warn' | 'error', message: string, data?: Record<string, unknown>): void {\n if (!this.verbose && level === 'info') return;\n\n const timestamp = new Date().toISOString().split('T')[1].split('.')[0];\n const prefix = level === 'error' ? '❌' : level === 'warn' ? '⚠️' : '📋';\n\n console.log(`[${timestamp}] ${prefix} [migration] ${message}`, data ? JSON.stringify(data) : '');\n }\n}\n\nexport type { MigrationResult, OrchestratorOptions, ParsedAnalysis };\n"],"names":[],"mappings":";;;AAkHO,MAAM,sBAAsB;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAA0C;AAAA,EAElD,YAAY,SAA8B;AACxC,SAAK,cAAc,QAAQ;AAC3B,SAAK,WAAW,QAAQ;AACxB,SAAK,cAAc,QAAQ;AAC3B,SAAK,UAAU,QA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AAI,KAAK,SAAS,UAAU,KAAK,KAAK,SAAS,SAAS,KAAK,KAAK,SAAS,OAAO,KAC9E,KAAK,SAAS,MAAM,KAAK,KAAK,SAAS,UAAU,GAAG;AACtD,aAAO;AAAA,IACT;AAEA,QAAI,KAAK,SAAS,QAAQ,KAAK,KAAK,SAAS,WAAW,KAAK,KAAK,SAAS,UAAU,GAAG;AACtF,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKQ,IAAI,OAAkC,SAAiB,MAAsC;AACnG,QAAI,CAAC,KAAK,WAAW,UAAU,OAAQ;AAEvC,UAAM,aAAY,oBAAI,KAAA,GAAO,cAAc,MAAM,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC;AACrE,UAAM,SAAS,UAAU,UAAU,MAAM,UAAU,SAAS,OAAO;AAEnE,YAAQ,IAAI,IAAI,SAAS,KAAK,MAAM,gBAAgB,OAAO,IAAI,OAAO,KAAK,UAAU,IAAI,IAAI,EAAE;AAAA,EACjG;AACF;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weavelogic/knowledge-graph-agent",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.3",
|
|
4
4
|
"description": "Knowledge graph agent for Claude Code - generates knowledge graphs, initializes docs, and integrates with claude-flow",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|