@shadevkumar/agent-wrapped 0.2.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/README.md +10 -4
- package/dist/build.js +21 -4
- package/dist/chapters.js +46 -0
- package/dist/claude-cli.js +27 -0
- package/dist/cli.js +65 -21
- package/dist/letter.js +6 -18
- package/dist/moments.js +83 -6
- package/dist/personality.js +12 -2
- package/dist/read-worker.js +18 -0
- package/dist/screen.js +78 -0
- package/dist/sources/claude.js +4 -4
- package/dist/sources/codex.js +2 -3
- package/dist/sources/cursor.js +81 -0
- package/dist/story/index.html +12 -7
- package/dist/story/link.d.ts +4 -0
- package/dist/story/link.js +53 -0
- package/dist/story/story.js +372 -81
- package/dist/story.js +15 -3
- package/dist/types.js +25 -9
- package/dist/words.js +23 -1
- package/package.json +1 -1
|
@@ -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
|
+
}
|
package/dist/story/index.html
CHANGED
|
@@ -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
|
|
|
@@ -161,10 +165,9 @@ a.button[hidden] { display: none; }
|
|
|
161
165
|
/* Home: the keys type moments from Shadev's story; everything else stays quiet. */
|
|
162
166
|
#home {
|
|
163
167
|
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
168
|
}
|
|
166
|
-
#home
|
|
167
|
-
|
|
169
|
+
html.home #home[hidden] { display: grid !important; }
|
|
170
|
+
html.home:not(.fonts-in) #home { visibility: hidden; }
|
|
168
171
|
#home > div { max-width: 780px; }
|
|
169
172
|
.typing {
|
|
170
173
|
--k: min(62px, calc((100vw - 32px - 9 * 8px) / 9.2));
|
|
@@ -215,10 +218,11 @@ a.button[hidden] { display: none; }
|
|
|
215
218
|
.github:hover { color: var(--ink); }
|
|
216
219
|
.github:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
|
|
217
220
|
.github svg { width: 22px; height: 22px; fill: currentColor; }
|
|
218
|
-
@media (prefers-reduced-motion: reduce) { .typing-note { opacity: 1; }
|
|
221
|
+
@media (prefers-reduced-motion: reduce) { .typing-note { opacity: 1; } }
|
|
219
222
|
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
220
223
|
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
|
|
221
224
|
</style>
|
|
225
|
+
<!--HOME-->
|
|
222
226
|
</head>
|
|
223
227
|
<body>
|
|
224
228
|
<main class="player" id="player">
|
|
@@ -226,6 +230,7 @@ a.button[hidden] { display: none; }
|
|
|
226
230
|
<canvas id="stage" width="1080" height="1920" aria-hidden="true"></canvas>
|
|
227
231
|
<div class="bars" id="bars"></div>
|
|
228
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>
|
|
229
234
|
<button id="sound" aria-pressed="true">Sound on</button>
|
|
230
235
|
<button id="save-now">Save this card</button>
|
|
231
236
|
<button id="skip">Skip to sharing</button>
|
|
@@ -233,7 +238,7 @@ a.button[hidden] { display: none; }
|
|
|
233
238
|
<div class="start" id="start">
|
|
234
239
|
<div>
|
|
235
240
|
<button class="primary" id="play">Play my story</button>
|
|
236
|
-
<p id="start-note">Sound on for the full effect. Tap the right side to go on, the left to go back.
|
|
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>
|
|
237
242
|
</div>
|
|
238
243
|
</div>
|
|
239
244
|
</div>
|
|
@@ -269,7 +274,7 @@ a.button[hidden] { display: none; }
|
|
|
269
274
|
<section class="ending" id="ending" aria-labelledby="ending-title" hidden>
|
|
270
275
|
<div>
|
|
271
276
|
<h1 id="ending-title" tabindex="-1">Make your own</h1>
|
|
272
|
-
<p class="lede">Run this in your terminal. It reads your Claude Code and
|
|
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>
|
|
273
278
|
<div class="command">
|
|
274
279
|
<code>npx @shadevkumar/agent-wrapped</code>
|
|
275
280
|
<button class="primary" data-copy-command>Copy</button>
|
|
@@ -292,7 +297,7 @@ a.button[hidden] { display: none; }
|
|
|
292
297
|
<div class="typing" id="home-keys" aria-hidden="true"></div>
|
|
293
298
|
<p class="typing-note" id="home-note" aria-hidden="true"></p>
|
|
294
299
|
<h1 id="home-title"><span>Agent Wrapped 2026</span></h1>
|
|
295
|
-
<p class="lede">Your year with Claude Code and
|
|
300
|
+
<p class="lede">Your year with Claude Code, Codex and Cursor, played back in keyboard keys.</p>
|
|
296
301
|
<div class="command">
|
|
297
302
|
<code>npx @shadevkumar/agent-wrapped</code>
|
|
298
303
|
<button class="primary" data-copy-command>Copy</button>
|
|
@@ -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
|
+
}
|