@weavelogic/knowledge-graph-agent 0.10.7 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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,CAyV9C"}
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;AAEA,UAAI,QAAQ,eAAe;AACzB,gBAAQ,OAAO;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AAM,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,OAAO,mBAAmB,0BAA0B,GAAG,EACvD,OAAO,aAAa,gDAAg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C;AAEH,SAAO;AACT;"}
@@ -0,0 +1,195 @@
1
+ /**
2
+ * Migration Orchestrator - Implements Analysis Recommendations
3
+ *
4
+ * Uses claude-flow swarms to implement suggestions from cultivation analysis:
5
+ * - Fill documentation gaps identified by Gap Analyst
6
+ * - Answer research questions with specialized agents
7
+ * - Build knowledge graph connections
8
+ * - Create missing MOC files and documentation
9
+ *
10
+ * @module cultivation/migration-orchestrator
11
+ */
12
+ /**
13
+ * Parsed gap from analysis
14
+ */
15
+ interface DocumentationGap {
16
+ section: string;
17
+ description: string;
18
+ recommendation: string;
19
+ priority: 'high' | 'medium' | 'low';
20
+ relatedDocs: string[];
21
+ }
22
+ /**
23
+ * Parsed research question from analysis
24
+ */
25
+ interface ResearchQuestion {
26
+ question: string;
27
+ context: string;
28
+ importance: string;
29
+ suggestedResources: string[];
30
+ category: string;
31
+ }
32
+ /**
33
+ * Parsed connection suggestion from analysis
34
+ */
35
+ interface ConnectionSuggestion {
36
+ source: string;
37
+ target: string;
38
+ relationship: string;
39
+ reason: string;
40
+ }
41
+ /**
42
+ * Parsed analysis results
43
+ */
44
+ interface ParsedAnalysis {
45
+ vision: {
46
+ purpose: string;
47
+ goals: string[];
48
+ recommendations: string[];
49
+ };
50
+ gaps: DocumentationGap[];
51
+ questions: ResearchQuestion[];
52
+ connections: ConnectionSuggestion[];
53
+ }
54
+ /**
55
+ * Migration result
56
+ */
57
+ interface MigrationResult {
58
+ success: boolean;
59
+ agentsUsed: number;
60
+ documentsCreated: number;
61
+ documentsUpdated: number;
62
+ connectionsAdded: number;
63
+ questionsAnswered: number;
64
+ gapsFilled: number;
65
+ errors: string[];
66
+ warnings: string[];
67
+ duration: number;
68
+ }
69
+ /**
70
+ * Orchestrator options
71
+ */
72
+ interface OrchestratorOptions {
73
+ projectRoot: string;
74
+ docsPath: string;
75
+ analysisDir: string;
76
+ verbose?: boolean;
77
+ dryRun?: boolean;
78
+ useVectorSearch?: boolean;
79
+ maxAgents?: number;
80
+ }
81
+ /**
82
+ * Orchestrates the migration from analysis to implemented documentation
83
+ */
84
+ export declare class MigrationOrchestrator {
85
+ private projectRoot;
86
+ private docsPath;
87
+ private analysisDir;
88
+ private verbose;
89
+ private dryRun;
90
+ private useVectorSearch;
91
+ private maxAgents;
92
+ private geminiClient;
93
+ constructor(options: OrchestratorOptions);
94
+ /**
95
+ * Check availability status
96
+ */
97
+ getAvailabilityStatus(): Promise<{
98
+ available: boolean;
99
+ reason: string;
100
+ }>;
101
+ /**
102
+ * Run the migration process
103
+ */
104
+ migrate(): Promise<MigrationResult>;
105
+ /**
106
+ * Parse all analysis files from the analysis directory
107
+ */
108
+ private parseAnalysisFiles;
109
+ /**
110
+ * Parse vision synthesis file
111
+ */
112
+ private parseVisionFile;
113
+ /**
114
+ * Parse documentation gaps file
115
+ */
116
+ private parseGapsFile;
117
+ /**
118
+ * Parse research questions file
119
+ */
120
+ private parseQuestionsFile;
121
+ /**
122
+ * Parse knowledge connections file
123
+ */
124
+ private parseConnectionsFile;
125
+ /**
126
+ * Load all documentation as context
127
+ */
128
+ private loadDocsContext;
129
+ /**
130
+ * Create migration agents based on analysis
131
+ */
132
+ private createMigrationAgents;
133
+ /**
134
+ * Build context for gap filler agent
135
+ */
136
+ private buildGapFillerContext;
137
+ /**
138
+ * Build context for researcher agent
139
+ */
140
+ private buildResearcherContext;
141
+ /**
142
+ * Build context for MOC builder agent
143
+ */
144
+ private buildMOCBuilderContext;
145
+ /**
146
+ * Build context for connector agent
147
+ */
148
+ private buildConnectorContext;
149
+ /**
150
+ * Build context for integrator agent
151
+ */
152
+ private buildIntegratorContext;
153
+ /**
154
+ * Execute a single migration agent
155
+ */
156
+ private executeAgent;
157
+ /**
158
+ * Build prompt for agent
159
+ */
160
+ private buildAgentPrompt;
161
+ /**
162
+ * Call AI (Gemini or fallback)
163
+ */
164
+ private callAI;
165
+ /**
166
+ * Process agent response and create/update documents
167
+ */
168
+ private processAgentResponse;
169
+ /**
170
+ * Add frontmatter to document if not present
171
+ */
172
+ private addFrontmatter;
173
+ /**
174
+ * Infer document type from path
175
+ */
176
+ private inferDocType;
177
+ /**
178
+ * Update MOC files with new connections
179
+ */
180
+ private updateMOCFiles;
181
+ /**
182
+ * Find relevant docs based on query
183
+ */
184
+ private findRelevantDocs;
185
+ /**
186
+ * Infer priority from description
187
+ */
188
+ private inferPriority;
189
+ /**
190
+ * Log message
191
+ */
192
+ private log;
193
+ }
194
+ export type { MigrationResult, OrchestratorOptions, ParsedAnalysis };
195
+ //# sourceMappingURL=migration-orchestrator.d.ts.map
@@ -0,0 +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,EAA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