- Add complete agent harness structure with 8 roles (leader, triager, architect, implementer, reviewer, security, qa, documenter) - Implement strict workflow with 9 stages and mandatory gates - Add comprehensive verification script and runtime status tracking - Create artifact-based evidence system with contracts and schemas - Add agent policy matrix with permissions and anti-cheat rules - Include test suite (44 tests passing) and CI-ready structure - Add documentation: README, HOWTO, CHECKPOINTS, templates - Configure model routing policies and token-aware task assignment - Add BDD/SDD specification guides and feature templates - Include starter pack for quick project onboarding All verification checks pass. Framework ready for production use.
192 lines
5.9 KiB
Bash
Executable File
192 lines
5.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -u
|
|
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[0;33m'
|
|
NC='\033[0m'
|
|
|
|
ok() { printf "${GREEN}[OK]${NC} %s\n" "$1"; }
|
|
warn() { printf "${YELLOW}[WARN]${NC} %s\n" "$1"; }
|
|
fail() { printf "${RED}[FAIL]${NC} %s\n" "$1"; }
|
|
|
|
EXIT_CODE=0
|
|
|
|
cd "$(dirname "$0")/.." || exit 1
|
|
|
|
echo "── 1) Verificando estructura base ─────────────────────"
|
|
required=(
|
|
"AGENTS.md"
|
|
"CHECKPOINTS.md"
|
|
"harness/agents.matrix.yml"
|
|
"harness/workflow.stages.yml"
|
|
"harness/policies/governance.md"
|
|
"harness/policies/security.md"
|
|
"harness/policies/quality.md"
|
|
"harness/policies/language.md"
|
|
"harness/policies/model-routing.md"
|
|
"harness/models.profiles.yml"
|
|
"harness/contracts/handoff.md"
|
|
"harness/contracts/evidence.schema.json"
|
|
"spec/product.md"
|
|
"spec/tech.md"
|
|
"spec/acceptance.md"
|
|
"backlog/features.json"
|
|
"work/current.md"
|
|
"work/history.md"
|
|
"work/runtime-status.json"
|
|
"scripts/agent_status.py"
|
|
"scripts/new_ticket.py"
|
|
"scripts/start.sh"
|
|
"platforms/pi/README.md"
|
|
)
|
|
|
|
for f in "${required[@]}"; do
|
|
if [ -f "$f" ]; then
|
|
ok "Existe $f"
|
|
else
|
|
fail "Falta $f"
|
|
EXIT_CODE=1
|
|
fi
|
|
done
|
|
|
|
echo ""
|
|
echo "── 2) Validando backlog + gates ───────────────────────"
|
|
python3 - <<'PY'
|
|
import json
|
|
import pathlib
|
|
import sys
|
|
|
|
root = pathlib.Path('.')
|
|
path = root / 'backlog' / 'features.json'
|
|
|
|
try:
|
|
data = json.loads(path.read_text(encoding='utf-8'))
|
|
except Exception as e:
|
|
print(f"[FAIL] backlog/features.json inválido: {e}")
|
|
sys.exit(1)
|
|
|
|
valid = set(data.get('rules', {}).get('valid_status', ["pending", "in_progress", "blocked", "done"]))
|
|
features = data.get('features', [])
|
|
if not isinstance(features, list):
|
|
print('[FAIL] features debe ser una lista')
|
|
sys.exit(1)
|
|
|
|
ids = [str(f.get('id', '')).strip() for f in features]
|
|
if len(ids) != len(set(ids)):
|
|
print('[FAIL] Hay IDs de feature duplicados en backlog/features.json')
|
|
sys.exit(1)
|
|
|
|
in_progress = [f for f in features if f.get('status') == 'in_progress']
|
|
if len(in_progress) > 1:
|
|
print(f"[FAIL] Hay {len(in_progress)} features in_progress (máximo 1)")
|
|
sys.exit(1)
|
|
|
|
for f in features:
|
|
fid = str(f.get('id', '')).strip()
|
|
status = f.get('status')
|
|
if status not in valid:
|
|
print(f"[FAIL] Estado inválido en feature {fid}: {status}")
|
|
sys.exit(1)
|
|
|
|
if status == 'done':
|
|
d = root / 'work' / 'artifacts' / fid
|
|
req = ['reviewer.json', 'security.json', 'qa.json', 'leader-close.json', 'documenter.md']
|
|
missing = [name for name in req if not (d / name).is_file()]
|
|
if missing:
|
|
print(f"[FAIL] Feature {fid} done sin artefactos: {', '.join(missing)}")
|
|
sys.exit(1)
|
|
|
|
expected = {
|
|
'reviewer.json': 'reviewer',
|
|
'security.json': 'security',
|
|
'qa.json': 'qa',
|
|
'leader-close.json': 'leader',
|
|
}
|
|
for filename, agent in expected.items():
|
|
try:
|
|
obj = json.loads((d / filename).read_text(encoding='utf-8'))
|
|
except Exception as e:
|
|
print(f"[FAIL] {fid}/{filename} inválido: {e}")
|
|
sys.exit(1)
|
|
|
|
if obj.get('agent') != agent:
|
|
print(f"[FAIL] {fid}/{filename} agent debe ser '{agent}'")
|
|
sys.exit(1)
|
|
if obj.get('verdict') != 'APPROVED':
|
|
print(f"[FAIL] {fid}/{filename} no está APPROVED")
|
|
sys.exit(1)
|
|
|
|
print(f"[OK] backlog válido ({len(features)} features)")
|
|
PY
|
|
if [ $? -ne 0 ]; then EXIT_CODE=1; fi
|
|
|
|
python3 - <<'PY'
|
|
import json
|
|
import pathlib
|
|
import sys
|
|
|
|
path = pathlib.Path('work/runtime-status.json')
|
|
required = ['feature_id', 'stage', 'agent', 'action', 'state', 'next_agent', 'waiting_for', 'updated_at', 'timeline']
|
|
try:
|
|
data = json.loads(path.read_text(encoding='utf-8'))
|
|
except Exception as e:
|
|
print(f"[FAIL] work/runtime-status.json inválido: {e}")
|
|
sys.exit(1)
|
|
|
|
missing = [key for key in required if key not in data]
|
|
if missing:
|
|
print(f"[FAIL] work/runtime-status.json incompleto: {', '.join(missing)}")
|
|
sys.exit(1)
|
|
if not isinstance(data.get('timeline'), list):
|
|
print('[FAIL] work/runtime-status.json timeline debe ser una lista')
|
|
sys.exit(1)
|
|
print('[OK] runtime-status válido')
|
|
PY
|
|
if [ $? -ne 0 ]; then EXIT_CODE=1; fi
|
|
|
|
echo ""
|
|
echo "── 3) Verificación de tests/build (auto-detect) ───────"
|
|
if [ -f "Makefile" ] && grep -qE '^test:' Makefile; then
|
|
if make test; then ok "make test OK"; else fail "make test falló"; EXIT_CODE=1; fi
|
|
elif [ -f "package.json" ]; then
|
|
if command -v npm >/dev/null 2>&1; then
|
|
if npm test --silent --if-present; then ok "npm test OK"; else fail "npm test falló"; EXIT_CODE=1; fi
|
|
else
|
|
warn "package.json detectado pero npm no está disponible"
|
|
fi
|
|
elif [ -d "tests" ]; then
|
|
if command -v pytest >/dev/null 2>&1; then
|
|
if pytest -q; then ok "pytest OK"; else fail "pytest falló"; EXIT_CODE=1; fi
|
|
else
|
|
if python3 -m unittest discover -s tests -v; then ok "unittest OK"; else fail "unittest falló"; EXIT_CODE=1; fi
|
|
fi
|
|
else
|
|
warn "No se detectó suite automática (tests/ | Makefile test | package.json test)"
|
|
fi
|
|
|
|
echo ""
|
|
echo "── 4) Overlay local opcional ─────────────────────────"
|
|
if [ -x "scripts/verify.local.sh" ]; then
|
|
if ./scripts/verify.local.sh; then
|
|
ok "verify.local.sh OK"
|
|
else
|
|
fail "verify.local.sh falló"
|
|
EXIT_CODE=1
|
|
fi
|
|
elif [ -f "scripts/verify.local.sh" ]; then
|
|
warn "scripts/verify.local.sh existe pero no es ejecutable"
|
|
else
|
|
warn "Sin overlay local (scripts/verify.local.sh)"
|
|
fi
|
|
|
|
echo ""
|
|
echo "── 5) Resumen ─────────────────────────────────────────"
|
|
if [ $EXIT_CODE -eq 0 ]; then
|
|
ok "Harness verificado. Template listo para adaptar a cualquier proyecto."
|
|
else
|
|
fail "Harness NO verificado. Corrige antes de continuar."
|
|
fi
|
|
|
|
exit $EXIT_CODE
|