zmarketplace 0.4.3 → 0.4.5

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +34 -42
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmarketplace",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "Cross-agent marketplace search: find, audit, and install plugins/skills/themes/prompts across pi, omp, claude code, opencode, gemini cli, and codex",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/index.ts CHANGED
@@ -208,49 +208,41 @@ async function doInstall(pkg: PackageResult, ctx: Ctx): Promise<void> {
208
208
 
209
209
  // ── Factory ────────────────────────────────────────────────────────────────
210
210
 
211
+ // Command handler — extracted so it can be registered at the right time.
212
+ const commandDef = {
213
+ description: "Search, audit, and install packages across agent ecosystems",
214
+ handler: async (rawArgs: string, ctx: Ctx) => {
215
+ const args = parseArgs(rawArgs.trim().split(/\s+/).filter(Boolean));
216
+ switch (args.subcommand) {
217
+ case "help": { ctx.ui.notify(formatHelp(), "info"); break; }
218
+ case "audit":
219
+ case "a": {
220
+ const ref = args.positional[0];
221
+ if (!ref) { ctx.ui.notify("Usage: /zmarketplace audit <name>", "info"); break; }
222
+ await doAudit(resolveRef(ref)?.name ?? ref, ctx);
223
+ break;
224
+ }
225
+ case "search":
226
+ case "s":
227
+ case "": {
228
+ let query = args.positional.join(" ").trim();
229
+ let limit = 50;
230
+ if (!query && ctx.hasUI) {
231
+ const limitChoice = await ctx.ui.select("Results limit (50 per page)", ["25", "50", "150", "All (paged)"]);
232
+ limit = limitChoice?.startsWith("All") ? 999999 : parseInt(limitChoice ?? "50", 10);
233
+ query = (await ctx.ui.input("Search packages", "Type search query...")) ?? "";
234
+ if (!query) return;
235
+ }
236
+ await doSearch(query, ctx, limit);
237
+ break;
238
+ }
239
+ default: { await doSearch(rawArgs.trim(), ctx); }
240
+ }
241
+ },
242
+ } as const;
243
+
211
244
  export default function zmarketplace(pi: {
212
245
  registerCommand?(name: string, def: { description: string; handler: (args: string, ctx: Ctx) => Promise<void> }): void;
213
- setLabel?(label: string): void;
214
246
  }) {
215
- try {
216
- pi.setLabel?.("Z Marketplace");
217
- pi.registerCommand?.("zmarketplace", {
218
- description: "Search, audit, and install packages across agent ecosystems",
219
- handler: async (rawArgs: string, ctx: Ctx) => {
220
- const args = parseArgs(rawArgs.trim().split(/\s+/).filter(Boolean));
221
- switch (args.subcommand) {
222
- case "help": {
223
- ctx.ui.notify(formatHelp(), "info");
224
- break;
225
- }
226
- case "audit":
227
- case "a": {
228
- const ref = args.positional[0];
229
- if (!ref) { ctx.ui.notify("Usage: /zmarketplace audit <name>", "info"); break; }
230
- await doAudit(resolveRef(ref)?.name ?? ref, ctx);
231
- break;
232
- }
233
- case "search":
234
- case "s":
235
- case "": {
236
- let query = args.positional.join(" ").trim();
237
- let limit = 50;
238
- if (!query && ctx.hasUI) {
239
- const limitChoice = await ctx.ui.select("Results limit (50 per page)", ["25", "50", "150", "All (paged)"]);
240
- limit = limitChoice?.startsWith("All") ? 999999 : parseInt(limitChoice ?? "50", 10);
241
- query = (await ctx.ui.input("Search packages", "Type search query...")) ?? "";
242
- if (!query) return;
243
- }
244
- await doSearch(query, ctx, limit);
245
- break;
246
- }
247
- default: {
248
- await doSearch(rawArgs.trim(), ctx);
249
- }
250
- }
251
- },
252
- });
253
- } catch {
254
- // pi runtime may differ from omp — don't crash the agent
255
- }
247
+ pi.registerCommand?.("zmarketplace", commandDef);
256
248
  }