@jonandev/longbeard 0.11.2 → 0.12.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/AGENTS.md +3 -4
- package/CHANGELOG.md +67 -0
- package/README.md +63 -43
- package/beard.json +113 -26
- package/bin/long-beard.js +172 -36
- package/package.json +1 -1
- package/skills/design/SKILL.md +51 -126
- package/skills/design-brief/SKILL.md +146 -0
- package/skills/design-brief/references/graphic.md +59 -0
- package/skills/design-check/SKILL.md +27 -11
- package/skills/design-check/references/design-rules.md +21 -7
- package/skills/design-check/scripts/capture.mjs +121 -37
- package/skills/design-check/scripts/contrast.mjs +23 -9
- package/skills/design-check/scripts/rules.mjs +613 -0
- package/skills/design-check/scripts/screen-contrast.mjs +428 -0
- package/skills/design-check/scripts/tokens.mjs +346 -0
- package/skills/design-content/SKILL.md +118 -0
- package/skills/design-content/scripts/contact-sheet.mjs +259 -0
- package/skills/design-content/scripts/pictures.mjs +197 -0
- package/skills/design-direction/SKILL.md +115 -200
- package/skills/design-direction/references/controls.md +58 -0
- package/skills/{design → design-direction}/references/design-rules.md +21 -7
- package/skills/design-direction/references/five-second.md +47 -0
- package/skills/design-direction/references/full-build.md +19 -0
- package/skills/design-direction/references/graphic.md +35 -0
- package/skills/design-direction/references/grid.md +114 -0
- package/skills/design-direction/references/library.md +75 -0
- package/skills/design-direction/references/screen-template.html +233 -0
- package/skills/design-direction/references/subject.md +33 -0
- package/skills/design-direction/scripts/capture.mjs +121 -37
- package/skills/design-direction/scripts/contact-sheet.mjs +18 -7
- package/skills/design-direction/scripts/fonts.mjs +276 -0
- package/skills/design-direction/scripts/layout-diff.mjs +118 -0
- package/skills/design-direction/scripts/measure.mjs +1728 -0
- package/skills/design-direction/scripts/moodboard.mjs +123 -32
- package/skills/design-direction/scripts/picture-cast.mjs +270 -0
- package/skills/design-direction/scripts/pictures.mjs +197 -0
- package/skills/design-direction/scripts/screen-contrast.mjs +428 -0
- package/skills/design-direction/scripts/sheet.mjs +67 -0
- package/skills/design-direction/scripts/subject-colours.mjs +410 -0
- package/skills/design-families/SKILL.md +138 -0
- package/skills/design-families/scripts/contact-sheet.mjs +259 -0
- package/skills/design-families/scripts/families.mjs +606 -0
- package/skills/design-families/scripts/measure.mjs +1728 -0
- package/skills/design-families/scripts/moodboard.mjs +467 -0
- package/skills/design-families/scripts/tag.mjs +289 -0
- package/skills/design-figma/SKILL.md +69 -0
- package/skills/design-figma/references/graphic.md +26 -0
- package/skills/design-identity/SKILL.md +134 -0
- package/skills/design-identity/references/graphic.md +8 -0
- package/skills/design-identity/references/identity-board.html +140 -0
- package/skills/{design → design-identity}/scripts/capture.mjs +121 -37
- package/skills/design-identity/scripts/colours.mjs +213 -0
- package/skills/design-identity/scripts/contrast.mjs +41 -0
- package/skills/design-identity/scripts/fonts.mjs +276 -0
- package/skills/design-identity/scripts/measure.mjs +1728 -0
- package/skills/design-identity/scripts/sheet.mjs +67 -0
- package/skills/design-identity/scripts/subject-colours.mjs +410 -0
- package/skills/design-moodboard/SKILL.md +184 -0
- package/skills/design-moodboard/references/graphic.md +25 -0
- package/skills/{design-direction → design-moodboard}/references/sources.md +17 -11
- package/skills/design-moodboard/scripts/capture.mjs +893 -0
- package/skills/design-moodboard/scripts/contact-sheet.mjs +259 -0
- package/skills/design-moodboard/scripts/crops.mjs +256 -0
- package/skills/design-moodboard/scripts/dribbble-cards.mjs +418 -0
- package/skills/design-moodboard/scripts/families.mjs +606 -0
- package/skills/design-moodboard/scripts/group.mjs +221 -0
- package/skills/design-moodboard/scripts/measure.mjs +1728 -0
- package/skills/design-moodboard/scripts/moodboard.mjs +467 -0
- package/skills/{design-direction → design-moodboard}/scripts/picker.mjs +121 -20
- package/skills/design-moodboard/scripts/pictures.mjs +197 -0
- package/skills/design-moodboard/scripts/tag.mjs +289 -0
- package/skills/design-prototype/SKILL.md +149 -0
- package/skills/design-prototype/references/design-md-template.md +82 -0
- package/skills/design-prototype/references/design-rules.md +203 -0
- package/skills/design-prototype/references/five-second.md +47 -0
- package/skills/design-prototype/references/graphic.md +27 -0
- package/skills/design-prototype/scripts/capture.mjs +893 -0
- package/skills/design-prototype/scripts/contrast.mjs +41 -0
- package/skills/design-prototype/scripts/links.mjs +308 -0
- package/skills/design-prototype/scripts/pictures.mjs +197 -0
- package/skills/design-prototype/scripts/rules.mjs +613 -0
- package/skills/design-prototype/scripts/screen-contrast.mjs +428 -0
- package/skills/design-prototype/scripts/sheet.mjs +67 -0
- package/skills/design-prototype/scripts/tokens.mjs +346 -0
- package/skills/design-wordmark/SKILL.md +65 -0
- package/skills/design-wordmark/scripts/capture.mjs +893 -0
- package/skills/design-wordmark/scripts/sheet.mjs +67 -0
- package/skills/idea/SKILL.md +13 -7
- package/skills/idea/references/graphic.md +64 -0
- package/skills/design/references/design-md-template.md +0 -58
- package/skills/design/scripts/contrast.mjs +0 -27
- package/skills/design-direction/scripts/dribbble-cards.mjs +0 -356
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Build labelled contact sheets from a TSV of label\timageURL. The image can
|
|
3
|
+
// be a local file too, so a family's references are sorted by eye from a few
|
|
4
|
+
// sheets of thumbnails, not opened one at a time.
|
|
5
|
+
// Writes JPEG grids (~36 per sheet) into an output directory (scratch, not .longbeard/design/).
|
|
6
|
+
// Viewing listing thumbnails is allowed; this is not a capture.
|
|
7
|
+
//
|
|
8
|
+
// node contact-sheet.mjs candidates.tsv --out /tmp/hunt-sheets
|
|
9
|
+
// node contact-sheet.mjs family-f3.tsv --out <scratch>/f3 --contain # TSV: label<TAB>refs/name.jpg
|
|
10
|
+
import { spawn } from "node:child_process";
|
|
11
|
+
import {
|
|
12
|
+
existsSync,
|
|
13
|
+
mkdirSync,
|
|
14
|
+
mkdtempSync,
|
|
15
|
+
readFileSync,
|
|
16
|
+
rmSync,
|
|
17
|
+
writeFileSync,
|
|
18
|
+
} from "node:fs";
|
|
19
|
+
import { tmpdir } from "node:os";
|
|
20
|
+
import { join, resolve } from "node:path";
|
|
21
|
+
import { pathToFileURL } from "node:url";
|
|
22
|
+
|
|
23
|
+
const args = process.argv.slice(2);
|
|
24
|
+
const flag = (name, def) => {
|
|
25
|
+
const i = args.indexOf(`--${name}`);
|
|
26
|
+
if (i === -1) return def;
|
|
27
|
+
const v = args[i + 1];
|
|
28
|
+
args.splice(i, 2);
|
|
29
|
+
return v;
|
|
30
|
+
};
|
|
31
|
+
const tsvPath = args[0];
|
|
32
|
+
const outDir = resolve(flag("out", "") || "");
|
|
33
|
+
const perSheet = Math.max(1, Number(flag("per", "36")) || 36);
|
|
34
|
+
const cols = Math.min(8, Math.max(1, Number(flag("cols", "6")) || 6));
|
|
35
|
+
const containAt = args.indexOf("--contain");
|
|
36
|
+
const contain = containAt !== -1;
|
|
37
|
+
if (contain) args.splice(containAt, 1);
|
|
38
|
+
if (!tsvPath || !outDir) {
|
|
39
|
+
console.error("usage: node contact-sheet.mjs candidates.tsv --out <scratch>/sheets [--per 36] [--cols 6] [--contain]");
|
|
40
|
+
process.exit(2);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const lines = readFileSync(tsvPath, "utf8")
|
|
44
|
+
.split(/\r?\n/)
|
|
45
|
+
.map((l) => l.trim())
|
|
46
|
+
.filter(Boolean)
|
|
47
|
+
.map((l) => {
|
|
48
|
+
// label\timageURL, and any columns after that (a listing URL) are ignored.
|
|
49
|
+
const cols = l.split("\t").map((c) => c.trim());
|
|
50
|
+
if (cols.length === 1) return { label: l, url: l };
|
|
51
|
+
return { label: cols[0], url: cols[1] };
|
|
52
|
+
})
|
|
53
|
+
.map((r) => (/^https?:\/\//i.test(r.url) || !existsSync(r.url) ? r : { ...r, url: pathToFileURL(resolve(r.url)).href }))
|
|
54
|
+
.filter((r) => /^(https?|file):\/\//i.test(r.url));
|
|
55
|
+
|
|
56
|
+
if (!lines.length) {
|
|
57
|
+
console.error("no label\timageURL rows found");
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function findChrome() {
|
|
62
|
+
const env = process.env.CHROME_PATH;
|
|
63
|
+
// CHROME_PATH=none: run as if no browser were installed (a quick test run).
|
|
64
|
+
if (env === "none") return null;
|
|
65
|
+
if (env && existsSync(env)) return env;
|
|
66
|
+
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
67
|
+
const local = process.env.LOCALAPPDATA || "";
|
|
68
|
+
const pf = process.env.PROGRAMFILES || "C:\\Program Files";
|
|
69
|
+
const pf86 = process.env["PROGRAMFILES(X86)"] || "C:\\Program Files (x86)";
|
|
70
|
+
const candidates = [
|
|
71
|
+
join(pf, "Google/Chrome/Application/chrome.exe"),
|
|
72
|
+
join(pf86, "Google/Chrome/Application/chrome.exe"),
|
|
73
|
+
join(local, "Google/Chrome/Application/chrome.exe"),
|
|
74
|
+
join(pf, "Microsoft/Edge/Application/msedge.exe"),
|
|
75
|
+
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
76
|
+
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
|
77
|
+
"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
|
|
78
|
+
join(home, "Applications/Google Chrome.app/Contents/MacOS/Google Chrome"),
|
|
79
|
+
"/usr/bin/google-chrome",
|
|
80
|
+
"/usr/bin/google-chrome-stable",
|
|
81
|
+
"/usr/bin/chromium",
|
|
82
|
+
"/usr/bin/chromium-browser",
|
|
83
|
+
];
|
|
84
|
+
return candidates.find((path) => path && existsSync(path)) || null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
88
|
+
const exe = findChrome();
|
|
89
|
+
if (!exe) {
|
|
90
|
+
console.error("No Chrome/Edge/Chromium found. Install one or set CHROME_PATH.");
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
if (typeof WebSocket === "undefined") {
|
|
94
|
+
console.error("Node 22+ is required.");
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const dir = mkdtempSync(join(tmpdir(), "hunt-sheet-"));
|
|
99
|
+
let proc;
|
|
100
|
+
const drop = () => {
|
|
101
|
+
try {
|
|
102
|
+
if (proc?.pid) process.kill(proc.pid, "SIGKILL");
|
|
103
|
+
} catch {}
|
|
104
|
+
try {
|
|
105
|
+
rmSync(dir, { recursive: true, force: true });
|
|
106
|
+
} catch {}
|
|
107
|
+
};
|
|
108
|
+
process.once("exit", drop);
|
|
109
|
+
|
|
110
|
+
proc = spawn(
|
|
111
|
+
exe,
|
|
112
|
+
[
|
|
113
|
+
"--headless=new",
|
|
114
|
+
"--remote-debugging-port=0",
|
|
115
|
+
`--user-data-dir=${dir}`,
|
|
116
|
+
"--no-first-run",
|
|
117
|
+
"--hide-scrollbars",
|
|
118
|
+
"--mute-audio",
|
|
119
|
+
"--force-color-profile=srgb",
|
|
120
|
+
"--window-size=1600,1200",
|
|
121
|
+
"about:blank",
|
|
122
|
+
],
|
|
123
|
+
{ stdio: ["ignore", "ignore", "pipe"] },
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
let buf = "";
|
|
127
|
+
const wsUrl = await new Promise((resolveWs, reject) => {
|
|
128
|
+
const t = setTimeout(() => reject(new Error("Chrome did not start")), 20000);
|
|
129
|
+
proc.stderr.on("data", (d) => {
|
|
130
|
+
buf += d.toString();
|
|
131
|
+
const m = buf.match(/DevTools listening on (ws:\/\/[^\s]+)/);
|
|
132
|
+
if (m) {
|
|
133
|
+
clearTimeout(t);
|
|
134
|
+
resolveWs(m[1]);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
proc.on("exit", (code) => {
|
|
138
|
+
clearTimeout(t);
|
|
139
|
+
reject(new Error(`Chrome exited ${code}`));
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const ws = new WebSocket(wsUrl);
|
|
144
|
+
await new Promise((res, rej) => {
|
|
145
|
+
ws.onopen = res;
|
|
146
|
+
ws.onerror = () => rej(new Error("CDP socket failed"));
|
|
147
|
+
});
|
|
148
|
+
let nextId = 1;
|
|
149
|
+
const pending = new Map();
|
|
150
|
+
ws.onmessage = (ev) => {
|
|
151
|
+
const msg = JSON.parse(typeof ev.data === "string" ? ev.data : Buffer.from(ev.data).toString());
|
|
152
|
+
if (msg.id && pending.has(msg.id)) {
|
|
153
|
+
const { resolve: ok, reject: bad } = pending.get(msg.id);
|
|
154
|
+
pending.delete(msg.id);
|
|
155
|
+
if (msg.error) bad(new Error(msg.error.message));
|
|
156
|
+
else ok(msg.result);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const send = (method, params = {}, sessionId, timeoutMs = 30000) => {
|
|
160
|
+
const id = nextId++;
|
|
161
|
+
return new Promise((resolveSend, reject) => {
|
|
162
|
+
const timer = setTimeout(() => {
|
|
163
|
+
pending.delete(id);
|
|
164
|
+
reject(new Error(`CDP timeout: ${method}`));
|
|
165
|
+
}, timeoutMs);
|
|
166
|
+
pending.set(id, {
|
|
167
|
+
resolve: (v) => {
|
|
168
|
+
clearTimeout(timer);
|
|
169
|
+
resolveSend(v);
|
|
170
|
+
},
|
|
171
|
+
reject: (e) => {
|
|
172
|
+
clearTimeout(timer);
|
|
173
|
+
reject(e);
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
ws.send(JSON.stringify(sessionId ? { id, method, params, sessionId } : { id, method, params }));
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const { targetId } = await send("Target.createTarget", { url: "about:blank" });
|
|
181
|
+
const { sessionId } = await send("Target.attachToTarget", { targetId, flatten: true });
|
|
182
|
+
const page = (method, params, timeoutMs) => send(method, params, sessionId, timeoutMs);
|
|
183
|
+
|
|
184
|
+
await page("Page.enable");
|
|
185
|
+
await page("Runtime.enable");
|
|
186
|
+
await page("Emulation.setDeviceMetricsOverride", {
|
|
187
|
+
width: 1600,
|
|
188
|
+
height: 1200,
|
|
189
|
+
deviceScaleFactor: 1,
|
|
190
|
+
mobile: false,
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
mkdirSync(outDir, { recursive: true });
|
|
194
|
+
const sheets = [];
|
|
195
|
+
for (let i = 0; i < lines.length; i += perSheet) {
|
|
196
|
+
sheets.push(lines.slice(i, i + perSheet));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const esc = (s) =>
|
|
200
|
+
String(s)
|
|
201
|
+
.replace(/&/g, "&")
|
|
202
|
+
.replace(/</g, "<")
|
|
203
|
+
.replace(/>/g, ">")
|
|
204
|
+
.replace(/"/g, """);
|
|
205
|
+
|
|
206
|
+
for (let s = 0; s < sheets.length; s++) {
|
|
207
|
+
const cells = sheets[s]
|
|
208
|
+
.map(
|
|
209
|
+
(r) =>
|
|
210
|
+
`<figure><img src="${esc(r.url)}" loading="eager"><figcaption>${esc(r.label)}</figcaption></figure>`,
|
|
211
|
+
)
|
|
212
|
+
.join("\n");
|
|
213
|
+
const html = `<!doctype html><meta charset=utf-8>
|
|
214
|
+
<style>
|
|
215
|
+
body { margin: 16px; background: #1a1a1a; color: #eee; font: 11px/1.2 system-ui, sans-serif; }
|
|
216
|
+
.grid { display: grid; grid-template-columns: repeat(${cols}, 1fr); gap: 10px; }
|
|
217
|
+
figure { margin: 0; background: #2a2a2a; border-radius: 4px; overflow: hidden; }
|
|
218
|
+
img { display: block; width: 100%; height: ${contain ? Math.round(1200 / cols) : 140}px; object-fit: ${contain ? "contain" : "cover"}; background: #111; }
|
|
219
|
+
figcaption { padding: 6px 8px; word-break: break-word; max-height: 2.4em; overflow: hidden; }
|
|
220
|
+
</style>
|
|
221
|
+
<div class="grid">${cells}</div>
|
|
222
|
+
<script>
|
|
223
|
+
Promise.all([...document.images].map((img) => img.decode().catch(() => {}))).then(() => {
|
|
224
|
+
document.title = "ready";
|
|
225
|
+
});
|
|
226
|
+
</script>`;
|
|
227
|
+
const htmlPath = join(dir, `sheet-${s + 1}.html`);
|
|
228
|
+
writeFileSync(htmlPath, html);
|
|
229
|
+
await page("Page.navigate", { url: pathToFileURL(htmlPath).href }, 30000);
|
|
230
|
+
await sleep(500);
|
|
231
|
+
for (let i = 0; i < 60; i++) {
|
|
232
|
+
const title = (
|
|
233
|
+
await page("Runtime.evaluate", { expression: "document.title", returnByValue: true })
|
|
234
|
+
).result.value;
|
|
235
|
+
if (title === "ready") break;
|
|
236
|
+
await sleep(150);
|
|
237
|
+
}
|
|
238
|
+
await sleep(400);
|
|
239
|
+
const metrics = await page("Page.getLayoutMetrics");
|
|
240
|
+
const size = metrics.cssContentSize || metrics.contentSize;
|
|
241
|
+
const width = Math.max(1, Math.ceil(size.width || 1600));
|
|
242
|
+
const height = Math.max(1, Math.min(Math.ceil(size.height || 1200), 8000));
|
|
243
|
+
const { data } = await page(
|
|
244
|
+
"Page.captureScreenshot",
|
|
245
|
+
{
|
|
246
|
+
format: "jpeg",
|
|
247
|
+
quality: 80,
|
|
248
|
+
captureBeyondViewport: true,
|
|
249
|
+
clip: { x: 0, y: 0, width, height, scale: 1 },
|
|
250
|
+
},
|
|
251
|
+
60000,
|
|
252
|
+
);
|
|
253
|
+
const outPath = join(outDir, `sheet-${String(s + 1).padStart(2, "0")}.jpg`);
|
|
254
|
+
writeFileSync(outPath, Buffer.from(data, "base64"));
|
|
255
|
+
console.log(outPath);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
drop();
|
|
259
|
+
process.exit(0);
|