@shadevkumar/agent-wrapped 0.1.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/dist/screen.js ADDED
@@ -0,0 +1,78 @@
1
+ import { emitKeypressEvents } from "node:readline";
2
+ // What the command shows while it runs, on stderr, so --json output stays
3
+ // clean. In a terminal each step updates in place; piped, it prints plain lines.
4
+ const out = process.stderr;
5
+ const live = out.isTTY === true;
6
+ const color = live && !process.env.NO_COLOR;
7
+ const paint = (code) => (s) => (color ? `\x1b[${code}m${s}\x1b[0m` : s);
8
+ export const dim = paint("2");
9
+ export const bold = paint("1");
10
+ const green = paint("32");
11
+ export function line(text = "") {
12
+ out.write(`${text}\n`);
13
+ }
14
+ function redraw(text) {
15
+ if (live)
16
+ out.write(`\r\x1b[2K${text}`);
17
+ }
18
+ const FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
19
+ // Shows `doing` while `work` runs (with a spinner when the work lets the
20
+ // screen redraw), then a tick and what was done.
21
+ export async function step(doing, work, done) {
22
+ const started = Date.now();
23
+ let frame = 0;
24
+ redraw(` ${dim(FRAMES[0])} ${doing}`);
25
+ const spin = live ? setInterval(() => redraw(` ${dim(FRAMES[++frame % FRAMES.length])} ${doing}`), 80) : undefined;
26
+ // Let the first frame draw before work that holds the process.
27
+ await new Promise((r) => setImmediate(r));
28
+ try {
29
+ const result = await work();
30
+ const seconds = (Date.now() - started) / 1000;
31
+ const text = ` ${green("✓")} ${done(result)}${seconds >= 2 ? dim(` ${seconds.toFixed(0)}s`) : ""}`;
32
+ if (live)
33
+ redraw(`${text}\n`);
34
+ else
35
+ line(text);
36
+ return result;
37
+ }
38
+ finally {
39
+ clearInterval(spin);
40
+ }
41
+ }
42
+ // A choice made with the arrow keys and Enter. Without a terminal to ask in,
43
+ // the first option is the answer.
44
+ export async function choose(question, options) {
45
+ const input = process.stdin;
46
+ if (!live || !input.isTTY)
47
+ return options[0].value;
48
+ let at = 0;
49
+ const draw = () => redraw(` ${bold("?")} ${question} ${options.map((o, i) => (i === at ? bold(`❯ ${o.label}`) : dim(` ${o.label}`))).join(" ")} ${dim("← → Enter")}`);
50
+ emitKeypressEvents(input);
51
+ input.setRawMode(true);
52
+ input.resume();
53
+ draw();
54
+ const value = await new Promise((resolve) => {
55
+ const onKey = (_, key) => {
56
+ if (key.ctrl && key.name === "c") {
57
+ input.setRawMode(false);
58
+ line();
59
+ process.exit(130);
60
+ }
61
+ if (["left", "up"].includes(key.name ?? ""))
62
+ at = (at + options.length - 1) % options.length;
63
+ else if (["right", "down", "tab"].includes(key.name ?? ""))
64
+ at = (at + 1) % options.length;
65
+ else if (key.name === "return") {
66
+ input.off("keypress", onKey);
67
+ resolve(options[at].value);
68
+ return;
69
+ }
70
+ draw();
71
+ };
72
+ input.on("keypress", onKey);
73
+ });
74
+ input.setRawMode(false);
75
+ input.pause();
76
+ redraw(` ${green("✓")} ${question} ${dim(options[at].label)}\n`);
77
+ return value;
78
+ }
@@ -1,6 +1,6 @@
1
- import { join } from "node:path";
1
+ import { extname, join } from "node:path";
2
2
  import { coverage, findFiles, localDay, namesFromPath, readJson, readJsonl, toDate } from "../files.js";
3
- import { emptyHarvest } from "../types.js";
3
+ import { commandKinds, emptyHarvest } from "../types.js";
4
4
  // Claude Code keeps three things in ~/.claude:
5
5
  // - history.jsonl: every prompt typed, kept long term
6
6
  // - stats-cache.json: older token totals per model, up to `lastComputedDate`
@@ -42,15 +42,26 @@ export function harvestClaude(home) {
42
42
  // usage, and copies history into resumed sessions. Count each reply once.
43
43
  const replies = new Map();
44
44
  const turnIds = new Set();
45
- // Only replies and turn timings matter here; tool output and attachments,
46
- // most of each file, are skipped without being decoded.
47
- const relevant = (line) => line.includes('"type":"assistant"') || line.includes('"turn_duration"');
45
+ const actionIds = new Set();
46
+ // Only replies, turn timings and stops matter here; tool output and
47
+ // attachments, most of each file, are skipped without being decoded.
48
+ const relevant = (line) => line.includes('"type":"assistant"') || line.includes('"turn_duration"') || line.includes(INTERRUPTED);
48
49
  for (const file of findFiles(join(root, "projects"), ".jsonl")) {
49
50
  for (const row of readJsonl(file, relevant)) {
50
51
  if (typeof row.cwd === "string")
51
52
  addNames(h, namesFromPath(row.cwd));
52
53
  const at = toDate(row.timestamp);
53
- if (!at || (statsDay && localDay(at) <= statsDay))
54
+ if (!at)
55
+ continue;
56
+ // What the agent did, and when it was stopped, counts once each, even
57
+ // when a resumed session copies it.
58
+ for (const [id, action] of actionsIn(row)) {
59
+ if (actionIds.has(id))
60
+ continue;
61
+ actionIds.add(id);
62
+ h.actions.push({ agent: "claude", at, ...action });
63
+ }
64
+ if (statsDay && localDay(at) <= statsDay)
54
65
  continue;
55
66
  if (row.type === "system" && row.subtype === "turn_duration" && num(row.durationMs) > 0) {
56
67
  const id = String(row.uuid ?? `${row.sessionId}|${row.timestamp}`);
@@ -85,6 +96,31 @@ export function harvestClaude(home) {
85
96
  h.coverage.push(coverage("claude", "replies", [...replies.values()].map((u) => u.at)));
86
97
  return h;
87
98
  }
99
+ const INTERRUPTED = "[Request interrupted by user";
100
+ const EDIT_TOOLS = new Set(["Edit", "MultiEdit", "Write", "NotebookEdit"]);
101
+ // The tests, commits and edits in a reply, and a stop in a user line, each
102
+ // with an id to count it once by.
103
+ function actionsIn(row) {
104
+ const content = row.message?.content;
105
+ if (row.type === "user") {
106
+ const text = typeof content === "string" ? content : Array.isArray(content) ? content.map((b) => b?.text ?? "").join("") : "";
107
+ return text.includes(INTERRUPTED) ? [[`stop|${row.uuid ?? row.timestamp}`, { kind: "stop" }]] : [];
108
+ }
109
+ if (row.type !== "assistant" || !Array.isArray(content))
110
+ return [];
111
+ const out = [];
112
+ for (const b of content) {
113
+ if (b?.type !== "tool_use" || typeof b.id !== "string")
114
+ continue;
115
+ const path = b.input?.file_path ?? b.input?.notebook_path;
116
+ if (EDIT_TOOLS.has(b.name) && typeof path === "string")
117
+ out.push([b.id, { kind: "edit", ext: extname(path).toLowerCase() }]);
118
+ if (b.name === "Bash")
119
+ for (const kind of commandKinds(String(b.input?.command ?? "")))
120
+ out.push([`${b.id}|${kind}`, { kind }]);
121
+ }
122
+ return out;
123
+ }
88
124
  // Drops slash and shell commands and paste placeholders; keeps what was typed.
89
125
  export function cleanClaudePrompt(raw) {
90
126
  const text = raw
@@ -1,8 +1,8 @@
1
1
  import { existsSync, readdirSync } from "node:fs";
2
- import { join } from "node:path";
2
+ import { extname, join } from "node:path";
3
3
  import { DatabaseSync } from "node:sqlite";
4
4
  import { coverage, lastJsonLine, namesFromGitUrl, namesFromPath, toDate } from "../files.js";
5
- import { emptyHarvest } from "../types.js";
5
+ import { commandKinds, emptyHarvest } from "../types.js";
6
6
  // Codex keeps, in ~/.codex:
7
7
  // - state_N.sqlite `threads`: one row per thread, with its token total
8
8
  // - thread_history_N.sqlite: every message and turn, kept long term
@@ -82,12 +82,60 @@ export function harvestCodex(home) {
82
82
  catch {
83
83
  // Without turn timings the story skips agent hours; prompts still count.
84
84
  }
85
+ try {
86
+ for (const t of history.prepare("select started_at from thread_turns where status = 'interrupted'").all()) {
87
+ const at = toDate(Number(t.started_at) * 1000);
88
+ if (at)
89
+ h.actions.push({ agent: "codex", at, kind: "stop" });
90
+ }
91
+ }
92
+ catch {
93
+ // Older histories don't record how a turn ended.
94
+ }
95
+ try {
96
+ // Each item also holds the command's output or the file's diff, often
97
+ // far larger than the rest, so only its start is read: the command or
98
+ // the first file path is near the top.
99
+ const items = history
100
+ .prepare(`select item_type, created_at_ms, substr(item_json, 1, 1200) as head from thread_items
101
+ where item_type in ('commandExecution', 'fileChange')`)
102
+ .all();
103
+ for (const item of items) {
104
+ const at = toDate(Number(item.created_at_ms));
105
+ if (!at)
106
+ continue;
107
+ if (item.item_type === "fileChange") {
108
+ const path = firstString(item.head, "path");
109
+ if (path)
110
+ h.actions.push({ agent: "codex", at, kind: "edit", ext: extname(path).toLowerCase() });
111
+ }
112
+ else {
113
+ for (const kind of commandKinds(firstString(item.head, "command") ?? ""))
114
+ h.actions.push({ agent: "codex", at, kind });
115
+ }
116
+ }
117
+ }
118
+ catch {
119
+ // Without these the story skips what the agents did; the rest still works.
120
+ }
85
121
  finally {
86
122
  history.close();
87
123
  }
88
124
  }
89
125
  return h;
90
126
  }
127
+ // The first "key":"value" string in a piece of JSON that may be cut off.
128
+ function firstString(json, key) {
129
+ const m = json.match(new RegExp(`"${key}":("(?:[^"\\\\]|\\\\.)*")`));
130
+ if (!m)
131
+ return null;
132
+ try {
133
+ return JSON.parse(m[1]);
134
+ }
135
+ catch {
136
+ return null;
137
+ }
138
+ }
91
139
  // The Codex app wraps a typed request with IDE context and tagged blocks.
92
140
  // Returns only what the person typed, or null for text Codex wrote itself.
93
141
  export function cleanCodexPrompt(raw) {
@@ -0,0 +1,81 @@
1
+ import { readdirSync } from "node:fs";
2
+ import { extname, join } from "node:path";
3
+ import { coverage, readJsonl, toDate } from "../files.js";
4
+ import { commandKinds, emptyHarvest } from "../types.js";
5
+ // Cursor's agent keeps one transcript per chat in
6
+ // ~/.cursor/projects/<folder>/agent-transcripts/<chat>/<chat>.jsonl. A line is
7
+ // a user or assistant message; only the person's lines carry a time, written
8
+ // into the text as <timestamp>, with what they typed in <user_query>. Lines
9
+ // without both are instructions Cursor added itself. The same chat can be
10
+ // saved under two folders, so each prompt and action counts once.
11
+ export function harvestCursor(home) {
12
+ const root = join(home, ".cursor", "projects");
13
+ const h = emptyHarvest();
14
+ const seen = new Set();
15
+ for (const folder of list(root)) {
16
+ // The folder is the project path with dashes ("Users-me-acme-portal").
17
+ h.privateNames.add(folder.toLowerCase());
18
+ for (const chat of list(join(root, folder, "agent-transcripts"))) {
19
+ let at = null; // the person's latest prompt, the time of what follows
20
+ let step = 0;
21
+ for (const row of readJsonl(join(root, folder, "agent-transcripts", chat, `${chat}.jsonl`))) {
22
+ const content = Array.isArray(row.message?.content) ? row.message.content : [];
23
+ if (row.role === "user") {
24
+ const prompt = parsePrompt(content.map((b) => b?.text ?? "").join(""));
25
+ if (!prompt)
26
+ continue;
27
+ at = prompt.at;
28
+ step = 0;
29
+ const id = `${chat}|${at.getTime()}|${prompt.text}`;
30
+ if (seen.has(id))
31
+ continue;
32
+ seen.add(id);
33
+ h.prompts.push({ agent: "cursor", text: prompt.text, at, session: chat });
34
+ continue;
35
+ }
36
+ if (row.role !== "assistant" || !at)
37
+ continue;
38
+ for (const b of content) {
39
+ if (b?.type !== "tool_use")
40
+ continue;
41
+ const id = `${chat}|${at.getTime()}|${step++}`;
42
+ if (seen.has(id))
43
+ continue;
44
+ seen.add(id);
45
+ const path = b.input?.path;
46
+ if (EDIT_TOOLS.has(b.name) && typeof path === "string")
47
+ h.actions.push({ agent: "cursor", at, kind: "edit", ext: extname(path).toLowerCase() });
48
+ if (b.name === "Shell")
49
+ for (const kind of commandKinds(String(b.input?.command ?? "")))
50
+ h.actions.push({ agent: "cursor", at, kind });
51
+ }
52
+ }
53
+ }
54
+ }
55
+ h.coverage.push(coverage("cursor", "prompts", h.prompts.map((p) => p.at)));
56
+ return h;
57
+ }
58
+ const EDIT_TOOLS = new Set(["StrReplace", "Write", "EditNotebook"]);
59
+ const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
60
+ // "<timestamp>Friday, Aug 7, 2026, 5:58 PM (UTC+5:30)</timestamp>
61
+ // <user_query>fix it</user_query>" -> the time and "fix it".
62
+ export function parsePrompt(raw) {
63
+ const time = raw.match(/<timestamp>[^<]*?(\w{3}) (\d{1,2}), (\d{4}), (\d{1,2}):(\d{2}) ([AP]M) \(UTC([+-])(\d{1,2})(?::(\d{2}))?\)<\/timestamp>/);
64
+ const query = raw.match(/<user_query>([\s\S]*?)<\/user_query>/);
65
+ const month = MONTHS.indexOf(time?.[1] ?? "");
66
+ const text = query?.[1]?.trim();
67
+ if (!time || !text || month < 0)
68
+ return null;
69
+ const hour = (Number(time[4]) % 12) + (time[6] === "PM" ? 12 : 0);
70
+ const offset = (time[7] === "-" ? -1 : 1) * (Number(time[8]) * 60 + Number(time[9] ?? 0));
71
+ const at = toDate(Date.UTC(Number(time[3]), month, Number(time[2]), hour, Number(time[5])) - offset * 60_000);
72
+ return at ? { at, text } : null;
73
+ }
74
+ function list(dir) {
75
+ try {
76
+ return readdirSync(dir, { withFileTypes: true }).filter((d) => d.isDirectory() && !d.name.startsWith(".")).map((d) => d.name);
77
+ }
78
+ catch {
79
+ return [];
80
+ }
81
+ }
@@ -81,6 +81,10 @@ canvas#stage { width: 100%; height: 100%; display: block; touch-action: manipula
81
81
  .bars i { display: block; height: 100%; width: 0; background: var(--ink); }
82
82
  .controls { position: absolute; top: 28px; right: 16px; display: flex; gap: 8px; transition: opacity .5s; }
83
83
  .controls button { padding: 9px 12px 10px; font-size: 12px; }
84
+ .controls button.icon { padding: 9px 11px 10px; }
85
+ .icon svg { display: block; width: 12px; height: 12px; fill: currentColor; }
86
+ .icon .tri, .icon[aria-pressed="true"] .bar { display: none; }
87
+ .icon[aria-pressed="true"] .tri { display: inline; }
84
88
  .idle .controls { opacity: 0; }
85
89
  .idle .controls:focus-within { opacity: 1; }
86
90
 
@@ -139,13 +143,86 @@ a.button[hidden] { display: none; }
139
143
  .ending > div, .missing > div { max-width: 480px; }
140
144
  .ending .lede, .missing .lede { margin: 0 auto 24px; }
141
145
  .ending .row { justify-content: center; }
142
- code.command {
143
- display: block; margin: 0 auto 20px; padding: 16px 20px; border-radius: 12px;
144
- font: 500 20px/1 "Geist", ui-monospace, monospace; background: var(--key-side); box-shadow: inset 0 0 0 1px var(--line);
146
+ /* The command sits in a sunken well, like a terminal line, with Copy inside. */
147
+ .command {
148
+ display: flex; align-items: center; gap: 12px;
149
+ width: min(100%, 470px); margin: 0 auto 16px; padding: 7px 7px 7px 18px;
150
+ border-radius: 14px; background: var(--key-side);
151
+ box-shadow: inset 0 0 0 1px var(--line), inset 0 2px 8px rgba(0, 0, 0, 0.45);
145
152
  }
153
+ .command code {
154
+ flex: 1; min-width: 0; text-align: left; white-space: nowrap; overflow-x: auto; scrollbar-width: none;
155
+ font: 500 16px/1.4 "Geist", ui-monospace, monospace; letter-spacing: -0.01em;
156
+ }
157
+ .command code::before { content: "$ "; color: var(--faint); }
158
+ .command button { flex: none; min-width: 76px; }
159
+ @media (max-width: 440px) {
160
+ .command { flex-wrap: wrap; padding: 14px; }
161
+ .command code { flex-basis: 100%; text-align: center; font-size: 15px; }
162
+ .command button { flex: 1; }
163
+ }
164
+
165
+ /* Home: the keys type moments from Shadev's story; everything else stays quiet. */
166
+ #home {
167
+ background: radial-gradient(110% 60% at 50% -10%, rgba(255, 255, 255, 0.07), transparent 65%), var(--page);
168
+ }
169
+ html.home #home[hidden] { display: grid !important; }
170
+ html.home:not(.fonts-in) #home { visibility: hidden; }
171
+ #home > div { max-width: 780px; }
172
+ .typing {
173
+ --k: min(62px, calc((100vw - 32px - 9 * 8px) / 9.2));
174
+ display: flex; justify-content: center; gap: 8px;
175
+ height: calc(var(--k) * 1.12); margin-bottom: 14px;
176
+ }
177
+ .key {
178
+ width: var(--k); height: var(--k); flex: none;
179
+ display: grid; place-items: center;
180
+ border-radius: calc(var(--k) * 0.22);
181
+ font: 500 calc(var(--k) * 0.42)/1 "Geist", system-ui, sans-serif; color: var(--ink);
182
+ background: linear-gradient(var(--key-top), var(--key));
183
+ box-shadow: 0 calc(var(--k) * 0.1) 0 var(--key-side), 0 14px 30px rgba(0, 0, 0, 0.45), inset 0 1.5px 0 rgba(255, 255, 255, 0.1);
184
+ transition: transform .07s, box-shadow .07s, background .25s, color .25s;
185
+ }
186
+ .key.space { width: calc(var(--k) * 0.45); background: none; box-shadow: none; }
187
+ .key.down {
188
+ transform: translateY(calc(var(--k) * 0.08));
189
+ box-shadow: 0 calc(var(--k) * 0.02) 0 var(--key-side), 0 0 28px rgba(255, 255, 255, 0.28), inset 0 1.5px 0 rgba(255, 255, 255, 0.1);
190
+ }
191
+ .key.lit {
192
+ color: var(--plate); background: linear-gradient(var(--lit-top), var(--lit));
193
+ box-shadow: 0 calc(var(--k) * 0.1) 0 var(--lit-side), 0 14px 30px rgba(0, 0, 0, 0.45);
194
+ }
195
+ .typing-note {
196
+ min-height: 1.4em; margin: 0 0 44px;
197
+ font: italic 400 18px/1.4 "Newsreader", Georgia, serif; color: var(--faint);
198
+ opacity: 0; transition: opacity .4s;
199
+ }
200
+ .typing-note.show { opacity: 1; }
201
+ /* Medium weight, lit from above like a key cap. The fill only paints inside
202
+ the box, so it's padded to hold the tails of g and p, and each line of a
203
+ wrapped title gets its own light. */
204
+ #home h1 { font-size: clamp(44px, 9vw, 84px); font-weight: 480; letter-spacing: -0.06em; line-height: 1.02; margin-bottom: 18px; }
205
+ #home h1 span {
206
+ padding: 0.06em 0.04em 0.16em;
207
+ background: linear-gradient(180deg, #FFFFFF 30%, #8E9096); -webkit-background-clip: text; background-clip: text; color: transparent;
208
+ -webkit-box-decoration-break: clone; box-decoration-break: clone;
209
+ }
210
+ #home .lede { font: italic 400 clamp(19px, 2.6vw, 23px)/1.35 "Newsreader", Georgia, serif; max-width: 30ch; margin-bottom: 36px; }
211
+ #home .row { margin-bottom: 44px; }
212
+ .fine { margin: 0 auto; color: var(--faint); font-size: 13px; line-height: 1.55; }
213
+ .github {
214
+ position: absolute; top: max(20px, env(safe-area-inset-top)); right: 20px;
215
+ display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
216
+ color: var(--faint); transition: color .2s;
217
+ }
218
+ .github:hover { color: var(--ink); }
219
+ .github:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
220
+ .github svg { width: 22px; height: 22px; fill: currentColor; }
221
+ @media (prefers-reduced-motion: reduce) { .typing-note { opacity: 1; } }
146
222
  .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
147
223
  @media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
148
224
  </style>
225
+ <!--HOME-->
149
226
  </head>
150
227
  <body>
151
228
  <main class="player" id="player">
@@ -153,6 +230,7 @@ code.command {
153
230
  <canvas id="stage" width="1080" height="1920" aria-hidden="true"></canvas>
154
231
  <div class="bars" id="bars"></div>
155
232
  <div class="controls">
233
+ <button id="pause" class="icon" aria-pressed="false" aria-label="Pause" aria-keyshortcuts="Space"><svg viewBox="0 0 12 12" aria-hidden="true"><rect class="bar" x="2" y="1.5" width="2.6" height="9" rx="0.6"/><rect class="bar" x="7.4" y="1.5" width="2.6" height="9" rx="0.6"/><path class="tri" d="M3 1.6v8.8a.6.6 0 0 0 .9.5l7-4.4a.6.6 0 0 0 0-1l-7-4.4a.6.6 0 0 0-.9.5z"/></svg></button>
156
234
  <button id="sound" aria-pressed="true">Sound on</button>
157
235
  <button id="save-now">Save this card</button>
158
236
  <button id="skip">Skip to sharing</button>
@@ -160,7 +238,7 @@ code.command {
160
238
  <div class="start" id="start">
161
239
  <div>
162
240
  <button class="primary" id="play">Play my story</button>
163
- <p id="start-note">Sound on for the full effect. Tap the right side to go on, the left to go back. Press S to save a card.</p>
241
+ <p id="start-note">Sound on for the full effect. Tap the right side to go on, the left to go back. Space pauses, and S saves a card.</p>
164
242
  </div>
165
243
  </div>
166
244
  </div>
@@ -196,10 +274,12 @@ code.command {
196
274
  <section class="ending" id="ending" aria-labelledby="ending-title" hidden>
197
275
  <div>
198
276
  <h1 id="ending-title" tabindex="-1">Make your own</h1>
199
- <p class="lede">Run this in your terminal. It reads your Claude Code and Codex logs on your computer, and nothing leaves it unless you share.</p>
200
- <code class="command">npx @shadevkumar/agent-wrapped</code>
277
+ <p class="lede">Run this in your terminal. It reads your Claude Code, Codex and Cursor logs on your computer, and nothing leaves it unless you share.</p>
278
+ <div class="command">
279
+ <code>npx @shadevkumar/agent-wrapped</code>
280
+ <button class="primary" data-copy-command>Copy</button>
281
+ </div>
201
282
  <div class="row">
202
- <button class="primary" data-copy-command>Copy command</button>
203
283
  <button data-replay>Watch again</button>
204
284
  </div>
205
285
  </div>
@@ -214,13 +294,22 @@ code.command {
214
294
 
215
295
  <section class="ending" id="home" aria-labelledby="home-title" hidden>
216
296
  <div>
217
- <h1 id="home-title">Agent Wrapped 2026</h1>
218
- <p class="lede">Your year with Claude Code and Codex, played back in keyboard keys: your favourite typo, your latest night, your streak and a letter from your agents. Run this in your terminal. It reads your logs on your computer and nothing leaves it unless you share.</p>
219
- <code class="command">npx @shadevkumar/agent-wrapped</code>
297
+ <div class="typing" id="home-keys" aria-hidden="true"></div>
298
+ <p class="typing-note" id="home-note" aria-hidden="true"></p>
299
+ <h1 id="home-title"><span>Agent Wrapped 2026</span></h1>
300
+ <p class="lede">Your year with Claude Code, Codex and Cursor, played back in keyboard keys.</p>
301
+ <div class="command">
302
+ <code>npx @shadevkumar/agent-wrapped</code>
303
+ <button class="primary" data-copy-command>Copy</button>
304
+ </div>
220
305
  <div class="row">
221
- <button class="primary" data-copy-command>Copy command</button>
306
+ <a class="button" id="featured" href="#featured">Watch Shadev's story</a>
222
307
  </div>
308
+ <p class="fine">Runs on your computer. Nothing is uploaded unless you share.</p>
223
309
  </div>
310
+ <a class="github" href="https://github.com/shadevkumar/agent-wrapped" aria-label="The code on GitHub">
311
+ <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg>
312
+ </a>
224
313
  </section>
225
314
 
226
315
  <p class="toast" id="toast" role="status"></p>
@@ -0,0 +1,4 @@
1
+ import type { StoryData } from "../story.ts";
2
+
3
+ export function toLink(data: StoryData): unknown[];
4
+ export function fromLink(values: unknown[]): Partial<StoryData>;
@@ -0,0 +1,53 @@
1
+ // A shared story travels inside its link, after "#v2.". To keep links short,
2
+ // a link holds only the values, in the order below, never the field names.
3
+ // Fields are only ever added at the end of a list, so an older link still
4
+ // reads: a field it doesn't have comes back missing.
5
+ //
6
+ // The page and the site build both use this file.
7
+
8
+ const listOf = (fields) => ({ list: fields });
9
+
10
+ const FIELDS = [
11
+ ["range", ["from", "to"]],
12
+ "prompts",
13
+ "activeDays",
14
+ "sessions",
15
+ ["topTypo", ["spelling", "word", "count"]],
16
+ ["spellings", ["word", "spellings", "ways"]],
17
+ ["slip", ["meant", "hit", "count"]],
18
+ ["topPrompts", listOf(["text", "count"])],
19
+ ["catchphrase", ["text", "sessions"]],
20
+ ["night", ["latest", "prompts"]],
21
+ ["streak", ["days", "from", "to"]],
22
+ ["agents", ["claude", "codex", "cursor", "hours", "bothDays"]],
23
+ ["money", ["atLeastUsd", "pricesAsOf"]],
24
+ ["talk", [["nickname", ["word", "count"]], "please", "thanks", "checkIns"]],
25
+ ["work", ["since", "tests", "commits", "stops", "languages"]],
26
+ ["chapters", listOf(["from", "to", "name"])],
27
+ ["personality", ["name", "line", "traits"]],
28
+ ["letter", ["text"]],
29
+ "period",
30
+ ["shipped", ["since", "pushes", "prs", "deploys", ["biggestWeek", ["from", "to", "commits"]]]],
31
+ ];
32
+
33
+ export function toLink(data, fields = FIELDS) {
34
+ return fields.map((f) => {
35
+ const [key, inner] = typeof f === "string" ? [f] : f;
36
+ const value = data[key];
37
+ if (value === undefined || value === null) return null;
38
+ if (!inner) return value;
39
+ return inner.list ? value.map((item) => toLink(item, inner.list)) : toLink(value, inner);
40
+ });
41
+ }
42
+
43
+ export function fromLink(values, fields = FIELDS) {
44
+ const data = {};
45
+ fields.forEach((f, i) => {
46
+ const [key, inner] = typeof f === "string" ? [f] : f;
47
+ const value = values[i];
48
+ if (value === undefined) return;
49
+ if (value === null || !inner) data[key] = value;
50
+ else data[key] = inner.list ? value.map((item) => fromLink(item, inner.list)) : fromLink(value, inner);
51
+ });
52
+ return data;
53
+ }