kaven-cli 0.4.1-alpha.0 → 0.4.2-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 (68) hide show
  1. package/README.md +181 -207
  2. package/dist/EnvManager-NMS3NMIE.js +15 -0
  3. package/dist/MarketplaceClient-YCFH2VU4.js +1 -0
  4. package/dist/chunk-JHLQ46NG.js +1 -0
  5. package/dist/index.d.ts +4 -0
  6. package/dist/index.js +242 -304
  7. package/dist/tier-table-DQMPQSI2.js +6 -0
  8. package/package.json +26 -11
  9. package/dist/EnvManager-GQMEZ6NV.js +0 -158
  10. package/dist/MarketplaceClient-IJGRQRC4.js +0 -7
  11. package/dist/chunk-3RG5ZIWI.js +0 -10
  12. package/dist/chunk-GHZX5OAA.js +0 -455
  13. package/dist/commands/aiox/index.js +0 -20
  14. package/dist/commands/auth/login.js +0 -122
  15. package/dist/commands/auth/logout.js +0 -23
  16. package/dist/commands/auth/whoami.js +0 -36
  17. package/dist/commands/cache/index.js +0 -43
  18. package/dist/commands/config/features.js +0 -161
  19. package/dist/commands/config/index.js +0 -95
  20. package/dist/commands/index.js +0 -2
  21. package/dist/commands/init/aiox-bootstrap.js +0 -83
  22. package/dist/commands/init/index.js +0 -210
  23. package/dist/commands/init-ci/index.js +0 -153
  24. package/dist/commands/license/index.js +0 -10
  25. package/dist/commands/license/status.js +0 -44
  26. package/dist/commands/license/tier-table.js +0 -46
  27. package/dist/commands/marketplace/browse.js +0 -186
  28. package/dist/commands/marketplace/install.js +0 -263
  29. package/dist/commands/marketplace/list.js +0 -122
  30. package/dist/commands/module/activate.js +0 -245
  31. package/dist/commands/module/add.js +0 -69
  32. package/dist/commands/module/doctor.js +0 -175
  33. package/dist/commands/module/list.js +0 -51
  34. package/dist/commands/module/publish.js +0 -258
  35. package/dist/commands/module/remove.js +0 -58
  36. package/dist/commands/telemetry/view.js +0 -27
  37. package/dist/commands/upgrade/check.js +0 -162
  38. package/dist/commands/upgrade/index.js +0 -185
  39. package/dist/core/AuthService.js +0 -222
  40. package/dist/core/CacheManager.js +0 -154
  41. package/dist/core/ConfigManager.js +0 -166
  42. package/dist/core/EnvManager.js +0 -196
  43. package/dist/core/ErrorRecovery.js +0 -192
  44. package/dist/core/LicenseService.js +0 -83
  45. package/dist/core/ManifestParser.js +0 -52
  46. package/dist/core/MarkerService.js +0 -62
  47. package/dist/core/ModuleDoctor.js +0 -451
  48. package/dist/core/ModuleInstaller.js +0 -169
  49. package/dist/core/ProjectInitializer.js +0 -183
  50. package/dist/core/RegistryResolver.js +0 -95
  51. package/dist/core/SchemaActivator.js +0 -278
  52. package/dist/core/ScriptRunner.js +0 -73
  53. package/dist/core/SignatureVerifier.js +0 -75
  54. package/dist/core/index.js +0 -2
  55. package/dist/infrastructure/Container.js +0 -37
  56. package/dist/infrastructure/MarketplaceClient.js +0 -425
  57. package/dist/infrastructure/TelemetryBuffer.js +0 -73
  58. package/dist/infrastructure/TransactionalFileSystem.js +0 -77
  59. package/dist/infrastructure/errors.js +0 -63
  60. package/dist/infrastructure/index.js +0 -2
  61. package/dist/lib/capabilities-catalog.js +0 -73
  62. package/dist/lib/module-registry.js +0 -47
  63. package/dist/lib/schema-modifier.js +0 -40
  64. package/dist/tier-table-LAL6PAVW.js +0 -52
  65. package/dist/types/auth.js +0 -2
  66. package/dist/types/manifest.js +0 -45
  67. package/dist/types/markers.js +0 -10
  68. package/dist/types/marketplace.js +0 -2
@@ -1,153 +0,0 @@
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.initCi = initCi;
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const ora_1 = __importDefault(require("ora"));
9
- const path_1 = __importDefault(require("path"));
10
- const fs_extra_1 = __importDefault(require("fs-extra"));
11
- const GITHUB_WORKFLOW_TEST = `name: Tests
12
- on:
13
- push:
14
- branches: [main, develop]
15
- pull_request:
16
- branches: [main, develop]
17
-
18
- jobs:
19
- test:
20
- runs-on: ubuntu-latest
21
- services:
22
- postgres:
23
- image: postgres:15
24
- env:
25
- POSTGRES_PASSWORD: postgres
26
- options: >-
27
- --health-cmd pg_isready
28
- --health-interval 10s
29
- --health-timeout 5s
30
- --health-retries 5
31
- ports:
32
- - 5432:5432
33
- steps:
34
- - uses: actions/checkout@v3
35
- - uses: pnpm/action-setup@v2
36
- with:
37
- version: 8
38
- - uses: actions/setup-node@v3
39
- with:
40
- node-version: 20
41
- cache: 'pnpm'
42
- - run: pnpm install
43
- - run: pnpm typecheck
44
- - run: pnpm lint
45
- - run: pnpm test
46
- - run: pnpm build
47
- `;
48
- const GITHUB_WORKFLOW_PUBLISH = `name: Publish Module
49
- on:
50
- push:
51
- tags:
52
- - 'v*'
53
-
54
- jobs:
55
- publish:
56
- runs-on: ubuntu-latest
57
- steps:
58
- - uses: actions/checkout@v3
59
- - uses: pnpm/action-setup@v2
60
- with:
61
- version: 8
62
- - uses: actions/setup-node@v3
63
- with:
64
- node-version: 20
65
- cache: 'pnpm'
66
- - run: pnpm install
67
- - run: pnpm build
68
- - name: Publish to Kaven Marketplace
69
- env:
70
- KAVEN_LICENSE_KEY: \${{ secrets.KAVEN_LICENSE_KEY }}
71
- run: kaven module publish
72
- `;
73
- const PRE_COMMIT_HOOK = `#!/bin/bash
74
- # Pre-commit hook for Kaven projects
75
- set -e
76
-
77
- echo "🔍 Running pre-commit checks..."
78
-
79
- # Lint
80
- echo " Linting..."
81
- pnpm lint || exit 1
82
-
83
- # Type check
84
- echo " Type checking..."
85
- pnpm typecheck || exit 1
86
-
87
- # Format check
88
- if command -v pnpm format &> /dev/null; then
89
- echo " Format checking..."
90
- pnpm format || exit 1
91
- fi
92
-
93
- echo "✅ All pre-commit checks passed"
94
- `;
95
- /**
96
- * C2.6: Initialize CI/CD templates
97
- */
98
- async function initCi(options) {
99
- const cwd = process.cwd();
100
- // Check if it's a Kaven project
101
- const packageJsonPath = path_1.default.join(cwd, "package.json");
102
- if (!(await fs_extra_1.default.pathExists(packageJsonPath))) {
103
- console.error(chalk_1.default.red("Error: package.json not found. Run this in a Kaven project root."));
104
- process.exit(1);
105
- }
106
- const spinner = (0, ora_1.default)("Setting up CI/CD configuration...").start();
107
- try {
108
- // Create .github/workflows directory
109
- const workflowDir = path_1.default.join(cwd, ".github", "workflows");
110
- await fs_extra_1.default.ensureDir(workflowDir);
111
- // Create test workflow
112
- const testWorkflowPath = path_1.default.join(workflowDir, "test.yml");
113
- if (!options.dryRun) {
114
- await fs_extra_1.default.writeFile(testWorkflowPath, GITHUB_WORKFLOW_TEST);
115
- }
116
- spinner.text = `Creating ${chalk_1.default.cyan(".github/workflows/test.yml")}...`;
117
- // Create publish workflow
118
- const publishWorkflowPath = path_1.default.join(workflowDir, "publish.yml");
119
- if (!options.dryRun) {
120
- await fs_extra_1.default.writeFile(publishWorkflowPath, GITHUB_WORKFLOW_PUBLISH);
121
- }
122
- spinner.text = `Creating ${chalk_1.default.cyan(".github/workflows/publish.yml")}...`;
123
- // Create pre-commit hook
124
- const hookDir = path_1.default.join(cwd, ".husky");
125
- await fs_extra_1.default.ensureDir(hookDir);
126
- const preCommitHookPath = path_1.default.join(hookDir, "pre-commit");
127
- if (!options.dryRun) {
128
- await fs_extra_1.default.writeFile(preCommitHookPath, PRE_COMMIT_HOOK);
129
- await fs_extra_1.default.chmod(preCommitHookPath, 0o755);
130
- }
131
- spinner.text = `Creating ${chalk_1.default.cyan(".husky/pre-commit")}...`;
132
- spinner.succeed("CI/CD configuration created");
133
- console.log();
134
- console.log(chalk_1.default.bold("Files created:"));
135
- console.log(` ${chalk_1.default.cyan(".github/workflows/test.yml")} - Run tests on push/PR`);
136
- console.log(` ${chalk_1.default.cyan(".github/workflows/publish.yml")} - Publish on git tags`);
137
- console.log(` ${chalk_1.default.cyan(".husky/pre-commit")} - Local pre-commit validation`);
138
- console.log();
139
- console.log(chalk_1.default.bold("Next steps:"));
140
- console.log(chalk_1.default.gray(" 1. Install husky: pnpm husky install"));
141
- console.log(chalk_1.default.gray(" 2. Add GitHub secrets: KAVEN_LICENSE_KEY"));
142
- console.log(chalk_1.default.gray(" 3. Push to GitHub and watch workflows run"));
143
- if (options.dryRun) {
144
- console.log();
145
- console.log(chalk_1.default.yellow("(Dry-run: No files were actually created)"));
146
- }
147
- }
148
- catch (error) {
149
- spinner.fail("Failed to create CI/CD configuration");
150
- console.error(chalk_1.default.red(error instanceof Error ? error.message : String(error)));
151
- process.exit(1);
152
- }
153
- }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildLicenseCommand = buildLicenseCommand;
4
- const commander_1 = require("commander");
5
- const status_js_1 = require("./status.js");
6
- function buildLicenseCommand() {
7
- const cmd = new commander_1.Command('license').description('Manage Kaven licenses');
8
- cmd.addCommand((0, status_js_1.buildLicenseStatusCommand)());
9
- return cmd;
10
- }
@@ -1,44 +0,0 @@
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.buildLicenseStatusCommand = buildLicenseStatusCommand;
7
- const commander_1 = require("commander");
8
- const chalk_1 = __importDefault(require("chalk"));
9
- const LicenseService_js_1 = require("../../core/LicenseService.js");
10
- function buildLicenseStatusCommand() {
11
- return new commander_1.Command('status')
12
- .description('Show license status and tier information')
13
- .argument('[license-key]', 'License key to check (uses stored license if omitted)')
14
- .action(async (licenseKey) => {
15
- const service = new LicenseService_js_1.LicenseService();
16
- // Resolve key from arg or environment
17
- const key = licenseKey ?? process.env.KAVEN_LICENSE_KEY;
18
- if (!key) {
19
- console.error(chalk_1.default.red('✗ No license key provided. Pass as argument or set KAVEN_LICENSE_KEY.'));
20
- process.exit(1);
21
- }
22
- try {
23
- console.log(chalk_1.default.dim('Checking license status...'));
24
- const status = await service.getLicenseStatus(key);
25
- console.log('\n' + chalk_1.default.bold('License Status') + '\n');
26
- console.log(` Key: ${chalk_1.default.dim(status.key.substring(0, 16) + '...')}`);
27
- console.log(` Tier: ${chalk_1.default.magenta(status.tier)}`);
28
- if (status.expiresAt) {
29
- const days = status.daysUntilExpiry;
30
- const expiryColor = days !== null && days < 30 ? chalk_1.default.red : chalk_1.default.green;
31
- console.log(` Expires: ${expiryColor(status.expiresAt)}${days !== null ? chalk_1.default.dim(` (${days} days)`) : ''}`);
32
- }
33
- else {
34
- console.log(` Expires: ${chalk_1.default.green('Never')}`);
35
- }
36
- console.log();
37
- }
38
- catch (err) {
39
- const message = err instanceof Error ? err.message : 'Failed to check license status';
40
- console.error(chalk_1.default.red('✗ ' + message));
41
- process.exit(1);
42
- }
43
- });
44
- }
@@ -1,46 +0,0 @@
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.printTierComparisonTable = printTierComparisonTable;
7
- const cli_table3_1 = __importDefault(require("cli-table3"));
8
- const chalk_1 = __importDefault(require("chalk"));
9
- const TIERS = [
10
- { name: 'STARTER', price: '$149', projects: '1', tenants: '10', marketplace: false },
11
- { name: 'COMPLETE', price: '$399', projects: '1', tenants: 'Unlimited', marketplace: false },
12
- { name: 'PRO', price: '$799', projects: '5', tenants: 'Unlimited', marketplace: true },
13
- { name: 'ENTERPRISE', price: 'Custom', projects: 'Unlimited', tenants: 'Unlimited', marketplace: true },
14
- ];
15
- function colorTier(tier) {
16
- switch (tier.toUpperCase()) {
17
- case 'STARTER': return chalk_1.default.green(tier);
18
- case 'COMPLETE': return chalk_1.default.yellow(tier);
19
- case 'PRO': return chalk_1.default.magenta(tier);
20
- case 'ENTERPRISE': return chalk_1.default.cyan(tier);
21
- default: return tier;
22
- }
23
- }
24
- function printTierComparisonTable(userTier, requiredTier) {
25
- console.log(chalk_1.default.red('\n✗ License tier insufficient\n'));
26
- console.log(` Your tier: ${colorTier(userTier)}`);
27
- console.log(` Required tier: ${colorTier(requiredTier)}\n`);
28
- const table = new cli_table3_1.default({
29
- head: ['Tier', 'Price', 'Projects', 'Tenants', 'Marketplace'],
30
- style: { head: ['cyan'] },
31
- });
32
- for (const t of TIERS) {
33
- const isUser = t.name === userTier.toUpperCase();
34
- const isRequired = t.name === requiredTier.toUpperCase();
35
- const marker = isRequired ? chalk_1.default.yellow(' ← required') : isUser ? chalk_1.default.dim(' ← you') : '';
36
- table.push([
37
- colorTier(t.name) + marker,
38
- t.price,
39
- t.projects,
40
- t.tenants,
41
- t.marketplace ? chalk_1.default.green('✓') : chalk_1.default.dim('✗'),
42
- ]);
43
- }
44
- console.log(table.toString());
45
- console.log(chalk_1.default.dim('\n Upgrade at: https://kaven.dev/pricing\n'));
46
- }
@@ -1,186 +0,0 @@
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.marketplaceBrowse = marketplaceBrowse;
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const ora_1 = __importDefault(require("ora"));
9
- const AuthService_1 = require("../../core/AuthService");
10
- const MarketplaceClient_1 = require("../../infrastructure/MarketplaceClient");
11
- const install_1 = require("./install");
12
- const PAGE_SIZE = 10;
13
- function tierBadge(tier) {
14
- switch (tier.toUpperCase()) {
15
- case "FREE":
16
- return chalk_1.default.gray("[FREE]");
17
- case "STARTER":
18
- return chalk_1.default.green("[STARTER]");
19
- case "COMPLETE":
20
- return chalk_1.default.yellow("[COMPLETE]");
21
- case "PRO":
22
- return chalk_1.default.magenta("[PRO]");
23
- case "ENTERPRISE":
24
- return chalk_1.default.cyan("[ENTERPRISE]");
25
- default:
26
- return chalk_1.default.gray(`[${tier}]`);
27
- }
28
- }
29
- async function marketplaceBrowse() {
30
- const authService = new AuthService_1.AuthService();
31
- const client = new MarketplaceClient_1.MarketplaceClient(authService);
32
- const state = {
33
- category: null,
34
- page: 1,
35
- selectedModule: null,
36
- screen: "categories",
37
- };
38
- const { select } = await import("@inquirer/prompts");
39
- while (state.screen !== "exit") {
40
- if (state.screen === "categories") {
41
- // Step 1: Category selection
42
- const spinner = (0, ora_1.default)("Loading categories...").start();
43
- let categories = [];
44
- try {
45
- categories = await client.getCategories();
46
- spinner.stop();
47
- }
48
- catch {
49
- spinner.stop();
50
- console.log(chalk_1.default.yellow("Could not load categories — showing all modules."));
51
- }
52
- const categoryChoices = [
53
- { name: "All modules", value: "__all__" },
54
- ...categories.map((c) => ({ name: c, value: c })),
55
- { name: chalk_1.default.red("Exit"), value: "__exit__" },
56
- ];
57
- const selected = await select({
58
- message: "Browse by category:",
59
- choices: categoryChoices,
60
- });
61
- if (selected === "__exit__") {
62
- state.screen = "exit";
63
- break;
64
- }
65
- state.category = selected === "__all__" ? null : selected;
66
- state.page = 1;
67
- state.screen = "list";
68
- continue;
69
- }
70
- if (state.screen === "list") {
71
- // Step 2: Module listing with pagination
72
- const spinner = (0, ora_1.default)("Loading modules...").start();
73
- let modules = [];
74
- let totalPages = 1;
75
- try {
76
- const result = await client.listModules({
77
- category: state.category || undefined,
78
- page: state.page,
79
- pageSize: PAGE_SIZE,
80
- });
81
- modules = result.data;
82
- totalPages = Math.ceil(result.total / PAGE_SIZE) || 1;
83
- spinner.stop();
84
- }
85
- catch (error) {
86
- spinner.stop();
87
- console.error(chalk_1.default.red(`Error loading modules: ${error instanceof Error ? error.message : String(error)}`));
88
- state.screen = "categories";
89
- continue;
90
- }
91
- if (modules.length === 0) {
92
- console.log(chalk_1.default.yellow(`No modules found${state.category ? ` in category: ${state.category}` : ""}.`));
93
- state.screen = "categories";
94
- continue;
95
- }
96
- const categoryLabel = state.category ? ` [${state.category}]` : "";
97
- const pageLabel = totalPages > 1 ? ` (page ${state.page}/${totalPages})` : "";
98
- const moduleChoices = [
99
- ...modules.map((m) => ({
100
- name: `${m.name} ${tierBadge(m.requiredTier ?? m.tier ?? "")} — ${m.description}`,
101
- value: m.slug,
102
- })),
103
- ];
104
- // Navigation options at bottom
105
- if (state.page < totalPages) {
106
- moduleChoices.push({ name: chalk_1.default.cyan("→ Next page"), value: "__next__" });
107
- }
108
- if (state.page > 1) {
109
- moduleChoices.push({ name: chalk_1.default.cyan("← Previous page"), value: "__prev__" });
110
- }
111
- moduleChoices.push({ name: chalk_1.default.dim("↑ Back to categories"), value: "__back__" });
112
- moduleChoices.push({ name: chalk_1.default.red("Exit"), value: "__exit__" });
113
- const selected = await select({
114
- message: `Modules${categoryLabel}${pageLabel}:`,
115
- choices: moduleChoices,
116
- });
117
- if (selected === "__exit__") {
118
- state.screen = "exit";
119
- break;
120
- }
121
- if (selected === "__back__") {
122
- state.screen = "categories";
123
- continue;
124
- }
125
- if (selected === "__next__") {
126
- state.page++;
127
- continue;
128
- }
129
- if (selected === "__prev__") {
130
- state.page = Math.max(1, state.page - 1);
131
- continue;
132
- }
133
- // Find selected module
134
- const module = modules.find((m) => m.slug === selected);
135
- if (module) {
136
- state.selectedModule = module;
137
- state.screen = "detail";
138
- }
139
- continue;
140
- }
141
- if (state.screen === "detail" && state.selectedModule) {
142
- const m = state.selectedModule;
143
- // Step 3: Module detail view
144
- console.log();
145
- console.log(chalk_1.default.bold(`${m.name}`), tierBadge(m.requiredTier ?? m.tier ?? ""));
146
- console.log(chalk_1.default.gray(`Version: ${m.latestVersion || "latest"}`));
147
- if (m.installCount !== undefined) {
148
- console.log(chalk_1.default.gray(`Installs: ${m.installCount.toLocaleString()}`));
149
- }
150
- if (m.description) {
151
- console.log();
152
- console.log(m.description);
153
- }
154
- console.log();
155
- const action = await select({
156
- message: "What would you like to do?",
157
- choices: [
158
- { name: `Install ${m.name}`, value: "install" },
159
- { name: "Back to module list", value: "back" },
160
- { name: chalk_1.default.red("Exit"), value: "exit" },
161
- ],
162
- });
163
- if (action === "exit") {
164
- state.screen = "exit";
165
- break;
166
- }
167
- if (action === "back") {
168
- state.selectedModule = null;
169
- state.screen = "list";
170
- continue;
171
- }
172
- if (action === "install") {
173
- console.log();
174
- await (0, install_1.marketplaceInstall)(m.slug, {
175
- force: false,
176
- skipEnv: false,
177
- });
178
- state.screen = "exit";
179
- break;
180
- }
181
- }
182
- }
183
- if (state.screen === "exit") {
184
- console.log(chalk_1.default.gray("Browse session ended."));
185
- }
186
- }