zmarketplace 0.4.4 → 0.4.6
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 +24 -49
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zmarketplace",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
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
|
@@ -58,23 +58,16 @@ async function browseResults(results: PackageResult[], ctx: Ctx): Promise<void>
|
|
|
58
58
|
const pageEnd = Math.min(pageStart + PAGE_SIZE, results.length);
|
|
59
59
|
const page = results.slice(pageStart, pageEnd);
|
|
60
60
|
|
|
61
|
-
const options = page.map((r, i) =>
|
|
62
|
-
const globalIdx = pageStart + i;
|
|
63
|
-
return { label: formatResultOption(r, globalIdx).label, description: r.installCommand ?? "" };
|
|
64
|
-
});
|
|
61
|
+
const options: string[] = page.map((r, i) => formatResultOption(r, pageStart + i).label);
|
|
65
62
|
|
|
66
|
-
// Pagination controls
|
|
67
63
|
if (pageStart > 0) {
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
options.push({ label: `← Previous (${prevStart}-${prevEnd})`, description: "" });
|
|
64
|
+
const ps = Math.max(0, pageStart - PAGE_SIZE) + 1;
|
|
65
|
+
options.push(`← Previous (${ps}-${pageStart})`);
|
|
71
66
|
}
|
|
72
67
|
if (pageEnd < results.length) {
|
|
73
|
-
|
|
74
|
-
const nextEnd = Math.min(pageEnd + PAGE_SIZE, results.length);
|
|
75
|
-
options.push({ label: `→ Next (${nextStart}-${nextEnd})`, description: "" });
|
|
68
|
+
options.push(`→ Next (${pageEnd + 1}-${Math.min(pageEnd + PAGE_SIZE, results.length)})`);
|
|
76
69
|
}
|
|
77
|
-
options.push(
|
|
70
|
+
options.push("↩ Done");
|
|
78
71
|
|
|
79
72
|
const title = `zmarketplace: ${results.length} results (page ${Math.floor(pageStart / PAGE_SIZE) + 1}/${Math.ceil(results.length / PAGE_SIZE)})`;
|
|
80
73
|
const selected = await ctx.ui.select(title, options);
|
|
@@ -173,25 +166,26 @@ async function doInstall(pkg: PackageResult, ctx: Ctx): Promise<void> {
|
|
|
173
166
|
"",
|
|
174
167
|
];
|
|
175
168
|
|
|
176
|
-
// Build install options
|
|
177
|
-
const cmds:
|
|
169
|
+
// Build install options as plain strings
|
|
170
|
+
const cmds: string[] = [];
|
|
171
|
+
const cmdMap = new Map<string, string>();
|
|
178
172
|
const seen = new Set<string>();
|
|
173
|
+
const addCmd = (label: string, command: string) => { cmds.push(label); cmdMap.set(label, command); };
|
|
174
|
+
|
|
179
175
|
for (const eco of pkg.ecosystems) {
|
|
180
176
|
if ((eco === "pi" || eco === "omp") && !seen.has("pi")) {
|
|
181
177
|
seen.add("pi");
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
cmds.push({ label: "⌥ omp install", description: `omp plugin install npm:${pkg.name}` });
|
|
185
|
-
auditLines.push("⌥ omp install");
|
|
178
|
+
addCmd("🥧 pi install", `pi install npm:${pkg.name}`);
|
|
179
|
+
addCmd("⌥ omp install", `omp plugin install npm:${pkg.name}`);
|
|
186
180
|
}
|
|
187
|
-
if (eco === "claude" && !seen.has("claude")) { seen.add("claude");
|
|
188
|
-
if (eco === "opencode" && !seen.has("opencode")) { seen.add("opencode");
|
|
189
|
-
if (eco === "gemini" && !seen.has("gemini")) { seen.add("gemini");
|
|
190
|
-
if (eco === "codex" && !seen.has("codex")) { seen.add("codex");
|
|
181
|
+
if (eco === "claude" && !seen.has("claude")) { seen.add("claude"); addCmd("🤖 claude", `claude plugin install npm:${pkg.name}`); }
|
|
182
|
+
if (eco === "opencode" && !seen.has("opencode")) { seen.add("opencode"); addCmd("🔓 opencode", `opencode plugin ${pkg.name}`); }
|
|
183
|
+
if (eco === "gemini" && !seen.has("gemini")) { seen.add("gemini"); addCmd("💎 gemini", `gemini extension install ${pkg.repository ?? pkg.name}`); }
|
|
184
|
+
if (eco === "codex" && !seen.has("codex")) { seen.add("codex"); addCmd("🔲 codex", `codex plugin add npm:${pkg.name}`); }
|
|
191
185
|
}
|
|
192
|
-
if (!seen.has("npm"))
|
|
193
|
-
|
|
194
|
-
cmds.push(
|
|
186
|
+
if (!seen.has("npm")) addCmd("📦 npm", `npm install ${pkg.name}`);
|
|
187
|
+
addCmd("⚡ bunx", `bunx ${pkg.name}`);
|
|
188
|
+
cmds.push("↩ Cancel");
|
|
195
189
|
|
|
196
190
|
// High risk confirmation
|
|
197
191
|
if (report.risk === "critical" || report.risk === "high") {
|
|
@@ -199,11 +193,10 @@ async function doInstall(pkg: PackageResult, ctx: Ctx): Promise<void> {
|
|
|
199
193
|
if (!proceed) { ctx.ui.notify("Cancelled.", "info"); return; }
|
|
200
194
|
}
|
|
201
195
|
|
|
202
|
-
const choice = await ctx.ui.select(`Install ${pkg.name} —
|
|
203
|
-
if (!choice || choice
|
|
204
|
-
const
|
|
205
|
-
if (
|
|
206
|
-
ctx.ui.notify(`✅ Run:\n ${selected.description}`, "info");
|
|
196
|
+
const choice = await ctx.ui.select(`Install ${pkg.name} — Risk: ${report.risk}`, cmds);
|
|
197
|
+
if (!choice || choice === "↩ Cancel") return;
|
|
198
|
+
const command = cmdMap.get(choice);
|
|
199
|
+
if (command) ctx.ui.notify(`✅ Run:\n ${command}`, "info");
|
|
207
200
|
}
|
|
208
201
|
|
|
209
202
|
// ── Factory ────────────────────────────────────────────────────────────────
|
|
@@ -243,24 +236,6 @@ const commandDef = {
|
|
|
243
236
|
|
|
244
237
|
export default function zmarketplace(pi: {
|
|
245
238
|
registerCommand?(name: string, def: { description: string; handler: (args: string, ctx: Ctx) => Promise<void> }): void;
|
|
246
|
-
setLabel?(label: string): void;
|
|
247
|
-
on?(event: string, handler: (...args: unknown[]) => unknown): void;
|
|
248
239
|
}) {
|
|
249
|
-
pi.
|
|
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
|
-
}
|
|
240
|
+
pi.registerCommand?.("zmarketplace", commandDef);
|
|
266
241
|
}
|