linejig 0.0.0-stage → 0.2.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/LICENSE ADDED
@@ -0,0 +1,16 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Linejig
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6
+ documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8
+ persons to whom the Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11
+ Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,90 @@
1
- # Temporary Holding Version
1
+ # linejig
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Linejig is an agent skill that draws interactive 3D line illustrations in three.js. It was published as
4
+ `keyline-3d` before; `npx linejig install` replaces an install under that name.
5
+
6
+ One object from a few rounded solids, in an isometric view, one fine line width, with a hero part that answers hover
7
+ and click. Every figure keeps one consistent illustration style. Use it for empty states, 404 pages, onboarding steps
8
+ and heroes. Illustration only, with no captions, logos or generated images.
9
+
10
+ This free skill draws in line art: white, black and a grey ramp. The Brand and Dots styles (the hero in your brand
11
+ colour; the figure as a dot matrix) are a separate Pro skill, `linejig-pro`, from https://linejig.com/pricing. After
12
+ purchase, install it from the download with `npx linejig install --pro ~/Downloads/linejig-pro.zip`.
13
+
14
+ It is one skill folder (`SKILL.md` plus `references/`) in the open Agent Skills format, so the same files work in
15
+ Claude Code, OpenAI Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and other agents that read skills.
16
+
17
+ ## Install
18
+
19
+ ```sh
20
+ npx linejig install
21
+ ```
22
+
23
+ The installer finds the coding agents on your machine and copies the skill to each one's own skills folder. Tools
24
+ that share `~/.agents/skills` get one copy there. If it finds none, it installs for Claude Code, as earlier versions
25
+ did. It needs Node 18 or later and has no dependencies.
26
+
27
+ | Command | What it does |
28
+ |---|---|
29
+ | `npx linejig install` | Install for every agent it finds |
30
+ | `npx linejig install --agent cursor --agent codex` | Only these agents (`--agent` repeats) |
31
+ | `npx linejig install --all` | Every agent it knows, found or not |
32
+ | `npx linejig install --project` | This project only: `.claude/skills`, `.agents/skills` or `.windsurf/skills` |
33
+ | `npx linejig install --project --agent agents-md` | Also add a marked block to `./AGENTS.md` (merged, never overwritten) |
34
+ | `npx linejig install --dry-run` | Say what would change, change nothing |
35
+ | `npx linejig install --force` | Replace a copy that differs from this version |
36
+ | `npx linejig install --keep-old` | Leave a copy under the earlier name `keyline-3d` in place (by default install replaces it) |
37
+ | `npx linejig list` | Show each agent, whether it was found, where it looks, what is installed |
38
+ | `npx linejig uninstall` | Remove every copy it can find (add `--project` for project copies and the AGENTS.md block) |
39
+ | `npx linejig print` | Print the whole skill as one Markdown file (`--compact` for the short version) |
40
+
41
+ Running `install` again is safe: an identical copy is left alone, and the AGENTS.md block is replaced in place.
42
+ If a copy under the earlier name `keyline-3d` is there, `install` removes it (its AGENTS.md block becomes the
43
+ `linejig` block, in place) and `uninstall` removes both names.
44
+
45
+ ## Where it goes
46
+
47
+ | Agent | `--agent` | User-level folder | Project folder | Check it worked |
48
+ |---|---|---|---|---|
49
+ | Claude Code | `claude-code` | `~/.claude/skills/` | `.claude/skills/` | run `/skills` and look for linejig |
50
+ | OpenAI Codex | `codex` | `~/.agents/skills/` | `.agents/skills/` | run `/skills`, or type `$` |
51
+ | Cursor | `cursor` | `~/.agents/skills/` | `.agents/skills/` | restart, then Customize > Skills, or type `/` in Agent chat |
52
+ | Gemini CLI | `gemini` | `~/.agents/skills/` | `.agents/skills/` | `gemini skills list` |
53
+ | GitHub Copilot (VS Code agent mode, Copilot CLI, cloud agent) | `copilot` | `~/.copilot/skills/` | `.agents/skills/` | type `/` in a new chat |
54
+ | Windsurf | `windsurf` | `~/.codeium/windsurf/skills/` | `.windsurf/skills/` | Customize > Skills, or `/linejig` |
55
+ | Devin Desktop and CLI | `devin` | `~/.agents/skills/` | `.agents/skills/` | Customize > Skills, or `/linejig` |
56
+ | OpenCode | `opencode` | `~/.agents/skills/` | `.agents/skills/` | ask it to load `@linejig` |
57
+ | Amp | `amp` | `~/.agents/skills/` | `.agents/skills/` | `amp skills list` |
58
+ | goose | `goose` | `~/.agents/skills/` | `.agents/skills/` | `goose skills list` |
59
+ | Any tool that reads AGENTS.md | `agents-md` | (project only) | `.agents/skills/` and a block in `AGENTS.md` | open `AGENTS.md` |
60
+
61
+ Copilot's cloud agent reads project skills from the repository, so commit `.agents/skills/linejig` (installed
62
+ with `--project`) for it. Each folder comes from the tool's own documentation, read in November 2026.
63
+
64
+ ### Other ways in
65
+
66
+ - **The skills CLI:** `npx skills add <owner>/<repo>` installs from a repo with the skill at `skills/linejig/`.
67
+ - **Claude Code plugin:** from a repo with a `.claude-plugin/marketplace.json`, run
68
+ `/plugin marketplace add <owner>/<repo>`, then `/plugin install linejig@linejig`.
69
+ - **Chat tools with no skill folders** (ChatGPT, Grok, Gemini and Claude.ai projects): run
70
+ `npx linejig print > linejig.md` and attach the file to a project, or paste the output of
71
+ `npx linejig print --compact` (about 6,600 characters) into instructions that allow that much.
72
+
73
+ ## Use
74
+
75
+ Ask in plain words and name the skill:
76
+
77
+ - draw an empty state for no messages with linejig
78
+ - make a 404 illustration with linejig for our docs site
79
+ - put a Linejig figure in this shadcn card, matching our theme
80
+
81
+ ## Links
82
+
83
+ - Library of finished figures: https://linejig.com/library.html
84
+ - Kernel (every figure imports it): https://linejig.com/kernel/keyline3d.js
85
+ - Install page: https://linejig.com/skill
86
+
87
+ ## Licence and credits
88
+
89
+ The package code is MIT. The line rules build on Hairline by Lucas Marques (MIT):
90
+ https://hairline.lucasmarkes.com, published on npm as `@lucasmarkes/hairline`.
package/bin/cli.mjs ADDED
@@ -0,0 +1,331 @@
1
+ #!/usr/bin/env node
2
+ // linejig installer: copies the skill folder to every installed coding agent's skills directory.
3
+ // Zero dependencies, Node 18+. The paths and checks come from each tool's own docs (README.md, "Where it goes").
4
+ import { cpSync, existsSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync, mkdirSync, mkdtempSync } from 'node:fs';
5
+ import { homedir, tmpdir } from 'node:os';
6
+ import { execFileSync } from 'node:child_process';
7
+ import { delimiter, dirname, join, relative, sep } from 'node:path';
8
+ import { fileURLToPath } from 'node:url';
9
+ import { buildFull, buildCompact } from '../lib/bundle.mjs';
10
+ import { NAME, OLD_NAMES, PRO, SITE } from '../lib/names.mjs'; // the names and the site URL live there, in one place
11
+ const FREE_SOURCE = join(dirname(fileURLToPath(import.meta.url)), '..', 'skill', NAME);
12
+ const HOME = homedir(), CWD = process.cwd();
13
+
14
+ // user: the user-level skills directory (relative to HOME); project: the project-level one (relative to the cwd).
15
+ // Several tools read the shared ~/.agents/skills and .agents/skills, so one copy there serves all of them.
16
+ // detect: config directories under HOME and commands on PATH that show the tool is installed.
17
+ const AGENTS = [
18
+ { id: 'claude-code', aliases: ['claude'], name: 'Claude Code', user: '.claude/skills', project: '.claude/skills',
19
+ detect: { dirs: ['.claude'], bins: ['claude'] },
20
+ check: `run /skills in Claude Code and look for ${NAME} (it picks up new skills without a restart)` },
21
+ { id: 'codex', aliases: ['openai-codex'], name: 'OpenAI Codex', user: '.agents/skills', project: '.agents/skills',
22
+ detect: { dirs: ['.codex'], bins: ['codex'] },
23
+ check: `in Codex run /skills, or type $ and look for ${NAME} (restart Codex if it is missing)` },
24
+ { id: 'cursor', name: 'Cursor', user: '.agents/skills', project: '.agents/skills',
25
+ detect: { dirs: ['.cursor'], bins: ['cursor', 'cursor-agent'] },
26
+ check: `restart Cursor, then open Customize > Skills, or type / in Agent chat and search ${NAME}` },
27
+ { id: 'gemini', aliases: ['gemini-cli'], name: 'Gemini CLI', user: '.agents/skills', project: '.agents/skills',
28
+ detect: { dirs: ['.gemini'], bins: ['gemini'] },
29
+ check: `run \`gemini skills list\` (or /skills list in a session) and look for ${NAME}` },
30
+ { id: 'copilot', aliases: ['github-copilot', 'vscode'], name: 'GitHub Copilot', user: '.copilot/skills',
31
+ project: '.agents/skills', detect: { dirs: ['.copilot'], bins: ['copilot'], ext: ['github.copilot'] },
32
+ check: `in a new Copilot chat (VS Code agent mode or Copilot CLI) type / and look for ${NAME}` },
33
+ { id: 'windsurf', name: 'Windsurf', user: '.codeium/windsurf/skills', project: '.windsurf/skills',
34
+ detect: { dirs: ['.codeium/windsurf'], bins: ['windsurf'] },
35
+ check: `open Customize > Skills in Windsurf, or type /${NAME} in Cascade` },
36
+ { id: 'devin', aliases: ['devin-desktop'], name: 'Devin (Desktop and CLI)', user: '.agents/skills', project: '.agents/skills',
37
+ detect: { dirs: ['.config/devin', '.devin'], bins: ['devin'] },
38
+ check: `open Customize > Skills, or type /${NAME}` },
39
+ { id: 'opencode', name: 'OpenCode', user: '.agents/skills', project: '.agents/skills',
40
+ detect: { dirs: ['.config/opencode'], bins: ['opencode'] },
41
+ check: `ask OpenCode to "load @${NAME}" and look for the skill tool call` },
42
+ { id: 'amp', name: 'Amp', user: '.agents/skills', project: '.agents/skills',
43
+ detect: { dirs: ['.config/amp'], bins: ['amp'] },
44
+ check: `run \`amp skills list\` and look for ${NAME}` },
45
+ { id: 'goose', name: 'goose', user: '.agents/skills', project: '.agents/skills',
46
+ detect: { dirs: ['.config/goose'], bins: ['goose'] },
47
+ check: `run \`goose skills list\` and look for ${NAME}` },
48
+ { id: 'agents-md', name: 'AGENTS.md (any tool that reads it)', user: null, project: '.agents/skills', block: 'AGENTS.md',
49
+ detect: null,
50
+ check: `open AGENTS.md: the ${NAME} block points the agent at .agents/skills/${NAME}/SKILL.md` },
51
+ ];
52
+
53
+ const HELP = `${NAME}: an agent skill for interactive 3D line illustrations in three.js.
54
+
55
+ Usage
56
+ npx ${NAME} install Install for every coding agent found on this machine (the free Line art skill)
57
+ npx ${NAME} install --pro <linejig-pro.zip or folder>
58
+ Install ${PRO}, the Pro styles (Brand, Dots), from the download you got after purchase
59
+ npx ${NAME} uninstall Remove every copy this installer can find
60
+ npx ${NAME} list Show the agents, where each looks, and what is installed (also --list)
61
+ npx ${NAME} print [--compact] Print the skill as one Markdown file, for chat tools (ChatGPT, Grok, ...)
62
+
63
+ Options
64
+ --agent <id> Only this agent (repeatable): ${AGENTS.map((a) => a.id).join(', ')}
65
+ --all Every agent, found or not
66
+ --project Use this project's folders (.claude/skills, .agents/skills, ...) instead of your home folder;
67
+ with --agent agents-md (or --all) it also adds a marked block to ./AGENTS.md
68
+ --dry-run Say what would change, and change nothing
69
+ --force Replace a copy that differs from this version
70
+ --keep-old Leave a copy under an earlier name (${OLD_NAMES.join(', ')}) in place instead of replacing it
71
+ --pro <path> Install (or with uninstall, remove) the Pro skill; install needs the downloaded zip or folder
72
+ --help Show this help
73
+
74
+ This skill was called ${OLD_NAMES.join(', ')} before: install replaces a copy under that name, and uninstall removes it.
75
+
76
+ More: ${SITE}/skill`;
77
+
78
+ // ---------- arguments ----------
79
+ function fail(msg) { console.error(`${NAME}: ${msg}\nRun "npx ${NAME} --help" for usage.`); process.exit(1); }
80
+ const argv = process.argv.slice(2), flags = new Set(), agentsAsked = [], commands = [];
81
+ let proPath = null;
82
+ for (let i = 0; i < argv.length; i++) {
83
+ const a = argv[i];
84
+ if (a === '--agent' || a === '-a') { if (!argv[i + 1] || argv[i + 1].startsWith('-')) fail('--agent needs an agent id'); agentsAsked.push(argv[++i]); }
85
+ else if (a.startsWith('--agent=')) agentsAsked.push(a.slice(8));
86
+ else if (a === '--pro') { flags.add('--pro'); if (argv[i + 1] && !argv[i + 1].startsWith('-') && !['install', 'uninstall', 'list', 'print'].includes(argv[i + 1])) proPath = argv[++i]; }
87
+ else if (a.startsWith('--pro=')) { flags.add('--pro'); proPath = a.slice(6); }
88
+ else if (a.startsWith('-')) flags.add(a);
89
+ else commands.push(a);
90
+ }
91
+ const KNOWN = new Set(['--pro', '--all', '--project', '--dry-run', '--force', '--keep-old', '--help', '-h', '--list', '--compact']);
92
+ if (flags.has('--list')) commands.unshift('list');
93
+ const unknown = [...flags].filter((f) => !KNOWN.has(f));
94
+ if (flags.has('--help') || flags.has('-h') || commands.length === 0) { console.log(HELP); process.exit(commands.length || flags.size ? 0 : 1); }
95
+ if (unknown.length) fail(`unknown option ${unknown.join(', ')}`);
96
+ if (commands.length > 1) fail(`expected one command, got ${commands.join(' ')}`);
97
+ const IS_PRO = flags.has('--pro');
98
+ const SKILL_ID = IS_PRO ? PRO : NAME; // which skill this run installs or removes
99
+ if (IS_PRO && commands[0] === 'install' && !proPath) fail(`--pro needs the path to ${PRO}.zip or its folder (from your purchase email)`);
100
+ if (IS_PRO && commands[0] === 'print') fail('print makes the free skill only; the Pro download has its own single-file edition');
101
+ const PROJECT = flags.has('--project'), DRY = flags.has('--dry-run'), FORCE = flags.has('--force'), KEEP_OLD = flags.has('--keep-old');
102
+ const byId = (id) => AGENTS.find((a) => a.id === id || (a.aliases || []).includes(id));
103
+ for (const id of agentsAsked) if (!byId(id)) fail(`unknown agent "${id}". Known: ${AGENTS.map((a) => a.id).join(', ')}`);
104
+
105
+ // ---------- detection ----------
106
+ const onPath = (bin) => (process.env.PATH || '').split(delimiter).filter(Boolean).some((d) =>
107
+ (process.platform === 'win32' ? ['', '.exe', '.cmd', '.bat'] : ['']).some((x) => existsSync(join(d, bin + x))));
108
+ function detected(a) {
109
+ if (!a.detect) return null;
110
+ for (const d of a.detect.dirs || []) if (existsSync(join(HOME, d))) return `~/${d}`;
111
+ for (const b of a.detect.bins || []) if (onPath(b)) return `${b} on PATH`;
112
+ for (const e of a.detect.ext || []) {
113
+ const ext = join(HOME, '.vscode', 'extensions');
114
+ if (existsSync(ext) && readdirSync(ext).some((f) => f.startsWith(e))) return 'its VS Code extension';
115
+ }
116
+ return null;
117
+ }
118
+ const tilde = (p) => (p === HOME || p.startsWith(HOME + sep) ? '~' + p.slice(HOME.length) : p);
119
+ const show = (p) => (PROJECT ? (relative(CWD, p) || '.') : tilde(p));
120
+ const base = (a) => (PROJECT ? (a.project && join(CWD, a.project)) : (a.user && join(HOME, a.user)));
121
+
122
+ function chooseAgents({ forRemoval = false } = {}) {
123
+ if (agentsAsked.length) return [...new Set(agentsAsked.map((id) => byId(id)))];
124
+ if (flags.has('--all') || forRemoval) return AGENTS;
125
+ const found = AGENTS.filter((a) => detected(a));
126
+ if (found.length) return found;
127
+ console.log('No coding agent found on this machine; installing for Claude Code, as earlier versions did.\n' +
128
+ `Use --agent <id> or --all for others ("npx ${NAME} list" shows them).\n`);
129
+ return [byId('claude-code')];
130
+ }
131
+
132
+ // ---------- the Pro skill: from the buyer's download, a zip or a folder ----------
133
+ function findSkill(dir, depth = 0) { // the folder under dir whose SKILL.md says name: linejig-pro
134
+ if (existsSync(join(dir, 'SKILL.md')) && ours(dir, PRO)) return dir;
135
+ if (depth > 2) return null;
136
+ for (const f of readdirSync(dir)) {
137
+ const p = join(dir, f);
138
+ if (!f.startsWith('.') && f !== '__MACOSX' && statSync(p).isDirectory()) { const hit = findSkill(p, depth + 1); if (hit) return hit; }
139
+ }
140
+ return null;
141
+ }
142
+ function proSource() {
143
+ const p = proPath.replace(/^~(?=$|[\\/])/, HOME);
144
+ if (!existsSync(p)) fail(`no file or folder at ${proPath}`);
145
+ let dir = p;
146
+ if (!statSync(p).isDirectory()) {
147
+ dir = mkdtempSync(join(tmpdir(), `${PRO}-`));
148
+ process.on('exit', () => rmSync(dir, { recursive: true, force: true }));
149
+ try { execFileSync('tar', ['-xf', p, '-C', dir], { stdio: 'ignore' }); } // bsdtar reads zip on macOS and Windows
150
+ catch { try { execFileSync('unzip', ['-q', p, '-d', dir], { stdio: 'ignore' }); } catch { fail(`could not unpack ${proPath}; unzip it and pass the folder instead`); } }
151
+ }
152
+ const hit = findSkill(dir);
153
+ if (!hit) fail(`${proPath} does not hold the ${PRO} skill (a folder whose SKILL.md says name: ${PRO})`);
154
+ return hit;
155
+ }
156
+
157
+ // ---------- the skill folder ----------
158
+ function tree(dir, at = '') { // every file under dir, as { relativePath: contents }
159
+ const out = {};
160
+ for (const f of readdirSync(join(dir, at))) {
161
+ const p = at ? `${at}/${f}` : f, full = join(dir, p);
162
+ if (statSync(full).isDirectory()) Object.assign(out, tree(dir, p)); else out[p] = readFileSync(full);
163
+ }
164
+ return out;
165
+ }
166
+ function same(a, b) {
167
+ const ta = tree(a), tb = tree(b), ka = Object.keys(ta).sort(), kb = Object.keys(tb).sort();
168
+ return ka.length === kb.length && ka.every((k, i) => k === kb[i] && ta[k].equals(tb[k]));
169
+ }
170
+ // a skill folder is ours when its SKILL.md says name: <id> (this name, or an earlier one for an old copy)
171
+ const ours = (dir, id = NAME) => { try { return new RegExp(`^name:\\s*${id}\\s*$`, 'm').test(readFileSync(join(dir, 'SKILL.md'), 'utf8')); } catch { return false; } };
172
+ // copies under an earlier name in a skills directory, which this one replaces
173
+ const oldCopies = (dir) => OLD_NAMES.map((id) => ({ id, path: join(dir, id) })).filter((o) => existsSync(o.path));
174
+
175
+ // ---------- the AGENTS.md block: marked, merged, never touching the rest of the file ----------
176
+ // A block under an earlier name (<!-- keyline-3d:start ... -->) is the same block from an older version: install
177
+ // replaces it with this one in place, and uninstall removes it.
178
+ const esc = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
179
+ const START = `<!-- ${NAME}:start (added by npx ${NAME}; replaced on reinstall, removed by "npx ${NAME} uninstall --project --agent agents-md") -->`;
180
+ const END = `<!-- ${NAME}:end -->`;
181
+ const BLOCK = `${START}
182
+ ## 3D line illustrations
183
+
184
+ For interactive 3D line illustrations (empty states, 404 pages, onboarding steps, heroes, slides), read
185
+ \`.agents/skills/${NAME}/SKILL.md\` first and follow it, opening its \`references/\` files as it says.
186
+ ${END}`;
187
+ const blockOf = (id) => new RegExp(`<!-- ${esc(id)}:start[^\\n]*-->[\\s\\S]*?<!-- ${esc(id)}:end -->`);
188
+ const blockRe = blockOf(NAME), oldBlockRes = OLD_NAMES.map(blockOf);
189
+ function readBlockFile(file) {
190
+ if (!existsSync(file)) return { text: null, eol: '\n' };
191
+ const raw = readFileSync(file, 'utf8'), eol = raw.includes('\r\n') ? '\r\n' : '\n';
192
+ for (const id of [NAME, ...OLD_NAMES]) {
193
+ const starts = raw.split(`<!-- ${id}:start`).length - 1, ends = raw.split(`<!-- ${id}:end -->`).length - 1;
194
+ if (starts !== ends || starts > 1) throw new Error(`${show(file)} has a broken or repeated ${id} block; fix it by hand, then run again`);
195
+ }
196
+ return { text: raw.replace(/\r\n/g, '\n'), eol };
197
+ }
198
+ const cut = (text, re) => text.replace(new RegExp(`\\n*${re.source}\\n?`), '\n').replace(/^\n+/, '');
199
+ function writeBlock(file) {
200
+ const { text, eol } = readBlockFile(file);
201
+ let next, how;
202
+ const old = text !== null && oldBlockRes.find((re) => re.test(text));
203
+ if (text === null) { next = BLOCK + '\n'; how = 'created'; }
204
+ else if (blockRe.test(text)) { next = text.replace(blockRe, BLOCK); how = 'updated'; }
205
+ else if (old) { next = text.replace(old, BLOCK); how = `updated (it replaced the block from the earlier name, ${OLD_NAMES.join(', ')})`; }
206
+ else { next = (text.trim() ? text.replace(/\s*$/, '\n\n') : '') + BLOCK + '\n'; how = 'appended'; }
207
+ for (const re of oldBlockRes) if (re !== old && re.test(next)) { next = cut(next, re); how += ', and removed an older block'; }
208
+ if (text === next) return 'unchanged';
209
+ if (!DRY) writeFileSync(file, next.replace(/\n/g, eol));
210
+ return how;
211
+ }
212
+ function removeBlock(file) {
213
+ const { text, eol } = readBlockFile(file);
214
+ if (text === null) return 'absent';
215
+ let next = text;
216
+ for (const re of [blockRe, ...oldBlockRes]) if (re.test(next)) next = cut(next, re);
217
+ if (next === text) return 'absent';
218
+ const empty = !next.trim();
219
+ if (!DRY) { if (empty) rmSync(file); else writeFileSync(file, next.replace(/\s*$/, '\n').replace(/\n/g, eol)); }
220
+ return empty ? 'removed (the file held nothing else, so it was deleted)' : 'removed';
221
+ }
222
+
223
+ // ---------- commands ----------
224
+ let problems = 0;
225
+ const verb = (done, would) => (DRY ? would : done);
226
+
227
+ function groups(list) { // agents that share one directory get one copy
228
+ const out = new Map();
229
+ for (const a of list) {
230
+ const b = base(a);
231
+ if (!b) { if (agentsAsked.length) { problems++; console.log(`${a.name}: there is only a project location; add --project.`); } continue; }
232
+ if (!out.has(b)) out.set(b, []);
233
+ out.get(b).push(a);
234
+ }
235
+ return out;
236
+ }
237
+
238
+ // a copy under an earlier name, next to the new one: replaced (removed) unless --keep-old; a folder under that name
239
+ // that is not this skill is left alone
240
+ function replaceOld(dir) {
241
+ for (const o of oldCopies(dir)) {
242
+ if (!ours(o.path, o.id)) { console.log(`${show(o.path)}: left alone: it has the earlier name ${o.id} but is not this skill`); continue; }
243
+ if (KEEP_OLD) { console.log(`${show(o.path)}: kept (--keep-old): the earlier ${o.id} copy; agents will see both until you remove it`); continue; }
244
+ if (!DRY) rmSync(o.path, { recursive: true, force: true });
245
+ console.log(`${show(o.path)}: ${verb('removed', 'would remove')}: the earlier ${o.id} copy, replaced by ${NAME}`);
246
+ }
247
+ }
248
+
249
+ function install() {
250
+ const SOURCE = IS_PRO ? proSource() : FREE_SOURCE;
251
+ if (!existsSync(join(SOURCE, 'SKILL.md'))) fail(`the packaged skill is missing at ${SOURCE}`);
252
+ if (IS_PRO) for (const a of chooseAgents()) { const b = base(a); if (b && !existsSync(join(b, NAME))) console.log(`Note: ${PRO} works with the free ${NAME} skill, which is not in ${show(b)} yet: run "npx ${NAME} install" as well.`); }
253
+ const list = chooseAgents();
254
+ if (PROJECT) for (const a of list) if (a.block) readBlockFile(join(CWD, a.block)); // refuse a broken block before writing anything
255
+ if (DRY) console.log('Dry run: nothing is written.\n');
256
+ for (const [dir, agents] of groups(list)) {
257
+ const target = join(dir, SKILL_ID);
258
+ let what;
259
+ if (!existsSync(target)) {
260
+ if (!DRY) { mkdirSync(dir, { recursive: true }); cpSync(SOURCE, target, { recursive: true }); }
261
+ what = verb('installed', 'would install');
262
+ } else if (same(SOURCE, target)) what = 'already up to date';
263
+ else if (FORCE) {
264
+ if (!DRY) { rmSync(target, { recursive: true, force: true }); cpSync(SOURCE, target, { recursive: true }); }
265
+ what = verb('replaced', 'would replace');
266
+ } else {
267
+ problems++;
268
+ const when = statSync(target).mtime.toISOString().slice(0, 10);
269
+ what = `NOT changed: a different copy is there (modified ${when}${ours(target, SKILL_ID) ? '' : `, and it is not ${SKILL_ID}`}). Run again with --force to replace it`;
270
+ }
271
+ console.log(`${show(target)}: ${what}`);
272
+ if (!IS_PRO) replaceOld(dir);
273
+ for (const a of agents) {
274
+ if (a.block && !IS_PRO) { const r = writeBlock(join(CWD, a.block)); console.log(` ${a.block}: block ${r === 'unchanged' ? 'already up to date' : verb(r, 'would be ' + r)}`); }
275
+ console.log(` ${a.name}, check it worked: ${a.check.replaceAll(NAME, SKILL_ID)}`);
276
+ }
277
+ }
278
+ console.log(IS_PRO ? `\nThen ask, for example: draw an empty state for no messages with ${NAME}, in the brand style in #2f6bff`
279
+ : `\nThen ask, for example: draw an empty state for no messages with ${NAME}`);
280
+ }
281
+
282
+ function uninstall() {
283
+ const list = chooseAgents({ forRemoval: true });
284
+ if (DRY) console.log('Dry run: nothing is removed.\n');
285
+ let any = false;
286
+ for (const [dir, agents] of groups(list)) {
287
+ for (const a of agents) {
288
+ if (!a.block || !PROJECT || IS_PRO) continue;
289
+ const r = removeBlock(join(CWD, a.block));
290
+ if (r !== 'absent') { any = true; console.log(`${a.block}: block ${DRY ? 'would be ' : ''}${r}`); }
291
+ }
292
+ for (const [id, target] of IS_PRO ? [[PRO, join(dir, PRO)]] : [[NAME, join(dir, NAME)], ...oldCopies(dir).map((o) => [o.id, o.path])]) {
293
+ if (!existsSync(target)) continue;
294
+ if (id !== NAME && id !== PRO && !ours(target, id)) { console.log(`${show(target)}: left alone: it has the earlier name ${id} but is not this skill`); continue; }
295
+ any = true;
296
+ if (!ours(target, id) && !FORCE) { problems++; console.log(`${show(target)}: NOT removed: it is not the ${id} skill. Use --force to remove it anyway`); continue; }
297
+ if (!DRY) rmSync(target, { recursive: true, force: true });
298
+ console.log(`${show(target)}: ${verb('removed', 'would remove')}${id === NAME || id === PRO ? '' : ` (the earlier name, ${id})`} (read by ${agents.map((a) => a.name).join(', ')})`);
299
+ }
300
+ }
301
+ if (!any) console.log(`Nothing to remove: no ${SKILL_ID} skill in any ${PROJECT ? 'project' : 'user-level'} location${agentsAsked.length ? ' for that agent' : ''}.`);
302
+ }
303
+
304
+ function list() {
305
+ console.log(`${PROJECT ? 'Project locations, in ' + CWD : 'User-level locations (~ is ' + HOME + ')'}:\n`);
306
+ let olds = 0;
307
+ const rows = AGENTS.map((a) => {
308
+ const b = base(a), found = detected(a), where = b ? show(join(b, NAME)) : '(project only: add --project)';
309
+ let here = b && existsSync(join(b, NAME)) ? (same(FREE_SOURCE, join(b, NAME)) ? 'installed' : 'installed, a different version') : '';
310
+ if (b && existsSync(join(b, PRO)) && ours(join(b, PRO), PRO)) here = [here, `${PRO} installed`].filter(Boolean).join('; ');
311
+ const old = b ? oldCopies(b).filter((o) => ours(o.path, o.id)) : [];
312
+ if (old.length) { olds++; here = [here, `earlier name: ${old.map((o) => o.id).join(', ')}`].filter(Boolean).join('; '); }
313
+ return [a.id, a.detect ? (found ? `found (${found})` : 'not found') : 'on request', where, here];
314
+ });
315
+ const w = [0, 1, 2].map((i) => Math.max(...rows.map((r) => r[i].length)));
316
+ for (const r of rows) console.log(` ${r[0].padEnd(w[0])} ${r[1].padEnd(w[1])} ${r[2].padEnd(w[2])} ${r[3]}`.trimEnd());
317
+ console.log(`\n"npx ${NAME} install" installs for every agent marked found (Claude Code if none is).`);
318
+ if (olds) console.log(`A copy under the earlier name (${OLD_NAMES.join(', ')}) is replaced when you install ${NAME} there.`);
319
+ }
320
+
321
+ try {
322
+ const cmd = commands[0];
323
+ if (cmd === 'install') install();
324
+ else if (cmd === 'uninstall') uninstall();
325
+ else if (cmd === 'list') list();
326
+ else if (cmd === 'print') process.stdout.write(flags.has('--compact') ? buildCompact(FREE_SOURCE) : buildFull(FREE_SOURCE));
327
+ else fail(`unknown command "${cmd}"`);
328
+ } catch (err) {
329
+ fail(err.code === 'EACCES' || err.code === 'EPERM' ? `permission denied: ${err.path || err.message}` : err.message);
330
+ }
331
+ process.exit(problems ? 1 : 0);
package/lib/bundle.mjs ADDED
@@ -0,0 +1,98 @@
1
+ // Builds the single-file editions of the skill, for chat tools with no skill system (ChatGPT, Grok, a chat app's
2
+ // project instructions or attached files). Zero dependencies; used by `linejig print` and scripts/build-paste.mjs.
3
+ import { readFileSync, readdirSync, existsSync } from 'node:fs';
4
+ import { join } from 'node:path';
5
+ import { NAME, SITE } from './names.mjs';
6
+
7
+ // Read a SKILL.md into { name, description, body }. Only the two plain one-line fields this skill uses are parsed.
8
+ export function readSkill(dir) {
9
+ const raw = readFileSync(join(dir, 'SKILL.md'), 'utf8').replace(/\r\n/g, '\n');
10
+ const m = /^---\n([\s\S]*?)\n---\n?/.exec(raw);
11
+ if (!m) throw new Error(`no front matter in ${join(dir, 'SKILL.md')}`);
12
+ const field = (k) => (new RegExp(`^${k}:\\s*(.*)$`, 'm').exec(m[1]) || [])[1]?.trim() || '';
13
+ return { name: field('name'), description: field('description'), body: raw.slice(m[0].length) };
14
+ }
15
+
16
+ // Push every Markdown heading one level down (outside code fences), so a file can sit under a section heading.
17
+ function demote(md, by = 1) {
18
+ let fence = false;
19
+ return md.split('\n').map((line) => {
20
+ if (/^\s*(```|~~~)/.test(line)) fence = !fence;
21
+ return !fence && /^#{1,5} /.test(line) ? '#'.repeat(by) + line : line;
22
+ }).join('\n');
23
+ }
24
+
25
+ const stripComments = (md) => md.replace(/<!--[\s\S]*?-->\n?/g, '');
26
+ const tidy = (md) => md.replace(/\n{3,}/g, '\n\n').trim() + '\n';
27
+
28
+ function files(dir, sub, ext) {
29
+ const d = join(dir, sub);
30
+ return existsSync(d) ? readdirSync(d).filter((f) => f.endsWith(ext)).sort().map((f) => `${sub}/${f}`) : [];
31
+ }
32
+
33
+ const PREFACE = (s) => s.name !== NAME ? `> This is the \`${s.name}\` agent skill in one file, the Pro add-on to the \`${NAME}\` skill, for chat tools
34
+ > that have no skill folders. Add it next to ${NAME}.md (the free single-file edition, ${SITE}/skill) in a project's
35
+ > instructions or knowledge files. Coding agents should install the folder instead:
36
+ > \`npx ${NAME} install --pro <path to ${s.name}.zip>\`.
37
+
38
+ **When to use it:** ${s.description}
39
+ ` : `> This is the \`${s.name}\` agent skill in one file, for chat tools that have no skill folders
40
+ > (ChatGPT, Grok, Gemini, Claude.ai and others). Add it to a project's instructions or knowledge files, or attach it
41
+ > to a chat, then ask for a 3D line illustration. Coding agents (Claude Code, Codex, Cursor, Gemini CLI, Copilot and
42
+ > others) should install the skill folder instead: \`npx ${NAME} install\`.
43
+ >
44
+ > Where the text names a file such as \`references/motion.md\`, that file is included below under the same name. If
45
+ > you cannot run a browser or a shell, skip the headless render checks and ask the user to open the page and look.
46
+
47
+ **When to use it:** ${s.description}
48
+ `;
49
+
50
+ // The full edition: SKILL.md, every reference and the starter page, in one Markdown file.
51
+ export function buildFull(dir) {
52
+ const s = readSkill(dir);
53
+ const parts = [`# ${s.name} (single-file edition)\n`, PREFACE(s), demote(stripComments(s.body)).trim()];
54
+ for (const f of files(dir, 'references', '.md')) {
55
+ parts.push(`## File: ${f}\n\n` + demote(readFileSync(join(dir, f), 'utf8').replace(/\r\n/g, '\n'), 2).trim());
56
+ }
57
+ for (const f of files(dir, 'scripts', '.html')) {
58
+ parts.push(`## File: ${f}\n\n\`\`\`html\n${readFileSync(join(dir, f), 'utf8').trim()}\n\`\`\``);
59
+ }
60
+ return tidy(parts.join('\n\n'));
61
+ }
62
+
63
+ // The compact edition: the rules a chat tool needs to draw one figure, for instruction boxes with a size limit.
64
+ // It keeps these SKILL.md sections whole and drops everything else (listed in COMPACT_DROPS).
65
+ export const COMPACT_KEEP = ['What stays out', 'The kernel', 'The look, in brief', 'The hero part', 'Interaction, in brief',
66
+ 'Motion, in brief'];
67
+ export const COMPACT_DROPS = ['the three-concepts step and the comparison with the Keyline pixel skills', 'Style (line art; the Pro styles pointer)',
68
+ 'Workflow and the gallery steps', 'Using it with what you already have', 'Lessons', 'every references/ file',
69
+ 'the starter page'];
70
+
71
+ function sections(body) {
72
+ const out = new Map(); let cur = null;
73
+ for (const line of body.split('\n')) {
74
+ const h = /^## (.+)$/.exec(line);
75
+ if (h) { cur = h[1].trim(); out.set(cur, []); continue; }
76
+ if (cur) out.get(cur).push(line);
77
+ }
78
+ return out;
79
+ }
80
+
81
+ export function buildCompact(dir) {
82
+ const s = readSkill(dir), sec = sections(stripComments(s.body));
83
+ const keep = COMPACT_KEEP.filter((k) => sec.has(k)).map((k) => `## ${k}\n${sec.get(k).join('\n').trim()}`);
84
+ const head = `# ${s.name} (compact)
85
+
86
+ Draw one object as an interactive 3D line illustration in three.js on the published kernel. Before drawing, write
87
+ three concepts (object, its one hero part, why, its one move), recommend one and wait for the user's pick unless they
88
+ said "just draw it". Draw in line art: white, black and the grey ramp, no colour. This compact edition leaves out
89
+ the workflow, the reference files and the starter page; attach the full single-file edition (${s.name}.md) for those.
90
+
91
+ A figure page needs the three.js import map, \`<script type="importmap">{ "imports": { "three":
92
+ "https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.min.js", "three/addons/":
93
+ "https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/" } }</script>\`, the stylesheet
94
+ \`${SITE}/kernel/linejig.css\`, a \`<main><div id="plate" role="img" aria-label="..."></div></main>\`,
95
+ and a module script that imports \`createFigure\` from \`${SITE}/kernel/linejig.js\`.
96
+ `;
97
+ return tidy([head, ...keep].join('\n\n'));
98
+ }
package/lib/names.mjs ADDED
@@ -0,0 +1,10 @@
1
+ // The product's names and its site, in one place: the CLI, the single-file editions and the dist-skill build read
2
+ // them from here. The skill folder's own Markdown carries the same URL as text (see skill/linejig/SKILL.md).
3
+
4
+ // usekeyline.dev, the old domain, redirects here path for path, so copies built with it keep working.
5
+ export const SITE = 'https://linejig.com';
6
+
7
+ export const NAME = 'linejig'; // the npm package, the command, the skill id (folder and SKILL.md `name`)
8
+ export const PRODUCT = 'Linejig'; // the product, in prose: always one word, capital L
9
+ export const PRO = 'linejig-pro'; // the paid add-on skill (Brand, Dots): delivered as a download, never on npm
10
+ export const OLD_NAMES = ['keyline-3d']; // earlier names of this skill: replaced on install, removed on uninstall
package/package.json CHANGED
@@ -1,6 +1,44 @@
1
1
  {
2
2
  "name": "linejig",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "An agent skill for interactive 3D line illustrations in three.js, for Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and other coding agents: empty states, 404s, onboarding and heroes.",
5
+ "license": "MIT",
6
+ "homepage": "https://linejig.com/skill",
7
+ "keywords": [
8
+ "linejig",
9
+ "3d",
10
+ "illustrations",
11
+ "isometric",
12
+ "interactive",
13
+ "three.js",
14
+ "line-art",
15
+ "agent-skill",
16
+ "agent-skills",
17
+ "skill",
18
+ "claude-skill",
19
+ "claude-code",
20
+ "codex",
21
+ "cursor",
22
+ "gemini",
23
+ "github-copilot",
24
+ "windsurf",
25
+ "empty-state",
26
+ "404"
27
+ ],
28
+ "type": "module",
29
+ "bin": {
30
+ "linejig": "bin/cli.mjs"
31
+ },
32
+ "files": [
33
+ "bin",
34
+ "lib",
35
+ "skill"
36
+ ],
37
+ "engines": {
38
+ "node": ">=18"
39
+ },
40
+ "scripts": {
41
+ "prepack": "node -e \"const fs=require('fs');fs.rmSync('skill',{recursive:true,force:true});fs.cpSync('../skill/linejig','skill/linejig',{recursive:true})\"",
42
+ "build:paste": "node scripts/build-paste.mjs"
43
+ }
44
+ }