chompyy 0.5.0 → 0.6.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 +11 -0
- package/dist/agentlimits.js +77 -0
- package/dist/agentusage.js +96 -0
- package/dist/appstate.js +63 -3
- package/dist/away.js +44 -5
- package/dist/blueprint.js +3 -7
- package/dist/board.js +1 -0
- package/dist/cli.js +263 -5
- package/dist/codexquota.js +106 -0
- package/dist/codexusage.js +10 -0
- package/dist/config.js +2 -0
- package/dist/context.js +30 -0
- package/dist/costs.js +1 -0
- package/dist/demon.js +20 -0
- package/dist/label.js +33 -0
- package/dist/menu.js +17 -0
- package/dist/nightcap.js +60 -0
- package/dist/nudge.js +47 -18
- package/dist/pacing.js +16 -1
- package/dist/questions.js +71 -0
- package/dist/recap.js +74 -0
- package/dist/receipt.js +48 -0
- package/dist/recipe.js +79 -0
- package/dist/stamps.js +14 -0
- package/dist/triggers.js +5 -0
- package/dist/usage.js +21 -1
- package/dist/vendor/codeburn/antigravity.js +309 -0
- package/dist/vendor/codeburn/codex.js +429 -0
- package/dist/vendor/codeburn/copilot.js +292 -0
- package/dist/vendor/codeburn/gemini.js +195 -0
- package/dist/vendor/codeburn/grokbot.js +182 -0
- package/dist/vendor/codeburn/kimi.js +178 -0
- package/dist/vendor/codeburn/shims/chalk.js +14 -0
- package/dist/vendor/codeburn/shims/strip-ansi.js +6 -0
- package/dist/vendor/codeburn/src/act/backup.js +83 -0
- package/dist/vendor/codeburn/src/act/model-defaults.js +151 -0
- package/dist/vendor/codeburn/src/act/types.js +37 -0
- package/dist/vendor/codeburn/src/bash-utils.js +204 -0
- package/dist/vendor/codeburn/src/behavioral-weight.js +47 -0
- package/dist/vendor/codeburn/src/cache-dir.js +26 -0
- package/dist/vendor/codeburn/src/cache-refresh-lock.js +543 -0
- package/dist/vendor/codeburn/src/cache-sweep.js +67 -0
- package/dist/vendor/codeburn/src/classifier.js +209 -0
- package/dist/vendor/codeburn/src/claude-identity.js +223 -0
- package/dist/vendor/codeburn/src/codex-cache.js +377 -0
- package/dist/vendor/codeburn/src/codex-fork-replay.js +232 -0
- package/dist/vendor/codeburn/src/codex-jsonl-fields.js +99 -0
- package/dist/vendor/codeburn/src/codex-session-index.js +113 -0
- package/dist/vendor/codeburn/src/codex-throughput.js +544 -0
- package/dist/vendor/codeburn/src/compare-stats.js +405 -0
- package/dist/vendor/codeburn/src/config.js +145 -0
- package/dist/vendor/codeburn/src/content-utils.js +56 -0
- package/dist/vendor/codeburn/src/context-tree-codex.js +329 -0
- package/dist/vendor/codeburn/src/context-tree.js +664 -0
- package/dist/vendor/codeburn/src/copilot-aiu.js +16 -0
- package/dist/vendor/codeburn/src/currency.js +189 -0
- package/dist/vendor/codeburn/src/cursor-cache.js +238 -0
- package/dist/vendor/codeburn/src/cursor-import.js +402 -0
- package/dist/vendor/codeburn/src/cursor-sync.js +256 -0
- package/dist/vendor/codeburn/src/daily-cache.js +2036 -0
- package/dist/vendor/codeburn/src/data/litellm-snapshot.json +1 -0
- package/dist/vendor/codeburn/src/data/pricing-fallback.json +1 -0
- package/dist/vendor/codeburn/src/day-aggregator.js +327 -0
- package/dist/vendor/codeburn/src/editor-data-dir.js +11 -0
- package/dist/vendor/codeburn/src/fetch-utils.js +18 -0
- package/dist/vendor/codeburn/src/format.js +118 -0
- package/dist/vendor/codeburn/src/fs-utils.js +270 -0
- package/dist/vendor/codeburn/src/git-origin.js +334 -0
- package/dist/vendor/codeburn/src/granular-history.js +328 -0
- package/dist/vendor/codeburn/src/hermes-session-ledger.js +512 -0
- package/dist/vendor/codeburn/src/launcher-homes.js +142 -0
- package/dist/vendor/codeburn/src/live-sessions.js +358 -0
- package/dist/vendor/codeburn/src/math-utils.js +8 -0
- package/dist/vendor/codeburn/src/menubar-json.js +294 -0
- package/dist/vendor/codeburn/src/models.js +1879 -0
- package/dist/vendor/codeburn/src/optimize-one-hour-cache.js +92 -0
- package/dist/vendor/codeburn/src/optimize.js +4110 -0
- package/dist/vendor/codeburn/src/parse-workers.js +219 -0
- package/dist/vendor/codeburn/src/parser.js +6953 -0
- package/dist/vendor/codeburn/src/path-privacy.js +26 -0
- package/dist/vendor/codeburn/src/plans.js +135 -0
- package/dist/vendor/codeburn/src/pr-signals.js +132 -0
- package/dist/vendor/codeburn/src/project-filter-warnings.js +33 -0
- package/dist/vendor/codeburn/src/provider-issues.js +30 -0
- package/dist/vendor/codeburn/src/providers/amp.js +286 -0
- package/dist/vendor/codeburn/src/providers/antigravity.js +1731 -0
- package/dist/vendor/codeburn/src/providers/claude.js +551 -0
- package/dist/vendor/codeburn/src/providers/cline-cli.js +401 -0
- package/dist/vendor/codeburn/src/providers/cline.js +63 -0
- package/dist/vendor/codeburn/src/providers/codebuff.js +336 -0
- package/dist/vendor/codeburn/src/providers/codewhale.js +442 -0
- package/dist/vendor/codeburn/src/providers/codex.js +1720 -0
- package/dist/vendor/codeburn/src/providers/command-code.js +196 -0
- package/dist/vendor/codeburn/src/providers/copilot.js +3278 -0
- package/dist/vendor/codeburn/src/providers/crush.js +226 -0
- package/dist/vendor/codeburn/src/providers/cursor-agent.js +837 -0
- package/dist/vendor/codeburn/src/providers/cursor.js +1163 -0
- package/dist/vendor/codeburn/src/providers/devin.js +569 -0
- package/dist/vendor/codeburn/src/providers/droid.js +324 -0
- package/dist/vendor/codeburn/src/providers/dsh.js +690 -0
- package/dist/vendor/codeburn/src/providers/forge.js +245 -0
- package/dist/vendor/codeburn/src/providers/gemini.js +230 -0
- package/dist/vendor/codeburn/src/providers/goose.js +252 -0
- package/dist/vendor/codeburn/src/providers/grok.js +581 -0
- package/dist/vendor/codeburn/src/providers/grokbot.js +290 -0
- package/dist/vendor/codeburn/src/providers/hermes.js +771 -0
- package/dist/vendor/codeburn/src/providers/ibm-bob.js +53 -0
- package/dist/vendor/codeburn/src/providers/index.js +360 -0
- package/dist/vendor/codeburn/src/providers/kilo-code.js +50 -0
- package/dist/vendor/codeburn/src/providers/kimi.js +363 -0
- package/dist/vendor/codeburn/src/providers/kimicode.js +402 -0
- package/dist/vendor/codeburn/src/providers/kiro.js +1174 -0
- package/dist/vendor/codeburn/src/providers/lingtai-tui.js +372 -0
- package/dist/vendor/codeburn/src/providers/mistral-vibe-unified.js +236 -0
- package/dist/vendor/codeburn/src/providers/mistral-vibe.js +405 -0
- package/dist/vendor/codeburn/src/providers/mux.js +242 -0
- package/dist/vendor/codeburn/src/providers/open-design.js +217 -0
- package/dist/vendor/codeburn/src/providers/openclaude.js +309 -0
- package/dist/vendor/codeburn/src/providers/openclaw.js +442 -0
- package/dist/vendor/codeburn/src/providers/opencode-file-parser.js +131 -0
- package/dist/vendor/codeburn/src/providers/opencode.js +91 -0
- package/dist/vendor/codeburn/src/providers/pi.js +429 -0
- package/dist/vendor/codeburn/src/providers/quickdesk.js +491 -0
- package/dist/vendor/codeburn/src/providers/qwen.js +193 -0
- package/dist/vendor/codeburn/src/providers/session-message.js +118 -0
- package/dist/vendor/codeburn/src/providers/sqlite-session-parser.js +457 -0
- package/dist/vendor/codeburn/src/providers/types.js +5 -0
- package/dist/vendor/codeburn/src/providers/vercel-gateway.js +135 -0
- package/dist/vendor/codeburn/src/providers/vscode-cline-parser.js +212 -0
- package/dist/vendor/codeburn/src/providers/warp.js +575 -0
- package/dist/vendor/codeburn/src/providers/zcode.js +249 -0
- package/dist/vendor/codeburn/src/providers/zed.js +187 -0
- package/dist/vendor/codeburn/src/providers/zerostack.js +139 -0
- package/dist/vendor/codeburn/src/quota/antigravity.js +310 -0
- package/dist/vendor/codeburn/src/quota/claude.js +244 -0
- package/dist/vendor/codeburn/src/quota/cursor.js +301 -0
- package/dist/vendor/codeburn/src/quota/security.js +299 -0
- package/dist/vendor/codeburn/src/quota/types.js +1 -0
- package/dist/vendor/codeburn/src/scan-facts.js +99 -0
- package/dist/vendor/codeburn/src/session-cache.js +3040 -0
- package/dist/vendor/codeburn/src/session-count-label.js +14 -0
- package/dist/vendor/codeburn/src/session-output.js +139 -0
- package/dist/vendor/codeburn/src/session-population.js +30 -0
- package/dist/vendor/codeburn/src/sessions-report.js +1342 -0
- package/dist/vendor/codeburn/src/sqlite.js +528 -0
- package/dist/vendor/codeburn/src/sync/otlp.js +420 -0
- package/dist/vendor/codeburn/src/telemetry-snapshot.js +244 -0
- package/dist/vendor/codeburn/src/token-estimate.js +5 -0
- package/dist/vendor/codeburn/src/types.js +16 -0
- package/dist/vendor/codeburn/src/work-units.js +126 -0
- package/dist/vendor/codeburn/src/workflow-insights.js +228 -0
- package/dist/vendor/codeburn/src/wsl.js +198 -0
- package/dist/vendor/codeburn/src/yield.js +666 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -123,6 +123,7 @@ Each card in a git repo runs in its own worktree at `~/.chompyy/worktrees/<id>`
|
|
|
123
123
|
| `chompyy away <1h\|30m\|1h30m> [--dry-run] [--force]` | Run approved cards until the time is up or the gate closes |
|
|
124
124
|
| `chompyy report [--all]` | Cards that ran since the last report: one action each, cards needing you first. No paths or raw agent text; ask for those with `show` |
|
|
125
125
|
| `chompyy diff <id>` | The change the card made on its branch |
|
|
126
|
+
| `chompyy recipe <id>` | A kept card as a recipe: the files it changed, the steps it took, when it landed (`--json` for the app) |
|
|
126
127
|
| `chompyy keep <id>` | Merge the card's branch into your current branch and remove its worktree. Refuses when you have unsaved changes in a file the card also changed, or anything staged; other unsaved work is left alone |
|
|
127
128
|
| `chompyy undo <id> [--plan] [--json]` | Throw the run away: remove its worktree and branch (or draft folder). Your own branches are never touched. On a kept card it takes the card back: off your branch when it's only on this Mac (closing its PR if one is open), or with a revert PR on GitHub once its PR merged. `--plan` says which and changes nothing |
|
|
128
129
|
| `chompyy redo <id>` | Throw a ran card's result away and put it back in *approved*; it runs again from your latest code |
|
|
@@ -149,6 +150,16 @@ Each card in a git repo runs in its own worktree at `~/.chompyy/worktrees/<id>`
|
|
|
149
150
|
| `chompyy nudge [--json]` | On or off, what the stops and warnings led to (compacted, left, sent anyway), the tokens not written again, and the measured trend: cold returns this week against last week. The menu panel shows the same line |
|
|
150
151
|
| `chompyy nudge due [--json]` | Conversations 45-60 minutes into a pause, about to go cold, each reported once (only while nudge is on). The menu bar app asks every minute and sends a notification, while /compact is still cheap. Skips conversations already compacted |
|
|
151
152
|
| `chompyy triggers on\|off` | Install or remove the macOS LaunchAgent that runs `chompyy tick` every 5 minutes |
|
|
153
|
+
| `chompyy limits [<agent> on\|off] [--json]` | Limits for Gemini CLI, GitHub Copilot, Antigravity, Kimi Code and Grok Bot through codeburn's readers. Each is off until you allow it, since it uses that agent's own login (read-only, never rewritten) |
|
|
154
|
+
| `chompyy recap [--month 2026-11] [--json]` | Your month with Chompyy on one card: tokens, API value and cookies, busiest day, conversations, cards baked and kept, biggest bake. This month once it's a week old, else last month. No names, safe to share |
|
|
155
|
+
| `chompyy menu [--json]` | Every coding agent you used in the last 30 days as a café chalkboard: Claude Code and the others, tokens and API value, most first. Agent and model names only, safe to share |
|
|
156
|
+
| `chompyy label [--json]` | Your week of Claude Code as a Nutrition Facts label: cached reads (fibre), cache writes (carbs), tokens resent after a break (added sugar), input and output (protein). Amounts only, safe to share |
|
|
157
|
+
| `chompyy stamps [--json]` | Your loyalty stamp card: one stamp per card you kept, ten to a card, with the dates. No titles, safe to share |
|
|
158
|
+
| `chompyy agents [--json] [--refresh]` | Every other coding agent codeburn reads (Cursor, Copilot, Gemini CLI, OpenCode, … about 40): tokens and API value today, this week and over 30 and 90 days (agents used in the last 90 days), at most one scan per 10 minutes |
|
|
159
|
+
| `chompyy codex [on\|off] [--json]` | Codex beside Claude: its 5-hour and weekly limits (reads Codex's saved login to ask OpenAI; never renews or changes it) and its tokens and API value (codeburn's Codex parser) |
|
|
160
|
+
| `chompyy nightcap [on [23:30]\|skip\|unskip]` | The evening offer: run approved cards at bedtime tonight (`on` sets bedtime and turns triggers on), or skip tonight |
|
|
161
|
+
| `chompyy demon [on\|off]` | Demon mode: in the last 90 minutes of a window that would reset 20%+ unused, run approved cards to eat it (`on` = every window, via the last-hour trigger) |
|
|
162
|
+
| `chompyy receipt [--json]` | Your week as a bake-sale receipt: cards baked and their API value, kept, burnt (undone), tokens, resent less than last week. No names, safe to share |
|
|
152
163
|
| `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
164
|
| `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
165
|
| `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 |
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Limits for the other agents codeburn can read them for, beside Claude and Codex: Gemini CLI, GitHub Copilot,
|
|
2
|
+
// Antigravity, Kimi Code and Grok Bot, through codeburn's own readers (src/vendor/codeburn/<agent>.ts).
|
|
3
|
+
//
|
|
4
|
+
// Each one is off until you allow it (config agentLimits), because it uses that agent's saved login: Gemini's
|
|
5
|
+
// ~/.gemini/oauth_creds.json, Copilot's ~/.config/github-copilot, Kimi's ~/.kimi-code credentials, the session of
|
|
6
|
+
// the Cursor app Grok Bot uses, or Antigravity's own app running on this Mac. All read-only: none of these readers
|
|
7
|
+
// writes a login back (checked 2026-12-05). Each agent is asked at most every 5 minutes.
|
|
8
|
+
import { existsSync } from 'node:fs';
|
|
9
|
+
import { homedir } from 'node:os';
|
|
10
|
+
import { join } from 'node:path';
|
|
11
|
+
import { fetchAntigravityQuota } from './vendor/codeburn/antigravity.js';
|
|
12
|
+
import { copilotConfigDirs, fetchCopilotQuota } from './vendor/codeburn/copilot.js';
|
|
13
|
+
import { fetchGeminiQuota } from './vendor/codeburn/gemini.js';
|
|
14
|
+
import { fetchGrokbotQuota, grokbotInstalled } from './vendor/codeburn/grokbot.js';
|
|
15
|
+
import { fetchKimiQuota } from './vendor/codeburn/kimi.js';
|
|
16
|
+
import { homePath, readJson, writeJson } from './home.js';
|
|
17
|
+
export const LIMITS_MIN_INTERVAL_MS = 5 * 60_000;
|
|
18
|
+
const home = homedir();
|
|
19
|
+
export const READERS = [
|
|
20
|
+
{ name: 'gemini', displayName: 'Gemini CLI', login: "the Gemini CLI's saved Google login", hint: 'Run the Gemini CLI once to sign in, then refresh.', installed: () => existsSync(join(home, '.gemini', 'oauth_creds.json')), fetch: () => fetchGeminiQuota() },
|
|
21
|
+
{ name: 'copilot', displayName: 'GitHub Copilot', login: "Copilot's saved GitHub login", hint: 'Sign in to GitHub Copilot in your editor once, then refresh.', installed: () => copilotConfigDirs().some((d) => existsSync(join(d, 'apps.json')) || existsSync(join(d, 'hosts.json'))), fetch: () => fetchCopilotQuota() },
|
|
22
|
+
{ name: 'antigravity', displayName: 'Antigravity', login: 'the Antigravity app running on this Mac', hint: 'Open the Antigravity app, then refresh.', installed: () => existsSync('/Applications/Antigravity.app') || existsSync(join(home, '.gemini', 'antigravity')), fetch: async () => ({ quota: await fetchAntigravityQuota() }) },
|
|
23
|
+
{ name: 'kimi', displayName: 'Kimi Code', login: "Kimi Code's saved login", hint: 'Sign in to Kimi Code once, then refresh.', installed: () => existsSync(join(process.env.KIMI_CODE_HOME ?? join(home, '.kimi-code'), 'credentials', 'kimi-code.json')), fetch: () => fetchKimiQuota() },
|
|
24
|
+
{ name: 'grokbot', displayName: 'Grok Bot', login: 'the Cursor app session Grok Bot uses', hint: 'Sign in to the Cursor app with the account Grok Bot uses, then refresh.', installed: () => grokbotInstalled(), fetch: () => fetchGrokbotQuota() },
|
|
25
|
+
];
|
|
26
|
+
const filePath = () => homePath('agent-limits.json');
|
|
27
|
+
export const loadLimits = () => readJson(filePath(), {});
|
|
28
|
+
function windowOf(w) {
|
|
29
|
+
return { label: w.label, usedPct: Math.round(w.percent * 1000) / 10, resetsAt: w.resetsAt ? Math.floor(Date.parse(w.resetsAt) / 1000) : null };
|
|
30
|
+
}
|
|
31
|
+
export function limitFrom(q, now, hint = '') {
|
|
32
|
+
return {
|
|
33
|
+
lastTryAt: now.toISOString(),
|
|
34
|
+
connection: q.connection,
|
|
35
|
+
plan: q.planLabel,
|
|
36
|
+
primary: q.primary ? windowOf(q.primary) : null,
|
|
37
|
+
windows: q.details.map(windowOf),
|
|
38
|
+
note: q.connection === 'connected' ? null : q.footerLines.join(' ') || hint || null,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** Read the allowed agents' limits (each at most every 5 minutes unless forced) and save them. */
|
|
42
|
+
export async function refreshLimits(allowed, opts = {}) {
|
|
43
|
+
const now = opts.now ?? new Date();
|
|
44
|
+
const saved = loadLimits();
|
|
45
|
+
for (const r of opts.readers ?? READERS) {
|
|
46
|
+
if (!allowed[r.name] || !r.installed())
|
|
47
|
+
continue;
|
|
48
|
+
const last = saved[r.name];
|
|
49
|
+
if (last?.retryAfterAt && Date.parse(last.retryAfterAt) > now.getTime())
|
|
50
|
+
continue;
|
|
51
|
+
if (!opts.force && last && now.getTime() - Date.parse(last.lastTryAt) < LIMITS_MIN_INTERVAL_MS)
|
|
52
|
+
continue;
|
|
53
|
+
try {
|
|
54
|
+
const res = await r.fetch();
|
|
55
|
+
const next = limitFrom(res.quota, now, r.hint);
|
|
56
|
+
if (res.retryAfterSeconds)
|
|
57
|
+
next.retryAfterAt = new Date(now.getTime() + res.retryAfterSeconds * 1000).toISOString();
|
|
58
|
+
saved[r.name] = next;
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
saved[r.name] = { lastTryAt: now.toISOString(), connection: 'transientFailure', plan: null, primary: null, windows: [], note: `Couldn't read ${r.displayName}'s limits right now.` };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
writeJson(filePath(), saved);
|
|
65
|
+
return saved;
|
|
66
|
+
}
|
|
67
|
+
/** For the app: every agent on this Mac with a limits reader, whether you allowed it, and its last reading. */
|
|
68
|
+
export function limitsState(allowed, readers = READERS) {
|
|
69
|
+
const saved = loadLimits();
|
|
70
|
+
const out = {};
|
|
71
|
+
for (const r of readers) {
|
|
72
|
+
if (!r.installed())
|
|
73
|
+
continue;
|
|
74
|
+
out[r.name] = { displayName: r.displayName, login: r.login, allowed: r.name in allowed ? allowed[r.name] : null, limit: allowed[r.name] ? saved[r.name] ?? null : null };
|
|
75
|
+
}
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// Every coding agent codeburn reads (Codex, Cursor, Copilot, Gemini CLI, OpenCode, … ~40 of them), through its own
|
|
2
|
+
// readers in src/vendor/codeburn/src/providers/: where each keeps its sessions, their formats and the quirks codeburn
|
|
3
|
+
// works around. Claude is left out: Chompyy reads Claude Code itself (usage.ts).
|
|
4
|
+
//
|
|
5
|
+
// Scanning every agent takes a few seconds, so it runs at most every 10 minutes (`chompyy agents`, which the app
|
|
6
|
+
// calls) and the result is saved; `chompyy state` only reads the saved file.
|
|
7
|
+
import { homePath, readJson, writeJson } from './home.js';
|
|
8
|
+
import { loadPricing } from './vendor/codeburn/src/models.js';
|
|
9
|
+
import { getAllProviders, providerDisplayName, safeDiscoverSessions } from './vendor/codeburn/src/providers/index.js';
|
|
10
|
+
export const AGENTS_MIN_INTERVAL_MS = 10 * 60_000;
|
|
11
|
+
const filePath = () => homePath('agents-usage.json');
|
|
12
|
+
export const loadAgents = () => readJson(filePath(), null);
|
|
13
|
+
/** Every token a call moved: fresh input, cache writes, cache reads and output (reasoning is part of output). */
|
|
14
|
+
export const callTokens = (c) => c.inputTokens + c.outputTokens + c.cacheCreationInputTokens + c.cacheReadInputTokens;
|
|
15
|
+
/** Quiet settings for codeburn inside Chompyy: bundled prices only (no download), its cache in ~/.chompyy. */
|
|
16
|
+
export async function prepareCodeburn() {
|
|
17
|
+
process.env.CODEBURN_PRICING_SNAPSHOT_ONLY ??= '1';
|
|
18
|
+
process.env.CODEBURN_CACHE_DIR ??= homePath('codeburn-cache');
|
|
19
|
+
await loadPricing();
|
|
20
|
+
}
|
|
21
|
+
/** One agent's tokens and API value today (local day) and over the last 7, 30 and 90 days. */
|
|
22
|
+
export async function usageFor(provider, now, sources) {
|
|
23
|
+
const end = now.getTime();
|
|
24
|
+
const start = end - 90 * 24 * 3600_000;
|
|
25
|
+
const monthStart = end - 30 * 24 * 3600_000;
|
|
26
|
+
const weekStart = end - 7 * 24 * 3600_000;
|
|
27
|
+
const dayStart = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();
|
|
28
|
+
const today = { tokens: 0, costUsd: 0 };
|
|
29
|
+
const week = { tokens: 0, costUsd: 0 };
|
|
30
|
+
const month = { tokens: 0, costUsd: 0 };
|
|
31
|
+
const quarter = { tokens: 0, costUsd: 0 };
|
|
32
|
+
const byModel = new Map();
|
|
33
|
+
const seen = new Set();
|
|
34
|
+
for (const source of sources ?? (await provider.discoverSessions())) {
|
|
35
|
+
for await (const call of provider.createSessionParser(source, seen, { start: new Date(start), end: now }).parse()) {
|
|
36
|
+
const at = Date.parse(call.timestamp);
|
|
37
|
+
if (!Number.isFinite(at) || at < start || at > end)
|
|
38
|
+
continue;
|
|
39
|
+
const n = callTokens(call);
|
|
40
|
+
quarter.tokens += n;
|
|
41
|
+
quarter.costUsd += call.costUSD;
|
|
42
|
+
if (at >= monthStart) {
|
|
43
|
+
month.tokens += n;
|
|
44
|
+
month.costUsd += call.costUSD;
|
|
45
|
+
}
|
|
46
|
+
if (at >= weekStart) {
|
|
47
|
+
week.tokens += n;
|
|
48
|
+
week.costUsd += call.costUSD;
|
|
49
|
+
}
|
|
50
|
+
if (at >= dayStart) {
|
|
51
|
+
today.tokens += n;
|
|
52
|
+
today.costUsd += call.costUSD;
|
|
53
|
+
}
|
|
54
|
+
if (call.model)
|
|
55
|
+
byModel.set(call.model, (byModel.get(call.model) ?? 0) + n);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
name: provider.name,
|
|
60
|
+
displayName: provider.displayName || providerDisplayName(provider.name),
|
|
61
|
+
today,
|
|
62
|
+
week,
|
|
63
|
+
month,
|
|
64
|
+
quarter,
|
|
65
|
+
models: [...byModel.entries()].sort((a, b) => b[1] - a[1]).map(([m]) => m),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** Scan every agent (at most every 10 minutes unless forced) and save what each used. */
|
|
69
|
+
export async function refreshAgents(opts = {}) {
|
|
70
|
+
const now = opts.now ?? new Date();
|
|
71
|
+
const last = loadAgents();
|
|
72
|
+
if (!opts.force && last && now.getTime() - Date.parse(last.scannedAt) < AGENTS_MIN_INTERVAL_MS)
|
|
73
|
+
return last;
|
|
74
|
+
await prepareCodeburn();
|
|
75
|
+
const agents = [];
|
|
76
|
+
const failed = [];
|
|
77
|
+
for (const p of opts.providers ?? (await getAllProviders())) {
|
|
78
|
+
if (p.name === 'claude')
|
|
79
|
+
continue;
|
|
80
|
+
try {
|
|
81
|
+
const sources = await safeDiscoverSessions(p);
|
|
82
|
+
if (!sources.length)
|
|
83
|
+
continue;
|
|
84
|
+
const u = await usageFor(p, now, sources);
|
|
85
|
+
if (u.quarter.tokens > 0)
|
|
86
|
+
agents.push(u);
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
failed.push(p.name);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
agents.sort((a, b) => b.quarter.tokens - a.quarter.tokens);
|
|
93
|
+
const file = { scannedAt: now.toISOString(), agents, failed };
|
|
94
|
+
writeJson(filePath(), file);
|
|
95
|
+
return file;
|
|
96
|
+
}
|
package/dist/appstate.js
CHANGED
|
@@ -18,19 +18,27 @@ import { costRange, readRuns } from './costs.js';
|
|
|
18
18
|
import { cachedWorkspaces, loadDream } from './dream.js';
|
|
19
19
|
import { learning } from './learning.js';
|
|
20
20
|
import { describeSignal, loadStore, nextQuestion, readSignals, receipts } from './taste.js';
|
|
21
|
-
import { agentInstalled, loadTriggerState } from './triggers.js';
|
|
21
|
+
import { agentInstalled, awayRunning, loadTriggerState } from './triggers.js';
|
|
22
|
+
import { nightcap } from './nightcap.js';
|
|
23
|
+
import { demonOffer } from './demon.js';
|
|
22
24
|
import { planFor } from './permissions.js';
|
|
23
25
|
import { loadProfile, preflightHosts } from './preflight.js';
|
|
24
26
|
import { gitRoot } from './workspace.js';
|
|
25
27
|
import { writeBlueprintFile } from './blueprint.js';
|
|
26
28
|
import { outboxes } from './send.js';
|
|
27
29
|
import { exe } from './exe.js';
|
|
30
|
+
import { warmCaches } from './nudge.js';
|
|
31
|
+
import { codexInstalled, loadCodexState } from './codexquota.js';
|
|
32
|
+
import { limitsState } from './agentlimits.js';
|
|
33
|
+
import { parseQuestions } from './questions.js';
|
|
28
34
|
export function cardView(card, runs = readRuns()) {
|
|
29
35
|
const qPath = card.run ? join(card.run.workdir, 'QUESTIONS.md') : '';
|
|
36
|
+
const questionsText = qPath && existsSync(qPath) ? readFileSync(qPath, 'utf8') : null;
|
|
30
37
|
return {
|
|
31
38
|
...card,
|
|
32
39
|
files: card.run ? changedFiles(card) : [],
|
|
33
|
-
questionsText
|
|
40
|
+
questionsText,
|
|
41
|
+
questions: questionsText ? parseQuestions(questionsText) : [],
|
|
34
42
|
pictureStale: Boolean(card.picture && card.picture.blueprintHash !== blueprintHash(card.blueprint)),
|
|
35
43
|
costRange: card.run ? null : costRange(card, runs),
|
|
36
44
|
folderBranch: card.column === 'review' && card.run?.branch ? (card.run.base?.branch || currentBranch(card.cwd)) : null,
|
|
@@ -61,6 +69,8 @@ export function currentBranch(cwd) {
|
|
|
61
69
|
export function appState(board, snap, config, now) {
|
|
62
70
|
const live = loadLiveState();
|
|
63
71
|
const runs = readRuns();
|
|
72
|
+
const pace = pacing(snap, loadSamples(), now, config.bedtime);
|
|
73
|
+
const approved = board.cards.filter((c) => c.column === 'approved').length;
|
|
64
74
|
return {
|
|
65
75
|
generatedAt: now.toISOString(),
|
|
66
76
|
quota: {
|
|
@@ -71,7 +81,7 @@ export function appState(board, snap, config, now) {
|
|
|
71
81
|
askKeychain: keychainAsk(config),
|
|
72
82
|
fiveHour: windowView(snap?.fiveHour, now),
|
|
73
83
|
sevenDay: windowView(snap?.sevenDay, now),
|
|
74
|
-
pacing:
|
|
84
|
+
pacing: pace,
|
|
75
85
|
},
|
|
76
86
|
gate: budgetGate(snap, config, now),
|
|
77
87
|
cards: board.cards.map((c) => cardView(c, runs)),
|
|
@@ -82,9 +92,59 @@ export function appState(board, snap, config, now) {
|
|
|
82
92
|
taste: tasteState(),
|
|
83
93
|
dream: dreamState(config, now),
|
|
84
94
|
pictures: config.pictures,
|
|
95
|
+
/** Conversations whose cache is still warm, soonest to expire first: the cookie steams while there are any. */
|
|
96
|
+
caches: safeWarmCaches(now),
|
|
85
97
|
triggers: { installed: agentInstalled(), lastHour: config.lastHourTrigger, bedtime: config.bedtime, ...loadTriggerState() },
|
|
98
|
+
/** The evening nightcap: offer to run approved cards at bedtime, or say what runs tonight. */
|
|
99
|
+
nightcap: nightcapNow(board, config, now),
|
|
100
|
+
/** Demon mode: eat what's left of the window before it resets. `auto` = the last-hour trigger runs it alone. */
|
|
101
|
+
demon: {
|
|
102
|
+
offer: demonOffer(windowView(snap?.fiveHour, now), pace.fiveHourForecast, approved, awayRunning() !== null),
|
|
103
|
+
auto: config.lastHourTrigger && agentInstalled(),
|
|
104
|
+
},
|
|
105
|
+
/** Other agents' limits beside Claude's: the app's provider switch. Only agents found on this Mac. */
|
|
106
|
+
providers: providersState(config, now),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/** Codex: whether it's here, whether you allowed the quota read, and its windows from the last check. */
|
|
110
|
+
export function providersState(config, now) {
|
|
111
|
+
const limits = limitsState(config.agentLimits ?? {});
|
|
112
|
+
if (!codexInstalled())
|
|
113
|
+
return { limits };
|
|
114
|
+
const s = loadCodexState();
|
|
115
|
+
return {
|
|
116
|
+
limits,
|
|
117
|
+
codex: {
|
|
118
|
+
allowed: config.codexQuota,
|
|
119
|
+
connection: s.connection ?? null,
|
|
120
|
+
plan: s.plan ?? null,
|
|
121
|
+
note: s.note ?? null,
|
|
122
|
+
capturedAt: s.capturedAt ?? null,
|
|
123
|
+
fiveHour: windowView(s.fiveHour, now),
|
|
124
|
+
sevenDay: windowView(s.sevenDay, now),
|
|
125
|
+
usage: s.usage ?? null,
|
|
126
|
+
},
|
|
86
127
|
};
|
|
87
128
|
}
|
|
129
|
+
export function nightcapNow(board, config, now) {
|
|
130
|
+
return nightcap({
|
|
131
|
+
now,
|
|
132
|
+
bedtime: config.bedtime,
|
|
133
|
+
bedtimeWindowMin: config.bedtimeWindowMin,
|
|
134
|
+
triggersOn: agentInstalled(),
|
|
135
|
+
approved: board.cards.filter((c) => c.column === 'approved').length,
|
|
136
|
+
fired: loadTriggerState().fired,
|
|
137
|
+
awayBusy: awayRunning() !== null,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function safeWarmCaches(now) {
|
|
141
|
+
try {
|
|
142
|
+
return warmCaches(now.getTime());
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
return [];
|
|
146
|
+
}
|
|
147
|
+
}
|
|
88
148
|
/** The nightly read for the app: on or off, the workspaces with their ticks, and how last night went. */
|
|
89
149
|
function dreamState(config, now) {
|
|
90
150
|
let workspaces = [];
|
package/dist/away.js
CHANGED
|
@@ -7,7 +7,7 @@ import { formatDuration } from './duration.js';
|
|
|
7
7
|
import { budgetGate } from './gate.js';
|
|
8
8
|
import { homePath } from './home.js';
|
|
9
9
|
import { windowView } from './quota.js';
|
|
10
|
-
import { recordRun, usedBetween } from './costs.js';
|
|
10
|
+
import { costRange, readRuns, recordRun, usedBetween } from './costs.js';
|
|
11
11
|
import { applyPermissions } from './permissions.js';
|
|
12
12
|
import { tasteForPrompt } from './taste.js';
|
|
13
13
|
import { boxTempDirs } from './verify.js';
|
|
@@ -22,7 +22,9 @@ export function safetyRules(workdir) {
|
|
|
22
22
|
2. Nothing outward: no git push, merge, rebase or pull request; no sending email or messages, no posting,
|
|
23
23
|
no publishing packages, no purchases, no changes to remote services.
|
|
24
24
|
3. If you need a decision only the user can make, stop and write the question(s) to QUESTIONS.md in this
|
|
25
|
-
directory
|
|
25
|
+
directory. Don't guess on anything irreversible. The user picks an answer from a list, so for each question:
|
|
26
|
+
a "## " heading that asks it, one or two lines of why, then a line "Options:" and a numbered list of 2-4
|
|
27
|
+
options. Start each option with a short sentence saying what you'd do, and put "(Recommended)" on yours.
|
|
26
28
|
4. Stay inside the blueprint's scope. Don't commit: leave your changes as files in this directory. Chompyy
|
|
27
29
|
commits them to this folder's branch when you finish (the branch is how the user reviews and undoes it), and
|
|
28
30
|
the repo's .git is read-only to you. git status, git diff and git log work.
|
|
@@ -30,8 +32,9 @@ export function safetyRules(workdir) {
|
|
|
30
32
|
sandbox, so local commands like tests and scripts are fine. The sandbox has no network: don't install or
|
|
31
33
|
download anything (no npm install/ci, pip install, brew, curl). Dependencies the repo already has installed
|
|
32
34
|
are in place. If a check can't run without a download, don't retry it: say so in the CHECKS line.
|
|
33
|
-
6. End with a short summary: what you made, where it is, and how to check it.
|
|
34
|
-
|
|
35
|
+
6. End with a short summary: what you made, where it is, and how to check it. Then a line "RECIPE:" and under
|
|
36
|
+
it 2-3 lines starting with "- ", each saying what changed for the user in plain words: 12 words or fewer,
|
|
37
|
+
no file paths, line numbers or code. The very last line must be exactly one of:
|
|
35
38
|
CHECKS: passed — <what you ran>
|
|
36
39
|
CHECKS: failed — <what fails, and whether it failed before your change>
|
|
37
40
|
CHECKS: not run — <why you couldn't check>`;
|
|
@@ -130,6 +133,32 @@ export function parseChecks(output) {
|
|
|
130
133
|
return undefined;
|
|
131
134
|
return { result: last[1].toLowerCase(), why: last[2].trim() };
|
|
132
135
|
}
|
|
136
|
+
/** The plain steps under the agent's last "RECIPE:" line: what changed for the user, for the recipe card. At most 3. */
|
|
137
|
+
export function parseRecipe(output) {
|
|
138
|
+
const all = output.split('\n');
|
|
139
|
+
let at = -1;
|
|
140
|
+
all.forEach((l, i) => { if (/^\s*\**RECIPE:\**\s*$/i.test(l))
|
|
141
|
+
at = i; });
|
|
142
|
+
if (at < 0)
|
|
143
|
+
return [];
|
|
144
|
+
const steps = [];
|
|
145
|
+
for (const l of all.slice(at + 1)) {
|
|
146
|
+
const m = /^\s*(?:[-*]|\d+\.)\s+(.*)$/.exec(l);
|
|
147
|
+
if (!m) {
|
|
148
|
+
if (l.trim() === '' && steps.length === 0)
|
|
149
|
+
continue;
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
const step = m[1].replace(/\*\*|`/g, '').trim();
|
|
153
|
+
if (step)
|
|
154
|
+
steps.push(step);
|
|
155
|
+
}
|
|
156
|
+
return steps.slice(0, 3);
|
|
157
|
+
}
|
|
158
|
+
/** The output without its RECIPE block, so the summary keeps to what was made and how to check it. */
|
|
159
|
+
function withoutRecipe(output) {
|
|
160
|
+
return output.replace(/^\s*\**RECIPE:\**\s*\n(?:\s*\n)?(?:\s*(?:[-*]|\d+\.)\s+.*(?:\n|$))*/gim, '');
|
|
161
|
+
}
|
|
133
162
|
function firstLines(text, n = 5) {
|
|
134
163
|
return text
|
|
135
164
|
.split('\n')
|
|
@@ -251,6 +280,12 @@ export async function runCard(id, timeoutMs, deps, trigger) {
|
|
|
251
280
|
const c = getCard(b, id);
|
|
252
281
|
c.column = 'running';
|
|
253
282
|
c.updatedAt = new Date(startedMs).toISOString();
|
|
283
|
+
const est = costRange(c, readRuns());
|
|
284
|
+
c.oven = {
|
|
285
|
+
since: c.updatedAt,
|
|
286
|
+
until: new Date(startedMs + timeoutMs).toISOString(),
|
|
287
|
+
...(est ? { expect: new Date(startedMs + Math.min(est.durationMidMs, timeoutMs)).toISOString(), from: est.n } : {}),
|
|
288
|
+
};
|
|
254
289
|
return { ...c };
|
|
255
290
|
});
|
|
256
291
|
out(`▶ #${card.id} ${card.title} (up to ${formatDuration(timeoutMs)})`);
|
|
@@ -260,6 +295,7 @@ export async function runCard(id, timeoutMs, deps, trigger) {
|
|
|
260
295
|
let status;
|
|
261
296
|
let exitCode = null;
|
|
262
297
|
let summaryText = '';
|
|
298
|
+
let recipe = [];
|
|
263
299
|
let checks;
|
|
264
300
|
let verified;
|
|
265
301
|
let tokens;
|
|
@@ -339,7 +375,8 @@ export async function runCard(id, timeoutMs, deps, trigger) {
|
|
|
339
375
|
? `Stopped by Chompyy: it was going in circles (${result.stuck}).`
|
|
340
376
|
: result.stalled
|
|
341
377
|
? `Stopped by Chompyy: ${result.stalled} (a hung command or a stalled agent), so the next card could run.`
|
|
342
|
-
: firstLines(result.output.replace(/^\s*CHECKS:.*$/gim, '')) || firstLines(result.stderr);
|
|
378
|
+
: firstLines(withoutRecipe(result.output).replace(/^\s*CHECKS:.*$/gim, '')) || firstLines(result.stderr);
|
|
379
|
+
recipe = parseRecipe(result.output);
|
|
343
380
|
log = `# prompt\n\n${prompt}\n\n# output\n\n${result.output}\n\n# stderr\n\n${result.stderr}\n`;
|
|
344
381
|
}
|
|
345
382
|
catch (err) {
|
|
@@ -363,6 +400,7 @@ export async function runCard(id, timeoutMs, deps, trigger) {
|
|
|
363
400
|
updateBoard((b) => {
|
|
364
401
|
const c = getCard(b, id);
|
|
365
402
|
c.column = 'review';
|
|
403
|
+
delete c.oven;
|
|
366
404
|
c.updatedAt = new Date(finishedMs).toISOString();
|
|
367
405
|
c.logPath = logPath;
|
|
368
406
|
c.run = {
|
|
@@ -376,6 +414,7 @@ export async function runCard(id, timeoutMs, deps, trigger) {
|
|
|
376
414
|
...(ws?.base ? { base: ws.base } : {}),
|
|
377
415
|
summary: summaryText,
|
|
378
416
|
...(checks ? { checks } : {}),
|
|
417
|
+
...(recipe.length ? { recipe } : {}),
|
|
379
418
|
cost,
|
|
380
419
|
...(verified ? { verified } : {}),
|
|
381
420
|
...(tokens ? { tokens } : {}),
|
package/dist/blueprint.js
CHANGED
|
@@ -128,9 +128,8 @@ export async function draftBlueprint(card, runner, opts) {
|
|
|
128
128
|
throw new Error(`claude exited with ${result.exitCode}: ${(result.stderr.trim() || result.output.trim()).slice(0, 300)}`);
|
|
129
129
|
return cleanBlueprint(result.output);
|
|
130
130
|
}
|
|
131
|
-
/** Most words
|
|
131
|
+
/** Most words a card title may have. Never cut by characters: a word cut in half reads as broken, and the board wraps titles. */
|
|
132
132
|
export const TITLE_MAX_WORDS = 10;
|
|
133
|
-
export const TITLE_MAX_CHARS = 60;
|
|
134
133
|
export function titlePrompt(idea) {
|
|
135
134
|
return `Write a short title for this task card on a kanban board. Reply with ONLY the title: at most ${TITLE_MAX_WORDS} words,
|
|
136
135
|
no quotes, no ending period, no preamble. Say what the task is about, e.g. "Retitle parked cards with a model summary".
|
|
@@ -139,7 +138,7 @@ Task: ${idea}`;
|
|
|
139
138
|
}
|
|
140
139
|
/**
|
|
141
140
|
* The model's reply as a card title: first non-empty line, without quotes, bullets, a "Title:" label or an
|
|
142
|
-
* ending period, cut to 10 words
|
|
141
|
+
* ending period, cut to 10 whole words. Empty when nothing usable is left.
|
|
143
142
|
*/
|
|
144
143
|
export function cleanTitle(output) {
|
|
145
144
|
const line = output.split('\n').map((l) => l.trim()).find((l) => l.length > 0) ?? '';
|
|
@@ -150,10 +149,7 @@ export function cleanTitle(output) {
|
|
|
150
149
|
.replace(/[.。]+$/, '')
|
|
151
150
|
.replace(/\s+/g, ' ')
|
|
152
151
|
.trim();
|
|
153
|
-
|
|
154
|
-
if (t.length > TITLE_MAX_CHARS)
|
|
155
|
-
t = t.slice(0, TITLE_MAX_CHARS - 1).trimEnd() + '…';
|
|
156
|
-
return t;
|
|
152
|
+
return t.split(' ').slice(0, TITLE_MAX_WORDS).join(' ');
|
|
157
153
|
}
|
|
158
154
|
/**
|
|
159
155
|
* A short title for the card, written by the same cheap model as the blueprint (no tools, one short call).
|
package/dist/board.js
CHANGED
|
@@ -251,6 +251,7 @@ export function recoverRunning(board, now, where = () => ({ dir: '' }), why = 'T
|
|
|
251
251
|
const ws = where(c);
|
|
252
252
|
const startedAt = c.updatedAt || now.toISOString();
|
|
253
253
|
c.column = 'review';
|
|
254
|
+
delete c.oven;
|
|
254
255
|
c.updatedAt = now.toISOString();
|
|
255
256
|
c.run = {
|
|
256
257
|
status: 'error',
|