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.
Files changed (166) hide show
  1. package/README.md +79 -6
  2. package/THIRD_PARTY_NOTICES.md +28 -0
  3. package/dist/appstate.js +43 -2
  4. package/dist/away.js +104 -15
  5. package/dist/board.js +33 -3
  6. package/dist/claudesettings.js +23 -0
  7. package/dist/cli.js +409 -27
  8. package/dist/coldstart.js +207 -0
  9. package/dist/config.js +36 -1
  10. package/dist/costs.js +162 -0
  11. package/dist/gate.js +29 -0
  12. package/dist/history.js +308 -0
  13. package/dist/livequota.js +15 -1
  14. package/dist/pacing.js +189 -0
  15. package/dist/picture.js +117 -0
  16. package/dist/projects.js +2 -2
  17. package/dist/quota.js +31 -5
  18. package/dist/report.js +38 -21
  19. package/dist/review.js +47 -4
  20. package/dist/runner.js +268 -8
  21. package/dist/taste.js +507 -0
  22. package/dist/triggers.js +182 -0
  23. package/dist/verify.js +131 -0
  24. package/package.json +2 -1
  25. package/skills/taste/SKILL.md +4 -1
  26. package/vendor/diagram-design/LICENSE +21 -0
  27. package/vendor/diagram-design/SKILL.md +399 -0
  28. package/vendor/diagram-design/UPSTREAM.md +18 -0
  29. package/vendor/diagram-design/assets/example-arc-diagram.html +111 -0
  30. package/vendor/diagram-design/assets/example-architecture-containment.html +205 -0
  31. package/vendor/diagram-design/assets/example-architecture-delta.html +193 -0
  32. package/vendor/diagram-design/assets/example-architecture.html +183 -0
  33. package/vendor/diagram-design/assets/example-axonometric-plan-campus.html +108 -0
  34. package/vendor/diagram-design/assets/example-axonometric-plan-coffee-shop.html +121 -0
  35. package/vendor/diagram-design/assets/example-axonometric-plan-warehouse.html +127 -0
  36. package/vendor/diagram-design/assets/example-axonometric-plan.html +114 -0
  37. package/vendor/diagram-design/assets/example-bar.html +129 -0
  38. package/vendor/diagram-design/assets/example-beeswarm.html +384 -0
  39. package/vendor/diagram-design/assets/example-box-plot.html +127 -0
  40. package/vendor/diagram-design/assets/example-bubble.html +147 -0
  41. package/vendor/diagram-design/assets/example-bump.html +142 -0
  42. package/vendor/diagram-design/assets/example-data-flow.html +143 -0
  43. package/vendor/diagram-design/assets/example-datalake.html +269 -0
  44. package/vendor/diagram-design/assets/example-db-schema.html +302 -0
  45. package/vendor/diagram-design/assets/example-dependency.html +224 -0
  46. package/vendor/diagram-design/assets/example-deployment.html +190 -0
  47. package/vendor/diagram-design/assets/example-dp-integration.html +81 -0
  48. package/vendor/diagram-design/assets/example-dp-security-matrix.html +88 -0
  49. package/vendor/diagram-design/assets/example-er.html +202 -0
  50. package/vendor/diagram-design/assets/example-event-modeling.html +64 -0
  51. package/vendor/diagram-design/assets/example-exploded-ai-stack.html +85 -0
  52. package/vendor/diagram-design/assets/example-exploded-keyboard.html +84 -0
  53. package/vendor/diagram-design/assets/example-exploded-phone.html +83 -0
  54. package/vendor/diagram-design/assets/example-exploded-unboxing.html +84 -0
  55. package/vendor/diagram-design/assets/example-exploded.html +83 -0
  56. package/vendor/diagram-design/assets/example-fishbone.html +152 -0
  57. package/vendor/diagram-design/assets/example-flowchart.html +163 -0
  58. package/vendor/diagram-design/assets/example-gantt.html +137 -0
  59. package/vendor/diagram-design/assets/example-heatmap.html +224 -0
  60. package/vendor/diagram-design/assets/example-high-level-vertical.html +325 -0
  61. package/vendor/diagram-design/assets/example-high-level.html +301 -0
  62. package/vendor/diagram-design/assets/example-import-drawio.html +185 -0
  63. package/vendor/diagram-design/assets/example-import-excalidraw.html +70 -0
  64. package/vendor/diagram-design/assets/example-import-mermaid.html +70 -0
  65. package/vendor/diagram-design/assets/example-import-plantuml.html +107 -0
  66. package/vendor/diagram-design/assets/example-it-state.html +128 -0
  67. package/vendor/diagram-design/assets/example-journey.html +148 -0
  68. package/vendor/diagram-design/assets/example-kanban.html +174 -0
  69. package/vendor/diagram-design/assets/example-layers.html +123 -0
  70. package/vendor/diagram-design/assets/example-line.html +111 -0
  71. package/vendor/diagram-design/assets/example-loop.html +100 -0
  72. package/vendor/diagram-design/assets/example-marimekko.html +148 -0
  73. package/vendor/diagram-design/assets/example-medallion.html +159 -0
  74. package/vendor/diagram-design/assets/example-nested.html +136 -0
  75. package/vendor/diagram-design/assets/example-org-chart.html +45 -0
  76. package/vendor/diagram-design/assets/example-polar.html +116 -0
  77. package/vendor/diagram-design/assets/example-process.html +64 -0
  78. package/vendor/diagram-design/assets/example-pyramid.html +119 -0
  79. package/vendor/diagram-design/assets/example-quadrant-consultant.html +166 -0
  80. package/vendor/diagram-design/assets/example-quadrant.html +135 -0
  81. package/vendor/diagram-design/assets/example-radar.html +139 -0
  82. package/vendor/diagram-design/assets/example-requirement-traceability.html +122 -0
  83. package/vendor/diagram-design/assets/example-ridgeline.html +104 -0
  84. package/vendor/diagram-design/assets/example-sankey.html +150 -0
  85. package/vendor/diagram-design/assets/example-sbgn.html +213 -0
  86. package/vendor/diagram-design/assets/example-scatter.html +141 -0
  87. package/vendor/diagram-design/assets/example-sequence-oauth.html +227 -0
  88. package/vendor/diagram-design/assets/example-sequence.html +222 -0
  89. package/vendor/diagram-design/assets/example-service-blueprint.html +185 -0
  90. package/vendor/diagram-design/assets/example-slopegraph.html +119 -0
  91. package/vendor/diagram-design/assets/example-state-lifecycle.html +92 -0
  92. package/vendor/diagram-design/assets/example-state.html +147 -0
  93. package/vendor/diagram-design/assets/example-steps.html +78 -0
  94. package/vendor/diagram-design/assets/example-story-map.html +184 -0
  95. package/vendor/diagram-design/assets/example-streamgraph.html +99 -0
  96. package/vendor/diagram-design/assets/example-swimlane.html +172 -0
  97. package/vendor/diagram-design/assets/example-timeline.html +135 -0
  98. package/vendor/diagram-design/assets/example-tree-block-decomposition.html +151 -0
  99. package/vendor/diagram-design/assets/example-tree.html +173 -0
  100. package/vendor/diagram-design/assets/example-treemap.html +107 -0
  101. package/vendor/diagram-design/assets/example-uml-class.html +188 -0
  102. package/vendor/diagram-design/assets/example-unit-grid.html +141 -0
  103. package/vendor/diagram-design/assets/example-venn.html +110 -0
  104. package/vendor/diagram-design/assets/example-wardley.html +153 -0
  105. package/vendor/diagram-design/assets/example-waterfall.html +129 -0
  106. package/vendor/diagram-design/assets/template-dark.html +99 -0
  107. package/vendor/diagram-design/assets/template.html +100 -0
  108. package/vendor/diagram-design/references/layout-budget.md +103 -0
  109. package/vendor/diagram-design/references/output-spec.md +277 -0
  110. package/vendor/diagram-design/references/primitive-annotation.md +36 -0
  111. package/vendor/diagram-design/references/primitive-sketchy.md +43 -0
  112. package/vendor/diagram-design/references/primitives-core.md +146 -0
  113. package/vendor/diagram-design/references/semantic-patterns.md +154 -0
  114. package/vendor/diagram-design/references/style-guide.md +234 -0
  115. package/vendor/diagram-design/references/type-architecture-delta.md +143 -0
  116. package/vendor/diagram-design/references/type-architecture.md +117 -0
  117. package/vendor/diagram-design/references/type-axonometric-plan.md +83 -0
  118. package/vendor/diagram-design/references/type-bar.md +108 -0
  119. package/vendor/diagram-design/references/type-data-flow.md +371 -0
  120. package/vendor/diagram-design/references/type-db-schema.md +48 -0
  121. package/vendor/diagram-design/references/type-dependency.md +113 -0
  122. package/vendor/diagram-design/references/type-deployment.md +45 -0
  123. package/vendor/diagram-design/references/type-dp-integration.md +407 -0
  124. package/vendor/diagram-design/references/type-dp-security-matrix.md +379 -0
  125. package/vendor/diagram-design/references/type-er.md +25 -0
  126. package/vendor/diagram-design/references/type-event-modeling.md +36 -0
  127. package/vendor/diagram-design/references/type-exploded.md +115 -0
  128. package/vendor/diagram-design/references/type-fishbone.md +75 -0
  129. package/vendor/diagram-design/references/type-flowchart.md +23 -0
  130. package/vendor/diagram-design/references/type-gantt.md +45 -0
  131. package/vendor/diagram-design/references/type-heatmap.md +80 -0
  132. package/vendor/diagram-design/references/type-high-level.md +470 -0
  133. package/vendor/diagram-design/references/type-it-state.md +468 -0
  134. package/vendor/diagram-design/references/type-journey.md +55 -0
  135. package/vendor/diagram-design/references/type-kanban.md +49 -0
  136. package/vendor/diagram-design/references/type-layers.md +26 -0
  137. package/vendor/diagram-design/references/type-line.md +337 -0
  138. package/vendor/diagram-design/references/type-loop.md +223 -0
  139. package/vendor/diagram-design/references/type-medallion.md +356 -0
  140. package/vendor/diagram-design/references/type-nested.md +22 -0
  141. package/vendor/diagram-design/references/type-org-chart.md +44 -0
  142. package/vendor/diagram-design/references/type-polar.md +136 -0
  143. package/vendor/diagram-design/references/type-process.md +490 -0
  144. package/vendor/diagram-design/references/type-pyramid.md +33 -0
  145. package/vendor/diagram-design/references/type-quadrant.md +81 -0
  146. package/vendor/diagram-design/references/type-radar.md +82 -0
  147. package/vendor/diagram-design/references/type-requirement-traceability.md +45 -0
  148. package/vendor/diagram-design/references/type-sankey.md +75 -0
  149. package/vendor/diagram-design/references/type-sbgn.md +80 -0
  150. package/vendor/diagram-design/references/type-scatter.md +276 -0
  151. package/vendor/diagram-design/references/type-sequence.md +130 -0
  152. package/vendor/diagram-design/references/type-service-blueprint.md +103 -0
  153. package/vendor/diagram-design/references/type-state.md +30 -0
  154. package/vendor/diagram-design/references/type-steps.md +180 -0
  155. package/vendor/diagram-design/references/type-story-map.md +46 -0
  156. package/vendor/diagram-design/references/type-swimlane.md +22 -0
  157. package/vendor/diagram-design/references/type-timeline.md +20 -0
  158. package/vendor/diagram-design/references/type-tree.md +24 -0
  159. package/vendor/diagram-design/references/type-treemap.md +137 -0
  160. package/vendor/diagram-design/references/type-uml-class.md +65 -0
  161. package/vendor/diagram-design/references/type-unit-grid.md +63 -0
  162. package/vendor/diagram-design/references/type-venn.md +26 -0
  163. package/vendor/diagram-design/references/type-wardley.md +39 -0
  164. package/vendor/diagram-design/references/type-waterfall.md +75 -0
  165. package/vendor/diagram-design/scripts/self_check.py +1177 -0
  166. package/vendor/diagram-design/scripts/verify_geometry.py +696 -0
@@ -0,0 +1,182 @@
1
+ // Triggers (spec §5.2): start an away run on its own in the last hour before a 5-hour reset, or at your bedtime.
2
+ // `chompyy tick` checks them; `chompyy triggers on` installs a macOS LaunchAgent that runs the tick every
3
+ // 5 minutes. Nothing fires until you turn triggers on. The budget gate still decides every card.
4
+ import { execFileSync } from 'node:child_process';
5
+ import { existsSync, rmSync, writeFileSync, mkdirSync } from 'node:fs';
6
+ import { homedir } from 'node:os';
7
+ import { dirname, join } from 'node:path';
8
+ import { budgetGate } from './gate.js';
9
+ import { homePath, readJson, writeJson } from './home.js';
10
+ import { windowView } from './quota.js';
11
+ const statePath = () => homePath('triggers.json');
12
+ export const loadTriggerState = () => readJson(statePath(), { fired: [] });
13
+ export function markFired(key, now, why) {
14
+ const s = loadTriggerState();
15
+ s.fired = [...s.fired.filter((k) => k !== key), key].slice(-50);
16
+ s.lastTickAt = now.toISOString();
17
+ s.lastDecision = why;
18
+ writeJson(statePath(), s);
19
+ }
20
+ export function noteTick(now, why) {
21
+ writeJson(statePath(), { ...loadTriggerState(), lastTickAt: now.toISOString(), lastDecision: why });
22
+ }
23
+ /** "23:30" → minutes after midnight; throws on anything else. */
24
+ export function parseClock(text) {
25
+ const m = text.trim().match(/^(\d{1,2}):(\d{2})$/);
26
+ if (!m || Number(m[1]) > 23 || Number(m[2]) > 59)
27
+ throw new Error(`Bedtime must look like 23:30, not "${text}".`);
28
+ return Number(m[1]) * 60 + Number(m[2]);
29
+ }
30
+ /** If `now` is within the bedtime window, the local date the bedtime started on (handles windows past midnight). */
31
+ export function bedtimeKey(now, bedtime, windowMin) {
32
+ const start = parseClock(bedtime);
33
+ const minutes = now.getHours() * 60 + now.getMinutes();
34
+ let since = minutes - start;
35
+ const day = new Date(now);
36
+ if (since < 0) {
37
+ since += 24 * 60; // bedtime was yesterday evening
38
+ day.setDate(day.getDate() - 1);
39
+ }
40
+ if (since >= windowMin)
41
+ return null;
42
+ const pad = (n) => String(n).padStart(2, '0');
43
+ return `bedtime:${day.getFullYear()}-${pad(day.getMonth() + 1)}-${pad(day.getDate())}`;
44
+ }
45
+ /** Leave this much before the reset so the last card isn't cut off by a fresh window. */
46
+ const RESET_MARGIN_MS = 2 * 60_000;
47
+ const MIN_RUN_MS = 10 * 60_000;
48
+ /** Should a trigger start an away run now? Pure: the tick reads state, this decides. */
49
+ export function decideTrigger(now, snap, config, fired, approved, awayRunning) {
50
+ if (awayRunning)
51
+ return { fire: false, why: 'an away run is already going' };
52
+ if (approved === 0)
53
+ return { fire: false, why: 'no approved cards' };
54
+ const gate = budgetGate(snap, config, now);
55
+ if (!gate.ok)
56
+ return { fire: false, why: `gate closed: ${gate.reasons.join('; ')}` };
57
+ const five = windowView(snap?.fiveHour, now);
58
+ if (!five.known)
59
+ return { fire: false, why: '5h window unknown' };
60
+ const untilReset = five.msLeft - RESET_MARGIN_MS;
61
+ if (config.lastHourTrigger && five.msLeft <= 60 * 60_000) {
62
+ const key = `last-hour:${five.resetsAt}`;
63
+ if (fired.includes(key))
64
+ return { fire: false, why: 'last-hour already ran for this window' };
65
+ if (five.leftPct < config.lastHourMinLeftPct)
66
+ return { fire: false, why: `last hour, but only ${Math.round(five.leftPct)}% left (under ${config.lastHourMinLeftPct}%)` };
67
+ if (untilReset < MIN_RUN_MS)
68
+ return { fire: false, why: 'too close to the reset to finish a card' };
69
+ return { fire: true, kind: 'last-hour', durationMs: untilReset, key, why: `last hour before the reset with ${Math.round(five.leftPct)}% left` };
70
+ }
71
+ if (config.bedtime) {
72
+ const key = bedtimeKey(now, config.bedtime, config.bedtimeWindowMin);
73
+ if (key) {
74
+ if (fired.includes(key))
75
+ return { fire: false, why: 'bedtime already ran tonight' };
76
+ if (untilReset < MIN_RUN_MS)
77
+ return { fire: false, why: 'too close to the reset to finish a card' };
78
+ return { fire: true, kind: 'bedtime', durationMs: untilReset, key, why: `bedtime, ${Math.round(five.leftPct)}% of the window left` };
79
+ }
80
+ }
81
+ return { fire: false, why: 'no trigger due' };
82
+ }
83
+ // ---------- the away lock (a trigger and a manual away must not run the same cards) ----------
84
+ export function lockPath() {
85
+ return homePath('away.lock');
86
+ }
87
+ function alive(pid) {
88
+ try {
89
+ process.kill(pid, 0);
90
+ return true;
91
+ }
92
+ catch (err) {
93
+ return err.code === 'EPERM';
94
+ }
95
+ }
96
+ /** The pid of a running away, or null. A lock left by a dead process doesn't count. */
97
+ export function awayRunning() {
98
+ const lock = readJson(lockPath(), null);
99
+ return lock?.pid && lock.pid !== process.pid && alive(lock.pid) ? lock.pid : null;
100
+ }
101
+ /** Take the lock or throw. Returns a release function. */
102
+ export function takeAwayLock(now, why) {
103
+ const other = awayRunning();
104
+ if (other)
105
+ throw new Error(`Another away run is going (pid ${other}). Wait for it, or stop it first.`);
106
+ writeJson(lockPath(), { pid: process.pid, at: now.toISOString(), why });
107
+ return () => {
108
+ const lock = readJson(lockPath(), null);
109
+ if (lock?.pid === process.pid)
110
+ rmSync(lockPath(), { force: true });
111
+ };
112
+ }
113
+ // ---------- LaunchAgent ----------
114
+ export const AGENT_LABEL = 'dev.chompyy.tick';
115
+ export function agentPath() {
116
+ return join(homedir(), 'Library', 'LaunchAgents', `${AGENT_LABEL}.plist`);
117
+ }
118
+ const xml = (s) => s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
119
+ export function launchAgentPlist(opts) {
120
+ const env = Object.entries(opts.env)
121
+ .map(([k, v]) => ` <key>${xml(k)}</key><string>${xml(v)}</string>`)
122
+ .join('\n');
123
+ return `<?xml version="1.0" encoding="UTF-8"?>
124
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
125
+ <plist version="1.0">
126
+ <dict>
127
+ <key>Label</key><string>${AGENT_LABEL}</string>
128
+ <key>ProgramArguments</key>
129
+ <array>
130
+ <string>${xml(opts.node)}</string>
131
+ <string>${xml(opts.script)}</string>
132
+ <string>tick</string>
133
+ </array>
134
+ <key>StartInterval</key><integer>${opts.intervalSec ?? 300}</integer>
135
+ <key>RunAtLoad</key><false/>
136
+ <key>StandardOutPath</key><string>${xml(opts.log)}</string>
137
+ <key>StandardErrorPath</key><string>${xml(opts.log)}</string>
138
+ <key>EnvironmentVariables</key>
139
+ <dict>
140
+ ${env}
141
+ </dict>
142
+ </dict>
143
+ </plist>
144
+ `;
145
+ }
146
+ function launchctl(args) {
147
+ execFileSync('launchctl', args, { stdio: 'ignore' });
148
+ }
149
+ /** Install (or reinstall) the LaunchAgent that runs `chompyy tick` every 5 minutes. */
150
+ export function installAgent() {
151
+ if (process.platform !== 'darwin')
152
+ throw new Error('Triggers run from a macOS LaunchAgent; on other systems, run `chompyy tick` from cron every 5 minutes.');
153
+ const path = agentPath();
154
+ const env = { PATH: process.env.PATH ?? '/usr/bin:/bin' };
155
+ if (process.env.CHOMPYY_HOME)
156
+ env.CHOMPYY_HOME = process.env.CHOMPYY_HOME;
157
+ if (process.env.HOME)
158
+ env.HOME = process.env.HOME;
159
+ mkdirSync(dirname(path), { recursive: true });
160
+ writeFileSync(path, launchAgentPlist({ node: process.execPath, script: process.argv[1], log: homePath('tick.log'), env }));
161
+ const domain = `gui/${process.getuid?.() ?? 501}`;
162
+ try {
163
+ launchctl(['bootout', `${domain}/${AGENT_LABEL}`]);
164
+ }
165
+ catch { }
166
+ launchctl(['bootstrap', domain, path]);
167
+ return path;
168
+ }
169
+ export function uninstallAgent() {
170
+ const path = agentPath();
171
+ if (!existsSync(path))
172
+ return false;
173
+ try {
174
+ launchctl(['bootout', `gui/${process.getuid?.() ?? 501}/${AGENT_LABEL}`]);
175
+ }
176
+ catch { }
177
+ rmSync(path, { force: true });
178
+ return true;
179
+ }
180
+ export function agentInstalled() {
181
+ return existsSync(agentPath());
182
+ }
package/dist/verify.js ADDED
@@ -0,0 +1,131 @@
1
+ // Independent check (FEATURES §5): after a card runs, Chompyy runs the repo's own tests itself, so "Checks
2
+ // pass" no longer rests only on the agent grading its own work. The tests are code the agent may have
3
+ // written, so they run in a macOS sandbox (sandbox-exec): writes only in the card's folder, the tool cache and
4
+ // temp folders; no network; no reads of credential folders. Elsewhere the check is skipped, never run open.
5
+ import { spawn } from 'node:child_process';
6
+ import { existsSync, lstatSync, readFileSync, readdirSync, rmSync, symlinkSync } from 'node:fs';
7
+ import { homedir } from 'node:os';
8
+ import { join } from 'node:path';
9
+ /** Signs in test output that the sandbox, not the code, stopped it. */
10
+ export function looksSandboxBlocked(output) {
11
+ return /\bEPERM\b|Operation not permitted|ENOTFOUND|EAI_AGAIN|getaddrinfo|network is unreachable|Could not resolve host/i.test(output);
12
+ }
13
+ const read = (p) => (existsSync(p) ? readFileSync(p, 'utf8') : '');
14
+ /** The repo's test command, from what's in the folder. `override` (from config) wins. */
15
+ export function detectCheck(dir, override) {
16
+ if (override?.trim())
17
+ return { argv: ['sh', '-c', override], label: override.trim() };
18
+ const pkg = read(join(dir, 'package.json'));
19
+ if (pkg) {
20
+ try {
21
+ const test = JSON.parse(pkg).scripts?.test;
22
+ if (test && !/no test specified/.test(test)) {
23
+ const pm = existsSync(join(dir, 'pnpm-lock.yaml')) ? 'pnpm' : existsSync(join(dir, 'yarn.lock')) ? 'yarn' : 'npm';
24
+ return { argv: [pm, 'test'], label: `${pm} test`, node: true };
25
+ }
26
+ }
27
+ catch { }
28
+ }
29
+ if (existsSync(join(dir, 'go.mod')))
30
+ return { argv: ['go', 'test', './...'], label: 'go test ./...' };
31
+ if (existsSync(join(dir, 'Cargo.toml')))
32
+ return { argv: ['cargo', 'test', '--offline'], label: 'cargo test --offline' };
33
+ const py = read(join(dir, 'pyproject.toml')) + read(join(dir, 'setup.cfg')) + read(join(dir, 'tox.ini'));
34
+ const hasPyTests = existsSync(join(dir, 'pytest.ini')) || /pytest/.test(py) || (existsSync(join(dir, 'tests')) && readdirSync(join(dir, 'tests')).some((f) => /^test_.*\.py$/.test(f)));
35
+ if (hasPyTests)
36
+ return { argv: ['python3', '-m', 'pytest', '-q'], label: 'pytest' };
37
+ if (/^test:/m.test(read(join(dir, 'Makefile'))))
38
+ return { argv: ['make', 'test'], label: 'make test' };
39
+ return null;
40
+ }
41
+ const sbString = (p) => `"${p.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
42
+ const expand = (p) => (p.startsWith('~/') ? join(homedir(), p.slice(2)) : p);
43
+ /** The sandbox-exec profile: everything readable except credentials; writes only where the check needs them. */
44
+ export function sandboxProfile(opts) {
45
+ return [
46
+ '(version 1)',
47
+ '(allow default)',
48
+ '(deny network*)',
49
+ '(allow network* (local unix))',
50
+ '(deny file-write*)',
51
+ `(allow file-write* ${[...opts.writable.map((p) => `(subpath ${sbString(p)})`), '(subpath "/private/tmp")', '(subpath "/private/var/folders")', '(literal "/dev/null")', '(literal "/dev/tty")'].join(' ')})`,
52
+ ...opts.denyRead.map((p) => `(deny file-read* (subpath ${sbString(expand(p))}))`),
53
+ ].join('\n');
54
+ }
55
+ function tail(text, lines = 15) {
56
+ return text
57
+ .replace(/\u001b\[[0-9;]*[A-Za-z]/g, '') // colour codes
58
+ .trimEnd().split('\n').slice(-lines).join('\n').slice(-2000);
59
+ }
60
+ /** Run the repo's tests in the card's folder, sandboxed. Never throws. */
61
+ export async function verifyRun(opts) {
62
+ const at = () => opts.now().toISOString();
63
+ const check = detectCheck(opts.dir, opts.override);
64
+ if (!check)
65
+ return { result: 'not run', why: 'no test command found in the repo', at: at() };
66
+ if (!opts.unsandboxed && (process.platform !== 'darwin' || !existsSync('/usr/bin/sandbox-exec'))) {
67
+ return { result: 'not run', command: check.label, why: 'needs the macOS sandbox (sandbox-exec) to run tests safely', at: at() };
68
+ }
69
+ // A fresh worktree has no node_modules (it's gitignored): borrow your checkout's for the check.
70
+ const writable = [opts.dir, opts.cacheDir];
71
+ let linked = '';
72
+ if (check.node && opts.repoRoot) {
73
+ const mine = join(opts.dir, 'node_modules');
74
+ const theirs = join(opts.repoRoot, 'node_modules');
75
+ if (!existsSync(mine) && existsSync(theirs)) {
76
+ symlinkSync(theirs, mine, 'dir');
77
+ linked = mine;
78
+ writable.push(join(theirs, '.vite'), join(theirs, '.vite-temp'), join(theirs, '.cache')); // test runners' caches and temp files
79
+ }
80
+ }
81
+ const argv = opts.unsandboxed ? check.argv : ['/usr/bin/sandbox-exec', '-p', sandboxProfile({ writable, denyRead: opts.denyRead }), ...check.argv];
82
+ try {
83
+ const r = await run(argv, opts.dir, { ...process.env, ...opts.env, CI: '1', NO_COLOR: '1', FORCE_COLOR: '0' }, opts.timeoutMs);
84
+ if (r.timedOut)
85
+ return { result: 'failed', command: check.label, why: `took longer than ${Math.round(opts.timeoutMs / 60_000)} minutes`, at: at(), tail: tail(r.output) };
86
+ if (r.code === 0)
87
+ return { result: 'passed', command: check.label, why: `${check.label} passed`, at: at() };
88
+ if (!opts.unsandboxed && looksSandboxBlocked(r.output)) {
89
+ return { result: 'failed', command: check.label, why: `${check.label} failed, but the sandbox blocked something it needs (a write outside the folder or the network), so it may not be the change`, at: at(), tail: tail(r.output), sandboxBlocked: true };
90
+ }
91
+ return { result: 'failed', command: check.label, why: `${check.label} exited with ${r.code}`, at: at(), tail: tail(r.output) };
92
+ }
93
+ catch (err) {
94
+ return { result: 'not run', command: check.label, why: `couldn't start: ${err instanceof Error ? err.message : err}`, at: at() };
95
+ }
96
+ finally {
97
+ if (linked && lstatSync(linked).isSymbolicLink())
98
+ rmSync(linked);
99
+ }
100
+ }
101
+ function run(argv, cwd, env, timeoutMs) {
102
+ return new Promise((resolve, reject) => {
103
+ const child = spawn(argv[0], argv.slice(1), { cwd, env, stdio: ['ignore', 'pipe', 'pipe'], detached: true });
104
+ let output = '';
105
+ let timedOut = false;
106
+ const add = (d) => {
107
+ output = (output + d.toString()).slice(-20_000);
108
+ };
109
+ child.stdout.on('data', add);
110
+ child.stderr.on('data', add);
111
+ const kill = () => {
112
+ try {
113
+ if (child.pid)
114
+ process.kill(-child.pid, 'SIGKILL');
115
+ }
116
+ catch { }
117
+ };
118
+ const timer = setTimeout(() => {
119
+ timedOut = true;
120
+ kill();
121
+ }, timeoutMs);
122
+ child.on('error', (err) => {
123
+ clearTimeout(timer);
124
+ reject(err);
125
+ });
126
+ child.on('close', (code) => {
127
+ clearTimeout(timer);
128
+ resolve({ code, output, timedOut });
129
+ });
130
+ });
131
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chompyy",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Use Claude Code 5-hour window capacity that would reset unused: park ideas, blueprint them, run approved cards while you're away.",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -27,6 +27,7 @@
27
27
  "files": [
28
28
  "dist",
29
29
  "skills",
30
+ "vendor",
30
31
  "LICENSE",
31
32
  "THIRD_PARTY_NOTICES.md"
32
33
  ],
@@ -12,5 +12,8 @@ description: Show the user's Chompyy taste.md, what Chompyy has learned about ho
12
12
  ```
13
13
 
14
14
  It prints `~/.chompyy/taste.md`, creating a stub with a header the first time.
15
- 2. Show the content as is. If it's only the stub, say that preferences aren't distilled yet: ratings from `chompyy rate` collect in `~/.chompyy/signals.jsonl` until the distiller exists.
15
+ 2. Show the content as is. If it's only the stub, say nothing is learned yet: preferences come from ratings, blueprint edits and keep/undo, and the distiller reads them after each away run (or now with `chompyy distill`).
16
+ - To see every preference, including ones waiting to be asked: `chompyy taste list`.
17
+ - "Why do you think that?": `chompyy taste why <id>` shows the cards, edits and quotes behind it.
18
+ - The user answers a question with `chompyy taste yes|not-now|never <id>`, or stops one with `chompyy taste retire <id>`.
16
19
  3. If the user wants to change something, edit `~/.chompyy/taste.md` directly. The user's edits always win; keep each line short and under a `## <scope>` heading.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Cathryn Lavery
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.