asta-ui 0.6.1 → 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 +11 -0
- package/bin/asta-ui.mjs +179 -2
- package/package.json +1 -1
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 {
|
|
6
|
-
import {
|
|
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];
|
package/package.json
CHANGED