chompyy 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/README.md +11 -0
  2. package/dist/agentlimits.js +77 -0
  3. package/dist/agentusage.js +96 -0
  4. package/dist/appstate.js +63 -3
  5. package/dist/away.js +44 -5
  6. package/dist/blueprint.js +3 -7
  7. package/dist/board.js +1 -0
  8. package/dist/cli.js +263 -5
  9. package/dist/codexquota.js +106 -0
  10. package/dist/codexusage.js +10 -0
  11. package/dist/config.js +2 -0
  12. package/dist/context.js +30 -0
  13. package/dist/costs.js +1 -0
  14. package/dist/demon.js +20 -0
  15. package/dist/label.js +33 -0
  16. package/dist/menu.js +17 -0
  17. package/dist/nightcap.js +60 -0
  18. package/dist/nudge.js +47 -18
  19. package/dist/pacing.js +16 -1
  20. package/dist/questions.js +71 -0
  21. package/dist/recap.js +74 -0
  22. package/dist/receipt.js +48 -0
  23. package/dist/recipe.js +79 -0
  24. package/dist/stamps.js +14 -0
  25. package/dist/triggers.js +5 -0
  26. package/dist/usage.js +21 -1
  27. package/dist/vendor/codeburn/antigravity.js +309 -0
  28. package/dist/vendor/codeburn/codex.js +429 -0
  29. package/dist/vendor/codeburn/copilot.js +292 -0
  30. package/dist/vendor/codeburn/gemini.js +195 -0
  31. package/dist/vendor/codeburn/grokbot.js +182 -0
  32. package/dist/vendor/codeburn/kimi.js +178 -0
  33. package/dist/vendor/codeburn/shims/chalk.js +14 -0
  34. package/dist/vendor/codeburn/shims/strip-ansi.js +6 -0
  35. package/dist/vendor/codeburn/src/act/backup.js +83 -0
  36. package/dist/vendor/codeburn/src/act/model-defaults.js +151 -0
  37. package/dist/vendor/codeburn/src/act/types.js +37 -0
  38. package/dist/vendor/codeburn/src/bash-utils.js +204 -0
  39. package/dist/vendor/codeburn/src/behavioral-weight.js +47 -0
  40. package/dist/vendor/codeburn/src/cache-dir.js +26 -0
  41. package/dist/vendor/codeburn/src/cache-refresh-lock.js +543 -0
  42. package/dist/vendor/codeburn/src/cache-sweep.js +67 -0
  43. package/dist/vendor/codeburn/src/classifier.js +209 -0
  44. package/dist/vendor/codeburn/src/claude-identity.js +223 -0
  45. package/dist/vendor/codeburn/src/codex-cache.js +377 -0
  46. package/dist/vendor/codeburn/src/codex-fork-replay.js +232 -0
  47. package/dist/vendor/codeburn/src/codex-jsonl-fields.js +99 -0
  48. package/dist/vendor/codeburn/src/codex-session-index.js +113 -0
  49. package/dist/vendor/codeburn/src/codex-throughput.js +544 -0
  50. package/dist/vendor/codeburn/src/compare-stats.js +405 -0
  51. package/dist/vendor/codeburn/src/config.js +145 -0
  52. package/dist/vendor/codeburn/src/content-utils.js +56 -0
  53. package/dist/vendor/codeburn/src/context-tree-codex.js +329 -0
  54. package/dist/vendor/codeburn/src/context-tree.js +664 -0
  55. package/dist/vendor/codeburn/src/copilot-aiu.js +16 -0
  56. package/dist/vendor/codeburn/src/currency.js +189 -0
  57. package/dist/vendor/codeburn/src/cursor-cache.js +238 -0
  58. package/dist/vendor/codeburn/src/cursor-import.js +402 -0
  59. package/dist/vendor/codeburn/src/cursor-sync.js +256 -0
  60. package/dist/vendor/codeburn/src/daily-cache.js +2036 -0
  61. package/dist/vendor/codeburn/src/data/litellm-snapshot.json +1 -0
  62. package/dist/vendor/codeburn/src/data/pricing-fallback.json +1 -0
  63. package/dist/vendor/codeburn/src/day-aggregator.js +327 -0
  64. package/dist/vendor/codeburn/src/editor-data-dir.js +11 -0
  65. package/dist/vendor/codeburn/src/fetch-utils.js +18 -0
  66. package/dist/vendor/codeburn/src/format.js +118 -0
  67. package/dist/vendor/codeburn/src/fs-utils.js +270 -0
  68. package/dist/vendor/codeburn/src/git-origin.js +334 -0
  69. package/dist/vendor/codeburn/src/granular-history.js +328 -0
  70. package/dist/vendor/codeburn/src/hermes-session-ledger.js +512 -0
  71. package/dist/vendor/codeburn/src/launcher-homes.js +142 -0
  72. package/dist/vendor/codeburn/src/live-sessions.js +358 -0
  73. package/dist/vendor/codeburn/src/math-utils.js +8 -0
  74. package/dist/vendor/codeburn/src/menubar-json.js +294 -0
  75. package/dist/vendor/codeburn/src/models.js +1879 -0
  76. package/dist/vendor/codeburn/src/optimize-one-hour-cache.js +92 -0
  77. package/dist/vendor/codeburn/src/optimize.js +4110 -0
  78. package/dist/vendor/codeburn/src/parse-workers.js +219 -0
  79. package/dist/vendor/codeburn/src/parser.js +6953 -0
  80. package/dist/vendor/codeburn/src/path-privacy.js +26 -0
  81. package/dist/vendor/codeburn/src/plans.js +135 -0
  82. package/dist/vendor/codeburn/src/pr-signals.js +132 -0
  83. package/dist/vendor/codeburn/src/project-filter-warnings.js +33 -0
  84. package/dist/vendor/codeburn/src/provider-issues.js +30 -0
  85. package/dist/vendor/codeburn/src/providers/amp.js +286 -0
  86. package/dist/vendor/codeburn/src/providers/antigravity.js +1731 -0
  87. package/dist/vendor/codeburn/src/providers/claude.js +551 -0
  88. package/dist/vendor/codeburn/src/providers/cline-cli.js +401 -0
  89. package/dist/vendor/codeburn/src/providers/cline.js +63 -0
  90. package/dist/vendor/codeburn/src/providers/codebuff.js +336 -0
  91. package/dist/vendor/codeburn/src/providers/codewhale.js +442 -0
  92. package/dist/vendor/codeburn/src/providers/codex.js +1720 -0
  93. package/dist/vendor/codeburn/src/providers/command-code.js +196 -0
  94. package/dist/vendor/codeburn/src/providers/copilot.js +3278 -0
  95. package/dist/vendor/codeburn/src/providers/crush.js +226 -0
  96. package/dist/vendor/codeburn/src/providers/cursor-agent.js +837 -0
  97. package/dist/vendor/codeburn/src/providers/cursor.js +1163 -0
  98. package/dist/vendor/codeburn/src/providers/devin.js +569 -0
  99. package/dist/vendor/codeburn/src/providers/droid.js +324 -0
  100. package/dist/vendor/codeburn/src/providers/dsh.js +690 -0
  101. package/dist/vendor/codeburn/src/providers/forge.js +245 -0
  102. package/dist/vendor/codeburn/src/providers/gemini.js +230 -0
  103. package/dist/vendor/codeburn/src/providers/goose.js +252 -0
  104. package/dist/vendor/codeburn/src/providers/grok.js +581 -0
  105. package/dist/vendor/codeburn/src/providers/grokbot.js +290 -0
  106. package/dist/vendor/codeburn/src/providers/hermes.js +771 -0
  107. package/dist/vendor/codeburn/src/providers/ibm-bob.js +53 -0
  108. package/dist/vendor/codeburn/src/providers/index.js +360 -0
  109. package/dist/vendor/codeburn/src/providers/kilo-code.js +50 -0
  110. package/dist/vendor/codeburn/src/providers/kimi.js +363 -0
  111. package/dist/vendor/codeburn/src/providers/kimicode.js +402 -0
  112. package/dist/vendor/codeburn/src/providers/kiro.js +1174 -0
  113. package/dist/vendor/codeburn/src/providers/lingtai-tui.js +372 -0
  114. package/dist/vendor/codeburn/src/providers/mistral-vibe-unified.js +236 -0
  115. package/dist/vendor/codeburn/src/providers/mistral-vibe.js +405 -0
  116. package/dist/vendor/codeburn/src/providers/mux.js +242 -0
  117. package/dist/vendor/codeburn/src/providers/open-design.js +217 -0
  118. package/dist/vendor/codeburn/src/providers/openclaude.js +309 -0
  119. package/dist/vendor/codeburn/src/providers/openclaw.js +442 -0
  120. package/dist/vendor/codeburn/src/providers/opencode-file-parser.js +131 -0
  121. package/dist/vendor/codeburn/src/providers/opencode.js +91 -0
  122. package/dist/vendor/codeburn/src/providers/pi.js +429 -0
  123. package/dist/vendor/codeburn/src/providers/quickdesk.js +491 -0
  124. package/dist/vendor/codeburn/src/providers/qwen.js +193 -0
  125. package/dist/vendor/codeburn/src/providers/session-message.js +118 -0
  126. package/dist/vendor/codeburn/src/providers/sqlite-session-parser.js +457 -0
  127. package/dist/vendor/codeburn/src/providers/types.js +5 -0
  128. package/dist/vendor/codeburn/src/providers/vercel-gateway.js +135 -0
  129. package/dist/vendor/codeburn/src/providers/vscode-cline-parser.js +212 -0
  130. package/dist/vendor/codeburn/src/providers/warp.js +575 -0
  131. package/dist/vendor/codeburn/src/providers/zcode.js +249 -0
  132. package/dist/vendor/codeburn/src/providers/zed.js +187 -0
  133. package/dist/vendor/codeburn/src/providers/zerostack.js +139 -0
  134. package/dist/vendor/codeburn/src/quota/antigravity.js +310 -0
  135. package/dist/vendor/codeburn/src/quota/claude.js +244 -0
  136. package/dist/vendor/codeburn/src/quota/cursor.js +301 -0
  137. package/dist/vendor/codeburn/src/quota/security.js +299 -0
  138. package/dist/vendor/codeburn/src/quota/types.js +1 -0
  139. package/dist/vendor/codeburn/src/scan-facts.js +99 -0
  140. package/dist/vendor/codeburn/src/session-cache.js +3040 -0
  141. package/dist/vendor/codeburn/src/session-count-label.js +14 -0
  142. package/dist/vendor/codeburn/src/session-output.js +139 -0
  143. package/dist/vendor/codeburn/src/session-population.js +30 -0
  144. package/dist/vendor/codeburn/src/sessions-report.js +1342 -0
  145. package/dist/vendor/codeburn/src/sqlite.js +528 -0
  146. package/dist/vendor/codeburn/src/sync/otlp.js +420 -0
  147. package/dist/vendor/codeburn/src/telemetry-snapshot.js +244 -0
  148. package/dist/vendor/codeburn/src/token-estimate.js +5 -0
  149. package/dist/vendor/codeburn/src/types.js +16 -0
  150. package/dist/vendor/codeburn/src/work-units.js +126 -0
  151. package/dist/vendor/codeburn/src/workflow-insights.js +228 -0
  152. package/dist/vendor/codeburn/src/wsl.js +198 -0
  153. package/dist/vendor/codeburn/src/yield.js +666 -0
  154. package/package.json +1 -1
@@ -0,0 +1,219 @@
1
+ // @ts-nocheck: codeburn type-checks this under its own tsconfig; Chompyy adds noUncheckedIndexedAccess (see UPSTREAM.md)
2
+ import { availableParallelism, totalmem } from 'os';
3
+ import { MessageChannel, Worker } from 'worker_threads';
4
+ import { loadCodexParentReplayIndex } from './codex-fork-replay.js';
5
+ import { snapshotPricingState } from './models.js';
6
+ // A worker holds one file's entries plus its serialized result, and the parent
7
+ // buffers up to `pool.size` finished results while it installs one — both are in
8
+ // this budget. A flat 256 MB was measured wrong on Codex: a 260 MB rollout peaks
9
+ // near 430 MB per worker and scales linearly with the pool. So derive it from the
10
+ // average pending file instead, floored at the small-transcript figure and capped
11
+ // at 1 GB. Going over the budget is what turns a parallel parse into a swapping one.
12
+ const MIN_PER_WORKER_RSS_BYTES = 256 * 1024 * 1024;
13
+ const MAX_PER_WORKER_RSS_BYTES = 1024 * 1024 * 1024;
14
+ const PER_WORKER_RSS_OVERHEAD_BYTES = 128 * 1024 * 1024;
15
+ const MEMORY_BUDGET_CAP_BYTES = 2 * 1024 * 1024 * 1024;
16
+ const MIN_AVAILABLE_BYTES = 4 * 1024 * 1024 * 1024;
17
+ const MIN_FILES_PER_WORKER = 50;
18
+ const MIN_BYTES_PER_WORKER = 200 * 1024 * 1024;
19
+ // Below this a parse is warm/incremental and the thread startup + result transfer
20
+ // costs more than the parallelism buys. Bytes, not file count: 250 pending files
21
+ // holding under a megabyte between them spawn threads that make the run ~5%
22
+ // SLOWER, and the file count only starts paying for itself around 400.
23
+ const MIN_PENDING_BYTES = 200 * 1024 * 1024;
24
+ // `process.availableMemory()` respects a container's cgroup / rlimit, which is the
25
+ // case this gate exists for; where it is absent it falls back to total RAM. Free
26
+ // memory is deliberately NOT used: on macOS `os.freemem()` counts free pages, not
27
+ // available memory, and reads as a few hundred MB on an idle 128 GB machine — a
28
+ // gate built on it turns the feature on and off at random.
29
+ function currentSystemCapacity() {
30
+ return {
31
+ cores: availableParallelism(),
32
+ availableBytes: typeof process.availableMemory === 'function' ? process.availableMemory() : totalmem(),
33
+ };
34
+ }
35
+ /// Decide how many parse worker threads a pending workload earns. Returning 0
36
+ /// means "parse serially" — the only behaviour before this existed, and still
37
+ /// the behaviour for every warm run, every small corpus, and every low-spec box.
38
+ export function decideParseWorkers(pending, sys = currentSystemCapacity(), env = process.env) {
39
+ // Every reason carries the full decision input, so a support log line explains
40
+ // itself without a second run.
41
+ const inputs = `${sys.cores} cores, ${Math.round(sys.availableBytes / 1e9 * 10) / 10} GB available, ${pending.files} pending files / ${Math.round(pending.bytes / 1e6)} MB`;
42
+ const override = env['CODEBURN_PARSE_WORKERS'];
43
+ if (override !== undefined && override !== '') {
44
+ const n = Number(override);
45
+ if (!Number.isFinite(n) || n < 0)
46
+ return { workers: 0, reason: `invalid CODEBURN_PARSE_WORKERS=${override}` };
47
+ const capped = Math.min(Math.floor(n), sys.cores);
48
+ return { workers: capped, reason: `${capped === 0 ? 'forced serial' : 'forced'} by CODEBURN_PARSE_WORKERS=${override}; ${inputs}` };
49
+ }
50
+ // Workload gates first, so a warm run's log line says "warm", not whatever the
51
+ // machine happened to look like at that moment.
52
+ if (pending.bytes < MIN_PENDING_BYTES)
53
+ return { workers: 0, reason: `below ${Math.round(MIN_PENDING_BYTES / 1e6)} MB pending; ${inputs}` };
54
+ if (sys.cores <= 2)
55
+ return { workers: 0, reason: `too few cores; ${inputs}` };
56
+ if (sys.availableBytes < MIN_AVAILABLE_BYTES)
57
+ return { workers: 0, reason: `below ${Math.round(MIN_AVAILABLE_BYTES / 1e9)} GB available memory; ${inputs}` };
58
+ const memoryBudget = Math.min(0.25 * sys.availableBytes, MEMORY_BUDGET_CAP_BYTES);
59
+ const perWorker = Math.min(MAX_PER_WORKER_RSS_BYTES, Math.max(MIN_PER_WORKER_RSS_BYTES, 2 * (pending.bytes / Math.max(1, pending.files)) + PER_WORKER_RSS_OVERHEAD_BYTES));
60
+ // Files and bytes each earn threads on their own: a few hundred huge rollouts
61
+ // are as parallelisable as a few thousand small transcripts, and gating the
62
+ // count on files alone would hand a 6 GB / 60-file workload a single thread.
63
+ const workers = Math.min(sys.cores - 1, Math.floor(memoryBudget / perWorker), Math.max(Math.floor(pending.files / MIN_FILES_PER_WORKER), Math.floor(pending.bytes / MIN_BYTES_PER_WORKER)));
64
+ return { workers, reason: inputs };
65
+ }
66
+ // In dist the entry is the bundled sibling of this module and a worker can load
67
+ // it directly. Running from source (tsx, vitest) the entry is TypeScript, and a
68
+ // worker thread inherits none of the parent's loader hooks — so register tsx's
69
+ // inside the thread before importing. tsx is a devDependency, which is exactly
70
+ // the only situation where the entry can be a .ts file at all.
71
+ function workerBootstrap(entryUrl) {
72
+ if (!entryUrl.endsWith('.ts'))
73
+ return { source: new URL(entryUrl), eval: false };
74
+ return {
75
+ eval: true,
76
+ // Chained, not awaited: the eval scope is CommonJS, and a top-level await of
77
+ // the entry re-enters it as a require(esm) cycle.
78
+ source: `
79
+ process.noDeprecation = true
80
+ import('tsx/esm/api').then(tsx => { tsx.register(); return import(${JSON.stringify(entryUrl)}) })
81
+ `,
82
+ };
83
+ }
84
+ function workerEntryUrl() {
85
+ const ext = import.meta.url.endsWith('.ts') ? '.ts' : '.js';
86
+ return new URL(`./parse-worker${ext}`, import.meta.url).href;
87
+ }
88
+ function serveParentReplay(port) {
89
+ port.on('message', ({ id, args }) => {
90
+ loadCodexParentReplayIndex(...args).then(index => port.postMessage({ id, index }), (err) => port.postMessage({ id, error: err instanceof Error ? err.message : String(err) }));
91
+ });
92
+ port.unref();
93
+ }
94
+ export class ParseWorkerPool {
95
+ workers = [];
96
+ idle = [];
97
+ inflight = new Map();
98
+ queue = [];
99
+ replayPorts = [];
100
+ closed = false;
101
+ constructor(size) {
102
+ const boot = workerBootstrap(workerEntryUrl());
103
+ const workerData = { pricing: snapshotPricingState() };
104
+ try {
105
+ for (let i = 0; i < size; i++) {
106
+ const { port1, port2 } = new MessageChannel();
107
+ serveParentReplay(port1);
108
+ this.replayPorts.push(port1);
109
+ const worker = new Worker(boot.source, { eval: boot.eval, workerData: { ...workerData, replayPort: port2 }, transferList: [port2] });
110
+ worker.on('message', (msg) => this.settle(worker, msg));
111
+ worker.on('error', (err) => this.settle(worker, { error: err.message }, true));
112
+ worker.on('exit', () => this.drop(worker));
113
+ this.workers.push(worker);
114
+ this.idle.push(worker);
115
+ }
116
+ }
117
+ catch (err) {
118
+ for (const w of this.workers)
119
+ void w.terminate();
120
+ for (const p of this.replayPorts)
121
+ p.close();
122
+ this.workers.length = 0;
123
+ this.idle.length = 0;
124
+ throw err;
125
+ }
126
+ }
127
+ get size() {
128
+ return this.workers.length;
129
+ }
130
+ /// Parse one file off-thread. Never rejects: a worker-side failure (or a dead
131
+ /// pool) comes back as `ok: false` so the caller can fall back to an in-process
132
+ /// parse and never lose a file to a crashed thread.
133
+ submit(job) {
134
+ return new Promise((resolve) => {
135
+ if (this.closed || this.workers.length === 0) {
136
+ resolve({ ok: false, error: 'parse worker pool unavailable' });
137
+ return;
138
+ }
139
+ this.queue.push({ job, resolve: resolve });
140
+ this.pump();
141
+ });
142
+ }
143
+ async close() {
144
+ this.closed = true;
145
+ const pending = [...this.queue];
146
+ this.queue.length = 0;
147
+ for (const task of pending)
148
+ task.resolve({ ok: false, error: 'parse worker pool closed' });
149
+ await Promise.all(this.workers.map(w => w.terminate()));
150
+ for (const p of this.replayPorts)
151
+ p.close();
152
+ this.workers.length = 0;
153
+ this.idle.length = 0;
154
+ this.inflight.clear();
155
+ }
156
+ pump() {
157
+ while (this.queue.length > 0 && this.idle.length > 0) {
158
+ const worker = this.idle.pop();
159
+ const task = this.queue.shift();
160
+ this.inflight.set(worker, task);
161
+ worker.postMessage(task.job);
162
+ }
163
+ }
164
+ settle(worker, msg, fatal = false) {
165
+ const task = this.inflight.get(worker);
166
+ this.inflight.delete(worker);
167
+ if (task) {
168
+ if (msg.error !== undefined)
169
+ task.resolve({ ok: false, error: msg.error });
170
+ else
171
+ task.resolve({ ok: true, parsed: msg.json == null ? null : JSON.parse(msg.json) });
172
+ }
173
+ if (fatal)
174
+ return;
175
+ if (!this.closed) {
176
+ this.idle.push(worker);
177
+ this.pump();
178
+ }
179
+ }
180
+ // A thread that died takes its queue slot with it; the remaining files are
181
+ // handed back for a serial parse rather than being lost.
182
+ drop(worker) {
183
+ const i = this.workers.indexOf(worker);
184
+ if (i >= 0)
185
+ this.workers.splice(i, 1);
186
+ const j = this.idle.indexOf(worker);
187
+ if (j >= 0)
188
+ this.idle.splice(j, 1);
189
+ const task = this.inflight.get(worker);
190
+ if (task) {
191
+ this.inflight.delete(worker);
192
+ task.resolve({ ok: false, error: 'parse worker exited' });
193
+ }
194
+ if (this.workers.length === 0) {
195
+ const pending = [...this.queue];
196
+ this.queue.length = 0;
197
+ for (const t of pending)
198
+ t.resolve({ ok: false, error: 'all parse workers exited' });
199
+ }
200
+ }
201
+ }
202
+ /// Yield results for `jobs` in the SAME order they were given, no matter which
203
+ /// worker finishes first. Keeps exactly `pool.size` files in flight, so at most
204
+ /// that many parsed results are buffered while the caller installs one.
205
+ export async function* parseFilesInOrder(pool, jobs) {
206
+ const inflight = [];
207
+ let next = 0;
208
+ const fill = () => {
209
+ while (inflight.length < Math.max(1, pool.size) && next < jobs.length) {
210
+ inflight.push(pool.submit(jobs[next++]));
211
+ }
212
+ };
213
+ fill();
214
+ for (let i = 0; i < jobs.length; i++) {
215
+ const result = await inflight.shift();
216
+ fill();
217
+ yield result;
218
+ }
219
+ }