Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/workflow-insights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ export const USER_CORRECTION_PATTERNS: RegExp[] = [
/\byou (?:missed|forgot|misunderstood|broke)\b/i,
/\brevert (?:that|it|this|your|the last|the change)\b/i,
/\bundo (?:that|it|this|your|the last|the change)\b/i,
/\bwrong (?:file|approach|place|method|function|answer|way|direction)\b/i,
// "answer" is deliberately absent from the noun list: injected skill/system
// prose lands in the user-message slot and reads as ordinary writing where
// "the wrong answer" is an idiom ("a well-composed page is never the wrong
// answer" counted 4 phantom corrections on real data). The other nouns are
// concrete work artifacts that prose rarely uses with "wrong".
/\bwrong (?:file|approach|place|method|function|way|direction)\b/i,
/\bstill (?:wrong|broken|failing|not working)\b/i,
]

Expand Down
13 changes: 13 additions & 0 deletions tests/workflow-insights.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,25 @@ describe('scanUserCorrections', () => {
'undo the migration when done',
'the build is failing, can you fix it',
'what went wrong here',
// Verbatim from an injected skill prompt that counted 4 phantom
// corrections on real data: "wrong answer" is prose idiom, not a
// correction, which is why "answer" is not in the wrong-<noun> list.
'When unsure: a well-composed page is never the wrong answer; an over-designed visual identity sometimes is.',
]
const p = project([session('s1', phrases.map(m => turn({ userMessage: m })))])
const r = scanUserCorrections([p])
expect(r.corrections).toBe(0)
})

it('still flags concrete wrong-<artifact> follow-ups', () => {
const p = project([session('s1', [
turn({ userMessage: 'rename the helper' }),
turn({ userMessage: 'you edited the wrong file' }),
turn({ userMessage: "that's the wrong approach, use the cache" }),
])])
expect(scanUserCorrections([p]).corrections).toBe(2)
})

it('ignores continuation turns with no fresh prompt', () => {
const p = project([session('s1', [
turn({ userMessage: 'build the feature' }),
Expand Down
Loading