decklight 0.2.0 → 0.3.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 +69 -31
- package/SPEC.md +855 -80
- package/cli/agents.mjs +113 -9
- package/cli/associate.mjs +279 -0
- package/cli/audit.mjs +424 -0
- package/cli/bundle.mjs +174 -46
- package/cli/deckfile.mjs +233 -0
- package/cli/decklight.mjs +201 -8
- package/cli/dev.mjs +244 -55
- package/cli/edit.mjs +564 -107
- package/cli/extension.mjs +108 -0
- package/cli/git.mjs +141 -0
- package/cli/import.mjs +398 -0
- package/cli/init.mjs +421 -116
- package/cli/loader.mjs +263 -0
- package/cli/marketplace.mjs +730 -0
- package/cli/pdf.mjs +156 -0
- package/cli/pkg.mjs +69 -0
- package/cli/plugin.mjs +646 -0
- package/cli/port-conflict.mjs +94 -0
- package/cli/present.mjs +560 -0
- package/cli/publish.mjs +342 -0
- package/cli/qr.mjs +334 -0
- package/cli/rec.mjs +5 -8
- package/cli/remote.mjs +149 -0
- package/cli/report-bug.mjs +97 -0
- package/cli/restore.mjs +174 -0
- package/cli/serve.mjs +247 -0
- package/cli/sign.mjs +216 -0
- package/cli/skill-content.mjs +222 -0
- package/cli/skills.mjs +338 -0
- package/cli/supervise.mjs +57 -0
- package/cli/theme.mjs +201 -0
- package/cli/units.mjs +488 -0
- package/cli/upgrade.mjs +250 -0
- package/cli/util.mjs +90 -0
- package/cli/wizard.mjs +432 -0
- package/cli/zip.mjs +121 -0
- package/dist/decklight.css +716 -29
- package/dist/decklight.js +198 -125
- package/dist/decklight.js.map +4 -4
- package/docs/architecture.svg +1 -1
- package/package.json +5 -4
- package/themes/README.md +6 -4
- package/themes/aurora.css +1 -1
- package/themes/berry.css +1 -1
- package/themes/carbon.css +1 -1
- package/themes/citrus.css +1 -1
- package/themes/coastal.css +1 -1
- package/themes/cosmos.css +1 -1
- package/themes/dune.css +1 -1
- package/themes/eclipse.css +1 -1
- package/themes/ember.css +1 -1
- package/themes/fjord.css +1 -1
- package/themes/gallery.html +3 -11
- package/themes/glacier.css +1 -1
- package/themes/graphite.css +1 -1
- package/themes/harvest.css +1 -1
- package/themes/ibm-modern.css +1 -1
- package/themes/ink.css +1 -1
- package/themes/latte.css +1 -1
- package/themes/linen.css +1 -1
- package/themes/meadow.css +1 -1
- package/themes/metropolis.css +1 -1
- package/themes/midnight.css +1 -1
- package/themes/mint.css +1 -1
- package/themes/moss.css +1 -1
- package/themes/obsidian.css +1 -1
- package/themes/orchid.css +1 -1
- package/themes/packs.json +2 -30
- package/themes/paper.css +1 -1
- package/themes/peony.css +1 -1
- package/themes/porcelain.css +1 -1
- package/themes/reveal-beige.css +1 -1
- package/themes/reveal-black.css +1 -1
- package/themes/reveal-blood.css +1 -1
- package/themes/reveal-dracula.css +1 -1
- package/themes/reveal-league.css +1 -1
- package/themes/reveal-moon.css +1 -1
- package/themes/reveal-night.css +1 -1
- package/themes/reveal-serif.css +1 -1
- package/themes/reveal-simple.css +1 -1
- package/themes/reveal-sky.css +1 -1
- package/themes/reveal-solarized.css +1 -1
- package/themes/reveal-white.css +1 -1
- package/themes/sepia.css +1 -1
- package/themes/seriph.css +1 -1
- package/themes/slate.css +1 -1
- package/themes/storm.css +1 -1
- package/themes/synthwave.css +1 -1
- package/themes/velvet.css +1 -1
- package/themes/yamabuki.css +1 -1
- package/tools/args.mjs +32 -0
- package/tools/bridge.mjs +30 -0
- package/tools/chrome.mjs +11 -2
- package/tools/color.mjs +110 -0
- package/tools/deck-html.mjs +138 -0
- package/tools/elevenlabs-tts.mjs +248 -0
- package/tools/escape.mjs +40 -0
- package/tools/extension-check-runner.mjs +41 -0
- package/tools/extension-check.mjs +266 -0
- package/tools/gemini-tts.mjs +25 -3
- package/tools/lipsync-engines.mjs +81 -0
- package/tools/lipsync-server.mjs +78 -37
- package/tools/lipsync.mjs +36 -21
- package/tools/local-voice.mjs +209 -0
- package/tools/ooxml.mjs +151 -0
- package/tools/pptx.mjs +320 -0
- package/tools/publish-site-voices.mjs +2 -1
- package/tools/publish-targets.mjs +143 -0
- package/tools/publish-voices.mjs +230 -0
- package/tools/shot.mjs +91 -47
- package/tools/theme-check.mjs +139 -0
- package/tools/tts-engines.mjs +270 -41
- package/tools/tts-setup.mjs +257 -0
- package/tools/veo.mjs +204 -0
- package/tools/video.mjs +316 -0
- package/tools/voiceover-server.mjs +163 -54
- package/tools/voiceover.mjs +24 -7
- package/tools/zip.mjs +143 -0
- package/docs/demo.svg +0 -124
- package/themes/aliens.css +0 -87
- package/themes/apple2.css +0 -129
- package/themes/blade-runner.css +0 -86
- package/themes/c64.css +0 -88
- package/themes/friends.css +0 -85
- package/themes/gameboy.css +0 -121
- package/themes/genesis.css +0 -87
- package/themes/godfather.css +0 -85
- package/themes/ibm-oldschool.css +0 -87
- package/themes/miami-vice.css +0 -87
- package/themes/pulp-fiction.css +0 -87
- package/themes/severance.css +0 -85
- package/themes/snes.css +0 -85
- package/themes/star-wars.css +0 -88
- package/themes/stranger-things.css +0 -87
- package/themes/terminator.css +0 -87
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
// Copyright 2026 Gilles Philippart
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The Decklight authoring skill's *content*, in one place: the reference
|
|
6
|
+
* doc (sliced from SPEC.md), the Claude SKILL.md body, and the AGENTS.md
|
|
7
|
+
* section. `init` and `skills` both render these — the deck scaffolder and
|
|
8
|
+
* the standalone skill installer must hand every agent the same contract,
|
|
9
|
+
* so they share the source rather than each carrying a copy that can drift.
|
|
10
|
+
*
|
|
11
|
+
* The reference is derived from the installed version's SPEC.md, so it
|
|
12
|
+
* always matches the runtime that produced it — an agent should trust it
|
|
13
|
+
* over prior training.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import fs from 'node:fs';
|
|
17
|
+
import path from 'node:path';
|
|
18
|
+
|
|
19
|
+
// Imported and re-exported, not redefined: the package root has one
|
|
20
|
+
// definition (pkg.mjs), and every bug in this area came from a second one.
|
|
21
|
+
// `import` then `export`, not `export … from`, because this module reads
|
|
22
|
+
// PKG.version itself and a bare re-export creates no local binding.
|
|
23
|
+
import { PKG_ROOT, PKG } from './pkg.mjs';
|
|
24
|
+
|
|
25
|
+
export { PKG_ROOT, PKG };
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The authoring contract, sliced from SPEC.md through JS_API (everything an
|
|
29
|
+
* agent needs to write slides), dropping the repo-layout/tooling section
|
|
30
|
+
* that only matters to Decklight's own contributors.
|
|
31
|
+
*/
|
|
32
|
+
export function referenceDoc() {
|
|
33
|
+
const spec = fs.readFileSync(path.join(PKG_ROOT, 'SPEC.md'), 'utf8');
|
|
34
|
+
const cut = spec.indexOf('\n## REPO_LAYOUT');
|
|
35
|
+
return (cut > 0 ? spec.slice(0, cut) : spec).trimEnd() + '\n';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The Claude Code SKILL.md — YAML frontmatter Claude indexes on, then a
|
|
40
|
+
* progressive-disclosure body that points at `referenceHref` (a path
|
|
41
|
+
* relative to the SKILL.md) for the full contract.
|
|
42
|
+
*/
|
|
43
|
+
export function claudeSkillMd(referenceHref = 'reference.md') {
|
|
44
|
+
return `---
|
|
45
|
+
name: decklight
|
|
46
|
+
description: Author and edit Decklight presentations — single-file HTML decks with Keynote-style builds, theme-aware SVG diagrams, 46 built-in themes, truthful terminal recordings, and live TTS narration. Use whenever creating or editing a Decklight deck (a .html file with a <div class="decklight"> of <section> slides) in this project.
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
Decklight decks are one HTML file: no build step, no bundler, no server to
|
|
50
|
+
author. A deck is \`<div class="decklight">\` containing \`<section>\` slides;
|
|
51
|
+
the runtime is one JS file + one CSS file + one theme CSS file.
|
|
52
|
+
|
|
53
|
+
**Full authoring contract**: read [${referenceHref}](${referenceHref}) in this same
|
|
54
|
+
skill directory before authoring or editing a slide — SLIDE_DENSITY is how much goes on
|
|
55
|
+
one, COMPARISON_SLIDES is the worked comparison (pros/cons) slide, and past those it covers builds,
|
|
56
|
+
speaker notes segmentation (⟨CLICK⟩), SVG diagrams, theming, motion, code
|
|
57
|
+
blocks, LaTeX math, terminal recordings, narration, and the public JS API. It's sliced
|
|
58
|
+
straight from Decklight's SPEC.md (v${PKG.version}), so it won't drift from
|
|
59
|
+
the installed runtime's actual behavior — trust it over prior training.
|
|
60
|
+
|
|
61
|
+
**Minimal skeleton** (see \`deck.html\` in this project for a worked example
|
|
62
|
+
with a build and notes already wired):
|
|
63
|
+
|
|
64
|
+
\`\`\`html
|
|
65
|
+
<div class="decklight">
|
|
66
|
+
<section>
|
|
67
|
+
<h1>Title</h1>
|
|
68
|
+
<aside class="notes"><p>What you'd say on this slide.</p></aside>
|
|
69
|
+
</section>
|
|
70
|
+
</div>
|
|
71
|
+
\`\`\`
|
|
72
|
+
|
|
73
|
+
**CLI** (\`npx decklight <command>\`, no install needed):
|
|
74
|
+
- \`decklight author deck.html\` — the whole authoring loop: serve with live reload; **E** in the browser edits speaker notes back into the file
|
|
75
|
+
- \`decklight rec script.term.yaml\` — record a truthful terminal cast in a real PTY, for \`<div class="terminal">\`
|
|
76
|
+
- \`decklight bundle deck.html --themes all\` — flatten into one self-contained file to hand off or publish
|
|
77
|
+
- \`decklight pdf deck.html\` — render every slide to a PDF, and report the ones that overflow
|
|
78
|
+
- \`decklight tts\` — live voice bridge so the deck can narrate itself on the fly
|
|
79
|
+
- \`decklight skills\` — regenerate this skill after upgrading Decklight
|
|
80
|
+
|
|
81
|
+
**Render the deck before you call a slide done.** Content that exceeds a slide
|
|
82
|
+
is clipped, and the runtime marks that section \`data-overflow\` — but only in a
|
|
83
|
+
browser. An agent authoring twenty slides in one pass never sees it, and ships
|
|
84
|
+
decks whose bottom lines are simply missing. One command checks all of them:
|
|
85
|
+
|
|
86
|
+
\`\`\`sh
|
|
87
|
+
npx decklight pdf deck.html -o /tmp/check.pdf
|
|
88
|
+
\`\`\`
|
|
89
|
+
|
|
90
|
+
Every \`⚠ slide N overflows\` line is a slide losing content: split it, cut it,
|
|
91
|
+
or move the detail into the notes. Run it after each batch of slides rather
|
|
92
|
+
than once at the end — and note that overflow is the *late* failure. A slide
|
|
93
|
+
that fits can still be too crowded to present from; prefer ~3–4 bullets or ~2
|
|
94
|
+
short paragraphs per column, and one idea per slide, over anything that merely
|
|
95
|
+
fits (SLIDE_DENSITY).
|
|
96
|
+
|
|
97
|
+
**For a comparison slide, use \`data-layout="split"\` — and do not also write
|
|
98
|
+
your own column flexbox.** Two sibling blocks become the columns, a third
|
|
99
|
+
becomes a full-width footer. A hand-rolled flex shell inside a section that
|
|
100
|
+
also carries \`data-layout="split"\` leaves two layout systems fighting, and the
|
|
101
|
+
visible result is the pinned title landing on top of the column headings.
|
|
102
|
+
COMPARISON_SLIDES has the markup. The engine marks the mixed state
|
|
103
|
+
\`data-split-conflict\` (assertable headlessly, like \`data-overflow\`), and the
|
|
104
|
+
same \`decklight pdf\` run above names such slides — one render check catches
|
|
105
|
+
both.
|
|
106
|
+
|
|
107
|
+
Speaker notes drive both live narration and the transcript/caption
|
|
108
|
+
features, so write them even for decks that will only ever be read: split
|
|
109
|
+
multi-beat notes with a bare \`⟨CLICK⟩\` line so narration and build steps
|
|
110
|
+
stay in sync (PRESENTING in the reference).
|
|
111
|
+
|
|
112
|
+
**Commit your own changes when an authoring server is running.** \`decklight
|
|
113
|
+
author\` auto-commits the deck, but on a timer and under a generic \`autosave\`
|
|
114
|
+
message — it cannot tell your edits from anyone else's, because it did not
|
|
115
|
+
start you. When you finish one logical change, say so:
|
|
116
|
+
|
|
117
|
+
\`\`\`sh
|
|
118
|
+
curl -sf -X POST localhost:8788/edit/commit \\
|
|
119
|
+
-H 'content-type: application/json' \\
|
|
120
|
+
-d '{"message":"split the crowded video slides"}'
|
|
121
|
+
\`\`\`
|
|
122
|
+
|
|
123
|
+
One call per logical change, with a subject describing THAT change — not
|
|
124
|
+
\"updated the deck\". It commits only the deck file, and does nothing when
|
|
125
|
+
nothing changed, so an extra call is harmless. If the port is not listening
|
|
126
|
+
there is no authoring server: skip it silently and carry on, never start one
|
|
127
|
+
yourself. This is what makes a history someone can read afterwards, instead
|
|
128
|
+
of a wall of identical timer commits.
|
|
129
|
+
`;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export const AGENTS_MARKER = '<!-- decklight:skill -->';
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The marked AGENTS.md block every AGENTS.md-reading agent (Codex,
|
|
136
|
+
* OpenCode, IBM Bob, …) shares. `referenceHref` is where that agent
|
|
137
|
+
* should look for the full contract, relative to the repo root. The
|
|
138
|
+
* marker pair lets `init`/`skills` refresh the block in place instead of
|
|
139
|
+
* appending a duplicate.
|
|
140
|
+
*/
|
|
141
|
+
export function agentsSection(referenceHref = '.claude/skills/decklight/reference.md') {
|
|
142
|
+
return `${AGENTS_MARKER}
|
|
143
|
+
## Decklight decks
|
|
144
|
+
|
|
145
|
+
This project contains a Decklight presentation (a single-file HTML deck —
|
|
146
|
+
see \`${referenceHref}\` for the full authoring
|
|
147
|
+
contract: builds, notes, SVG diagrams, themes, terminals, narration).
|
|
148
|
+
Read that file before adding or editing slides.
|
|
149
|
+
|
|
150
|
+
After editing slides, render the deck and check nothing is clipped:
|
|
151
|
+
\`npx decklight pdf deck.html -o /tmp/check.pdf\` — every \`⚠ slide N overflows\`
|
|
152
|
+
line is a slide losing content. Overflow is the late failure, though: a slide
|
|
153
|
+
that fits can still be too crowded, so keep to one idea and ~3–4 bullets per
|
|
154
|
+
column rather than to whatever renders.
|
|
155
|
+
|
|
156
|
+
When an authoring server is running (\`decklight author\`), commit each logical
|
|
157
|
+
change you finish rather than leaving it to the timer's generic \`autosave\`:
|
|
158
|
+
\`curl -sf -X POST localhost:8788/edit/commit -H 'content-type: application/json'
|
|
159
|
+
-d '{"message":"what this change did"}'\`. No server listening means no
|
|
160
|
+
authoring session — skip it and carry on.
|
|
161
|
+
|
|
162
|
+
Hit a Decklight bug? Run \`npx decklight report-bug\` for the environment
|
|
163
|
+
facts, then ask the user what happened, what they expected, and the smallest
|
|
164
|
+
repro — and show them the whole issue before filing anything.
|
|
165
|
+
${AGENTS_MARKER}
|
|
166
|
+
`;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The `decklight-report-bug` skill (#73): the conversational half of filing a
|
|
171
|
+
* bug, which the print-and-exit CLI deliberately does not do.
|
|
172
|
+
*
|
|
173
|
+
* Two consent gates are the point of this text, not decoration. A screenshot
|
|
174
|
+
* here is a HEADLESS RENDER of a deck file the user names — never a capture of
|
|
175
|
+
* their screen — and a public issue publishes whatever slide it shows, so the
|
|
176
|
+
* user has to say yes knowing both. And nothing is filed until they have seen
|
|
177
|
+
* the whole body. An agent that quietly attaches a slide or opens an issue on
|
|
178
|
+
* someone's behalf has done something they cannot take back.
|
|
179
|
+
*/
|
|
180
|
+
export function reportBugSkillMd() {
|
|
181
|
+
return `---
|
|
182
|
+
name: decklight-report-bug
|
|
183
|
+
description: File a Decklight bug report — gather version and environment facts, ask what broke and how to reproduce it, optionally attach a headless screenshot, and open the issue only after the user approves the full text. Use when the user hits a Decklight bug or asks to report one.
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
Help the user file a bug report against Decklight that a triager can act on
|
|
187
|
+
without a round trip. Work in this order.
|
|
188
|
+
|
|
189
|
+
**1. Collect the machine facts.** Run \`npx decklight report-bug\`. It prints a
|
|
190
|
+
markdown environment block and the issues URL and does nothing else — no
|
|
191
|
+
network, nothing sent. Use its output verbatim; do not retype it from memory.
|
|
192
|
+
|
|
193
|
+
**2. Ask what the command cannot know.** Three questions:
|
|
194
|
+
- what happened (ask for any error output **verbatim** — paraphrased errors
|
|
195
|
+
cost a round trip)
|
|
196
|
+
- what they expected instead
|
|
197
|
+
- the smallest deck and keypresses that reproduce it
|
|
198
|
+
|
|
199
|
+
**3. Offer a screenshot — and be exact about what one is.** Before capturing
|
|
200
|
+
anything, say plainly that it would be a **headless render of the deck file
|
|
201
|
+
they name**, produced with \`node tools/shot.mjs <deck> -o .shots/bug.png\`, and
|
|
202
|
+
**never a capture of their screen**; and that a public issue **publishes that
|
|
203
|
+
slide's content**, so a deck with anything confidential on it should not be
|
|
204
|
+
attached. No explicit yes means no screenshot — continue without one, it is
|
|
205
|
+
optional. If Chrome is not available (the environment block says so), skip
|
|
206
|
+
this step with a note rather than treating it as an error. When a shot is
|
|
207
|
+
taken, show the user the saved PNG **before** anything else happens.
|
|
208
|
+
|
|
209
|
+
**4. Show the whole issue, then ask.** Assemble the title, what happened, what
|
|
210
|
+
was expected, the repro, and the environment block, and show the user the
|
|
211
|
+
**complete** text. File it only on an explicit yes:
|
|
212
|
+
- \`gh issue create --repo decklight/decklight\` when \`gh\` is authenticated
|
|
213
|
+
- otherwise hand them the new-issue URL and the body to paste
|
|
214
|
+
|
|
215
|
+
GitHub has no supported CLI path for attaching an image to an issue, so a
|
|
216
|
+
screenshot cannot ride either route: finish by pointing at the saved PNG and
|
|
217
|
+
telling them to drag it into the issue.
|
|
218
|
+
|
|
219
|
+
**Say what has and has not been sent.** If the user declines at any gate, tell
|
|
220
|
+
them plainly that nothing was uploaded and nothing was filed.
|
|
221
|
+
`;
|
|
222
|
+
}
|
package/cli/skills.mjs
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Copyright 2026 Gilles Philippart
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* decklight skills — install the Decklight authoring skill for one or more
|
|
7
|
+
* AI coding agents, each in the convention it reads.
|
|
8
|
+
*
|
|
9
|
+
* decklight skills [agent…] [--dir path | --global] [--all] [--force]
|
|
10
|
+
decklight skills claude --pack [-o <file>]
|
|
11
|
+
*
|
|
12
|
+
* `init` scaffolds a deck *and* hands Claude a skill; this command is the
|
|
13
|
+
* skill on its own. Claude Code loads a real skill (`.claude/skills/`);
|
|
14
|
+
* Codex, OpenCode and IBM Bob read the `AGENTS.md` convention. Both point at
|
|
15
|
+
* a reference sliced from the installed version's SPEC.md so it can't drift.
|
|
16
|
+
*
|
|
17
|
+
* Two scopes. **Project** (default) installs into the current repo, next to
|
|
18
|
+
* the deck. **--global** installs into each agent's user-level config home
|
|
19
|
+
* (~/.claude, ~/.codex, …) so the skill is on hand in *every* project — a
|
|
20
|
+
* Decklight deck is one self-contained HTML file that plays on any machine
|
|
21
|
+
* for any purpose, so authoring it isn't tied to one codebase.
|
|
22
|
+
*
|
|
23
|
+
* The roster is data (see TARGETS): teaching a new agent its convention —
|
|
24
|
+
* and where its config lives globally — is one entry, mirroring agents.mjs.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import fs from 'node:fs';
|
|
28
|
+
import os from 'node:os';
|
|
29
|
+
import path from 'node:path';
|
|
30
|
+
|
|
31
|
+
import { onPath } from './agents.mjs';
|
|
32
|
+
import { makeFail, runMain } from './util.mjs';
|
|
33
|
+
import { isMain } from '../tools/args.mjs';
|
|
34
|
+
import { zipSync } from './zip.mjs';
|
|
35
|
+
import {
|
|
36
|
+
PKG, AGENTS_MARKER, agentsSection, claudeSkillMd, referenceDoc, reportBugSkillMd,
|
|
37
|
+
} from './skill-content.mjs';
|
|
38
|
+
|
|
39
|
+
// The reference doc, relative to whatever dir carries it. Skills keep their
|
|
40
|
+
// own copy next to SKILL.md; AGENTS.md agents keep one under .decklight/.
|
|
41
|
+
const SKILL_REF = 'reference.md';
|
|
42
|
+
const SHARED_REF = '.decklight/reference.md';
|
|
43
|
+
// Path from a project-root AGENTS.md to Claude's skill copy, so a repo with
|
|
44
|
+
// both installed shares one reference instead of carrying two.
|
|
45
|
+
const CLAUDE_REF = '.claude/skills/decklight/reference.md';
|
|
46
|
+
|
|
47
|
+
// An agent target is data: the label to print, the CLI `bin` to probe for
|
|
48
|
+
// auto-detection, the `kind` of layout it wants ('skill' is Claude's own
|
|
49
|
+
// .claude/skills/ format, 'agents' is the cross-agent AGENTS.md file), and
|
|
50
|
+
// `home(env)` — the user-level config dir it reads globally, honoring each
|
|
51
|
+
// agent's own override env var before falling back under $HOME.
|
|
52
|
+
export const TARGETS = {
|
|
53
|
+
claude: {
|
|
54
|
+
label: 'Claude Code', bin: 'claude', kind: 'skill',
|
|
55
|
+
home: (env) => env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), '.claude'),
|
|
56
|
+
},
|
|
57
|
+
codex: {
|
|
58
|
+
label: 'OpenAI Codex', bin: 'codex', kind: 'agents',
|
|
59
|
+
home: (env) => env.CODEX_HOME || path.join(os.homedir(), '.codex'),
|
|
60
|
+
},
|
|
61
|
+
opencode: {
|
|
62
|
+
label: 'OpenCode', bin: 'opencode', kind: 'agents',
|
|
63
|
+
home: (env) => path.join(env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config'), 'opencode'),
|
|
64
|
+
},
|
|
65
|
+
bob: {
|
|
66
|
+
label: 'IBM Bob', bin: 'bob', kind: 'agents',
|
|
67
|
+
home: (env) => env.BOB_HOME || path.join(os.homedir(), '.bob'),
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const fail = makeFail('skills');
|
|
72
|
+
|
|
73
|
+
const HELP = `decklight skills — install the Decklight authoring skill for AI agents
|
|
74
|
+
|
|
75
|
+
Usage:
|
|
76
|
+
decklight skills [agent…] [--dir path | --global] [--all] [--force]
|
|
77
|
+
decklight skills add|list|remove <name> marketplace skills
|
|
78
|
+
|
|
79
|
+
Agents:
|
|
80
|
+
${Object.entries(TARGETS).map(([k, t]) => ` ${k.padEnd(9)} ${t.label}`).join('\n')}
|
|
81
|
+
|
|
82
|
+
With no agent named, targets the ones detected on your PATH. Name one or
|
|
83
|
+
more explicitly (decklight skills claude codex) to override detection, or
|
|
84
|
+
--all to install for every supported agent.
|
|
85
|
+
|
|
86
|
+
Options:
|
|
87
|
+
--dir <path> target project directory (default: current directory)
|
|
88
|
+
--global install into each agent's user-level config home
|
|
89
|
+
(~/.claude, ~/.codex, ~/.config/opencode, ~/.bob) so the
|
|
90
|
+
skill is available in every project, not just this one
|
|
91
|
+
--all install for every supported agent
|
|
92
|
+
--pack write decklight-skill.zip to upload in your claude.ai skill
|
|
93
|
+
settings — the account-level route, for every project at once
|
|
94
|
+
(Claude's skill format only; -o names the file)
|
|
95
|
+
-o <file> where --pack writes [decklight-skill.zip]
|
|
96
|
+
--force overwrite files that already exist (default: refuses to
|
|
97
|
+
clobber a SKILL.md/reference.md; the AGENTS.md section is
|
|
98
|
+
always refreshed in place, never duplicated)
|
|
99
|
+
|
|
100
|
+
Claude Code gets a real skill (.claude/skills/decklight/); Codex, OpenCode
|
|
101
|
+
and IBM Bob get a marked section in AGENTS.md. Both point at a reference
|
|
102
|
+
sliced from this version's SPEC.md, so the contract never drifts from the
|
|
103
|
+
installed runtime.
|
|
104
|
+
|
|
105
|
+
Marketplace skills (decklight skills add <name>) are a different thing and
|
|
106
|
+
live somewhere else — ~/.decklight/skills/ — so they sit ALONGSIDE the
|
|
107
|
+
authoring skill above and never replace it. The command above always writes
|
|
108
|
+
the authoring skill; nothing installed from a catalog changes that.
|
|
109
|
+
`;
|
|
110
|
+
|
|
111
|
+
/** The agents found on PATH, in roster order (empty when none is). */
|
|
112
|
+
export function detectedTargets(hasBin = onPath) {
|
|
113
|
+
return Object.keys(TARGETS).filter((k) => hasBin(TARGETS[k].bin));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** The agents to target: an explicit list, everything (--all), or detected. */
|
|
117
|
+
function resolveTargets({ names, all, hasBin }) {
|
|
118
|
+
if (all) return Object.keys(TARGETS);
|
|
119
|
+
if (names.length) return names;
|
|
120
|
+
const detected = detectedTargets(hasBin);
|
|
121
|
+
if (detected.length) return { detected };
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** A path for humans: relative to cwd when inside it, else `~/…`, else absolute. */
|
|
126
|
+
export function display(file) {
|
|
127
|
+
const rel = path.relative(process.cwd(), file);
|
|
128
|
+
if (rel && !rel.startsWith('..') && !path.isAbsolute(rel)) return rel;
|
|
129
|
+
const home = os.homedir();
|
|
130
|
+
if (home && (file === home || file.startsWith(home + path.sep))) return '~' + file.slice(home.length);
|
|
131
|
+
return file;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Write a file, refusing to clobber an existing one without --force. */
|
|
135
|
+
function writeIfAbsent(file, content, force) {
|
|
136
|
+
if (fs.existsSync(file) && !force) {
|
|
137
|
+
fail(`${display(file)} already exists — pass --force to overwrite`);
|
|
138
|
+
}
|
|
139
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
140
|
+
fs.writeFileSync(file, content);
|
|
141
|
+
return file;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Add/refresh the marked Decklight block in the AGENTS.md under `dir`. */
|
|
145
|
+
function mergeAgentsMd(dir, refHref) {
|
|
146
|
+
const agentsPath = path.join(dir, 'AGENTS.md');
|
|
147
|
+
const section = agentsSection(refHref);
|
|
148
|
+
if (!fs.existsSync(agentsPath)) {
|
|
149
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
150
|
+
fs.writeFileSync(agentsPath, `# Agent notes\n\n${section}`);
|
|
151
|
+
return `created ${display(agentsPath)}`;
|
|
152
|
+
}
|
|
153
|
+
const existing = fs.readFileSync(agentsPath, 'utf8');
|
|
154
|
+
const markerRe = new RegExp(`${AGENTS_MARKER}[\\s\\S]*?${AGENTS_MARKER}\\n?`);
|
|
155
|
+
if (markerRe.test(existing)) {
|
|
156
|
+
fs.writeFileSync(agentsPath, existing.replace(markerRe, section));
|
|
157
|
+
return `refreshed the Decklight section in ${display(agentsPath)}`;
|
|
158
|
+
}
|
|
159
|
+
fs.writeFileSync(agentsPath, existing.replace(/\n*$/, '\n\n') + section);
|
|
160
|
+
return `appended a Decklight section to ${display(agentsPath)}`;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Write Claude's self-contained skill (SKILL.md + reference) into skillDir. */
|
|
164
|
+
function installClaudeSkill(skillDir, force, written) {
|
|
165
|
+
written.push(display(writeIfAbsent(path.join(skillDir, 'SKILL.md'), claudeSkillMd(SKILL_REF), force)));
|
|
166
|
+
written.push(display(writeIfAbsent(path.join(skillDir, SKILL_REF), referenceDoc(), force)));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The bug-reporting skill, a sibling of the authoring one (#73). Its own
|
|
171
|
+
* directory because Claude indexes one skill per SKILL.md, and it carries no
|
|
172
|
+
* reference doc — the authoring contract is not what filing a bug needs.
|
|
173
|
+
*/
|
|
174
|
+
function installReportBugSkill(skillsRoot, force, written) {
|
|
175
|
+
const dir = path.join(skillsRoot, 'decklight-report-bug');
|
|
176
|
+
written.push(display(writeIfAbsent(path.join(dir, 'SKILL.md'), reportBugSkillMd(), force)));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// --- project scope: one repo, one shared AGENTS.md for every agent ----------
|
|
180
|
+
|
|
181
|
+
function installProject(targets, dir, force) {
|
|
182
|
+
const root = path.resolve(dir);
|
|
183
|
+
fs.mkdirSync(root, { recursive: true });
|
|
184
|
+
|
|
185
|
+
const wantsClaude = targets.includes('claude');
|
|
186
|
+
const mdAgents = targets.filter((k) => TARGETS[k].kind === 'agents');
|
|
187
|
+
const written = [];
|
|
188
|
+
|
|
189
|
+
if (wantsClaude) {
|
|
190
|
+
const skillsRoot = path.join(root, '.claude', 'skills');
|
|
191
|
+
installClaudeSkill(path.join(skillsRoot, 'decklight'), force, written);
|
|
192
|
+
installReportBugSkill(skillsRoot, force, written);
|
|
193
|
+
}
|
|
194
|
+
if (mdAgents.length) {
|
|
195
|
+
// one reference copy: Claude's skill dir when Claude is also a target,
|
|
196
|
+
// else a standalone .decklight/ copy the AGENTS.md agents point at.
|
|
197
|
+
const refHref = wantsClaude ? CLAUDE_REF : SHARED_REF;
|
|
198
|
+
if (!wantsClaude) written.push(display(writeIfAbsent(path.join(root, SHARED_REF), referenceDoc(), force)));
|
|
199
|
+
written.push(mergeAgentsMd(root, refHref));
|
|
200
|
+
}
|
|
201
|
+
return written;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// --- global scope: each agent self-contained in its own config home ---------
|
|
205
|
+
|
|
206
|
+
function installGlobal(targets, env, force) {
|
|
207
|
+
const written = [];
|
|
208
|
+
for (const key of targets) {
|
|
209
|
+
const t = TARGETS[key];
|
|
210
|
+
const home = t.home(env);
|
|
211
|
+
if (t.kind === 'skill') {
|
|
212
|
+
installClaudeSkill(path.join(home, 'skills', 'decklight'), force, written);
|
|
213
|
+
installReportBugSkill(path.join(home, 'skills'), force, written);
|
|
214
|
+
} else {
|
|
215
|
+
written.push(display(writeIfAbsent(path.join(home, SHARED_REF), referenceDoc(), force)));
|
|
216
|
+
written.push(mergeAgentsMd(home, SHARED_REF));
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return written;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* The global install as one delegable step — what init's skill-scope question
|
|
224
|
+
* runs on a `g`: the same "detected on PATH" notice and summary lines
|
|
225
|
+
* `decklight skills --global` prints, over the same installGlobal machinery.
|
|
226
|
+
* `force: true` is init's refresh semantics — the skill files are derived
|
|
227
|
+
* content, so a re-run refreshes them instead of demanding --force.
|
|
228
|
+
*/
|
|
229
|
+
export function installGlobalSkill(targets, { env = process.env, force = false, detected = false, out = process.stdout } = {}) {
|
|
230
|
+
if (detected) out.write(`detected on PATH: ${targets.map((k) => TARGETS[k].label).join(', ')}\n`);
|
|
231
|
+
const written = installGlobal(targets, env, force);
|
|
232
|
+
out.write(`installed the Decklight skill (v${PKG.version}) globally for ${targets.map((k) => TARGETS[k].label).join(', ')}\n`);
|
|
233
|
+
for (const w of written) out.write(` ${w}\n`);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* The account-level distribution artifact (#80): the same two files a project
|
|
238
|
+
* install writes, in a standard archive you upload once instead of committing
|
|
239
|
+
* per repo. Rendered from skill-content.mjs like every other install, so the
|
|
240
|
+
* packed copy cannot drift from the installed one.
|
|
241
|
+
*
|
|
242
|
+
* The folder-with-SKILL.md-at-its-root shape is the ecosystem's interchange
|
|
243
|
+
* form, and is also directly usable as `unzip -d ~/.claude/skills/` — so the
|
|
244
|
+
* artifact stays useful even if an upload surface moves.
|
|
245
|
+
*/
|
|
246
|
+
export function packSkill() {
|
|
247
|
+
return zipSync([
|
|
248
|
+
{ name: 'decklight/SKILL.md', data: claudeSkillMd(SKILL_REF) },
|
|
249
|
+
{ name: `decklight/${SKILL_REF}`, data: referenceDoc() },
|
|
250
|
+
]);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* `add`, `list` and `remove` are marketplace skills (`UNITS#REST`); every
|
|
255
|
+
* other positional is an agent name. They share this command because they
|
|
256
|
+
* are the same subject — a skill — and a separate `decklight skill` beside
|
|
257
|
+
* `decklight skills` would be a footgun that reads as a typo either way.
|
|
258
|
+
*
|
|
259
|
+
* Unambiguous in practice: the agent roster is a closed set of nouns
|
|
260
|
+
* (`claude`, `codex`, …) and these are verbs, so no name can be both. A
|
|
261
|
+
* future agent called "list" would collide, and the roster is ours.
|
|
262
|
+
*/
|
|
263
|
+
const UNIT_SUBCOMMANDS = new Set(['add', 'list', 'remove']);
|
|
264
|
+
|
|
265
|
+
export async function skillsMain(argv = process.argv.slice(2), { hasBin = onPath, env = process.env } = {}) {
|
|
266
|
+
if (UNIT_SUBCOMMANDS.has(argv[0])) {
|
|
267
|
+
const { unitMain } = await import('./units.mjs');
|
|
268
|
+
const code = await unitMain('skill', argv);
|
|
269
|
+
if (code) process.exitCode = code;
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if (argv.includes('--help') || argv.includes('-h')) {
|
|
273
|
+
process.stdout.write(HELP);
|
|
274
|
+
return 0;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
let dir = null, all = false, force = false, global = false, pack = false, outFile = null;
|
|
278
|
+
const names = [];
|
|
279
|
+
for (let i = 0; i < argv.length; i++) {
|
|
280
|
+
const a = argv[i];
|
|
281
|
+
if (a === '--dir') dir = argv[++i];
|
|
282
|
+
else if (a === '--global' || a === '-g') global = true;
|
|
283
|
+
else if (a === '--all') all = true;
|
|
284
|
+
else if (a === '--force') force = true;
|
|
285
|
+
else if (a === '--pack') pack = true;
|
|
286
|
+
else if (a === '-o' || a === '--out') outFile = argv[++i];
|
|
287
|
+
else if (a.startsWith('-')) fail(`unknown argument: ${a}`);
|
|
288
|
+
else if (TARGETS[a]) names.push(a);
|
|
289
|
+
else fail(`unknown agent: ${a} (supported: ${Object.keys(TARGETS).join(', ')})`);
|
|
290
|
+
}
|
|
291
|
+
if (global && dir !== null) fail('--global and --dir are mutually exclusive');
|
|
292
|
+
|
|
293
|
+
if (pack) {
|
|
294
|
+
// --pack writes an artifact; the other flags describe installs. Rejecting
|
|
295
|
+
// the combinations outright beats silently honouring one and ignoring the
|
|
296
|
+
// rest, which is how you end up with a zip you think went somewhere.
|
|
297
|
+
if (global) fail('--pack and --global are different routes: --pack writes an archive to upload, --global installs into this machine');
|
|
298
|
+
if (dir !== null) fail('--pack and --dir are different things: --pack writes an archive, not a directory install — use -o to choose the file');
|
|
299
|
+
if (all) fail("--pack targets Claude's skill format only — drop --all");
|
|
300
|
+
const other = names.find((n) => n !== 'claude');
|
|
301
|
+
if (other) fail(`--pack targets Claude's skill format only — ${TARGETS[other].label} has no upload surface (use --global for it)`);
|
|
302
|
+
|
|
303
|
+
const file = path.resolve(outFile ?? 'decklight-skill.zip');
|
|
304
|
+
if (fs.existsSync(file) && !force) fail(`${display(file)} already exists — pass --force to overwrite`);
|
|
305
|
+
fs.writeFileSync(file, packSkill());
|
|
306
|
+
process.stdout.write(
|
|
307
|
+
`packed the Decklight skill (v${PKG.version}) → ${display(file)}\n`
|
|
308
|
+
+ ` decklight/SKILL.md\n decklight/${SKILL_REF}\n\n`
|
|
309
|
+
+ 'Two ways to reach Claude Code on the web:\n'
|
|
310
|
+
+ ' this repo commit .claude/skills/decklight/ — cloud sessions load it with the clone\n'
|
|
311
|
+
+ ` every project upload ${path.basename(file)} in your claude.ai skill settings\n`
|
|
312
|
+
+ ` (or: unzip ${path.basename(file)} -d ~/.claude/skills/ for local sessions)\n`,
|
|
313
|
+
);
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const resolved = resolveTargets({ names, all, hasBin });
|
|
318
|
+
if (!resolved) {
|
|
319
|
+
fail('no supported agent detected on PATH — name one '
|
|
320
|
+
+ `(${Object.keys(TARGETS).join(', ')}) or pass --all`);
|
|
321
|
+
}
|
|
322
|
+
const selected = Array.isArray(resolved) ? resolved : resolved.detected;
|
|
323
|
+
if (resolved.detected) {
|
|
324
|
+
process.stdout.write(`detected on PATH: ${selected.map((k) => TARGETS[k].label).join(', ')}\n`);
|
|
325
|
+
}
|
|
326
|
+
// de-dupe while keeping the roster's order for stable output
|
|
327
|
+
const targets = Object.keys(TARGETS).filter((k) => selected.includes(k));
|
|
328
|
+
|
|
329
|
+
const written = global ? installGlobal(targets, env, force) : installProject(targets, dir ?? '.', force);
|
|
330
|
+
|
|
331
|
+
const where = global ? 'globally' : `in ${display(path.resolve(dir ?? '.'))}`;
|
|
332
|
+
process.stdout.write(
|
|
333
|
+
`installed the Decklight skill (v${PKG.version}) ${where} for ${targets.map((k) => TARGETS[k].label).join(', ')}\n`,
|
|
334
|
+
);
|
|
335
|
+
for (const w of written) process.stdout.write(` ${w}\n`);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (isMain(import.meta.url)) process.exitCode = await runMain('skills', skillsMain);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Copyright 2026 Gilles Philippart
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Outliving your parent is the one way a decklight server leaks.
|
|
6
|
+
*
|
|
7
|
+
* `author` runs the deck server and the bridges as child processes and reaps
|
|
8
|
+
* them on its way out — but only for the signals it can catch. SIGKILL it (a
|
|
9
|
+
* test harness, the OOM killer, an impatient `kill -9`) and author vanishes
|
|
10
|
+
* with no chance to pass the signal on: the servers are reparented to init and
|
|
11
|
+
* go on holding their ports, and the next `decklight author` finds a port
|
|
12
|
+
* taken by something nobody remembers starting.
|
|
13
|
+
*
|
|
14
|
+
* The fix is a channel the OS closes for us. author opens a pipe to each
|
|
15
|
+
* child's stdin and never writes a byte to it; the child reads it and exits at
|
|
16
|
+
* EOF. However author dies, the write end dies with it and every child hears
|
|
17
|
+
* about it at once — no polling, no pid to watch, no signal to catch, and
|
|
18
|
+
* nothing for a dying parent to remember to do.
|
|
19
|
+
*
|
|
20
|
+
* Opt-in, because stdin means something else to a server you started
|
|
21
|
+
* yourself: `node cli/edit.mjs deck.html < /dev/null` would EOF immediately,
|
|
22
|
+
* and a terminal never EOFs at all. author sets LEASH in the child's
|
|
23
|
+
* environment; only then does anything here read stdin.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** Set to '1' by a supervising parent in the child's environment. */
|
|
27
|
+
export const LEASH = 'DECKLIGHT_PARENT_PIPE';
|
|
28
|
+
|
|
29
|
+
/** Is this process on a parent's leash? */
|
|
30
|
+
export const onLeash = (env = process.env) => env[LEASH] === '1';
|
|
31
|
+
|
|
32
|
+
/** The environment a supervising parent hands a child. */
|
|
33
|
+
export const leashEnv = (env = process.env) => ({ ...env, [LEASH]: '1' });
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Exit when the supervising parent goes away. A no-op when unsupervised, so
|
|
37
|
+
* the dispatcher can call it unconditionally. Returns whether it armed.
|
|
38
|
+
*
|
|
39
|
+
* stdin is resumed (nothing else is reading it, so without a consumer the
|
|
40
|
+
* `end` never arrives) and then unref'd, so holding the leash cannot by itself
|
|
41
|
+
* keep a command alive that would otherwise have finished.
|
|
42
|
+
*/
|
|
43
|
+
export function exitWhenOrphaned({
|
|
44
|
+
env = process.env,
|
|
45
|
+
stdin = process.stdin,
|
|
46
|
+
exit = (code) => process.exit(code),
|
|
47
|
+
} = {}) {
|
|
48
|
+
if (!onLeash(env)) return false;
|
|
49
|
+
// An orphan is not a failure — the parent asked for this by dying.
|
|
50
|
+
const done = () => exit(0);
|
|
51
|
+
stdin.on('end', done);
|
|
52
|
+
stdin.on('close', done);
|
|
53
|
+
stdin.on('error', done); // a broken pipe says the same thing as EOF
|
|
54
|
+
stdin.resume();
|
|
55
|
+
stdin.unref?.();
|
|
56
|
+
return true;
|
|
57
|
+
}
|