chompyy 0.4.6 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # chompyy (CLI)
2
2
 
3
- Uses the capacity in Claude Code's 5-hour window that would otherwise reset unused. You park ideas as cards, each card gets a short **blueprint** (the scope agreed before it runs), approved cards run headless while you're away, and a report shows what ran so you can rate it.
3
+ Uses the capacity in Claude Code's 5-hour window that would otherwise reset unused. You park ideas as cards, each card gets a short **blueprint** (the scope agreed before it runs), approved cards run headless while you're away, and a report shows what ran so you can rate it, keep it and send it to GitHub.
4
4
 
5
- This is the MVP from [the spec](../research/spec-token-utilization.md) §10, CLI only. Node 20+, no runtime dependencies.
5
+ This is the engine behind the [Mac app](../mac/README.md): everything the app does is a `chompyy` command, so it all works from Terminal too. Node 20+, no runtime dependencies. Design: [the spec](../research/spec-token-utilization.md).
6
6
 
7
7
  ## Install
8
8
 
@@ -42,20 +42,22 @@ By default Chompyy reads live quota with Claude Code's saved login (macOS Keycha
42
42
 
43
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
44
 
45
- ## Set up the quota snapshot (fallback)
45
+ ## The status line: cache timer and quota
46
46
 
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`:
47
+ ```bash
48
+ chompyy statusline on # off gives your old status line back
49
+ ```
50
+
51
+ Claude Code's status line then shows when the conversation's cache goes cold, and once it has, what your next message rewrites:
48
52
 
49
- ```json
50
- {
51
- "statusLine": {
52
- "type": "command",
53
- "command": "chompyy statusline"
54
- }
55
- }
56
53
  ```
54
+ 🍪 5h 62% left · 1h40m · ~43% unused at 20:55 | 7d 41% used | cache warm till 19:46
55
+ 🍪 /compact first: cache cold, next message rewrites 242k | 5h 62% left · 1h40m | 7d 41% used
56
+ ```
57
+
58
+ The cache part needs Claude Code 2.1.251+, and shows only for conversations of 40k+ tokens (not right after a compaction). Claude Code re-runs the status line the moment the cache expires, so the clock time stays true. A status line you already had keeps running: Chompyy runs it on the same input and prints its line above Chompyy's. `on` backs up `~/.claude/settings.json` first.
57
59
 
58
- Each status line refresh writes `~/.chompyy/quota.json` and shows one line:
60
+ The same command also reads quota, never by sending a message (if no window is active, the first message would start a new 5-hour window). Each status line refresh writes `~/.chompyy/quota.json`:
59
61
 
60
62
  ```
61
63
  🍪 5h 62% left · 1h40m · ~37%/h | 7d 41% used
@@ -63,8 +65,6 @@ Each status line refresh writes `~/.chompyy/quota.json` and shows one line:
63
65
 
64
66
  That reads: 62% of the 5h window left, it resets in 1h40m, so about 37% per hour is available until then; 41% of the weekly limit is used. `rate_limits` only appears after the first reply of a session; until then the last snapshot is kept. Once the window's `resets_at` has passed, the snapshot is stale and Chompyy treats the window as unknown.
65
67
 
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.
67
-
68
68
  ## Get to know you (cold start)
69
69
 
70
70
  ```bash
@@ -106,7 +106,8 @@ Each card in a git repo runs in its own worktree at `~/.chompyy/worktrees/<id>`
106
106
 
107
107
  | Command | What it does |
108
108
  |---|---|
109
- | `chompyy statusline` | Status line hook: reads Claude Code's JSON on stdin, saves the snapshot, prints one line |
109
+ | `chompyy statusline` | Status line hook: reads Claude Code's JSON on stdin, saves the snapshot, prints one line with the cache timer |
110
+ | `chompyy statusline on\|off` | Makes it Claude Code's status line, keeping the one you had running above it; off gives yours back |
110
111
  | `chompyy status` | % left in the 5h window, time to reset, weekly used, pace delta, forecast, today's allowance, per-model weekly windows |
111
112
  | `chompyy eat-tokens` | Read-only view of remaining 5h quota and approved/later cards; starts nothing |
112
113
  | `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). The card starts titled with the idea's first 60 characters; with the blueprint the same model writes a title of 10 words or fewer (one extra short call, no tools). If that call fails, the first title stays |
@@ -115,28 +116,51 @@ Each card in a git repo runs in its own worktree at `~/.chompyy/worktrees/<id>`
115
116
  | `chompyy blueprint <id> [--model m]` | Draft (or redraft) the blueprint with a cheap model |
116
117
  | `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) |
117
118
  | `chompyy edit-idea <id>` | Replace a *later* card's idea (and its title) with text from stdin, e.g. `echo "new idea" \| chompyy edit-idea 3`. The blueprint stays; redraft it with `blueprint <id>` |
118
- | `chompyy approve <id>` / `drop <id>` | Queue a card for away runs / remove it (kept in `archive.jsonl`) |
119
+ | `chompyy edit-blueprint <id>` | Replace a card's blueprint with text from stdin |
120
+ | `chompyy approve <id>` / `chompyy drop <id>` | Queue a card for away runs / remove it (kept in `archive.jsonl`) |
121
+ | `chompyy answer <id> ["answers"]` | Answer a card's questions (as words, or on stdin); it goes back to *approved* and the next away run continues it |
122
+ | `chompyy suggest [repo] [--force]` | A few tasks for a repo, from its goals and its code, added as suggested cards (one model call, only inside an active window) |
119
123
  | `chompyy away <1h\|30m\|1h30m> [--dry-run] [--force]` | Run approved cards until the time is up or the gate closes |
120
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` |
121
125
  | `chompyy diff <id>` | The change the card made on its branch |
122
126
  | `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 |
123
- | `chompyy undo <id>` | Throw the run away: remove its worktree and branch (or draft folder). Your own branches are never touched |
127
+ | `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
+ | `chompyy redo <id>` | Throw a ran card's result away and put it back in *approved*; it runs again from your latest code |
129
+ | `chompyy continue <id> ["what is still missing"]` | Put a ran card back in *approved* as its next cycle; the next run gets what the last one did, plus your note |
130
+ | `chompyy refresh [<id>]` | Bring a card that clashes with your newer main up to date and check it again (no id: every clashing card). Waits for quota when there is none |
131
+ | `chompyy send [--json]` | Open one pull request on GitHub per kept card your main has and GitHub's doesn't, from `chompyy/card-<id>` with just that card's commits (needs `gh`). Main itself is never pushed. Run it again after merging: once every card is on GitHub, your main moves to match GitHub's (only when that loses nothing; unsaved work is kept) |
124
132
  | `chompyy rate <id> <1-5> ["why"]` | Rate a result against its blueprint; moves it to *done* and logs a signal |
133
+ | `chompyy signals [--json]` | Every signal so far (ratings, edits, cold start picks), oldest first |
125
134
  | `chompyy taste` | Show `taste.md` |
126
135
  | `chompyy taste list` / `why <id>` | Every learned preference and its status / the cards, edits and quotes behind one |
127
136
  | `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 |
128
137
  | `chompyy taste retire <id>` | Stop using a preference; it stays in `taste list` with the reason |
138
+ | `chompyy taste daytime [on\|off]` | Your rules in every Claude Code session too: one import line in `~/.claude/CLAUDE.md` loads `~/.chompyy/taste-for-claude.md`, which Chompyy keeps up to date. Off takes the line out |
139
+ | `chompyy dream [--dry-run] [--force] [--since 7d]` | The nightly read: learn taste from your recent Claude Code sessions in ticked folders now. Runs on its own at bedtime when on |
140
+ | `chompyy dream workspaces` / `tick <folder>` / `untick <folder>` / `on\|off` | Which folders the nightly read may learn from; turn it on or off |
129
141
  | `chompyy distill [--force]` | Read new signals and update preferences now (also runs after every away run) |
130
- | `chompyy trends` | Last 7 days vs the 7 before: cost per card, keep rate, rating, blueprint edits |
142
+ | `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 |
131
143
  | `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 |
132
144
  | `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 |
133
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 |
134
146
  | `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
+ | `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 |
135
148
  | `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 |
136
149
  | `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 |
137
150
  | `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 |
138
151
  | `chompyy triggers on\|off` | Install or remove the macOS LaunchAgent that runs `chompyy tick` every 5 minutes |
139
- | `chompyy bedtime <23:30\|off>` / `last-hour <on\|off>` / `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 |
152
+ | `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
+ | `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
+ | `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 |
155
+ | `chompyy trace <conversation id> [--json]` | Where one conversation's tokens went (ids: `chompyy usage --json`) |
156
+ | `chompyy tokens [--json]` | Exact tokens and API-price cost of each away run (last 20) |
157
+ | `chompyy plan-price <dollars\|auto>` | Your plan's monthly price, for the plan-vs-API comparison in `usage` |
158
+ | `chompyy history [--digest] [--json]` | What cold start would read: sessions, projects, dates. Local; sends nothing |
159
+ | `chompyy coldstart [show\|accept\|forget] [--force]` | One model call that proposes taste lines and suggested cards from your history; `accept --taste t1 --cards c1` keeps the ones you pick |
160
+ | `chompyy keep-history <days>` | How long Claude Code keeps transcripts (default 30 days) |
161
+ | `chompyy projects [--json]` | Recent project folders, for picking where a card runs |
162
+ | `chompyy app` | macOS: download and open the menu bar app |
163
+ | `chompyy version` / `chompyy help` | The CLI's version / the command list |
140
164
 
141
165
  ## Taste
142
166
 
package/dist/advice.js CHANGED
@@ -214,10 +214,11 @@ export function approveAdvice(c, now) {
214
214
  a.note = 'Applies once no Claude Code session has run for 10 minutes.';
215
215
  return `✅ #${c.id} approved. Applies once no Claude Code session has run for 10 minutes.`;
216
216
  }
217
+ // Nothing for Chompyy to apply or run: the card closes at once, so it leaves the board.
217
218
  c.column = 'done';
218
219
  a.since = at;
219
220
  a.state = a.lane === 'habit' ? 'trying' : 'done';
220
- return a.lane === 'habit' ? `✅ #${c.id}: trying it from today. ${a.check}` : `✅ #${c.id} done. ${a.check}`;
221
+ return a.lane === 'habit' ? `✅ #${c.id} closed: trying it from today. ${a.check}` : `✅ #${c.id} closed. ${a.check}`;
221
222
  }
222
223
  /** When a Claude Code session last wrote its transcript (ms), so settings never change under an open conversation. */
223
224
  export function lastSessionActivity(root = projectsDir()) {
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 { daytimeState } from './daytime.js';
3
4
  import { execFileSync } from 'node:child_process';
4
5
  import { readFileSync, existsSync } from 'node:fs';
5
6
  import { clashOf } from './refresh.js';
@@ -15,6 +16,7 @@ import { loadColdStart } from './coldstart.js';
15
16
  import { blueprintHash } from './picture.js';
16
17
  import { costRange, readRuns } from './costs.js';
17
18
  import { cachedWorkspaces, loadDream } from './dream.js';
19
+ import { learning } from './learning.js';
18
20
  import { describeSignal, loadStore, nextQuestion, readSignals, receipts } from './taste.js';
19
21
  import { agentInstalled, loadTriggerState } from './triggers.js';
20
22
  import { planFor } from './permissions.js';
@@ -22,6 +24,7 @@ import { loadProfile, preflightHosts } from './preflight.js';
22
24
  import { gitRoot } from './workspace.js';
23
25
  import { writeBlueprintFile } from './blueprint.js';
24
26
  import { outboxes } from './send.js';
27
+ import { exe } from './exe.js';
25
28
  export function cardView(card, runs = readRuns()) {
26
29
  const qPath = card.run ? join(card.run.workdir, 'QUESTIONS.md') : '';
27
30
  return {
@@ -49,7 +52,7 @@ function permissionPlanFor(card) {
49
52
  /** The branch a folder is on (what Keep merges into), or null. */
50
53
  export function currentBranch(cwd) {
51
54
  try {
52
- return execFileSync('git', ['-C', cwd, 'rev-parse', '--abbrev-ref', 'HEAD'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || null;
55
+ return execFileSync(exe('git'), ['-C', cwd, 'rev-parse', '--abbrev-ref', 'HEAD'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || null;
53
56
  }
54
57
  catch {
55
58
  return null;
@@ -105,7 +108,7 @@ export function tasteQuestion() {
105
108
  * For "What Chompyy heard from you": the rules waiting for your yes (strongest evidence first) and the ones in
106
109
  * force. The app shows the waiting count as a badge on the button.
107
110
  */
108
- export function tasteState() {
111
+ export function tasteState(now = new Date()) {
109
112
  const signals = readSignals();
110
113
  const byId = new Map(signals.map((s) => [s.id, s]));
111
114
  const store = loadStore();
@@ -122,7 +125,12 @@ export function tasteState() {
122
125
  waiting.push(q);
123
126
  rest.prefs = rest.prefs.filter((p) => p.id !== q.id);
124
127
  }
125
- return { waiting: waiting.map(item), learned: store.prefs.filter((p) => p.status === 'active').map(item) };
128
+ return {
129
+ waiting: waiting.map(item),
130
+ learned: store.prefs.filter((p) => p.status === 'active').map(item),
131
+ daytime: daytimeState().on,
132
+ learning: learning(store, signals, loadDream().readThrough ?? {}, waiting.length, now),
133
+ };
126
134
  }
127
135
  /** Whether the app should offer the cold start: never run, proposals waiting, or done. */
128
136
  export function coldStartState() {
package/dist/board.js CHANGED
@@ -143,6 +143,7 @@ export function continueCard(board, id, note, now, prior = {}) {
143
143
  // The new cycle starts clean: these belonged to the run that just ended (and are kept in the Cycle).
144
144
  delete card.run;
145
145
  delete card.outcome;
146
+ delete card.unkept;
146
147
  delete card.rating;
147
148
  delete card.answers;
148
149
  delete card.fiveStarOptions;
@@ -157,6 +158,10 @@ export function dropCard(board, id, now) {
157
158
  throw new Error(`Card #${card.id} is running; wait for the run to finish.`);
158
159
  board.cards = board.cards.filter((c) => c !== card);
159
160
  appendJsonl(homePath('archive.jsonl'), { ...card, droppedAt: now.toISOString() });
161
+ // Dropping advice you never approved is a "no, never": taste reads it as evidence (taste.ts 'advice-declined').
162
+ if (card.advice && (card.column === 'suggested' || card.column === 'later')) {
163
+ appendJsonl(homePath('signals.jsonl'), { at: now.toISOString(), card: card.id, title: card.title, kind: 'advice-declined', key: card.advice.key, rule: card.advice.rule, lane: card.advice.lane });
164
+ }
160
165
  return card;
161
166
  }
162
167
  /**
@@ -337,6 +342,8 @@ export function formatCard(c) {
337
342
  lines.push(`log: ${c.logPath}`);
338
343
  if (c.outcome)
339
344
  lines.push(`outcome: ${c.outcome}`);
345
+ if (c.unkept)
346
+ lines.push(`undone after keep: ${c.unkept.how === 'revert-pr' ? `revert PR #${c.unkept.pr?.number ?? '?'}` : c.unkept.how === 'dropped' ? 'branch moved back' : 'Undo commit'}${c.unkept.closed ? `, PR #${c.unkept.closed} closed` : ''}`);
340
347
  if (c.rating)
341
348
  lines.push(`rating: ${c.rating.score}/5${c.rating.reason ? ` · ${c.rating.reason}` : ''}`);
342
349
  return lines.join('\n');
package/dist/cli.js CHANGED
@@ -3,7 +3,7 @@
3
3
  import { execFileSync, spawn } from 'node:child_process';
4
4
  import { backfillTokens, median } from './tokenstore.js';
5
5
  import { compact, formatTokens, totalTokens } from './tokens.js';
6
- import { closeSync, existsSync, openSync, readFileSync } from 'node:fs';
6
+ import { closeSync, existsSync, openSync, readFileSync, writeFileSync } from 'node:fs';
7
7
  import { resolve } from 'node:path';
8
8
  import { parseArgs } from 'node:util';
9
9
  import { away, runCard } from './away.js';
@@ -16,13 +16,13 @@ import { loadConfig, setConfig } from './config.js';
16
16
  import { formatDuration, parseDuration } from './duration.js';
17
17
  import { budgetGate } from './gate.js';
18
18
  import { chompyyHome, homePath } from './home.js';
19
- import { loadSnapshot, mergeSnapshot, parseStatusline, saveSnapshot, statusLineText, statusText as baseStatusText, windowView } from './quota.js';
19
+ import { loadSnapshot, saveSnapshot, statuslineSnapshot, statusLineText, statusText as baseStatusText, windowView } from './quota.js';
20
20
  import { loadSamples } from './pacing.js';
21
- import { cardsSince, formatReport, lastReportAt, markReported, morningLine, rateCard, readTaste } from './report.js';
21
+ import { cardsSince, formatReport, lastReportAt, markReported, morningLine, rateCard, readTaste, tasteCountLine } from './report.js';
22
22
  import { approvedText, changedFiles, diffCard, keepCard, overlaps, questionsOf, undoCard } from './review.js';
23
23
  import { CappedText, ClaudeRunner, claudeAvailable } from './runner.js';
24
24
  import { branchOf, commitLeftovers, gitRoot, planWorkspace, prepareWorkspace } from './workspace.js';
25
- import { answerCard, appState, cardView, currentBranch, editBlueprint, editIdea, recordCliLocation } from './appstate.js';
25
+ import { answerCard, appState, cardView, currentBranch, editBlueprint, editIdea, recordCliLocation, tasteState } from './appstate.js';
26
26
  import { detect, detectText } from './detect.js';
27
27
  import { allWindowEnds, archiveWindowEnds, premise, premiseText } from './premise.js';
28
28
  import { keychainAllowed, loadLiveState, refreshLiveQuota } from './livequota.js';
@@ -33,24 +33,29 @@ import { acceptColdStart, forgetColdStart, formatColdStart, loadColdStart, runCo
33
33
  import { keepHistory } from './claudesettings.js';
34
34
  import { blueprintHash, drawPicture } from './picture.js';
35
35
  import { costRange, formatCostRange, readRuns, tasteEffect, tasteEffectLine, trendLines } from './costs.js';
36
- import { answerPreference, distill, distillDue, formatPrefs, formatQuestion, formatWhy, getPref, loadStore, nextQuestion, readSignals, recordOutcome, retirePreference, syncTasteFile, tasteChangesSince, } from './taste.js';
36
+ import { answerPreference, distill, distillDue, formatPrefs, formatQuestion, formatWhy, getPref, learnedCount, loadStore, nextQuestion, readSignals, recordOutcome, renderAgentsBlock, retirePreference, syncTasteFile, tasteChangesSince, tasteRulesForProject, } from './taste.js';
37
37
  import { cachedWorkspaces, dream, dreamDue, formatDream, formatWorkspaces, projectsDir, readLogPath, setTicked } from './dream.js';
38
38
  import { byKind, compare, formatExtras, formatUsage, loadLedger, periodDays, PERIODS, prCosts, usageView } from './usage.js';
39
39
  import { formatTrace, traceSession } from './trace.js';
40
40
  import { homedir } from 'node:os';
41
41
  import { clashOf, refreshCard, refreshGate, refreshClashing, withRefreshLock } from './refresh.js';
42
42
  import { adviseText, applyDue, approveAdvice, runAdvise, undoAdvice } from './advice.js';
43
- import { checkWorked, nudgeProof, nudgeProofText, shareText, workedText } from './didwork.js';
43
+ import { daytimeFile, daytimeState, setDaytime } from './daytime.js';
44
+ import { checkWorked, nudgeProofText, savedSoFar, shareText, workedText } from './didwork.js';
44
45
  import { addSuggested, suggestTasks, suggestText } from './suggest.js';
45
46
  import { coldWarningText, hookCommand, impact, loadNudges, nudgeInstalled, nudgeText, runHook, setNudge, setProjectMode, takeGoingCold } from './nudge.js';
46
47
  import { withKeepLock } from './keeplock.js';
47
48
  import { sendKept } from './send.js';
49
+ import { planUnkeep, unkeep } from './unkeep.js';
50
+ import { cacheText, composeLine, setStatusline, statuslineInstalled, statusLineOutput, wrappedCommand } from './statusline.js';
48
51
  import { formatLive, keepAffectsLive, liveOff, liveSet, liveUpdateLocked, loadLive, startLiveUpdate } from './live.js';
49
52
  import { agentInstalled, awayRunning, bedtimeKey, decideTrigger, installAgent, loadTriggerState, markFired, noteTick, parseClock, takeAwayLock, uninstallAgent } from './triggers.js';
53
+ import { exe } from './exe.js';
50
54
  const HELP = `chompyy: use the 5-hour window capacity that would reset unused
51
55
 
52
56
  Quota
53
- chompyy statusline Claude Code statusLine command: reads JSON on stdin, saves a snapshot
57
+ chompyy statusline Claude Code statusLine command: reads JSON on stdin, saves a snapshot, shows the cache timer
58
+ chompyy statusline on|off use it as Claude Code's status line (the one you had keeps running above it)
54
59
  chompyy status % left, time to reset, pace, weekly used, staleness
55
60
  chompyy quota [--refresh] read live quota from Anthropic now (uses Claude Code's saved login; sends no message)
56
61
  chompyy quota --allow-keychain | --no-keychain allow (or stop) reading that login from the macOS Keychain
@@ -93,9 +98,11 @@ Back
93
98
  chompyy report [--all] what ran, and the one thing to do about each
94
99
  chompyy diff <id> the change it made
95
100
  chompyy keep <id> merge its branch into the branch it started from (and update the live app, if set)
96
- chompyy send [--json] open one PR on GitHub with every kept card GitHub's main doesn't have yet
101
+ chompyy send [--json] open one PR on GitHub per kept card GitHub's main doesn't have yet
97
102
  chompyy refresh [<id>] bring cards in review up to date with main (Chompyy does this by itself after each Keep)
98
103
  chompyy undo <id> throw it away (removes its branch; yours are untouched)
104
+ a kept card: takes it back off your branch, or opens a revert PR on GitHub
105
+ (--plan says which, changing nothing; --json for the app)
99
106
  chompyy answer <id> answer the run's questions (stdin); the card goes back to approved
100
107
  chompyy redo <id> throw this attempt away and run it again from your latest code
101
108
  chompyy continue <id> ["note"] a done card did only part of the job: run another cycle that builds on it
@@ -119,6 +126,8 @@ Taste (learned from what you keep, undo, edit and rate)
119
126
  chompyy taste why <id> the cards, edits and quotes behind a preference
120
127
  chompyy taste yes|not-now|never <id> answer a question (yes writes it to taste.md)
121
128
  chompyy taste retire <id> stop using a preference (kept, with the reason)
129
+ chompyy taste agents <project> <file> copy Everywhere + <project> rules into a marked block in an AGENTS.md
130
+ chompyy taste daytime on|off your rules in every Claude Code session too (one import line in ~/.claude/CLAUDE.md)
122
131
  chompyy distill [--force] read new signals and update preferences now (one model call; runs after away too)
123
132
 
124
133
  Triggers (start away runs on their own; the budget gate still decides every card)
@@ -406,7 +415,7 @@ function awayDeps(config, freshQuota) {
406
415
  const cacheDir = homePath('cache', 'tools');
407
416
  if (!root || ws.kind !== 'worktree')
408
417
  return undefined;
409
- const baseCommit = ws.base?.commit ?? execFileSync('git', ['-C', root, 'merge-base', 'HEAD', ws.branch], { encoding: 'utf8' }).trim();
418
+ const baseCommit = ws.base?.commit ?? execFileSync(exe('git'), ['-C', root, 'merge-base', 'HEAD', ws.branch], { encoding: 'utf8' }).trim();
410
419
  return verifyCard({ root, dir: ws.dir, baseCommit, cacheDir, denyRead: config.denyReadPaths, timeoutMs: config.checkTimeoutMin * 60_000, now: () => new Date() });
411
420
  },
412
421
  }
@@ -486,6 +495,7 @@ async function main(argv) {
486
495
  column: { type: 'string', multiple: true },
487
496
  help: { type: 'boolean', short: 'h' },
488
497
  json: { type: 'boolean' },
498
+ plan: { type: 'boolean' },
489
499
  refresh: { type: 'boolean' },
490
500
  'allow-keychain': { type: 'boolean' },
491
501
  'no-keychain': { type: 'boolean' },
@@ -523,16 +533,27 @@ async function main(argv) {
523
533
  };
524
534
  switch (command) {
525
535
  case 'statusline': {
536
+ const sub = args[0];
537
+ if (sub === 'on' || sub === 'off')
538
+ return console.log(setStatusline(sub === 'on'));
539
+ if (process.stdin.isTTY)
540
+ return console.log(statuslineInstalled() ? 'Cache timer on in Claude Code\'s status line. Turn it off: chompyy statusline off' : 'Show the cache timer in Claude Code\'s status line: chompyy statusline on');
526
541
  // Must never fail loudly: it runs on every status bar refresh.
542
+ let stdin = '';
543
+ let ours = '🍪';
527
544
  try {
528
- const parsed = parseStatusline(await readStdin(), now);
529
- const snap = mergeSnapshot(loadSnapshot(), { ...parsed, ...(parsed.fiveHour || parsed.sevenDay ? { source: 'statusline' } : {}) });
530
- saveSnapshot(snap);
531
- console.log(statusLineText(snap, now, { samples: loadSamples(), color: true }));
545
+ stdin = await readStdin();
546
+ const prev = loadSnapshot();
547
+ const fresh = statuslineSnapshot(stdin, now, prev);
548
+ if (fresh)
549
+ saveSnapshot(fresh);
550
+ const snap = fresh ?? prev ?? { capturedAt: now.toISOString() };
551
+ ours = composeLine(statusLineText(snap, now, { samples: loadSamples(), color: true }), cacheText(stdin, now), true);
532
552
  }
533
553
  catch {
534
- console.log('🍪');
554
+ /* the cookie alone */
535
555
  }
556
+ console.log(statusLineOutput(ours, wrappedCommand(), stdin));
536
557
  return;
537
558
  }
538
559
  case 'status': {
@@ -1170,7 +1191,7 @@ async function main(argv) {
1170
1191
  case 'worked': {
1171
1192
  // The detective, step 5: each applied/tried advice card against the check it registered (didwork.ts).
1172
1193
  const cards = updateBoard((b) => checkWorked(b, now));
1173
- const proof = nudgeInstalled() || loadNudges().length ? nudgeProof(now) : null;
1194
+ const { proof, total } = savedSoFar(cards, now, { on: nudgeInstalled() || loadNudges().length > 0 });
1174
1195
  if (values.share) {
1175
1196
  // A summary to paste on the tester issue: counts, tokens and dates; no project, skill or file names.
1176
1197
  const text = shareText(cards, proof, { version: cliVersion(), now });
@@ -1179,10 +1200,11 @@ async function main(argv) {
1179
1200
  return console.log(`${text}\n\nNo project, skill or file names in it. Copy it: chompyy worked --share | pbcopy`);
1180
1201
  }
1181
1202
  if (values.json)
1182
- return json({ cards: cards.map((c) => ({ id: c.id, title: c.title, rule: c.advice.rule, lane: c.advice.lane, ...c.advice.result })), nudge: proof });
1203
+ return json({ cards: cards.map((c) => ({ id: c.id, title: c.title, rule: c.advice.rule, lane: c.advice.lane, ...c.advice.result })), nudge: proof, total });
1204
+ const sum = total ? ['', total.line] : [];
1183
1205
  if (!cards.length && proof)
1184
- return console.log(nudgeProofText(proof).join('\n'));
1185
- return console.log([workedText(cards, { all: Boolean(values.all) }), ...(proof ? ['', ...nudgeProofText(proof)] : [])].join('\n'));
1206
+ return console.log([...nudgeProofText(proof), ...sum].join('\n'));
1207
+ return console.log([workedText(cards, { all: Boolean(values.all) }), ...(proof ? ['', ...nudgeProofText(proof)] : []), ...sum].join('\n'));
1186
1208
  }
1187
1209
  case 'suggest': {
1188
1210
  // A few tasks for a repo, from what it wants to become and what its code shows: suggested cards to approve.
@@ -1231,9 +1253,10 @@ async function main(argv) {
1231
1253
  }
1232
1254
  if (values.json) {
1233
1255
  // The menu panel: the trend line, plus did the nudge work (its verdict, from the day it was turned on).
1256
+ // Plus the running total: what was counted (stops, re-counted fixes), from the results `worked` last wrote.
1234
1257
  const i = impact();
1235
- const p = i.on ? nudgeProof(now) : null;
1236
- return json({ ...i, ...(p ? { verdict: { verdict: p.result.verdict, line: p.result.line, dueAt: p.result.dueAt } } : {}) });
1258
+ const { proof: p, total } = savedSoFar(loadBoard().cards, now, { on: i.on });
1259
+ return json({ ...i, ...(p ? { verdict: { verdict: p.result.verdict, line: p.result.line, dueAt: p.result.dueAt } } : {}), ...(total ? { total: { tokens: total.tokens, line: total.line } } : {}) });
1237
1260
  }
1238
1261
  return console.log([nudgeText(nudgeInstalled()), impact().line].join('\n'));
1239
1262
  }
@@ -1252,6 +1275,7 @@ async function main(argv) {
1252
1275
  const lines = trendLines(runs, signals, now);
1253
1276
  console.log(lines.length ? lines.join('\n') : 'Not enough runs yet for trends (needs 3).');
1254
1277
  console.log(tasteEffectLine(tasteEffect(runs, signals)));
1278
+ console.log(tasteState(now).learning.line);
1255
1279
  return;
1256
1280
  }
1257
1281
  case 'report': {
@@ -1262,7 +1286,9 @@ async function main(argv) {
1262
1286
  const signals = readSignals();
1263
1287
  const morning = morningLine(cards, tasteChangesSince(store, since));
1264
1288
  const question = nextQuestion(store, signals);
1265
- const footer = [...(question ? formatQuestion(question, signals) : []), ...trendLines(readRuns(), signals, now)];
1289
+ // Footer, not header: the header is dropped when no cards ran, and the count should still show.
1290
+ const tasteCount = tasteCountLine(learnedCount(readTaste().text, now));
1291
+ const footer = [...(tasteCount ? [tasteCount] : []), ...(question ? formatQuestion(question, signals) : []), ...trendLines(readRuns(), signals, now)];
1266
1292
  console.log(formatReport(cards, since, (c) => ({ files: changedFiles(c), questions: questionsOf(c) }), { header: morning ? [morning] : [], footer }));
1267
1293
  markReported(now);
1268
1294
  return;
@@ -1293,9 +1319,9 @@ async function main(argv) {
1293
1319
  return;
1294
1320
  }
1295
1321
  case 'send': {
1296
- // Kept cards live on your local main only; this opens (or updates) one PR with them. Main itself is never pushed.
1322
+ // Kept cards live on your local main only; this opens (or updates) one PR per card. Main itself is never pushed.
1297
1323
  const sent = sendKept(loadBoard().cards);
1298
- console.log(args.includes('--json') ? JSON.stringify(sent) : sent.message);
1324
+ console.log(values.json ? JSON.stringify(sent) : sent.message);
1299
1325
  return;
1300
1326
  }
1301
1327
  case 'refresh': {
@@ -1317,6 +1343,23 @@ async function main(argv) {
1317
1343
  const undone = getCard(loadBoard(), id);
1318
1344
  if (undone.advice && undone.advice.lane !== 'work')
1319
1345
  return console.log(updateBoard((b) => undoAdvice(getCard(b, id), now)));
1346
+ if (undone.outcome === 'kept') {
1347
+ // Undo after Keep: off your branch, or a revert PR on GitHub once it's there (unkeep.ts). It moves the
1348
+ // branch Keep lands on, so it waits in line with Keeps.
1349
+ if (values.plan)
1350
+ return console.log(planUnkeep(undone).line);
1351
+ const r = withKeepLock(() => unkeep(undone));
1352
+ console.log(values.json ? JSON.stringify({ message: r.message, url: r.url }) : r.message);
1353
+ updateBoard((b) => {
1354
+ const card = getCard(b, id);
1355
+ card.outcome = 'undone';
1356
+ card.unkept = { at: now.toISOString(), ...r.unkept };
1357
+ card.updatedAt = now.toISOString();
1358
+ recordOutcome(card, 'undone', now);
1359
+ return card;
1360
+ });
1361
+ return;
1362
+ }
1320
1363
  const files = changedFiles(undone); // read before Undo removes the branch
1321
1364
  console.log(undoCard(undone));
1322
1365
  updateBoard((b) => {
@@ -1345,6 +1388,7 @@ async function main(argv) {
1345
1388
  c.updatedAt = c.approvedAt;
1346
1389
  delete c.run;
1347
1390
  delete c.outcome;
1391
+ delete c.unkept;
1348
1392
  return c;
1349
1393
  });
1350
1394
  console.log(`🔁 #${card.id} back in approved; it runs again from your latest code on the next away run.`);
@@ -1390,8 +1434,35 @@ async function main(argv) {
1390
1434
  const p = retirePreference(need(args[1], 'chompyy taste retire <id>'), now);
1391
1435
  return console.log(`Retired ${p.id}: "${p.text}". It's kept in \`chompyy taste list\` with the reason.`);
1392
1436
  }
1437
+ if (sub === 'agents') {
1438
+ const usage = 'chompyy taste agents <project> <file>';
1439
+ const project = need(args[1], usage);
1440
+ const file = resolve(need(args[2], usage));
1441
+ const rules = tasteRulesForProject(project);
1442
+ if (!rules)
1443
+ throw new Error(`Add a rule under "## Everywhere" or "## ${project}" in taste.md first: no rules to copy. Nothing changed.`);
1444
+ const before = existsSync(file) ? readFileSync(file, 'utf8') : '';
1445
+ const after = renderAgentsBlock(before, rules);
1446
+ if (after === before)
1447
+ return console.log(`Nothing to do: ${file} already has these rules.`);
1448
+ writeFileSync(file, after);
1449
+ const n = rules.split('\n').filter((l) => !l.startsWith('## ') && l.trim()).length;
1450
+ return console.log(`Wrote ${n} rule${n === 1 ? '' : 's'} for ${project} to ${file}. Text outside the chompyy:taste block is unchanged.`);
1451
+ }
1452
+ if (sub === 'daytime') {
1453
+ const how = args[1];
1454
+ if (how === 'on' || how === 'off') {
1455
+ if (how === 'on')
1456
+ syncTasteFile(now);
1457
+ return console.log(setDaytime(how === 'on'));
1458
+ }
1459
+ if (how)
1460
+ throw new Error('Usage: chompyy taste daytime [on|off]');
1461
+ const st = daytimeState();
1462
+ return console.log(st.on ? `On: Claude Code loads your rules from ${daytimeFile()} at every session start. Turn off: chompyy taste daytime off` : 'Off: only away runs use your taste. Turn on: chompyy taste daytime on');
1463
+ }
1393
1464
  if (sub)
1394
- throw new Error('Usage: chompyy taste [list | why <id> | yes|not-now|never <id> | retire <id>]');
1465
+ throw new Error('Usage: chompyy taste [list | why <id> | yes|not-now|never <id> | retire <id> | agents <project> <file> | daytime [on|off]]');
1395
1466
  const { path, text, created } = readTaste();
1396
1467
  if (created)
1397
1468
  console.log(`(created ${path})\n`);
@@ -0,0 +1,68 @@
1
+ // Taste in daytime sessions: the rules you said yes to, in a file Claude Code loads at every session start.
2
+ //
3
+ // Chompyy writes its own file (~/.chompyy/taste-for-claude.md) and adds one import line to your user CLAUDE.md,
4
+ // inside the chompyy:taste markers. After that it only ever rewrites its own file: a yes, a retire or an edit to
5
+ // taste.md shows up in the next session without touching CLAUDE.md again. Off takes the line out and leaves
6
+ // everything else in CLAUDE.md as it was.
7
+ import { existsSync, readFileSync, rmSync, writeFileSync, mkdirSync } from 'node:fs';
8
+ import { homedir } from 'node:os';
9
+ import { dirname, join } from 'node:path';
10
+ import { homePath, readJson, writeJson } from './home.js';
11
+ import { AGENTS_END, AGENTS_START, renderAgentsBlock, tasteForPrompt } from './taste.js';
12
+ export const claudeMdPath = () => join(homedir(), '.claude', 'CLAUDE.md');
13
+ const statePath = () => homePath('daytime.json');
14
+ export const daytimeFile = () => homePath('taste-for-claude.md');
15
+ export const daytimeState = () => readJson(statePath(), { on: false });
16
+ /** `~/…` when under your home folder: the import line reads the same on any Mac. */
17
+ const tilde = (p) => (p.startsWith(`${homedir()}/`) ? `~${p.slice(homedir().length)}` : p);
18
+ const HEADER = '# How I like work done (learned by Chompyy)\n\nFollow these. A section named after a project applies only in that project.';
19
+ /** The text Claude Code loads: your taste.md rules through the same filter as away runs (retired ones left out). */
20
+ export function daytimeText(rules = tasteForPrompt()) {
21
+ return rules ? `${HEADER}\n\n${rules}\n` : `${HEADER}\n\n(No rules yet: say yes to one in Chompyy.)\n`;
22
+ }
23
+ /** Rough size, so turning it on says what it costs at each session start (about 4 characters a token). */
24
+ export const daytimeTokens = (text) => Math.ceil(text.length / 4);
25
+ /** Rewrite Chompyy's own file when it's on. Called after every taste change. */
26
+ export function refreshDaytime() {
27
+ if (!daytimeState().on)
28
+ return;
29
+ const path = daytimeFile();
30
+ const text = daytimeText();
31
+ if (!existsSync(path) || readFileSync(path, 'utf8') !== text)
32
+ writeFileSync(path, text);
33
+ }
34
+ /** CLAUDE.md text with the chompyy:taste block taken out, and the blank line before it. */
35
+ export function removeBlock(text) {
36
+ const start = text.indexOf(AGENTS_START);
37
+ const end = text.indexOf(AGENTS_END);
38
+ if (start < 0 || end < start)
39
+ return text;
40
+ const before = text.slice(0, start).replace(/\n+$/, text.slice(0, start).trim() ? '\n' : '');
41
+ const after = text.slice(end + AGENTS_END.length).replace(/^\n/, '');
42
+ return before + (before && after ? '\n' : '') + after;
43
+ }
44
+ export function setDaytime(on, claudeMd = claudeMdPath()) {
45
+ const before = existsSync(claudeMd) ? readFileSync(claudeMd, 'utf8') : null;
46
+ const shown = tilde(claudeMd);
47
+ if (on) {
48
+ writeJson(statePath(), { on: true, claudeMd });
49
+ const text = daytimeText();
50
+ writeFileSync(daytimeFile(), text);
51
+ const after = renderAgentsBlock(before ?? '', `@${tilde(daytimeFile())}`);
52
+ if (after !== before) {
53
+ if (before !== null)
54
+ writeFileSync(`${claudeMd}.chompyy-backup`, before);
55
+ mkdirSync(dirname(claudeMd), { recursive: true });
56
+ writeFileSync(claudeMd, after);
57
+ }
58
+ return `Taste in everyday sessions on: new Claude Code sessions load your rules (~${daytimeTokens(text)} tokens each start).\nOne import line in ${shown}; nothing else there changed.`;
59
+ }
60
+ writeJson(statePath(), { on: false });
61
+ rmSync(daytimeFile(), { force: true });
62
+ if (before !== null) {
63
+ const after = removeBlock(before);
64
+ if (after !== before)
65
+ writeFileSync(claudeMd, after);
66
+ }
67
+ return `Taste in everyday sessions off: Chompyy's line is out of ${shown}. Away runs still use your taste.`;
68
+ }
package/dist/deps.js CHANGED
@@ -10,6 +10,7 @@ import { createHash } from 'node:crypto';
10
10
  import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync } from 'node:fs';
11
11
  import { join, relative } from 'node:path';
12
12
  import { homePath } from './home.js';
13
+ import { exe } from './exe.js';
13
14
  // The snapshot only has package.json and the lockfile, so the repo's own scripts (e.g. "prepare": "npm run build")
14
15
  // can't run there: install with --ignore-scripts, then rebuild, which runs the dependencies' install steps only.
15
16
  const LOCKFILES = [
@@ -60,7 +61,7 @@ function cloneModules(from, to) {
60
61
  const dst = join(to, 'node_modules');
61
62
  if (existsSync(dst))
62
63
  rmSync(dst, { recursive: true, force: true });
63
- return spawnSync('cp', ['-cR', join(from, 'node_modules'), dst], { stdio: 'ignore', timeout: 180_000 }).status === 0;
64
+ return spawnSync(exe('cp'), ['-cR', join(from, 'node_modules'), dst], { stdio: 'ignore', timeout: 180_000 }).status === 0;
64
65
  }
65
66
  /**
66
67
  * Give every package folder in `worktree` its dependencies, preferring what's already installed. `checkout` is your
@@ -99,7 +100,7 @@ export function setupDependencies(checkout, worktree, repoKey, opts = {}) {
99
100
  copyFileSync(join(dir, lock.file), join(snap, lock.file));
100
101
  const ok = opts.install
101
102
  ? opts.install(lock.install, snap)
102
- : lock.install.every((argv) => spawnSync(argv[0], argv.slice(1), { cwd: snap, stdio: 'ignore', timeout: opts.timeoutMs ?? 300_000, env: { ...process.env, ...opts.env } }).status === 0);
103
+ : lock.install.every((argv) => spawnSync(exe(argv[0]), argv.slice(1), { cwd: snap, stdio: 'ignore', timeout: opts.timeoutMs ?? 300_000, env: { ...process.env, ...opts.env } }).status === 0);
103
104
  if (!ok || !hasModules(snap)) {
104
105
  rmSync(join(snap, 'node_modules'), { recursive: true, force: true });
105
106
  // Better something than nothing: your checkout's packages, flagged as a mismatch.