@jonandev/longbeard 0.10.0 → 0.11.1

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.
@@ -0,0 +1,254 @@
1
+ #!/usr/bin/env node
2
+ // A picker: a wide pool of candidates from any source, as one page where the
3
+ // person marks each like or no. It hotlinks each listing's own thumbnail and
4
+ // saves nothing, so it is a view, not a capture. Their picks come back as
5
+ // text they copy into the chat.
6
+ //
7
+ // The TSV has one row per candidate: title, image, link, source, meta (a
8
+ // short line such as the designer and likes). Columns after the image may be
9
+ // empty. A line starting with # is a comment. Each
10
+ // row's id is the round letter and its row number (a1, a2…, b1… in round 2),
11
+ // so a pick maps to its line in the TSV. A row with source "seed" starts
12
+ // liked; its image may be a path in the project instead of a URL.
13
+ //
14
+ // node picker.mjs design-exploration/identity/candidates.tsv --out design-exploration/identity/picker.html
15
+ // node picker.mjs design-exploration/identity/candidates-2.tsv --round 2 --out design-exploration/identity/picker-2.html
16
+ import { execSync } from "node:child_process";
17
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
18
+ import { dirname, isAbsolute, relative, resolve } from "node:path";
19
+
20
+ const args = process.argv.slice(2);
21
+ const flag = (name) => {
22
+ const i = args.indexOf(`--${name}`);
23
+ return i === -1 ? "" : (args.splice(i, 2)[1] ?? "");
24
+ };
25
+ const outArg = flag("out");
26
+ const roundArg = flag("round") || "1";
27
+ const round = Number(roundArg);
28
+ const tsvArg = args[0];
29
+ if (!tsvArg || !outArg || args.length !== 1 || !Number.isInteger(round) || round < 1 || round > 26) {
30
+ console.error(
31
+ "usage: node picker.mjs design-exploration/<slug>/candidates.tsv --out design-exploration/<slug>/picker.html [--round 2]",
32
+ );
33
+ process.exit(2);
34
+ }
35
+ const letter = String.fromCharCode(96 + round);
36
+
37
+ function projectRoot() {
38
+ try {
39
+ return execSync("git rev-parse --show-toplevel", { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
40
+ } catch {
41
+ return process.cwd();
42
+ }
43
+ }
44
+
45
+ const root = projectRoot();
46
+ const resolvePath = (path) => (isAbsolute(path) ? path : resolve(root, path));
47
+ const tsvPath = resolvePath(tsvArg);
48
+ const outPath = resolvePath(outArg);
49
+ if (!existsSync(tsvPath)) {
50
+ console.error(`picker: no candidates at ${tsvArg}`);
51
+ process.exit(1);
52
+ }
53
+
54
+ // Every field is scraped text from someone else's page.
55
+ const esc = (s) =>
56
+ String(s ?? "")
57
+ .replace(/&/g, "&amp;")
58
+ .replace(/</g, "&lt;")
59
+ .replace(/>/g, "&gt;")
60
+ .replace(/"/g, "&quot;")
61
+ .replace(/'/g, "&#39;");
62
+ const isUrl = (s) => /^https?:\/\//i.test(s);
63
+
64
+ const rows = readFileSync(tsvPath, "utf8")
65
+ .split(/\r?\n/)
66
+ .filter((l) => l.trim() && !l.trimStart().startsWith("#"));
67
+
68
+ const tiles = [];
69
+ const seenImages = new Set();
70
+ rows.forEach((line, i) => {
71
+ const id = `${letter}${i + 1}`;
72
+ const [title = "", image = "", link = "", source = "", meta = ""] = line.split("\t").map((c) => c.trim());
73
+ let src = image;
74
+ if (!isUrl(image)) {
75
+ const abs = image ? resolvePath(image) : "";
76
+ if (!abs || !existsSync(abs)) {
77
+ console.error(`picker: ${id} has no image (${image || "empty"}), skipped`);
78
+ return;
79
+ }
80
+ src = relative(dirname(outPath), abs).split("\\").join("/");
81
+ if (!src.startsWith(".")) src = `./${src}`;
82
+ }
83
+ if (seenImages.has(src)) {
84
+ console.error(`picker: ${id} repeats an earlier image, skipped`);
85
+ return;
86
+ }
87
+ seenImages.add(src);
88
+ const name = title || id;
89
+ const seed = source.toLowerCase() === "seed";
90
+ const caption =
91
+ (isUrl(link)
92
+ ? `<a class="name" href="${esc(link)}" title="${esc(name)}" target="_blank" rel="noopener noreferrer">${esc(name)}</a>`
93
+ : `<span class="name" title="${esc(name)}">${esc(name)}</span>`) +
94
+ (meta ? `<span class="meta">${esc(meta)}</span>` : "");
95
+ tiles.push(`<figure class="tile" data-id="${esc(id)}" data-title="${esc(name)}"${seed ? ' data-seed="1"' : ""}>
96
+ <button type="button" class="frame" aria-pressed="false" aria-label="${esc(`${id} ${name}: mark like, no, or clear`)}">
97
+ <img src="${esc(src)}" alt="" loading="lazy" referrerpolicy="no-referrer">
98
+ <span class="id">${esc(id)}</span>${source ? `<span class="src">${esc(source)}</span>` : ""}
99
+ <span class="mark"></span>
100
+ </button>
101
+ <figcaption>${caption}</figcaption>
102
+ </figure>`);
103
+ });
104
+
105
+ if (!tiles.length) {
106
+ console.error("picker: no row has an image");
107
+ process.exit(1);
108
+ }
109
+
110
+ const html = `<!DOCTYPE html>
111
+ <html lang="en">
112
+ <head>
113
+ <meta charset="utf-8">
114
+ <meta name="viewport" content="width=device-width, initial-scale=1">
115
+ <title>Pick, round ${round}</title>
116
+ <style>
117
+ :root { --canvas: #e4e4e2; --paper: #ffffff; --ink: #1c1c1a; --muted: #6f6f6a; --like: #1f7a3a; --no: #b3261e; }
118
+ * { box-sizing: border-box; }
119
+ html { color-scheme: light; }
120
+ body { margin: 0; background: var(--canvas); color: var(--ink); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
121
+ main { max-width: 1400px; margin: 0 auto; padding: 40px 24px 300px; }
122
+ h1 { margin: 0 0 6px 2px; font-size: 11px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
123
+ .how { margin: 0 0 20px 2px; font-size: 14px; color: var(--muted); }
124
+ .filters { margin: 0 0 18px 2px; display: flex; gap: 8px; }
125
+ .filters button { font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 999px; border: 1px solid #c8c8c4; background: var(--paper); color: var(--ink); cursor: pointer; }
126
+ .filters button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
127
+ .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
128
+ .tile { margin: 0; display: flex; flex-direction: column; background: var(--paper); border-radius: 16px; overflow: hidden; outline: 3px solid transparent; outline-offset: -3px; }
129
+ .tile[data-state="like"] { outline-color: var(--like); }
130
+ .tile[data-state="no"] .frame img { opacity: 0.3; filter: grayscale(1); }
131
+ .tile[hidden] { display: none; }
132
+ .frame { position: relative; display: block; width: 100%; aspect-ratio: 4 / 3; padding: 0; border: 0; overflow: hidden; background: #141414; cursor: pointer; }
133
+ .frame:focus-visible { outline: 3px solid #2f6fdb; outline-offset: -3px; }
134
+ .frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
135
+ .id, .src, .mark { position: absolute; font-size: 11px; font-weight: 600; padding: 3px 7px; border-radius: 6px; background: rgba(0,0,0,0.65); color: #fff; }
136
+ .id { top: 8px; left: 8px; }
137
+ .src { top: 8px; right: 8px; font-weight: 500; }
138
+ .mark { bottom: 8px; left: 8px; display: none; font-size: 12px; }
139
+ .tile[data-state="like"] .mark { display: block; background: var(--like); }
140
+ .tile[data-state="like"] .mark::after { content: "Like"; }
141
+ .tile[data-state="no"] .mark { display: block; background: var(--no); }
142
+ .tile[data-state="no"] .mark::after { content: "No"; }
143
+ figcaption { padding: 10px 12px 12px; font-size: 13px; line-height: 1.35; }
144
+ /* A scraped title can carry a whole tag list: two lines, the rest on hover. */
145
+ .name { color: var(--ink); text-decoration: none; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
146
+ .meta { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); }
147
+ a.name:hover { text-decoration: underline; }
148
+ .bar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--paper); border-top: 1px solid #c8c8c4; box-shadow: 0 -6px 24px rgba(0,0,0,0.08); }
149
+ .bar-in { max-width: 1400px; margin: 0 auto; padding: 14px 24px 16px; display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 14px; align-items: start; }
150
+ .bar label { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
151
+ .bar textarea { width: 100%; font: 13px/1.4 ui-monospace, Menlo, monospace; padding: 8px 10px; border: 1px solid #c8c8c4; border-radius: 8px; resize: vertical; }
152
+ #note { height: 96px; font-family: inherit; font-size: 14px; }
153
+ #out { height: 96px; background: #f6f6f4; }
154
+ .side { display: flex; flex-direction: column; gap: 8px; padding-top: 22px; min-width: 150px; }
155
+ #count { font-size: 13px; color: var(--muted); }
156
+ #copy { font: inherit; font-size: 14px; font-weight: 600; padding: 10px 16px; border-radius: 10px; border: 0; background: var(--ink); color: var(--paper); cursor: pointer; }
157
+ @media (max-width: 800px) { .bar-in { grid-template-columns: 1fr; } .side { padding-top: 0; } main { padding-bottom: 480px; } }
158
+ </style>
159
+ </head>
160
+ <body>
161
+ <main>
162
+ <h1>Pick, round ${round}</h1>
163
+ <p class="how">Click a picture: once for like, twice for no, three times to clear. Leave anything you have no view on. The name opens the source.</p>
164
+ <div class="filters" role="group" aria-label="Show">
165
+ <button type="button" data-show="all" aria-pressed="true">All</button>
166
+ <button type="button" data-show="open" aria-pressed="false">Not marked</button>
167
+ <button type="button" data-show="like" aria-pressed="false">Likes</button>
168
+ <button type="button" data-show="no" aria-pressed="false">Noes</button>
169
+ </div>
170
+ <div class="grid">
171
+ ${tiles.join("\n ")}
172
+ </div>
173
+ </main>
174
+ <div class="bar">
175
+ <div class="bar-in">
176
+ <div><label for="note">Why, in your words (optional)</label><textarea id="note" placeholder="What the likes share, what put you off the noes"></textarea></div>
177
+ <div><label for="out">Copy this into the chat</label><textarea id="out" readonly></textarea></div>
178
+ <div class="side"><span id="count"></span><button type="button" id="copy">Copy picks</button></div>
179
+ </div>
180
+ </div>
181
+ <script>
182
+ (() => {
183
+ const key = "longbeard-picker:" + location.pathname + ":${letter}";
184
+ const tiles = [...document.querySelectorAll(".tile")];
185
+ const note = document.getElementById("note");
186
+ const out = document.getElementById("out");
187
+ const count = document.getElementById("count");
188
+ let saved = {};
189
+ try { saved = JSON.parse(localStorage.getItem(key) || "{}"); } catch (e) { saved = {}; }
190
+ const states = saved.states || {};
191
+ note.value = saved.note || "";
192
+ // A mark is saved with its title, so a row dropped and the page rebuilt
193
+ // never moves a mark onto another picture. A cleared seed stays cleared.
194
+ const tag = (t) => t.dataset.id + "|" + t.dataset.title;
195
+ for (const t of tiles) {
196
+ const s = tag(t) in states ? states[tag(t)] : t.dataset.seed ? "like" : "";
197
+ if (s) t.dataset.state = s;
198
+ }
199
+ let show = "all";
200
+ const short = (s) => (s.length > 48 ? s.slice(0, 47) + "…" : s);
201
+ const list = (state) => tiles.filter((t) => t.dataset.state === state).map((t) => t.dataset.id + " " + short(t.dataset.title));
202
+ function render() {
203
+ const like = list("like");
204
+ const no = list("no");
205
+ const lines = ["Picks, round ${round} (${letter})", "like: " + (like.join("; ") || "none"), "no: " + (no.join("; ") || "none")];
206
+ if (note.value.trim()) lines.push("note: " + note.value.trim().replace(/\\s+/g, " "));
207
+ out.value = lines.join("\\n");
208
+ count.textContent = like.length + " like · " + no.length + " no · " + tiles.length + " shown";
209
+ for (const t of tiles) {
210
+ const s = t.dataset.state || "";
211
+ t.querySelector(".frame").setAttribute("aria-pressed", s ? "true" : "false");
212
+ t.hidden = !(show === "all" || (show === "open" ? !s : s === show));
213
+ }
214
+ const keep = {};
215
+ for (const t of tiles) if (t.dataset.state || t.dataset.seed) keep[tag(t)] = t.dataset.state || "";
216
+ try { localStorage.setItem(key, JSON.stringify({ states: keep, note: note.value })); } catch (e) {}
217
+ }
218
+ const next = { "": "like", like: "no", no: "" };
219
+ for (const t of tiles) {
220
+ t.querySelector(".frame").addEventListener("click", () => {
221
+ const s = next[t.dataset.state || ""];
222
+ if (s) t.dataset.state = s; else delete t.dataset.state;
223
+ render();
224
+ });
225
+ }
226
+ for (const b of document.querySelectorAll(".filters button")) {
227
+ b.addEventListener("click", () => {
228
+ show = b.dataset.show;
229
+ for (const o of document.querySelectorAll(".filters button")) o.setAttribute("aria-pressed", o === b ? "true" : "false");
230
+ render();
231
+ });
232
+ }
233
+ note.addEventListener("input", render);
234
+ // The text box is the real path: the clipboard API can be refused on a file:// page.
235
+ document.getElementById("copy").addEventListener("click", async (e) => {
236
+ out.focus();
237
+ out.select();
238
+ let ok = false;
239
+ try { await navigator.clipboard.writeText(out.value); ok = true; } catch (err) {}
240
+ if (!ok) { try { ok = document.execCommand("copy"); } catch (err) {} }
241
+ e.target.textContent = ok ? "Copied" : "Selected, press Cmd/Ctrl+C";
242
+ setTimeout(() => { e.target.textContent = "Copy picks"; }, 1800);
243
+ });
244
+ render();
245
+ })();
246
+ </script>
247
+ </body>
248
+ </html>
249
+ `;
250
+
251
+ mkdirSync(dirname(outPath), { recursive: true });
252
+ writeFileSync(outPath, html);
253
+ console.error(`picker: ${tiles.length} of ${rows.length} rows, ids ${letter}1–${letter}${rows.length}`);
254
+ console.log(outArg);
@@ -11,7 +11,7 @@ description: >
11
11
 
12
12
  # Idea
13
13
 
14
- One file comes out: `docs/brief.md`, about 500 words, one page. Every later stage reads it: `design-direction` for the people, surface and identity nouns, `design` for the key screens, `to-spec` for the flows. No stage asks for these again, so the brief has to settle them.
14
+ One file comes out: `docs/brief.md`, about 500 words, one page. Every later stage reads it: `design-direction` for the people, surface, position and identity nouns, `design` for the key screens, `to-spec` for the flows. No stage asks for these again, so the brief has to settle them.
15
15
 
16
16
  The brief says what and for whom, never how. No framework, database, host or library. Those are Architecture's.
17
17
 
@@ -19,26 +19,29 @@ The brief says what and for whom, never how. No framework, database, host or lib
19
19
 
20
20
  Look at the repo. Do not ask what is there.
21
21
 
22
- 1. `docs/brief.md` exists and they bring a feature → not this skill. Grill the feature with `grill-with-docs` when it brings new terms, otherwise `grilling`; then `to-spec`. The brief stays as it is.
22
+ 1. `docs/brief.md` exists and they bring a feature → not this skill. Grill the feature: they type `/grill-with-docs` when it brings new terms, otherwise load `grilling`. Then they type `/to-spec`. The brief stays as it is.
23
23
  2. `docs/brief.md` exists and the product itself changes (new people, new surface, a flow dropped) → **Change**.
24
24
  3. No brief, and the repo has code or a README → **Existing project**.
25
25
  4. Otherwise → **New idea**.
26
26
 
27
27
  ## New idea
28
28
 
29
- Load Matt's `grilling` and run it. The design tree is the brief's sections below. Start with the frontier: a working name, problem, who it is for, surface. Flows, screens and scope hang off those. A working name is enough; it can change.
29
+ Load Matt's `grilling` and run it. The design tree is the brief's sections below. Start with the frontier: a working name, problem, who it is for, surface. Flows, screens, position and scope hang off those. A working name is enough; it can change.
30
30
 
31
31
  - One round per message, numbered, a recommended answer on each, as `grilling` says.
32
32
  - Recommend from the idea itself. A one-line idea still has a likely person and a likely first flow: propose them, they correct.
33
+ - Position comes from what they do today instead. Name those alternatives, then recommend the one thing this product is remembered for. Most people have not thought about it, so propose it; they correct.
33
34
  - A section they do not care about gets your recommendation and a "yes" settles it. Never leave one blank.
34
- - Stop asking when every section has an answer. Then say the brief in chat in six lines (problem, for, flows, surface, v1, out) and ask "Write `docs/brief.md`?" Write on yes.
35
+ - Stop asking when every section has an answer. Then say the brief in chat in seven lines (problem, for, flows, surface, remembered for, v1, out) and ask "Write `docs/brief.md`?" Write on yes.
35
36
 
36
37
  ## Existing project
37
38
 
38
- Read the README, the package manifest, the routes or entry points, and any `docs/`. Draft every section you can from what is there and mark each one **from the repo** or **gap**. A section the code shows but the README contradicts is a gap.
39
+ Read the README, the package manifest, the routes or entry points, any `docs/`, and any file at the root that describes the product. Draft every section you can from what is there and mark each one **from the repo** or **gap**. A section the code shows but a document contradicts is a gap. Stack and architecture stay out, wherever they are written.
39
40
 
40
41
  Show the draft, then grill only the gaps, in rounds. Same confirm, same write.
41
42
 
43
+ Another document may now cover the same ground as the brief. Two descriptions of the product drift apart, so after writing, recommend what happens to it (trim it, or keep it for detail with a line pointing to the brief) and change it only on their yes.
44
+
42
45
  ## Change
43
46
 
44
47
  Read the brief. Grill only what changes and what hangs off it: a new surface reopens key screens, a new person reopens flows. Update those sections, add a line under **Changes** with the date and why, and leave the rest word for word.
@@ -74,6 +77,11 @@ Read the brief. Grill only what changes and what hangs off it: a new surface reo
74
77
  ## Constraints
75
78
  - <What is fixed: devices, offline, languages, accessibility needs, a deadline, a budget. Not tech choices.>
76
79
 
80
+ ## Position
81
+ - against: <what they use today instead, by name: "the phone's notes app, a paper logbook">
82
+ - remembered for: <one concrete thing someone would describe to a friend: "the tide line that runs down every entry". Not a value word>
83
+ - personality: <three adjectives>. Says: "<a line it would say>". Never: "<a line it would never say>"
84
+
77
85
  ## Identity nouns
78
86
  <4–8 concrete nouns from the product's world: the things, places, tools and materials its people know. "Tide, buoy, logbook, brass", not "trust, speed, simple".>
79
87
 
@@ -83,15 +91,17 @@ Read the brief. Grill only what changes and what hangs off it: a new surface reo
83
91
 
84
92
  - Every section has content. "None" is an answer. A guess is not.
85
93
  - **Changes** is added under Out of scope by the first Change, never before.
94
+ - Position is concrete. "Fast, simple, trustworthy" says nothing every rival would not say. `remembered for` is a thing you could point at on a screen or in a sentence; `against` names real products or habits.
86
95
  - Content is real: the longest names the people will type, the likely numbers, the real empty case. `design` uses them as copy.
87
96
  - Over a page means a flow is really two products, or a section is doing Architecture's job. Cut it.
88
97
 
89
98
  ## After writing
90
99
 
91
- Offer the next stage in one line:
100
+ Offer the next stage in one line. A stage whose file already exists is done, so go past it:
92
101
 
93
- - Surface is site or app → `design-direction`.
94
- - No UI → stages 2 and 3 are skipped. Next is Architecture: `grill-with-docs`.
102
+ - Site or app, no `DESIGN.md` → `design-direction`.
103
+ - No UI, or `DESIGN.md` exists → stages 2 and 3 are skipped. Next is Architecture: they type `/grill-with-docs`.
104
+ - `GLOSSARY.md` exists too → next is Plan: they type `/to-spec` for the first flow or feature.
95
105
 
96
106
  Do not start it until they say so.
97
107
 
@@ -99,5 +109,5 @@ Do not start it until they say so.
99
109
 
100
110
  - Pick a stack, or write a requirement as one ("uses Postgres").
101
111
  - Ask a question the repo or the idea already answers.
102
- - Write the brief before they confirm the six-line summary.
112
+ - Write the brief before they confirm the seven-line summary.
103
113
  - Edit the brief for a feature. Features get specs.