@event4u/agent-config 7.5.0 → 8.0.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/.claude-plugin/marketplace.json +8 -1
- package/AGENTS.md +9 -9
- package/CHANGELOG.md +325 -0
- package/README.md +35 -5
- package/dist/agent-src/commands/analytics/prune.md +1 -1
- package/dist/agent-src/commands/analytics/show.md +1 -1
- package/dist/agent-src/commands/analyze/decision.md +2 -2
- package/dist/agent-src/commands/analyze/incident.md +2 -2
- package/dist/agent-src/commands/analyze/near-miss.md +2 -2
- package/dist/agent-src/commands/analyze/postmortem.md +2 -2
- package/dist/agent-src/commands/analyze/premortem.md +2 -2
- package/dist/agent-src/commands/cost-report.md +25 -0
- package/dist/agent-src/commands/evals/analyze.json +30 -0
- package/dist/agent-src/commands/evals/mission-upgrade.json +30 -0
- package/dist/agent-src/commands/implement-ticket.md +1 -1
- package/dist/agent-src/commands/knowledge/forget.md +1 -1
- package/dist/agent-src/commands/knowledge/ingest.md +1 -1
- package/dist/agent-src/commands/knowledge/list.md +1 -1
- package/dist/agent-src/commands/memory/load.md +12 -11
- package/dist/agent-src/commands/memory/promote.md +30 -0
- package/dist/agent-src/commands/memory/propose.md +16 -2
- package/dist/agent-src/commands/mission/upgrade.md +1 -1
- package/dist/agent-src/commands/module/explore.md +11 -7
- package/dist/agent-src/commands/optimize-project.md +243 -0
- package/dist/agent-src/commands/optimize.md +5 -0
- package/dist/agent-src/commands/pr/create.md +37 -8
- package/dist/agent-src/commands/prediction-pool.md +2 -2
- package/dist/agent-src/commands/profile/activate.md +3 -3
- package/dist/agent-src/commands/profile/deactivate.md +2 -2
- package/dist/agent-src/commands/profile/show.md +3 -3
- package/dist/agent-src/commands/research/deep.md +5 -0
- package/dist/agent-src/commands/research/report.md +2 -1
- package/dist/agent-src/commands/roadmap/create.md +88 -10
- package/dist/agent-src/commands/roadmap/materialize.md +1 -1
- package/dist/agent-src/commands/roadmap/process-full.md +15 -2
- package/dist/agent-src/commands/roadmap/process-phase.md +18 -6
- package/dist/agent-src/commands/roadmap/process-step.md +4 -0
- package/dist/agent-src/commands/roadmap.md +1 -1
- package/dist/agent-src/commands/security-audit-config.md +1 -1
- package/dist/agent-src/commands/sync-agent-settings.md +1 -1
- package/dist/agent-src/commands/sync-gitignore/fix.md +42 -6
- package/dist/agent-src/commands/team-knowledge/bootstrap.md +106 -0
- package/dist/agent-src/commands/team-knowledge/consolidate.md +105 -0
- package/dist/agent-src/commands/team-knowledge.md +64 -0
- package/dist/agent-src/contexts/authority/commit-mechanics.md +8 -0
- package/dist/agent-src/contexts/authority/destructive-mechanics.md +11 -0
- package/dist/agent-src/contexts/authority/scope-mechanics.md +25 -0
- package/dist/agent-src/contexts/communication/rules-auto/reply-close-mechanics.md +43 -0
- package/dist/agent-src/contexts/contracts/agents-md-anatomy.md +1 -1
- package/dist/agent-src/contexts/contracts/artifact-engagement-flow.md +2 -2
- package/dist/agent-src/contexts/contracts/frugality-charter.md +1 -0
- package/dist/agent-src/contexts/execution/auto-dispatch-classification.md +14 -4
- package/dist/agent-src/contexts/execution/autonomy-mechanics.md +11 -0
- package/dist/agent-src/contexts/execution/orchestration-telemetry.md +32 -8
- package/dist/agent-src/contexts/execution/roadmap-execution-contract.md +107 -0
- package/dist/agent-src/contexts/execution/roadmap-process-loop.md +71 -15
- package/dist/agent-src/contexts/execution/subagent-steering.md +41 -1
- package/dist/agent-src/contexts/override-system.md +1 -1
- package/dist/agent-src/personas/brand-strategist.md +0 -1
- package/dist/agent-src/personas/data-integrity.md +66 -0
- package/dist/agent-src/personas/design-director.md +0 -1
- package/dist/agent-src/personas/performance-engineer.md +66 -0
- package/dist/agent-src/personas/production-validator.md +73 -0
- package/dist/agent-src/rules/agent-authority.md +3 -4
- package/dist/agent-src/rules/analysis-skill-routing.md +3 -5
- package/dist/agent-src/rules/architecture.md +2 -4
- package/dist/agent-src/rules/artifact-drafting-protocol.md +35 -6
- package/dist/agent-src/rules/artifact-engagement-recording.md +2 -4
- package/dist/agent-src/rules/ask-when-uncertain.md +10 -14
- package/dist/agent-src/rules/augment-edit-discipline.md +3 -5
- package/dist/agent-src/rules/autonomous-execution.md +3 -5
- package/dist/agent-src/rules/brand-consistency.md +3 -5
- package/dist/agent-src/rules/brand-source-of-truth.md +3 -5
- package/dist/agent-src/rules/cli-output-handling.md +4 -6
- package/dist/agent-src/rules/command-suggestion-policy.md +3 -5
- package/dist/agent-src/rules/commit-conventions.md +3 -5
- package/dist/agent-src/rules/commit-policy.md +8 -10
- package/dist/agent-src/rules/content-quoting-floor.md +88 -0
- package/dist/agent-src/rules/context-hygiene.md +3 -5
- package/dist/agent-src/rules/copilot-routing.md +4 -6
- package/dist/agent-src/rules/decision-revisit-gate.md +120 -0
- package/dist/agent-src/rules/delegation-policy.md +10 -6
- package/dist/agent-src/rules/design-fidelity.md +3 -5
- package/dist/agent-src/rules/devcontainer-routing.md +4 -6
- package/dist/agent-src/rules/direct-answers.md +13 -17
- package/dist/agent-src/rules/docker-commands.md +3 -5
- package/dist/agent-src/rules/domain-adoption-policy.md +3 -5
- package/dist/agent-src/rules/domain-safety-disclaimer.md +3 -5
- package/dist/agent-src/rules/domain-safety-pii.md +3 -5
- package/dist/agent-src/rules/domain-safety-retention.md +3 -5
- package/dist/agent-src/rules/downstream-changes.md +3 -4
- package/dist/agent-src/rules/engineering-safety-floor.md +3 -5
- package/dist/agent-src/rules/external-reference-deep-dive.md +3 -5
- package/dist/agent-src/rules/fast-path-marker-visibility.md +3 -5
- package/dist/agent-src/rules/finance-safety-floor.md +3 -6
- package/dist/agent-src/rules/framework-neutrality-in-generic-skills.md +3 -5
- package/dist/agent-src/rules/git-history-discipline.md +3 -5
- package/dist/agent-src/rules/guidelines.md +2 -4
- package/dist/agent-src/rules/icon-consistency.md +3 -5
- package/dist/agent-src/rules/image-likeness-and-rights.md +3 -5
- package/dist/agent-src/rules/improve-before-implement.md +5 -5
- package/dist/agent-src/rules/invite-challenge.md +3 -5
- package/dist/agent-src/rules/language-and-tone.md +13 -15
- package/dist/agent-src/rules/laravel-routing.md +3 -5
- package/dist/agent-src/rules/laravel-translations.md +3 -5
- package/dist/agent-src/rules/legal-safety-floor.md +3 -5
- package/dist/agent-src/rules/lethal-trifecta-guard.md +3 -5
- package/dist/agent-src/rules/linked-projects-onboarding-gate.md +4 -7
- package/dist/agent-src/rules/low-impact-corpus-privacy-floor.md +3 -5
- package/dist/agent-src/rules/markdown-safe-codeblocks.md +2 -4
- package/dist/agent-src/rules/media-governance-routing.md +3 -5
- package/dist/agent-src/rules/media-sync-ground-truth.md +3 -5
- package/dist/agent-src/rules/minimal-safe-diff.md +5 -5
- package/dist/agent-src/rules/missing-tool-handling.md +3 -5
- package/dist/agent-src/rules/model-recommendation.md +4 -6
- package/dist/agent-src/rules/no-attribution-footers.md +3 -5
- package/dist/agent-src/rules/no-cheap-questions.md +5 -8
- package/dist/agent-src/rules/no-decorative-emojis-in-git-surfaces.md +3 -6
- package/dist/agent-src/rules/no-pr-progress-comments.md +3 -6
- package/dist/agent-src/rules/no-roadmap-references.md +3 -5
- package/dist/agent-src/rules/non-destructive-by-default.md +11 -13
- package/dist/agent-src/rules/notes-first-reasoning.md +3 -5
- package/dist/agent-src/rules/onboarding-gate.md +4 -6
- package/dist/agent-src/rules/output-discipline.md +3 -5
- package/dist/agent-src/rules/package-ci-checks.md +3 -5
- package/dist/agent-src/rules/persona-governance.md +2 -4
- package/dist/agent-src/rules/php-coding.md +3 -5
- package/dist/agent-src/rules/preservation-guard.md +2 -4
- package/dist/agent-src/rules/provider-lifecycle-discipline.md +3 -5
- package/dist/agent-src/rules/reviewer-awareness.md +5 -6
- package/dist/agent-src/rules/roadmap-ci-steps-policy.md +3 -5
- package/dist/agent-src/rules/roadmap-progress-sync.md +5 -5
- package/dist/agent-src/rules/role-mode-adherence.md +2 -4
- package/dist/agent-src/rules/rule-type-governance.md +3 -5
- package/dist/agent-src/rules/runtime-safety.md +2 -4
- package/dist/agent-src/rules/scope-control.md +10 -11
- package/dist/agent-src/rules/security-sensitive-stop.md +4 -5
- package/dist/agent-src/rules/size-enforcement.md +2 -4
- package/dist/agent-src/rules/skill-improvement-trigger.md +3 -5
- package/dist/agent-src/rules/skill-quality.md +3 -5
- package/dist/agent-src/rules/slash-command-routing-policy.md +3 -5
- package/dist/agent-src/rules/source-confidentiality.md +3 -5
- package/dist/agent-src/rules/source-discovery-gate.md +3 -5
- package/dist/agent-src/rules/source-of-truth.md +3 -5
- package/dist/agent-src/rules/strategy-safety-floor.md +3 -5
- package/dist/agent-src/rules/symfony-routing.md +4 -6
- package/dist/agent-src/rules/telegraph-speak.md +4 -5
- package/dist/agent-src/rules/think-before-action.md +7 -4
- package/dist/agent-src/rules/token-budget-discipline.md +29 -5
- package/dist/agent-src/rules/token-efficiency.md +3 -5
- package/dist/agent-src/rules/token-optimizer-maintenance.md +3 -5
- package/dist/agent-src/rules/tool-safety.md +2 -4
- package/dist/agent-src/rules/ui-audit-gate.md +3 -6
- package/dist/agent-src/rules/untrusted-input-defense.md +3 -5
- package/dist/agent-src/rules/upstream-proposal.md +4 -6
- package/dist/agent-src/rules/user-interaction.md +7 -5
- package/dist/agent-src/rules/user-interrupt-priority.md +17 -8
- package/dist/agent-src/rules/verify-before-complete.md +12 -22
- package/dist/agent-src/scripts/archive_completed_roadmaps.ts +3 -3
- package/dist/agent-src/scripts/update_roadmap_progress.ts +197 -7
- package/dist/agent-src/skills/adr-create/SKILL.md +48 -42
- package/dist/agent-src/skills/agent-docs-writing/SKILL.md +18 -0
- package/dist/agent-src/skills/agent-security-review/SKILL.md +1 -1
- package/dist/agent-src/skills/ai-council/SKILL.md +14 -1
- package/dist/agent-src/skills/blameless-post-mortem/SKILL.md +0 -3
- package/dist/agent-src/skills/brand/SKILL.md +1 -1
- package/dist/agent-src/skills/brand-identity/SKILL.md +3 -3
- package/dist/agent-src/skills/brand-strategy/SKILL.md +1 -1
- package/dist/agent-src/skills/brand-to-tokens/SKILL.md +3 -3
- package/dist/agent-src/skills/canvas-design/SKILL.md +6 -0
- package/dist/agent-src/skills/check-refs/SKILL.md +7 -4
- package/dist/agent-src/skills/code-review/SKILL.md +1 -0
- package/dist/agent-src/skills/complexity-first-planning/SKILL.md +6 -5
- package/dist/agent-src/skills/condense-memory/SKILL.md +11 -11
- package/dist/agent-src/skills/context-document/SKILL.md +17 -0
- package/dist/agent-src/skills/corpus-grounding/SKILL.md +3 -3
- package/dist/agent-src/skills/decision-record/SKILL.md +6 -0
- package/dist/agent-src/skills/decision-review/SKILL.md +5 -3
- package/dist/agent-src/skills/deep-reading-analyst/SKILL.md +6 -1
- package/dist/agent-src/skills/design-intelligence/SKILL.md +5 -2
- package/dist/agent-src/skills/design-intelligence/references/design-languages.md +1 -1
- package/dist/agent-src/skills/design-tokens/SKILL.md +10 -4
- package/dist/agent-src/skills/design-variations/SKILL.md +127 -0
- package/dist/agent-src/skills/design-variations/evals/triggers.json +17 -0
- package/dist/agent-src/skills/emit-tickets/SKILL.md +4 -4
- package/dist/agent-src/skills/fe-design/SKILL.md +20 -0
- package/dist/agent-src/skills/html-deck/SKILL.md +123 -0
- package/dist/agent-src/skills/html-deck/evals/triggers.json +17 -0
- package/dist/agent-src/skills/html-deck/templates/deck-shell.html +77 -0
- package/dist/agent-src/skills/judge-code-quality/SKILL.md +1 -0
- package/dist/agent-src/skills/laravel/SKILL.md +0 -1
- package/dist/agent-src/skills/learning-to-rule-or-skill/SKILL.md +46 -0
- package/dist/agent-src/skills/lint-skills/SKILL.md +6 -6
- package/dist/agent-src/skills/md-language-check/SKILL.md +3 -3
- package/dist/agent-src/skills/memory-consolidation/SKILL.md +66 -1
- package/dist/agent-src/skills/migration-architect/SKILL.md +1 -0
- package/dist/agent-src/skills/module-detect-on-the-fly/SKILL.md +2 -2
- package/dist/agent-src/skills/performance-analysis/SKILL.md +2 -0
- package/dist/agent-src/skills/prediction-pool-optimizer/SKILL.md +4 -4
- package/dist/agent-src/skills/premortem/SKILL.md +0 -3
- package/dist/agent-src/skills/project-analysis-core/SKILL.md +16 -0
- package/dist/agent-src/skills/reasoning-orchestrator/SKILL.md +3 -1
- package/dist/agent-src/skills/release-comms/SKILL.md +46 -45
- package/dist/agent-src/skills/roadmap-management/SKILL.md +21 -0
- package/dist/agent-src/skills/roadmap-writing/SKILL.md +32 -2
- package/dist/agent-src/skills/root-cause-frameworks/SKILL.md +0 -3
- package/dist/agent-src/skills/security-audit/SKILL.md +1 -0
- package/dist/agent-src/skills/skill-improvement-pipeline/SKILL.md +4 -0
- package/dist/agent-src/skills/source-discovery/SKILL.md +22 -3
- package/dist/agent-src/skills/subagent-orchestration/SKILL.md +33 -14
- package/dist/agent-src/skills/subagent-orchestration/prompts/README.md +11 -0
- package/dist/agent-src/skills/subagent-orchestration/prompts/do-in-steps.md +8 -0
- package/dist/agent-src/skills/systematic-debugging/SKILL.md +29 -0
- package/dist/agent-src/skills/threat-modeling/SKILL.md +2 -2
- package/dist/agent-src/skills/typography-system/SKILL.md +2 -2
- package/dist/agent-src/skills/verify-completion-evidence/SKILL.md +2 -0
- package/dist/agent-src/skills/wireframe/SKILL.md +118 -0
- package/dist/agent-src/skills/wireframe/evals/triggers.json +17 -0
- package/dist/agent-src/templates/agent-settings.md +22 -1
- package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
- package/dist/agent-src/templates/command.md +2 -2
- package/dist/agent-src/templates/contexts/knowledge-pages.md +116 -0
- package/dist/agent-src/templates/hooks/pre-commit-frontmatter +1 -1
- package/dist/agent-src/templates/roadmaps.md +70 -2
- package/dist/agent-src/templates/rule.md +1 -1
- package/dist/agent-src/templates/scripts/README.md +3 -3
- package/dist/agent-src/templates/scripts/work_engine/_lib/agent_settings.ts +109 -0
- package/dist/agent-src/templates/tickets.md +8 -8
- package/dist/cli/commands/recordTriggerEval.test.js +1 -1
- package/dist/cli/commands/recordTriggerEval.test.js.map +1 -1
- package/dist/cli/initRouting.js +4 -2
- package/dist/cli/initRouting.js.map +1 -1
- package/dist/cli/registry.js +1 -0
- package/dist/cli/registry.js.map +1 -1
- package/dist/discovery/deprecation-report.md +1 -1
- package/dist/discovery/discovery-manifest.json +718 -240
- package/dist/discovery/discovery-manifest.json.sha256 +1 -1
- package/dist/discovery/discovery-manifest.summary.md +8 -8
- package/dist/discovery/orphan-report.md +1 -1
- package/dist/discovery/packs.json +43 -28
- package/dist/discovery/trust-report.md +12 -11
- package/dist/discovery/workspaces.json +29 -18
- package/dist/install/preflight.js +173 -0
- package/dist/install/preflight.js.map +1 -0
- package/dist/mcp/registry-manifest.json +4 -4
- package/dist/router.json +1 -1
- package/dist/server/routes/settings.js +4 -0
- package/dist/server/routes/settings.js.map +1 -1
- package/dist/server/schemas/settings.js +3 -1
- package/dist/server/schemas/settings.js.map +1 -1
- package/docs/CLAIMS.md +108 -0
- package/docs/MIGRATION.md +3 -3
- package/docs/architecture.md +5 -5
- package/docs/benchmark.md +133 -2
- package/docs/benchmark.pinned.yml +31 -0
- package/docs/capability-matrix.md +1 -0
- package/docs/catalog.md +70 -60
- package/docs/command-flows.md +15 -3
- package/docs/comparison.yaml +35 -0
- package/docs/contracts/agents-layout.md +148 -0
- package/docs/contracts/brand-token-consumption.md +5 -0
- package/docs/contracts/capability-boundary.md +5 -0
- package/docs/contracts/command-category-governance.md +5 -0
- package/docs/contracts/command-clusters.md +1 -0
- package/docs/contracts/command-surface-tiers.md +1 -1
- package/docs/contracts/conformance.md +84 -0
- package/docs/contracts/creative-pack-boundary.md +5 -0
- package/docs/contracts/discovery-manifest.schema.json +5 -4
- package/docs/contracts/file-ownership-matrix.json +4605 -985
- package/docs/contracts/governance-enforcement-projection.md +5 -0
- package/docs/contracts/gui-wizard.md +1 -1
- package/docs/contracts/hook-architecture-v1.md +2 -2
- package/docs/contracts/implement-ticket-flow.md +1 -1
- package/docs/contracts/kernel-membership.md +13 -0
- package/docs/contracts/mcp-tool-inventory.md +23 -23
- package/docs/contracts/no-runtime-boundary.md +6 -1
- package/docs/contracts/review-lens-schema.md +5 -0
- package/docs/contracts/rule-router.md +102 -8
- package/docs/contracts/skill-bundled-assets.md +1 -1
- package/docs/contracts/skill-dry-run.md +1 -1
- package/docs/contracts/subagent-boundary.md +5 -0
- package/docs/contracts/ticket-bundle-format.md +9 -4
- package/docs/contracts/tier-3-contrib-plugin.md +2 -2
- package/docs/contracts/write-engine.md +3 -0
- package/docs/customization.md +87 -15
- package/docs/decisions/ADR-107-legal-domain-pack-adoption.md +1 -1
- package/docs/decisions/ADR-109-subagent-v1-contract.md +246 -0
- package/docs/decisions/ADR-110-discipline-profile-resolution-locus.md +105 -0
- package/docs/decisions/INDEX.md +2 -0
- package/docs/distribution/awesome-list-submission.md +46 -0
- package/docs/distribution/launch-story-draft.md +58 -0
- package/docs/end-to-end-walkthroughs.md +2 -2
- package/docs/getting-started.md +2 -2
- package/docs/guidelines/agent-infra/asking-and-brevity-examples.md +24 -0
- package/docs/guidelines/agent-infra/corpus-grounding-authoring.md +1 -1
- package/docs/guidelines/agent-infra/linked-projects-onboarding-gate.md +2 -2
- package/docs/guidelines/agent-infra/missing-tool-handling.md +3 -3
- package/docs/guidelines/agent-infra/verify-before-complete-demos.md +2 -2
- package/docs/guidelines/augment-portability-patterns.md +1 -1
- package/docs/guidelines/code-clarity.md +19 -0
- package/docs/guidelines/design-antipatterns-triggers.json +2 -1
- package/docs/guidelines/design-antipatterns.md +10 -1
- package/docs/guidelines/design-modes.md +6 -0
- package/docs/guidelines/php/general.md +9 -1
- package/docs/guidelines/php/php-coding-patterns.md +7 -0
- package/docs/guides/cross-repo-retrieval.md +1 -1
- package/docs/guides/frontend-design-corpus-refresh.md +2 -2
- package/docs/guides/local-analytics.md +4 -4
- package/docs/guides/skill-discovery.md +1 -1
- package/docs/guides/skill-preview.md +1 -1
- package/docs/hook-payload-capture.md +6 -6
- package/docs/install-friction-report.md +66 -0
- package/docs/installation.md +1 -1
- package/docs/maintainers/optional-media-deps.md +50 -0
- package/docs/mcp-server.md +11 -12
- package/docs/media/proof-demo.cast +14 -0
- package/docs/media/proof-demo.gif +0 -0
- package/docs/migration/consumer-template-consumption-model.md +1 -1
- package/docs/migration/divergences/bench-stats-float-precision.md +1 -1
- package/docs/migration/node-floor.md +1 -1
- package/docs/migration/yaml-roundtrip-spike.md +1 -1
- package/docs/personas.md +16 -5
- package/docs/positioning-evidence.md +86 -0
- package/docs/proof.md +86 -0
- package/docs/skills-catalog.md +1 -1
- package/docs/troubleshooting.md +8 -8
- package/docs/wedge/production-validator/README.md +57 -0
- package/docs/wedge/production-validator/production-validator.md +56 -0
- package/docs/wizard.md +2 -2
- package/package.json +1 -1
- package/src/config/agent-settings.template.yml +59 -4
- package/src/config/agents-paths.yml +254 -0
- package/src/config/budgets.yml +16 -0
- package/src/config/discovery/packs.yml +1 -0
- package/src/config/discovery/unassigned-artefacts.yml +2 -0
- package/src/config/gitignore-block.txt +25 -0
- package/src/config/host-capabilities.yml +31 -0
- package/src/config/profiles/balanced.ini +4 -0
- package/src/config/profiles/full.ini +4 -0
- package/src/config/profiles/minimal.ini +4 -0
- package/src/scripts/_cli/cmd_conformance.ts +716 -0
- package/src/scripts/_cli/cmd_doctor.ts +23 -2
- package/src/scripts/_cli/cmd_fleet.ts +401 -0
- package/src/scripts/_cli/cmd_preflight.ts +159 -0
- package/src/scripts/_dispatch.bash +10 -0
- package/src/scripts/_lib/knowledge_events.ts +193 -0
- package/src/scripts/_lib/subagent_steering.ts +115 -3
- package/src/scripts/_lib/text_similarity.ts +75 -0
- package/src/scripts/ai-video/test-pipeline.sh +1 -1
- package/src/scripts/ai_council/clients.ts +19 -3
- package/src/scripts/append_contested.ts +112 -0
- package/src/scripts/audit_auto_rules.ts +11 -1
- package/src/scripts/audit_mcp_tools.ts +25 -11
- package/src/scripts/bench_ab_v2_run.ts +527 -40
- package/src/scripts/bench_ab_v2_stats.ts +6 -0
- package/src/scripts/bench_matrix.ts +266 -0
- package/src/scripts/bootstrap_knowledge.ts +267 -0
- package/src/scripts/build_discovery_manifest.ts +42 -2
- package/src/scripts/build_proof.ts +214 -0
- package/src/scripts/check_always_budget.ts +3 -0
- package/src/scripts/check_augment_description_cap.ts +2 -2
- package/src/scripts/check_claims.ts +270 -0
- package/src/scripts/check_comparison.ts +79 -0
- package/src/scripts/check_generated_artefact_headers.ts +109 -0
- package/src/scripts/check_generator_output_coverage.ts +142 -0
- package/src/scripts/check_gitignore_freshness.ts +127 -0
- package/src/scripts/check_knowledge_pages.ts +210 -0
- package/src/scripts/check_knowledge_sharing.ts +162 -0
- package/src/scripts/check_media_deps.ts +91 -0
- package/src/scripts/check_memory_contradiction.ts +280 -0
- package/src/scripts/check_memory_similarity.ts +134 -0
- package/src/scripts/check_quality_regression.ts +56 -10
- package/src/scripts/check_references.ts +3 -1
- package/src/scripts/check_release_pr_shape.ts +4 -0
- package/src/scripts/check_site_links.ts +135 -0
- package/src/scripts/check_skill_gaps.ts +99 -0
- package/src/scripts/check_token_quality_golden.ts +197 -11
- package/src/scripts/check_tracked_but_ignored.ts +67 -0
- package/src/scripts/cluster_near_miss_patterns.ts +0 -0
- package/src/scripts/compile_router.ts +30 -3
- package/src/scripts/condense.ts +350 -14
- package/src/scripts/consolidate_knowledge_events.ts +192 -0
- package/src/scripts/degrade_to_pointer.ts +136 -0
- package/src/scripts/design_slop_rules.test.ts +15 -0
- package/src/scripts/design_slop_rules.ts +28 -0
- package/src/scripts/emit_knowledge_event.ts +158 -0
- package/src/scripts/export_replay_corpus.ts +187 -0
- package/src/scripts/external_sources_denylist.json +7 -2
- package/src/scripts/fold_intake.ts +281 -0
- package/src/scripts/generate_capability_matrix.ts +9 -1
- package/src/scripts/generate_knowledge_index.ts +222 -0
- package/src/scripts/hook_manifest.yaml +26 -14
- package/src/scripts/hooks/dispatch_hook.ts +18 -0
- package/src/scripts/hot_context_hook.ts +372 -0
- package/src/scripts/install +47 -0
- package/src/scripts/install-hooks.sh +17 -0
- package/src/scripts/inventory_meta_layers.ts +11 -0
- package/src/scripts/janitor.ts +258 -0
- package/src/scripts/lint_agents_layout.ts +74 -15
- package/src/scripts/lint_bench_ab.ts +4 -1
- package/src/scripts/lint_featured_skills.ts +0 -0
- package/src/scripts/lint_framework_leakage_allowlist.json +26 -3
- package/src/scripts/lint_knowledge_scale.ts +250 -0
- package/src/scripts/lint_legal_pack.ts +67 -0
- package/src/scripts/lint_persona_governance.ts +8 -3
- package/src/scripts/lint_regression.ts +15 -0
- package/src/scripts/lint_roadmap_blockers.ts +202 -0
- package/src/scripts/lint_roadmap_complexity.ts +81 -2
- package/src/scripts/lint_subagent_determinism.ts +125 -0
- package/src/scripts/measure_augment_budget.ts +46 -6
- package/src/scripts/measure_patterns.ts +4 -3
- package/src/scripts/measure_skill_reduction.ts +6 -6
- package/src/scripts/migration_status.ts +6 -2
- package/src/scripts/mine_missing_guardrails.ts +189 -0
- package/src/scripts/parity/phase_gate.ts +1 -1
- package/src/scripts/parity/replay.ts +21 -0
- package/src/scripts/project_thin_rules.ts +120 -16
- package/src/scripts/release.ts +39 -1
- package/src/scripts/render_benchmark_composite.ts +378 -0
- package/src/scripts/roadmap_progress_hook.ts +101 -43
- package/src/scripts/schemas/skill.schema.json +27 -0
- package/src/scripts/schemas/subagent.schema.json +106 -0
- package/src/scripts/skill_linter.ts +1 -0
- package/src/scripts/smoke/kernel.sh +5 -4
- package/src/scripts/surface-tiers.yml +1 -0
- package/src/scripts/sync_gitignore.ts +4 -0
- package/src/scripts/update_skill_candidates.ts +172 -0
- package/src/scripts/validate_frontmatter.ts +1 -0
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
/**
|
|
3
|
+
* Idempotent extractive fold rollup over the gitignored intake JSONL —
|
|
4
|
+
* road-to-second-brain Phase 3 (council 2026-07-07, verdict:
|
|
5
|
+
* `agents/settings/contexts/second-brain-delta-verdict.md`).
|
|
6
|
+
*
|
|
7
|
+
* Deterministic compression for the linearly-growing intake stream:
|
|
8
|
+
* - **2^k batching** — consecutive, non-overlapping batches of
|
|
9
|
+
* `--batch-size` events (default 32; must be a power of two) in stable
|
|
10
|
+
* file+line order. Only COMPLETE batches fold; the tail stays live.
|
|
11
|
+
* - **Deterministic fold IDs** — sha256 over the batch's raw JSONL lines,
|
|
12
|
+
* first 12 hex chars. Same input → same ID, always.
|
|
13
|
+
* - **Children never mutated** — the intake files are read-only to this
|
|
14
|
+
* script; a fold is an ADDITIVE archive page with link-backs
|
|
15
|
+
* (`<file>:<first-line>-<last-line>` per child range), never a rewrite.
|
|
16
|
+
* - **Idempotent** — an existing `fold-<id>.md` is skipped, so re-runs are
|
|
17
|
+
* no-ops and interrupted runs resume cleanly.
|
|
18
|
+
*
|
|
19
|
+
* MANUAL TRIGGER ONLY (council decision): this script is deliberately NOT
|
|
20
|
+
* wired into hooks or CI. The Phase-0 intake tripwire
|
|
21
|
+
* (`lint_knowledge_scale.ts`, intake > 2000 events) names this script as its
|
|
22
|
+
* pre-decided activation path — when it fires, wire the script into the
|
|
23
|
+
* post-session/CI cadence. Tracked files (`agents/knowledge/sessions/`) are
|
|
24
|
+
* NEVER fold-compressed here; that path requires the consolidate gate.
|
|
25
|
+
*
|
|
26
|
+
* Usage:
|
|
27
|
+
* fold_intake.ts [--intake-dir agents/knowledge/intake]
|
|
28
|
+
* [--out-dir agents/memory/archive]
|
|
29
|
+
* [--batch-size 32] [--dry-run] [--format text|json]
|
|
30
|
+
*
|
|
31
|
+
* Exit codes: 0 = ok (including nothing-to-fold), 2 = usage error,
|
|
32
|
+
* 3 = internal error.
|
|
33
|
+
*/
|
|
34
|
+
import { createHash } from 'node:crypto';
|
|
35
|
+
import * as fs from 'node:fs';
|
|
36
|
+
import * as path from 'node:path';
|
|
37
|
+
import process from 'node:process';
|
|
38
|
+
import { fileURLToPath } from 'node:url';
|
|
39
|
+
|
|
40
|
+
const PROG = 'fold_intake.ts';
|
|
41
|
+
|
|
42
|
+
export const DEFAULT_BATCH_SIZE = 32;
|
|
43
|
+
const DEFAULT_INTAKE_DIR = path.join('agents', 'knowledge', 'intake');
|
|
44
|
+
const DEFAULT_OUT_DIR = path.join('agents', 'memory', 'archive');
|
|
45
|
+
const SNIPPET_CHARS = 140;
|
|
46
|
+
|
|
47
|
+
export interface IntakeLine {
|
|
48
|
+
file: string; // relative or absolute path as discovered
|
|
49
|
+
line: number; // 1-based line number within the file
|
|
50
|
+
raw: string; // raw JSONL line (trimmed)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface FoldPlan {
|
|
54
|
+
id: string;
|
|
55
|
+
index: number; // 0-based batch index in the stable order
|
|
56
|
+
children: IntakeLine[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function listIntakeFiles(dir: string): string[] {
|
|
60
|
+
let names: string[];
|
|
61
|
+
try {
|
|
62
|
+
names = fs.readdirSync(dir);
|
|
63
|
+
} catch {
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
return names
|
|
67
|
+
.filter((n) => n.startsWith('events-') && n.endsWith('.jsonl'))
|
|
68
|
+
.sort()
|
|
69
|
+
.map((n) => path.join(dir, n));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Stable event order: sorted(files) then line order. Children read-only. */
|
|
73
|
+
export function readIntakeLines(dir: string): IntakeLine[] {
|
|
74
|
+
const out: IntakeLine[] = [];
|
|
75
|
+
for (const file of listIntakeFiles(dir)) {
|
|
76
|
+
let text: string;
|
|
77
|
+
try {
|
|
78
|
+
text = fs.readFileSync(file, 'utf-8');
|
|
79
|
+
} catch {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const lines = text.split('\n');
|
|
83
|
+
for (let i = 0; i < lines.length; i++) {
|
|
84
|
+
const raw = (lines[i] ?? '').trim();
|
|
85
|
+
if (!raw) continue;
|
|
86
|
+
out.push({ file, line: i + 1, raw });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return out;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function foldId(children: IntakeLine[]): string {
|
|
93
|
+
const h = createHash('sha256');
|
|
94
|
+
for (const c of children) {
|
|
95
|
+
h.update(c.raw);
|
|
96
|
+
h.update('\n');
|
|
97
|
+
}
|
|
98
|
+
return h.digest('hex').slice(0, 12);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Consecutive complete batches of `batchSize`; the tail stays unfolded. */
|
|
102
|
+
export function planFolds(lines: IntakeLine[], batchSize: number): FoldPlan[] {
|
|
103
|
+
const plans: FoldPlan[] = [];
|
|
104
|
+
const complete = Math.floor(lines.length / batchSize);
|
|
105
|
+
for (let b = 0; b < complete; b++) {
|
|
106
|
+
const children = lines.slice(b * batchSize, (b + 1) * batchSize);
|
|
107
|
+
plans.push({ id: foldId(children), index: b, children });
|
|
108
|
+
}
|
|
109
|
+
return plans;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function snippet(raw: string): string {
|
|
113
|
+
let parsed: unknown;
|
|
114
|
+
try {
|
|
115
|
+
parsed = JSON.parse(raw);
|
|
116
|
+
} catch {
|
|
117
|
+
return raw.slice(0, SNIPPET_CHARS);
|
|
118
|
+
}
|
|
119
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
120
|
+
return raw.slice(0, SNIPPET_CHARS);
|
|
121
|
+
}
|
|
122
|
+
const e = parsed as Record<string, unknown>;
|
|
123
|
+
const ts = typeof e.ts === 'string' ? e.ts : '';
|
|
124
|
+
const type = typeof e.type === 'string' ? e.type : 'event';
|
|
125
|
+
// First string field that carries the claim, by event-type precedence.
|
|
126
|
+
const claim =
|
|
127
|
+
[e.pattern, e.correction, e.endpoint, e.observation, e.body, e.text].find(
|
|
128
|
+
(v): v is string => typeof v === 'string' && v.trim().length > 0,
|
|
129
|
+
) ?? '';
|
|
130
|
+
const oneLine = claim.replace(/\s+/g, ' ').trim();
|
|
131
|
+
const clipped = oneLine.length > SNIPPET_CHARS ? oneLine.slice(0, SNIPPET_CHARS - 1) + '…' : oneLine;
|
|
132
|
+
return [ts, type, clipped].filter(Boolean).join(' · ');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Contiguous per-file line ranges for the link-back section. */
|
|
136
|
+
export function childRanges(children: IntakeLine[]): string[] {
|
|
137
|
+
const ranges: string[] = [];
|
|
138
|
+
let start: IntakeLine | null = null;
|
|
139
|
+
let prev: IntakeLine | null = null;
|
|
140
|
+
const flush = (): void => {
|
|
141
|
+
if (start && prev) {
|
|
142
|
+
ranges.push(
|
|
143
|
+
start.line === prev.line
|
|
144
|
+
? `${start.file}:${start.line}`
|
|
145
|
+
: `${start.file}:${start.line}-${prev.line}`,
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
for (const c of children) {
|
|
150
|
+
if (prev && c.file === prev.file && c.line === prev.line + 1) {
|
|
151
|
+
prev = c;
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
flush();
|
|
155
|
+
start = c;
|
|
156
|
+
prev = c;
|
|
157
|
+
}
|
|
158
|
+
flush();
|
|
159
|
+
return ranges;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export function renderFold(plan: FoldPlan, batchSize: number): string {
|
|
163
|
+
const lines: string[] = [
|
|
164
|
+
`# Fold ${plan.id}`,
|
|
165
|
+
'',
|
|
166
|
+
'> Idempotent extractive rollup of a completed intake batch',
|
|
167
|
+
`> (batch ${plan.index}, size ${batchSize}). Children are never mutated —`,
|
|
168
|
+
'> this page is an additive archive with link-backs, not a rewrite.',
|
|
169
|
+
'> Generated by `src/scripts/fold_intake.ts` (deterministic, no LLM).',
|
|
170
|
+
'',
|
|
171
|
+
`Fold ID: ${plan.id}`,
|
|
172
|
+
`Batch index: ${plan.index}`,
|
|
173
|
+
`Events: ${plan.children.length}`,
|
|
174
|
+
'',
|
|
175
|
+
'## Extract',
|
|
176
|
+
'',
|
|
177
|
+
];
|
|
178
|
+
for (const c of plan.children) {
|
|
179
|
+
lines.push(`- ${snippet(c.raw)}`);
|
|
180
|
+
}
|
|
181
|
+
lines.push('', '## Children (link-backs)', '');
|
|
182
|
+
for (const r of childRanges(plan.children)) {
|
|
183
|
+
lines.push(`- ${r}`);
|
|
184
|
+
}
|
|
185
|
+
lines.push('');
|
|
186
|
+
return lines.join('\n');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function main(argv: string[]): number {
|
|
190
|
+
let intakeDir = DEFAULT_INTAKE_DIR;
|
|
191
|
+
let outDir = DEFAULT_OUT_DIR;
|
|
192
|
+
let batchSize = DEFAULT_BATCH_SIZE;
|
|
193
|
+
let dryRun = false;
|
|
194
|
+
let format = 'text';
|
|
195
|
+
|
|
196
|
+
for (let i = 0; i < argv.length; i++) {
|
|
197
|
+
const a = argv[i];
|
|
198
|
+
const next = (): string => {
|
|
199
|
+
const v = argv[++i];
|
|
200
|
+
if (v === undefined) {
|
|
201
|
+
process.stderr.write(`${PROG}: error: ${a} requires a value\n`);
|
|
202
|
+
process.exit(2);
|
|
203
|
+
}
|
|
204
|
+
return v;
|
|
205
|
+
};
|
|
206
|
+
if (a === '--intake-dir') intakeDir = next();
|
|
207
|
+
else if (a === '--out-dir') outDir = next();
|
|
208
|
+
else if (a === '--batch-size') {
|
|
209
|
+
batchSize = Number(next());
|
|
210
|
+
if (!Number.isInteger(batchSize) || batchSize < 2 || (batchSize & (batchSize - 1)) !== 0) {
|
|
211
|
+
process.stderr.write(`${PROG}: error: --batch-size must be a power of two >= 2\n`);
|
|
212
|
+
return 2;
|
|
213
|
+
}
|
|
214
|
+
} else if (a === '--dry-run') dryRun = true;
|
|
215
|
+
else if (a === '--format') {
|
|
216
|
+
format = next();
|
|
217
|
+
if (format !== 'text' && format !== 'json') {
|
|
218
|
+
process.stderr.write(`${PROG}: error: --format must be text|json\n`);
|
|
219
|
+
return 2;
|
|
220
|
+
}
|
|
221
|
+
} else if (a === '-h' || a === '--help') {
|
|
222
|
+
process.stdout.write(
|
|
223
|
+
`usage: ${PROG} [--intake-dir <dir>] [--out-dir <dir>] ` +
|
|
224
|
+
`[--batch-size <2^k>] [--dry-run] [--format text|json]\n`,
|
|
225
|
+
);
|
|
226
|
+
return 0;
|
|
227
|
+
} else {
|
|
228
|
+
process.stderr.write(`${PROG}: error: unknown argument ${a}\n`);
|
|
229
|
+
return 2;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
try {
|
|
234
|
+
const lines = readIntakeLines(intakeDir);
|
|
235
|
+
const plans = planFolds(lines, batchSize);
|
|
236
|
+
const results: Array<{ id: string; index: number; events: number; action: string }> = [];
|
|
237
|
+
|
|
238
|
+
for (const plan of plans) {
|
|
239
|
+
const target = path.join(outDir, `fold-${plan.id}.md`);
|
|
240
|
+
let action: string;
|
|
241
|
+
if (fs.existsSync(target)) {
|
|
242
|
+
action = 'exists (skipped — idempotent)';
|
|
243
|
+
} else if (dryRun) {
|
|
244
|
+
action = 'would write';
|
|
245
|
+
} else {
|
|
246
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
247
|
+
const tmp = `${target}.tmp-${process.pid}`;
|
|
248
|
+
fs.writeFileSync(tmp, renderFold(plan, batchSize), 'utf-8');
|
|
249
|
+
fs.renameSync(tmp, target);
|
|
250
|
+
action = 'written';
|
|
251
|
+
}
|
|
252
|
+
results.push({ id: plan.id, index: plan.index, events: plan.children.length, action });
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const tail = lines.length - plans.length * batchSize;
|
|
256
|
+
if (format === 'json') {
|
|
257
|
+
process.stdout.write(
|
|
258
|
+
JSON.stringify(
|
|
259
|
+
{ dry_run: dryRun, batch_size: batchSize, total_events: lines.length, unfolded_tail: tail, folds: results },
|
|
260
|
+
null,
|
|
261
|
+
2,
|
|
262
|
+
) + '\n',
|
|
263
|
+
);
|
|
264
|
+
} else {
|
|
265
|
+
for (const r of results) {
|
|
266
|
+
process.stdout.write(`fold-${r.id} batch=${r.index} events=${r.events} ${r.action}\n`);
|
|
267
|
+
}
|
|
268
|
+
process.stdout.write(
|
|
269
|
+
`${PROG}: ${results.length} fold(s), ${tail} event(s) in the live tail (batch size ${batchSize}${dryRun ? ', dry-run' : ''})\n`,
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
return 0;
|
|
273
|
+
} catch (exc) {
|
|
274
|
+
process.stderr.write(`${PROG}: internal error: ${String(exc)}\n`);
|
|
275
|
+
return 3;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (fileURLToPath(import.meta.url) === path.resolve(process.argv[1] ?? '')) {
|
|
280
|
+
process.exit(main(process.argv.slice(2)));
|
|
281
|
+
}
|
|
@@ -65,7 +65,7 @@ const HOSTS = [
|
|
|
65
65
|
'windsurf', 'cline', 'gemini', 'copilot', 'claude-desktop',
|
|
66
66
|
];
|
|
67
67
|
|
|
68
|
-
const ARTIFACTS = ['rules', 'skills', 'commands', 'personas', 'user-types', 'hooks'];
|
|
68
|
+
const ARTIFACTS = ['rules', 'skills', 'commands', 'subagents', 'personas', 'user-types', 'hooks'];
|
|
69
69
|
|
|
70
70
|
interface FnSpec {
|
|
71
71
|
artifact: string;
|
|
@@ -109,6 +109,14 @@ const _FN_SPEC: Record<string, FnSpec> = {
|
|
|
109
109
|
artifact: 'commands',
|
|
110
110
|
cells: { 'claude-code': 'native', augment: 'native' },
|
|
111
111
|
},
|
|
112
|
+
generate_claude_subagents: {
|
|
113
|
+
artifact: 'subagents',
|
|
114
|
+
cells: { 'claude-code': 'native' },
|
|
115
|
+
},
|
|
116
|
+
generate_subagent_host_contexts: {
|
|
117
|
+
artifact: 'subagents',
|
|
118
|
+
cells: { cursor: 'adapter', windsurf: 'adapter', cline: 'adapter' },
|
|
119
|
+
},
|
|
112
120
|
generate_plugin_command_skills: {
|
|
113
121
|
artifact: 'skills', cells: { 'claude-plugin': 'native' },
|
|
114
122
|
},
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
/**
|
|
3
|
+
* Generate `agents/knowledge/INDEX.md` — the one-line catalog over every
|
|
4
|
+
* knowledge surface: the flat anti-hallucination cards (ADR-100) plus the
|
|
5
|
+
* lifecycle-typed sibling directories (`sessions/`, `concepts/`,
|
|
6
|
+
* `procedures/`, `decisions/`) added by road-to-knowledge-system.
|
|
7
|
+
*
|
|
8
|
+
* Design per the 2026-07-05 council verdict (Option C — extend
|
|
9
|
+
* `agents/knowledge/` in place): ONE index, index-first + grep retrieval,
|
|
10
|
+
* no search infrastructure. This script is the deterministic backstop —
|
|
11
|
+
* agents read INDEX.md first, grep second, read specific files third.
|
|
12
|
+
*
|
|
13
|
+
* Deterministic and idempotent: same inputs always produce byte-identical
|
|
14
|
+
* output. No network, no LLM calls.
|
|
15
|
+
*
|
|
16
|
+
* Usage:
|
|
17
|
+
* generate_knowledge_index.ts [--dir <repo-root>] [--check] [--quiet]
|
|
18
|
+
*
|
|
19
|
+
* Exit codes: 0 = written / no drift, 1 = drift found (--check) or usage
|
|
20
|
+
* error, 3 = internal error.
|
|
21
|
+
*/
|
|
22
|
+
import * as fs from 'node:fs';
|
|
23
|
+
import * as path from 'node:path';
|
|
24
|
+
import process from 'node:process';
|
|
25
|
+
import { fileURLToPath } from 'node:url';
|
|
26
|
+
import YAML from 'yaml';
|
|
27
|
+
|
|
28
|
+
const _HERE = fileURLToPath(import.meta.url);
|
|
29
|
+
const PROG = 'generate_knowledge_index.ts';
|
|
30
|
+
|
|
31
|
+
const FRONTMATTER_RE = /^---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*\r?\n/;
|
|
32
|
+
|
|
33
|
+
// Section order is fixed — cards first (the pre-existing anti-hallucination
|
|
34
|
+
// store), then the lifecycle-typed dirs in capture-order (episodic → semantic
|
|
35
|
+
// → procedural → decisions).
|
|
36
|
+
const SECTIONS: ReadonlyArray<{ heading: string; dir: string | null }> = [
|
|
37
|
+
{ heading: 'Knowledge Cards', dir: null }, // flat *.md directly under agents/knowledge/
|
|
38
|
+
{ heading: 'Sessions', dir: 'sessions' },
|
|
39
|
+
{ heading: 'Concepts', dir: 'concepts' },
|
|
40
|
+
{ heading: 'Procedures', dir: 'procedures' },
|
|
41
|
+
{ heading: 'Decisions', dir: 'decisions' },
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
const SKIP_FILES = new Set(['README.md', 'INDEX.md']);
|
|
45
|
+
const MAX_SUMMARY_CHARS = 140;
|
|
46
|
+
|
|
47
|
+
interface Entry {
|
|
48
|
+
file: string; // basename, e.g. "stripe-webhooks.md"
|
|
49
|
+
relPath: string; // path relative to agents/knowledge/, POSIX separators
|
|
50
|
+
summary: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function readFrontmatter(body: string): Record<string, unknown> {
|
|
54
|
+
const m = FRONTMATTER_RE.exec(body);
|
|
55
|
+
if (m?.[1] === undefined) return {};
|
|
56
|
+
try {
|
|
57
|
+
const parsed = YAML.parse(m[1]);
|
|
58
|
+
return parsed && typeof parsed === 'object' ? (parsed as Record<string, unknown>) : {};
|
|
59
|
+
} catch {
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function stripFrontmatter(body: string): string {
|
|
65
|
+
return body.replace(FRONTMATTER_RE, '');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function firstHeadingOrLine(body: string): string {
|
|
69
|
+
for (const line of body.split(/\r?\n/)) {
|
|
70
|
+
const trimmed = line.trim();
|
|
71
|
+
if (!trimmed) continue;
|
|
72
|
+
return trimmed.replace(/^#+\s*/, '');
|
|
73
|
+
}
|
|
74
|
+
return '';
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function truncate(s: string, max: number): string {
|
|
78
|
+
if (s.length <= max) return s;
|
|
79
|
+
return s.slice(0, max - 1).trimEnd() + '…';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Derive a one-line summary: frontmatter `description`/`summary` wins; else the first heading/line after frontmatter. */
|
|
83
|
+
function summarize(body: string): string {
|
|
84
|
+
const fm = readFrontmatter(body);
|
|
85
|
+
const fromFrontmatter = (fm.description ?? fm.summary) as unknown;
|
|
86
|
+
if (typeof fromFrontmatter === 'string' && fromFrontmatter.trim()) {
|
|
87
|
+
return truncate(fromFrontmatter.trim(), MAX_SUMMARY_CHARS);
|
|
88
|
+
}
|
|
89
|
+
const rest = stripFrontmatter(body);
|
|
90
|
+
return truncate(firstHeadingOrLine(rest), MAX_SUMMARY_CHARS);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function listMarkdownFiles(dirPath: string): string[] {
|
|
94
|
+
let entries: fs.Dirent[];
|
|
95
|
+
try {
|
|
96
|
+
entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
97
|
+
} catch {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
return entries
|
|
101
|
+
.filter((e) => e.isFile() && e.name.toLowerCase().endsWith('.md') && !SKIP_FILES.has(e.name))
|
|
102
|
+
.map((e) => e.name)
|
|
103
|
+
.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function collectSection(knowledgeRoot: string, dir: string | null): Entry[] {
|
|
107
|
+
const scanDir = dir ? path.join(knowledgeRoot, dir) : knowledgeRoot;
|
|
108
|
+
const files = listMarkdownFiles(scanDir);
|
|
109
|
+
const out: Entry[] = [];
|
|
110
|
+
for (const file of files) {
|
|
111
|
+
const abs = path.join(scanDir, file);
|
|
112
|
+
let body = '';
|
|
113
|
+
try {
|
|
114
|
+
body = fs.readFileSync(abs, 'utf8');
|
|
115
|
+
} catch {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const relPath = dir ? `${dir}/${file}` : file;
|
|
119
|
+
out.push({ file, relPath, summary: summarize(body) });
|
|
120
|
+
}
|
|
121
|
+
return out;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function renderIndex(knowledgeRoot: string): string {
|
|
125
|
+
const lines: string[] = [];
|
|
126
|
+
lines.push('# Knowledge Index');
|
|
127
|
+
lines.push('');
|
|
128
|
+
lines.push(
|
|
129
|
+
'_Auto-generated by `src/scripts/generate_knowledge_index.ts` — do not edit by hand. Regenerate with `task generate-knowledge-index`._',
|
|
130
|
+
);
|
|
131
|
+
lines.push('');
|
|
132
|
+
lines.push(
|
|
133
|
+
'_Retrieval protocol: read this index first, `grep` for keywords second, read the specific file third. Never enumerate every knowledge file directly._',
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
for (const section of SECTIONS) {
|
|
137
|
+
const entries = collectSection(knowledgeRoot, section.dir);
|
|
138
|
+
if (entries.length === 0) continue;
|
|
139
|
+
lines.push('');
|
|
140
|
+
// Entry count in the heading — cheap human scannability
|
|
141
|
+
// (road-to-second-brain Phase 4: the council-endorsed browsability
|
|
142
|
+
// alternative to a vault view).
|
|
143
|
+
lines.push(`## ${section.heading} (${entries.length})`);
|
|
144
|
+
lines.push('');
|
|
145
|
+
for (const e of entries) {
|
|
146
|
+
const title = e.file.replace(/\.md$/, '');
|
|
147
|
+
const suffix = e.summary ? ` — ${e.summary}` : '';
|
|
148
|
+
lines.push(`- [${title}](${e.relPath})${suffix}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
lines.push('');
|
|
152
|
+
return lines.join('\n');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function printUsage(): void {
|
|
156
|
+
process.stdout.write(`usage: ${PROG} [--dir DIR] [--check] [--quiet]\n`);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function main(argv: string[]): number {
|
|
160
|
+
let dir = process.cwd();
|
|
161
|
+
let check = false;
|
|
162
|
+
let quiet = false;
|
|
163
|
+
|
|
164
|
+
for (let i = 0; i < argv.length; i++) {
|
|
165
|
+
const arg = argv[i];
|
|
166
|
+
if (arg === '-h' || arg === '--help') {
|
|
167
|
+
printUsage();
|
|
168
|
+
return 0;
|
|
169
|
+
} else if (arg === '--dir') {
|
|
170
|
+
const value = argv[++i];
|
|
171
|
+
if (!value) {
|
|
172
|
+
process.stderr.write(`${PROG}: error: --dir requires a value\n`);
|
|
173
|
+
return 1;
|
|
174
|
+
}
|
|
175
|
+
dir = value;
|
|
176
|
+
} else if (arg === '--check') {
|
|
177
|
+
check = true;
|
|
178
|
+
} else if (arg === '--quiet') {
|
|
179
|
+
quiet = true;
|
|
180
|
+
} else {
|
|
181
|
+
process.stderr.write(`${PROG}: error: unrecognized argument: ${arg}\n`);
|
|
182
|
+
printUsage();
|
|
183
|
+
return 1;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const knowledgeRoot = path.join(dir, 'agents', 'knowledge');
|
|
188
|
+
if (!fs.existsSync(knowledgeRoot)) {
|
|
189
|
+
if (!quiet) {
|
|
190
|
+
process.stdout.write(`${PROG}: ${knowledgeRoot} does not exist — nothing to index.\n`);
|
|
191
|
+
}
|
|
192
|
+
return 0;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const rendered = renderIndex(knowledgeRoot);
|
|
196
|
+
const indexPath = path.join(knowledgeRoot, 'INDEX.md');
|
|
197
|
+
const existing = fs.existsSync(indexPath) ? fs.readFileSync(indexPath, 'utf8') : null;
|
|
198
|
+
|
|
199
|
+
if (check) {
|
|
200
|
+
if (existing === rendered) {
|
|
201
|
+
if (!quiet) process.stdout.write(`${PROG}: agents/knowledge/INDEX.md is up to date.\n`);
|
|
202
|
+
return 0;
|
|
203
|
+
}
|
|
204
|
+
process.stderr.write(
|
|
205
|
+
`${PROG}: agents/knowledge/INDEX.md is stale — run without --check to regenerate.\n`,
|
|
206
|
+
);
|
|
207
|
+
return 1;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (existing === rendered) {
|
|
211
|
+
if (!quiet) process.stdout.write(`${PROG}: agents/knowledge/INDEX.md already up to date.\n`);
|
|
212
|
+
return 0;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
fs.writeFileSync(indexPath, rendered, 'utf8');
|
|
216
|
+
if (!quiet) process.stdout.write(`${PROG}: wrote agents/knowledge/INDEX.md\n`);
|
|
217
|
+
return 0;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (fileURLToPath(import.meta.url) === path.resolve(process.argv[1] ?? '')) {
|
|
221
|
+
process.exit(main(process.argv.slice(2)));
|
|
222
|
+
}
|
|
@@ -18,6 +18,18 @@ concerns:
|
|
|
18
18
|
script: src/scripts/chat_history.ts
|
|
19
19
|
args: [hook-dispatch]
|
|
20
20
|
fail_closed: false
|
|
21
|
+
# Hot-context working-memory cache (road-to-second-brain Phase 1).
|
|
22
|
+
# stop: deterministic, redacted 400-word overwrite of
|
|
23
|
+
# agents/runtime/state/hot-context.md from the chat-history JSONL.
|
|
24
|
+
# session_start: staleness-checked restore; the dispatcher forwards the
|
|
25
|
+
# returned `context` block to its own stdout (Claude Code SessionStart
|
|
26
|
+
# injection; on Claude, source=compact re-injects after compaction).
|
|
27
|
+
# Runs AFTER chat-history in both slots so the stop-write sees the final
|
|
28
|
+
# session entries. Never blocks.
|
|
29
|
+
hot-context:
|
|
30
|
+
script: src/scripts/hot_context_hook.ts
|
|
31
|
+
args: []
|
|
32
|
+
fail_closed: false
|
|
21
33
|
roadmap-progress:
|
|
22
34
|
script: src/scripts/roadmap_progress_hook.ts
|
|
23
35
|
args: []
|
|
@@ -116,16 +128,16 @@ concerns:
|
|
|
116
128
|
|
|
117
129
|
platforms:
|
|
118
130
|
augment:
|
|
119
|
-
session_start: [chat-history, first-run-gate, onboarding-gate, verify-before-complete, minimal-safe-diff, profile-staleness, wrapper-freshness]
|
|
131
|
+
session_start: [chat-history, hot-context, first-run-gate, onboarding-gate, verify-before-complete, minimal-safe-diff, profile-staleness, wrapper-freshness]
|
|
120
132
|
session_end: [chat-history]
|
|
121
|
-
stop: [chat-history, verify-before-complete]
|
|
133
|
+
stop: [chat-history, hot-context, verify-before-complete]
|
|
122
134
|
pre_tool_use: [block-no-verify, rtk-wrap, design-slop]
|
|
123
135
|
post_tool_use: [chat-history, roadmap-progress, context-hygiene, verify-before-complete, minimal-safe-diff, injection-scan]
|
|
124
136
|
|
|
125
137
|
claude:
|
|
126
|
-
session_start: [chat-history, first-run-gate, onboarding-gate, verify-before-complete, minimal-safe-diff, profile-staleness, wrapper-freshness]
|
|
138
|
+
session_start: [chat-history, hot-context, first-run-gate, onboarding-gate, verify-before-complete, minimal-safe-diff, profile-staleness, wrapper-freshness]
|
|
127
139
|
session_end: [chat-history]
|
|
128
|
-
stop: [chat-history, verify-before-complete]
|
|
140
|
+
stop: [chat-history, hot-context, verify-before-complete]
|
|
129
141
|
user_prompt_submit: [chat-history, verify-before-complete, minimal-safe-diff]
|
|
130
142
|
pre_tool_use: [block-no-verify, rtk-wrap, design-slop]
|
|
131
143
|
post_tool_use: [chat-history, roadmap-progress, context-hygiene, verify-before-complete, minimal-safe-diff, injection-scan]
|
|
@@ -145,9 +157,9 @@ platforms:
|
|
|
145
157
|
# Decision matrix + upstream blockers tracked in
|
|
146
158
|
# agents/settings/contexts/chat-history-platform-hooks.md § Cowork.
|
|
147
159
|
cowork:
|
|
148
|
-
session_start: [chat-history, first-run-gate, onboarding-gate, verify-before-complete, minimal-safe-diff, profile-staleness, wrapper-freshness]
|
|
160
|
+
session_start: [chat-history, hot-context, first-run-gate, onboarding-gate, verify-before-complete, minimal-safe-diff, profile-staleness, wrapper-freshness]
|
|
149
161
|
session_end: [chat-history]
|
|
150
|
-
stop: [chat-history, verify-before-complete]
|
|
162
|
+
stop: [chat-history, hot-context, verify-before-complete]
|
|
151
163
|
user_prompt_submit: [chat-history, verify-before-complete, minimal-safe-diff]
|
|
152
164
|
pre_tool_use: [block-no-verify, rtk-wrap, design-slop]
|
|
153
165
|
post_tool_use: [chat-history, roadmap-progress, context-hygiene, verify-before-complete, minimal-safe-diff, injection-scan]
|
|
@@ -160,9 +172,9 @@ platforms:
|
|
|
160
172
|
# IDE-only — CLI-only users fall back to /checkpoint per
|
|
161
173
|
# agents/settings/contexts/chat-history-platform-hooks.md.
|
|
162
174
|
cursor:
|
|
163
|
-
session_start: [chat-history, first-run-gate, onboarding-gate, verify-before-complete, minimal-safe-diff, profile-staleness, wrapper-freshness]
|
|
175
|
+
session_start: [chat-history, hot-context, first-run-gate, onboarding-gate, verify-before-complete, minimal-safe-diff, profile-staleness, wrapper-freshness]
|
|
164
176
|
session_end: [chat-history]
|
|
165
|
-
stop: [chat-history, verify-before-complete]
|
|
177
|
+
stop: [chat-history, hot-context, verify-before-complete]
|
|
166
178
|
user_prompt_submit: [chat-history, verify-before-complete, minimal-safe-diff]
|
|
167
179
|
post_tool_use: [chat-history, roadmap-progress, context-hygiene, verify-before-complete, minimal-safe-diff, injection-scan]
|
|
168
180
|
|
|
@@ -175,9 +187,9 @@ platforms:
|
|
|
175
187
|
# both map to session_start. TaskCancel maps to stop because the
|
|
176
188
|
# session is interrupted with partial state (mirrors Augment Stop).
|
|
177
189
|
cline:
|
|
178
|
-
session_start: [chat-history, first-run-gate, onboarding-gate, verify-before-complete, minimal-safe-diff, profile-staleness, wrapper-freshness]
|
|
190
|
+
session_start: [chat-history, hot-context, first-run-gate, onboarding-gate, verify-before-complete, minimal-safe-diff, profile-staleness, wrapper-freshness]
|
|
179
191
|
session_end: [chat-history]
|
|
180
|
-
stop: [chat-history, verify-before-complete]
|
|
192
|
+
stop: [chat-history, hot-context, verify-before-complete]
|
|
181
193
|
user_prompt_submit: [chat-history, verify-before-complete, minimal-safe-diff]
|
|
182
194
|
post_tool_use: [chat-history, roadmap-progress, context-hygiene, verify-before-complete, minimal-safe-diff, injection-scan]
|
|
183
195
|
|
|
@@ -194,8 +206,8 @@ platforms:
|
|
|
194
206
|
# surface to record verification commands; documented limitation).
|
|
195
207
|
# minimal-safe-diff is omitted entirely on Windsurf for the same reason.
|
|
196
208
|
windsurf:
|
|
197
|
-
session_start: [chat-history, first-run-gate, onboarding-gate, verify-before-complete, profile-staleness, wrapper-freshness]
|
|
198
|
-
stop: [chat-history, verify-before-complete]
|
|
209
|
+
session_start: [chat-history, hot-context, first-run-gate, onboarding-gate, verify-before-complete, profile-staleness, wrapper-freshness]
|
|
210
|
+
stop: [chat-history, hot-context, verify-before-complete]
|
|
199
211
|
user_prompt_submit: [chat-history, verify-before-complete]
|
|
200
212
|
|
|
201
213
|
# Phase 7.8 — Gemini CLI. Hooks live at `.gemini/settings.json`
|
|
@@ -209,9 +221,9 @@ platforms:
|
|
|
209
221
|
# turn-check semantics. AfterAgent fires when the agent loop ends
|
|
210
222
|
# — this is our `stop` slot.
|
|
211
223
|
gemini:
|
|
212
|
-
session_start: [chat-history, first-run-gate, onboarding-gate, verify-before-complete, minimal-safe-diff, profile-staleness, wrapper-freshness]
|
|
224
|
+
session_start: [chat-history, hot-context, first-run-gate, onboarding-gate, verify-before-complete, minimal-safe-diff, profile-staleness, wrapper-freshness]
|
|
213
225
|
session_end: [chat-history]
|
|
214
|
-
stop: [chat-history, verify-before-complete]
|
|
226
|
+
stop: [chat-history, hot-context, verify-before-complete]
|
|
215
227
|
user_prompt_submit: [chat-history, verify-before-complete, minimal-safe-diff]
|
|
216
228
|
post_tool_use: [chat-history, roadmap-progress, context-hygiene, verify-before-complete, minimal-safe-diff, injection-scan]
|
|
217
229
|
|
|
@@ -786,6 +786,13 @@ export function main(argv?: string[]): number {
|
|
|
786
786
|
const started_at = _now_iso();
|
|
787
787
|
const rcs: number[] = [];
|
|
788
788
|
const feedback_entries: FeedbackEntry[] = [];
|
|
789
|
+
// session_start context forwarding (road-to-second-brain Phase 1): a
|
|
790
|
+
// concern may return {"context": "<string>"} in its stdout JSON; on
|
|
791
|
+
// session_start the dispatcher forwards those blocks to its OWN stdout so
|
|
792
|
+
// the host adds them to the session context (Claude Code SessionStart
|
|
793
|
+
// stdout-injection; harmless surfacing elsewhere). All other events keep
|
|
794
|
+
// the swallow-stdout contract unchanged.
|
|
795
|
+
const context_blocks: string[] = [];
|
|
789
796
|
for (const concern of concerns) {
|
|
790
797
|
const concern_started = _now_iso();
|
|
791
798
|
const { rc: rawRcResult, stderr: stderr_text, stdout: stdout_text, duration_ms } =
|
|
@@ -804,6 +811,14 @@ export function main(argv?: string[]): number {
|
|
|
804
811
|
}
|
|
805
812
|
rcs.push(rc);
|
|
806
813
|
const reply = _parse_concern_stdout(stdout_text);
|
|
814
|
+
if (
|
|
815
|
+
args.event === "session_start" &&
|
|
816
|
+
rc === EXIT_ALLOW &&
|
|
817
|
+
typeof reply["context"] === "string" &&
|
|
818
|
+
(reply["context"] as string).trim()
|
|
819
|
+
) {
|
|
820
|
+
context_blocks.push((reply["context"] as string).trim());
|
|
821
|
+
}
|
|
807
822
|
feedback_entries.push({
|
|
808
823
|
concern: String(concern["name"]),
|
|
809
824
|
exit_code: rc,
|
|
@@ -819,6 +834,9 @@ export function main(argv?: string[]): number {
|
|
|
819
834
|
}
|
|
820
835
|
const final_rc = _reduce(rcs);
|
|
821
836
|
_write_feedback(envelope, session_id, feedback_entries, final_rc, started_at);
|
|
837
|
+
if (context_blocks.length > 0 && final_rc === EXIT_ALLOW) {
|
|
838
|
+
process.stdout.write(context_blocks.join("\n\n") + "\n");
|
|
839
|
+
}
|
|
822
840
|
return final_rc;
|
|
823
841
|
}
|
|
824
842
|
|