@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/story.js CHANGED
@@ -1,18 +1,30 @@
1
+ import { plainName } from "./chapters.js";
1
2
  // Phrases everyone types; a catchphrase should sound like this person.
2
3
  const PLAIN_OPENINGS = /^(let me|tell me|can you|could you|what we|then we|i want|i need|do you|is there|we have|we need)\b/;
3
4
  export function pickCatchphrase(list) {
4
5
  return list.find((c) => !PLAIN_OPENINGS.test(c.text)) ?? null;
5
6
  }
6
- export function storyData(w, personality, letter) {
7
+ const SPELLINGS_SHOWN = 16;
8
+ // Pushes, pull requests and deploys together, before they make a card.
9
+ const SHIPPED = 5;
10
+ // A count this small isn't a habit yet.
11
+ const HABIT = 20;
12
+ // `chapterNames` come from `nameChapters`; without them a chapter is named by its top words.
13
+ export function storyData(w, personality, letter, chapterNames = w.chapters.map((c) => plainName(c.words)), span = "year") {
7
14
  const family = w.voice.typos.find((f) => f.spellings.length >= 5) ?? null;
8
15
  const streak = w.rhythm.longestStreak;
16
+ const nickname = w.voice.nicknames[0] && w.voice.nicknames[0].count >= HABIT ? w.voice.nicknames[0] : null;
17
+ const please = w.voice.lexicon.please ?? 0;
18
+ const thanks = w.voice.lexicon.thanks ?? 0;
19
+ const wk = w.work;
9
20
  return {
10
21
  range: w.totals.firstDay && w.totals.lastDay ? { from: w.totals.firstDay, to: w.totals.lastDay } : null,
11
22
  prompts: w.totals.prompts,
12
23
  activeDays: w.totals.activeDays,
13
24
  sessions: w.totals.sessions,
14
25
  topTypo: w.voice.topTypo && w.voice.topTypo.count >= 10 ? w.voice.topTypo : null,
15
- spellings: family ? { word: family.word, spellings: family.spellings.map((s) => s.spelling) } : null,
26
+ // The card flashes the most common few; more would only make links longer.
27
+ spellings: family ? { word: family.word, spellings: family.spellings.slice(0, SPELLINGS_SHOWN).map((s) => s.spelling), ways: family.spellings.length + 1 } : null,
16
28
  slip: w.voice.keySlips.neighbours[0] && w.voice.keySlips.neighbours[0].count >= 10 ? w.voice.keySlips.neighbours[0] : null,
17
29
  topPrompts: w.voice.topPrompts.slice(0, 4),
18
30
  catchphrase: pickCatchphrase(w.voice.catchphrases),
@@ -24,12 +36,24 @@ export function storyData(w, personality, letter) {
24
36
  ? {
25
37
  claude: w.loyalty.claudeShare,
26
38
  codex: w.loyalty.codexShare,
39
+ cursor: w.loyalty.cursorShare,
27
40
  hours: w.totals.agentHours,
28
41
  bothDays: w.loyalty.bothAgentDays,
29
42
  }
30
43
  : null,
31
- money: w.cost.atLeastUsd >= 1 ? { atLeastUsd: w.cost.atLeastUsd, pricesAsOf: w.cost.pricesAsOf } : null,
44
+ money: w.cost.atLeastUsd >= 1 ? { atLeastUsd: Math.round(w.cost.atLeastUsd), pricesAsOf: w.cost.pricesAsOf } : null,
45
+ talk: nickname || please + thanks >= HABIT || w.voice.checkIns >= HABIT
46
+ ? { nickname, please, thanks, checkIns: w.voice.checkIns }
47
+ : null,
48
+ work: wk.since && wk.tests + wk.commits >= 10
49
+ ? { since: wk.since, tests: wk.tests, commits: wk.commits, stops: wk.stops, languages: wk.languages.slice(0, 2).map((l) => l.name) }
50
+ : null,
51
+ shipped: wk.since && wk.pushes + wk.prs + wk.deploys >= SHIPPED
52
+ ? { since: wk.since, pushes: wk.pushes, prs: wk.prs, deploys: wk.deploys, biggestWeek: wk.biggestWeek && wk.biggestWeek.commits >= 5 ? wk.biggestWeek : null }
53
+ : null,
54
+ chapters: w.chapters.length >= 3 ? w.chapters.map((c, i) => ({ from: c.from, to: c.to, name: chapterNames[i] })) : null,
32
55
  personality,
33
56
  letter,
57
+ period: span,
34
58
  };
35
59
  }
package/dist/types.js CHANGED
@@ -1,11 +1,37 @@
1
1
  // Everything read from disk lands in a Harvest. A Harvest is private: it holds
2
2
  // raw prompt text and never leaves the process. Only `share.ts` output is safe
3
3
  // to show or export.
4
+ export const AGENTS = ["claude", "codex", "cursor"];
4
5
  export function usageTokens(u) {
5
6
  return u.input + u.cacheRead + u.cacheWrite + u.cacheWrite1h + u.output;
6
7
  }
8
+ // Commands that run a project's tests, make a commit, push it, open a pull
9
+ // request, or put the work out: a deploy or a published package.
10
+ const COMMANDS = {
11
+ test: /\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/,
12
+ commit: /\bgit commit\b/,
13
+ push: /\bgit push\b/,
14
+ pr: /\b(gh pr create|glab mr create)\b/,
15
+ deploy: /\b((npm|pnpm|yarn) publish|vercel (deploy )?--prod|netlify deploy|fly(ctl)? deploy|firebase deploy|wrangler (deploy|publish)|railway up|gcloud (run|app|functions) deploy|eas (submit|update)|cdk deploy|serverless deploy)\b/,
16
+ };
17
+ // Everything one command did: "git commit -m x && git push" is both.
18
+ export function commandKinds(command) {
19
+ return Object.keys(COMMANDS).filter((kind) => COMMANDS[kind].test(command));
20
+ }
7
21
  export function emptyHarvest() {
8
- return { prompts: [], usage: [], totals: [], turns: [], coverage: [], privateNames: new Set() };
22
+ return { prompts: [], usage: [], totals: [], turns: [], actions: [], coverage: [], privateNames: new Set() };
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);
27
+ return {
28
+ ...h,
29
+ prompts: recent(h.prompts),
30
+ usage: recent(h.usage),
31
+ totals: recent(h.totals),
32
+ turns: recent(h.turns),
33
+ actions: recent(h.actions),
34
+ };
9
35
  }
10
36
  export function mergeHarvests(parts) {
11
37
  const out = emptyHarvest();
@@ -14,6 +40,7 @@ export function mergeHarvests(parts) {
14
40
  out.usage.push(...p.usage);
15
41
  out.totals.push(...p.totals);
16
42
  out.turns.push(...p.turns);
43
+ out.actions.push(...p.actions);
17
44
  out.coverage.push(...p.coverage);
18
45
  for (const n of p.privateNames)
19
46
  out.privateNames.add(n);
package/dist/words.js CHANGED
@@ -16,12 +16,15 @@ const MODERN = new Set(("okay ok hey yeah yep nope bro dude lol lmao pls plz thx
16
16
  const STOPWORDS = new Set("a an the to of in on at for and or is are was be it this that i you we me my your with as do so if".split(" "));
17
17
  export class Words {
18
18
  dict;
19
+ people;
19
20
  blocked;
20
21
  // `names` are private names (folders, repos, orgs) that never appear in a
21
22
  // quote. A name is always blocked; its parts ("acme" in "acme-portal") are
22
23
  // blocked unless they are everyday words ("the" in "bridge-the-gap").
23
- constructor(names, dict) {
24
+ // `people` are words the dictionary also lists as a name ("Mary", "Jack").
25
+ constructor(names, dict, people) {
24
26
  this.dict = dict ?? loadDictionary(SYSTEM_DICTIONARY);
27
+ this.people = people ?? (dict ? new Set() : loadNames(SYSTEM_DICTIONARY));
25
28
  this.blocked = new Set();
26
29
  for (const name of names) {
27
30
  const lower = name.toLowerCase();
@@ -65,6 +68,14 @@ export class Words {
65
68
  isStopword(word) {
66
69
  return STOPWORDS.has(word);
67
70
  }
71
+ // A word safe to name a theme of the year with: an everyday word that is no
72
+ // private name and could not be a person's name either. Stricter than a
73
+ // quote, since it says what someone worked on; it may drop a word like "jack".
74
+ isTopicWord(word) {
75
+ if (!this.isKnown(word) || this.isBlocked(word) || this.people.has(word))
76
+ return false;
77
+ return !baseForms(word).some((base) => this.people.has(base));
78
+ }
68
79
  }
69
80
  export function loadDictionary(path) {
70
81
  if (!existsSync(path))
@@ -77,6 +88,17 @@ export function loadDictionary(path) {
77
88
  }
78
89
  return words;
79
90
  }
91
+ // The dictionary's capitalized entries (names of people and places), lowercased.
92
+ export function loadNames(path) {
93
+ if (!existsSync(path))
94
+ return new Set();
95
+ const names = new Set();
96
+ for (const line of readFileSync(path, "utf8").split("\n")) {
97
+ if (line && line !== line.toLowerCase())
98
+ names.add(line.toLowerCase());
99
+ }
100
+ return names;
101
+ }
80
102
  // Lowercase words, after removing code, links, paths and addresses.
81
103
  export function tokenize(text) {
82
104
  const plain = text
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shadevkumar/agent-wrapped",
3
- "version": "0.1.0",
3
+ "version": "0.3.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",