-
Notifications
You must be signed in to change notification settings - Fork 32
fix(history): count all imperative samples #248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,43 @@ | |
|
|
||
| const CONVENTIONAL_PREFIX_RE = /^(feat|fix|chore|docs|style|refactor|perf|test|build|ci|revert)(\([^)]+\))?:\s*/; | ||
|
|
||
| const BASE_FORM_VERBS_WITH_SUFFIXES = new Set([ | ||
| 'bleed', | ||
| 'breed', | ||
| 'bring', | ||
| 'cling', | ||
| 'ding', | ||
| 'embed', | ||
| 'exceed', | ||
| 'feed', | ||
| 'fling', | ||
| 'heed', | ||
| 'imbed', | ||
| 'king', | ||
| 'need', | ||
| 'ping', | ||
| 'proceed', | ||
| 'ring', | ||
| 'seed', | ||
| 'shed', | ||
| 'sing', | ||
| 'sling', | ||
| 'speed', | ||
| 'spring', | ||
| 'sting', | ||
| 'string', | ||
| 'swing', | ||
| 'wed', | ||
| 'wing', | ||
| 'wring', | ||
| 'zing', | ||
| ]); | ||
|
|
||
| function isDescriptiveVerb(verb: string): boolean { | ||
| verb = verb.toLowerCase(); | ||
| return !BASE_FORM_VERBS_WITH_SUFFIXES.has(verb) && (verb.endsWith('ed') || verb.endsWith('ing')); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When history contains sentence-case subjects such as AGENTS.md reference: AGENTS.md:L63-L63 Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When an imperative subject begins with a compound base verb such as AGENTS.md reference: AGENTS.md:L63-L63 Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a commit uses an imperative derived verb such as Useful? React with 👍 / 👎. |
||
| } | ||
|
|
||
| const HISTORY_LOCK_RETRY_MS = 25; | ||
| const HISTORY_LOCK_STALE_MS = 60_000; | ||
| const HISTORY_LOCK_TIMEOUT_MS = HISTORY_LOCK_STALE_MS + 10_000; | ||
|
|
@@ -309,17 +346,11 @@ | |
| const verbMatch = firstLine.match( | ||
| /^(?:feat|fix|chore|docs|style|refactor|perf|test|build|ci|revert)(?:\([^)]+\))?:\s*(\w+)/, | ||
| ); | ||
| if (verbMatch) { | ||
| const verb = verbMatch[1]!; | ||
| if (!verb.endsWith('ed') && !verb.endsWith('ing')) { | ||
| imperativeCount++; | ||
| imperativeSampleCount++; | ||
| } | ||
| } else { | ||
| const firstWord = firstLine.match(/^\w+/); | ||
| if (firstWord && !firstWord[0]!.endsWith('ed') && !firstWord[0]!.endsWith('ing')) { | ||
| const verb = verbMatch?.[1] ?? firstLine.match(/^\w+/)?.[0]; | ||
|
Check warning on line 349 in src/history/store.ts
|
||
| if (verb) { | ||
| imperativeSampleCount++; | ||
| if (!isDescriptiveVerb(verb)) { | ||
| imperativeCount++; | ||
|
Comment on lines
+351
to
353
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When history contains base-form imperative verbs whose spelling ends in AGENTS.md reference: AGENTS.md:L63-L63 Useful? React with 👍 / 👎. |
||
| imperativeSampleCount++; | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Normalize verb casing before suffix classification.
verbpreserves commit-message casing, but the exception set is lowercase. Thereforefix: Bring retriesis incorrectly treated as descriptive and lowers the imperative rate.src/history/store.ts#L42-L43: normalizeverbbefore both the exception lookup and suffix checks.tests/history-profile.test.mjs#L70-L85: capitalizebringin the fixture (or add a capitalized case) and retain the expected2 / 3rate.Proposed fix
function isDescriptiveVerb(verb: string): boolean { - return !BASE_FORM_VERBS_WITH_SUFFIXES.has(verb) && (verb.endsWith('ed') || verb.endsWith('ing')); + const normalizedVerb = verb.toLowerCase(); + return !BASE_FORM_VERBS_WITH_SUFFIXES.has(normalizedVerb) + && (normalizedVerb.endsWith('ed') || normalizedVerb.endsWith('ing')); }📝 Committable suggestion
📍 Affects 2 files
src/history/store.ts#L42-L43(this comment)tests/history-profile.test.mjs#L70-L85🤖 Prompt for AI Agents