fix(story-mode): the badge counts the card it sits on, opinions mid-step, a deviation is a note (review round 10)

From the fact-checker:
- "+37" sat on mathx.py's card, which has 11 of those lines; with
  several files the badge now counts the card in front (the Director's
  cut keeps every file's count).
- A second opinion asked in the middle of a step's calls read "after
  asking"; it now reads "along the way, asks a stronger AI model…".
- "Two places where I didn't follow your wording exactly" under
  "Mission complete!": not following your words is a note ("Done, with a
  note"), and the sentence counts as a word on what you asked.
- A test run that patched a file written a panel before said "Claude
  writes" it: whole files are written, patched ones changed ("Claude
  writes pyproject.toml and changes test_csvstat.py; …").

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer committed 2026-10-18 17:22:11 +02:00
1 parent 713978eb81
commit 175017f604
8 files changed
+100 -22

No files matched your search

+29 -9
View File
@@ -314,7 +314,7 @@ const KEY_KINDS: Array<[StoryKeyKind, RegExp]> = [
['failed', /(?<!\b(a|the|any|on) )(?<!\d )\b(failed|fails)\b/i],
[
'asked',
/\b(as you (asked|expected|said|wanted|suggested)|you asked|your (--?[\w-]+|request|option|flag|change))\b/i,
/\b(as you (asked|expected|said|wanted|suggested)|you asked|your (--?[\w-]+|request|option|flag|change)|(didn't|did not|couldn't|could not) (follow|use|do) (your|exactly what you))\b/i,
],
// A warning or report that turned out wrong: what resolves a worry an earlier panel raised.
[
@@ -2121,12 +2121,16 @@ const REPORT_TALK: Partial<Record<StoryPanelKind, RegExp>> = {
const ANNOUNCES = /\b(I'll|I will|let me|let's|I'm going to|next,? I|now I)\b/i;
/** What Claude's last words leave open: a catch (a problem), a note (something pending), a question. */
/** Claude did something differently from what you asked: worth a note on the final panel. */
const DEVIATED =
/\b(didn't|did not|couldn't|could not) (follow|use|do) (your|exactly what you)|\bnot exactly as you\b/i;
function closingKinds(points: string[] = []): { openNote?: 'catch' | 'note'; asks?: boolean } {
const kinds = new Set(points.map(keyKindOf));
return {
...(kinds.has('problem')
? { openNote: 'catch' as const }
: kinds.has('pending')
: kinds.has('pending') || points.some((p) => DEVIATED.test(p))
? { openNote: 'note' as const }
: {}),
...(points.some((p) => keyKindOf(p) === 'offer' && ASKS_YOU.test(p)) ? { asks: true } : {}),
@@ -2573,7 +2577,8 @@ function decorate(draft: DraftPanel, events: StoryEvent[], turn: StoryTurn, inde
if (draft.kind === 'fix') {
const created = unique(edits.filter((e) => e.created).map((e) => e.file)).length;
const whole =
edits.length > 0 && edits.every((d) => d.created || d.hunks.every((h) => !h.oldStart && !h.oldLines));
edits.length > 0 &&
edits.every((d) => d.created || (d.hunks.length > 0 && d.hunks.every((h) => !h.oldStart && !h.oldLines)));
story =
created && created === files.length
? files.length <= 2
@@ -2708,7 +2713,16 @@ function decorate(draft: DraftPanel, events: StoryEvent[], turn: StoryTurn, inde
`The $1 $2$3 in a fresh copy made from ${basename(cloned.replace(/\/+$/, ''))}`
);
const written = unique(edits.map((d) => d.file));
if (written.length) story = `Claude writes ${fileWords(written)}; ${story[0].toLowerCase()}${story.slice(1)}`;
// Whole files are written; a file it patched is changed (a later panel often patches one written earlier).
const isWhole = (d: StoryEdit) =>
d.created || (d.hunks.length > 0 && d.hunks.every((h) => !h.oldStart && !h.oldLines));
const wholeFiles = written.filter((f) => edits.filter((d) => d.file === f).every(isWhole));
const patched = written.filter((f) => !wholeFiles.includes(f));
const did = [
wholeFiles.length ? `writes ${fileWords(wholeFiles)}` : '',
patched.length ? `changes ${fileWords(patched)}` : '',
].filter(Boolean);
if (did.length) story = `Claude ${did.join(' and ')}; ${story[0].toLowerCase()}${story.slice(1)}`;
const saved = checks.reduce((n, e) => n + (e.commits ?? 0), 0);
if (saved) {
director += ` · ${plural(saved, 'commit')}`;
@@ -2875,11 +2889,17 @@ function decorate(draft: DraftPanel, events: StoryEvent[], turn: StoryTurn, inde
break;
}
if (panel.secondOpinion) {
// Asked before the step, or (nothing following) after the last one.
const lastWork = Math.max(...draft.events.filter((i) => events[i].tool !== 'Advisor'));
const trailing = draft.events.some((i) => events[i].tool === 'Advisor' && i > lastWork);
const unanswered = draft.events.every((i) => events[i].tool !== 'Advisor' || events[i].ok === false);
director += ` · ${trailing ? 'then' : 'after'} ${plural(panel.secondOpinion, 'second opinion')}${unanswered ? ' (no answer)' : ''}`;
// Asked before the step, after it (nothing following), or in the middle of a step's calls.
const work = draft.events.filter((i) => events[i].tool !== 'Advisor');
const asked = draft.events.filter((i) => events[i].tool === 'Advisor');
const when = asked.every((i) => i < Math.min(...work))
? 'after'
: asked.every((i) => i > Math.max(...work))
? 'then'
: 'during';
const unanswered = asked.every((i) => events[i].ok === false);
const count = plural(panel.secondOpinion, 'second opinion');
director += ` · ${when === 'during' ? `${count} along the way` : `${when} ${count}`}${unanswered ? ' (no answer)' : ''}`;
}
panel.caption = { story, director };
return panel;
+20 -8
View File
@@ -1060,10 +1060,15 @@ const StoryArt = (() => {
const hp = [tip[0] + 20 + Math.sin(f / 2.6) * 3, tip[1] - 28 + Math.cos(f / 3.1) * 2.5];
const a = agent(ctx, ax, 248, { frame: f, mood: 'focus', l: [hp[0] - ax, hp[1] - 248], r: [30, -42] });
pencil(ctx, a.l, [tip[0] + Math.sin(f / 2.6) * 3, tip[1] + Math.cos(f / 3.1) * 2.5]);
if (p.panel.added)
// With several files the badge counts the card in front: a total beside one file's card read as
// that file's own. The Director's cut has every file's count.
const front = files.length > 1 && first ? edits.filter((d) => d.file === first.file) : null;
const added = front ? front.reduce((n, d) => n + d.added, 0) : p.panel.added;
const removed = front ? front.reduce((n, d) => n + d.removed, 0) : p.panel.removed;
if (added)
sfx(
ctx,
`+${p.panel.added}`,
`+${added}`,
x0 + pw * 0.32,
y0 + ph + 2,
26,
@@ -1071,10 +1076,10 @@ const StoryArt = (() => {
-0.18,
spring(f - 44, { damping: 9, stiffness: 170 })
);
if (p.panel.removed)
if (removed)
sfx(
ctx,
`−${p.panel.removed}`,
`−${removed}`,
x0 + pw * 0.74,
y0 + ph + 6,
24,
@@ -2494,15 +2499,22 @@ Object.assign(CodemanApp.prototype, {
// Asked before this step, or after it when nothing followed.
const work = p.events.filter((i) => page.events[i]?.tool !== 'Advisor');
const asked = p.events.filter((i) => page.events[i]?.tool === 'Advisor');
const trailing = asked.some((i) => i > Math.max(...work));
// Before the step's calls, after them, or in the middle of them.
const before = asked.every((i) => i < Math.min(...work));
const trailing = !before && asked.every((i) => i > Math.max(...work));
// A call that came back with an error brought no opinion: say so, never that one was given.
const unanswered = asked.length > 0 && asked.every((i) => page.events[i].ok === false);
const ask = unanswered ? 'tries to ask' : 'asks';
rt.capNote.hidden = !p.secondOpinion;
rt.capNote.textContent = !p.secondOpinion
? ''
: unanswered
? `${trailing ? 'then tries to ask' : 'after trying to ask'} a stronger AI model for a second opinion (no answer came)`
: `${trailing ? 'then asks' : 'after asking'} a stronger AI model for a second opinion`;
: `${
before
? `after ${unanswered ? 'trying to ask' : 'asking'}`
: trailing
? `then ${ask}`
: `along the way, ${ask}`
} a stronger AI model for a second opinion${unanswered ? ' (no answer came)' : ''}`;
}
rt.el.classList.toggle('is-live', !!p.live);
// Named by its place only: the caption inside is read as the panel's content, once.