chompyy 0.7.0 → 0.7.1

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.
@@ -57,3 +57,31 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
57
57
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
58
58
  SOFTWARE.
59
59
  ```
60
+
61
+ `cli/src/stuck.ts`: the error kinds are adapted from `ERROR_PATTERNS` in [sniffly](https://github.com/chiphuyen/sniffly) (`sniffly/core/constants.py`, MIT, Copyright (c) 2025 Chip Huyen), regrouped and reworded.
62
+
63
+ Its licence, in full:
64
+
65
+ ```
66
+ MIT License
67
+
68
+ Copyright (c) 2025 Chip Huyen
69
+
70
+ Permission is hereby granted, free of charge, to any person obtaining a copy
71
+ of this software and associated documentation files (the "Software"), to deal
72
+ in the Software without restriction, including without limitation the rights
73
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
74
+ copies of the Software, and to permit persons to whom the Software is
75
+ furnished to do so, subject to the following conditions:
76
+
77
+ The above copyright notice and this permission notice shall be included in all
78
+ copies or substantial portions of the Software.
79
+
80
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
81
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
82
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
83
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
84
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
85
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
86
+ SOFTWARE.
87
+ ```
package/dist/cli.js CHANGED
@@ -4,7 +4,7 @@ import { execFileSync, spawn } from 'node:child_process';
4
4
  import { backfillTokens, median } from './tokenstore.js';
5
5
  import { compact, formatTokens, totalTokens } from './tokens.js';
6
6
  import { closeSync, existsSync, openSync, readFileSync, writeFileSync } from 'node:fs';
7
- import { resolve } from 'node:path';
7
+ import { join, resolve } from 'node:path';
8
8
  import { parseArgs } from 'node:util';
9
9
  import { away, runCard } from './away.js';
10
10
  import { formatPreflight, loadProfile, preflight, saveProfile } from './preflight.js';
@@ -39,7 +39,7 @@ import { approvalsPrompt, approvalStats, approvalsText, decisions, featureStats,
39
39
  import { allWindowEnds, archiveWindowEnds, premise, premiseText } from './premise.js';
40
40
  import { keychainAllowed, loadLiveState, refreshLiveQuota } from './livequota.js';
41
41
  import { recentProjects } from './projects.js';
42
- import { cliVersion, installApp } from './macapp.js';
42
+ import { cliVersion, installApp, installedVersion, isNewer } from './macapp.js';
43
43
  import { buildDigest, historyRetention, scanHistory } from './history.js';
44
44
  import { acceptColdStart, forgetColdStart, formatColdStart, loadColdStart, runColdStart } from './coldstart.js';
45
45
  import { keepHistory } from './claudesettings.js';
@@ -810,9 +810,14 @@ async function main(argv) {
810
810
  return console.log(formatLive(loadLive()));
811
811
  }
812
812
  case 'app': {
813
- console.log(`Downloading Chompyy ${cliVersion()} for Mac…`);
814
- const at = await installApp();
815
- console.log(`Installed ${at} and opened it. Look for the cookie in your menu bar.`);
813
+ const have = installedVersion(join(homedir(), 'Applications'));
814
+ if (!have || !isNewer(have, cliVersion()))
815
+ console.log(`Downloading Chompyy ${cliVersion()} for Mac…`);
816
+ const r = await installApp();
817
+ if (r.kept)
818
+ console.log(`Opened Chompyy ${r.kept}. Kept it: this chompyy command is older (${cliVersion()}).\nUpdate the command: npm install -g chompyy@latest`);
819
+ else
820
+ console.log(`Installed ${r.at} and opened it. Look for the cookie in your menu bar.`);
816
821
  return;
817
822
  }
818
823
  case 'history': {
package/dist/detect.js CHANGED
@@ -8,6 +8,7 @@ import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
8
8
  import { homedir } from 'node:os';
9
9
  import { basename, dirname, join } from 'node:path';
10
10
  import { projectsDir } from './dream.js';
11
+ import { errorKind, ruleStuck } from './stuck.js';
11
12
  /**
12
13
  * Folders under ~/.claude/projects made by automated runs in temp folders (benchmarks, sandboxes, Chompyy's own
13
14
  * cards): not your sessions, so they don't count for or against you.
@@ -21,11 +22,15 @@ export function readSession(file) {
21
22
  const skills = new Map();
22
23
  const commands = new Map();
23
24
  const mcp = new Map();
25
+ const errors = new Map();
26
+ let failed = 0;
27
+ let interrupts = 0;
24
28
  // What changed since the last request: read back when the next request says the tool list changed.
25
29
  let loaded = [];
26
30
  let after = '';
27
31
  for (const line of readFileSync(file, 'utf8').split('\n')) {
28
- if (!line.includes('"assistant"') && !line.includes('<command-name>') && !line.includes('deferred_tools_record'))
32
+ const stuckLine = line.includes('"is_error":true') || line.includes('[Request interrupted');
33
+ if (!stuckLine && !line.includes('"assistant"') && !line.includes('<command-name>') && !line.includes('deferred_tools_record'))
29
34
  continue;
30
35
  let e;
31
36
  try {
@@ -54,6 +59,21 @@ export function readSession(file) {
54
59
  after = `/${m[1]}`;
55
60
  }
56
61
  }
62
+ if (stuckLine && e.type === 'user' && !e.isSidechain) {
63
+ const blocks = typeof content === 'string' ? [{ type: 'text', text: content }] : Array.isArray(content) ? content : [];
64
+ for (const b of blocks) {
65
+ if (b?.type === 'text' && typeof b.text === 'string' && b.text.startsWith('[Request interrupted'))
66
+ interrupts += 1;
67
+ if (b?.type !== 'tool_result' || b.is_error !== true)
68
+ continue;
69
+ failed += 1;
70
+ const text = typeof b.content === 'string' ? b.content : Array.isArray(b.content) ? b.content.map((x) => (typeof x?.text === 'string' ? x.text : '')).join(' ') : '';
71
+ const kind = errorKind(text.slice(0, 2000));
72
+ if (kind)
73
+ errors.set(kind, (errors.get(kind) ?? 0) + 1);
74
+ }
75
+ continue;
76
+ }
57
77
  if (e.type !== 'assistant' || !msg?.usage || e.isSidechain)
58
78
  continue;
59
79
  if (Array.isArray(content)) {
@@ -102,7 +122,7 @@ export function readSession(file) {
102
122
  cwd,
103
123
  turns: [...turns.values()].filter((t) => t.at).sort((a, b) => a.at - b.at),
104
124
  };
105
- return Object.assign(session, { skills, commands, mcp });
125
+ return Object.assign(session, { skills, commands, mcp, errors, failed, interrupts });
106
126
  }
107
127
  const sessionMemo = new Map();
108
128
  /** Your sessions from the last `days` days (by file time), automated runs left out. */
@@ -110,7 +130,7 @@ export function scan(opts = {}) {
110
130
  const now = (opts.now ?? new Date()).getTime();
111
131
  const since = now - (opts.days ?? 30) * 86_400_000;
112
132
  const root = opts.root ?? projectsDir();
113
- const out = { sessions: [], skills: new Map(), commands: new Map(), mcp: new Map(), firstAt: Infinity, lastAt: 0 };
133
+ const out = { sessions: [], skills: new Map(), commands: new Map(), mcp: new Map(), firstAt: Infinity, lastAt: 0, errors: new Map(), failed: 0, interrupts: 0 };
114
134
  if (!existsSync(root))
115
135
  return { ...out, firstAt: 0 };
116
136
  for (const folder of readdirSync(root)) {
@@ -151,6 +171,10 @@ export function scan(opts = {}) {
151
171
  out.skills.set(k, (out.skills.get(k) ?? 0) + v);
152
172
  for (const [k, v] of s.commands)
153
173
  out.commands.set(k, (out.commands.get(k) ?? 0) + v);
174
+ for (const [k, v] of s.errors)
175
+ out.errors.set(k, (out.errors.get(k) ?? 0) + v);
176
+ out.failed += s.failed;
177
+ out.interrupts += s.interrupts;
154
178
  for (const [k, v] of s.mcp) {
155
179
  const m = out.mcp.get(k) ?? { calls: 0, projects: new Set() };
156
180
  m.calls += v;
@@ -514,6 +538,7 @@ export function detect(opts = {}) {
514
538
  ...ruleS2(s, opts.claudeDir),
515
539
  ...ruleS4(s, servers),
516
540
  ...ruleS5(opts.root),
541
+ ...ruleStuck(s),
517
542
  ];
518
543
  // Baselines for the checks advice cards register before a fix: what a session start costs, and last week's cold returns.
519
544
  const starts = s.sessions.map((x) => x.turns[0]).map((t) => t.cacheRead + t.cacheWrite).filter((n) => n > 0);
package/dist/macapp.js CHANGED
@@ -32,11 +32,42 @@ const defaultDeps = () => ({
32
32
  platform: process.platform,
33
33
  appsDir: join(homedir(), 'Applications'),
34
34
  });
35
- /** Install (or update) Chompyy.app. Returns where it went. */
35
+ /** The version in an installed Chompyy.app's Info.plist, or null when there's no app or no readable version. */
36
+ export function installedVersion(appsDir) {
37
+ try {
38
+ const plist = readFileSync(join(appsDir, 'Chompyy.app', 'Contents', 'Info.plist'), 'utf8');
39
+ return plist.match(/<key>CFBundleShortVersionString<\/key>\s*<string>([^<]+)<\/string>/)?.[1]?.trim() ?? null;
40
+ }
41
+ catch {
42
+ return null;
43
+ }
44
+ }
45
+ /** True when version `a` is newer than `b` (plain x.y.z; a missing part counts as 0). */
46
+ export function isNewer(a, b) {
47
+ const pa = a.split('.').map((n) => parseInt(n, 10) || 0);
48
+ const pb = b.split('.').map((n) => parseInt(n, 10) || 0);
49
+ for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
50
+ const d = (pa[i] ?? 0) - (pb[i] ?? 0);
51
+ if (d)
52
+ return d > 0;
53
+ }
54
+ return false;
55
+ }
56
+ /**
57
+ * Install (or update) Chompyy.app. Returns where it is, and `kept` when a newer app was already there:
58
+ * an old `chompyy` command once replaced a 0.7.0 app with 0.5.0, so a newer app is opened as it is, never downgraded.
59
+ */
36
60
  export async function installApp(opts = {}, deps = defaultDeps()) {
37
61
  if (deps.platform !== 'darwin')
38
62
  throw new Error('The Chompyy app is macOS only for now. The CLI works everywhere: `chompyy help`.');
39
63
  const version = opts.version ?? cliVersion();
64
+ const have = installedVersion(deps.appsDir);
65
+ if (have && isNewer(have, version)) {
66
+ const at = join(deps.appsDir, 'Chompyy.app');
67
+ if (opts.open !== false)
68
+ deps.exec('open', [at]);
69
+ return { at, kept: have };
70
+ }
40
71
  const url = appZipUrl(version);
41
72
  const res = await deps.fetch(url);
42
73
  if (!res.ok)
@@ -73,7 +104,7 @@ export async function installApp(opts = {}, deps = defaultDeps()) {
73
104
  renameSync(unpacked, target);
74
105
  if (opts.open !== false)
75
106
  deps.exec('open', [target]);
76
- return target;
107
+ return { at: target };
77
108
  }
78
109
  finally {
79
110
  rmSync(tmp, { recursive: true, force: true });
package/dist/stuck.js ADDED
@@ -0,0 +1,36 @@
1
+ export const KINDS = [
2
+ { id: 'rejected', label: 'actions you turned down', re: /user doesn't want to (proceed|take this action)|\[Request interrupted/i, fix: 'Say what you want up front, or put the rule in CLAUDE.md: you turned these down after Claude started them.' },
3
+ { id: 'not-read', label: 'writes before reading the file', re: /File has not been read yet/i, fix: 'Ask Claude to read a file before it edits it.' },
4
+ { id: 'stale', label: 'edits on stale text', re: /File has been modified since read|String to replace not found|String not found in file|replace_all is false/i, fix: 'Have Claude read the file again before editing: the text it tried to replace had changed or appears twice.' },
5
+ { id: 'path', label: 'wrong paths', re: /No such file or directory|File does not exist|ENOENT|No module named|Cannot find module/i, fix: 'Have Claude list the folder before opening files, or add the project layout to CLAUDE.md.' },
6
+ { id: 'blocked', label: 'blocked by permissions', re: /Permission denied|was blocked|Operation not permitted|not allowed/i, fix: 'Allow the commands you trust with /permissions, or tell Claude in CLAUDE.md what it may not run.' },
7
+ { id: 'missing-tool', label: 'commands not installed', re: /command not found/i, fix: 'Install the missing command, or tell Claude in CLAUDE.md what to use instead.' },
8
+ { id: 'timeout', label: 'timeouts', re: /timed out/i, fix: 'Ask Claude to run long commands in the background.' },
9
+ { id: 'input', label: 'malformed tool calls', re: /InputValidationError|SyntaxError|syntax error|jq: error/i, fix: 'Mostly the model\'s slip: nothing to change unless one tool keeps failing.' },
10
+ ];
11
+ /** The kind of one failed tool call's text; null when no pattern names it (a plain non-zero exit, say). */
12
+ export function errorKind(text) {
13
+ return KINDS.find((k) => k.re.test(text))?.id ?? null;
14
+ }
15
+ /** Fewer named failures than this in the scan: not a pattern worth a line. */
16
+ export const MIN_ERRORS = 10;
17
+ /** L2 · Where Claude gets stuck. Counts, not tokens: L1 already prices recovering from failures. */
18
+ export function ruleStuck(s) {
19
+ const ranked = [...(s.errors ?? new Map())].filter(([id]) => id !== 'rejected').sort((a, b) => b[1] - a[1]);
20
+ const named = ranked.reduce((a, [, n]) => a + n, 0);
21
+ if (named < MIN_ERRORS)
22
+ return [];
23
+ const top = ranked.slice(0, 3).map(([id, n]) => `${n} ${KINDS.find((k) => k.id === id).label}`);
24
+ const turnedDown = s.errors?.get('rejected') ?? 0;
25
+ const stopped = (s.interrupts ?? 0) + turnedDown;
26
+ const fix = KINDS.find((k) => k.id === ranked[0][0]).fix;
27
+ return [{
28
+ rule: 'L2',
29
+ title: 'Where Claude gets stuck',
30
+ say: `${s.failed ?? named} failed tool calls. Most named: ${top.join(', ')}.${stopped ? ` You stopped or turned down Claude ${stopped} times.` : ''}`,
31
+ basis: 'measured',
32
+ notProve: 'Counts what failed, not what it cost; some failures are quick tries.',
33
+ fix,
34
+ lane: 'habit',
35
+ }];
36
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chompyy",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Chompyy: runs the tasks you approve with the Claude Code 5-hour window you'd otherwise lose, then lets you review, keep and send them to GitHub. CLI behind the Chompyy Mac menu bar app.",
5
5
  "keywords": [
6
6
  "claude-code",