asta-ui 0.6.0 → 0.7.0

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/README.md CHANGED
@@ -30,6 +30,17 @@ Works with `npx`, `bunx` and `yarn dlx` too. Under the hood it calls the [shadcn
30
30
 
31
31
  Set `ASTA_UI_URL` to point at another registry host (e.g. a local dev server).
32
32
 
33
+ ## Agent skills
34
+
35
+ ```sh
36
+ npx asta-ui@latest skills install # astabyte-ui, astabyte-design, astabyte-skills-update → ~/.claude/skills
37
+ npx asta-ui@latest skills update # update copies that changed (checks ~/.claude, ./.claude and .agents)
38
+ npx asta-ui@latest skills status
39
+ npx asta-ui@latest skills auto # Claude Code SessionStart hook, once a day; --off removes it
40
+ ```
41
+
42
+ MCP server: `https://ui.astabyte.com/mcp` (Streamable HTTP, no key).
43
+
33
44
  ## Import it (library)
34
45
 
35
46
  ```sh
package/bin/asta-ui.mjs CHANGED
@@ -2,8 +2,10 @@
2
2
  // Astabyte UI CLI: a thin layer over the shadcn CLI that knows our registry.
3
3
  // No dependencies on purpose, so `npx asta-ui@latest` starts instantly.
4
4
  import { spawn } from "node:child_process";
5
- import { existsSync, readFileSync, writeFileSync } from "node:fs";
6
- import { join } from "node:path";
5
+ import { createHash } from "node:crypto";
6
+ import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
7
+ import { homedir } from "node:os";
8
+ import { dirname, join, resolve } from "node:path";
7
9
  import { createRequire } from "node:module";
8
10
 
9
11
  const { version } = createRequire(import.meta.url)("../package.json");
@@ -21,10 +23,15 @@ ${bold("Usage")}
21
23
  npx asta-ui@latest add <component...> [flags] add components (e.g. add dialog select)
22
24
  npx asta-ui@latest list [search] list components and variants
23
25
  npx asta-ui@latest prompt <component> print a prompt for your AI coding agent
26
+ npx asta-ui@latest skills install [name...] install the agent skills (~/.claude/skills)
27
+ npx asta-ui@latest skills update update installed agent skills that changed
28
+ npx asta-ui@latest skills status show installed agent skills and if they're current
29
+ npx asta-ui@latest skills auto [--off] update the skills at the start of each Claude Code session
24
30
 
25
31
  ${bold("Flags")}
26
32
  --radix | --base primitive library (default: what init chose, else Radix)
27
33
  any other flag is passed to shadcn (e.g. -y, -o, -p src/components)
34
+ skills: --project (./.claude), --dir <path>, --auto, --quiet, --daily
28
35
 
29
36
  ${bold("Docs")} ${SITE}
30
37
  `;
@@ -182,6 +189,175 @@ Use it to: [describe where it goes and what it should do]`);
182
189
  return 0;
183
190
  }
184
191
 
192
+
193
+ /* Agent skills: install and keep them in step with ui.astabyte.com/skills.json. */
194
+
195
+ const sha = (s) => createHash("sha256").update(s).digest("hex").slice(0, 16);
196
+ const STAMP = join(homedir(), ".cache", "asta-ui", "skills-checked");
197
+ const HOOK_MARK = "asta-ui@latest skills update";
198
+ const skillDirs = () => [
199
+ ...new Set([join(homedir(), ".claude", "skills"), resolve(".claude", "skills"), join(homedir(), ".agents", "skills"), resolve(".agents", "skills")]),
200
+ ];
201
+ const pretty = (p) => p.replace(homedir(), "~");
202
+
203
+ async function getText(url) {
204
+ const res = await fetch(url, { signal: AbortSignal.timeout(15000) });
205
+ if (!res.ok) throw new Error(`${url} returned ${res.status}`);
206
+ return res.text();
207
+ }
208
+ const manifest = async () => JSON.parse(await getText(`${SITE}/skills.json`));
209
+
210
+ const readOr = (p) => {
211
+ try {
212
+ return readFileSync(p, "utf8");
213
+ } catch {
214
+ return null;
215
+ }
216
+ };
217
+ // Same hash as the site: every file of the skill, in manifest order. A missing file never matches.
218
+ function localHash(dir, skill) {
219
+ const parts = [];
220
+ for (const f of skill.files) {
221
+ const c = readOr(join(dir, skill.name, f.path));
222
+ if (c === null) return null;
223
+ parts.push(`${f.path}\n${c}`);
224
+ }
225
+ return sha(parts.join("\n\0\n"));
226
+ }
227
+
228
+ async function writeSkill(dir, skill) {
229
+ for (const f of skill.files) {
230
+ const target = join(dir, skill.name, f.path);
231
+ mkdirSync(dirname(target), { recursive: true });
232
+ writeFileSync(target, await getText(`${SITE}/skills/${skill.name}/${f.path}`));
233
+ }
234
+ }
235
+
236
+ function pick(m, names) {
237
+ const unknown = names.filter((n) => !m.skills.some((s) => s.name === n));
238
+ if (unknown.length) throw new Error(`Unknown skill ${unknown.join(", ")}. Available: ${m.skills.map((s) => s.name).join(", ")}`);
239
+ return names.length ? m.skills.filter((s) => names.includes(s.name)) : m.skills;
240
+ }
241
+
242
+ function touchStamp() {
243
+ try {
244
+ mkdirSync(dirname(STAMP), { recursive: true });
245
+ writeFileSync(STAMP, new Date().toISOString() + "\n");
246
+ } catch {}
247
+ }
248
+
249
+ async function skillsUpdate(names, opts) {
250
+ if (opts.daily) {
251
+ try {
252
+ if (Date.now() - statSync(STAMP).mtimeMs < 24 * 3600 * 1000) return 0;
253
+ } catch {}
254
+ }
255
+ let m;
256
+ try {
257
+ m = await manifest();
258
+ } catch (e) {
259
+ if (opts.quiet) return 0; // offline: keep the skills we have, say nothing
260
+ throw e;
261
+ }
262
+ const wanted = pick(m, names);
263
+ let found = 0;
264
+ const updated = [];
265
+ for (const dir of skillDirs()) {
266
+ for (const s of wanted) {
267
+ if (!existsSync(join(dir, s.name, "SKILL.md"))) continue;
268
+ found++;
269
+ if (localHash(dir, s) === s.hash) continue;
270
+ await writeSkill(dir, s);
271
+ updated.push(`${s.name} in ${pretty(dir)}`);
272
+ }
273
+ }
274
+ touchStamp();
275
+ if (updated.length) console.log(`${green("✓")} Updated Astabyte skills to v${m.version}: ${updated.join(", ")}. Re-read any of them you are using.`);
276
+ else if (!opts.quiet) console.log(found ? `${green("✓")} Astabyte skills are current (v${m.version}).` : `No Astabyte skills installed. Install them with ${blue("npx asta-ui@latest skills install")}`);
277
+ return 0;
278
+ }
279
+
280
+ async function skillsInstall(names, opts) {
281
+ const m = await manifest();
282
+ const dir = opts.dir ? resolve(opts.dir.replace(/^~(?=$|\/)/, homedir())) : opts.project ? resolve(".claude", "skills") : join(homedir(), ".claude", "skills");
283
+ for (const s of pick(m, names)) {
284
+ await writeSkill(dir, s);
285
+ console.log(`${green("✓")} ${bold(s.name)} → ${pretty(join(dir, s.name))}`);
286
+ }
287
+ touchStamp();
288
+ if (opts.auto) return skillsAuto(opts);
289
+ console.log(dim(`Keep them current: npx asta-ui@latest skills update · or every session: npx asta-ui@latest skills auto`));
290
+ return 0;
291
+ }
292
+
293
+ async function skillsStatus() {
294
+ const m = await manifest();
295
+ let any = false;
296
+ for (const dir of skillDirs()) {
297
+ for (const s of m.skills) {
298
+ if (!existsSync(join(dir, s.name, "SKILL.md"))) continue;
299
+ any = true;
300
+ const ok = localHash(dir, s) === s.hash;
301
+ console.log(`${ok ? green("current") : red("outdated")} ${s.name.padEnd(24)} ${dim(pretty(dir))}`);
302
+ }
303
+ }
304
+ if (!any) console.log(`No Astabyte skills installed. Install them with ${blue("npx asta-ui@latest skills install")}`);
305
+ const hooked = (readOr(join(homedir(), ".claude", "settings.json")) ?? "").includes(HOOK_MARK) || (readOr(resolve(".claude", "settings.json")) ?? "").includes(HOOK_MARK);
306
+ console.log(dim(`\nLatest v${m.version} · auto-update ${hooked ? "on" : "off"} · ${SITE}/skills.json`));
307
+ return 0;
308
+ }
309
+
310
+ // One SessionStart hook in Claude Code settings. On macOS/Linux a find test skips npx entirely when the last
311
+ // check is under a day old, so most sessions start without touching the network.
312
+ function skillsAuto(opts) {
313
+ const file = opts.project ? resolve(".claude", "settings.json") : join(homedir(), ".claude", "settings.json");
314
+ const raw = readOr(file);
315
+ if (opts.off && (raw === null || !raw.includes(HOOK_MARK))) {
316
+ console.log(`Auto-update is already off (${pretty(file)})`);
317
+ return 0;
318
+ }
319
+ let cfg = {};
320
+ if (raw) {
321
+ try {
322
+ cfg = JSON.parse(raw);
323
+ } catch {
324
+ console.error(red(`${pretty(file)} is not valid JSON; not touching it.`));
325
+ return 1;
326
+ }
327
+ }
328
+ const starts = (cfg.hooks?.SessionStart ?? []).filter((g) => !JSON.stringify(g).includes(HOOK_MARK));
329
+ if (!opts.off) {
330
+ const cmd = `npx -y ${HOOK_MARK} --quiet --daily`;
331
+ const command = process.platform === "win32" ? cmd : `test -n "$(find "$HOME/.cache/asta-ui/skills-checked" -mmin -1440 2>/dev/null)" || ${cmd}`;
332
+ starts.push({ hooks: [{ type: "command", command, timeout: 60 }] });
333
+ }
334
+ cfg.hooks = { ...(cfg.hooks ?? {}), SessionStart: starts };
335
+ if (!cfg.hooks.SessionStart.length) delete cfg.hooks.SessionStart;
336
+ if (!Object.keys(cfg.hooks).length) delete cfg.hooks;
337
+ mkdirSync(dirname(file), { recursive: true });
338
+ writeFileSync(file, JSON.stringify(cfg, null, 2) + "\n");
339
+ console.log(opts.off ? `${green("✓")} Auto-update off (${pretty(file)})` : `${green("✓")} Auto-update on: Claude Code checks the Astabyte skills once a day at session start (${pretty(file)})`);
340
+ return 0;
341
+ }
342
+
343
+ function skills(args) {
344
+ const [sub, ...more] = args;
345
+ const opts = {};
346
+ const names = [];
347
+ for (let i = 0; i < more.length; i++) {
348
+ const a = more[i];
349
+ if (a === "--dir") opts.dir = more[++i];
350
+ else if (a.startsWith("--")) opts[a.slice(2)] = true;
351
+ else names.push(a);
352
+ }
353
+ if (sub === "install" || sub === "add") return skillsInstall(names, opts);
354
+ if (sub === "update" || sub === "up") return skillsUpdate(names, opts);
355
+ if (sub === "status" || sub === "ls") return skillsStatus();
356
+ if (sub === "auto") return skillsAuto(opts);
357
+ console.error(red("Usage: npx asta-ui@latest skills <install|update|status|auto> [name...] [--project] [--dir <path>] [--auto] [--off]"));
358
+ return Promise.resolve(1);
359
+ }
360
+
185
361
  const argv = process.argv.slice(2);
186
362
  const cmd = argv[0];
187
363
  const flags = new Set();
@@ -202,6 +378,7 @@ const main = {
202
378
  list: () => list(names[0]),
203
379
  ls: () => list(names[0]),
204
380
  prompt: () => prompt(names[0], flags),
381
+ skills: async () => skills(argv.slice(1)),
205
382
  "-v": () => (console.log(version), 0),
206
383
  "--version": () => (console.log(version), 0),
207
384
  }[cmd];
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  Candlestick
4
- } from "../chunk-7MGB7FVD.js";
4
+ } from "../chunk-RTAHGY6P.js";
5
5
  export {
6
6
  Candlestick as default
7
7
  };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  PriceChart
4
- } from "../chunk-JIVLBHHE.js";
4
+ } from "../chunk-OFPZUTBI.js";
5
5
  export {
6
6
  PriceChart as default
7
7
  };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  TradeTicket
4
- } from "../chunk-Z6IAITZJ.js";
4
+ } from "../chunk-5VQV2I7C.js";
5
5
  export {
6
6
  TradeTicket as default
7
7
  };
package/dist/base.js CHANGED
@@ -139,7 +139,7 @@ import {
139
139
  } from "./chunk-CNY76NHF.js";
140
140
  import {
141
141
  TradeTicket
142
- } from "./chunk-Z6IAITZJ.js";
142
+ } from "./chunk-5VQV2I7C.js";
143
143
  import {
144
144
  CardCheckout
145
145
  } from "./chunk-UEOEWP7L.js";
@@ -154,10 +154,10 @@ import {
154
154
  } from "./chunk-F5I6EK7F.js";
155
155
  import {
156
156
  PriceChart
157
- } from "./chunk-JIVLBHHE.js";
157
+ } from "./chunk-OFPZUTBI.js";
158
158
  import {
159
159
  Candlestick
160
- } from "./chunk-7MGB7FVD.js";
160
+ } from "./chunk-RTAHGY6P.js";
161
161
  import {
162
162
  SplitFlap
163
163
  } from "./chunk-2Z5Z4YYZ.js";
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  Candlestick
4
- } from "./chunk-7MGB7FVD.js";
4
+ } from "./chunk-RTAHGY6P.js";
5
5
  export {
6
6
  Candlestick as default
7
7
  };
@@ -109,7 +109,7 @@ function TradeTicket() {
109
109
  /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
110
110
  /* @__PURE__ */ jsxs("div", { className: "text-[clamp(2.2rem,7vw,3.4rem)] font-medium leading-none tracking-[-0.045em] text-ink tabular-nums", children: [
111
111
  amount.toFixed(3),
112
- /* @__PURE__ */ jsx("span", { className: "ml-2 text-[0.42em] font-normal tracking-normal text-mute", children: "ACME" })
112
+ /* @__PURE__ */ jsx("span", { className: "ml-2 text-[0.42em] font-normal tracking-normal text-mute", children: "ASTA" })
113
113
  ] }),
114
114
  /* @__PURE__ */ jsxs("p", { className: "mt-2 font-mono text-[12px] tabular-nums text-mute", children: [
115
115
  "\u2248 $",
@@ -192,7 +192,7 @@ function TradeTicket() {
192
192
  children: [
193
193
  /* @__PURE__ */ jsxs("span", { className: `absolute flex items-center gap-2 transition-[transform,opacity] duration-500 ease-[cubic-bezier(.16,1,.3,1)] ${phase === "idle" ? "translate-y-0 opacity-100" : "-translate-y-4 opacity-0"}`, children: [
194
194
  /* @__PURE__ */ jsx("span", { className: "capitalize", children: side }),
195
- " ACME"
195
+ " ASTA"
196
196
  ] }),
197
197
  /* @__PURE__ */ jsx("span", { className: `absolute transition-[transform,opacity] duration-500 ease-[cubic-bezier(.16,1,.3,1)] ${phase === "sending" ? "scale-100 opacity-100" : "scale-50 opacity-0"}`, children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", className: "h-5 w-5 animate-spin", fill: "none", "aria-hidden": true, children: [
198
198
  /* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "6", stroke: "currentColor", strokeOpacity: ".3", strokeWidth: "2" }),
@@ -177,7 +177,7 @@ function PriceChart() {
177
177
  };
178
178
  return /* @__PURE__ */ jsxs("div", { className: "relative flex h-full w-full flex-col p-5 sm:p-6", children: [
179
179
  /* @__PURE__ */ jsxs("div", { className: "relative z-10", children: [
180
- /* @__PURE__ */ jsx("p", { className: "font-mono text-[11px] uppercase tracking-[0.12em] text-mute", children: "ACME / USD" }),
180
+ /* @__PURE__ */ jsx("p", { className: "font-mono text-[11px] uppercase tracking-[0.12em] text-mute", children: "ASTA / USD" }),
181
181
  /* @__PURE__ */ jsxs("div", { className: "mt-2 flex flex-wrap items-center gap-3", children: [
182
182
  /* @__PURE__ */ jsx("span", { className: "text-[clamp(1.9rem,5.5vw,3rem)] font-medium leading-none tracking-[-0.04em] text-ink", children: /* @__PURE__ */ jsx(Roll, { text: price.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 }) }) }),
183
183
  /* @__PURE__ */ jsxs(
@@ -199,7 +199,7 @@ function Candlestick() {
199
199
  S.current.hx = -1;
200
200
  setOhlc(null);
201
201
  },
202
- children: /* @__PURE__ */ jsx("canvas", { ref: canvas, className: "block", "aria-label": "Live candlestick chart for ACME / USD", role: "img" })
202
+ children: /* @__PURE__ */ jsx("canvas", { ref: canvas, className: "block", "aria-label": "Live candlestick chart for ASTA / USD", role: "img" })
203
203
  }
204
204
  ),
205
205
  /* @__PURE__ */ jsx("div", { className: "pointer-events-none absolute left-5 top-5 font-mono text-[11px] tabular-nums sm:left-6", children: ohlc ? /* @__PURE__ */ jsxs("span", { className: "text-mute", children: [
@@ -212,7 +212,7 @@ function Candlestick() {
212
212
  " C",
213
213
  " ",
214
214
  /* @__PURE__ */ jsx("span", { style: { color: ohlc.c >= ohlc.o ? "var(--brand)" : "var(--ink-2)" }, children: f(ohlc.c) })
215
- ] }) : /* @__PURE__ */ jsx("span", { className: "uppercase tracking-[0.12em] text-mute", children: "ACME / USD \xB7 1m" }) })
215
+ ] }) : /* @__PURE__ */ jsx("span", { className: "uppercase tracking-[0.12em] text-mute", children: "ASTA / USD \xB7 1m" }) })
216
216
  ] });
217
217
  }
218
218
 
package/dist/index.js CHANGED
@@ -139,7 +139,7 @@ import {
139
139
  } from "./chunk-CNY76NHF.js";
140
140
  import {
141
141
  TradeTicket
142
- } from "./chunk-Z6IAITZJ.js";
142
+ } from "./chunk-5VQV2I7C.js";
143
143
  import {
144
144
  CardCheckout
145
145
  } from "./chunk-UEOEWP7L.js";
@@ -154,10 +154,10 @@ import {
154
154
  } from "./chunk-F5I6EK7F.js";
155
155
  import {
156
156
  PriceChart
157
- } from "./chunk-JIVLBHHE.js";
157
+ } from "./chunk-OFPZUTBI.js";
158
158
  import {
159
159
  Candlestick
160
- } from "./chunk-7MGB7FVD.js";
160
+ } from "./chunk-RTAHGY6P.js";
161
161
  import {
162
162
  SplitFlap
163
163
  } from "./chunk-2Z5Z4YYZ.js";
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  PriceChart
4
- } from "./chunk-JIVLBHHE.js";
4
+ } from "./chunk-OFPZUTBI.js";
5
5
  export {
6
6
  PriceChart as default
7
7
  };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  TradeTicket
4
- } from "./chunk-Z6IAITZJ.js";
4
+ } from "./chunk-5VQV2I7C.js";
5
5
  export {
6
6
  TradeTicket as default
7
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asta-ui",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Astabyte UI: motion-first React + Tailwind v4 components (Radix or Base UI). Install as a package, or copy the source with the CLI.",
5
5
  "keywords": [
6
6
  "astabyte",