contextdevkit 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +592 -0
- package/LICENSE +21 -0
- package/README.md +401 -0
- package/docs/AGENT-PACKAGE-FORMAT.md +140 -0
- package/docs/ARCHITECTURE.md +258 -0
- package/docs/CHANGELOG.md +559 -0
- package/docs/CUSTOMIZING.md +211 -0
- package/docs/LEVELS.md +151 -0
- package/docs/ROADMAP.md +385 -0
- package/docs/SQUAD-PIPELINE-FORMAT.md +258 -0
- package/docs/SQUADS/agent-forge.md +65 -0
- package/docs/SQUADS/design-team.md +161 -0
- package/docs/token-economy-plan.md +135 -0
- package/install.mjs +273 -0
- package/instrucoes.md +274 -0
- package/package.json +46 -0
- package/templates/CLAUDE.md.tpl +133 -0
- package/templates/claude/agents/_TEMPLATE.md +52 -0
- package/templates/claude/agents/accessibility.md +36 -0
- package/templates/claude/agents/agent-architect.md +37 -0
- package/templates/claude/agents/architect.md +39 -0
- package/templates/claude/agents/code-reviewer.md +43 -0
- package/templates/claude/agents/code-security.md +59 -0
- package/templates/claude/agents/context-keeper.md +40 -0
- package/templates/claude/agents/devops.md +40 -0
- package/templates/claude/agents/eval-designer.md +40 -0
- package/templates/claude/agents/forge-orchestrator.md +42 -0
- package/templates/claude/agents/governance-officer.md +45 -0
- package/templates/claude/agents/growth.md +92 -0
- package/templates/claude/agents/infra-security.md +53 -0
- package/templates/claude/agents/landing-architect.md +154 -0
- package/templates/claude/agents/model-router.md +34 -0
- package/templates/claude/agents/packager.md +38 -0
- package/templates/claude/agents/privacy-lgpd.md +64 -0
- package/templates/claude/agents/product-owner.md +51 -0
- package/templates/claude/agents/prompt-engineer.md +33 -0
- package/templates/claude/agents/qa-e2e.md +52 -0
- package/templates/claude/agents/qa-fuzzer.md +24 -0
- package/templates/claude/agents/qa-integration.md +21 -0
- package/templates/claude/agents/qa-orchestrator.md +40 -0
- package/templates/claude/agents/qa-perf.md +40 -0
- package/templates/claude/agents/qa-unit.md +39 -0
- package/templates/claude/agents/rag-designer.md +54 -0
- package/templates/claude/agents/retention.md +85 -0
- package/templates/claude/agents/security.md +48 -0
- package/templates/claude/agents/seo-specialist.md +106 -0
- package/templates/claude/agents/test-engineer.md +48 -0
- package/templates/claude/agents/tool-designer.md +32 -0
- package/templates/claude/agents/ui-designer.md +37 -0
- package/templates/claude/agents/ux-designer.md +38 -0
- package/templates/claude/commands/README.md +95 -0
- package/templates/claude/commands/advise.md +80 -0
- package/templates/claude/commands/audit/analyze-code-ia-practices.md +75 -0
- package/templates/claude/commands/audit/audit.md +35 -0
- package/templates/claude/commands/audit/contract-check.md +21 -0
- package/templates/claude/commands/audit/deep-analysis.md +48 -0
- package/templates/claude/commands/audit/deps-audit.md +49 -0
- package/templates/claude/commands/audit/security-setup.md +35 -0
- package/templates/claude/commands/audit/seo-audit.md +63 -0
- package/templates/claude/commands/audit/tech-debt-sweep.md +35 -0
- package/templates/claude/commands/bug-hunt.md +42 -0
- package/templates/claude/commands/claude-md.md +36 -0
- package/templates/claude/commands/close-version.md +25 -0
- package/templates/claude/commands/context-refresh.md +19 -0
- package/templates/claude/commands/context-stats.md +15 -0
- package/templates/claude/commands/dashboard.md +66 -0
- package/templates/claude/commands/distill-apply.md +19 -0
- package/templates/claude/commands/distill-sessions.md +26 -0
- package/templates/claude/commands/fleet.md +47 -0
- package/templates/claude/commands/forge/forge-audit.md +16 -0
- package/templates/claude/commands/forge/forge-budget.md +16 -0
- package/templates/claude/commands/forge/forge-deprecate.md +16 -0
- package/templates/claude/commands/forge/forge-doctor.md +17 -0
- package/templates/claude/commands/forge/forge-eval.md +16 -0
- package/templates/claude/commands/forge/forge-fallback-test.md +17 -0
- package/templates/claude/commands/forge/forge-killswitch.md +17 -0
- package/templates/claude/commands/forge/forge-list.md +17 -0
- package/templates/claude/commands/forge/forge-new.md +41 -0
- package/templates/claude/commands/forge/forge-policy.md +16 -0
- package/templates/claude/commands/forge/forge-redteam.md +17 -0
- package/templates/claude/commands/forge/forge-refresh-matrix.md +20 -0
- package/templates/claude/commands/forge/forge-route.md +17 -0
- package/templates/claude/commands/forge/forge-show.md +16 -0
- package/templates/claude/commands/landing-page.md +71 -0
- package/templates/claude/commands/log-session.md +59 -0
- package/templates/claude/commands/media-gen.md +93 -0
- package/templates/claude/commands/new-adr.md +30 -0
- package/templates/claude/commands/pipeline/dev-start.md +64 -0
- package/templates/claude/commands/pipeline/pipeline.md +36 -0
- package/templates/claude/commands/pipeline/resume.md +70 -0
- package/templates/claude/commands/pipeline/retro.md +34 -0
- package/templates/claude/commands/pipeline/runs.md +63 -0
- package/templates/claude/commands/pipeline/ship.md +54 -0
- package/templates/claude/commands/pipeline/workflow.md +85 -0
- package/templates/claude/commands/playbook.md +27 -0
- package/templates/claude/commands/predictions-review.md +28 -0
- package/templates/claude/commands/qa/qa-signoff.md +24 -0
- package/templates/claude/commands/qa/scaffold-tests.md +27 -0
- package/templates/claude/commands/qa/test-plan.md +26 -0
- package/templates/claude/commands/qa/visual-test.md +42 -0
- package/templates/claude/commands/roadmap.md +48 -0
- package/templates/claude/commands/setup/aidevtool-from0.md +104 -0
- package/templates/claude/commands/setup/context-config.md +25 -0
- package/templates/claude/commands/setup/context-doctor.md +21 -0
- package/templates/claude/commands/setup/context-level.md +17 -0
- package/templates/claude/commands/setup/setupcontextdevkit.md +121 -0
- package/templates/claude/commands/simulate-impact.md +32 -0
- package/templates/claude/commands/squad.md +44 -0
- package/templates/claude/commands/state.md +21 -0
- package/templates/claude/commands/token-report.md +29 -0
- package/templates/claude/commands/tune-agents.md +35 -0
- package/templates/claude/commands/vcs/claim.md +18 -0
- package/templates/claude/commands/vcs/git.md +83 -0
- package/templates/claude/commands/vcs/release.md +15 -0
- package/templates/claude/commands/vcs/worktree-new.md +18 -0
- package/templates/claude/commands/watch.md +47 -0
- package/templates/contextkit/.env.example +36 -0
- package/templates/contextkit/CLAUDE.child.md.tpl +38 -0
- package/templates/contextkit/README.md +74 -0
- package/templates/contextkit/behaviors-examples.md +183 -0
- package/templates/contextkit/behaviors.md +116 -0
- package/templates/contextkit/best-practices.md +323 -0
- package/templates/contextkit/config.json +66 -0
- package/templates/contextkit/detectors/README.md +45 -0
- package/templates/contextkit/detectors/example-detector.mjs.example +25 -0
- package/templates/contextkit/instrucoes.md +114 -0
- package/templates/contextkit/memory/GLOSSARY.md +13 -0
- package/templates/contextkit/memory/SESSIONS.md +9 -0
- package/templates/contextkit/memory/WORKSPACE.md +7 -0
- package/templates/contextkit/memory/business-rules/_TEMPLATE.md +33 -0
- package/templates/contextkit/memory/decisions/0000-record-architecture-decisions.md +34 -0
- package/templates/contextkit/memory/decisions/_TEMPLATE.md +25 -0
- package/templates/contextkit/memory/predictions/.gitkeep +0 -0
- package/templates/contextkit/memory/roadmap.md +28 -0
- package/templates/contextkit/memory/sessions/.gitkeep +0 -0
- package/templates/contextkit/memory/workflows/.gitkeep +0 -0
- package/templates/contextkit/pipeline/backlog/.gitkeep +0 -0
- package/templates/contextkit/pipeline/conclusion/.gitkeep +0 -0
- package/templates/contextkit/pipeline/devpipeline.md +9 -0
- package/templates/contextkit/pipeline/testing/.gitkeep +0 -0
- package/templates/contextkit/pipeline/working/.gitkeep +0 -0
- package/templates/contextkit/review-protocol.md +214 -0
- package/templates/contextkit/runtime/config/defaults.mjs +215 -0
- package/templates/contextkit/runtime/config/levels.mjs +42 -0
- package/templates/contextkit/runtime/config/load.mjs +105 -0
- package/templates/contextkit/runtime/config/paths.mjs +92 -0
- package/templates/contextkit/runtime/config/presets.mjs +47 -0
- package/templates/contextkit/runtime/config/schema.mjs +88 -0
- package/templates/contextkit/runtime/config/settings-compose.mjs +55 -0
- package/templates/contextkit/runtime/git-hooks/commit-msg.mjs +55 -0
- package/templates/contextkit/runtime/git-hooks/pre-commit.mjs +47 -0
- package/templates/contextkit/runtime/git-hooks/pre-push.mjs +102 -0
- package/templates/contextkit/runtime/hooks/boot-context-readers.mjs +111 -0
- package/templates/contextkit/runtime/hooks/boot-signals.mjs +135 -0
- package/templates/contextkit/runtime/hooks/check-registration.mjs +228 -0
- package/templates/contextkit/runtime/hooks/concurrency-guard.mjs +110 -0
- package/templates/contextkit/runtime/hooks/ledger.mjs +231 -0
- package/templates/contextkit/runtime/hooks/md-extract.mjs +65 -0
- package/templates/contextkit/runtime/hooks/path-classification.mjs +62 -0
- package/templates/contextkit/runtime/hooks/safe-io.mjs +84 -0
- package/templates/contextkit/runtime/hooks/session-digest-core.mjs +85 -0
- package/templates/contextkit/runtime/hooks/session-start.mjs +248 -0
- package/templates/contextkit/runtime/hooks/simulate-gate.mjs +108 -0
- package/templates/contextkit/runtime/hooks/track-edits.mjs +154 -0
- package/templates/contextkit/runtime/providers/media/_adapter.mjs +120 -0
- package/templates/contextkit/runtime/providers/media/nano-banana.mjs +110 -0
- package/templates/contextkit/runtime/providers/media/veo.mjs +162 -0
- package/templates/contextkit/runtime/providers/review/_adapter.mjs +71 -0
- package/templates/contextkit/runtime/providers/review/detect.mjs +115 -0
- package/templates/contextkit/runtime/providers/review/gh.mjs +103 -0
- package/templates/contextkit/runtime/state/state-io.mjs +172 -0
- package/templates/contextkit/runtime/statusline.mjs +51 -0
- package/templates/contextkit/squads/README.md +115 -0
- package/templates/contextkit/squads/_BRIEFING.md.tpl +27 -0
- package/templates/contextkit/squads/agent-forge/README.md +69 -0
- package/templates/contextkit/squads/agent-forge/ROADMAP.md +108 -0
- package/templates/contextkit/squads/agent-forge/best-practices.md +89 -0
- package/templates/contextkit/squads/agent-forge/cli/forge-admin.mjs +132 -0
- package/templates/contextkit/squads/agent-forge/cli/forge-eval-cli.mjs +163 -0
- package/templates/contextkit/squads/agent-forge/cli/forge-new.mjs +97 -0
- package/templates/contextkit/squads/agent-forge/cli/forge-ops.mjs +177 -0
- package/templates/contextkit/squads/agent-forge/lib/architect.mjs +112 -0
- package/templates/contextkit/squads/agent-forge/lib/eval-designer.mjs +133 -0
- package/templates/contextkit/squads/agent-forge/lib/eval-runner.mjs +167 -0
- package/templates/contextkit/squads/agent-forge/lib/governance-officer.mjs +178 -0
- package/templates/contextkit/squads/agent-forge/lib/package-ops.mjs +101 -0
- package/templates/contextkit/squads/agent-forge/lib/packager.mjs +219 -0
- package/templates/contextkit/squads/agent-forge/lib/prompt-gen.mjs +122 -0
- package/templates/contextkit/squads/agent-forge/lib/rag-designer.mjs +102 -0
- package/templates/contextkit/squads/agent-forge/lib/router.mjs +165 -0
- package/templates/contextkit/squads/agent-forge/lib/tool-gen.mjs +113 -0
- package/templates/contextkit/squads/agent-forge/lib/yaml.mjs +47 -0
- package/templates/contextkit/squads/agent-forge/pipeline.yaml +65 -0
- package/templates/contextkit/squads/agent-forge/router/capability-matrix.json +112 -0
- package/templates/contextkit/squads/agent-forge/router/decision-rules.json +120 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/.agentforgerc +12 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/CHANGELOG.md +13 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/LICENSE +5 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/README.md +39 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/go/README.md +10 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/go/agent.go +14 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/go/go.mod +3 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/node/README.md +11 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/node/index.js +53 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/node/package.json +9 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/python/README.md +10 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/python/agent.py +16 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/python/pyproject.toml +10 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/evals/golden.jsonl +1 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/evals/red-team.jsonl +3 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/evals/rubric.yaml +14 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/evals/run-eval.md +17 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/evals/thresholds.yaml +18 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/examples/basic.node.md +17 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/examples/with-fallback.node.md +24 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/examples/with-rag.python.md +20 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/governance/audit.schema.json +23 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/governance/compliance.policy.yaml +43 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/governance/cost.policy.yaml +36 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/governance/fallback-chain.yaml +16 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/governance/quality.policy.yaml +43 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/manifest.yaml +91 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/prompts/system.anthropic.md +19 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/prompts/system.canonical.md +25 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/prompts/system.deepseek.md +21 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/prompts/system.google.md +19 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/prompts/system.ollama.md +21 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/prompts/system.openai.md +20 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/rag/config.yaml +17 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/rag/index/.gitkeep +3 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/rag/ingestion/chunker.config.yaml +6 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/rag/ingestion/sources.yaml +8 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/rag/retrieval/query-template.md +16 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/rag/retrieval/rerank.config.yaml +6 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/tools/adapters/anthropic.tools.json +11 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/tools/adapters/deepseek.tools.json +14 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/tools/adapters/google.tools.json +11 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/tools/adapters/ollama.tools.json +14 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/tools/adapters/openai.tools.json +14 -0
- package/templates/contextkit/squads/agent-forge/templates/agent-package/tools/schemas.canonical.json +25 -0
- package/templates/contextkit/starters/tanstack/README.md +86 -0
- package/templates/contextkit/starters/tanstack/index.html +12 -0
- package/templates/contextkit/starters/tanstack/package.json +25 -0
- package/templates/contextkit/starters/tanstack/src/main.tsx +40 -0
- package/templates/contextkit/starters/tanstack/src/router.tsx +12 -0
- package/templates/contextkit/starters/tanstack/src/routes/__root.tsx +10 -0
- package/templates/contextkit/starters/tanstack/src/routes/index.tsx +17 -0
- package/templates/contextkit/starters/tanstack/tsconfig.json +19 -0
- package/templates/contextkit/starters/tanstack/vite.config.ts +10 -0
- package/templates/contextkit/tools/scripts/adr-digest-core.mjs +42 -0
- package/templates/contextkit/tools/scripts/adr-digest.mjs +78 -0
- package/templates/contextkit/tools/scripts/agent-tuning.mjs +74 -0
- package/templates/contextkit/tools/scripts/aiso-audit.mjs +174 -0
- package/templates/contextkit/tools/scripts/audit-shared.mjs +129 -0
- package/templates/contextkit/tools/scripts/claim.mjs +133 -0
- package/templates/contextkit/tools/scripts/claude-md.mjs +123 -0
- package/templates/contextkit/tools/scripts/clean-drive.mjs +78 -0
- package/templates/contextkit/tools/scripts/context-config.mjs +111 -0
- package/templates/contextkit/tools/scripts/context-level.mjs +98 -0
- package/templates/contextkit/tools/scripts/context-pack.mjs +120 -0
- package/templates/contextkit/tools/scripts/contract-scan.mjs +186 -0
- package/templates/contextkit/tools/scripts/dashboard-data.mjs +198 -0
- package/templates/contextkit/tools/scripts/dashboard-html.mjs +215 -0
- package/templates/contextkit/tools/scripts/dashboard-server.mjs +129 -0
- package/templates/contextkit/tools/scripts/dashboard.mjs +107 -0
- package/templates/contextkit/tools/scripts/deep-analysis.mjs +62 -0
- package/templates/contextkit/tools/scripts/deps-audit.mjs +201 -0
- package/templates/contextkit/tools/scripts/detect-stack.mjs +164 -0
- package/templates/contextkit/tools/scripts/distill-detect.mjs +90 -0
- package/templates/contextkit/tools/scripts/doctor.mjs +165 -0
- package/templates/contextkit/tools/scripts/fleet.mjs +170 -0
- package/templates/contextkit/tools/scripts/generate-context.mjs +142 -0
- package/templates/contextkit/tools/scripts/gh-alerts.mjs +117 -0
- package/templates/contextkit/tools/scripts/git.mjs +97 -0
- package/templates/contextkit/tools/scripts/home.mjs +106 -0
- package/templates/contextkit/tools/scripts/mark-simulation.mjs +78 -0
- package/templates/contextkit/tools/scripts/media-gen.mjs +154 -0
- package/templates/contextkit/tools/scripts/pipeline-board.mjs +74 -0
- package/templates/contextkit/tools/scripts/pipeline-prioritize.mjs +68 -0
- package/templates/contextkit/tools/scripts/pipeline-session.mjs +99 -0
- package/templates/contextkit/tools/scripts/pipeline-validate.mjs +136 -0
- package/templates/contextkit/tools/scripts/pipeline.mjs +302 -0
- package/templates/contextkit/tools/scripts/playbook.mjs +123 -0
- package/templates/contextkit/tools/scripts/predictions-review.mjs +113 -0
- package/templates/contextkit/tools/scripts/release.mjs +60 -0
- package/templates/contextkit/tools/scripts/resume.mjs +114 -0
- package/templates/contextkit/tools/scripts/roadmap.mjs +86 -0
- package/templates/contextkit/tools/scripts/runs.mjs +116 -0
- package/templates/contextkit/tools/scripts/seo-audit.mjs +150 -0
- package/templates/contextkit/tools/scripts/session-digest.mjs +89 -0
- package/templates/contextkit/tools/scripts/session-reindex.mjs +91 -0
- package/templates/contextkit/tools/scripts/setup-complete.mjs +69 -0
- package/templates/contextkit/tools/scripts/squad-meta.mjs +23 -0
- package/templates/contextkit/tools/scripts/squad-pipeline-condition.mjs +192 -0
- package/templates/contextkit/tools/scripts/squad-pipeline.mjs +301 -0
- package/templates/contextkit/tools/scripts/squad.mjs +80 -0
- package/templates/contextkit/tools/scripts/stats.mjs +138 -0
- package/templates/contextkit/tools/scripts/sync-check.mjs +235 -0
- package/templates/contextkit/tools/scripts/tech-debt-detectors.mjs +76 -0
- package/templates/contextkit/tools/scripts/tech-debt-scan.mjs +164 -0
- package/templates/contextkit/tools/scripts/token-report.mjs +153 -0
- package/templates/contextkit/tools/scripts/visual-test.mjs +132 -0
- package/templates/contextkit/tools/scripts/watch.mjs +106 -0
- package/templates/contextkit/tools/scripts/workflow.mjs +136 -0
- package/templates/contextkit/tools/scripts/workspace-sync.mjs +220 -0
- package/templates/contextkit/tools/scripts/worktree-new.mjs +50 -0
- package/templates/contextkit/workflows/L1-static-loading.md +59 -0
- package/templates/contextkit/workflows/L2-session-ledger.md +86 -0
- package/templates/contextkit/workflows/L3-multi-session.md +80 -0
- package/templates/contextkit/workflows/L4-squads.md +68 -0
- package/templates/contextkit/workflows/L5-proactive.md +88 -0
- package/templates/contextkit/workflows/README.md +47 -0
- package/templates/contextkit/workflows/playbooks/distillation-cycle.md +74 -0
- package/templates/contextkit/workflows/playbooks/landing-page.md +197 -0
- package/templates/contextkit/workflows/playbooks/security-batch.md +68 -0
- package/templates/contextkit/workflows/playbooks/seo-aiso.md +288 -0
- package/templates/contextkit/workflows/playbooks/simulate-impact.md +83 -0
- package/templates/contextkit/workflows/playbooks/tanstack.md +164 -0
- package/templates/contextkit/workflows/playbooks/tech-debt-sweep.md +77 -0
- package/templates/docs/CHANGELOG.md.tpl +11 -0
- package/templates/gitattributes +3 -0
- package/templates/github/ISSUE_TEMPLATE/bug_report.md +30 -0
- package/templates/github/ISSUE_TEMPLATE/feature_request.md +22 -0
- package/templates/github/PULL_REQUEST_TEMPLATE.md +27 -0
- package/templates/github/dependabot.yml +27 -0
- package/templates/github/workflows/quality.yml +36 -0
- package/templates/github/workflows/security.yml +54 -0
- package/tools/install/cli.mjs +62 -0
- package/tools/install/fs.mjs +56 -0
- package/tools/install/git.mjs +114 -0
- package/tools/install/project.mjs +51 -0
- package/tools/install/uninstall.mjs +54 -0
- package/tools/integration-test-compozy.mjs +88 -0
- package/tools/integration-test-guards.mjs +269 -0
- package/tools/integration-test-tooling-agent-forge.mjs +189 -0
- package/tools/integration-test-tooling-pipeline.mjs +164 -0
- package/tools/integration-test-tooling.mjs +172 -0
- package/tools/integration-test.mjs +228 -0
- package/tools/it-helpers.mjs +60 -0
- package/tools/selfcheck-agent-forge-ops.mjs +107 -0
- package/tools/selfcheck-agent-forge.mjs +304 -0
- package/tools/selfcheck-config.mjs +80 -0
- package/tools/selfcheck-runtime.mjs +135 -0
- package/tools/selfcheck-source.mjs +326 -0
- package/tools/selfcheck.mjs +268 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical state.json substrate ([ADR-0015](../../memory/decisions/0015-pipeline-dsl-working-stage-and-multi-session-work-claims.md) Part C).
|
|
3
|
+
*
|
|
4
|
+
* One schema, two kinds of in-flight items:
|
|
5
|
+
* - `kind: 'task'` β a DevPipeline task currently in `working/`
|
|
6
|
+
* - `kind: 'pipeline-run'` β a single execution of a squad's `pipeline.yaml`
|
|
7
|
+
*
|
|
8
|
+
* Storage: one file per item under `contextkit/pipeline/<id>/state.json` (the
|
|
9
|
+
* pipeline directory is single-sourced via `paths.mjs`). Defensive everywhere
|
|
10
|
+
* β corrupt or missing JSON returns `null`, not throws.
|
|
11
|
+
*
|
|
12
|
+
* Schema (canonical):
|
|
13
|
+
* {
|
|
14
|
+
* kind: 'task' | 'pipeline-run',
|
|
15
|
+
* id: string,
|
|
16
|
+
* status: 'backlog'|'working'|'testing'|'done'|'running'|'blocked-on-checkpoint'|'failed',
|
|
17
|
+
* ownerSessionId: string|null,
|
|
18
|
+
* ownerUser: string|null,
|
|
19
|
+
* branch: string|null,
|
|
20
|
+
* step: { current: string, total: number } | null, // pipeline-run only
|
|
21
|
+
* startedAt: number,
|
|
22
|
+
* lastHeartbeat: number,
|
|
23
|
+
* endedAt: number|null,
|
|
24
|
+
* cycles: Record<string, number> // pipeline-run only
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* Zero-dep, pure ESM over `node:*`. The hot path may import this β it never
|
|
28
|
+
* pulls in the optional `yaml` dep.
|
|
29
|
+
*/
|
|
30
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, unlinkSync } from 'node:fs';
|
|
31
|
+
import { dirname, resolve } from 'node:path';
|
|
32
|
+
import { writeFileAtomicSync } from '../hooks/safe-io.mjs';
|
|
33
|
+
|
|
34
|
+
const VALID_KINDS = new Set(['task', 'pipeline-run']);
|
|
35
|
+
const VALID_STATUSES = new Set(['backlog', 'working', 'testing', 'done', 'running', 'blocked-on-checkpoint', 'failed']);
|
|
36
|
+
let warnedOnce = false;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @param {string} pipeDir β repo-relative pipeline root (single-sourced from paths.mjs)
|
|
40
|
+
* @param {string} id
|
|
41
|
+
*/
|
|
42
|
+
function fileFor(pipeDir, id) {
|
|
43
|
+
return resolve(pipeDir, String(id), 'state.json');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Reads a state file. Returns `null` when missing OR corrupt β never throws.
|
|
48
|
+
* On the FIRST corruption per process, logs a single line so the maintainer
|
|
49
|
+
* sees it; subsequent corruptions are silent.
|
|
50
|
+
*
|
|
51
|
+
* @param {string} pipeDir
|
|
52
|
+
* @param {string} id
|
|
53
|
+
* @returns {object | null}
|
|
54
|
+
*/
|
|
55
|
+
export function readState(pipeDir, id) {
|
|
56
|
+
const file = fileFor(pipeDir, id);
|
|
57
|
+
if (!existsSync(file)) return null;
|
|
58
|
+
try {
|
|
59
|
+
const raw = readFileSync(file, 'utf-8').replace(/^ο»Ώ/, '');
|
|
60
|
+
const parsed = JSON.parse(raw);
|
|
61
|
+
return normalize(parsed);
|
|
62
|
+
} catch {
|
|
63
|
+
if (!warnedOnce) {
|
|
64
|
+
process.stderr.write(`[state-io] corrupt or unreadable: ${file}\n`);
|
|
65
|
+
warnedOnce = true;
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Writes/updates a state file with a partial payload β fields not present in
|
|
73
|
+
* `patch` are preserved from the existing file. Validates `kind` + `status`;
|
|
74
|
+
* malformed inputs throw (state.json is owned by the kit, garbage in is a bug).
|
|
75
|
+
*
|
|
76
|
+
* Atomic via `writeFileAtomicSync` (tmp + rename).
|
|
77
|
+
*
|
|
78
|
+
* @param {string} pipeDir
|
|
79
|
+
* @param {string} id
|
|
80
|
+
* @param {object} patch
|
|
81
|
+
* @returns {object} the merged record
|
|
82
|
+
*/
|
|
83
|
+
export function writeState(pipeDir, id, patch) {
|
|
84
|
+
if (!patch || typeof patch !== 'object') throw new Error('writeState: patch must be an object');
|
|
85
|
+
const previous = readState(pipeDir, id) || {};
|
|
86
|
+
const merged = { ...previous, ...patch, id: String(id) };
|
|
87
|
+
if (merged.kind != null && !VALID_KINDS.has(merged.kind)) throw new Error(`writeState: invalid kind "${merged.kind}"`);
|
|
88
|
+
if (merged.status != null && !VALID_STATUSES.has(merged.status)) throw new Error(`writeState: invalid status "${merged.status}"`);
|
|
89
|
+
if (typeof merged.startedAt !== 'number') merged.startedAt = Date.now();
|
|
90
|
+
merged.lastHeartbeat = typeof patch.lastHeartbeat === 'number' ? patch.lastHeartbeat : Date.now();
|
|
91
|
+
const file = fileFor(pipeDir, id);
|
|
92
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
93
|
+
writeFileAtomicSync(file, JSON.stringify(merged, null, 2));
|
|
94
|
+
return merged;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Lists every state file under `pipeDir/<id>/state.json`. Optional `{ kind }`
|
|
99
|
+
* filter and `{ sinceMs }` cutoff (returns only states whose `startedAt` >=
|
|
100
|
+
* the cutoff). Sorted by `startedAt` descending (newest first).
|
|
101
|
+
*
|
|
102
|
+
* @param {string} pipeDir
|
|
103
|
+
* @param {{ kind?: 'task'|'pipeline-run', sinceMs?: number }} [opts]
|
|
104
|
+
* @returns {object[]}
|
|
105
|
+
*/
|
|
106
|
+
export function listStates(pipeDir, opts = {}) {
|
|
107
|
+
if (!existsSync(pipeDir)) return [];
|
|
108
|
+
const states = [];
|
|
109
|
+
let entries;
|
|
110
|
+
try {
|
|
111
|
+
entries = readdirSync(pipeDir, { withFileTypes: true });
|
|
112
|
+
} catch {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
for (const ent of entries) {
|
|
116
|
+
if (!ent.isDirectory()) continue;
|
|
117
|
+
const state = readState(pipeDir, ent.name);
|
|
118
|
+
if (!state) continue;
|
|
119
|
+
if (opts.kind && state.kind !== opts.kind) continue;
|
|
120
|
+
if (opts.sinceMs && (state.startedAt || 0) < opts.sinceMs) continue;
|
|
121
|
+
states.push(state);
|
|
122
|
+
}
|
|
123
|
+
states.sort((a, b) => (b.startedAt || 0) - (a.startedAt || 0));
|
|
124
|
+
return states;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Removes state files whose `endedAt` is older than `olderThanDays` ago. Live
|
|
129
|
+
* states (no `endedAt`) are never pruned. Returns the count removed.
|
|
130
|
+
*
|
|
131
|
+
* @param {string} pipeDir
|
|
132
|
+
* @param {{ olderThanDays: number }} opts
|
|
133
|
+
* @returns {number}
|
|
134
|
+
*/
|
|
135
|
+
export function prune(pipeDir, { olderThanDays }) {
|
|
136
|
+
if (!Number.isFinite(olderThanDays) || olderThanDays <= 0) return 0;
|
|
137
|
+
const cutoff = Date.now() - olderThanDays * 24 * 60 * 60 * 1000;
|
|
138
|
+
let removed = 0;
|
|
139
|
+
for (const state of listStates(pipeDir)) {
|
|
140
|
+
if (typeof state.endedAt !== 'number' || state.endedAt > cutoff) continue;
|
|
141
|
+
const file = fileFor(pipeDir, state.id);
|
|
142
|
+
try {
|
|
143
|
+
if (existsSync(file)) { unlinkSync(file); removed += 1; }
|
|
144
|
+
} catch { /* best-effort */ }
|
|
145
|
+
}
|
|
146
|
+
return removed;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Coerces a parsed record into the canonical shape with safe defaults. Unknown
|
|
151
|
+
* fields are dropped; missing required fields get sensible defaults so a
|
|
152
|
+
* partially-written record still parses.
|
|
153
|
+
*
|
|
154
|
+
* @param {object} obj
|
|
155
|
+
* @returns {object}
|
|
156
|
+
*/
|
|
157
|
+
function normalize(obj) {
|
|
158
|
+
const safe = obj && typeof obj === 'object' ? obj : {};
|
|
159
|
+
return {
|
|
160
|
+
kind: VALID_KINDS.has(safe.kind) ? safe.kind : 'task',
|
|
161
|
+
id: typeof safe.id === 'string' ? safe.id : String(safe.id ?? ''),
|
|
162
|
+
status: VALID_STATUSES.has(safe.status) ? safe.status : 'backlog',
|
|
163
|
+
ownerSessionId: typeof safe.ownerSessionId === 'string' ? safe.ownerSessionId : null,
|
|
164
|
+
ownerUser: typeof safe.ownerUser === 'string' ? safe.ownerUser : null,
|
|
165
|
+
branch: typeof safe.branch === 'string' ? safe.branch : null,
|
|
166
|
+
step: safe.step && typeof safe.step === 'object' ? safe.step : null,
|
|
167
|
+
startedAt: typeof safe.startedAt === 'number' ? safe.startedAt : 0,
|
|
168
|
+
lastHeartbeat: typeof safe.lastHeartbeat === 'number' ? safe.lastHeartbeat : 0,
|
|
169
|
+
endedAt: typeof safe.endedAt === 'number' ? safe.endedAt : null,
|
|
170
|
+
cycles: safe.cycles && typeof safe.cycles === 'object' ? safe.cycles : {},
|
|
171
|
+
};
|
|
172
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Status-line widget for Claude Code (wired as `settings.statusLine` at level >= 1).
|
|
4
|
+
*
|
|
5
|
+
* Prints ONE compact line about the ContextDevKit state of the current project:
|
|
6
|
+
* π L6 Β· 11 sess Β· 5 ADR Β· 2 bklog
|
|
7
|
+
*
|
|
8
|
+
* It runs on every prompt, so it stays cheap (a few directory counts + one config
|
|
9
|
+
* read) and zero-dependency. It NEVER throws β on any error it prints a minimal
|
|
10
|
+
* fallback so the status line can't break the session. Claude Code pipes session
|
|
11
|
+
* JSON on stdin; we don't need it (we read the project at `process.cwd()`).
|
|
12
|
+
*/
|
|
13
|
+
import { existsSync, readdirSync } from 'node:fs';
|
|
14
|
+
import { resolve } from 'node:path';
|
|
15
|
+
import { pathsFor } from './config/paths.mjs';
|
|
16
|
+
import { readJsonSafe } from './hooks/safe-io.mjs';
|
|
17
|
+
|
|
18
|
+
const ROOT = process.cwd();
|
|
19
|
+
const P = pathsFor(ROOT);
|
|
20
|
+
|
|
21
|
+
function count(dir, re) {
|
|
22
|
+
try {
|
|
23
|
+
return readdirSync(resolve(ROOT, dir)).filter((f) => re.test(f)).length;
|
|
24
|
+
} catch {
|
|
25
|
+
return 0;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function level() {
|
|
30
|
+
const lvl = Number(readJsonSafe(P.config, {}).level);
|
|
31
|
+
return Number.isInteger(lvl) ? lvl : null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function main() {
|
|
35
|
+
try {
|
|
36
|
+
if (!existsSync(P.platform)) {
|
|
37
|
+
process.stdout.write('π contextdevkit');
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const lvl = level();
|
|
41
|
+
const sess = count('contextkit/memory/sessions', /^\d{4}-\d{2}-\d{2}-\d{2,}-.+\.md$/);
|
|
42
|
+
const adrs = count('contextkit/memory/decisions', /^\d{4}-.+\.md$/);
|
|
43
|
+
const bklog = count('contextkit/pipeline/backlog', /\.md$/);
|
|
44
|
+
const parts = [lvl ? `L${lvl}` : null, `${sess} sess`, `${adrs} ADR`, `${bklog} bklog`].filter(Boolean);
|
|
45
|
+
process.stdout.write(`π ${parts.join(' Β· ')}`);
|
|
46
|
+
} catch {
|
|
47
|
+
process.stdout.write('π contextdevkit');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
main();
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Squads β how the sub-agents are organized
|
|
2
|
+
|
|
3
|
+
> The sub-agents in `.claude/agents/` (installed at **Level 4**) aren't a loose
|
|
4
|
+
> pile β they're organized into **squads** with distinct jobs, and a coordination
|
|
5
|
+
> rule for when they disagree. This is the roster + the rules. Manage it with
|
|
6
|
+
> `/squad`. Enable the squads relevant to your project; ignore the rest.
|
|
7
|
+
|
|
8
|
+
## The squads
|
|
9
|
+
|
|
10
|
+
### π οΈ devteam β constructive (builds + reviews)
|
|
11
|
+
Ships code and guards the constitution. Members:
|
|
12
|
+
|
|
13
|
+
| Agent | When to use |
|
|
14
|
+
| --- | --- |
|
|
15
|
+
| `architect` | Cross-cutting design, choosing a pattern, planning a migration β *before* code |
|
|
16
|
+
| `code-reviewer` | Pre-merge audit against `CLAUDE.md` (style, structure, SRP, immutable rules) |
|
|
17
|
+
| `context-keeper` | The platform itself: ADRs, sessions, glossary, hooks, commands, memory |
|
|
18
|
+
| `security` | Auth, secrets, crypto, trust boundaries, dependency risk, security review |
|
|
19
|
+
| `test-engineer` | Test strategy + writing tests, raising coverage, regression for a bug |
|
|
20
|
+
| _(add yours)_ | Domain agents you scaffold: `backend`, `frontend`, `db`, β¦ (from `_TEMPLATE.md`) |
|
|
21
|
+
|
|
22
|
+
### π§ͺ qa-team β adversarial (verifies behaviour under stress)
|
|
23
|
+
A red team with a different epistemic axis: it audits *behaviour*, not style.
|
|
24
|
+
Single entry point is the orchestrator.
|
|
25
|
+
|
|
26
|
+
| Agent | Tier | When to use |
|
|
27
|
+
| --- | --- | --- |
|
|
28
|
+
| `qa-orchestrator` | 1 | The router + sign-off. `/test-plan`, `/scaffold-tests`, `/qa-signoff` |
|
|
29
|
+
| `qa-unit` | 1 | Fast isolated unit tests (mocked deps) |
|
|
30
|
+
| `qa-integration` | 1 | Cross-boundary tests (HTTP/DB/queue/fs) |
|
|
31
|
+
| `qa-fuzzer` | 1 | Property-based / adversarial input on parsers, validators, auth |
|
|
32
|
+
| `qa-perf` | 2 | Benchmarks/profiling once a hot path is identified |
|
|
33
|
+
| `qa-e2e` | 2 | Critical user journeys through the real UI |
|
|
34
|
+
|
|
35
|
+
### π security-team β security & infra (DevSecOps)
|
|
36
|
+
The system's safety net: application security **and** the infrastructure and
|
|
37
|
+
supply chain it runs on. Enable on any project that ships to real users (i.e.
|
|
38
|
+
almost all). Owns the security best-practices bar and the dependency policy.
|
|
39
|
+
|
|
40
|
+
| Agent | When to use |
|
|
41
|
+
| --- | --- |
|
|
42
|
+
| `security` | AppSec **lead**: auth, secrets, crypto, input/trust boundaries, threat modeling, security review; owns the security bar + dependency policy |
|
|
43
|
+
| `code-security` | The **code's** external surface: third-party integration code (API clients/SDKs, webhooks, (de)serialization), dependency provenance/SBOM + **license policy**, SAST/CodeQL triage |
|
|
44
|
+
| `infra-security` | The **platform's** threat model: IaC/cloud misconfig, IAM least-privilege, network exposure, secrets management, container/runtime + CI/CD supply-chain hardening |
|
|
45
|
+
| `devops` | Infra & **delivery**: CI/CD, build/deploy, environments, secrets plumbing, observability, release safety β *builds what `infra-security` audits* |
|
|
46
|
+
| _(add yours)_ | `sre` (reliability/incident), `iac` (policy-as-code) as the system grows |
|
|
47
|
+
|
|
48
|
+
`security` and `devops` are **shared** with devteam/ops-team β security is a
|
|
49
|
+
cross-cutting concern, not a silo. On a Critical/High finding, security-team can
|
|
50
|
+
**block a release** (veto on the L5/L6 gates for high-risk paths).
|
|
51
|
+
|
|
52
|
+
### βοΈ compliance-team β data protection & law
|
|
53
|
+
Enable when the product handles personal data (especially of Brazilian residents).
|
|
54
|
+
|
|
55
|
+
| Agent | When to use |
|
|
56
|
+
| --- | --- |
|
|
57
|
+
| `privacy-lgpd` | LGPD (Lei 13.709/2018): legal basis, consent, data-subject rights (Art. 18), retention/deletion, DPO, incidents/ANPD, processors. Standardized Brazilian-law skills. |
|
|
58
|
+
| _(add yours)_ | `gdpr`, `soc2`, `hipaa`, `accessibility-law` β¦ per your jurisdiction/market |
|
|
59
|
+
|
|
60
|
+
### π¨ design-team β UI/UX
|
|
61
|
+
Enable when the product has a user interface.
|
|
62
|
+
|
|
63
|
+
| Agent | When to use |
|
|
64
|
+
| --- | --- |
|
|
65
|
+
| `ux-designer` | Flows, information architecture, interaction, usability (incl. empty/error states) |
|
|
66
|
+
| `ui-designer` | Visual design + design system/tokens, layout, responsive behaviour |
|
|
67
|
+
| `accessibility` | WCAG 2.1 AA: semantics, keyboard, screen readers, contrast, focus |
|
|
68
|
+
|
|
69
|
+
### π growth-team β acquisition β activation β retention
|
|
70
|
+
Enable when the product needs users to find it, reach value, and come back. Owns
|
|
71
|
+
the `/advise` **growth** lane (ADR-0028).
|
|
72
|
+
|
|
73
|
+
| Agent | When to use |
|
|
74
|
+
| --- | --- |
|
|
75
|
+
| `growth` | **Lead.** Activation, funnels, growth loops, referral/revenue, experimentation, instrumentation. Audit-first; refuses dark patterns |
|
|
76
|
+
| `retention` | Cohort retention, churn (voluntary + involuntary), engagement loops, habit formation, lifecycle messaging, resurrection |
|
|
77
|
+
| `seo-specialist` | Acquisition / discoverability (Google + LLM answer engines) β **shared** with design-team |
|
|
78
|
+
|
|
79
|
+
`seo-specialist` is **shared** (it owns the page being indexable); `growth` and
|
|
80
|
+
`retention` own what happens after the click β first value, then staying.
|
|
81
|
+
|
|
82
|
+
### π product-team & βοΈ ops-team (starters included)
|
|
83
|
+
| Agent | Squad | When to use |
|
|
84
|
+
| --- | --- | --- |
|
|
85
|
+
| `product-owner` | product-team | Roadmap shaping, prioritization, requirements (stories + acceptance criteria) |
|
|
86
|
+
| `devops` | ops-team | CI/CD, build/deploy, environments, secrets, observability, release safety |
|
|
87
|
+
|
|
88
|
+
## Sovereignty (who decides when they conflict)
|
|
89
|
+
|
|
90
|
+
- **`code-reviewer` (devteam)** owns **style + the constitution** (ADR-0008-style).
|
|
91
|
+
- **`qa-orchestrator` (qa-team)** owns **behaviour + test sign-off**.
|
|
92
|
+
- **`security` (security-team)** owns **the security bar** β it can block a
|
|
93
|
+
release on a Critical/High finding, regardless of the other squads.
|
|
94
|
+
- On conflict, **devteam decides** until the project reaches a maturity milestone
|
|
95
|
+
you define β then quality gates can harden (see `/context-level`, the L5/L6 gates).
|
|
96
|
+
|
|
97
|
+
## Growing a squad
|
|
98
|
+
|
|
99
|
+
- **Add an agent** β copy `.claude/agents/_TEMPLATE.md`, give it a sharp
|
|
100
|
+
`description` (that's how routing works), and list it here under its squad.
|
|
101
|
+
- **Rich briefing (two-tier, optional)** β a lean agent in `.claude/agents/` +
|
|
102
|
+
a deep briefing in `contextkit/squads/<squad>/<agent>.md` (from `_BRIEFING.md.tpl`)
|
|
103
|
+
for full anti-patterns and recipes. Use `/squad brief <agent>`.
|
|
104
|
+
- **New squad** β add a section here under the same convention.
|
|
105
|
+
Use `/squad new-squad <name>`.
|
|
106
|
+
|
|
107
|
+
### More squads worth adding (templates / suggestions)
|
|
108
|
+
Scaffold any of these with `/squad new-squad <name>` when the project needs it:
|
|
109
|
+
- **docs-team** β `tech-writer` (READMEs, API docs, ADR prose, changelog clarity).
|
|
110
|
+
- **data-team** β `data-engineer` / `analytics` (schemas, pipelines, event tracking).
|
|
111
|
+
- **support-team** β `support-engineer` (triage, repro, runbooks from incidents).
|
|
112
|
+
- jurisdiction add-ons for compliance-team β `gdpr`, `hipaa`, `soc2`.
|
|
113
|
+
|
|
114
|
+
The orchestration commands (`/ship`, `/test-plan`, `/scaffold-tests`,
|
|
115
|
+
`/qa-signoff`) fan work out to these squads.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# {{AGENT}} β rich briefing ({{SQUAD}} squad)
|
|
2
|
+
|
|
3
|
+
> Optional **tier-2** briefing for the lean agent in `.claude/agents/{{AGENT}}.md`.
|
|
4
|
+
> The lean file is the executable router (frontmatter + a tight prompt); THIS is
|
|
5
|
+
> the deep reference β full anti-patterns, end-to-end recipes, edge cases β that
|
|
6
|
+
> the agent reads when it needs more than the headline rules.
|
|
7
|
+
> Created via `/squad brief {{AGENT}}`.
|
|
8
|
+
|
|
9
|
+
## Mandate
|
|
10
|
+
<!-- One paragraph: exactly what this agent owns and what it refuses. -->
|
|
11
|
+
|
|
12
|
+
## Mental model
|
|
13
|
+
<!-- The diagram / invariants the agent treats as hard rules. -->
|
|
14
|
+
|
|
15
|
+
## Anti-patterns (full catalogue)
|
|
16
|
+
| Symptom | Why it's wrong | Fix |
|
|
17
|
+
| --- | --- | --- |
|
|
18
|
+
| | | |
|
|
19
|
+
|
|
20
|
+
## End-to-end recipes
|
|
21
|
+
<!-- The canonical step-by-step for the 1β3 tasks this agent does most. -->
|
|
22
|
+
|
|
23
|
+
## Edge cases & traps
|
|
24
|
+
<!-- The stack-/domain-specific gotchas worth writing down. -->
|
|
25
|
+
|
|
26
|
+
## Hand-offs
|
|
27
|
+
<!-- When to delegate to another squad member, and to whom. -->
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# agent-forge β the agent factory squad
|
|
2
|
+
|
|
3
|
+
> A **factory** squad: unlike the internal squads (devteam, qa-team, β¦) whose
|
|
4
|
+
> client is *the developer inside Claude Code*, agent-forge produces an artifact
|
|
5
|
+
> that ships **out** β a portable, multi-provider **Agent Package** consumed by a
|
|
6
|
+
> client project's production runtime. Approved + scoped by
|
|
7
|
+
> [ADR-0012](../../memory/decisions/0012-agent-forge-squad-for-portable-agent-packages.md).
|
|
8
|
+
> Read [`best-practices.md`](best-practices.md) before forging.
|
|
9
|
+
|
|
10
|
+
## What it produces
|
|
11
|
+
|
|
12
|
+
The **Agent Package (APF)** β a versioned, self-contained folder under the client
|
|
13
|
+
project's `agent-packages/<name>@<semver>/` with: a single source-of-truth
|
|
14
|
+
`manifest.yaml`, per-provider prompts, canonical tool schemas + provider adapters,
|
|
15
|
+
optional RAG config, an eval harness (golden + red-team), three governance policies
|
|
16
|
+
(cost Β· compliance Β· quality), and optional runtime adapters (Node/Python/β¦).
|
|
17
|
+
|
|
18
|
+
**The output has zero dependency on ContextDevKit, Node, or any runtime at consume
|
|
19
|
+
time.** The forge runs here; the package runs anywhere. (ADR-0012, constraint 1β2.)
|
|
20
|
+
|
|
21
|
+
## The boundary (why this squad is different)
|
|
22
|
+
|
|
23
|
+
| Internal squad (devteam/qa-team/β¦) | agent-forge (factory) |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| Client = the developer, in Claude Code | Client = the client's product, in production |
|
|
26
|
+
| Output = edits / reviews / tests in this repo | Output = a portable Agent Package |
|
|
27
|
+
| Provider = Claude | Provider = Claude Β· OpenAI Β· Gemini Β· DeepSeek Β· self-hosted |
|
|
28
|
+
|
|
29
|
+
## Roster (delivered across phases β see backlog 030β035)
|
|
30
|
+
|
|
31
|
+
> Membership follows the kit convention β **no `squad.manifest.json`**. Each agent is
|
|
32
|
+
> a lean file in `.claude/agents/<name>.md` tagged `(agent-forge squad)` (detected by
|
|
33
|
+
> `squadOf`), with an optional tier-2 briefing here in `squads/agent-forge/`.
|
|
34
|
+
|
|
35
|
+
| Agent | Role | Phase |
|
|
36
|
+
| --- | --- | --- |
|
|
37
|
+
| `forge-orchestrator` | Runs the pipeline (architect β router β prompt+tool+rag β eval β governance β packager) | Fase 1 |
|
|
38
|
+
| `agent-architect` | Interviews the dev β produces the Agent Blueprint (YAML) | Fase 1 |
|
|
39
|
+
| `model-router` | Picks provider/model from the capability matrix + decision rules; writes the rationale | Fase 1 |
|
|
40
|
+
| `prompt-engineer` | System prompt per provider (XML for Claude, few-shot for Gemini, CoT for DeepSeekβ¦) | Fase 1β2 |
|
|
41
|
+
| `tool-designer` | Canonical JSON Schema β per-provider tool/function adapters | Fase 1β2 |
|
|
42
|
+
| `eval-designer` | Golden dataset + red-team cases + rubric + thresholds | Fase 3 |
|
|
43
|
+
| `governance-officer` | Attaches the three policies + fallback chain + kill switch + audit schema | Fase 3 |
|
|
44
|
+
| `rag-designer` | *(opt)* chunking, embeddings, index, reranker β only if the blueprint needs retrieval | Fase 5 |
|
|
45
|
+
| `packager` | Assembles the APF, versions it (semver + provenance), generates runtime adapters | Fase 1 |
|
|
46
|
+
|
|
47
|
+
## The five principles (full text in `best-practices.md`)
|
|
48
|
+
|
|
49
|
+
1. **Portability absolute** β the APF depends on nothing of ours at runtime.
|
|
50
|
+
2. **Provider-agnostic manifest, provider-specific adapter** β switch provider = switch adapter.
|
|
51
|
+
3. **Economic choice is structured, not intuitive** β the router decides by matrix + rules; the LLM is only a tie-breaker.
|
|
52
|
+
4. **Best practices are the default, not a suggestion** β caching, fallback, retry, audit, kill switch, eval ship by default; removing one needs a reason.
|
|
53
|
+
5. **Eval before embarkation** β no package leaves the forge without passing a minimum golden + red-team gate.
|
|
54
|
+
|
|
55
|
+
## Where it sits in the levels
|
|
56
|
+
|
|
57
|
+
- **L4** β an optional squad; enable per project (e.g. `project_type: ai-product`).
|
|
58
|
+
- **L5** β edits under `agent-packages/` are a high-risk path β `/simulate-impact` applies (changing a primary model has wide blast radius).
|
|
59
|
+
- **L6** β `/context-stats` gains a Forge Stats section (agents in prod, aggregate cost, fallback rate, eval drift).
|
|
60
|
+
- **L7** β `/fleet` manages agent packages cross-repo (one agent serving many projects).
|
|
61
|
+
|
|
62
|
+
## Status
|
|
63
|
+
|
|
64
|
+
Fase 0 (foundations) β **complete**. This README, [`best-practices.md`](best-practices.md),
|
|
65
|
+
the [`router/capability-matrix.json`](router/capability-matrix.json) seed, and the
|
|
66
|
+
[`templates/agent-package/`](templates/agent-package/) APF v1 skeleton are in place. The
|
|
67
|
+
agents and the `/forge-*` commands land across Fases 1β5 β track them on the DevPipeline
|
|
68
|
+
(031β035). For the **section-by-section blueprint-coverage map** (the single artifact a
|
|
69
|
+
future session opens to know where we stand), read [`ROADMAP.md`](ROADMAP.md).
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# agent-forge β blueprint β status
|
|
2
|
+
|
|
3
|
+
> The single map between the original `agent-forge` blueprint and what is actually
|
|
4
|
+
> shipped here. Read this **first** when working on the squad β it spares you a
|
|
5
|
+
> spelunk through the ADRs, the backlog, and the source. Kept current as work moves.
|
|
6
|
+
>
|
|
7
|
+
> **Status key** (same as [`docs/ROADMAP.md`](../../../../docs/ROADMAP.md)):
|
|
8
|
+
> β
done Β· β³ in progress Β· π‘ partial Β· π planned Β· β dropped/superseded Β·
|
|
9
|
+
> π added by ADR (not in the original blueprint).
|
|
10
|
+
|
|
11
|
+
## Anchors
|
|
12
|
+
|
|
13
|
+
- **Approved by** [ADR-0012](../../memory/decisions/0012-agent-forge-squad-for-portable-agent-packages.md) β 7 binding constraints reshape the blueprint where it collided with the kit.
|
|
14
|
+
- **YAML strategy** [ADR-0013](../../memory/decisions/0013-agent-forge-yaml-via-optional-dynamic-import.md) β optional `yaml` behind dynamic import (the `zod` precedent).
|
|
15
|
+
- **Declarative pipeline DSL** [ADR-0015](../../memory/decisions/0015-pipeline-dsl-working-stage-and-multi-session-work-claims.md) β `pipeline.yaml` per squad; engine is opt-in, dry-runnable, simulate-impact-mappable. First consumer is this squad (Fase 6).
|
|
16
|
+
- **Phased delivery** on the DevPipeline as tasks **030β035** (Fases 0β5 β all β
) + **Fase 6** (declarative pipeline DSL β β
, shipped on `feat/agent-forge-fase6-pipeline-dsl`).
|
|
17
|
+
|
|
18
|
+
## Coverage map (blueprint section β here)
|
|
19
|
+
|
|
20
|
+
| Β§ | Blueprint | Status | Where / next |
|
|
21
|
+
|---|---|---|---|
|
|
22
|
+
| 0β1 | Exec summary + 5 principles | β
| [`README.md`](README.md), [`best-practices.md`](best-practices.md) |
|
|
23
|
+
| 2 | `squad.manifest.json` | β | Dropped by ADR-0012 Β§3 β squads detected by `squadOf` (the `(agent-forge squad)` tag) |
|
|
24
|
+
| 2 | Squad folder + roster table | β
| [`README.md`](README.md) β agents listed by phase |
|
|
25
|
+
| 2 | The 9 lean agent files (`.claude/agents/forge-*.md`) | β
| Fase 1: `forge-orchestrator` / `agent-architect` / `model-router` / `prompt-engineer` / `tool-designer` / `packager`. Fase 3: `eval-designer` + `governance-officer`. Fase 5: `rag-designer`. |
|
|
26
|
+
| 2 | `templates/providers/<provider>/` reusable snippets | π‘ | Per-provider stubs currently live **inside** the APF (`prompts/system.<provider>.md` + `tools/adapters/<provider>.tools.json`). Split out only if Fase 1β2 generators need shared snippets above APF scope. |
|
|
27
|
+
| 2 | `policies/*.template.yaml` (squad scope) | π‘ | The canonical policy templates ship **inside** the APF (`agent-package/governance/*.policy.yaml`). Equivalent for now; split if Fase 3's governance-officer needs squad-level partials. |
|
|
28
|
+
| 3 | APF v1 β full tree (45 files) | β
| [`templates/agent-package/`](templates/agent-package/) (commit `d5efcd2`) |
|
|
29
|
+
| 4.1 | Router inputs | β
| Documented (best-practices Β§4 / blueprint Β§4.1) β consumed in Fase 1 |
|
|
30
|
+
| 4.2 | `capability-matrix.json` | β
| [`router/capability-matrix.json`](router/capability-matrix.json) (5 providers / 11 models, dated, ADR-gated, parse/id guard β commit `3ad928a`) |
|
|
31
|
+
| 4.3 | `decision-rules.json` | β
| [`router/decision-rules.json`](router/decision-rules.json) β 13 rules (cap 15), shortlists only, no quality opinions (ADR-0012 Β§5). Engine in [`lib/router.mjs`](lib/router.mjs). |
|
|
32
|
+
| 4.4 | Rationale section in package README | β
slot + generator | The model-router emits the canonical `## Model Selection Rationale` block (rule trace + cross-provider fallback warning + eval-as-authority disclaimer) β `lib/router.mjs` `buildRationale`. |
|
|
33
|
+
| 5 | Per-provider behaviour notes | β
| `best-practices.md` Β§4 (condensed table) |
|
|
34
|
+
| 5 | `prompt-engineer` per-provider generators | β
| All 5 providers: Anthropic (XML, `cache=ephemeral`), OpenAI (Markdown), Google (`systemInstruction` body + safetySettings note), DeepSeek (OpenAI-compat + explicit CoT cue), Ollama (Markdown, chat_template applied by runtime). [`lib/prompt-gen.mjs`](lib/prompt-gen.mjs) |
|
|
35
|
+
| 5 | `tool-designer` per-provider generators | β
| All 5 providers: Anthropic (`name`/`description`/`input_schema`), OpenAI (`type:function`), Google (`functionDeclarations` SUBSET β `additionalProperties` + `$schema` stripped), DeepSeek + Ollama (OpenAI-compat shapes). [`lib/tool-gen.mjs`](lib/tool-gen.mjs) |
|
|
36
|
+
| 5 | Runtime `AgentRuntime` contract | β
| Documented in APF adapter READMEs + Node/Python/Go stubs |
|
|
37
|
+
| 6.1β6.3 | Cost / compliance / quality policy templates | β
| [`templates/agent-package/governance/`](templates/agent-package/governance/) |
|
|
38
|
+
| 6.x | `fallback-chain.yaml` + `audit.schema.json` | β
| Same dir |
|
|
39
|
+
| 6 | `governance-officer` ENFORCER ("refuse if any pillar under-configured") | β
| [`lib/governance-officer.mjs`](lib/governance-officer.mjs) β `attachGovernance` populates the 3 pillars from the blueprint + builds fallback chain from the router decision; `validateGovernance` refuses on missing sections or unresolved `{{TOKEN}}` placeholders. Briefing in [`.claude/agents/governance-officer.md`](../../../claude/agents/governance-officer.md). |
|
|
40
|
+
| 6.4 | Three-pillar equal-weight rationale | β
| `best-practices.md` Β§5 |
|
|
41
|
+
| 7.1β7.3 | Golden / red-team / rubric / thresholds | β
templates | [`templates/agent-package/evals/`](templates/agent-package/evals/) |
|
|
42
|
+
| 7.4 | Eval lifecycle (3 moments) | β
| `best-practices.md` Β§6 (docs); [`lib/eval-runner.mjs`](lib/eval-runner.mjs) `runEvalSuite` (golden + red-team aggregated against thresholds; provider-agnostic β mock for CI, real adapter for prod). |
|
|
43
|
+
| 7 | Eval gate in orchestrator (refuse to ship on fail) | β
| `forgeNew` supports `opts.runEval = { provider, semantic }`; `packageAgent` stamps `provenance.eval_passed_at` only when `evalResult.verdict === 'pass'`. The (β€3 retries β abort) refinement loop is the AGENT's job β driven by `.claude/agents/eval-designer.md`. |
|
|
44
|
+
| 8 | `/forge-new` | β
| [`templates/claude/commands/forge-new.md`](../../../claude/commands/forge-new.md) + CLI [`cli/forge-new.mjs`](cli/forge-new.mjs) (`forgeNew()` exported for the integration test) |
|
|
45
|
+
| 8 | 13 maintenance `/forge-*` commands | β
| `cli/forge-ops.mjs` (list/show/doctor/policy/budget/audit) + `cli/forge-eval-cli.mjs` (eval/redteam/route/fallback-test) + `cli/forge-admin.mjs` (refresh-matrix/killswitch/deprecate, dry-run by default). 13 thin briefings under `templates/claude/commands/forge-*.md`. |
|
|
46
|
+
| 9 | Full lifecycle (forge β review β install β prod β maintain) | β
| Fase 1 engine + Fase 3 eval gate + Fase 4 maintenance commands all wired. The runtime adapter ships a `createShadowEval` scaffold (sample rate from `quality.policy.yaml.eval_gates.drift_monitoring.sample_pct`). |
|
|
47
|
+
| 10 | L4 enablement | β
| `README.md` "Where it sits in the levels" |
|
|
48
|
+
| 10 | L5 `simulate-impact` for `agent-packages/` edits | β
| `defaults.l5.highRiskPaths` includes `agent-packages/**` β the simulate-gate triggers on any forged-agent edit. Guarded by `checkL5ForgePath`. |
|
|
49
|
+
| 10 | L6 `/context-stats` Forge Stats section | β
| `stats.mjs` `collectForge()` walks `agent-packages/`; surfaces package count, eval-stamp ratio, aggregate monthly target + hard cap, distribution by primary provider. |
|
|
50
|
+
| 10 | L7 `/fleet` cross-repo agent-package registry | β
| `fleet.mjs cmdStats` aggregates per-repo Forge Stats β packages, eval-stamp ratio, monthly target + hard cap, surfaced both per-repo and as a fleet total. |
|
|
51
|
+
| 11 | Implementation roadmap (5 fases) | β
| Mapped 1:1 to backlog 030β035 with sequenced SLAs |
|
|
52
|
+
| 12 | Risks β matrix freshness | β
| ADR-0012 Β§6 + `checkCapabilityMatrix` |
|
|
53
|
+
| 12 | Risks β decision-rules Frankenstein | β
| Router enforces the 15-rule cap at runtime; currently 13/15. Split by intent category when outgrown. |
|
|
54
|
+
| 12 | Risks β golden eval staleness | π | Shadow eval feeding golden (Fase 4) |
|
|
55
|
+
| 12 | Risks β cross-project package divergence | β
| `/fleet stats` surfaces packages-per-repo + aggregate budget so divergence becomes visible across the fleet. |
|
|
56
|
+
| 12 | Risks β compliance vertical templates (HIPAA/PCI) | β v1 | Future jurisdiction add-ons via `compliance-team` squad |
|
|
57
|
+
| 12 | Risks β forge self-cost | β
planned | Orchestrator defaults to Haiku (set in agent files, Fase 1) |
|
|
58
|
+
| Ap A | forge vs classic squad table | β
| `README.md` "The boundary (why this squad is different)" |
|
|
59
|
+
| Ap B | Why a separate factory squad | β
| Same section |
|
|
60
|
+
| Ap C | Glossary | π low priority | Inline in best-practices for now; consolidate if it grows |
|
|
61
|
+
| β | **Fase 6 β declarative `pipeline.yaml` + dry-run engine** (ADR-0015 Β§A) | β
| [`pipeline.yaml`](pipeline.yaml) (9 steps) + engine [`templates/contextkit/tools/scripts/squad-pipeline.mjs`](../../tools/scripts/squad-pipeline.mjs) + whitelisted condition parser [`squad-pipeline-condition.mjs`](../../tools/scripts/squad-pipeline-condition.mjs). Parses via `lib/yaml.mjs` (ADR-0013); refuses on missing `yaml` with **exit 0 + informative** message (pipelines are opt-in, not hot-path). `--dry-run` walks the graph with empty ctx (markers `β / β / βΊ`). `max_review_cycles` is a hard cap; vendor model names are refused (router stays the single resolver). 8 new selfchecks (`checkConditionParser` + `checkSquadPipeline`) + 4 new integration asserts (ships, validates, yaml-absent path). Spec: [`docs/SQUAD-PIPELINE-FORMAT.md`](../../../../docs/SQUAD-PIPELINE-FORMAT.md). `state.json` per run is deferred to task 040 (ADR-0015 Β§C). |
|
|
62
|
+
|
|
63
|
+
## Net additions (ADR-driven, not in the original blueprint)
|
|
64
|
+
|
|
65
|
+
π **No `squad.manifest.json`** (ADR-0012 Β§3) β reuse the kit's `squadOf` detection.
|
|
66
|
+
π **No phantom `AI-AGENT-PRACTICES.md`** (ADR-0012 Β§4) β authored inline as `best-practices.md`.
|
|
67
|
+
π **Eval-as-authority** (ADR-0012 Β§5) β router rules are deterministic shortlists; the eval harness measured on the user's golden set decides.
|
|
68
|
+
π **Matrix-freshness guard** (ADR-0012 Β§6) β `checkCapabilityMatrix` rejects malformed / duplicate / disallowed model ids.
|
|
69
|
+
π **Hot-path zero-yaml** (ADR-0013) β `checkHotPathNoYaml` enforces rule 1.
|
|
70
|
+
π **`lib/yaml.mjs` loader** (ADR-0013) β the single touchpoint for the optional `yaml` dep.
|
|
71
|
+
π **`checkRouterEngine` selfcheck** (Fase 1) β behavioural guard: typical blueprint + no-cloud constraint both honored; rationale carries the eval-as-authority disclaimer.
|
|
72
|
+
π **Installer copies the squad at L>=4** (Fase 1 fix) β without this, agent-forge code lived only in source; selfcheck `checkSourceInvariants` guards the copy.
|
|
73
|
+
π **forge-new no-yaml fallback** (Fase 1) β integration test exercises the pure half of the pipeline (validate β route β assembleManifest β gens) so CI without the optional `yaml` dep still proves correctness end-to-end.
|
|
74
|
+
π **`runtime_adapters` is a first-class blueprint field** (Fase 2) β `enum-multi` over `[node, python, go]` with default `[node]`; `validateBlueprint` rejects unknown entries; `assembleManifest` reads it straight from the blueprint, so the manifest is no longer a packager-opts artifact.
|
|
75
|
+
π **Gemini subset enforced at generation time** (Fase 2) β `downConvertForGemini` strips `additionalProperties` / `$schema` / `$id` / `$ref` recursively so `functionDeclarations` is valid the moment it's written; the runtime adapter never has to remediate.
|
|
76
|
+
π **DeepSeek CoT cue baked into the prompt, not the runtime** (Fase 2) β `renderDeepSeek` prepends "Think step by stepβ¦" to Rules; the runtime contract stays uniform across providers.
|
|
77
|
+
π **governance-officer THROWS, not warns** (Fase 3) β `attachGovernance` runs at the top of `packageAgent`, before any I/O, so under-configured pillars never waste a `copyTree`. Refusal is a feature.
|
|
78
|
+
π **`semantic_similarity:>=N` skips without a callback** (Fase 3) β when `opts.semantic` is absent the field is *uncounted*, not failed; CI gates don't false-negative on missing embeddings.
|
|
79
|
+
π **One seed golden per package** (Fase 3) β `eval-designer` ships ONE category-shaped case; the eval-designer agent drives 10β50 domain-specific expansion with the dev. Templates carry no made-up domain content.
|
|
80
|
+
π **`eval_passed_at` defaults to `null`** (Fase 3) β the default is a *refused* gate, not an assumed pass. Only `evalResult.verdict === 'pass'` stamps the timestamp.
|
|
81
|
+
π **Mutator CLIs are dry-run by default** (Fase 4) β `/forge-refresh-matrix` / `/forge-killswitch` / `/forge-deprecate` only print the proposed diff; `--write` triggers an atomic tmp+rename. Refuse-over-rubber-stamp posture.
|
|
82
|
+
π **`discoverPackages` survives without `yaml`** (Fase 4) β directory walk + regex on `<name>@<semver>`; listing always works, columns from `manifest.yaml` degrade to `?` / `NEVER` gracefully.
|
|
83
|
+
π **Three CLI modules grouped by intent**, not 13 files (Fase 4) β `cli/forge-ops.mjs` (read) / `cli/forge-eval-cli.mjs` (re-run) / `cli/forge-admin.mjs` (mutate) share `lib/package-ops.mjs` and stay under 180 lines each.
|
|
84
|
+
π **Shadow-eval is a scaffold, not a runner** (Fase 4) β Node adapter ships `createShadowEval` with the sample-rate gate + a `runOne` delegation point; scoring stays single-sourced in the package's `evals/` + the kit's `eval-runner`.
|
|
85
|
+
π **`/forge-refresh-matrix` only stamps `updated`** (Fase 4) β model adds/removes/price changes stay ADR-gated (ADR-0012 Β§6). The command surfaces the ADR expectation in its output.
|
|
86
|
+
π **L5 simulate-impact gate is default-ON for `agent-packages/**`** (Fase 5) β `defaults.l5.highRiskPaths` ships with the glob; swapping a forged agent's primary model is too high-blast-radius to require opt-in.
|
|
87
|
+
π **Selfcheck split by responsibility, not phase** (Fase 5) β `selfcheck-agent-forge.mjs` (build pipeline: matrix + hot-path + router + Fase-3 gate) vs `selfcheck-agent-forge-ops.mjs` (operations: package-ops + rag-designer + L5 gate). Build engine vs running fleet.
|
|
88
|
+
π **Pinecone-under-no-cloud is refused, not silently downgraded** (Fase 5) β `rag-designer` makes the compliance contradiction explicit rather than quietly switching to pgvector and hiding the residency intent.
|
|
89
|
+
π **`/fleet stats` Forge fleet aggregation** (Fase 5) β `fleet.mjs cmdStats` surfaces packages, eval-stamp ratio, monthly target + hard cap both per-repo and as a fleet total β cross-project divergence becomes visible at the registry level.
|
|
90
|
+
π **.NET / Rust adapters deferred to demand** (Fase 5) β `stampRuntimeAdapters` seam is clean (a one-line `if (runtimes.includes('dotnet'))` branch when a real project asks). The blueprint said "per demand", and the polish is honest about it.
|
|
91
|
+
π **`pipeline.yaml` is opt-in per squad** (Fase 6, ADR-0015) β agent-forge is the first consumer; squads without a `pipeline.yaml` keep working as today. The engine refuses (with a clear message) when `yaml` is absent β pipelines are opt-in, not hot-path, so the zero-dep rule still holds.
|
|
92
|
+
π **Whitelisted `condition` grammar** (Fase 6, ADR-0015 Β§A.2) β only `<id>(.<id>)* <op> <literal>` and `β¦length <op> <int>` in v1. No arbitrary expression evaluation; bigger grammar needs a new ADR with a real use case.
|
|
93
|
+
π **Vendor model names stay out of YAML** (Fase 6, ADR-0015 Β§A.3) β `model_tier: fast|powerful|reasoning` only; the router (ADR-0012 Β§4) is the single resolver.
|
|
94
|
+
π **`max_review_cycles` is a hard cap** (Fase 6, ADR-0015 Β§A.4) β the engine refuses to loop past the cap and exits with "manual escalation required" instead of silently retrying forever.
|
|
95
|
+
π **Engine refuses with exit 0 when yaml is absent** (Fase 6, shipped) β pipelines are opt-in; missing yaml is a "feature not enabled" informative message, not an error. Selfcheck + integration test both exercise this path. Matches rule 2 ("hooks never break real work") β the squad keeps running fine if the optional dep is missing.
|
|
96
|
+
π **`condition` parser + engine split** (Fase 6, shipped) β `squad-pipeline-condition.mjs` (parser+eval, 192 lines) is a sibling of `squad-pipeline.mjs` (engine + dry-run, 250 lines). One file per responsibility β parser stays pure & testable without the yaml dep; engine handles I/O + dual-layout (source/installed) discovery.
|
|
97
|
+
|
|
98
|
+
## How this stays current
|
|
99
|
+
|
|
100
|
+
A session that touches agent-forge **updates the markers here** as work moves (β
β³π‘πβ) β same convention as `docs/ROADMAP.md`. New architectural decisions β a new ADR, then a row update here cross-referencing it. The DevPipeline tasks 030β035 are the *executable* counterpart; this is the **map** that ties them to the original spec + the ADRs + the source files.
|
|
101
|
+
|
|
102
|
+
## Quick refs
|
|
103
|
+
|
|
104
|
+
- Approval + constraints: [ADR-0012](../../memory/decisions/0012-agent-forge-squad-for-portable-agent-packages.md)
|
|
105
|
+
- YAML strategy: [ADR-0013](../../memory/decisions/0013-agent-forge-yaml-via-optional-dynamic-import.md)
|
|
106
|
+
- Backlog: `contextkit/pipeline/backlog/032..035-*.md` Β· concluded: `conclusion/030-*.md` + `conclusion/031-*.md`
|
|
107
|
+
- Sessions: 17 (Fase 0 + ADRs) Β· 18 (Fase 1: router engine + libs + agents + /forge-new + integration round-trip)
|
|
108
|
+
- Branches: `feat/agent-forge-fase0` (PR #18) Β· `feat/agent-forge-fase1` (current β Fase 1 complete)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Forge best-practices β the bar every forged agent clears
|
|
2
|
+
|
|
3
|
+
> The normative reference for `agent-forge`. This is what the blueprint called the
|
|
4
|
+
> "ConstituiΓ§Γ£o / AI-AGENT-PRACTICES" β authored **here**, inline, rather than as a
|
|
5
|
+
> phantom prerequisite ([ADR-0012](../../memory/decisions/0012-agent-forge-squad-for-portable-agent-packages.md),
|
|
6
|
+
> constraint 4). It governs the **forged agents** (the output), not this repo's own
|
|
7
|
+
> hot path. Conflicts resolve top-down by the five principles.
|
|
8
|
+
|
|
9
|
+
## 1. The five principles
|
|
10
|
+
|
|
11
|
+
1. **Portability is absolute.** The Agent Package depends on no ContextDevKit, Node, or
|
|
12
|
+
language runtime *at consume time*. It is declarative files + optional adapters. A
|
|
13
|
+
client runs it via the provider SDK, LangChain, or their own runtime β with the kit
|
|
14
|
+
uninstalled.
|
|
15
|
+
2. **Provider-agnostic manifest, provider-specific adapter.** The `manifest.yaml`
|
|
16
|
+
describes the agent abstractly (intent, capabilities, tools, RAG, policy). Adapters
|
|
17
|
+
translate to each provider's wire format. Switching provider swaps an adapter; it
|
|
18
|
+
never rewrites the agent.
|
|
19
|
+
3. **Economic choice is structured, not intuitive.** The `model-router` picks
|
|
20
|
+
provider+model from a capability matrix + deterministic rules. An LLM enters only as
|
|
21
|
+
a tie-breaker on genuinely ambiguous cases. Predictable cost is a design goal.
|
|
22
|
+
4. **Best practices are the default, not a suggestion.** Everything in Β§3 ships in the
|
|
23
|
+
base template. To *remove* one, the dev records a reason; to *keep* it, they do
|
|
24
|
+
nothing. Default-safe beats flexible.
|
|
25
|
+
5. **Eval before embarkation.** No package leaves the forge without passing a minimum
|
|
26
|
+
golden + red-team gate. Failed β refinement loop. An unmeasured agent never reaches
|
|
27
|
+
the client.
|
|
28
|
+
|
|
29
|
+
## 2. Router authority comes from eval, not frozen opinion
|
|
30
|
+
|
|
31
|
+
The decision rules may deterministically *shortlist and rank* providers β but the final
|
|
32
|
+
"best model for this agent" verdict is the **eval harness measured on the user's golden
|
|
33
|
+
set**, not a preference frozen in JSON the day it was written (ADR-0012, constraint 5).
|
|
34
|
+
Shipped rules carry no hardcoded quality claims (no "model X is 8pp better at PT-BR").
|
|
35
|
+
The capability matrix is dated, versioned, and changed only via ADR + `/forge-refresh-matrix`.
|
|
36
|
+
|
|
37
|
+
## 3. The default catalogue (every forged agent ships with these)
|
|
38
|
+
|
|
39
|
+
| Default | Why it's not optional |
|
|
40
|
+
| --- | --- |
|
|
41
|
+
| **Prompt caching** (where the provider supports it) | Largest single cost lever on long, stable prompts (glossaries, rules). |
|
|
42
|
+
| **Fallback chain** (β₯1 provider *different* from primary) | Survives a provider outage; a single-provider agent is a single point of failure. |
|
|
43
|
+
| **Retry with backoff** (exponential; on 5xx/timeout/rate-limit; **never** on 4xx/safety-block) | Transient errors recover; client errors and safety decisions must not be retried blindly. |
|
|
44
|
+
| **Rate limiting** (per-user + global) | Caps blast radius of a bug or abuse before it becomes a bill. |
|
|
45
|
+
| **Audit log** (inputs after redaction, output, model, cost, fallback, PII redactions) | Without it there is no compliance story and no drift forensics. |
|
|
46
|
+
| **Kill switch** (cost breach, eval-below-threshold, red-team regression) | The agent must be able to refuse *itself* when a guardrail trips. |
|
|
47
|
+
| **Eval golden + red-team** | The only objective evidence the agent works and is safe. |
|
|
48
|
+
| **Structured-output validation** | A malformed payload is a failure, not a "best effort" β validate, retry once, then fail. |
|
|
49
|
+
|
|
50
|
+
## 4. Provider best-practices (condensed)
|
|
51
|
+
|
|
52
|
+
| Provider | System prompt | Tools | Notes that bite |
|
|
53
|
+
| --- | --- | --- | --- |
|
|
54
|
+
| **Anthropic** | Separate param; XML-structured sections | `tools[]` + `input_schema`; `tool_choice` to force | No native JSON mode β use a single-tool schema for structured output; mark static blocks `cache_control`. |
|
|
55
|
+
| **OpenAI** | First `system` message | `tools[]` type `function` | Native `response_format: json_schema` strict mode; caching is automatic >1024-tok prefix. o-series: no system msg, `reasoning_effort`. |
|
|
56
|
+
| **Google (Gemini)** | `systemInstruction` param | `functionDeclarations[]` (JSON-Schema **subset**) | **Set `safetySettings` explicitly** or hit surprise blocks; up to 2M ctx (RAG win); caching needs >32k tokens. |
|
|
57
|
+
| **DeepSeek** | OpenAI-compatible | OpenAI-compatible | Prefers explicit CoT; reasoner models split `reasoning_content`; an order of magnitude cheaper; PT-BR/vision weaker than Claude/Gemini. |
|
|
58
|
+
| **Self-hosted (Ollama/vLLM)** | Per-model `chat_template` | Native but less reliable β robust eval is critical | Data never leaves the client's infra β the only viable path for heavy PII + strict residency. Perf depends on their hardware. |
|
|
59
|
+
|
|
60
|
+
The runtime adapters expose **one interface** regardless of provider β `invoke`,
|
|
61
|
+
`invokeStream`, `preflight`, `estimate`, `onEvent`. The client switches provider by
|
|
62
|
+
editing `manifest.yaml β spec.model_selection.primary`; their code does not change.
|
|
63
|
+
|
|
64
|
+
## 5. Governance β three pillars, equal weight
|
|
65
|
+
|
|
66
|
+
The forge refuses to package an agent with any of the three under-configured.
|
|
67
|
+
|
|
68
|
+
- **Cost** β per-call + monthly budgets, alert tiers, caching required, rate limits,
|
|
69
|
+
kill switch on hard-cap breach. *Without it the agent dies of budget politics.*
|
|
70
|
+
- **Compliance** β PII detection + redaction/tokenization, LGPD basis + data-subject
|
|
71
|
+
rights, data residency (allow/deny providers), retention, audit. *Without it the
|
|
72
|
+
agent is fined, sued, or banned in regulated work.*
|
|
73
|
+
- **Quality** β eval gates (golden + red-team thresholds), fallback chain, retry policy,
|
|
74
|
+
drift monitoring, kill switch on quality regression. *Without it the agent is cheap
|
|
75
|
+
and legal but hallucinates and burns the product.*
|
|
76
|
+
|
|
77
|
+
## 6. Eval lifecycle
|
|
78
|
+
|
|
79
|
+
1. **Pre-release** *(mandatory)* β the package does not ship unless golden + red-team
|
|
80
|
+
clear thresholds (e.g. golden accuracy β₯ 0.85; PII-leak block rate = 1.00).
|
|
81
|
+
2. **Pre-version-bump** *(mandatory on minor/major)* β a significant change reruns eval.
|
|
82
|
+
3. **Shadow in production** *(recommended)* β the client evals a sample (~5%) of real
|
|
83
|
+
traffic to catch upstream model drift; feeds candidates back into the golden set.
|
|
84
|
+
|
|
85
|
+
## 7. Red-team minimum
|
|
86
|
+
|
|
87
|
+
Every package carries at least: **prompt-injection**, **jailbreak**, and **PII-leak**
|
|
88
|
+
cases. PII-leak tolerance is zero (block rate 1.00). These run before each release and
|
|
89
|
+
on every version bump; bias tests are recommended where the domain warrants.
|