chompyy 0.5.0 → 0.7.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.
Files changed (162) hide show
  1. package/README.md +14 -1
  2. package/dist/advice.js +98 -1
  3. package/dist/agentlimits.js +77 -0
  4. package/dist/agentusage.js +96 -0
  5. package/dist/approvals.js +129 -0
  6. package/dist/appstate.js +73 -3
  7. package/dist/away.js +48 -5
  8. package/dist/blueprint.js +3 -7
  9. package/dist/board.js +1 -0
  10. package/dist/cli.js +343 -18
  11. package/dist/codexquota.js +106 -0
  12. package/dist/codexusage.js +10 -0
  13. package/dist/config.js +2 -0
  14. package/dist/context.js +30 -0
  15. package/dist/costs.js +41 -2
  16. package/dist/demon.js +20 -0
  17. package/dist/detect.js +38 -6
  18. package/dist/didwork.js +26 -0
  19. package/dist/label.js +33 -0
  20. package/dist/menu.js +17 -0
  21. package/dist/nightcap.js +72 -0
  22. package/dist/nudge.js +70 -24
  23. package/dist/pacing.js +16 -1
  24. package/dist/punchcard.js +39 -0
  25. package/dist/questions.js +71 -0
  26. package/dist/recap.js +74 -0
  27. package/dist/receipt.js +48 -0
  28. package/dist/recipe.js +79 -0
  29. package/dist/savings.js +111 -0
  30. package/dist/stamps.js +14 -0
  31. package/dist/suggest.js +15 -5
  32. package/dist/triggers.js +5 -0
  33. package/dist/usage.js +21 -1
  34. package/dist/vendor/codeburn/antigravity.js +309 -0
  35. package/dist/vendor/codeburn/codex.js +429 -0
  36. package/dist/vendor/codeburn/copilot.js +292 -0
  37. package/dist/vendor/codeburn/gemini.js +195 -0
  38. package/dist/vendor/codeburn/grokbot.js +182 -0
  39. package/dist/vendor/codeburn/kimi.js +178 -0
  40. package/dist/vendor/codeburn/shims/chalk.js +14 -0
  41. package/dist/vendor/codeburn/shims/strip-ansi.js +6 -0
  42. package/dist/vendor/codeburn/src/act/backup.js +83 -0
  43. package/dist/vendor/codeburn/src/act/model-defaults.js +151 -0
  44. package/dist/vendor/codeburn/src/act/types.js +37 -0
  45. package/dist/vendor/codeburn/src/bash-utils.js +204 -0
  46. package/dist/vendor/codeburn/src/behavioral-weight.js +47 -0
  47. package/dist/vendor/codeburn/src/cache-dir.js +26 -0
  48. package/dist/vendor/codeburn/src/cache-refresh-lock.js +543 -0
  49. package/dist/vendor/codeburn/src/cache-sweep.js +67 -0
  50. package/dist/vendor/codeburn/src/classifier.js +209 -0
  51. package/dist/vendor/codeburn/src/claude-identity.js +223 -0
  52. package/dist/vendor/codeburn/src/codex-cache.js +377 -0
  53. package/dist/vendor/codeburn/src/codex-fork-replay.js +232 -0
  54. package/dist/vendor/codeburn/src/codex-jsonl-fields.js +99 -0
  55. package/dist/vendor/codeburn/src/codex-session-index.js +113 -0
  56. package/dist/vendor/codeburn/src/codex-throughput.js +544 -0
  57. package/dist/vendor/codeburn/src/compare-stats.js +405 -0
  58. package/dist/vendor/codeburn/src/config.js +145 -0
  59. package/dist/vendor/codeburn/src/content-utils.js +56 -0
  60. package/dist/vendor/codeburn/src/context-tree-codex.js +329 -0
  61. package/dist/vendor/codeburn/src/context-tree.js +664 -0
  62. package/dist/vendor/codeburn/src/copilot-aiu.js +16 -0
  63. package/dist/vendor/codeburn/src/currency.js +189 -0
  64. package/dist/vendor/codeburn/src/cursor-cache.js +238 -0
  65. package/dist/vendor/codeburn/src/cursor-import.js +402 -0
  66. package/dist/vendor/codeburn/src/cursor-sync.js +256 -0
  67. package/dist/vendor/codeburn/src/daily-cache.js +2036 -0
  68. package/dist/vendor/codeburn/src/data/litellm-snapshot.json +1 -0
  69. package/dist/vendor/codeburn/src/data/pricing-fallback.json +1 -0
  70. package/dist/vendor/codeburn/src/day-aggregator.js +327 -0
  71. package/dist/vendor/codeburn/src/editor-data-dir.js +11 -0
  72. package/dist/vendor/codeburn/src/fetch-utils.js +18 -0
  73. package/dist/vendor/codeburn/src/format.js +118 -0
  74. package/dist/vendor/codeburn/src/fs-utils.js +270 -0
  75. package/dist/vendor/codeburn/src/git-origin.js +334 -0
  76. package/dist/vendor/codeburn/src/granular-history.js +328 -0
  77. package/dist/vendor/codeburn/src/hermes-session-ledger.js +512 -0
  78. package/dist/vendor/codeburn/src/launcher-homes.js +142 -0
  79. package/dist/vendor/codeburn/src/live-sessions.js +358 -0
  80. package/dist/vendor/codeburn/src/math-utils.js +8 -0
  81. package/dist/vendor/codeburn/src/menubar-json.js +294 -0
  82. package/dist/vendor/codeburn/src/models.js +1879 -0
  83. package/dist/vendor/codeburn/src/optimize-one-hour-cache.js +92 -0
  84. package/dist/vendor/codeburn/src/optimize.js +4110 -0
  85. package/dist/vendor/codeburn/src/parse-workers.js +219 -0
  86. package/dist/vendor/codeburn/src/parser.js +6955 -0
  87. package/dist/vendor/codeburn/src/path-privacy.js +26 -0
  88. package/dist/vendor/codeburn/src/plans.js +135 -0
  89. package/dist/vendor/codeburn/src/pr-signals.js +132 -0
  90. package/dist/vendor/codeburn/src/project-filter-warnings.js +33 -0
  91. package/dist/vendor/codeburn/src/provider-issues.js +30 -0
  92. package/dist/vendor/codeburn/src/providers/amp.js +286 -0
  93. package/dist/vendor/codeburn/src/providers/antigravity.js +1731 -0
  94. package/dist/vendor/codeburn/src/providers/claude.js +551 -0
  95. package/dist/vendor/codeburn/src/providers/cline-cli.js +401 -0
  96. package/dist/vendor/codeburn/src/providers/cline.js +63 -0
  97. package/dist/vendor/codeburn/src/providers/codebuff.js +336 -0
  98. package/dist/vendor/codeburn/src/providers/codewhale.js +442 -0
  99. package/dist/vendor/codeburn/src/providers/codex.js +1720 -0
  100. package/dist/vendor/codeburn/src/providers/command-code.js +196 -0
  101. package/dist/vendor/codeburn/src/providers/copilot.js +3278 -0
  102. package/dist/vendor/codeburn/src/providers/crush.js +226 -0
  103. package/dist/vendor/codeburn/src/providers/cursor-agent.js +837 -0
  104. package/dist/vendor/codeburn/src/providers/cursor.js +1163 -0
  105. package/dist/vendor/codeburn/src/providers/devin.js +569 -0
  106. package/dist/vendor/codeburn/src/providers/droid.js +324 -0
  107. package/dist/vendor/codeburn/src/providers/dsh.js +690 -0
  108. package/dist/vendor/codeburn/src/providers/forge.js +245 -0
  109. package/dist/vendor/codeburn/src/providers/gemini.js +230 -0
  110. package/dist/vendor/codeburn/src/providers/goose.js +252 -0
  111. package/dist/vendor/codeburn/src/providers/grok.js +581 -0
  112. package/dist/vendor/codeburn/src/providers/grokbot.js +290 -0
  113. package/dist/vendor/codeburn/src/providers/hermes.js +771 -0
  114. package/dist/vendor/codeburn/src/providers/ibm-bob.js +53 -0
  115. package/dist/vendor/codeburn/src/providers/index.js +360 -0
  116. package/dist/vendor/codeburn/src/providers/kilo-code.js +50 -0
  117. package/dist/vendor/codeburn/src/providers/kimi.js +363 -0
  118. package/dist/vendor/codeburn/src/providers/kimicode.js +402 -0
  119. package/dist/vendor/codeburn/src/providers/kiro.js +1174 -0
  120. package/dist/vendor/codeburn/src/providers/lingtai-tui.js +372 -0
  121. package/dist/vendor/codeburn/src/providers/mistral-vibe-unified.js +236 -0
  122. package/dist/vendor/codeburn/src/providers/mistral-vibe.js +405 -0
  123. package/dist/vendor/codeburn/src/providers/mux.js +242 -0
  124. package/dist/vendor/codeburn/src/providers/open-design.js +217 -0
  125. package/dist/vendor/codeburn/src/providers/openclaude.js +309 -0
  126. package/dist/vendor/codeburn/src/providers/openclaw.js +442 -0
  127. package/dist/vendor/codeburn/src/providers/opencode-file-parser.js +131 -0
  128. package/dist/vendor/codeburn/src/providers/opencode.js +91 -0
  129. package/dist/vendor/codeburn/src/providers/pi.js +429 -0
  130. package/dist/vendor/codeburn/src/providers/quickdesk.js +491 -0
  131. package/dist/vendor/codeburn/src/providers/qwen.js +193 -0
  132. package/dist/vendor/codeburn/src/providers/session-message.js +118 -0
  133. package/dist/vendor/codeburn/src/providers/sqlite-session-parser.js +457 -0
  134. package/dist/vendor/codeburn/src/providers/types.js +5 -0
  135. package/dist/vendor/codeburn/src/providers/vercel-gateway.js +135 -0
  136. package/dist/vendor/codeburn/src/providers/vscode-cline-parser.js +212 -0
  137. package/dist/vendor/codeburn/src/providers/warp.js +575 -0
  138. package/dist/vendor/codeburn/src/providers/zcode.js +249 -0
  139. package/dist/vendor/codeburn/src/providers/zed.js +187 -0
  140. package/dist/vendor/codeburn/src/providers/zerostack.js +139 -0
  141. package/dist/vendor/codeburn/src/quota/antigravity.js +310 -0
  142. package/dist/vendor/codeburn/src/quota/claude.js +244 -0
  143. package/dist/vendor/codeburn/src/quota/cursor.js +301 -0
  144. package/dist/vendor/codeburn/src/quota/security.js +299 -0
  145. package/dist/vendor/codeburn/src/quota/types.js +1 -0
  146. package/dist/vendor/codeburn/src/scan-facts.js +99 -0
  147. package/dist/vendor/codeburn/src/session-cache.js +3040 -0
  148. package/dist/vendor/codeburn/src/session-count-label.js +14 -0
  149. package/dist/vendor/codeburn/src/session-output.js +139 -0
  150. package/dist/vendor/codeburn/src/session-population.js +30 -0
  151. package/dist/vendor/codeburn/src/sessions-report.js +1342 -0
  152. package/dist/vendor/codeburn/src/sqlite.js +528 -0
  153. package/dist/vendor/codeburn/src/sync/otlp.js +420 -0
  154. package/dist/vendor/codeburn/src/telemetry-snapshot.js +244 -0
  155. package/dist/vendor/codeburn/src/token-estimate.js +5 -0
  156. package/dist/vendor/codeburn/src/types.js +16 -0
  157. package/dist/vendor/codeburn/src/work-units.js +126 -0
  158. package/dist/vendor/codeburn/src/workflow-insights.js +228 -0
  159. package/dist/vendor/codeburn/src/wsl.js +198 -0
  160. package/dist/vendor/codeburn/src/yield.js +666 -0
  161. package/dist/wastechecks.js +233 -0
  162. package/package.json +1 -1
package/README.md CHANGED
@@ -123,6 +123,7 @@ Each card in a git repo runs in its own worktree at `~/.chompyy/worktrees/<id>`
123
123
  | `chompyy away <1h\|30m\|1h30m> [--dry-run] [--force]` | Run approved cards until the time is up or the gate closes |
124
124
  | `chompyy report [--all]` | Cards that ran since the last report: one action each, cards needing you first. No paths or raw agent text; ask for those with `show` |
125
125
  | `chompyy diff <id>` | The change the card made on its branch |
126
+ | `chompyy recipe <id>` | A kept card as a recipe: the files it changed, the steps it took, when it landed (`--json` for the app) |
126
127
  | `chompyy keep <id>` | Merge the card's branch into your current branch and remove its worktree. Refuses when you have unsaved changes in a file the card also changed, or anything staged; other unsaved work is left alone |
127
128
  | `chompyy undo <id> [--plan] [--json]` | Throw the run away: remove its worktree and branch (or draft folder). Your own branches are never touched. On a kept card it takes the card back: off your branch when it's only on this Mac (closing its PR if one is open), or with a revert PR on GitHub once its PR merged. `--plan` says which and changes nothing |
128
129
  | `chompyy redo <id>` | Throw a ran card's result away and put it back in *approved*; it runs again from your latest code |
@@ -142,13 +143,25 @@ Each card in a git repo runs in its own worktree at `~/.chompyy/worktrees/<id>`
142
143
  | `chompyy trends` | Last 7 days vs the 7 before: cost per card, keep rate, rating, blueprint edits; then what Chompyy learned: rules this week, waiting, corrections per conversation |
143
144
  | `chompyy premise [--json]` | How often a 5-hour window reset with 20%+ left in a week that still had 10%+ spare: the capacity away runs can use. From your quota readings; every ended window is kept in `windows.jsonl` (numbers only), so it grows past the 8 days of `quota-history.json`. `--json` to share it |
144
145
  | `chompyy detect [--days 30] [--all] [--json]` | The detective: what wastes tokens in your setup and habits, from your own files. One screen: the findings ranked by tokens and the fix to start with; `--all` adds each finding's count, measured or estimated, what it doesn't prove, and every fix. A mid-session cache rebuild names its cause (e.g. Tool Search loading an MCP server's tools). Works cold with `npx chompyy detect`, nothing else installed. This version checks startup tax (long CLAUDE.md, unused skills and MCP servers, cut-off MEMORY.md) and cache (cold returns, mid-session rebuilds). Reads only; changes nothing |
145
- | `chompyy advise [--json]` | The detective, step 3: turns detect's findings into suggested cards on the board (the app's "Find savings"). Each card's plan shows what Chompyy saw, what it doesn't prove, the exact change and how it will check it worked. Approve a settings card (e.g. turn off a plugin you never use) and Chompyy applies it once no Claude Code session has been active for 10 minutes, backed up first; `chompyy undo <id>` puts it back if nothing changed it since. Habit cards are tracked from the day you approve; some things only you can do (claude.ai-synced skills). Dropped advice never comes back. Advice never runs on an away run |
146
+ | `chompyy advise [--json]` | The detective, step 3: turns detect's findings into suggested cards on the board (the app's Savings window: "Find savings again"; `chompyy advise fix` is its "Fix for me"). Each card's plan shows what Chompyy saw, what it doesn't prove, the exact change and how it will check it worked. Approve a settings card (e.g. turn off a plugin you never use) and Chompyy applies it once no Claude Code session has been active for 10 minutes, backed up first; `chompyy undo <id>` puts it back if nothing changed it since. Habit cards are tracked from the day you approve; some things only you can do (claude.ai-synced skills). Dropped advice never comes back. Advice never runs on an away run |
146
147
  | `chompyy advise apply` | Apply approved settings advice now if no session has been active for 10 minutes (the app and the 5-minute tick do this on their own) |
147
148
  | `chompyy worked [--all] [--json] [--share]` | Did the advice work: each applied card against the check it set up, plus the nudge's measured result, and one "Saved so far" total (also in the menu panel) that adds only what was counted. `--share` prints a summary with no project, skill or file names |
148
149
  | `chompyy nudge on\|off` | Live suggestions while you work. Adds a UserPromptSubmit hook to `~/.claude/settings.json` (backed up first; your other hooks stay). When you come back to a conversation of 40k+ tokens after more than an hour, its cache has expired: the hook stops that first message once and says what sending it rebuilds, what a fresh start costs, and the cheaper ways (/clear with a note, or /compact). Send it again and it goes through. A conversation compacted since its last reply (your /compact, or Claude Code's own while you were away) sends a summary, so it isn't stopped. Needs a global install (`npm install -g chompyy`); away runs turn hooks off, so it never touches them |
149
150
  | `chompyy nudge [--json]` | On or off, what the stops and warnings led to (compacted, left, sent anyway), the tokens not written again, and the measured trend: cold returns this week against last week. The menu panel shows the same line |
150
151
  | `chompyy nudge due [--json]` | Conversations 45-60 minutes into a pause, about to go cold, each reported once (only while nudge is on). The menu bar app asks every minute and sends a notification, while /compact is still cheap. Skips conversations already compacted |
151
152
  | `chompyy triggers on\|off` | Install or remove the macOS LaunchAgent that runs `chompyy tick` every 5 minutes |
153
+ | `chompyy limits [<agent> on\|off] [--json]` | Limits for Gemini CLI, GitHub Copilot, Antigravity, Kimi Code and Grok Bot through codeburn's readers. Each is off until you allow it, since it uses that agent's own login (read-only, never rewritten) |
154
+ | `chompyy recap [--month 2026-11] [--json]` | Your month with Chompyy on one card: tokens, API value and cookies, busiest day, conversations, cards baked and kept, biggest bake. This month once it's a week old, else last month. No names, safe to share |
155
+ | `chompyy menu [--json]` | Every coding agent you used in the last 30 days as a café chalkboard: Claude Code and the others, tokens and API value, most first. Agent and model names only, safe to share |
156
+ | `chompyy label [--json]` | Your week of Claude Code as a Nutrition Facts label: cached reads (fibre), cache writes (carbs), tokens resent after a break (added sugar), input and output (protein). Amounts only, safe to share |
157
+ | `chompyy approvals [--json]` | Which of Chompyy's suggestions you approve, by kind (repo tasks, chores, tests, docs, …), from what you approved, dropped or let expire. New suggestions are ranked by it and the suggester is told what you tend to want |
158
+ | `chompyy savings [--json]` | Where your tokens went this week (cheap cached reads vs the slice worth fixing), every waste ranked with its status (to fix, measuring, worked) and before → after, and your biggest cold return step by step. The app's Savings window draws it |
159
+ | `chompyy stamps [--json]` | Your loyalty stamp card: one stamp per card you kept, ten to a card, with the dates. No titles, safe to share |
160
+ | `chompyy agents [--json] [--refresh]` | Every other coding agent codeburn reads (Cursor, Copilot, Gemini CLI, OpenCode, … about 40): tokens and API value today, this week and over 30 and 90 days (agents used in the last 90 days), at most one scan per 10 minutes |
161
+ | `chompyy codex [on\|off] [--json]` | Codex beside Claude: its 5-hour and weekly limits (reads Codex's saved login to ask OpenAI; never renews or changes it) and its tokens and API value (codeburn's Codex parser) |
162
+ | `chompyy nightcap [on [23:30]\|skip\|unskip]` | The evening offer: run approved cards at bedtime tonight (`on` sets bedtime and turns triggers on), or skip tonight |
163
+ | `chompyy demon [on\|off]` | Demon mode: in the last 90 minutes of a window that would reset 20%+ unused, run approved cards to eat it (`on` = every window, via the last-hour trigger) |
164
+ | `chompyy receipt [--json]` | Your week as a bake-sale receipt: cards baked and their API value, kept, burnt (undone), tokens, resent less than last week. No names, safe to share |
152
165
  | `chompyy bedtime <23:30\|off>` / `chompyy last-hour <on\|off>` / `chompyy missed-reset <on\|off>` | Turn the bedtime, last-hour-before-reset and missed-reset (first tick after an unused reset, default off) triggers on or off |
153
166
  | `chompyy quota [--refresh] [--allow-keychain\|--no-keychain]` | Read the live quota now and show `status`. The keychain flags allow or stop reading your Claude sign-in from the macOS keychain |
154
167
  | `chompyy usage [--period today\|7d\|30d\|month] [--days 7] [--json]` | Tokens and cost by day, project and kind of work, pull request costs, and how your plan compares with API prices |
package/dist/advice.js CHANGED
@@ -28,6 +28,63 @@ function plan(f, a, what) {
28
28
  `**Check:** ${a.check}`,
29
29
  ].filter(Boolean).join('\n\n');
30
30
  }
31
+ /** Most new-check cards one advise run makes, and the least tokens a week worth a card. */
32
+ export const NEW_CHECK_CARDS = 3;
33
+ export const NEW_CHECK_MIN_WEEK = 10_000;
34
+ /** codeburn reports that point at sessions or correlations, with no step to take: listed, never a card. */
35
+ const NO_CARD = new Set(['retry-heavy-capabilities', 'low-worth-sessions', 'cost-outliers']);
36
+ /**
37
+ * codeburn checks Chompyy can fix itself, as a Claude Code setting with a backup and Undo (settings lane): no
38
+ * shell-profile edits. These always get a card (not capped), since one approval does the whole fix.
39
+ */
40
+ export const AUTO_FIX = {
41
+ 'bash-output-cap': (settings) => ({
42
+ changes: [{ file: settings, key: ['env', 'BASH_MAX_OUTPUT_LENGTH'], from: settingAt(settings, ['env', 'BASH_MAX_OUTPUT_LENGTH']), to: '15000' }],
43
+ doing: 'Cap shell output at 15,000 characters in new sessions (Claude Code setting). Undo puts it back',
44
+ }),
45
+ };
46
+ function settingAt(file, key) {
47
+ try {
48
+ return getAt(JSON.parse(readFileSync(file, 'utf8')), key);
49
+ }
50
+ catch {
51
+ return undefined;
52
+ }
53
+ }
54
+ /** Tokens a week, from a total over `days` days. */
55
+ export const perWeek = (tokens, days) => Math.round((tokens / Math.max(1, days)) * 7);
56
+ /**
57
+ * A card for one of codeburn's checks or our newer rules: what it found, the exact fix to do (a command, a line for
58
+ * CLAUDE.md, or a habit), and the check registered before: the same check, per week, a third or less of today.
59
+ * Nothing is changed for you yet: "I've done it" (or trying the habit) starts the clock.
60
+ */
61
+ export function newCheckAdvice(f, days, settings = claudeSettingsPath()) {
62
+ if (!f.tokens)
63
+ return null;
64
+ const week = perWeek(f.tokens, days);
65
+ const habit = f.lane === 'habit';
66
+ const goal = Math.floor(week / 3);
67
+ const a = {
68
+ key: f.key ?? `cb:${f.codeburnId}`,
69
+ rule: f.rule,
70
+ lane: habit ? 'habit' : 'manual',
71
+ basis: f.basis,
72
+ tokens: f.tokens,
73
+ baseline: { tokens: week },
74
+ check: `It worked if this check finds ~${k(goal)} tokens a week or less (now ~${k(week)}).`,
75
+ saw: `${f.basis === 'estimated' ? '~' : ''}${k(week)} tokens a week: ${f.title.charAt(0).toLowerCase()}${f.title.slice(1)}`,
76
+ // codeburn's fix reads "<action>: <detail>"; the action alone is the short step.
77
+ doing: (f.source === 'codeburn' ? f.fix.split(': ')[0] : f.fix.split(/(?<=\.)\s/)[0]).replace(/\.$/, ''),
78
+ checkShort: `~${k(goal)} a week or less (now ~${k(week)})`,
79
+ };
80
+ const auto = f.codeburnId ? AUTO_FIX[f.codeburnId]?.(settings) : undefined;
81
+ if (auto) {
82
+ Object.assign(a, { lane: 'settings', changes: auto.changes, doing: auto.doing });
83
+ return { title: f.title, idea: auto.doing, plan: plan(f, a, settingsWhat(auto.changes)), advice: a };
84
+ }
85
+ const what = habit ? `**Try:** ${f.fix}` : `**Do:** ${f.fix}\n\nThen press "I've done it".`;
86
+ return { title: f.title, idea: f.fix, plan: plan(f, a, what), advice: a };
87
+ }
31
88
  const settingsWhat = (changes) => [
32
89
  '**The change:**',
33
90
  ...changes.map((c) => `- ${describeKey(c)}`),
@@ -39,7 +96,23 @@ export function adviceFrom(r, opts = {}) {
39
96
  const out = [];
40
97
  const settings = opts.settings ?? claudeSettingsPath();
41
98
  const home = homedir();
99
+ // codeburn's checks and our newer ones (own key): cards only for the biggest few with a concrete step, so the
100
+ // board isn't flooded; the rest stay in detect and the Savings window.
101
+ const isNew = (f) => (f.source === 'codeburn' || f.key) && !f.worthKnowing && !!f.tokens;
102
+ const autoFix = r.findings.filter((f) => isNew(f) && f.codeburnId && AUTO_FIX[f.codeburnId]);
103
+ const fresh = r.findings
104
+ .filter((f) => isNew(f) && !autoFix.includes(f) && !NO_CARD.has(f.codeburnId ?? '') && perWeek(f.tokens, r.scanned.days) >= NEW_CHECK_MIN_WEEK)
105
+ .sort((a, b) => b.tokens - a.tokens)
106
+ .slice(0, NEW_CHECK_CARDS);
107
+ for (const f of [...autoFix, ...fresh]) {
108
+ const draft = newCheckAdvice(f, r.scanned.days, settings);
109
+ if (draft)
110
+ out.push({ ...draft, cwd: home });
111
+ }
42
112
  for (const f of r.findings) {
113
+ // codeburn's checks and our newer ones (own key): handled above.
114
+ if (f.source === 'codeburn' || f.key)
115
+ continue;
43
116
  if (f.rule === 'C1') {
44
117
  const w = r.scanned.coldWeek;
45
118
  const a = {
@@ -147,7 +220,8 @@ export function adviceFrom(r, opts = {}) {
147
220
  return out;
148
221
  }
149
222
  /** Keys you dropped (not ones that expired unseen): those never come back. */
150
- function droppedKeys() {
223
+ /** Advice keys you dropped ("no, never"): never suggested again, and the Savings window says you declined them. */
224
+ export function droppedKeys() {
151
225
  const path = homePath('archive.jsonl');
152
226
  const keys = new Set();
153
227
  if (!existsSync(path))
@@ -220,6 +294,29 @@ export function approveAdvice(c, now) {
220
294
  a.state = a.lane === 'habit' ? 'trying' : 'done';
221
295
  return a.lane === 'habit' ? `✅ #${c.id} closed: trying it from today. ${a.check}` : `✅ #${c.id} closed. ${a.check}`;
222
296
  }
297
+ /** Lanes Chompyy carries out itself: a settings change (backed up, Undo) or a sandboxed away run. */
298
+ export const SELF_LANES = new Set(['settings', 'work']);
299
+ /**
300
+ * "Fix these for me": approve every suggested advice card Chompyy can carry out itself. Settings go in once no
301
+ * Claude Code session has run for 10 minutes; work cards run in the next away run (tonight's, with a bedtime).
302
+ * Habits and steps only you can take stay as they are, counted so the window can say so.
303
+ */
304
+ export function fixForMe(board, now) {
305
+ const open = board.cards.filter((c) => c.advice && (c.column === 'suggested' || c.column === 'later'));
306
+ const approved = [];
307
+ for (const c of open) {
308
+ if (!SELF_LANES.has(c.advice.lane))
309
+ continue;
310
+ if (c.advice.lane === 'work') {
311
+ c.column = 'approved';
312
+ c.approvedAt = c.updatedAt = now.toISOString();
313
+ }
314
+ else
315
+ approveAdvice(c, now);
316
+ approved.push(c);
317
+ }
318
+ return { approved, needsYou: open.length - approved.length };
319
+ }
223
320
  /** When a Claude Code session last wrote its transcript (ms), so settings never change under an open conversation. */
224
321
  export function lastSessionActivity(root = projectsDir()) {
225
322
  let last = 0;
@@ -0,0 +1,77 @@
1
+ // Limits for the other agents codeburn can read them for, beside Claude and Codex: Gemini CLI, GitHub Copilot,
2
+ // Antigravity, Kimi Code and Grok Bot, through codeburn's own readers (src/vendor/codeburn/<agent>.ts).
3
+ //
4
+ // Each one is off until you allow it (config agentLimits), because it uses that agent's saved login: Gemini's
5
+ // ~/.gemini/oauth_creds.json, Copilot's ~/.config/github-copilot, Kimi's ~/.kimi-code credentials, the session of
6
+ // the Cursor app Grok Bot uses, or Antigravity's own app running on this Mac. All read-only: none of these readers
7
+ // writes a login back (checked 2026-12-05). Each agent is asked at most every 5 minutes.
8
+ import { existsSync } from 'node:fs';
9
+ import { homedir } from 'node:os';
10
+ import { join } from 'node:path';
11
+ import { fetchAntigravityQuota } from './vendor/codeburn/antigravity.js';
12
+ import { copilotConfigDirs, fetchCopilotQuota } from './vendor/codeburn/copilot.js';
13
+ import { fetchGeminiQuota } from './vendor/codeburn/gemini.js';
14
+ import { fetchGrokbotQuota, grokbotInstalled } from './vendor/codeburn/grokbot.js';
15
+ import { fetchKimiQuota } from './vendor/codeburn/kimi.js';
16
+ import { homePath, readJson, writeJson } from './home.js';
17
+ export const LIMITS_MIN_INTERVAL_MS = 5 * 60_000;
18
+ const home = homedir();
19
+ export const READERS = [
20
+ { name: 'gemini', displayName: 'Gemini CLI', login: "the Gemini CLI's saved Google login", hint: 'Run the Gemini CLI once to sign in, then refresh.', installed: () => existsSync(join(home, '.gemini', 'oauth_creds.json')), fetch: () => fetchGeminiQuota() },
21
+ { name: 'copilot', displayName: 'GitHub Copilot', login: "Copilot's saved GitHub login", hint: 'Sign in to GitHub Copilot in your editor once, then refresh.', installed: () => copilotConfigDirs().some((d) => existsSync(join(d, 'apps.json')) || existsSync(join(d, 'hosts.json'))), fetch: () => fetchCopilotQuota() },
22
+ { name: 'antigravity', displayName: 'Antigravity', login: 'the Antigravity app running on this Mac', hint: 'Open the Antigravity app, then refresh.', installed: () => existsSync('/Applications/Antigravity.app') || existsSync(join(home, '.gemini', 'antigravity')), fetch: async () => ({ quota: await fetchAntigravityQuota() }) },
23
+ { name: 'kimi', displayName: 'Kimi Code', login: "Kimi Code's saved login", hint: 'Sign in to Kimi Code once, then refresh.', installed: () => existsSync(join(process.env.KIMI_CODE_HOME ?? join(home, '.kimi-code'), 'credentials', 'kimi-code.json')), fetch: () => fetchKimiQuota() },
24
+ { name: 'grokbot', displayName: 'Grok Bot', login: 'the Cursor app session Grok Bot uses', hint: 'Sign in to the Cursor app with the account Grok Bot uses, then refresh.', installed: () => grokbotInstalled(), fetch: () => fetchGrokbotQuota() },
25
+ ];
26
+ const filePath = () => homePath('agent-limits.json');
27
+ export const loadLimits = () => readJson(filePath(), {});
28
+ function windowOf(w) {
29
+ return { label: w.label, usedPct: Math.round(w.percent * 1000) / 10, resetsAt: w.resetsAt ? Math.floor(Date.parse(w.resetsAt) / 1000) : null };
30
+ }
31
+ export function limitFrom(q, now, hint = '') {
32
+ return {
33
+ lastTryAt: now.toISOString(),
34
+ connection: q.connection,
35
+ plan: q.planLabel,
36
+ primary: q.primary ? windowOf(q.primary) : null,
37
+ windows: q.details.map(windowOf),
38
+ note: q.connection === 'connected' ? null : q.footerLines.join(' ') || hint || null,
39
+ };
40
+ }
41
+ /** Read the allowed agents' limits (each at most every 5 minutes unless forced) and save them. */
42
+ export async function refreshLimits(allowed, opts = {}) {
43
+ const now = opts.now ?? new Date();
44
+ const saved = loadLimits();
45
+ for (const r of opts.readers ?? READERS) {
46
+ if (!allowed[r.name] || !r.installed())
47
+ continue;
48
+ const last = saved[r.name];
49
+ if (last?.retryAfterAt && Date.parse(last.retryAfterAt) > now.getTime())
50
+ continue;
51
+ if (!opts.force && last && now.getTime() - Date.parse(last.lastTryAt) < LIMITS_MIN_INTERVAL_MS)
52
+ continue;
53
+ try {
54
+ const res = await r.fetch();
55
+ const next = limitFrom(res.quota, now, r.hint);
56
+ if (res.retryAfterSeconds)
57
+ next.retryAfterAt = new Date(now.getTime() + res.retryAfterSeconds * 1000).toISOString();
58
+ saved[r.name] = next;
59
+ }
60
+ catch {
61
+ saved[r.name] = { lastTryAt: now.toISOString(), connection: 'transientFailure', plan: null, primary: null, windows: [], note: `Couldn't read ${r.displayName}'s limits right now.` };
62
+ }
63
+ }
64
+ writeJson(filePath(), saved);
65
+ return saved;
66
+ }
67
+ /** For the app: every agent on this Mac with a limits reader, whether you allowed it, and its last reading. */
68
+ export function limitsState(allowed, readers = READERS) {
69
+ const saved = loadLimits();
70
+ const out = {};
71
+ for (const r of readers) {
72
+ if (!r.installed())
73
+ continue;
74
+ out[r.name] = { displayName: r.displayName, login: r.login, allowed: r.name in allowed ? allowed[r.name] : null, limit: allowed[r.name] ? saved[r.name] ?? null : null };
75
+ }
76
+ return out;
77
+ }
@@ -0,0 +1,96 @@
1
+ // Every coding agent codeburn reads (Codex, Cursor, Copilot, Gemini CLI, OpenCode, … ~40 of them), through its own
2
+ // readers in src/vendor/codeburn/src/providers/: where each keeps its sessions, their formats and the quirks codeburn
3
+ // works around. Claude is left out: Chompyy reads Claude Code itself (usage.ts).
4
+ //
5
+ // Scanning every agent takes a few seconds, so it runs at most every 10 minutes (`chompyy agents`, which the app
6
+ // calls) and the result is saved; `chompyy state` only reads the saved file.
7
+ import { homePath, readJson, writeJson } from './home.js';
8
+ import { loadPricing } from './vendor/codeburn/src/models.js';
9
+ import { getAllProviders, providerDisplayName, safeDiscoverSessions } from './vendor/codeburn/src/providers/index.js';
10
+ export const AGENTS_MIN_INTERVAL_MS = 10 * 60_000;
11
+ const filePath = () => homePath('agents-usage.json');
12
+ export const loadAgents = () => readJson(filePath(), null);
13
+ /** Every token a call moved: fresh input, cache writes, cache reads and output (reasoning is part of output). */
14
+ export const callTokens = (c) => c.inputTokens + c.outputTokens + c.cacheCreationInputTokens + c.cacheReadInputTokens;
15
+ /** Quiet settings for codeburn inside Chompyy: bundled prices only (no download), its cache in ~/.chompyy. */
16
+ export async function prepareCodeburn() {
17
+ process.env.CODEBURN_PRICING_SNAPSHOT_ONLY ??= '1';
18
+ process.env.CODEBURN_CACHE_DIR ??= homePath('codeburn-cache');
19
+ await loadPricing();
20
+ }
21
+ /** One agent's tokens and API value today (local day) and over the last 7, 30 and 90 days. */
22
+ export async function usageFor(provider, now, sources) {
23
+ const end = now.getTime();
24
+ const start = end - 90 * 24 * 3600_000;
25
+ const monthStart = end - 30 * 24 * 3600_000;
26
+ const weekStart = end - 7 * 24 * 3600_000;
27
+ const dayStart = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();
28
+ const today = { tokens: 0, costUsd: 0 };
29
+ const week = { tokens: 0, costUsd: 0 };
30
+ const month = { tokens: 0, costUsd: 0 };
31
+ const quarter = { tokens: 0, costUsd: 0 };
32
+ const byModel = new Map();
33
+ const seen = new Set();
34
+ for (const source of sources ?? (await provider.discoverSessions())) {
35
+ for await (const call of provider.createSessionParser(source, seen, { start: new Date(start), end: now }).parse()) {
36
+ const at = Date.parse(call.timestamp);
37
+ if (!Number.isFinite(at) || at < start || at > end)
38
+ continue;
39
+ const n = callTokens(call);
40
+ quarter.tokens += n;
41
+ quarter.costUsd += call.costUSD;
42
+ if (at >= monthStart) {
43
+ month.tokens += n;
44
+ month.costUsd += call.costUSD;
45
+ }
46
+ if (at >= weekStart) {
47
+ week.tokens += n;
48
+ week.costUsd += call.costUSD;
49
+ }
50
+ if (at >= dayStart) {
51
+ today.tokens += n;
52
+ today.costUsd += call.costUSD;
53
+ }
54
+ if (call.model)
55
+ byModel.set(call.model, (byModel.get(call.model) ?? 0) + n);
56
+ }
57
+ }
58
+ return {
59
+ name: provider.name,
60
+ displayName: provider.displayName || providerDisplayName(provider.name),
61
+ today,
62
+ week,
63
+ month,
64
+ quarter,
65
+ models: [...byModel.entries()].sort((a, b) => b[1] - a[1]).map(([m]) => m),
66
+ };
67
+ }
68
+ /** Scan every agent (at most every 10 minutes unless forced) and save what each used. */
69
+ export async function refreshAgents(opts = {}) {
70
+ const now = opts.now ?? new Date();
71
+ const last = loadAgents();
72
+ if (!opts.force && last && now.getTime() - Date.parse(last.scannedAt) < AGENTS_MIN_INTERVAL_MS)
73
+ return last;
74
+ await prepareCodeburn();
75
+ const agents = [];
76
+ const failed = [];
77
+ for (const p of opts.providers ?? (await getAllProviders())) {
78
+ if (p.name === 'claude')
79
+ continue;
80
+ try {
81
+ const sources = await safeDiscoverSessions(p);
82
+ if (!sources.length)
83
+ continue;
84
+ const u = await usageFor(p, now, sources);
85
+ if (u.quarter.tokens > 0)
86
+ agents.push(u);
87
+ }
88
+ catch {
89
+ failed.push(p.name);
90
+ }
91
+ }
92
+ agents.sort((a, b) => b.quarter.tokens - a.quarter.tokens);
93
+ const file = { scannedAt: now.toISOString(), agents, failed };
94
+ writeJson(filePath(), file);
95
+ return file;
96
+ }
@@ -0,0 +1,129 @@
1
+ // Which of Chompyy's suggestions you approve: a separate taste from how you like work done (FEATURES §3). Every
2
+ // suggested card you approve, drop or leave to expire is one decision; each card has a few plain features (where it
3
+ // came from, next step or chore, small or medium, what it's about). The approve rate per feature ranks new
4
+ // suggestions and tells the suggester what you tend to want. Counts only, from the board and its archive.
5
+ import { existsSync, readFileSync } from 'node:fs';
6
+ import { homePath } from './home.js';
7
+ const TOPICS = [
8
+ ['tests', /\btests?\b|\bspec\b|coverage/i],
9
+ ['docs', /\bdocs?\b|readme|documentation|changelog|comment/i],
10
+ ['bug fixes', /\bfix(es|ed)?\b|\bbug\b|crash|broken|error/i],
11
+ ['refactors', /refactor|clean ?up|simplif|rename|split|extract/i],
12
+ ['speed', /\bperf|faster|slow|cache|speed/i],
13
+ ['UI', /\bui\b|window|button|panel|popover|layout|board|menu/i],
14
+ ['savings', /token|quota|compact|skill|plugin|mcp/i],
15
+ ];
16
+ /** A card's features: "from repo tasks", "chores", "small", "tests", … (plain words: they show in the app and prompt). */
17
+ export function features(c) {
18
+ const out = [];
19
+ if (c.source === 'detect')
20
+ out.push('savings advice');
21
+ else if (c.source === 'history')
22
+ out.push('ideas from history');
23
+ else if (c.source === 'suggest')
24
+ out.push('repo tasks');
25
+ const why = c.why ?? '';
26
+ if (/^Chore\b/.test(why))
27
+ out.push('chores');
28
+ else if (/^Next step\b/.test(why))
29
+ out.push('next steps');
30
+ if (/· medium/.test(why))
31
+ out.push('medium tasks');
32
+ else if (/· small/.test(why))
33
+ out.push('small tasks');
34
+ // Topic from the title only: every suggested idea says how it's checked ("tests pass"), which isn't its topic.
35
+ for (const [name, re] of TOPICS)
36
+ if (re.test(c.title))
37
+ out.push(name);
38
+ return out;
39
+ }
40
+ const PAST_SUGGESTED = new Set(['approved', 'running', 'review', 'done']);
41
+ /** One decision per Chompyy-suggested card: approved (on the board), dropped or expired (in the archive). */
42
+ export function decisions(board, archived) {
43
+ const out = [];
44
+ for (const c of board.cards) {
45
+ if (!c.source)
46
+ continue;
47
+ if (c.approvedAt || PAST_SUGGESTED.has(c.column))
48
+ out.push({ card: c, outcome: 'yes' });
49
+ }
50
+ for (const c of archived) {
51
+ if (!c.source || !c.droppedAt)
52
+ continue;
53
+ if (c.approvedAt)
54
+ out.push({ card: c, outcome: 'yes' });
55
+ else
56
+ out.push({ card: c, outcome: c.expired ? 'ignored' : 'no' });
57
+ }
58
+ return out;
59
+ }
60
+ /** A feature needs this many decisions before it ranks anything or reaches the prompt. */
61
+ export const MIN_DECISIONS = 3;
62
+ export function featureStats(ds) {
63
+ const by = new Map();
64
+ for (const d of ds) {
65
+ for (const f of features(d.card)) {
66
+ const s = by.get(f) ?? { feature: f, yes: 0, no: 0, ignored: 0, rate: 0 };
67
+ s[d.outcome] += 1;
68
+ by.set(f, s);
69
+ }
70
+ }
71
+ for (const s of by.values())
72
+ s.rate = (s.yes + 1) / (s.yes + s.no + s.ignored / 2 + 2);
73
+ return [...by.values()].sort((a, b) => b.rate - a.rate || b.yes - a.yes);
74
+ }
75
+ const decided = (s) => s.yes + s.no + s.ignored;
76
+ /** How likely you'd approve this card: the mean rate of its features with enough decisions, else 0.5. */
77
+ export function approveScore(c, stats) {
78
+ const known = features(c).map((f) => stats.find((s) => s.feature === f)).filter((s) => !!s && decided(s) >= MIN_DECISIONS);
79
+ return known.length ? known.reduce((a, s) => a + s.rate, 0) / known.length : 0.5;
80
+ }
81
+ /** The strongest reason a card ranks where it does, e.g. "you approved 9 of 10 chores". */
82
+ export function reasonFor(c, stats) {
83
+ const known = features(c).map((f) => stats.find((s) => s.feature === f)).filter((s) => !!s && decided(s) >= MIN_DECISIONS);
84
+ const top = known.sort((a, b) => Math.abs(b.rate - 0.5) - Math.abs(a.rate - 0.5))[0];
85
+ return top ? `you approved ${top.yes} of ${decided(top)} ${top.feature}` : null;
86
+ }
87
+ /** For the suggester's prompt: what you tend to approve and drop. Empty until there are enough decisions. */
88
+ export function approvalsPrompt(stats) {
89
+ const known = stats.filter((s) => decided(s) >= MIN_DECISIONS);
90
+ const likes = known.filter((s) => s.rate >= 0.6).slice(0, 3);
91
+ const dislikes = known.filter((s) => s.rate <= 0.4).slice(-3);
92
+ if (!likes.length && !dislikes.length)
93
+ return '';
94
+ const say = (s) => `${s.feature} (approved ${s.yes} of ${decided(s)})`;
95
+ return [
96
+ '## Which suggestions the owner approves (from past decisions)',
97
+ likes.length ? `Tends to approve: ${likes.map(say).join(', ')}.` : '',
98
+ dislikes.length ? `Tends to drop or ignore: ${dislikes.map(say).join(', ')}. Suggest fewer of these unless the source is strong.` : '',
99
+ ].filter(Boolean).join('\n');
100
+ }
101
+ export function loadArchive() {
102
+ const path = homePath('archive.jsonl');
103
+ if (!existsSync(path))
104
+ return [];
105
+ const out = [];
106
+ for (const line of readFileSync(path, 'utf8').split('\n')) {
107
+ try {
108
+ if (line.trim())
109
+ out.push(JSON.parse(line));
110
+ }
111
+ catch { }
112
+ }
113
+ return out;
114
+ }
115
+ export function approvalStats(board) {
116
+ return featureStats(decisions(board, loadArchive()));
117
+ }
118
+ export function approvalsText(stats, total) {
119
+ if (!total)
120
+ return 'No decisions on suggested cards yet. Approve or drop a few and Chompyy learns which ones you want.';
121
+ const known = stats.filter((s) => decided(s) >= MIN_DECISIONS);
122
+ const lines = [`What you approve, from ${total} decisions on suggested cards:`, ''];
123
+ for (const s of known.slice(0, 8))
124
+ lines.push(` ${String(Math.round(s.rate * 100)).padStart(3)}% ${s.feature.padEnd(20)} approved ${s.yes}, dropped ${s.no}, let expire ${s.ignored}`);
125
+ if (!known.length)
126
+ lines.push(` Not enough yet: each kind needs ${MIN_DECISIONS} decisions.`);
127
+ lines.push('', 'New suggestions are ranked by this, and the suggester is told what you tend to want.');
128
+ return lines.join('\n');
129
+ }
package/dist/appstate.js CHANGED
@@ -18,19 +18,29 @@ import { costRange, readRuns } from './costs.js';
18
18
  import { cachedWorkspaces, loadDream } from './dream.js';
19
19
  import { learning } from './learning.js';
20
20
  import { describeSignal, loadStore, nextQuestion, readSignals, receipts } from './taste.js';
21
- import { agentInstalled, loadTriggerState } from './triggers.js';
21
+ import { agentInstalled, awayRunning, loadTriggerState } from './triggers.js';
22
+ import { nightcap } from './nightcap.js';
23
+ import { punchcard } from './punchcard.js';
24
+ import { loadLedger } from './usage.js';
25
+ import { demonOffer } from './demon.js';
22
26
  import { planFor } from './permissions.js';
23
27
  import { loadProfile, preflightHosts } from './preflight.js';
24
28
  import { gitRoot } from './workspace.js';
25
29
  import { writeBlueprintFile } from './blueprint.js';
26
30
  import { outboxes } from './send.js';
27
31
  import { exe } from './exe.js';
32
+ import { warmCaches } from './nudge.js';
33
+ import { codexInstalled, loadCodexState } from './codexquota.js';
34
+ import { limitsState } from './agentlimits.js';
35
+ import { parseQuestions } from './questions.js';
28
36
  export function cardView(card, runs = readRuns()) {
29
37
  const qPath = card.run ? join(card.run.workdir, 'QUESTIONS.md') : '';
38
+ const questionsText = qPath && existsSync(qPath) ? readFileSync(qPath, 'utf8') : null;
30
39
  return {
31
40
  ...card,
32
41
  files: card.run ? changedFiles(card) : [],
33
- questionsText: qPath && existsSync(qPath) ? readFileSync(qPath, 'utf8') : null,
42
+ questionsText,
43
+ questions: questionsText ? parseQuestions(questionsText) : [],
34
44
  pictureStale: Boolean(card.picture && card.picture.blueprintHash !== blueprintHash(card.blueprint)),
35
45
  costRange: card.run ? null : costRange(card, runs),
36
46
  folderBranch: card.column === 'review' && card.run?.branch ? (card.run.base?.branch || currentBranch(card.cwd)) : null,
@@ -61,6 +71,8 @@ export function currentBranch(cwd) {
61
71
  export function appState(board, snap, config, now) {
62
72
  const live = loadLiveState();
63
73
  const runs = readRuns();
74
+ const pace = pacing(snap, loadSamples(), now, config.bedtime);
75
+ const approved = board.cards.filter((c) => c.column === 'approved').length;
64
76
  return {
65
77
  generatedAt: now.toISOString(),
66
78
  quota: {
@@ -71,7 +83,7 @@ export function appState(board, snap, config, now) {
71
83
  askKeychain: keychainAsk(config),
72
84
  fiveHour: windowView(snap?.fiveHour, now),
73
85
  sevenDay: windowView(snap?.sevenDay, now),
74
- pacing: pacing(snap, loadSamples(), now, config.bedtime),
86
+ pacing: pace,
75
87
  },
76
88
  gate: budgetGate(snap, config, now),
77
89
  cards: board.cards.map((c) => cardView(c, runs)),
@@ -82,9 +94,67 @@ export function appState(board, snap, config, now) {
82
94
  taste: tasteState(),
83
95
  dream: dreamState(config, now),
84
96
  pictures: config.pictures,
97
+ /** Conversations whose cache is still warm, soonest to expire first: the cookie steams while there are any. */
98
+ caches: safeWarmCaches(now),
85
99
  triggers: { installed: agentInstalled(), lastHour: config.lastHourTrigger, bedtime: config.bedtime, ...loadTriggerState() },
100
+ /** The evening nightcap: offer to run approved cards at bedtime, or say what runs tonight. */
101
+ nightcap: nightcapNow(board, config, now),
102
+ /** Demon mode: eat what's left of the window before it resets. `auto` = the last-hour trigger runs it alone. */
103
+ demon: {
104
+ offer: demonOffer(windowView(snap?.fiveHour, now), pace.fiveHourForecast, approved, awayRunning() !== null),
105
+ auto: config.lastHourTrigger && agentInstalled(),
106
+ },
107
+ /** Other agents' limits beside Claude's: the app's provider switch. Only agents found on this Mac. */
108
+ providers: providersState(config, now),
109
+ };
110
+ }
111
+ /** Codex: whether it's here, whether you allowed the quota read, and its windows from the last check. */
112
+ export function providersState(config, now) {
113
+ const limits = limitsState(config.agentLimits ?? {});
114
+ if (!codexInstalled())
115
+ return { limits };
116
+ const s = loadCodexState();
117
+ return {
118
+ limits,
119
+ codex: {
120
+ allowed: config.codexQuota,
121
+ connection: s.connection ?? null,
122
+ plan: s.plan ?? null,
123
+ note: s.note ?? null,
124
+ capturedAt: s.capturedAt ?? null,
125
+ fiveHour: windowView(s.fiveHour, now),
126
+ sevenDay: windowView(s.sevenDay, now),
127
+ usage: s.usage ?? null,
128
+ },
86
129
  };
87
130
  }
131
+ export function nightcapNow(board, config, now) {
132
+ return nightcap({
133
+ now,
134
+ bedtime: config.bedtime,
135
+ bedtimeWindowMin: config.bedtimeWindowMin,
136
+ triggersOn: agentInstalled(),
137
+ approved: board.cards.filter((c) => c.column === 'approved').length,
138
+ fired: loadTriggerState().fired,
139
+ awayBusy: awayRunning() !== null,
140
+ quietFrom: () => {
141
+ try {
142
+ return punchcard(loadLedger().rows, now).quiet?.from ?? null;
143
+ }
144
+ catch {
145
+ return null;
146
+ }
147
+ },
148
+ });
149
+ }
150
+ function safeWarmCaches(now) {
151
+ try {
152
+ return warmCaches(now.getTime());
153
+ }
154
+ catch {
155
+ return [];
156
+ }
157
+ }
88
158
  /** The nightly read for the app: on or off, the workspaces with their ticks, and how last night went. */
89
159
  function dreamState(config, now) {
90
160
  let workspaces = [];