zmarketplace 0.4.2 → 0.4.4
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.
- package/package.json +1 -1
- package/src/index.ts +51 -40
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zmarketplace",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
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,48 +208,59 @@ 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
|
-
registerCommand(name: string, def: { description: string; handler: (args: string, ctx: Ctx) => Promise<void> }): void;
|
|
245
|
+
registerCommand?(name: string, def: { description: string; handler: (args: string, ctx: Ctx) => Promise<void> }): void;
|
|
213
246
|
setLabel?(label: string): void;
|
|
247
|
+
on?(event: string, handler: (...args: unknown[]) => unknown): void;
|
|
214
248
|
}) {
|
|
215
249
|
pi.setLabel?.("Z Marketplace");
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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
|
-
// Choose result limit
|
|
240
|
-
const limitChoice = await ctx.ui.select("Results limit (50 per page)", ["25", "50", "150", "All (paged — may lag on fetch)"]);
|
|
241
|
-
limit = limitChoice?.startsWith("All") ? 999999 : parseInt(limitChoice ?? "50", 10);
|
|
242
|
-
query = (await ctx.ui.input("🔍 Search packages", "Type search query...")) ?? "";
|
|
243
|
-
if (!query) return;
|
|
244
|
-
}
|
|
245
|
-
await doSearch(query, ctx, limit);
|
|
246
|
-
break;
|
|
247
|
-
}
|
|
248
|
-
default: {
|
|
249
|
-
// Treat unknown as search query
|
|
250
|
-
await doSearch(rawArgs.trim(), ctx);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
},
|
|
254
|
-
});
|
|
250
|
+
|
|
251
|
+
// Try registering immediately (works on omp).
|
|
252
|
+
// If it throws, fall back to session_start (works on pi).
|
|
253
|
+
let registered = false;
|
|
254
|
+
try {
|
|
255
|
+
pi.registerCommand?.("zmarketplace", commandDef);
|
|
256
|
+
registered = true;
|
|
257
|
+
} catch {
|
|
258
|
+
// pi may not allow registerCommand during load — try on session_start
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (!registered && pi.on) {
|
|
262
|
+
pi.on("session_start", () => {
|
|
263
|
+
try { pi.registerCommand?.("zmarketplace", commandDef); } catch { /* give up */ }
|
|
264
|
+
});
|
|
265
|
+
}
|
|
255
266
|
}
|