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,266 @@
1
+ "use strict";
2
+ /**
3
+ * @file studio.command.ts
4
+ * @description `sovkora studio` — browse, install and run installable business workflows (ADR-034).
5
+ *
6
+ * The CLI surface of the marketplace. It exists because a Studio run is a first-class
7
+ * operation of the platform, not a web-only feature: the same REST surface the browser
8
+ * uses is reachable from a terminal, and a professional automating their week should not
9
+ * need a tab open.
10
+ */
11
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
+ desc = { enumerable: true, get: function() { return m[k]; } };
16
+ }
17
+ Object.defineProperty(o, k2, desc);
18
+ }) : (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ }));
22
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
23
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
24
+ }) : function(o, v) {
25
+ o["default"] = v;
26
+ });
27
+ var __importStar = (this && this.__importStar) || (function () {
28
+ var ownKeys = function(o) {
29
+ ownKeys = Object.getOwnPropertyNames || function (o) {
30
+ var ar = [];
31
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
32
+ return ar;
33
+ };
34
+ return ownKeys(o);
35
+ };
36
+ return function (mod) {
37
+ if (mod && mod.__esModule) return mod;
38
+ var result = {};
39
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
40
+ __setModuleDefault(result, mod);
41
+ return result;
42
+ };
43
+ })();
44
+ var __importDefault = (this && this.__importDefault) || function (mod) {
45
+ return (mod && mod.__esModule) ? mod : { "default": mod };
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.studioCommand = void 0;
49
+ const commander_1 = require("commander");
50
+ const fs = __importStar(require("node:fs"));
51
+ const chalk_1 = __importDefault(require("chalk"));
52
+ const threads_1 = require("../threads");
53
+ const prompts_1 = require("../ui/prompts");
54
+ const box_1 = require("../ui/box");
55
+ const logger_1 = require("../ui/logger");
56
+ const studio_api_1 = require("../services/studio.api");
57
+ const runs_wait_1 = require("../services/runs.wait");
58
+ const notify_1 = require("../services/notify");
59
+ const node_child_process_1 = require("node:child_process");
60
+ /** Turns `k=v,k2=v2` into an object. The CLI's one concession to terseness. */
61
+ function parsePairs(raw) {
62
+ if (!raw) {
63
+ return {};
64
+ }
65
+ const parsed = {};
66
+ for (const pair of raw.split(",")) {
67
+ const separator = pair.indexOf("=");
68
+ if (separator > 0) {
69
+ parsed[pair.slice(0, separator).trim()] = pair.slice(separator + 1).trim();
70
+ }
71
+ }
72
+ return parsed;
73
+ }
74
+ /** Inputs additionally split comma-lists into arrays, which is what a fan-out needs. */
75
+ function parseInputs(raw) {
76
+ const flat = parsePairs(raw);
77
+ const inputs = {};
78
+ for (const [key, value] of Object.entries(flat)) {
79
+ inputs[key] = value.includes("|") ? value.split("|").map((item) => item.trim()) : value;
80
+ }
81
+ return inputs;
82
+ }
83
+ /**
84
+ * Inputs from a JSON file: what a prose input needs, since a sentence carries the commas that
85
+ * `--inputs` splits on. `--inputs` pairs are applied on top, so one file can be re-run with a seed.
86
+ */
87
+ function readInputsFile(file) {
88
+ const parsed = JSON.parse(fs.readFileSync(file, "utf-8"));
89
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
90
+ throw new Error(`${file} must hold one JSON object of inputs`);
91
+ }
92
+ return parsed;
93
+ }
94
+ function fail(message, error) {
95
+ const detail = error instanceof Error ? error.message : "Unknown error";
96
+ logger_1.Logger.error(`${message}: ${detail}`);
97
+ process.exit(1);
98
+ }
99
+ const listCommand = new commander_1.Command("list")
100
+ .description("Browse the Studio catalogue")
101
+ .option("-p, --profession <trade>", "Filter by trade")
102
+ .action(async (options) => {
103
+ (0, threads_1.requireAuth)();
104
+ const spinner = await (0, prompts_1.createSpinner)();
105
+ spinner.start("Loading the Studio catalogue...");
106
+ try {
107
+ const studios = await studio_api_1.StudioApi.list(options.profession);
108
+ spinner.stop(`${studios.length} Studio(s)`);
109
+ const items = [];
110
+ for (const studio of studios) {
111
+ // A locked Studio is listed, not hidden: the terminal is a funnel too.
112
+ const state = studio.locked ? chalk_1.default.yellow(`○ ${studio.lockedReason}`) : chalk_1.default.green("● available");
113
+ items.push(`${state} ${chalk_1.default.bold(studio.label)} (${studio.studioKey})`);
114
+ if (studio.tagline) {
115
+ items.push(` ${chalk_1.default.gray(studio.tagline)}`);
116
+ }
117
+ items.push(` ${chalk_1.default.gray("" + studio.profession + " · " + studio.pricing + " · " + (studio.latestVersion ?? "unpublished"))}`);
118
+ }
119
+ if (items.length === 0) {
120
+ items.push("No Studio matches that trade yet.");
121
+ }
122
+ box_1.Box.render("🎬 SOVKORA STUDIOS", items, { borderColor: "cyan", titleColor: "white" });
123
+ }
124
+ catch (error) {
125
+ spinner.stop("Failed to load the catalogue");
126
+ fail("Failed to load the Studio catalogue", error);
127
+ }
128
+ });
129
+ const installedCommand = new commander_1.Command("installed")
130
+ .description("List the Studios you have installed")
131
+ .action(async () => {
132
+ (0, threads_1.requireAuth)();
133
+ const spinner = await (0, prompts_1.createSpinner)();
134
+ spinner.start("Loading your Studios...");
135
+ try {
136
+ const installations = await studio_api_1.StudioApi.installations();
137
+ spinner.stop(`${installations.length} installed`);
138
+ const items = [];
139
+ for (const installation of installations) {
140
+ const upgrade = installation.status === "UPGRADE_AVAILABLE" ? chalk_1.default.yellow(` ⤴ ${installation.latestVersion} available`) : "";
141
+ items.push(`${chalk_1.default.bold(installation.label)} (${installation.studioKey}) @ ${installation.pinnedVersion}${upgrade}`, ` ${chalk_1.default.gray(installation.id)}`);
142
+ }
143
+ if (items.length === 0) {
144
+ items.push("Nothing installed yet — try `sovkora studio list`.");
145
+ }
146
+ box_1.Box.render("🎬 MY STUDIOS", items, { borderColor: "cyan", titleColor: "white" });
147
+ }
148
+ catch (error) {
149
+ spinner.stop("Failed to load your Studios");
150
+ fail("Failed to load your installations", error);
151
+ }
152
+ });
153
+ const installCommand = new commander_1.Command("install")
154
+ .description("Install a Studio into your workspace")
155
+ .argument("<studioKey>", "The Studio to install")
156
+ .option("-c, --config <pairs>", "Configuration as key=value,key2=value2")
157
+ .action(async (studioKey, options) => {
158
+ (0, threads_1.requireAuth)();
159
+ const spinner = await (0, prompts_1.createSpinner)();
160
+ spinner.start(`Installing ${studioKey}...`);
161
+ try {
162
+ const installation = await studio_api_1.StudioApi.install(studioKey, parsePairs(options.config));
163
+ spinner.stop(`Installed ${installation.label}`);
164
+ logger_1.Logger.info(`Installation id: ${installation.id}`);
165
+ logger_1.Logger.info(`Pinned version : ${installation.pinnedVersion}`);
166
+ }
167
+ catch (error) {
168
+ spinner.stop("Install refused");
169
+ // A refusal here is usually a 409 naming the package to buy — surfacing the
170
+ // server's message verbatim keeps the upsell intact instead of flattening it.
171
+ fail(`Could not install ${studioKey}`, error);
172
+ }
173
+ });
174
+ const runCommand = new commander_1.Command("run")
175
+ .description("Run an installed Studio — or, with --studio, a toolkit Studio by its key")
176
+ .argument("<target>", "The installation to run (or the Studio key with --studio)")
177
+ .option("-i, --inputs <pairs>", "Inputs as key=value,key2=a|b|c (pipes make a list)")
178
+ .option("-f, --inputs-file <file>", "Inputs as one JSON object (for prose with commas); --inputs pairs apply on top")
179
+ .option("-s, --studio", "The target is a Studio key: a toolkit Studio (media, art direction) has no installation")
180
+ .option("--background", "Print the run id and return at once; follow it with `sovkora runs ls` or `runs wait`")
181
+ .option("--notify", "Send a desktop notification when the run ends or needs your approval")
182
+ .action(async (target, options) => {
183
+ (0, threads_1.requireAuth)();
184
+ const spinner = await (0, prompts_1.createSpinner)();
185
+ spinner.start("Starting the run...");
186
+ try {
187
+ const inputs = {
188
+ ...(options.inputsFile ? readInputsFile(options.inputsFile) : {}),
189
+ ...parseInputs(options.inputs),
190
+ };
191
+ const run = options.studio
192
+ ? await studio_api_1.StudioApi.startStudioRun(target, inputs)
193
+ : await studio_api_1.StudioApi.run(target, inputs);
194
+ spinner.stop(`Run ${run.status.toLowerCase()}`);
195
+ logger_1.Logger.info(`Run id: ${run.id}`);
196
+ if (options.background) {
197
+ logger_1.Logger.info(`Follow it with: sovkora runs wait ${run.id}`);
198
+ if (options.notify)
199
+ watchDetached(run.id);
200
+ return;
201
+ }
202
+ const { outcome } = await (0, runs_wait_1.waitForRun)(run.id, { onStatus: (status) => logger_1.Logger.info(status.toLowerCase()) });
203
+ if (options.notify)
204
+ (0, notify_1.notify)("Sovkora", (0, notify_1.outcomeMessage)(outcome, run.id));
205
+ logger_1.Logger.info((0, notify_1.outcomeMessage)(outcome, run.id));
206
+ logger_1.Logger.info(`Details: sovkora studio logs ${run.id}`);
207
+ }
208
+ catch (error) {
209
+ spinner.stop("Run refused");
210
+ fail("Could not start the run", error);
211
+ }
212
+ });
213
+ /** `--background --notify`: a detached `runs wait --notify` outlives this command and notifies when the run needs you. */
214
+ function watchDetached(runId) {
215
+ const child = (0, node_child_process_1.spawn)(process.execPath, [process.argv[1], "runs", "wait", runId, "--notify", "--json"], {
216
+ detached: true,
217
+ stdio: "ignore",
218
+ });
219
+ child.unref();
220
+ }
221
+ const logsCommand = new commander_1.Command("logs")
222
+ .description("Show a run's per-step state and results")
223
+ .argument("<runId>", "The run to inspect")
224
+ .action(async (runId) => {
225
+ (0, threads_1.requireAuth)();
226
+ const spinner = await (0, prompts_1.createSpinner)();
227
+ spinner.start("Loading the run...");
228
+ try {
229
+ const run = await studio_api_1.StudioApi.runDetail(runId);
230
+ spinner.stop(`Run ${run.status}`);
231
+ const items = [`${chalk_1.default.bold(run.studioKey)} @ ${run.blueprintVersion} — ${run.status}`];
232
+ for (const step of run.steps) {
233
+ let tone = chalk_1.default.gray;
234
+ if (step.status === "SUCCEEDED")
235
+ tone = chalk_1.default.green;
236
+ else if (step.status === "FAILED")
237
+ tone = chalk_1.default.red;
238
+ const fanOut = step.ordinal > 0 ? ` #${step.ordinal + 1}` : "";
239
+ items.push(`${tone("● " + step.status.padEnd(9))} ${step.stepId}${fanOut}`);
240
+ if (step.error) {
241
+ items.push(` ${chalk_1.default.red(step.error)}`);
242
+ }
243
+ if (step.jobId) {
244
+ items.push(` ${chalk_1.default.gray("job " + step.jobId)}`);
245
+ }
246
+ }
247
+ for (const artefact of run.outputs ?? []) {
248
+ items.push(`${chalk_1.default.cyan("→")} ${chalk_1.default.bold(artefact.label)}: ${artefact.value}`);
249
+ }
250
+ if (run.errorMessage) {
251
+ items.push(chalk_1.default.red(run.errorMessage));
252
+ }
253
+ box_1.Box.render("🎬 STUDIO RUN", items, { borderColor: "cyan", titleColor: "white" });
254
+ }
255
+ catch (error) {
256
+ spinner.stop("Failed to load the run");
257
+ fail("Could not load the run", error);
258
+ }
259
+ });
260
+ exports.studioCommand = new commander_1.Command("studio")
261
+ .description("Browse, install and run installable business workflows")
262
+ .addCommand(listCommand)
263
+ .addCommand(installedCommand)
264
+ .addCommand(installCommand)
265
+ .addCommand(runCommand)
266
+ .addCommand(logsCommand);
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ /**
3
+ * @file test.command.ts
4
+ * @description `sovkora test [unit|it|e2e]` — single entry point for the test
5
+ * pyramid (AGENTS.md §1, §9). Maps each tier to the Maven profile matrix
6
+ * (ADR-040): unit → surefire, it → failsafe/Testcontainers, e2e → the hermetic
7
+ * end-to-end orchestration under the `staging` profile.
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
42
+ var __importDefault = (this && this.__importDefault) || function (mod) {
43
+ return (mod && mod.__esModule) ? mod : { "default": mod };
44
+ };
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ exports.testCommand = void 0;
47
+ const commander_1 = require("commander");
48
+ const fs = __importStar(require("node:fs"));
49
+ const path = __importStar(require("node:path"));
50
+ const node_child_process_1 = require("node:child_process");
51
+ const chalk_1 = __importDefault(require("chalk"));
52
+ const prompts_1 = require("../ui/prompts");
53
+ const workspace_guard_1 = require("./workspace-guard");
54
+ const MODES = ["unit", "it", "e2e", "worker"];
55
+ /** Maven invocation per tier. The heavy E2E module is excluded from unit/it. */
56
+ const MAVEN_ARGS = {
57
+ unit: ["test", "-pl", "!e2e/sovkora-e2e"],
58
+ it: ["verify", "-pl", "!e2e/sovkora-e2e"],
59
+ e2e: ["verify", "-P", "staging"],
60
+ // `worker` does not go through Maven — see runWorkerGate below.
61
+ worker: [],
62
+ };
63
+ const DESCRIPTIONS = {
64
+ unit: "Unit tests (surefire) across every module except the E2E suite",
65
+ it: "Integration tests (failsafe / Testcontainers) across the framework + apps",
66
+ e2e: "Hermetic end-to-end orchestration (infra + router + Playwright, staging profile)",
67
+ worker: "Python media worker: ruff lint + pytest (the Maven reactor excludes it by design)",
68
+ };
69
+ /** The Sovkora workspace root (where `./mvnw` lives). */
70
+ function resolveMonorepoRoot() {
71
+ return (0, workspace_guard_1.requireWorkspace)("test");
72
+ }
73
+ function isTestMode(value) {
74
+ return MODES.includes(value);
75
+ }
76
+ exports.testCommand = new commander_1.Command("test")
77
+ .description("Run the test pyramid: unit | it (Testcontainers) | e2e (hermetic)")
78
+ .argument("[mode]", `test tier to run (${MODES.join(" | ")})`, "unit")
79
+ .action(async (mode) => {
80
+ const tier = mode.toLowerCase();
81
+ if (!isTestMode(tier)) {
82
+ await (0, prompts_1.logWarning)(`Unknown test mode "${mode}". Use one of: ${MODES.join(", ")}.`);
83
+ process.exitCode = 1;
84
+ return;
85
+ }
86
+ const root = resolveMonorepoRoot();
87
+ if (tier === "worker") {
88
+ await runWorkerGate(root);
89
+ return;
90
+ }
91
+ const args = [...MAVEN_ARGS[tier]];
92
+ const mvnw = process.platform === "win32" ? "mvnw.cmd" : "./mvnw";
93
+ await (0, prompts_1.intro)(chalk_1.default.cyan(`sovkora test ${tier}`));
94
+ await (0, prompts_1.note)(`${DESCRIPTIONS[tier]}\n\n${chalk_1.default.gray("$")} ${mvnw} ${args.join(" ")}`, "Maven");
95
+ const result = (0, node_child_process_1.spawnSync)(mvnw, args, { cwd: root, stdio: "inherit", shell: false });
96
+ if (result.status === 0) {
97
+ await (0, prompts_1.outro)(chalk_1.default.green(`✔ test ${tier} — green`));
98
+ return;
99
+ }
100
+ await (0, prompts_1.logWarning)(`test ${tier} failed (exit ${result.status ?? result.signal ?? "unknown"})`);
101
+ process.exitCode = result.status ?? 1;
102
+ });
103
+ /**
104
+ * Lint and test the Python media worker.
105
+ *
106
+ * Outside Maven on purpose — the reactor excludes this module because it is a Python project, and
107
+ * that is a sound reason not to hand it to javac. It is not a reason to leave 1 490 lines with no
108
+ * linter and 41 tests nothing runs, in the one component that writes to disk outside the database.
109
+ *
110
+ * Uses the module's own virtualenv rather than a system Python, so the gate runs against the
111
+ * interpreter the worker actually executes under.
112
+ */
113
+ async function runWorkerGate(root) {
114
+ const worker = path.join(root, "workers", "media");
115
+ const bin = path.join(worker, ".venv", "bin");
116
+ if (!fs.existsSync(path.join(bin, "ruff"))) {
117
+ await (0, prompts_1.logWarning)("The worker virtualenv has no ruff/pytest. Run:\n" + ` ${path.join(bin, "python")} -m pip install ruff pytest`);
118
+ process.exitCode = 1;
119
+ return;
120
+ }
121
+ for (const [label, cmd, args] of [
122
+ ["ruff", path.join(bin, "ruff"), ["check", "."]],
123
+ ["pytest", path.join(bin, "pytest"), []],
124
+ ]) {
125
+ await (0, prompts_1.note)(`${chalk_1.default.gray("$")} ${label} ${args.join(" ")}`, "Python worker");
126
+ const result = (0, node_child_process_1.spawnSync)(cmd, [...args], { cwd: worker, stdio: "inherit", shell: false });
127
+ if (result.status !== 0) {
128
+ await (0, prompts_1.logWarning)(`worker ${label} failed`);
129
+ process.exitCode = result.status ?? 1;
130
+ return;
131
+ }
132
+ }
133
+ await (0, prompts_1.outro)(chalk_1.default.green("✔ worker — green"));
134
+ }
@@ -0,0 +1,52 @@
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.verifyCommand = void 0;
7
+ const commander_1 = require("commander");
8
+ const prompts_1 = require("../ui/prompts");
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ const auth_api_1 = require("../services/auth.api");
11
+ async function promptToken(tokenArg) {
12
+ if (tokenArg)
13
+ return tokenArg;
14
+ const tokenInput = await (0, prompts_1.text)({
15
+ message: "Enter Verification Token:",
16
+ validate: (val) => (val.trim().length === 0 ? "Token is required" : undefined),
17
+ });
18
+ if ((0, prompts_1.isCancel)(tokenInput)) {
19
+ throw new Error("CANCELLED");
20
+ }
21
+ return tokenInput;
22
+ }
23
+ exports.verifyCommand = new commander_1.Command("verify")
24
+ .description("Verify account registration token")
25
+ .argument("[token]", "Email verification token")
26
+ .action(async (tokenArg) => {
27
+ try {
28
+ await (0, prompts_1.intro)(chalk_1.default.cyan("Sovkora Email Verification"));
29
+ const token = await promptToken(tokenArg);
30
+ const s = await (0, prompts_1.createSpinner)();
31
+ s.start("Verifying token...");
32
+ try {
33
+ await auth_api_1.AuthApi.verifyEmail(token);
34
+ s.stop("Verification success!");
35
+ await (0, prompts_1.outro)(chalk_1.default.green("✓ Email verified successfully!"));
36
+ await (0, prompts_1.outro)(chalk_1.default.yellow("You can now login: sovkora login"));
37
+ }
38
+ catch (err) {
39
+ s.stop("Verification failed");
40
+ const msg = err instanceof Error ? err.message : "Unknown error";
41
+ await (0, prompts_1.outro)(chalk_1.default.red(`❌ Verification Failed: ${msg}`));
42
+ process.exit(1);
43
+ }
44
+ }
45
+ catch (err) {
46
+ if (err instanceof Error && err.message === "CANCELLED") {
47
+ await (0, prompts_1.outro)(chalk_1.default.red("Verification cancelled."));
48
+ return;
49
+ }
50
+ throw err;
51
+ }
52
+ });
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.videoCommand = void 0;
4
+ exports.videoRunOptions = videoRunOptions;
5
+ const commander_1 = require("commander");
6
+ const prompts_1 = require("../ui/prompts");
7
+ const threads_1 = require("../threads");
8
+ const composer_run_1 = require("../services/composer.run");
9
+ const renderers_1 = require("../renderers");
10
+ const logger_1 = require("../ui/logger");
11
+ /** The inputs a `video` flag set sends to the Studio: only what was chosen (the Studio's own defaults fill the rest). */
12
+ function videoRunOptions(options) {
13
+ const aspect = options.aspect?.trim();
14
+ if (aspect && !["9:16", "16:9", "1:1"].includes(aspect)) {
15
+ throw new Error(`--aspect is one of 9:16, 16:9, 1:1 (got "${aspect}")`);
16
+ }
17
+ const seed = options.seed?.trim();
18
+ if (seed && !/^\d{1,19}$/.test(seed)) {
19
+ throw new Error(`--seed is a whole number (got "${seed}")`);
20
+ }
21
+ return {
22
+ durationSeconds: Number.parseInt(options.duration ?? "", 10) || 4,
23
+ model: options.model,
24
+ aspect,
25
+ seed,
26
+ };
27
+ }
28
+ exports.videoCommand = new commander_1.Command("video")
29
+ .description("Generate video from a text prompt")
30
+ .argument("<prompt>", "Text prompt describing the desired video")
31
+ .option("-d, --duration <seconds>", "Duration of the video in seconds", "4")
32
+ .option("-m, --model <model>", "Specify AI model name")
33
+ .option("-a, --aspect <ratio>", "Frame: 9:16 (default of the Studio), 16:9 or 1:1 — the model must make it")
34
+ .option("-s, --seed <number>", "The same prompt, model and seed make the same shot again")
35
+ .option("-o, --output <path>", "Specific file path to save the video")
36
+ .action(async (prompt, options) => {
37
+ (0, threads_1.requireAuth)();
38
+ let runOptions;
39
+ try {
40
+ runOptions = videoRunOptions(options);
41
+ }
42
+ catch (err) {
43
+ logger_1.Logger.error(err instanceof Error ? err.message : "Invalid options");
44
+ process.exit(1);
45
+ }
46
+ const durationSeconds = runOptions.durationSeconds;
47
+ logger_1.Logger.info(`Generating video (${durationSeconds}s)...`);
48
+ logger_1.Logger.hint(`Prompt: "${prompt}"`);
49
+ if (options.model) {
50
+ logger_1.Logger.hint(`Model: "${options.model}"`);
51
+ }
52
+ logger_1.Logger.hint("This may take a while depending on your hardware.\n");
53
+ const s = await (0, prompts_1.createSpinner)();
54
+ s.start("Starting the video-generation run...");
55
+ try {
56
+ // A run, not a POST to /api/v1/media/generation/video: the same work, through the
57
+ // one door that meters it, keeps it for its class and records who asked (ADR-068).
58
+ const run = await (0, composer_run_1.runComposerStudio)({
59
+ capabilityKey: composer_run_1.CAPABILITY.video,
60
+ primary: prompt,
61
+ options: runOptions,
62
+ onStatus: (status) => s.message(`Generating video... Status: ${status}`),
63
+ });
64
+ s.stop(`Generation complete — run ${run.id}`);
65
+ await (0, renderers_1.renderVideo)((0, composer_run_1.firstOutput)(run), options.output);
66
+ }
67
+ catch (err) {
68
+ s.stop("Video generation failed");
69
+ const msg = err instanceof Error ? err.message : "Unknown error";
70
+ logger_1.Logger.error(`Video Generation Failed: ${msg}`);
71
+ process.exit(1);
72
+ }
73
+ });
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ /**
3
+ * @file workspace-guard.ts
4
+ * @description The commands that drive the platform (start, dev, test, docs) run inside an Sovkora
5
+ * workspace. Installed from npm, the CLI can be started anywhere: outside a workspace it says what is
6
+ * missing and how to get it, instead of spawning `./mvnw` in an empty directory.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __importDefault = (this && this.__importDefault) || function (mod) {
42
+ return (mod && mod.__esModule) ? mod : { "default": mod };
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.requireWorkspace = requireWorkspace;
46
+ const path = __importStar(require("node:path"));
47
+ const chalk_1 = __importDefault(require("chalk"));
48
+ const platform_1 = require("../utils/platform");
49
+ /** What a newcomer needs, in the order the workspace loop uses it (AGENTS.md §1). */
50
+ const WORKSPACE_HELP = [
51
+ "Requirements: git, JDK 21, Node.js 22+, Docker (Python 3.11+ for the media worker).",
52
+ "",
53
+ ` ${chalk_1.default.cyan("npx sovkora install")} clones the platform into ./orazaka, then configures it`,
54
+ " or by hand:",
55
+ ` ${chalk_1.default.cyan("git clone https://github.com/krizaka/sovkora.git && cd sovkora")}`,
56
+ ` ${chalk_1.default.cyan("./mvnw install")} ${chalk_1.default.gray("&&")} ${chalk_1.default.cyan("pnpm install")}`,
57
+ ].join("\n");
58
+ /**
59
+ * The workspace root, or exits with the way to get one. Run from outside the workspace it was found in
60
+ * (a clone's own CLI started elsewhere), the process moves into it so every path resolves the same way.
61
+ */
62
+ function requireWorkspace(command) {
63
+ const root = (0, platform_1.locateWorkspace)();
64
+ if (root) {
65
+ if (path.relative(root, process.cwd()).startsWith(".."))
66
+ process.chdir(root);
67
+ return root;
68
+ }
69
+ console.error(chalk_1.default.red(`✖ \`sovkora ${command}\` runs inside a Sovkora workspace, and none was found above ${process.cwd()}.`));
70
+ console.error(`\n${WORKSPACE_HELP}\n`);
71
+ process.exit(1);
72
+ }