Scrum4Me/scripts
Janpeter Visser d84cdf664f
feat(PBI-67): IDEA_REVIEW_PLAN — iterative multi-model plan review (#199)
* feat(ideas): upload-plan knop — short-circuit van Make-Plan AI-flow

Voegt een 'Upload plan' knop toe in idea-row-actions (verschijnt in zowel
list als idea-detail). Klik → file picker → kies .md → server-side parse +
opslaan; idea-status springt naar PLAN_READY. Vandaaruit de bestaande
'Maak PBI' knop voor materialize.

Server (uploadPlanMdAction):
- Toegestaan vanuit DRAFT, GRILLED, PLAN_FAILED, PLAN_READY
- DRAFT → skip-grill: status gaat direct naar PLAN_READY
- PLAN_READY overschrijft het bestaande plan (consistent met
  updatePlanMdAction, geen confirmation)
- Geblokkeerd in GRILLING/PLANNING (job loopt), PLANNED (al gematerialiseerd)
- Parse-failure → 422 + details (NIET opslaan, zodat een onparseerbaar plan
  nooit in de DB belandt)
- Empty / >100k chars → 422
- Schrijft IdeaLog NOTE met from_status + length
- Rate-limit + demo-guard + ownership-check via loadOwnedIdea (zelfde
  patroon als updatePlanMdAction)

UI (idea-row-actions.tsx):
- Hidden <input type=file accept=".md,.markdown,text/markdown,text/plain">
- FileReader → text → action
- Toast bij success + router.refresh()
- Blocked-tooltip in andere statussen

Tests: 10 nieuwe in __tests__/actions/ideas-crud.test.ts dekkend voor:
happy paths (DRAFT/GRILLED/PLAN_READY-overwrite/PLAN_FAILED), blocks
(PLANNED/GRILLING), validation (empty/oversized/parse-fail), 404.
Full suite groen: 849/849.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Add reviews for Bootstrap-wizard plans v3.2 to v3.4

- Review v3.2: Addressed executor model, fire-and-forget issues, and PAT handling.
- Review v3.3: Improved transaction handling, stale recovery, and ID generation.
- Review v3.4: Finalized GitHub permissions, catalog versioning, and E2E verification queries.
- Updated recommendations for each version to enhance implementation readiness.

* docs(plans): M8 bootstrap-wizard upload-variant v1.4 — backtick-paden

Upload-variant van het volledige technische plan (docs/plans/M8-bootstrap-wizard.md),
bedoeld voor de "Upload plan"-functie. Genereert 1 PBI + 4 Stories + 22 Tasks
via materializeIdeaPlanAction.

v1.4-aanpassingen tov eerdere generatie-iteratie:
- Alle bestandspaden in implementation_plan in backticks (path-extractor matchen)
- Expliciete "Bestanden:" blok per task vóór de stappen
- Alle tasks op verify_required: ALIGNED_OR_PARTIAL (was deels ALIGNED — te strict
  voor ADR-stubs en multi-file edits)

Fixt forward-only: T-963 cancelled_by_self door DIVERGENT verifier-verdict.
Re-upload van dit bestand produceert tasks die door verify_task_against_plan
als ALIGNED of PARTIAL geclassificeerd kunnen worden.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* PBI-67: Add review-plan support to Idea model and job config

- Add plan_review_log and reviewed_at fields to Idea model
- Add REVIEWING_PLAN, PLAN_REVIEW_FAILED, PLAN_REVIEWED to IdeaStatus enum
- Add IDEA_REVIEW_PLAN to ClaudeJobKind enum
- Add IDEA_REVIEW_PLAN config to job-config.ts with model=opus, thinking_budget=6000
- Create migration record for schema changes (applied via db push)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

* PBI-67 Phase 2: Add update-idea-plan-reviewed MCP tool

- Create src/tools/update-idea-plan-reviewed.ts: saves review-log and transitions idea status to PLAN_REVIEWED
- Add PLAN_REVIEW_RESULT to IdeaLogType enum (both repos)
- Register tool in src/index.ts
- Update Prisma schemas (both repos): add plan_review_log and reviewed_at fields to Idea model
- Add REVIEWING_PLAN, PLAN_REVIEW_FAILED, PLAN_REVIEWED to IdeaStatus enum (MCP schema)
- Add IDEA_REVIEW_PLAN to ClaudeJobKind enum (MCP schema)
- Tool includes transaction safety and convergence metrics logging

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

* feat(PBI-67): IDEA_REVIEW_PLAN Phases 3-6 — server actions, UI components, prompt & tests

- Phase 3: startReviewPlanJobAction, cancelIdeaJobAction, status transitions
  (REVIEWING_PLAN / PLAN_REVIEWED / PLAN_REVIEW_FAILED), status colors,
  job-card/jobs-column filters, idea-list status tabs
- Phase 4: review-plan-job.md prompt (multi-model orchestration with codex
  injection + active plan revision via update_idea_plan_md after each round),
  runbook, 13 unit tests
- Phase 5: ReviewLogViewer component (rounds, convergence, approval, issues),
  idea-detail integration, proper ReviewLog TypeScript types exported from component
- Phase 6.1: wait-for-job discriminator wired (IDEA_REVIEW_PLAN), plan-revision
  step made mandatory in prompt (was previously optional/missing)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 03:35:02 +02:00
..
build-manual.mjs PBI-58: Developer manual + in-app /manual page (#148) 2026-05-07 18:00:10 +02:00
check-doc-links.mjs fix(ci): docs:check-links groen — exclude docs/old/ + archiveer stale plans (#193) 2026-05-11 21:33:47 +02:00
create-admin.ts feat(ST-l9kkxh2m): CLI-script scripts/create-admin.ts voor admin-bootstrap 2026-05-05 14:34:10 +02:00
generate-docs-index.mjs docs(cleanup): archief verouderde plannen, backlog en root-duplicaten (#191) 2026-05-11 19:46:00 +02:00
insert-milestone.ts feat(codes): server actions + seed/scripts gebruiken code overal 2026-05-04 08:36:41 +02:00
README.md feat(PBI-66): wekelijkse sync van model_prices via Anthropic /v1/models (#167) 2026-05-08 09:38:33 +02:00
realtime-mutate.ts feat(M8): Realtime Solo Paneel via Postgres LISTEN/NOTIFY (ST-801..ST-806) (#8) 2026-04-27 13:59:32 +02:00
sync-model-prices.ts feat(PBI-66): wekelijkse sync van model_prices via Anthropic /v1/models (#167) 2026-05-08 09:38:33 +02:00
test-api.sh chore: update API test script base URL and IDs; add ST-313 to backlog 2026-04-25 22:53:50 +02:00
verify-review-plan-files.sh feat(PBI-67): IDEA_REVIEW_PLAN — iterative multi-model plan review (#199) 2026-05-14 03:35:02 +02:00

Scripts

sync-model-prices.ts

Wekelijks handmatig draaibaar script dat de tabel model_prices synchroniseert. Haalt de actuele Claude 4.x modellijst op via GET /v1/models (Anthropic API) en upsert de prijzen vanuit een hardcoded PRICE_TABLE in het script. Anthropic biedt geen prijs-API; bij elke prijswijziging update je de tabel in scripts/sync-model-prices.ts.

Prerequisites

What How
ANTHROPIC_API_KEY in .env.local Genereer op console.anthropic.com → API Keys. Free Evaluation tier is voldoende — /v1/models is een gratis metadata-call.
DATABASE_URL in .env.local Standaard Scrum4Me-setup.

Gebruik

# Eerst droog draaien — toont wat er zou gebeuren, schrijft niets
npm run db:sync-model-prices -- --dry-run

# Echt synchroniseren
npm run db:sync-model-prices

Output

Fetching /v1/models from Anthropic API...
  → 12 models received, 4 match Claude 4.x filter

Syncing prices:
  ✓ claude-opus-4-7                   (unchanged)
  ✓ claude-sonnet-4-6                 (unchanged)
  ✓ claude-haiku-4-5-20251001         (unchanged)
  ⚠ claude-sonnet-4-9                 (geen prijs in PRICE_TABLE — ...)

Result: 0 created, 0 updated, 3 unchanged, 1 skipped

Bij een nieuw model (⚠ skipped)

  1. Open de Anthropic pricing-pagina.
  2. Voeg het model toe aan PRICE_TABLE in scripts/sync-model-prices.ts:
    'claude-sonnet-4-9': { input: 3.0, output: 15.0 },
    
  3. Draai het script opnieuw.

Edge cases

  • API geeft 401: controleer ANTHROPIC_API_KEY.
  • API geeft 5xx: script doet 1× retry met 2s delay, daarna falen.
  • Model in DB maar niet meer in API: wordt niet verwijderd — alleen gelogd, zodat oude claude_jobs rijen kostberekening blijven hebben.

test-api.sh

Runs curl-based tests against all 7 Scrum4Me API endpoints. Covers happy paths, auth (401), demo-block (403), and input validation (400).

Prerequisites

What How
Database seeded npx prisma db seed
Dev server running npm run dev
curl installed curl --version

Step 1 — Get a token for lars

  1. Open http://localhost:3000 in your browser
  2. Log in as lars / scrum4me123
  3. Go to Settings → API Tokens
  4. Click New token, give it any label
  5. Copy the token — it is shown only once

Open scripts/test-api.sh and paste it into TOKEN="".

Step 2 — Find your IDs

You need four IDs. The easiest way is to use the API itself:

# 1. Get PRODUCT_ID — run this after setting TOKEN
curl -s -H "Authorization: Bearer <TOKEN>" http://localhost:3000/api/products | grep -o '"id":"[^"]*"' | head -1

# 2. SPRINT_ID — look in the database or the UI (Sprint → copy ID from the URL)
# 3. STORY_ID  — open a story in the Sprint Board, copy the ID from the URL or the activity log
# 4. TASK_ID   — open a task, copy its ID

Or query the database directly:

# With psql / Neon CLI:
SELECT id FROM "Sprint" WHERE status = 'ACTIVE' LIMIT 1;
SELECT id FROM "Story"  WHERE status = 'IN_SPRINT' LIMIT 1;
SELECT id FROM "Task"   WHERE story_id = '<story-id>' LIMIT 1;

Paste the four values into the variables at the top of test-api.sh.

Step 3 — (Optional) Get a demo token for 403 tests

The 403 demo-block tests are skipped unless you set DEMO_TOKEN.

  1. Log out, log in as demo / demo1234
  2. Go to Settings → API Tokens, create a token
  3. Paste it into DEMO_TOKEN="" in test-api.sh

Step 4 — Run

bash scripts/test-api.sh

Expected output when all IDs are set and a demo token is provided:

============================================================
  Scrum4Me API Test Suite
  Base URL : http://localhost:3000
  Token    : scrum4me... (lars)
  Demo     : demo1234... (403 tests active)
============================================================

── GET /api/products ──────────────────────────────────────────────
  PASS  TC-P-09  happy path (lars)
  PASS  TC-P-01  no token → 401
  PASS  TC-P-02  invalid token → 401

── GET /api/products/:id/next-story ───────────────────────────────
  PASS  TC-NS-08  happy path (lars, 200 or 404 both valid)
  PASS  TC-NS-01  no token → 401
  ...

============================================================
  Results: 30 passed, 0 failed
============================================================

Notes

  • product_id is required for POST /api/todos. The Zod schema enforces z.string().min(1). Sending a todo without a product_id returns 400.
  • TC-NS-08 accepts both 200 and 404. After a fresh seed lars has no active sprint, so 404 is the expected response unless you create a sprint and add stories to it.
  • Reorder test (TC-RO-10) uses a single task ID. A reorder with one element is valid (sort_order is updated to 1).
  • The todos happy-path test appends $(date +%s) to the title to avoid duplicate-title issues on repeated runs.