@uxmaltech/collab-cli 0.1.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.
Files changed (109) hide show
  1. package/README.md +227 -0
  2. package/bin/collab +10 -0
  3. package/dist/cli.js +34 -0
  4. package/dist/commands/canon/index.js +16 -0
  5. package/dist/commands/canon/rebuild.js +95 -0
  6. package/dist/commands/compose/generate.js +63 -0
  7. package/dist/commands/compose/index.js +18 -0
  8. package/dist/commands/compose/validate.js +53 -0
  9. package/dist/commands/doctor.js +153 -0
  10. package/dist/commands/index.js +27 -0
  11. package/dist/commands/infra/down.js +23 -0
  12. package/dist/commands/infra/index.js +20 -0
  13. package/dist/commands/infra/shared.js +59 -0
  14. package/dist/commands/infra/status.js +64 -0
  15. package/dist/commands/infra/up.js +29 -0
  16. package/dist/commands/init.js +830 -0
  17. package/dist/commands/mcp/index.js +20 -0
  18. package/dist/commands/mcp/shared.js +57 -0
  19. package/dist/commands/mcp/start.js +45 -0
  20. package/dist/commands/mcp/status.js +62 -0
  21. package/dist/commands/mcp/stop.js +23 -0
  22. package/dist/commands/seed.js +55 -0
  23. package/dist/commands/uninstall.js +36 -0
  24. package/dist/commands/up.js +78 -0
  25. package/dist/commands/update-canons.js +48 -0
  26. package/dist/commands/upgrade.js +54 -0
  27. package/dist/index.js +14 -0
  28. package/dist/lib/ai-client.js +317 -0
  29. package/dist/lib/ansi.js +58 -0
  30. package/dist/lib/canon-index-generator.js +64 -0
  31. package/dist/lib/canon-index-targets.js +68 -0
  32. package/dist/lib/canon-resolver.js +262 -0
  33. package/dist/lib/canon-scaffold.js +57 -0
  34. package/dist/lib/cli-detection.js +149 -0
  35. package/dist/lib/command-context.js +23 -0
  36. package/dist/lib/compose-defaults.js +47 -0
  37. package/dist/lib/compose-env.js +24 -0
  38. package/dist/lib/compose-paths.js +36 -0
  39. package/dist/lib/compose-renderer.js +134 -0
  40. package/dist/lib/compose-validator.js +56 -0
  41. package/dist/lib/config.js +195 -0
  42. package/dist/lib/credentials.js +63 -0
  43. package/dist/lib/docker-checks.js +73 -0
  44. package/dist/lib/docker-compose.js +15 -0
  45. package/dist/lib/docker-status.js +151 -0
  46. package/dist/lib/domain-gen.js +376 -0
  47. package/dist/lib/ecosystem.js +150 -0
  48. package/dist/lib/env-file.js +77 -0
  49. package/dist/lib/errors.js +30 -0
  50. package/dist/lib/executor.js +85 -0
  51. package/dist/lib/github-auth.js +204 -0
  52. package/dist/lib/hash.js +7 -0
  53. package/dist/lib/health-checker.js +140 -0
  54. package/dist/lib/logger.js +87 -0
  55. package/dist/lib/mcp-client.js +88 -0
  56. package/dist/lib/mode.js +36 -0
  57. package/dist/lib/model-listing.js +102 -0
  58. package/dist/lib/model-registry.js +55 -0
  59. package/dist/lib/npm-operations.js +69 -0
  60. package/dist/lib/orchestrator.js +170 -0
  61. package/dist/lib/parsers.js +42 -0
  62. package/dist/lib/port-resolver.js +57 -0
  63. package/dist/lib/preconditions.js +35 -0
  64. package/dist/lib/preflight.js +88 -0
  65. package/dist/lib/process.js +6 -0
  66. package/dist/lib/prompt.js +125 -0
  67. package/dist/lib/providers.js +117 -0
  68. package/dist/lib/repo-analysis-helpers.js +379 -0
  69. package/dist/lib/repo-scanner.js +195 -0
  70. package/dist/lib/service-health.js +79 -0
  71. package/dist/lib/shell.js +49 -0
  72. package/dist/lib/state.js +38 -0
  73. package/dist/lib/update-checker.js +130 -0
  74. package/dist/lib/version.js +27 -0
  75. package/dist/stages/agent-skills-setup.js +301 -0
  76. package/dist/stages/assistant-setup.js +325 -0
  77. package/dist/stages/canon-ingest.js +249 -0
  78. package/dist/stages/canon-rebuild-graph.js +33 -0
  79. package/dist/stages/canon-rebuild-indexes.js +40 -0
  80. package/dist/stages/canon-rebuild-snapshot.js +75 -0
  81. package/dist/stages/canon-rebuild-validate.js +57 -0
  82. package/dist/stages/canon-rebuild-vectors.js +30 -0
  83. package/dist/stages/canon-scaffold.js +15 -0
  84. package/dist/stages/canon-sync.js +49 -0
  85. package/dist/stages/ci-setup.js +56 -0
  86. package/dist/stages/domain-gen.js +363 -0
  87. package/dist/stages/graph-seed.js +26 -0
  88. package/dist/stages/repo-analysis-fileonly.js +111 -0
  89. package/dist/stages/repo-analysis.js +112 -0
  90. package/dist/stages/repo-scaffold.js +110 -0
  91. package/dist/templates/canon/contracts-readme.js +39 -0
  92. package/dist/templates/canon/domain-readme.js +40 -0
  93. package/dist/templates/canon/evolution/changelog.js +53 -0
  94. package/dist/templates/canon/governance/confidence-levels.js +38 -0
  95. package/dist/templates/canon/governance/implementation-process.js +34 -0
  96. package/dist/templates/canon/governance/review-process.js +29 -0
  97. package/dist/templates/canon/governance/schema-versioning.js +25 -0
  98. package/dist/templates/canon/governance/what-enters-the-canon.js +44 -0
  99. package/dist/templates/canon/index.js +28 -0
  100. package/dist/templates/canon/knowledge-readme.js +129 -0
  101. package/dist/templates/canon/system-prompt.js +101 -0
  102. package/dist/templates/ci/architecture-merge.js +29 -0
  103. package/dist/templates/ci/architecture-pr.js +26 -0
  104. package/dist/templates/ci/index.js +7 -0
  105. package/dist/templates/consolidated.js +114 -0
  106. package/dist/templates/infra.js +90 -0
  107. package/dist/templates/mcp.js +32 -0
  108. package/install.sh +455 -0
  109. package/package.json +48 -0
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerCommands = registerCommands;
4
+ const canon_1 = require("./canon");
5
+ const compose_1 = require("./compose");
6
+ const doctor_1 = require("./doctor");
7
+ const infra_1 = require("./infra");
8
+ const init_1 = require("./init");
9
+ const mcp_1 = require("./mcp");
10
+ const seed_1 = require("./seed");
11
+ const up_1 = require("./up");
12
+ const uninstall_1 = require("./uninstall");
13
+ const update_canons_1 = require("./update-canons");
14
+ const upgrade_1 = require("./upgrade");
15
+ function registerCommands(program) {
16
+ (0, init_1.registerInitCommand)(program);
17
+ (0, canon_1.registerCanonCommand)(program);
18
+ (0, compose_1.registerComposeCommand)(program);
19
+ (0, infra_1.registerInfraCommand)(program);
20
+ (0, mcp_1.registerMcpCommand)(program);
21
+ (0, up_1.registerUpCommand)(program);
22
+ (0, seed_1.registerSeedCommand)(program);
23
+ (0, doctor_1.registerDoctorCommand)(program);
24
+ (0, update_canons_1.registerUpdateCanonsCommand)(program);
25
+ (0, upgrade_1.registerUpgradeCommand)(program);
26
+ (0, uninstall_1.registerUninstallCommand)(program);
27
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerInfraDownCommand = registerInfraDownCommand;
4
+ const command_context_1 = require("../../lib/command-context");
5
+ const shared_1 = require("./shared");
6
+ function registerInfraDownCommand(program) {
7
+ program
8
+ .command('down')
9
+ .description('Stop infrastructure services (Qdrant + Nebula)')
10
+ .option('--file <path>', 'Compose file to use')
11
+ .option('--output-dir <directory>', 'Directory used to locate generated compose files')
12
+ .addHelpText('after', `
13
+ Examples:
14
+ collab infra down
15
+ collab infra down --file docker-compose.yml
16
+ `)
17
+ .action(async (options, command) => {
18
+ const context = (0, command_context_1.createCommandContext)(command);
19
+ const selection = (0, shared_1.resolveInfraComposeFile)(context.config, options.outputDir, options.file);
20
+ await (0, shared_1.runInfraCompose)(context.logger, context.executor, context.config, selection, 'stop');
21
+ context.logger.result(`Infrastructure stopped using ${selection.filePath}`);
22
+ });
23
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerInfraCommand = registerInfraCommand;
4
+ const down_1 = require("./down");
5
+ const status_1 = require("./status");
6
+ const up_1 = require("./up");
7
+ function registerInfraCommand(program) {
8
+ const infra = program
9
+ .command('infra')
10
+ .description('Manage infrastructure services used by collab')
11
+ .addHelpText('after', `
12
+ Examples:
13
+ collab infra up
14
+ collab infra down
15
+ collab infra status
16
+ `);
17
+ (0, up_1.registerInfraUpCommand)(infra);
18
+ (0, down_1.registerInfraDownCommand)(infra);
19
+ (0, status_1.registerInfraStatusCommand)(infra);
20
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.INFRA_SERVICES = void 0;
7
+ exports.resolveInfraComposeFile = resolveInfraComposeFile;
8
+ exports.runInfraCompose = runInfraCompose;
9
+ const node_path_1 = __importDefault(require("node:path"));
10
+ const compose_paths_1 = require("../../lib/compose-paths");
11
+ const docker_compose_1 = require("../../lib/docker-compose");
12
+ const errors_1 = require("../../lib/errors");
13
+ const preconditions_1 = require("../../lib/preconditions");
14
+ const service_health_1 = require("../../lib/service-health");
15
+ exports.INFRA_SERVICES = ['qdrant', 'metad0', 'storaged0', 'graphd'];
16
+ /**
17
+ * Resolves the compose file to use for infrastructure services.
18
+ * Prefers an explicit `--file` flag, then falls back to compose-paths resolution.
19
+ */
20
+ function resolveInfraComposeFile(config, outputDirectory, explicitFile) {
21
+ if (explicitFile) {
22
+ const filePath = node_path_1.default.resolve(config.workspaceDir, explicitFile);
23
+ return { filePath, source: 'split' };
24
+ }
25
+ const paths = (0, compose_paths_1.getComposeFilePaths)(config, outputDirectory);
26
+ const selected = (0, compose_paths_1.selectInfraComposeFile)(paths);
27
+ return {
28
+ filePath: selected.file,
29
+ source: selected.source,
30
+ };
31
+ }
32
+ /**
33
+ * Runs a docker compose action for infrastructure services (Qdrant, NebulaGraph).
34
+ * When the action is `'up'`, waits for health checks to pass.
35
+ */
36
+ async function runInfraCompose(logger, executor, config, selection, action, options = {}) {
37
+ (0, preconditions_1.ensureCommandAvailable)('docker', { dryRun: executor.dryRun });
38
+ if (!executor.dryRun) {
39
+ (0, preconditions_1.ensureFileExists)(selection.filePath, 'Compose file');
40
+ }
41
+ const args = action === 'up' ? ['up', '-d'] : action === 'stop' ? ['stop'] : ['ps'];
42
+ const services = selection.source === 'consolidated' ? [...exports.INFRA_SERVICES] : [];
43
+ (0, docker_compose_1.runDockerCompose)({
44
+ executor,
45
+ files: [selection.filePath],
46
+ arguments: [...args, ...services],
47
+ cwd: config.workspaceDir,
48
+ projectName: config.compose.projectName,
49
+ });
50
+ if (action !== 'up') {
51
+ return;
52
+ }
53
+ const env = (0, service_health_1.loadRuntimeEnv)(config);
54
+ const health = await (0, service_health_1.waitForInfraHealth)(env, (0, service_health_1.dryRunHealthOptions)(executor, options.health ?? {}));
55
+ (0, service_health_1.logServiceHealth)(logger, 'infra health', health);
56
+ if (!health.ok) {
57
+ throw new errors_1.CliError('Infrastructure services did not become healthy in time.');
58
+ }
59
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerInfraStatusCommand = registerInfraStatusCommand;
4
+ const command_context_1 = require("../../lib/command-context");
5
+ const docker_compose_1 = require("../../lib/docker-compose");
6
+ const docker_status_1 = require("../../lib/docker-status");
7
+ const health_checker_1 = require("../../lib/health-checker");
8
+ const preconditions_1 = require("../../lib/preconditions");
9
+ const service_health_1 = require("../../lib/service-health");
10
+ const shared_1 = require("./shared");
11
+ /** Fast health check options for status display (no retries). */
12
+ const QUICK_HEALTH_OPTIONS = { timeoutMs: 2_000, retries: 1, retryDelayMs: 0 };
13
+ function registerInfraStatusCommand(program) {
14
+ program
15
+ .command('status')
16
+ .description('Show infrastructure service status')
17
+ .option('--file <path>', 'Compose file to use')
18
+ .option('--output-dir <directory>', 'Directory used to locate generated compose files')
19
+ .addHelpText('after', `
20
+ Examples:
21
+ collab infra status
22
+ collab infra status --file docker-compose.infra.yml
23
+ `)
24
+ .action(async (options, command) => {
25
+ const context = (0, command_context_1.createCommandContext)(command);
26
+ const selection = (0, shared_1.resolveInfraComposeFile)(context.config, options.outputDir, options.file);
27
+ (0, preconditions_1.ensureCommandAvailable)('docker', { dryRun: context.executor.dryRun });
28
+ if (!context.executor.dryRun) {
29
+ (0, preconditions_1.ensureFileExists)(selection.filePath, 'Compose file');
30
+ }
31
+ // Query container status via docker compose ps --format json
32
+ const serviceScope = selection.source === 'consolidated' ? [...shared_1.INFRA_SERVICES] : [];
33
+ let containers = [];
34
+ try {
35
+ const result = (0, docker_compose_1.runDockerCompose)({
36
+ executor: context.executor,
37
+ files: [selection.filePath],
38
+ arguments: ['ps', '--format', 'json', ...serviceScope],
39
+ cwd: context.config.workspaceDir,
40
+ projectName: context.config.compose.projectName,
41
+ check: false,
42
+ });
43
+ containers = (0, docker_status_1.parseComposePs)(result.stdout);
44
+ }
45
+ catch {
46
+ // docker compose ps failed — treat as no running containers
47
+ }
48
+ // Run quick health checks (skip in dry-run mode)
49
+ const env = (0, service_health_1.loadRuntimeEnv)(context.config);
50
+ const qdrantHost = env['QDRANT_HOST'] || '127.0.0.1';
51
+ const qdrantPort = Number(env['QDRANT_PORT']) || 6333;
52
+ const nebulaHost = env['NEBULA_HOST'] || '127.0.0.1';
53
+ const nebulaPort = Number(env['NEBULA_GRAPHD_PORT']) || 9669;
54
+ const healthChecks = context.executor.dryRun
55
+ ? []
56
+ : await Promise.all([
57
+ (0, health_checker_1.checkHttpHealth)('qdrant', `http://${qdrantHost}:${qdrantPort}/collections`, QUICK_HEALTH_OPTIONS),
58
+ (0, health_checker_1.checkTcpHealth)('graphd', nebulaHost, nebulaPort, QUICK_HEALTH_OPTIONS),
59
+ ]);
60
+ // Build and display status table
61
+ const services = (0, docker_status_1.buildServiceStatusList)([...shared_1.INFRA_SERVICES], containers, healthChecks);
62
+ (0, docker_status_1.printStatusTable)(context.logger, 'Infrastructure Services', services, selection.filePath);
63
+ });
64
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerInfraUpCommand = registerInfraUpCommand;
4
+ const command_context_1 = require("../../lib/command-context");
5
+ const parsers_1 = require("../../lib/parsers");
6
+ const shared_1 = require("./shared");
7
+ function registerInfraUpCommand(program) {
8
+ program
9
+ .command('up')
10
+ .description('Start infrastructure services (Qdrant + Nebula) and wait for health')
11
+ .option('--file <path>', 'Compose file to use')
12
+ .option('--output-dir <directory>', 'Directory used to locate generated compose files')
13
+ .option('--timeout-ms <ms>', 'Per-check timeout in milliseconds', '5000')
14
+ .option('--retries <count>', 'Health check retries', '15')
15
+ .option('--retry-delay-ms <ms>', 'Delay between retries in milliseconds', '2000')
16
+ .addHelpText('after', `
17
+ Examples:
18
+ collab infra up
19
+ collab infra up --file docker-compose.infra.yml --timeout-ms 3000 --retries 20
20
+ `)
21
+ .action(async (options, command) => {
22
+ const context = (0, command_context_1.createCommandContext)(command);
23
+ const selection = (0, shared_1.resolveInfraComposeFile)(context.config, options.outputDir, options.file);
24
+ await (0, shared_1.runInfraCompose)(context.logger, context.executor, context.config, selection, 'up', {
25
+ health: (0, parsers_1.parseHealthOptions)(options),
26
+ });
27
+ context.logger.result(`Infrastructure started using ${selection.filePath}`);
28
+ });
29
+ }