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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- The GitHub issue fetch finds the acceptance criteria under a `##`, `###` or `####` heading. The section ends at the next heading of the same level or a higher level (#808).

---

## [3.20.0] - 2026-11-23
Expand Down
2 changes: 1 addition & 1 deletion src/assets/mds/tracker/_github.mds
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ gh issue view "$ISSUE_NUMBER" \
BODY=$(gh issue view "$ISSUE" --json body -q '.body')

# Extract acceptance criteria
CRITERIA=$(printf '%s\n' "$BODY" | tr -d '\r' | awk 'tolower($0) ~ /^##[[:blank:]]*acceptance criteria:?[[:blank:]]*$/ {f=1; next} /^##[[:blank:]]/ {f=0} f' | grep -E '^[[:space:]]*([-*]|[0-9]+[.)])[[:space:]]+[^[:space:]]' || true)
CRITERIA=$(printf '%s\n' "$BODY" | tr -d '\r' | awk '/^[[:blank:]]*([`][`][`]|~~~)/ {c=!c} {h=0; if (!c && match($0, /^#+/)) h=RLENGTH; t=tolower(substr($0, h+1))} f && h && h<=lvl && (t=="" || t ~ /^[[:blank:]]/) {f=0} !f && h>=2 && h<=4 && t ~ /^[[:blank:]]*acceptance criteria:?[[:blank:]]*$/ {f=1; lvl=h; next} f' | grep -E '^[[:space:]]*([-*]|[0-9]+[.)])[[:space:]]+[^[:space:]]' || true)

# Extract dependencies
DEPENDS_ON=$(echo "$BODY" | grep -oE '(depends on|blocked by) #[0-9]+' | grep -oE '#[0-9]+' || true)
Expand Down
22 changes: 22 additions & 0 deletions tests/tracker/setup-task-common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,14 @@ function runRecipe(recipe: string, body: string): { status: number | null; crite
const RETIRED_RECIPE =
`CRITERIA=$(echo "$BODY" | sed -n '/## Acceptance Criteria/,/^##/p' | grep -E '^\\s*-\\s*\\[' || true)`

/** The level-2-only recipe #808 replaced — a known-bad sample for `###` headings. */
const LEVEL_2_ONLY_RECIPE =
`CRITERIA=$(printf '%s\\n' "$BODY" | tr -d '\\r' | awk 'tolower($0) ~ /^##[[:blank:]]*acceptance criteria:?[[:blank:]]*$/ {f=1; next} /^##[[:blank:]]/ {f=0} f' | grep -E '^[[:space:]]*([-*]|[0-9]+[.)])[[:space:]]+[^[:space:]]' || true)`

const NUMBERED_LOWERCASE = '## acceptance criteria:\n1. first item\n2) second item\n\n## Notes\n- [ ] not a criterion\n'

const LEVEL_3 = '### Cause\nText.\n\n### Acceptance criteria\n\n- [ ] AC-1: one\n- [ ] AC-2: two\n'

describe('fetch-issue: the acceptance-criteria recipe, executed', () => {
const recipe = collectCriteriaRecipe(requireRef('tracker/github/fetch-issue.md'))

Expand All @@ -282,6 +288,21 @@ describe('fetch-issue: the acceptance-criteria recipe, executed', () => {
},
{ label: 'CRLF line endings', body: '## Acceptance Criteria\r\n- [ ] one\r\n- two\r\n', expected: '- [ ] one\n- two' },
{ label: 'no heading', body: 'Nothing here\n- [ ] stray\n', expected: '' },
{ label: 'a ### heading starts the section', body: LEVEL_3, expected: '- [ ] AC-1: one\n- [ ] AC-2: two' },
{
label: 'a #### heading with a colon, a nested ##### stays inside, a following ### ends it',
body: '#### acceptance criteria:\n- a\n##### Detail\n- b\n### Notes\n- [ ] c\n',
expected: '- a\n- b',
},
{ label: 'a higher-level # heading ends a ### section', body: '### Acceptance criteria\n- a\n# Top\n- c\n', expected: '- a' },
{ label: 'a # or ##### heading starts no section', body: '# Acceptance criteria\n- a\n##### Acceptance criteria\n- b\n', expected: '' },
{ label: 'a second ### heading ends a ### section', body: '### Acceptance criteria\n- a\n### Notes\n- c\n', expected: '- a' },
{
label: 'a # comment inside a code fence does not end the section',
body: '## Acceptance criteria\n- [ ] AC-1 one\n\n```bash\n# build it\n## step\nnpm run build\n```\n\n~~~\n#\n~~~\n- [ ] AC-2 two\n## Notes\n- c\n',
expected: '- [ ] AC-1 one\n- [ ] AC-2 two',
},
{ label: 'no space after the hashes, trailing blanks', body: '##Acceptance criteria \t\n- a\n## Notes\n- c\n', expected: '- a' },
]

for (const { label, body, expected } of cases) {
Expand All @@ -294,6 +315,7 @@ describe('fetch-issue: the acceptance-criteria recipe, executed', () => {

it('known-bad probe: the retired recipe misses the numbered, lowercase section', () => {
expect(runRecipe(RETIRED_RECIPE, NUMBERED_LOWERCASE).criteria).toBe('')
expect(runRecipe(LEVEL_2_ONLY_RECIPE, LEVEL_3).criteria).toBe('')
expect(collectCriteriaRecipe('BODY=$(x)\n# nothing\n')).toBeNull()
})
})
Loading