@shadevkumar/agent-wrapped 0.1.0 → 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/README.md CHANGED
@@ -6,7 +6,7 @@ Your life with AI coding agents, wrapped.
6
6
  npx @shadevkumar/agent-wrapped
7
7
  ```
8
8
 
9
- It reads your Claude Code and Codex logs on your computer and turns them into a short animated story made of keyboard keys: your most-typed typo, every way you've spelled "everything", the key you hit when you meant another, your latest prompt after midnight, your streak, and what all that agent work would cost at public API prices. It ends with your personality and a letter from your agents.
9
+ It reads your Claude Code and Codex logs on your computer and turns them into a short animated story made of keyboard keys: your most-typed typo, every way you've spelled "everything", the key you hit when you meant another, how you talk to your agents, your latest prompt after midnight, your streak, what your agents got done, and what all that work would cost at public API prices. It ends with your personality and a letter from your agents.
10
10
 
11
11
  Then you share it. One link plays your whole story for anyone who opens it, keys and sound included, and ends by showing them how to make their own. You can leave cards out first, or save a video for places that don't take links. While you watch, the buttons fade away so a screenshot shows only the card, and pressing S saves the card on screen.
12
12
 
@@ -24,13 +24,13 @@ Nothing is uploaded. The story is one HTML file written to your computer's temp
24
24
  | Agent | Where | What |
25
25
  | --- | --- | --- |
26
26
  | Claude Code | `~/.claude/history.jsonl` | the prompts you typed |
27
- | Claude Code | `~/.claude/projects/**/*.jsonl` | token use and how long each request took |
27
+ | Claude Code | `~/.claude/projects/**/*.jsonl` | token use, how long each request took, and when the agent ran tests, made a commit, edited a file or was stopped |
28
28
  | Claude Code | `~/.claude/stats-cache.json` | older token totals |
29
- | Codex | `~/.codex/thread_history_*.sqlite` | the prompts you typed and how long each request took |
29
+ | Codex | `~/.codex/thread_history_*.sqlite` | the prompts you typed, how long each request took, and the same tests, commits, edits and stops |
30
30
  | Codex | `~/.codex/state_*.sqlite` | token totals per thread |
31
31
  | Codex | `~/.codex/sessions/**/*.jsonl` | token splits for recent threads |
32
32
 
33
- Everything is opened read-only. Claude Code deletes full transcripts after about 30 days, so older Claude token use can be missing. The prompts themselves go back further.
33
+ Everything is opened read-only. For what the agents did, only the kind is kept (a test run, a commit, a stop) and, for an edit, the file type: never a command, a file name or any output. Claude Code deletes full transcripts after about 30 days, so older Claude token use and work can be missing. The prompts themselves go back further.
34
34
 
35
35
  ## How the cost is worked out
36
36
 
package/dist/build.js CHANGED
@@ -40,6 +40,9 @@ export function buildHtml(data, playerUrl = PLAYER_URL) {
40
40
  const json = JSON.stringify(data).replace(/</g, "\\u003c");
41
41
  return readFileSync(join(STORY_DIR, "index.html"), "utf8")
42
42
  .replace("<!--HEAD-->", () => (data ? "" : PUBLIC_HEAD))
43
+ // The public page doesn't know yet whether its link holds a story, so its
44
+ // player starts hidden instead of flashing an empty frame.
45
+ .replace('<main class="player" id="player">', (tag) => (data ? tag : '<main class="player" id="player" hidden>'))
43
46
  .replace("/*FONTS*/", () => fonts)
44
47
  .replace("/*DATA*/", () => json)
45
48
  .replace("/*PLAYER_URL*/", () => JSON.stringify(playerUrl).replace(/</g, "\\u003c"))
package/dist/letter.js CHANGED
@@ -16,6 +16,10 @@ export function factsFor(w, p) {
16
16
  ...w.voice.topPrompts.slice(0, 3).map((t) => `They typed "${t.text}" ${t.count} times.`),
17
17
  ...w.voice.catchphrases.slice(0, 2).map((c) => `Catchphrase "${c.text}" in ${c.sessions} sessions.`),
18
18
  ...w.voice.typos.slice(0, 2).map((t) => `They spelled "${t.word}" ${t.spellings.length} wrong ways, like "${t.spellings[0]?.spelling}".`),
19
+ w.voice.nicknames[0] ? `They called their agents "${w.voice.nicknames[0].word}" ${w.voice.nicknames[0].count} times.` : "",
20
+ `They said please ${w.voice.lexicon.please ?? 0} times and thanks ${w.voice.lexicon.thanks ?? 0} times.`,
21
+ w.work.tests ? `Their agents ran their tests ${w.work.tests} times and made ${w.work.commits} commits.` : "",
22
+ w.work.stops ? `They stopped their agents mid-answer ${w.work.stops} times.` : "",
19
23
  ];
20
24
  return facts.filter(Boolean).join("\n");
21
25
  }
package/dist/moments.js CHANGED
@@ -20,6 +20,17 @@ const LEXICON = {
20
20
  wait: ["wait"],
21
21
  perfect: ["perfect", "great", "awesome", "nice"],
22
22
  };
23
+ const NICKNAMES = ["dude", "bro", "man", "buddy", "mate", "bhai", "boss", "chief", "fam"];
24
+ const CHECK_IN = /\b(okay|ok|right)\s*\?/i;
25
+ // File types that are code, by the language they're written in.
26
+ const LANGUAGES = {
27
+ ".py": "Python", ".ts": "TypeScript", ".tsx": "TypeScript", ".js": "JavaScript", ".jsx": "JavaScript",
28
+ ".mjs": "JavaScript", ".cjs": "JavaScript", ".go": "Go", ".rs": "Rust", ".rb": "Ruby", ".java": "Java",
29
+ ".kt": "Kotlin", ".swift": "Swift", ".c": "C", ".h": "C", ".cpp": "C++", ".cc": "C++", ".hpp": "C++",
30
+ ".cs": "C#", ".php": "PHP", ".dart": "Dart", ".scala": "Scala", ".ex": "Elixir", ".exs": "Elixir",
31
+ ".lua": "Lua", ".sql": "SQL", ".sh": "Shell", ".css": "CSS", ".scss": "CSS", ".html": "HTML",
32
+ ".vue": "Vue", ".svelte": "Svelte",
33
+ };
23
34
  export function computeWrapped(h, words = new Words(h.privateNames)) {
24
35
  const prompts = [...h.prompts].sort((a, b) => a.at.getTime() - b.at.getTime());
25
36
  const tokenized = prompts.map((p) => tokenize(p.text));
@@ -67,12 +78,42 @@ export function computeWrapped(h, words = new Words(h.privateNames)) {
67
78
  pastedShare: share(pasted.filter((flags) => flags.some(Boolean)).length, prompts.length),
68
79
  doubleSends: doubleSends(prompts),
69
80
  lexicon: lexicon(tokenized),
81
+ nicknames: nicknames(tokenized),
82
+ checkIns: prompts.filter((p) => CHECK_IN.test(p.text)).length,
70
83
  },
71
84
  loyalty: {
72
85
  claudeShare: share(agents.claude.prompts, prompts.length),
73
86
  codexShare: share(agents.codex.prompts, prompts.length),
74
87
  bothAgentDays: bothAgentDays(prompts),
75
88
  },
89
+ work: work(h),
90
+ };
91
+ }
92
+ function nicknames(tokenized) {
93
+ const counts = new Map(NICKNAMES.map((w) => [w, 0]));
94
+ for (const toks of tokenized)
95
+ for (const w of toks)
96
+ if (counts.has(w))
97
+ counts.set(w, counts.get(w) + 1);
98
+ return [...counts].filter(([, n]) => n > 0).map(([word, count]) => ({ word, count })).sort((a, b) => b.count - a.count);
99
+ }
100
+ function work(h) {
101
+ const count = (kind) => h.actions.filter((a) => a.kind === kind).length;
102
+ const byLanguage = new Map();
103
+ for (const a of h.actions) {
104
+ const name = a.kind === "edit" && a.ext ? LANGUAGES[a.ext] : undefined;
105
+ if (name)
106
+ byLanguage.set(name, (byLanguage.get(name) ?? 0) + 1);
107
+ }
108
+ // Stops are kept far longer than the rest, so they don't move the start.
109
+ const first = h.actions.reduce((min, a) => (a.kind !== "stop" && (!min || a.at < min) ? a.at : min), null);
110
+ return {
111
+ since: first ? localDay(first) : null,
112
+ tests: count("test"),
113
+ commits: count("commit"),
114
+ edits: count("edit"),
115
+ stops: count("stop"),
116
+ languages: [...byLanguage].map(([name, edits]) => ({ name, edits })).sort((a, b) => b.edits - a.edits),
76
117
  };
77
118
  }
78
119
  function agentStats(agent, h) {
@@ -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 { commandKind, 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
+ const kind = b.name === "Bash" ? commandKind(String(b.input?.command ?? "")) : null;
119
+ if (kind)
120
+ out.push([b.id, { 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 { commandKind, 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,61 @@ 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
+ const kind = commandKind(firstString(item.head, "command") ?? "");
114
+ if (kind)
115
+ h.actions.push({ agent: "codex", at, kind });
116
+ }
117
+ }
118
+ }
119
+ catch {
120
+ // Without these the story skips what the agents did; the rest still works.
121
+ }
85
122
  finally {
86
123
  history.close();
87
124
  }
88
125
  }
89
126
  return h;
90
127
  }
128
+ // The first "key":"value" string in a piece of JSON that may be cut off.
129
+ function firstString(json, key) {
130
+ const m = json.match(new RegExp(`"${key}":("(?:[^"\\\\]|\\\\.)*")`));
131
+ if (!m)
132
+ return null;
133
+ try {
134
+ return JSON.parse(m[1]);
135
+ }
136
+ catch {
137
+ return null;
138
+ }
139
+ }
91
140
  // The Codex app wraps a typed request with IDE context and tagged blocks.
92
141
  // Returns only what the person typed, or null for text Codex wrote itself.
93
142
  export function cleanCodexPrompt(raw) {
@@ -139,10 +139,83 @@ a.button[hidden] { display: none; }
139
139
  .ending > div, .missing > div { max-width: 480px; }
140
140
  .ending .lede, .missing .lede { margin: 0 auto 24px; }
141
141
  .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);
142
+ /* The command sits in a sunken well, like a terminal line, with Copy inside. */
143
+ .command {
144
+ display: flex; align-items: center; gap: 12px;
145
+ width: min(100%, 470px); margin: 0 auto 16px; padding: 7px 7px 7px 18px;
146
+ border-radius: 14px; background: var(--key-side);
147
+ box-shadow: inset 0 0 0 1px var(--line), inset 0 2px 8px rgba(0, 0, 0, 0.45);
145
148
  }
149
+ .command code {
150
+ flex: 1; min-width: 0; text-align: left; white-space: nowrap; overflow-x: auto; scrollbar-width: none;
151
+ font: 500 16px/1.4 "Geist", ui-monospace, monospace; letter-spacing: -0.01em;
152
+ }
153
+ .command code::before { content: "$ "; color: var(--faint); }
154
+ .command button { flex: none; min-width: 76px; }
155
+ @media (max-width: 440px) {
156
+ .command { flex-wrap: wrap; padding: 14px; }
157
+ .command code { flex-basis: 100%; text-align: center; font-size: 15px; }
158
+ .command button { flex: 1; }
159
+ }
160
+
161
+ /* Home: the keys type moments from Shadev's story; everything else stays quiet. */
162
+ #home {
163
+ background: radial-gradient(110% 60% at 50% -10%, rgba(255, 255, 255, 0.07), transparent 65%), var(--page);
164
+ animation: appear .35s ease-out both;
165
+ }
166
+ #home > * { animation: appear .5s ease-out .05s both; }
167
+ @keyframes appear { from { opacity: 0; } }
168
+ #home > div { max-width: 780px; }
169
+ .typing {
170
+ --k: min(62px, calc((100vw - 32px - 9 * 8px) / 9.2));
171
+ display: flex; justify-content: center; gap: 8px;
172
+ height: calc(var(--k) * 1.12); margin-bottom: 14px;
173
+ }
174
+ .key {
175
+ width: var(--k); height: var(--k); flex: none;
176
+ display: grid; place-items: center;
177
+ border-radius: calc(var(--k) * 0.22);
178
+ font: 500 calc(var(--k) * 0.42)/1 "Geist", system-ui, sans-serif; color: var(--ink);
179
+ background: linear-gradient(var(--key-top), var(--key));
180
+ 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);
181
+ transition: transform .07s, box-shadow .07s, background .25s, color .25s;
182
+ }
183
+ .key.space { width: calc(var(--k) * 0.45); background: none; box-shadow: none; }
184
+ .key.down {
185
+ transform: translateY(calc(var(--k) * 0.08));
186
+ 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);
187
+ }
188
+ .key.lit {
189
+ color: var(--plate); background: linear-gradient(var(--lit-top), var(--lit));
190
+ box-shadow: 0 calc(var(--k) * 0.1) 0 var(--lit-side), 0 14px 30px rgba(0, 0, 0, 0.45);
191
+ }
192
+ .typing-note {
193
+ min-height: 1.4em; margin: 0 0 44px;
194
+ font: italic 400 18px/1.4 "Newsreader", Georgia, serif; color: var(--faint);
195
+ opacity: 0; transition: opacity .4s;
196
+ }
197
+ .typing-note.show { opacity: 1; }
198
+ /* Medium weight, lit from above like a key cap. The fill only paints inside
199
+ the box, so it's padded to hold the tails of g and p, and each line of a
200
+ wrapped title gets its own light. */
201
+ #home h1 { font-size: clamp(44px, 9vw, 84px); font-weight: 480; letter-spacing: -0.06em; line-height: 1.02; margin-bottom: 18px; }
202
+ #home h1 span {
203
+ padding: 0.06em 0.04em 0.16em;
204
+ background: linear-gradient(180deg, #FFFFFF 30%, #8E9096); -webkit-background-clip: text; background-clip: text; color: transparent;
205
+ -webkit-box-decoration-break: clone; box-decoration-break: clone;
206
+ }
207
+ #home .lede { font: italic 400 clamp(19px, 2.6vw, 23px)/1.35 "Newsreader", Georgia, serif; max-width: 30ch; margin-bottom: 36px; }
208
+ #home .row { margin-bottom: 44px; }
209
+ .fine { margin: 0 auto; color: var(--faint); font-size: 13px; line-height: 1.55; }
210
+ .github {
211
+ position: absolute; top: max(20px, env(safe-area-inset-top)); right: 20px;
212
+ display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
213
+ color: var(--faint); transition: color .2s;
214
+ }
215
+ .github:hover { color: var(--ink); }
216
+ .github:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
217
+ .github svg { width: 22px; height: 22px; fill: currentColor; }
218
+ @media (prefers-reduced-motion: reduce) { .typing-note { opacity: 1; } #home, #home > * { animation: none; } }
146
219
  .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
147
220
  @media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
148
221
  </style>
@@ -197,9 +270,11 @@ code.command {
197
270
  <div>
198
271
  <h1 id="ending-title" tabindex="-1">Make your own</h1>
199
272
  <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>
273
+ <div class="command">
274
+ <code>npx @shadevkumar/agent-wrapped</code>
275
+ <button class="primary" data-copy-command>Copy</button>
276
+ </div>
201
277
  <div class="row">
202
- <button class="primary" data-copy-command>Copy command</button>
203
278
  <button data-replay>Watch again</button>
204
279
  </div>
205
280
  </div>
@@ -214,13 +289,22 @@ code.command {
214
289
 
215
290
  <section class="ending" id="home" aria-labelledby="home-title" hidden>
216
291
  <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>
292
+ <div class="typing" id="home-keys" aria-hidden="true"></div>
293
+ <p class="typing-note" id="home-note" aria-hidden="true"></p>
294
+ <h1 id="home-title"><span>Agent Wrapped 2026</span></h1>
295
+ <p class="lede">Your year with Claude Code and Codex, played back in keyboard keys.</p>
296
+ <div class="command">
297
+ <code>npx @shadevkumar/agent-wrapped</code>
298
+ <button class="primary" data-copy-command>Copy</button>
299
+ </div>
220
300
  <div class="row">
221
- <button class="primary" data-copy-command>Copy command</button>
301
+ <a class="button" id="featured" href="#featured">Watch Shadev's story</a>
222
302
  </div>
303
+ <p class="fine">Runs on your computer. Nothing is uploaded unless you share.</p>
223
304
  </div>
305
+ <a class="github" href="https://github.com/shadevkumar/agent-wrapped" aria-label="The code on GitHub">
306
+ <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>
307
+ </a>
224
308
  </section>
225
309
 
226
310
  <p class="toast" id="toast" role="status"></p>
@@ -7,12 +7,7 @@
7
7
 
8
8
  // ---------------------------------------------------------------- story data
9
9
 
10
- const PLAYER_URL = JSON.parse(document.getElementById("player-url").textContent);
11
- const OWN = JSON.parse(document.getElementById("data").textContent);
12
- const SHARED = !OWN;
13
- const D = OWN ?? (await openLink());
14
- if (!D) await new Promise(() => {}); // nothing to play; the page says why
15
- const YEAR = D.range?.to.slice(0, 4) ?? "";
10
+ const COMMAND = "npx @shadevkumar/agent-wrapped";
16
11
 
17
12
  const toast = document.getElementById("toast");
18
13
  let toastTimer = 0;
@@ -23,21 +18,33 @@ function notify(message, { stay = false } = {}) {
23
18
  if (!stay) toastTimer = setTimeout(() => toast.classList.remove("show"), 2800);
24
19
  }
25
20
 
26
- // Wired first: the home page has no story, so the script stops early there.
21
+ // Everything the home page needs is set up above the line where the script
22
+ // stops for a link with no story in it.
27
23
  for (const btn of document.querySelectorAll("[data-copy-command]")) btn.addEventListener("click", async () => {
28
24
  try {
29
- await navigator.clipboard.writeText("npx @shadevkumar/agent-wrapped");
30
- notify("Copied. Paste it into your terminal.");
25
+ await navigator.clipboard.writeText(COMMAND);
26
+ btn.textContent = "Copied";
27
+ setTimeout(() => (btn.textContent = "Copy"), 1800);
31
28
  } catch {
32
- notify("Couldn't copy it. Type npx @shadevkumar/agent-wrapped in your terminal.");
29
+ notify(`Couldn't copy it. Type ${COMMAND} in your terminal.`);
33
30
  }
34
31
  });
35
32
 
33
+ const PLAYER_URL = JSON.parse(document.getElementById("player-url").textContent);
34
+ const OWN = JSON.parse(document.getElementById("data").textContent);
35
+ const SHARED = !OWN;
36
+ // A new link in the same tab, like "Watch Shadev's story", starts over.
37
+ if (SHARED) addEventListener("hashchange", () => location.reload());
38
+ const D = OWN ?? (await openLink());
39
+ if (!D) await new Promise(() => {}); // nothing to play; the page says why
40
+ const YEAR = D.range?.to.slice(0, 4) ?? "";
41
+
36
42
  // The public page with no story in its link is the home page.
37
43
  async function openLink() {
38
44
  document.getElementById("player").hidden = true;
39
45
  if (!location.hash) {
40
46
  document.getElementById("home").hidden = false;
47
+ typeMoments();
41
48
  return null;
42
49
  }
43
50
  try {
@@ -51,6 +58,62 @@ async function openLink() {
51
58
  return null;
52
59
  }
53
60
 
61
+ // The home page's keys type moments from Shadev's story, the one its
62
+ // "Watch Shadev's story" link plays, so the two always match. Everything it
63
+ // uses lives inside it: it runs before the rest of the script.
64
+ async function typeMoments() {
65
+ const s = await unpack(document.getElementById("featured").hash.replace(/^#v1\./, ""));
66
+ const n = (x) => x.toLocaleString("en-US");
67
+ // The keys that differ from the right spelling stay lit.
68
+ const wrong = (typed, word) => {
69
+ const at = [...typed].flatMap((ch, i) => (ch === word[i] ? [] : [i]));
70
+ return typed.length === word.length ? at : at.slice(0, 1);
71
+ };
72
+ // [what gets typed, which keys stay lit, what it is]
73
+ const MOMENTS = [
74
+ s.topTypo && [s.topTypo.spelling, wrong(s.topTypo.spelling, s.topTypo.word), `Shadev typed this ${n(s.topTypo.count)} times`],
75
+ s.spellings && [s.spellings.spellings[0], wrong(s.spellings.spellings[0], s.spellings.word), `one of Shadev's ${s.spellings.spellings.length} ways to spell ${s.spellings.word}`],
76
+ s.topPrompts[0] && [s.topPrompts[0].text, [], "Shadev's most-sent prompt"],
77
+ s.catchphrase && [s.catchphrase.text, [], `Shadev said this in ${n(s.catchphrase.sessions)} sessions`],
78
+ s.night && [s.night.latest, [], "Shadev's latest prompt of the year"],
79
+ ].filter((m) => m && m[0].length <= 10);
80
+ const row = document.getElementById("home-keys");
81
+ const note = document.getElementById("home-note");
82
+ const wait = (ms) => new Promise((r) => setTimeout(r, ms));
83
+ const key = (ch) => {
84
+ const k = document.createElement("span");
85
+ k.className = ch === " " ? "key space" : "key";
86
+ k.textContent = ch;
87
+ return k;
88
+ };
89
+ const show = ([word, lit, what]) => {
90
+ row.replaceChildren(...[...word].map(key));
91
+ for (const i of lit) row.children[i].classList.add("lit");
92
+ note.textContent = what;
93
+ };
94
+ if (matchMedia("(prefers-reduced-motion: reduce)").matches) return show(MOMENTS[0]);
95
+ for (let m = 0; ; m = (m + 1) % MOMENTS.length) {
96
+ const [word, lit, what] = MOMENTS[m];
97
+ for (const [i, ch] of [...word].entries()) {
98
+ const k = row.appendChild(key(ch));
99
+ k.classList.add("down");
100
+ await wait(70);
101
+ k.classList.remove("down");
102
+ if (lit.includes(i)) k.classList.add("lit");
103
+ await wait(60 + Math.random() * 90);
104
+ }
105
+ note.textContent = what;
106
+ note.classList.add("show");
107
+ await wait(2600);
108
+ note.classList.remove("show");
109
+ while (row.lastChild) {
110
+ row.lastChild.remove();
111
+ await wait(38);
112
+ }
113
+ await wait(450);
114
+ }
115
+ }
116
+
54
117
  // JSON, compressed and written with link-safe characters.
55
118
  async function pack(data) {
56
119
  const stream = new Blob([JSON.stringify(data)]).stream().pipeThrough(new CompressionStream("deflate-raw"));
@@ -269,7 +332,7 @@ function initials(name) {
269
332
  }
270
333
 
271
334
  function watermark(ctx, cw) {
272
- text(ctx, { x: 0, w: shape.W }, "made with npx @shadevkumar/agent-wrapped", shape.H - (shape === SHAPES.wide ? 84 : 124), {
335
+ text(ctx, { x: 0, w: shape.W }, `made with ${COMMAND}`, shape.H - (shape === SHAPES.wide ? 84 : 124), {
273
336
  family: "Geist", weight: 500, size: 26, color: cw.faint, align: "center",
274
337
  });
275
338
  }
@@ -535,6 +598,29 @@ function buildCards(D) {
535
598
  });
536
599
  }
537
600
 
601
+ if (D.talk) {
602
+ const k = D.talk;
603
+ const word = k.nickname?.word ?? "please";
604
+ const lines = [
605
+ k.nickname ? `You called us “${k.nickname.word}” ${num(k.nickname.count)} times.` : `You said please ${num(k.please)} times.`,
606
+ k.nickname && k.please + k.thanks > 0 && `Please ${num(k.please)} times. Thanks ${num(k.thanks)}.${k.thanks * 3 < k.please ? " We noticed." : ""}`,
607
+ !k.nickname && `And thanks ${num(k.thanks)} times.`,
608
+ k.checkIns >= 20 && `And you asked “okay?” ${num(k.checkIns)} times.`,
609
+ ].filter(Boolean);
610
+ add({
611
+ id: "talk", name: "How you talk", dur: 7,
612
+ alt: `How you talk to us. ${lines.join(" ")}`,
613
+ head: (ctx, t, fx, cw, b) => text(ctx, b, "How you talk to us", 0, { ...say(54), color: cw.soft }),
614
+ visual: (ctx, t, fx, cw, b) => typeRow(ctx, b, chars(word), 120, 210, t, 0.4, fx, cw, { step: 0.16 }),
615
+ words(ctx, t, fx, cw, b) {
616
+ let y = text(ctx, b, lines[0], 0, { ...big(72), color: cw.ink, alpha: fade(t, 1.4) });
617
+ lines.slice(1).forEach((line, i) => {
618
+ y = text(ctx, b, line, y + 18, { ...say(), color: cw.soft, alpha: fade(t, 2.2 + i * 0.8) });
619
+ });
620
+ },
621
+ });
622
+ }
623
+
538
624
  if (D.night) {
539
625
  const n = D.night;
540
626
  add({
@@ -606,6 +692,39 @@ function buildCards(D) {
606
692
  });
607
693
  }
608
694
 
695
+ if (D.work) {
696
+ const w = D.work;
697
+ const rows = [["ran your tests", w.tests], ["made commits", w.commits], ["got stopped by you", w.stops]].filter(([, n]) => n > 0);
698
+ const most = Math.max(...rows.map(([, n]) => n));
699
+ const last = 0.6 + (rows.length - 1) * 0.35;
700
+ add({
701
+ id: "work", name: "What we did", dur: 7,
702
+ alt: `What we got done, since ${day(w.since)}: ${rows.map(([what, n]) => `${what}, ${num(n)} times`).join("; ")}.${w.languages.length ? ` Mostly in ${w.languages.join(" and ")}.` : ""}`,
703
+ head: (ctx, t, fx, cw, b) => text(ctx, b, "What we got done", 0, { ...big(70), color: cw.ink }),
704
+ visual(ctx, t, fx, cw, b) {
705
+ rows.forEach(([what, n], i) => {
706
+ const at = 0.6 + i * 0.35;
707
+ fx.key(at);
708
+ const local = REDUCED ? 9 : t - at;
709
+ if (local < 0) return;
710
+ const label = { text: what, size: 44, family: "Geist", weight: 500 };
711
+ const right = { text: `${num(n)}×`, size: 40, family: "Geist", weight: 400 };
712
+ const least = textWidth(ctx, label.text, 46, label) + textWidth(ctx, right.text, 46, right) + 140;
713
+ const width = Math.min(b.w, least + (b.w - least) * (n / most) * easeOut(local / 0.5));
714
+ cap(ctx, b.x + width / 2, 80 + i * 190, width, 140, "", { ...cw, left: true, lines: [label], right, press: pressAt(local) });
715
+ });
716
+ },
717
+ words(ctx, t, fx, cw, b) {
718
+ const y = w.languages.length
719
+ ? text(ctx, b, `Mostly in ${w.languages.join(" and ")}.`, 0, { ...say(), color: cw.soft, alpha: fade(t, last + 0.5) }) + 20
720
+ : 0;
721
+ text(ctx, b, `Counted from the logs your agents keep, since ${day(w.since)}.`, y, {
722
+ size: 34, color: cw.faint, alpha: fade(t, last + 1.2),
723
+ });
724
+ },
725
+ });
726
+ }
727
+
609
728
  if (D.money) {
610
729
  const m = D.money;
611
730
  add({
@@ -955,7 +1074,7 @@ const postLinkedIn = document.getElementById("post-linkedin");
955
1074
  // Cards you can leave out, and the part of the story each one needs.
956
1075
  const LEAVABLE = {
957
1076
  "top-typo": "topTypo", spellings: "spellings", slip: "slip", "top-prompts": "topPrompts", catchphrase: "catchphrase",
958
- night: "night", streak: "streak", agents: "agents", money: "money", letter: "letter",
1077
+ talk: "talk", night: "night", streak: "streak", agents: "agents", work: "work", money: "money", letter: "letter",
959
1078
  };
960
1079
  const left = new Set(); // ids of the cards left out
961
1080
  let link = "";
package/dist/story.js CHANGED
@@ -3,9 +3,15 @@ const PLAIN_OPENINGS = /^(let me|tell me|can you|could you|what we|then we|i wan
3
3
  export function pickCatchphrase(list) {
4
4
  return list.find((c) => !PLAIN_OPENINGS.test(c.text)) ?? null;
5
5
  }
6
+ // A count this small isn't a habit yet.
7
+ const HABIT = 20;
6
8
  export function storyData(w, personality, letter) {
7
9
  const family = w.voice.typos.find((f) => f.spellings.length >= 5) ?? null;
8
10
  const streak = w.rhythm.longestStreak;
11
+ const nickname = w.voice.nicknames[0] && w.voice.nicknames[0].count >= HABIT ? w.voice.nicknames[0] : null;
12
+ const please = w.voice.lexicon.please ?? 0;
13
+ const thanks = w.voice.lexicon.thanks ?? 0;
14
+ const wk = w.work;
9
15
  return {
10
16
  range: w.totals.firstDay && w.totals.lastDay ? { from: w.totals.firstDay, to: w.totals.lastDay } : null,
11
17
  prompts: w.totals.prompts,
@@ -29,6 +35,12 @@ export function storyData(w, personality, letter) {
29
35
  }
30
36
  : null,
31
37
  money: w.cost.atLeastUsd >= 1 ? { atLeastUsd: w.cost.atLeastUsd, pricesAsOf: w.cost.pricesAsOf } : null,
38
+ talk: nickname || please + thanks >= HABIT || w.voice.checkIns >= HABIT
39
+ ? { nickname, please, thanks, checkIns: w.voice.checkIns }
40
+ : null,
41
+ work: wk.since && wk.tests + wk.commits >= 10
42
+ ? { since: wk.since, tests: wk.tests, commits: wk.commits, stops: wk.stops, languages: wk.languages.slice(0, 2).map((l) => l.name) }
43
+ : null,
32
44
  personality,
33
45
  letter,
34
46
  };
package/dist/types.js CHANGED
@@ -4,8 +4,18 @@
4
4
  export function usageTokens(u) {
5
5
  return u.input + u.cacheRead + u.cacheWrite + u.cacheWrite1h + u.output;
6
6
  }
7
+ // Commands that run a project's tests, and ones that make a commit.
8
+ const TEST_COMMAND = /\b(pytest|vitest|jest|mocha|go test|cargo test|npm (run )?test|pnpm (run )?test|yarn test|bun test|node --test|tests?\.sh|phpunit|rspec)\b/;
9
+ const COMMIT_COMMAND = /\bgit commit\b/;
10
+ export function commandKind(command) {
11
+ if (COMMIT_COMMAND.test(command))
12
+ return "commit";
13
+ if (TEST_COMMAND.test(command))
14
+ return "test";
15
+ return null;
16
+ }
7
17
  export function emptyHarvest() {
8
- return { prompts: [], usage: [], totals: [], turns: [], coverage: [], privateNames: new Set() };
18
+ return { prompts: [], usage: [], totals: [], turns: [], actions: [], coverage: [], privateNames: new Set() };
9
19
  }
10
20
  export function mergeHarvests(parts) {
11
21
  const out = emptyHarvest();
@@ -14,6 +24,7 @@ export function mergeHarvests(parts) {
14
24
  out.usage.push(...p.usage);
15
25
  out.totals.push(...p.totals);
16
26
  out.turns.push(...p.turns);
27
+ out.actions.push(...p.actions);
17
28
  out.coverage.push(...p.coverage);
18
29
  for (const n of p.privateNames)
19
30
  out.privateNames.add(n);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shadevkumar/agent-wrapped",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Your year with AI coding agents, played back in keyboard keys. Reads Claude Code and Codex logs on your computer.",
5
5
  "keywords": [
6
6
  "claude-code",