chompyy 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -1
- package/dist/advice.js +98 -1
- package/dist/agentlimits.js +77 -0
- package/dist/agentusage.js +96 -0
- package/dist/approvals.js +129 -0
- package/dist/appstate.js +73 -3
- package/dist/away.js +48 -5
- package/dist/blueprint.js +3 -7
- package/dist/board.js +1 -0
- package/dist/cli.js +343 -18
- 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 +41 -2
- package/dist/demon.js +20 -0
- package/dist/detect.js +38 -6
- package/dist/didwork.js +26 -0
- package/dist/label.js +33 -0
- package/dist/menu.js +17 -0
- package/dist/nightcap.js +72 -0
- package/dist/nudge.js +70 -24
- package/dist/pacing.js +16 -1
- package/dist/punchcard.js +39 -0
- 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/savings.js +111 -0
- package/dist/stamps.js +14 -0
- package/dist/suggest.js +15 -5
- 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 +6955 -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/dist/wastechecks.js +233 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -17,13 +17,25 @@ import { formatDuration, parseDuration } from './duration.js';
|
|
|
17
17
|
import { budgetGate } from './gate.js';
|
|
18
18
|
import { chompyyHome, homePath } from './home.js';
|
|
19
19
|
import { loadSnapshot, saveSnapshot, statuslineSnapshot, statusLineText, statusText as baseStatusText, windowView } from './quota.js';
|
|
20
|
-
import { loadSamples } from './pacing.js';
|
|
20
|
+
import { loadSamples, pacing } from './pacing.js';
|
|
21
|
+
import { demonOffer } from './demon.js';
|
|
21
22
|
import { cardsSince, formatReport, lastReportAt, markReported, morningLine, rateCard, readTaste, tasteCountLine } from './report.js';
|
|
22
23
|
import { approvedText, changedFiles, diffCard, keepCard, overlaps, questionsOf, undoCard } from './review.js';
|
|
24
|
+
import { recipeOf } from './recipe.js';
|
|
23
25
|
import { CappedText, ClaudeRunner, claudeAvailable } from './runner.js';
|
|
24
26
|
import { branchOf, commitLeftovers, gitRoot, planWorkspace, prepareWorkspace } from './workspace.js';
|
|
25
|
-
import { answerCard, appState, cardView, currentBranch, editBlueprint, editIdea, recordCliLocation, tasteState } from './appstate.js';
|
|
26
|
-
import {
|
|
27
|
+
import { answerCard, appState, cardView, currentBranch, editBlueprint, editIdea, nightcapNow, providersState, recordCliLocation, tasteState } from './appstate.js';
|
|
28
|
+
import { codexInstalled, refreshCodexQuota } from './codexquota.js';
|
|
29
|
+
import { refreshAgents } from './agentusage.js';
|
|
30
|
+
import { stampCard } from './stamps.js';
|
|
31
|
+
import { nutritionLabel } from './label.js';
|
|
32
|
+
import { recap, recapMonth } from './recap.js';
|
|
33
|
+
import { menuFrom } from './menu.js';
|
|
34
|
+
import { limitsState, READERS, refreshLimits } from './agentlimits.js';
|
|
35
|
+
import { detectFull, detectText, scan } from './detect.js';
|
|
36
|
+
import { savingsView } from './savings.js';
|
|
37
|
+
import { punchcard } from './punchcard.js';
|
|
38
|
+
import { approvalsPrompt, approvalStats, approvalsText, decisions, featureStats, loadArchive } from './approvals.js';
|
|
27
39
|
import { allWindowEnds, archiveWindowEnds, premise, premiseText } from './premise.js';
|
|
28
40
|
import { keychainAllowed, loadLiveState, refreshLiveQuota } from './livequota.js';
|
|
29
41
|
import { recentProjects } from './projects.js';
|
|
@@ -32,16 +44,17 @@ import { buildDigest, historyRetention, scanHistory } from './history.js';
|
|
|
32
44
|
import { acceptColdStart, forgetColdStart, formatColdStart, loadColdStart, runColdStart } from './coldstart.js';
|
|
33
45
|
import { keepHistory } from './claudesettings.js';
|
|
34
46
|
import { blueprintHash, drawPicture } from './picture.js';
|
|
35
|
-
import {
|
|
47
|
+
import { receipt, receiptText } from './receipt.js';
|
|
48
|
+
import { costRange, formatCostRange, hitRate, readRuns, tasteEffect, tasteEffectLine, trendLines } from './costs.js';
|
|
36
49
|
import { answerPreference, distill, distillDue, formatPrefs, formatQuestion, formatWhy, getPref, learnedCount, loadStore, nextQuestion, readSignals, recordOutcome, renderAgentsBlock, retirePreference, syncTasteFile, tasteChangesSince, tasteRulesForProject, } from './taste.js';
|
|
37
50
|
import { cachedWorkspaces, dream, dreamDue, formatDream, formatWorkspaces, projectsDir, readLogPath, setTicked } from './dream.js';
|
|
38
|
-
import { byKind, compare, formatExtras, formatUsage, loadLedger, periodDays, PERIODS, prCosts, usageView } from './usage.js';
|
|
51
|
+
import { byKind, compactTokens, compare, formatExtras, formatUsage, loadLedger, periodDays, PERIODS, prCosts, usageView } from './usage.js';
|
|
39
52
|
import { formatTrace, traceSession } from './trace.js';
|
|
40
53
|
import { homedir } from 'node:os';
|
|
41
54
|
import { clashOf, refreshCard, refreshGate, refreshClashing, withRefreshLock } from './refresh.js';
|
|
42
|
-
import { adviseText, applyDue, approveAdvice, runAdvise, undoAdvice } from './advice.js';
|
|
55
|
+
import { adviceFrom, adviseText, applyDue, approveAdvice, droppedKeys, fixForMe, runAdvise, SELF_LANES, undoAdvice } from './advice.js';
|
|
43
56
|
import { daytimeFile, daytimeState, setDaytime } from './daytime.js';
|
|
44
|
-
import { checkWorked, nudgeProofText, savedSoFar, shareText, workedText } from './didwork.js';
|
|
57
|
+
import { checkWorked, isNewCheck, measurable, newCheckDays, nudgeProofText, savedSoFar, shareText, workedText } from './didwork.js';
|
|
45
58
|
import { addSuggested, suggestTasks, suggestText } from './suggest.js';
|
|
46
59
|
import { coldWarningText, hookCommand, impact, loadNudges, nudgeInstalled, nudgeText, runHook, setNudge, setProjectMode, takeGoingCold } from './nudge.js';
|
|
47
60
|
import { withKeepLock } from './keeplock.js';
|
|
@@ -49,7 +62,7 @@ import { sendKept } from './send.js';
|
|
|
49
62
|
import { planUnkeep, unkeep } from './unkeep.js';
|
|
50
63
|
import { cacheText, composeLine, setStatusline, statuslineInstalled, statusLineOutput, wrappedCommand } from './statusline.js';
|
|
51
64
|
import { formatLive, keepAffectsLive, liveOff, liveSet, liveUpdateLocked, loadLive, startLiveUpdate } from './live.js';
|
|
52
|
-
import { agentInstalled, awayRunning, bedtimeKey, decideTrigger, installAgent, loadTriggerState, markFired, noteTick, parseClock, takeAwayLock, uninstallAgent } from './triggers.js';
|
|
65
|
+
import { agentInstalled, awayRunning, bedtimeKey, decideTrigger, installAgent, loadTriggerState, markFired, noteTick, parseClock, takeAwayLock, uninstallAgent, unmarkFired } from './triggers.js';
|
|
53
66
|
import { exe } from './exe.js';
|
|
54
67
|
const HELP = `chompyy: use the 5-hour window capacity that would reset unused
|
|
55
68
|
|
|
@@ -97,6 +110,7 @@ Away
|
|
|
97
110
|
Back
|
|
98
111
|
chompyy report [--all] what ran, and the one thing to do about each
|
|
99
112
|
chompyy diff <id> the change it made
|
|
113
|
+
chompyy recipe <id> [--json] a kept card as a recipe: files, steps, when it landed
|
|
100
114
|
chompyy keep <id> merge its branch into the branch it started from (and update the live app, if set)
|
|
101
115
|
chompyy send [--json] open one PR on GitHub per kept card GitHub's main doesn't have yet
|
|
102
116
|
chompyy refresh [<id>] bring cards in review up to date with main (Chompyy does this by itself after each Keep)
|
|
@@ -133,6 +147,18 @@ Taste (learned from what you keep, undo, edit and rate)
|
|
|
133
147
|
Triggers (start away runs on their own; the budget gate still decides every card)
|
|
134
148
|
chompyy triggers on|off install or remove the macOS LaunchAgent that runs \`chompyy tick\` every 5 minutes
|
|
135
149
|
chompyy triggers what is set, and what the last tick decided
|
|
150
|
+
chompyy limits [<agent> on|off] limits for Gemini CLI, Copilot, Antigravity, Kimi Code, Grok Bot (off until you allow each)
|
|
151
|
+
chompyy recap [--month 2026-11] [--json] your month on one shareable card: tokens, busiest day, cards baked
|
|
152
|
+
chompyy menu [--json] every agent you used in 30 days as a café chalkboard: tokens and value, safe to share
|
|
153
|
+
chompyy label [--json] your week as Nutrition Facts: cached reads, cache writes, resent tokens, output; shareable
|
|
154
|
+
chompyy approvals [--json] which suggestions you approve, by kind; ranks new suggestions
|
|
155
|
+
chompyy savings [--json] where your tokens went, what's worth fixing, what your fixes saved
|
|
156
|
+
chompyy stamps [--json] your loyalty stamp card: one stamp per kept card, ten to a card; shareable
|
|
157
|
+
chompyy agents [--json] every other coding agent on this Mac (Cursor, Copilot, Gemini, …): tokens and value
|
|
158
|
+
chompyy codex [on|off] [--json] Codex's limits and tokens beside Claude's (on = read its login, never change it)
|
|
159
|
+
chompyy nightcap [on [23:30]|skip|unskip] tonight's bedtime run: turn it on, or skip tonight
|
|
160
|
+
chompyy demon [on|off] eat what's left of a window before it resets: run approved cards (on = every window)
|
|
161
|
+
chompyy receipt [--json] your week as a bake-sale receipt: cards baked, kept, burnt, tokens; safe to share
|
|
136
162
|
chompyy bedtime <23:30|off> run approved cards at bedtime (with the window that is left)
|
|
137
163
|
chompyy last-hour <on|off> run approved cards in the last hour before a 5-hour reset
|
|
138
164
|
chompyy missed-reset <on|off> run approved cards on the first tick after a reset nothing used (default off)
|
|
@@ -492,6 +518,7 @@ async function main(argv) {
|
|
|
492
518
|
share: { type: 'boolean' },
|
|
493
519
|
quiet: { type: 'boolean' },
|
|
494
520
|
model: { type: 'string' },
|
|
521
|
+
month: { type: 'string' },
|
|
495
522
|
column: { type: 'string', multiple: true },
|
|
496
523
|
help: { type: 'boolean', short: 'h' },
|
|
497
524
|
json: { type: 'boolean' },
|
|
@@ -521,6 +548,11 @@ async function main(argv) {
|
|
|
521
548
|
recordCliLocation();
|
|
522
549
|
/** Fresh quota before anything that reads it (at most every 5 minutes unless forced). */
|
|
523
550
|
const freshQuota = async (force = false) => {
|
|
551
|
+
// Codex beside Claude, once you allowed it (read-only; never renews its login).
|
|
552
|
+
if (loadConfig().codexQuota && codexInstalled())
|
|
553
|
+
await refreshCodexQuota({ force }).catch(() => null);
|
|
554
|
+
// And the other agents whose limits you allowed (read-only, each at most every 5 minutes).
|
|
555
|
+
await refreshLimits(loadConfig().agentLimits ?? {}, { force }).catch(() => null);
|
|
524
556
|
if (loadConfig().quotaSource !== 'api')
|
|
525
557
|
return null;
|
|
526
558
|
try {
|
|
@@ -577,6 +609,174 @@ async function main(argv) {
|
|
|
577
609
|
console.log(statusText(loadSnapshot(), now));
|
|
578
610
|
return;
|
|
579
611
|
}
|
|
612
|
+
case 'limits': {
|
|
613
|
+
// Limits for Gemini CLI, Copilot, Antigravity, Kimi Code and Grok Bot: each off until you allow it.
|
|
614
|
+
const [name, sub] = args;
|
|
615
|
+
const config = loadConfig();
|
|
616
|
+
const allowed = { ...(config.agentLimits ?? {}) };
|
|
617
|
+
if (name && (sub === 'on' || sub === 'off')) {
|
|
618
|
+
const r = READERS.find((x) => x.name === name);
|
|
619
|
+
if (!r)
|
|
620
|
+
throw new Error(`No limits reader for "${name}". Agents with one: ${READERS.map((x) => x.name).join(', ')}.`);
|
|
621
|
+
allowed[name] = sub === 'on';
|
|
622
|
+
setConfig('agentLimits', allowed);
|
|
623
|
+
if (sub === 'off')
|
|
624
|
+
return console.log(`${r.displayName} limits off. Chompyy won't use ${r.login}.`);
|
|
625
|
+
const got = (await refreshLimits(allowed, { force: true }))[name];
|
|
626
|
+
if (!r.installed())
|
|
627
|
+
return console.log(`${r.displayName} limits on, once it's on this Mac.`);
|
|
628
|
+
return console.log(got?.primary ? `${r.displayName}: ${Math.round(100 - got.primary.usedPct)}% left (${got.primary.label}). Chompyy only reads ${r.login}.` : `${r.displayName} limits on, but: ${got?.note ?? got?.connection ?? 'nothing read yet'}`);
|
|
629
|
+
}
|
|
630
|
+
if (name || sub)
|
|
631
|
+
throw new Error('Usage: chompyy limits [<agent> on|off] [--json]');
|
|
632
|
+
await refreshLimits(allowed, { force: Boolean(values.refresh) });
|
|
633
|
+
const st = limitsState(allowed);
|
|
634
|
+
if (values.json)
|
|
635
|
+
return json(st);
|
|
636
|
+
const names = Object.keys(st);
|
|
637
|
+
if (!names.length)
|
|
638
|
+
return console.log('No agent with readable limits on this Mac (Gemini CLI, Copilot, Antigravity, Kimi Code, Grok Bot).');
|
|
639
|
+
for (const n of names) {
|
|
640
|
+
const a = st[n];
|
|
641
|
+
if (a.allowed !== true)
|
|
642
|
+
console.log(`${a.displayName}: off. Turn on (uses ${a.login}, read-only): chompyy limits ${n} on`);
|
|
643
|
+
else if (a.limit?.primary)
|
|
644
|
+
console.log(`${a.displayName}: ${Math.round(100 - a.limit.primary.usedPct)}% left (${a.limit.primary.label})${a.limit.plan ? ` · ${a.limit.plan}` : ''}`);
|
|
645
|
+
else
|
|
646
|
+
console.log(`${a.displayName}: ${a.limit?.note ?? a.limit?.connection ?? 'not read yet'}`);
|
|
647
|
+
}
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
case 'recap': {
|
|
651
|
+
// The monthly recap: the month in numbers on one card, safe to share (no names).
|
|
652
|
+
const r = recap(loadLedger().rows, readRuns(), loadBoard().cards, recapMonth(now, values.month));
|
|
653
|
+
if (values.json)
|
|
654
|
+
return json(r);
|
|
655
|
+
if (!r.tokens)
|
|
656
|
+
return console.log(`Nothing to recap for ${r.label} yet.`);
|
|
657
|
+
console.log(`Your ${r.label} with Chompyy`);
|
|
658
|
+
console.log(` ${compactTokens(r.tokens)} tokens ($${r.costUsd.toFixed(2)} API value), about ${r.cookies.toLocaleString('en-US')} cookies`);
|
|
659
|
+
if (r.busiestDay)
|
|
660
|
+
console.log(` Busiest day: ${r.busiestDay.day} (${compactTokens(r.busiestDay.tokens)})`);
|
|
661
|
+
console.log(` ${r.conversations} conversations on ${r.activeDays} days · ${r.cardsBaked} cards baked, ${r.kept} kept`);
|
|
662
|
+
if (r.biggestBake)
|
|
663
|
+
console.log(` Biggest bake: ${compactTokens(r.biggestBake.tokens)} tokens in ${r.biggestBake.minutes} min`);
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
case 'menu': {
|
|
667
|
+
// The chalkboard menu: every agent you used in the last 30 days, tokens and API value. Safe to share.
|
|
668
|
+
const agents = await refreshAgents({});
|
|
669
|
+
const view = usageView(loadLedger(), now, 30);
|
|
670
|
+
const top = view.byModel[0]?.model ?? null;
|
|
671
|
+
const m = menuFrom({ tokens: view.total.tokens, costUsd: view.total.costUsd, model: top }, agents.agents, now);
|
|
672
|
+
if (values.json)
|
|
673
|
+
return json(m);
|
|
674
|
+
if (!m.items.length)
|
|
675
|
+
return console.log('Nothing on the menu: no agent used in the last 30 days.');
|
|
676
|
+
console.log('CHOMPYY CAFÉ · last 30 days');
|
|
677
|
+
for (const i of m.items)
|
|
678
|
+
console.log(` ${i.name.padEnd(16, '.')} ${compactTokens(i.tokens).padStart(7)} · $${i.costUsd.toFixed(2)}`);
|
|
679
|
+
console.log(` ${'Total'.padEnd(16, '.')} ${compactTokens(m.total.tokens).padStart(7)} · $${m.total.costUsd.toFixed(2)}`);
|
|
680
|
+
if (m.special)
|
|
681
|
+
console.log(`Today's special: ${m.special}`);
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
case 'label': {
|
|
685
|
+
// The nutrition label: the week's tokens as Nutrition Facts, safe to share (no names).
|
|
686
|
+
let resent = 0;
|
|
687
|
+
try {
|
|
688
|
+
resent = impact().thisWeek.tokens;
|
|
689
|
+
}
|
|
690
|
+
catch { }
|
|
691
|
+
const l = nutritionLabel(loadLedger().rows, resent, now);
|
|
692
|
+
if (values.json)
|
|
693
|
+
return json(l);
|
|
694
|
+
console.log(`Nutrition Facts · ${compactTokens(l.tokens)} tokens over ${l.servings} conversations`);
|
|
695
|
+
for (const x of l.lines)
|
|
696
|
+
console.log(` ${x.sub ? ' ' : ''}${x.name} (${x.kind})`.padEnd(38) + `${compactTokens(x.tokens).padStart(7)} ${x.pct}%`);
|
|
697
|
+
console.log(l.tip);
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
case 'savings': {
|
|
701
|
+
// The Savings window: the week as one bar (fine vs fixable), every waste ranked with its status and
|
|
702
|
+
// before → after, and one conversation step by step (savings.ts).
|
|
703
|
+
let resent = 0;
|
|
704
|
+
try {
|
|
705
|
+
resent = impact().thisWeek.tokens;
|
|
706
|
+
}
|
|
707
|
+
catch { }
|
|
708
|
+
const label = nutritionLabel(loadLedger().rows, resent, now);
|
|
709
|
+
const r = await detectFull({ now });
|
|
710
|
+
const cards = loadBoard().cards;
|
|
711
|
+
const { total } = savedSoFar(cards.filter((c) => c.advice), now, { on: nudgeInstalled() || loadNudges().length > 0 });
|
|
712
|
+
const view = savingsView({ label, detect: r, cards, saved: total ? { tokens: total.tokens, since: total.since, line: total.line } : null, scan: scan({ days: 14, now }), now, dropped: droppedKeys(), autoKeys: new Set(adviceFrom(r, { nudgeOn: nudgeInstalled() }).filter((d) => SELF_LANES.has(d.advice.lane)).map((d) => d.advice.key)) });
|
|
713
|
+
if (values.json)
|
|
714
|
+
return json(view);
|
|
715
|
+
console.log(`This week: ${compactTokens(view.week.tokens)} tokens, ${view.week.parts.filter((p) => p.fixable).map((p) => `${compactTokens(p.tokens)} resent for nothing`).join('') || 'nothing resent'}.`);
|
|
716
|
+
if (view.saved)
|
|
717
|
+
console.log(view.saved.line);
|
|
718
|
+
console.log(`Still fixable: ~${compactTokens(view.fixable.tokens)} tokens in ${view.fixable.days} days.\n`);
|
|
719
|
+
for (const row of view.rows.slice(0, 5))
|
|
720
|
+
console.log(` ${row.status.padEnd(13)} ${row.tokens === undefined ? '' : compactTokens(row.tokens).padStart(6)} ${row.title}`);
|
|
721
|
+
console.log('\nOpen it as a picture: the Savings window in the app.');
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
case 'stamps': {
|
|
725
|
+
// The loyalty stamp card: one stamp per kept card, ten to a card. Safe to share (no titles).
|
|
726
|
+
const c = stampCard(loadBoard().cards);
|
|
727
|
+
if (values.json)
|
|
728
|
+
return json(c);
|
|
729
|
+
console.log(`Stamp card: ${'●'.repeat(c.stamps.length)}${'○'.repeat(c.full ? 0 : c.toGo)} (${c.stamps.length}/10)`);
|
|
730
|
+
console.log(c.full ? `Card full! That's ${c.fullCards} full card${c.fullCards === 1 ? '' : 's'}: ${c.kept} kept in all.` : `${c.toGo} more kept card${c.toGo === 1 ? '' : 's'} to fill it · ${c.fullCards} full so far, ${c.kept} kept in all.`);
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
case 'agents': {
|
|
734
|
+
// Every other coding agent codeburn reads: tokens and API value this week and over 30 and 90 days.
|
|
735
|
+
const f = await refreshAgents({ force: Boolean(values.refresh) });
|
|
736
|
+
if (values.json)
|
|
737
|
+
return json(f);
|
|
738
|
+
if (!f.agents.length)
|
|
739
|
+
return console.log('No other agent used on this Mac in the last 90 days.');
|
|
740
|
+
const usd = (n) => `$${n.toFixed(2)}`;
|
|
741
|
+
for (const a of f.agents.slice(0, 5)) {
|
|
742
|
+
console.log(`${a.displayName}: ${compactTokens(a.week.tokens)} this week · ${compactTokens(a.month.tokens)} in 30 days · ${compactTokens(a.quarter.tokens)} in 90 days (${usd(a.quarter.costUsd)})`);
|
|
743
|
+
}
|
|
744
|
+
if (f.agents.length > 5)
|
|
745
|
+
console.log(`…and ${f.agents.length - 5} more: chompyy agents --json`);
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
case 'codex': {
|
|
749
|
+
// The second provider: Codex's limits (read-only login).
|
|
750
|
+
const sub = args[0];
|
|
751
|
+
if (sub === 'on') {
|
|
752
|
+
setConfig('codexQuota', true);
|
|
753
|
+
const r = await refreshCodexQuota({ force: true });
|
|
754
|
+
return console.log(r.ok ? `Codex quota on. ${r.message} Chompyy only reads Codex's login; it never renews or changes it.` : `Codex quota on, but: ${r.message}`);
|
|
755
|
+
}
|
|
756
|
+
if (sub === 'off') {
|
|
757
|
+
setConfig('codexQuota', false);
|
|
758
|
+
return console.log("Codex quota off. Chompyy won't read Codex's login.");
|
|
759
|
+
}
|
|
760
|
+
if (sub)
|
|
761
|
+
throw new Error('Usage: chompyy codex [on|off] [--json]');
|
|
762
|
+
if (!codexInstalled())
|
|
763
|
+
return console.log('Codex isn\'t on this Mac (no ~/.codex).');
|
|
764
|
+
const config = loadConfig();
|
|
765
|
+
if (config.codexQuota)
|
|
766
|
+
await refreshCodexQuota({ force: Boolean(values.refresh) });
|
|
767
|
+
const p = providersState(config, now).codex;
|
|
768
|
+
if (values.json)
|
|
769
|
+
return json(p);
|
|
770
|
+
if (!config.codexQuota)
|
|
771
|
+
return console.log("Codex quota is off. Turn it on (reads Codex's saved login, never changes it): chompyy codex on");
|
|
772
|
+
if (!p.fiveHour.known)
|
|
773
|
+
return console.log(p.note ?? 'No Codex quota yet.');
|
|
774
|
+
const pct = (n) => `${Math.round(n)}%`;
|
|
775
|
+
console.log(`Codex${p.plan ? ` ${p.plan}` : ''}: 5h ${pct(p.fiveHour.leftPct)} left${p.sevenDay.known ? ` · week ${pct(p.sevenDay.usedPct)} used` : ''}`);
|
|
776
|
+
if (p.usage)
|
|
777
|
+
console.log(`Tokens: ${compactTokens(p.usage.today.tokens)} today ($${p.usage.today.costUsd.toFixed(2)}) · ${compactTokens(p.usage.week.tokens)} this week ($${p.usage.week.costUsd.toFixed(2)})`);
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
580
780
|
case 'state': {
|
|
581
781
|
const refreshed = await freshQuota(Boolean(values.refresh));
|
|
582
782
|
draftPending(now);
|
|
@@ -780,7 +980,7 @@ async function main(argv) {
|
|
|
780
980
|
console.log(` #${card.id} ${card.title} [${state}]`);
|
|
781
981
|
if (card.column === 'later' && !card.blueprint?.trim())
|
|
782
982
|
console.log(' blueprint needed before approval');
|
|
783
|
-
console.log(` ${formatCostRange(costRange(card, runs))}`);
|
|
983
|
+
console.log(` ${formatCostRange(costRange(card, runs), hitRate(runs))}`);
|
|
784
984
|
}
|
|
785
985
|
console.log('\nThis is a read-only list. Start selected work with `chompyy away <duration>`.');
|
|
786
986
|
return;
|
|
@@ -844,7 +1044,7 @@ async function main(argv) {
|
|
|
844
1044
|
return json(cardView(card));
|
|
845
1045
|
console.log(formatCard(card));
|
|
846
1046
|
if (!card.run)
|
|
847
|
-
console.log(`\n${formatCostRange(costRange(card, readRuns()))}`);
|
|
1047
|
+
console.log(`\n${formatCostRange(costRange(card, readRuns()), hitRate(readRuns()))}`);
|
|
848
1048
|
else if (card.run.cost?.fiveHourPct != null)
|
|
849
1049
|
console.log(`used ${card.run.cost.fiveHourPct}% of the 5h window${card.run.trigger ? ` · started by the ${card.run.trigger} trigger` : ''}`);
|
|
850
1050
|
return;
|
|
@@ -1067,6 +1267,71 @@ async function main(argv) {
|
|
|
1067
1267
|
console.log(`last tick ${st.lastTickAt.slice(0, 16).replace('T', ' ')}: ${st.lastDecision ?? ''}`);
|
|
1068
1268
|
return;
|
|
1069
1269
|
}
|
|
1270
|
+
case 'nightcap': {
|
|
1271
|
+
// The evening offer in the panel: run approved cards at bedtime, or skip tonight.
|
|
1272
|
+
const sub = args[0];
|
|
1273
|
+
const now2 = now;
|
|
1274
|
+
if (sub === 'on') {
|
|
1275
|
+
const t = args[1] ?? loadConfig().bedtime ?? '23:30';
|
|
1276
|
+
parseClock(t);
|
|
1277
|
+
setConfig('bedtime', t);
|
|
1278
|
+
installAgent();
|
|
1279
|
+
return console.log(`🌙 Tonight at ${t}: approved cards run while you sleep.`);
|
|
1280
|
+
}
|
|
1281
|
+
const cap = nightcapNow(loadBoard(), loadConfig(), now2);
|
|
1282
|
+
if (sub === 'skip' || sub === 'not-tonight') {
|
|
1283
|
+
if (!cap)
|
|
1284
|
+
return console.log('Nothing planned for tonight.');
|
|
1285
|
+
markFired(cap.key, now2, 'skipped tonight from the panel');
|
|
1286
|
+
return console.log(cap.phase === 'offer' ? 'Not tonight. Ask again tomorrow evening.' : `Skipping tonight. Back tomorrow at ${cap.bedtime}.`);
|
|
1287
|
+
}
|
|
1288
|
+
if (sub === 'unskip') {
|
|
1289
|
+
if (!cap || cap.phase !== 'skipped')
|
|
1290
|
+
return console.log('Tonight is not skipped.');
|
|
1291
|
+
unmarkFired(cap.key);
|
|
1292
|
+
return console.log(`Back on: tonight at ${cap.bedtime}.`);
|
|
1293
|
+
}
|
|
1294
|
+
if (sub)
|
|
1295
|
+
throw new Error('Usage: chompyy nightcap [on [23:30]|skip|unskip]');
|
|
1296
|
+
if (values.json)
|
|
1297
|
+
return json(cap);
|
|
1298
|
+
if (!cap)
|
|
1299
|
+
return console.log('No nightcap now: it shows in the evening when cards are approved.');
|
|
1300
|
+
const line = { offer: `Leave it to me tonight? ${cap.cards} card(s) could run at ${cap.bedtime}: chompyy nightcap on ${cap.bedtime}`,
|
|
1301
|
+
armed: `Tonight at ${cap.bedtime}: ${cap.cards} card(s) run while you sleep. Skip: chompyy nightcap skip`,
|
|
1302
|
+
skipped: `Skipping tonight. Back on: chompyy nightcap unskip`, running: 'Running your cards. Sleep well.' }[cap.phase];
|
|
1303
|
+
return console.log(`🌙 ${line}`);
|
|
1304
|
+
}
|
|
1305
|
+
case 'demon': {
|
|
1306
|
+
// Demon mode: run approved cards in the last hour of a window that would otherwise reset unused.
|
|
1307
|
+
const sub = args[0];
|
|
1308
|
+
if (sub === 'on') {
|
|
1309
|
+
setConfig('lastHourTrigger', true);
|
|
1310
|
+
installAgent();
|
|
1311
|
+
return console.log(`😈 Demon mode on: in the last hour before a reset, Chompyy eats what's left (with ≥${loadConfig().lastHourMinLeftPct}% left).`);
|
|
1312
|
+
}
|
|
1313
|
+
if (sub === 'off') {
|
|
1314
|
+
setConfig('lastHourTrigger', false);
|
|
1315
|
+
const c = loadConfig();
|
|
1316
|
+
if (!c.bedtime && !c.missedReset)
|
|
1317
|
+
uninstallAgent();
|
|
1318
|
+
return console.log('Demon mode off. Leftover windows just reset.');
|
|
1319
|
+
}
|
|
1320
|
+
if (sub)
|
|
1321
|
+
throw new Error('Usage: chompyy demon [on|off]');
|
|
1322
|
+
await freshQuota();
|
|
1323
|
+
const snap = loadSnapshot();
|
|
1324
|
+
const config = loadConfig();
|
|
1325
|
+
const offer = demonOffer(windowView(snap?.fiveHour, now), pacing(snap, loadSamples(), now, config.bedtime).fiveHourForecast, loadBoard().cards.filter((c) => c.column === 'approved').length, awayRunning() !== null);
|
|
1326
|
+
const auto = config.lastHourTrigger && agentInstalled();
|
|
1327
|
+
if (values.json)
|
|
1328
|
+
return json({ offer, auto });
|
|
1329
|
+
console.log(offer
|
|
1330
|
+
? `😈 ~${offer.unusedPct}% of this window resets unused. Eat it: chompyy away ${offer.duration} (${offer.cards} card${offer.cards === 1 ? '' : 's'} ready).`
|
|
1331
|
+
: 'Nothing to eat right now: Chompyy offers in the last 90 minutes when 20% or more would go unused and a card is approved.');
|
|
1332
|
+
console.log(`Every window: ${auto ? 'on' : 'off (chompyy demon on)'}`);
|
|
1333
|
+
return;
|
|
1334
|
+
}
|
|
1070
1335
|
case 'bedtime': {
|
|
1071
1336
|
const v = need(args[0], 'chompyy bedtime <23:30|off>');
|
|
1072
1337
|
if (v === 'off') {
|
|
@@ -1135,7 +1400,7 @@ async function main(argv) {
|
|
|
1135
1400
|
if (values.json && values.app) {
|
|
1136
1401
|
const long = usageView(ledger, now, 84, 0, canShow);
|
|
1137
1402
|
const week = usageView(ledger, now, 7, 10, canShow);
|
|
1138
|
-
return json({ generatedAt: to, period: period || `${days}d`, days: long.days, today: long.today, week, view: { ...view, byKind: kinds, prs }, compare: cmp, unpriced: long.unpriced });
|
|
1403
|
+
return json({ generatedAt: to, period: period || `${days}d`, days: long.days, today: long.today, week, view: { ...view, byKind: kinds, prs }, compare: cmp, unpriced: long.unpriced, punchcard: punchcard(ledger.rows, now) });
|
|
1139
1404
|
}
|
|
1140
1405
|
if (values.json)
|
|
1141
1406
|
return json({ ...view, byKind: kinds, prs, compare: cmp });
|
|
@@ -1168,7 +1433,7 @@ async function main(argv) {
|
|
|
1168
1433
|
return;
|
|
1169
1434
|
}
|
|
1170
1435
|
case 'detect': {
|
|
1171
|
-
const r =
|
|
1436
|
+
const r = await detectFull({ days: values.days ? Number(values.days) : 30, now });
|
|
1172
1437
|
if (values.json)
|
|
1173
1438
|
return json(r);
|
|
1174
1439
|
console.log(detectText(r, { all: Boolean(values.all), projects: projectsDir().replace(homedir(), '~') }).join('\n'));
|
|
@@ -1183,14 +1448,53 @@ async function main(argv) {
|
|
|
1183
1448
|
return json(lines);
|
|
1184
1449
|
return console.log(lines.length ? lines.join('\n') : 'Nothing waiting to be applied.');
|
|
1185
1450
|
}
|
|
1186
|
-
const
|
|
1451
|
+
const found = await detectFull({ now });
|
|
1452
|
+
if (args[0] === 'fix') {
|
|
1453
|
+
// "Fix these for me" (Savings window): cards for every finding, then approve what Chompyy can do itself.
|
|
1454
|
+
updateBoard((b) => runAdvise(b, now, found));
|
|
1455
|
+
const res = updateBoard((b) => fixForMe(b, now));
|
|
1456
|
+
const applied = updateBoard((b) => applyDue(b, now));
|
|
1457
|
+
if (values.json)
|
|
1458
|
+
return json({ approved: res.approved.map((c) => ({ id: c.id, title: c.title, lane: c.advice.lane })), needsYou: res.needsYou, applied });
|
|
1459
|
+
if (!res.approved.length)
|
|
1460
|
+
return console.log(`Nothing Chompyy can fix by itself right now.${res.needsYou ? ` ${res.needsYou} need you: habits and steps only you can take.` : ''}`);
|
|
1461
|
+
console.log(`Fixing ${res.approved.length}:`);
|
|
1462
|
+
for (const c of res.approved)
|
|
1463
|
+
console.log(` #${c.id} ${c.title} · ${c.advice.lane === 'work' ? 'runs in the next away run' : 'settings, once no session has run for 10 min (Undo any time)'}`);
|
|
1464
|
+
for (const line of applied)
|
|
1465
|
+
console.log(` ${line}`);
|
|
1466
|
+
if (res.needsYou)
|
|
1467
|
+
console.log(`${res.needsYou} need you: habits and steps only you can take.`);
|
|
1468
|
+
return;
|
|
1469
|
+
}
|
|
1470
|
+
const res = updateBoard((b) => runAdvise(b, now, found));
|
|
1187
1471
|
if (values.json)
|
|
1188
1472
|
return json({ added: res.added.map((c) => c.id), updated: res.updated.map((c) => c.id), skipped: res.skipped });
|
|
1189
1473
|
return console.log(adviseText(res));
|
|
1190
1474
|
}
|
|
1475
|
+
case 'receipt': {
|
|
1476
|
+
// The Sunday bake-sale receipt: the week in counts, tokens and dollars, safe to share (no names).
|
|
1477
|
+
let resent = null;
|
|
1478
|
+
try {
|
|
1479
|
+
const i = impact();
|
|
1480
|
+
resent = { thisWeek: i.thisWeek.tokens, lastWeek: i.lastWeek.tokens };
|
|
1481
|
+
}
|
|
1482
|
+
catch { }
|
|
1483
|
+
const r = receipt(readRuns(), loadBoard().cards, resent, now);
|
|
1484
|
+
if (values.json)
|
|
1485
|
+
return json(r);
|
|
1486
|
+
return console.log(receiptText(r));
|
|
1487
|
+
}
|
|
1191
1488
|
case 'worked': {
|
|
1192
1489
|
// The detective, step 5: each applied/tried advice card against the check it registered (didwork.ts).
|
|
1193
|
-
|
|
1490
|
+
// New-check cards (codeburn's checks, our newer rules) re-run those checks over the days since each started.
|
|
1491
|
+
const recheck = new Map();
|
|
1492
|
+
for (const c of loadBoard().cards.filter((x) => measurable(x) && isNewCheck(x.advice))) {
|
|
1493
|
+
const days = newCheckDays(Date.parse(c.advice.since ?? c.approvedAt ?? c.updatedAt), now.getTime());
|
|
1494
|
+
if (days >= 7 && !recheck.has(days))
|
|
1495
|
+
recheck.set(days, (await detectFull({ days, now })).findings);
|
|
1496
|
+
}
|
|
1497
|
+
const cards = updateBoard((b) => checkWorked(b, now, { recheck }));
|
|
1194
1498
|
const { proof, total } = savedSoFar(cards, now, { on: nudgeInstalled() || loadNudges().length > 0 });
|
|
1195
1499
|
if (values.share) {
|
|
1196
1500
|
// A summary to paste on the tester issue: counts, tokens and dates; no project, skill or file names.
|
|
@@ -1216,13 +1520,25 @@ async function main(argv) {
|
|
|
1216
1520
|
throw new Error('Suggesting tasks needs the claude command (Claude Code in Terminal). See TRY.md.');
|
|
1217
1521
|
if (!values.force && !windowActive(now))
|
|
1218
1522
|
throw new Error('No active 5-hour window: suggesting now would start one. Try again while you use Claude Code, or add --force.');
|
|
1219
|
-
const
|
|
1220
|
-
const
|
|
1221
|
-
|
|
1523
|
+
const board = loadBoard();
|
|
1524
|
+
const existing = board.cards.map((c) => c.title);
|
|
1525
|
+
// What you tend to approve (approvals.ts) steers the suggester and ranks what comes back.
|
|
1526
|
+
const stats = approvalStats(board);
|
|
1527
|
+
const { tasks, dropped } = await suggestTasks(repo, new ClaudeRunner(config.claudeBin), { model: config.suggestModel, cwd: chompyyHome(), existing, approvals: approvalsPrompt(stats) });
|
|
1528
|
+
const cards = updateBoard((b) => addSuggested(b, repo, tasks, now, stats));
|
|
1222
1529
|
if (values.json)
|
|
1223
1530
|
return json({ repo, added: cards.map((c) => ({ id: c.id, title: c.title, why: c.why })), dropped });
|
|
1224
1531
|
return console.log(suggestText(repo, cards, dropped));
|
|
1225
1532
|
}
|
|
1533
|
+
case 'approvals': {
|
|
1534
|
+
// Which suggestions you approve: the rate per kind of card, from approvals, drops and expiries.
|
|
1535
|
+
const board = loadBoard();
|
|
1536
|
+
const ds = decisions(board, loadArchive());
|
|
1537
|
+
const stats = featureStats(ds);
|
|
1538
|
+
if (values.json)
|
|
1539
|
+
return json({ decisions: ds.length, features: stats });
|
|
1540
|
+
return console.log(approvalsText(stats, ds.length));
|
|
1541
|
+
}
|
|
1226
1542
|
case 'hook': {
|
|
1227
1543
|
// Claude Code's UserPromptSubmit hook. Must never fail loudly or stop a prompt by accident.
|
|
1228
1544
|
if (args[0] !== 'prompt')
|
|
@@ -1256,7 +1572,7 @@ async function main(argv) {
|
|
|
1256
1572
|
// Plus the running total: what was counted (stops, re-counted fixes), from the results `worked` last wrote.
|
|
1257
1573
|
const i = impact();
|
|
1258
1574
|
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 } } : {}) });
|
|
1575
|
+
return json({ ...i, ...(p ? { verdict: { verdict: p.result.verdict, line: p.result.line, dueAt: p.result.dueAt } } : {}), ...(total ? { total: { tokens: total.tokens, since: total.since, line: total.line } } : {}) });
|
|
1260
1576
|
}
|
|
1261
1577
|
return console.log([nudgeText(nudgeInstalled()), impact().line].join('\n'));
|
|
1262
1578
|
}
|
|
@@ -1293,6 +1609,15 @@ async function main(argv) {
|
|
|
1293
1609
|
markReported(now);
|
|
1294
1610
|
return;
|
|
1295
1611
|
}
|
|
1612
|
+
case 'recipe': {
|
|
1613
|
+
// A kept card as a recipe (the app's recipe card): ingredients, steps, when it was served.
|
|
1614
|
+
const card = getCard(loadBoard(), need(args[0], 'chompyy recipe <id>'));
|
|
1615
|
+
const r = recipeOf(card);
|
|
1616
|
+
if (values.json)
|
|
1617
|
+
return json(r);
|
|
1618
|
+
console.log([`Ingredients: ${r.ingredients.join(', ') || 'none found'}`, ...r.steps.map((s, i) => `${i + 1}. ${s}`)].join('\n'));
|
|
1619
|
+
return;
|
|
1620
|
+
}
|
|
1296
1621
|
case 'diff': {
|
|
1297
1622
|
console.log(diffCard(getCard(loadBoard(), need(args[0], 'chompyy diff <id>'))));
|
|
1298
1623
|
return;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Codex, the second provider (after Claude): its 5-hour and weekly limits from OpenAI's usage endpoint, via codeburn's
|
|
2
|
+
// reader (src/vendor/codeburn/codex.ts), and its tokens from codeburn's Codex session parser (src/codexusage.ts).
|
|
3
|
+
//
|
|
4
|
+
// Read-only on purpose. codeburn renews Codex's login when it's old or rejected and writes the new one back to
|
|
5
|
+
// ~/.codex/auth.json; a renewal that goes wrong signs you out of Codex. Chompyy never does that: every request to
|
|
6
|
+
// OpenAI's sign-in server is refused before it leaves the Mac, so the saved login is only ever read. When it has
|
|
7
|
+
// expired, opening Codex once renews it.
|
|
8
|
+
import { existsSync } from 'node:fs';
|
|
9
|
+
import { homedir } from 'node:os';
|
|
10
|
+
import { join } from 'node:path';
|
|
11
|
+
import { fetchCodexQuota } from './vendor/codeburn/codex.js';
|
|
12
|
+
import { readSecureFile } from './vendor/codeburn/security.js';
|
|
13
|
+
import { homePath, readJson, writeJson } from './home.js';
|
|
14
|
+
import { codexUsage } from './codexusage.js';
|
|
15
|
+
/** Don't ask OpenAI more often than this. */
|
|
16
|
+
export const CODEX_MIN_INTERVAL_MS = 5 * 60_000;
|
|
17
|
+
const SIGN_IN_HOST = 'https://auth.openai.com';
|
|
18
|
+
const statePath = () => homePath('codex-quota.json');
|
|
19
|
+
export const loadCodexState = () => readJson(statePath(), {});
|
|
20
|
+
/** Codex is on this Mac: it keeps its login and sessions in ~/.codex. */
|
|
21
|
+
export function codexInstalled(home = homedir()) {
|
|
22
|
+
return existsSync(join(home, '.codex'));
|
|
23
|
+
}
|
|
24
|
+
/** fetch that refuses OpenAI's sign-in server, so codeburn's renewal never runs and the login on disk stays as it is. */
|
|
25
|
+
export function readOnlyFetch(real = globalThis.fetch) {
|
|
26
|
+
return ((input, init) => {
|
|
27
|
+
const url = typeof input === 'string' ? input : input instanceof URL ? input.href : input.url;
|
|
28
|
+
if (url.startsWith(SIGN_IN_HOST))
|
|
29
|
+
return Promise.resolve(new Response(null, { status: 403, statusText: 'Chompyy never renews the Codex login' }));
|
|
30
|
+
return real(input, init);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Codex's login file as codeburn should see it. Older Codex versions wrote ChatGPT sign-ins without `auth_mode`;
|
|
35
|
+
* codeburn then takes them for an API key and gives up. A file with ChatGPT tokens is a ChatGPT sign-in. In memory
|
|
36
|
+
* only: the file itself is never changed.
|
|
37
|
+
*/
|
|
38
|
+
export async function readCodexAuth(path, maxBytes) {
|
|
39
|
+
const raw = await readSecureFile(path, maxBytes);
|
|
40
|
+
if (!raw)
|
|
41
|
+
return raw;
|
|
42
|
+
try {
|
|
43
|
+
const doc = JSON.parse(raw);
|
|
44
|
+
if (!doc.auth_mode && doc.tokens?.access_token)
|
|
45
|
+
return JSON.stringify({ ...doc, auth_mode: 'chatgpt' });
|
|
46
|
+
}
|
|
47
|
+
catch { }
|
|
48
|
+
return raw;
|
|
49
|
+
}
|
|
50
|
+
function windowFrom(p, label) {
|
|
51
|
+
const row = p.details.find((d) => d.label === label);
|
|
52
|
+
if (!row || !row.resetsAt)
|
|
53
|
+
return undefined;
|
|
54
|
+
return { usedPct: Math.round(row.percent * 1000) / 10, resetsAt: Math.floor(Date.parse(row.resetsAt) / 1000) };
|
|
55
|
+
}
|
|
56
|
+
/** Ask OpenAI for Codex's limits and recount its tokens, at most every 5 minutes unless forced. */
|
|
57
|
+
export async function refreshCodexQuota(opts = {}) {
|
|
58
|
+
const now = opts.now ?? new Date();
|
|
59
|
+
const state = loadCodexState();
|
|
60
|
+
if (state.retryAfterAt && Date.parse(state.retryAfterAt) > now.getTime())
|
|
61
|
+
return { ok: false, message: 'OpenAI limits how often Codex quota can be checked. Try again later.' };
|
|
62
|
+
if (!opts.force && state.lastTryAt && now.getTime() - Date.parse(state.lastTryAt) < CODEX_MIN_INTERVAL_MS)
|
|
63
|
+
return { ok: true, message: 'Fresh enough.' };
|
|
64
|
+
const fetchQuota = opts.fetchQuota ?? (() => fetchCodexQuota({ fetch: readOnlyFetch(), readFile: readCodexAuth, allowKeychain: false }));
|
|
65
|
+
const result = await fetchQuota();
|
|
66
|
+
const p = result.quota;
|
|
67
|
+
const next = { ...state, lastTryAt: now.toISOString(), connection: p.connection, plan: p.planLabel };
|
|
68
|
+
delete next.retryAfterAt;
|
|
69
|
+
try {
|
|
70
|
+
next.usage = await (opts.usage ?? codexUsage)(now);
|
|
71
|
+
}
|
|
72
|
+
catch { }
|
|
73
|
+
if (result.retryAfterSeconds)
|
|
74
|
+
next.retryAfterAt = new Date(now.getTime() + result.retryAfterSeconds * 1000).toISOString();
|
|
75
|
+
if (p.connection === 'connected') {
|
|
76
|
+
const five = windowFrom(p, '5-hour');
|
|
77
|
+
const week = windowFrom(p, 'Weekly');
|
|
78
|
+
if (five)
|
|
79
|
+
next.fiveHour = five;
|
|
80
|
+
else
|
|
81
|
+
delete next.fiveHour;
|
|
82
|
+
if (week)
|
|
83
|
+
next.sevenDay = week;
|
|
84
|
+
else
|
|
85
|
+
delete next.sevenDay;
|
|
86
|
+
next.capturedAt = now.toISOString();
|
|
87
|
+
delete next.note;
|
|
88
|
+
writeJson(statePath(), next);
|
|
89
|
+
return { ok: true, message: `Updated from OpenAI${p.planLabel ? ` (Codex ${p.planLabel})` : ''}.` };
|
|
90
|
+
}
|
|
91
|
+
next.note = explainCodex(p);
|
|
92
|
+
writeJson(statePath(), next);
|
|
93
|
+
return { ok: false, message: next.note };
|
|
94
|
+
}
|
|
95
|
+
export function explainCodex(p) {
|
|
96
|
+
switch (p.connection) {
|
|
97
|
+
case 'disconnected':
|
|
98
|
+
return 'No Codex login found. Sign in to Codex once, then try again.';
|
|
99
|
+
case 'transientFailure':
|
|
100
|
+
return "Couldn't read Codex's limits right now. If it keeps failing, open Codex once so it renews its login.";
|
|
101
|
+
case 'terminalFailure':
|
|
102
|
+
return 'OpenAI refused the request. Codex quota works with a ChatGPT sign-in, not an API key.';
|
|
103
|
+
default:
|
|
104
|
+
return "Couldn't reach OpenAI right now.";
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Codex tokens and their API value, read by codeburn's own Codex session parser (via agentusage.ts, which reads
|
|
2
|
+
// every agent the same way).
|
|
3
|
+
import { prepareCodeburn, usageFor } from './agentusage.js';
|
|
4
|
+
import { codex } from './vendor/codeburn/src/providers/codex.js';
|
|
5
|
+
export { callTokens } from './agentusage.js';
|
|
6
|
+
export async function codexUsage(now, provider = codex) {
|
|
7
|
+
await prepareCodeburn();
|
|
8
|
+
const { today, week, models } = await usageFor(provider, now);
|
|
9
|
+
return { today, week, models };
|
|
10
|
+
}
|