@weavelogic/knowledge-graph-agent 0.8.8 → 0.9.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":"docs.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/docs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAoM3C"}
1
+ {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/docs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CA6U3C"}
@@ -1,8 +1,10 @@
1
1
  import { Command } from "commander";
2
2
  import chalk from "chalk";
3
3
  import ora from "ora";
4
+ import { join } from "path";
4
5
  import { docsExist, initDocs, getDocsPath } from "../../generators/docs-init.js";
5
6
  import { generateDocsWithAgents } from "../../generators/doc-generator-agents.js";
7
+ import { cultivateDocs } from "../../generators/doc-cultivator.js";
6
8
  import { validateProjectRoot, validateDocsPath } from "../../core/security.js";
7
9
  function createDocsCommand() {
8
10
  const command = new Command("docs");
@@ -144,6 +146,110 @@ function createDocsCommand() {
144
146
  });
145
147
  console.log();
146
148
  });
149
+ command.command("cultivate").description("Recursively build out all documentation using claude-flow swarm").option("-p, --path <path>", "Project root path", ".").option("-d, --docs <path>", "Docs directory path", "docs").option("--dry-run", "Show what would be generated without creating files").option("-v, --verbose", "Show detailed output").option("-f, --force", "Force regenerate all documents").option("--no-dev-plan", "Skip development plan generation").option("--no-infra-plan", "Skip infrastructure plan generation").option("--include-sops", "Include SOP compliance analysis").option("--services <services>", "Comma-separated list of services to analyze").option("--max-agents <number>", "Maximum concurrent agents", "4").option("--background", "Run in background mode").action(async (options) => {
150
+ const projectRoot = validateProjectRoot(options.path);
151
+ const docsPath = options.docs;
152
+ validateDocsPath(projectRoot, docsPath);
153
+ console.log();
154
+ console.log(chalk.cyan.bold(" Documentation Cultivation"));
155
+ console.log(chalk.gray(" ─────────────────────────────"));
156
+ console.log();
157
+ if (options.dryRun) {
158
+ console.log(chalk.yellow(" [Dry Run Mode]"));
159
+ console.log();
160
+ }
161
+ const spinner = ora("Starting documentation cultivation...").start();
162
+ try {
163
+ const result = await cultivateDocs(
164
+ projectRoot,
165
+ join(projectRoot, docsPath),
166
+ {
167
+ dryRun: options.dryRun,
168
+ verbose: options.verbose,
169
+ force: options.force,
170
+ generateDevPlan: options.devPlan !== false,
171
+ generateInfraPlan: options.infraPlan !== false,
172
+ includeSops: options.includeSops,
173
+ services: options.services?.split(",").map((s) => s.trim()),
174
+ maxAgents: parseInt(options.maxAgents, 10),
175
+ background: options.background
176
+ }
177
+ );
178
+ if (options.dryRun) {
179
+ spinner.info("Dry run complete");
180
+ } else if (result.success) {
181
+ spinner.succeed("Documentation cultivation complete!");
182
+ } else {
183
+ spinner.warn("Cultivation completed with errors");
184
+ }
185
+ console.log();
186
+ console.log(chalk.white(" Services Analyzed:"));
187
+ for (const service of result.services) {
188
+ console.log(chalk.gray(` • ${service.name} (${service.type}) - ${service.sourceFiles.length} files`));
189
+ }
190
+ if (!options.dryRun) {
191
+ console.log();
192
+ console.log(chalk.white(" Documents Generated:"), chalk.green(result.documentsGenerated.length));
193
+ if (result.documentsGenerated.length > 0 && options.verbose) {
194
+ for (const doc of result.documentsGenerated) {
195
+ console.log(chalk.gray(` ✓ ${doc}`));
196
+ }
197
+ }
198
+ if (result.developmentPlan) {
199
+ console.log();
200
+ console.log(chalk.white(" Development Plan:"));
201
+ console.log(chalk.gray(` Phases: ${result.developmentPlan.phases.length}`));
202
+ console.log(chalk.gray(` Total Estimate: ${result.developmentPlan.totalEstimate}`));
203
+ for (const phase of result.developmentPlan.phases) {
204
+ console.log(chalk.gray(` • ${phase.name} (${phase.estimatedEffort})`));
205
+ }
206
+ }
207
+ if (result.infrastructurePlan) {
208
+ console.log();
209
+ console.log(chalk.white(" Infrastructure Plan:"));
210
+ console.log(chalk.gray(` Environments: ${result.infrastructurePlan.environments.join(", ")}`));
211
+ }
212
+ if (result.sopCompliance) {
213
+ console.log();
214
+ console.log(chalk.white(" SOP Compliance:"));
215
+ const scoreColor = result.sopCompliance.score >= 80 ? chalk.green : result.sopCompliance.score >= 50 ? chalk.yellow : chalk.red;
216
+ console.log(chalk.gray(` Score: `) + scoreColor(`${result.sopCompliance.score}%`));
217
+ if (result.sopCompliance.gaps.length > 0) {
218
+ console.log(chalk.gray(` Gaps: ${result.sopCompliance.gaps.length}`));
219
+ }
220
+ }
221
+ }
222
+ if (result.errors.length > 0) {
223
+ console.log();
224
+ console.log(chalk.yellow(" Errors:"));
225
+ for (const error of result.errors.slice(0, 5)) {
226
+ console.log(chalk.gray(` - ${error}`));
227
+ }
228
+ if (result.errors.length > 5) {
229
+ console.log(chalk.gray(` ... and ${result.errors.length - 5} more`));
230
+ }
231
+ }
232
+ console.log();
233
+ console.log(chalk.cyan(" Generated files in: ") + chalk.white(join(projectRoot, docsPath)));
234
+ console.log();
235
+ if (!options.dryRun) {
236
+ console.log(chalk.cyan(" Key documents:"));
237
+ console.log(chalk.gray(" • docs/planning/development-plan.md"));
238
+ console.log(chalk.gray(" • docs/planning/infrastructure-plan.md"));
239
+ console.log(chalk.gray(" • docs/services/{service}/README.md"));
240
+ console.log();
241
+ }
242
+ console.log(chalk.cyan("Next steps:"));
243
+ console.log(chalk.gray(" 1. Review generated documentation"));
244
+ console.log(chalk.gray(" 2. Fill in project-specific details"));
245
+ console.log(chalk.gray(" 3. Run ") + chalk.white("kg graph") + chalk.gray(" to visualize"));
246
+ console.log();
247
+ } catch (error) {
248
+ spinner.fail("Cultivation failed");
249
+ console.error(chalk.red(String(error)));
250
+ process.exit(1);
251
+ }
252
+ });
147
253
  return command;
148
254
  }
149
255
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"docs.js","sources":["../../../src/cli/commands/docs.ts"],"sourcesContent":["/**\n * Docs Command\n *\n * Initialize and manage documentation directory.\n */\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport ora from 'ora';\nimport { initDocs, docsExist, getDocsPath } from '../../generators/docs-init.js';\nimport { generateDocsWithAgents } from '../../generators/doc-generator-agents.js';\nimport { validateProjectRoot, validateDocsPath } from '../../core/security.js';\n\n/**\n * Create docs command\n */\nexport function createDocsCommand(): Command {\n const command = new Command('docs');\n\n command\n .description('Documentation management commands');\n\n // Init subcommand\n command\n .command('init')\n .description('Initialize documentation directory with weave-nn structure')\n .option('-p, --path <path>', 'Project root path', '.')\n .option('-d, --docs <path>', 'Docs directory path', 'docs')\n .option('-t, --template <template>', 'Template to use (default, minimal)')\n .option('--no-examples', 'Skip example files')\n .option('--no-detect', 'Skip framework detection')\n .option('-f, --force', 'Overwrite existing files')\n .option('-g, --generate', 'Generate documents using expert agents')\n .option('--parallel', 'Run agent generation in parallel')\n .option('--dry-run', 'Show what would be generated without creating files')\n .option('-v, --verbose', 'Show detailed agent output')\n .option('--force-generate', 'Force regenerate documents even if they exist')\n .action(async (options) => {\n const spinner = ora('Initializing documentation...').start();\n\n try {\n // Validate paths to prevent traversal attacks\n const projectRoot = validateProjectRoot(options.path);\n const docsPath = options.docs;\n validateDocsPath(projectRoot, docsPath); // Ensure docs stays within project\n\n // Note: initDocs is additive - it only creates missing files/directories\n // The --force flag is for overwriting existing files if needed in the future\n const isExisting = docsExist(projectRoot, docsPath);\n if (isExisting) {\n spinner.text = 'Adding missing files to existing documentation...';\n }\n\n const result = await initDocs({\n projectRoot,\n docsPath,\n includeExamples: options.examples !== false,\n detectFramework: options.detect !== false,\n });\n\n if (result.success) {\n if (isExisting && result.filesCreated.length === 0) {\n spinner.succeed('Documentation already complete - no new files needed');\n } else if (isExisting) {\n spinner.succeed(`Documentation updated - added ${result.filesCreated.length} missing files`);\n } else {\n spinner.succeed('Documentation initialized!');\n }\n } else {\n spinner.warn('Documentation initialized with errors');\n }\n\n console.log();\n console.log(chalk.white(' Created:'));\n console.log(chalk.gray(` Path: ${result.docsPath}`));\n console.log(chalk.green(` Files: ${result.filesCreated.length}`));\n\n if (result.errors.length > 0) {\n console.log();\n console.log(chalk.yellow(' Errors:'));\n result.errors.forEach(err => {\n console.log(chalk.gray(` - ${err}`));\n });\n }\n\n console.log();\n console.log(chalk.cyan('Structure created:'));\n console.log(chalk.gray(`\n ${docsPath}/\n ├── README.md # Documentation home\n ├── PRIMITIVES.md # Technology primitives\n ├── MOC.md # Map of Content\n ├── concepts/ # Abstract concepts\n ├── components/ # Reusable components\n ├── services/ # Backend services\n ├── features/ # Product features\n ├── integrations/ # External integrations\n ├── standards/ # Coding standards\n ├── guides/ # How-to guides\n └── references/ # API references\n `));\n\n // Run agent generation if requested\n if (options.generate) {\n console.log();\n const genSpinner = ora('Analyzing project and generating documents with expert agents...').start();\n\n try {\n const genResult = await generateDocsWithAgents(projectRoot, result.docsPath, {\n parallel: options.parallel,\n dryRun: options.dryRun,\n verbose: options.verbose,\n force: options.forceGenerate,\n });\n\n if (options.dryRun) {\n genSpinner.info('Dry run complete - no files created');\n } else if (genResult.success) {\n genSpinner.succeed(`Generated ${genResult.documentsGenerated.filter(d => d.generated).length} documents using ${genResult.agentsSpawned} agents`);\n } else {\n genSpinner.warn(`Generated ${genResult.documentsGenerated.filter(d => d.generated).length} documents with ${genResult.errors.length} errors`);\n }\n\n if (genResult.documentsGenerated.length > 0 && !options.dryRun) {\n console.log();\n console.log(chalk.white(' Generated Documents:'));\n for (const doc of genResult.documentsGenerated) {\n const icon = doc.generated ? chalk.green('✓') : chalk.red('✗');\n console.log(` ${icon} ${doc.path}${doc.error ? chalk.gray(` (${doc.error})`) : ''}`);\n }\n }\n\n if (genResult.errors.length > 0 && !options.dryRun) {\n console.log();\n console.log(chalk.yellow(' Agent Errors:'));\n genResult.errors.forEach(err => {\n console.log(chalk.gray(` - ${err}`));\n });\n }\n } catch (genError) {\n genSpinner.fail('Agent generation failed');\n console.error(chalk.red(String(genError)));\n }\n }\n\n console.log();\n console.log(chalk.cyan('Next: ') + chalk.white('kg graph') + chalk.gray(' to generate knowledge graph'));\n console.log();\n\n } catch (error) {\n spinner.fail('Failed to initialize documentation');\n console.error(chalk.red(String(error)));\n process.exit(1);\n }\n });\n\n // Status subcommand\n command\n .command('status')\n .description('Show documentation status')\n .option('-p, --path <path>', 'Project root path', '.')\n .action(async (options) => {\n // Validate path to prevent traversal\n const projectRoot = validateProjectRoot(options.path);\n const docsPath = getDocsPath(projectRoot);\n\n if (!docsPath) {\n console.log(chalk.yellow(' No documentation directory found'));\n console.log(chalk.gray(' Run ') + chalk.cyan('kg docs init') + chalk.gray(' to create one'));\n return;\n }\n\n console.log(chalk.white('\\n Documentation Status\\n'));\n console.log(chalk.gray(' Path:'), chalk.white(docsPath));\n console.log();\n\n // Count files\n const fg = await import('fast-glob');\n const files = await fg.default('**/*.md', {\n cwd: docsPath,\n ignore: ['node_modules/**', '.git/**'],\n });\n\n console.log(chalk.gray(' Markdown files:'), chalk.white(files.length));\n\n // Check for key files\n const keyFiles = ['README.md', 'PRIMITIVES.md', 'MOC.md'];\n const fs = await import('fs');\n const path = await import('path');\n\n console.log();\n console.log(chalk.white(' Key Files:'));\n keyFiles.forEach(file => {\n const exists = fs.existsSync(path.join(docsPath, file));\n const icon = exists ? chalk.green('✓') : chalk.red('✗');\n console.log(` ${icon} ${file}`);\n });\n\n // Check directories\n const dirs = ['concepts', 'components', 'services', 'features', 'guides'];\n console.log();\n console.log(chalk.white(' Directories:'));\n dirs.forEach(dir => {\n const exists = fs.existsSync(path.join(docsPath, dir));\n const icon = exists ? chalk.green('✓') : chalk.gray('○');\n console.log(` ${icon} ${dir}/`);\n });\n\n console.log();\n });\n\n return command;\n}\n"],"names":[],"mappings":";;;;;;AAgBO,SAAS,oBAA6B;AAC3C,QAAM,UAAU,IAAI,QAAQ,MAAM;AAElC,UACG,Y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ands/docs.ts"],"sourcesContent":["/**\n * Docs Command\n *\n * Initialize and manage documentation directory.\n */\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport ora from 'ora';\nimport { join } from 'path';\nimport { initDocs, docsExist, getDocsPath } from '../../generators/docs-init.js';\nimport { generateDocsWithAgents } from '../../generators/doc-generator-agents.js';\nimport { cultivateDocs } from '../../generators/doc-cultivator.js';\nimport { validateProjectRoot, validateDocsPath } from '../../core/security.js';\n\n/**\n * Create docs command\n */\nexport function createDocsCommand(): Command {\n const command = new Command('docs');\n\n command\n .description('Documentation management commands');\n\n // Init subcommand\n command\n .command('init')\n .description('Initialize documentation directory with weave-nn structure')\n .option('-p, --path <path>', 'Project root path', '.')\n .option('-d, --docs <path>', 'Docs directory path', 'docs')\n .option('-t, --template <template>', 'Template to use (default, minimal)')\n .option('--no-examples', 'Skip example files')\n .option('--no-detect', 'Skip framework detection')\n .option('-f, --force', 'Overwrite existing files')\n .option('-g, --generate', 'Generate documents using expert agents')\n .option('--parallel', 'Run agent generation in parallel')\n .option('--dry-run', 'Show what would be generated without creating files')\n .option('-v, --verbose', 'Show detailed agent output')\n .option('--force-generate', 'Force regenerate documents even if they exist')\n .action(async (options) => {\n const spinner = ora('Initializing documentation...').start();\n\n try {\n // Validate paths to prevent traversal attacks\n const projectRoot = validateProjectRoot(options.path);\n const docsPath = options.docs;\n validateDocsPath(projectRoot, docsPath); // Ensure docs stays within project\n\n // Note: initDocs is additive - it only creates missing files/directories\n // The --force flag is for overwriting existing files if needed in the future\n const isExisting = docsExist(projectRoot, docsPath);\n if (isExisting) {\n spinner.text = 'Adding missing files to existing documentation...';\n }\n\n const result = await initDocs({\n projectRoot,\n docsPath,\n includeExamples: options.examples !== false,\n detectFramework: options.detect !== false,\n });\n\n if (result.success) {\n if (isExisting && result.filesCreated.length === 0) {\n spinner.succeed('Documentation already complete - no new files needed');\n } else if (isExisting) {\n spinner.succeed(`Documentation updated - added ${result.filesCreated.length} missing files`);\n } else {\n spinner.succeed('Documentation initialized!');\n }\n } else {\n spinner.warn('Documentation initialized with errors');\n }\n\n console.log();\n console.log(chalk.white(' Created:'));\n console.log(chalk.gray(` Path: ${result.docsPath}`));\n console.log(chalk.green(` Files: ${result.filesCreated.length}`));\n\n if (result.errors.length > 0) {\n console.log();\n console.log(chalk.yellow(' Errors:'));\n result.errors.forEach(err => {\n console.log(chalk.gray(` - ${err}`));\n });\n }\n\n console.log();\n console.log(chalk.cyan('Structure created:'));\n console.log(chalk.gray(`\n ${docsPath}/\n ├── README.md # Documentation home\n ├── PRIMITIVES.md # Technology primitives\n ├── MOC.md # Map of Content\n ├── concepts/ # Abstract concepts\n ├── components/ # Reusable components\n ├── services/ # Backend services\n ├── features/ # Product features\n ├── integrations/ # External integrations\n ├── standards/ # Coding standards\n ├── guides/ # How-to guides\n └── references/ # API references\n `));\n\n // Run agent generation if requested\n if (options.generate) {\n console.log();\n const genSpinner = ora('Analyzing project and generating documents with expert agents...').start();\n\n try {\n const genResult = await generateDocsWithAgents(projectRoot, result.docsPath, {\n parallel: options.parallel,\n dryRun: options.dryRun,\n verbose: options.verbose,\n force: options.forceGenerate,\n });\n\n if (options.dryRun) {\n genSpinner.info('Dry run complete - no files created');\n } else if (genResult.success) {\n genSpinner.succeed(`Generated ${genResult.documentsGenerated.filter(d => d.generated).length} documents using ${genResult.agentsSpawned} agents`);\n } else {\n genSpinner.warn(`Generated ${genResult.documentsGenerated.filter(d => d.generated).length} documents with ${genResult.errors.length} errors`);\n }\n\n if (genResult.documentsGenerated.length > 0 && !options.dryRun) {\n console.log();\n console.log(chalk.white(' Generated Documents:'));\n for (const doc of genResult.documentsGenerated) {\n const icon = doc.generated ? chalk.green('✓') : chalk.red('✗');\n console.log(` ${icon} ${doc.path}${doc.error ? chalk.gray(` (${doc.error})`) : ''}`);\n }\n }\n\n if (genResult.errors.length > 0 && !options.dryRun) {\n console.log();\n console.log(chalk.yellow(' Agent Errors:'));\n genResult.errors.forEach(err => {\n console.log(chalk.gray(` - ${err}`));\n });\n }\n } catch (genError) {\n genSpinner.fail('Agent generation failed');\n console.error(chalk.red(String(genError)));\n }\n }\n\n console.log();\n console.log(chalk.cyan('Next: ') + chalk.white('kg graph') + chalk.gray(' to generate knowledge graph'));\n console.log();\n\n } catch (error) {\n spinner.fail('Failed to initialize documentation');\n console.error(chalk.red(String(error)));\n process.exit(1);\n }\n });\n\n // Status subcommand\n command\n .command('status')\n .description('Show documentation status')\n .option('-p, --path <path>', 'Project root path', '.')\n .action(async (options) => {\n // Validate path to prevent traversal\n const projectRoot = validateProjectRoot(options.path);\n const docsPath = getDocsPath(projectRoot);\n\n if (!docsPath) {\n console.log(chalk.yellow(' No documentation directory found'));\n console.log(chalk.gray(' Run ') + chalk.cyan('kg docs init') + chalk.gray(' to create one'));\n return;\n }\n\n console.log(chalk.white('\\n Documentation Status\\n'));\n console.log(chalk.gray(' Path:'), chalk.white(docsPath));\n console.log();\n\n // Count files\n const fg = await import('fast-glob');\n const files = await fg.default('**/*.md', {\n cwd: docsPath,\n ignore: ['node_modules/**', '.git/**'],\n });\n\n console.log(chalk.gray(' Markdown files:'), chalk.white(files.length));\n\n // Check for key files\n const keyFiles = ['README.md', 'PRIMITIVES.md', 'MOC.md'];\n const fs = await import('fs');\n const path = await import('path');\n\n console.log();\n console.log(chalk.white(' Key Files:'));\n keyFiles.forEach(file => {\n const exists = fs.existsSync(path.join(docsPath, file));\n const icon = exists ? chalk.green('✓') : chalk.red('✗');\n console.log(` ${icon} ${file}`);\n });\n\n // Check directories\n const dirs = ['concepts', 'components', 'services', 'features', 'guides'];\n console.log();\n console.log(chalk.white(' Directories:'));\n dirs.forEach(dir => {\n const exists = fs.existsSync(path.join(docsPath, dir));\n const icon = exists ? chalk.green('✓') : chalk.gray('○');\n console.log(` ${icon} ${dir}/`);\n });\n\n console.log();\n });\n\n // Cultivate subcommand - long-running swarm-based documentation buildout\n command\n .command('cultivate')\n .description('Recursively build out all documentation using claude-flow swarm')\n .option('-p, --path <path>', 'Project root path', '.')\n .option('-d, --docs <path>', 'Docs directory path', 'docs')\n .option('--dry-run', 'Show what would be generated without creating files')\n .option('-v, --verbose', 'Show detailed output')\n .option('-f, --force', 'Force regenerate all documents')\n .option('--no-dev-plan', 'Skip development plan generation')\n .option('--no-infra-plan', 'Skip infrastructure plan generation')\n .option('--include-sops', 'Include SOP compliance analysis')\n .option('--services <services>', 'Comma-separated list of services to analyze')\n .option('--max-agents <number>', 'Maximum concurrent agents', '4')\n .option('--background', 'Run in background mode')\n .action(async (options) => {\n const projectRoot = validateProjectRoot(options.path);\n const docsPath = options.docs;\n validateDocsPath(projectRoot, docsPath);\n\n console.log();\n console.log(chalk.cyan.bold(' Documentation Cultivation'));\n console.log(chalk.gray(' ─────────────────────────────'));\n console.log();\n\n if (options.dryRun) {\n console.log(chalk.yellow(' [Dry Run Mode]'));\n console.log();\n }\n\n const spinner = ora('Starting documentation cultivation...').start();\n\n try {\n const result = await cultivateDocs(\n projectRoot,\n join(projectRoot, docsPath),\n {\n dryRun: options.dryRun,\n verbose: options.verbose,\n force: options.force,\n generateDevPlan: options.devPlan !== false,\n generateInfraPlan: options.infraPlan !== false,\n includeSops: options.includeSops,\n services: options.services?.split(',').map((s: string) => s.trim()),\n maxAgents: parseInt(options.maxAgents, 10),\n background: options.background,\n }\n );\n\n if (options.dryRun) {\n spinner.info('Dry run complete');\n } else if (result.success) {\n spinner.succeed('Documentation cultivation complete!');\n } else {\n spinner.warn('Cultivation completed with errors');\n }\n\n // Display results\n console.log();\n console.log(chalk.white(' Services Analyzed:'));\n for (const service of result.services) {\n console.log(chalk.gray(` • ${service.name} (${service.type}) - ${service.sourceFiles.length} files`));\n }\n\n if (!options.dryRun) {\n console.log();\n console.log(chalk.white(' Documents Generated:'), chalk.green(result.documentsGenerated.length));\n if (result.documentsGenerated.length > 0 && options.verbose) {\n for (const doc of result.documentsGenerated) {\n console.log(chalk.gray(` ✓ ${doc}`));\n }\n }\n\n if (result.developmentPlan) {\n console.log();\n console.log(chalk.white(' Development Plan:'));\n console.log(chalk.gray(` Phases: ${result.developmentPlan.phases.length}`));\n console.log(chalk.gray(` Total Estimate: ${result.developmentPlan.totalEstimate}`));\n for (const phase of result.developmentPlan.phases) {\n console.log(chalk.gray(` • ${phase.name} (${phase.estimatedEffort})`));\n }\n }\n\n if (result.infrastructurePlan) {\n console.log();\n console.log(chalk.white(' Infrastructure Plan:'));\n console.log(chalk.gray(` Environments: ${result.infrastructurePlan.environments.join(', ')}`));\n }\n\n if (result.sopCompliance) {\n console.log();\n console.log(chalk.white(' SOP Compliance:'));\n const scoreColor = result.sopCompliance.score >= 80 ? chalk.green :\n result.sopCompliance.score >= 50 ? chalk.yellow : chalk.red;\n console.log(chalk.gray(` Score: `) + scoreColor(`${result.sopCompliance.score}%`));\n if (result.sopCompliance.gaps.length > 0) {\n console.log(chalk.gray(` Gaps: ${result.sopCompliance.gaps.length}`));\n }\n }\n }\n\n if (result.errors.length > 0) {\n console.log();\n console.log(chalk.yellow(' Errors:'));\n for (const error of result.errors.slice(0, 5)) {\n console.log(chalk.gray(` - ${error}`));\n }\n if (result.errors.length > 5) {\n console.log(chalk.gray(` ... and ${result.errors.length - 5} more`));\n }\n }\n\n console.log();\n console.log(chalk.cyan(' Generated files in: ') + chalk.white(join(projectRoot, docsPath)));\n console.log();\n\n if (!options.dryRun) {\n console.log(chalk.cyan(' Key documents:'));\n console.log(chalk.gray(' • docs/planning/development-plan.md'));\n console.log(chalk.gray(' • docs/planning/infrastructure-plan.md'));\n console.log(chalk.gray(' • docs/services/{service}/README.md'));\n console.log();\n }\n\n console.log(chalk.cyan('Next steps:'));\n console.log(chalk.gray(' 1. Review generated documentation'));\n console.log(chalk.gray(' 2. Fill in project-specific details'));\n console.log(chalk.gray(' 3. Run ') + chalk.white('kg graph') + chalk.gray(' to visualize'));\n console.log();\n\n } catch (error) {\n spinner.fail('Cultivation failed');\n console.error(chalk.red(String(error)));\n process.exit(1);\n }\n });\n\n return command;\n}\n"],"names":[],"mappings":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cAAQ,IAAI,MAAM,KAAK,aAAa,CAAC;AACrC,cAAQ,IAAI,MAAM,KAAK,qCAAqC,CAAC;AAC7D,cAAQ,IAAI,MAAM,KAAK,uCAAuC,CAAC;AAC/D,cAAQ,IAAI,MAAM,KAAK,WAAW,IAAI,MAAM,MAAM,UAAU,IAAI,MAAM,KAAK,eAAe,CAAC;AAC3F,cAAQ,IAAA;AAAA,IAEV,SAAS,OAAO;AACd,cAAQ,KAAK,oBAAoB;AACjC,cAAQ,MAAM,MAAM,IAAI,OAAO,KAAK,CAAC,CAAC;AACtC,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AAEH,SAAO;AACT;"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Documentation Cultivator
3
+ *
4
+ * Long-running swarm-based process that recursively analyzes and builds out
5
+ * all documentation, creates development plans, and integrates SOPs.
6
+ *
7
+ * Uses claude-flow swarm orchestration to systematically:
8
+ * - Research and analyze existing docs
9
+ * - Fill documentation gaps
10
+ * - Create phased development plans
11
+ * - Generate deployment/infrastructure plans
12
+ * - Integrate SOP compliance
13
+ *
14
+ * @module generators/doc-cultivator
15
+ */
16
+ /**
17
+ * Cultivation options
18
+ */
19
+ export interface CultivationOptions {
20
+ /** Run in background mode */
21
+ background?: boolean;
22
+ /** Verbose output */
23
+ verbose?: boolean;
24
+ /** Dry run - show plan without executing */
25
+ dryRun?: boolean;
26
+ /** Force regenerate all docs */
27
+ force?: boolean;
28
+ /** Include SOP compliance analysis */
29
+ includeSops?: boolean;
30
+ /** Generate development plan */
31
+ generateDevPlan?: boolean;
32
+ /** Generate deployment/infrastructure plan */
33
+ generateInfraPlan?: boolean;
34
+ /** Custom service directories to analyze */
35
+ services?: string[];
36
+ /** Maximum concurrent agents */
37
+ maxAgents?: number;
38
+ /** Output file for background mode */
39
+ outputFile?: string;
40
+ }
41
+ /**
42
+ * Service analysis result
43
+ */
44
+ export interface ServiceAnalysis {
45
+ name: string;
46
+ path: string;
47
+ type: 'frontend' | 'backend' | 'api' | 'admin' | 'shared' | 'unknown';
48
+ languages: string[];
49
+ frameworks: string[];
50
+ existingDocs: string[];
51
+ sourceFiles: string[];
52
+ dependencies: string[];
53
+ description: string;
54
+ }
55
+ /**
56
+ * Development phase
57
+ */
58
+ export interface DevelopmentPhase {
59
+ id: string;
60
+ name: string;
61
+ description: string;
62
+ priority: 'critical' | 'high' | 'medium' | 'low';
63
+ estimatedEffort: string;
64
+ dependencies: string[];
65
+ services: string[];
66
+ tasks: DevelopmentTask[];
67
+ deliverables: string[];
68
+ }
69
+ /**
70
+ * Development task
71
+ */
72
+ export interface DevelopmentTask {
73
+ id: string;
74
+ title: string;
75
+ description: string;
76
+ service: string;
77
+ type: 'feature' | 'infrastructure' | 'documentation' | 'testing' | 'deployment';
78
+ priority: 'critical' | 'high' | 'medium' | 'low';
79
+ estimatedEffort: string;
80
+ dependencies: string[];
81
+ acceptance: string[];
82
+ }
83
+ /**
84
+ * Cultivation result
85
+ */
86
+ export interface CultivationResult {
87
+ success: boolean;
88
+ projectRoot: string;
89
+ docsPath: string;
90
+ startTime: Date;
91
+ endTime?: Date;
92
+ services: ServiceAnalysis[];
93
+ documentsGenerated: string[];
94
+ documentsUpdated: string[];
95
+ developmentPlan?: {
96
+ phases: DevelopmentPhase[];
97
+ totalEstimate: string;
98
+ criticalPath: string[];
99
+ };
100
+ infrastructurePlan?: {
101
+ environments: string[];
102
+ services: Record<string, string>;
103
+ deployment: string;
104
+ };
105
+ sopCompliance?: {
106
+ score: number;
107
+ gaps: string[];
108
+ recommendations: string[];
109
+ };
110
+ errors: string[];
111
+ logs: string[];
112
+ }
113
+ /**
114
+ * Main cultivation function
115
+ */
116
+ export declare function cultivateDocs(projectRoot: string, docsPath: string, options?: CultivationOptions): Promise<CultivationResult>;
117
+ //# sourceMappingURL=doc-cultivator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doc-cultivator.d.ts","sourceRoot":"","sources":["../../src/generators/doc-cultivator.ts"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