chompyy 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.
Files changed (166) hide show
  1. package/README.md +79 -6
  2. package/THIRD_PARTY_NOTICES.md +28 -0
  3. package/dist/appstate.js +43 -2
  4. package/dist/away.js +104 -15
  5. package/dist/board.js +33 -3
  6. package/dist/claudesettings.js +23 -0
  7. package/dist/cli.js +409 -27
  8. package/dist/coldstart.js +207 -0
  9. package/dist/config.js +36 -1
  10. package/dist/costs.js +162 -0
  11. package/dist/gate.js +29 -0
  12. package/dist/history.js +308 -0
  13. package/dist/livequota.js +15 -1
  14. package/dist/pacing.js +189 -0
  15. package/dist/picture.js +117 -0
  16. package/dist/projects.js +2 -2
  17. package/dist/quota.js +31 -5
  18. package/dist/report.js +38 -21
  19. package/dist/review.js +47 -4
  20. package/dist/runner.js +268 -8
  21. package/dist/taste.js +507 -0
  22. package/dist/triggers.js +182 -0
  23. package/dist/verify.js +131 -0
  24. package/package.json +2 -1
  25. package/skills/taste/SKILL.md +4 -1
  26. package/vendor/diagram-design/LICENSE +21 -0
  27. package/vendor/diagram-design/SKILL.md +399 -0
  28. package/vendor/diagram-design/UPSTREAM.md +18 -0
  29. package/vendor/diagram-design/assets/example-arc-diagram.html +111 -0
  30. package/vendor/diagram-design/assets/example-architecture-containment.html +205 -0
  31. package/vendor/diagram-design/assets/example-architecture-delta.html +193 -0
  32. package/vendor/diagram-design/assets/example-architecture.html +183 -0
  33. package/vendor/diagram-design/assets/example-axonometric-plan-campus.html +108 -0
  34. package/vendor/diagram-design/assets/example-axonometric-plan-coffee-shop.html +121 -0
  35. package/vendor/diagram-design/assets/example-axonometric-plan-warehouse.html +127 -0
  36. package/vendor/diagram-design/assets/example-axonometric-plan.html +114 -0
  37. package/vendor/diagram-design/assets/example-bar.html +129 -0
  38. package/vendor/diagram-design/assets/example-beeswarm.html +384 -0
  39. package/vendor/diagram-design/assets/example-box-plot.html +127 -0
  40. package/vendor/diagram-design/assets/example-bubble.html +147 -0
  41. package/vendor/diagram-design/assets/example-bump.html +142 -0
  42. package/vendor/diagram-design/assets/example-data-flow.html +143 -0
  43. package/vendor/diagram-design/assets/example-datalake.html +269 -0
  44. package/vendor/diagram-design/assets/example-db-schema.html +302 -0
  45. package/vendor/diagram-design/assets/example-dependency.html +224 -0
  46. package/vendor/diagram-design/assets/example-deployment.html +190 -0
  47. package/vendor/diagram-design/assets/example-dp-integration.html +81 -0
  48. package/vendor/diagram-design/assets/example-dp-security-matrix.html +88 -0
  49. package/vendor/diagram-design/assets/example-er.html +202 -0
  50. package/vendor/diagram-design/assets/example-event-modeling.html +64 -0
  51. package/vendor/diagram-design/assets/example-exploded-ai-stack.html +85 -0
  52. package/vendor/diagram-design/assets/example-exploded-keyboard.html +84 -0
  53. package/vendor/diagram-design/assets/example-exploded-phone.html +83 -0
  54. package/vendor/diagram-design/assets/example-exploded-unboxing.html +84 -0
  55. package/vendor/diagram-design/assets/example-exploded.html +83 -0
  56. package/vendor/diagram-design/assets/example-fishbone.html +152 -0
  57. package/vendor/diagram-design/assets/example-flowchart.html +163 -0
  58. package/vendor/diagram-design/assets/example-gantt.html +137 -0
  59. package/vendor/diagram-design/assets/example-heatmap.html +224 -0
  60. package/vendor/diagram-design/assets/example-high-level-vertical.html +325 -0
  61. package/vendor/diagram-design/assets/example-high-level.html +301 -0
  62. package/vendor/diagram-design/assets/example-import-drawio.html +185 -0
  63. package/vendor/diagram-design/assets/example-import-excalidraw.html +70 -0
  64. package/vendor/diagram-design/assets/example-import-mermaid.html +70 -0
  65. package/vendor/diagram-design/assets/example-import-plantuml.html +107 -0
  66. package/vendor/diagram-design/assets/example-it-state.html +128 -0
  67. package/vendor/diagram-design/assets/example-journey.html +148 -0
  68. package/vendor/diagram-design/assets/example-kanban.html +174 -0
  69. package/vendor/diagram-design/assets/example-layers.html +123 -0
  70. package/vendor/diagram-design/assets/example-line.html +111 -0
  71. package/vendor/diagram-design/assets/example-loop.html +100 -0
  72. package/vendor/diagram-design/assets/example-marimekko.html +148 -0
  73. package/vendor/diagram-design/assets/example-medallion.html +159 -0
  74. package/vendor/diagram-design/assets/example-nested.html +136 -0
  75. package/vendor/diagram-design/assets/example-org-chart.html +45 -0
  76. package/vendor/diagram-design/assets/example-polar.html +116 -0
  77. package/vendor/diagram-design/assets/example-process.html +64 -0
  78. package/vendor/diagram-design/assets/example-pyramid.html +119 -0
  79. package/vendor/diagram-design/assets/example-quadrant-consultant.html +166 -0
  80. package/vendor/diagram-design/assets/example-quadrant.html +135 -0
  81. package/vendor/diagram-design/assets/example-radar.html +139 -0
  82. package/vendor/diagram-design/assets/example-requirement-traceability.html +122 -0
  83. package/vendor/diagram-design/assets/example-ridgeline.html +104 -0
  84. package/vendor/diagram-design/assets/example-sankey.html +150 -0
  85. package/vendor/diagram-design/assets/example-sbgn.html +213 -0
  86. package/vendor/diagram-design/assets/example-scatter.html +141 -0
  87. package/vendor/diagram-design/assets/example-sequence-oauth.html +227 -0
  88. package/vendor/diagram-design/assets/example-sequence.html +222 -0
  89. package/vendor/diagram-design/assets/example-service-blueprint.html +185 -0
  90. package/vendor/diagram-design/assets/example-slopegraph.html +119 -0
  91. package/vendor/diagram-design/assets/example-state-lifecycle.html +92 -0
  92. package/vendor/diagram-design/assets/example-state.html +147 -0
  93. package/vendor/diagram-design/assets/example-steps.html +78 -0
  94. package/vendor/diagram-design/assets/example-story-map.html +184 -0
  95. package/vendor/diagram-design/assets/example-streamgraph.html +99 -0
  96. package/vendor/diagram-design/assets/example-swimlane.html +172 -0
  97. package/vendor/diagram-design/assets/example-timeline.html +135 -0
  98. package/vendor/diagram-design/assets/example-tree-block-decomposition.html +151 -0
  99. package/vendor/diagram-design/assets/example-tree.html +173 -0
  100. package/vendor/diagram-design/assets/example-treemap.html +107 -0
  101. package/vendor/diagram-design/assets/example-uml-class.html +188 -0
  102. package/vendor/diagram-design/assets/example-unit-grid.html +141 -0
  103. package/vendor/diagram-design/assets/example-venn.html +110 -0
  104. package/vendor/diagram-design/assets/example-wardley.html +153 -0
  105. package/vendor/diagram-design/assets/example-waterfall.html +129 -0
  106. package/vendor/diagram-design/assets/template-dark.html +99 -0
  107. package/vendor/diagram-design/assets/template.html +100 -0
  108. package/vendor/diagram-design/references/layout-budget.md +103 -0
  109. package/vendor/diagram-design/references/output-spec.md +277 -0
  110. package/vendor/diagram-design/references/primitive-annotation.md +36 -0
  111. package/vendor/diagram-design/references/primitive-sketchy.md +43 -0
  112. package/vendor/diagram-design/references/primitives-core.md +146 -0
  113. package/vendor/diagram-design/references/semantic-patterns.md +154 -0
  114. package/vendor/diagram-design/references/style-guide.md +234 -0
  115. package/vendor/diagram-design/references/type-architecture-delta.md +143 -0
  116. package/vendor/diagram-design/references/type-architecture.md +117 -0
  117. package/vendor/diagram-design/references/type-axonometric-plan.md +83 -0
  118. package/vendor/diagram-design/references/type-bar.md +108 -0
  119. package/vendor/diagram-design/references/type-data-flow.md +371 -0
  120. package/vendor/diagram-design/references/type-db-schema.md +48 -0
  121. package/vendor/diagram-design/references/type-dependency.md +113 -0
  122. package/vendor/diagram-design/references/type-deployment.md +45 -0
  123. package/vendor/diagram-design/references/type-dp-integration.md +407 -0
  124. package/vendor/diagram-design/references/type-dp-security-matrix.md +379 -0
  125. package/vendor/diagram-design/references/type-er.md +25 -0
  126. package/vendor/diagram-design/references/type-event-modeling.md +36 -0
  127. package/vendor/diagram-design/references/type-exploded.md +115 -0
  128. package/vendor/diagram-design/references/type-fishbone.md +75 -0
  129. package/vendor/diagram-design/references/type-flowchart.md +23 -0
  130. package/vendor/diagram-design/references/type-gantt.md +45 -0
  131. package/vendor/diagram-design/references/type-heatmap.md +80 -0
  132. package/vendor/diagram-design/references/type-high-level.md +470 -0
  133. package/vendor/diagram-design/references/type-it-state.md +468 -0
  134. package/vendor/diagram-design/references/type-journey.md +55 -0
  135. package/vendor/diagram-design/references/type-kanban.md +49 -0
  136. package/vendor/diagram-design/references/type-layers.md +26 -0
  137. package/vendor/diagram-design/references/type-line.md +337 -0
  138. package/vendor/diagram-design/references/type-loop.md +223 -0
  139. package/vendor/diagram-design/references/type-medallion.md +356 -0
  140. package/vendor/diagram-design/references/type-nested.md +22 -0
  141. package/vendor/diagram-design/references/type-org-chart.md +44 -0
  142. package/vendor/diagram-design/references/type-polar.md +136 -0
  143. package/vendor/diagram-design/references/type-process.md +490 -0
  144. package/vendor/diagram-design/references/type-pyramid.md +33 -0
  145. package/vendor/diagram-design/references/type-quadrant.md +81 -0
  146. package/vendor/diagram-design/references/type-radar.md +82 -0
  147. package/vendor/diagram-design/references/type-requirement-traceability.md +45 -0
  148. package/vendor/diagram-design/references/type-sankey.md +75 -0
  149. package/vendor/diagram-design/references/type-sbgn.md +80 -0
  150. package/vendor/diagram-design/references/type-scatter.md +276 -0
  151. package/vendor/diagram-design/references/type-sequence.md +130 -0
  152. package/vendor/diagram-design/references/type-service-blueprint.md +103 -0
  153. package/vendor/diagram-design/references/type-state.md +30 -0
  154. package/vendor/diagram-design/references/type-steps.md +180 -0
  155. package/vendor/diagram-design/references/type-story-map.md +46 -0
  156. package/vendor/diagram-design/references/type-swimlane.md +22 -0
  157. package/vendor/diagram-design/references/type-timeline.md +20 -0
  158. package/vendor/diagram-design/references/type-tree.md +24 -0
  159. package/vendor/diagram-design/references/type-treemap.md +137 -0
  160. package/vendor/diagram-design/references/type-uml-class.md +65 -0
  161. package/vendor/diagram-design/references/type-unit-grid.md +63 -0
  162. package/vendor/diagram-design/references/type-venn.md +26 -0
  163. package/vendor/diagram-design/references/type-wardley.md +39 -0
  164. package/vendor/diagram-design/references/type-waterfall.md +75 -0
  165. package/vendor/diagram-design/scripts/self_check.py +1177 -0
  166. package/vendor/diagram-design/scripts/verify_geometry.py +696 -0
package/README.md CHANGED
@@ -29,6 +29,19 @@ You also need [Claude Code](https://code.claude.com) (`claude` on your PATH) for
29
29
 
30
30
  By default Chompyy reads live quota with Claude Code's saved login (macOS Keychain or `~/.claude/.credentials.json`), from the same usage endpoint Claude Code's `/usage` shows. It sends no message, so it never starts a window, and it checks at most every 5 minutes. Nothing to set up. To use only the status line instead, set `"quotaSource": "statusline"` in `~/.chompyy/config.json`.
31
31
 
32
+ ### Pacing
33
+
34
+ ```
35
+ 🍪 5h 22% left ⇡41% · 3h07m · limit ~20:24 | 7d 24% used ⇣7%
36
+ ```
37
+
38
+ - **Pace delta**: used % minus the % of the window that has passed. `⇣` (green) is headroom, `⇡` (red) is burning faster than an even pace.
39
+ - **Forecast**: from your pace over the last hour (or your average this window), how much of the 5-hour window will reset unused (`~40% unused at 18:20`, the moment to give Chompyy a card), or when you'll hit the limit first. Once a limit is hit it stops projecting and shows when it resets.
40
+ - **Today** (`chompyy status`): what's left of the week ÷ the days left, where your day ends at your `bedtime` (midnight if unset), with on pace / ahead / behind / over. It needs a reading from before today to judge; until then it shows the allowance only.
41
+ - **Per-model weekly limits** (e.g. Opus) appear in `chompyy status` when your plan has them, and the gate respects them: a run on a model whose weekly window is over the hard stop doesn't start.
42
+
43
+ The rate comes from a small history of quota readings (`quota-history.json`, 8 days), saved whenever the numbers change; no extra calls.
44
+
32
45
  ## Set up the quota snapshot (fallback)
33
46
 
34
47
  Chompyy can also read quota from Claude Code's status line, never by sending a message (if no window is active, the first message would start a new 5-hour window). Add this to `~/.claude/settings.json`:
@@ -52,6 +65,18 @@ That reads: 62% of the 5h window left, it resets in 1h40m, so about 37% per hour
52
65
 
53
66
  If you already have a status line command, keep it and call Chompyy from a small wrapper: save stdin to a variable, pipe it to `chompyy statusline`, and print both.
54
67
 
68
+ ## Get to know you (cold start)
69
+
70
+ ```bash
71
+ chompyy history # what it would read: sessions, projects, dates (local, sends nothing)
72
+ chompyy history --digest # the exact text it would send
73
+ chompyy coldstart # one model call: proposes taste lines and suggested cards
74
+ chompyy coldstart accept --taste t1,t2 --cards c1 # the rest are declined
75
+ chompyy keep-history 365 # Claude Code deletes transcripts after 30 days by default
76
+ ```
77
+
78
+ Only interactive sessions are read (headless runs are skipped). Each proposal must cite your sessions: a taste line needs 3 separate sessions, and a card's quote must really appear in what you said. Anything that doesn't check out is thrown away.
79
+
55
80
  ## Two-minute walkthrough
56
81
 
57
82
  ```bash
@@ -82,12 +107,13 @@ Each card in a git repo runs in its own worktree at `~/.chompyy/worktrees/<id>`
82
107
  | Command | What it does |
83
108
  |---|---|
84
109
  | `chompyy statusline` | Status line hook: reads Claude Code's JSON on stdin, saves the snapshot, prints one line |
85
- | `chompyy status` | % left in the 5h window, time to reset, per-hour pace, weekly used, stale or not |
110
+ | `chompyy status` | % left in the 5h window, time to reset, weekly used, pace delta, forecast, today's allowance, per-model weekly windows |
86
111
  | `chompyy eat-tokens` | Read-only view of remaining 5h quota and approved/later cards; starts nothing |
87
112
  | `chompyy later "<idea>"` | New card in *later*, remembering the current directory. Drafts the blueprint in the background when `claude` is available (`--wait` to wait for it, `--no-blueprint` to skip) |
88
113
  | `chompyy board [--column approved]` | Cards by column: suggested, later, approved, running, review, done |
89
114
  | `chompyy show <id>` | One card with its blueprint, last run and rating |
90
115
  | `chompyy blueprint <id> [--model m]` | Draft (or redraft) the blueprint with a cheap model |
116
+ | `chompyy picture <id> [--model m]` | Draw (or redraw) the card's picture: a diagram of what it will do, made with the diagram-design skill. Happens on its own after each blueprint while a window is active (`"pictures": false` in config.json turns it off) |
91
117
  | `chompyy approve <id>` / `drop <id>` | Queue a card for away runs / remove it (kept in `archive.jsonl`) |
92
118
  | `chompyy away <1h\|30m\|1h30m> [--dry-run] [--force]` | Run approved cards until the time is up or the gate closes |
93
119
  | `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` |
@@ -95,7 +121,36 @@ Each card in a git repo runs in its own worktree at `~/.chompyy/worktrees/<id>`
95
121
  | `chompyy keep <id>` | Merge the card's branch into your current branch and remove its worktree. Refuses if your repo has uncommitted changes |
96
122
  | `chompyy undo <id>` | Throw the run away: remove its worktree and branch (or draft folder). Your own branches are never touched |
97
123
  | `chompyy rate <id> <1-5> ["why"]` | Rate a result against its blueprint; moves it to *done* and logs a signal |
98
- | `chompyy taste` | Show `taste.md` (a stub for now; nothing is distilled yet) |
124
+ | `chompyy taste` | Show `taste.md` |
125
+ | `chompyy taste list` / `why <id>` | Every learned preference and its status / the cards, edits and quotes behind one |
126
+ | `chompyy taste yes\|not-now\|never <id>` | Answer the report's question. Only *yes* writes it to `taste.md`; *never* stops Chompyy proposing it again |
127
+ | `chompyy taste retire <id>` | Stop using a preference; it stays in `taste list` with the reason |
128
+ | `chompyy distill [--force]` | Read new signals and update preferences now (also runs after every away run) |
129
+ | `chompyy trends` | Last 7 days vs the 7 before: cost per card, keep rate, rating, blueprint edits |
130
+ | `chompyy triggers on\|off` | Install or remove the macOS LaunchAgent that runs `chompyy tick` every 5 minutes |
131
+ | `chompyy bedtime <23:30\|off>` / `last-hour <on\|off>` | Turn the bedtime and last-hour-before-reset triggers on or off |
132
+
133
+ ## Taste
134
+
135
+ Chompyy learns how you like work done from what you do with results, not from what you tell it:
136
+
137
+ 1. **Signals** collect in `signals.jsonl`: ratings and their reasons, "what would have made it a 5?" picks, blueprint edits, keep and undo, answers. Only cards you approved, ran or rated count; drafts you dropped don't.
138
+ 2. **The distiller** (`distillModel`, default sonnet; one model call, only inside an active window) reads new signals and proposes preferences. Each one must cite signals, and the citations are checked, so it can't invent evidence.
139
+ 3. **Asked, not assumed.** A preference becomes a question after 3 separate cards, or after one if you said it yourself in a rating. The report asks at most one question, strongest evidence first.
140
+ 4. **Yes** writes it to `taste.md` with a valid-from date, and away runs get `taste.md` in their prompt. Contradicted or removed preferences are retired with the reason, never silently deleted. Delete a learned line from `taste.md` and that preference is retired: your edits win.
141
+
142
+ ## Triggers
143
+
144
+ `chompyy triggers on` installs a LaunchAgent (`~/Library/LaunchAgents/dev.chompyy.tick.plist`) that runs `chompyy tick` every 5 minutes. Nothing fires until you turn it on. A tick starts an away run when:
145
+
146
+ - **last hour**: the 5-hour window resets within the hour with at least `lastHourMinLeftPct` left (default 25%); once per window;
147
+ - **bedtime**: it's within `bedtimeWindowMin` (default 60) of your `bedtime`; once a night. At bedtime it also distils taste when there's something new.
148
+
149
+ Either way the run lasts until 2 minutes before the reset, the budget gate still decides every card, and only one away runs at a time (`away.lock`). Ticks are logged to `tick.log`.
150
+
151
+ ## Cost ranges
152
+
153
+ Each run records what it used of your windows: 5-hour and weekly quota after the card minus before (it also counts anything else you did at the same time, so it's an upper bound). A card that hasn't run shows a range from similar past runs (`show`, `eat-tokens`): min–max at first, P10–P90 once there are 5 or more.
99
154
 
100
155
  ## The budget gate
101
156
 
@@ -129,6 +184,18 @@ An unknown weekly window doesn't close the gate (some plans don't report it); `a
129
184
  | `sandbox` | `true` | Run away cards in Claude Code's OS sandbox (macOS, Linux, WSL2) |
130
185
  | `sandboxAllowedDomains` | `[]` | Domains sandboxed commands may reach, e.g. `["registry.npmjs.org"]` |
131
186
  | `extraArgs` | `[]` | Appended to every away-run `claude -p` call, e.g. `["--max-budget-usd", "2"]` for API-key users |
187
+ | `denyReadPaths` | `~/.ssh`, `~/.aws`, `~/.gnupg`, … | Never readable by away runs (sandbox `denyRead` + `Read(...)` deny rules) |
188
+ | `loopRepeat` | `5` | Circuit breaker: stop a card that repeats the same tool call this often; `0` = off |
189
+ | `independentCheck` | `true` | Run the repo's tests after each card, sandboxed (macOS) |
190
+ | `checkTimeoutMin` | `10` | Time limit for that check |
191
+ | `checkCommands` | `{}` | Test command per repo when the detected one is wrong, e.g. `{"/Users/me/app": "npm run test:unit"}` |
192
+ | `suggestedExpiryDays` | `14` | Archive suggested cards untouched this long; `0` = never |
193
+ | `distillModel` | `"sonnet"` | Model that distils taste from your signals |
194
+ | `distillAfterAway` | `true` | Distil after each away run when there are new signals |
195
+ | `lastHourTrigger` | `true` | Last-hour trigger (only fires once `chompyy triggers on`) |
196
+ | `lastHourMinLeftPct` | `25` | Last-hour trigger needs at least this much of the window left |
197
+ | `bedtime` | `null` | Bedtime trigger as `"23:30"`; `null` = off |
198
+ | `bedtimeWindowMin` | `60` | How long after bedtime it may still start |
132
199
 
133
200
  Set `CHOMPYY_HOME` to keep state somewhere other than `~/.chompyy` (the tests do this).
134
201
 
@@ -138,9 +205,12 @@ A card runs unattended only inside a box (spec §5.5):
138
205
 
139
206
  - **Its own place**: a fresh git worktree on `chompyy/<id>`, or a draft folder under `~/.chompyy/runs/<id>/`. Your checkout is never touched; nothing is merged.
140
207
  - **Rules in the prompt**, before the blueprint: work only inside this directory; no git push, merge, rebase or PR; no sending, posting, publishing or purchases; if a decision is needed, stop and write `QUESTIONS.md` (the report flags those cards as ❓).
141
- - **Enforced by the OS** (default, `sandbox: true`): cards run in Claude Code's sandbox. Shell commands can write only inside the card's folder (plus its repo's `.git`, so commits work) and have **no network** unless you list domains in `sandboxAllowedDomains`. So a `git push` fails even if a test script tries it. If the sandbox can't start, the card refuses to run rather than run unprotected. Checked on macOS with a real headless run: network and outside writes were blocked, the commit worked. File reads are not restricted.
208
+ - **Enforced by the OS** (default, `sandbox: true`): cards run in Claude Code's sandbox. Shell commands can write only inside the card's folder (plus its repo's `.git`, so commits work) and have **no network** unless you list domains in `sandboxAllowedDomains`. So a `git push` fails even if a test script tries it. If the sandbox can't start, the card refuses to run rather than run unprotected. Checked on macOS with a real headless run: network and outside writes were blocked, the commit worked. Credential folders (`denyReadPaths`: `~/.ssh`, `~/.aws`, `~/.gnupg`, cloud CLI configs, `.netrc`, `.npmrc`, Keychains, …) can't be read, by shell commands or by the file tools; other reads are allowed.
142
209
  - **Rules in the tools**: `acceptEdits` plus an allow list, a deny list for push/merge/`gh`/publish, and `--permission-prompts none` so anything outside the lists is refused instead of waiting for you.
143
- - **Caps**: a wall-clock timeout per card, a turn cap, the away duration, and the budget gate above.
210
+ - **Caps**: a wall-clock timeout per card, a turn cap, the away duration, and the budget gate above. The gate never lets a card start past 100% of a window, so a plan with extra usage turned on is never billed by Chompyy.
211
+ - **Circuit breaker**: away runs are watched as they happen. The same tool call 5 times in the last 20, or the same shell command failing 4 times in a row, stops the card (⛔ *stuck* in the report). `loopRepeat` sets the number; `0` turns it off.
212
+ - **Independent check**: after a run, Chompyy runs the repo's own tests itself (`npm test`, `go test`, `cargo test --offline`, `pytest`, `make test`; set your own per repo in `checkCommands`). They run in a macOS sandbox: writes only in the card's folder, no network, no credential reads. A fresh worktree has no `node_modules`, so your checkout's is linked in for the check. The report trusts this result over what the agent says. If a failure looks like the sandbox blocked something (a write outside the folder, the network), the report says so instead of calling the change broken. Skipped on other systems; `independentCheck: false` turns it off.
213
+ - **Overlaps**: approving a card warns when a queued or unreviewed card looks like it touches the same files.
144
214
  - **Blueprint first**: a card can't be approved without one.
145
215
 
146
216
  These lower the risk; they don't make it zero. Read the result (and its branch) before you merge anything.
@@ -166,8 +236,11 @@ Everything is plain JSON or Markdown in `~/.chompyy/`:
166
236
  | `board.json` | Cards, with blueprints, run info and ratings |
167
237
  | `runs/<id>/<time>.log` | Prompt, output and errors of each run |
168
238
  | `worktrees/<id>/` | Git worktrees of cards that ran in a repo |
169
- | `signals.jsonl` | One line per rating: card, rating, reason, blueprint (input for the future taste distiller) |
170
- | `taste.md` | What's been learned; edit freely |
239
+ | `signals.jsonl` | Everything you did that teaches taste: ratings, blueprint edits, keep/undo, answers, taste answers |
240
+ | `preferences.json` | Learned preferences with evidence, status, valid-from and retired-because |
241
+ | `taste.md` | What's been learned and confirmed, plus your own lines; edit freely |
242
+ | `runs.jsonl` | One line per run: duration and what it used of the 5-hour and weekly windows |
243
+ | `triggers.json` / `tick.log` | What fired, and what each tick decided |
171
244
  | `archive.jsonl` | Dropped cards |
172
245
  | `state.json` | When the last report was shown |
173
246
  | `config.json` | Your settings |
@@ -29,3 +29,31 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
29
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
30
  SOFTWARE.
31
31
  ```
32
+
33
+ `cli/vendor/diagram-design/`: from [diagram-design](https://github.com/cathrynlavery/diagram-design) (MIT, Copyright (c) 2025 Cathryn Lavery), the skill that draws every card's picture. See its `UPSTREAM.md` for what was kept and changed.
34
+
35
+ Its licence, in full:
36
+
37
+ ```
38
+ MIT License
39
+
40
+ Copyright (c) 2025 Cathryn Lavery
41
+
42
+ Permission is hereby granted, free of charge, to any person obtaining a copy
43
+ of this software and associated documentation files (the "Software"), to deal
44
+ in the Software without restriction, including without limitation the rights
45
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
46
+ copies of the Software, and to permit persons to whom the Software is
47
+ furnished to do so, subject to the following conditions:
48
+
49
+ The above copyright notice and this permission notice shall be included in all
50
+ copies or substantial portions of the Software.
51
+
52
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
53
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
54
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
55
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
56
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
57
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
58
+ SOFTWARE.
59
+ ```
package/dist/appstate.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // What the Mac app reads (`chompyy state --json`) and the card actions it needs beyond the CLI's.
2
2
  // The app holds no logic of its own: it shows this JSON and calls chompyy commands.
3
+ import { execFileSync } from 'node:child_process';
3
4
  import { readFileSync, existsSync } from 'node:fs';
4
5
  import { join } from 'node:path';
5
6
  import { getCard } from './board.js';
@@ -7,17 +8,36 @@ import { budgetGate } from './gate.js';
7
8
  import { appendJsonl, homePath, readJson, writeJson } from './home.js';
8
9
  import { loadLiveState } from './livequota.js';
9
10
  import { windowView } from './quota.js';
11
+ import { loadSamples, pacing } from './pacing.js';
10
12
  import { changedFiles } from './review.js';
11
- export function cardView(card) {
13
+ import { loadColdStart } from './coldstart.js';
14
+ import { blueprintHash } from './picture.js';
15
+ import { costRange, readRuns } from './costs.js';
16
+ import { loadStore, nextQuestion, readSignals, receipts } from './taste.js';
17
+ import { agentInstalled, loadTriggerState } from './triggers.js';
18
+ export function cardView(card, runs = readRuns()) {
12
19
  const qPath = card.run ? join(card.run.workdir, 'QUESTIONS.md') : '';
13
20
  return {
14
21
  ...card,
15
22
  files: card.run ? changedFiles(card) : [],
16
23
  questionsText: qPath && existsSync(qPath) ? readFileSync(qPath, 'utf8') : null,
24
+ pictureStale: Boolean(card.picture && card.picture.blueprintHash !== blueprintHash(card.blueprint)),
25
+ costRange: card.run ? null : costRange(card, runs),
26
+ folderBranch: card.column === 'review' && card.run?.branch ? currentBranch(card.cwd) : null,
17
27
  };
18
28
  }
29
+ /** The branch a folder is on (what Keep merges into), or null. */
30
+ function currentBranch(cwd) {
31
+ try {
32
+ return execFileSync('git', ['-C', cwd, 'rev-parse', '--abbrev-ref', 'HEAD'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || null;
33
+ }
34
+ catch {
35
+ return null;
36
+ }
37
+ }
19
38
  export function appState(board, snap, config, now) {
20
39
  const live = loadLiveState();
40
+ const runs = readRuns();
21
41
  return {
22
42
  generatedAt: now.toISOString(),
23
43
  quota: {
@@ -27,11 +47,32 @@ export function appState(board, snap, config, now) {
27
47
  note: live.note ?? null,
28
48
  fiveHour: windowView(snap?.fiveHour, now),
29
49
  sevenDay: windowView(snap?.sevenDay, now),
50
+ pacing: pacing(snap, loadSamples(), now, config.bedtime),
30
51
  },
31
52
  gate: budgetGate(snap, config, now),
32
- cards: board.cards.map(cardView),
53
+ cards: board.cards.map((c) => cardView(c, runs)),
54
+ coldStart: coldStartState(),
55
+ tasteQuestion: tasteQuestion(),
56
+ triggers: { installed: agentInstalled(), lastHour: config.lastHourTrigger, bedtime: config.bedtime, ...loadTriggerState() },
33
57
  };
34
58
  }
59
+ /** The one taste question waiting, with its receipts, for the app to show as a one-tap card. */
60
+ export function tasteQuestion() {
61
+ const signals = readSignals();
62
+ const p = nextQuestion(loadStore(), signals);
63
+ if (!p)
64
+ return null;
65
+ const byId = new Map(signals.map((s) => [s.id, s]));
66
+ return { id: p.id, text: p.text, noticed: p.noticed, scope: p.scope, evidence: receipts(p.evidence.map((e) => byId.get(e)).filter(Boolean)) };
67
+ }
68
+ /** Whether the app should offer the cold start: never run, proposals waiting, or done. */
69
+ export function coldStartState() {
70
+ const cs = loadColdStart();
71
+ if (!cs)
72
+ return { status: 'never', waiting: 0 };
73
+ const waiting = [...cs.taste, ...cs.cards].filter((p) => p.status === 'proposed').length;
74
+ return { status: waiting ? 'proposed' : 'done', waiting };
75
+ }
35
76
  /** Replace a card's blueprint with your edit. Edits are the strongest taste signal, so the change is logged. */
36
77
  export function editBlueprint(board, id, text, now) {
37
78
  const card = getCard(board, id);
package/dist/away.js CHANGED
@@ -1,10 +1,12 @@
1
1
  // Away run (spec §5.2, §5.5, §5.6): approved cards, one at a time, headless, inside the window.
2
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
3
3
  import { join } from 'node:path';
4
4
  import { awayQueue, loadBoard, recoverRunning, updateBoard, getCard } from './board.js';
5
5
  import { formatDuration } from './duration.js';
6
6
  import { budgetGate } from './gate.js';
7
7
  import { homePath } from './home.js';
8
+ import { recordRun, usedBetween } from './costs.js';
9
+ import { tasteForPrompt } from './taste.js';
8
10
  /** Don't start a card with less than this much time left in the away run. */
9
11
  export const MIN_CARD_MS = 2 * 60_000;
10
12
  export function safetyRules(workdir) {
@@ -40,13 +42,13 @@ export function cacheEnv(dir) {
40
42
  XDG_CACHE_HOME: dir,
41
43
  };
42
44
  }
43
- export function sandboxSettings(ws, allowedDomains, cacheDir) {
45
+ export function sandboxSettings(ws, allowedDomains, cacheDir, denyRead = []) {
44
46
  return {
45
47
  sandbox: {
46
48
  enabled: true,
47
49
  failIfUnavailable: true, // refuse to run rather than run unprotected
48
50
  allowUnsandboxedCommands: false, // no retrying outside the sandbox
49
- filesystem: { allowWrite: [...(ws.gitDir ? [ws.gitDir] : []), ...(cacheDir ? [cacheDir] : [])] },
51
+ filesystem: { allowWrite: [...(ws.gitDir ? [ws.gitDir] : []), ...(cacheDir ? [cacheDir] : [])], ...(denyRead.length ? { denyRead } : {}) },
50
52
  network: { allowedDomains },
51
53
  // Commands are confined by the sandbox, so local ones (tests, scripts) run without a prompt.
52
54
  // The deny list still blocks outward commands (push, publish, curl, …).
@@ -54,9 +56,17 @@ export function sandboxSettings(ws, allowedDomains, cacheDir) {
54
56
  },
55
57
  };
56
58
  }
57
- export function taskPrompt(card, workdir) {
59
+ /** Read rules for the file tools: the sandbox's denyRead only covers shell commands. */
60
+ export function denyReadRules(paths) {
61
+ return paths.flatMap((p) => [`Read(${p})`, `Read(${p}/**)`]);
62
+ }
63
+ export function taskPrompt(card, workdir, taste = '') {
58
64
  return `${safetyRules(workdir)}
65
+ ${taste ? `
66
+ # How this user likes work done (their taste.md; follow it unless the blueprint says otherwise)
59
67
 
68
+ ${taste}
69
+ ` : ''}
60
70
  # Task #${card.id}: ${card.title}
61
71
 
62
72
  Original idea: ${card.idea}
@@ -93,14 +103,17 @@ function firstLines(text, n = 5) {
93
103
  function stamp(ms) {
94
104
  return new Date(ms).toISOString().replace(/[:.]/g, '-');
95
105
  }
106
+ /** When quota was last read after a card (module state: one away run per process). */
107
+ let lastRefreshMs = -Infinity;
96
108
  export async function away(durationMs, deps, opts = {}) {
97
109
  const { config, out } = deps;
98
110
  const start = deps.now();
99
111
  const deadline = start + durationMs;
112
+ lastRefreshMs = -Infinity;
100
113
  if (!opts.dryRun) {
101
- const recovered = updateBoard((b) => recoverRunning(b, new Date(deps.now())));
114
+ const recovered = updateBoard((b) => recoverRunning(b, new Date(deps.now()), deps.plan));
102
115
  if (recovered.length)
103
- out(`Put back in approved after an interrupted run: ${recovered.map((id) => `#${id}`).join(', ')}`);
116
+ out(`Moved to review after an interrupted run: ${recovered.map((id) => `#${id}`).join(', ')}`);
104
117
  }
105
118
  const queue = awayQueue(loadBoard());
106
119
  const summary = { ran: [], skipped: [], stoppedBecause: null };
@@ -115,7 +128,8 @@ export async function away(durationMs, deps, opts = {}) {
115
128
  summary.stoppedBecause = 'time is up';
116
129
  break;
117
130
  }
118
- if (!opts.dryRun && deps.refreshQuota)
131
+ // The previous card already read quota when it finished; don't ask twice in a row.
132
+ if (!opts.dryRun && deps.refreshQuota && deps.now() - lastRefreshMs > 60_000)
119
133
  await deps.refreshQuota();
120
134
  const gate = budgetGate(deps.snapshot(), config, new Date(deps.now()));
121
135
  if (!gate.ok && !opts.force) {
@@ -129,7 +143,8 @@ export async function away(durationMs, deps, opts = {}) {
129
143
  summary.ran.push(queued.id);
130
144
  continue;
131
145
  }
132
- summary.ran.push(await runCard(queued.id, Math.min(config.cardTimeoutMin * 60_000, remaining), deps));
146
+ const timeoutMs = Math.min(config.cardTimeoutMin * 60_000, remaining);
147
+ summary.ran.push(deps.isolate ? await runIsolated(queued.id, timeoutMs, deps, opts.trigger) : await runCard(queued.id, timeoutMs, deps, opts.trigger));
133
148
  }
134
149
  const notRun = queue.map((c) => c.id).filter((id) => !summary.ran.includes(id));
135
150
  summary.skipped = notRun;
@@ -143,9 +158,39 @@ export async function away(durationMs, deps, opts = {}) {
143
158
  out(`Done. ${summary.ran.length} card(s) in review. See \`chompyy report\`.`);
144
159
  return summary;
145
160
  }
146
- async function runCard(id, timeoutMs, deps) {
161
+ /** Where a card's agent pid is kept while it runs, so the supervisor can stop it if the worker dies. */
162
+ export const agentPidPath = (id) => homePath('runs', id, 'agent.pid');
163
+ /** Run a card in a worker process; if the worker dies mid-card, stop its agent and put the card in review. */
164
+ async function runIsolated(id, timeoutMs, deps, trigger) {
165
+ let res;
166
+ try {
167
+ res = await deps.isolate(id, timeoutMs, trigger);
168
+ }
169
+ catch (err) {
170
+ res = { exitCode: null, stderr: String(err instanceof Error ? err.message : err) };
171
+ }
172
+ // An orphaned agent would keep working (and spending) alongside the next card.
173
+ const pid = Number(existsSync(agentPidPath(id)) ? readFileSync(agentPidPath(id), 'utf8') : NaN);
174
+ if (pid > 0) {
175
+ try {
176
+ process.kill(-pid, 'SIGTERM');
177
+ }
178
+ catch { }
179
+ }
180
+ rmSync(agentPidPath(id), { force: true });
181
+ if (getCard(loadBoard(), id).column !== 'running')
182
+ return id;
183
+ const how = res.signal ? `was killed (${res.signal})` : `exited with code ${res.exitCode}`;
184
+ const tail = res.stderr.trim().split('\n').filter((l) => !/^\s*\d+: 0x/.test(l)).slice(-3).join(' ').slice(0, 300);
185
+ const why = `Chompyy's worker for this card ${how} before it finished${tail ? `: ${tail}` : ''}.`;
186
+ updateBoard((b) => recoverRunning(b, new Date(deps.now()), deps.plan, why));
187
+ deps.out(` ⛔ #${id}: ${why} Moving on to the next card.`);
188
+ return id;
189
+ }
190
+ export async function runCard(id, timeoutMs, deps, trigger) {
147
191
  const { config, out } = deps;
148
192
  const startedMs = deps.now();
193
+ const quotaBefore = deps.snapshot();
149
194
  const card = updateBoard((b) => {
150
195
  const c = getCard(b, id);
151
196
  c.column = 'running';
@@ -159,10 +204,11 @@ async function runCard(id, timeoutMs, deps) {
159
204
  let exitCode = null;
160
205
  let summaryText = '';
161
206
  let checks;
207
+ let verified;
162
208
  let log = '';
163
209
  try {
164
210
  ws = deps.prepare(card);
165
- const prompt = taskPrompt(card, ws.dir);
211
+ const prompt = taskPrompt(card, ws.dir, (deps.taste ?? tasteForPrompt)());
166
212
  const cacheDir = homePath('cache', 'tools');
167
213
  mkdirSync(cacheDir, { recursive: true });
168
214
  const questionsPath = join(ws.dir, 'QUESTIONS.md');
@@ -176,11 +222,17 @@ async function runCard(id, timeoutMs, deps) {
176
222
  permissionMode: config.permissionMode,
177
223
  permissionPrompts: config.permissionPrompts,
178
224
  allowedTools: config.allowedTools,
179
- disallowedTools: config.disallowedTools,
180
- ...(config.sandbox ? { settings: sandboxSettings(ws, config.sandboxAllowedDomains, cacheDir) } : {}),
225
+ disallowedTools: [...config.disallowedTools, ...denyReadRules(config.denyReadPaths)],
226
+ ...(config.sandbox ? { settings: sandboxSettings(ws, config.sandboxAllowedDomains, cacheDir, config.denyReadPaths) } : {}),
181
227
  env: cacheEnv(cacheDir),
182
228
  extraArgs: config.extraArgs,
229
+ ...(config.loopRepeat > 0 ? { loopRepeat: config.loopRepeat } : {}),
230
+ ...(config.idleTimeoutMin > 0 ? { idleTimeoutMs: config.idleTimeoutMin * 60_000 } : {}),
231
+ onSpawn: (pid) => writeFileSync(agentPidPath(card.id), String(pid)),
232
+ // The whole stream (every tool call and result) goes to disk, never into memory: what to read when a run goes wrong.
233
+ rawLogPath: logPath.replace(/\.log$/, '.stream.jsonl'),
183
234
  });
235
+ rmSync(agentPidPath(card.id), { force: true });
184
236
  exitCode = result.exitCode;
185
237
  try {
186
238
  if (deps.commitLeftovers?.(ws, card))
@@ -190,9 +242,23 @@ async function runCard(id, timeoutMs, deps) {
190
242
  out(` couldn't commit leftover changes: ${err instanceof Error ? err.message : err}`);
191
243
  }
192
244
  const hasQuestions = existsSync(questionsPath) && readFileSync(questionsPath, 'utf8') !== questionsBefore;
193
- status = result.timedOut ? 'timeout' : result.exitCode !== 0 ? 'failed' : hasQuestions ? 'questions' : 'ok';
245
+ status = result.stuck || result.stalled ? 'stuck' : result.timedOut ? 'timeout' : result.exitCode !== 0 ? 'failed' : hasQuestions ? 'questions' : 'ok';
246
+ if (result.stuck)
247
+ out(` ⛔ stopped: it was going in circles (${result.stuck})`);
248
+ if (result.stalled)
249
+ out(` ⛔ stopped: ${result.stalled}`);
194
250
  checks = parseChecks(result.output);
195
- summaryText = firstLines(result.output.replace(/^\s*CHECKS:.*$/gim, '')) || firstLines(result.stderr);
251
+ if (deps.verify && ws.kind === 'worktree' && !result.stuck && !result.timedOut && result.exitCode === 0) {
252
+ out(' checking it independently (running the repo\'s tests, sandboxed)…');
253
+ verified = await deps.verify(ws, card).catch(() => undefined);
254
+ if (verified)
255
+ out(` ${verified.result === 'passed' ? '✓' : verified.result === 'failed' ? '✗' : '·'} ${verified.why}`);
256
+ }
257
+ summaryText = result.stuck
258
+ ? `Stopped by Chompyy: it was going in circles (${result.stuck}).`
259
+ : result.stalled
260
+ ? `Stopped by Chompyy: ${result.stalled} (a hung command or a stalled agent), so the next card could run.`
261
+ : firstLines(result.output.replace(/^\s*CHECKS:.*$/gim, '')) || firstLines(result.stderr);
196
262
  log = `# prompt\n\n${prompt}\n\n# output\n\n${result.output}\n\n# stderr\n\n${result.stderr}\n`;
197
263
  }
198
264
  catch (err) {
@@ -201,6 +267,16 @@ async function runCard(id, timeoutMs, deps) {
201
267
  log = `# error\n\n${summaryText}\n`;
202
268
  }
203
269
  const finishedMs = deps.now();
270
+ // What the card cost, in points of your windows: quota after minus before (an upper bound if you were busy too).
271
+ if (deps.refreshQuota) {
272
+ await deps.refreshQuota().catch(() => { });
273
+ lastRefreshMs = deps.now();
274
+ }
275
+ const quotaAfter = deps.snapshot();
276
+ const cost = {
277
+ fiveHourPct: usedBetween(quotaBefore?.fiveHour, quotaAfter?.fiveHour),
278
+ weeklyPct: usedBetween(quotaBefore?.sevenDay, quotaAfter?.sevenDay),
279
+ };
204
280
  const header = `card #${card.id} · ${status} · exit ${exitCode} · ${formatDuration(finishedMs - startedMs)}\nworkdir: ${ws?.dir ?? '-'}${ws?.branch ? `\nbranch: ${ws.branch}` : ''}\n\n`;
205
281
  writeFileSync(logPath, header + log);
206
282
  updateBoard((b) => {
@@ -218,8 +294,21 @@ async function runCard(id, timeoutMs, deps) {
218
294
  ...(ws?.branch ? { branch: ws.branch } : {}),
219
295
  summary: summaryText,
220
296
  ...(checks ? { checks } : {}),
297
+ cost,
298
+ ...(verified ? { verified } : {}),
299
+ ...(trigger ? { trigger } : {}),
221
300
  };
222
301
  });
223
- out(` → ${status} · ${formatDuration(finishedMs - startedMs)} · log ${logPath}`);
302
+ recordRun({
303
+ at: new Date(finishedMs).toISOString(),
304
+ card: card.id,
305
+ title: card.title,
306
+ idea: card.idea,
307
+ cwd: card.cwd,
308
+ status,
309
+ durationMs: finishedMs - startedMs,
310
+ ...cost,
311
+ });
312
+ out(` → ${status} · ${formatDuration(finishedMs - startedMs)}${cost.fiveHourPct !== null ? ` · used ${cost.fiveHourPct}% of the 5h window` : ''} · log ${logPath}`);
224
313
  return card.id;
225
314
  }
package/dist/board.js CHANGED
@@ -87,16 +87,46 @@ export function dropCard(board, id, now) {
87
87
  appendJsonl(homePath('archive.jsonl'), { ...card, droppedAt: now.toISOString() });
88
88
  return card;
89
89
  }
90
+ /**
91
+ * Suggested cards (Chompyy's ideas, not yours) that sat untouched for `days` are archived, so the column
92
+ * doesn't fill with stale guesses. Your own parked ideas never expire. Returns the archived cards.
93
+ */
94
+ export function expireSuggested(board, now, days) {
95
+ if (days <= 0)
96
+ return [];
97
+ const cutoff = now.getTime() - days * 24 * 3600_000;
98
+ const stale = board.cards.filter((c) => c.column === 'suggested' && Date.parse(c.updatedAt) < cutoff && !c.draftingAt && !c.drawingAt);
99
+ for (const c of stale)
100
+ appendJsonl(homePath('archive.jsonl'), { ...c, droppedAt: now.toISOString(), expired: true });
101
+ board.cards = board.cards.filter((c) => !stale.includes(c));
102
+ return stale;
103
+ }
90
104
  export function cardsIn(board, column) {
91
105
  return board.cards.filter((c) => c.column === column);
92
106
  }
93
107
  /** Approved cards in the order they were approved: the away queue. */
94
- /** Cards stuck in running (the away run was stopped or crashed) go back to approved. Returns their ids. */
95
- export function recoverRunning(board, now) {
108
+ /**
109
+ * Cards stuck in running whose away run is gone (it crashed or was stopped) go to review as an error, with
110
+ * whatever they finished: put back in approved they would look untouched, and a card that crashes Chompyy
111
+ * would crash every away. `where` says where a card's work is. Returns their ids.
112
+ */
113
+ export function recoverRunning(board, now, where = () => ({ dir: '' }), why = 'The away run stopped in the middle of this card (Chompyy crashed or was stopped), so it never finished.') {
96
114
  const stuck = cardsIn(board, 'running');
97
115
  for (const c of stuck) {
98
- c.column = 'approved';
116
+ const ws = where(c);
117
+ const startedAt = c.updatedAt || now.toISOString();
118
+ c.column = 'review';
99
119
  c.updatedAt = now.toISOString();
120
+ c.run = {
121
+ status: 'error',
122
+ startedAt,
123
+ finishedAt: now.toISOString(),
124
+ durationMs: Math.max(0, now.getTime() - Date.parse(startedAt)) || 0,
125
+ exitCode: null,
126
+ workdir: ws.dir,
127
+ ...(ws.branch ? { branch: ws.branch } : {}),
128
+ summary: `${why} Anything it committed is on its branch; Run again to retry.`,
129
+ };
100
130
  }
101
131
  return stuck.map((c) => c.id);
102
132
  }
@@ -0,0 +1,23 @@
1
+ // The one change Chompyy offers to make to Claude Code's own settings: keep transcripts longer
2
+ // (`cleanupPeriodDays`, default 30), so there's more history to learn from. Only on request.
3
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
4
+ import { homedir } from 'node:os';
5
+ import { dirname, join } from 'node:path';
6
+ export function keepHistory(days, path = join(homedir(), '.claude', 'settings.json')) {
7
+ let settings = {};
8
+ if (existsSync(path)) {
9
+ const raw = readFileSync(path, 'utf8');
10
+ try {
11
+ settings = JSON.parse(raw);
12
+ }
13
+ catch {
14
+ throw new Error(`${path} isn't valid JSON, so I left it alone. Add "cleanupPeriodDays": ${days} yourself.`);
15
+ }
16
+ writeFileSync(`${path}.chompyy-backup`, raw);
17
+ }
18
+ const before = typeof settings.cleanupPeriodDays === 'number' ? settings.cleanupPeriodDays : null;
19
+ settings.cleanupPeriodDays = days;
20
+ mkdirSync(dirname(path), { recursive: true });
21
+ writeFileSync(path, JSON.stringify(settings, null, 2) + '\n');
22
+ return { path, before };
23
+ }