@a5c-ai/babysitter-sdk 0.0.175 → 0.0.176-staging.56d8a856

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 (38) hide show
  1. package/dist/cli/commands/plugin.d.ts +58 -0
  2. package/dist/cli/commands/plugin.d.ts.map +1 -0
  3. package/dist/cli/commands/plugin.js +650 -0
  4. package/dist/cli/main.d.ts.map +1 -1
  5. package/dist/cli/main.js +92 -0
  6. package/dist/harness/geminiCli.d.ts +31 -0
  7. package/dist/harness/geminiCli.d.ts.map +1 -0
  8. package/dist/harness/geminiCli.js +705 -0
  9. package/dist/harness/index.d.ts +1 -0
  10. package/dist/harness/index.d.ts.map +1 -1
  11. package/dist/harness/index.js +3 -1
  12. package/dist/harness/registry.d.ts.map +1 -1
  13. package/dist/harness/registry.js +2 -0
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +1 -0
  17. package/dist/plugins/index.d.ts +14 -0
  18. package/dist/plugins/index.d.ts.map +1 -0
  19. package/dist/plugins/index.js +50 -0
  20. package/dist/plugins/marketplace.d.ts +70 -0
  21. package/dist/plugins/marketplace.d.ts.map +1 -0
  22. package/dist/plugins/marketplace.js +177 -0
  23. package/dist/plugins/migrations.d.ts +52 -0
  24. package/dist/plugins/migrations.d.ts.map +1 -0
  25. package/dist/plugins/migrations.js +151 -0
  26. package/dist/plugins/packageReader.d.ts +47 -0
  27. package/dist/plugins/packageReader.d.ts.map +1 -0
  28. package/dist/plugins/packageReader.js +153 -0
  29. package/dist/plugins/paths.d.ts +30 -0
  30. package/dist/plugins/paths.d.ts.map +1 -0
  31. package/dist/plugins/paths.js +69 -0
  32. package/dist/plugins/registry.d.ts +54 -0
  33. package/dist/plugins/registry.d.ts.map +1 -0
  34. package/dist/plugins/registry.js +116 -0
  35. package/dist/plugins/types.d.ts +128 -0
  36. package/dist/plugins/types.d.ts.map +1 -0
  37. package/dist/plugins/types.js +30 -0
  38. package/package.json +1 -1
@@ -0,0 +1,650 @@
1
+ "use strict";
2
+ /**
3
+ * plugin:* commands — Manage plugins and marketplaces.
4
+ *
5
+ * Marketplace commands:
6
+ * plugin:add-marketplace --marketplace-url <url> --scope global|project [--json]
7
+ * plugin:update-marketplace --marketplace-name <name> --scope global|project [--json]
8
+ * plugin:list-plugins --marketplace-name <name> --scope global|project [--json]
9
+ *
10
+ * Plugin commands:
11
+ * plugin:install, plugin:uninstall, plugin:update, plugin:configure,
12
+ * plugin:list-installed, plugin:update-registry, plugin:remove-from-registry
13
+ */
14
+ var __importDefault = (this && this.__importDefault) || function (mod) {
15
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.validateScope = validateScope;
19
+ exports.requireArg = requireArg;
20
+ exports.handlePluginAddMarketplace = handlePluginAddMarketplace;
21
+ exports.handlePluginUpdateMarketplace = handlePluginUpdateMarketplace;
22
+ exports.handlePluginListPlugins = handlePluginListPlugins;
23
+ exports.handlePluginInstall = handlePluginInstall;
24
+ exports.handlePluginUninstall = handlePluginUninstall;
25
+ exports.handlePluginUpdate = handlePluginUpdate;
26
+ exports.handlePluginConfigure = handlePluginConfigure;
27
+ exports.handlePluginListInstalled = handlePluginListInstalled;
28
+ exports.handlePluginUpdateRegistry = handlePluginUpdateRegistry;
29
+ exports.handlePluginRemoveFromRegistry = handlePluginRemoveFromRegistry;
30
+ const node_fs_1 = require("node:fs");
31
+ const node_path_1 = __importDefault(require("node:path"));
32
+ const marketplace_1 = require("../../plugins/marketplace");
33
+ const packageReader_1 = require("../../plugins/packageReader");
34
+ const migrations_1 = require("../../plugins/migrations");
35
+ const registry_1 = require("../../plugins/registry");
36
+ // ============================================================================
37
+ // Validation Helpers
38
+ // ============================================================================
39
+ function validateScope(scope) {
40
+ return scope === "global" || scope === "project";
41
+ }
42
+ function requireArg(value, name, command, json) {
43
+ if (!value) {
44
+ const msg = `[${command}] ${name} is required`;
45
+ if (json) {
46
+ console.log(JSON.stringify({ error: "missing_argument", message: msg }));
47
+ }
48
+ else {
49
+ console.error(msg);
50
+ }
51
+ return null;
52
+ }
53
+ return value;
54
+ }
55
+ function requireScope(scope, command, json) {
56
+ if (!validateScope(scope)) {
57
+ const msg = `[${command}] --scope (global|project) is required`;
58
+ if (json) {
59
+ console.log(JSON.stringify({ error: "missing_argument", message: msg }));
60
+ }
61
+ else {
62
+ console.error(msg);
63
+ }
64
+ return false;
65
+ }
66
+ return true;
67
+ }
68
+ // ============================================================================
69
+ // Marketplace Handlers
70
+ // ============================================================================
71
+ /**
72
+ * Clones a marketplace repository into the local marketplaces directory.
73
+ *
74
+ * Requires: marketplaceUrl, scope
75
+ */
76
+ async function handlePluginAddMarketplace(args) {
77
+ const { marketplaceUrl, scope, json } = args;
78
+ const url = requireArg(marketplaceUrl, "--marketplace-url", "plugin:add-marketplace", json);
79
+ if (!url)
80
+ return 1;
81
+ if (!requireScope(scope, "plugin:add-marketplace", json))
82
+ return 1;
83
+ const projectDir = scope === "project" ? process.cwd() : undefined;
84
+ try {
85
+ const targetDir = await (0, marketplace_1.cloneMarketplace)(marketplaceUrl, scope, projectDir);
86
+ if (json) {
87
+ console.log(JSON.stringify({
88
+ success: true,
89
+ url: marketplaceUrl,
90
+ scope,
91
+ directory: targetDir,
92
+ }, null, 2));
93
+ }
94
+ else {
95
+ console.log(`Marketplace cloned successfully.\n URL: ${marketplaceUrl}\n Scope: ${scope}\n Directory: ${targetDir}`);
96
+ }
97
+ return 0;
98
+ }
99
+ catch (error) {
100
+ const message = error instanceof Error ? error.message : String(error);
101
+ if (json) {
102
+ console.log(JSON.stringify({ error: "clone_failed", message }));
103
+ }
104
+ else {
105
+ console.error(`[plugin:add-marketplace] ${message}`);
106
+ }
107
+ return 1;
108
+ }
109
+ }
110
+ /**
111
+ * Updates a previously cloned marketplace by pulling latest changes.
112
+ *
113
+ * Requires: marketplaceName, scope
114
+ */
115
+ async function handlePluginUpdateMarketplace(args) {
116
+ const { marketplaceName, scope, json } = args;
117
+ const name = requireArg(marketplaceName, "--marketplace-name", "plugin:update-marketplace", json);
118
+ if (!name)
119
+ return 1;
120
+ if (!requireScope(scope, "plugin:update-marketplace", json))
121
+ return 1;
122
+ const projectDir = scope === "project" ? process.cwd() : undefined;
123
+ try {
124
+ await (0, marketplace_1.updateMarketplace)(marketplaceName, scope, projectDir);
125
+ if (json) {
126
+ console.log(JSON.stringify({
127
+ success: true,
128
+ marketplace: marketplaceName,
129
+ scope,
130
+ }, null, 2));
131
+ }
132
+ else {
133
+ console.log(`Marketplace "${marketplaceName}" updated successfully (scope: ${scope}).`);
134
+ }
135
+ return 0;
136
+ }
137
+ catch (error) {
138
+ const message = error instanceof Error ? error.message : String(error);
139
+ if (json) {
140
+ console.log(JSON.stringify({ error: "update_failed", message }));
141
+ }
142
+ else {
143
+ console.error(`[plugin:update-marketplace] ${message}`);
144
+ }
145
+ return 1;
146
+ }
147
+ }
148
+ /**
149
+ * Lists all plugins available in a marketplace manifest.
150
+ *
151
+ * Requires: marketplaceName, scope
152
+ */
153
+ async function handlePluginListPlugins(args) {
154
+ const { marketplaceName, scope, json } = args;
155
+ const name = requireArg(marketplaceName, "--marketplace-name", "plugin:list-plugins", json);
156
+ if (!name)
157
+ return 1;
158
+ if (!requireScope(scope, "plugin:list-plugins", json))
159
+ return 1;
160
+ const projectDir = scope === "project" ? process.cwd() : undefined;
161
+ try {
162
+ const plugins = await (0, marketplace_1.listMarketplacePlugins)(marketplaceName, scope, projectDir);
163
+ if (json) {
164
+ console.log(JSON.stringify({
165
+ marketplace: marketplaceName,
166
+ scope,
167
+ count: plugins.length,
168
+ plugins,
169
+ }, null, 2));
170
+ }
171
+ else {
172
+ if (plugins.length === 0) {
173
+ console.log(`No plugins found in marketplace "${marketplaceName}" (scope: ${scope}).`);
174
+ }
175
+ else {
176
+ console.log(`Plugins in marketplace "${marketplaceName}" (scope: ${scope}):\n`);
177
+ const nameWidth = Math.max(...plugins.map((p) => p.name.length), 4);
178
+ const versionWidth = Math.max(...plugins.map((p) => p.latestVersion.length), 7);
179
+ console.log(` ${"NAME".padEnd(nameWidth)} ${"VERSION".padEnd(versionWidth)} DESCRIPTION`);
180
+ console.log(` ${"─".repeat(nameWidth)} ${"─".repeat(versionWidth)} ${"─".repeat(40)}`);
181
+ for (const plugin of plugins) {
182
+ console.log(` ${plugin.name.padEnd(nameWidth)} ${plugin.latestVersion.padEnd(versionWidth)} ${plugin.description}`);
183
+ }
184
+ console.log(`\n ${plugins.length} plugin(s) available.`);
185
+ }
186
+ }
187
+ return 0;
188
+ }
189
+ catch (error) {
190
+ const message = error instanceof Error ? error.message : String(error);
191
+ if (json) {
192
+ console.log(JSON.stringify({ error: "list_failed", message }));
193
+ }
194
+ else {
195
+ console.error(`[plugin:list-plugins] ${message}`);
196
+ }
197
+ return 1;
198
+ }
199
+ }
200
+ // ============================================================================
201
+ // Plugin Handlers
202
+ // ============================================================================
203
+ /** Install a plugin from a marketplace. */
204
+ async function handlePluginInstall(args) {
205
+ const { pluginName, marketplaceName, scope, pluginVersion, json } = args;
206
+ const plugin = requireArg(pluginName, "--plugin-name", "plugin:install", json);
207
+ if (!plugin)
208
+ return 1;
209
+ const marketplace = requireArg(marketplaceName, "--marketplace-name", "plugin:install", json);
210
+ if (!marketplace)
211
+ return 1;
212
+ if (!requireScope(scope, "plugin:install", json))
213
+ return 1;
214
+ const projectDir = scope === "project" ? process.cwd() : undefined;
215
+ try {
216
+ // Update marketplace to ensure latest
217
+ await (0, marketplace_1.updateMarketplace)(marketplaceName, scope, projectDir);
218
+ // Determine version: use provided or read latestVersion from manifest
219
+ let version = pluginVersion;
220
+ if (!version) {
221
+ const manifest = await (0, marketplace_1.readMarketplaceManifest)(marketplaceName, scope, projectDir);
222
+ const entry = manifest.plugins[pluginName];
223
+ if (!entry) {
224
+ throw new Error(`Plugin "${pluginName}" not found in marketplace "${marketplaceName}"`);
225
+ }
226
+ version = entry.latestVersion;
227
+ }
228
+ // Resolve the plugin package path
229
+ const packagePath = await (0, marketplace_1.resolvePluginPackagePath)(marketplaceName, pluginName, scope, projectDir);
230
+ // Read install instructions
231
+ const instructions = await (0, packageReader_1.readInstallInstructions)(packagePath);
232
+ // Check for install-process.js
233
+ const processFilePath = node_path_1.default.join(packagePath, "install-process.js");
234
+ let processFile = null;
235
+ try {
236
+ await node_fs_1.promises.access(processFilePath);
237
+ processFile = processFilePath;
238
+ }
239
+ catch {
240
+ // No install-process.js is fine
241
+ }
242
+ const result = {
243
+ plugin: pluginName,
244
+ version,
245
+ marketplace: marketplaceName,
246
+ scope,
247
+ instructions: instructions ?? null,
248
+ processFile,
249
+ };
250
+ if (json) {
251
+ console.log(JSON.stringify(result, null, 2));
252
+ }
253
+ else {
254
+ console.log(`Plugin: ${pluginName} v${version}`);
255
+ console.log(`Marketplace: ${marketplaceName}`);
256
+ console.log(`Scope: ${scope}`);
257
+ if (instructions) {
258
+ console.log(`\nInstall Instructions:\n${instructions}`);
259
+ }
260
+ else {
261
+ console.log("\nNo install instructions found.");
262
+ }
263
+ if (processFile) {
264
+ console.log(`\nInstall process file: ${processFile}`);
265
+ }
266
+ }
267
+ return 0;
268
+ }
269
+ catch (error) {
270
+ const message = error instanceof Error ? error.message : String(error);
271
+ if (json) {
272
+ console.log(JSON.stringify({ error: "install_failed", message }));
273
+ }
274
+ else {
275
+ console.error(`[plugin:install] ${message}`);
276
+ }
277
+ return 1;
278
+ }
279
+ }
280
+ /** Uninstall a previously installed plugin. */
281
+ async function handlePluginUninstall(args) {
282
+ const { pluginName, scope, json } = args;
283
+ const plugin = requireArg(pluginName, "--plugin-name", "plugin:uninstall", json);
284
+ if (!plugin)
285
+ return 1;
286
+ if (!requireScope(scope, "plugin:uninstall", json))
287
+ return 1;
288
+ const projectDir = scope === "project" ? process.cwd() : undefined;
289
+ try {
290
+ // Read the registry to find the installed plugin
291
+ const registry = await (0, registry_1.readPluginRegistry)(scope, projectDir);
292
+ const entry = (0, registry_1.getPluginEntry)(registry, pluginName);
293
+ if (!entry) {
294
+ throw new Error(`Plugin "${pluginName}" is not installed in the ${scope} registry`);
295
+ }
296
+ const { marketplace, version } = entry;
297
+ // Resolve the plugin package path from the marketplace
298
+ const packagePath = await (0, marketplace_1.resolvePluginPackagePath)(marketplace, pluginName, scope, projectDir);
299
+ // Read uninstall instructions
300
+ const instructions = await (0, packageReader_1.readUninstallInstructions)(packagePath);
301
+ // Check for uninstall-process.js
302
+ const processFilePath = node_path_1.default.join(packagePath, "uninstall-process.js");
303
+ let processFile = null;
304
+ try {
305
+ await node_fs_1.promises.access(processFilePath);
306
+ processFile = processFilePath;
307
+ }
308
+ catch {
309
+ // No uninstall-process.js is fine
310
+ }
311
+ const result = {
312
+ plugin: pluginName,
313
+ version,
314
+ marketplace,
315
+ scope,
316
+ instructions: instructions ?? null,
317
+ processFile,
318
+ };
319
+ if (json) {
320
+ console.log(JSON.stringify(result, null, 2));
321
+ }
322
+ else {
323
+ console.log(`Plugin: ${pluginName} v${version}`);
324
+ console.log(`Marketplace: ${marketplace}`);
325
+ console.log(`Scope: ${scope}`);
326
+ if (instructions) {
327
+ console.log(`\nUninstall Instructions:\n${instructions}`);
328
+ }
329
+ else {
330
+ console.log("\nNo uninstall instructions found.");
331
+ }
332
+ if (processFile) {
333
+ console.log(`\nUninstall process file: ${processFile}`);
334
+ }
335
+ }
336
+ return 0;
337
+ }
338
+ catch (error) {
339
+ const message = error instanceof Error ? error.message : String(error);
340
+ if (json) {
341
+ console.log(JSON.stringify({ error: "uninstall_failed", message }));
342
+ }
343
+ else {
344
+ console.error(`[plugin:uninstall] ${message}`);
345
+ }
346
+ return 1;
347
+ }
348
+ }
349
+ /** Update an installed plugin to a newer version. */
350
+ async function handlePluginUpdate(args) {
351
+ const { pluginName, marketplaceName, scope, pluginVersion, json } = args;
352
+ const plugin = requireArg(pluginName, "--plugin-name", "plugin:update", json);
353
+ if (!plugin)
354
+ return 1;
355
+ const marketplace = requireArg(marketplaceName, "--marketplace-name", "plugin:update", json);
356
+ if (!marketplace)
357
+ return 1;
358
+ if (!requireScope(scope, "plugin:update", json))
359
+ return 1;
360
+ const projectDir = scope === "project" ? process.cwd() : undefined;
361
+ try {
362
+ // Read registry to get currently installed version
363
+ const registry = await (0, registry_1.readPluginRegistry)(scope, projectDir);
364
+ const entry = (0, registry_1.getPluginEntry)(registry, pluginName);
365
+ if (!entry) {
366
+ throw new Error(`Plugin "${pluginName}" is not installed in the ${scope} registry`);
367
+ }
368
+ const installedVersion = entry.version;
369
+ // Update marketplace to get latest
370
+ await (0, marketplace_1.updateMarketplace)(marketplaceName, scope, projectDir);
371
+ // Determine target version
372
+ let targetVersion = pluginVersion;
373
+ if (!targetVersion) {
374
+ const manifest = await (0, marketplace_1.readMarketplaceManifest)(marketplaceName, scope, projectDir);
375
+ const manifestEntry = manifest.plugins[pluginName];
376
+ if (!manifestEntry) {
377
+ throw new Error(`Plugin "${pluginName}" not found in marketplace "${marketplaceName}"`);
378
+ }
379
+ targetVersion = manifestEntry.latestVersion;
380
+ }
381
+ if (installedVersion === targetVersion) {
382
+ const result = {
383
+ plugin: pluginName,
384
+ fromVersion: installedVersion,
385
+ toVersion: targetVersion,
386
+ migrations: [],
387
+ message: "Already at target version",
388
+ };
389
+ if (json) {
390
+ console.log(JSON.stringify(result, null, 2));
391
+ }
392
+ else {
393
+ console.log(`Plugin "${pluginName}" is already at version ${targetVersion}.`);
394
+ }
395
+ return 0;
396
+ }
397
+ // Resolve the plugin package path
398
+ const packagePath = await (0, marketplace_1.resolvePluginPackagePath)(marketplaceName, pluginName, scope, projectDir);
399
+ // Resolve migration chain
400
+ const chain = await (0, migrations_1.resolveMigrationChain)(packagePath, installedVersion, targetVersion);
401
+ if (!chain) {
402
+ throw new Error(`No migration path found from version "${installedVersion}" to "${targetVersion}" for plugin "${pluginName}"`);
403
+ }
404
+ const migrations = chain.map(({ descriptor, content }) => ({
405
+ from: descriptor.from,
406
+ to: descriptor.to,
407
+ file: descriptor.file,
408
+ type: descriptor.type,
409
+ instructions: content,
410
+ processFile: descriptor.type === "js"
411
+ ? node_path_1.default.join(packagePath, "migrations", descriptor.file)
412
+ : null,
413
+ }));
414
+ const result = {
415
+ plugin: pluginName,
416
+ fromVersion: installedVersion,
417
+ toVersion: targetVersion,
418
+ marketplace: marketplaceName,
419
+ scope,
420
+ migrations,
421
+ };
422
+ if (json) {
423
+ console.log(JSON.stringify(result, null, 2));
424
+ }
425
+ else {
426
+ console.log(`Plugin: ${pluginName}\nFrom: ${installedVersion} → To: ${targetVersion}`);
427
+ console.log(`Migration steps: ${migrations.length}`);
428
+ for (const m of migrations) {
429
+ console.log(`\n--- ${m.from} → ${m.to} (${m.file}) ---`);
430
+ console.log(m.instructions);
431
+ if (m.processFile) {
432
+ console.log(`Process file: ${m.processFile}`);
433
+ }
434
+ }
435
+ }
436
+ return 0;
437
+ }
438
+ catch (error) {
439
+ const message = error instanceof Error ? error.message : String(error);
440
+ if (json) {
441
+ console.log(JSON.stringify({ error: "update_failed", message }));
442
+ }
443
+ else {
444
+ console.error(`[plugin:update] ${message}`);
445
+ }
446
+ return 1;
447
+ }
448
+ }
449
+ /** Configure an installed plugin. */
450
+ async function handlePluginConfigure(args) {
451
+ const { pluginName, marketplaceName, scope, json } = args;
452
+ const plugin = requireArg(pluginName, "--plugin-name", "plugin:configure", json);
453
+ if (!plugin)
454
+ return 1;
455
+ const marketplace = requireArg(marketplaceName, "--marketplace-name", "plugin:configure", json);
456
+ if (!marketplace)
457
+ return 1;
458
+ if (!requireScope(scope, "plugin:configure", json))
459
+ return 1;
460
+ const projectDir = scope === "project" ? process.cwd() : undefined;
461
+ try {
462
+ // Resolve plugin package path
463
+ const packagePath = await (0, marketplace_1.resolvePluginPackagePath)(marketplaceName, pluginName, scope, projectDir);
464
+ // Read configure instructions
465
+ const instructions = await (0, packageReader_1.readConfigureInstructions)(packagePath);
466
+ // Check for configure-process.js
467
+ const processFilePath = node_path_1.default.join(packagePath, "configure-process.js");
468
+ let processFile = null;
469
+ try {
470
+ await node_fs_1.promises.access(processFilePath);
471
+ processFile = processFilePath;
472
+ }
473
+ catch {
474
+ // No configure-process.js is fine
475
+ }
476
+ const result = {
477
+ plugin: pluginName,
478
+ marketplace: marketplaceName,
479
+ scope,
480
+ instructions: instructions ?? null,
481
+ processFile,
482
+ };
483
+ if (json) {
484
+ console.log(JSON.stringify(result, null, 2));
485
+ }
486
+ else {
487
+ console.log(`Plugin: ${pluginName}`);
488
+ console.log(`Marketplace: ${marketplaceName}`);
489
+ console.log(`Scope: ${scope}`);
490
+ if (instructions) {
491
+ console.log(`\nConfigure Instructions:\n${instructions}`);
492
+ }
493
+ else {
494
+ console.log("\nNo configure instructions found.");
495
+ }
496
+ if (processFile) {
497
+ console.log(`\nConfigure process file: ${processFile}`);
498
+ }
499
+ }
500
+ return 0;
501
+ }
502
+ catch (error) {
503
+ const message = error instanceof Error ? error.message : String(error);
504
+ if (json) {
505
+ console.log(JSON.stringify({ error: "configure_failed", message }));
506
+ }
507
+ else {
508
+ console.error(`[plugin:configure] ${message}`);
509
+ }
510
+ return 1;
511
+ }
512
+ }
513
+ /** List all installed plugins from the registry. */
514
+ async function handlePluginListInstalled(args) {
515
+ const { scope, json } = args;
516
+ if (!requireScope(scope, "plugin:list-installed", json))
517
+ return 1;
518
+ const projectDir = scope === "project" ? process.cwd() : undefined;
519
+ try {
520
+ const registry = await (0, registry_1.readPluginRegistry)(scope, projectDir);
521
+ const entries = (0, registry_1.listPluginEntries)(registry);
522
+ if (json) {
523
+ console.log(JSON.stringify(entries.map((e) => ({
524
+ name: e.name,
525
+ version: e.version,
526
+ marketplace: e.marketplace,
527
+ installedAt: e.installedAt,
528
+ updatedAt: e.updatedAt,
529
+ })), null, 2));
530
+ }
531
+ else {
532
+ if (entries.length === 0) {
533
+ console.log(`No plugins installed (scope: ${scope}).`);
534
+ }
535
+ else {
536
+ console.log(`Installed plugins (scope: ${scope}):\n`);
537
+ const nameWidth = Math.max(...entries.map((e) => e.name.length), 4);
538
+ const versionWidth = Math.max(...entries.map((e) => e.version.length), 7);
539
+ const marketplaceWidth = Math.max(...entries.map((e) => e.marketplace.length), 11);
540
+ console.log(` ${"NAME".padEnd(nameWidth)} ${"VERSION".padEnd(versionWidth)} ${"MARKETPLACE".padEnd(marketplaceWidth)} INSTALLED`);
541
+ console.log(` ${"─".repeat(nameWidth)} ${"─".repeat(versionWidth)} ${"─".repeat(marketplaceWidth)} ${"─".repeat(20)}`);
542
+ for (const entry of entries) {
543
+ console.log(` ${entry.name.padEnd(nameWidth)} ${entry.version.padEnd(versionWidth)} ${entry.marketplace.padEnd(marketplaceWidth)} ${entry.installedAt}`);
544
+ }
545
+ console.log(`\n ${entries.length} plugin(s) installed.`);
546
+ }
547
+ }
548
+ return 0;
549
+ }
550
+ catch (error) {
551
+ const message = error instanceof Error ? error.message : String(error);
552
+ if (json) {
553
+ console.log(JSON.stringify({ error: "list_failed", message }));
554
+ }
555
+ else {
556
+ console.error(`[plugin:list-installed] ${message}`);
557
+ }
558
+ return 1;
559
+ }
560
+ }
561
+ /** Update the plugin registry entry for a plugin. */
562
+ async function handlePluginUpdateRegistry(args) {
563
+ const { pluginName, pluginVersion, marketplaceName, scope, json } = args;
564
+ const plugin = requireArg(pluginName, "--plugin-name", "plugin:update-registry", json);
565
+ if (!plugin)
566
+ return 1;
567
+ const version = requireArg(pluginVersion, "--plugin-version", "plugin:update-registry", json);
568
+ if (!version)
569
+ return 1;
570
+ const marketplace = requireArg(marketplaceName, "--marketplace-name", "plugin:update-registry", json);
571
+ if (!marketplace)
572
+ return 1;
573
+ if (!requireScope(scope, "plugin:update-registry", json))
574
+ return 1;
575
+ const projectDir = scope === "project" ? process.cwd() : undefined;
576
+ try {
577
+ const registry = await (0, registry_1.readPluginRegistry)(scope, projectDir);
578
+ // Resolve the plugin package path for the registry entry
579
+ const packagePath = await (0, marketplace_1.resolvePluginPackagePath)(marketplaceName, pluginName, scope, projectDir);
580
+ const now = new Date().toISOString();
581
+ const existingEntry = (0, registry_1.getPluginEntry)(registry, pluginName);
582
+ const entry = {
583
+ name: pluginName,
584
+ version: pluginVersion,
585
+ marketplace: marketplaceName,
586
+ scope,
587
+ installedAt: existingEntry?.installedAt ?? now,
588
+ updatedAt: now,
589
+ packagePath,
590
+ metadata: existingEntry?.metadata ?? {},
591
+ };
592
+ const updatedRegistry = (0, registry_1.upsertPluginEntry)(registry, entry);
593
+ await (0, registry_1.writePluginRegistry)(updatedRegistry, scope, projectDir);
594
+ if (json) {
595
+ console.log(JSON.stringify(entry, null, 2));
596
+ }
597
+ else {
598
+ console.log(`Plugin ${pluginName}@${pluginVersion} registered (marketplace: ${marketplaceName})`);
599
+ }
600
+ return 0;
601
+ }
602
+ catch (error) {
603
+ const message = error instanceof Error ? error.message : String(error);
604
+ if (json) {
605
+ console.log(JSON.stringify({
606
+ error: "update_registry_failed",
607
+ message,
608
+ }));
609
+ }
610
+ else {
611
+ console.error(`[plugin:update-registry] ${message}`);
612
+ }
613
+ return 1;
614
+ }
615
+ }
616
+ /** Remove a plugin entry from the registry. */
617
+ async function handlePluginRemoveFromRegistry(args) {
618
+ const { pluginName, scope, json } = args;
619
+ const plugin = requireArg(pluginName, "--plugin-name", "plugin:remove-from-registry", json);
620
+ if (!plugin)
621
+ return 1;
622
+ if (!requireScope(scope, "plugin:remove-from-registry", json))
623
+ return 1;
624
+ const projectDir = scope === "project" ? process.cwd() : undefined;
625
+ try {
626
+ const registry = await (0, registry_1.readPluginRegistry)(scope, projectDir);
627
+ const updatedRegistry = (0, registry_1.removePluginEntry)(registry, pluginName);
628
+ await (0, registry_1.writePluginRegistry)(updatedRegistry, scope, projectDir);
629
+ if (json) {
630
+ console.log(JSON.stringify({ removed: true, plugin: pluginName }, null, 2));
631
+ }
632
+ else {
633
+ console.log(`Plugin ${pluginName} removed from registry`);
634
+ }
635
+ return 0;
636
+ }
637
+ catch (error) {
638
+ const message = error instanceof Error ? error.message : String(error);
639
+ if (json) {
640
+ console.log(JSON.stringify({
641
+ error: "remove_failed",
642
+ message,
643
+ }));
644
+ }
645
+ else {
646
+ console.error(`[plugin:remove-from-registry] ${message}`);
647
+ }
648
+ return 1;
649
+ }
650
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,sBAAsB,IAAI,6BAA6B,EAAoB,MAAM,oBAAoB,CAAC;AAsd/G;;;;;;;;;GASG;AACH,iBAAS,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CA8BlE;AAOD,2EAA2E;AAC3E,QAAA,MAAM,sBAAsB,sCAAgC,CAAC;AA+9C7D,OAAO,EAAE,aAAa,IAAI,cAAc,EAAE,sBAAsB,IAAI,uBAAuB,EAAE,CAAC;AAE9F,wBAAgB,mBAAmB;eAEf,MAAM,EAAE,GAA2B,OAAO,CAAC,MAAM,CAAC;kBAmNpD,MAAM;EAIvB"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,sBAAsB,IAAI,6BAA6B,EAAoB,MAAM,oBAAoB,CAAC;AA8gB/G;;;;;;;;;GASG;AACH,iBAAS,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CA8BlE;AAOD,2EAA2E;AAC3E,QAAA,MAAM,sBAAsB,sCAAgC,CAAC;AAy+C7D,OAAO,EAAE,aAAa,IAAI,cAAc,EAAE,sBAAsB,IAAI,uBAAuB,EAAE,CAAC;AAE9F,wBAAgB,mBAAmB;eAEf,MAAM,EAAE,GAA2B,OAAO,CAAC,MAAM,CAAC;kBA8PpD,MAAM;EAIvB"}