@shadevkumar/agent-wrapped 0.4.1 → 0.5.2

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,9 +6,9 @@ Your life with AI coding agents, wrapped.
6
6
  npx @shadevkumar/agent-wrapped
7
7
  ```
8
8
 
9
- It reads your Claude Code, Codex and Cursor logs on your computer and turns them into a short animated story made of keyboard keys, with a quiet lofi loop underneath: your year in chapters, 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 crashouts, your latest prompt after midnight, your streak, what your agents got done, what you shipped, and what all that work would cost at public API prices. It ends with your personality and a letter from your agents.
9
+ It reads your Claude Code, Codex and Cursor logs on your computer and turns them into a short animated story made of keyboard keys, with a quiet lofi loop underneath: your year in chapters, 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 crashouts, how late your latest night ran, your streak, what your agents got done, what you shipped, 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
- It asks whether to cover everything so far or only the last 30 days. Each card stays up long enough to read it; press Space, the pause button, or press and hold to stop on one.
11
+ It asks whether to cover this year so far or only the last 30 days. A year's story starts on 1 January; made in January, it covers the year that just ended. Each card stays up long enough to read it; press Space, the pause button, or press and hold to stop on one.
12
12
 
13
13
  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.
14
14
 
@@ -20,6 +20,7 @@ Nothing is uploaded unless you share. The story is one HTML file written to your
20
20
  - **Nothing is shared until you share it.** When you share, the site saves what's on your cards so the link can be short. Your prompts and logs never leave your computer. If the site can't be reached, you get a long link that carries the story inside it instead. Anyone you give the link to can watch it.
21
21
  - **You see the story before you share it,** and a card you leave out is not in the link at all.
22
22
  - **Your year in chapters** splits your year into stretches, each named from the everyday words that set it apart, found on your computer. Words that could be a person's or a private name are left out. Your `claude` command turns those few words into short names; it never sees a prompt. Chapters say what you worked on, so they are left out of a share link unless you add them. With `--no-ai`, a chapter is named by its top words.
23
+ - **Your first name** opens your story and heads its summary card. It is left out of a share link unless you add it.
23
24
  - **The letter** is written by your own `claude` command, if you have one. It gets your numbers and a few quotes that passed the same privacy check as the cards, never your prompts or logs. It doesn't save a session or load any project files. Run with `--no-ai` to use a template letter instead.
24
25
 
25
26
  ## What it reads
@@ -29,12 +30,16 @@ Nothing is uploaded unless you share. The story is one HTML file written to your
29
30
  | Claude Code | `~/.claude/history.jsonl` | the prompts you typed |
30
31
  | 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 |
31
32
  | Claude Code | `~/.claude/stats-cache.json` | older token totals |
33
+ | Claude Code | `~/.claude.json` | the first word of your account's name |
32
34
  | Codex | `~/.codex/thread_history_*.sqlite` | the prompts you typed, how long each request took, and the same tests, commits, edits and stops |
33
35
  | Codex | `~/.codex/state_*.sqlite` | token totals per thread |
34
36
  | Codex | `~/.codex/sessions/**/*.jsonl` | token splits for recent threads |
35
37
  | Cursor | `~/.cursor/projects/*/agent-transcripts/*/*.jsonl` | the prompts you typed to Cursor's agent, and the same tests, commits and edits |
38
+ | Git | `git config --global user.name` | the first word of your name, when your Claude account has none |
36
39
 
37
- Everything is opened read-only. For what the agents did, only the kind is kept (a test run, a commit, a push, a pull request, a deploy, a stop) and, for an edit, the file type: never a command, a file name or any output. Cursor doesn't log tokens or how long its agent worked, so Cursor adds prompts and work but no hours or cost. 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.
40
+ Everything is opened read-only. For what the agents did, only the kind is kept (a test run, a commit, a push, a pull request, a deploy, a stop) and, for an edit, the file type: never a command, a file name or any output. Cursor doesn't log tokens or how long its agent worked, so Cursor adds prompts and work but no hours or cost. Claude Code deletes full transcripts after about 30 days, so older Claude token use, hours and work can be missing. The prompts themselves go back further. That is why the story says "at least" before its hours.
41
+
42
+ A late night is the prompts you sent between midnight and 5 AM. If you were still going at 5, the night runs on until your first break of more than an hour. From 6 AM it is morning: a night that was still going then only counts if none of your nights ended sooner. The story shows the latest one.
38
43
 
39
44
  ## How the cost is worked out
40
45
 
@@ -51,7 +56,7 @@ Prices are in `src/pricing.ts`, with the date they were read and their source pa
51
56
  | Flag | What it does |
52
57
  | --- | --- |
53
58
  | `--last-month` | Make the story from the last 30 days only |
54
- | `--everything` | Make it from everything so far, without asking |
59
+ | `--year` | Make it from this year, without asking (`--everything` does the same) |
55
60
  | `--no-ai` | Don't ask your `claude` command: a template letter, and chapters named by their top words |
56
61
  | `--no-open` | Write the story file without opening it |
57
62
  | `--json` | Print the numbers behind the story instead of making it |
package/dist/cli.js CHANGED
@@ -8,18 +8,22 @@ import { nameChapters } from "./chapters.js";
8
8
  import { localDay } from "./files.js";
9
9
  import { templateLetter, writeLetter } from "./letter.js";
10
10
  import { computeWrapped } from "./moments.js";
11
+ import { firstName } from "./name.js";
11
12
  import { pickPersonality } from "./personality.js";
12
13
  import { bold, choose, dim, line, step } from "./screen.js";
13
14
  import { readInBackground } from "./read-worker.js";
14
15
  import { storyData } from "./story.js";
15
- import { harvestSince, mergeHarvests } from "./types.js";
16
+ import { harvestSince, mergeHarvests, storyYear } from "./types.js";
16
17
  import { Words } from "./words.js";
17
- const HELP = `Agent Wrapped 2026: your year with Claude Code, Codex and Cursor, played back in keyboard keys.
18
+ const today = new Date();
19
+ const year = storyYear(today);
20
+ const yearOver = today.getFullYear() !== year; // January: the story is last year's
21
+ const HELP = `Agent Wrapped ${year}: your year with Claude Code, Codex and Cursor, played back in keyboard keys.
18
22
 
19
23
  Usage: npx @shadevkumar/agent-wrapped [options]
20
24
 
21
25
  --last-month Make the story from the last 30 days only
22
- --everything Make it from everything so far, without asking
26
+ --year Make it from ${year}, without asking
23
27
  --no-ai Don't ask your claude command: a template letter, and chapters named by their top words
24
28
  --no-open Write the story file without opening it
25
29
  --json Print the numbers behind the story instead of making it
@@ -33,23 +37,25 @@ const home = homedir();
33
37
  const useAi = !args.has("--no-ai");
34
38
  const n = (x) => Math.round(x).toLocaleString("en-US");
35
39
  line();
36
- line(` ${bold("Agent Wrapped 2026")}`);
40
+ line(` ${bold(`Agent Wrapped ${year}`)}`);
37
41
  line(` ${dim("Reads your agents' logs on this computer. Nothing is uploaded.")}`);
38
42
  line();
39
43
  const span = args.has("--last-month")
40
44
  ? "month"
41
- : args.has("--everything") || args.has("--json")
45
+ : args.has("--year") || args.has("--everything") || args.has("--json") // --everything is --year's old name
42
46
  ? "year"
43
47
  : await choose("Which stretch should your story cover?", [
44
- { label: "Everything so far", value: "year" },
48
+ { label: yearOver ? `All of ${year}` : `${year} so far`, value: "year" },
45
49
  { label: "The last 30 days", value: "month" },
46
50
  ]);
47
- const since = span === "month" ? new Date(Date.now() - 30 * 86_400_000) : null;
51
+ // A year's story runs from 1 January, so older logs don't count towards it.
52
+ const since = span === "month" ? new Date(today.getTime() - 30 * 86_400_000) : new Date(year, 0, 1);
53
+ const before = span === "month" ? undefined : new Date(year + 1, 0, 1);
48
54
  // All three are read at once; each line ticks when its agent is done.
49
55
  const reading = ["claude", "codex", "cursor"].map((source) => readInBackground(source, home));
50
56
  const parts = [];
51
57
  for (const [i, name] of ["Claude Code", "Codex", "Cursor"].entries()) {
52
- parts.push(await step(`Reading ${name}`, async () => (since ? harvestSince(await reading[i], since) : reading[i]), (h) => `${name} ${dim(h.prompts.length ? `${n(h.prompts.length)} prompts` : "none on this computer")}`));
58
+ parts.push(await step(`Reading ${name}`, async () => harvestSince(await reading[i], since, before), (h) => `${name} ${dim(h.prompts.length ? `${n(h.prompts.length)} prompts` : "none on this computer")}`));
53
59
  }
54
60
  const harvest = mergeHarvests(parts);
55
61
  const words = new Words(harvest.privateNames);
@@ -60,9 +66,9 @@ if (args.has("--json")) {
60
66
  }
61
67
  if (wrapped.totals.prompts === 0) {
62
68
  line();
63
- line(since
69
+ line(span === "month"
64
70
  ? " No prompts from the last 30 days on this computer. Try it without --last-month."
65
- : " No Claude Code, Codex or Cursor prompts on this computer, so there's no story yet.");
71
+ : ` No Claude Code, Codex or Cursor prompts from ${year} on this computer, so there's no story yet.${yearOver ? " Try --last-month for the last 30 days." : ""}`);
66
72
  process.exit(1);
67
73
  }
68
74
  const personality = pickPersonality(wrapped);
@@ -77,7 +83,7 @@ const [letter, chapterNames] = await step(useAi ? "Writing your letter" : "Writi
77
83
  const dir = join(tmpdir(), "agent-wrapped");
78
84
  mkdirSync(dir, { recursive: true });
79
85
  const file = join(dir, `agent-wrapped-${localDay(new Date())}${span === "month" ? "-last-30-days" : ""}.html`);
80
- writeFileSync(file, buildHtml(storyData(wrapped, personality, letter, chapterNames, span)));
86
+ writeFileSync(file, buildHtml(storyData(wrapped, personality, letter, chapterNames, span, firstName(home))));
81
87
  const hours = wrapped.totals.agentHours >= 1 ? `, ${n(wrapped.totals.agentHours)} hours of agent work` : "";
82
88
  line();
83
89
  console.log(` You are ${bold(personality.name)}.`);
package/dist/letter.js CHANGED
@@ -6,7 +6,7 @@ Write a short letter from their agents to them. Rules:
6
6
  - Use two or three of the facts given, quoting their words exactly as given.
7
7
  - Never invent numbers, names, projects or events that are not in the facts.
8
8
  - End with a short sign-off line from "your agents".`;
9
- // "02:34" -> "2:34 AM". Late-night times run from midnight to 5 AM.
9
+ // "02:34" -> "2:34 AM". A late night ends before 6 AM.
10
10
  export const clock = (hhmm) => `${Number(hhmm.slice(0, 2)) % 12 || 12}:${hhmm.slice(3)} AM`;
11
11
  export function factsFor(w, p, span = "year") {
12
12
  const facts = [
package/dist/moments.js CHANGED
@@ -3,6 +3,10 @@ import { apiCost, PRICES_AS_OF } from "./pricing.js";
3
3
  import { AGENTS, usageTokens } from "./types.js";
4
4
  import { findTypos, keySlips, tokenize, Words } from "./words.js";
5
5
  const LATE_NIGHT_END_HOUR = 5;
6
+ // A night still going at 5 AM runs on until the first break this long. From
7
+ // 6 AM it is morning.
8
+ const NIGHT_BREAK_MINUTES = 60;
9
+ const MORNING_HOUR = 6;
6
10
  // Repeats under a second apart are the logs writing a message twice, not a person.
7
11
  const DOUBLE_SEND_MIN_MS = 1_000;
8
12
  const DOUBLE_SEND_MAX_MS = 120_000;
@@ -254,19 +258,17 @@ function rhythm(prompts, days) {
254
258
  const byWeekday = new Array(7).fill(0);
255
259
  const perDay = new Map();
256
260
  let late = 0;
257
- let latestMinute = -1;
258
261
  for (const p of prompts) {
259
262
  const hour = p.at.getHours();
260
263
  byHour[hour]++;
261
264
  byWeekday[p.at.getDay()]++;
262
265
  const day = localDay(p.at);
263
266
  perDay.set(day, (perDay.get(day) ?? 0) + 1);
264
- if (hour < LATE_NIGHT_END_HOUR) {
267
+ if (hour < LATE_NIGHT_END_HOUR)
265
268
  late++;
266
- latestMinute = Math.max(latestMinute, hour * 60 + p.at.getMinutes());
267
- }
268
269
  }
269
270
  const busiest = [...perDay].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))[0];
271
+ const night = latestNight(prompts);
270
272
  return {
271
273
  byHour,
272
274
  byWeekday,
@@ -275,10 +277,54 @@ function rhythm(prompts, days) {
275
277
  lateNight: {
276
278
  prompts: late,
277
279
  share: share(late, prompts.length),
278
- latest: latestMinute < 0 ? null : `${pad(Math.floor(latestMinute / 60))}:${pad(latestMinute % 60)}`,
280
+ latest: night ? `${pad(Math.floor(night.minute / 60))}:${pad(night.minute % 60)}` : null,
281
+ latestDay: night?.day ?? null,
279
282
  },
280
283
  };
281
284
  }
285
+ // When the latest night ended, in minutes past midnight, and on which day.
286
+ // A night is the prompts between midnight and 5 AM. One still going at 5 runs
287
+ // on for as long as the breaks stay under an hour, so a prompt at 5:20 after
288
+ // one at 4:59 is the same night, and the first prompt after a sleep is not.
289
+ // A night still going at 6 AM has turned into a morning: it only counts, up to
290
+ // its last prompt before 6, when no night ended sooner. So the time shown is
291
+ // when you stopped, not always 5:59.
292
+ // `prompts` are sorted, oldest first.
293
+ export function latestNight(prompts) {
294
+ const mornings = new Map(); // local day -> minutes past midnight, up to 6:59
295
+ for (const p of prompts) {
296
+ if (p.at.getHours() > MORNING_HOUR)
297
+ continue;
298
+ const day = localDay(p.at);
299
+ if (!mornings.has(day))
300
+ mornings.set(day, []);
301
+ mornings.get(day).push(p.at.getHours() * 60 + p.at.getMinutes());
302
+ }
303
+ let ended = null;
304
+ let ranOn = null;
305
+ for (const [day, minutes] of mornings) {
306
+ let end = -1;
307
+ let pastSix = false;
308
+ for (const m of minutes) {
309
+ if (m >= LATE_NIGHT_END_HOUR * 60 && (end < 0 || m - end > NIGHT_BREAK_MINUTES))
310
+ break;
311
+ if (m >= MORNING_HOUR * 60) {
312
+ pastSix = true;
313
+ break;
314
+ }
315
+ end = m;
316
+ }
317
+ if (end < 0)
318
+ continue;
319
+ if (pastSix) {
320
+ if (end > (ranOn?.minute ?? -1))
321
+ ranOn = { minute: end, day };
322
+ }
323
+ else if (end > (ended?.minute ?? -1))
324
+ ended = { minute: end, day };
325
+ }
326
+ return ended ?? ranOn;
327
+ }
282
328
  // `days` are sorted, unique local days (YYYY-MM-DD).
283
329
  export function longestStreak(days) {
284
330
  if (days.length === 0)
package/dist/name.js ADDED
@@ -0,0 +1,22 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import { join } from "node:path";
3
+ import { readJson } from "./files.js";
4
+ // The first name the story greets you by: from your Claude account, else from
5
+ // git. Only the first word, so a full name never ends up on a card.
6
+ export function firstName(home) {
7
+ const account = readJson(join(home, ".claude.json"))?.oauthAccount;
8
+ for (const full of [account?.displayName, account?.fullName, gitName(home)]) {
9
+ const first = typeof full === "string" ? full.trim().split(/\s+/)[0].replace(/\p{C}/gu, "") : "";
10
+ if (first)
11
+ return first.slice(0, 24);
12
+ }
13
+ return null;
14
+ }
15
+ function gitName(home) {
16
+ try {
17
+ return execFileSync("git", ["config", "--global", "user.name"], { env: { ...process.env, HOME: home }, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
18
+ }
19
+ catch {
20
+ return null; // no git, or no name set
21
+ }
22
+ }
@@ -70,12 +70,16 @@ export function harvestCodex(home) {
70
70
  catch {
71
71
  h.coverage.push(coverage("codex", "prompts", []));
72
72
  }
73
+ // Some turns have no start time, only when they ended and how long they
74
+ // ran. Older histories have no end time either; there the start is used as is.
75
+ const ended = hasColumn(history, "thread_turns", "completed_at");
73
76
  try {
77
+ const start = ended ? "coalesce(started_at, completed_at - duration_ms / 1000)" : "started_at";
74
78
  const turns = history
75
- .prepare("select started_at, duration_ms from thread_turns where duration_ms > 0")
79
+ .prepare(`select ${start} as started_at, duration_ms from thread_turns where duration_ms > 0`)
76
80
  .all();
77
81
  for (const t of turns) {
78
- const at = toDate(Number(t.started_at) * 1000);
82
+ const at = seconds(t.started_at);
79
83
  if (at)
80
84
  h.turns.push({ agent: "codex", at, durationMs: Number(t.duration_ms) });
81
85
  }
@@ -84,8 +88,9 @@ export function harvestCodex(home) {
84
88
  // Without turn timings the story skips agent hours; prompts still count.
85
89
  }
86
90
  try {
87
- for (const t of history.prepare("select started_at from thread_turns where status = 'interrupted'").all()) {
88
- const at = toDate(Number(t.started_at) * 1000);
91
+ const start = ended ? "coalesce(started_at, completed_at)" : "started_at";
92
+ for (const t of history.prepare(`select ${start} as started_at from thread_turns where status = 'interrupted'`).all()) {
93
+ const at = seconds(t.started_at);
89
94
  if (at)
90
95
  h.actions.push({ agent: "codex", at, kind: "stop" });
91
96
  }
@@ -125,6 +130,18 @@ export function harvestCodex(home) {
125
130
  }
126
131
  return h;
127
132
  }
133
+ // A time Codex keeps in seconds. One it didn't keep is no time, not 1970.
134
+ function seconds(value) {
135
+ return value === null || value === undefined ? null : toDate(Number(value) * 1000);
136
+ }
137
+ function hasColumn(db, table, column) {
138
+ try {
139
+ return db.prepare(`pragma table_info(${table})`).all().some((c) => c.name === column);
140
+ }
141
+ catch {
142
+ return false;
143
+ }
144
+ }
128
145
  // The first "key":"value" string in a piece of JSON that may be cut off.
129
146
  function firstString(json, key) {
130
147
  const m = json.match(new RegExp(`"${key}":("(?:[^"\\\\]|\\\\.)*")`));
@@ -280,6 +280,9 @@ html.home:not(.fonts-in) #home { visibility: hidden; }
280
280
  <button class="primary" data-copy-command>Copy</button>
281
281
  </div>
282
282
  <div class="row">
283
+ <button id="ending-copy">Copy link</button>
284
+ <a class="button" id="ending-x" href="#">Post on X</a>
285
+ <a class="button" id="ending-linkedin" href="#">Post on LinkedIn</a>
283
286
  <button data-replay>Watch again</button>
284
287
  </div>
285
288
  </div>
@@ -17,7 +17,7 @@ const FIELDS = [
17
17
  ["slip", ["meant", "hit", "count"]],
18
18
  ["topPrompts", listOf(["text", "count"])],
19
19
  ["catchphrase", ["text", "sessions"]],
20
- ["night", ["latest", "prompts"]],
20
+ ["night", ["latest", "prompts", "day"]],
21
21
  ["streak", ["days", "from", "to"]],
22
22
  ["agents", ["claude", "codex", "cursor", "hours", "bothDays"]],
23
23
  ["money", ["atLeastUsd", "pricesAsOf"]],
@@ -29,6 +29,7 @@ const FIELDS = [
29
29
  "period",
30
30
  ["shipped", ["since", "pushes", "prs", "deploys", ["biggestWeek", ["from", "to", "commits"]]]],
31
31
  ["crashouts", ["count", ["worstDay", ["day", "count"]], "word"]],
32
+ "name",
32
33
  ];
33
34
 
34
35
  export function toLink(data, fields = FIELDS) {
@@ -187,7 +187,7 @@ const fade = (t, at, dur = 0.45) => (REDUCED ? 1 : easeOut((t - at) / dur));
187
187
  const num = (n) => Math.round(n).toLocaleString("en-US");
188
188
  const day = (iso) =>
189
189
  new Date(`${iso}T12:00:00`).toLocaleDateString("en-US", { month: "short", day: "numeric" });
190
- // "02:34" -> "2:34 AM". Late-night times run from midnight to 5 AM.
190
+ // "02:34" -> "2:34 AM". A late night ends before 6 AM.
191
191
  const clock = (hhmm) => `${Number(hhmm.slice(0, 2)) % 12 || 12}:${hhmm.slice(3)} AM`;
192
192
  const month = (ym) => new Date(`${ym}-15T12:00:00`).toLocaleDateString("en-US", { month: "short" });
193
193
 
@@ -954,13 +954,14 @@ function buildCards(D) {
954
954
  const plain = (l) => l === "," || l === ":" || l === "." || l === " AM";
955
955
  const big = (size) => ({ family: "Geist", weight: 600, size });
956
956
  const say = (size = 50) => ({ size, style: "italic" });
957
+ const opening = D.name ? `${D.name}, your agents have been talking about you.` : "Your agents have been talking about you.";
957
958
 
958
959
  add({
959
960
  id: "intro", name: "Intro", ready: 2.6,
960
- alt: "Your agents have been talking about you.",
961
+ alt: opening,
961
962
  visual: (ctx, t, fx, cw, b) => typeRow(ctx, b, ["h", "e", "y"], 120, 210, t, 0.4, fx, cw, { step: 0.17 }),
962
963
  words(ctx, t, fx, cw, b) {
963
- const y = text(ctx, b, "Your agents have been talking about you.", 0, { ...big(78), color: cw.ink, alpha: fade(t, 1.3) });
964
+ const y = text(ctx, b, opening, 0, { ...big(78), color: cw.ink, alpha: fade(t, 1.3) });
964
965
  if (D.range) {
965
966
  text(ctx, b, `Here's what we noticed, ${day(D.range.from)} to ${day(D.range.to)}.`, y + 20, {
966
967
  ...say(48), color: cw.soft, alpha: fade(t, 2.1),
@@ -989,21 +990,22 @@ function buildCards(D) {
989
990
  alt: `Your year in chapters: ${list.map((c) => `${months(c)}, ${c.name}`).join("; ")}.`,
990
991
  head: (ctx, t, fx, cw, b) => text(ctx, b, "Your year in chapters", 0, { ...big(70), color: cw.ink }),
991
992
  visual(ctx, t, fx, cw, b) {
992
- // One text size for every row: the largest the longest name fits at.
993
+ // One text size for every row: the largest the longest name fits at,
994
+ // down to 30. A name still too long takes two lines.
993
995
  const right = (c) => ({ text: months(c), size: 34, family: "Geist", weight: 400 });
994
- const size = Math.min(
995
- ...list.map((c) => {
996
- const room = b.w - 100 - textWidth(ctx, right(c).text, 36, right(c));
997
- return clamp((40 * room) / textWidth(ctx, c.name, 40, { family: "Geist", weight: 500 }), 26, 40);
998
- }),
999
- );
996
+ const name = { family: "Geist", weight: 500 };
997
+ const room = (c) => b.w - 100 - textWidth(ctx, right(c).text, 36, right(c));
998
+ const size = Math.min(...list.map((c) => clamp((40 * room(c)) / textWidth(ctx, c.name, 40, name), 30, 40)));
1000
999
  list.forEach((c, i) => {
1001
1000
  const at = 0.6 + i * 0.35;
1002
1001
  fx.key(at);
1003
1002
  const local = REDUCED ? 9 : t - at;
1004
1003
  if (local < 0) return;
1005
- const label = { text: c.name, size, family: "Geist", weight: 500 };
1006
- cap(ctx, b.x + b.w / 2, 70 + i * 160, b.w * easeOut(local / 0.5), 120, "", { ...cw, left: true, lines: [label], right: right(c), press: pressAt(local) });
1004
+ ctx.save();
1005
+ ctx.font = font(size, name);
1006
+ const lines = wrap(ctx, c.name, room(c)).slice(0, 2).map((text) => ({ text, size, ...name }));
1007
+ ctx.restore();
1008
+ cap(ctx, b.x + b.w / 2, 70 + i * 160, b.w * easeOut(local / 0.5), 120, "", { ...cw, left: true, lines, right: right(c), press: pressAt(local) });
1007
1009
  });
1008
1010
  },
1009
1011
  words: (ctx, t, fx, cw, b) =>
@@ -1193,12 +1195,15 @@ function buildCards(D) {
1193
1195
  if (D.night) {
1194
1196
  const n = D.night;
1195
1197
  add({
1196
- id: "night", name: "Late night", ready: 2.5,
1197
- alt: `The latest you were still prompting: ${clock(n.latest)}. ${num(n.prompts)} prompts between midnight and 5 AM.`,
1198
+ id: "night", name: "Late night", ready: n.day ? 2.8 : 2.5,
1199
+ alt: `The latest you were still prompting: ${clock(n.latest)}${n.day ? `, on ${day(n.day)}` : ""}. ${num(n.prompts)} prompts between midnight and 5 AM.`,
1198
1200
  head: (ctx, t, fx, cw, b) => text(ctx, b, "The latest you were still prompting", 0, { ...say(54), color: cw.soft }),
1199
1201
  visual: (ctx, t, fx, cw, b) => typeRow(ctx, b, [...chars(clock(n.latest).slice(0, -3)), " AM"], 110, 190, t, 0.6, fx, cw, { plain, step: 0.15 }),
1200
- words: (ctx, t, fx, cw, b) =>
1201
- text(ctx, b, `${num(n.prompts)} prompts between midnight and 5 AM. We were up too.`, 0, { ...big(68), color: cw.ink, alpha: fade(t, 1.9) }),
1202
+ words(ctx, t, fx, cw, b) {
1203
+ // A link shared before nights had a day says only the time.
1204
+ const y = n.day ? text(ctx, b, `That was ${day(n.day)}.`, 0, { ...say(), color: cw.soft, alpha: fade(t, 1.6) }) + 24 : 0;
1205
+ text(ctx, b, `${num(n.prompts)} prompts between midnight and 5 AM. We were up too.`, y, { ...big(68), color: cw.ink, alpha: fade(t, n.day ? 2.2 : 1.9) });
1206
+ },
1202
1207
  });
1203
1208
  }
1204
1209
 
@@ -1236,21 +1241,28 @@ function buildCards(D) {
1236
1241
 
1237
1242
  if (D.agents) {
1238
1243
  const a = D.agents;
1239
- const parts = [["Codex", a.codex], ["Claude", a.claude], ["Cursor", a.cursor ?? 0]].filter(([, v]) => v > 0);
1240
- const split = ["", "", ", split between two of us", ", split between three of us"][parts.length];
1241
- // Cursor doesn't log how long it worked, so a Cursor-only year has no hours.
1242
- const title = a.hours >= 1 ? `${num(a.hours)} hours of work${split}.` : `Your prompts${split || ", all to one of us"}.`;
1244
+ // The bars are each agent's share of your prompts, biggest first.
1245
+ const parts = [["Codex", a.codex], ["Claude", a.claude], ["Cursor", a.cursor ?? 0]].filter(([, v]) => v > 0).sort((x, y) => y[1] - x[1]);
1246
+ const percent = (share) => (share < 0.005 ? "<1" : Math.round(share * 100));
1247
+ const split = `Your prompts${["", ", all to one of us", ", split between two of us", ", split between three of us"][parts.length]}.`;
1248
+ // The hours are a floor: Claude Code keeps how long it worked for about a
1249
+ // month, and Cursor doesn't log it, so a Cursor-only year has no hours.
1250
+ const hours = a.hours >= 1 ? `At least ${num(a.hours)} hours of work.` : "";
1243
1251
  add({
1244
1252
  id: "agents", name: "Your agents", ready: 2.5,
1245
- alt: `${num(a.hours)} hours of agent work. ${parts.map(([name, share]) => `${name} ${Math.round(share * 100)} percent`).join(", ")}.`,
1246
- head: (ctx, t, fx, cw, b) => text(ctx, b, title, 0, { ...big(72), color: cw.ink }),
1253
+ alt: `${hours ? `${hours} ` : ""}Your prompts: ${parts.map(([name, share]) => `${name} ${percent(share)} percent`).join(", ")}.`,
1254
+ head(ctx, t, fx, cw, b) {
1255
+ if (!hours) return text(ctx, b, split, 0, { ...big(72), color: cw.ink });
1256
+ const y = text(ctx, b, hours, 0, { ...big(72), color: cw.ink });
1257
+ return text(ctx, b, split, y + 18, { ...say(), color: cw.soft });
1258
+ },
1247
1259
  visual(ctx, t, fx, cw, b) {
1248
1260
  parts.forEach(([name, share], i) => {
1249
1261
  const at = 0.7 + i * 0.4;
1250
1262
  fx.key(at);
1251
1263
  const local = REDUCED ? 9 : t - at;
1252
1264
  if (local < 0) return;
1253
- const label = { text: `${name} ${Math.round(share * 100)}%`, size: 48, family: "Geist", weight: 500 };
1265
+ const label = { text: `${name} ${percent(share)}%`, size: 48, family: "Geist", weight: 500 };
1254
1266
  const least = textWidth(ctx, label.text, 52, label) + 100;
1255
1267
  const w = Math.max(least, b.w * share) * easeOut(local / 0.6);
1256
1268
  cap(ctx, b.x + w / 2, 95 + i * 230, w, 170, "", { ...cw, left: true, lines: [label], press: pressAt(local) });
@@ -1433,7 +1445,7 @@ function buildCards(D) {
1433
1445
 
1434
1446
  const tiles = [
1435
1447
  [num(D.prompts), "prompts"],
1436
- D.agents ? [num(D.agents.hours), "hours of agent work"] : null,
1448
+ D.agents?.hours >= 1 ? [num(D.agents.hours), "hours of agent work"] : null,
1437
1449
  D.topTypo ? [`${D.topTypo.spelling} ×${num(D.topTypo.count)}`, "my favourite typo"] : null,
1438
1450
  D.night ? [clock(D.night.latest), "latest you were still prompting"] : D.streak ? [`${D.streak.days} days`, "longest streak"] : null,
1439
1451
  ].filter(Boolean);
@@ -1441,7 +1453,7 @@ function buildCards(D) {
1441
1453
  id: "summary", name: "Summary", ready: 0.7 + tiles.length * 0.25,
1442
1454
  alt: `Summary: ${p.name}. ${num(D.prompts)} prompts.`,
1443
1455
  head(ctx, t, fx, cw, b) {
1444
- const y = text(ctx, b, `My ${SPAN} with AI agents`, 0, { ...say(), color: cw.soft });
1456
+ const y = text(ctx, b, `${D.name ? `${D.name}'s` : "My"} ${SPAN} with AI agents`, 0, { ...say(), color: cw.soft });
1445
1457
  text(ctx, b, p.name, y + 10, { family: "Geist", weight: 700, size: 92, color: cw.ink, lh: 1.05 });
1446
1458
  },
1447
1459
  visual(ctx, t, fx, cw, b) {
@@ -1742,10 +1754,11 @@ const postLinkedIn = document.getElementById("post-linkedin");
1742
1754
  const LEAVABLE = {
1743
1755
  chapters: "chapters", "top-typo": "topTypo", spellings: "spellings", slip: "slip", "top-prompts": "topPrompts", catchphrase: "catchphrase",
1744
1756
  talk: "talk", crashouts: "crashouts", night: "night", streak: "streak", agents: "agents", work: "work", shipped: "shipped", money: "money", letter: "letter",
1757
+ name: "name",
1745
1758
  };
1746
- // ids of the cards left out. Chapters say what you worked on, so they stay
1747
- // out of a link unless you add them.
1748
- const left = new Set(["chapters"]);
1759
+ // ids of what's left out. Chapters say what you worked on, and your name who
1760
+ // you are, so they stay out of a link unless you add them.
1761
+ const left = new Set(["chapters", "name"]);
1749
1762
  let link = "";
1750
1763
  let linkFor = 0; // ignores a slower, older link if the choice changed meanwhile
1751
1764
 
@@ -1756,7 +1769,11 @@ function sharedData() {
1756
1769
  return d;
1757
1770
  }
1758
1771
 
1759
- const shareText = (d) => `My ${SPAN} with AI coding agents, wrapped. I'm ${d.personality.name}.`;
1772
+ // Someone else's story is passed on in the third person, named only if its owner shared their name.
1773
+ const shareText = (d) =>
1774
+ SHARED
1775
+ ? `${D.name ? `${D.name}'s` : "Someone's"} ${SPAN} with AI coding agents, wrapped: ${D.personality.name}.`
1776
+ : `My ${SPAN} with AI coding agents, wrapped. I'm ${d.personality.name}.`;
1760
1777
 
1761
1778
  function finalFrame(card, s) {
1762
1779
  return withShape(s, () => {
@@ -1802,9 +1819,10 @@ async function renderShare() {
1802
1819
 
1803
1820
  function renderChoices() {
1804
1821
  const list = document.getElementById("choices");
1822
+ // Your name isn't a card of its own, but leaves the link the same way.
1823
+ const named = D.name ? [{ id: "name", name: "Your name" }] : [];
1805
1824
  list.replaceChildren(
1806
- ...cards
1807
- .filter((card) => card.id in LEAVABLE)
1825
+ ...[...named, ...cards.filter((card) => card.id in LEAVABLE)]
1808
1826
  .map((card) => {
1809
1827
  const btn = document.createElement("button");
1810
1828
  btn.className = "chip";
@@ -1843,6 +1861,7 @@ function openShare() {
1843
1861
  // code and names it. Without the site, the long link still works.
1844
1862
  let short = { for: "", url: "" };
1845
1863
  async function shortLink() {
1864
+ if (SHARED) return location.href; // the link it was opened from
1846
1865
  const mine = link;
1847
1866
  if (short.for === mine) return short.url;
1848
1867
  try {
@@ -1856,7 +1875,7 @@ async function shortLink() {
1856
1875
  }
1857
1876
  }
1858
1877
 
1859
- document.getElementById("copy-link").addEventListener("click", async () => {
1878
+ for (const id of ["copy-link", "ending-copy"]) document.getElementById(id).addEventListener("click", async () => {
1860
1879
  const url = shortLink();
1861
1880
  try {
1862
1881
  // Handing the clipboard a promise keeps the click's permission to copy
@@ -1868,7 +1887,7 @@ document.getElementById("copy-link").addEventListener("click", async () => {
1868
1887
  }
1869
1888
  notify("Link copied. Paste it anywhere.");
1870
1889
  } catch {
1871
- notify("Couldn't copy the link. Try Share instead.");
1890
+ notify(SHARED ? "Couldn't copy the link. Copy it from the address bar instead." : "Couldn't copy the link. Try Share instead.");
1872
1891
  }
1873
1892
  });
1874
1893
 
@@ -1885,9 +1904,13 @@ document.getElementById("share-link").addEventListener("click", async () => {
1885
1904
 
1886
1905
  // The post opens in a new tab straight away, so it isn't blocked, and moves
1887
1906
  // to the post once the short link is ready.
1907
+ const toX = (url) => `https://x.com/intent/post?text=${encodeURIComponent(shareText(sharedData()))}&url=${encodeURIComponent(url)}`;
1908
+ const toLinkedIn = (url) => `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(url)}`;
1888
1909
  for (const [el, post] of [
1889
- [postX, (url) => `https://x.com/intent/post?text=${encodeURIComponent(shareText(sharedData()))}&url=${encodeURIComponent(url)}`],
1890
- [postLinkedIn, (url) => `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(url)}`],
1910
+ [postX, toX],
1911
+ [postLinkedIn, toLinkedIn],
1912
+ [document.getElementById("ending-x"), toX],
1913
+ [document.getElementById("ending-linkedin"), toLinkedIn],
1891
1914
  ]) {
1892
1915
  el.addEventListener("click", async (e) => {
1893
1916
  e.preventDefault();
package/dist/story.js CHANGED
@@ -14,7 +14,7 @@ export const starred = (word) => word[0] + "*".repeat(word.length - 2) + word.at
14
14
  // A count this small isn't a habit yet.
15
15
  const HABIT = 20;
16
16
  // `chapterNames` come from `nameChapters`; without them a chapter is named by its top words.
17
- export function storyData(w, personality, letter, chapterNames = w.chapters.map((c) => plainName(c.words)), span = "year") {
17
+ export function storyData(w, personality, letter, chapterNames = w.chapters.map((c) => plainName(c.words)), span = "year", name = null) {
18
18
  const family = w.voice.typos.find((f) => f.spellings.length >= 5) ?? null;
19
19
  const streak = w.rhythm.longestStreak;
20
20
  const nickname = w.voice.nicknames[0] && w.voice.nicknames[0].count >= HABIT ? w.voice.nicknames[0] : null;
@@ -33,7 +33,7 @@ export function storyData(w, personality, letter, chapterNames = w.chapters.map(
33
33
  topPrompts: w.voice.topPrompts.slice(0, 4),
34
34
  catchphrase: pickCatchphrase(w.voice.catchphrases),
35
35
  night: w.rhythm.lateNight.latest && w.rhythm.lateNight.prompts >= 5
36
- ? { latest: w.rhythm.lateNight.latest, prompts: w.rhythm.lateNight.prompts }
36
+ ? { latest: w.rhythm.lateNight.latest, prompts: w.rhythm.lateNight.prompts, day: w.rhythm.lateNight.latestDay ?? undefined }
37
37
  : null,
38
38
  streak: streak && streak.days >= 5 ? streak : null,
39
39
  agents: w.totals.prompts
@@ -62,5 +62,6 @@ export function storyData(w, personality, letter, chapterNames = w.chapters.map(
62
62
  crashouts: w.voice.crashouts.count >= CRASHOUTS
63
63
  ? { ...w.voice.crashouts, word: w.voice.crashouts.word && starred(w.voice.crashouts.word) }
64
64
  : null,
65
+ name,
65
66
  };
66
67
  }
package/dist/types.js CHANGED
@@ -21,9 +21,10 @@ export function commandKinds(command) {
21
21
  export function emptyHarvest() {
22
22
  return { prompts: [], usage: [], totals: [], turns: [], actions: [], coverage: [], privateNames: new Set() };
23
23
  }
24
- // Only what happened from `since` on. What each source covered is kept as read.
25
- export function harvestSince(h, since) {
26
- const recent = (list) => list.filter((x) => x.at >= since);
24
+ // Only what happened from `since` on, and before `before` when there is one.
25
+ // What each source covered is kept as read.
26
+ export function harvestSince(h, since, before) {
27
+ const recent = (list) => list.filter((x) => x.at >= since && (!before || x.at < before));
27
28
  return {
28
29
  ...h,
29
30
  prompts: recent(h.prompts),
@@ -33,6 +34,11 @@ export function harvestSince(h, since) {
33
34
  actions: recent(h.actions),
34
35
  };
35
36
  }
37
+ // The year a story made on `today` covers: this one, or in January the one
38
+ // that just ended, so a story made on New Year's Day is still last year's.
39
+ export function storyYear(today) {
40
+ return today.getMonth() === 0 ? today.getFullYear() - 1 : today.getFullYear();
41
+ }
36
42
  export function mergeHarvests(parts) {
37
43
  const out = emptyHarvest();
38
44
  for (const p of parts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shadevkumar/agent-wrapped",
3
- "version": "0.4.1",
3
+ "version": "0.5.2",
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",