popcons 0.0.0-stage → 1.0.1

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 (4) hide show
  1. package/LICENSE +12 -0
  2. package/README.md +52 -3
  3. package/dist/index.js +1234 -0
  4. package/package.json +43 -4
package/LICENSE ADDED
@@ -0,0 +1,12 @@
1
+ Popcons CLI - commercial license
2
+
3
+ Copyright (c) Popcons. All rights reserved.
4
+
5
+ This command line tool is distributed to licensed Popcons customers. Installing
6
+ icons and components with it requires a valid Popcons license key. The assets it
7
+ downloads are covered by the Popcons license terms:
8
+
9
+ https://popcons.dev/license
10
+
11
+ You may not redistribute the downloaded assets as a standalone icon or component
12
+ library. See the URL above for the full terms.
package/README.md CHANGED
@@ -1,3 +1,52 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # popcons
2
+
3
+ CLI for [Popcons](https://popcons.dev): 800+ animated icons and 29 style packs of animated React + Tailwind components. Popcons is license-only. Files are copied into your project as source; nothing paid is published to npm.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npx popcons login # opens popcons.dev in your browser; click Allow
9
+ npx popcons add bell heart # writes components/popcons/Bell.tsx, Heart.tsx
10
+ ```
11
+
12
+ Get a license at https://popcons.dev/pricing.
13
+
14
+ ## Commands
15
+
16
+ | Command | What it does |
17
+ | --- | --- |
18
+ | `login [key]`, `logout`, `whoami` | Sign in through the browser (or save a key for CI), stored in `~/.config/popcons/config.json`, mode 0600 |
19
+ | `init` | Write `popcons.json`, detecting framework, TypeScript and Tailwind |
20
+ | `search <words> [--category c] [--json]`, `categories`, `list` | Browse the catalog |
21
+ | `add <icon...> [--format react\|vue\|svelte\|svg\|css\|html] [--dir] [--variant outline\|duotone] [--sound] [--overwrite]` | Add icons as source files |
22
+ | `ui add <component...>` | Add UI components (prints npm deps to install) |
23
+ | `pack add <pack-id>` | Add a whole style pack |
24
+ | `skill install` | Install the icon designer agent skill |
25
+ | `mcp` | Run the stdio MCP bridge |
26
+ | `validate <file.json>` | Validate an icon definition offline |
27
+
28
+ Add `--json` to list-like commands for agents. Colors appear only on a TTY and respect `NO_COLOR`.
29
+
30
+ ## CI
31
+
32
+ Set `POPCONS_LICENSE_KEY` (takes priority over the saved key). Override the server with `POPCONS_SITE` or `--site`.
33
+
34
+ ## MCP
35
+
36
+ Claude Code (signs in through the browser the first time it is used):
37
+
38
+ ```bash
39
+ claude mcp add --transport http popcons https://popcons.dev/api/mcp
40
+ ```
41
+
42
+ Editors that only run local (stdio) servers can use the bridge instead: `npx -y popcons mcp`.
43
+
44
+ Cursor (`.cursor/mcp.json`) and VS Code (`.vscode/mcp.json`, use `"servers"` and `"type": "stdio"`):
45
+
46
+ ```json
47
+ { "mcpServers": { "popcons": { "command": "npx", "args": ["-y", "popcons", "mcp"] } } }
48
+ ```
49
+
50
+ The bridge uses your saved key, or `POPCONS_LICENSE_KEY` / `POPCONS_API_KEY`.
51
+
52
+ License: see LICENSE and https://popcons.dev/license.
package/dist/index.js ADDED
@@ -0,0 +1,1234 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/cli.ts
4
+ import { mkdir as mkdir3, readFile as readFile3, stat, writeFile as writeFile3 } from "fs/promises";
5
+ import path3 from "path";
6
+
7
+ // src/skill.ts
8
+ import { mkdir, readFile, writeFile } from "fs/promises";
9
+ import path from "path";
10
+ import { gzipSync } from "zlib";
11
+
12
+ // ../core/src/motion.ts
13
+ var EASINGS = {
14
+ pop: [0.34, 1.56, 0.64, 1],
15
+ smooth: [0.45, 0, 0.55, 1],
16
+ snap: [0.2, 0.9, 0.1, 1],
17
+ bounce: [0.68, -0.55, 0.27, 1.55],
18
+ linear: [0, 0, 1, 1]
19
+ };
20
+ var REST = {
21
+ rotate: 0,
22
+ translateX: 0,
23
+ translateY: 0,
24
+ scale: 1,
25
+ opacity: 1,
26
+ draw: 1
27
+ };
28
+ function validateMotion(m) {
29
+ const errs = [];
30
+ if (!(m.duration >= 150 && m.duration <= 4e3)) errs.push(`duration ${m.duration} outside 150..4000ms`);
31
+ if (!EASINGS[m.easing]) errs.push(`unknown easing ${m.easing}`);
32
+ if (!m.tracks.length) errs.push("motion has no tracks");
33
+ for (const tr of m.tracks) {
34
+ const k = tr.keyframes;
35
+ if (k.length < 2) errs.push(`${tr.target}.${tr.property}: needs \u22652 keyframes`);
36
+ if (k[0]?.t !== 0 || k[k.length - 1]?.t !== 1) errs.push(`${tr.target}.${tr.property}: keyframes must start at t=0 and end at t=1`);
37
+ for (let i = 1; i < k.length; i++) {
38
+ if (k[i].t <= k[i - 1].t) errs.push(`${tr.target}.${tr.property}: keyframe times must increase`);
39
+ }
40
+ const rest = REST[tr.property];
41
+ const last = k[k.length - 1]?.v ?? rest;
42
+ const endsAtRest = Math.abs(last - rest) < 1e-9 || tr.property === "rotate" && (Math.abs(last % 360) < 1e-9 || m.preset === "spin" && Math.abs(last % 60) < 1e-9);
43
+ if (Math.abs(k[0].v - rest) > 1e-9 || !endsAtRest) {
44
+ errs.push(`${tr.target}.${tr.property}: first and last keyframe must equal rest value ${rest}`);
45
+ }
46
+ }
47
+ return errs;
48
+ }
49
+
50
+ // ../core/src/types.ts
51
+ var DEFAULT_STYLE = {
52
+ size: 24,
53
+ color: "currentColor",
54
+ strokeWidth: 2,
55
+ corner: "round",
56
+ speed: 1,
57
+ intensity: 1,
58
+ variant: "outline"
59
+ };
60
+
61
+ // ../core/src/tree.ts
62
+ function resolveStyle(style) {
63
+ return { ...DEFAULT_STYLE, ...style ?? {} };
64
+ }
65
+ function partsWithDraw(def) {
66
+ return new Set(def.motion.tracks.filter((t) => t.property === "draw").map((t) => t.target));
67
+ }
68
+ function originOf(def, target) {
69
+ const tr = def.motion.tracks.find((t) => t.target === target && t.origin);
70
+ return tr?.origin ?? [12, 12];
71
+ }
72
+ function isFilled(n2) {
73
+ return n2.fill ? n2.fill === "duo" : n2.tag === "path" ? /z\s*$/i.test(String(n2.attrs.d)) : n2.tag !== "line" && n2.tag !== "polyline";
74
+ }
75
+ function nodeEl(n2, draw, style) {
76
+ const attrs = { ...n2.attrs };
77
+ if (draw) attrs.pathLength = 1;
78
+ if (style?.variant === "duotone" && isFilled(n2)) {
79
+ attrs.fill = style.secondary ?? "currentColor";
80
+ if (!style.secondary) attrs["fill-opacity"] = 0.2;
81
+ }
82
+ return { tag: n2.tag, attrs, children: [] };
83
+ }
84
+ function buildTree(def, styleIn, extraAttrs = {}) {
85
+ const style = resolveStyle(styleIn);
86
+ const drawParts = partsWithDraw(def);
87
+ const groups = [];
88
+ let current = null;
89
+ let currentPart;
90
+ for (const n2 of def.nodes) {
91
+ if (!n2.part) {
92
+ current = null;
93
+ currentPart = void 0;
94
+ groups.push(nodeEl(n2, drawParts.has("root"), style));
95
+ continue;
96
+ }
97
+ if (!current || currentPart !== n2.part) {
98
+ const [ox, oy] = originOf(def, n2.part);
99
+ const gAttrs = {
100
+ "data-part": n2.part,
101
+ style: `transform-box:view-box;transform-origin:${ox}px ${oy}px`
102
+ };
103
+ if (drawParts.has(n2.part)) gAttrs["stroke-dasharray"] = "1 1";
104
+ current = { tag: "g", attrs: gAttrs, children: [] };
105
+ currentPart = n2.part;
106
+ groups.push(current);
107
+ }
108
+ current.children.push(nodeEl(n2, drawParts.has(n2.part), style));
109
+ }
110
+ const [rx, ry] = originOf(def, "root");
111
+ const rootAttrs = {
112
+ "data-part": "root",
113
+ style: `transform-box:view-box;transform-origin:${rx}px ${ry}px`
114
+ };
115
+ if (drawParts.has("root")) rootAttrs["stroke-dasharray"] = "1 1";
116
+ const join = style.corner === "round" ? "round" : "miter";
117
+ const cap = style.corner === "round" ? "round" : "square";
118
+ return {
119
+ tag: "svg",
120
+ attrs: {
121
+ xmlns: "http://www.w3.org/2000/svg",
122
+ width: style.size,
123
+ height: style.size,
124
+ viewBox: "0 0 24 24",
125
+ fill: "none",
126
+ stroke: style.color,
127
+ "stroke-width": style.strokeWidth,
128
+ "stroke-linecap": cap,
129
+ "stroke-linejoin": join,
130
+ // Duotone fills use currentColor, so the svg's own `color` follows the stroke colour.
131
+ ...style.variant === "duotone" && !style.secondary ? { color: style.color } : {},
132
+ ...extraAttrs
133
+ },
134
+ children: [{ tag: "g", attrs: rootAttrs, children: groups }]
135
+ };
136
+ }
137
+ var esc = (s) => String(s).replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
138
+ function stringify(el, indent = "") {
139
+ const attrs = Object.entries(el.attrs).map(([k, v]) => ` ${k}="${esc(v)}"`).join("");
140
+ if (!el.children.length) return `${indent}<${el.tag}${attrs}/>`;
141
+ const inner = el.children.map((c) => stringify(c, indent ? indent + " " : "")).join(indent ? "\n" : "");
142
+ return indent ? `${indent}<${el.tag}${attrs}>
143
+ ${inner}
144
+ ${indent}</${el.tag}>` : `<${el.tag}${attrs}>${inner}</${el.tag}>`;
145
+ }
146
+ function renderSvg(def, style, opts = {}) {
147
+ const extra = opts.title ? { role: "img", "aria-label": opts.title } : { "aria-hidden": "true" };
148
+ const tree = buildTree(def, style, extra);
149
+ if (opts.title) tree.children.unshift({ tag: "title", attrs: {}, children: [] });
150
+ let out2 = stringify(tree, opts.pretty ? " " : "").replace(/^ /, "");
151
+ if (opts.title) out2 = out2.replace("<title/>", `<title>${esc(opts.title)}</title>`);
152
+ return out2;
153
+ }
154
+
155
+ // ../core/src/path.ts
156
+ var K = 0.5522847498;
157
+ var Builder = class {
158
+ contours = [];
159
+ cur = null;
160
+ start(p) {
161
+ this.cur = { closed: false, v: [p], i: [[0, 0]], o: [[0, 0]] };
162
+ this.contours.push(this.cur);
163
+ }
164
+ last() {
165
+ const c = this.cur;
166
+ return c.v[c.v.length - 1];
167
+ }
168
+ line(p) {
169
+ this.cubic(this.last(), p, p);
170
+ }
171
+ cubic(c1, c2, p) {
172
+ const c = this.cur;
173
+ const lp = this.last();
174
+ c.o[c.v.length - 1] = [c1[0] - lp[0], c1[1] - lp[1]];
175
+ c.v.push(p);
176
+ c.i.push([c2[0] - p[0], c2[1] - p[1]]);
177
+ c.o.push([0, 0]);
178
+ }
179
+ close() {
180
+ const c = this.cur;
181
+ if (!c) return;
182
+ c.closed = true;
183
+ const n2 = c.v.length;
184
+ if (n2 > 1) {
185
+ const a = c.v[0];
186
+ const b = c.v[n2 - 1];
187
+ if (Math.abs(a[0] - b[0]) < 1e-6 && Math.abs(a[1] - b[1]) < 1e-6) {
188
+ c.i[0] = c.i[n2 - 1];
189
+ c.v.pop();
190
+ c.i.pop();
191
+ c.o.pop();
192
+ }
193
+ }
194
+ }
195
+ };
196
+ function tokenize(d) {
197
+ const out2 = [];
198
+ const re = /([MmLlHhVvCcSsQqTtAaZz])|(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)/g;
199
+ let m;
200
+ while (m = re.exec(d)) out2.push(m[1] ?? parseFloat(m[2]));
201
+ return out2;
202
+ }
203
+ function arcToCubics(p0, rx, ry, phiDeg, large, sweep, p) {
204
+ if (rx === 0 || ry === 0) return [[p0, p, p]];
205
+ const phi = phiDeg * Math.PI / 180;
206
+ const cos = Math.cos(phi);
207
+ const sin = Math.sin(phi);
208
+ const dx = (p0[0] - p[0]) / 2;
209
+ const dy = (p0[1] - p[1]) / 2;
210
+ const x1 = cos * dx + sin * dy;
211
+ const y1 = -sin * dx + cos * dy;
212
+ rx = Math.abs(rx);
213
+ ry = Math.abs(ry);
214
+ const lam = x1 * x1 / (rx * rx) + y1 * y1 / (ry * ry);
215
+ if (lam > 1) {
216
+ rx *= Math.sqrt(lam);
217
+ ry *= Math.sqrt(lam);
218
+ }
219
+ const num = rx * rx * ry * ry - rx * rx * y1 * y1 - ry * ry * x1 * x1;
220
+ const den = rx * rx * y1 * y1 + ry * ry * x1 * x1;
221
+ let co = Math.sqrt(Math.max(0, num / den));
222
+ if (large === sweep) co = -co;
223
+ const cx1 = co * rx * y1 / ry;
224
+ const cy1 = -co * ry * x1 / rx;
225
+ const cx = cos * cx1 - sin * cy1 + (p0[0] + p[0]) / 2;
226
+ const cy = sin * cx1 + cos * cy1 + (p0[1] + p[1]) / 2;
227
+ const ang = (ux, uy, vx, vy) => {
228
+ const a2 = Math.atan2(ux * vy - uy * vx, ux * vx + uy * vy);
229
+ return a2;
230
+ };
231
+ const t1 = ang(1, 0, (x1 - cx1) / rx, (y1 - cy1) / ry);
232
+ let dt = ang((x1 - cx1) / rx, (y1 - cy1) / ry, (-x1 - cx1) / rx, (-y1 - cy1) / ry);
233
+ if (!sweep && dt > 0) dt -= 2 * Math.PI;
234
+ if (sweep && dt < 0) dt += 2 * Math.PI;
235
+ const segs = Math.max(1, Math.ceil(Math.abs(dt) / (Math.PI / 2)));
236
+ const step = dt / segs;
237
+ const alpha = 4 / 3 * Math.tan(step / 4);
238
+ const pt = (t) => [cx + rx * Math.cos(t) * cos - ry * Math.sin(t) * sin, cy + rx * Math.cos(t) * sin + ry * Math.sin(t) * cos];
239
+ const der = (t) => [-rx * Math.sin(t) * cos - ry * Math.cos(t) * sin, -rx * Math.sin(t) * sin + ry * Math.cos(t) * cos];
240
+ const out2 = [];
241
+ let a = t1;
242
+ for (let i = 0; i < segs; i++) {
243
+ const b = a + step;
244
+ const pa = pt(a);
245
+ const pb = i === segs - 1 ? p : pt(b);
246
+ const da = der(a);
247
+ const db = der(b);
248
+ out2.push([
249
+ [pa[0] + alpha * da[0], pa[1] + alpha * da[1]],
250
+ [pb[0] - alpha * db[0], pb[1] - alpha * db[1]],
251
+ pb
252
+ ]);
253
+ a = b;
254
+ }
255
+ return out2;
256
+ }
257
+ function parsePath(d) {
258
+ const t = tokenize(d);
259
+ const b = new Builder();
260
+ let i = 0;
261
+ let cmd = "";
262
+ let cur = [0, 0];
263
+ let startPt = [0, 0];
264
+ let lastCtrl = null;
265
+ let lastQ = null;
266
+ const num = () => t[i++];
267
+ while (i < t.length) {
268
+ if (typeof t[i] === "string") cmd = t[i++];
269
+ const rel = cmd === cmd.toLowerCase();
270
+ const C = cmd.toUpperCase();
271
+ const ox = rel ? cur[0] : 0;
272
+ const oy = rel ? cur[1] : 0;
273
+ if (C === "Z") {
274
+ b.close();
275
+ cur = startPt;
276
+ lastCtrl = lastQ = null;
277
+ continue;
278
+ }
279
+ if (C === "M") {
280
+ cur = [num() + ox, num() + oy];
281
+ startPt = cur;
282
+ b.start(cur);
283
+ cmd = rel ? "l" : "L";
284
+ lastCtrl = lastQ = null;
285
+ continue;
286
+ }
287
+ if (!b.cur) b.start(cur);
288
+ if (C === "L") {
289
+ cur = [num() + ox, num() + oy];
290
+ b.line(cur);
291
+ lastCtrl = lastQ = null;
292
+ } else if (C === "H") {
293
+ cur = [num() + ox, cur[1]];
294
+ b.line(cur);
295
+ lastCtrl = lastQ = null;
296
+ } else if (C === "V") {
297
+ cur = [cur[0], num() + oy];
298
+ b.line(cur);
299
+ lastCtrl = lastQ = null;
300
+ } else if (C === "C") {
301
+ const c1 = [num() + ox, num() + oy];
302
+ const c2 = [num() + ox, num() + oy];
303
+ cur = [num() + ox, num() + oy];
304
+ b.cubic(c1, c2, cur);
305
+ lastCtrl = c2;
306
+ lastQ = null;
307
+ } else if (C === "S") {
308
+ const c1 = lastCtrl ? [2 * cur[0] - lastCtrl[0], 2 * cur[1] - lastCtrl[1]] : cur;
309
+ const c2 = [num() + ox, num() + oy];
310
+ cur = [num() + ox, num() + oy];
311
+ b.cubic(c1, c2, cur);
312
+ lastCtrl = c2;
313
+ lastQ = null;
314
+ } else if (C === "Q" || C === "T") {
315
+ const q = C === "Q" ? [num() + ox, num() + oy] : lastQ ? [2 * cur[0] - lastQ[0], 2 * cur[1] - lastQ[1]] : cur;
316
+ const p = [num() + ox, num() + oy];
317
+ const c1 = [cur[0] + 2 / 3 * (q[0] - cur[0]), cur[1] + 2 / 3 * (q[1] - cur[1])];
318
+ const c2 = [p[0] + 2 / 3 * (q[0] - p[0]), p[1] + 2 / 3 * (q[1] - p[1])];
319
+ b.cubic(c1, c2, p);
320
+ cur = p;
321
+ lastQ = q;
322
+ lastCtrl = null;
323
+ } else if (C === "A") {
324
+ const rx = num();
325
+ const ry = num();
326
+ const rot = num();
327
+ const large = num();
328
+ const sweep = num();
329
+ const p = [num() + ox, num() + oy];
330
+ for (const [c1, c2, e] of arcToCubics(cur, rx, ry, rot, large, sweep, p)) b.cubic(c1, c2, e);
331
+ cur = p;
332
+ lastCtrl = lastQ = null;
333
+ } else {
334
+ throw new Error(`Unsupported path command ${cmd}`);
335
+ }
336
+ }
337
+ return b.contours;
338
+ }
339
+ function ellipse(cx, cy, rx, ry) {
340
+ return {
341
+ closed: true,
342
+ v: [[cx, cy - ry], [cx + rx, cy], [cx, cy + ry], [cx - rx, cy]],
343
+ i: [[-rx * K, 0], [0, -ry * K], [rx * K, 0], [0, ry * K]],
344
+ o: [[rx * K, 0], [0, ry * K], [-rx * K, 0], [0, -ry * K]]
345
+ };
346
+ }
347
+ var n = (v, d = 0) => v === void 0 ? d : Number(v);
348
+ function nodeToPathD(node) {
349
+ const a = node.attrs;
350
+ switch (node.tag) {
351
+ case "path":
352
+ return String(a.d);
353
+ case "line":
354
+ return `M${n(a.x1)} ${n(a.y1)}L${n(a.x2)} ${n(a.y2)}`;
355
+ case "polyline": {
356
+ const pts = String(a.points).trim().split(/[\s,]+/).map(Number);
357
+ let d = `M${pts[0]} ${pts[1]}`;
358
+ for (let i = 2; i < pts.length; i += 2) d += `L${pts[i]} ${pts[i + 1]}`;
359
+ return d;
360
+ }
361
+ case "circle": {
362
+ const cx = n(a.cx), cy = n(a.cy), r = n(a.r);
363
+ return `M${cx - r} ${cy}A${r} ${r} 0 1 0 ${cx + r} ${cy}A${r} ${r} 0 1 0 ${cx - r} ${cy}Z`;
364
+ }
365
+ case "ellipse": {
366
+ const cx = n(a.cx), cy = n(a.cy), rx = n(a.rx), ry = n(a.ry);
367
+ return `M${cx - rx} ${cy}A${rx} ${ry} 0 1 0 ${cx + rx} ${cy}A${rx} ${ry} 0 1 0 ${cx - rx} ${cy}Z`;
368
+ }
369
+ case "rect": {
370
+ const x = n(a.x), y = n(a.y), w = n(a.width), h = n(a.height);
371
+ const r = Math.min(n(a.rx, n(a.ry)), w / 2, h / 2);
372
+ if (!r) return `M${x} ${y}H${x + w}V${y + h}H${x}Z`;
373
+ return `M${x + r} ${y}H${x + w - r}A${r} ${r} 0 0 1 ${x + w} ${y + r}V${y + h - r}A${r} ${r} 0 0 1 ${x + w - r} ${y + h}H${x + r}A${r} ${r} 0 0 1 ${x} ${y + h - r}V${y + r}A${r} ${r} 0 0 1 ${x + r} ${y}Z`;
374
+ }
375
+ }
376
+ }
377
+ function nodeToContours(node) {
378
+ const a = node.attrs;
379
+ if (node.tag === "circle") return [ellipse(n(a.cx), n(a.cy), n(a.r), n(a.r))];
380
+ if (node.tag === "ellipse") return [ellipse(n(a.cx), n(a.cy), n(a.rx), n(a.ry))];
381
+ return parsePath(nodeToPathD(node));
382
+ }
383
+ function contoursBBox(cs) {
384
+ let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
385
+ for (const c of cs)
386
+ for (const [x, y] of c.v) {
387
+ x0 = Math.min(x0, x);
388
+ y0 = Math.min(y0, y);
389
+ x1 = Math.max(x1, x);
390
+ y1 = Math.max(y1, y);
391
+ }
392
+ return [x0, y0, x1, y1];
393
+ }
394
+
395
+ // ../core/src/validate.ts
396
+ var SVG_BYTE_BUDGET = 1200;
397
+ var ALLOWED_ATTRS = {
398
+ path: ["d"],
399
+ circle: ["cx", "cy", "r"],
400
+ ellipse: ["cx", "cy", "rx", "ry"],
401
+ rect: ["x", "y", "width", "height", "rx", "ry"],
402
+ line: ["x1", "y1", "x2", "y2"],
403
+ polyline: ["points"]
404
+ };
405
+ function validateIcon(def) {
406
+ const errs = [];
407
+ const p = (m) => errs.push(`${def.name}: ${m}`);
408
+ if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(def.name)) p("name must be kebab-case");
409
+ if (def.tags.length < 3) p("needs at least 3 search tags");
410
+ if (!def.nodes.length) p("no nodes");
411
+ const parts = new Set(def.nodes.map((n2) => n2.part).filter(Boolean));
412
+ parts.add("root");
413
+ for (const tr of def.motion.tracks) if (!parts.has(tr.target)) p(`motion targets unknown part "${tr.target}"`);
414
+ for (const n2 of def.nodes) {
415
+ if (n2.fill !== void 0 && n2.fill !== "duo" && n2.fill !== "none") p(`invalid fill hint "${String(n2.fill)}" (use "duo" or "none")`);
416
+ const allowed = ALLOWED_ATTRS[n2.tag];
417
+ if (!allowed) {
418
+ p(`unsupported tag ${n2.tag}`);
419
+ continue;
420
+ }
421
+ for (const k of Object.keys(n2.attrs)) if (!allowed.includes(k)) p(`attribute "${k}" not allowed on <${n2.tag}>`);
422
+ try {
423
+ const cs = nodeToContours(n2);
424
+ const [x0, y0, x1, y1] = contoursBBox(cs);
425
+ if (x0 < 0.5 || y0 < 0.5 || x1 > 23.5 || y1 > 23.5)
426
+ p(`<${n2.tag}> leaves the 24px grid (bbox ${[x0, y0, x1, y1].map((v) => v.toFixed(1))})`);
427
+ } catch (e) {
428
+ p(`<${n2.tag}> unparsable: ${e.message}`);
429
+ }
430
+ }
431
+ for (const m of validateMotion(def.motion)) p(m);
432
+ const bytes = new TextEncoder().encode(renderSvg(def)).length;
433
+ if (bytes > SVG_BYTE_BUDGET) p(`SVG is ${bytes}B, over the ${SVG_BYTE_BUDGET}B budget`);
434
+ return errs;
435
+ }
436
+
437
+ // src/zip.ts
438
+ import { inflateRawSync } from "zlib";
439
+ function readZip(buf) {
440
+ let eocd = -1;
441
+ for (let i = buf.length - 22; i >= Math.max(0, buf.length - 22 - 65535); i--) {
442
+ if (buf.readUInt32LE(i) === 101010256) {
443
+ eocd = i;
444
+ break;
445
+ }
446
+ }
447
+ if (eocd < 0) throw new Error("not a zip file");
448
+ const count = buf.readUInt16LE(eocd + 10);
449
+ let p = buf.readUInt32LE(eocd + 16);
450
+ const out2 = [];
451
+ for (let n2 = 0; n2 < count; n2++) {
452
+ if (buf.readUInt32LE(p) !== 33639248) throw new Error("corrupt zip directory");
453
+ const method = buf.readUInt16LE(p + 10);
454
+ const compSize = buf.readUInt32LE(p + 20);
455
+ const nameLen = buf.readUInt16LE(p + 28);
456
+ const extraLen = buf.readUInt16LE(p + 30);
457
+ const commentLen = buf.readUInt16LE(p + 32);
458
+ const localOffset = buf.readUInt32LE(p + 42);
459
+ const name = buf.toString("utf8", p + 46, p + 46 + nameLen);
460
+ p += 46 + nameLen + extraLen + commentLen;
461
+ if (name.endsWith("/")) continue;
462
+ if (buf.readUInt32LE(localOffset) !== 67324752) throw new Error("corrupt zip entry");
463
+ const start = localOffset + 30 + buf.readUInt16LE(localOffset + 26) + buf.readUInt16LE(localOffset + 28);
464
+ const raw = buf.subarray(start, start + compSize);
465
+ if (method === 0) out2.push({ path: name, data: Buffer.from(raw) });
466
+ else if (method === 8) out2.push({ path: name, data: inflateRawSync(raw) });
467
+ else throw new Error(`unsupported zip compression method ${method}`);
468
+ }
469
+ return out2;
470
+ }
471
+
472
+ // src/skill.ts
473
+ var SKILL_NAME = "popcons-icon-designer";
474
+ function skillFilesFromZip(zip) {
475
+ const files = readZip(zip).map((e) => {
476
+ const parts = e.path.split("/").filter(Boolean);
477
+ if (parts[0] === SKILL_NAME) parts.shift();
478
+ if (!parts.length || parts.some((p) => p === ".." || p === "." || p.includes("\\") || /^[a-zA-Z]:/.test(p))) throw new Error(`unsafe path in archive: ${e.path}`);
479
+ return { path: parts.join("/"), content: e.data.toString("utf8") };
480
+ });
481
+ if (!files.some((f) => f.path === "SKILL.md")) throw new Error("the archive does not contain SKILL.md");
482
+ return files;
483
+ }
484
+ async function writeSkillFiles(dest, files) {
485
+ const written = [];
486
+ for (const f of files) {
487
+ const abs = path.join(dest, ...f.path.split("/"));
488
+ await mkdir(path.dirname(abs), { recursive: true });
489
+ await writeFile(abs, f.content, "utf8");
490
+ written.push(abs);
491
+ }
492
+ return written;
493
+ }
494
+ var stripFrontmatter = (md) => md.replace(/^---\n[\s\S]*?\n---\n+/, "");
495
+ var descriptionOf = (md) => /^description:\s*(.+)$/m.exec(md)?.[1].trim() ?? "Design Popcons animated icons.";
496
+ function cursorRule(files) {
497
+ const skill = files.find((f) => f.path === "SKILL.md").content;
498
+ const refs = files.filter((f) => f.path !== "SKILL.md").sort((a, b) => a.path.localeCompare(b.path)).map((f) => `## ${f.path}
499
+
500
+ ${f.content.trim()}`);
501
+ const desc = descriptionOf(skill).replace(/"/g, "'");
502
+ return [`---`, `description: "${desc}"`, `globs:`, `alwaysApply: false`, `---`, ``, stripFrontmatter(skill).trim(), ``, `# References`, ``, ...refs, ``].join("\n");
503
+ }
504
+ function isObj(v) {
505
+ return typeof v === "object" && v !== null && !Array.isArray(v);
506
+ }
507
+ function shapeErrors(x) {
508
+ if (!isObj(x)) return ["the file must contain one icon object"];
509
+ const e = [];
510
+ if (typeof x.name !== "string") e.push("name must be a string");
511
+ if (typeof x.category !== "string") e.push("category must be a string");
512
+ if (!Array.isArray(x.tags) || x.tags.some((t) => typeof t !== "string")) e.push("tags must be an array of strings");
513
+ if (!Array.isArray(x.nodes)) e.push("nodes must be an array");
514
+ else x.nodes.forEach((n2, i) => isObj(n2) && typeof n2.tag === "string" && isObj(n2.attrs) ? void 0 : e.push(`nodes[${i}] needs tag and attrs`));
515
+ const m = x.motion;
516
+ if (!isObj(m) || typeof m.duration !== "number" || typeof m.easing !== "string" || !Array.isArray(m.tracks)) e.push("motion needs preset, duration (number), easing and tracks (array)");
517
+ else
518
+ m.tracks.forEach((t, i) => {
519
+ if (!isObj(t) || typeof t.target !== "string" || typeof t.property !== "string" || !Array.isArray(t.keyframes) || t.keyframes.some((k) => !isObj(k) || typeof k.t !== "number" || typeof k.v !== "number"))
520
+ e.push(`motion.tracks[${i}] needs target, property and keyframes [{ t, v }]`);
521
+ });
522
+ return e;
523
+ }
524
+ async function validateFile(file) {
525
+ let raw;
526
+ try {
527
+ raw = JSON.parse(await readFile(file, "utf8"));
528
+ } catch (e) {
529
+ const missing = e.code === "ENOENT";
530
+ return { valid: false, errors: [missing ? `file not found: ${file}` : `not valid JSON: ${e.message}`], bytes: 0, gzipBytes: 0 };
531
+ }
532
+ const input = isObj(raw) && isObj(raw.icon) && !("nodes" in raw) ? raw.icon : raw;
533
+ const shape = shapeErrors(input);
534
+ if (shape.length) return { valid: false, errors: shape, bytes: 0, gzipBytes: 0 };
535
+ const def = input;
536
+ let errors;
537
+ try {
538
+ errors = validateIcon(def);
539
+ } catch (e) {
540
+ errors = [`could not validate: ${e.message}`];
541
+ }
542
+ let bytes = 0;
543
+ let gzipBytes = 0;
544
+ try {
545
+ const svg = renderSvg(def);
546
+ bytes = Buffer.byteLength(svg);
547
+ gzipBytes = gzipSync(svg).length;
548
+ } catch {
549
+ }
550
+ return { valid: errors.length === 0, name: def.name, errors, bytes, gzipBytes };
551
+ }
552
+
553
+ // src/common.ts
554
+ import os from "os";
555
+ var CliError = class extends Error {
556
+ };
557
+ var BOOLEAN_FLAGS = /* @__PURE__ */ new Set(["sound", "overwrite", "json", "help", "h", "version", "v", "no-color", "yes"]);
558
+ function parseArgs(argv) {
559
+ const positional = [];
560
+ const flags = {};
561
+ for (let i = 0; i < argv.length; i++) {
562
+ const a = argv[i];
563
+ if (a.startsWith("--")) {
564
+ const eq = a.indexOf("=");
565
+ if (eq > 0) flags[a.slice(2, eq)] = a.slice(eq + 1);
566
+ else if (!BOOLEAN_FLAGS.has(a.slice(2)) && argv[i + 1] !== void 0 && !argv[i + 1].startsWith("--")) flags[a.slice(2)] = argv[++i];
567
+ else flags[a.slice(2)] = true;
568
+ } else positional.push(a);
569
+ }
570
+ return { positional, flags };
571
+ }
572
+ var pascal = (name) => name.split(/[^a-zA-Z0-9]+/).filter(Boolean).map((w) => w[0].toUpperCase() + w.slice(1)).join("");
573
+ var str = (v) => typeof v === "string" ? v : void 0;
574
+ async function hiddenPrompt(question, hidden = false) {
575
+ const { createInterface: createInterface2 } = await import("readline");
576
+ const rl = createInterface2({ input: process.stdin, output: process.stdout, terminal: true });
577
+ if (hidden) {
578
+ const w = rl;
579
+ w._writeToOutput = (s) => {
580
+ if (s.includes(question)) process.stdout.write(s);
581
+ };
582
+ }
583
+ return new Promise((resolve) => {
584
+ rl.question(question, (a) => {
585
+ rl.close();
586
+ if (hidden) process.stdout.write("\n");
587
+ resolve(a);
588
+ });
589
+ });
590
+ }
591
+ var defaultIO = () => ({
592
+ fetch: globalThis.fetch,
593
+ out: (s) => process.stdout.write(s + "\n"),
594
+ err: (s) => process.stderr.write(s + "\n"),
595
+ cwd: process.cwd(),
596
+ home: os.homedir(),
597
+ env: process.env,
598
+ color: Boolean(process.stdout.isTTY) && !process.env.NO_COLOR,
599
+ prompt: hiddenPrompt
600
+ });
601
+ var paint = (io) => {
602
+ const w = (code) => (s) => io.color ? `\x1B[${code}m${s}\x1B[0m` : s;
603
+ return { bold: w(1), dim: w(2), red: w(31), green: w(32), yellow: w(33), cyan: w(36) };
604
+ };
605
+ function table(io, head, rows) {
606
+ const c = paint(io);
607
+ const widths = head.map((h, i) => Math.max(h.length, ...rows.map((r) => (r[i] ?? "").length)));
608
+ const line = (r) => r.map((cell, i) => i === r.length - 1 ? cell : cell.padEnd(widths[i])).join(" ");
609
+ return [c.bold(line(head)), ...rows.map(line)].join("\n");
610
+ }
611
+ async function request(io, url, key, init = {}) {
612
+ const headers = { accept: "application/json", ...init.headers };
613
+ if (key) headers.authorization = `Bearer ${key}`;
614
+ try {
615
+ return await io.fetch(url, { ...init, headers });
616
+ } catch {
617
+ throw new CliError(`Could not reach ${new URL(url).origin}. Check your connection, or set --site / POPCONS_SITE.`);
618
+ }
619
+ }
620
+ async function errorMessage(res) {
621
+ const j = await res.json().catch(() => null);
622
+ return j?.error ?? `server returned ${res.status}`;
623
+ }
624
+
625
+ // src/config.ts
626
+ import { chmod, mkdir as mkdir2, readFile as readFile2, rm, writeFile as writeFile2 } from "fs/promises";
627
+ import path2 from "path";
628
+ var DEFAULT_SITE = "https://popcons.dev";
629
+ var PRICING_URL = "https://popcons.dev/pricing";
630
+ var NO_LICENSE = `No license found. Run \`npx popcons login\` (get one at ${PRICING_URL}) or set POPCONS_LICENSE_KEY.`;
631
+ var configDir = (io) => path2.join(io.home, ".config", "popcons");
632
+ var configPath = (io) => path2.join(configDir(io), "config.json");
633
+ async function readConfig(io) {
634
+ for (const f of [configPath(io), path2.join(io.home, ".popconsrc")]) {
635
+ try {
636
+ const j = JSON.parse(await readFile2(f, "utf8"));
637
+ if (j && typeof j === "object") return j;
638
+ } catch {
639
+ }
640
+ }
641
+ return {};
642
+ }
643
+ async function writeConfig(io, cfg) {
644
+ const dir = configDir(io);
645
+ await mkdir2(dir, { recursive: true, mode: 448 });
646
+ await chmod(dir, 448).catch(() => void 0);
647
+ const file = configPath(io);
648
+ await writeFile2(file, JSON.stringify(cfg, null, 2) + "\n", { mode: 384 });
649
+ await chmod(file, 384).catch(() => void 0);
650
+ return file;
651
+ }
652
+ async function removeConfig(io) {
653
+ let removed = false;
654
+ for (const f of [configPath(io), path2.join(io.home, ".popconsrc")]) {
655
+ try {
656
+ await readFile2(f);
657
+ await rm(f);
658
+ removed = true;
659
+ } catch {
660
+ }
661
+ }
662
+ return removed;
663
+ }
664
+ async function resolveKey(io) {
665
+ const env = io.env.POPCONS_LICENSE_KEY?.trim();
666
+ if (env) return { key: env, source: "env" };
667
+ const cfg = await readConfig(io);
668
+ return cfg.key ? { key: cfg.key, source: "config" } : {};
669
+ }
670
+ var maskKey = (k) => k.length <= 9 ? "****" : k.startsWith("pc_live_") ? `pc_live_****${k.slice(-4)}` : `${k.slice(0, 3)}-****-****-****-${k.slice(-4)}`;
671
+
672
+ // src/admin.ts
673
+ async function call(c, method, path4, body) {
674
+ const res = await request(c.io, `${c.site}${path4}`, c.key, {
675
+ method,
676
+ headers: body ? { "content-type": "application/json" } : {},
677
+ body: body ? JSON.stringify(body) : void 0
678
+ });
679
+ if (res.status === 401) throw new CliError("Not authenticated. Run `npx popcons login` to sign in again.");
680
+ if (res.status === 403) throw new CliError("Forbidden: this license key does not belong to an admin.");
681
+ if (!res.ok) {
682
+ const j = await res.json().catch(() => null);
683
+ throw new CliError(j?.error ?? `The server returned ${res.status}.`);
684
+ }
685
+ return await res.json().catch(() => ({}));
686
+ }
687
+ var date = (s) => s ? String(s).slice(0, 10) : "-";
688
+ var money = (cents) => `$${(cents / 100).toFixed(2)}`;
689
+ var out = (c, human, data) => c.io.out(c.flags.json ? JSON.stringify(data, null, 2) : human());
690
+ async function admin(c, args) {
691
+ const [sub, action, ...rest] = args;
692
+ const q = str(c.flags.q);
693
+ const qs = q ? `?q=${encodeURIComponent(q)}` : "";
694
+ if (sub === "stats") {
695
+ const s = await call(c, "GET", "/api/admin/stats");
696
+ out(
697
+ c,
698
+ () => table(c.io, ["metric", "value"], [
699
+ ["licenses", String(s.licenses.total)],
700
+ [" early bird", String(s.licenses.earlyBird)],
701
+ [" regular", String(s.licenses.regular)],
702
+ [" granted", String(s.licenses.granted)],
703
+ [" revoked", String(s.licenses.revoked)],
704
+ ["revenue", money(s.revenueCents)],
705
+ ["users", String(s.users)],
706
+ ["last 7 days: licenses", String(s.last7d.licenses)],
707
+ ["last 7 days: revenue", money(s.last7d.revenueCents)]
708
+ ]),
709
+ s
710
+ );
711
+ return 0;
712
+ }
713
+ if (sub === "licenses") {
714
+ if (action === "grant") {
715
+ const email = rest[0];
716
+ if (!email) throw new CliError("Usage: popcons admin licenses grant <email> [--note text]");
717
+ const r = await call(c, "POST", "/api/admin/licenses", { email, ...str(c.flags.note) ? { note: str(c.flags.note) } : {} });
718
+ out(c, () => `Granted a license to ${r.license.email} (${r.license.id}, ${r.license.keyMasked}).`, r);
719
+ return 0;
720
+ }
721
+ if (action === "revoke") {
722
+ if (!rest[0]) throw new CliError("Usage: popcons admin licenses revoke <licenseId>");
723
+ const r = await call(c, "POST", `/api/admin/licenses/${encodeURIComponent(rest[0])}/revoke`);
724
+ out(c, () => `Revoked license ${r.license?.id ?? rest[0]}.`, r);
725
+ return 0;
726
+ }
727
+ const s = action && action !== "list" ? void 0 : await call(c, "GET", `/api/admin/licenses${qs}`);
728
+ if (!s) throw new CliError("Usage: popcons admin licenses [--q email] | grant <email> [--note] | revoke <licenseId>");
729
+ out(c, () => s.licenses.length ? table(c.io, ["id", "key", "email", "source", "status", "created", "note"], s.licenses.map((l) => [l.id, l.keyMasked, l.email, l.source, l.status, date(l.created_at), l.note ?? ""])) : "No licenses found.", s);
730
+ return 0;
731
+ }
732
+ if (sub === "coupons") {
733
+ if (action === "create") {
734
+ const code = rest[0];
735
+ const percent = Number(str(c.flags.percent));
736
+ if (!code || !Number.isFinite(percent) || percent <= 0 || percent > 100) throw new CliError("Usage: popcons admin coupons create <CODE> --percent N [--max-uses N] [--expires YYYY-MM-DD]");
737
+ const body = { code: code.toUpperCase(), percent };
738
+ if (str(c.flags["max-uses"])) body.maxUses = Number(str(c.flags["max-uses"]));
739
+ const exp = str(c.flags.expires);
740
+ if (exp) {
741
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(exp)) throw new CliError("--expires must be YYYY-MM-DD.");
742
+ body.expiresAt = exp;
743
+ }
744
+ const r = await call(c, "POST", "/api/admin/coupons", body);
745
+ out(c, () => `Created coupon ${r.coupon.code} (${r.coupon.percent}% off, id ${r.coupon.id}).`, r);
746
+ return 0;
747
+ }
748
+ if (action === "delete") {
749
+ if (!rest[0]) throw new CliError("Usage: popcons admin coupons delete <id>");
750
+ const r = await call(c, "DELETE", `/api/admin/coupons/${encodeURIComponent(rest[0])}`);
751
+ out(c, () => `Deleted coupon ${rest[0]}.`, r);
752
+ return 0;
753
+ }
754
+ if (action && action !== "list") throw new CliError("Usage: popcons admin coupons | create <CODE> --percent N | delete <id>");
755
+ const s = await call(c, "GET", "/api/admin/coupons");
756
+ out(c, () => s.coupons.length ? table(c.io, ["id", "code", "percent", "used", "expires", "status"], s.coupons.map((x) => [x.id, x.code, `${x.percent}%`, `${x.used}/${x.maxUses ?? "inf"}`, date(x.expiresAt), x.status])) : "No coupons.", s);
757
+ return 0;
758
+ }
759
+ if (sub === "users") {
760
+ const s = await call(c, "GET", `/api/admin/users${qs}`);
761
+ out(c, () => s.users.length ? table(c.io, ["id", "email", "created", "licensed", "admin"], s.users.map((u) => [u.id, u.email, date(u.created_at), u.licensed ? "yes" : "no", u.isAdmin ? "yes" : ""])) : "No users found.", s);
762
+ return 0;
763
+ }
764
+ throw new CliError("Usage: popcons admin stats | licenses | coupons | users (run `popcons help`)");
765
+ }
766
+
767
+ // src/bridge.ts
768
+ import { createInterface } from "readline";
769
+ var DEFAULT_URL = "https://popcons.dev";
770
+ var endpoint = (env) => `${(env.POPCONS_URL || DEFAULT_URL).replace(/\/+$/, "")}/api/mcp`;
771
+ function parseBody(contentType, body) {
772
+ if (!body.trim()) return [];
773
+ if (contentType.includes("text/event-stream")) {
774
+ return body.split(/\n\n+/).map((ev) => ev.split("\n").filter((l) => l.startsWith("data:")).map((l) => l.slice(5).trim()).join("")).filter(Boolean).map((d) => JSON.parse(d));
775
+ }
776
+ const v = JSON.parse(body);
777
+ return Array.isArray(v) ? v : [v];
778
+ }
779
+ async function forward(line, io) {
780
+ let msg;
781
+ try {
782
+ msg = JSON.parse(line);
783
+ } catch {
784
+ return [{ jsonrpc: "2.0", id: null, error: { code: -32700, message: "Parse error" } }];
785
+ }
786
+ const headers = { "Content-Type": "application/json", Accept: "application/json, text/event-stream" };
787
+ if (io.env.POPCONS_API_KEY) headers.Authorization = `Bearer ${io.env.POPCONS_API_KEY}`;
788
+ try {
789
+ const res = await io.fetch(endpoint(io.env), { method: "POST", headers, body: line });
790
+ const text = await res.text();
791
+ if (!res.ok && !text.trim().startsWith("{")) {
792
+ return msg?.id === void 0 ? [] : [{ jsonrpc: "2.0", id: msg.id, error: { code: -32e3, message: `Popcons server returned ${res.status}` } }];
793
+ }
794
+ return parseBody(res.headers.get("content-type") ?? "", text);
795
+ } catch (e) {
796
+ return msg?.id === void 0 ? [] : [{ jsonrpc: "2.0", id: msg.id, error: { code: -32e3, message: `Could not reach Popcons: ${e instanceof Error ? e.message : "network error"}` } }];
797
+ }
798
+ }
799
+ async function runBridge(io) {
800
+ const rl = createInterface({ input: io.input });
801
+ const pending = [];
802
+ for await (const line of rl) {
803
+ if (!line.trim()) continue;
804
+ pending.push(
805
+ forward(line, io).then((out2) => {
806
+ for (const m of out2) io.output.write(`${JSON.stringify(m)}
807
+ `);
808
+ })
809
+ );
810
+ }
811
+ await Promise.all(pending);
812
+ }
813
+
814
+ // src/browser-login.ts
815
+ import { createHash, randomBytes } from "crypto";
816
+ import { spawn } from "child_process";
817
+ import { createServer } from "http";
818
+ async function browserLogin(io, site, opts = {}) {
819
+ const verifier = randomBytes(32).toString("base64url");
820
+ const challenge = createHash("sha256").update(verifier).digest("base64url");
821
+ const state = randomBytes(16).toString("base64url");
822
+ let resolveCode;
823
+ let rejectCode;
824
+ const gotCode = new Promise((res, rej) => (resolveCode = res, rejectCode = rej));
825
+ const page = (title, body) => `<!doctype html><meta charset="utf-8"><title>${title}</title><body style="font:16px system-ui;background:#F3F4EF;color:#1B1B22;display:grid;place-items:center;min-height:90vh"><div style="border:2px solid #1B1B22;background:#fff;padding:32px 40px;box-shadow:6px 6px 0 #1B1B22;max-width:440px"><h1 style="margin:0 0 8px;font-size:24px">${title}</h1><p style="margin:0">${body}</p></div>`;
826
+ const server = createServer((req, res) => {
827
+ const u = new URL(req.url ?? "/", "http://127.0.0.1");
828
+ if (u.pathname !== "/callback") {
829
+ res.writeHead(404).end();
830
+ return;
831
+ }
832
+ const err = u.searchParams.get("error");
833
+ const code = u.searchParams.get("code");
834
+ if (u.searchParams.get("state") !== state) {
835
+ res.writeHead(400, { "content-type": "text/html" }).end(page("Sign-in failed", "This request did not come from your terminal. Run popcons login again."));
836
+ return rejectCode(new CliError("Sign-in failed: state mismatch. Run `popcons login` again."));
837
+ }
838
+ if (err || !code) {
839
+ res.writeHead(200, { "content-type": "text/html" }).end(page("Sign-in cancelled", "You can close this tab."));
840
+ return rejectCode(new CliError(err === "access_denied" ? "Sign-in was cancelled." : `Sign-in failed (${err ?? "no code"}).`));
841
+ }
842
+ res.writeHead(200, { "content-type": "text/html" }).end(page("You are signed in", "Popcons is connected to your terminal. You can close this tab."));
843
+ resolveCode(code);
844
+ });
845
+ await new Promise((res) => server.listen(0, "127.0.0.1", () => res()));
846
+ const port = server.address().port;
847
+ const redirectUri = `http://127.0.0.1:${port}/callback`;
848
+ try {
849
+ const reg = await io.fetch(`${site}/api/oauth/register`, {
850
+ method: "POST",
851
+ headers: { "content-type": "application/json" },
852
+ body: JSON.stringify({ client_name: "Popcons CLI", redirect_uris: [redirectUri] })
853
+ });
854
+ if (!reg.ok) throw new CliError(`Could not start sign-in (server returned ${reg.status}).`);
855
+ const { client_id } = await reg.json();
856
+ const auth = new URL(`${site}/oauth/authorize`);
857
+ for (const [k, v] of Object.entries({ response_type: "code", client_id, redirect_uri: redirectUri, code_challenge: challenge, code_challenge_method: "S256", state, scope: "popcons" })) auth.searchParams.set(k, v);
858
+ io.out(`Opening your browser to sign in. If it does not open, visit:
859
+ ${auth}`);
860
+ (opts.open ?? openBrowser)(auth.toString());
861
+ const timer = setTimeout(() => rejectCode(new CliError("Sign-in timed out. Run `popcons login` again.")), opts.timeoutMs ?? 5 * 6e4);
862
+ const code = await gotCode.finally(() => clearTimeout(timer));
863
+ const tok = await io.fetch(`${site}/api/oauth/token`, {
864
+ method: "POST",
865
+ headers: { "content-type": "application/x-www-form-urlencoded" },
866
+ body: new URLSearchParams({ grant_type: "authorization_code", code, code_verifier: verifier, client_id, redirect_uri: redirectUri }).toString()
867
+ });
868
+ const j = await tok.json().catch(() => ({}));
869
+ if (!tok.ok || !j.access_token) throw new CliError(`Sign-in failed: ${j.error_description ?? `server returned ${tok.status}`}.`);
870
+ return j.access_token;
871
+ } finally {
872
+ server.close();
873
+ }
874
+ }
875
+ function openBrowser(url) {
876
+ const [cmd, args] = process.platform === "win32" ? ["cmd", ["/c", "start", "", url.replace(/&/g, "^&")]] : process.platform === "darwin" ? ["open", [url]] : ["xdg-open", [url]];
877
+ try {
878
+ spawn(cmd, args, { stdio: "ignore", detached: true }).on("error", () => void 0).unref();
879
+ } catch {
880
+ }
881
+ }
882
+
883
+ // src/cli.ts
884
+ var VERSION = "1.0.1";
885
+ var NAME_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/;
886
+ var checkName = (n2) => {
887
+ if (!NAME_RE.test(n2)) throw new CliError(`"${n2}" is not a valid name. Use kebab-case, for example "arrow-right". Run "popcons search <word>" to find icons.`);
888
+ return n2;
889
+ };
890
+ var siteOf = async (io, flags) => String(str(flags.site) ?? io.env.POPCONS_SITE ?? (await readConfig(io)).site ?? DEFAULT_SITE).replace(/\/+$/, "");
891
+ async function needKey(io) {
892
+ const { key } = await resolveKey(io);
893
+ if (!key) throw new CliError(NO_LICENSE);
894
+ return key;
895
+ }
896
+ async function exists(p) {
897
+ return stat(p).then(() => true, () => false);
898
+ }
899
+ async function writeOut(io, file, content, overwrite) {
900
+ const abs = path3.resolve(io.cwd, file);
901
+ const rel = path3.relative(io.cwd, abs);
902
+ if (rel.startsWith("..") || path3.isAbsolute(rel)) throw new CliError(`Refusing to write outside the project: ${file}`);
903
+ if (!overwrite && await exists(abs)) {
904
+ io.out(` skipped ${rel} (exists, use --overwrite)`);
905
+ return false;
906
+ }
907
+ await mkdir3(path3.dirname(abs), { recursive: true });
908
+ await writeFile3(abs, content, "utf8");
909
+ io.out(` wrote ${rel}`);
910
+ return true;
911
+ }
912
+ function denied(res, what) {
913
+ if (res.status === 401) throw new CliError(`Your Popcons sign-in was rejected for ${what}. Run "npx popcons login" to sign in again.`);
914
+ if (res.status === 403) throw new CliError(`${what} needs an active Popcons license. Get one at https://popcons.dev/pricing`);
915
+ if (res.status === 404) throw new CliError(`${what} was not found. Run "popcons search <word>" to see what is available.`);
916
+ }
917
+ async function readProject(io) {
918
+ try {
919
+ return JSON.parse(await readFile3(path3.join(io.cwd, "popcons.json"), "utf8"));
920
+ } catch {
921
+ return {};
922
+ }
923
+ }
924
+ async function detect(io) {
925
+ let pkg = {};
926
+ try {
927
+ pkg = JSON.parse(await readFile3(path3.join(io.cwd, "package.json"), "utf8"));
928
+ } catch {
929
+ }
930
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
931
+ const has = (n2) => n2 in deps;
932
+ const framework = has("next") ? "next" : has("nuxt") ? "nuxt" : has("@sveltejs/kit") || has("svelte") ? "svelte" : has("vue") ? "vue" : has("vite") ? "vite" : has("react") ? "react" : "unknown";
933
+ const format = framework === "vue" || framework === "nuxt" ? "vue" : framework === "svelte" ? "svelte" : has("react") ? "react" : "svg";
934
+ const typescript = has("typescript") || await exists(path3.join(io.cwd, "tsconfig.json"));
935
+ const tailwind = has("tailwindcss");
936
+ const src = await exists(path3.join(io.cwd, "src"));
937
+ return { framework, format, typescript, tailwind, src };
938
+ }
939
+ async function loadIndex(io, site) {
940
+ const res = await request(io, `${site}/r/index.json`);
941
+ if (!res.ok) throw new CliError(`Could not load the catalog (${await errorMessage(res)}).`);
942
+ const j = await res.json().catch(() => null);
943
+ if (!j?.items?.length) throw new CliError("The server returned an empty catalog.");
944
+ return j.items;
945
+ }
946
+ var isIcon = (i) => i.name.endsWith("-icon");
947
+ var iconName = (i) => i.name.replace(/-icon$/, "");
948
+ function printItems(io, flags, items) {
949
+ if (flags.json) return io.out(JSON.stringify(items.map((i) => ({ name: isIcon(i) ? iconName(i) : i.name, kind: isIcon(i) ? "icon" : "ui", category: i.category ?? null, title: i.title ?? null })), null, 2));
950
+ if (!items.length) return io.out("No matches.");
951
+ io.out(table(io, ["name", "kind", "category"], items.map((i) => [isIcon(i) ? iconName(i) : i.name, isIcon(i) ? "icon" : "ui", i.category ?? ""])));
952
+ io.out(`${items.length} item${items.length === 1 ? "" : "s"}`);
953
+ }
954
+ var FORMAT_EXT = { react: ".tsx", vue: ".vue", svelte: ".svelte", svg: ".svg", css: ".css", html: ".html" };
955
+ async function addIcons(io, site, key, names, flags) {
956
+ const project = await readProject(io);
957
+ const format = str(flags.format) ?? project.format ?? "react";
958
+ if (!(format in FORMAT_EXT)) throw new CliError(`--format must be one of ${Object.keys(FORMAT_EXT).join(", ")}.`);
959
+ const variant = str(flags.variant);
960
+ if (variant && !["outline", "duotone"].includes(variant)) throw new CliError('--variant must be "outline" or "duotone".');
961
+ const corner = str(flags.corner);
962
+ if (corner && !["round", "sharp"].includes(corner)) throw new CliError('--corner must be "round" or "sharp".');
963
+ const dir = str(flags.dir) ?? project.dir ?? "components/popcons";
964
+ const overwrite = Boolean(flags.overwrite);
965
+ const style = {};
966
+ for (const [flag, k] of [["color", "color"], ["stroke", "strokeWidth"], ["corner", "corner"], ["speed", "speed"], ["intensity", "intensity"], ["variant", "variant"], ["secondary", "secondary"]]) {
967
+ const v = str(flags[flag]);
968
+ if (v !== void 0) style[k] = v;
969
+ }
970
+ const serverFormat = format === "html" ? "css" : format;
971
+ for (const name of names.map(checkName)) {
972
+ io.out(`Adding ${name}`);
973
+ const body = { icon: name, format: serverFormat, ...Object.keys(style).length ? { style } : {} };
974
+ if (flags.sound) body.sound = true;
975
+ const trigger = str(flags.trigger);
976
+ if (trigger) body.trigger = trigger;
977
+ const res = await request(io, `${site}/api/export`, key, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) });
978
+ denied(res, `icon "${name}"`);
979
+ if (res.status === 400) throw new CliError(`The server rejected the request for "${name}": ${await errorMessage(res)}`);
980
+ if (!res.ok) throw new CliError(`The server returned ${res.status} for icon "${name}". Try again shortly.`);
981
+ const j = await res.json().catch(() => null);
982
+ if (!j || typeof j.content !== "string") throw new CliError(`The server returned an unexpected response for "${name}".`);
983
+ const content = j.encoding === "base64" ? Buffer.from(j.content, "base64").toString("utf8") : j.content;
984
+ if (format === "html") {
985
+ const m = /\/\* ---- HTML ----\n([\s\S]*?)\n\*\//.exec(content);
986
+ const css = content.slice(0, content.indexOf("/* ---- HTML ----")).trimEnd() + "\n";
987
+ await writeOut(io, path3.join(dir, `${name}.css`), css, overwrite);
988
+ await writeOut(io, path3.join(dir, `${name}.html`), (m?.[1] ?? "").replace(/\* \//g, "*/") + "\n", overwrite);
989
+ } else {
990
+ const filename = j.filename && !/[\\/]/.test(j.filename) ? j.filename : `${pascal(name)}${FORMAT_EXT[format]}`;
991
+ await writeOut(io, path3.join(dir, filename), content, overwrite);
992
+ }
993
+ }
994
+ if (format === "react") io.out(`Import: import { ${pascal(names[0])} } from "<alias>/${path3.posix.join(dir.replace(/\\/g, "/"), pascal(names[0]))}" (peer dependency: react)`);
995
+ }
996
+ async function fetchReg(io, site, key, name, what) {
997
+ const res = await request(io, `${site}/r/ui/${name}.json`, key);
998
+ denied(res, what);
999
+ if (!res.ok) throw new CliError(`The server returned ${res.status} for ${what}. Try again shortly.`);
1000
+ const j = await res.json().catch(() => null);
1001
+ if (!j) throw new CliError(`The server returned an unexpected response for ${what}.`);
1002
+ return j;
1003
+ }
1004
+ async function installUi(io, site, key, names, flags) {
1005
+ const project = await readProject(io);
1006
+ const root = str(flags.root) ?? str(flags.dir) ?? project.uiRoot ?? (await exists(path3.join(io.cwd, "src")) ? "src" : ".");
1007
+ const overwrite = Boolean(flags.overwrite);
1008
+ const seen = /* @__PURE__ */ new Set();
1009
+ const queue = [...names];
1010
+ const npm = /* @__PURE__ */ new Set();
1011
+ while (queue.length) {
1012
+ const name = checkName(queue.shift());
1013
+ if (seen.has(name)) continue;
1014
+ seen.add(name);
1015
+ io.out(`Adding ${name}`);
1016
+ const item = await fetchReg(io, site, key, name, `component "${name}"`);
1017
+ if (!item.files?.length) throw new CliError(`Component "${name}" returned no files.`);
1018
+ for (const f of item.files) {
1019
+ if (typeof f.content !== "string" || !f.path) continue;
1020
+ await writeOut(io, path3.join(root, f.path), f.content, overwrite);
1021
+ }
1022
+ for (const d of item.dependencies ?? []) npm.add(d);
1023
+ for (const d of item.registryDependencies ?? []) if (/^[a-z0-9-]+$/.test(d)) queue.push(d);
1024
+ }
1025
+ if (npm.size) io.out(`
1026
+ Install dependencies:
1027
+ npm install ${[...npm].join(" ")}`);
1028
+ }
1029
+ async function packAdd(io, site, key, id, flags) {
1030
+ checkName(id);
1031
+ const item = await fetchReg(io, site, key, `pack-${id}`, `pack "${id}"`);
1032
+ const deps = (item.registryDependencies ?? []).filter((d) => typeof d === "string");
1033
+ if (!deps.length) throw new CliError(`Pack "${id}" returned no components.`);
1034
+ io.out(`Pack ${id}: ${deps.length} components`);
1035
+ await installUi(io, site, key, deps, flags);
1036
+ if (item.dependencies?.length) io.out(` npm install ${item.dependencies.join(" ")}`);
1037
+ }
1038
+ var HELP = `popcons - animated icons and components (license required)
1039
+
1040
+ Usage: npx popcons <command>
1041
+
1042
+ Account
1043
+ login Sign in through your browser (or: login <key>, login --paste)
1044
+ logout Remove the saved key
1045
+ whoami Show the active key and license status
1046
+ Project
1047
+ init Write popcons.json (detects framework, TypeScript, Tailwind)
1048
+ Catalog
1049
+ search <words> [--category c] [--json] Search icons and components
1050
+ categories [--json] List icon categories
1051
+ list [--json] List everything
1052
+ Install (files are copied into your project as source)
1053
+ add <icon...> Add icons from the licensed export API
1054
+ --format react|vue|svelte|svg|css|html (default react)
1055
+ --dir components/popcons --variant outline|duotone --sound --overwrite
1056
+ --color --stroke --corner round|sharp --speed --intensity --trigger
1057
+ ui add <component...> Add UI components (--root src, --overwrite)
1058
+ pack add <pack-id> Add every component of a style pack
1059
+ Agents
1060
+ skill install [--target claude|cursor|dir] [--dir path] Install the icon designer skill
1061
+ mcp Run the stdio MCP bridge (npx popcons mcp)
1062
+ validate <file.json> Validate an icon definition offline
1063
+ Admin (admin license keys only)
1064
+ admin stats | licenses [--q email] | licenses grant <email> [--note t] | licenses revoke <id>
1065
+ admin coupons | coupons create <CODE> --percent N [--max-uses N] [--expires YYYY-MM-DD] | coupons delete <id>
1066
+ admin users [--q text]
1067
+
1068
+ Global options
1069
+ --site <url> API origin (default $POPCONS_SITE or ${DEFAULT_SITE})
1070
+ --json Machine-readable output on list-like commands
1071
+
1072
+ Env: POPCONS_LICENSE_KEY overrides the saved key (CI). NO_COLOR disables colors.
1073
+ `;
1074
+ async function run(argv, io = defaultIO()) {
1075
+ try {
1076
+ const { positional, flags } = parseArgs(argv);
1077
+ if (flags["no-color"]) io = { ...io, color: false };
1078
+ const [cmd, ...rest] = positional;
1079
+ if (flags.version || flags.v) {
1080
+ io.out(VERSION);
1081
+ return 0;
1082
+ }
1083
+ if (!cmd || cmd === "help" || flags.help || flags.h) {
1084
+ io.out(HELP);
1085
+ return cmd || flags.help || flags.h ? 0 : 1;
1086
+ }
1087
+ const site = await siteOf(io, flags);
1088
+ const c = paint(io);
1089
+ if (cmd === "login") {
1090
+ let key = (rest[0] ?? "").trim();
1091
+ if (!key && flags.paste) key = (await io.prompt("License key: ", true)).trim();
1092
+ if (!key) {
1093
+ key = await (io.browserLogin ?? ((s) => browserLogin(io, s)))(site);
1094
+ }
1095
+ if (!key.startsWith("pc_live_")) key = key.toUpperCase();
1096
+ const res = await request(io, `${site}/api/license/verify`, void 0, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ key }) });
1097
+ if (!res.ok) throw new CliError(`Could not verify the key (server returned ${res.status}).`);
1098
+ const j = await res.json().catch(() => ({}));
1099
+ if (!j.valid) throw new CliError(`That key is not valid, or the account has no license. Run \`popcons login\` to sign in, or get a license at https://popcons.dev/pricing`);
1100
+ const cfg = await readConfig(io);
1101
+ const file = await writeConfig(io, { ...cfg, key, ...site !== DEFAULT_SITE ? { site } : {} });
1102
+ io.out(`${c.green("Logged in")}${j.email ? ` as ${j.email}` : ""}. Saved to ${file}`);
1103
+ return 0;
1104
+ }
1105
+ if (cmd === "logout") {
1106
+ const removed = await removeConfig(io);
1107
+ io.out(removed ? "Logged out. Saved key removed." : "No saved key found.");
1108
+ if (io.env.POPCONS_LICENSE_KEY) io.out("Note: POPCONS_LICENSE_KEY is still set in your environment.");
1109
+ return 0;
1110
+ }
1111
+ if (cmd === "whoami") {
1112
+ const { key, source } = await resolveKey(io);
1113
+ if (!key) throw new CliError(NO_LICENSE);
1114
+ const res = await request(io, `${site}/api/license/verify`, void 0, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ key: key.startsWith("pc_live_") ? key : key.toUpperCase() }) });
1115
+ if (!res.ok) throw new CliError(`Could not verify the key (server returned ${res.status}).`);
1116
+ const j = await res.json().catch(() => ({}));
1117
+ const info = { key: maskKey(key), source: source === "env" ? "POPCONS_LICENSE_KEY" : configPath(io), status: j.valid ? "active" : "invalid", email: j.email ?? null, site };
1118
+ if (flags.json) io.out(JSON.stringify(info, null, 2));
1119
+ else io.out([`Key: ${info.key} (${info.source})`, `License: ${j.valid ? c.green("active") : c.red("invalid")}`, `Email: ${info.email ?? "-"}`, `Site: ${site}`].join("\n"));
1120
+ return j.valid ? 0 : 1;
1121
+ }
1122
+ if (cmd === "init") {
1123
+ const d = await detect(io);
1124
+ const file = path3.join(io.cwd, "popcons.json");
1125
+ if (await exists(file) && !flags.overwrite) throw new CliError("popcons.json already exists. Use --overwrite to replace it.");
1126
+ const cfg = { $schema: "https://popcons.dev/popcons.schema.json", dir: d.src ? "src/components/popcons" : "components/popcons", format: d.format, uiRoot: d.src ? "src" : "." };
1127
+ await writeFile3(file, JSON.stringify(cfg, null, 2) + "\n", "utf8");
1128
+ io.out(`Detected: framework ${d.framework}, TypeScript ${d.typescript ? "yes" : "no"}, Tailwind ${d.tailwind ? "yes" : "no"}`);
1129
+ io.out(`Wrote popcons.json (dir ${cfg.dir}, format ${cfg.format})`);
1130
+ if (!d.tailwind) io.out("Note: UI components use Tailwind. Install it before `popcons ui add`.");
1131
+ return 0;
1132
+ }
1133
+ if (cmd === "list" || cmd === "categories" || cmd === "search") {
1134
+ let items = await loadIndex(io, site);
1135
+ if (cmd === "categories") {
1136
+ const counts = /* @__PURE__ */ new Map();
1137
+ for (const i of items.filter(isIcon)) counts.set(i.category ?? "uncategorized", (counts.get(i.category ?? "uncategorized") ?? 0) + 1);
1138
+ const rows = [...counts].sort((a, b) => a[0].localeCompare(b[0]));
1139
+ if (flags.json) io.out(JSON.stringify(rows.map(([name, count]) => ({ name, count })), null, 2));
1140
+ else io.out(table(io, ["category", "icons"], rows.map(([n2, k]) => [n2, String(k)])));
1141
+ return 0;
1142
+ }
1143
+ if (cmd === "search") {
1144
+ const words = rest.map((w) => w.toLowerCase());
1145
+ const cat = str(flags.category)?.toLowerCase();
1146
+ if (!words.length && !cat) throw new CliError("Usage: popcons search <words> [--category name] [--json]");
1147
+ items = items.filter((i) => {
1148
+ const hay = `${i.name} ${i.title ?? ""} ${i.category ?? ""} ${i.description ?? ""}`.toLowerCase();
1149
+ return words.every((w) => hay.includes(w)) && (!cat || (i.category ?? "").toLowerCase() === cat);
1150
+ });
1151
+ }
1152
+ printItems(io, flags, items);
1153
+ return 0;
1154
+ }
1155
+ if (cmd === "add") {
1156
+ if (!rest.length) throw new CliError("Usage: popcons add <icon...> [--format react] [--dir components/popcons]");
1157
+ await addIcons(io, site, await needKey(io), rest, flags);
1158
+ return 0;
1159
+ }
1160
+ if (cmd === "ui") {
1161
+ const pack = str(flags.pack);
1162
+ if (rest[0] !== "add" || rest.length < 2 && !pack) throw new CliError("Usage: popcons ui add <component...> (whole packs: popcons pack add <id>)");
1163
+ const key = await needKey(io);
1164
+ if (pack) await packAdd(io, site, key, pack, flags);
1165
+ if (rest.length > 1) await installUi(io, site, key, rest.slice(1), flags);
1166
+ return 0;
1167
+ }
1168
+ if (cmd === "pack") {
1169
+ if (rest[0] !== "add" || !rest[1]) throw new CliError("Usage: popcons pack add <pack-id> [--root src] [--overwrite]");
1170
+ await packAdd(io, site, await needKey(io), rest[1], flags);
1171
+ return 0;
1172
+ }
1173
+ if (cmd === "admin") {
1174
+ return await admin({ io, site, key: await needKey(io), flags }, rest);
1175
+ }
1176
+ if (cmd === "mcp") {
1177
+ const { key } = await resolveKey(io);
1178
+ const env = { ...io.env, POPCONS_URL: io.env.POPCONS_URL ?? site, ...key ? { POPCONS_API_KEY: io.env.POPCONS_API_KEY ?? key } : {} };
1179
+ await runBridge({ input: process.stdin, output: process.stdout, env, fetch: io.fetch });
1180
+ return 0;
1181
+ }
1182
+ if (cmd === "skill") {
1183
+ if (rest[0] !== "install") throw new CliError("Usage: popcons skill install [--target claude|cursor|dir] [--dir path]");
1184
+ const key = await needKey(io);
1185
+ const dirFlag = str(flags.dir);
1186
+ const target = str(flags.target) ?? (dirFlag ? "dir" : "claude");
1187
+ if (!["claude", "cursor", "dir"].includes(target)) throw new CliError('--target must be "claude", "cursor" or "dir".');
1188
+ if (target === "dir" && !dirFlag) throw new CliError("--target dir needs --dir <path>.");
1189
+ const res = await request(io, `${site}/api/skill`, key, { headers: { accept: "application/zip" } });
1190
+ denied(res, "the skill download");
1191
+ if (!res.ok) throw new CliError(`The server returned ${res.status} for the skill download. Try again shortly.`);
1192
+ let files;
1193
+ try {
1194
+ files = skillFilesFromZip(Buffer.from(await res.arrayBuffer()));
1195
+ } catch (e) {
1196
+ throw new CliError(`The skill download could not be read: ${e instanceof Error ? e.message : "bad archive"}`);
1197
+ }
1198
+ if (target === "cursor") {
1199
+ const root = path3.resolve(io.cwd, dirFlag ?? ".");
1200
+ const file = path3.join(root, ".cursor", "rules", `${SKILL_NAME}.mdc`);
1201
+ await mkdir3(path3.dirname(file), { recursive: true });
1202
+ await writeFile3(file, cursorRule(files), "utf8");
1203
+ io.out(`Installed the Cursor rule at ${file}`);
1204
+ } else {
1205
+ const dest = target === "dir" ? path3.resolve(io.cwd, dirFlag) : path3.join(dirFlag ? path3.resolve(io.cwd, dirFlag) : path3.join(io.home, ".claude", "skills"), SKILL_NAME);
1206
+ const written = await writeSkillFiles(dest, files);
1207
+ for (const w of written) io.out(` wrote ${path3.relative(io.cwd, w) || w}`);
1208
+ io.out(`Installed ${files.length} files to ${dest}`);
1209
+ }
1210
+ io.out(`Next: connect your editor to the Popcons MCP server (${site}/mcp) so your assistant can call validate_icon and export_icon, then ask it to design an icon.`);
1211
+ return 0;
1212
+ }
1213
+ if (cmd === "validate") {
1214
+ if (!rest[0]) throw new CliError("Usage: popcons validate <file.json>");
1215
+ const r = await validateFile(path3.resolve(io.cwd, rest[0]));
1216
+ if (!r.valid) {
1217
+ io.err(`${rest[0]} is not valid${r.name ? ` (${r.name})` : ""}:`);
1218
+ for (const e of r.errors) io.err(` - ${e}`);
1219
+ return 1;
1220
+ }
1221
+ io.out(`${r.name} is valid. ${r.bytes} bytes (${r.gzipBytes} gzipped), budget ${SVG_BYTE_BUDGET}.`);
1222
+ return 0;
1223
+ }
1224
+ throw new CliError(`Unknown command "${cmd}". Run "popcons help".`);
1225
+ } catch (e) {
1226
+ io.err(`error: ${e instanceof Error ? e.message : "unexpected failure"}`);
1227
+ return 1;
1228
+ }
1229
+ }
1230
+
1231
+ // src/index.ts
1232
+ run(process.argv.slice(2)).then((code) => {
1233
+ process.exitCode = code;
1234
+ });
package/package.json CHANGED
@@ -1,6 +1,45 @@
1
1
  {
2
2
  "name": "popcons",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.1",
4
+ "private": false,
5
+ "license": "SEE LICENSE IN LICENSE",
6
+ "description": "Popcons CLI: license-gated install of 800+ animated icons and 29 animated React + Tailwind component packs, copied into your project as source.",
7
+ "keywords": [
8
+ "animated-icons",
9
+ "react",
10
+ "tailwind",
11
+ "mcp",
12
+ "agent",
13
+ "cli"
14
+ ],
15
+ "homepage": "https://popcons.dev",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/popcons/popcons.git",
19
+ "directory": "packages/cli"
20
+ },
21
+ "type": "module",
22
+ "bin": {
23
+ "popcons": "dist/index.js"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "README.md"
28
+ ],
29
+ "engines": {
30
+ "node": ">=18.17"
31
+ },
32
+ "scripts": {
33
+ "build": "tsup",
34
+ "test": "vitest run",
35
+ "typecheck": "tsc --noEmit"
36
+ },
37
+ "devDependencies": {
38
+ "@popcons/core": "workspace:*",
39
+ "@types/node": "^20",
40
+ "@types/react": "^19",
41
+ "tsup": "^8.3.5",
42
+ "typescript": "^5",
43
+ "vitest": "^2.1.9"
44
+ }
45
+ }