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,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in default configuration for ContextDevKit — STACK-AGNOSTIC.
|
|
3
|
+
*
|
|
4
|
+
* This object is the fallback whenever `contextkit/config.json` is missing,
|
|
5
|
+
* malformed, or only partially overrides the tree. It carries ZERO runtime
|
|
6
|
+
* dependencies (no zod) so the Level 1–3 hooks work in a brand-new project
|
|
7
|
+
* with nothing installed. Level 5 validation (`/context-config`) layers an
|
|
8
|
+
* optional zod schema on top — see `schema.mjs`.
|
|
9
|
+
*
|
|
10
|
+
* The defaults intentionally describe a *generic* repository (`src/`, `lib/`,
|
|
11
|
+
* `app/`, `packages/`, ...). The installer tunes these per detected stack and
|
|
12
|
+
* the user refines them with `/context-config`.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* `level` (1–7) gates which subsystems are active. 1–5 add Claude hooks; 6–7 are
|
|
17
|
+
* capability tiers (no new hook — commands/tooling on top of the L5 gates):
|
|
18
|
+
* 1 Memory — boot context + session log + ADRs + changelog
|
|
19
|
+
* 2 Ledger — drift detection (PostToolUse + Stop nudge)
|
|
20
|
+
* 3 Multi — claims, worktrees, derived indices, git hooks
|
|
21
|
+
* 4 Squads — specialized sub-agents
|
|
22
|
+
* 5 Proactive — simulate-impact gate, tech-debt sweep, contract drift
|
|
23
|
+
* 6 Autonomy — /ship pipeline, /retro, metrics (capability tier)
|
|
24
|
+
* 7 Ecosystem — fleet (multi-repo), agent-tuning, visual tests, playbooks,
|
|
25
|
+
* token/cost insight, security automation (capability tier)
|
|
26
|
+
*/
|
|
27
|
+
export const DEFAULT_CONFIG = Object.freeze({
|
|
28
|
+
level: 2,
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* First-run onboarding state. The installer writes `completed: false` into a
|
|
32
|
+
* fresh project's config so the SessionStart hook fires the `/setupcontextdevkit`
|
|
33
|
+
* trigger on the first session. `/setupcontextdevkit` flips it to `true` when
|
|
34
|
+
* onboarding finishes. The DEFAULT is `true` so a missing/corrupt config never
|
|
35
|
+
* nags — only an installer-written `false` triggers the banner.
|
|
36
|
+
*/
|
|
37
|
+
setup: { completed: true },
|
|
38
|
+
|
|
39
|
+
/** Best-practices skill (contextkit/best-practices.md). When active, boot reminds + /analyze-code-ia-practices is encouraged. */
|
|
40
|
+
practices: { active: false },
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Behavioral discipline (contextkit/behaviors.md, ADR-0029) — how the agent ACTS
|
|
44
|
+
* while coding: think-before-coding (surface assumptions / ask when ambiguous),
|
|
45
|
+
* simplicity-first, surgical changes, goal-driven (reproduce-test first). When
|
|
46
|
+
* `active`, the SessionStart hook reminds you each session. ON by default — it's
|
|
47
|
+
* universal, cheap, and the constitution §8 already states it.
|
|
48
|
+
*/
|
|
49
|
+
behaviors: { active: true },
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Path classification for the L2 ledger. Override per stack via config.
|
|
53
|
+
* - `important`: an edit here can trigger the Stop drift nudge.
|
|
54
|
+
* - `irrelevant`: never tracked (build output, caches, runtime state).
|
|
55
|
+
* - `registration`: an edit here counts AS registering the session.
|
|
56
|
+
*/
|
|
57
|
+
ledger: {
|
|
58
|
+
important: [
|
|
59
|
+
'src/',
|
|
60
|
+
'lib/',
|
|
61
|
+
'app/',
|
|
62
|
+
'apps/',
|
|
63
|
+
'packages/',
|
|
64
|
+
'components/',
|
|
65
|
+
'pages/',
|
|
66
|
+
'server/',
|
|
67
|
+
'contextkit/',
|
|
68
|
+
'.claude/',
|
|
69
|
+
'.github/',
|
|
70
|
+
'CLAUDE.md',
|
|
71
|
+
'package.json',
|
|
72
|
+
'tsconfig.json',
|
|
73
|
+
'pyproject.toml',
|
|
74
|
+
'go.mod',
|
|
75
|
+
'Cargo.toml',
|
|
76
|
+
],
|
|
77
|
+
irrelevant: [
|
|
78
|
+
'node_modules/',
|
|
79
|
+
'dist/',
|
|
80
|
+
'build/',
|
|
81
|
+
'out/',
|
|
82
|
+
'.next/',
|
|
83
|
+
'.turbo/',
|
|
84
|
+
'.expo/',
|
|
85
|
+
'.svelte-kit/',
|
|
86
|
+
'coverage/',
|
|
87
|
+
'__pycache__/',
|
|
88
|
+
'target/',
|
|
89
|
+
'vendor/',
|
|
90
|
+
'.context-snapshot.md',
|
|
91
|
+
'.claude/.sessions/',
|
|
92
|
+
'.claude/.workspace/',
|
|
93
|
+
],
|
|
94
|
+
registration: ['contextkit/memory/SESSIONS.md', 'docs/CHANGELOG.md'],
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
/** L3 — Multi-session. `mainBranch` is the upstream the pre-push conflict check compares against. */
|
|
98
|
+
l3: { mainBranch: 'main' },
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* QA squad config (used by /test-plan, /scaffold-tests, /qa-signoff and the
|
|
102
|
+
* qa-* agents at Level >= 4). `criticalPaths` get the highest coverage
|
|
103
|
+
* priority; `coverageTarget` is the floor a sign-off aims for.
|
|
104
|
+
*/
|
|
105
|
+
qa: {
|
|
106
|
+
criticalPaths: [],
|
|
107
|
+
coverageTarget: { lines: 80, branches: 70 },
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* DevPipeline prioritization (WSJF / SAFe) + bug severity + SLA + WIP eviction.
|
|
112
|
+
* - `wsjfBands`: WSJF score ≥ value → priority (P0/P1/P2, else P3).
|
|
113
|
+
* - `severityPriority`: ITIL bug severity S1–S4 → priority.
|
|
114
|
+
* - `slaDays`: resolution target (days) per priority → the task's SLA due date.
|
|
115
|
+
* - `bugTypes`: the bug taxonomy used to classify bug tasks.
|
|
116
|
+
* - `workingStaleAfterMinutes`: ADR-0015 §B — a task auto-evicts from `working/`
|
|
117
|
+
* back to `backlog/` when its owning session is silent past this threshold.
|
|
118
|
+
*/
|
|
119
|
+
pipeline: {
|
|
120
|
+
framework: 'wsjf',
|
|
121
|
+
wsjfBands: { p0: 8, p1: 5, p2: 2 },
|
|
122
|
+
severityPriority: { S1: 'P0', S2: 'P1', S3: 'P2', S4: 'P3' },
|
|
123
|
+
slaDays: { P0: 1, P1: 3, P2: 14, P3: 60 },
|
|
124
|
+
bugTypes: ['functional', 'regression', 'security', 'performance', 'data', 'integration', 'ui', 'build', 'flaky', 'other'],
|
|
125
|
+
workingStaleAfterMinutes: 90,
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Security mode — proactive analysis cadence. When `active`, the SessionStart
|
|
130
|
+
* hook reminds you to run `/deep-analysis` every `everyNSessions` sessions.
|
|
131
|
+
* ACTIVE by default; set `active: false` to disable.
|
|
132
|
+
*/
|
|
133
|
+
securityMode: { active: true, everyNSessions: 10 },
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Token economy & usage insight (L6). `/token-report` reads Claude Code's local
|
|
137
|
+
* session transcripts (`~/.claude/projects/…`) and aggregates token usage for this
|
|
138
|
+
* project — advisory, read-only, aggregated counts only.
|
|
139
|
+
* - `budgetPerSession`: total tokens/session that triggers a ⚠️ warning (0 = off).
|
|
140
|
+
* - `warnAtPct`: warn once a session reaches this % of the budget.
|
|
141
|
+
*/
|
|
142
|
+
tokens: { budgetPerSession: 0, warnAtPct: 80 },
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Predictions-review cadence (L5/L6). When `active`, the SessionStart hook reminds you
|
|
146
|
+
* to run `/predictions-review` every `everyNSessions` sessions — but ONLY when there are
|
|
147
|
+
* unreviewed `/simulate-impact` predictions, so it stays silent otherwise.
|
|
148
|
+
*/
|
|
149
|
+
predictionsReview: { active: true, everyNSessions: 10 },
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Proactive Advisor (L6, ADR-0028) — the six-lane improvement engine. When
|
|
153
|
+
* `active`, `/advise` fans out to the owning agent per lane and emits ONE
|
|
154
|
+
* classified digest (`--before` = opportunities/risks, `--after` = improvements)
|
|
155
|
+
* whose findings flow into the DevPipeline backlog. `nudgeOnStop` makes the Stop
|
|
156
|
+
* hook suggest `/advise` after a productive session (≥ 2 important paths touched,
|
|
157
|
+
* debounced 24h). Each lane is `{ owner }` — the agent/command that owns it, or
|
|
158
|
+
* `null` to mute a lane. All six ship with an owner; a muted lane is reported as
|
|
159
|
+
* *skipped*, never faked (rule 8/9). `growth` is the growth-team lead (pairs with
|
|
160
|
+
* `retention` + `seo-specialist` for acquisition); `deepen` is product-owner's
|
|
161
|
+
* depth lens (maturing existing features, distinct from greenfield `features`).
|
|
162
|
+
*/
|
|
163
|
+
advisor: {
|
|
164
|
+
active: true,
|
|
165
|
+
nudgeOnStop: true,
|
|
166
|
+
lanes: {
|
|
167
|
+
architecture: { owner: 'architect' },
|
|
168
|
+
features: { owner: 'product-owner' },
|
|
169
|
+
deepen: { owner: 'product-owner' },
|
|
170
|
+
security: { owner: 'security' },
|
|
171
|
+
ux: { owner: 'ux-designer' },
|
|
172
|
+
growth: { owner: 'growth' },
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Dependency policy for `/deps-audit` (security-team). All advisory — findings
|
|
178
|
+
* flow into the DevPipeline backlog, they don't block by default.
|
|
179
|
+
* - `requireLockfile`: flag a manifest with deps but no committed lockfile.
|
|
180
|
+
* - `licenses.allow`: if non-empty, a dependency whose license is NOT listed
|
|
181
|
+
* is flagged (allow-list mode). SPDX ids, case-insensitive.
|
|
182
|
+
* - `licenses.deny`: a dependency whose license IS listed is always flagged.
|
|
183
|
+
* - `maxAgeDays`: reserved for registry-backed staleness (not enforced yet).
|
|
184
|
+
*/
|
|
185
|
+
deps: {
|
|
186
|
+
requireLockfile: true,
|
|
187
|
+
licenses: { allow: [], deny: ['GPL-3.0', 'AGPL-3.0'] },
|
|
188
|
+
maxAgeDays: null,
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
/** L5 — Proactive Engineering. Inert unless `level >= 5`. */
|
|
192
|
+
l5: {
|
|
193
|
+
/** Editing any of these without a prior `/simulate-impact` is gated.
|
|
194
|
+
* agent-packages/** is included by default — swapping a forged agent's primary
|
|
195
|
+
* model is high blast radius (ADR-0012 + Fase 5). Remove if you don't ship agents. */
|
|
196
|
+
highRiskPaths: ['agent-packages/**'],
|
|
197
|
+
/** Line-budget thresholds used by the tech-debt scanner. */
|
|
198
|
+
lineBudget: { yellow: 240, red: 308 },
|
|
199
|
+
/** Files whose exported symbols form the public contract (drift gate). Empty = off. */
|
|
200
|
+
contractGlobs: [],
|
|
201
|
+
/** Auto-distill cadence (CLAUDE.md self-refinement loop). */
|
|
202
|
+
distill: {
|
|
203
|
+
observeWindow: 10,
|
|
204
|
+
proposeAfterSessions: 30,
|
|
205
|
+
archiveLedgersOlderThanDays: 7,
|
|
206
|
+
},
|
|
207
|
+
techDebtSweep: {
|
|
208
|
+
default: 'full',
|
|
209
|
+
profiles: {
|
|
210
|
+
full: { cadenceDays: 14, scope: 'all' },
|
|
211
|
+
quick: { cadenceDays: 3, scope: 'red-zone-only' },
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical level taxonomy — the SINGLE source of truth for ContextDevKit's
|
|
3
|
+
* activation levels. Every place that names a level range or label imports from
|
|
4
|
+
* here so they can never drift: `getLevel` (load.mjs), the optional config
|
|
5
|
+
* schema (schema.mjs), the installer labels (tools/install/cli.mjs) and the
|
|
6
|
+
* in-project `/context-level` helper. Zero third-party deps (hot-path safe).
|
|
7
|
+
*
|
|
8
|
+
* Levels 1–5 add Claude hooks; 6–7 are capability tiers (no new hook — commands
|
|
9
|
+
* and tooling layered on the L5 gates). See ADR-0010.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** Lowest selectable level. */
|
|
13
|
+
export const MIN_LEVEL = 1;
|
|
14
|
+
|
|
15
|
+
/** Highest selectable level. Bump this (and add a LEVEL_LABELS entry) to add a tier. */
|
|
16
|
+
export const MAX_LEVEL = 7;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Human-readable label per level — the ONE table. The installer and `/context-level`
|
|
20
|
+
* both render from this; keep the wording here and nowhere else.
|
|
21
|
+
*/
|
|
22
|
+
export const LEVEL_LABELS = {
|
|
23
|
+
1: 'L1 Memory — boot context, session log, ADRs, changelog',
|
|
24
|
+
2: 'L2 Ledger — + drift detection (PostToolUse + Stop nudge)',
|
|
25
|
+
3: 'L3 Multi — + claims, worktrees, derived indices, git hooks (recommended for a NEW/empty project)',
|
|
26
|
+
4: 'L4 Squads — + specialized sub-agents (.claude/agents)',
|
|
27
|
+
5: 'L5 Proactive — + simulate-impact gate, tech-debt sweep, contract drift',
|
|
28
|
+
6: 'L6 Autonomy & Insight — + /ship pipeline, /retro learning loop, metrics',
|
|
29
|
+
7: 'L7 Ecosystem & Scale — + fleet (multi-repo), agent-tuning, visual tests, playbooks, token/cost insight (recommended for an EXISTING project with code)',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** True when `n` is an integer within the valid level range. */
|
|
33
|
+
export function isValidLevel(n) {
|
|
34
|
+
return Number.isInteger(n) && n >= MIN_LEVEL && n <= MAX_LEVEL;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Clamps any number into the valid level range (rounds non-integers). */
|
|
38
|
+
export function clampLevel(n) {
|
|
39
|
+
const i = Math.round(Number(n));
|
|
40
|
+
if (!Number.isFinite(i)) return MIN_LEVEL;
|
|
41
|
+
return Math.min(MAX_LEVEL, Math.max(MIN_LEVEL, i));
|
|
42
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zero-dependency config loader for ContextDevKit.
|
|
3
|
+
*
|
|
4
|
+
* Contract:
|
|
5
|
+
* - `loadConfig()` / `loadConfigSync()` MUST NEVER throw. Hooks depend on
|
|
6
|
+
* them and a broken config file cannot be allowed to block real work.
|
|
7
|
+
* On any failure they log to stderr and return the deep-merged defaults.
|
|
8
|
+
* - No third-party deps. JSON.parse + a small recursive merge only. This is
|
|
9
|
+
* what lets Levels 1–3 run in a project that has installed nothing.
|
|
10
|
+
* - Strict validation (zod) is OPTIONAL and lives in `schema.mjs`, used
|
|
11
|
+
* solely by `/context-config`. It is never imported on a hook path.
|
|
12
|
+
*/
|
|
13
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
14
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
15
|
+
import { resolve } from 'node:path';
|
|
16
|
+
import { DEFAULT_CONFIG } from './defaults.mjs';
|
|
17
|
+
import { isValidLevel } from './levels.mjs';
|
|
18
|
+
import { CONFIG_FILE } from './paths.mjs';
|
|
19
|
+
|
|
20
|
+
export function configPathFor(root = process.cwd()) {
|
|
21
|
+
return resolve(root, CONFIG_FILE);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Deep-merges a partial override onto a base object. Arrays REPLACE (so a
|
|
26
|
+
* project can fully redefine `ledger.important`), objects merge recursively.
|
|
27
|
+
*
|
|
28
|
+
* @param {Record<string, any>} base
|
|
29
|
+
* @param {Record<string, any>} override
|
|
30
|
+
*/
|
|
31
|
+
function deepMerge(base, override) {
|
|
32
|
+
if (!override || typeof override !== 'object') return base;
|
|
33
|
+
const out = Array.isArray(base) ? [...base] : { ...base };
|
|
34
|
+
for (const [key, value] of Object.entries(override)) {
|
|
35
|
+
if (
|
|
36
|
+
value &&
|
|
37
|
+
typeof value === 'object' &&
|
|
38
|
+
!Array.isArray(value) &&
|
|
39
|
+
out[key] &&
|
|
40
|
+
typeof out[key] === 'object' &&
|
|
41
|
+
!Array.isArray(out[key])
|
|
42
|
+
) {
|
|
43
|
+
out[key] = deepMerge(out[key], value);
|
|
44
|
+
} else {
|
|
45
|
+
out[key] = value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function parseRaw(buf, path) {
|
|
52
|
+
try {
|
|
53
|
+
// Strip a leading UTF-8 BOM — common when a file is written by a Windows
|
|
54
|
+
// editor or PowerShell's `Set-Content -Encoding utf8` (PS 5.1 adds one).
|
|
55
|
+
return JSON.parse(buf.replace(/^/, ''));
|
|
56
|
+
} catch (err) {
|
|
57
|
+
process.stderr.write(`[context-config] malformed JSON in ${path} — using defaults: ${err?.message ?? err}\n`);
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Async load + deep-merge over defaults. Never throws. */
|
|
63
|
+
export async function loadConfig(root = process.cwd()) {
|
|
64
|
+
const path = configPathFor(root);
|
|
65
|
+
let buf;
|
|
66
|
+
try {
|
|
67
|
+
buf = await readFile(path, 'utf-8');
|
|
68
|
+
} catch {
|
|
69
|
+
return structuredClone(DEFAULT_CONFIG);
|
|
70
|
+
}
|
|
71
|
+
const raw = parseRaw(buf, path);
|
|
72
|
+
if (raw === null) return structuredClone(DEFAULT_CONFIG);
|
|
73
|
+
return deepMerge(structuredClone(DEFAULT_CONFIG), raw);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Synchronous variant for hooks that cannot await. Never throws. */
|
|
77
|
+
export function loadConfigSync(root = process.cwd()) {
|
|
78
|
+
const path = configPathFor(root);
|
|
79
|
+
if (!existsSync(path)) return structuredClone(DEFAULT_CONFIG);
|
|
80
|
+
let buf;
|
|
81
|
+
try {
|
|
82
|
+
buf = readFileSync(path, 'utf-8');
|
|
83
|
+
} catch {
|
|
84
|
+
return structuredClone(DEFAULT_CONFIG);
|
|
85
|
+
}
|
|
86
|
+
const raw = parseRaw(buf, path);
|
|
87
|
+
if (raw === null) return structuredClone(DEFAULT_CONFIG);
|
|
88
|
+
return deepMerge(structuredClone(DEFAULT_CONFIG), raw);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Reads only the active level (MIN_LEVEL..MAX_LEVEL). Defensive — defaults to 2. */
|
|
92
|
+
export function getLevel(root = process.cwd()) {
|
|
93
|
+
const lvl = Number(loadConfigSync(root)?.level);
|
|
94
|
+
return isValidLevel(lvl) ? lvl : 2;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Persists a config object. Used by `/context-config set`. NOT defensive by
|
|
99
|
+
* design — surfaces write errors so the slash command can report them.
|
|
100
|
+
*/
|
|
101
|
+
export async function writeConfig(candidate, root = process.cwd()) {
|
|
102
|
+
const payload = `${JSON.stringify(candidate, null, 2)}\n`;
|
|
103
|
+
await writeFile(configPathFor(root), payload, 'utf-8');
|
|
104
|
+
return candidate;
|
|
105
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical path constants for the ContextDevKit platform.
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth so every hook, script and slash command agrees on
|
|
5
|
+
* where memory artifacts live. `.claude/` is fixed by Claude Code (it reads
|
|
6
|
+
* settings/commands/agents from hardcoded locations). Everything else lives
|
|
7
|
+
* under `contextkit/` — the rebrandable platform bounded context.
|
|
8
|
+
*
|
|
9
|
+
* To rebrand the platform folder (e.g. back to `devAItools/`), change
|
|
10
|
+
* `PLATFORM_DIR` here and run the installer's `--rewire` step. Nothing else
|
|
11
|
+
* references the literal folder name.
|
|
12
|
+
*/
|
|
13
|
+
import { resolve } from 'node:path';
|
|
14
|
+
|
|
15
|
+
/** Platform bounded-context folder (everything except `.claude/`). */
|
|
16
|
+
export const PLATFORM_DIR = 'contextkit';
|
|
17
|
+
|
|
18
|
+
/** Memory root — ADRs, sessions, glossary, indices. */
|
|
19
|
+
export const MEMORY_DIR = `${PLATFORM_DIR}/memory`;
|
|
20
|
+
|
|
21
|
+
/** One markdown file per work session. */
|
|
22
|
+
export const SESSIONS_DIR = `${MEMORY_DIR}/sessions`;
|
|
23
|
+
|
|
24
|
+
/** Auto-generated reverse-chronological index of sessions. */
|
|
25
|
+
export const SESSIONS_INDEX = `${MEMORY_DIR}/SESSIONS.md`;
|
|
26
|
+
|
|
27
|
+
/** Auto-generated aggregate of active workspace claims. */
|
|
28
|
+
export const WORKSPACE_INDEX = `${MEMORY_DIR}/WORKSPACE.md`;
|
|
29
|
+
|
|
30
|
+
/** Architecture Decision Records (immutable once accepted). */
|
|
31
|
+
export const DECISIONS_DIR = `${MEMORY_DIR}/decisions`;
|
|
32
|
+
|
|
33
|
+
/** Domain glossary — UI/business term ↔ code identifier. */
|
|
34
|
+
export const GLOSSARY = `${MEMORY_DIR}/GLOSSARY.md`;
|
|
35
|
+
|
|
36
|
+
/** L5 prediction artifacts (Blast Radius Reports). */
|
|
37
|
+
export const PREDICTIONS_DIR = `${MEMORY_DIR}/predictions`;
|
|
38
|
+
|
|
39
|
+
/** Factual release chronology (Keep a Changelog format). */
|
|
40
|
+
export const CHANGELOG = 'docs/CHANGELOG.md';
|
|
41
|
+
|
|
42
|
+
/** Platform config (level, ledger overrides, L5 params). */
|
|
43
|
+
export const CONFIG_FILE = `${PLATFORM_DIR}/config.json`;
|
|
44
|
+
|
|
45
|
+
/** Per-session ledger files (gitignored runtime state). */
|
|
46
|
+
export const LEDGER_DIR = '.claude/.sessions';
|
|
47
|
+
|
|
48
|
+
/** Per-session workspace claim files (gitignored runtime state). */
|
|
49
|
+
export const WORKSPACE_STATE_DIR = '.claude/.workspace';
|
|
50
|
+
|
|
51
|
+
/** On-demand full-project snapshot (gitignored). */
|
|
52
|
+
export const CONTEXT_SNAPSHOT = '.context-snapshot.md';
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Resolves every canonical location to an ABSOLUTE path under `root`. This is the
|
|
56
|
+
* single helper scripts/hooks use instead of hardcoding `resolve(ROOT, 'contextkit/…')`
|
|
57
|
+
* literals — so the platform folder name lives only in `PLATFORM_DIR` (immutable
|
|
58
|
+
* rule 4). One-off files under memory use `resolve(p.memory, '<name>')`.
|
|
59
|
+
*
|
|
60
|
+
* @param {string} [root] project root (default cwd)
|
|
61
|
+
*/
|
|
62
|
+
export function pathsFor(root = process.cwd()) {
|
|
63
|
+
const at = (rel) => resolve(root, rel);
|
|
64
|
+
return {
|
|
65
|
+
root,
|
|
66
|
+
platform: at(PLATFORM_DIR),
|
|
67
|
+
memory: at(MEMORY_DIR),
|
|
68
|
+
sessions: at(SESSIONS_DIR),
|
|
69
|
+
sessionsIndex: at(SESSIONS_INDEX),
|
|
70
|
+
workspaceIndex: at(WORKSPACE_INDEX),
|
|
71
|
+
decisions: at(DECISIONS_DIR),
|
|
72
|
+
glossary: at(GLOSSARY),
|
|
73
|
+
predictions: at(PREDICTIONS_DIR),
|
|
74
|
+
changelog: at(CHANGELOG),
|
|
75
|
+
config: at(CONFIG_FILE),
|
|
76
|
+
ledgerDir: at(LEDGER_DIR),
|
|
77
|
+
workspaceStateDir: at(WORKSPACE_STATE_DIR),
|
|
78
|
+
contextSnapshot: at(CONTEXT_SNAPSHOT),
|
|
79
|
+
pipeline: at(`${PLATFORM_DIR}/pipeline`),
|
|
80
|
+
runtime: at(`${PLATFORM_DIR}/runtime`),
|
|
81
|
+
tools: at(`${PLATFORM_DIR}/tools`),
|
|
82
|
+
scripts: at(`${PLATFORM_DIR}/tools/scripts`),
|
|
83
|
+
squads: at(`${PLATFORM_DIR}/squads`),
|
|
84
|
+
workflows: at(`${PLATFORM_DIR}/workflows`),
|
|
85
|
+
playbooks: at(`${PLATFORM_DIR}/workflows/playbooks`),
|
|
86
|
+
detectors: at(`${PLATFORM_DIR}/detectors`),
|
|
87
|
+
businessRules: at(`${MEMORY_DIR}/business-rules`),
|
|
88
|
+
roadmap: at(`${MEMORY_DIR}/roadmap.md`),
|
|
89
|
+
contractBaseline: at(`${MEMORY_DIR}/contract-baseline.json`),
|
|
90
|
+
bestPractices: at(`${PLATFORM_DIR}/best-practices.md`),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stack presets — opt-in config fragments that tune ContextDevKit to a stack.
|
|
3
|
+
*
|
|
4
|
+
* Applied by `install.mjs --preset <name>` (and offered by `/setupcontextdevkit`).
|
|
5
|
+
* Each preset UNIONS its array fields onto the config (stack paths ADD to the
|
|
6
|
+
* generic defaults, they don't replace them) and sets stack-specific high-risk /
|
|
7
|
+
* QA-critical paths. Zero-dependency.
|
|
8
|
+
*/
|
|
9
|
+
export const PRESETS = {
|
|
10
|
+
next: {
|
|
11
|
+
ledger: { important: ['app/', 'components/', 'lib/', 'pages/', 'src/'] },
|
|
12
|
+
l5: { highRiskPaths: ['app/api/', 'middleware.ts'] },
|
|
13
|
+
qa: { criticalPaths: ['app/', 'components/'] },
|
|
14
|
+
},
|
|
15
|
+
go: {
|
|
16
|
+
ledger: { important: ['cmd/', 'internal/', 'pkg/'] },
|
|
17
|
+
l5: { highRiskPaths: ['internal/auth/'] },
|
|
18
|
+
qa: { criticalPaths: ['internal/', 'pkg/'] },
|
|
19
|
+
},
|
|
20
|
+
python: {
|
|
21
|
+
ledger: { important: ['src/', 'app/', 'tests/'] },
|
|
22
|
+
l5: { highRiskPaths: ['*/auth/', '*/security/'] },
|
|
23
|
+
qa: { criticalPaths: ['src/'] },
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export function listPresets() {
|
|
28
|
+
return Object.keys(PRESETS);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const uniq = (arr) => [...new Set(arr)];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Returns a NEW config with the named preset merged in (array fields unioned).
|
|
35
|
+
* Unknown name → the config is returned unchanged. Every preset field is read
|
|
36
|
+
* with optional chaining so a partial/custom preset that omits `ledger`, `l5`,
|
|
37
|
+
* or `qa` merges what it has instead of crashing on `undefined.field`.
|
|
38
|
+
*/
|
|
39
|
+
export function applyPreset(config, name) {
|
|
40
|
+
const preset = PRESETS[name];
|
|
41
|
+
if (!preset) return config;
|
|
42
|
+
const cfg = { ...config };
|
|
43
|
+
cfg.ledger = { ...(cfg.ledger || {}), important: uniq([...(cfg.ledger?.important || []), ...(preset.ledger?.important || [])]) };
|
|
44
|
+
cfg.l5 = { ...(cfg.l5 || {}), highRiskPaths: uniq([...(cfg.l5?.highRiskPaths || []), ...(preset.l5?.highRiskPaths || [])]) };
|
|
45
|
+
cfg.qa = { ...(cfg.qa || {}), criticalPaths: uniq([...(cfg.qa?.criticalPaths || []), ...(preset.qa?.criticalPaths || [])]) };
|
|
46
|
+
return cfg;
|
|
47
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OPTIONAL strict config schema (zod) for `/context-config`.
|
|
3
|
+
*
|
|
4
|
+
* The hot path (hooks) NEVER imports this — it uses the zero-dependency
|
|
5
|
+
* loader in `load.mjs`. This module is loaded ONLY by `/context-config` when the
|
|
6
|
+
* user wants strict validation before persisting an edit, and it degrades
|
|
7
|
+
* gracefully when `zod` is not installed (the slash command catches the import
|
|
8
|
+
* error and falls back to structural checks).
|
|
9
|
+
*
|
|
10
|
+
* Install `zod` in the target project to enable strict validation:
|
|
11
|
+
* npm i -D zod (or pnpm/yarn/bun equivalent)
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
import { MAX_LEVEL, MIN_LEVEL } from './levels.mjs';
|
|
15
|
+
|
|
16
|
+
const PathString = z
|
|
17
|
+
.string()
|
|
18
|
+
.min(1, 'path must not be empty')
|
|
19
|
+
.refine((p) => !p.startsWith('/') && !p.includes('\\'), {
|
|
20
|
+
message: 'use forward-slashed, repo-relative paths (no leading /, no backslashes)',
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const Profile = z.object({
|
|
24
|
+
cadenceDays: z.number().int().positive(),
|
|
25
|
+
scope: z.string().min(1),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const LedgerSchema = z
|
|
29
|
+
.object({
|
|
30
|
+
important: z.array(PathString).min(1),
|
|
31
|
+
irrelevant: z.array(PathString),
|
|
32
|
+
registration: z.array(PathString),
|
|
33
|
+
})
|
|
34
|
+
.partial()
|
|
35
|
+
.default({});
|
|
36
|
+
|
|
37
|
+
const L5Schema = z
|
|
38
|
+
.object({
|
|
39
|
+
highRiskPaths: z.array(PathString).default([]),
|
|
40
|
+
distill: z
|
|
41
|
+
.object({
|
|
42
|
+
observeWindow: z.number().int().positive().default(10),
|
|
43
|
+
proposeAfterSessions: z.number().int().positive().default(30),
|
|
44
|
+
archiveLedgersOlderThanDays: z.number().int().positive().default(7),
|
|
45
|
+
})
|
|
46
|
+
.default({}),
|
|
47
|
+
techDebtSweep: z
|
|
48
|
+
.object({ default: z.string().min(1), profiles: z.record(z.string(), Profile) })
|
|
49
|
+
.default({ default: 'full', profiles: { full: { cadenceDays: 14, scope: 'all' } } }),
|
|
50
|
+
})
|
|
51
|
+
.default({});
|
|
52
|
+
|
|
53
|
+
const DepsSchema = z
|
|
54
|
+
.object({
|
|
55
|
+
requireLockfile: z.boolean().default(true),
|
|
56
|
+
licenses: z
|
|
57
|
+
.object({ allow: z.array(z.string()).default([]), deny: z.array(z.string()).default([]) })
|
|
58
|
+
.default({}),
|
|
59
|
+
maxAgeDays: z.number().int().positive().nullable().default(null),
|
|
60
|
+
})
|
|
61
|
+
.default({});
|
|
62
|
+
|
|
63
|
+
// `.passthrough()` keeps every section the defaults define (qa, pipeline,
|
|
64
|
+
// securityMode, tokens, predictionsReview, l3, setup, practices, …) instead of
|
|
65
|
+
// silently dropping the ones not modelled here — the alternative to re-declaring
|
|
66
|
+
// the whole config tree in zod. The level bound is single-sourced from
|
|
67
|
+
// levels.mjs so it can never drift from getLevel again. See ADR-0010.
|
|
68
|
+
export const ConfigSchema = z
|
|
69
|
+
.object({
|
|
70
|
+
level: z.number().int().min(MIN_LEVEL).max(MAX_LEVEL).default(2),
|
|
71
|
+
ledger: LedgerSchema,
|
|
72
|
+
l5: L5Schema,
|
|
73
|
+
deps: DepsSchema,
|
|
74
|
+
})
|
|
75
|
+
.passthrough()
|
|
76
|
+
.default({});
|
|
77
|
+
|
|
78
|
+
export function validateConfig(raw) {
|
|
79
|
+
const parsed = ConfigSchema.safeParse(raw ?? {});
|
|
80
|
+
if (parsed.success) return { ok: true, config: parsed.data };
|
|
81
|
+
return { ok: false, error: parsed.error };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function formatZodError(error) {
|
|
85
|
+
return error.issues
|
|
86
|
+
.map((i) => ` - ${i.path.length ? i.path.join('.') : '(root)'}: ${i.message}`)
|
|
87
|
+
.join('\n');
|
|
88
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composes `.claude/settings.json` hook wiring for a given activation level.
|
|
3
|
+
*
|
|
4
|
+
* Shared by the installer (`install.mjs`) and the in-project `/context-level`
|
|
5
|
+
* helper so they can never drift. It preserves the user's own hooks and
|
|
6
|
+
* top-level keys, stripping only previously-installed ContextDevKit entries
|
|
7
|
+
* (so re-running at a lower level cleanly removes now-disabled hooks).
|
|
8
|
+
*
|
|
9
|
+
* Level → hooks:
|
|
10
|
+
* 1 SessionStart
|
|
11
|
+
* 2 + PostToolUse (Edit|Write|MultiEdit), Stop
|
|
12
|
+
* 3 + PreToolUse (concurrency-guard) — and git hooks (installed separately)
|
|
13
|
+
* 5 + PreToolUse (simulate-gate)
|
|
14
|
+
* (Level 4 adds agents — not Claude hooks.)
|
|
15
|
+
*
|
|
16
|
+
* @param {Record<string, any> | null} existing parsed settings.json (or null)
|
|
17
|
+
* @param {number} level 1–7
|
|
18
|
+
* @returns {Record<string, any>}
|
|
19
|
+
*/
|
|
20
|
+
export function composeSettings(existing, level) {
|
|
21
|
+
const settings = existing && typeof existing === 'object' ? existing : {};
|
|
22
|
+
if (!settings['$schema']) settings['$schema'] = 'https://json.schemastore.org/claude-code-settings.json';
|
|
23
|
+
const hooks = settings.hooks && typeof settings.hooks === 'object' ? settings.hooks : {};
|
|
24
|
+
|
|
25
|
+
for (const evt of ['SessionStart', 'PostToolUse', 'Stop', 'PreToolUse']) {
|
|
26
|
+
if (!Array.isArray(hooks[evt])) continue;
|
|
27
|
+
hooks[evt] = hooks[evt]
|
|
28
|
+
.map((g) => ({ ...g, hooks: (g.hooks || []).filter((h) => !String(h.command || '').includes('contextkit/runtime/hooks')) }))
|
|
29
|
+
.filter((g) => (g.hooks || []).length > 0);
|
|
30
|
+
if (hooks[evt].length === 0) delete hooks[evt];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const add = (evt, matcher, script) => {
|
|
34
|
+
const entry = { hooks: [{ type: 'command', command: `node contextkit/runtime/hooks/${script}` }] };
|
|
35
|
+
if (matcher) entry.matcher = matcher;
|
|
36
|
+
(hooks[evt] = hooks[evt] || []).push(entry);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Status-line widget (level >= 1). Preserve a user's own statusLine — only set
|
|
40
|
+
// or replace a previously-installed ContextDevKit one.
|
|
41
|
+
if (level >= 1 && (!settings.statusLine || String(settings.statusLine.command || '').includes('contextkit/runtime/statusline'))) {
|
|
42
|
+
settings.statusLine = { type: 'command', command: 'node contextkit/runtime/statusline.mjs', padding: 0 };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (level >= 1) add('SessionStart', null, 'session-start.mjs');
|
|
46
|
+
if (level >= 2) {
|
|
47
|
+
add('PostToolUse', 'Edit|Write|MultiEdit', 'track-edits.mjs');
|
|
48
|
+
add('Stop', null, 'check-registration.mjs');
|
|
49
|
+
}
|
|
50
|
+
if (level >= 3) add('PreToolUse', 'Edit|Write|MultiEdit', 'concurrency-guard.mjs');
|
|
51
|
+
if (level >= 5) add('PreToolUse', 'Edit|Write|MultiEdit', 'simulate-gate.mjs');
|
|
52
|
+
|
|
53
|
+
settings.hooks = hooks;
|
|
54
|
+
return settings;
|
|
55
|
+
}
|