chompyy 0.4.2 → 0.4.3

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/dist/cli.js CHANGED
@@ -40,7 +40,7 @@ import { formatTrace, traceSession } from './trace.js';
40
40
  import { homedir } from 'node:os';
41
41
  import { clashOf, refreshCard, refreshGate, refreshClashing, withRefreshLock } from './refresh.js';
42
42
  import { adviseText, applyDue, approveAdvice, runAdvise, undoAdvice } from './advice.js';
43
- import { checkWorked, nudgeProof, nudgeProofText, workedText } from './didwork.js';
43
+ import { checkWorked, nudgeProof, nudgeProofText, shareText, workedText } from './didwork.js';
44
44
  import { coldWarningText, hookCommand, impact, loadNudges, nudgeInstalled, nudgeText, runHook, setNudge, setProjectMode, takeGoingCold } from './nudge.js';
45
45
  import { formatLive, keepAffectsLive, liveOff, liveSet, liveUpdateLocked, loadLive, startLiveUpdate } from './live.js';
46
46
  import { agentInstalled, awayRunning, bedtimeKey, decideTrigger, installAgent, loadTriggerState, markFired, noteTick, parseClock, takeAwayLock, uninstallAgent } from './triggers.js';
@@ -56,6 +56,7 @@ Quota
56
56
  applied (backed up, undoable) once no Claude Code session is active; habits are tracked
57
57
  chompyy advise apply apply approved settings advice now, if no session has been active for 10 minutes
58
58
  chompyy worked [--json] did it work? measure each approved advice card against the check on its card
59
+ chompyy worked --share the same as a summary to paste (no project, skill or file names)
59
60
  chompyy nudge on|off live suggestions while you work: stops the first message to a big conversation
60
61
  whose cache expired, with the price and the cheaper ways (Claude Code hook)
61
62
  chompyy nudge strict|quiet|learn [dir] in this project: always stop me, only a heads-up, or learn (default:
@@ -469,6 +470,7 @@ async function main(argv) {
469
470
  'dry-run': { type: 'boolean' },
470
471
  force: { type: 'boolean' },
471
472
  all: { type: 'boolean' },
473
+ share: { type: 'boolean' },
472
474
  quiet: { type: 'boolean' },
473
475
  model: { type: 'string' },
474
476
  column: { type: 'string', multiple: true },
@@ -1162,6 +1164,13 @@ async function main(argv) {
1162
1164
  // The detective, step 5: each applied/tried advice card against the check it registered (didwork.ts).
1163
1165
  const cards = updateBoard((b) => checkWorked(b, now));
1164
1166
  const proof = nudgeInstalled() || loadNudges().length ? nudgeProof(now) : null;
1167
+ if (values.share) {
1168
+ // A summary to paste on the tester issue: counts, tokens and dates; no project, skill or file names.
1169
+ const text = shareText(cards, proof, { version: cliVersion(), now });
1170
+ if (!process.stdout.isTTY)
1171
+ return console.log(text);
1172
+ return console.log(`${text}\n\nNo project, skill or file names in it. Copy it: chompyy worked --share | pbcopy`);
1173
+ }
1165
1174
  if (values.json)
1166
1175
  return json({ cards: cards.map((c) => ({ id: c.id, title: c.title, rule: c.advice.rule, lane: c.advice.lane, ...c.advice.result })), nudge: proof });
1167
1176
  if (!cards.length && proof)
@@ -1196,8 +1205,12 @@ async function main(argv) {
1196
1205
  return json(due);
1197
1206
  return console.log(due.length ? due.map((d) => `${d.title}\n ${d.body}`).join('\n') : 'Nothing about to go cold.');
1198
1207
  }
1199
- if (values.json)
1200
- return json(impact());
1208
+ if (values.json) {
1209
+ // The menu panel: the trend line, plus did the nudge work (its verdict, from the day it was turned on).
1210
+ const i = impact();
1211
+ const p = i.on ? nudgeProof(now) : null;
1212
+ return json({ ...i, ...(p ? { verdict: { verdict: p.result.verdict, line: p.result.line, dueAt: p.result.dueAt } } : {}) });
1213
+ }
1201
1214
  return console.log([nudgeText(nudgeInstalled()), impact().line].join('\n'));
1202
1215
  }
1203
1216
  case 'premise': {
package/dist/didwork.js CHANGED
@@ -60,7 +60,7 @@ export function checkC1(since, now, s) {
60
60
  verdict: 'too-early',
61
61
  before: before.length,
62
62
  after: so.length,
63
- line: `${plural(so.length, 'cold return')} so far (was ${before.length} a week). Verdict ${day(due)}.`,
63
+ line: `${plural(so.length, 'cold return')} since ${day(since)} (was ${before.length} a week). Verdict ${day(due)}.`,
64
64
  };
65
65
  }
66
66
  const week = coldReturns(s, since + 7 * DAY).filter((x) => x.at < due);
@@ -296,8 +296,31 @@ export function checkWorked(board, now, opts = {}) {
296
296
  else if (a.rule === 'S4' || a.rule === 'S5')
297
297
  a.result = checkRuleAgain(a, t, s ?? scan({ now, root }), root);
298
298
  }
299
+ reopenUndone(cards, now);
299
300
  return cards;
300
301
  }
302
+ /** Give claude.ai settings a day to sync before calling a "done" card not done. */
303
+ export const REOPEN_AFTER_MS = DAY;
304
+ /**
305
+ * A card you marked done whose re-count shows nothing changed comes back to suggested, with what's still there,
306
+ * instead of sitting in Done as if it worked. Only "yours to do" cards: settings changes are Chompyy's own.
307
+ */
308
+ export function reopenUndone(cards, now) {
309
+ const back = [];
310
+ for (const c of cards) {
311
+ const a = c.advice;
312
+ if (a.lane !== 'manual' || a.state !== 'done' || a.result?.verdict !== 'no-change')
313
+ continue;
314
+ if (now.getTime() - startOf(c) < REOPEN_AFTER_MS)
315
+ continue;
316
+ c.column = 'suggested';
317
+ delete a.state;
318
+ a.note = `Back from Done: ${a.result.line.replace(/^Not yet: /, '')} Do it, then press "I've done it" again.`;
319
+ c.updatedAt = now.toISOString();
320
+ back.push(c);
321
+ }
322
+ return back;
323
+ }
301
324
  export function nudgeProof(now, opts = {}) {
302
325
  const events = opts.events ?? loadNudges();
303
326
  const since = nudgeOnSince(events);
@@ -365,3 +388,67 @@ export function workedText(cards) {
365
388
  }
366
389
  return lines.join('\n');
367
390
  }
391
+ // ---------- worked --share: a summary to paste, with no names in it ----------
392
+ /** What each fix was, in words that name no project, skill, plugin or file. */
393
+ function shareLabel(a) {
394
+ if (a.rule === 'C1')
395
+ return 'Cold returns (a habit)';
396
+ if (a.rule === 'C2')
397
+ return 'Mid-session rebuilds (a habit)';
398
+ if (a.rule === 'S3' && a.lane === 'settings')
399
+ return 'Unused plugin turned off';
400
+ if (a.key === 'S3:synced')
401
+ return 'Unused synced skills turned off';
402
+ if (a.rule === 'S3')
403
+ return 'Unused own skills archived';
404
+ if (a.rule === 'S2')
405
+ return 'Long CLAUDE.md shortened';
406
+ if (a.rule === 'S4')
407
+ return 'Unused MCP servers removed';
408
+ if (a.rule === 'S5')
409
+ return 'MEMORY.md compressed';
410
+ return 'Other fix';
411
+ }
412
+ const VERDICT_WORD = { 'too-early': 'too early', worked: 'worked', short: 'fell short', 'no-change': 'no change', worse: 'went the wrong way', 'cant-tell': "can't tell" };
413
+ /** The numbers only: before → after, the method, the verdict or the day it comes. */
414
+ function shareNumbers(a, r) {
415
+ const due = r.dueAt && r.verdict === 'too-early' ? ` · verdict ${day(Date.parse(r.dueAt))}` : '';
416
+ const how = r.method === 'recount' ? 're-counted' : 'before vs after';
417
+ if (r.before === undefined || r.after === undefined)
418
+ return `${how}${due}`;
419
+ if (r.verdict === 'cant-tell' && r.before === 0)
420
+ return 'nothing to improve (none before)';
421
+ if (a.rule === 'C1')
422
+ return r.verdict === 'too-early' ? `${r.after} since start (was ${r.before} a week)${due}` : `${r.before} → ${r.after} a week (${r.saved >= 0 ? `${k(r.saved)} fewer` : `${k(-r.saved)} more`} tokens rewritten) · ${how}`;
423
+ if (a.rule === 'C2')
424
+ return `${r.before} → ${r.after} in two weeks · ${how}${due}`;
425
+ if (a.rule === 'S3' && a.lane !== 'settings')
426
+ return `${r.before - r.after} of ${r.before} gone · ${how}`;
427
+ return `~${k(r.before)} → ~${k(r.after)} tokens per ${r.per ?? 'session start'} · ${how}`;
428
+ }
429
+ /** Markdown for an issue comment. Counts, tokens and dates only. */
430
+ export function shareText(cards, proof, meta) {
431
+ const lines = [`**chompyy worked --share** · ${meta.version} · ${meta.now.toISOString().slice(0, 10)}`, ''];
432
+ const measured = cards.filter((c) => c.advice?.result);
433
+ if (measured.length) {
434
+ lines.push('Fixes:');
435
+ for (const c of measured) {
436
+ const a = c.advice;
437
+ const r = a.result;
438
+ lines.push(`- ${ICON[r.verdict]} ${shareLabel(a)}: ${VERDICT_WORD[r.verdict]} · ${shareNumbers(a, r)}`);
439
+ }
440
+ }
441
+ else
442
+ lines.push('Fixes: none approved yet.');
443
+ if (proof) {
444
+ const r = proof.result;
445
+ const c = proof.counted;
446
+ lines.push('', `Live suggestions (on since ${day(Date.parse(proof.since))}):`);
447
+ lines.push(`- ${ICON[r.verdict]} Cold returns: ${VERDICT_WORD[r.verdict]} · ${r.before === undefined ? 'no week before to compare' : r.verdict === 'too-early' ? `${r.after} since (was ${r.before} a week) · verdict ${day(Date.parse(r.dueAt))}` : `${r.before} → ${r.after} a week`}`);
448
+ if (c.stops || c.compacted)
449
+ lines.push(`- Stops: ${c.stops} (compacted ${c.compacted}, left ${c.left}, sent anyway ${c.sent}) · ~${k(c.saved)} not rewritten${c.saved > c.measured ? ` (~${k(c.saved - c.measured)} estimated)` : ''}${c.rewritten ? ` · ${k(c.rewritten)} rewritten when sent anyway` : ''}`);
450
+ if (proof.quiet.length)
451
+ lines.push(`- Heads-up instead of a stop in ${proof.quiet.length} project${proof.quiet.length === 1 ? '' : 's'}`);
452
+ }
453
+ return lines.join('\n');
454
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chompyy",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
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",