Files
atomic-design-poc/docs/project/refactor-backlog-setup/setup.sh
T
ehoandClaude Opus 5 664a43bf2d docs: refactoring-backlog workspace — baseline + 3 Phase 1 agents
Runs the multi-agent refactoring-backlog pipeline in docs/project/
refactor-backlog-setup/ up to and including three of the seven Phase 1
agents.

00-baseline.md establishes the metrics every later agent must cite, using
only tooling already in the repo (vitest lcov, coverlet cobertura, ESLint's
core `complexity` rule at threshold 0 for a full distribution, depcruise
--metrics). Duplication and C# complexity had no tooling, so
tools/baseline-scan.mjs adds a deterministic ~200-line text scan rather
than a new dependency; the approximations are labelled as such.

Headline: FE 75.1% line coverage but only over the 98 of 220 source files a
spec loads; BE 97.6% line / 79.6% branch; 0 layering violations; 7.1%
duplication; 25 of 2085 TS functions over CC 10.

Then 02-testability, 04-cqrs-light and 06-adr-conformance (27 findings).
01/03/05 were skipped deliberately — the baseline shows little for them to
find; 07 (BIO2) and 08 (consolidation) are still open.

Each agent corrected a baseline observation of mine, and in every case the
error was in something derived rather than measured:

- BL-007 counted ~13 adapter "mutations" from the `runSubmit` helper name;
  5 of those call sites are reads. It also missed 3 real mutations that
  reach the raw ApiClient and never return a Result.
- BL-002 diagnosed the 100%-duplicated auth folders as ADR-0002's
  divergence prediction failing. It never had a chance to fail: §3's
  `Principal` union was never built.
- BL-004 named libs/shared/domain and libs/beheer/contracts as coverage
  gaps; both are pure type declarations where 0% is unimprovable.

All three corrections are recorded inline in 00-baseline.md §10, so agent
08 does not inherit the bad numbers.

.prettierignore excludes the agent prompt directories — reflowing their
markdown would edit the prompt text itself.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 16:44:32 +02:00

74 lines
2.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Sets up the multi-agent refactoring backlog workspace.
# Run from the root of the target repo: bash setup.sh
set -euo pipefail
WORK_DIR="./refactor-backlog"
AGENTS_SRC="$(dirname "$0")/agents"
PROTOCOL="$AGENTS_SRC/_persistence-protocol.md"
echo "Setting up $WORK_DIR ..."
mkdir -p "$WORK_DIR/implementation"
mkdir -p "$WORK_DIR/final-prompts"
# 1. Initialize _status.md
cat > "$WORK_DIR/_status.md" << 'EOF'
# Agent run status
| Agent | Status | Last module processed | Last updated | Notes |
|---|---|---|---|---|
| baseline | not_started | - | - | |
| readability | not_started | - | - | |
| testability | not_started | - | - | |
| ddd-hexagonal | not_started | - | - | |
| cqrs-light | not_started | - | - | |
| bdd | not_started | - | - | |
| adr-conformance | not_started | - | - | |
| bio2-compliance | not_started | - | - | |
| consolidation | not_started | - | - | |
EOF
echo " created _status.md"
# 2. Initialize empty output files with headers
for f in 00-baseline 01-readability 02-testability 03-ddd-hexagonal \
04-cqrs-light 05-bdd 06-adr-conformance 07-bio2-compliance; do
cat > "$WORK_DIR/${f}.md" << EOF
## Scope: [to be filled by agent]
## Status: not_started
## Last updated: -
## Depends on: [see agent prompt]
## ---
EOF
done
touch "$WORK_DIR/99-backlog.md"
echo " initialized 8 phase-1 output files + 99-backlog.md"
# 3. Assemble final prompts: inject persistence protocol into each agent prompt
# at the "[Insert contents of _persistence-protocol.md here...]" marker.
for src in "$AGENTS_SRC"/*.prompt.md; do
name="$(basename "$src")"
out="$WORK_DIR/final-prompts/$name"
awk -v protofile="$PROTOCOL" '
/\[Insert contents of _persistence-protocol\.md here/ {
while ((getline line < protofile) > 0) print line
close(protofile)
next
}
{ print }
' "$src" > "$out"
echo " assembled final-prompts/$name"
done
echo ""
echo "Done. Structure:"
echo " $WORK_DIR/_status.md (run tracker — all agents not_started)"
echo " $WORK_DIR/00-baseline.md ... 07-bio2-compliance.md (empty, agent-writable)"
echo " $WORK_DIR/99-backlog.md (empty, Consolidation writes here)"
echo " $WORK_DIR/implementation/ (Phase 3 notes land here)"
echo " $WORK_DIR/final-prompts/ (ready-to-dispatch prompts, protocol"
echo " already merged in — no manual copy-paste)"
echo ""
echo "Next: dispatch final-prompts/00-baseline.prompt.md first (blocks everything),"
echo "then the 7 Phase 1 prompts in parallel, then 08-consolidation.prompt.md,"
echo "then per-ticket 09-implementation.prompt.md (fill in TICKET-ID each time)."