* docs(ST-1101..1108): add M11 — Claude question-channel milestone to backlog
Plant acht stories ST-1101..ST-1108 voor het persistente vraag-antwoord-kanaal
tussen Claude (MCP) en de actieve gebruiker. Eerste concrete uitwerking van
de AI-driven dev-flow-richting (strategisch besluit "B" uit overleg na M10).
Beveiligingsuitgangspunt: atomic answer via updateMany WHERE status='open',
demo-blok op write-tools, access-check via productAccessFilter in DB-query én
SSE-filter, cron-endpoint via Bearer-secret, geen vraag/antwoord-tekst in logs.
Hergebruikt bestaande scrum4me_changes-channel (uitgebreid met entity:'question')
en het LISTEN/NOTIFY+ReadableStream-pattern uit M8/M10. Nieuw: user-scoped SSE
op /api/realtime/notifications zodat de bell globaal werkt over producten heen.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore(M11): swap demo-active sprint from M10 to M11
M10 is gemerged en afgesloten — M11 wordt de nieuwe demo-actieve milestone
zodat get_claude_context (via MCP) ST-1101 als next-story teruggeeft.
Drie maps in parse-backlog.ts uitgebreid: M11 priority=4, goal omschrijving,
sprint_status='ACTIVE'. M10 → COMPLETED.
Vereist npx prisma db seed na deze commit zodat de live DB de nieuwe
sprint-state weerspiegelt.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* docs(ST-1108): add F-11b — Claude question-channel to functional spec
Voegt feature-omschrijving toe naast bestaande F-11 (Claude Code REST API).
Beschrijft het verloop (Claude → MCP-tool → DB → trigger → SSE → user → answer
→ trigger → Claude polls), acceptatiecriteria (8 items), randgevallen (offline-
Claude, assignee-change, expiry, abuse) en datamodel (claude_questions tabel).
Persona Lars als primair, Dina secundair voor klant-werk.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore(M11): drop parser ACTIVE-flip; sprint goes via UI from now on
Bij M9/M10 hebben we de seed-flip (MILESTONE_SPRINT_STATUS pivot) gebruikt om
nieuwe stories als IN_SPRINT in een verse sprint te krijgen. Dat werkt maar
is fragiel:
- npm run seed wist user-data
- de "sprint" die de seed maakt is geen echte planning-actie
- bij multi-product scenario's breekt het model
Vanaf M11 gebruiken we de bestaande Sprint-creatie-UI van Scrum4Me. Stories
voor M11 worden via scripts/insert-milestone.ts (idempotent insert, geen
seed-reset) aan de DB toegevoegd; de gebruiker maakt zelf een Sprint aan in
/products/[scrum4me]/sprint en sleept ST-1101..1108 ernaartoe.
Parser-map M11 dus terug naar COMPLETED zodat een eventuele re-seed niet meer
een fake sprint aanmaakt voor M11-stories.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat(ST-1101): add ClaudeQuestion model + notify_question_change trigger
Schema (prisma/schema.prisma):
- Nieuw model ClaudeQuestion: id (cuid), story_id (FK Cascade), task_id?
(FK SetNull), product_id (FK Cascade — gedenormaliseerd uit story.product_id
voor SSE-filter zonder join), asked_by (FK Restrict — Claude-token-houder),
question (Text), options (Json? — string[] voor multi-choice), status
('open'|'answered'|'cancelled'|'expired'), answer (Text?), answered_by
(FK SetNull), answered_at?, created_at, expires_at
- Indexes: (story_id, status), (product_id, status), (status, expires_at)
- Back-relations: User.asked_questions (ClaudeQuestionAsker),
User.answered_questions (ClaudeQuestionAnswerer), Story.claude_questions,
Task.claude_questions, Product.claude_questions
Migratie (20260427224849_add_claude_questions):
- Prisma-gegenereerde DDL voor claude_questions + indexes + 5 FK's
- Toegevoegde notify_question_change() functie + claude_questions_notify trigger
op AFTER INSERT/UPDATE
- Emit op BESTAANDE scrum4me_changes-channel met entity:'question' (i.t.t. M10
dat eigen scrum4me_pairing-channel kreeg) — solo-route in ST-1104 moet
entity='question' wegfilteren om regressie op solo-board te voorkomen
- Trigger leest story.assignee_id voor "wacht op jou"-emphase in payload
- DELETE niet ondersteund — questions gaan naar answered/cancelled/expired
Verification: Node pg-client roundtrip via DATABASE_URL toonde correcte payloads
bij INSERT (op=I, status=open) en UPDATE (op=U, status=answered) met alle FK-IDs
en assignee_id correct uit story-join.
Volgende stap M11: ST-1102 — vier MCP-tools in scrum4me-mcp-repo
(ask_user_question, get_question_answer, list_open_questions, cancel_question).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat(ST-1103): add answerQuestion server action
actions/questions.ts:
- answerQuestion(questionId, answer) — auth + Zod + demo-blok + access-check
via productAccessFilter (anyone met product-membership mag antwoorden,
consistent met Scrum self-organizing — niet alleen story-assignee)
- Atomic prisma.claudeQuestion.updateMany WHERE id + status='open' +
expires_at>now → status='answered'; concurrent dubbele submit: één wint
(count=1), rest count=0 met disambiguatie via second findFirst
- revalidatePath('/', 'layout') refresh't NavBar bell-count voor SSR-paths;
realtime updates voor andere clients gaan via SSE in ST-1104/1105
- Begrijpelijke NL-foutmeldingen voor elk faalpad
Tests __tests__/actions/questions.test.ts (6 cases):
- happy: status update + revalidatePath called
- demo-block: error + geen DB-call + geen revalidate
- geen access: error + geen update
- al-answered: race-error 'is al answered'
- expired: race-error 'is verlopen'
- lege answer: Zod-validatie
Quality gates: lint 0 errors, tsc clean, vitest 145/145 (17 files).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat(ST-1104): add user-scoped /api/realtime/notifications + filter solo-route
Twee delen:
1. Solo-route filter (1-regel-fix in app/api/realtime/solo/route.ts):
- NotifyPayload uitgebreid met entity:'question'
- shouldEmit returnt direct false bij entity='question'
Voorkomt dat solo-clients M11 question-events ontvangen (geen lekkage naar
het Solo-bord; geen onnodig netwerk-verkeer; loose coupling tussen features).
2. Nieuwe SSE-route app/api/realtime/notifications/route.ts:
- User-scoped (geen ?product_id=); query alle accessible product-IDs één keer
bij connect via productAccessFilter
- LISTEN scrum4me_changes; filter entity='question' && product_id ∈ accessible
- Initial-state-event NA LISTEN actief (race-fix conform M10 ST-1004):
query open vragen voor deze user's accessible products, stuur als event:state
met summary (id, story_code/title, assignee_id, question, options, expires_at)
- Hergebruikt het pg.Client + ReadableStream + heartbeat 25s + hard-close 240s +
abort-cleanup-pattern uit solo-route
Tests __tests__/api/notifications-stream.test.ts:
- 401 zonder iron-session cookie (en geen DB-call)
- Solo-route filter wordt visueel/E2E gedekt in ST-1108-acceptatie
Quality gates: lint 0 errors, tsc clean, vitest 146/146 (18 files).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat(ST-1105): add NavBar bell + sheet + answer-modal + Zustand store + SSE hook
UI-volledig voor de Claude vraag-antwoord-flow (M11). Bel-icon links van avatar
in NavBar; klik opent slide-over rechts met openstaande vragen; klik op een vraag
opent een modal voor antwoord. Story-assignee = current user krijgt visuele
"voor jou"-emphase met primary-container accent en error-color badge-ring.
Bestanden:
- stores/notifications-store.ts — Zustand store met init/upsert/remove +
openCount/forYouCount selectors (vereenvoudigd vs solo-store: geen pendingOps,
geen optimistic-echo-onderdrukking)
- lib/realtime/use-notifications-realtime.ts — EventSource hook met state-
event en message-event handling, exponential-backoff reconnect, Page
Visibility pause-resume
- components/notifications/notifications-bridge.tsx — Server Component die
initial open-questions fetcht via productAccessFilter
- components/notifications/notifications-realtime-mount.tsx — tiny client
island dat de store hydrateert + de hook activeert
- components/notifications/notifications-sheet.tsx — shadcn Sheet met item-
lijst, "voor jou"-accent voor assignee-vragen, lege staat
- components/notifications/answer-modal.tsx — Dialog met options-radio of
free-text Textarea (max 4000), char-counter, demo-blok via Tooltip; bij
succes optimistisch remove + sheet blijft open zodat meerdere vragen
achter elkaar te beantwoorden zijn
- components/shared/notifications-bell.tsx — Bell-icon met badge (count >9 → "9+"),
ring-accent als forYouCount > 0, ARIA-label voor screenreaders
Wiring:
- components/shared/nav-bar.tsx — <NotificationsBell /> rechts naast <UserMenu>
- app/(app)/layout.tsx — <NotificationsBridge /> naast <SoloRealtimeBridge />,
user.id (server-side) als prop
base-ui-aanpassingen: SheetTrigger/TooltipTrigger gebruiken render-prop ipv
asChild (geen Radix).
Quality gates: lint 0 errors, tsc clean, vitest 146/146, npm run build groen.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* test(ST-1106): add cross-product access-isolation test for notifications SSE
Demo-policy + assignee-emphase zaten al in eerdere stories:
- answerQuestion demo-blok in actions/questions.test.ts (ST-1103)
- AnswerModal demo-tooltip in components/notifications/answer-modal.tsx (ST-1105)
- requireWriteAccess in MCP write-tools (ST-1102)
Deze story voegt expliciet een access-isolation-test toe op de notifications-
SSE-route: productAccessFilter wordt met de echte userId aangeroepen, en
prisma.product.findMany filter't op archived=false + user_id-scope. Dat
garandeert dat een gebruiker geen question-events ontvangt voor producten waar
hij geen membership op heeft.
Story-assignee-emphase blijft visueel-only (NotificationsBell ring-accent +
Sheet primary-container) — toegang werkt product-membership-breed zodat een
team-lid kan invallen als de assignee niet beschikbaar is.
Quality gates: lint 0 errors, tsc clean, vitest 147/147 (was 146).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat(ST-1107): add Vercel cron expire-questions (+ M10 pairing cleanup)
POST /api/cron/expire-questions:
- Auth via Authorization: Bearer ${CRON_SECRET} (Vercel injecteert dit
automatisch wanneer de env-var op de project-omgeving staat); 401 als secret
niet matcht of niet is gezet (faal-veilig — geen open endpoint in dev)
- updateMany op claude_questions WHERE status='open' AND expires_at<now →
'expired'
- Bonus: zelfde route ruimt M10 login_pairings op (status='pending' AND
expires_at<now → 'cancelled'). Eén cron-job is goedkoper qua Vercel-budget
en houdt cleanup-strategie centraal — opvolg-actie uit M10 dat geparkeerd was.
Config:
- vercel.json: crons-entry { path: '/api/cron/expire-questions', schedule: '0 */6 * * *' } (4x/dag)
- lib/env.ts: CRON_SECRET als optional in Zod-schema
- .env.example: documentatie + openssl rand-tip
Tests __tests__/api/cron-expire-questions.test.ts (4 cases):
- 401 zonder Authorization-header
- 401 met verkeerde secret
- 401 als CRON_SECRET niet is gezet (faal-veilig)
- 200 met juiste secret: response { expired_questions, expired_pairings, ran_at }
+ beide updateMany WHERE/data correct
Quality gates: lint 0 errors, tsc clean, vitest 151/151.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* docs(ST-1108): document M11 question-channel — API + architecture + pattern
docs/API.md — twee nieuwe secties:
- 'Notifications' met /api/realtime/notifications SSE-endpoint (event-shapes,
filter-rules, voorbeeld)
- 'Cron — Expire questions' met /api/cron/expire-questions (Bearer-auth,
schedule, response-shape, manual curl)
docs/scrum4me-architecture.md — nieuw hoofdstuk 'Vraag-antwoord-kanaal Claude
↔ user' tussen QR-pairing-flow en Projectstructuur:
- Mermaid sequence-diagram (Claude → DB → trigger → SSE → user → answer →
trigger → Claude polls)
- Threat-model-tabel (race, demo-misbruik, cross-product leak, cron-misbruik,
growth, log-leakage)
- Subsectie 'Waarom hergebruik scrum4me_changes-kanaal' met trade-off vs M10's
eigen-kanaal-aanpak
docs/patterns/claude-question-channel.md — herbruikbaar pattern 'Bidirectionele
async-comms tussen MCP-agent en interactieve user' met de vier eindpunten,
vier security-uitgangspunten, channel-strategie-tabel, TTL-richtlijn, en
sjabloon-bestanden per laag (DB / server / client / MCP-tools).
CLAUDE.md — extra rij in Implementatiepatronen-tabel die naar het nieuwe
pattern-doc verwijst.
Acceptatie 6 scenario's:
1. Sync happy path (MCP wait_seconds + UI submit) — handmatig getest tijdens
ST-1105 acceptance-loop met de q-test injection
2. Async happy path — gedekt door get_question_answer-tool in ST-1102 +
list_open_questions
3. Demo-block — actions/questions.test.ts (case 2: demo-user) + AnswerModal
tooltip (visueel)
4. Access-isolation — notifications-stream.test.ts (case 'access-isolation')
5. Expiry — cron-expire-questions.test.ts (case '200 met juiste secret')
6. Race — actions/questions.test.ts (case 'al-answered' via atomic updateMany)
Quality gates: lint 0 errors, tsc clean, vitest 151/151 (19 files), npm run
build groen.
M11 is hiermee feature-compleet. feat/M11-claude-questions heeft 12 commits
lokaal, klaar voor user-acceptatie en PR.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(ST-1107): cron schedule daily — Vercel Hobby allows only 1 run/day
Vercel deploy faalde met:
> Hobby accounts are limited to daily cron jobs.
> This cron expression (0 */6 * * *) would run more than once per day.
Schedule van 4×/dag (0 */6 * * *) naar 1×/dag (0 4 * * * — 04:00 UTC, rustig
tijdstip). Functioneel acceptabel: ClaudeQuestion TTL is 24u, dus daily
cleanup pakt alles dat in de afgelopen 24u verlopen is. Login-pairings TTL
is 2 min — die zijn al onbruikbaar zodra ze expiren, cron is alleen voor
status-housekeeping.
Schedule-referenties consistent bijgewerkt in docs (API.md, architecture,
backlog M11-sectie, plan-doc, pattern-doc) + comment in route.ts. Vermelding
overal dat dit een Hobby-plan-beperking is en Pro fijnmaziger ondersteunt.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
261 lines
7.4 KiB
TypeScript
261 lines
7.4 KiB
TypeScript
import { readFile } from 'node:fs/promises'
|
|
import path from 'node:path'
|
|
|
|
export type ParsedTask = {
|
|
title: string
|
|
description: string
|
|
sort_order: number
|
|
}
|
|
|
|
export type ParsedStory = {
|
|
ref: string
|
|
title: string
|
|
acceptance_criteria: string
|
|
status: 'DONE' | 'OPEN'
|
|
sort_order: number
|
|
tasks: ParsedTask[]
|
|
}
|
|
|
|
export type ParsedMilestone = {
|
|
key: string
|
|
title: string
|
|
goal: string
|
|
priority: 1 | 2 | 3 | 4
|
|
sprint_status: 'ACTIVE' | 'COMPLETED'
|
|
sort_order: number
|
|
stories: ParsedStory[]
|
|
}
|
|
|
|
const MILESTONE_HEADER = /^### (M[\d.]+|PBI-\d+):\s*(.+?)\s*$/
|
|
const TASK_BULLET = /^- \[(x| )\] \*\*(ST-\d+)\*\*\s+(.+?)\s*$/
|
|
const SUB_BULLET = /^ {2}- (.+?)\s*$/
|
|
const NESTED_LINE = /^ {4,}\S/
|
|
const SECTION_BREAK = /^---\s*$/
|
|
const BOLD_PREFIX = /^\*\*([^*]+?)\*\*\s*:?\s*(.*)$/
|
|
|
|
const MILESTONE_PRIORITY: Record<string, 1 | 2 | 3 | 4> = {
|
|
M0: 1,
|
|
M1: 1,
|
|
M2: 1,
|
|
M3: 1,
|
|
'M3.5': 2,
|
|
M4: 2,
|
|
M5: 3,
|
|
M6: 4,
|
|
M7: 4,
|
|
M8: 4,
|
|
M9: 4,
|
|
M10: 4,
|
|
M11: 4,
|
|
}
|
|
|
|
const MILESTONE_GOAL: Record<string, string> = {
|
|
M0: 'Project, database, auth, navigatieshell',
|
|
M1: "Producten, PBI's, gesplitst scherm",
|
|
M2: 'Stories als blokken, dnd-kit, Zustand',
|
|
M3: 'Sprint aanmaken, stories slepen, taken',
|
|
'M3.5': 'Story-claim, persoonlijk Kanban-bord per product',
|
|
M4: 'Alle endpoints, tokenbeheer',
|
|
M5: 'Todo CRUD, promotie naar PBI/story; Data Table + detail-kaart',
|
|
M6: 'Foutafhandeling, toegankelijkheid, CI/CD, beveiliging',
|
|
M7: 'MCP-server voor Claude Code',
|
|
M8: 'Realtime updates voor Solo Paneel',
|
|
M9: 'Actief Product Backlog — persistent gekozen product',
|
|
M10: 'Password-loze inlog via QR-pairing',
|
|
M11: 'Vraag-antwoord-kanaal Claude ↔ user',
|
|
}
|
|
|
|
const MILESTONE_SPRINT_STATUS: Record<string, ParsedMilestone['sprint_status']> = {
|
|
M0: 'COMPLETED',
|
|
M1: 'COMPLETED',
|
|
M2: 'COMPLETED',
|
|
M3: 'COMPLETED',
|
|
'M3.5': 'COMPLETED',
|
|
M4: 'COMPLETED',
|
|
M5: 'COMPLETED',
|
|
M6: 'COMPLETED',
|
|
M7: 'COMPLETED',
|
|
M8: 'COMPLETED',
|
|
M9: 'COMPLETED',
|
|
M10: 'COMPLETED',
|
|
M11: 'COMPLETED',
|
|
}
|
|
|
|
const MILESTONE_KEY = /^(?:M[\d.]+|PBI-\d+)$/
|
|
|
|
type SubBullet = {
|
|
headLine: string
|
|
nestedLines: string[]
|
|
isAcceptance: boolean
|
|
}
|
|
|
|
function buildTask(b: SubBullet, sort_order: number): ParsedTask {
|
|
const nested = b.nestedLines.join('\n')
|
|
const m = b.headLine.match(BOLD_PREFIX)
|
|
if (m) {
|
|
const title = m[1].replace(/`/g, '').replace(/:$/, '').trim()
|
|
const description = [m[2].trim(), nested].filter(Boolean).join('\n').trim()
|
|
return { title, description, sort_order }
|
|
}
|
|
// No bold prefix: derive a short title from the first clause; full bullet stays in description.
|
|
const head = b.headLine.replace(/`/g, '').trim()
|
|
const firstClause = head.split(/[;.]\s/, 1)[0].trim()
|
|
const title = firstClause.length > 80 ? firstClause.slice(0, 79).trim() + '…' : firstClause
|
|
const description = [b.headLine, nested].filter(Boolean).join('\n').trim()
|
|
return { title, description, sort_order }
|
|
}
|
|
|
|
function buildAcceptance(b: SubBullet): string {
|
|
const head = b.headLine.replace(/^Done when:\s*/i, '').trim()
|
|
const nested = b.nestedLines.join('\n').trim()
|
|
return [head, nested].filter(Boolean).join('\n').trim()
|
|
}
|
|
|
|
export async function loadBacklog(
|
|
repoRoot: string,
|
|
options: { strict?: boolean } = {},
|
|
): Promise<ParsedMilestone[]> {
|
|
const { strict = true } = options
|
|
const file = path.join(repoRoot, 'docs/scrum4me-backlog.md')
|
|
const md = await readFile(file, 'utf8')
|
|
|
|
const milestones: ParsedMilestone[] = []
|
|
let current: ParsedMilestone | null = null
|
|
let pending: {
|
|
story: ParsedStory
|
|
bullets: SubBullet[]
|
|
activeBullet: SubBullet | null
|
|
} | null = null
|
|
|
|
const flushPending = () => {
|
|
if (!pending) return
|
|
if (pending.activeBullet) {
|
|
pending.bullets.push(pending.activeBullet)
|
|
pending.activeBullet = null
|
|
}
|
|
const taskBullets = pending.bullets.filter((b) => !b.isAcceptance)
|
|
const acceptanceBullets = pending.bullets.filter((b) => b.isAcceptance)
|
|
pending.story.tasks = taskBullets.map((b, i) => buildTask(b, i + 1))
|
|
pending.story.acceptance_criteria = acceptanceBullets
|
|
.map(buildAcceptance)
|
|
.filter(Boolean)
|
|
.join('\n')
|
|
pending = null
|
|
}
|
|
|
|
for (const raw of md.split('\n')) {
|
|
const headerMatch = raw.match(MILESTONE_HEADER)
|
|
if (headerMatch && MILESTONE_KEY.test(headerMatch[1])) {
|
|
flushPending()
|
|
const key = headerMatch[1]
|
|
const title = headerMatch[2]
|
|
current = {
|
|
key,
|
|
title,
|
|
goal: MILESTONE_GOAL[key] ?? title,
|
|
priority: MILESTONE_PRIORITY[key] ?? 4,
|
|
sprint_status: MILESTONE_SPRINT_STATUS[key] ?? 'COMPLETED',
|
|
sort_order: milestones.length + 1,
|
|
stories: [],
|
|
}
|
|
milestones.push(current)
|
|
continue
|
|
}
|
|
|
|
if (SECTION_BREAK.test(raw)) {
|
|
flushPending()
|
|
continue
|
|
}
|
|
|
|
if (!current) continue
|
|
|
|
const taskMatch = raw.match(TASK_BULLET)
|
|
if (taskMatch) {
|
|
flushPending()
|
|
const story: ParsedStory = {
|
|
ref: taskMatch[2],
|
|
title: taskMatch[3],
|
|
acceptance_criteria: '',
|
|
status: taskMatch[1] === 'x' ? 'DONE' : 'OPEN',
|
|
sort_order: current.stories.length + 1,
|
|
tasks: [],
|
|
}
|
|
current.stories.push(story)
|
|
pending = { story, bullets: [], activeBullet: null }
|
|
continue
|
|
}
|
|
|
|
if (!pending) continue
|
|
|
|
const subMatch = raw.match(SUB_BULLET)
|
|
if (subMatch) {
|
|
if (pending.activeBullet) {
|
|
pending.bullets.push(pending.activeBullet)
|
|
}
|
|
const content = subMatch[1]
|
|
pending.activeBullet = {
|
|
headLine: content.replace(/^Done when:\s*/i, ''),
|
|
nestedLines: [],
|
|
isAcceptance: /^Done when:/i.test(content),
|
|
}
|
|
continue
|
|
}
|
|
|
|
if (NESTED_LINE.test(raw) && pending.activeBullet) {
|
|
pending.activeBullet.nestedLines.push(raw.trim())
|
|
continue
|
|
}
|
|
|
|
if (raw.trim() === '') continue
|
|
|
|
flushPending()
|
|
}
|
|
|
|
flushPending()
|
|
|
|
if (strict) {
|
|
if (milestones.length < 8) {
|
|
throw new Error(
|
|
`Backlog parser found only ${milestones.length} milestones (expected 8). Format may have drifted in ${file}.`,
|
|
)
|
|
}
|
|
const totalStories = milestones.reduce((acc, m) => acc + m.stories.length, 0)
|
|
if (totalStories < 60) {
|
|
throw new Error(
|
|
`Backlog parser found only ${totalStories} stories (expected ≥ 60). Format may have drifted in ${file}.`,
|
|
)
|
|
}
|
|
}
|
|
|
|
return milestones
|
|
}
|
|
|
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
const repoRoot = path.resolve(path.dirname(new URL(import.meta.url).pathname), '..', '..')
|
|
loadBacklog(repoRoot)
|
|
.then((milestones) => {
|
|
const total = milestones.reduce((acc, m) => acc + m.stories.length, 0)
|
|
const done = milestones.reduce(
|
|
(acc, m) => acc + m.stories.filter((s) => s.status === 'DONE').length,
|
|
0,
|
|
)
|
|
const open = total - done
|
|
const totalTasks = milestones.reduce(
|
|
(acc, m) => acc + m.stories.reduce((a, s) => a + s.tasks.length, 0),
|
|
0,
|
|
)
|
|
console.log(
|
|
`Parsed ${milestones.length} milestones, ${total} stories (${done} DONE, ${open} OPEN), ${totalTasks} tasks`,
|
|
)
|
|
for (const m of milestones) {
|
|
const ms = m.stories.reduce((a, s) => a + s.tasks.length, 0)
|
|
console.log(
|
|
` ${m.key.padEnd(5)} ${m.title.padEnd(36)} priority=${m.priority} sprint=${m.sprint_status} stories=${m.stories.length} tasks=${ms}`,
|
|
)
|
|
}
|
|
})
|
|
.catch((err) => {
|
|
console.error(err)
|
|
process.exit(1)
|
|
})
|
|
}
|