decklight 0.9.0 → 0.10.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.
Files changed (48) hide show
  1. package/PLATFORM.md +44 -3
  2. package/README.md +7 -5
  3. package/SPEC.md +100 -31
  4. package/cli/agent-review.mjs +5 -4
  5. package/cli/agents.mjs +11 -5
  6. package/cli/bundle-audio.mjs +10 -3
  7. package/cli/bundle-module.mjs +95 -0
  8. package/cli/bundle.mjs +58 -6
  9. package/cli/cast.mjs +41 -5
  10. package/cli/check-fixes.mjs +186 -0
  11. package/cli/check.mjs +32 -5
  12. package/cli/commit-flow.mjs +7 -3
  13. package/cli/commit-message.mjs +1 -1
  14. package/cli/commit-split.mjs +2 -2
  15. package/cli/deck-refs.mjs +8 -3
  16. package/cli/design-system-refs.mjs +263 -6
  17. package/cli/design-system.mjs +82 -14
  18. package/cli/edit-git.mjs +2 -2
  19. package/cli/edit-handover.mjs +129 -23
  20. package/cli/edit-look.mjs +248 -5
  21. package/cli/edit.mjs +504 -58
  22. package/cli/enhance.mjs +12 -10
  23. package/cli/git.mjs +13 -0
  24. package/cli/init.mjs +8 -3
  25. package/cli/marketplace-autocheck.mjs +200 -0
  26. package/cli/marketplace.mjs +250 -13
  27. package/cli/narrate.mjs +78 -3
  28. package/cli/open.mjs +24 -6
  29. package/cli/pdf.mjs +27 -8
  30. package/cli/pptx-export.mjs +7 -4
  31. package/cli/record.mjs +73 -13
  32. package/cli/remote.mjs +32 -6
  33. package/cli/serve.mjs +2 -2
  34. package/cli/skill-content.mjs +40 -3
  35. package/cli/skills.mjs +247 -3
  36. package/cli/theme-refs.mjs +14 -2
  37. package/cli/units.mjs +75 -7
  38. package/dist/build-info.json +1 -1
  39. package/dist/decklight.css +429 -32
  40. package/dist/decklight.js +169 -123
  41. package/dist/decklight.js.map +4 -4
  42. package/package.json +1 -1
  43. package/tools/design-system-format.mjs +25 -0
  44. package/tools/design-system-migrations.mjs +207 -0
  45. package/tools/exec.mjs +10 -2
  46. package/tools/narration-manifest.mjs +77 -3
  47. package/tools/site-clip.mjs +114 -0
  48. package/tools/video.mjs +69 -6
package/cli/skills.mjs CHANGED
@@ -33,9 +33,11 @@ import { makeFail, runMain } from './util.mjs';
33
33
  import { isMain } from '../tools/args.mjs';
34
34
  import { zipSync } from './zip.mjs';
35
35
  import {
36
- PKG, AGENTS_MARKER, agentsSection, claudeSkillMd, referenceDoc, reportBugSkillMd, skillVersionOf,
36
+ PKG, AGENTS_MARKER, agentsSection, claudeSkillMd, homePath, referenceDoc, reportBugSkillMd, skillVersionOf,
37
37
  } from './skill-content.mjs';
38
38
  import { semverCompare } from '../tools/semver.mjs';
39
+ import { librarySkills } from './units.mjs';
40
+ import { configHome } from './marketplace.mjs';
39
41
 
40
42
  // The reference doc, relative to whatever dir carries it. Skills keep their
41
43
  // own copy next to SKILL.md; AGENTS.md agents keep one under .decklight/.
@@ -106,7 +108,9 @@ installed runtime.
106
108
  Marketplace skills (decklight library add skill <name>) are a different thing and
107
109
  live somewhere else — ~/.decklight/skills/ — so they sit ALONGSIDE the
108
110
  authoring skill above and never replace it. The command above always writes
109
- the authoring skill; nothing installed from a catalog changes that.
111
+ the authoring skill; nothing installed from a catalog changes that. It does
112
+ hand them on: each is copied into .claude/skills/<name>/ when missing (never
113
+ over one already there) and listed in the AGENTS.md section.
110
114
  `;
111
115
 
112
116
  /** The agents found on PATH, in roster order (empty when none is). */
@@ -167,7 +171,7 @@ const wrote = (file) => (file ? display(file) : null);
167
171
  /** Add/refresh the marked Decklight block in the AGENTS.md under `dir`. */
168
172
  function mergeAgentsMd(dir, refHref) {
169
173
  const agentsPath = path.join(dir, 'AGENTS.md');
170
- const section = agentsSection(refHref);
174
+ const section = agentsSection(refHref, { librarySkills: librarySkills() });
171
175
  if (!fs.existsSync(agentsPath)) {
172
176
  fs.mkdirSync(dir, { recursive: true });
173
177
  fs.writeFileSync(agentsPath, `# Agent notes\n\n${section}`);
@@ -202,6 +206,182 @@ function installReportBugSkill(skillsRoot, force, written) {
202
206
  written.push(wrote(writeIfAbsent(path.join(dir, 'SKILL.md'), reportBugSkillMd(), force)));
203
207
  }
204
208
 
209
+ // --- marketplace skills, handed on to the agents (#880) ----------------------
210
+ //
211
+ // A library skill lives in ~/.decklight/skills/, which no agent reads. Claude
212
+ // indexes one skill per directory under .claude/skills/, so each is COPIED
213
+ // there (a copy, not a link: a symlink is a privilege on Windows, and a copy
214
+ // is what `unzip -d ~/.claude/skills/` would leave too); an AGENTS.md agent
215
+ // reads only its file, so the section lists them (`agentsSection`). A copy
216
+ // carries LIBRARY_MARK, and only a marked directory is ever replaced or
217
+ // removed: a skill the user wrote that happens to share a name is theirs.
218
+
219
+ const LIBRARY_MARK = '.decklight-library';
220
+
221
+ /**
222
+ * Copy one library skill under `skillsRoot`. `update` replaces a copy already
223
+ * there (what `library add` does, to take a new version); without it an
224
+ * existing copy is kept as it is (what a `decklight skills` re-run does).
225
+ */
226
+ function copyLibrarySkill(skill, skillsRoot, { update }) {
227
+ const dest = path.join(skillsRoot, skill.name);
228
+ if (fs.existsSync(dest)) {
229
+ if (!fs.existsSync(path.join(dest, LIBRARY_MARK))) {
230
+ return `left ${display(dest)} alone — a skill of that name that the library did not put there`;
231
+ }
232
+ if (!update) return null;
233
+ fs.rmSync(dest, { recursive: true, force: true });
234
+ }
235
+ fs.cpSync(skill.path, dest, { recursive: true });
236
+ fs.writeFileSync(path.join(dest, LIBRARY_MARK),
237
+ `copied from ${homePath(skill.path)} by decklight library add skill; decklight library remove skill ${skill.name} removes it\n`);
238
+ return `copied ${skill.name} from your library to ${display(dest)}`;
239
+ }
240
+
241
+ /**
242
+ * Bring the library skills under one Claude skills root up to the library:
243
+ * add the missing ones, drop the copies whose skill was removed from it.
244
+ * Never overwrites a copy — the authoring install re-run keeps them as they are.
245
+ */
246
+ export function syncLibrarySkills(skillsRoot, written) {
247
+ const skills = librarySkills();
248
+ for (const skill of skills) written.push(copyLibrarySkill(skill, skillsRoot, { update: false }));
249
+ if (!fs.existsSync(skillsRoot)) return;
250
+ const have = new Set(skills.map((s) => s.name));
251
+ for (const name of fs.readdirSync(skillsRoot)) {
252
+ const dir = path.join(skillsRoot, name);
253
+ if (have.has(name) || !fs.existsSync(path.join(dir, LIBRARY_MARK))) continue;
254
+ fs.rmSync(dir, { recursive: true, force: true });
255
+ written.push(`removed ${display(dir)} — no longer in your library`);
256
+ }
257
+ }
258
+
259
+ /**
260
+ * Refresh every Decklight AGENTS.md section this command can find — the
261
+ * project's under `dir` and each agent's global one — so its list of library
262
+ * skills matches the library. Only a file already carrying the section is
263
+ * touched: this never creates an AGENTS.md nobody asked for.
264
+ */
265
+ function refreshAgentsSections({ dir = '.', env = process.env } = {}) {
266
+ const out = [];
267
+ const marked = (d) => {
268
+ try { return fs.readFileSync(path.join(d, 'AGENTS.md'), 'utf8').includes(AGENTS_MARKER); } catch { return false; }
269
+ };
270
+ const root = path.resolve(dir);
271
+ if (marked(root)) out.push(mergeAgentsMd(root, fs.existsSync(path.join(root, CLAUDE_REF)) ? CLAUDE_REF : SHARED_REF));
272
+ for (const t of Object.values(TARGETS)) {
273
+ const home = t.home(env);
274
+ if (t.kind === 'agents' && marked(home)) out.push(mergeAgentsMd(home, SHARED_REF));
275
+ }
276
+ return [...new Set(out)];
277
+ }
278
+
279
+ /** Claude's skills root for a scope: the project's, or its config home's. */
280
+ const claudeSkillsRoot = ({ dir = '.', global = false, env = process.env }) =>
281
+ (global ? path.join(TARGETS.claude.home(env), 'skills') : path.join(path.resolve(dir), '.claude', 'skills'));
282
+
283
+ /**
284
+ * `library add skill <name>` hands the installed skill to the agents: a copy
285
+ * in Claude's skills (the project's, or with `global` its config home's), and
286
+ * a line in every AGENTS.md section. Returns the lines to print.
287
+ */
288
+ export function placeLibrarySkill(name, { dir = '.', global = false, dirNamed = false, env = process.env } = {}) {
289
+ const skill = librarySkills().find((s) => s.name === name);
290
+ if (!skill) return [];
291
+ const out = [];
292
+ // a project is a directory that already has an agent setup, or one named with
293
+ // --dir: run from ~ or a scratch folder, a stray .claude/ helps nobody
294
+ if (global || dirNamed || agentProject(dir)) out.push(copyLibrarySkill(skill, claudeSkillsRoot({ dir, global, env }), { update: true }));
295
+ out.push(...refreshAgentsSections({ dir, env }));
296
+ if (!out.filter(Boolean).length) {
297
+ out.push(`not handed to an agent yet — ${display(path.resolve(dir))} has no .claude/ or Decklight AGENTS.md:`
298
+ + ` decklight skills in a project, or --dir <project> / --global`);
299
+ }
300
+ return out.filter(Boolean);
301
+ }
302
+
303
+ /**
304
+ * Where an agent already loads skill `name` from, or null: Claude's skills,
305
+ * its config home's (every project) before the project's under `dir`. A skill
306
+ * that is only in the library or a marketplace checkout is on no agent's
307
+ * path yet, and whatever needs it offers to put it there (#893).
308
+ */
309
+ export function placedSkill(name, { dir = '.', env = process.env } = {}) {
310
+ for (const global of [true, false]) {
311
+ const file = path.join(claudeSkillsRoot({ dir, global, env }), name, 'SKILL.md');
312
+ if (fs.existsSync(file)) return { scope: global ? 'global' : 'project', file };
313
+ }
314
+ return null;
315
+ }
316
+
317
+ /** The two places an offer to install skill `name` names, as the author reads them. */
318
+ export function skillPlaces(name, { dir = '.', env = process.env } = {}) {
319
+ return {
320
+ global: display(path.join(claudeSkillsRoot({ global: true, env }), name)),
321
+ project: display(path.join(claudeSkillsRoot({ dir, env }), name)),
322
+ };
323
+ }
324
+
325
+ /**
326
+ * The answer to that offer on a terminal: Enter (or g) is every project, the
327
+ * one recommended; p is this project only; anything else is not now (null).
328
+ */
329
+ export function skillPlaceAnswer(text) {
330
+ const a = String(text ?? '').trim().toLowerCase();
331
+ if (a === '' || a.startsWith('g') || a.startsWith('y')) return 'global';
332
+ return a.startsWith('p') ? 'project' : null;
333
+ }
334
+
335
+ /** The question that offer asks on a terminal. */
336
+ export const skillPlaceQuestion = (name, at) => `Install the ${name} skill for your agent?`
337
+ + ` [G] every project, ${at.global} (recommended) · [p] this project only, ${at.project} · [n] not now: `;
338
+
339
+ /**
340
+ * Put skill `name` where the agent loads skills, as an offer was answered:
341
+ * `global` (Claude's config home, every project) or the project under `dir`.
342
+ * Not in the library yet, it is installed there first from `ref`, its
343
+ * catalog entry. Returns `{ file, lines }`: the SKILL.md the agent now
344
+ * finds, and what was done, to print.
345
+ */
346
+ export async function placeSkill(name, { global = true, dir = '.', ref = name, env = process.env, home } = {}) {
347
+ const lines = [];
348
+ if (!librarySkills(home).some((s) => s.name === name)) {
349
+ const { installUnit } = await import('./units.mjs');
350
+ const done = await installUnit('skill', ref, home);
351
+ lines.push(`installed ${done.name}${done.entry.version ? ` ${done.entry.version}` : ''} from ${done.qualified}`);
352
+ }
353
+ const skill = librarySkills(home).find((s) => s.name === name);
354
+ if (skill) {
355
+ lines.push(copyLibrarySkill(skill, claudeSkillsRoot({ dir, global, env }), { update: true }));
356
+ lines.push(...refreshAgentsSections({ dir, env }));
357
+ }
358
+ return { file: placedSkill(name, { dir, env })?.file ?? null, lines: lines.filter(Boolean) };
359
+ }
360
+
361
+ /** Does `dir` already have an agent setup: a `.claude/`, or an AGENTS.md with the Decklight section? */
362
+ function agentProject(dir) {
363
+ const root = path.resolve(dir);
364
+ if (fs.existsSync(path.join(root, '.claude'))) return true;
365
+ try { return fs.readFileSync(path.join(root, 'AGENTS.md'), 'utf8').includes(AGENTS_MARKER); } catch { return false; }
366
+ }
367
+
368
+ /**
369
+ * `library remove skill <name>` takes it back from the same places: the
370
+ * copy in this project's and in Claude's global skills (both, whatever scope
371
+ * it was added with — only a marked copy is ours), and its AGENTS.md lines.
372
+ */
373
+ export function unplaceLibrarySkill(name, { dir = '.', env = process.env } = {}) {
374
+ const out = [];
375
+ for (const global of [false, true]) {
376
+ const copy = path.join(claudeSkillsRoot({ dir, global, env }), name);
377
+ if (!fs.existsSync(path.join(copy, LIBRARY_MARK))) continue;
378
+ fs.rmSync(copy, { recursive: true, force: true });
379
+ out.push(`removed ${display(copy)}`);
380
+ }
381
+ out.push(...refreshAgentsSections({ dir, env }));
382
+ return out;
383
+ }
384
+
205
385
  // --- project scope: one repo, one shared AGENTS.md for every agent ----------
206
386
 
207
387
  function installProject(targets, dir, force) {
@@ -216,6 +396,7 @@ function installProject(targets, dir, force) {
216
396
  const skillsRoot = path.join(root, '.claude', 'skills');
217
397
  installClaudeSkill(path.join(skillsRoot, 'decklight'), force, written);
218
398
  installReportBugSkill(skillsRoot, force, written);
399
+ syncLibrarySkills(skillsRoot, written);
219
400
  }
220
401
  if (mdAgents.length) {
221
402
  // one reference copy: Claude's skill dir when Claude is also a target,
@@ -237,6 +418,7 @@ function installGlobal(targets, env, force) {
237
418
  if (t.kind === 'skill') {
238
419
  installClaudeSkill(path.join(home, 'skills', 'decklight'), force, written);
239
420
  installReportBugSkill(path.join(home, 'skills'), force, written);
421
+ syncLibrarySkills(path.join(home, 'skills'), written);
240
422
  } else {
241
423
  written.push(wrote(writeIfAbsent(path.join(home, SHARED_REF), referenceDoc(), force)));
242
424
  written.push(mergeAgentsMd(home, SHARED_REF));
@@ -316,6 +498,68 @@ export function installGlobalSkill(targets, { env = process.env, force = false,
316
498
  for (const w of written) out.write(` ${w}\n`);
317
499
  }
318
500
 
501
+ // --- before an agent job: is Decklight's skill where this agent reads it? ----
502
+
503
+ /**
504
+ * Where Decklight's own skill reaches the agent `key` (an agents.mjs name),
505
+ * its config home's before the project's under `dir`: `{ scope, file }`, or
506
+ * null when it reaches it from neither. An agent decklight has no install
507
+ * for (not in TARGETS) is never offered one, so it reads as having it.
508
+ */
509
+ export function placedDecklightSkill(key, { dir = '.', env = process.env } = {}) {
510
+ const t = TARGETS[key];
511
+ if (!t) return { scope: 'none', file: null };
512
+ const at = (file) => {
513
+ if (!fs.existsSync(file)) return false;
514
+ if (t.kind === 'skill') return true;
515
+ try { return fs.readFileSync(file, 'utf8').includes(AGENTS_MARKER); } catch { return false; }
516
+ };
517
+ const global = t.kind === 'skill' ? path.join(t.home(env), 'skills', 'decklight', 'SKILL.md') : path.join(t.home(env), 'AGENTS.md');
518
+ if (at(global)) return { scope: 'global', file: global };
519
+ const root = path.resolve(dir);
520
+ const project = t.kind === 'skill' ? path.join(root, '.claude', 'skills', 'decklight', 'SKILL.md') : path.join(root, 'AGENTS.md');
521
+ return at(project) ? { scope: 'project', file: project } : null;
522
+ }
523
+
524
+ /** The two places an offer of Decklight's skill to agent `key` names, as the author reads them. */
525
+ export function decklightSkillPlaces(key, { dir = '.', env = process.env } = {}) {
526
+ const t = TARGETS[key];
527
+ const root = path.resolve(dir);
528
+ return t.kind === 'skill'
529
+ ? { global: display(path.join(t.home(env), 'skills', 'decklight')), project: display(path.join(root, '.claude', 'skills', 'decklight')) }
530
+ : { global: display(path.join(t.home(env), 'AGENTS.md')), project: display(path.join(root, 'AGENTS.md')) };
531
+ }
532
+
533
+ /**
534
+ * Install Decklight's skill for agent `key`, as an offer was answered: in its
535
+ * config home (`global`, every project) or the project under `dir`. The same
536
+ * writers as `decklight skills [--global]`. Returns the lines it would print.
537
+ */
538
+ export function installDecklightSkill(key, { global = true, dir = '.', env = process.env } = {}) {
539
+ return global ? installGlobal([key], env, false) : installProject([key], dir, false);
540
+ }
541
+
542
+ // A no to that offer, remembered per project and agent: the next ask goes
543
+ // ahead without asking again, and `decklight skills` is still the way in.
544
+ const declinedFile = (env) => path.join(configHome(env), 'skill-offer-declined.json');
545
+ const readDeclined = (env) => { try { return JSON.parse(fs.readFileSync(declinedFile(env), 'utf8')); } catch { return {}; } };
546
+
547
+ /** Did the author turn down Decklight's skill for agent `key` in the project under `dir`? */
548
+ export function skillOfferDeclined(key, { dir = '.', env = process.env } = {}) {
549
+ return (readDeclined(env)[path.resolve(dir)] ?? []).includes(key);
550
+ }
551
+
552
+ /** Remember that no. */
553
+ export function declineSkillOffer(key, { dir = '.', env = process.env } = {}) {
554
+ const all = readDeclined(env);
555
+ const root = path.resolve(dir);
556
+ all[root] = [...new Set([...(all[root] ?? []), key])];
557
+ try {
558
+ fs.mkdirSync(configHome(env), { recursive: true });
559
+ fs.writeFileSync(declinedFile(env), `${JSON.stringify(all, null, 2)}\n`);
560
+ } catch { /* not remembered: asked again next time */ }
561
+ }
562
+
319
563
  /**
320
564
  * The account-level distribution artifact (#80): the same two files a project
321
565
  * install writes, in a standard archive you upload once instead of committing
@@ -117,6 +117,12 @@ export const markedShipped = (html) => markedEntries(html).filter((r) => r.shipp
117
117
  export function portableSource(source) {
118
118
  if (typeof source !== 'string' || !source) return null;
119
119
  const bare = source.replace(/^(https?:\/\/|ssh:\/\/|git:\/\/)[^/@]*@/i, '$1');
120
+ // GitHub over SSH is the same repo as over https: one identity, or a deck
121
+ // marked where the catalog was added by SSH URL is "a different catalog"
122
+ // wherever it was added as owner/repo. Here only: `classifySource` also picks
123
+ // the clone transport, and an SSH user keeps cloning over SSH.
124
+ const ssh = /^(?:ssh:\/\/github\.com(?::22)?\/|git@github\.com:)([\w.-]+)\/([\w.-]+?)(?:\.git)?\/?$/i.exec(bare);
125
+ if (ssh) return `${ssh[1]}/${ssh[2]}`;
120
126
  const src = classifySource(bare, { exists: () => false });
121
127
  if (src.kind === 'github') return `${src.owner}/${src.repo}`;
122
128
  if (src.kind === 'git' && !/^file:\/\//i.test(bare)) return bare.replace(/\.git\/?$/, '').replace(/\/$/, '');
@@ -171,7 +177,10 @@ export function resolveCatalogEntry(parsed, home = configHome(), { source = null
171
177
  const registry = loadRegistry(home).marketplaces ?? {};
172
178
  let marketplace = parsed.marketplace;
173
179
  if (source) {
174
- const same = Object.entries(registry).find(([, m]) => portableSource(m.source) === source)?.[0];
180
+ // both sides: a deck that recorded the SSH form before it was normalised
181
+ // still resolves without being re-marked
182
+ const wanted = portableSource(source) ?? source;
183
+ const same = Object.entries(registry).find(([, m]) => portableSource(m.source) === wanted)?.[0];
175
184
  if (same) marketplace = same;
176
185
  else if (registry[marketplace]) {
177
186
  return { ...parsed, missing: `"${marketplace}" here is a different catalog (${portableSource(registry[marketplace].source) ?? 'a local one'}) — the deck's comes from ${source}` };
@@ -465,7 +474,10 @@ export function withKey(inner, key, value) {
465
474
  * whatever each machine that marks from it happens to call it.
466
475
  */
467
476
  export function refForDeck(html, name, local, source) {
468
- const known = source ? Object.entries(markedSources(html)).find(([, v]) => v === source)?.[0] : null;
477
+ // by portable identity, as resolving does: a deck that recorded the SSH
478
+ // form still means the catalog this machine registered as owner/repo (#874)
479
+ const wanted = portableSource(source) ?? source;
480
+ const known = source ? Object.entries(markedSources(html)).find(([, v]) => (portableSource(v) ?? v) === wanted)?.[0] : null;
469
481
  return `${name}@${known ?? local}`;
470
482
  }
471
483
 
package/cli/units.mjs CHANGED
@@ -21,7 +21,9 @@
21
21
  * deck at a desk.
22
22
  *
23
23
  * WHAT IS DELIBERATELY NOT HERE: running an installed unit. A skill is
24
- * Markdown, so it is just files. An import adapter and
24
+ * Markdown, so it is just files — read by an agent, not by a decklight
25
+ * command, so `library add skill` also hands it to the agents `decklight
26
+ * skills` writes for (`cli/skills.mjs` `placeLibrarySkill`, #880). An import adapter and
25
27
  * a build-time transform are both **Node code**, and executing either is one
26
28
  * shared capability rather than two copies of resolve-fetch-validate-load —
27
29
  * `cli/loader.mjs` (`EXTENSIONS#LOADER`) is that shared loader. `bundle
@@ -55,7 +57,7 @@ export const UNIT_TYPES = {
55
57
  files: ['SKILL.md'],
56
58
  optional: ['reference.md'],
57
59
  label: 'agent skill',
58
- use: 'decklight library add skill <name>',
60
+ use: 'your coding agent (decklight skills hands it to Claude Code and the AGENTS.md agents)',
59
61
  example: 'conference-cfp',
60
62
  required: [],
61
63
  },
@@ -249,6 +251,23 @@ export function installedVoices(engine, home = configHome()) {
249
251
  return out;
250
252
  }
251
253
 
254
+ /**
255
+ * The installed marketplace skills, each with the `description` its SKILL.md
256
+ * frontmatter gives — what an agent picks one by (#880): the AGENTS.md section
257
+ * lists them, and `decklight skills` copies them beside the authoring skill.
258
+ * Offline like every read here; a SKILL.md with no frontmatter still lists, by
259
+ * name alone.
260
+ */
261
+ export function librarySkills(home = configHome()) {
262
+ return listUnits('skill', home).map(({ name, path }) => {
263
+ let text = '';
264
+ try { text = readFileSync(join(path, 'SKILL.md'), 'utf8'); } catch { /* listed by name */ }
265
+ const front = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text)?.[1] ?? '';
266
+ const description = (/^description:[ \t]*(.*)$/m.exec(front)?.[1] ?? '').trim().replace(/^(['"])(.*)\1$/, '$2');
267
+ return { name, description, path };
268
+ });
269
+ }
270
+
252
271
  // ── installing, the one place that reaches the network ─────────────────────
253
272
 
254
273
  /** Read one artifact file from a resolved source (a URL or a local path). */
@@ -418,15 +437,39 @@ export const unitUsage = (type) => {
418
437
  decklight library remove ${type} <name>
419
438
  delete it from your library
420
439
 
421
- used by: ${t.use}
440
+ used by: ${t.use}${type === 'skill' ? `
441
+
442
+ A skill is read by your coding agent, so \`add\` also copies it where the
443
+ agent loads skills: on a terminal it asks, every project (~/.claude/skills/,
444
+ --global, recommended) or this one (.claude/skills/, --dir <path> names
445
+ another); otherwise into a project that already has a .claude/ or a
446
+ Decklight AGENTS.md
447
+ and lists it in every AGENTS.md carrying the Decklight section; \`remove\`
448
+ takes both away again. \`decklight skills\` keeps them.` : ''}
422
449
 
423
450
  Registering a marketplace is not fetching it (SPEC MARKETPLACE_REGISTRY):
424
451
  \`list\` reads only the cache and works on a plane, and the network is touched
425
452
  only by an explicit \`add\`. DECKLIGHT_HOME overrides ~/.decklight/.`;
426
453
  };
427
454
 
455
+ /**
456
+ * The positionals and the agent scope of a unit command: `--global` (each
457
+ * agent's config home) or `--dir <path>` (a project other than the current
458
+ * directory). Only a skill reads the scope — it is the one kind an agent reads.
459
+ */
460
+ function scopeArgs(args) {
461
+ const out = { names: [], global: false, dir: '.', dirNamed: false };
462
+ for (let i = 0; i < args.length; i++) {
463
+ if (args[i] === '--global' || args[i] === '-g') out.global = true;
464
+ else if (args[i] === '--dir') { out.dir = args[++i] ?? '.'; out.dirNamed = true; }
465
+ else if (!args[i].startsWith('-')) out.names.push(args[i]);
466
+ }
467
+ return out;
468
+ }
469
+
428
470
  async function addMain(type, args, home) {
429
- const [ref] = args.filter((a) => !a.startsWith('-'));
471
+ const scope = scopeArgs(args);
472
+ const [ref] = scope.names;
430
473
  if (!ref) { console.error(`decklight library add ${type}: needs a name\n\n${unitUsage(type)}`); return 1; }
431
474
  let done;
432
475
  try { done = await installUnit(type, ref, home); } catch (e) {
@@ -436,6 +479,26 @@ async function addMain(type, args, home) {
436
479
  }
437
480
  console.log(`installed ${done.name}${done.entry.version ? ` ${done.entry.version}` : ''} from ${done.qualified} — ${UNIT_TYPES[type].use}`);
438
481
  if (done.entry.description) console.log(` ${done.entry.description}`);
482
+ // A skill's consumer is an agent, not a decklight command: hand it to the
483
+ // agents `decklight skills` writes for, or it sits where nothing reads (#880).
484
+ if (type === 'skill') {
485
+ const { placeLibrarySkill, skillPlaces, skillPlaceAnswer, skillPlaceQuestion } = await import('./skills.mjs');
486
+ // No scope typed, on a terminal: ask where it goes, every project first,
487
+ // rather than guess from whether this folder has a .claude/ (#893)
488
+ if (!scope.global && !scope.dirNamed && process.stdin.isTTY && process.stdout.isTTY) {
489
+ const { createInterface } = await import('node:readline/promises');
490
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
491
+ let where;
492
+ try { where = skillPlaceAnswer(await rl.question(skillPlaceQuestion(done.name, skillPlaces(done.name, scope)))); } finally { rl.close(); }
493
+ if (!where) {
494
+ console.log(` not handed to an agent: decklight library add skill ${done.name} --global (or --dir <project>) does it later`);
495
+ return 0;
496
+ }
497
+ if (where === 'global') scope.global = true;
498
+ else scope.dirNamed = true;
499
+ }
500
+ for (const line of placeLibrarySkill(done.name, scope)) console.log(` ${line}`);
501
+ }
439
502
  return 0;
440
503
  }
441
504
 
@@ -462,8 +525,9 @@ function listMain(type, home) {
462
525
  return 0;
463
526
  }
464
527
 
465
- function removeMain(type, args, home) {
466
- const [name] = args.filter((a) => !a.startsWith('-'));
528
+ async function removeMain(type, args, home) {
529
+ const scope = scopeArgs(args);
530
+ const [name] = scope.names;
467
531
  if (!name) { console.error(`decklight library remove ${type}: which one?\n\n${unitUsage(type)}`); return 1; }
468
532
  try { removeUnit(type, name, home); } catch (e) {
469
533
  if (!(e instanceof UnitError)) throw e;
@@ -471,6 +535,10 @@ function removeMain(type, args, home) {
471
535
  return 1;
472
536
  }
473
537
  console.log(`removed ${name}`);
538
+ if (type === 'skill') {
539
+ const { unplaceLibrarySkill } = await import('./skills.mjs');
540
+ for (const line of unplaceLibrarySkill(name, scope)) console.log(` ${line}`);
541
+ }
474
542
  return 0;
475
543
  }
476
544
 
@@ -484,7 +552,7 @@ export async function unitMain(type, args = []) {
484
552
  try {
485
553
  if (sub === 'add') return await addMain(type, rest, home);
486
554
  if (sub === 'list') return listMain(type, home);
487
- if (sub === 'remove') return removeMain(type, rest, home);
555
+ if (sub === 'remove') return await removeMain(type, rest, home);
488
556
  } catch (e) {
489
557
  if (e instanceof UnitError || e instanceof MarketplaceError) {
490
558
  console.error(`decklight library ${sub} ${type}: ${e.message}`);
@@ -1 +1 @@
1
- {"tag":"0.9.0","commits":0,"commit":"a3046d2","dirty":false}
1
+ {"tag":"0.10.0","commits":0,"commit":"8d022b5","dirty":false}