@weavelogic/knowledge-graph-agent 0.10.7 → 0.11.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/dist/cli/commands/analyze.d.ts.map +1 -1
- package/dist/cli/commands/analyze.js +102 -0
- package/dist/cli/commands/analyze.js.map +1 -1
- package/dist/cultivation/deep-analyzer.d.ts +16 -0
- package/dist/cultivation/deep-analyzer.d.ts.map +1 -1
- package/dist/cultivation/deep-analyzer.js +227 -11
- package/dist/cultivation/deep-analyzer.js.map +1 -1
- package/dist/cultivation/migration-orchestrator.d.ts +195 -0
- package/dist/cultivation/migration-orchestrator.d.ts.map +1 -0
- package/dist/cultivation/migration-orchestrator.js +797 -0
- package/dist/cultivation/migration-orchestrator.js.map +1 -0
- package/dist/node_modules/@typescript-eslint/types/dist/index.js +1 -1
- package/dist/node_modules/@typescript-eslint/visitor-keys/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/analyze.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,
|
|
1
|
+
{"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/analyze.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAoe9C"}
|
|
@@ -173,6 +173,108 @@ function createAnalyzeCommand() {
|
|
|
173
173
|
process.exit(1);
|
|
174
174
|
}
|
|
175
175
|
});
|
|
176
|
+
command.command("migrate").description("Implement analysis recommendations using AI agents to fill gaps, answer questions, and build connections").argument("[path]", "Project root path", ".").option("-d, --docs <dir>", "Documentation directory", "docs").option("-a, --analysis <dir>", "Analysis directory (relative to docs)", "analysis").option("--max-agents <n>", "Maximum parallel agents", "8").option("--dry-run", "Preview changes without making them").option("--use-vector", "Use vector search for context retrieval").option("-v, --verbose", "Verbose output").action(async (path, options) => {
|
|
177
|
+
const spinner = ora("Initializing migration orchestration...").start();
|
|
178
|
+
try {
|
|
179
|
+
const projectRoot = validateProjectRoot(path);
|
|
180
|
+
const docsDir = options.docs;
|
|
181
|
+
const analysisDir = options.analysis;
|
|
182
|
+
const dryRun = options.dryRun ?? false;
|
|
183
|
+
const verbose = options.verbose ?? false;
|
|
184
|
+
const analysisPath = join(projectRoot, docsDir, analysisDir);
|
|
185
|
+
if (!existsSync(analysisPath)) {
|
|
186
|
+
spinner.fail(`Analysis directory not found: ${analysisPath}`);
|
|
187
|
+
console.log(chalk.gray(' Run "kg cultivate --deep-analysis" first to generate analysis'));
|
|
188
|
+
process.exit(1);
|
|
189
|
+
}
|
|
190
|
+
const requiredFiles = ["documentation-gaps.md", "research-questions.md"];
|
|
191
|
+
const missingFiles = requiredFiles.filter((f) => !existsSync(join(analysisPath, f)));
|
|
192
|
+
if (missingFiles.length > 0) {
|
|
193
|
+
spinner.warn(`Missing analysis files: ${missingFiles.join(", ")}`);
|
|
194
|
+
console.log(chalk.gray(' Run "kg cultivate --deep-analysis" to generate complete analysis'));
|
|
195
|
+
}
|
|
196
|
+
const { MigrationOrchestrator } = await import("../../cultivation/migration-orchestrator.js");
|
|
197
|
+
const orchestrator = new MigrationOrchestrator({
|
|
198
|
+
projectRoot,
|
|
199
|
+
docsPath: docsDir,
|
|
200
|
+
analysisDir,
|
|
201
|
+
verbose,
|
|
202
|
+
dryRun,
|
|
203
|
+
useVectorSearch: options.useVector ?? false,
|
|
204
|
+
maxAgents: parseInt(options.maxAgents || "8", 10)
|
|
205
|
+
});
|
|
206
|
+
const status = await orchestrator.getAvailabilityStatus();
|
|
207
|
+
if (!status.available) {
|
|
208
|
+
spinner.fail("Migration unavailable");
|
|
209
|
+
console.log(chalk.red(` ${status.reason}`));
|
|
210
|
+
console.log(chalk.gray(" Set GOOGLE_GEMINI_API_KEY or ANTHROPIC_API_KEY"));
|
|
211
|
+
process.exit(1);
|
|
212
|
+
}
|
|
213
|
+
spinner.text = `Running migration (${status.reason})...`;
|
|
214
|
+
if (dryRun) {
|
|
215
|
+
spinner.text = `Running migration dry run (${status.reason})...`;
|
|
216
|
+
}
|
|
217
|
+
const result = await orchestrator.migrate();
|
|
218
|
+
if (result.success) {
|
|
219
|
+
if (dryRun) {
|
|
220
|
+
spinner.succeed("Migration dry run complete!");
|
|
221
|
+
} else {
|
|
222
|
+
spinner.succeed("Migration complete!");
|
|
223
|
+
}
|
|
224
|
+
} else {
|
|
225
|
+
spinner.warn("Migration completed with errors");
|
|
226
|
+
}
|
|
227
|
+
console.log();
|
|
228
|
+
console.log(chalk.cyan.bold(" Migration Results"));
|
|
229
|
+
console.log(chalk.gray(" ─────────────────────────────────────"));
|
|
230
|
+
console.log();
|
|
231
|
+
if (dryRun) {
|
|
232
|
+
console.log(chalk.yellow(" [DRY RUN] No changes were made\n"));
|
|
233
|
+
}
|
|
234
|
+
console.log(chalk.white(" Summary:"));
|
|
235
|
+
console.log(chalk.gray(` Analysis dir: ${docsDir}/${analysisDir}/`));
|
|
236
|
+
console.log(chalk.green(` Agents used: ${result.agentsUsed}`));
|
|
237
|
+
console.log(chalk.green(` Documents created: ${result.documentsCreated}`));
|
|
238
|
+
console.log(chalk.blue(` Documents updated: ${result.documentsUpdated}`));
|
|
239
|
+
console.log(chalk.cyan(` Gaps filled: ${result.gapsFilled}`));
|
|
240
|
+
console.log(chalk.cyan(` Questions answered: ${result.questionsAnswered}`));
|
|
241
|
+
console.log(chalk.cyan(` Connections added: ${result.connectionsAdded}`));
|
|
242
|
+
console.log(chalk.gray(` Duration: ${(result.duration / 1e3).toFixed(1)}s`));
|
|
243
|
+
if (result.warnings.length > 0) {
|
|
244
|
+
console.log();
|
|
245
|
+
console.log(chalk.yellow(" Warnings:"));
|
|
246
|
+
result.warnings.slice(0, 5).forEach((w) => {
|
|
247
|
+
console.log(chalk.gray(` - ${w}`));
|
|
248
|
+
});
|
|
249
|
+
if (result.warnings.length > 5) {
|
|
250
|
+
console.log(chalk.gray(` ... and ${result.warnings.length - 5} more`));
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (result.errors.length > 0) {
|
|
254
|
+
console.log();
|
|
255
|
+
console.log(chalk.red(" Errors:"));
|
|
256
|
+
result.errors.slice(0, 5).forEach((e) => {
|
|
257
|
+
console.log(chalk.gray(` - ${e}`));
|
|
258
|
+
});
|
|
259
|
+
if (result.errors.length > 5) {
|
|
260
|
+
console.log(chalk.gray(` ... and ${result.errors.length - 5} more`));
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (!dryRun && result.documentsCreated > 0) {
|
|
264
|
+
console.log();
|
|
265
|
+
console.log(chalk.cyan(" Next steps:"));
|
|
266
|
+
console.log(chalk.white(` 1. Review generated documents in ${docsDir}/`));
|
|
267
|
+
console.log(chalk.white(` 2. Check ${docsDir}/${analysisDir}/ for summaries`));
|
|
268
|
+
console.log(chalk.white(` 3. Run: kg graph --docs ${docsDir}`));
|
|
269
|
+
console.log(chalk.white(` 4. Run: kg stats --docs ${docsDir}`));
|
|
270
|
+
}
|
|
271
|
+
console.log();
|
|
272
|
+
} catch (error) {
|
|
273
|
+
spinner.fail("Migration failed");
|
|
274
|
+
console.error(chalk.red(String(error)));
|
|
275
|
+
process.exit(1);
|
|
276
|
+
}
|
|
277
|
+
});
|
|
176
278
|
command.command("report").description("Generate analysis report without creating files").option("-p, --path <path>", "Project root path", ".").option("-s, --source <dir>", "Source docs directory", "docs").option("--json", "Output as JSON").action(async (options) => {
|
|
177
279
|
const spinner = ora("Generating analysis report...").start();
|
|
178
280
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze.js","sources":["../../../src/cli/commands/analyze.ts"],"sourcesContent":["/**\n * Analyze Command\n *\n * Advanced documentation analyzer using claude-flow for deep analysis\n * and creating proper knowledge graph documentation structure.\n */\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport ora from 'ora';\nimport { existsSync } from 'fs';\nimport { join } from 'path';\nimport { analyzeDocs } from '../../generators/docs-analyzer.js';\nimport { validateProjectRoot } from '../../core/security.js';\n\n/**\n * Create analyze command\n */\nexport function createAnalyzeCommand(): Command {\n const command = new Command('analyze');\n\n command\n .description('Analyze and migrate docs to knowledge graph structure')\n .option('-p, --path <path>', 'Project root path', '.')\n .option('-s, --source <dir>', 'Source docs directory', 'docs')\n .option('-t, --target <dir>', 'Target directory', 'docs')\n .option('--use-claude-flow', 'Use claude-flow for deep analysis')\n .option('--no-moc', 'Skip MOC (Map of Content) generation')\n .option('--no-link-original', 'Do not link back to original docs')\n .option('--max-depth <n>', 'Maximum analysis depth', '3')\n .option('--dry-run', 'Show what would be done without making changes')\n .option('-v, --verbose', 'Verbose output')\n .action(async (options) => {\n const spinner = ora('Analyzing documentation...').start();\n\n try {\n const projectRoot = validateProjectRoot(options.path);\n const sourceDir = options.source;\n const targetDir = options.target;\n\n // Check source exists\n if (!existsSync(join(projectRoot, sourceDir))) {\n spinner.fail(`Source directory not found: ${sourceDir}`);\n console.log(chalk.gray(' Specify source with --source <dir>'));\n process.exit(1);\n }\n\n // Check if target already exists\n if (existsSync(join(projectRoot, targetDir)) && !options.dryRun) {\n spinner.warn(`Target directory exists: ${targetDir}`);\n console.log(chalk.yellow(' Files may be overwritten. Use --dry-run to preview.'));\n }\n\n if (options.dryRun) {\n spinner.text = 'Analyzing documentation (dry run)...';\n }\n\n if (options.useClaudeFlow) {\n spinner.text = 'Analyzing with claude-flow (deep analysis)...';\n }\n\n const result = await analyzeDocs({\n sourceDir,\n targetDir,\n projectRoot,\n useClaudeFlow: options.useClaudeFlow,\n createMOC: options.moc !== false,\n linkOriginal: options.linkOriginal !== false,\n maxDepth: parseInt(options.maxDepth, 10),\n dryRun: options.dryRun,\n verbose: options.verbose,\n });\n\n if (result.success) {\n if (options.dryRun) {\n spinner.succeed('Dry run complete!');\n } else {\n spinner.succeed('Documentation analyzed and migrated!');\n }\n } else {\n spinner.warn('Analysis completed with errors');\n }\n\n // Display results\n console.log();\n console.log(chalk.cyan.bold(' Analysis Results'));\n console.log(chalk.gray(' ─────────────────────────────────────'));\n console.log();\n console.log(chalk.white(' Summary:'));\n console.log(chalk.gray(` Source: ${sourceDir}/`));\n console.log(chalk.gray(` Target: ${targetDir}/`));\n console.log(chalk.green(` Files analyzed: ${result.filesAnalyzed}`));\n console.log(chalk.green(` Files created: ${result.filesCreated}`));\n console.log(chalk.blue(` MOC files: ${result.mocFilesCreated}`));\n\n // Category breakdown\n if (result.structure.size > 0) {\n console.log();\n console.log(chalk.white(' Categories:'));\n for (const [category, docs] of result.structure) {\n console.log(chalk.cyan(` ${category.padEnd(15)}`), chalk.gray(`${docs.length} docs`));\n }\n }\n\n // Show sample analyzed documents\n if (result.analyzed.length > 0 && options.verbose) {\n console.log();\n console.log(chalk.white(' Sample documents:'));\n result.analyzed.slice(0, 5).forEach(doc => {\n console.log(chalk.gray(` ${doc.originalPath}`));\n console.log(chalk.cyan(` → ${doc.newPath}`) + chalk.gray(` [${doc.type}]`));\n if (doc.tags.length > 0) {\n console.log(chalk.gray(` tags: ${doc.tags.slice(0, 5).map(t => `#${t}`).join(' ')}`));\n }\n });\n if (result.analyzed.length > 5) {\n console.log(chalk.gray(` ... and ${result.analyzed.length - 5} more`));\n }\n }\n\n // Show errors\n if (result.errors.length > 0) {\n console.log();\n console.log(chalk.red(' Errors:'));\n result.errors.slice(0, 5).forEach(err => {\n console.log(chalk.gray(` - ${err}`));\n });\n if (result.errors.length > 5) {\n console.log(chalk.gray(` ... and ${result.errors.length - 5} more`));\n }\n }\n\n // Research needed summary\n const researchDocs = result.analyzed.filter(d => d.researchNeeded.length > 0);\n const todoDocs = result.analyzed.filter(d => d.todos.length > 0);\n\n if (researchDocs.length > 0 || todoDocs.length > 0) {\n console.log();\n console.log(chalk.yellow(' Attention Needed:'));\n if (researchDocs.length > 0) {\n console.log(chalk.yellow(` 📚 ${researchDocs.length} docs need research`));\n }\n if (todoDocs.length > 0) {\n console.log(chalk.yellow(` ✏️ ${todoDocs.length} docs have TODOs`));\n }\n }\n\n // Next steps\n if (!options.dryRun && result.filesCreated > 0) {\n console.log();\n console.log(chalk.cyan(' Next steps:'));\n console.log(chalk.white(` 1. Review ${targetDir}/MOC.md (Master Index)`));\n console.log(chalk.white(` 2. Check ${targetDir}/PRIMITIVES.md`));\n console.log(chalk.white(` 3. Run: kg graph --docs ${targetDir}`));\n console.log(chalk.white(` 4. Run: kg stats --docs ${targetDir}`));\n if (researchDocs.length > 0) {\n console.log(chalk.white(` 5. Address research items in flagged docs`));\n }\n }\n\n console.log();\n\n } catch (error) {\n spinner.fail('Analysis failed');\n console.error(chalk.red(String(error)));\n process.exit(1);\n }\n });\n\n // Deep analyze subcommand (uses claude-flow agents)\n command\n .command('deep')\n .description('Deep analysis using claude-flow agents for comprehensive knowledge extraction')\n .option('-p, --path <path>', 'Project root path', '.')\n .option('-s, --source <dir>', 'Source docs directory', 'docs')\n .option('-t, --target <dir>', 'Target directory', 'docs')\n .option('--agents <n>', 'Number of parallel agents', '3')\n .action(async (options) => {\n const spinner = ora('Initializing deep analysis with claude-flow...').start();\n\n try {\n const projectRoot = validateProjectRoot(options.path);\n const sourceDir = options.source;\n const targetDir = options.target;\n\n // Check source exists\n if (!existsSync(join(projectRoot, sourceDir))) {\n spinner.fail(`Source directory not found: ${sourceDir}`);\n process.exit(1);\n }\n\n spinner.text = 'Running claude-flow deep analysis...';\n\n // Run deep analysis with claude-flow\n const result = await analyzeDocs({\n sourceDir,\n targetDir,\n projectRoot,\n useClaudeFlow: true,\n createMOC: true,\n linkOriginal: true,\n maxDepth: 5,\n dryRun: false,\n verbose: true,\n });\n\n if (result.success) {\n spinner.succeed('Deep analysis complete!');\n } else {\n spinner.warn('Deep analysis completed with some errors');\n }\n\n console.log();\n console.log(chalk.cyan.bold(' Deep Analysis Results'));\n console.log(chalk.gray(' ─────────────────────────────────────'));\n console.log(chalk.green(` Documents analyzed: ${result.filesAnalyzed}`));\n console.log(chalk.green(` Knowledge docs: ${result.filesCreated}`));\n console.log(chalk.blue(` Index files (MOC): ${result.mocFilesCreated}`));\n console.log(chalk.gray(` Categories: ${result.structure.size}`));\n\n // Research summary\n const totalResearch = result.analyzed.reduce((sum, d) => sum + d.researchNeeded.length, 0);\n const totalTodos = result.analyzed.reduce((sum, d) => sum + d.todos.length, 0);\n\n console.log();\n console.log(chalk.white(' Knowledge extraction:'));\n console.log(chalk.cyan(` Research areas: ${totalResearch}`));\n console.log(chalk.cyan(` TODOs found: ${totalTodos}`));\n console.log(chalk.cyan(` Concepts: ${result.analyzed.reduce((sum, d) => sum + d.concepts.length, 0)}`));\n console.log(chalk.cyan(` Cross-refs: ${result.analyzed.reduce((sum, d) => sum + d.related.length, 0)}`));\n\n console.log();\n console.log(chalk.white(` Output: ${targetDir}/`));\n console.log(chalk.gray(` MOC.md Master index`));\n console.log(chalk.gray(` PRIMITIVES.md Core building blocks`));\n console.log(chalk.gray(` */\\_MOC.md Category indexes`));\n console.log();\n\n } catch (error) {\n spinner.fail('Deep analysis failed');\n console.error(chalk.red(String(error)));\n process.exit(1);\n }\n });\n\n // Report subcommand\n command\n .command('report')\n .description('Generate analysis report without creating files')\n .option('-p, --path <path>', 'Project root path', '.')\n .option('-s, --source <dir>', 'Source docs directory', 'docs')\n .option('--json', 'Output as JSON')\n .action(async (options) => {\n const spinner = ora('Generating analysis report...').start();\n\n try {\n const projectRoot = validateProjectRoot(options.path);\n const sourceDir = options.source;\n\n if (!existsSync(join(projectRoot, sourceDir))) {\n spinner.fail(`Source directory not found: ${sourceDir}`);\n process.exit(1);\n }\n\n const result = await analyzeDocs({\n sourceDir,\n targetDir: 'docs',\n projectRoot,\n useClaudeFlow: false,\n createMOC: false,\n linkOriginal: false,\n dryRun: true,\n verbose: false,\n });\n\n spinner.succeed('Report generated!');\n\n if (options.json) {\n // JSON output\n const report = {\n summary: {\n totalDocs: result.filesAnalyzed,\n categories: Object.fromEntries(result.structure),\n },\n documents: result.analyzed.map(d => ({\n original: d.originalPath,\n target: d.newPath,\n type: d.type,\n category: d.category,\n tags: d.tags,\n concepts: d.concepts,\n researchNeeded: d.researchNeeded,\n todos: d.todos,\n })),\n researchAreas: result.analyzed\n .flatMap(d => d.researchNeeded.map(r => ({ doc: d.title, area: r }))),\n todos: result.analyzed\n .flatMap(d => d.todos.map(t => ({ doc: d.title, todo: t }))),\n };\n console.log(JSON.stringify(report, null, 2));\n } else {\n // Human-readable output\n console.log();\n console.log(chalk.cyan.bold(' Documentation Analysis Report'));\n console.log(chalk.gray(' ─────────────────────────────────────'));\n console.log();\n console.log(chalk.white(` Total documents: ${result.filesAnalyzed}`));\n console.log();\n\n // Type breakdown\n const byType = new Map<string, number>();\n result.analyzed.forEach(d => {\n byType.set(d.type, (byType.get(d.type) || 0) + 1);\n });\n\n console.log(chalk.white(' By Type:'));\n for (const [type, count] of byType) {\n const bar = '█'.repeat(Math.ceil(count / result.filesAnalyzed * 20));\n console.log(chalk.cyan(` ${type.padEnd(12)} ${bar} ${count}`));\n }\n console.log();\n\n // Category breakdown\n console.log(chalk.white(' By Category:'));\n for (const [category, docs] of result.structure) {\n const bar = '█'.repeat(Math.ceil(docs.length / result.filesAnalyzed * 20));\n console.log(chalk.cyan(` ${category.padEnd(12)} ${bar} ${docs.length}`));\n }\n console.log();\n\n // Issues\n const withResearch = result.analyzed.filter(d => d.researchNeeded.length > 0);\n const withTodos = result.analyzed.filter(d => d.todos.length > 0);\n\n console.log(chalk.white(' Areas Needing Attention:'));\n console.log(chalk.yellow(` 📚 Research needed: ${withResearch.length} docs`));\n console.log(chalk.yellow(` ✏️ With TODOs: ${withTodos.length} docs`));\n console.log();\n\n // Top research areas\n if (withResearch.length > 0) {\n console.log(chalk.white(' Top Research Areas:'));\n withResearch.slice(0, 5).forEach(d => {\n console.log(chalk.gray(` ${d.title}:`));\n d.researchNeeded.slice(0, 2).forEach(r => {\n console.log(chalk.yellow(` - ${r.slice(0, 60)}...`));\n });\n });\n console.log();\n }\n\n console.log(chalk.cyan(' Run `kg analyze` to migrate documentation'));\n console.log();\n }\n\n } catch (error) {\n spinner.fail('Report generation failed');\n console.error(chalk.red(String(error)));\n process.exit(1);\n }\n });\n\n return command;\n}\n"],"names":[],"mappings":";;;;;;;AAkBO,SAAS,uBAAgC;AAC9C,QAAM,UAAU,IAAI,QAAQ,SAAS;AAErC,UACG,YAAY,uDAAuD,EACnE,OAAO,qBAAqB,qBAAqB,GAAG,EACpD,OAAO,sBAAsB,yBAAyB,MAAM,EAC5D,OAAO,sBAAsB,oBAAoB,MAAM,EACvD,OAAO,qBAAqB,mCAAmC,EAC/D,OAAO,YAAY,sCAAsC,EACzD,OAAO,sBAAsB,mCAAmC,EAChE,OAAO,mBAAmB,0BAA0B,GAAG,EACvD,OAAO,aAAa,gDAAgD,EACpE,OAAO,iBAAiB,gBAAgB,EACxC,OAAO,OAAO,YAAY;AACzB,UAAM,UAAU,IAAI,4BAA4B,EAAE,MAAA;AAElD,QAAI;AACF,YAAM,cAAc,oBAAoB,QAAQ,IAAI;AACpD,YAAM,YAAY,QAAQ;AAC1B,YAAM,YAAY,QAAQ;AAG1B,UAAI,CAAC,WAAW,KAAK,aAAa,SAAS,CAAC,GAAG;AAC7C,gBAAQ,KAAK,+BAA+B,SAAS,EAAE;AACvD,gBAAQ,IAAI,MAAM,KAAK,sCAAsC,CAAC;AAC9D,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAGA,UAAI,WAAW,KAAK,aAAa,SAAS,CAAC,KAAK,CAAC,QAAQ,QAAQ;AAC/D,gBAAQ,KAAK,4BAA4B,SAAS,EAAE;AACpD,gBAAQ,IAAI,MAAM,OAAO,uDAAuD,CAAC;AAAA,MACnF;AAEA,UAAI,QAAQ,QAAQ;AAClB,gBAAQ,OAAO;AAAA,MACjB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;AACxC,sBAAQ,IAAI,MAAM,OAAO,WAAW,EAAE,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC;AAAA,YAC1D,CAAC;AAAA,UACH,CAAC;AACD,kBAAQ,IAAA;AAAA,QACV;AAEA,gBAAQ,IAAI,MAAM,KAAK,6CAA6C,CAAC;AACrE,gBAAQ,IAAA;AAAA,MACV;AAAA,IAEF,SAAS,OAAO;AACd,cAAQ,KAAK,0BAA0B;AACvC,cAAQ,MAAM,MAAM,IAAI,OAAO,KAAK,CAAC,CAAC;AACtC,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AAEH,SAAO;AACT;"}
|
|
1
|
+
{"version":3,"file":"analyze.js","sources":["../../../src/cli/commands/analyze.ts"],"sourcesContent":["/**\n * Analyze Command\n *\n * Advanced documentation analyzer using claude-flow for deep analysis\n * and creating proper knowledge graph documentation structure.\n */\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport ora from 'ora';\nimport { existsSync } from 'fs';\nimport { join } from 'path';\nimport { analyzeDocs } from '../../generators/docs-analyzer.js';\nimport { validateProjectRoot } from '../../core/security.js';\n\n/**\n * Create analyze command\n */\nexport function createAnalyzeCommand(): Command {\n const command = new Command('analyze');\n\n command\n .description('Analyze and migrate docs to knowledge graph structure')\n .option('-p, --path <path>', 'Project root path', '.')\n .option('-s, --source <dir>', 'Source docs directory', 'docs')\n .option('-t, --target <dir>', 'Target directory', 'docs')\n .option('--use-claude-flow', 'Use claude-flow for deep analysis')\n .option('--no-moc', 'Skip MOC (Map of Content) generation')\n .option('--no-link-original', 'Do not link back to original docs')\n .option('--max-depth <n>', 'Maximum analysis depth', '3')\n .option('--dry-run', 'Show what would be done without making changes')\n .option('-v, --verbose', 'Verbose output')\n .action(async (options) => {\n const spinner = ora('Analyzing documentation...').start();\n\n try {\n const projectRoot = validateProjectRoot(options.path);\n const sourceDir = options.source;\n const targetDir = options.target;\n\n // Check source exists\n if (!existsSync(join(projectRoot, sourceDir))) {\n spinner.fail(`Source directory not found: ${sourceDir}`);\n console.log(chalk.gray(' Specify source with --source <dir>'));\n process.exit(1);\n }\n\n // Check if target already exists\n if (existsSync(join(projectRoot, targetDir)) && !options.dryRun) {\n spinner.warn(`Target directory exists: ${targetDir}`);\n console.log(chalk.yellow(' Files may be overwritten. Use --dry-run to preview.'));\n }\n\n if (options.dryRun) {\n spinner.text = 'Analyzing documentation (dry run)...';\n }\n\n if (options.useClaudeFlow) {\n spinner.text = 'Analyzing with claude-flow (deep analysis)...';\n }\n\n const result = await analyzeDocs({\n sourceDir,\n targetDir,\n projectRoot,\n useClaudeFlow: options.useClaudeFlow,\n createMOC: options.moc !== false,\n linkOriginal: options.linkOriginal !== false,\n maxDepth: parseInt(options.maxDepth, 10),\n dryRun: options.dryRun,\n verbose: options.verbose,\n });\n\n if (result.success) {\n if (options.dryRun) {\n spinner.succeed('Dry run complete!');\n } else {\n spinner.succeed('Documentation analyzed and migrated!');\n }\n } else {\n spinner.warn('Analysis completed with errors');\n }\n\n // Display results\n console.log();\n console.log(chalk.cyan.bold(' Analysis Results'));\n console.log(chalk.gray(' ─────────────────────────────────────'));\n console.log();\n console.log(chalk.white(' Summary:'));\n console.log(chalk.gray(` Source: ${sourceDir}/`));\n console.log(chalk.gray(` Target: ${targetDir}/`));\n console.log(chalk.green(` Files analyzed: ${result.filesAnalyzed}`));\n console.log(chalk.green(` Files created: ${result.filesCreated}`));\n console.log(chalk.blue(` MOC files: ${result.mocFilesCreated}`));\n\n // Category breakdown\n if (result.structure.size > 0) {\n console.log();\n console.log(chalk.white(' Categories:'));\n for (const [category, docs] of result.structure) {\n console.log(chalk.cyan(` ${category.padEnd(15)}`), chalk.gray(`${docs.length} docs`));\n }\n }\n\n // Show sample analyzed documents\n if (result.analyzed.length > 0 && options.verbose) {\n console.log();\n console.log(chalk.white(' Sample documents:'));\n result.analyzed.slice(0, 5).forEach(doc => {\n console.log(chalk.gray(` ${doc.originalPath}`));\n console.log(chalk.cyan(` → ${doc.newPath}`) + chalk.gray(` [${doc.type}]`));\n if (doc.tags.length > 0) {\n console.log(chalk.gray(` tags: ${doc.tags.slice(0, 5).map(t => `#${t}`).join(' ')}`));\n }\n });\n if (result.analyzed.length > 5) {\n console.log(chalk.gray(` ... and ${result.analyzed.length - 5} more`));\n }\n }\n\n // Show errors\n if (result.errors.length > 0) {\n console.log();\n console.log(chalk.red(' Errors:'));\n result.errors.slice(0, 5).forEach(err => {\n console.log(chalk.gray(` - ${err}`));\n });\n if (result.errors.length > 5) {\n console.log(chalk.gray(` ... and ${result.errors.length - 5} more`));\n }\n }\n\n // Research needed summary\n const researchDocs = result.analyzed.filter(d => d.researchNeeded.length > 0);\n const todoDocs = result.analyzed.filter(d => d.todos.length > 0);\n\n if (researchDocs.length > 0 || todoDocs.length > 0) {\n console.log();\n console.log(chalk.yellow(' Attention Needed:'));\n if (researchDocs.length > 0) {\n console.log(chalk.yellow(` 📚 ${researchDocs.length} docs need research`));\n }\n if (todoDocs.length > 0) {\n console.log(chalk.yellow(` ✏️ ${todoDocs.length} docs have TODOs`));\n }\n }\n\n // Next steps\n if (!options.dryRun && result.filesCreated > 0) {\n console.log();\n console.log(chalk.cyan(' Next steps:'));\n console.log(chalk.white(` 1. Review ${targetDir}/MOC.md (Master Index)`));\n console.log(chalk.white(` 2. Check ${targetDir}/PRIMITIVES.md`));\n console.log(chalk.white(` 3. Run: kg graph --docs ${targetDir}`));\n console.log(chalk.white(` 4. Run: kg stats --docs ${targetDir}`));\n if (researchDocs.length > 0) {\n console.log(chalk.white(` 5. Address research items in flagged docs`));\n }\n }\n\n console.log();\n\n } catch (error) {\n spinner.fail('Analysis failed');\n console.error(chalk.red(String(error)));\n process.exit(1);\n }\n });\n\n // Deep analyze subcommand (uses claude-flow agents)\n command\n .command('deep')\n .description('Deep analysis using claude-flow agents for comprehensive knowledge extraction')\n .option('-p, --path <path>', 'Project root path', '.')\n .option('-s, --source <dir>', 'Source docs directory', 'docs')\n .option('-t, --target <dir>', 'Target directory', 'docs')\n .option('--agents <n>', 'Number of parallel agents', '3')\n .action(async (options) => {\n const spinner = ora('Initializing deep analysis with claude-flow...').start();\n\n try {\n const projectRoot = validateProjectRoot(options.path);\n const sourceDir = options.source;\n const targetDir = options.target;\n\n // Check source exists\n if (!existsSync(join(projectRoot, sourceDir))) {\n spinner.fail(`Source directory not found: ${sourceDir}`);\n process.exit(1);\n }\n\n spinner.text = 'Running claude-flow deep analysis...';\n\n // Run deep analysis with claude-flow\n const result = await analyzeDocs({\n sourceDir,\n targetDir,\n projectRoot,\n useClaudeFlow: true,\n createMOC: true,\n linkOriginal: true,\n maxDepth: 5,\n dryRun: false,\n verbose: true,\n });\n\n if (result.success) {\n spinner.succeed('Deep analysis complete!');\n } else {\n spinner.warn('Deep analysis completed with some errors');\n }\n\n console.log();\n console.log(chalk.cyan.bold(' Deep Analysis Results'));\n console.log(chalk.gray(' ─────────────────────────────────────'));\n console.log(chalk.green(` Documents analyzed: ${result.filesAnalyzed}`));\n console.log(chalk.green(` Knowledge docs: ${result.filesCreated}`));\n console.log(chalk.blue(` Index files (MOC): ${result.mocFilesCreated}`));\n console.log(chalk.gray(` Categories: ${result.structure.size}`));\n\n // Research summary\n const totalResearch = result.analyzed.reduce((sum, d) => sum + d.researchNeeded.length, 0);\n const totalTodos = result.analyzed.reduce((sum, d) => sum + d.todos.length, 0);\n\n console.log();\n console.log(chalk.white(' Knowledge extraction:'));\n console.log(chalk.cyan(` Research areas: ${totalResearch}`));\n console.log(chalk.cyan(` TODOs found: ${totalTodos}`));\n console.log(chalk.cyan(` Concepts: ${result.analyzed.reduce((sum, d) => sum + d.concepts.length, 0)}`));\n console.log(chalk.cyan(` Cross-refs: ${result.analyzed.reduce((sum, d) => sum + d.related.length, 0)}`));\n\n console.log();\n console.log(chalk.white(` Output: ${targetDir}/`));\n console.log(chalk.gray(` MOC.md Master index`));\n console.log(chalk.gray(` PRIMITIVES.md Core building blocks`));\n console.log(chalk.gray(` */\\_MOC.md Category indexes`));\n console.log();\n\n } catch (error) {\n spinner.fail('Deep analysis failed');\n console.error(chalk.red(String(error)));\n process.exit(1);\n }\n });\n\n // Migrate subcommand - implements analysis recommendations\n command\n .command('migrate')\n .description('Implement analysis recommendations using AI agents to fill gaps, answer questions, and build connections')\n .argument('[path]', 'Project root path', '.')\n .option('-d, --docs <dir>', 'Documentation directory', 'docs')\n .option('-a, --analysis <dir>', 'Analysis directory (relative to docs)', 'analysis')\n .option('--max-agents <n>', 'Maximum parallel agents', '8')\n .option('--dry-run', 'Preview changes without making them')\n .option('--use-vector', 'Use vector search for context retrieval')\n .option('-v, --verbose', 'Verbose output')\n .action(async (path: string, options) => {\n const spinner = ora('Initializing migration orchestration...').start();\n\n try {\n const projectRoot = validateProjectRoot(path);\n const docsDir = options.docs;\n const analysisDir = options.analysis;\n const dryRun = options.dryRun ?? false;\n const verbose = options.verbose ?? false;\n\n // Check analysis directory exists\n const analysisPath = join(projectRoot, docsDir, analysisDir);\n if (!existsSync(analysisPath)) {\n spinner.fail(`Analysis directory not found: ${analysisPath}`);\n console.log(chalk.gray(' Run \"kg cultivate --deep-analysis\" first to generate analysis'));\n process.exit(1);\n }\n\n // Check for required analysis files\n const requiredFiles = ['documentation-gaps.md', 'research-questions.md'];\n const missingFiles = requiredFiles.filter(f => !existsSync(join(analysisPath, f)));\n if (missingFiles.length > 0) {\n spinner.warn(`Missing analysis files: ${missingFiles.join(', ')}`);\n console.log(chalk.gray(' Run \"kg cultivate --deep-analysis\" to generate complete analysis'));\n }\n\n // Import and create orchestrator\n const { MigrationOrchestrator } = await import('../../cultivation/migration-orchestrator.js');\n const orchestrator = new MigrationOrchestrator({\n projectRoot,\n docsPath: docsDir,\n analysisDir,\n verbose,\n dryRun,\n useVectorSearch: options.useVector ?? false,\n maxAgents: parseInt(options.maxAgents || '8', 10)\n });\n\n // Check availability\n const status = await orchestrator.getAvailabilityStatus();\n if (!status.available) {\n spinner.fail('Migration unavailable');\n console.log(chalk.red(` ${status.reason}`));\n console.log(chalk.gray(' Set GOOGLE_GEMINI_API_KEY or ANTHROPIC_API_KEY'));\n process.exit(1);\n }\n\n spinner.text = `Running migration (${status.reason})...`;\n if (dryRun) {\n spinner.text = `Running migration dry run (${status.reason})...`;\n }\n\n // Run migration\n const result = await orchestrator.migrate();\n\n if (result.success) {\n if (dryRun) {\n spinner.succeed('Migration dry run complete!');\n } else {\n spinner.succeed('Migration complete!');\n }\n } else {\n spinner.warn('Migration completed with errors');\n }\n\n // Display results\n console.log();\n console.log(chalk.cyan.bold(' Migration Results'));\n console.log(chalk.gray(' ─────────────────────────────────────'));\n console.log();\n\n if (dryRun) {\n console.log(chalk.yellow(' [DRY RUN] No changes were made\\n'));\n }\n\n console.log(chalk.white(' Summary:'));\n console.log(chalk.gray(` Analysis dir: ${docsDir}/${analysisDir}/`));\n console.log(chalk.green(` Agents used: ${result.agentsUsed}`));\n console.log(chalk.green(` Documents created: ${result.documentsCreated}`));\n console.log(chalk.blue(` Documents updated: ${result.documentsUpdated}`));\n console.log(chalk.cyan(` Gaps filled: ${result.gapsFilled}`));\n console.log(chalk.cyan(` Questions answered: ${result.questionsAnswered}`));\n console.log(chalk.cyan(` Connections added: ${result.connectionsAdded}`));\n console.log(chalk.gray(` Duration: ${(result.duration / 1000).toFixed(1)}s`));\n\n // Show warnings\n if (result.warnings.length > 0) {\n console.log();\n console.log(chalk.yellow(' Warnings:'));\n result.warnings.slice(0, 5).forEach(w => {\n console.log(chalk.gray(` - ${w}`));\n });\n if (result.warnings.length > 5) {\n console.log(chalk.gray(` ... and ${result.warnings.length - 5} more`));\n }\n }\n\n // Show errors\n if (result.errors.length > 0) {\n console.log();\n console.log(chalk.red(' Errors:'));\n result.errors.slice(0, 5).forEach(e => {\n console.log(chalk.gray(` - ${e}`));\n });\n if (result.errors.length > 5) {\n console.log(chalk.gray(` ... and ${result.errors.length - 5} more`));\n }\n }\n\n // Next steps\n if (!dryRun && result.documentsCreated > 0) {\n console.log();\n console.log(chalk.cyan(' Next steps:'));\n console.log(chalk.white(` 1. Review generated documents in ${docsDir}/`));\n console.log(chalk.white(` 2. Check ${docsDir}/${analysisDir}/ for summaries`));\n console.log(chalk.white(` 3. Run: kg graph --docs ${docsDir}`));\n console.log(chalk.white(` 4. Run: kg stats --docs ${docsDir}`));\n }\n\n console.log();\n\n } catch (error) {\n spinner.fail('Migration failed');\n console.error(chalk.red(String(error)));\n process.exit(1);\n }\n });\n\n // Report subcommand\n command\n .command('report')\n .description('Generate analysis report without creating files')\n .option('-p, --path <path>', 'Project root path', '.')\n .option('-s, --source <dir>', 'Source docs directory', 'docs')\n .option('--json', 'Output as JSON')\n .action(async (options) => {\n const spinner = ora('Generating analysis report...').start();\n\n try {\n const projectRoot = validateProjectRoot(options.path);\n const sourceDir = options.source;\n\n if (!existsSync(join(projectRoot, sourceDir))) {\n spinner.fail(`Source directory not found: ${sourceDir}`);\n process.exit(1);\n }\n\n const result = await analyzeDocs({\n sourceDir,\n targetDir: 'docs',\n projectRoot,\n useClaudeFlow: false,\n createMOC: false,\n linkOriginal: false,\n dryRun: true,\n verbose: false,\n });\n\n spinner.succeed('Report generated!');\n\n if (options.json) {\n // JSON output\n const report = {\n summary: {\n totalDocs: result.filesAnalyzed,\n categories: Object.fromEntries(result.structure),\n },\n documents: result.analyzed.map(d => ({\n original: d.originalPath,\n target: d.newPath,\n type: d.type,\n category: d.category,\n tags: d.tags,\n concepts: d.concepts,\n researchNeeded: d.researchNeeded,\n todos: d.todos,\n })),\n researchAreas: result.analyzed\n .flatMap(d => d.researchNeeded.map(r => ({ doc: d.title, area: r }))),\n todos: result.analyzed\n .flatMap(d => d.todos.map(t => ({ doc: d.title, todo: t }))),\n };\n console.log(JSON.stringify(report, null, 2));\n } else {\n // Human-readable output\n console.log();\n console.log(chalk.cyan.bold(' Documentation Analysis Report'));\n console.log(chalk.gray(' ─────────────────────────────────────'));\n console.log();\n console.log(chalk.white(` Total documents: ${result.filesAnalyzed}`));\n console.log();\n\n // Type breakdown\n const byType = new Map<string, number>();\n result.analyzed.forEach(d => {\n byType.set(d.type, (byType.get(d.type) || 0) + 1);\n });\n\n console.log(chalk.white(' By Type:'));\n for (const [type, count] of byType) {\n const bar = '█'.repeat(Math.ceil(count / result.filesAnalyzed * 20));\n console.log(chalk.cyan(` ${type.padEnd(12)} ${bar} ${count}`));\n }\n console.log();\n\n // Category breakdown\n console.log(chalk.white(' By Category:'));\n for (const [category, docs] of result.structure) {\n const bar = '█'.repeat(Math.ceil(docs.length / result.filesAnalyzed * 20));\n console.log(chalk.cyan(` ${category.padEnd(12)} ${bar} ${docs.length}`));\n }\n console.log();\n\n // Issues\n const withResearch = result.analyzed.filter(d => d.researchNeeded.length > 0);\n const withTodos = result.analyzed.filter(d => d.todos.length > 0);\n\n console.log(chalk.white(' Areas Needing Attention:'));\n console.log(chalk.yellow(` 📚 Research needed: ${withResearch.length} docs`));\n console.log(chalk.yellow(` ✏️ With TODOs: ${withTodos.length} docs`));\n console.log();\n\n // Top research areas\n if (withResearch.length > 0) {\n console.log(chalk.white(' Top Research Areas:'));\n withResearch.slice(0, 5).forEach(d => {\n console.log(chalk.gray(` ${d.title}:`));\n d.researchNeeded.slice(0, 2).forEach(r => {\n console.log(chalk.yellow(` - ${r.slice(0, 60)}...`));\n });\n });\n console.log();\n }\n\n console.log(chalk.cyan(' Run `kg analyze` to migrate documentation'));\n console.log();\n }\n\n } catch (error) {\n spinner.fail('Report generation failed');\n console.error(chalk.red(String(error)));\n process.exit(1);\n }\n });\n\n return command;\n}\n"],"names":[],"mappings":";;;;;;;AAkBO,SAAS,uBAAgC;AAC9C,QAAM,UAAU,IAAI,QAAQ,SAAS;AAErC,UACG,YAAY,uDAAuD,EACnE,OAAO,qBAAqB,qBAAqB,GAAG,EACpD,OAAO,sBAAsB,yBAAyB,MAAM,EAC5D,OAAO,sBAAsB,oBAAoB,MAAM,EACvD,OAAO,qBAAqB,mCAAmC,EAC/D,OAAO,YAAY,sCAAsC,EACzD,OAAO,sBAAsB,mCAAmC,EAChE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C;AACtC,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AAEH,SAAO;AACT;"}
|
|
@@ -133,6 +133,18 @@ export declare class DeepAnalyzer {
|
|
|
133
133
|
* Read full content of key documents
|
|
134
134
|
*/
|
|
135
135
|
private readKeyDocuments;
|
|
136
|
+
/**
|
|
137
|
+
* Scan directory structure for MOC files and coverage
|
|
138
|
+
*/
|
|
139
|
+
private scanDirectoryStructure;
|
|
140
|
+
/**
|
|
141
|
+
* Load previous analysis results for iteration tracking
|
|
142
|
+
*/
|
|
143
|
+
private loadPreviousAnalysis;
|
|
144
|
+
/**
|
|
145
|
+
* Save analysis metadata for iteration tracking
|
|
146
|
+
*/
|
|
147
|
+
private saveAnalysisMetadata;
|
|
136
148
|
/**
|
|
137
149
|
* Run deep analysis
|
|
138
150
|
*/
|
|
@@ -141,6 +153,10 @@ export declare class DeepAnalyzer {
|
|
|
141
153
|
* Execute a single agent
|
|
142
154
|
*/
|
|
143
155
|
private executeAgent;
|
|
156
|
+
/**
|
|
157
|
+
* Build directory coverage summary for prompts
|
|
158
|
+
*/
|
|
159
|
+
private buildCoverageSummary;
|
|
144
160
|
/**
|
|
145
161
|
* Build context-aware prompt for documentation cultivation
|
|
146
162
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-analyzer.d.ts","sourceRoot":"","sources":["../../src/cultivation/deep-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AASH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,6BAA6B;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6BAA6B;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mCAAmC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qCAAqC;IACrC,YAAY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AkB;IAI1B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAI1B;;OAEG;IACH,OAAO,CAAC,eAAe;IASvB;;OAEG;IACH,OAAO,CAAC,eAAe;IASvB;;OAEG;IACH,OAAO,CAAC,cAAc;IAatB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAiD3B;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAKrC;;OAEG;IACG,qBAAqB,IAAI,OAAO,CAAC;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAQ9E;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA6DzB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA+BxB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IA0F9B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAe5B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA+B5B;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAgI5C;;OAEG;YACW,YAAY;IAuD1B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA4C5B;;OAEG;IACH,OAAO,CAAC,WAAW;IA0JnB;;OAEG;YACW,UAAU;IA4BxB;;OAEG;YACW,gBAAgB;IA8B9B;;OAEG;YACW,aAAa;IA4B3B;;OAEG;IACH,OAAO,CAAC,eAAe;IAqBvB;;OAEG;IACH,OAAO,CAAC,YAAY;CA6BrB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAE7E;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,WAAW,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,kBAAkB,CAAC,CAG7B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execFileSync, execSync } from "child_process";
|
|
2
|
-
import { existsSync, readFileSync,
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync, readdirSync, statSync } from "fs";
|
|
3
3
|
import { resolve, join, extname, relative, basename } from "path";
|
|
4
4
|
import { createLogger } from "../utils/logger.js";
|
|
5
5
|
const logger = createLogger("deep-analyzer");
|
|
@@ -200,6 +200,122 @@ class DeepAnalyzer {
|
|
|
200
200
|
}
|
|
201
201
|
return keyDocs;
|
|
202
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Scan directory structure for MOC files and coverage
|
|
205
|
+
*/
|
|
206
|
+
scanDirectoryStructure() {
|
|
207
|
+
const docsDir = join(this.projectRoot, this.docsPath);
|
|
208
|
+
if (!existsSync(docsDir)) {
|
|
209
|
+
return [];
|
|
210
|
+
}
|
|
211
|
+
const directories = [];
|
|
212
|
+
const ignoredDirs = /* @__PURE__ */ new Set([".", "..", "analysis", "node_modules", ".git", ".obsidian"]);
|
|
213
|
+
const scanDir = (dir, depth = 0) => {
|
|
214
|
+
if (depth > 5) return;
|
|
215
|
+
const relPath = relative(docsDir, dir) || ".";
|
|
216
|
+
const entries = readdirSync(dir, { withFileTypes: true });
|
|
217
|
+
const subdirs = [];
|
|
218
|
+
const docs = [];
|
|
219
|
+
let mocFile = null;
|
|
220
|
+
let mocContent = "";
|
|
221
|
+
for (const entry of entries) {
|
|
222
|
+
if (ignoredDirs.has(entry.name) || entry.name.startsWith(".")) continue;
|
|
223
|
+
if (entry.isDirectory()) {
|
|
224
|
+
subdirs.push(entry.name);
|
|
225
|
+
scanDir(join(dir, entry.name), depth + 1);
|
|
226
|
+
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
227
|
+
docs.push(entry.name);
|
|
228
|
+
if (entry.name === "_MOC.md" || entry.name === "MOC.md" || entry.name === "index.md") {
|
|
229
|
+
mocFile = entry.name;
|
|
230
|
+
try {
|
|
231
|
+
mocContent = readFileSync(join(dir, entry.name), "utf-8");
|
|
232
|
+
} catch {
|
|
233
|
+
mocContent = "";
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
let mocStatus = "missing";
|
|
239
|
+
if (mocFile) {
|
|
240
|
+
if (mocContent.length < 100) {
|
|
241
|
+
mocStatus = "empty";
|
|
242
|
+
} else if (mocContent.toLowerCase().includes("stub") || mocContent.includes("TODO") || mocContent.includes("TBD") || !mocContent.includes("[[")) {
|
|
243
|
+
mocStatus = "stub";
|
|
244
|
+
} else {
|
|
245
|
+
mocStatus = "complete";
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
let needsDocumentation = false;
|
|
249
|
+
let reason = "";
|
|
250
|
+
if (subdirs.length > 0 || docs.length > 1) {
|
|
251
|
+
if (mocStatus === "missing") {
|
|
252
|
+
needsDocumentation = true;
|
|
253
|
+
reason = "Directory has content but no MOC file";
|
|
254
|
+
} else if (mocStatus === "empty" || mocStatus === "stub") {
|
|
255
|
+
needsDocumentation = true;
|
|
256
|
+
reason = `MOC file is ${mocStatus} - needs content`;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (subdirs.length > 0 || docs.length > 0 || relPath === ".") {
|
|
260
|
+
directories.push({
|
|
261
|
+
path: relPath,
|
|
262
|
+
name: basename(dir),
|
|
263
|
+
hasMOC: mocFile !== null,
|
|
264
|
+
mocStatus,
|
|
265
|
+
documentCount: docs.length,
|
|
266
|
+
subdirectories: subdirs,
|
|
267
|
+
documents: docs,
|
|
268
|
+
needsDocumentation,
|
|
269
|
+
reason
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
scanDir(docsDir);
|
|
274
|
+
return directories;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Load previous analysis results for iteration tracking
|
|
278
|
+
*/
|
|
279
|
+
loadPreviousAnalysis() {
|
|
280
|
+
const metadataFile = join(this.outputDir, ".analysis-metadata.json");
|
|
281
|
+
if (!existsSync(metadataFile)) {
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
try {
|
|
285
|
+
const content = readFileSync(metadataFile, "utf-8");
|
|
286
|
+
return JSON.parse(content);
|
|
287
|
+
} catch {
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Save analysis metadata for iteration tracking
|
|
293
|
+
*/
|
|
294
|
+
saveAnalysisMetadata(result, dirCoverage) {
|
|
295
|
+
const metadataFile = join(this.outputDir, ".analysis-metadata.json");
|
|
296
|
+
const previous = this.loadPreviousAnalysis();
|
|
297
|
+
const totalDirs = dirCoverage.length;
|
|
298
|
+
const coveredDirs = dirCoverage.filter((d) => d.mocStatus === "complete").length;
|
|
299
|
+
const coverageScore = totalDirs > 0 ? coveredDirs / totalDirs * 100 : 0;
|
|
300
|
+
const gapsResult = result.results.find((r) => r.type === "gaps");
|
|
301
|
+
const questionsResult = result.results.find((r) => r.type === "research");
|
|
302
|
+
const coverageResult = result.results.find((r) => r.type === "coverage");
|
|
303
|
+
const metadata = {
|
|
304
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
305
|
+
iteration: (previous?.iteration || 0) + 1,
|
|
306
|
+
gapsIdentified: (gapsResult?.insights.length || 0) + (coverageResult?.insights.length || 0),
|
|
307
|
+
gapsFilled: 0,
|
|
308
|
+
// Updated by migrate command
|
|
309
|
+
questionsRaised: questionsResult?.insights.length || 0,
|
|
310
|
+
questionsAnswered: 0,
|
|
311
|
+
// Updated by migrate command
|
|
312
|
+
coverageScore
|
|
313
|
+
};
|
|
314
|
+
try {
|
|
315
|
+
writeFileSync(metadataFile, JSON.stringify(metadata, null, 2));
|
|
316
|
+
} catch {
|
|
317
|
+
}
|
|
318
|
+
}
|
|
203
319
|
/**
|
|
204
320
|
* Run deep analysis
|
|
205
321
|
*/
|
|
@@ -228,12 +344,21 @@ class DeepAnalyzer {
|
|
|
228
344
|
}
|
|
229
345
|
const documents = this.scanDocumentation();
|
|
230
346
|
const keyDocs = this.readKeyDocuments();
|
|
347
|
+
const dirCoverage = this.scanDirectoryStructure();
|
|
348
|
+
const previousAnalysis = this.loadPreviousAnalysis();
|
|
231
349
|
if (documents.length === 0) {
|
|
232
350
|
result.errors.push("No markdown documents found in docs directory");
|
|
233
351
|
result.duration = Date.now() - startTime;
|
|
234
352
|
return result;
|
|
235
353
|
}
|
|
236
|
-
|
|
354
|
+
const iteration = (previousAnalysis?.iteration || 0) + 1;
|
|
355
|
+
logger.info("Found documentation", {
|
|
356
|
+
documents: documents.length,
|
|
357
|
+
keyDocs: keyDocs.size,
|
|
358
|
+
directories: dirCoverage.length,
|
|
359
|
+
needsWork: dirCoverage.filter((d) => d.needsDocumentation).length,
|
|
360
|
+
iteration
|
|
361
|
+
});
|
|
237
362
|
const agents = [
|
|
238
363
|
{
|
|
239
364
|
name: "Vision Synthesizer",
|
|
@@ -241,6 +366,12 @@ class DeepAnalyzer {
|
|
|
241
366
|
task: "Synthesize the project vision, goals, and core value proposition from the documentation",
|
|
242
367
|
outputFile: "vision-synthesis.md"
|
|
243
368
|
},
|
|
369
|
+
{
|
|
370
|
+
name: "Directory Coverage Analyst",
|
|
371
|
+
type: "coverage",
|
|
372
|
+
task: "Analyze directory structure, MOC files, and identify areas needing documentation",
|
|
373
|
+
outputFile: "directory-coverage.md"
|
|
374
|
+
},
|
|
244
375
|
{
|
|
245
376
|
name: "Gap Analyst",
|
|
246
377
|
type: "gaps",
|
|
@@ -260,16 +391,19 @@ class DeepAnalyzer {
|
|
|
260
391
|
outputFile: "knowledge-connections.md"
|
|
261
392
|
}
|
|
262
393
|
];
|
|
263
|
-
logger.info("Executing cultivation agents", { agents: agents.length, mode: "sequential" });
|
|
394
|
+
logger.info("Executing cultivation agents", { agents: agents.length, mode: "sequential", iteration });
|
|
264
395
|
for (const agent of agents) {
|
|
265
396
|
const agentResult = await this.executeAgent(
|
|
266
397
|
agent,
|
|
267
398
|
executionMode.mode,
|
|
268
399
|
documents,
|
|
269
|
-
keyDocs
|
|
400
|
+
keyDocs,
|
|
401
|
+
dirCoverage,
|
|
402
|
+
previousAnalysis
|
|
270
403
|
);
|
|
271
404
|
result.results.push(agentResult);
|
|
272
405
|
}
|
|
406
|
+
this.saveAnalysisMetadata(result, dirCoverage);
|
|
273
407
|
result.agentsSpawned = result.results.length;
|
|
274
408
|
result.insightsCount = result.results.reduce((sum, r) => sum + r.insights.length, 0);
|
|
275
409
|
result.documentsCreated = result.results.reduce((sum, r) => sum + r.documents.length, 0);
|
|
@@ -291,7 +425,7 @@ class DeepAnalyzer {
|
|
|
291
425
|
/**
|
|
292
426
|
* Execute a single agent
|
|
293
427
|
*/
|
|
294
|
-
async executeAgent(agent, mode, documents, keyDocs) {
|
|
428
|
+
async executeAgent(agent, mode, documents, keyDocs, dirCoverage, previousAnalysis) {
|
|
295
429
|
const startTime = Date.now();
|
|
296
430
|
const outputPath = join(this.outputDir, agent.outputFile);
|
|
297
431
|
const result = {
|
|
@@ -304,7 +438,7 @@ class DeepAnalyzer {
|
|
|
304
438
|
};
|
|
305
439
|
try {
|
|
306
440
|
logger.info(`Executing agent: ${agent.name}`, { type: agent.type, mode });
|
|
307
|
-
const prompt = this.buildPrompt(agent, documents, keyDocs);
|
|
441
|
+
const prompt = this.buildPrompt(agent, documents, keyDocs, dirCoverage, previousAnalysis);
|
|
308
442
|
let output;
|
|
309
443
|
if (mode === "cli") {
|
|
310
444
|
output = await this.runWithCli(prompt);
|
|
@@ -327,16 +461,91 @@ class DeepAnalyzer {
|
|
|
327
461
|
result.duration = Date.now() - startTime;
|
|
328
462
|
return result;
|
|
329
463
|
}
|
|
464
|
+
/**
|
|
465
|
+
* Build directory coverage summary for prompts
|
|
466
|
+
*/
|
|
467
|
+
buildCoverageSummary(dirCoverage) {
|
|
468
|
+
const lines = [];
|
|
469
|
+
const total = dirCoverage.length;
|
|
470
|
+
const complete = dirCoverage.filter((d) => d.mocStatus === "complete").length;
|
|
471
|
+
const stub = dirCoverage.filter((d) => d.mocStatus === "stub").length;
|
|
472
|
+
const empty = dirCoverage.filter((d) => d.mocStatus === "empty").length;
|
|
473
|
+
const missing = dirCoverage.filter((d) => d.mocStatus === "missing").length;
|
|
474
|
+
lines.push(`### Summary`);
|
|
475
|
+
lines.push(`- Total Directories: ${total}`);
|
|
476
|
+
lines.push(`- Complete MOCs: ${complete} (${(complete / total * 100).toFixed(1)}%)`);
|
|
477
|
+
lines.push(`- Stub MOCs: ${stub}`);
|
|
478
|
+
lines.push(`- Empty MOCs: ${empty}`);
|
|
479
|
+
lines.push(`- Missing MOCs: ${missing}`);
|
|
480
|
+
lines.push(`- Coverage Score: ${(complete / total * 100).toFixed(1)}%`);
|
|
481
|
+
lines.push("");
|
|
482
|
+
const needsWork = dirCoverage.filter((d) => d.needsDocumentation);
|
|
483
|
+
if (needsWork.length > 0) {
|
|
484
|
+
lines.push("### Directories Needing Documentation");
|
|
485
|
+
for (const dir of needsWork) {
|
|
486
|
+
lines.push(`- **${dir.path}/** (${dir.mocStatus})`);
|
|
487
|
+
lines.push(` - Documents: ${dir.documents.join(", ") || "none"}`);
|
|
488
|
+
lines.push(` - Subdirectories: ${dir.subdirectories.join(", ") || "none"}`);
|
|
489
|
+
lines.push(` - Reason: ${dir.reason}`);
|
|
490
|
+
}
|
|
491
|
+
lines.push("");
|
|
492
|
+
}
|
|
493
|
+
const completeDirs = dirCoverage.filter((d) => d.mocStatus === "complete");
|
|
494
|
+
if (completeDirs.length > 0) {
|
|
495
|
+
lines.push("### Directories with Complete MOCs");
|
|
496
|
+
for (const dir of completeDirs) {
|
|
497
|
+
lines.push(`- ${dir.path}/ (${dir.documentCount} docs)`);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
return lines.join("\n");
|
|
501
|
+
}
|
|
330
502
|
/**
|
|
331
503
|
* Build context-aware prompt for documentation cultivation
|
|
332
504
|
*/
|
|
333
|
-
buildPrompt(agent, documents, keyDocs) {
|
|
505
|
+
buildPrompt(agent, documents, keyDocs, dirCoverage, previousAnalysis) {
|
|
334
506
|
const inventory = documents.map((d) => `- ${d.path} (${d.type}): ${d.title}`).join("\n");
|
|
335
507
|
const keyContent = Array.from(keyDocs.entries()).map(([name, content]) => `### ${name}
|
|
336
508
|
|
|
337
509
|
${content}`).join("\n\n---\n\n");
|
|
510
|
+
const coverageSummary = this.buildCoverageSummary(dirCoverage);
|
|
511
|
+
const iterationContext = previousAnalysis ? `
|
|
512
|
+
## Previous Analysis (Iteration ${previousAnalysis.iteration})
|
|
513
|
+
- Timestamp: ${previousAnalysis.timestamp}
|
|
514
|
+
- Gaps Identified: ${previousAnalysis.gapsIdentified}
|
|
515
|
+
- Gaps Filled: ${previousAnalysis.gapsFilled}
|
|
516
|
+
- Questions Raised: ${previousAnalysis.questionsRaised}
|
|
517
|
+
- Questions Answered: ${previousAnalysis.questionsAnswered}
|
|
518
|
+
- Coverage Score: ${previousAnalysis.coverageScore.toFixed(1)}%
|
|
519
|
+
|
|
520
|
+
Focus on NEW gaps and questions not addressed in previous iterations.
|
|
521
|
+
` : "";
|
|
338
522
|
let specificInstructions = "";
|
|
339
523
|
switch (agent.type) {
|
|
524
|
+
case "coverage":
|
|
525
|
+
specificInstructions = `
|
|
526
|
+
Focus on directory structure and MOC (Map of Content) files:
|
|
527
|
+
|
|
528
|
+
1. **Directory Analysis**: Review each directory and its MOC file status
|
|
529
|
+
2. **Empty/Stub MOCs**: Identify MOC files that are empty or just stubs
|
|
530
|
+
3. **Missing MOCs**: Identify directories that need MOC files
|
|
531
|
+
4. **Documentation Needs**: For each directory, determine what documentation is needed
|
|
532
|
+
5. **Not Needed**: If a directory genuinely doesn't need documentation, explain why
|
|
533
|
+
|
|
534
|
+
For each directory needing work:
|
|
535
|
+
- State the directory path
|
|
536
|
+
- Current MOC status (missing/empty/stub/complete)
|
|
537
|
+
- What documentation should be added
|
|
538
|
+
- Priority (high/medium/low)
|
|
539
|
+
- Suggested content or links to include
|
|
540
|
+
|
|
541
|
+
The goal is 100% documentation coverage - every directory should either:
|
|
542
|
+
1. Have a complete MOC with links to contents
|
|
543
|
+
2. Have documentation explaining why it doesn't need more docs
|
|
544
|
+
3. Be marked for future documentation
|
|
545
|
+
|
|
546
|
+
## Directory Coverage Status
|
|
547
|
+
${coverageSummary}`;
|
|
548
|
+
break;
|
|
340
549
|
case "vision":
|
|
341
550
|
specificInstructions = `
|
|
342
551
|
Focus on:
|
|
@@ -356,11 +565,16 @@ Identify:
|
|
|
356
565
|
3. Outdated information (anything that seems inconsistent?)
|
|
357
566
|
4. Missing examples or use cases
|
|
358
567
|
5. Unclear terminology or concepts that need definitions
|
|
568
|
+
6. Empty or stub MOC files that need content (see Directory Coverage below)
|
|
359
569
|
|
|
360
570
|
For each gap, specify:
|
|
361
571
|
- What is missing
|
|
362
|
-
- Where it should be documented
|
|
363
|
-
- Why it's important
|
|
572
|
+
- Where it should be documented (specific file path)
|
|
573
|
+
- Why it's important
|
|
574
|
+
- Priority (high/medium/low)
|
|
575
|
+
|
|
576
|
+
## Directory Coverage Status
|
|
577
|
+
${coverageSummary}`;
|
|
364
578
|
break;
|
|
365
579
|
case "research":
|
|
366
580
|
specificInstructions = `
|
|
@@ -392,7 +606,7 @@ Also identify concepts that should be linked but aren't currently.`;
|
|
|
392
606
|
break;
|
|
393
607
|
}
|
|
394
608
|
return `You are a documentation analyst helping to cultivate a knowledge graph.
|
|
395
|
-
|
|
609
|
+
${iterationContext}
|
|
396
610
|
## Your Task
|
|
397
611
|
${agent.task}
|
|
398
612
|
|
|
@@ -414,9 +628,11 @@ Provide your analysis in markdown format with:
|
|
|
414
628
|
3. Specific recommendations (prefix with "Recommendation:")
|
|
415
629
|
4. Key findings (prefix with "Finding:")
|
|
416
630
|
5. Research questions where applicable (prefix with "Question:")
|
|
631
|
+
6. Priority levels (high/medium/low) for actionable items
|
|
417
632
|
|
|
418
633
|
Reference specific documents using [[document-name]] wiki-link format where relevant.
|
|
419
|
-
Be specific and actionable in your analysis
|
|
634
|
+
Be specific and actionable in your analysis.
|
|
635
|
+
${previousAnalysis ? "\nFocus on NEW items not identified in previous iterations." : ""}`;
|
|
420
636
|
}
|
|
421
637
|
/**
|
|
422
638
|
* Run analysis using Claude CLI
|