kaven-cli 0.4.0-alpha.1 → 0.4.1-alpha.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 (54) hide show
  1. package/README.md +147 -84
  2. package/README.pt-BR.md +334 -0
  3. package/dist/EnvManager-GQMEZ6NV.js +158 -0
  4. package/dist/MarketplaceClient-IJGRQRC4.js +7 -0
  5. package/dist/chunk-3RG5ZIWI.js +10 -0
  6. package/dist/chunk-GHZX5OAA.js +455 -0
  7. package/dist/commands/aiox/index.js +20 -0
  8. package/dist/commands/config/features.js +110 -1008
  9. package/dist/commands/config/index.js +1 -34
  10. package/dist/commands/index.js +1 -0
  11. package/dist/commands/init/aiox-bootstrap.js +83 -0
  12. package/dist/commands/init/index.js +20 -40
  13. package/dist/commands/marketplace/browse.js +1 -34
  14. package/dist/commands/module/activate.js +89 -48
  15. package/dist/commands/module/list.js +51 -0
  16. package/dist/commands/module/publish.js +2 -35
  17. package/dist/commands/upgrade/index.js +6 -39
  18. package/dist/core/AuthService.js +2 -34
  19. package/dist/core/CacheManager.js +3 -0
  20. package/dist/core/ConfigManager.js +8 -7
  21. package/dist/core/ErrorRecovery.js +1 -0
  22. package/dist/core/LicenseService.js +3 -38
  23. package/dist/core/ModuleDoctor.js +3 -0
  24. package/dist/core/ModuleInstaller.js +5 -36
  25. package/dist/core/ProjectInitializer.js +43 -5
  26. package/dist/core/RegistryResolver.js +3 -2
  27. package/dist/core/SchemaActivator.js +29 -8
  28. package/dist/core/ScriptRunner.js +3 -2
  29. package/dist/core/index.js +1 -0
  30. package/dist/index.js +30 -9
  31. package/dist/infrastructure/Container.js +2 -4
  32. package/dist/infrastructure/MarketplaceClient.js +31 -3
  33. package/dist/infrastructure/TelemetryBuffer.js +3 -1
  34. package/dist/infrastructure/TransactionalFileSystem.js +4 -1
  35. package/dist/infrastructure/errors.js +2 -0
  36. package/dist/infrastructure/index.js +1 -0
  37. package/dist/lib/capabilities-catalog.js +73 -0
  38. package/dist/lib/module-registry.js +47 -0
  39. package/dist/lib/schema-modifier.js +40 -0
  40. package/dist/tier-table-LAL6PAVW.js +52 -0
  41. package/package.json +11 -3
  42. package/dist/commands/modules/add.js +0 -53
  43. package/dist/commands/modules/list.js +0 -40
  44. package/dist/commands/modules/remove.js +0 -54
  45. package/dist/core/api/KavenApiClient.js +0 -61
  46. package/dist/core/auth/AuthManager.js +0 -91
  47. package/dist/core/modules/Injector.js +0 -86
  48. package/dist/core/modules/ModuleInstaller.js +0 -63
  49. package/dist/core/modules/ModuleManager.js +0 -59
  50. package/dist/core/modules/ModuleRemover.js +0 -60
  51. package/dist/lib/config.js +0 -66
  52. package/dist/lib/errors.js +0 -32
  53. package/dist/lib/logger.js +0 -70
  54. package/dist/types/module.js +0 -49
@@ -1,37 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
@@ -113,7 +80,7 @@ async function configView(options) {
113
80
  * C2.4: Config reset — Reset to defaults
114
81
  */
115
82
  async function configReset() {
116
- const { confirm } = await Promise.resolve().then(() => __importStar(require("@inquirer/prompts")));
83
+ const { confirm } = await import("@inquirer/prompts");
117
84
  const confirmed = await confirm({
118
85
  message: "Are you sure you want to reset config to defaults?",
119
86
  default: false,
@@ -1 +1,2 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.runEnvironmentBootstrap = runEnvironmentBootstrap;
40
+ const node_child_process_1 = require("node:child_process");
41
+ const fs = __importStar(require("node:fs"));
42
+ const path = __importStar(require("node:path"));
43
+ const ora_1 = __importDefault(require("ora"));
44
+ const chalk_1 = __importDefault(require("chalk"));
45
+ /**
46
+ * Runs the AIOX environment bootstrap process.
47
+ * This identifies the project stack and generates .aiox/ runtime configs.
48
+ */
49
+ async function runEnvironmentBootstrap(projectDir, options = {}) {
50
+ if (options.skipAiox)
51
+ return;
52
+ // Check if AIOX Core is installed
53
+ const aioxCorePath = path.join(projectDir, ".aiox-core");
54
+ if (!fs.existsSync(aioxCorePath)) {
55
+ // If not found in .aiox-core, check if it's a symlink (Dev environment)
56
+ const isDevLink = fs.existsSync(path.join(projectDir, ".aiox"));
57
+ if (!isDevLink) {
58
+ return; // Silent skip if AIOX is not present
59
+ }
60
+ }
61
+ const spinner = (0, ora_1.default)("Bootstrapping AIOX environment...").start();
62
+ try {
63
+ // The AIOX Core exposes a CLI at bin/aiox.js
64
+ // We call: node .aiox-core/bin/aiox.js devops environment-bootstrap --quiet
65
+ // Determine the bin path
66
+ const binPath = fs.existsSync(path.join(projectDir, ".aiox-core/bin/aiox.js"))
67
+ ? ".aiox-core/bin/aiox.js"
68
+ : ".aiox/bin/aiox.js"; // Fallback for dev symlink
69
+ (0, node_child_process_1.execSync)(`node ${binPath} devops environment-bootstrap --quiet`, {
70
+ cwd: projectDir,
71
+ stdio: "pipe",
72
+ timeout: 60000, // 1 minute timeout
73
+ });
74
+ spinner.succeed("AIOX environment bootstrapped");
75
+ }
76
+ catch (error) {
77
+ spinner.warn("AIOX environment bootstrap failed");
78
+ console.log(chalk_1.default.yellow(" ⚠ Run manually inside the project: kaven aiox bootstrap"));
79
+ if (process.env.KAVEN_DEBUG) {
80
+ console.error(chalk_1.default.gray(` Error: ${error.message}`));
81
+ }
82
+ }
83
+ }
@@ -1,37 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
@@ -43,9 +10,10 @@ const path_1 = __importDefault(require("path"));
43
10
  const fs_extra_1 = __importDefault(require("fs-extra"));
44
11
  const ProjectInitializer_1 = require("../../core/ProjectInitializer");
45
12
  const ConfigManager_1 = require("../../core/ConfigManager");
13
+ const aiox_bootstrap_1 = require("./aiox-bootstrap");
46
14
  async function promptAnswers(projectName) {
47
15
  // Dynamic import to keep startup fast and avoid issues if not installed
48
- const { input, select } = await Promise.resolve().then(() => __importStar(require("@inquirer/prompts")));
16
+ const { input, select } = await import("@inquirer/prompts");
49
17
  // Load defaults from config if available
50
18
  await ConfigManager_1.configManager.initialize();
51
19
  const existingDefaults = ConfigManager_1.configManager.getAll().projectDefaults || {};
@@ -83,7 +51,7 @@ async function initProject(projectName, options) {
83
51
  resolvedName = "my-kaven-app";
84
52
  }
85
53
  else {
86
- const { input } = await Promise.resolve().then(() => __importStar(require("@inquirer/prompts")));
54
+ const { input } = await import("@inquirer/prompts");
87
55
  resolvedName = await input({
88
56
  message: "Project name:",
89
57
  default: "my-kaven-app",
@@ -126,7 +94,7 @@ async function initProject(projectName, options) {
126
94
  // Clone template
127
95
  const cloneSpinner = (0, ora_1.default)("Cloning kaven-template...").start();
128
96
  try {
129
- await initializer.cloneTemplate(targetDir);
97
+ await initializer.cloneTemplate(targetDir, options.template);
130
98
  cloneSpinner.succeed("Template cloned successfully");
131
99
  }
132
100
  catch (error) {
@@ -176,6 +144,16 @@ async function initProject(projectName, options) {
176
144
  const squadResult = await initializer.installSquad(targetDir);
177
145
  if (squadResult.installed) {
178
146
  squadSpinner.succeed("kaven-squad installed in squads/kaven-squad/");
147
+ // Install AIOX Core runtime (non-fatal)
148
+ const aioxSpinner = (0, ora_1.default)("Activating AIOX Core...").start();
149
+ const aioxResult = await initializer.installAIOXCore(targetDir);
150
+ if (aioxResult.installed) {
151
+ aioxSpinner.succeed("AIOX Core activated — agents online");
152
+ }
153
+ else {
154
+ aioxSpinner.warn(`AIOX Core not activated automatically (${aioxResult.reason})`);
155
+ console.log(chalk_1.default.yellow(` Run inside the project: npx aiox-core install`));
156
+ }
179
157
  }
180
158
  else if (squadResult.reason === "already-exists") {
181
159
  squadSpinner.info("kaven-squad already installed — skipping");
@@ -187,6 +165,8 @@ async function initProject(projectName, options) {
187
165
  }
188
166
  // Health check
189
167
  const healthCheckSpinner = (0, ora_1.default)("Running health check...").start();
168
+ // AIOX Environment Bootstrap
169
+ await (0, aiox_bootstrap_1.runEnvironmentBootstrap)(targetDir, { skipAiox: options.skipAiox });
190
170
  const health = await initializer.healthCheck(targetDir);
191
171
  if (health.healthy) {
192
172
  healthCheckSpinner.succeed("Health check passed");
@@ -207,12 +187,12 @@ async function initProject(projectName, options) {
207
187
  console.log(chalk_1.default.cyan(" npx prisma migrate dev"));
208
188
  console.log(chalk_1.default.cyan(" pnpm dev"));
209
189
  console.log();
210
- console.log(chalk_1.default.gray("For more help, visit: https://docs.kaven.sh/getting-started"));
190
+ console.log(chalk_1.default.gray("For more help, visit: https://docs.kaven.site/getting-started"));
211
191
  if (options.withSquad) {
212
192
  console.log();
213
- console.log(chalk_1.default.bold("AIOX Squad next step:"));
214
- console.log(chalk_1.default.cyan(" node /path/to/aiox-core/bin/aiox.js install --quiet --merge"));
215
- console.log(chalk_1.default.gray(" (replace /path/to/aiox-core with your AIOX installation path)"));
193
+ console.log(chalk_1.default.bold("AIOX Agents:"));
194
+ console.log(chalk_1.default.cyan(` cd ${name}`));
195
+ console.log(chalk_1.default.cyan(" # Type @dev in Claude Code to start with AI agents"));
216
196
  }
217
197
  // Save project defaults to config for future use
218
198
  await ConfigManager_1.configManager.initialize();
@@ -1,37 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
@@ -68,7 +35,7 @@ async function marketplaceBrowse() {
68
35
  selectedModule: null,
69
36
  screen: "categories",
70
37
  };
71
- const { select } = await Promise.resolve().then(() => __importStar(require("@inquirer/prompts")));
38
+ const { select } = await import("@inquirer/prompts");
72
39
  while (state.screen !== "exit") {
73
40
  if (state.screen === "categories") {
74
41
  // Step 1: Category selection
@@ -8,6 +8,8 @@ exports.moduleDeactivate = moduleDeactivate;
8
8
  exports.moduleListActivation = moduleListActivation;
9
9
  const chalk_1 = __importDefault(require("chalk"));
10
10
  const ora_1 = __importDefault(require("ora"));
11
+ const node_path_1 = __importDefault(require("node:path"));
12
+ const prompts_1 = require("@inquirer/prompts");
11
13
  const SchemaActivator_1 = require("../../core/SchemaActivator");
12
14
  const TelemetryBuffer_1 = require("../../infrastructure/TelemetryBuffer");
13
15
  // ============================================================
@@ -16,38 +18,39 @@ const TelemetryBuffer_1 = require("../../infrastructure/TelemetryBuffer");
16
18
  function findModuleDef(moduleId) {
17
19
  return SchemaActivator_1.KAVEN_MODULES.find((m) => m.id === moduleId.toLowerCase());
18
20
  }
19
- function assertSchemaExists(exists) {
21
+ function assertSchemaExists(exists, root) {
20
22
  if (!exists) {
21
- console.error(chalk_1.default.red("\nNão encontrei packages/database/prisma/schema.extended.prisma."));
22
- console.error(chalk_1.default.gray("Execute este comando na raiz de um projeto Kaven."));
23
+ const fullPath = node_path_1.default.join(root, "packages", "database", "prisma", "schema.extended.prisma");
24
+ console.error(chalk_1.default.red(`\nError: Schema not found at: ${fullPath}`));
25
+ console.error(chalk_1.default.gray("Make sure you are in the root of a valid Kaven project."));
23
26
  process.exit(1);
24
27
  }
25
28
  }
26
29
  // ============================================================
27
30
  // kaven module activate <name>
28
31
  // ============================================================
29
- async function moduleActivate(moduleName, projectRoot) {
32
+ async function moduleActivate(moduleName, projectRoot, options = {}) {
30
33
  const telemetry = TelemetryBuffer_1.TelemetryBuffer.getInstance();
31
34
  const startTime = Date.now();
32
35
  telemetry.capture("cli.module.activate.start", { moduleName });
33
36
  const root = projectRoot ?? process.cwd();
34
37
  const activator = new SchemaActivator_1.SchemaActivator(root);
35
- const spinner = (0, ora_1.default)(`Ativando módulo ${moduleName}...`).start();
38
+ const spinner = (0, ora_1.default)(`Activating module ${moduleName}...`).start();
36
39
  try {
37
- // 1. Validar que o schema existe
40
+ // 1. Validate schema exists
38
41
  const exists = await activator.exists();
39
42
  spinner.stop();
40
- assertSchemaExists(exists);
41
- // 2. Validar que o módulo é conhecido
43
+ assertSchemaExists(exists, root);
44
+ // 2. Validate module is known
42
45
  const def = findModuleDef(moduleName);
43
46
  if (!def) {
44
- console.error(chalk_1.default.red(`\nMódulo desconhecido: "${moduleName}".`));
45
- console.error(chalk_1.default.gray(`Módulos disponíveis: ${SchemaActivator_1.KAVEN_MODULES.map((m) => m.id).join(", ")}`));
47
+ console.error(chalk_1.default.red(`\nUnknown module: "${moduleName}".`));
48
+ console.error(chalk_1.default.gray(`Available modules: ${SchemaActivator_1.KAVEN_MODULES.map((m) => m.id).join(", ")}`));
46
49
  process.exit(1);
47
50
  }
48
- // 3. Verificar dependências
51
+ // 3. Check dependencies
49
52
  if (def.dependsOn.length > 0) {
50
- spinner.start("Verificando dependências...");
53
+ spinner.start("Checking dependencies...");
51
54
  const depStatuses = [];
52
55
  for (const depId of def.dependsOn) {
53
56
  const depDef = findModuleDef(depId);
@@ -59,28 +62,59 @@ async function moduleActivate(moduleName, projectRoot) {
59
62
  const missing = depStatuses.filter((s) => !s.active);
60
63
  if (missing.length > 0) {
61
64
  spinner.stop();
62
- console.error(chalk_1.default.red(`\nDependências inativas para "${moduleName}": ${missing.map((m) => m.id).join(", ")}`));
63
- console.error(chalk_1.default.gray(`Ative as dependências primeiro:\n${missing.map((m) => ` kaven module activate ${m.id}`).join("\n")}`));
64
- process.exit(1);
65
+ // Auto-activate deps if --with-deps
66
+ if (options.withDeps) {
67
+ for (const dep of missing) {
68
+ await moduleActivate(dep.id, projectRoot, { ...options, withDeps: true });
69
+ }
70
+ }
71
+ else {
72
+ console.error(chalk_1.default.red(`\nInactive dependencies for "${moduleName}": ${missing.map((m) => m.id).join(", ")}`));
73
+ console.error(chalk_1.default.gray(`Activate them first:\n${missing.map((m) => ` kaven module activate ${m.id}`).join("\n")}`));
74
+ console.log(chalk_1.default.gray("\nOr use --with-deps to activate them automatically."));
75
+ process.exit(1);
76
+ }
65
77
  }
66
78
  spinner.stop();
67
79
  }
68
- // 4. Verificar se está ativo
80
+ // 4. Check if already active
69
81
  const current = await activator.getModuleStatus(def);
70
82
  if (current.active) {
71
- console.log(chalk_1.default.yellow(`\nMódulo "${def.label}" está ativo.`));
83
+ console.log(chalk_1.default.yellow(`\nModule "${def.label}" is already active.`));
72
84
  return;
73
85
  }
74
- // 5. Ativar
75
- spinner.start(`Descomentando modelos de ${def.label} no schema...`);
86
+ // 5. Confirm if not --yes
87
+ if (!options.yes) {
88
+ const ok = await (0, prompts_1.confirm)({
89
+ message: `Activate module "${def.label}"? This will uncomment ${def.models.length} model(s) in the schema.`,
90
+ default: true,
91
+ });
92
+ if (!ok) {
93
+ console.log(chalk_1.default.gray("\nActivation aborted."));
94
+ return;
95
+ }
96
+ }
97
+ // 6. Dry run
98
+ if (options.dryRun) {
99
+ console.log(chalk_1.default.bold(`\n--- DRY RUN: Activating ${def.label} ---`));
100
+ console.log(`Models to uncomment: ${def.models.join(", ")}`);
101
+ if (def.enums.length > 0) {
102
+ console.log(`Enums to uncomment: ${def.enums.join(", ")}`);
103
+ }
104
+ return;
105
+ }
106
+ // 7. Activate
107
+ spinner.start(`Uncommenting ${def.label} models in schema...`);
76
108
  await activator.activateModule(def);
77
- spinner.succeed(chalk_1.default.green(`\nMódulo ${def.label} ativado. ${def.models.length} models adicionados: ${def.models.join(", ")}`));
78
- console.log(chalk_1.default.cyan("\nSugestão: Execute `pnpm db:generate && pnpm db:migrate` para aplicar as mudanças."));
109
+ spinner.succeed(chalk_1.default.green(`\nModule ${def.label} activated. ${def.models.length} models added: ${def.models.join(", ")}`));
110
+ if (!options.skipMigrate) {
111
+ console.log(chalk_1.default.cyan("\nNext step: Run `pnpm db:generate && pnpm db:migrate` to apply changes."));
112
+ }
79
113
  telemetry.capture("cli.module.activate.success", { moduleName: def.id, models: def.models.length }, Date.now() - startTime);
80
114
  await telemetry.flush();
81
115
  }
82
116
  catch (error) {
83
- spinner.fail(chalk_1.default.red(`Falha ao ativar módulo: ${error instanceof Error ? error.message : String(error)}`));
117
+ spinner.fail(chalk_1.default.red(`Failed to activate module: ${error instanceof Error ? error.message : String(error)}`));
84
118
  telemetry.capture("cli.module.activate.error", { moduleName, error: error.message }, Date.now() - startTime);
85
119
  await telemetry.flush();
86
120
  process.exit(1);
@@ -89,27 +123,27 @@ async function moduleActivate(moduleName, projectRoot) {
89
123
  // ============================================================
90
124
  // kaven module deactivate <name>
91
125
  // ============================================================
92
- async function moduleDeactivate(moduleName, projectRoot) {
126
+ async function moduleDeactivate(moduleName, projectRoot, options = {}) {
93
127
  const telemetry = TelemetryBuffer_1.TelemetryBuffer.getInstance();
94
128
  const startTime = Date.now();
95
129
  telemetry.capture("cli.module.deactivate.start", { moduleName });
96
130
  const root = projectRoot ?? process.cwd();
97
131
  const activator = new SchemaActivator_1.SchemaActivator(root);
98
- const spinner = (0, ora_1.default)(`Desativando módulo ${moduleName}...`).start();
132
+ const spinner = (0, ora_1.default)(`Deactivating module ${moduleName}...`).start();
99
133
  try {
100
- // 1. Validar que o schema existe
134
+ // 1. Validate schema exists
101
135
  const exists = await activator.exists();
102
136
  spinner.stop();
103
- assertSchemaExists(exists);
104
- // 2. Validar módulo
137
+ assertSchemaExists(exists, root);
138
+ // 2. Validate module
105
139
  const def = findModuleDef(moduleName);
106
140
  if (!def) {
107
- console.error(chalk_1.default.red(`\nMódulo desconhecido: "${moduleName}".`));
108
- console.error(chalk_1.default.gray(`Módulos disponíveis: ${SchemaActivator_1.KAVEN_MODULES.map((m) => m.id).join(", ")}`));
141
+ console.error(chalk_1.default.red(`\nUnknown module: "${moduleName}".`));
142
+ console.error(chalk_1.default.gray(`Available modules: ${SchemaActivator_1.KAVEN_MODULES.map((m) => m.id).join(", ")}`));
109
143
  process.exit(1);
110
144
  }
111
- // 3. Verificar se outros módulos ativos dependem deste
112
- spinner.start("Verificando dependências reversas...");
145
+ // 3. Check for active dependents
146
+ spinner.start("Checking reverse dependencies...");
113
147
  const dependents = [];
114
148
  for (const candidate of SchemaActivator_1.KAVEN_MODULES) {
115
149
  if (candidate.id === def.id)
@@ -123,28 +157,37 @@ async function moduleDeactivate(moduleName, projectRoot) {
123
157
  }
124
158
  if (dependents.length > 0) {
125
159
  spinner.stop();
126
- console.error(chalk_1.default.red(`\nNão é possível desativar "${moduleName}": os seguintes módulos dependem dele e estão ativos:`));
160
+ console.error(chalk_1.default.red(`\nCannot deactivate "${moduleName}": the following active modules depend on it:`));
127
161
  console.error(chalk_1.default.gray(` ${dependents.join(", ")}`));
128
- console.error(chalk_1.default.gray(`Desative-os primeiro:\n${dependents.map((d) => ` kaven module deactivate ${d}`).join("\n")}`));
162
+ console.error(chalk_1.default.gray(`Deactivate them first:\n${dependents.map((d) => ` kaven module deactivate ${d}`).join("\n")}`));
129
163
  process.exit(1);
130
164
  }
131
- // 4. Verificar se está inativo
165
+ // 4. Check if already inactive
132
166
  const current = await activator.getModuleStatus(def);
133
167
  if (!current.active) {
134
168
  spinner.stop();
135
- console.log(chalk_1.default.yellow(`\nMódulo "${def.label}" está inativo.`));
169
+ console.log(chalk_1.default.yellow(`\nModule "${def.label}" is already inactive.`));
136
170
  return;
137
171
  }
138
- // 5. Desativar
139
- spinner.start(`Comentando modelos de ${def.label} no schema...`);
172
+ // 5. Dry run
173
+ if (options.dryRun) {
174
+ spinner.stop();
175
+ console.log(chalk_1.default.bold(`\n--- DRY RUN: Deactivating ${def.label} ---`));
176
+ console.log(`Models to comment: ${def.models.join(", ")}`);
177
+ return;
178
+ }
179
+ // 6. Deactivate
180
+ spinner.start(`Commenting ${def.label} models in schema...`);
140
181
  await activator.deactivateModule(def);
141
- spinner.succeed(chalk_1.default.green(`\nMódulo ${def.label} desativado com sucesso.`));
142
- console.log(chalk_1.default.cyan("\nSugestão: Execute `pnpm db:generate && pnpm db:migrate` para aplicar as mudanças."));
182
+ spinner.succeed(chalk_1.default.green(`\nModule ${def.label} deactivated successfully.`));
183
+ if (!options.skipMigrate) {
184
+ console.log(chalk_1.default.cyan("\nNext step: Run `pnpm db:generate && pnpm db:migrate` to apply changes."));
185
+ }
143
186
  telemetry.capture("cli.module.deactivate.success", { moduleName: def.id }, Date.now() - startTime);
144
187
  await telemetry.flush();
145
188
  }
146
189
  catch (error) {
147
- spinner.fail(chalk_1.default.red(`Falha ao desativar módulo: ${error instanceof Error ? error.message : String(error)}`));
190
+ spinner.fail(chalk_1.default.red(`Failed to deactivate module: ${error instanceof Error ? error.message : String(error)}`));
148
191
  telemetry.capture("cli.module.deactivate.error", { moduleName, error: error.message }, Date.now() - startTime);
149
192
  await telemetry.flush();
150
193
  process.exit(1);
@@ -157,9 +200,9 @@ async function moduleListActivation(projectRoot) {
157
200
  const root = projectRoot ?? process.cwd();
158
201
  const activator = new SchemaActivator_1.SchemaActivator(root);
159
202
  const schemaExists = await activator.exists();
160
- // Cabeçalho da tabela
203
+ // Table header
161
204
  const COL = {
162
- module: 14,
205
+ module: 18,
163
206
  status: 10,
164
207
  models: 44,
165
208
  deps: 20,
@@ -170,7 +213,7 @@ async function moduleListActivation(projectRoot) {
170
213
  chalk_1.default.bold("Depends on");
171
214
  const divider = "─".repeat(COL.module + COL.status + COL.models + COL.deps);
172
215
  console.log();
173
- console.log(chalk_1.default.blue("Módulos Kaven disponíveis\n"));
216
+ console.log(chalk_1.default.blue("Kaven Schema Modules\n"));
174
217
  console.log(header);
175
218
  console.log(chalk_1.default.gray(divider));
176
219
  if (!schemaExists) {
@@ -182,8 +225,8 @@ async function moduleListActivation(projectRoot) {
182
225
  console.log(`${modCol}${statusCol}${modelsCol}${depsCol}`);
183
226
  }
184
227
  console.log();
185
- console.log(chalk_1.default.yellow("Atenção: schema.extended.prisma não encontrado. Status não pode ser determinado."));
186
- console.log(chalk_1.default.gray("Execute este comando na raiz de um projeto Kaven para ver o status real."));
228
+ console.log(chalk_1.default.yellow("Warning: schema.extended.prisma not found. Status cannot be determined."));
229
+ console.log(chalk_1.default.gray("Run this command in the root of a Kaven project to see real status."));
187
230
  return;
188
231
  }
189
232
  for (const def of SchemaActivator_1.KAVEN_MODULES) {
@@ -198,7 +241,5 @@ async function moduleListActivation(projectRoot) {
198
241
  console.log(`${modCol}${statusColored}${modelsCol}${depsCol}`);
199
242
  }
200
243
  console.log();
201
- console.log(chalk_1.default.gray("Core (sempre ativo): Tenant, User, Role, Capability, AuthSession, AuditLog"));
202
- console.log();
203
- console.log(chalk_1.default.gray("Para ativar: kaven module activate <name> | Para desativar: kaven module deactivate <name>"));
244
+ console.log(chalk_1.default.gray("To activate: kaven module activate <name> | To deactivate: kaven module deactivate <name>"));
204
245
  }
@@ -0,0 +1,51 @@
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.marketplaceList = marketplaceList;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const fs_extra_1 = __importDefault(require("fs-extra"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const module_registry_1 = require("../../lib/module-registry");
11
+ const schema_modifier_1 = require("../../lib/schema-modifier");
12
+ /**
13
+ * Finds the Prisma schema file in the project
14
+ */
15
+ function findSchemaPath(root) {
16
+ const searchPath = root || process.cwd();
17
+ const paths = [
18
+ path_1.default.join(searchPath, "packages/database/prisma/schema.extended.prisma"),
19
+ path_1.default.join(searchPath, "prisma/schema.prisma"),
20
+ ];
21
+ for (const p of paths) {
22
+ if (fs_extra_1.default.existsSync(p))
23
+ return p;
24
+ }
25
+ throw new Error("Prisma schema file not found.");
26
+ }
27
+ async function marketplaceList(root) {
28
+ try {
29
+ const schemaPath = findSchemaPath(root);
30
+ const content = await fs_extra_1.default.readFile(schemaPath, "utf-8");
31
+ console.log(`\n ${chalk_1.default.bold.underline("Kaven Schema Modules")}\n`);
32
+ const active = module_registry_1.MODULE_REGISTRY.filter(m => (0, schema_modifier_1.isModuleActive)(content, m.models));
33
+ const inactive = module_registry_1.MODULE_REGISTRY.filter(m => !(0, schema_modifier_1.isModuleActive)(content, m.models));
34
+ console.log(chalk_1.default.green(" ACTIVE"));
35
+ active.forEach(m => {
36
+ const suffix = m.id === "core" ? chalk_1.default.gray(" (always active)") : "";
37
+ console.log(` ${chalk_1.default.green("✓")} ${m.id.padEnd(15)} ${m.name} (${m.models.length} models)${suffix}`);
38
+ });
39
+ if (inactive.length > 0) {
40
+ console.log(`\\n ${chalk_1.default.yellow("INACTIVE")}`);
41
+ inactive.forEach(m => {
42
+ const deps = m.dependsOn.length > 0 ? chalk_1.default.gray(` (requires: ${m.dependsOn.join(", ")})`) : "";
43
+ console.log(` ${chalk_1.default.gray("○")} ${m.id.padEnd(15)} ${m.name} (${m.models.length} models)${deps}`);
44
+ });
45
+ }
46
+ console.log();
47
+ }
48
+ catch (error) {
49
+ console.error(chalk_1.default.red(`Error: ${error.message}`));
50
+ }
51
+ }
@@ -1,37 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
@@ -95,7 +62,7 @@ async function sha256File(filePath) {
95
62
  }
96
63
  /** Create tar.gz archive of current directory, excluding common noise. */
97
64
  async function createTarball(sourceDir, outputPath) {
98
- const tar = await Promise.resolve().then(() => __importStar(require("tar")));
65
+ const tar = await import("tar");
99
66
  await tar.create({
100
67
  gzip: true,
101
68
  file: outputPath,
@@ -281,7 +248,7 @@ async function modulePublish(options) {
281
248
  await fs_extra_1.default.remove(tarballPath).catch(() => { });
282
249
  console.log();
283
250
  console.log(chalk_1.default.green(`✅ Published ${moduleJson.name} v${moduleJson.version} to the Kaven Marketplace!`));
284
- console.log(chalk_1.default.gray(`View your module at: https://marketplace.kaven.sh/modules/${moduleJson.slug}`));
251
+ console.log(chalk_1.default.gray(`View your module at: https://marketplace.kaven.site/modules/${moduleJson.slug}`));
285
252
  // Show next steps
286
253
  console.log();
287
254
  console.log(chalk_1.default.bold("Next steps:"));