chompyy 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -6
- package/THIRD_PARTY_NOTICES.md +28 -0
- package/dist/appstate.js +43 -2
- package/dist/away.js +104 -15
- package/dist/board.js +33 -3
- package/dist/claudesettings.js +23 -0
- package/dist/cli.js +409 -27
- package/dist/coldstart.js +207 -0
- package/dist/config.js +36 -1
- package/dist/costs.js +162 -0
- package/dist/gate.js +29 -0
- package/dist/history.js +308 -0
- package/dist/livequota.js +15 -1
- package/dist/pacing.js +189 -0
- package/dist/picture.js +117 -0
- package/dist/projects.js +2 -2
- package/dist/quota.js +31 -5
- package/dist/report.js +38 -21
- package/dist/review.js +47 -4
- package/dist/runner.js +268 -8
- package/dist/taste.js +507 -0
- package/dist/triggers.js +182 -0
- package/dist/verify.js +131 -0
- package/package.json +2 -1
- package/skills/taste/SKILL.md +4 -1
- package/vendor/diagram-design/LICENSE +21 -0
- package/vendor/diagram-design/SKILL.md +399 -0
- package/vendor/diagram-design/UPSTREAM.md +18 -0
- package/vendor/diagram-design/assets/example-arc-diagram.html +111 -0
- package/vendor/diagram-design/assets/example-architecture-containment.html +205 -0
- package/vendor/diagram-design/assets/example-architecture-delta.html +193 -0
- package/vendor/diagram-design/assets/example-architecture.html +183 -0
- package/vendor/diagram-design/assets/example-axonometric-plan-campus.html +108 -0
- package/vendor/diagram-design/assets/example-axonometric-plan-coffee-shop.html +121 -0
- package/vendor/diagram-design/assets/example-axonometric-plan-warehouse.html +127 -0
- package/vendor/diagram-design/assets/example-axonometric-plan.html +114 -0
- package/vendor/diagram-design/assets/example-bar.html +129 -0
- package/vendor/diagram-design/assets/example-beeswarm.html +384 -0
- package/vendor/diagram-design/assets/example-box-plot.html +127 -0
- package/vendor/diagram-design/assets/example-bubble.html +147 -0
- package/vendor/diagram-design/assets/example-bump.html +142 -0
- package/vendor/diagram-design/assets/example-data-flow.html +143 -0
- package/vendor/diagram-design/assets/example-datalake.html +269 -0
- package/vendor/diagram-design/assets/example-db-schema.html +302 -0
- package/vendor/diagram-design/assets/example-dependency.html +224 -0
- package/vendor/diagram-design/assets/example-deployment.html +190 -0
- package/vendor/diagram-design/assets/example-dp-integration.html +81 -0
- package/vendor/diagram-design/assets/example-dp-security-matrix.html +88 -0
- package/vendor/diagram-design/assets/example-er.html +202 -0
- package/vendor/diagram-design/assets/example-event-modeling.html +64 -0
- package/vendor/diagram-design/assets/example-exploded-ai-stack.html +85 -0
- package/vendor/diagram-design/assets/example-exploded-keyboard.html +84 -0
- package/vendor/diagram-design/assets/example-exploded-phone.html +83 -0
- package/vendor/diagram-design/assets/example-exploded-unboxing.html +84 -0
- package/vendor/diagram-design/assets/example-exploded.html +83 -0
- package/vendor/diagram-design/assets/example-fishbone.html +152 -0
- package/vendor/diagram-design/assets/example-flowchart.html +163 -0
- package/vendor/diagram-design/assets/example-gantt.html +137 -0
- package/vendor/diagram-design/assets/example-heatmap.html +224 -0
- package/vendor/diagram-design/assets/example-high-level-vertical.html +325 -0
- package/vendor/diagram-design/assets/example-high-level.html +301 -0
- package/vendor/diagram-design/assets/example-import-drawio.html +185 -0
- package/vendor/diagram-design/assets/example-import-excalidraw.html +70 -0
- package/vendor/diagram-design/assets/example-import-mermaid.html +70 -0
- package/vendor/diagram-design/assets/example-import-plantuml.html +107 -0
- package/vendor/diagram-design/assets/example-it-state.html +128 -0
- package/vendor/diagram-design/assets/example-journey.html +148 -0
- package/vendor/diagram-design/assets/example-kanban.html +174 -0
- package/vendor/diagram-design/assets/example-layers.html +123 -0
- package/vendor/diagram-design/assets/example-line.html +111 -0
- package/vendor/diagram-design/assets/example-loop.html +100 -0
- package/vendor/diagram-design/assets/example-marimekko.html +148 -0
- package/vendor/diagram-design/assets/example-medallion.html +159 -0
- package/vendor/diagram-design/assets/example-nested.html +136 -0
- package/vendor/diagram-design/assets/example-org-chart.html +45 -0
- package/vendor/diagram-design/assets/example-polar.html +116 -0
- package/vendor/diagram-design/assets/example-process.html +64 -0
- package/vendor/diagram-design/assets/example-pyramid.html +119 -0
- package/vendor/diagram-design/assets/example-quadrant-consultant.html +166 -0
- package/vendor/diagram-design/assets/example-quadrant.html +135 -0
- package/vendor/diagram-design/assets/example-radar.html +139 -0
- package/vendor/diagram-design/assets/example-requirement-traceability.html +122 -0
- package/vendor/diagram-design/assets/example-ridgeline.html +104 -0
- package/vendor/diagram-design/assets/example-sankey.html +150 -0
- package/vendor/diagram-design/assets/example-sbgn.html +213 -0
- package/vendor/diagram-design/assets/example-scatter.html +141 -0
- package/vendor/diagram-design/assets/example-sequence-oauth.html +227 -0
- package/vendor/diagram-design/assets/example-sequence.html +222 -0
- package/vendor/diagram-design/assets/example-service-blueprint.html +185 -0
- package/vendor/diagram-design/assets/example-slopegraph.html +119 -0
- package/vendor/diagram-design/assets/example-state-lifecycle.html +92 -0
- package/vendor/diagram-design/assets/example-state.html +147 -0
- package/vendor/diagram-design/assets/example-steps.html +78 -0
- package/vendor/diagram-design/assets/example-story-map.html +184 -0
- package/vendor/diagram-design/assets/example-streamgraph.html +99 -0
- package/vendor/diagram-design/assets/example-swimlane.html +172 -0
- package/vendor/diagram-design/assets/example-timeline.html +135 -0
- package/vendor/diagram-design/assets/example-tree-block-decomposition.html +151 -0
- package/vendor/diagram-design/assets/example-tree.html +173 -0
- package/vendor/diagram-design/assets/example-treemap.html +107 -0
- package/vendor/diagram-design/assets/example-uml-class.html +188 -0
- package/vendor/diagram-design/assets/example-unit-grid.html +141 -0
- package/vendor/diagram-design/assets/example-venn.html +110 -0
- package/vendor/diagram-design/assets/example-wardley.html +153 -0
- package/vendor/diagram-design/assets/example-waterfall.html +129 -0
- package/vendor/diagram-design/assets/template-dark.html +99 -0
- package/vendor/diagram-design/assets/template.html +100 -0
- package/vendor/diagram-design/references/layout-budget.md +103 -0
- package/vendor/diagram-design/references/output-spec.md +277 -0
- package/vendor/diagram-design/references/primitive-annotation.md +36 -0
- package/vendor/diagram-design/references/primitive-sketchy.md +43 -0
- package/vendor/diagram-design/references/primitives-core.md +146 -0
- package/vendor/diagram-design/references/semantic-patterns.md +154 -0
- package/vendor/diagram-design/references/style-guide.md +234 -0
- package/vendor/diagram-design/references/type-architecture-delta.md +143 -0
- package/vendor/diagram-design/references/type-architecture.md +117 -0
- package/vendor/diagram-design/references/type-axonometric-plan.md +83 -0
- package/vendor/diagram-design/references/type-bar.md +108 -0
- package/vendor/diagram-design/references/type-data-flow.md +371 -0
- package/vendor/diagram-design/references/type-db-schema.md +48 -0
- package/vendor/diagram-design/references/type-dependency.md +113 -0
- package/vendor/diagram-design/references/type-deployment.md +45 -0
- package/vendor/diagram-design/references/type-dp-integration.md +407 -0
- package/vendor/diagram-design/references/type-dp-security-matrix.md +379 -0
- package/vendor/diagram-design/references/type-er.md +25 -0
- package/vendor/diagram-design/references/type-event-modeling.md +36 -0
- package/vendor/diagram-design/references/type-exploded.md +115 -0
- package/vendor/diagram-design/references/type-fishbone.md +75 -0
- package/vendor/diagram-design/references/type-flowchart.md +23 -0
- package/vendor/diagram-design/references/type-gantt.md +45 -0
- package/vendor/diagram-design/references/type-heatmap.md +80 -0
- package/vendor/diagram-design/references/type-high-level.md +470 -0
- package/vendor/diagram-design/references/type-it-state.md +468 -0
- package/vendor/diagram-design/references/type-journey.md +55 -0
- package/vendor/diagram-design/references/type-kanban.md +49 -0
- package/vendor/diagram-design/references/type-layers.md +26 -0
- package/vendor/diagram-design/references/type-line.md +337 -0
- package/vendor/diagram-design/references/type-loop.md +223 -0
- package/vendor/diagram-design/references/type-medallion.md +356 -0
- package/vendor/diagram-design/references/type-nested.md +22 -0
- package/vendor/diagram-design/references/type-org-chart.md +44 -0
- package/vendor/diagram-design/references/type-polar.md +136 -0
- package/vendor/diagram-design/references/type-process.md +490 -0
- package/vendor/diagram-design/references/type-pyramid.md +33 -0
- package/vendor/diagram-design/references/type-quadrant.md +81 -0
- package/vendor/diagram-design/references/type-radar.md +82 -0
- package/vendor/diagram-design/references/type-requirement-traceability.md +45 -0
- package/vendor/diagram-design/references/type-sankey.md +75 -0
- package/vendor/diagram-design/references/type-sbgn.md +80 -0
- package/vendor/diagram-design/references/type-scatter.md +276 -0
- package/vendor/diagram-design/references/type-sequence.md +130 -0
- package/vendor/diagram-design/references/type-service-blueprint.md +103 -0
- package/vendor/diagram-design/references/type-state.md +30 -0
- package/vendor/diagram-design/references/type-steps.md +180 -0
- package/vendor/diagram-design/references/type-story-map.md +46 -0
- package/vendor/diagram-design/references/type-swimlane.md +22 -0
- package/vendor/diagram-design/references/type-timeline.md +20 -0
- package/vendor/diagram-design/references/type-tree.md +24 -0
- package/vendor/diagram-design/references/type-treemap.md +137 -0
- package/vendor/diagram-design/references/type-uml-class.md +65 -0
- package/vendor/diagram-design/references/type-unit-grid.md +63 -0
- package/vendor/diagram-design/references/type-venn.md +26 -0
- package/vendor/diagram-design/references/type-wardley.md +39 -0
- package/vendor/diagram-design/references/type-waterfall.md +75 -0
- package/vendor/diagram-design/scripts/self_check.py +1177 -0
- package/vendor/diagram-design/scripts/verify_geometry.py +696 -0
package/dist/cli.js
CHANGED
|
@@ -2,23 +2,33 @@
|
|
|
2
2
|
// chompyy: park ideas, blueprint them, run approved cards while you're away.
|
|
3
3
|
import { spawn } from 'node:child_process';
|
|
4
4
|
import { existsSync, readFileSync } from 'node:fs';
|
|
5
|
+
import { join, relative } from 'node:path';
|
|
5
6
|
import { parseArgs } from 'node:util';
|
|
6
|
-
import { away } from './away.js';
|
|
7
|
+
import { away, cacheEnv, runCard } from './away.js';
|
|
7
8
|
import { draftBlueprint, draftFiveStarOptions, GENERIC_FIVE_STAR } from './blueprint.js';
|
|
8
|
-
import { addCard, COLUMNS, dropCard, formatBoard, formatCard, getCard, loadBoard, moveCard, updateBoard } from './board.js';
|
|
9
|
-
import { loadConfig } from './config.js';
|
|
9
|
+
import { addCard, awayQueue, COLUMNS, dropCard, expireSuggested, formatBoard, formatCard, getCard, loadBoard, moveCard, recoverRunning, updateBoard } from './board.js';
|
|
10
|
+
import { loadConfig, setConfig } from './config.js';
|
|
10
11
|
import { formatDuration, parseDuration } from './duration.js';
|
|
11
12
|
import { budgetGate } from './gate.js';
|
|
12
13
|
import { chompyyHome, homePath } from './home.js';
|
|
13
|
-
import { loadSnapshot, mergeSnapshot, parseStatusline, saveSnapshot, statusLineText, statusText, windowView } from './quota.js';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
14
|
+
import { loadSnapshot, mergeSnapshot, parseStatusline, saveSnapshot, statusLineText, statusText as baseStatusText, windowView } from './quota.js';
|
|
15
|
+
import { loadSamples } from './pacing.js';
|
|
16
|
+
import { cardsSince, formatReport, lastReportAt, markReported, morningLine, rateCard, readTaste } from './report.js';
|
|
17
|
+
import { changedFiles, diffCard, keepCard, overlaps, questionsOf, undoCard } from './review.js';
|
|
18
|
+
import { CappedText, ClaudeRunner, claudeAvailable } from './runner.js';
|
|
19
|
+
import { commitLeftovers, gitRoot, planWorkspace, prepareWorkspace } from './workspace.js';
|
|
20
|
+
import { verifyRun } from './verify.js';
|
|
18
21
|
import { answerCard, appState, cardView, editBlueprint, recordCliLocation } from './appstate.js';
|
|
19
22
|
import { refreshLiveQuota } from './livequota.js';
|
|
20
23
|
import { recentProjects } from './projects.js';
|
|
21
24
|
import { cliVersion, installApp } from './macapp.js';
|
|
25
|
+
import { buildDigest, historyRetention, scanHistory } from './history.js';
|
|
26
|
+
import { acceptColdStart, forgetColdStart, formatColdStart, loadColdStart, runColdStart } from './coldstart.js';
|
|
27
|
+
import { keepHistory } from './claudesettings.js';
|
|
28
|
+
import { blueprintHash, drawPicture } from './picture.js';
|
|
29
|
+
import { costRange, formatCostRange, readRuns, trendLines } from './costs.js';
|
|
30
|
+
import { answerPreference, distill, distillDue, formatPrefs, formatQuestion, formatWhy, getPref, loadStore, nextQuestion, readSignals, recordOutcome, retirePreference, syncTasteFile, tasteChangesSince, } from './taste.js';
|
|
31
|
+
import { agentInstalled, awayRunning, bedtimeKey, decideTrigger, installAgent, loadTriggerState, markFired, noteTick, parseClock, takeAwayLock, uninstallAgent } from './triggers.js';
|
|
22
32
|
const HELP = `chompyy: use the 5-hour window capacity that would reset unused
|
|
23
33
|
|
|
24
34
|
Quota
|
|
@@ -33,6 +43,7 @@ Board
|
|
|
33
43
|
chompyy board [--column c] cards by column (suggested later approved running review done)
|
|
34
44
|
chompyy show <id> one card: blueprint, last run, what the agent said
|
|
35
45
|
chompyy blueprint <id> (re)draft the blueprint with a cheap model [--model haiku]
|
|
46
|
+
chompyy picture <id> (re)draw the card's picture: a diagram of what it will do (diagram-design skill)
|
|
36
47
|
chompyy approve <id> later → approved (needs a blueprint)
|
|
37
48
|
chompyy edit-blueprint <id> replace the blueprint with text from stdin
|
|
38
49
|
chompyy drop <id> remove a card (kept in archive.jsonl)
|
|
@@ -51,8 +62,29 @@ Back
|
|
|
51
62
|
chompyy redo <id> throw this attempt away and run it again from your latest code
|
|
52
63
|
chompyy rate <id> <1-5> ["why"] [--to-five "change" ...] rate a result; --to-five = what would have made it a 5
|
|
53
64
|
chompyy five-star <id> options for "what would have made it a 5?" (JSON)
|
|
54
|
-
chompyy taste show taste.md
|
|
55
65
|
chompyy signals [--json] everything Chompyy has recorded from you: ratings, edits, answers
|
|
66
|
+
chompyy trends last 7 days vs the 7 before: cost per card, keep rate, rating, blueprint edits
|
|
67
|
+
|
|
68
|
+
Taste (learned from what you keep, undo, edit and rate)
|
|
69
|
+
chompyy taste show taste.md
|
|
70
|
+
chompyy taste list every preference: to ask, in taste.md, candidates, declined, retired
|
|
71
|
+
chompyy taste why <id> the cards, edits and quotes behind a preference
|
|
72
|
+
chompyy taste yes|not-now|never <id> answer a question (yes writes it to taste.md)
|
|
73
|
+
chompyy taste retire <id> stop using a preference (kept, with the reason)
|
|
74
|
+
chompyy distill [--force] read new signals and update preferences now (one model call; runs after away too)
|
|
75
|
+
|
|
76
|
+
Triggers (start away runs on their own; the budget gate still decides every card)
|
|
77
|
+
chompyy triggers on|off install or remove the macOS LaunchAgent that runs \`chompyy tick\` every 5 minutes
|
|
78
|
+
chompyy triggers what is set, and what the last tick decided
|
|
79
|
+
chompyy bedtime <23:30|off> run approved cards at bedtime (with the window that is left)
|
|
80
|
+
chompyy last-hour <on|off> run approved cards in the last hour before a 5-hour reset
|
|
81
|
+
chompyy tick check the triggers once (what the LaunchAgent runs)
|
|
82
|
+
|
|
83
|
+
Get to know you (cold start)
|
|
84
|
+
chompyy history [--digest] what Chompyy would read from your Claude Code history (local; --digest = the exact text it would send)
|
|
85
|
+
chompyy coldstart [--force] read your history once and propose taste lines and suggested cards (one model call)
|
|
86
|
+
chompyy coldstart show the proposals accept --taste t1,t2 --cards c1 forget
|
|
87
|
+
chompyy keep-history <days> keep Claude Code transcripts longer (cleanupPeriodDays; default 30)
|
|
56
88
|
|
|
57
89
|
App
|
|
58
90
|
chompyy app install (or update) the Mac app in ~/Applications and open it
|
|
@@ -61,6 +93,10 @@ App
|
|
|
61
93
|
chompyy state --json everything the Mac app shows, in one JSON (board, show, status also take --json)
|
|
62
94
|
|
|
63
95
|
State lives in ${chompyyHome()} (override with CHOMPYY_HOME).`;
|
|
96
|
+
/** `chompyy status` text with pacing: burn-rate history and your bedtime. */
|
|
97
|
+
function statusText(snap, now) {
|
|
98
|
+
return baseStatusText(snap, now, { samples: loadSamples(), bedtime: loadConfig().bedtime });
|
|
99
|
+
}
|
|
64
100
|
async function readStdin() {
|
|
65
101
|
if (process.stdin.isTTY)
|
|
66
102
|
return '';
|
|
@@ -90,6 +126,8 @@ async function blueprintCard(id, model) {
|
|
|
90
126
|
delete c.draftingAt;
|
|
91
127
|
c.updatedAt = new Date().toISOString();
|
|
92
128
|
});
|
|
129
|
+
if (config.pictures && windowActive(new Date()))
|
|
130
|
+
await pictureCard(id).catch(() => { });
|
|
93
131
|
return text;
|
|
94
132
|
}
|
|
95
133
|
catch (err) {
|
|
@@ -102,6 +140,33 @@ async function blueprintCard(id, model) {
|
|
|
102
140
|
throw err;
|
|
103
141
|
}
|
|
104
142
|
}
|
|
143
|
+
/** Draw (or redraw) a card's picture with the diagram-design skill. Errors are kept on the card. */
|
|
144
|
+
async function pictureCard(id, model) {
|
|
145
|
+
const config = loadConfig();
|
|
146
|
+
const card = getCard(loadBoard(), id);
|
|
147
|
+
updateBoard((b) => {
|
|
148
|
+
getCard(b, id).drawingAt = new Date().toISOString();
|
|
149
|
+
});
|
|
150
|
+
try {
|
|
151
|
+
const info = await drawPicture(card, new ClaudeRunner(config.claudeBin), { model: model ?? config.pictureModel, now: new Date() });
|
|
152
|
+
updateBoard((b) => {
|
|
153
|
+
const c = getCard(b, id);
|
|
154
|
+
c.picture = info;
|
|
155
|
+
delete c.pictureError;
|
|
156
|
+
delete c.drawingAt;
|
|
157
|
+
});
|
|
158
|
+
return info.path;
|
|
159
|
+
}
|
|
160
|
+
catch (err) {
|
|
161
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
162
|
+
updateBoard((b) => {
|
|
163
|
+
const c = getCard(b, id);
|
|
164
|
+
c.pictureError = message;
|
|
165
|
+
delete c.drawingAt;
|
|
166
|
+
});
|
|
167
|
+
throw err;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
105
170
|
/** The agent's whole final message from the run log (the board keeps only its first lines). */
|
|
106
171
|
function fullOutput(card) {
|
|
107
172
|
if (!card.logPath || !existsSync(card.logPath))
|
|
@@ -118,6 +183,9 @@ function windowActive(now) {
|
|
|
118
183
|
* with no active window it would start a new 5-hour window. Called whenever quota is fresh.
|
|
119
184
|
*/
|
|
120
185
|
function draftPending(now) {
|
|
186
|
+
const days = loadConfig().suggestedExpiryDays;
|
|
187
|
+
if (days > 0 && loadBoard().cards.some((c) => c.column === 'suggested'))
|
|
188
|
+
updateBoard((b) => expireSuggested(b, now, days));
|
|
121
189
|
if (!windowActive(now) || !claudeAvailable(loadConfig().claudeBin))
|
|
122
190
|
return;
|
|
123
191
|
const stale = now.getTime() - 3 * 60_000;
|
|
@@ -129,6 +197,24 @@ function draftPending(now) {
|
|
|
129
197
|
});
|
|
130
198
|
for (const id of ids)
|
|
131
199
|
blueprintInBackground(id);
|
|
200
|
+
// Pictures for cards whose blueprint is ready but not drawn yet, or changed since (an edit or a redraw).
|
|
201
|
+
if (!loadConfig().pictures)
|
|
202
|
+
return;
|
|
203
|
+
const toDraw = updateBoard((b) => {
|
|
204
|
+
const due = b.cards.filter((c) => ['suggested', 'later', 'approved'].includes(c.column) &&
|
|
205
|
+
c.blueprint && !c.draftingAt && !c.pictureError &&
|
|
206
|
+
(!c.picture || c.picture.blueprintHash !== blueprintHash(c.blueprint)) &&
|
|
207
|
+
(!c.drawingAt || Date.parse(c.drawingAt) < now.getTime() - 6 * 60_000));
|
|
208
|
+
for (const c of due)
|
|
209
|
+
c.drawingAt = now.toISOString();
|
|
210
|
+
return due.map((c) => c.id);
|
|
211
|
+
});
|
|
212
|
+
for (const id of toDraw)
|
|
213
|
+
inBackground(['picture', id, '--quiet']);
|
|
214
|
+
}
|
|
215
|
+
function inBackground(args) {
|
|
216
|
+
const child = spawn(process.execPath, [process.argv[1], ...args], { detached: true, stdio: 'ignore', env: process.env });
|
|
217
|
+
child.unref();
|
|
132
218
|
}
|
|
133
219
|
/** Draft the blueprint in a detached child so `later` returns at once. */
|
|
134
220
|
function blueprintInBackground(id) {
|
|
@@ -139,6 +225,102 @@ function blueprintInBackground(id) {
|
|
|
139
225
|
});
|
|
140
226
|
child.unref();
|
|
141
227
|
}
|
|
228
|
+
/** Distil taste from new signals, but only inside an active window (a model call would otherwise start one). */
|
|
229
|
+
async function distillNow(now, force = false) {
|
|
230
|
+
const config = loadConfig();
|
|
231
|
+
if (!force && !windowActive(now))
|
|
232
|
+
return 'No active 5-hour window: distilling now would start one. It runs after your next away, or add --force.';
|
|
233
|
+
if (!claudeAvailable(config.claudeBin))
|
|
234
|
+
return `Can't find Claude Code (\`${config.claudeBin}\`).`;
|
|
235
|
+
const r = await distill(loadBoard(), new ClaudeRunner(config.claudeBin), { model: config.distillModel, cwd: chompyyHome(), now });
|
|
236
|
+
if (!r.read)
|
|
237
|
+
return 'No new signals to learn from.';
|
|
238
|
+
const c = r.changes;
|
|
239
|
+
const parts = [`${c.added.length} new`, `${c.extended.length} with more evidence`, `${c.ready.length} ready to ask`, `${c.retired.length} retired`];
|
|
240
|
+
return `Read ${r.read} new signal(s): ${parts.join(', ')}${c.dropped ? ` (${c.dropped} thrown out for weak evidence)` : ''}. See \`chompyy taste list\`.`;
|
|
241
|
+
}
|
|
242
|
+
/** An away run: one at a time (lock), then distil what the run taught, if anything. */
|
|
243
|
+
/** What an away run (and each card's worker) needs from the real world. */
|
|
244
|
+
function awayDeps(config, freshQuota) {
|
|
245
|
+
return {
|
|
246
|
+
runner: new ClaudeRunner(config.claudeBin),
|
|
247
|
+
config,
|
|
248
|
+
now: () => Date.now(),
|
|
249
|
+
snapshot: loadSnapshot,
|
|
250
|
+
plan: planWorkspace,
|
|
251
|
+
prepare: prepareWorkspace,
|
|
252
|
+
commitLeftovers,
|
|
253
|
+
refreshQuota: async () => {
|
|
254
|
+
await freshQuota(true);
|
|
255
|
+
},
|
|
256
|
+
...(config.independentCheck
|
|
257
|
+
? {
|
|
258
|
+
verify: (ws, card) => {
|
|
259
|
+
const root = gitRoot(card.cwd);
|
|
260
|
+
const cacheDir = homePath('cache', 'tools');
|
|
261
|
+
// A card made in a subfolder (e.g. cli/ of a repo) is checked there, with that folder's node_modules.
|
|
262
|
+
const sub = root ? relative(root, card.cwd) : '';
|
|
263
|
+
return verifyRun({
|
|
264
|
+
dir: sub && !sub.startsWith('..') ? join(ws.dir, sub) : ws.dir,
|
|
265
|
+
repoRoot: sub && !sub.startsWith('..') ? card.cwd : root,
|
|
266
|
+
cacheDir,
|
|
267
|
+
env: cacheEnv(cacheDir),
|
|
268
|
+
denyRead: config.denyReadPaths,
|
|
269
|
+
timeoutMs: config.checkTimeoutMin * 60_000,
|
|
270
|
+
override: root ? config.checkCommands[root] : undefined,
|
|
271
|
+
now: () => new Date(),
|
|
272
|
+
});
|
|
273
|
+
},
|
|
274
|
+
}
|
|
275
|
+
: {}),
|
|
276
|
+
out: (line) => console.log(line),
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
/** The supervisor's side of a worker: run `chompyy run-card` and wait, killing it if it outlives its card. */
|
|
280
|
+
function isolateCard(config) {
|
|
281
|
+
return (id, timeoutMs, trigger) => new Promise((resolve) => {
|
|
282
|
+
const args = [process.argv[1], 'run-card', id, '--timeout', String(timeoutMs), ...(trigger ? ['--trigger', trigger] : [])];
|
|
283
|
+
const child = spawn(process.execPath, args, { stdio: ['ignore', 'inherit', 'pipe'], env: process.env });
|
|
284
|
+
const stderr = new CappedText(64 * 1024);
|
|
285
|
+
child.stderr.setEncoding('utf8');
|
|
286
|
+
child.stderr.on('data', (d) => {
|
|
287
|
+
stderr.push(d);
|
|
288
|
+
process.stderr.write(d);
|
|
289
|
+
});
|
|
290
|
+
// Watchdog: the card's cap, plus time for the independent check and committing, plus a margin.
|
|
291
|
+
const limit = timeoutMs + (config.independentCheck ? config.checkTimeoutMin * 60_000 : 0) + 5 * 60_000;
|
|
292
|
+
const dog = setTimeout(() => {
|
|
293
|
+
child.kill('SIGTERM'); // the worker stops its agent's process group on SIGTERM
|
|
294
|
+
setTimeout(() => child.kill('SIGKILL'), 10_000).unref();
|
|
295
|
+
}, limit);
|
|
296
|
+
child.on('close', (code, signal) => {
|
|
297
|
+
clearTimeout(dog);
|
|
298
|
+
resolve({ exitCode: code, signal, stderr: stderr.toString() });
|
|
299
|
+
});
|
|
300
|
+
child.on('error', (err) => {
|
|
301
|
+
clearTimeout(dog);
|
|
302
|
+
resolve({ exitCode: null, signal: null, stderr: String(err) });
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
async function runAway(ms, opts, now, freshQuota) {
|
|
307
|
+
const config = loadConfig();
|
|
308
|
+
const release = opts.dryRun ? () => { } : takeAwayLock(now, opts.trigger ?? 'away');
|
|
309
|
+
try {
|
|
310
|
+
await away(ms, { ...awayDeps(config, freshQuota), isolate: isolateCard(config) }, opts);
|
|
311
|
+
}
|
|
312
|
+
finally {
|
|
313
|
+
release();
|
|
314
|
+
}
|
|
315
|
+
if (!opts.dryRun && config.distillAfterAway && distillDue(loadBoard(), new Date(), 0)) {
|
|
316
|
+
try {
|
|
317
|
+
console.log(`Taste: ${await distillNow(new Date())}`);
|
|
318
|
+
}
|
|
319
|
+
catch (err) {
|
|
320
|
+
console.log(`Taste: couldn't distil (${err instanceof Error ? err.message : err})`);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
142
324
|
async function main(argv) {
|
|
143
325
|
const { values, positionals } = parseArgs({
|
|
144
326
|
args: argv,
|
|
@@ -156,6 +338,11 @@ async function main(argv) {
|
|
|
156
338
|
json: { type: 'boolean' },
|
|
157
339
|
refresh: { type: 'boolean' },
|
|
158
340
|
'to-five': { type: 'string', multiple: true },
|
|
341
|
+
digest: { type: 'boolean' },
|
|
342
|
+
taste: { type: 'string' },
|
|
343
|
+
cards: { type: 'string' },
|
|
344
|
+
timeout: { type: 'string' },
|
|
345
|
+
trigger: { type: 'string' },
|
|
159
346
|
},
|
|
160
347
|
});
|
|
161
348
|
const [command, ...args] = values.help ? ["help"] : positionals;
|
|
@@ -181,7 +368,7 @@ async function main(argv) {
|
|
|
181
368
|
const parsed = parseStatusline(await readStdin(), now);
|
|
182
369
|
const snap = mergeSnapshot(loadSnapshot(), { ...parsed, ...(parsed.fiveHour || parsed.sevenDay ? { source: 'statusline' } : {}) });
|
|
183
370
|
saveSnapshot(snap);
|
|
184
|
-
console.log(statusLineText(snap, now));
|
|
371
|
+
console.log(statusLineText(snap, now, { samples: loadSamples(), color: true }));
|
|
185
372
|
}
|
|
186
373
|
catch {
|
|
187
374
|
console.log('🍪');
|
|
@@ -206,9 +393,14 @@ async function main(argv) {
|
|
|
206
393
|
return;
|
|
207
394
|
}
|
|
208
395
|
case 'state': {
|
|
209
|
-
await freshQuota(Boolean(values.refresh));
|
|
396
|
+
const refreshed = await freshQuota(Boolean(values.refresh));
|
|
210
397
|
draftPending(now);
|
|
211
|
-
|
|
398
|
+
// A card left in running by an away run that died shouldn't look like it's still working.
|
|
399
|
+
if (!awayRunning() && loadBoard().cards.some((c) => c.column === 'running'))
|
|
400
|
+
updateBoard((b) => recoverRunning(b, now, planWorkspace));
|
|
401
|
+
// What the quota check just did, so the app's Refresh button can say it instead of looking dead.
|
|
402
|
+
const quotaRefresh = values.refresh ? (refreshed ? { ok: refreshed.ok, message: refreshed.message } : { ok: false, message: 'Live quota reading is off (quotaSource in config.json).' }) : null;
|
|
403
|
+
return json({ ...appState(loadBoard(), loadSnapshot(), loadConfig(), now), quotaRefresh });
|
|
212
404
|
}
|
|
213
405
|
case 'app': {
|
|
214
406
|
console.log(`Downloading Chompyy ${cliVersion()} for Mac…`);
|
|
@@ -216,6 +408,72 @@ async function main(argv) {
|
|
|
216
408
|
console.log(`Installed ${at} and opened it. Look for the cookie in your menu bar.`);
|
|
217
409
|
return;
|
|
218
410
|
}
|
|
411
|
+
case 'history': {
|
|
412
|
+
const scan = scanHistory();
|
|
413
|
+
if (values.digest)
|
|
414
|
+
return console.log(buildDigest(scan.sessions).text || '(nothing to read)');
|
|
415
|
+
const { included, text } = buildDigest(scan.sessions);
|
|
416
|
+
const retention = historyRetention();
|
|
417
|
+
const projects = [...new Set(scan.sessions.map((s) => s.project))];
|
|
418
|
+
const info = {
|
|
419
|
+
sessions: scan.sessions.length,
|
|
420
|
+
projects: projects.length,
|
|
421
|
+
projectNames: projects.map((p) => p.split('/').pop()),
|
|
422
|
+
from: scan.from,
|
|
423
|
+
to: scan.to,
|
|
424
|
+
skipped: scan.skipped,
|
|
425
|
+
digest: { sessions: included.length, chars: text.length },
|
|
426
|
+
retention,
|
|
427
|
+
};
|
|
428
|
+
if (values.json)
|
|
429
|
+
return json(info);
|
|
430
|
+
console.log(`${info.sessions} interactive sessions in ${info.projects} projects, ${(scan.from ?? '').slice(0, 10)} to ${(scan.to ?? '').slice(0, 10)}`);
|
|
431
|
+
console.log(`Skipped: ${scan.skipped.headless} headless runs, ${scan.skipped.temp} in temp folders, ${scan.skipped.empty} empty`);
|
|
432
|
+
console.log(`Would send: the newest ${included.length} sessions, ${text.length} characters (see it: chompyy history --digest)`);
|
|
433
|
+
console.log(`Claude Code keeps transcripts ${retention.days} days${retention.isDefault ? ' (default; raise it with chompyy keep-history 365)' : ''}`);
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
case 'coldstart': {
|
|
437
|
+
const sub = args[0];
|
|
438
|
+
if (sub === 'show') {
|
|
439
|
+
const cs = loadColdStart();
|
|
440
|
+
if (values.json)
|
|
441
|
+
return json(cs);
|
|
442
|
+
return console.log(cs ? formatColdStart(cs) : 'No cold start yet. Run `chompyy coldstart`.');
|
|
443
|
+
}
|
|
444
|
+
if (sub === 'accept') {
|
|
445
|
+
const list = (v) => (v ?? '').split(',').map((x) => x.trim()).filter(Boolean);
|
|
446
|
+
const r = acceptColdStart({ taste: list(values.taste), cards: list(values.cards) }, now);
|
|
447
|
+
if (values.json)
|
|
448
|
+
return json(r);
|
|
449
|
+
console.log(`Added ${r.taste.length} taste line(s) to taste.md and ${r.cards.length} card(s) to suggested${r.cards.length ? ` (${r.cards.map((c) => `#${c.id}`).join(', ')})` : ''}.`);
|
|
450
|
+
draftPending(now);
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
if (sub === 'forget')
|
|
454
|
+
return console.log(forgetColdStart() ? 'Forgot the cold start proposals. Accepted taste lines stay in taste.md.' : 'Nothing to forget.');
|
|
455
|
+
if (sub)
|
|
456
|
+
throw new Error('Usage: chompyy coldstart [show|accept|forget]');
|
|
457
|
+
await freshQuota();
|
|
458
|
+
if (!values.force && !windowActive(now))
|
|
459
|
+
throw new Error('No active 5-hour window: reading your history would start one. Try again while you are using Claude Code, or add --force.');
|
|
460
|
+
const config = loadConfig();
|
|
461
|
+
if (!claudeAvailable(config.claudeBin))
|
|
462
|
+
throw new Error(`Can't find Claude Code (\`${config.claudeBin}\`).`);
|
|
463
|
+
const cs = await runColdStart(scanHistory(), new ClaudeRunner(config.claudeBin), { model: config.coldStartModel, cwd: chompyyHome(), now, existing: loadBoard().cards.map((c) => c.title) });
|
|
464
|
+
if (values.json)
|
|
465
|
+
return json(cs);
|
|
466
|
+
console.log(formatColdStart(cs));
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
case 'keep-history': {
|
|
470
|
+
const days = Number(need(args[0], 'chompyy keep-history <days>'));
|
|
471
|
+
if (!Number.isInteger(days) || days < 1)
|
|
472
|
+
throw new Error('Days must be a whole number, e.g. 365.');
|
|
473
|
+
const r = keepHistory(days);
|
|
474
|
+
console.log(`Claude Code now keeps transcripts for ${days} days (was ${r.before ?? '30, the default'}). Changed ${r.path}.`);
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
219
477
|
case 'version':
|
|
220
478
|
console.log(cliVersion());
|
|
221
479
|
return;
|
|
@@ -262,8 +520,13 @@ async function main(argv) {
|
|
|
262
520
|
});
|
|
263
521
|
if (values.json)
|
|
264
522
|
return json(items.reverse());
|
|
265
|
-
for (const s of items)
|
|
523
|
+
for (const s of items) {
|
|
524
|
+
if (s.kind === 'coldstart') {
|
|
525
|
+
console.log(`${s.at.slice(0, 16)} coldstart kept: ${[...s.accepted.taste, ...s.accepted.cards].join('; ') || '-'} left out: ${[...s.declined.taste, ...s.declined.cards].join('; ') || '-'}`);
|
|
526
|
+
continue;
|
|
527
|
+
}
|
|
266
528
|
console.log(`${s.at.slice(0, 16)} #${s.card} ${s.kind ?? 'rating'} ${s.rating ? `${s.rating}/5 ` : ''}${s.reason ?? s.text ?? ''}${s.toFive ? ` → to make it a 5: ${s.toFive.join('; ')}` : ''}`);
|
|
529
|
+
}
|
|
267
530
|
return;
|
|
268
531
|
}
|
|
269
532
|
case 'edit-blueprint': {
|
|
@@ -290,6 +553,7 @@ async function main(argv) {
|
|
|
290
553
|
return;
|
|
291
554
|
}
|
|
292
555
|
const eligible = loadBoard().cards.filter((card) => card.column === 'approved' || card.column === 'later');
|
|
556
|
+
const runs = readRuns();
|
|
293
557
|
if (!eligible.length) {
|
|
294
558
|
console.log('\nNo cards to consider. Park an idea with `chompyy later "<idea>"`.');
|
|
295
559
|
return;
|
|
@@ -300,6 +564,7 @@ async function main(argv) {
|
|
|
300
564
|
console.log(` #${card.id} ${card.title} [${state}]`);
|
|
301
565
|
if (card.column === 'later' && !card.blueprint?.trim())
|
|
302
566
|
console.log(' blueprint needed before approval');
|
|
567
|
+
console.log(` ${formatCostRange(costRange(card, runs))}`);
|
|
303
568
|
}
|
|
304
569
|
console.log('\nThis is a read-only list. Start selected work with `chompyy away <duration>`.');
|
|
305
570
|
return;
|
|
@@ -354,6 +619,20 @@ async function main(argv) {
|
|
|
354
619
|
if (values.json)
|
|
355
620
|
return json(cardView(card));
|
|
356
621
|
console.log(formatCard(card));
|
|
622
|
+
if (!card.run)
|
|
623
|
+
console.log(`\n${formatCostRange(costRange(card, readRuns()))}`);
|
|
624
|
+
else if (card.run.cost?.fiveHourPct != null)
|
|
625
|
+
console.log(`used ${card.run.cost.fiveHourPct}% of the 5h window${card.run.trigger ? ` · started by the ${card.run.trigger} trigger` : ''}`);
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
case 'picture': {
|
|
629
|
+
const id = need(args[0], 'chompyy picture <id> [--model sonnet]');
|
|
630
|
+
await freshQuota();
|
|
631
|
+
if (!values.force && !windowActive(now))
|
|
632
|
+
throw new Error('No active 5-hour window: drawing would start one. Add --force to draw anyway.');
|
|
633
|
+
const path = await pictureCard(id, values.model);
|
|
634
|
+
if (!values.quiet)
|
|
635
|
+
console.log(`Drew the picture for #${id}: ${path}`);
|
|
357
636
|
return;
|
|
358
637
|
}
|
|
359
638
|
case 'blueprint': {
|
|
@@ -366,6 +645,9 @@ async function main(argv) {
|
|
|
366
645
|
case 'approve': {
|
|
367
646
|
const card = updateBoard((b) => moveCard(b, need(args[0], 'chompyy approve <id>'), 'approved', now));
|
|
368
647
|
console.log(`✅ #${card.id} approved: ${card.title}`);
|
|
648
|
+
for (const o of overlaps(card, loadBoard().cards)) {
|
|
649
|
+
console.log(` ⚠️ #${o.id} "${o.title}" may touch the same files (${o.files.slice(0, 3).join(', ')}). Keeping both can conflict; Run again fixes that.`);
|
|
650
|
+
}
|
|
369
651
|
return;
|
|
370
652
|
}
|
|
371
653
|
case 'drop': {
|
|
@@ -373,6 +655,13 @@ async function main(argv) {
|
|
|
373
655
|
console.log(`🗑 #${card.id} dropped: ${card.title}`);
|
|
374
656
|
return;
|
|
375
657
|
}
|
|
658
|
+
case 'run-card': {
|
|
659
|
+
// A worker started by an away run: one card in its own process, so a crash ends only this card.
|
|
660
|
+
const id = need(args[0], 'chompyy run-card <id> --timeout <ms>');
|
|
661
|
+
const config = loadConfig();
|
|
662
|
+
await runCard(id, Number(values.timeout) || config.cardTimeoutMin * 60_000, awayDeps(config, freshQuota), values.trigger);
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
376
665
|
case 'away': {
|
|
377
666
|
const ms = parseDuration(need(args[0], 'chompyy away <1h|30m> [--dry-run] [--force]'));
|
|
378
667
|
const config = loadConfig();
|
|
@@ -380,24 +669,93 @@ async function main(argv) {
|
|
|
380
669
|
const gate = budgetGate(loadSnapshot(), config, now);
|
|
381
670
|
console.log(statusText(loadSnapshot(), now));
|
|
382
671
|
console.log(`gate ${gate.ok ? 'open' : values.force ? 'closed, forced open' : 'closed'}${[...gate.reasons, ...gate.notes].map((r) => `\n · ${r}`).join('')}\n`);
|
|
383
|
-
await
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
672
|
+
await runAway(ms, { dryRun: values['dry-run'], force: values.force }, now, freshQuota);
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
case 'tick': {
|
|
676
|
+
// Run by the LaunchAgent every 5 minutes. Prints one line per tick to tick.log.
|
|
677
|
+
await freshQuota();
|
|
678
|
+
const config = loadConfig();
|
|
679
|
+
const board = loadBoard();
|
|
680
|
+
const d = decideTrigger(now, loadSnapshot(), config, loadTriggerState().fired, awayQueue(board).length, Boolean(awayRunning()));
|
|
681
|
+
const stamp = now.toISOString().slice(0, 16);
|
|
682
|
+
if (!d.fire) {
|
|
683
|
+
noteTick(now, d.why);
|
|
684
|
+
// Nightly consolidation: at bedtime, distil taste even when no card runs.
|
|
685
|
+
if (config.bedtime && bedtimeKey(now, config.bedtime, config.bedtimeWindowMin) && !awayRunning() && windowActive(now) && distillDue(board, now, 12 * 3600_000)) {
|
|
686
|
+
console.log(`${stamp} bedtime · taste: ${await distillNow(now).catch((e) => String(e))}`);
|
|
687
|
+
}
|
|
688
|
+
else if (values.json || process.stdout.isTTY)
|
|
689
|
+
console.log(`${stamp} ${d.why}`);
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
markFired(d.key, now, d.why);
|
|
693
|
+
console.log(`${stamp} ▶ ${d.why}: away for ${formatDuration(d.durationMs)}`);
|
|
694
|
+
await runAway(d.durationMs, { trigger: d.kind }, now, freshQuota);
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
case 'triggers': {
|
|
698
|
+
const sub = args[0];
|
|
699
|
+
if (sub === 'on') {
|
|
700
|
+
const path = installAgent();
|
|
701
|
+
const c = loadConfig();
|
|
702
|
+
console.log(`Triggers on: ${path} runs \`chompyy tick\` every 5 minutes.`);
|
|
703
|
+
console.log(` last hour before a reset: ${c.lastHourTrigger ? `on (with ≥${c.lastHourMinLeftPct}% left)` : 'off'} · bedtime: ${c.bedtime ?? 'not set (chompyy bedtime 23:30)'}`);
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
if (sub === 'off')
|
|
707
|
+
return console.log(uninstallAgent() ? 'Triggers off: removed the LaunchAgent.' : 'Triggers were already off.');
|
|
708
|
+
if (sub)
|
|
709
|
+
throw new Error('Usage: chompyy triggers [on|off]');
|
|
710
|
+
const c = loadConfig();
|
|
711
|
+
const st = loadTriggerState();
|
|
712
|
+
if (values.json)
|
|
713
|
+
return json({ installed: agentInstalled(), lastHour: c.lastHourTrigger, lastHourMinLeftPct: c.lastHourMinLeftPct, bedtime: c.bedtime, ...st });
|
|
714
|
+
console.log(`LaunchAgent ${agentInstalled() ? 'on (every 5 minutes)' : 'off (turn on: chompyy triggers on)'}`);
|
|
715
|
+
console.log(`last hour ${c.lastHourTrigger ? `on, with ≥${c.lastHourMinLeftPct}% of the window left` : 'off'}`);
|
|
716
|
+
console.log(`bedtime ${c.bedtime ?? 'not set'}`);
|
|
717
|
+
if (st.lastTickAt)
|
|
718
|
+
console.log(`last tick ${st.lastTickAt.slice(0, 16).replace('T', ' ')}: ${st.lastDecision ?? ''}`);
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
case 'bedtime': {
|
|
722
|
+
const v = need(args[0], 'chompyy bedtime <23:30|off>');
|
|
723
|
+
if (v === 'off') {
|
|
724
|
+
setConfig('bedtime', null);
|
|
725
|
+
return console.log('Bedtime trigger off.');
|
|
726
|
+
}
|
|
727
|
+
parseClock(v);
|
|
728
|
+
setConfig('bedtime', v);
|
|
729
|
+
console.log(`Bedtime set to ${v}: approved cards run then, with the window that is left.${agentInstalled() ? '' : ' Turn triggers on with `chompyy triggers on`.'}`);
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
case 'last-hour': {
|
|
733
|
+
const v = need(args[0], 'chompyy last-hour <on|off>');
|
|
734
|
+
if (v !== 'on' && v !== 'off')
|
|
735
|
+
throw new Error('Usage: chompyy last-hour <on|off>');
|
|
736
|
+
setConfig('lastHourTrigger', v === 'on');
|
|
737
|
+
console.log(`Last-hour trigger ${v}.${v === 'on' && !agentInstalled() ? ' Turn triggers on with `chompyy triggers on`.' : ''}`);
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
case 'distill': {
|
|
741
|
+
console.log(await distillNow(now, Boolean(values.force)));
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
case 'trends': {
|
|
745
|
+
const lines = trendLines(readRuns(), readSignals(), now);
|
|
746
|
+
console.log(lines.length ? lines.join('\n') : 'Not enough runs yet for trends (needs 3).');
|
|
396
747
|
return;
|
|
397
748
|
}
|
|
398
749
|
case 'report': {
|
|
399
750
|
const since = values.all ? null : lastReportAt();
|
|
400
|
-
|
|
751
|
+
syncTasteFile(now);
|
|
752
|
+
const cards = cardsSince(loadBoard(), since);
|
|
753
|
+
const store = loadStore();
|
|
754
|
+
const signals = readSignals();
|
|
755
|
+
const morning = morningLine(cards, tasteChangesSince(store, since));
|
|
756
|
+
const question = nextQuestion(store, signals);
|
|
757
|
+
const footer = [...(question ? formatQuestion(question, signals) : []), ...trendLines(readRuns(), signals, now)];
|
|
758
|
+
console.log(formatReport(cards, since, (c) => ({ files: changedFiles(c), questions: questionsOf(c) }), { header: morning ? [morning] : [], footer }));
|
|
401
759
|
markReported(now);
|
|
402
760
|
return;
|
|
403
761
|
}
|
|
@@ -413,6 +771,7 @@ async function main(argv) {
|
|
|
413
771
|
card.outcome = 'kept';
|
|
414
772
|
card.column = 'done';
|
|
415
773
|
card.updatedAt = now.toISOString();
|
|
774
|
+
recordOutcome(card, 'kept', now);
|
|
416
775
|
return card;
|
|
417
776
|
});
|
|
418
777
|
return;
|
|
@@ -425,6 +784,7 @@ async function main(argv) {
|
|
|
425
784
|
card.outcome = 'undone';
|
|
426
785
|
card.column = 'done';
|
|
427
786
|
card.updatedAt = now.toISOString();
|
|
787
|
+
recordOutcome(card, 'undone', now);
|
|
428
788
|
return card;
|
|
429
789
|
});
|
|
430
790
|
return;
|
|
@@ -459,6 +819,28 @@ async function main(argv) {
|
|
|
459
819
|
return;
|
|
460
820
|
}
|
|
461
821
|
case 'taste': {
|
|
822
|
+
const sub = args[0];
|
|
823
|
+
const removed = syncTasteFile(now);
|
|
824
|
+
if (removed.length)
|
|
825
|
+
console.log(`Retired ${removed.join(', ')}: you removed ${removed.length === 1 ? 'it' : 'them'} from taste.md.\n`);
|
|
826
|
+
if (sub === 'list') {
|
|
827
|
+
if (values.json)
|
|
828
|
+
return json(loadStore());
|
|
829
|
+
return console.log(formatPrefs(loadStore(), readSignals()));
|
|
830
|
+
}
|
|
831
|
+
if (sub === 'why')
|
|
832
|
+
return console.log(formatWhy(getPref(loadStore(), need(args[1], 'chompyy taste why <id>')), readSignals()));
|
|
833
|
+
if (sub === 'yes' || sub === 'not-now' || sub === 'never') {
|
|
834
|
+
const p = answerPreference(need(args[1], `chompyy taste ${sub} <id>`), sub, now);
|
|
835
|
+
const said = { yes: `✓ Added to taste.md: "${p.text}". Agents follow it from now on.`, 'not-now': `Okay, not now. Chompyy asks again only when there's more evidence.`, never: `🔕 Won't ask about "${p.text}" again.` };
|
|
836
|
+
return console.log(said[sub]);
|
|
837
|
+
}
|
|
838
|
+
if (sub === 'retire') {
|
|
839
|
+
const p = retirePreference(need(args[1], 'chompyy taste retire <id>'), now);
|
|
840
|
+
return console.log(`Retired ${p.id}: "${p.text}". It's kept in \`chompyy taste list\` with the reason.`);
|
|
841
|
+
}
|
|
842
|
+
if (sub)
|
|
843
|
+
throw new Error('Usage: chompyy taste [list | why <id> | yes|not-now|never <id> | retire <id>]');
|
|
462
844
|
const { path, text, created } = readTaste();
|
|
463
845
|
if (created)
|
|
464
846
|
console.log(`(created ${path})\n`);
|