chompyy 0.4.6 → 0.4.7
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 +14 -13
- package/dist/appstate.js +2 -1
- package/dist/board.js +4 -0
- package/dist/cli.js +29 -13
- package/dist/deps.js +3 -2
- package/dist/dream.js +2 -1
- package/dist/exe.js +34 -0
- package/dist/live.js +4 -3
- package/dist/livequota.js +2 -1
- package/dist/macapp.js +2 -1
- package/dist/nudge.js +9 -5
- package/dist/picture.js +2 -1
- package/dist/preflight.js +2 -1
- package/dist/quota.js +10 -0
- package/dist/refresh.js +2 -1
- package/dist/report.js +6 -0
- package/dist/review.js +2 -1
- package/dist/runner.js +3 -2
- package/dist/send.js +140 -86
- package/dist/statusline.js +110 -0
- package/dist/suggest.js +3 -2
- package/dist/taste-merge.js +79 -0
- package/dist/taste.js +40 -4
- package/dist/triggers.js +2 -1
- package/dist/verify.js +4 -1
- package/dist/verifycard.js +166 -46
- package/dist/workspace.js +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -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
|
-
##
|
|
45
|
+
## The status line: cache timer and quota
|
|
46
46
|
|
|
47
|
-
|
|
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
|
|
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 |
|
package/dist/appstate.js
CHANGED
|
@@ -22,6 +22,7 @@ import { loadProfile, preflightHosts } from './preflight.js';
|
|
|
22
22
|
import { gitRoot } from './workspace.js';
|
|
23
23
|
import { writeBlueprintFile } from './blueprint.js';
|
|
24
24
|
import { outboxes } from './send.js';
|
|
25
|
+
import { exe } from './exe.js';
|
|
25
26
|
export function cardView(card, runs = readRuns()) {
|
|
26
27
|
const qPath = card.run ? join(card.run.workdir, 'QUESTIONS.md') : '';
|
|
27
28
|
return {
|
|
@@ -49,7 +50,7 @@ function permissionPlanFor(card) {
|
|
|
49
50
|
/** The branch a folder is on (what Keep merges into), or null. */
|
|
50
51
|
export function currentBranch(cwd) {
|
|
51
52
|
try {
|
|
52
|
-
return execFileSync('git', ['-C', cwd, 'rev-parse', '--abbrev-ref', 'HEAD'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || null;
|
|
53
|
+
return execFileSync(exe('git'), ['-C', cwd, 'rev-parse', '--abbrev-ref', 'HEAD'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || null;
|
|
53
54
|
}
|
|
54
55
|
catch {
|
|
55
56
|
return null;
|
package/dist/board.js
CHANGED
|
@@ -157,6 +157,10 @@ export function dropCard(board, id, now) {
|
|
|
157
157
|
throw new Error(`Card #${card.id} is running; wait for the run to finish.`);
|
|
158
158
|
board.cards = board.cards.filter((c) => c !== card);
|
|
159
159
|
appendJsonl(homePath('archive.jsonl'), { ...card, droppedAt: now.toISOString() });
|
|
160
|
+
// Dropping advice you never approved is a "no, never": taste reads it as evidence (taste.ts 'advice-declined').
|
|
161
|
+
if (card.advice && (card.column === 'suggested' || card.column === 'later')) {
|
|
162
|
+
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 });
|
|
163
|
+
}
|
|
160
164
|
return card;
|
|
161
165
|
}
|
|
162
166
|
/**
|
package/dist/cli.js
CHANGED
|
@@ -16,9 +16,9 @@ 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,
|
|
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';
|
|
@@ -33,7 +33,7 @@ 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, retirePreference, syncTasteFile, tasteChangesSince, } 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';
|
|
@@ -45,12 +45,15 @@ import { addSuggested, suggestTasks, suggestText } from './suggest.js';
|
|
|
45
45
|
import { coldWarningText, hookCommand, impact, loadNudges, nudgeInstalled, nudgeText, runHook, setNudge, setProjectMode, takeGoingCold } from './nudge.js';
|
|
46
46
|
import { withKeepLock } from './keeplock.js';
|
|
47
47
|
import { sendKept } from './send.js';
|
|
48
|
+
import { cacheText, composeLine, setStatusline, statuslineInstalled, statusLineOutput, wrappedCommand } from './statusline.js';
|
|
48
49
|
import { formatLive, keepAffectsLive, liveOff, liveSet, liveUpdateLocked, loadLive, startLiveUpdate } from './live.js';
|
|
49
50
|
import { agentInstalled, awayRunning, bedtimeKey, decideTrigger, installAgent, loadTriggerState, markFired, noteTick, parseClock, takeAwayLock, uninstallAgent } from './triggers.js';
|
|
51
|
+
import { exe } from './exe.js';
|
|
50
52
|
const HELP = `chompyy: use the 5-hour window capacity that would reset unused
|
|
51
53
|
|
|
52
54
|
Quota
|
|
53
|
-
chompyy statusline Claude Code statusLine command: reads JSON on stdin, saves a snapshot
|
|
55
|
+
chompyy statusline Claude Code statusLine command: reads JSON on stdin, saves a snapshot, shows the cache timer
|
|
56
|
+
chompyy statusline on|off use it as Claude Code's status line (the one you had keeps running above it)
|
|
54
57
|
chompyy status % left, time to reset, pace, weekly used, staleness
|
|
55
58
|
chompyy quota [--refresh] read live quota from Anthropic now (uses Claude Code's saved login; sends no message)
|
|
56
59
|
chompyy quota --allow-keychain | --no-keychain allow (or stop) reading that login from the macOS Keychain
|
|
@@ -93,7 +96,7 @@ Back
|
|
|
93
96
|
chompyy report [--all] what ran, and the one thing to do about each
|
|
94
97
|
chompyy diff <id> the change it made
|
|
95
98
|
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
|
|
99
|
+
chompyy send [--json] open one PR on GitHub per kept card GitHub's main doesn't have yet
|
|
97
100
|
chompyy refresh [<id>] bring cards in review up to date with main (Chompyy does this by itself after each Keep)
|
|
98
101
|
chompyy undo <id> throw it away (removes its branch; yours are untouched)
|
|
99
102
|
chompyy answer <id> answer the run's questions (stdin); the card goes back to approved
|
|
@@ -406,7 +409,7 @@ function awayDeps(config, freshQuota) {
|
|
|
406
409
|
const cacheDir = homePath('cache', 'tools');
|
|
407
410
|
if (!root || ws.kind !== 'worktree')
|
|
408
411
|
return undefined;
|
|
409
|
-
const baseCommit = ws.base?.commit ?? execFileSync('git', ['-C', root, 'merge-base', 'HEAD', ws.branch], { encoding: 'utf8' }).trim();
|
|
412
|
+
const baseCommit = ws.base?.commit ?? execFileSync(exe('git'), ['-C', root, 'merge-base', 'HEAD', ws.branch], { encoding: 'utf8' }).trim();
|
|
410
413
|
return verifyCard({ root, dir: ws.dir, baseCommit, cacheDir, denyRead: config.denyReadPaths, timeoutMs: config.checkTimeoutMin * 60_000, now: () => new Date() });
|
|
411
414
|
},
|
|
412
415
|
}
|
|
@@ -523,16 +526,27 @@ async function main(argv) {
|
|
|
523
526
|
};
|
|
524
527
|
switch (command) {
|
|
525
528
|
case 'statusline': {
|
|
529
|
+
const sub = args[0];
|
|
530
|
+
if (sub === 'on' || sub === 'off')
|
|
531
|
+
return console.log(setStatusline(sub === 'on'));
|
|
532
|
+
if (process.stdin.isTTY)
|
|
533
|
+
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
534
|
// Must never fail loudly: it runs on every status bar refresh.
|
|
535
|
+
let stdin = '';
|
|
536
|
+
let ours = '🍪';
|
|
527
537
|
try {
|
|
528
|
-
|
|
529
|
-
const
|
|
530
|
-
|
|
531
|
-
|
|
538
|
+
stdin = await readStdin();
|
|
539
|
+
const prev = loadSnapshot();
|
|
540
|
+
const fresh = statuslineSnapshot(stdin, now, prev);
|
|
541
|
+
if (fresh)
|
|
542
|
+
saveSnapshot(fresh);
|
|
543
|
+
const snap = fresh ?? prev ?? { capturedAt: now.toISOString() };
|
|
544
|
+
ours = composeLine(statusLineText(snap, now, { samples: loadSamples(), color: true }), cacheText(stdin, now), true);
|
|
532
545
|
}
|
|
533
546
|
catch {
|
|
534
|
-
|
|
547
|
+
/* the cookie alone */
|
|
535
548
|
}
|
|
549
|
+
console.log(statusLineOutput(ours, wrappedCommand(), stdin));
|
|
536
550
|
return;
|
|
537
551
|
}
|
|
538
552
|
case 'status': {
|
|
@@ -1262,7 +1276,9 @@ async function main(argv) {
|
|
|
1262
1276
|
const signals = readSignals();
|
|
1263
1277
|
const morning = morningLine(cards, tasteChangesSince(store, since));
|
|
1264
1278
|
const question = nextQuestion(store, signals);
|
|
1265
|
-
|
|
1279
|
+
// Footer, not header: the header is dropped when no cards ran, and the count should still show.
|
|
1280
|
+
const tasteCount = tasteCountLine(learnedCount(readTaste().text, now));
|
|
1281
|
+
const footer = [...(tasteCount ? [tasteCount] : []), ...(question ? formatQuestion(question, signals) : []), ...trendLines(readRuns(), signals, now)];
|
|
1266
1282
|
console.log(formatReport(cards, since, (c) => ({ files: changedFiles(c), questions: questionsOf(c) }), { header: morning ? [morning] : [], footer }));
|
|
1267
1283
|
markReported(now);
|
|
1268
1284
|
return;
|
|
@@ -1293,7 +1309,7 @@ async function main(argv) {
|
|
|
1293
1309
|
return;
|
|
1294
1310
|
}
|
|
1295
1311
|
case 'send': {
|
|
1296
|
-
// Kept cards live on your local main only; this opens (or updates) one PR
|
|
1312
|
+
// Kept cards live on your local main only; this opens (or updates) one PR per card. Main itself is never pushed.
|
|
1297
1313
|
const sent = sendKept(loadBoard().cards);
|
|
1298
1314
|
console.log(args.includes('--json') ? JSON.stringify(sent) : sent.message);
|
|
1299
1315
|
return;
|
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.
|
package/dist/dream.js
CHANGED
|
@@ -19,6 +19,7 @@ import { execFileSync } from 'node:child_process';
|
|
|
19
19
|
import { appendJsonl, chompyyHome, homePath, readJson, writeJson } from './home.js';
|
|
20
20
|
import { signalsPath } from './taste.js';
|
|
21
21
|
import { addTokens } from './tokens.js';
|
|
22
|
+
import { exe } from './exe.js';
|
|
22
23
|
export const DESKTOP = 'Claude desktop app';
|
|
23
24
|
/** First night: read this far back. */
|
|
24
25
|
export const FIRST_DAYS = 7;
|
|
@@ -65,7 +66,7 @@ function isRepo(dir, cache) {
|
|
|
65
66
|
if (!cache.has(dir)) {
|
|
66
67
|
let ok = false;
|
|
67
68
|
try {
|
|
68
|
-
execFileSync('git', ['-C', dir, 'rev-parse', '--git-dir'], { stdio: 'ignore' });
|
|
69
|
+
execFileSync(exe('git'), ['-C', dir, 'rev-parse', '--git-dir'], { stdio: 'ignore' });
|
|
69
70
|
ok = true;
|
|
70
71
|
}
|
|
71
72
|
catch { }
|
package/dist/exe.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Launch programs by full path (2026-11-30). Given a bare name like "git", Node tries each PATH folder in turn,
|
|
2
|
+
// and on macOS every miss still creates a short-lived process that the system vets as a copy of Node
|
|
3
|
+
// (syspolicyd, about 5 ms each, one at a time). /usr/bin is 15th on a typical PATH, and `npm test` adds more
|
|
4
|
+
// folders in front, so each git call cost about 14 of these. The app's `chompyy state` every 15 s (65 git calls)
|
|
5
|
+
// kept syspolicyd busy 40% of the time: every program launch on the Mac waited, and slow git tests timed out in
|
|
6
|
+
// Chompyy's own check. Looking the name up once here and launching the full path makes no throwaway processes.
|
|
7
|
+
import { accessSync, constants, statSync } from 'node:fs';
|
|
8
|
+
import { delimiter, join } from 'node:path';
|
|
9
|
+
const found = new Map();
|
|
10
|
+
/** The full path of `name`: the first match on PATH, the same one a spawn would run. A path, or a miss, comes back as given. */
|
|
11
|
+
export function exe(name, path = process.env.PATH ?? '') {
|
|
12
|
+
if (!name || name.includes('/'))
|
|
13
|
+
return name;
|
|
14
|
+
const key = `${name}\0${path}`;
|
|
15
|
+
const hit = found.get(key);
|
|
16
|
+
if (hit)
|
|
17
|
+
return hit;
|
|
18
|
+
for (const dir of path.split(delimiter)) {
|
|
19
|
+
if (!dir)
|
|
20
|
+
continue;
|
|
21
|
+
const full = join(dir, name);
|
|
22
|
+
try {
|
|
23
|
+
if (!statSync(full).isFile())
|
|
24
|
+
continue;
|
|
25
|
+
accessSync(full, constants.X_OK);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
found.set(key, full);
|
|
31
|
+
return full;
|
|
32
|
+
}
|
|
33
|
+
return name; // not on PATH: the spawn reports it as before
|
|
34
|
+
}
|
package/dist/live.js
CHANGED
|
@@ -11,10 +11,11 @@ import { closeSync, existsSync, mkdirSync, openSync, readFileSync, rmSync, write
|
|
|
11
11
|
import { homedir } from 'node:os';
|
|
12
12
|
import { basename, dirname, join, resolve } from 'node:path';
|
|
13
13
|
import { chompyyHome, homePath, readJson, writeJson } from './home.js';
|
|
14
|
+
import { exe } from './exe.js';
|
|
14
15
|
export const livePath = () => homePath('live.json');
|
|
15
16
|
export const liveDir = () => join(chompyyHome(), 'live');
|
|
16
17
|
export const loadLive = () => readJson(livePath(), null);
|
|
17
|
-
const git = (cwd, args) => execFileSync('git', ['-C', cwd, ...args], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();
|
|
18
|
+
const git = (cwd, args) => execFileSync(exe('git'), ['-C', cwd, ...args], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();
|
|
18
19
|
/** The repo's shared .git folder: the same for every worktree of one repo. */
|
|
19
20
|
export function commonDir(dir) {
|
|
20
21
|
try {
|
|
@@ -41,12 +42,12 @@ export function planUpdate(live, target, depsHash, appExists, macChanged) {
|
|
|
41
42
|
}
|
|
42
43
|
const defaultDeps = (log) => ({
|
|
43
44
|
run: (cmd, args, cwd) => {
|
|
44
|
-
execFileSync(cmd, args, { cwd, stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: 64 * 1024 * 1024 });
|
|
45
|
+
execFileSync(exe(cmd), args, { cwd, stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: 64 * 1024 * 1024 });
|
|
45
46
|
},
|
|
46
47
|
log,
|
|
47
48
|
appRunning: () => {
|
|
48
49
|
try {
|
|
49
|
-
execFileSync('pgrep', ['-x', 'Chompyy'], { stdio: 'ignore' });
|
|
50
|
+
execFileSync(exe('pgrep'), ['-x', 'Chompyy'], { stdio: 'ignore' });
|
|
50
51
|
return true;
|
|
51
52
|
}
|
|
52
53
|
catch {
|
package/dist/livequota.js
CHANGED
|
@@ -70,7 +70,8 @@ export async function refreshLiveQuota(opts = {}) {
|
|
|
70
70
|
if (state.retryAfterAt && Date.parse(state.retryAfterAt) > now.getTime()) {
|
|
71
71
|
return { ok: false, snapshot: current, message: `Anthropic limits how often quota can be checked; next check after ${hhmm(state.retryAfterAt)}.` };
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
// At most one request per 5 minutes, whichever wrote the snapshot since: the status line rewrites it on every reply.
|
|
74
|
+
if (!opts.force && state.lastTryAt && now.getTime() - Date.parse(state.lastTryAt) < MIN_INTERVAL_MS && current) {
|
|
74
75
|
return { ok: true, snapshot: current, message: 'Fresh enough.' };
|
|
75
76
|
}
|
|
76
77
|
const fetchQuota = opts.fetchQuota ?? ((o) => fetchClaudeQuota(o));
|
package/dist/macapp.js
CHANGED
|
@@ -7,6 +7,7 @@ import { existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, w
|
|
|
7
7
|
import { homedir, tmpdir } from 'node:os';
|
|
8
8
|
import { dirname, join } from 'node:path';
|
|
9
9
|
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import { exe } from './exe.js';
|
|
10
11
|
export const REPO = 'BranchWork-HQ/Chompyy';
|
|
11
12
|
/** The CLI's own version, from its package.json. */
|
|
12
13
|
export function cliVersion() {
|
|
@@ -26,7 +27,7 @@ export function parseChecksum(text) {
|
|
|
26
27
|
const defaultDeps = () => ({
|
|
27
28
|
fetch: (url) => fetch(url),
|
|
28
29
|
exec: (cmd, args) => {
|
|
29
|
-
execFileSync(cmd, args, { stdio: 'ignore' });
|
|
30
|
+
execFileSync(exe(cmd), args, { stdio: 'ignore' });
|
|
30
31
|
},
|
|
31
32
|
platform: process.platform,
|
|
32
33
|
appsDir: join(homedir(), 'Applications'),
|
package/dist/nudge.js
CHANGED
|
@@ -409,7 +409,7 @@ export function nudgeText(on, list = outcomes(), now = Date.now()) {
|
|
|
409
409
|
// ---------- installing the hook in Claude Code's settings ----------
|
|
410
410
|
export const claudeSettingsPath = () => process.env.CHOMPYY_CLAUDE_SETTINGS || join(homedir(), '.claude', 'settings.json');
|
|
411
411
|
const settingsPath = claudeSettingsPath;
|
|
412
|
-
function readSettings(path) {
|
|
412
|
+
export function readSettings(path) {
|
|
413
413
|
if (!existsSync(path))
|
|
414
414
|
return { settings: {}, raw: null };
|
|
415
415
|
const raw = readFileSync(path, 'utf8');
|
|
@@ -462,12 +462,16 @@ export function nudgeInstalled(path = settingsPath()) {
|
|
|
462
462
|
return false;
|
|
463
463
|
}
|
|
464
464
|
}
|
|
465
|
-
/**
|
|
466
|
-
export function
|
|
465
|
+
/** This CLI by absolute path, for Claude Code to run. A copy npx unpacked for one run can vanish, so not that. */
|
|
466
|
+
export function selfCommand(script = process.argv[1] ?? '', node = process.execPath) {
|
|
467
467
|
const real = existsSync(script) ? realpathSync(script) : script;
|
|
468
468
|
if (/[\\/]_npx[\\/]/.test(real))
|
|
469
|
-
throw new Error('This is a one-off npx copy. Install Chompyy first (npm install -g chompyy), then run
|
|
470
|
-
return `"${node}" "${real}"
|
|
469
|
+
throw new Error('This is a one-off npx copy. Install Chompyy first (npm install -g chompyy), then run this again.');
|
|
470
|
+
return `"${node}" "${real}"`;
|
|
471
|
+
}
|
|
472
|
+
/** The command the hook runs. */
|
|
473
|
+
export function hookCommand(script, node) {
|
|
474
|
+
return `${selfCommand(script, node)} hook prompt ${MARK}`;
|
|
471
475
|
}
|
|
472
476
|
/** Add (or remove) the hook in ~/.claude/settings.json, keeping every other hook. Backs the file up first. */
|
|
473
477
|
export function setNudge(on, command, path = settingsPath()) {
|
package/dist/picture.js
CHANGED
|
@@ -8,6 +8,7 @@ import { dirname, join } from 'node:path';
|
|
|
8
8
|
import { fileURLToPath } from 'node:url';
|
|
9
9
|
import { homePath } from './home.js';
|
|
10
10
|
import { chosenType, suggestTypes, typeHint } from './picturetype.js';
|
|
11
|
+
import { exe } from './exe.js';
|
|
11
12
|
export function skillDir() {
|
|
12
13
|
return join(dirname(fileURLToPath(import.meta.url)), '..', 'vendor', 'diagram-design');
|
|
13
14
|
}
|
|
@@ -95,7 +96,7 @@ export function cleanPicture(html) {
|
|
|
95
96
|
export const darkPicture = (html) => apply(html, TO_DARK);
|
|
96
97
|
/** The skill's own self-check (accessibility contract, single-file safety, content inside the viewBox). */
|
|
97
98
|
function selfCheck(file) {
|
|
98
|
-
const r = spawnSync('python3', [join(skillDir(), 'scripts', 'self_check.py'), file], { encoding: 'utf8', timeout: 20_000 });
|
|
99
|
+
const r = spawnSync(exe('python3'), [join(skillDir(), 'scripts', 'self_check.py'), file], { encoding: 'utf8', timeout: 20_000 });
|
|
99
100
|
if (r.error)
|
|
100
101
|
return null;
|
|
101
102
|
return (r.stdout + r.stderr).trim().split('\n').slice(0, 12).join('\n') || (r.status === 0 ? 'OK' : `exit ${r.status}`);
|
package/dist/preflight.js
CHANGED
|
@@ -15,6 +15,7 @@ import { homePath, readJson, writeJson } from './home.js';
|
|
|
15
15
|
import { detectCheck, run, sandboxProfile } from './verify.js';
|
|
16
16
|
import { setupDependencies } from './deps.js';
|
|
17
17
|
import { latestMain } from './workspace.js';
|
|
18
|
+
import { exe } from './exe.js';
|
|
18
19
|
export { latestMain };
|
|
19
20
|
const SKIP = new Set(['node_modules', '.git', '.build', 'dist', 'build', 'vendor', 'Pods', 'DerivedData', '.venv', 'venv', 'target']);
|
|
20
21
|
/** Every check the repo has, from what's in its folders (up to 3 levels deep). */
|
|
@@ -58,7 +59,7 @@ export function detectChecks(root, cacheDir, maxDepth = 3) {
|
|
|
58
59
|
walk(root, 0);
|
|
59
60
|
return checks;
|
|
60
61
|
}
|
|
61
|
-
const git = (cwd, args) => execFileSync('git', ['-C', cwd, ...args], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();
|
|
62
|
+
const git = (cwd, args) => execFileSync(exe('git'), ['-C', cwd, ...args], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();
|
|
62
63
|
const tryGit = (cwd, args) => {
|
|
63
64
|
try {
|
|
64
65
|
return git(cwd, args);
|
package/dist/quota.js
CHANGED
|
@@ -61,6 +61,16 @@ export function mergeSnapshot(prev, next) {
|
|
|
61
61
|
...(next.models ?? prev?.models ? { models: next.models ?? prev?.models } : {}),
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* What the status line saves: the merged snapshot when Claude Code sent quota numbers, else null. Before a
|
|
66
|
+
* session's first reply there are none; rewriting the old snapshot then would only make it look fresh.
|
|
67
|
+
*/
|
|
68
|
+
export function statuslineSnapshot(stdin, now, prev) {
|
|
69
|
+
const parsed = parseStatusline(stdin, now);
|
|
70
|
+
if (!parsed.fiveHour && !parsed.sevenDay)
|
|
71
|
+
return null;
|
|
72
|
+
return mergeSnapshot(prev, { ...parsed, source: 'statusline' });
|
|
73
|
+
}
|
|
64
74
|
/** % left, time left and pace for one window. Past resets_at the window has reset: unknown. */
|
|
65
75
|
export function windowView(w, now) {
|
|
66
76
|
if (!w)
|
package/dist/refresh.js
CHANGED
|
@@ -12,7 +12,8 @@ import { getCard, loadBoard, updateBoard } from './board.js';
|
|
|
12
12
|
import { homePath } from './home.js';
|
|
13
13
|
import { windowView } from './quota.js';
|
|
14
14
|
import { commitLeftovers, gitRoot, restoreGitLink } from './workspace.js';
|
|
15
|
-
|
|
15
|
+
import { exe } from './exe.js';
|
|
16
|
+
const git = (cwd, args) => execFileSync(exe('git'), ['-C', cwd, ...args], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();
|
|
16
17
|
const ok = (cwd, args) => {
|
|
17
18
|
try {
|
|
18
19
|
git(cwd, args);
|
package/dist/report.js
CHANGED
|
@@ -61,6 +61,12 @@ export function morningLine(cards, taste) {
|
|
|
61
61
|
bits.push(`taste: ${t.join(', ')}`);
|
|
62
62
|
return bits.length ? `Since last time: ${bits.join(' · ')}` : null;
|
|
63
63
|
}
|
|
64
|
+
/** "taste: 4 learned, 1 new in the last 7 days". Null when taste.md has no learned lines. */
|
|
65
|
+
export function tasteCountLine(count) {
|
|
66
|
+
if (!count.total)
|
|
67
|
+
return null;
|
|
68
|
+
return `taste: ${count.total} learned${count.newWithin7Days ? `, ${count.newWithin7Days} new in the last 7 days` : ''}`;
|
|
69
|
+
}
|
|
64
70
|
export function formatReport(cards, since, facts, extras = {}) {
|
|
65
71
|
const footer = extras.footer?.length ? ['', ...extras.footer] : [];
|
|
66
72
|
if (cards.length === 0)
|
package/dist/review.js
CHANGED
|
@@ -5,6 +5,7 @@ import { existsSync, readFileSync, readdirSync, rmSync } from 'node:fs';
|
|
|
5
5
|
import { basename, join } from 'node:path';
|
|
6
6
|
import { homePath } from './home.js';
|
|
7
7
|
import { commitLeftovers, gitRoot, uncommittedWork } from './workspace.js';
|
|
8
|
+
import { exe } from './exe.js';
|
|
8
9
|
/**
|
|
9
10
|
* What a card's changes are measured from: the commit it started from (the latest main at the time), so the
|
|
10
11
|
* list shows only the card's own work. Measuring from your folder's HEAD showed 56 files for a 6-file card when
|
|
@@ -14,7 +15,7 @@ function since(run) {
|
|
|
14
15
|
return run.base?.commit ?? 'HEAD';
|
|
15
16
|
}
|
|
16
17
|
function git(cwd, args) {
|
|
17
|
-
return execFileSync('git', ['-C', cwd, ...args], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();
|
|
18
|
+
return execFileSync(exe('git'), ['-C', cwd, ...args], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();
|
|
18
19
|
}
|
|
19
20
|
function ran(card) {
|
|
20
21
|
if (!card.run)
|
package/dist/runner.js
CHANGED
|
@@ -4,6 +4,7 @@ import { spawn, spawnSync } from 'node:child_process';
|
|
|
4
4
|
import { TokenTally } from './tokens.js';
|
|
5
5
|
import { closeSync, openSync, writeSync } from 'node:fs';
|
|
6
6
|
import { commandPattern, hostsInErrors } from './permissions.js';
|
|
7
|
+
import { exe } from './exe.js';
|
|
7
8
|
/** The raw output written to disk, cut off after `max` bytes (with a note saying so). */
|
|
8
9
|
export class RawLog {
|
|
9
10
|
max;
|
|
@@ -264,7 +265,7 @@ export class ClaudeRunner {
|
|
|
264
265
|
return new Promise((resolve) => {
|
|
265
266
|
// The prompt goes in on stdin: no argument-length limits, nothing in `ps`.
|
|
266
267
|
// Own process group, so a timeout also stops commands the agent started (tests, builds).
|
|
267
|
-
const child = spawn(this.bin, claudeArgs(req), { cwd: req.cwd, stdio: ['pipe', 'pipe', 'pipe'], detached: true, env: { ...process.env, ...req.env } });
|
|
268
|
+
const child = spawn(exe(this.bin), claudeArgs(req), { cwd: req.cwd, stdio: ['pipe', 'pipe', 'pipe'], detached: true, env: { ...process.env, ...req.env } });
|
|
268
269
|
stopActiveOnExit();
|
|
269
270
|
if (child.pid) {
|
|
270
271
|
active.add(child.pid);
|
|
@@ -400,6 +401,6 @@ export class ClaudeRunner {
|
|
|
400
401
|
}
|
|
401
402
|
}
|
|
402
403
|
export function claudeAvailable(bin = 'claude') {
|
|
403
|
-
const r = spawnSync(bin, ['--version'], { stdio: 'ignore', timeout: 10_000 });
|
|
404
|
+
const r = spawnSync(exe(bin), ['--version'], { stdio: 'ignore', timeout: 10_000 });
|
|
404
405
|
return r.status === 0;
|
|
405
406
|
}
|