sovkora 0.0.0-stage → 1.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 (98) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +9 -0
  3. package/README.md +67 -2
  4. package/dist/commands/agent.command.js +267 -0
  5. package/dist/commands/chat.command.js +214 -0
  6. package/dist/commands/chat.handlers.js +150 -0
  7. package/dist/commands/chat.types.js +44 -0
  8. package/dist/commands/cinema.command.js +643 -0
  9. package/dist/commands/config.command.js +228 -0
  10. package/dist/commands/db.command.js +114 -0
  11. package/dist/commands/demo.command.js +55 -0
  12. package/dist/commands/dev.command.js +462 -0
  13. package/dist/commands/docs.command.js +135 -0
  14. package/dist/commands/doctor.command.js +119 -0
  15. package/dist/commands/forgot.command.js +57 -0
  16. package/dist/commands/generate.command.js +376 -0
  17. package/dist/commands/graph.command.js +54 -0
  18. package/dist/commands/init.command.js +380 -0
  19. package/dist/commands/init.steps.js +115 -0
  20. package/dist/commands/install.command.js +459 -0
  21. package/dist/commands/login.command.js +110 -0
  22. package/dist/commands/logs.command.js +215 -0
  23. package/dist/commands/logs.steps.js +130 -0
  24. package/dist/commands/mcp.command.js +104 -0
  25. package/dist/commands/models.command.js +164 -0
  26. package/dist/commands/onboard.command.js +236 -0
  27. package/dist/commands/pack.command.js +255 -0
  28. package/dist/commands/profile.command.js +51 -0
  29. package/dist/commands/recover.command.js +489 -0
  30. package/dist/commands/register.command.js +94 -0
  31. package/dist/commands/release.command.js +99 -0
  32. package/dist/commands/reset.command.js +79 -0
  33. package/dist/commands/runs.command.js +201 -0
  34. package/dist/commands/settings.command.js +85 -0
  35. package/dist/commands/start.command.js +590 -0
  36. package/dist/commands/status.command.js +167 -0
  37. package/dist/commands/stop.command.js +313 -0
  38. package/dist/commands/studio.command.js +266 -0
  39. package/dist/commands/test.command.js +134 -0
  40. package/dist/commands/verify.command.js +52 -0
  41. package/dist/commands/video.command.js +73 -0
  42. package/dist/commands/workspace-guard.js +72 -0
  43. package/dist/index.js +207 -0
  44. package/dist/renderers.js +250 -0
  45. package/dist/services/api-client.js +150 -0
  46. package/dist/services/auth.api.js +87 -0
  47. package/dist/services/chat.api.js +117 -0
  48. package/dist/services/cinema-estimate.json +42 -0
  49. package/dist/services/cinema.childsafe.js +52 -0
  50. package/dist/services/cinema.director.js +285 -0
  51. package/dist/services/cinema.production.js +417 -0
  52. package/dist/services/cinema.staging.js +323 -0
  53. package/dist/services/cinema.story.js +758 -0
  54. package/dist/services/cinema.treatment.js +393 -0
  55. package/dist/services/composer.run.js +94 -0
  56. package/dist/services/demo/demo.documents.js +108 -0
  57. package/dist/services/demo/demo.guard.js +49 -0
  58. package/dist/services/demo/demo.persona.js +114 -0
  59. package/dist/services/demo/demo.seed.js +281 -0
  60. package/dist/services/diagnostics.js +327 -0
  61. package/dist/services/image-model-recipes.json +93 -0
  62. package/dist/services/image-models.js +152 -0
  63. package/dist/services/local-store.js +145 -0
  64. package/dist/services/mcp.api.js +38 -0
  65. package/dist/services/model-catalog.js +70 -0
  66. package/dist/services/notify.js +55 -0
  67. package/dist/services/pack.api.js +23 -0
  68. package/dist/services/pack.bundle.js +241 -0
  69. package/dist/services/pack.sources.js +101 -0
  70. package/dist/services/release-manifest.js +266 -0
  71. package/dist/services/runs.view.js +80 -0
  72. package/dist/services/runs.wait.js +38 -0
  73. package/dist/services/semver.js +55 -0
  74. package/dist/services/settings.api.js +108 -0
  75. package/dist/services/string-utils.js +70 -0
  76. package/dist/services/studio.api.js +120 -0
  77. package/dist/services/templates.js +893 -0
  78. package/dist/services/tool-installer.js +353 -0
  79. package/dist/services/tool-path.js +72 -0
  80. package/dist/services/version-manager.js +253 -0
  81. package/dist/services/workspace-bootstrap.js +68 -0
  82. package/dist/threads.js +202 -0
  83. package/dist/types/api.types.js +6 -0
  84. package/dist/types/local.types.js +6 -0
  85. package/dist/ui/box.js +46 -0
  86. package/dist/ui/logger.js +28 -0
  87. package/dist/ui/platform.js +32 -0
  88. package/dist/ui/prompts.js +130 -0
  89. package/dist/ui/table.js +33 -0
  90. package/dist/utils/config.js +150 -0
  91. package/dist/utils/development-status.js +22 -0
  92. package/dist/utils/endpoints.js +41 -0
  93. package/dist/utils/health.js +94 -0
  94. package/dist/utils/pid.js +83 -0
  95. package/dist/utils/platform.js +358 -0
  96. package/dist/utils/process.js +139 -0
  97. package/dist/utils/state-dir.js +105 -0
  98. package/package.json +95 -4
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ /**
3
+ * @file doctor.command.ts
4
+ * @description Health diagnostics with automatic recovery suggestions.
5
+ * Replaces the basic doctor.command.ts with advanced reporting.
6
+ */
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.doctorCommand = void 0;
12
+ const commander_1 = require("commander");
13
+ const chalk_1 = __importDefault(require("chalk"));
14
+ const prompts_1 = require("../ui/prompts");
15
+ const table_1 = require("../ui/table");
16
+ const diagnostics_1 = require("../services/diagnostics");
17
+ const config_1 = require("../utils/config");
18
+ exports.doctorCommand = new commander_1.Command("doctor")
19
+ .description("Advanced system health check with automatic recovery suggestions")
20
+ .option("-q, --quiet", "Only show issues, suppress passing checks")
21
+ .option("--fix", "Attempt to auto-fix detected issues")
22
+ .option("-v, --verbose", "Show detailed diagnostic output")
23
+ .action(async (options) => {
24
+ await (0, prompts_1.intro)(chalk_1.default.cyan.bold("🥷 Sovkora System Diagnostics v2"));
25
+ const spinner = await (0, prompts_1.createSpinner)();
26
+ // Run diagnostics
27
+ spinner.start("Scanning system and workspace...");
28
+ const report = await (0, diagnostics_1.runDiagnostics)();
29
+ spinner.stop(`Scan complete: ${report.criticalCount} error(s), ${report.warningCount} warning(s)`);
30
+ // Display system info
31
+ if (!options.quiet) {
32
+ await (0, prompts_1.note)([
33
+ `${chalk_1.default.yellow("OS")} ${report.systemInfo.platform} (${report.systemInfo.arch})`,
34
+ `${chalk_1.default.yellow("Hostname")} ${report.systemInfo.hostname}`,
35
+ `${chalk_1.default.yellow("CPU")} ${report.systemInfo.cpuModel}`,
36
+ `${chalk_1.default.yellow("Memory")} ${report.systemInfo.totalMemoryGb} GB`,
37
+ `${chalk_1.default.yellow("Node.js")} ${report.systemInfo.nodeVersion}`,
38
+ ].join("\n"), "System Information");
39
+ }
40
+ // Display issues in table format
41
+ if (report.issues.length > 0) {
42
+ const issueRows = [];
43
+ for (const issue of report.issues) {
44
+ let statusIcon = chalk_1.default.blue("ℹ");
45
+ if (issue.severity === "error")
46
+ statusIcon = chalk_1.default.red("✖");
47
+ else if (issue.severity === "warning")
48
+ statusIcon = chalk_1.default.yellow("⚠");
49
+ issueRows.push([statusIcon, chalk_1.default.gray(issue.code), issue.title, chalk_1.default.yellow(issue.severity)]);
50
+ }
51
+ console.log("\n");
52
+ table_1.TableFormatter.render(["Status", "Code", "Title", "Severity"], issueRows);
53
+ console.log();
54
+ // Show detailed suggestions
55
+ if (options.verbose) {
56
+ for (const issue of report.issues) {
57
+ await (0, prompts_1.logInfo)(`\n${chalk_1.default.bold(issue.title)} (${issue.code})`);
58
+ console.log(` ${issue.description}\n`);
59
+ console.log(" Suggestions:");
60
+ for (const suggestion of issue.suggestions) {
61
+ console.log(` • ${suggestion}`);
62
+ }
63
+ }
64
+ }
65
+ else {
66
+ await (0, prompts_1.note)(report.issues
67
+ .map((issue) => `${chalk_1.default.bold(issue.code)}: ${issue.title}\n${issue.description}\n\nRun with ${chalk_1.default.cyan("--verbose")} to see suggestions.`)
68
+ .join("\n\n"), "Detected Issues");
69
+ }
70
+ // Attempt auto-fix if requested
71
+ if (options.fix && report.issues.some((i) => i.autoFixable)) {
72
+ const shouldFix = await (0, prompts_1.confirm)({
73
+ message: "Attempt to auto-fix detected issues?",
74
+ initialValue: false,
75
+ });
76
+ if (shouldFix) {
77
+ spinner.start("Applying fixes...");
78
+ const fixed = await (0, diagnostics_1.autoFixIssues)(report.issues);
79
+ spinner.stop(`Fixed ${fixed.length} issue(s)`);
80
+ if (fixed.length > 0) {
81
+ for (const fixCode of fixed) {
82
+ await (0, prompts_1.logSuccess)(`Fixed: ${fixCode}`);
83
+ }
84
+ }
85
+ }
86
+ }
87
+ // Exit with error if critical issues
88
+ if (report.criticalCount > 0) {
89
+ await (0, prompts_1.logError)(`${report.criticalCount} critical issue(s) detected.\n` +
90
+ `Run with ${chalk_1.default.cyan("--verbose")} to see detailed suggestions.`);
91
+ process.exit(1);
92
+ }
93
+ }
94
+ else {
95
+ await (0, prompts_1.logSuccess)("✨ All systems healthy!");
96
+ }
97
+ // Runtime checks (ports, services)
98
+ await (0, prompts_1.logInfo)("Checking runtime services...");
99
+ const portChecks = [
100
+ { port: config_1.PORTS.postgres, name: "PostgreSQL", service: "database" },
101
+ { port: config_1.PORTS.redis, name: "Redis", service: "cache" },
102
+ { port: config_1.PORTS.rabbitmq, name: "RabbitMQ", service: "queue" },
103
+ { port: config_1.PORTS.ollama, name: "Ollama", service: "ai-engine" },
104
+ { port: config_1.PORTS.localai, name: "LocalAI (Images)", service: "image-worker" },
105
+ { port: config_1.PORTS.mediaWorker, name: "Media Worker", service: "media-worker" },
106
+ { port: config_1.PORTS.router, name: "Router API", service: "backend" },
107
+ { port: config_1.PORTS.web, name: "UI Frontend", service: "frontend" },
108
+ ];
109
+ const serviceRows = [];
110
+ for (const check of portChecks) {
111
+ const available = !(await (0, diagnostics_1.checkHttpEndpoint)(`http://localhost:${check.port}`, 500));
112
+ const status = available ? chalk_1.default.gray("Not Running") : chalk_1.default.green("✔ Running");
113
+ serviceRows.push([check.name, String(check.port), status]);
114
+ }
115
+ console.log();
116
+ table_1.TableFormatter.render(["Service", "Port", "Status"], serviceRows);
117
+ console.log();
118
+ await (0, prompts_1.outro)(chalk_1.default.cyan("✨ Diagnostics complete."));
119
+ });
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ /**
3
+ * @file forgot.command.ts
4
+ * @description Command to initiate a password reset request.
5
+ */
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.forgotCommand = void 0;
11
+ const commander_1 = require("commander");
12
+ const prompts_1 = require("../ui/prompts");
13
+ const chalk_1 = __importDefault(require("chalk"));
14
+ const auth_api_1 = require("../services/auth.api");
15
+ async function promptEmail(emailArg) {
16
+ if (emailArg)
17
+ return emailArg;
18
+ const emailInput = await (0, prompts_1.text)({
19
+ message: "Enter your account email:",
20
+ placeholder: "username@orazaka.com",
21
+ validate: (val) => (val.includes("@") ? undefined : "Invalid email address"),
22
+ });
23
+ if ((0, prompts_1.isCancel)(emailInput)) {
24
+ throw new Error("CANCELLED");
25
+ }
26
+ return emailInput;
27
+ }
28
+ exports.forgotCommand = new commander_1.Command("forgot")
29
+ .description("Request a password reset token via email")
30
+ .argument("[email]", "Account email address")
31
+ .action(async (emailArg) => {
32
+ try {
33
+ await (0, prompts_1.intro)(chalk_1.default.cyan("Sovkora Password Recovery"));
34
+ const email = await promptEmail(emailArg);
35
+ const s = await (0, prompts_1.createSpinner)();
36
+ s.start("Requesting password reset...");
37
+ try {
38
+ const result = await auth_api_1.AuthApi.forgotPassword(email);
39
+ s.stop("Request processed");
40
+ await (0, prompts_1.outro)(chalk_1.default.green(`✓ ${result.message}`));
41
+ await (0, prompts_1.outro)(chalk_1.default.yellow("Check your email for the reset token, then run: sovkora reset"));
42
+ }
43
+ catch (err) {
44
+ s.stop("Request failed");
45
+ const msg = err instanceof Error ? err.message : "Unknown error";
46
+ await (0, prompts_1.outro)(chalk_1.default.red(`❌ Password Reset Request Failed: ${msg}`));
47
+ process.exit(1);
48
+ }
49
+ }
50
+ catch (err) {
51
+ if (err instanceof Error && err.message === "CANCELLED") {
52
+ await (0, prompts_1.outro)(chalk_1.default.red("Password recovery cancelled."));
53
+ return;
54
+ }
55
+ throw err;
56
+ }
57
+ });
@@ -0,0 +1,376 @@
1
+ "use strict";
2
+ /**
3
+ * @file generate.command.ts
4
+ * @description Smart code generator that scans the workspace to detect placement
5
+ * directories, generates multi-file templates, and shows a full manifest of
6
+ * all files created or updated.
7
+ *
8
+ * Supported generator types:
9
+ * - Business Feature (full-stack: service + controller + hook + BFF route)
10
+ * - Technical Feature (properties + configuration)
11
+ * - Interceptor (Maven submodule + SPI auto-config)
12
+ * - External API Connector (RestClient adapter + properties)
13
+ * - Configuration (env vars + properties)
14
+ * - Low-level: java-service, java-controller, typescript-hook, sql-migration
15
+ */
16
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ var desc = Object.getOwnPropertyDescriptor(m, k);
19
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
20
+ desc = { enumerable: true, get: function() { return m[k]; } };
21
+ }
22
+ Object.defineProperty(o, k2, desc);
23
+ }) : (function(o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ o[k2] = m[k];
26
+ }));
27
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
28
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
29
+ }) : function(o, v) {
30
+ o["default"] = v;
31
+ });
32
+ var __importStar = (this && this.__importStar) || (function () {
33
+ var ownKeys = function(o) {
34
+ ownKeys = Object.getOwnPropertyNames || function (o) {
35
+ var ar = [];
36
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
37
+ return ar;
38
+ };
39
+ return ownKeys(o);
40
+ };
41
+ return function (mod) {
42
+ if (mod && mod.__esModule) return mod;
43
+ var result = {};
44
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
45
+ __setModuleDefault(result, mod);
46
+ return result;
47
+ };
48
+ })();
49
+ var __importDefault = (this && this.__importDefault) || function (mod) {
50
+ return (mod && mod.__esModule) ? mod : { "default": mod };
51
+ };
52
+ Object.defineProperty(exports, "__esModule", { value: true });
53
+ exports.generateCommand = void 0;
54
+ const commander_1 = require("commander");
55
+ const chalk_1 = __importDefault(require("chalk"));
56
+ const prompts_1 = require("../ui/prompts");
57
+ const templates_1 = require("../services/templates");
58
+ const string_utils_1 = require("../services/string-utils");
59
+ const platform_1 = require("../ui/platform");
60
+ const fs = __importStar(require("node:fs"));
61
+ const path = __importStar(require("node:path"));
62
+ /**
63
+ * Generate files based on template type.
64
+ */
65
+ function executeGeneration(templateType, ctx, workspaceRoot) {
66
+ switch (templateType) {
67
+ case "interceptor":
68
+ return (0, templates_1.generateInterceptor)(ctx, workspaceRoot);
69
+ case "business-feature":
70
+ return (0, templates_1.generateBusinessFeature)(ctx, workspaceRoot);
71
+ case "technical-feature":
72
+ return (0, templates_1.generateTechnicalFeature)(ctx, workspaceRoot);
73
+ case "api-connector":
74
+ return (0, templates_1.generateApiConnector)(ctx, workspaceRoot);
75
+ case "configuration":
76
+ return (0, templates_1.generateConfiguration)(ctx, workspaceRoot);
77
+ default:
78
+ return writeSingleTemplate(templateType, ctx, workspaceRoot);
79
+ }
80
+ }
81
+ /**
82
+ * Formats a generated file for the manifest display.
83
+ */
84
+ function formatFileManifest(file) {
85
+ let icon = chalk_1.default.gray("○");
86
+ let actionLabel = chalk_1.default.gray("SKIP");
87
+ if (file.action === "created") {
88
+ icon = chalk_1.default.green("✚");
89
+ actionLabel = chalk_1.default.green("NEW");
90
+ }
91
+ else if (file.action === "updated") {
92
+ icon = chalk_1.default.yellow("✎");
93
+ actionLabel = chalk_1.default.yellow("UPD");
94
+ }
95
+ return ` ${icon} [${actionLabel}] ${chalk_1.default.white(file.relativePath)}\n ${chalk_1.default.gray(file.description)}`;
96
+ }
97
+ /**
98
+ * Writes a single-file template (legacy templates) to the correct workspace location.
99
+ */
100
+ function writeSingleTemplate(type, ctx, workspaceRoot) {
101
+ const struct = (0, templates_1.scanWorkspaceStructure)(workspaceRoot);
102
+ const files = [];
103
+ const nextSteps = [];
104
+ switch (type) {
105
+ case "java-service": {
106
+ const result = (0, templates_1.generateJavaService)(ctx);
107
+ const coreSrc = path.join(struct.coreDir ?? path.join(workspaceRoot, "engine", "sovkora-engine-core"), "src", "main", "java", "com", "orazaka", "core", "application", "service");
108
+ const interfacePath = path.join(coreSrc, `${(0, string_utils_1.pascalCase)(ctx.moduleName)}Service.java`);
109
+ const implPath = path.join(coreSrc, `${(0, string_utils_1.pascalCase)(ctx.moduleName)}ServiceImpl.java`);
110
+ fs.mkdirSync(coreSrc, { recursive: true });
111
+ if (!fs.existsSync(interfacePath)) {
112
+ fs.writeFileSync(interfacePath, result.interface, "utf-8");
113
+ files.push({
114
+ path: interfacePath,
115
+ relativePath: path.relative(workspaceRoot, interfacePath),
116
+ action: "created",
117
+ description: "Service interface",
118
+ });
119
+ }
120
+ if (!fs.existsSync(implPath)) {
121
+ fs.writeFileSync(implPath, result.implementation, "utf-8");
122
+ files.push({
123
+ path: implPath,
124
+ relativePath: path.relative(workspaceRoot, implPath),
125
+ action: "created",
126
+ description: "Service implementation (package-private)",
127
+ });
128
+ }
129
+ nextSteps.push("Add business logic to the ServiceImpl", `Run: mvn clean install -pl engine/sovkora-engine-core`);
130
+ break;
131
+ }
132
+ case "java-controller": {
133
+ const content = (0, templates_1.generateJavaController)(ctx);
134
+ const conversationSrc = path.join(struct.conversationDir ?? path.join(workspaceRoot, "services", "conversation", "sovkora-conversation-service"), "src", "main", "java", "com", "orazaka", "conversationservice", "infrastructure", "adapter", "rest");
135
+ const controllerPath = path.join(conversationSrc, `${(0, string_utils_1.pascalCase)(ctx.moduleName)}Controller.java`);
136
+ fs.mkdirSync(conversationSrc, { recursive: true });
137
+ if (!fs.existsSync(controllerPath)) {
138
+ fs.writeFileSync(controllerPath, content, "utf-8");
139
+ files.push({
140
+ path: controllerPath,
141
+ relativePath: path.relative(workspaceRoot, controllerPath),
142
+ action: "created",
143
+ description: "REST controller",
144
+ });
145
+ }
146
+ nextSteps.push(`Test: curl -X POST http://localhost:8080/${(0, string_utils_1.kebabCase)(ctx.moduleName)}/execute`);
147
+ break;
148
+ }
149
+ case "typescript-hook": {
150
+ const content = (0, templates_1.generateTypeScriptHook)(ctx);
151
+ const hooksDir = path.join(struct.uiDir ?? path.join(workspaceRoot, "apps"), "src", "hooks");
152
+ const hookPath = path.join(hooksDir, `use${(0, string_utils_1.pascalCase)(ctx.moduleName)}.ts`);
153
+ fs.mkdirSync(hooksDir, { recursive: true });
154
+ if (!fs.existsSync(hookPath)) {
155
+ fs.writeFileSync(hookPath, content, "utf-8");
156
+ files.push({
157
+ path: hookPath,
158
+ relativePath: path.relative(workspaceRoot, hookPath),
159
+ action: "created",
160
+ description: "React hook",
161
+ });
162
+ }
163
+ nextSteps.push(`Import: import { use${(0, string_utils_1.pascalCase)(ctx.moduleName)} } from "@/hooks/use${(0, string_utils_1.pascalCase)(ctx.moduleName)}"`);
164
+ break;
165
+ }
166
+ case "sql-migration": {
167
+ const content = (0, templates_1.generateSqlMigration)(ctx);
168
+ const infraDir = struct.infraDir ?? path.join(workspaceRoot, "infra");
169
+ const migrationDir = path.join(infraDir, "local-db");
170
+ const existingFiles = fs.existsSync(migrationDir)
171
+ ? fs.readdirSync(migrationDir).filter((f) => f.endsWith(".sql"))
172
+ : [];
173
+ const nextNum = String(existingFiles.length + 1).padStart(2, "0");
174
+ const migrationPath = path.join(migrationDir, `${nextNum}-create-${(0, string_utils_1.kebabCase)(ctx.moduleName)}.sql`);
175
+ fs.mkdirSync(migrationDir, { recursive: true });
176
+ fs.writeFileSync(migrationPath, content, "utf-8");
177
+ files.push({
178
+ path: migrationPath,
179
+ relativePath: path.relative(workspaceRoot, migrationPath),
180
+ action: "created",
181
+ description: "SQL migration",
182
+ });
183
+ nextSteps.push("Reload DB: npx sovkora start --reinit-db");
184
+ break;
185
+ }
186
+ case "docker-compose": {
187
+ const content = (0, templates_1.generateDockerComposeService)(ctx);
188
+ const composePath = path.join(struct.infraDir ?? path.join(workspaceRoot, "infra"), "docker-compose.yml");
189
+ if (fs.existsSync(composePath)) {
190
+ let existing = fs.readFileSync(composePath, "utf-8");
191
+ existing += "\n" + content;
192
+ fs.writeFileSync(composePath, existing, "utf-8");
193
+ files.push({
194
+ path: composePath,
195
+ relativePath: path.relative(workspaceRoot, composePath),
196
+ action: "updated",
197
+ description: "Added service to docker-compose.yml",
198
+ });
199
+ }
200
+ break;
201
+ }
202
+ default:
203
+ break;
204
+ }
205
+ return { files, nextSteps };
206
+ }
207
+ exports.generateCommand = new commander_1.Command("generate")
208
+ .aliases(["gen", "scaffold"])
209
+ .description("Generate features, interceptors, connectors, and configurations")
210
+ .action(async () => {
211
+ await (0, prompts_1.intro)(chalk_1.default.cyan.bold("🥷 Sovkora Code Generator"));
212
+ const workspaceRoot = (0, platform_1.resolveWorkspaceRoot)();
213
+ const struct = (0, templates_1.scanWorkspaceStructure)(workspaceRoot);
214
+ // Show detected workspace structure
215
+ const structInfo = [
216
+ struct.interceptorsDir ? `${chalk_1.default.green("✔")} Interceptors` : `${chalk_1.default.red("✖")} Interceptors`,
217
+ struct.coreDir ? `${chalk_1.default.green("✔")} Core` : `${chalk_1.default.red("✖")} Core`,
218
+ struct.conversationDir ? `${chalk_1.default.green("✔")} Conversation` : `${chalk_1.default.red("✖")} Conversation`,
219
+ struct.uiDir ? `${chalk_1.default.green("✔")} UI` : `${chalk_1.default.red("✖")} UI`,
220
+ struct.businessDir ? `${chalk_1.default.green("✔")} Business` : `${chalk_1.default.red("✖")} Business`,
221
+ ].join(" │ ");
222
+ await (0, prompts_1.note)(structInfo, "Detected Workspace Modules");
223
+ // Step 1: Select generator type
224
+ const templateType = await (0, prompts_1.select)({
225
+ message: "What would you like to generate?",
226
+ options: [
227
+ {
228
+ value: "business-feature",
229
+ label: "📦 Business Feature",
230
+ hint: "Full-stack: Service + Controller + React Hook + BFF Route",
231
+ },
232
+ {
233
+ value: "technical-feature",
234
+ label: "⚙️ Technical Feature",
235
+ hint: "Properties record + Configuration class + tests",
236
+ },
237
+ {
238
+ value: "interceptor",
239
+ label: "🔗 Interceptor",
240
+ hint: "Maven submodule + SPI auto-config + tests (context-matrix pipeline)",
241
+ },
242
+ {
243
+ value: "api-connector",
244
+ label: "🌐 External API Connector",
245
+ hint: "RestClient adapter + port interface + properties",
246
+ },
247
+ {
248
+ value: "configuration",
249
+ label: "🔧 Configuration / Env Vars",
250
+ hint: "Properties class + .env updates + example env template",
251
+ },
252
+ {
253
+ value: "java-service",
254
+ label: "☕ Java Service (standalone)",
255
+ hint: "Service interface + implementation in orazaka-core",
256
+ },
257
+ {
258
+ value: "java-controller",
259
+ label: "🎯 REST Controller (standalone)",
260
+ hint: "Controller in orazaka-conversation-service/adapter/rest/",
261
+ },
262
+ {
263
+ value: "typescript-hook",
264
+ label: "⚛️ React Hook (standalone)",
265
+ hint: "Custom hook with API integration",
266
+ },
267
+ {
268
+ value: "sql-migration",
269
+ label: "🗃️ Database Migration",
270
+ hint: "Auto-numbered SQL migration in infra/local-db/",
271
+ },
272
+ {
273
+ value: "docker-compose",
274
+ label: "🐳 Docker Compose Service",
275
+ hint: "Append service to docker-compose.yml",
276
+ },
277
+ ],
278
+ initialValue: "business-feature",
279
+ });
280
+ (0, prompts_1.handleCancel)(templateType);
281
+ // Step 2: Get module name
282
+ const moduleName = await (0, prompts_1.text)({
283
+ message: "Enter feature/module name (kebab-case):",
284
+ placeholder: "e.g., user-auth, payment-processor, rag-context",
285
+ validate: (value) => {
286
+ if (!value.trim())
287
+ return "Name cannot be empty";
288
+ if (!(0, string_utils_1.isValidKebabCase)(value)) {
289
+ return "Must be lowercase with hyphens only (e.g., my-module)";
290
+ }
291
+ return undefined;
292
+ },
293
+ });
294
+ (0, prompts_1.handleCancel)(moduleName);
295
+ // Step 3: Get description
296
+ const description = await (0, prompts_1.text)({
297
+ message: "Brief description of this module:",
298
+ placeholder: "e.g., User authentication and session management",
299
+ defaultValue: `Module for ${moduleName}`,
300
+ });
301
+ (0, prompts_1.handleCancel)(description);
302
+ // Step 4: Show preview
303
+ const ctx = {
304
+ moduleName: moduleName,
305
+ description: description,
306
+ year: new Date().getFullYear(),
307
+ };
308
+ await (0, prompts_1.note)([
309
+ `${chalk_1.default.yellow("Type")} ${chalk_1.default.white(templateType)}`,
310
+ `${chalk_1.default.yellow("Name")} ${chalk_1.default.white(ctx.moduleName)}`,
311
+ `${chalk_1.default.yellow("PascalCase")} ${chalk_1.default.cyan((0, string_utils_1.pascalCase)(ctx.moduleName))}`,
312
+ `${chalk_1.default.yellow("Description")} ${chalk_1.default.white(ctx.description)}`,
313
+ ].join("\n"), "Generation Preview");
314
+ // Step 5: Confirm
315
+ const shouldGenerate = await (0, prompts_1.confirm)({
316
+ message: "Generate all files?",
317
+ initialValue: true,
318
+ });
319
+ (0, prompts_1.handleCancel)(shouldGenerate);
320
+ if (shouldGenerate !== true) {
321
+ await (0, prompts_1.outro)(chalk_1.default.yellow("Generation cancelled."));
322
+ return;
323
+ }
324
+ // Step 6: Generate
325
+ await (0, prompts_1.logStep)("Generating files...");
326
+ let result;
327
+ try {
328
+ result = executeGeneration(templateType, ctx, workspaceRoot);
329
+ }
330
+ catch (err) {
331
+ const msg = err instanceof Error ? err.message : "Unknown error";
332
+ await (0, prompts_1.logError)(`Generation failed: ${msg}`);
333
+ process.exit(1);
334
+ return;
335
+ }
336
+ // Step 7: Display manifest
337
+ if (result.files.length === 0) {
338
+ await (0, prompts_1.logWarning)("No files were generated.");
339
+ await (0, prompts_1.outro)(chalk_1.default.yellow("Nothing to do."));
340
+ return;
341
+ }
342
+ const created = result.files.filter((f) => f.action === "created");
343
+ const updated = result.files.filter((f) => f.action === "updated");
344
+ const skipped = result.files.filter((f) => f.action === "skipped");
345
+ const manifestLines = [];
346
+ if (created.length > 0) {
347
+ manifestLines.push(chalk_1.default.green.bold(`📄 Created (${String(created.length)}):`));
348
+ for (const f of created) {
349
+ manifestLines.push(formatFileManifest(f));
350
+ }
351
+ manifestLines.push("");
352
+ }
353
+ if (updated.length > 0) {
354
+ manifestLines.push(chalk_1.default.yellow.bold(`✎ Updated (${String(updated.length)}):`));
355
+ for (const f of updated) {
356
+ manifestLines.push(formatFileManifest(f));
357
+ }
358
+ manifestLines.push("");
359
+ }
360
+ if (skipped.length > 0) {
361
+ manifestLines.push(chalk_1.default.gray(`○ Skipped (${String(skipped.length)}):`));
362
+ for (const f of skipped) {
363
+ manifestLines.push(formatFileManifest(f));
364
+ }
365
+ manifestLines.push("");
366
+ }
367
+ manifestLines.push(chalk_1.default.gray("─".repeat(50)), ` Total: ${chalk_1.default.green(String(created.length))} new, ${chalk_1.default.yellow(String(updated.length))} updated, ${chalk_1.default.gray(String(skipped.length))} skipped`);
368
+ await (0, prompts_1.note)(manifestLines.join("\n"), "📋 File Manifest");
369
+ // Step 8: Show next steps
370
+ if (result.nextSteps.length > 0) {
371
+ const stepsLines = result.nextSteps.map((step, i) => ` ${chalk_1.default.cyan(String(i + 1) + ".")} ${step}`);
372
+ await (0, prompts_1.note)(stepsLines.join("\n"), "🚀 Next Steps");
373
+ }
374
+ await (0, prompts_1.logSuccess)(`✨ Generated ${String(result.files.length)} file(s) for ${chalk_1.default.cyan((0, string_utils_1.pascalCase)(ctx.moduleName))}`);
375
+ await (0, prompts_1.outro)(chalk_1.default.cyan("Happy coding! 🥷"));
376
+ });
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ /**
3
+ * @file graph.command.ts
4
+ * @description Command to fetch and display the Operation Graph and its capability states.
5
+ */
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.graphCommand = void 0;
11
+ const commander_1 = require("commander");
12
+ const prompts_1 = require("../ui/prompts");
13
+ const chalk_1 = __importDefault(require("chalk"));
14
+ const threads_1 = require("../threads");
15
+ const settings_api_1 = require("../services/settings.api");
16
+ const logger_1 = require("../ui/logger");
17
+ const box_1 = require("../ui/box");
18
+ exports.graphCommand = new commander_1.Command("graph")
19
+ .description("Display Operation Graph capability matrix")
20
+ .action(async () => {
21
+ (0, threads_1.requireAuth)();
22
+ const s = await (0, prompts_1.createSpinner)();
23
+ s.start("Loading Operation Graph...");
24
+ try {
25
+ const nodes = await settings_api_1.SettingsApi.getOperationGraph();
26
+ s.stop("Operation Graph loaded");
27
+ const visibleNodes = nodes.filter((n) => n.state.type !== "INVISIBLE");
28
+ const items = [];
29
+ if (visibleNodes.length === 0) {
30
+ items.push("No active capabilities returned by the engine.");
31
+ }
32
+ else {
33
+ for (const node of visibleNodes) {
34
+ const stateTag = node.state.type === "ACTIVE" ? chalk_1.default.green("● ACTIVE ") : chalk_1.default.red("○ LOCKED ");
35
+ items.push(`${stateTag} ${chalk_1.default.bold(node.id)}`);
36
+ if (node.state.type === "LOCKED" && node.state.reason) {
37
+ const reasonText = chalk_1.default.gray(`Reason: ${node.state.reason}`);
38
+ items.push(` ${reasonText}`);
39
+ }
40
+ }
41
+ }
42
+ items.push(`Total: ${visibleNodes.length} visible / ${nodes.length} total capabilities`);
43
+ box_1.Box.render("🥷 SOVKORA OPERATION GRAPH", items, {
44
+ borderColor: "cyan",
45
+ titleColor: "white",
46
+ });
47
+ }
48
+ catch (err) {
49
+ s.stop("Failed to load Operation Graph");
50
+ const msg = err instanceof Error ? err.message : "Unknown error";
51
+ logger_1.Logger.error(`Failed to load Operation Graph: ${msg}`);
52
+ process.exit(1);
53
+ }
54
+ });