@event4u/agent-config 16.4.0 → 17.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/.augment-plugin/marketplace.json +3 -3
- package/.augment-plugin/plugin.json +1 -1
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/skills/install-agent-config/SKILL.md +4 -4
- package/CHANGELOG.md +483 -669
- package/CONTRIBUTING.md +47 -0
- package/README.md +25 -25
- package/dist/agent-src/commands/{design.md → agent-design.md} +11 -7
- package/dist/agent-src/commands/agents/init.md +66 -3
- package/dist/agent-src/commands/agents/user/init.md +3 -0
- package/dist/agent-src/commands/{optimize/deep.md → analyze/and-optimize.md} +72 -33
- package/dist/agent-src/commands/analyze/inbox.md +168 -37
- package/dist/agent-src/commands/analyze/pr.md +144 -0
- package/dist/agent-src/commands/analyze/{repo.md → reference.md} +85 -14
- package/dist/agent-src/commands/analyze/roadmap-repos.md +19 -10
- package/dist/agent-src/commands/analyze.md +28 -12
- package/dist/agent-src/commands/audit.md +115 -0
- package/dist/agent-src/commands/brand/review.md +13 -2
- package/dist/agent-src/commands/brand/tokens.md +3 -3
- package/dist/agent-src/commands/brand/voice.md +8 -5
- package/dist/agent-src/commands/brand.md +2 -2
- package/dist/agent-src/commands/challenge-me/closure.md +25 -0
- package/dist/agent-src/commands/design-system/import.md +8 -3
- package/dist/agent-src/commands/design-system/sync.md +98 -0
- package/dist/agent-src/commands/design-system.md +6 -1
- package/dist/agent-src/commands/evals/analyze.json +44 -0
- package/dist/agent-src/commands/evals/audit.json +12 -0
- package/dist/agent-src/commands/evals/retro.json +12 -0
- package/dist/agent-src/commands/fix/ci.md +10 -8
- package/dist/agent-src/commands/ghostwriter/write.md +22 -0
- package/dist/agent-src/commands/memory/learn-low-impact.md +70 -83
- package/dist/agent-src/commands/memory/propose.md +12 -0
- package/dist/agent-src/commands/memory.md +1 -1
- package/dist/agent-src/commands/optimize.md +4 -3
- package/dist/agent-src/commands/post-as/me.md +18 -0
- package/dist/agent-src/commands/pr/create.md +17 -342
- package/dist/agent-src/commands/pr/merge.md +129 -368
- package/dist/agent-src/commands/retro.md +121 -0
- package/dist/agent-src/commands/review/routing.md +1 -1
- package/dist/agent-src/commands/roadmap/next.md +4 -1
- package/dist/agent-src/commands/roadmap/process-full.md +46 -333
- package/dist/agent-src/commands/roadmap/triage-parked.md +6 -2
- package/dist/agent-src/commands/team-knowledge/consolidate.md +2 -2
- package/dist/agent-src/commands/team-knowledge.md +1 -1
- package/dist/agent-src/commands/threat-model.md +1 -1
- package/dist/agent-src/commands/upstream-contribute.md +91 -101
- package/dist/agent-src/commands/worktree/cleanup.md +18 -11
- package/dist/agent-src/contexts/contracts/consumer-agents-md-guide.md +54 -0
- package/dist/agent-src/contexts/execution/analysis-loop.md +137 -0
- package/dist/agent-src/contexts/execution/auto-dispatch-classification.md +3 -3
- package/dist/agent-src/contexts/execution/decision-closure-execution.md +1 -1
- package/dist/agent-src/contexts/execution/host-capability-manifest.md +6 -0
- package/dist/agent-src/contexts/execution/orchestration-telemetry.md +11 -4
- package/dist/agent-src/contexts/execution/pr-create-branches-content.md +250 -0
- package/dist/agent-src/contexts/execution/pr-create-branches-freshness.md +150 -0
- package/dist/agent-src/contexts/execution/pr-merge-queue.md +287 -0
- package/dist/agent-src/contexts/execution/pr-merge-sync.md +276 -0
- package/dist/agent-src/contexts/execution/pr-merge-trust-boundary.md +69 -0
- package/dist/agent-src/contexts/execution/process-full-all.md +233 -0
- package/dist/agent-src/contexts/execution/process-full-delivery.md +231 -0
- package/dist/agent-src/contexts/execution/roadmap-execution-contract-branches.md +42 -0
- package/dist/agent-src/contexts/execution/roadmap-execution-contract.md +1 -35
- package/dist/agent-src/contexts/execution/roadmap-process-loop-close.md +235 -0
- package/dist/agent-src/contexts/execution/roadmap-process-loop-prescan.md +216 -0
- package/dist/agent-src/contexts/execution/roadmap-process-loop-run.md +253 -0
- package/dist/agent-src/contexts/execution/roadmap-process-loop-set.md +212 -0
- package/dist/agent-src/contexts/execution/roadmap-process-loop.md +25 -864
- package/dist/agent-src/contexts/execution/subagent-spawn-contract.md +14 -2
- package/dist/agent-src/contexts/execution/subagent-steering.md +65 -8
- package/dist/agent-src/contexts/model-recommendations.md +5 -5
- package/dist/agent-src/contexts/subagent-configuration.md +1 -1
- package/dist/agent-src/guidelines/agent-infra/api-cost-levers.md +4 -3
- package/dist/agent-src/guidelines/agent-infra/model-recommendation.md +11 -5
- package/dist/agent-src/guidelines/agent-infra/rule-body-migration-inventory.md +1 -1
- package/dist/agent-src/guidelines/agent-infra/self-improvement-pipeline.md +47 -24
- package/dist/agent-src/guidelines/design-antipatterns.md +6 -1
- package/dist/agent-src/guidelines/design-asset-discipline.md +17 -0
- package/dist/agent-src/guidelines/design-fidelity-routing.md +1 -0
- package/dist/agent-src/guidelines/php/api-design.md +10 -1
- package/dist/agent-src/rules/brand-source-of-truth.md +7 -6
- package/dist/agent-src/rules/code-provenance.md +1 -1
- package/dist/agent-src/rules/context-hygiene.md +0 -1
- package/dist/agent-src/rules/design-fidelity.md +12 -13
- package/dist/agent-src/rules/external-reference-deep-dive.md +2 -2
- package/dist/agent-src/rules/fix-what-you-see.md +1 -1
- package/dist/agent-src/rules/low-impact-corpus-privacy-floor.md +14 -15
- package/dist/agent-src/rules/missing-skill-recovery.md +12 -11
- package/dist/agent-src/rules/neighbour-precedence.md +1 -1
- package/dist/agent-src/rules/recurring-criticism.md +1 -1
- package/dist/agent-src/rules/roadmap-ci-steps-policy.md +0 -2
- package/dist/agent-src/rules/self-repair-loop.md +2 -2
- package/dist/agent-src/rules/token-budget-discipline.md +2 -2
- package/dist/agent-src/scripts/dashboard_mode.ts +4 -1
- package/dist/agent-src/scripts/roadmap_age.ts +175 -0
- package/dist/agent-src/scripts/update_roadmap_progress.ts +10 -2
- package/dist/agent-src/skills/accessibility-auditor/SKILL.md +3 -3
- package/dist/agent-src/skills/accessibility-auditor/data/aria-patterns.csv +2 -0
- package/dist/agent-src/skills/accessibility-auditor/data/manifest.json +3 -3
- package/dist/agent-src/skills/agent-security-review/SKILL.md +2 -2
- package/dist/agent-src/skills/agents-md-thin-root/SKILL.md +12 -4
- package/dist/agent-src/skills/ai-code-blindspots/SKILL.md +7 -0
- package/dist/agent-src/skills/ai-council/references/advanced-modes.md +11 -1
- package/dist/agent-src/skills/ai-council/references/cost-and-redaction.md +7 -0
- package/dist/agent-src/skills/ai-council/references/execution-modes.md +7 -0
- package/dist/agent-src/skills/ai-council/references/output-and-synthesis.md +19 -0
- package/dist/agent-src/skills/ai-council/references/procedure.md +7 -0
- package/dist/agent-src/skills/api-design/SKILL.md +2 -2
- package/dist/agent-src/skills/api-endpoint/SKILL.md +2 -2
- package/dist/agent-src/skills/authz-review/SKILL.md +5 -3
- package/dist/agent-src/skills/blade-ui/SKILL.md +2 -2
- package/dist/agent-src/skills/brand/SKILL.md +7 -3
- package/dist/agent-src/skills/brand-asset-generation/SKILL.md +13 -6
- package/dist/agent-src/skills/brand-audit/SKILL.md +2 -1
- package/dist/agent-src/skills/brand-identity/SKILL.md +5 -4
- package/dist/agent-src/skills/brand-strategy/SKILL.md +5 -4
- package/dist/agent-src/skills/brand-to-tokens/SKILL.md +18 -39
- package/dist/agent-src/skills/brand-to-tokens/templates/marp-brand-deck.md.example +2 -2
- package/dist/agent-src/skills/brand-to-tokens/templates/reveal-brand-deck.yaml +2 -2
- package/dist/agent-src/skills/canvas-design/SKILL.md +16 -4
- package/dist/agent-src/skills/competitive-positioning/SKILL.md +2 -2
- package/dist/agent-src/skills/composer-packages/SKILL.md +18 -0
- package/dist/agent-src/skills/condense-memory/SKILL.md +1 -1
- package/dist/agent-src/skills/content-funnel-design/SKILL.md +8 -1
- package/dist/agent-src/skills/context-authoring/SKILL.md +1 -1
- package/dist/agent-src/skills/context-document/SKILL.md +2 -2
- package/dist/agent-src/skills/corpus-grounding/SKILL.md +6 -6
- package/dist/agent-src/skills/corpus-grounding/scripts/decision_engine.ts +13 -11
- package/dist/agent-src/skills/corpus-grounding/scripts/ground.mjs +1706 -0
- package/dist/agent-src/skills/corpus-grounding/scripts/schema_validator.ts +7 -1
- package/dist/agent-src/skills/dashboard-design/SKILL.md +1 -1
- package/dist/agent-src/skills/data-flow-mapper/SKILL.md +5 -2
- package/dist/agent-src/skills/database/SKILL.md +5 -4
- package/dist/agent-src/skills/decision-record/references/weighted-matrix.md +12 -0
- package/dist/agent-src/skills/deep-reading-analyst/SKILL.md +1 -1
- package/dist/agent-src/skills/dependency-upgrade/SKILL.md +61 -11
- package/dist/agent-src/skills/description-assist/SKILL.md +1 -1
- package/dist/agent-src/skills/design-intelligence/SKILL.md +1 -1
- package/dist/agent-src/skills/design-intelligence/data/landing.csv +1 -1
- package/dist/agent-src/skills/design-intelligence/references/context-and-registers.md +10 -2
- package/dist/agent-src/skills/design-intelligence/references/design-languages.md +1 -1
- package/dist/agent-src/skills/design-intelligence/references/design-rules-checklist.md +4 -3
- package/dist/agent-src/skills/design-intelligence/references/integration-mapping.md +25 -22
- package/dist/agent-src/skills/{wireframe → design-review}/references/story-beat-ledger.schema.json +1 -1
- package/dist/agent-src/skills/design-review/references/verification-automation.md +11 -3
- package/dist/agent-src/skills/design-system-capture/SKILL.md +15 -10
- package/dist/agent-src/skills/design-system-capture/references/design-system-json.md +20 -5
- package/dist/agent-src/skills/design-system-capture/references/import-procedure.md +2 -2
- package/dist/agent-src/skills/design-tokens/SKILL.md +23 -23
- package/dist/agent-src/skills/design-tokens/scripts/tokens.mjs +1037 -0
- package/dist/agent-src/skills/design-tokens/scripts/tokens.ts +336 -13
- package/dist/agent-src/skills/design-tokens/templates/design-tokens-starter.json +52 -53
- package/dist/agent-src/skills/docker/SKILL.md +1 -1
- package/dist/agent-src/skills/estimate-ticket/SKILL.md +1 -1
- package/dist/agent-src/skills/existing-ui-audit/SKILL.md +14 -276
- package/dist/agent-src/skills/existing-ui-audit/procedure.yaml +44 -0
- package/dist/agent-src/skills/existing-ui-audit/references/anti-slop-cross-reference.md +1 -1
- package/dist/agent-src/skills/existing-ui-audit/references/steps/00-inspect-stack-and-input.md +4 -0
- package/dist/agent-src/skills/existing-ui-audit/references/steps/01-enumerate-components.md +26 -0
- package/dist/agent-src/skills/existing-ui-audit/references/steps/01b-detect-component-taxonomy.md +7 -0
- package/dist/agent-src/skills/existing-ui-audit/references/steps/02-identify-design-system.md +12 -0
- package/dist/agent-src/skills/existing-ui-audit/references/steps/03-detect-design-tokens.md +35 -0
- package/dist/agent-src/skills/existing-ui-audit/references/steps/04-detect-shadcn-inventory.md +13 -0
- package/dist/agent-src/skills/existing-ui-audit/references/steps/04b-live-storybook-read.md +26 -0
- package/dist/agent-src/skills/existing-ui-audit/references/steps/05-list-reusable-patterns.md +14 -0
- package/dist/agent-src/skills/existing-ui-audit/references/steps/06-match-candidates.md +52 -0
- package/dist/agent-src/skills/existing-ui-audit/references/steps/07-greenfield-branch.md +29 -0
- package/dist/agent-src/skills/existing-ui-audit/references/steps/08-a11y-baseline.md +40 -0
- package/dist/agent-src/skills/existing-ui-audit/references/steps/09-validate-and-write.md +5 -0
- package/dist/agent-src/skills/experiment-loop/SKILL.md +1 -1
- package/dist/agent-src/skills/fe-design/references/design-patterns.md +65 -4
- package/dist/agent-src/skills/fe-design/references/design-read-and-memory.md +1 -1
- package/dist/agent-src/skills/fe-design/references/source-led-port.md +1 -1
- package/dist/agent-src/skills/finishing-a-development-branch/SKILL.md +6 -6
- package/dist/agent-src/skills/flux/SKILL.md +1 -1
- package/dist/agent-src/skills/form-handler/SKILL.md +15 -2
- package/dist/agent-src/skills/frontend-render-security/SKILL.md +9 -0
- package/dist/agent-src/skills/git-workflow/SKILL.md +2 -2
- package/dist/agent-src/skills/git-workflow/references/branch-update.md +7 -0
- package/dist/agent-src/skills/git-workflow/references/commit-subject.md +12 -0
- package/dist/agent-src/skills/git-workflow/references/push-closes-its-loop.md +10 -0
- package/dist/agent-src/skills/gtm-launch/SKILL.md +8 -1
- package/dist/agent-src/skills/html-deck/SKILL.md +7 -2
- package/dist/agent-src/skills/humanizer/SKILL.md +16 -3
- package/dist/agent-src/skills/humanizer/references/anti-aiisms.md +13 -1
- package/dist/agent-src/skills/humanizer/references/fixtures.md +8 -0
- package/dist/agent-src/skills/iconography/SKILL.md +4 -2
- package/dist/agent-src/skills/image-provider-routing/SKILL.md +16 -5
- package/dist/agent-src/skills/js-library-packaging/SKILL.md +5 -4
- package/dist/agent-src/skills/js-library-packaging/scripts/check_package_surface.mjs +197 -0
- package/dist/agent-src/skills/judge-artifact-completeness/SKILL.md +1 -1
- package/dist/agent-src/skills/judge-security-auditor/SKILL.md +2 -2
- package/dist/agent-src/skills/launch-readiness/SKILL.md +18 -22
- package/dist/agent-src/skills/learning-to-rule-or-skill/SKILL.md +5 -5
- package/dist/agent-src/skills/livewire/SKILL.md +1 -1
- package/dist/agent-src/skills/llm-provider-knowledge/SKILL.md +18 -0
- package/dist/agent-src/skills/logo-generation/SKILL.md +21 -11
- package/dist/agent-src/skills/market-entry-analysis/SKILL.md +6 -1
- package/dist/agent-src/skills/markitdown/SKILL.md +1 -1
- package/dist/agent-src/skills/memory-consolidation/SKILL.md +2 -2
- package/dist/agent-src/skills/messaging-architecture/SKILL.md +8 -1
- package/dist/agent-src/skills/motion-choreographer/SKILL.md +2 -2
- package/dist/agent-src/skills/playwright-testing/SKILL.md +2 -0
- package/dist/agent-src/skills/positioning-strategy/SKILL.md +10 -2
- package/dist/agent-src/skills/prediction-pool-optimizer/references/ev-fixtures.md +13 -0
- package/dist/agent-src/skills/prediction-pool-optimizer/references/odds-and-bonus.md +7 -0
- package/dist/agent-src/skills/project-analysis-core/SKILL.md +1 -1
- package/dist/agent-src/skills/project-analysis-hypothesis-driven/SKILL.md +1 -1
- package/dist/agent-src/skills/project-analyzer/SKILL.md +14 -75
- package/dist/agent-src/skills/project-analyzer/procedure.yaml +39 -0
- package/dist/agent-src/skills/project-analyzer/references/steps/01-project-overview.md +9 -0
- package/dist/agent-src/skills/project-analyzer/references/steps/02-architecture.md +7 -0
- package/dist/agent-src/skills/project-analyzer/references/steps/03-data-layer.md +6 -0
- package/dist/agent-src/skills/project-analyzer/references/steps/04-business-domains.md +7 -0
- package/dist/agent-src/skills/project-analyzer/references/steps/05-api-surface.md +6 -0
- package/dist/agent-src/skills/project-analyzer/references/steps/06-service-map.md +6 -0
- package/dist/agent-src/skills/project-analyzer/references/steps/07-module-inventory.md +6 -0
- package/dist/agent-src/skills/project-analyzer/references/steps/08-infrastructure-and-testing.md +5 -0
- package/dist/agent-src/skills/project-analyzer/references/steps/09-agent-docs-audit.md +6 -0
- package/dist/agent-src/skills/project-analyzer/references/steps/10-gap-analysis.md +6 -0
- package/dist/agent-src/skills/quality-tools/references/js-ts-tools.md +10 -0
- package/dist/agent-src/skills/quality-tools/references/php-tools.md +13 -0
- package/dist/agent-src/skills/quality-tools/references/python-tools.md +11 -0
- package/dist/agent-src/skills/react-native-setup/SKILL.md +7 -2
- package/dist/agent-src/skills/react-shadcn-ui/SKILL.md +5 -1
- package/dist/agent-src/skills/react-shadcn-ui/references/registry.md +13 -0
- package/dist/agent-src/skills/react-shadcn-ui/scripts/shadcn_add.mjs +315 -0
- package/dist/agent-src/skills/react-shadcn-ui/scripts/shadcn_add.ts +6 -6
- package/dist/agent-src/skills/receiving-code-review/SKILL.md +1 -1
- package/dist/agent-src/skills/refine-ticket/SKILL.md +2 -2
- package/dist/agent-src/skills/release-comms/SKILL.md +2 -1
- package/dist/agent-src/skills/repomix-packer/SKILL.md +2 -2
- package/dist/agent-src/skills/requesting-code-review/SKILL.md +3 -3
- package/dist/agent-src/skills/roadmap-management/references/archival.md +3 -3
- package/dist/agent-src/skills/roadmap-management/references/authoring.md +9 -2
- package/dist/agent-src/skills/roadmap-management/references/dashboard.md +3 -3
- package/dist/agent-src/skills/roadmap-management/references/lifecycle.md +3 -3
- package/dist/agent-src/skills/roadmap-writing/SKILL.md +4 -4
- package/dist/agent-src/skills/rtk-output-filtering/SKILL.md +1 -1
- package/dist/agent-src/skills/rule-writing/SKILL.md +1 -2
- package/dist/agent-src/skills/security/SKILL.md +41 -5
- package/dist/agent-src/skills/skill-improvement-pipeline/SKILL.md +5 -3
- package/dist/agent-src/skills/skill-reviewer/SKILL.md +1 -1
- package/dist/agent-src/skills/skill-writing/SKILL.md +23 -8
- package/dist/agent-src/skills/skill-writing/references/section-patterns.md +19 -1
- package/dist/agent-src/skills/source-discovery/SKILL.md +3 -3
- package/dist/agent-src/skills/sql-writing/SKILL.md +2 -2
- package/dist/agent-src/skills/standards-from-config/SKILL.md +2 -2
- package/dist/agent-src/skills/storybook-workshop/SKILL.md +5 -0
- package/dist/agent-src/skills/storybook-workshop/scripts/story_contrast_floor.mjs +99 -0
- package/dist/agent-src/skills/subagent-orchestration/SKILL.md +13 -13
- package/dist/agent-src/skills/subagent-orchestration/prompts/README.md +4 -3
- package/dist/agent-src/skills/svg-authoring/SKILL.md +324 -0
- package/dist/agent-src/skills/systematic-debugging/SKILL.md +2 -2
- package/dist/agent-src/skills/tailwind-engineer/SKILL.md +8 -3
- package/dist/agent-src/skills/tailwind-engineer/scripts/tailwind_config_gen.mjs +482 -0
- package/dist/agent-src/skills/test-case-discovery/SKILL.md +1 -1
- package/dist/agent-src/skills/threat-modeling/SKILL.md +8 -1
- package/dist/agent-src/skills/threat-modeling/data/manifest.json +5 -2
- package/dist/agent-src/skills/threat-modeling/data/reasoning.csv +10 -10
- package/dist/agent-src/skills/threat-modeling/data/surfaces.csv +11 -10
- package/dist/agent-src/skills/threat-modeling/data/threats.csv +34 -20
- package/dist/agent-src/skills/type-design/SKILL.md +196 -0
- package/dist/agent-src/skills/type-design/references/font-spec.md +90 -0
- package/dist/agent-src/skills/type-design/references/gates.md +113 -0
- package/dist/agent-src/skills/type-design/references/toolchain.md +66 -0
- package/dist/agent-src/skills/typography-system/SKILL.md +21 -11
- package/dist/agent-src/skills/typography-system/references/worked-scales.md +85 -0
- package/dist/agent-src/skills/ui-apply-generic/SKILL.md +1 -1
- package/dist/agent-src/skills/universal-project-analysis/SKILL.md +1 -1
- package/dist/agent-src/skills/upstream-contribute/SKILL.md +120 -125
- package/dist/agent-src/skills/using-git-worktrees/SKILL.md +1 -0
- package/dist/agent-src/skills/verify-repair-loop/SKILL.md +1 -1
- package/dist/agent-src/skills/voice-and-tone-design/SKILL.md +71 -2
- package/dist/agent-src/skills/wireframe/SKILL.md +5 -2
- package/dist/agent-src/skills/worktree-lifecycle/SKILL.md +16 -14
- package/dist/agent-src/templates/AGENTS.md +1 -1
- package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
- package/dist/agent-src/templates/agents/proposal.example.md +1 -1
- package/dist/agent-src/templates/github-workflows/advisories-daily.yml +85 -0
- package/dist/agent-src/templates/roadmaps.md +39 -1
- package/dist/agent-src/templates/scripts/check_memory.ts +2 -2
- package/dist/agent-src/templates/scripts/historical-bug-patterns.example.yml +13 -1
- package/dist/agent-src/templates/scripts/work_engine/cli.ts +17 -0
- package/dist/agent-src/templates/scripts/work_engine/cli_args.ts +10 -0
- package/dist/agent-src/templates/scripts/work_engine/directives/ui/scaffold.ts +22 -13
- package/dist/agent-src/templates/scripts/work_engine/dispatcher.ts +18 -4
- package/dist/agent-src/templates/scripts/work_engine/procedure/checks.ts +283 -0
- package/dist/agent-src/templates/scripts/work_engine/procedure/run.ts +432 -0
- package/dist/agent-src/templates/scripts/work_engine/procedure/sidecar.ts +185 -0
- package/dist/agent-src/templates/scripts/work_engine/state.ts +3 -0
- package/dist/cli/commands/uiRender.js +265 -13
- package/dist/cli/commands/uiRenderAsset.js +1316 -0
- package/dist/cli/commands/uiRenderAssetCompare.js +752 -0
- package/dist/cli/commands/uiRenderAssetFonts.js +158 -0
- package/dist/cli/commands/uiRenderAssetGrid.js +265 -0
- package/dist/cli/commands/uiRenderAssetGrounds.js +323 -0
- package/dist/cli/commands/uiRenderAssetIsolation.js +85 -0
- package/dist/cli/commands/uiRenderAssetTypes.js +133 -0
- package/dist/cli/initRouting.js +1 -1
- package/dist/cli/main.js +47 -1
- package/dist/cli/mcp/dispatch.js +31 -9
- package/dist/cli/python/knowledge_ingest.js +7 -39
- package/dist/cli/python/workspace_secrets.js +4 -177
- package/dist/cli/registry.js +5 -2
- package/dist/cli-delegate/archive_completed_roadmaps.js +3 -2
- package/dist/cli-delegate/check_update_banner.js +635 -266
- package/dist/cli-delegate/{chunk-AED2VQGM.js → chunk-2CX7NWRB.js} +233 -437
- package/dist/cli-delegate/{chunk-F3QDG2GT.js → chunk-2SFOOFJJ.js} +259 -159
- package/dist/cli-delegate/chunk-2Y5AMLMY.js +136 -0
- package/dist/cli-delegate/{chunk-OKJUIAPS.js → chunk-4E2W63DA.js} +1 -62
- package/dist/cli-delegate/{chunk-6SRJTYJS.js → chunk-4SHNERBL.js} +37 -16
- package/dist/cli-delegate/chunk-5VO3RTMV.js +208 -0
- package/dist/cli-delegate/chunk-6E2LDY4F.js +27 -0
- package/dist/cli-delegate/{chunk-XQTPXKFA.js → chunk-6ZD2QZMN.js} +8 -17
- package/dist/cli-delegate/{chunk-6V5FMA3P.js → chunk-7CEI2YPS.js} +1 -1
- package/dist/cli-delegate/{chunk-DMSZHXZS.js → chunk-7DRWULEQ.js} +80 -7
- package/dist/cli-delegate/chunk-7NXCZSDL.js +54 -0
- package/dist/cli-delegate/chunk-AX3U3UWJ.js +328 -0
- package/dist/cli-delegate/{chunk-WOKWX5PL.js → chunk-BKALSTBZ.js} +18 -3
- package/dist/cli-delegate/chunk-BMGUGSY6.js +103 -0
- package/dist/cli-delegate/chunk-BYV46VRM.js +3309 -0
- package/dist/cli-delegate/{chunk-5GPULQBE.js → chunk-CAL76ADI.js} +4215 -682
- package/dist/cli-delegate/chunk-DSY6LLCQ.js +127 -0
- package/dist/cli-delegate/chunk-E6XNBVE4.js +581 -0
- package/dist/cli-delegate/{chunk-ZUZKZYCN.js → chunk-ESUNQ5XR.js} +46 -10
- package/dist/cli-delegate/{chunk-G5VVIZRC.js → chunk-F7HLSW6P.js} +1 -1
- package/dist/cli-delegate/chunk-FIEEOH5C.js +133 -0
- package/dist/cli-delegate/chunk-FKYZOWVD.js +719 -0
- package/dist/cli-delegate/chunk-GOMILC3O.js +918 -0
- package/dist/cli-delegate/chunk-I4KJYVPB.js +69 -0
- package/dist/cli-delegate/{chunk-JQOM7TTM.js → chunk-IDAOTDPE.js} +1 -100
- package/dist/cli-delegate/chunk-IROAQ77A.js +137 -0
- package/dist/cli-delegate/chunk-J2SJZICO.js +698 -0
- package/dist/cli-delegate/{chunk-6YQC2HLF.js → chunk-JHMMWNJ2.js} +54 -40
- package/dist/cli-delegate/{chunk-WQWXGIWB.js → chunk-M6CRG5O6.js} +165 -15
- package/dist/cli-delegate/{chunk-PHD7OOLE.js → chunk-MQ2UDEGV.js} +14 -3
- package/dist/cli-delegate/chunk-NTM7G2V4.js +220 -0
- package/dist/cli-delegate/chunk-PV7S5DPJ.js +175 -0
- package/dist/cli-delegate/{chunk-F7DQWYR5.js → chunk-RAXQOETZ.js} +6 -2
- package/dist/cli-delegate/{chunk-T7XSJSUQ.js → chunk-SIOMDAKL.js} +980 -784
- package/dist/cli-delegate/{chunk-KR6EM23A.js → chunk-TULVDQ4L.js} +3 -48
- package/dist/cli-delegate/chunk-UUYEKXKR.js +20 -0
- package/dist/cli-delegate/{chunk-7XGD2OEU.js → chunk-UXWHY6CQ.js} +2 -1
- package/dist/cli-delegate/{chunk-PWX7CKMD.js → chunk-VC3ECUEK.js} +1 -1
- package/dist/cli-delegate/{chunk-KXXWJTDO.js → chunk-WMNYVIYX.js} +1 -1
- package/dist/cli-delegate/chunk-XCY5KKUC.js +181 -0
- package/dist/cli-delegate/{chunk-H76PHZBI.js → chunk-XLY5G3CM.js} +14 -19
- package/dist/cli-delegate/cmd_adr_effective.js +41 -2
- package/dist/cli-delegate/cmd_analyze_session.js +7 -7
- package/dist/cli-delegate/cmd_brand_status.js +1287 -10
- package/dist/cli-delegate/cmd_ci_settle.js +330 -0
- package/dist/cli-delegate/cmd_conformance.js +669 -822
- package/dist/cli-delegate/cmd_doctor.js +26 -16
- package/dist/cli-delegate/cmd_doctor_neighbours.js +10 -7
- package/dist/cli-delegate/cmd_explain.js +9 -24
- package/dist/cli-delegate/cmd_export.js +14 -11
- package/dist/cli-delegate/cmd_fleet.js +5 -3
- package/dist/cli-delegate/cmd_git_convention.js +8 -4
- package/dist/cli-delegate/cmd_handoff.js +79 -242
- package/dist/cli-delegate/cmd_mcp_available.js +1 -1
- package/dist/cli-delegate/cmd_memory_get.js +4 -2
- package/dist/cli-delegate/cmd_migrate.js +2 -2
- package/dist/cli-delegate/cmd_packs_active.js +2 -2
- package/dist/cli-delegate/cmd_preflight.js +7 -5
- package/dist/cli-delegate/cmd_prune.js +16 -13
- package/dist/cli-delegate/cmd_route_audit.js +11 -8
- package/dist/cli-delegate/cmd_route_explain.js +649 -16
- package/dist/cli-delegate/cmd_session_recycle.js +15 -6
- package/dist/cli-delegate/cmd_settings_check.js +2 -2
- package/dist/cli-delegate/cmd_settings_get.js +1 -1
- package/dist/cli-delegate/cmd_settings_migrate.js +14 -11
- package/dist/cli-delegate/cmd_settings_set.js +1 -1
- package/dist/cli-delegate/cmd_sync.js +16 -13
- package/dist/cli-delegate/cmd_uninstall.js +185 -31
- package/dist/cli-delegate/cmd_update.js +67 -3
- package/dist/cli-delegate/cmd_upgrade.js +38 -7
- package/dist/cli-delegate/cmd_validate.js +16 -13
- package/dist/cli-delegate/cmd_versions.js +1 -1
- package/dist/cli-delegate/dashboard_mode.js +1 -1
- package/dist/cli-delegate/gate_execute.js +4 -3
- package/dist/cli-delegate/roadmap_age.js +22 -0
- package/dist/cli-delegate/roadmap_gates.js +4 -3
- package/dist/cli-delegate/update_roadmap_progress.js +3 -2
- package/dist/cli-delegate/upgrade_unattended-VVL6JLSX.js +541 -0
- package/dist/discovery/deprecation-report.md +1 -1
- package/dist/discovery/discovery-manifest.json +409 -201
- package/dist/discovery/discovery-manifest.json.sha256 +1 -1
- package/dist/discovery/discovery-manifest.summary.md +8 -8
- package/dist/discovery/dormancy-report.md +1 -1
- package/dist/discovery/orphan-report.md +1 -1
- package/dist/discovery/packs.json +36 -27
- package/dist/discovery/trust-report.md +3 -3
- package/dist/discovery/workspaces.json +25 -16
- package/dist/hooks/chat_history.chunk.cjs +6852 -0
- package/dist/hooks/chat_history.chunk.cjs.sha256 +1 -0
- package/dist/hooks/dispatch.js +17706 -18627
- package/dist/hooks/dispatch.sha256 +1 -1
- package/dist/hooks/egress_engine.chunk.cjs +915 -0
- package/dist/hooks/egress_engine.chunk.cjs.sha256 +1 -0
- package/dist/hooks/svg_rules.chunk.cjs +1858 -0
- package/dist/hooks/svg_rules.chunk.cjs.sha256 +1 -0
- package/dist/install/conflict.js +36 -6
- package/dist/install/conflictTracker.js +81 -7
- package/dist/install/detect.js +3 -3
- package/dist/install/hostPermissionsAdapter.js +106 -0
- package/dist/install/install.mjs +3117 -1949
- package/dist/install/installThinLayer.js +1 -1
- package/dist/install/manifestFiles.js +21 -0
- package/dist/install/noGoDenyRows.js +300 -0
- package/dist/install/noGoRules.js +368 -0
- package/dist/install/ownershipLedger.js +133 -0
- package/dist/install/plan.js +1 -1
- package/dist/install/preflight.js +39 -8
- package/dist/install/preserve.js +74 -12
- package/dist/install/recordedOwnership.js +88 -5
- package/dist/install/rule_scope.js +20 -3
- package/dist/install/stagedRuntime.js +455 -0
- package/dist/install/toolsArg.js +19 -0
- package/dist/install/userPin.js +47 -0
- package/dist/install/wizard-plan.js +26 -4
- package/dist/mcp/awesome-mcp-servers.row.md +1 -1
- package/dist/mcp/mcp-cloudflare-catalogue.json +3 -2
- package/dist/mcp/registry-manifest.json +6 -5
- package/dist/mcp/server.json +3 -3
- package/dist/mcp/server.mjs +9814 -5333
- package/dist/router.json +1 -1
- package/dist/scripts/_lib/agent_settings.js +7 -12
- package/dist/scripts/_lib/asset_render_record.js +219 -0
- package/dist/scripts/_lib/claude_builtin_names.js +9 -4
- package/dist/scripts/_lib/claude_settings_hooks.js +102 -34
- package/dist/scripts/_lib/egress_rules.js +766 -0
- package/dist/scripts/_lib/environment_detector.js +24 -33
- package/dist/scripts/_lib/global_deploy_inventory.js +146 -9
- package/dist/scripts/_lib/guidelines_lane.js +10 -1
- package/dist/scripts/_lib/identifier_redaction.js +24 -0
- package/dist/scripts/_lib/installed_layer.js +17 -0
- package/dist/scripts/_lib/installed_layer_normalise.js +72 -0
- package/dist/scripts/_lib/lean_projection_mode.js +34 -152
- package/dist/scripts/_lib/project_tree_form.js +118 -0
- package/dist/scripts/_lib/scan_scope.js +105 -0
- package/dist/scripts/_lib/scoped_projection.js +133 -3
- package/dist/scripts/_lib/settings_removed_keys.js +29 -0
- package/dist/scripts/_lib/settings_renamed_keys.js +17 -5
- package/dist/scripts/_lib/subagent_native_fields.js +35 -0
- package/dist/scripts/_lib/svg_dom.js +284 -0
- package/dist/scripts/_lib/svg_filled_counter.js +285 -0
- package/dist/scripts/_lib/svg_geometry.js +477 -0
- package/dist/scripts/_lib/svg_motion.js +179 -0
- package/dist/scripts/_lib/svg_rules.js +1339 -0
- package/dist/scripts/_lib/svg_urls.js +67 -0
- package/dist/scripts/_lib/ui_surface.js +19 -0
- package/dist/scripts/_lib/verification_command.js +364 -0
- package/dist/scripts/_lib/workspace_secrets.js +229 -0
- package/dist/scripts/ai_council/seat_policy.js +27 -0
- package/dist/scripts/ai_council/transport_resolver.js +9 -10
- package/dist/scripts/condense.js +25 -29
- package/dist/scripts/lint_svg_asset.js +324 -0
- package/dist/server/io/substituteTemplate.js +2 -2
- package/dist/server/io/yamlIO.js +2 -2
- package/dist/server/routes/install.js +5 -1
- package/dist/server/routes/settings.js +2 -2
- package/dist/server/routes/wizard.js +1 -1
- package/dist/server/schemas/settings.js +22 -16
- package/dist/server/serverInfo.js +1 -1
- package/dist/shared/brandTokenDocument.js +47 -0
- package/dist/shared/brandTokenPaths.js +43 -0
- package/dist/shared/settingsCarveOut.js +0 -7
- package/dist/shared/skillRanking.js +103 -5
- package/dist/shared/userMd/formAdapter.js +16 -0
- package/dist/shared/userMd/schema.js +17 -0
- package/dist/ui/assets/index-w70Ado09.js +23 -0
- package/dist/ui/index.html +1 -1
- package/docs/MIGRATION.md +89 -2
- package/docs/THIRD-PARTY-NOTICES.md +27 -0
- package/docs/contracts/settings-classes.md +27 -9
- package/docs/guidelines/agent-infra/api-cost-levers.md +4 -3
- package/docs/guidelines/agent-infra/model-recommendation.md +11 -5
- package/docs/guidelines/agent-infra/rule-body-migration-inventory.md +1 -1
- package/docs/guidelines/agent-infra/self-improvement-pipeline.md +47 -24
- package/docs/guidelines/design-antipatterns.md +6 -1
- package/docs/guidelines/design-asset-discipline.md +17 -0
- package/docs/guidelines/design-fidelity-routing.md +1 -0
- package/docs/guidelines/php/api-design.md +10 -1
- package/llms.txt +12 -10
- package/package.json +15 -5
- package/src/agent-src/scripts/dashboard_mode.ts +4 -1
- package/src/agent-src/scripts/roadmap_age.ts +175 -0
- package/src/agent-src/scripts/update_roadmap_progress.ts +10 -2
- package/src/agent-src/templates/AGENTS.md +1 -1
- package/src/agent-src/templates/scripts/check_memory.ts +2 -2
- package/src/agent-src/templates/scripts/historical-bug-patterns.example.yml +13 -1
- package/src/agent-src/templates/scripts/work_engine/cli.ts +17 -0
- package/src/agent-src/templates/scripts/work_engine/cli_args.ts +10 -0
- package/src/agent-src/templates/scripts/work_engine/directives/ui/scaffold.ts +22 -13
- package/src/agent-src/templates/scripts/work_engine/dispatcher.ts +18 -4
- package/src/agent-src/templates/scripts/work_engine/procedure/checks.ts +283 -0
- package/src/agent-src/templates/scripts/work_engine/procedure/run.ts +432 -0
- package/src/agent-src/templates/scripts/work_engine/procedure/sidecar.ts +185 -0
- package/src/agent-src/templates/scripts/work_engine/state.ts +3 -0
- package/src/config/agent-settings.template.yml +120 -57
- package/src/config/agents-paths.yml +13 -7
- package/src/config/ci-local-parity.yml +44 -0
- package/src/config/continuity-surface.json +51 -2
- package/src/config/depth-audit-samples.json +5 -0
- package/src/config/discovery/command-verbs.yml +1 -0
- package/src/config/dispatch-economy-metrics.json +1 -0
- package/src/config/egress-mutations/class-precedence-swapped.json +7 -0
- package/src/config/egress-mutations/credential-token-restores.json +7 -0
- package/src/config/egress-mutations/iban-checksum-disabled.json +7 -0
- package/src/config/egress-mutations/raw-value-in-the-count-record.json +7 -0
- package/src/config/evaluator-budgets.json +4 -4
- package/src/config/gate-coverage.yml +149 -3
- package/src/config/gate-reachability-exemptions.json +3 -5
- package/src/config/gate-violation-baselines.json +29 -25
- package/src/config/gitignore-block.txt +6 -3
- package/src/config/hook-bundle-budget.json +34 -3
- package/src/config/hook-carrier-probes.json +30 -0
- package/src/config/hook-latency-budget.json +4 -2
- package/src/config/host-injection-effect.json +8 -1
- package/src/config/host-skill-frontmatter-keys.json +56 -0
- package/src/config/layer-form-brakes.json +4 -0
- package/src/config/layer-form-comparison-corpus.json +42 -0
- package/src/config/loop-surfaces.yaml +28 -47
- package/src/config/memory-twin-verdicts.yml +9 -1
- package/src/config/metric-registry.yml +40 -3
- package/src/config/pack-size-budget.json +15 -0
- package/src/config/procedure-core-budget.json +21 -0
- package/src/config/profiles/minimal.ini +1 -1
- package/src/config/project-tree-form.json +24 -0
- package/src/config/reach-channels.yml +3 -3
- package/src/config/reach-prescriptions-intake.yml +1 -1
- package/src/config/roadmap-step-size-baseline.json +118 -0
- package/src/config/routing-coverage-seed.json +100 -2
- package/src/config/skill-body-budget.json +686 -0
- package/src/config/skill-fork-pilot.json +17 -0
- package/src/config/skill-lifecycle-probes-codex.json +57 -0
- package/src/config/skill-lifecycle-probes.json +57 -0
- package/src/config/skill-output-shape.json +316 -0
- package/src/config/step-depth-table.json +58 -0
- package/src/config/turnaround-budget.json +90 -0
- package/src/install/conflict.ts +38 -6
- package/src/install/conflictTracker.ts +126 -8
- package/src/install/detect.ts +3 -3
- package/src/install/hostPermissionsAdapter.ts +136 -0
- package/src/install/installThinLayer.ts +6 -1
- package/src/install/manifestFiles.ts +24 -0
- package/src/install/noGoDenyRows.ts +368 -0
- package/src/install/noGoRules.ts +438 -0
- package/src/install/ownershipLedger.ts +180 -0
- package/src/install/plan.ts +1 -1
- package/src/install/preflight.ts +42 -10
- package/src/install/preserve.ts +94 -12
- package/src/install/recordedOwnership.ts +121 -3
- package/src/install/rule_scope.ts +20 -3
- package/src/install/stagedRuntime.ts +528 -0
- package/src/install/toolsArg.ts +16 -0
- package/src/install/types.ts +23 -2
- package/src/install/userPin.ts +54 -0
- package/src/install/wizard-plan.ts +25 -4
- package/src/scripts/_cli/_doctor_emit.ts +24 -0
- package/src/scripts/_cli/cmd_brand_status.ts +223 -12
- package/src/scripts/_cli/cmd_ci_settle.ts +32 -0
- package/src/scripts/_cli/cmd_doctor.ts +23 -44
- package/src/scripts/_cli/cmd_route_explain.ts +176 -2
- package/src/scripts/_cli/cmd_uninstall.ts +270 -26
- package/src/scripts/_cli/cmd_update.ts +34 -1
- package/src/scripts/_cli/cmd_upgrade.ts +38 -2
- package/src/scripts/_cli/detection_report.ts +7 -0
- package/src/scripts/_cli/doctor_execution.ts +1 -2
- package/src/scripts/_cli/doctor_install_mode.ts +39 -0
- package/src/scripts/_cli/doctor_network_posture.ts +3 -3
- package/src/scripts/_cli/doctor_ownership_ledger.ts +126 -0
- package/src/scripts/_cli/doctor_update_verdict.ts +104 -0
- package/src/scripts/_cli/explain_last/scrubber.ts +9 -21
- package/src/scripts/_cli/upgrade_unattended.ts +548 -0
- package/src/scripts/_dispatch.bash +42 -9
- package/src/scripts/_lib/activation_ladder.ts +1 -1
- package/src/scripts/_lib/advisory_inventory.ts +405 -0
- package/src/scripts/_lib/advisory_notice.ts +270 -0
- package/src/scripts/_lib/advisory_sources.ts +752 -0
- package/src/scripts/_lib/advisory_verdicts.ts +363 -0
- package/src/scripts/_lib/agent_artifact_location.ts +177 -0
- package/src/scripts/_lib/agent_settings.ts +7 -12
- package/src/scripts/_lib/arrival_record.ts +217 -0
- package/src/scripts/_lib/asset_render_record.ts +247 -0
- package/src/scripts/_lib/billing_grant.ts +4 -2
- package/src/scripts/_lib/brand_voice_slot.ts +258 -0
- package/src/scripts/_lib/canary_status.ts +24 -0
- package/src/scripts/_lib/cc_transcript.ts +276 -0
- package/src/scripts/_lib/changelog_eras.ts +83 -0
- package/src/scripts/_lib/claim_phrases.ts +71 -0
- package/src/scripts/_lib/classify_update.ts +171 -0
- package/src/scripts/_lib/claude_builtin_names.ts +9 -4
- package/src/scripts/_lib/claude_hook_scope.ts +195 -0
- package/src/scripts/_lib/claude_settings_hooks.ts +118 -34
- package/src/scripts/_lib/codex_resident_set.ts +460 -0
- package/src/scripts/_lib/codex_skill_finder.ts +225 -0
- package/src/scripts/_lib/confusables.ts +19 -0
- package/src/scripts/_lib/consumer_impact.ts +199 -0
- package/src/scripts/_lib/content_class.ts +127 -0
- package/src/scripts/_lib/counted_probe.ts +68 -1
- package/src/scripts/_lib/credential_deny_rows.ts +151 -0
- package/src/scripts/_lib/credential_files.ts +367 -0
- package/src/scripts/_lib/delivery_arm_experiment.ts +2 -2
- package/src/scripts/_lib/depth_flip.ts +141 -0
- package/src/scripts/_lib/design_lock.ts +117 -0
- package/src/scripts/_lib/design_sync_ledger.ts +142 -0
- package/src/scripts/_lib/design_sync_plan.ts +177 -0
- package/src/scripts/_lib/design_sync_reconcile.ts +159 -0
- package/src/scripts/_lib/design_sync_verify.ts +99 -0
- package/src/scripts/_lib/design_system_claude_design.ts +323 -0
- package/src/scripts/_lib/design_system_import.ts +84 -6
- package/src/scripts/_lib/dispatch_import_closure.ts +42 -11
- package/src/scripts/_lib/egress_credential_env.ts +35 -0
- package/src/scripts/_lib/egress_engine.ts +22 -0
- package/src/scripts/_lib/egress_known_values.ts +223 -0
- package/src/scripts/_lib/egress_normalize.ts +67 -0
- package/src/scripts/_lib/egress_prefixes.ts +42 -0
- package/src/scripts/_lib/egress_rules.ts +896 -0
- package/src/scripts/_lib/egress_rules_linearity.ts +56 -0
- package/src/scripts/_lib/egress_sender_scan.ts +290 -0
- package/src/scripts/_lib/egress_session_table.ts +510 -0
- package/src/scripts/_lib/egress_text.ts +63 -0
- package/src/scripts/_lib/egress_token.ts +252 -0
- package/src/scripts/_lib/empty_cycles.ts +1 -1
- package/src/scripts/_lib/environment_detector.ts +45 -30
- package/src/scripts/_lib/exemption_shape.ts +75 -1
- package/src/scripts/_lib/floor_posture.ts +185 -0
- package/src/scripts/_lib/forge_protection.ts +140 -2
- package/src/scripts/_lib/global_deploy_inventory.ts +159 -6
- package/src/scripts/_lib/guidelines_lane.ts +12 -1
- package/src/scripts/_lib/hand_kinds.ts +65 -0
- package/src/scripts/_lib/headless_invocation.ts +3 -3
- package/src/scripts/_lib/host_capability.ts +34 -2
- package/src/scripts/_lib/host_env_write.ts +39 -18
- package/src/scripts/_lib/host_listing_model.ts +14 -7
- package/src/scripts/_lib/identifier_redaction.ts +26 -0
- package/src/scripts/_lib/impact_bump.ts +70 -0
- package/src/scripts/_lib/install_reach_checks.ts +53 -1
- package/src/scripts/_lib/installed_layer.ts +31 -0
- package/src/scripts/_lib/installed_layer_normalise.ts +75 -0
- package/src/scripts/_lib/instructions_loaded_classify.ts +75 -0
- package/src/scripts/_lib/instructions_loaded_event.ts +53 -0
- package/src/scripts/_lib/knowledge_global_redaction.ts +2 -2
- package/src/scripts/_lib/layer_form_corpus.ts +165 -0
- package/src/scripts/_lib/layer_form_decision.ts +248 -0
- package/src/scripts/_lib/layer_form_evidence.ts +112 -0
- package/src/scripts/_lib/lean_projection_mode.ts +32 -161
- package/src/scripts/_lib/llm_proposer_transport.ts +1 -0
- package/src/scripts/_lib/loop_guards.ts +8 -120
- package/src/scripts/_lib/major_surface.ts +207 -0
- package/src/scripts/_lib/mcp_bridge.ts +30 -69
- package/src/scripts/_lib/merge_clearance_record.ts +384 -0
- package/src/scripts/_lib/neighbour_census.ts +18 -1
- package/src/scripts/_lib/orchestration_record.ts +61 -0
- package/src/scripts/_lib/outcome_vocabularies.ts +15 -23
- package/src/scripts/_lib/pin_advice.ts +49 -0
- package/src/scripts/_lib/platform_anchor.ts +222 -0
- package/src/scripts/_lib/procedure_checks.ts +5 -0
- package/src/scripts/_lib/project_tree_form.ts +134 -0
- package/src/scripts/_lib/projection_key_migration.ts +122 -0
- package/src/scripts/_lib/prompt_shape.ts +13 -2
- package/src/scripts/_lib/provenance_verify.ts +272 -0
- package/src/scripts/_lib/quota_parked.ts +27 -1
- package/src/scripts/_lib/ratification_artifact.ts +64 -1
- package/src/scripts/_lib/ratification_subject.ts +508 -46
- package/src/scripts/_lib/release_findings_ingest.ts +52 -5
- package/src/scripts/_lib/release_highlights.ts +72 -2
- package/src/scripts/_lib/release_settings_surface.ts +392 -0
- package/src/scripts/_lib/review_round.ts +134 -0
- package/src/scripts/_lib/roadmap_checkboxes.ts +1 -1
- package/src/scripts/_lib/roadmap_slug_lock.ts +254 -0
- package/src/scripts/_lib/roadmap_step_size.ts +75 -0
- package/src/scripts/_lib/run_checkpoint.ts +60 -3
- package/src/scripts/_lib/runtime_wiring_checks.ts +15 -1
- package/src/scripts/_lib/scope_guard.sh +64 -5
- package/src/scripts/_lib/scoped_projection.ts +136 -3
- package/src/scripts/_lib/secret_detector.ts +24 -103
- package/src/scripts/_lib/security_fix.ts +429 -0
- package/src/scripts/_lib/security_fix_context.ts +133 -0
- package/src/scripts/_lib/self_repair.ts +69 -39
- package/src/scripts/_lib/self_repair_outgoing.ts +209 -0
- package/src/scripts/_lib/self_repair_payload.ts +86 -0
- package/src/scripts/_lib/session_eol.ts +3 -0
- package/src/scripts/_lib/session_pr_watch.ts +207 -0
- package/src/scripts/_lib/session_register.ts +51 -1
- package/src/scripts/_lib/session_tag.ts +51 -0
- package/src/scripts/_lib/settings_removed_keys.ts +30 -0
- package/src/scripts/_lib/settings_renamed_keys.ts +19 -5
- package/src/scripts/_lib/skill_catalogue.ts +66 -25
- package/src/scripts/_lib/skill_fork_pilot.ts +121 -0
- package/src/scripts/_lib/skill_leases.ts +203 -0
- package/src/scripts/_lib/skill_listing_overrides.ts +294 -0
- package/src/scripts/_lib/skill_materialisation.ts +388 -0
- package/src/scripts/_lib/skill_materialisation_gate.ts +210 -0
- package/src/scripts/_lib/skill_materialisation_lock.ts +149 -0
- package/src/scripts/_lib/skill_materialisation_triggers.ts +96 -0
- package/src/scripts/_lib/skill_origin.ts +21 -1
- package/src/scripts/_lib/skill_reach.ts +342 -0
- package/src/scripts/_lib/source_shape.ts +7 -2
- package/src/scripts/_lib/sqlite_guard.ts +1 -1
- package/src/scripts/_lib/step_anatomy.ts +330 -0
- package/src/scripts/_lib/subagent_capsule.ts +8 -2
- package/src/scripts/_lib/subagent_native_fields.ts +30 -0
- package/src/scripts/_lib/subagent_spawn.ts +36 -0
- package/src/scripts/_lib/subagent_steering.ts +367 -0
- package/src/scripts/_lib/svg_dom.ts +318 -0
- package/src/scripts/_lib/svg_filled_counter.ts +287 -0
- package/src/scripts/_lib/svg_geometry.ts +480 -0
- package/src/scripts/_lib/svg_motion.ts +208 -0
- package/src/scripts/_lib/svg_rules.ts +1455 -0
- package/src/scripts/_lib/svg_urls.ts +72 -0
- package/src/scripts/_lib/test_delta.ts +89 -6
- package/src/scripts/_lib/tier_downshift_verdict.ts +222 -0
- package/src/scripts/_lib/tool_result_census.ts +62 -0
- package/src/scripts/_lib/trigger_routers.ts +1 -0
- package/src/scripts/_lib/turnaround_throughput.ts +378 -0
- package/src/scripts/_lib/ui_surface.ts +22 -0
- package/src/scripts/_lib/unattended_gates.ts +100 -0
- package/src/scripts/_lib/undeployed_fixes.ts +34 -0
- package/src/scripts/_lib/update_check.ts +143 -12
- package/src/scripts/_lib/update_invite.ts +116 -0
- package/src/scripts/_lib/update_notice.ts +259 -0
- package/src/scripts/_lib/verification_command.ts +59 -0
- package/src/scripts/_lib/verify_clause.ts +31 -19
- package/src/scripts/_lib/version_order.ts +146 -0
- package/src/scripts/_lib/worker_reuse.ts +191 -0
- package/src/scripts/_lib/workspace_secrets.ts +273 -0
- package/src/scripts/_lib/worktree_git.ts +67 -0
- package/src/scripts/_lib/worktree_ignored.ts +116 -0
- package/src/scripts/adoption_status.ts +330 -3
- package/src/scripts/adr_cite_check.ts +93 -0
- package/src/scripts/advisories.ts +803 -0
- package/src/scripts/ai-image/adapters/flux.sh +1 -0
- package/src/scripts/ai-image/adapters/gemini-image.sh +1 -0
- package/src/scripts/ai-image/adapters/ideogram.sh +1 -0
- package/src/scripts/ai-image/adapters/recraft.sh +1 -0
- package/src/scripts/ai-video/adapters/comfyui.sh +1 -0
- package/src/scripts/ai-video/adapters/fal.sh +1 -0
- package/src/scripts/ai-video/adapters/gemini-veo.sh +1 -0
- package/src/scripts/ai-video/adapters/higgsfield.sh +1 -0
- package/src/scripts/ai-video/adapters/kling.sh +1 -0
- package/src/scripts/ai-video/adapters/musetalk.sh +1 -0
- package/src/scripts/ai-video/adapters/openai-images.sh +1 -0
- package/src/scripts/ai-video/adapters/replicate.sh +1 -0
- package/src/scripts/ai-video/adapters/sora.sh +1 -0
- package/src/scripts/ai-video/adapters/syncso.sh +1 -0
- package/src/scripts/ai-video/stitch.sh +115 -2
- package/src/scripts/ai_council/airgap.ts +1 -0
- package/src/scripts/ai_council/api_transport.ts +27 -4
- package/src/scripts/ai_council/budget_guard.ts +300 -11
- package/src/scripts/ai_council/bundler.ts +20 -29
- package/src/scripts/ai_council/chairman.ts +17 -2
- package/src/scripts/ai_council/cli_agency_bounds.ts +158 -0
- package/src/scripts/ai_council/cli_launch_env.ts +54 -0
- package/src/scripts/ai_council/cli_least_agency_canary.ts +18 -2
- package/src/scripts/ai_council/clients.ts +55 -73
- package/src/scripts/ai_council/config.ts +16 -22
- package/src/scripts/ai_council/council_egress.ts +167 -0
- package/src/scripts/ai_council/exposure_ledger.ts +117 -0
- package/src/scripts/ai_council/free_hand_shadow.ts +276 -0
- package/src/scripts/ai_council/free_route.ts +216 -0
- package/src/scripts/ai_council/free_route_catalog.ts +173 -0
- package/src/scripts/ai_council/free_route_client.ts +95 -0
- package/src/scripts/ai_council/free_rung.ts +61 -0
- package/src/scripts/ai_council/hand_payload.ts +230 -0
- package/src/scripts/ai_council/hand_schemas.ts +123 -0
- package/src/scripts/ai_council/jury_aggregate.ts +155 -1
- package/src/scripts/ai_council/kind_flip.ts +221 -0
- package/src/scripts/ai_council/kind_flip_state.ts +19 -0
- package/src/scripts/ai_council/learn_low_impact_preview.ts +50 -22
- package/src/scripts/ai_council/modification_review.ts +98 -5
- package/src/scripts/ai_council/necessity.ts +7 -0
- package/src/scripts/ai_council/orchestrator.ts +16 -16
- package/src/scripts/ai_council/pricing.ts +10 -0
- package/src/scripts/ai_council/redact_low_impact_entry.ts +5 -2
- package/src/scripts/ai_council/response_render.ts +27 -4
- package/src/scripts/ai_council/round_reservations.ts +119 -0
- package/src/scripts/ai_council/route_chooser.ts +161 -0
- package/src/scripts/ai_council/route_liveness.ts +152 -0
- package/src/scripts/ai_council/route_member.ts +52 -0
- package/src/scripts/ai_council/seat_policy.ts +40 -0
- package/src/scripts/ai_council/seat_resume.ts +40 -0
- package/src/scripts/ai_council/shadow_dispatch.ts +13 -3
- package/src/scripts/ai_council/spend_gate.ts +18 -2
- package/src/scripts/ai_council/status_surface.ts +37 -0
- package/src/scripts/ai_council/transport_resolver.ts +15 -18
- package/src/scripts/analysis_analysts.ts +226 -0
- package/src/scripts/analysis_anchors.ts +140 -0
- package/src/scripts/analysis_and_optimize.ts +44 -0
- package/src/scripts/analysis_emit.ts +150 -0
- package/src/scripts/analysis_exchange.ts +186 -0
- package/src/scripts/analysis_gate.ts +158 -0
- package/src/scripts/analysis_inbox_final.ts +173 -0
- package/src/scripts/analysis_ledger.ts +119 -0
- package/src/scripts/analysis_pr_optimize.ts +219 -0
- package/src/scripts/analysis_pr_review.ts +240 -0
- package/src/scripts/analysis_pr_target.ts +121 -0
- package/src/scripts/analysis_prompts.ts +130 -0
- package/src/scripts/analysis_publish.ts +358 -0
- package/src/scripts/analysis_questions.ts +78 -0
- package/src/scripts/analysis_run.ts +248 -0
- package/src/scripts/analysis_run_record.ts +210 -0
- package/src/scripts/analysis_target.ts +343 -0
- package/src/scripts/analysis_validate.ts +161 -0
- package/src/scripts/anchor_eval_falsify.ts +1 -1
- package/src/scripts/arrival_report.ts +115 -0
- package/src/scripts/ask_transport.ts +284 -35
- package/src/scripts/backfill_model_tier.ts +4 -5
- package/src/scripts/before_complete_hook.ts +48 -2
- package/src/scripts/bench_hook_latency.ts +3 -3
- package/src/scripts/bench_procedure_cursor.ts +440 -0
- package/src/scripts/bootstrap.sh +3 -3
- package/src/scripts/build_exit_code_register.ts +440 -0
- package/src/scripts/build_proof.ts +23 -1
- package/src/scripts/cache_realization_report.ts +155 -14
- package/src/scripts/canary_liveness.ts +117 -0
- package/src/scripts/chat_history.ts +12 -15
- package/src/scripts/check_account_surface.ts +318 -0
- package/src/scripts/check_agent_artifact_location.ts +17 -160
- package/src/scripts/check_bundle_path_leakage.ts +6 -0
- package/src/scripts/check_ci_local_parity.ts +21 -13
- package/src/scripts/check_claims.ts +77 -2
- package/src/scripts/check_completion_review.ts +34 -1
- package/src/scripts/check_concern_admissions.ts +41 -5
- package/src/scripts/check_consumer_scope_flip.ts +1 -1
- package/src/scripts/check_context_paths.ts +2 -0
- package/src/scripts/check_council_layout.ts +9 -0
- package/src/scripts/check_credential_spelling.ts +267 -0
- package/src/scripts/check_egress_mutations.ts +239 -0
- package/src/scripts/check_enforcement_coverage.ts +16 -3
- package/src/scripts/check_estate_count.ts +16 -1
- package/src/scripts/check_finding_dispositions.ts +147 -0
- package/src/scripts/check_gate_coverage.ts +123 -21
- package/src/scripts/check_gate_reachability.ts +16 -2
- package/src/scripts/check_generator_sync.ts +46 -0
- package/src/scripts/check_hook_bundle_composition.ts +139 -1
- package/src/scripts/check_host_docs_digest.ts +142 -5
- package/src/scripts/check_kernel_edit_ratified.ts +301 -76
- package/src/scripts/check_kernel_rule_bundle.ts +14 -10
- package/src/scripts/check_knowledge_cards.ts +83 -3
- package/src/scripts/check_memory.ts +13 -3
- package/src/scripts/check_pack_size.ts +1 -1
- package/src/scripts/check_permission_deny_syntax.ts +247 -0
- package/src/scripts/check_platform_anchor.ts +243 -0
- package/src/scripts/check_proposal.ts +183 -1
- package/src/scripts/check_reach_channels.ts +5 -3
- package/src/scripts/check_references.ts +5 -2
- package/src/scripts/check_release_manifest_content.ts +33 -0
- package/src/scripts/check_release_pr_shape.ts +5 -0
- package/src/scripts/check_rule_invariants.ts +9 -1
- package/src/scripts/check_skill_body_budget.ts +343 -0
- package/src/scripts/check_skill_requires.ts +137 -1
- package/src/scripts/check_step_receipts.ts +246 -0
- package/src/scripts/check_structural_breaking.ts +7 -1
- package/src/scripts/check_suppression_hygiene.ts +8 -0
- package/src/scripts/check_test_weakening.ts +14 -0
- package/src/scripts/check_token_quality_golden.ts +5 -1
- package/src/scripts/check_update_banner.ts +50 -3
- package/src/scripts/check_verify_expectation_delta.ts +2 -1
- package/src/scripts/check_voice_lexicon.ts +531 -0
- package/src/scripts/ci_os_attribution.ts +327 -0
- package/src/scripts/ci_platform_scope.ts +69 -0
- package/src/scripts/ci_settle.ts +4 -1
- package/src/scripts/ci_status.ts +0 -1
- package/src/scripts/ci_time_to_green.ts +748 -0
- package/src/scripts/classify_merge_risk.ts +407 -19
- package/src/scripts/code_graph/sqlite_store.ts +1 -1
- package/src/scripts/compile_trigger_evals.ts +353 -0
- package/src/scripts/condense.ts +25 -31
- package/src/scripts/consumer_matrix.ts +61 -3
- package/src/scripts/council_availability_hook.ts +12 -4
- package/src/scripts/council_cli.ts +48 -38
- package/src/scripts/cross_repo_retrieve.ts +9 -72
- package/src/scripts/design_lock.ts +106 -0
- package/src/scripts/design_slop_rules.ts +30 -0
- package/src/scripts/design_sync.ts +264 -0
- package/src/scripts/design_system_import.ts +30 -13
- package/src/scripts/dispatch_economy_report.ts +46 -1
- package/src/scripts/dispatch_r2_reviewer.ts +41 -5
- package/src/scripts/egress_canary.ts +166 -0
- package/src/scripts/egress_sender_census.ts +101 -0
- package/src/scripts/external_sources_denylist.json +94 -12
- package/src/scripts/generate_catalog.ts +6 -2
- package/src/scripts/generate_owned_digest.ts +163 -0
- package/src/scripts/generate_reference_toc.ts +143 -0
- package/src/scripts/generate_subagent_floor.ts +11 -1
- package/src/scripts/handoff_context_hook.ts +34 -0
- package/src/scripts/hook_carrier_census.ts +263 -0
- package/src/scripts/hook_chunks.d.mts +12 -0
- package/src/scripts/hook_chunks.mjs +114 -0
- package/src/scripts/hook_manifest.json +1 -1
- package/src/scripts/hook_manifest.yaml +65 -42
- package/src/scripts/hooks/block_config_weakening.ts +127 -3
- package/src/scripts/hooks/block_credential_reads.ts +165 -0
- package/src/scripts/hooks/block_no_verify.ts +47 -23
- package/src/scripts/hooks/block_speaking_inbox_dir.ts +54 -8
- package/src/scripts/hooks/category_a.ts +202 -25
- package/src/scripts/hooks/concern_failure_policy.ts +6 -6
- package/src/scripts/hooks/concern_registry.ts +31 -6
- package/src/scripts/hooks/concern_registry_types.ts +11 -0
- package/src/scripts/hooks/delegation_nudge_hook.ts +105 -15
- package/src/scripts/hooks/design_pass_hook.ts +199 -13
- package/src/scripts/hooks/dispatch_hook.ts +13 -12
- package/src/scripts/hooks/egress_engine_loader.ts +125 -0
- package/src/scripts/hooks/egress_stage.ts +440 -0
- package/src/scripts/hooks/hook_stdin.ts +29 -4
- package/src/scripts/hooks/host_docs_pages.ts +194 -0
- package/src/scripts/hooks/host_docs_pages.yaml +75 -0
- package/src/scripts/hooks/host_lowering.json +1 -1
- package/src/scripts/hooks/host_lowering.yaml +22 -21
- package/src/scripts/hooks/host_rate_marker_hook.ts +73 -0
- package/src/scripts/hooks/instructions_observer_hook.ts +170 -0
- package/src/scripts/hooks/interruption_ledger_hook.ts +1 -1
- package/src/scripts/hooks/lazy_concern.ts +148 -0
- package/src/scripts/hooks/orchestration_record_hook.ts +80 -2
- package/src/scripts/hooks/payload_stub.ts +16 -6
- package/src/scripts/hooks/permission_gate.ts +7 -7
- package/src/scripts/hooks/push_settle_hook.ts +32 -3
- package/src/scripts/hooks/replay_hook.ts +43 -0
- package/src/scripts/hooks/reread_guard_hook.ts +87 -10
- package/src/scripts/hooks/rtk_wrap_hook.ts +4 -3
- package/src/scripts/hooks/rule_inject_hook.ts +8 -1
- package/src/scripts/hooks/session_eol_hook.ts +48 -1
- package/src/scripts/hooks/source_first_gate_hook.ts +6 -8
- package/src/scripts/hooks/spawn_guard_shadow_hook.ts +203 -10
- package/src/scripts/hooks/state_io.ts +2 -2
- package/src/scripts/hooks/svg_obligation.ts +553 -0
- package/src/scripts/hooks/svg_rules_loader.ts +133 -0
- package/src/scripts/hooks/tool_result_bytes_hook.ts +14 -5
- package/src/scripts/hooks/turn_end_gate_hook.ts +5 -3
- package/src/scripts/hooks/ui_route_nudge_hook.ts +2 -12
- package/src/scripts/hooks_doctor.ts +31 -0
- package/src/scripts/hooks_status.ts +58 -3
- package/src/scripts/inbox_source_census.ts +74 -13
- package/src/scripts/install +25 -3
- package/src/scripts/install.ts +60 -91
- package/src/scripts/interruption_report.ts +11 -1
- package/src/scripts/layer_baseline_report.ts +267 -0
- package/src/scripts/learning_sidecar.ts +1 -1
- package/src/scripts/lint_agents_layout.ts +3 -0
- package/src/scripts/lint_blocker_citations.ts +104 -0
- package/src/scripts/lint_breaking_changes_index.ts +40 -7
- package/src/scripts/lint_consolidation_lineage.ts +150 -19
- package/src/scripts/lint_consumer_internal_refs.ts +90 -42
- package/src/scripts/lint_context_spine_usage.ts +21 -0
- package/src/scripts/lint_design_antipattern_parity.ts +39 -7
- package/src/scripts/lint_design_quality.ts +60 -12
- package/src/scripts/lint_evidence_artifacts.ts +31 -0
- package/src/scripts/lint_example_fences.ts +11 -2
- package/src/scripts/lint_ghostwriter_source.ts +42 -10
- package/src/scripts/lint_hook_manifest.ts +94 -0
- package/src/scripts/lint_marketplace_install_completeness.ts +4 -0
- package/src/scripts/lint_mcp_config_security.ts +9 -11
- package/src/scripts/lint_motion_authority_drift.ts +27 -0
- package/src/scripts/lint_plan_risk_register.ts +28 -1
- package/src/scripts/lint_positioning.ts +4 -4
- package/src/scripts/lint_provenance.ts +1 -0
- package/src/scripts/lint_roadmap_blockers.ts +65 -4
- package/src/scripts/lint_roadmap_complexity.ts +98 -0
- package/src/scripts/lint_skill_link_reach.ts +251 -9
- package/src/scripts/lint_skill_procedures.ts +252 -0
- package/src/scripts/lint_skill_scripts_readonly.ts +12 -1
- package/src/scripts/lint_subagent_determinism.ts +14 -1
- package/src/scripts/lint_svg_asset.ts +365 -0
- package/src/scripts/lint_ticked_unmet_criteria.ts +300 -21
- package/src/scripts/mcp_registry_submit.sh +2 -2
- package/src/scripts/mcp_server/consumer_tool_catalog.json +4 -4
- package/src/scripts/mcp_server/suggest_skill.ts +89 -4
- package/src/scripts/mcp_server/tools.ts +2 -33
- package/src/scripts/measure_skill_ranker_baseline.ts +203 -5
- package/src/scripts/measure_turn_end_gate.ts +61 -1
- package/src/scripts/merge_clearance.ts +225 -0
- package/src/scripts/migrate_command_suggestions.ts +1 -1
- package/src/scripts/network_sources.ts +236 -0
- package/src/scripts/no_go_deny_rows.ts +225 -0
- package/src/scripts/orchestration_record.ts +15 -2
- package/src/scripts/plan_test_shards.ts +103 -0
- package/src/scripts/pr_url_reminder_hook.ts +10 -0
- package/src/scripts/print_required_checks.ts +5 -5
- package/src/scripts/probe_depth_shadow.ts +406 -0
- package/src/scripts/probe_turnaround.ts +342 -10
- package/src/scripts/ratification_subject.ts +176 -0
- package/src/scripts/rdp_gate_classify.ts +1 -0
- package/src/scripts/rdp_quality_eval.ts +1 -0
- package/src/scripts/release.ts +26 -55
- package/src/scripts/release_drill.ts +52 -23
- package/src/scripts/release_env.ts +37 -0
- package/src/scripts/release_publication.ts +11 -1
- package/src/scripts/report_consumer_gate_reach.ts +233 -0
- package/src/scripts/report_merge_gate_load.ts +295 -0
- package/src/scripts/report_project_contract.ts +123 -0
- package/src/scripts/report_reducible_classes.ts +342 -0
- package/src/scripts/report_required_checks_drift.ts +5 -3
- package/src/scripts/report_skill_host_census.ts +199 -0
- package/src/scripts/report_standing_payload_by_host.ts +7 -7
- package/src/scripts/retro.ts +758 -0
- package/src/scripts/retro_facts.ts +575 -0
- package/src/scripts/retro_queue.ts +739 -0
- package/src/scripts/retro_session_facts.ts +218 -0
- package/src/scripts/retro_sweep.ts +493 -0
- package/src/scripts/retro_triage.ts +126 -0
- package/src/scripts/roadmap_context.ts +2 -2
- package/src/scripts/roadmap_drain_queue.ts +601 -0
- package/src/scripts/run_supervise.ts +24 -2
- package/src/scripts/schemas/agent-settings.schema.json +0 -16
- package/src/scripts/schemas/command.schema.json +3 -3
- package/src/scripts/schemas/review-findings.schema.json +8 -0
- package/src/scripts/schemas/skill.schema.json +7 -6
- package/src/scripts/schemas/subagent.schema.json +33 -2
- package/src/scripts/score_skill_selection.ts +5 -2
- package/src/scripts/second_brain_retrieval.ts +1 -0
- package/src/scripts/second_brain_run.ts +1 -0
- package/src/scripts/self_repair_cli.ts +563 -87
- package/src/scripts/self_review_gate.ts +59 -4
- package/src/scripts/session_register_hook.ts +91 -4
- package/src/scripts/sessions_cli.ts +100 -5
- package/src/scripts/skill_collision_clusters.ts +1 -1
- package/src/scripts/skill_tools/score_skill_relevance.ts +31 -2
- package/src/scripts/skill_trigger_eval.ts +4 -2
- package/src/scripts/source_adapters.ts +183 -0
- package/src/scripts/step_receipt.ts +100 -0
- package/src/scripts/sync_pr_branch.ts +4 -0
- package/src/scripts/test_council_qualification.ts +1 -1
- package/src/scripts/trigger_eval_grandfather.json +3 -49
- package/src/scripts/trigger_eval_rotation.ts +31 -3
- package/src/scripts/ui_conformance_probe.ts +405 -1
- package/src/scripts/update_counts.ts +230 -11
- package/src/scripts/update_invite_hook.ts +245 -0
- package/src/scripts/update_notice_hook.ts +298 -0
- package/src/scripts/validate_frontmatter.ts +85 -0
- package/src/scripts/worker_reuse_shadow_report.ts +121 -0
- package/src/scripts/worktree_cleanup_check.ts +915 -121
- package/src/server/io/yamlIO.ts +2 -2
- package/src/server/schemas/settings.ts +37 -23
- package/src/shared/brandTokenDocument.ts +46 -0
- package/src/shared/brandTokenPaths.ts +43 -0
- package/src/shared/settingsCarveOut.ts +0 -8
- package/src/shared/skillRanking.ts +106 -5
- package/src/shared/userMd/formAdapter.ts +15 -1
- package/src/shared/userMd/schema.ts +22 -0
- package/src/templates/agent-user.md +4 -0
- package/src/templates/agent-user.yml +4 -0
- package/dist/cli-delegate/chunk-523HCFYO.js +0 -90
- package/dist/cli-delegate/chunk-AL3RZ22D.js +0 -74
- package/dist/cli-delegate/chunk-KB5FZ655.js +0 -208
- package/dist/cli-delegate/chunk-MDPPKQCQ.js +0 -875
- package/dist/cli-delegate/chunk-MSUL5NYP.js +0 -1123
- package/dist/cli-delegate/chunk-OAFSJBHH.js +0 -272
- package/dist/ui/assets/index-C3djEJah.js +0 -23
- package/src/scripts/_lib/continuation_ladder.ts +0 -335
- package/src/scripts/hooks/run_continuation_hook.ts +0 -1524
|
@@ -1,33 +1,39 @@
|
|
|
1
1
|
import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
THIN_ENTRY_MARKER,
|
|
4
|
+
TIER_TO_CLAUDE_MODEL,
|
|
4
5
|
readRecentEntries
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-JHMMWNJ2.js";
|
|
7
|
+
import "./chunk-LF2KKJ4Q.js";
|
|
6
8
|
import {
|
|
7
9
|
detectToolPresence
|
|
8
10
|
} from "./chunk-A4QJ6ENT.js";
|
|
9
11
|
import {
|
|
10
12
|
NO_RED_EVIDENCE_REASON,
|
|
13
|
+
RENDER_REL,
|
|
11
14
|
deriveSessionKey,
|
|
12
15
|
describeRecordFinding,
|
|
13
16
|
foldRefusal,
|
|
14
17
|
foldShadow,
|
|
18
|
+
hasInstrumentGap,
|
|
15
19
|
hasRedThenGreen,
|
|
16
20
|
isCiPoll,
|
|
21
|
+
isPureRender,
|
|
17
22
|
isVacuousOutput,
|
|
18
|
-
|
|
23
|
+
isVerificationAttempt,
|
|
19
24
|
parseRecord,
|
|
20
25
|
parseShadowRecord,
|
|
21
26
|
pendingCount,
|
|
27
|
+
readAssetRenderRecords,
|
|
22
28
|
readInstallBoundary,
|
|
23
29
|
readRunEvidence,
|
|
24
30
|
readTurnRunState,
|
|
31
|
+
recordedManifest,
|
|
25
32
|
sessionRefusalFile,
|
|
26
33
|
sessionShadowFile,
|
|
27
34
|
shadowSetBy,
|
|
28
|
-
statePathFor
|
|
29
|
-
|
|
30
|
-
} from "./chunk-AED2VQGM.js";
|
|
35
|
+
statePathFor
|
|
36
|
+
} from "./chunk-2CX7NWRB.js";
|
|
31
37
|
import {
|
|
32
38
|
LexicalIndex,
|
|
33
39
|
isSqliteAvailableSync,
|
|
@@ -42,7 +48,6 @@ import {
|
|
|
42
48
|
_classify,
|
|
43
49
|
_collect_manifest_entries,
|
|
44
50
|
_foreign_records,
|
|
45
|
-
_is_global_only_consumer,
|
|
46
51
|
_jsonDumpsIndentAscii,
|
|
47
52
|
_resolve_project_root,
|
|
48
53
|
_run_checks,
|
|
@@ -51,25 +56,38 @@ import {
|
|
|
51
56
|
censusRuleDir,
|
|
52
57
|
comparePair,
|
|
53
58
|
frontmatterPaths,
|
|
59
|
+
openRecordStats,
|
|
54
60
|
proseEqual,
|
|
55
61
|
resolveSessionRole,
|
|
56
62
|
splitFrontmatter
|
|
57
|
-
} from "./chunk-
|
|
58
|
-
import
|
|
59
|
-
|
|
63
|
+
} from "./chunk-CAL76ADI.js";
|
|
64
|
+
import {
|
|
65
|
+
_is_global_only_consumer
|
|
66
|
+
} from "./chunk-2Y5AMLMY.js";
|
|
60
67
|
import "./chunk-ROYYTEZU.js";
|
|
61
68
|
import "./chunk-BTWUYDGN.js";
|
|
69
|
+
import "./chunk-UUYEKXKR.js";
|
|
70
|
+
import "./chunk-FTAISGDQ.js";
|
|
71
|
+
import "./chunk-5VO3RTMV.js";
|
|
72
|
+
import "./chunk-6V6TA25H.js";
|
|
73
|
+
import "./chunk-AX3U3UWJ.js";
|
|
62
74
|
import {
|
|
63
75
|
atomicAppendLine,
|
|
64
76
|
probeHostCapabilities
|
|
65
|
-
} from "./chunk-
|
|
66
|
-
import "./chunk-
|
|
77
|
+
} from "./chunk-GOMILC3O.js";
|
|
78
|
+
import "./chunk-7DRWULEQ.js";
|
|
67
79
|
import "./chunk-ULQRUR23.js";
|
|
68
80
|
import {
|
|
69
|
-
hardenedSpawnEnv
|
|
81
|
+
hardenedSpawnEnv
|
|
82
|
+
} from "./chunk-I4KJYVPB.js";
|
|
83
|
+
import {
|
|
84
|
+
EXIT_ALLOW,
|
|
85
|
+
EXIT_BLOCK,
|
|
86
|
+
EXIT_WARN,
|
|
70
87
|
projectStoreSlug
|
|
71
|
-
} from "./chunk-
|
|
88
|
+
} from "./chunk-FKYZOWVD.js";
|
|
72
89
|
import "./chunk-IAYTIIQW.js";
|
|
90
|
+
import "./chunk-PV7S5DPJ.js";
|
|
73
91
|
import "./chunk-LQOCRFWT.js";
|
|
74
92
|
import {
|
|
75
93
|
atomic_write_json,
|
|
@@ -81,35 +99,42 @@ import {
|
|
|
81
99
|
prune_stale_session_states,
|
|
82
100
|
session_state_file
|
|
83
101
|
} from "./chunk-7HKRE54K.js";
|
|
84
|
-
import
|
|
102
|
+
import {
|
|
103
|
+
load_agent_settings
|
|
104
|
+
} from "./chunk-XLY5G3CM.js";
|
|
105
|
+
import "./chunk-2SFOOFJJ.js";
|
|
106
|
+
import "./chunk-FIEEOH5C.js";
|
|
107
|
+
import "./chunk-E6XNBVE4.js";
|
|
108
|
+
import {
|
|
109
|
+
artefact_roots
|
|
110
|
+
} from "./chunk-YCU3TIXH.js";
|
|
85
111
|
import "./chunk-DEIV7XP7.js";
|
|
112
|
+
import "./chunk-J2SJZICO.js";
|
|
86
113
|
import {
|
|
87
114
|
manifest_path,
|
|
88
115
|
read_manifest
|
|
89
|
-
} from "./chunk-
|
|
90
|
-
import
|
|
91
|
-
|
|
116
|
+
} from "./chunk-4E2W63DA.js";
|
|
117
|
+
import {
|
|
118
|
+
parseRouteFields,
|
|
119
|
+
resolveRouteTransport
|
|
120
|
+
} from "./chunk-M6CRG5O6.js";
|
|
92
121
|
import "./chunk-MWRD5YOH.js";
|
|
93
|
-
import "./chunk-
|
|
122
|
+
import "./chunk-BMGUGSY6.js";
|
|
123
|
+
import {
|
|
124
|
+
readHookStdin
|
|
125
|
+
} from "./chunk-RAXQOETZ.js";
|
|
126
|
+
import "./chunk-IDAOTDPE.js";
|
|
94
127
|
import {
|
|
95
128
|
DeadScopeError,
|
|
96
129
|
assertScanned,
|
|
97
130
|
reportScanned
|
|
98
131
|
} from "./chunk-I3EIN2YG.js";
|
|
99
|
-
import {
|
|
100
|
-
readHookStdin
|
|
101
|
-
} from "./chunk-F7DQWYR5.js";
|
|
102
132
|
import {
|
|
103
133
|
require_dist
|
|
104
134
|
} from "./chunk-OY53J6II.js";
|
|
105
|
-
import "./chunk-LF2KKJ4Q.js";
|
|
106
135
|
import {
|
|
107
|
-
|
|
108
|
-
} from "./chunk-
|
|
109
|
-
import {
|
|
110
|
-
artefact_roots
|
|
111
|
-
} from "./chunk-YCU3TIXH.js";
|
|
112
|
-
import "./chunk-T6BP34WI.js";
|
|
136
|
+
resolve_with_fallback
|
|
137
|
+
} from "./chunk-T6BP34WI.js";
|
|
113
138
|
import {
|
|
114
139
|
resolvePackageRoot
|
|
115
140
|
} from "./chunk-MCJYCQPF.js";
|
|
@@ -119,12 +144,12 @@ import {
|
|
|
119
144
|
|
|
120
145
|
// src/scripts/_cli/cmd_conformance.ts
|
|
121
146
|
var YAML = __toESM(require_dist(), 1);
|
|
122
|
-
import * as
|
|
147
|
+
import * as fs22 from "node:fs";
|
|
123
148
|
import * as os7 from "node:os";
|
|
124
|
-
import * as
|
|
149
|
+
import * as path19 from "node:path";
|
|
125
150
|
import process5 from "node:process";
|
|
126
151
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
127
|
-
import { fileURLToPath as
|
|
152
|
+
import { fileURLToPath as fileURLToPath13, pathToFileURL as pathToFileURL13 } from "node:url";
|
|
128
153
|
|
|
129
154
|
// src/scripts/router_target_paths.mjs
|
|
130
155
|
var ROUTE_TARGET_TEMPLATES = Object.freeze({
|
|
@@ -137,10 +162,10 @@ var ROUTE_TARGET_TEMPLATES = Object.freeze({
|
|
|
137
162
|
])
|
|
138
163
|
});
|
|
139
164
|
function parseRouteTarget(target) {
|
|
140
|
-
const
|
|
141
|
-
if (
|
|
142
|
-
const kind = target.slice(0,
|
|
143
|
-
const id = target.slice(
|
|
165
|
+
const sep5 = target.indexOf(":");
|
|
166
|
+
if (sep5 <= 0) return null;
|
|
167
|
+
const kind = target.slice(0, sep5);
|
|
168
|
+
const id = target.slice(sep5 + 1);
|
|
144
169
|
if (!id) return null;
|
|
145
170
|
if (!Object.prototype.hasOwnProperty.call(ROUTE_TARGET_TEMPLATES, kind)) return null;
|
|
146
171
|
return { kind, id };
|
|
@@ -152,18 +177,18 @@ function routeTargetPathsPosix(target) {
|
|
|
152
177
|
}
|
|
153
178
|
|
|
154
179
|
// src/scripts/report_conformance_funnel.ts
|
|
155
|
-
import * as
|
|
180
|
+
import * as fs21 from "node:fs";
|
|
156
181
|
import * as os6 from "node:os";
|
|
157
|
-
import * as
|
|
182
|
+
import * as path18 from "node:path";
|
|
158
183
|
import process4 from "node:process";
|
|
159
|
-
import { fileURLToPath as
|
|
184
|
+
import { fileURLToPath as fileURLToPath12, pathToFileURL as pathToFileURL12 } from "node:url";
|
|
160
185
|
|
|
161
186
|
// src/scripts/conformance_scan.ts
|
|
162
187
|
import { createHash as createHash4 } from "node:crypto";
|
|
163
|
-
import
|
|
188
|
+
import fs17 from "node:fs";
|
|
164
189
|
import os2 from "node:os";
|
|
165
|
-
import
|
|
166
|
-
import { fileURLToPath as
|
|
190
|
+
import path14 from "node:path";
|
|
191
|
+
import { fileURLToPath as fileURLToPath8, pathToFileURL as pathToFileURL8 } from "node:url";
|
|
167
192
|
|
|
168
193
|
// src/scripts/_lib/transcript_entry.ts
|
|
169
194
|
function _isObject(v) {
|
|
@@ -210,8 +235,9 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
210
235
|
// src/scripts/_lib/prompt_shape.ts
|
|
211
236
|
function isSyntheticPrompt(prompt) {
|
|
212
237
|
const head = prompt.trimStart().slice(0, 400);
|
|
213
|
-
return head.startsWith("[SYSTEM NOTIFICATION - NOT USER INPUT]") || head.startsWith("<task-notification>") || head.startsWith("<system-reminder>") || head.startsWith("<local-command-caveat>") || head.startsWith("<agent-message") || head.startsWith("Your claude.ai usage limit has reset") || /^\[SYSTEM NOTIFICATION\b/.test(head);
|
|
238
|
+
return head.startsWith("[SYSTEM NOTIFICATION - NOT USER INPUT]") || head.startsWith("<task-notification>") || head.startsWith("<system-reminder>") || head.startsWith("<local-command-caveat>") || head.startsWith("<agent-message") || head.startsWith("Your claude.ai usage limit has reset") || /^\[SYSTEM NOTIFICATION\b/.test(head) || AGENT_MESSAGE_FRAME.test(head);
|
|
214
239
|
}
|
|
240
|
+
var AGENT_MESSAGE_FRAME = /^Another Claude session sent a message:\s*\n\s*<(?:agent-message|cross-session-message)\b/;
|
|
215
241
|
var DOCUMENT_HEAD = /^\s*(#{1,6}\s|-{3,}\s*$|={3,}\s*$|<[A-Za-z][\w-]*>\s*$)/;
|
|
216
242
|
function humanAuthoredLead(text) {
|
|
217
243
|
const kept = [];
|
|
@@ -262,8 +288,8 @@ function stripInjectedRegions(text) {
|
|
|
262
288
|
}
|
|
263
289
|
|
|
264
290
|
// src/scripts/language_mirror_hook.ts
|
|
265
|
-
var
|
|
266
|
-
var
|
|
291
|
+
var EXIT_ALLOW2 = 0;
|
|
292
|
+
var EXIT_WARN2 = 2;
|
|
267
293
|
var STATE_FILE = path.join("agents", "state", "language-mirror.json");
|
|
268
294
|
var STATE_DIR = path.join("agents", "state", "language-mirror");
|
|
269
295
|
var STATE_RETENTION_DAYS = 7;
|
|
@@ -463,24 +489,24 @@ function _clearPinLost(consumer_root, session_id) {
|
|
|
463
489
|
}
|
|
464
490
|
function _reEmitAfterCompaction(consumer_root, session_id, write_json = atomic_write_json) {
|
|
465
491
|
if (!hasStableSessionId(session_id)) {
|
|
466
|
-
return
|
|
492
|
+
return EXIT_ALLOW2;
|
|
467
493
|
}
|
|
468
494
|
if (!_pinLost(consumer_root, session_id)) {
|
|
469
|
-
return
|
|
495
|
+
return EXIT_ALLOW2;
|
|
470
496
|
}
|
|
471
|
-
return _withToolWriteLock(consumer_root, session_id,
|
|
497
|
+
return _withToolWriteLock(consumer_root, session_id, EXIT_ALLOW2, () => {
|
|
472
498
|
const previous = _loadState(path.join(consumer_root, statePathFor2(session_id)));
|
|
473
499
|
const language = previous.language;
|
|
474
500
|
const source = previous.source === "system-locale" ? "system-locale" : "prompt";
|
|
475
501
|
_clearPinLost(consumer_root, session_id);
|
|
476
502
|
if (language !== "de" && language !== "en") {
|
|
477
|
-
return
|
|
503
|
+
return EXIT_ALLOW2;
|
|
478
504
|
}
|
|
479
505
|
if (!_ownsPin(previous, session_id)) {
|
|
480
|
-
return
|
|
506
|
+
return EXIT_ALLOW2;
|
|
481
507
|
}
|
|
482
508
|
if (!_resetDistance(consumer_root, previous, session_id, write_json)) {
|
|
483
|
-
return
|
|
509
|
+
return EXIT_ALLOW2;
|
|
484
510
|
}
|
|
485
511
|
process.stdout.write(
|
|
486
512
|
`${JSON.stringify({
|
|
@@ -490,7 +516,7 @@ function _reEmitAfterCompaction(consumer_root, session_id, write_json = atomic_w
|
|
|
490
516
|
})}
|
|
491
517
|
`
|
|
492
518
|
);
|
|
493
|
-
return
|
|
519
|
+
return EXIT_WARN2;
|
|
494
520
|
});
|
|
495
521
|
}
|
|
496
522
|
function _pruneLegacyState(consumer_root) {
|
|
@@ -570,19 +596,19 @@ function _resetDistance(consumer_root, expected, session_id, write_json = atomic
|
|
|
570
596
|
}
|
|
571
597
|
function _reEmitAfterDistance(consumer_root, session_id, write_json = atomic_write_json) {
|
|
572
598
|
if (is_replay_mode()) {
|
|
573
|
-
return
|
|
599
|
+
return EXIT_ALLOW2;
|
|
574
600
|
}
|
|
575
601
|
if (!hasStableSessionId(session_id)) {
|
|
576
|
-
return
|
|
602
|
+
return EXIT_ALLOW2;
|
|
577
603
|
}
|
|
578
|
-
return _withToolWriteLock(consumer_root, session_id,
|
|
604
|
+
return _withToolWriteLock(consumer_root, session_id, EXIT_ALLOW2, () => {
|
|
579
605
|
const previous = _loadState(path.join(consumer_root, statePathFor2(session_id)));
|
|
580
606
|
const language = previous.language;
|
|
581
607
|
if (language !== "de" && language !== "en") {
|
|
582
|
-
return
|
|
608
|
+
return EXIT_ALLOW2;
|
|
583
609
|
}
|
|
584
610
|
if (!_ownsPin(previous, session_id)) {
|
|
585
|
-
return
|
|
611
|
+
return EXIT_ALLOW2;
|
|
586
612
|
}
|
|
587
613
|
const seen = typeof previous.tool_calls_since_pin === "number" && previous.tool_calls_since_pin >= 0 ? previous.tool_calls_since_pin : 0;
|
|
588
614
|
const advanced = seen + 1;
|
|
@@ -595,10 +621,10 @@ function _reEmitAfterDistance(consumer_root, session_id, write_json = atomic_wri
|
|
|
595
621
|
write_json
|
|
596
622
|
);
|
|
597
623
|
if (!due) {
|
|
598
|
-
return
|
|
624
|
+
return EXIT_ALLOW2;
|
|
599
625
|
}
|
|
600
626
|
if (!written) {
|
|
601
|
-
return
|
|
627
|
+
return EXIT_ALLOW2;
|
|
602
628
|
}
|
|
603
629
|
const source = previous.source === "system-locale" ? "system-locale" : "prompt";
|
|
604
630
|
process.stdout.write(
|
|
@@ -609,7 +635,7 @@ function _reEmitAfterDistance(consumer_root, session_id, write_json = atomic_wri
|
|
|
609
635
|
})}
|
|
610
636
|
`
|
|
611
637
|
);
|
|
612
|
-
return
|
|
638
|
+
return EXIT_WARN2;
|
|
613
639
|
});
|
|
614
640
|
}
|
|
615
641
|
function _onToolUse(consumer_root, session_id, write_json = atomic_write_json) {
|
|
@@ -627,24 +653,24 @@ function run(stdin_text, options) {
|
|
|
627
653
|
envelope = decoded;
|
|
628
654
|
}
|
|
629
655
|
} catch {
|
|
630
|
-
return
|
|
656
|
+
return EXIT_ALLOW2;
|
|
631
657
|
}
|
|
632
658
|
}
|
|
633
659
|
const payload = _isObject2(envelope["payload"]) ? envelope["payload"] : envelope;
|
|
634
660
|
const event = typeof envelope["event"] === "string" ? envelope["event"] : "";
|
|
635
661
|
if (event === "pre_compact") {
|
|
636
662
|
_setPinLost(options.consumer_root, _sessionId(envelope));
|
|
637
|
-
return
|
|
663
|
+
return EXIT_ALLOW2;
|
|
638
664
|
}
|
|
639
665
|
if (event === "post_tool_use") {
|
|
640
666
|
return _onToolUse(options.consumer_root, _sessionId(envelope), options.write_json);
|
|
641
667
|
}
|
|
642
668
|
const prompt = _extractPrompt(payload);
|
|
643
669
|
if (!prompt) {
|
|
644
|
-
return
|
|
670
|
+
return EXIT_ALLOW2;
|
|
645
671
|
}
|
|
646
672
|
if (isSyntheticPrompt(prompt)) {
|
|
647
|
-
return
|
|
673
|
+
return EXIT_ALLOW2;
|
|
648
674
|
}
|
|
649
675
|
const session_id = typeof envelope["session_id"] === "string" ? envelope["session_id"] : "";
|
|
650
676
|
const stateful = hasStableSessionId(session_id);
|
|
@@ -682,9 +708,9 @@ function run(stdin_text, options) {
|
|
|
682
708
|
`${JSON.stringify({ decision: "warn", reason: noticeText(effective, effectiveSource), additional_context: pinText(effective, effectiveSource) })}
|
|
683
709
|
`
|
|
684
710
|
);
|
|
685
|
-
return
|
|
711
|
+
return EXIT_WARN2;
|
|
686
712
|
}
|
|
687
|
-
return
|
|
713
|
+
return EXIT_ALLOW2;
|
|
688
714
|
}
|
|
689
715
|
function _errText(err) {
|
|
690
716
|
const t = err instanceof Error ? err.message : String(err);
|
|
@@ -871,7 +897,7 @@ function extractObjects(op, text) {
|
|
|
871
897
|
}
|
|
872
898
|
|
|
873
899
|
// src/scripts/git_authorization_hook.ts
|
|
874
|
-
var
|
|
900
|
+
var EXIT_ALLOW3 = 0;
|
|
875
901
|
var STATE_FILE2 = path2.join("agents", "state", "git-authorization.json");
|
|
876
902
|
var STATE_DIR2 = path2.join("agents", "state", "git-authorization");
|
|
877
903
|
var PENDING_DIR = path2.join("agents", "state", "git-authorization-pending");
|
|
@@ -1431,7 +1457,7 @@ function run2(stdin_text, options) {
|
|
|
1431
1457
|
envelope = decoded;
|
|
1432
1458
|
}
|
|
1433
1459
|
} catch {
|
|
1434
|
-
return
|
|
1460
|
+
return EXIT_ALLOW3;
|
|
1435
1461
|
}
|
|
1436
1462
|
}
|
|
1437
1463
|
const payload = _isObject3(envelope["payload"]) ? envelope["payload"] : envelope;
|
|
@@ -1444,11 +1470,11 @@ function run2(stdin_text, options) {
|
|
|
1444
1470
|
}
|
|
1445
1471
|
}
|
|
1446
1472
|
if (!prompt) {
|
|
1447
|
-
return
|
|
1473
|
+
return EXIT_ALLOW3;
|
|
1448
1474
|
}
|
|
1449
1475
|
const session = typeof envelope["session_id"] === "string" ? envelope["session_id"] : "";
|
|
1450
1476
|
if (!humanTypedThisTurn(prompt)) {
|
|
1451
|
-
return
|
|
1477
|
+
return EXIT_ALLOW3;
|
|
1452
1478
|
}
|
|
1453
1479
|
const { authorized, evidence } = classifyAuthorization(prompt);
|
|
1454
1480
|
const pending = takePending(options.consumer_root, session, Date.now());
|
|
@@ -1489,7 +1515,7 @@ function run2(stdin_text, options) {
|
|
|
1489
1515
|
`
|
|
1490
1516
|
);
|
|
1491
1517
|
}
|
|
1492
|
-
return
|
|
1518
|
+
return EXIT_ALLOW3;
|
|
1493
1519
|
}
|
|
1494
1520
|
function main2(argv) {
|
|
1495
1521
|
const args = argv ?? process.argv.slice(2);
|
|
@@ -1949,7 +1975,7 @@ var COMMAND_OBJECTS = {
|
|
|
1949
1975
|
// src/scripts/hooks/turn_end_gate_hook.ts
|
|
1950
1976
|
import * as fs12 from "node:fs";
|
|
1951
1977
|
import * as path10 from "node:path";
|
|
1952
|
-
import { fileURLToPath as
|
|
1978
|
+
import { fileURLToPath as fileURLToPath5, pathToFileURL as pathToFileURL5 } from "node:url";
|
|
1953
1979
|
|
|
1954
1980
|
// src/scripts/check_reply_consistency.ts
|
|
1955
1981
|
import * as fs3 from "node:fs";
|
|
@@ -2115,11 +2141,11 @@ function _rglobMdSorted(dir) {
|
|
|
2115
2141
|
return out;
|
|
2116
2142
|
}
|
|
2117
2143
|
function _relToPosixOrAbs(child, root) {
|
|
2118
|
-
const
|
|
2119
|
-
if (
|
|
2144
|
+
const rel2 = path3.relative(root, child);
|
|
2145
|
+
if (rel2 === "" || rel2.startsWith("..") || path3.isAbsolute(rel2)) {
|
|
2120
2146
|
return child.split(path3.sep).join("/");
|
|
2121
2147
|
}
|
|
2122
|
-
return
|
|
2148
|
+
return rel2.split(path3.sep).join("/");
|
|
2123
2149
|
}
|
|
2124
2150
|
function cmd_scan_dir(root) {
|
|
2125
2151
|
let roots;
|
|
@@ -2506,8 +2532,8 @@ function looksLikeGraph(p) {
|
|
|
2506
2532
|
function detectSources(root, nativeCache) {
|
|
2507
2533
|
const abs = path4.resolve(root);
|
|
2508
2534
|
const out = [];
|
|
2509
|
-
for (const
|
|
2510
|
-
const p = path4.join(abs,
|
|
2535
|
+
for (const rel2 of consumerCandidates(abs)) {
|
|
2536
|
+
const p = path4.join(abs, rel2);
|
|
2511
2537
|
if (fs4.existsSync(p)) {
|
|
2512
2538
|
const { ok, sha } = looksLikeGraph(p);
|
|
2513
2539
|
if (ok) out.push({ kind: "consumer", path: p, present: true, ...freshness(abs, p, sha) });
|
|
@@ -3159,15 +3185,15 @@ function toRepoRelative(root, paths) {
|
|
|
3159
3185
|
});
|
|
3160
3186
|
}
|
|
3161
3187
|
function _relativeInside(from, to) {
|
|
3162
|
-
let
|
|
3188
|
+
let rel2;
|
|
3163
3189
|
try {
|
|
3164
|
-
|
|
3190
|
+
rel2 = path6.relative(from, to);
|
|
3165
3191
|
} catch {
|
|
3166
3192
|
return null;
|
|
3167
3193
|
}
|
|
3168
|
-
if (
|
|
3169
|
-
if (
|
|
3170
|
-
return
|
|
3194
|
+
if (rel2 === "") return ".";
|
|
3195
|
+
if (rel2 === ".." || rel2.startsWith(`..${path6.sep}`) || path6.isAbsolute(rel2)) return null;
|
|
3196
|
+
return rel2.split(path6.sep).join("/");
|
|
3171
3197
|
}
|
|
3172
3198
|
function _resolveReal(p) {
|
|
3173
3199
|
const abs = path6.resolve(p);
|
|
@@ -3278,6 +3304,205 @@ function buildFeederRow(input) {
|
|
|
3278
3304
|
};
|
|
3279
3305
|
}
|
|
3280
3306
|
|
|
3307
|
+
// src/scripts/hooks/svg_obligation.ts
|
|
3308
|
+
import * as crypto from "node:crypto";
|
|
3309
|
+
import * as fs8 from "node:fs";
|
|
3310
|
+
import * as path7 from "node:path";
|
|
3311
|
+
var EDIT_TOOLS = /* @__PURE__ */ new Set(["Edit", "Write", "MultiEdit", "NotebookEdit"]);
|
|
3312
|
+
var PLANTED_PREFIXES = [
|
|
3313
|
+
"tests/design-artifacts/fixtures/",
|
|
3314
|
+
"tests/design-artifacts/scenarios/"
|
|
3315
|
+
];
|
|
3316
|
+
function hasErrorFinding(m) {
|
|
3317
|
+
const f = m.asset?.findings;
|
|
3318
|
+
return Array.isArray(f) && f.some((x) => x?.severity === "error");
|
|
3319
|
+
}
|
|
3320
|
+
var rel = (root, p) => {
|
|
3321
|
+
const slashed = p.split(path7.sep).join("/");
|
|
3322
|
+
if (!path7.isAbsolute(p)) return path7.posix.normalize(slashed).replace(/^\.\//, "");
|
|
3323
|
+
const inside = path7.relative(root, p).split(path7.sep).join("/");
|
|
3324
|
+
return inside === "" || inside.startsWith("../") ? slashed : inside;
|
|
3325
|
+
};
|
|
3326
|
+
function isPlantedFixture(relPath, root = "") {
|
|
3327
|
+
const norm = rel(root, relPath);
|
|
3328
|
+
return PLANTED_PREFIXES.some((prefix) => norm.startsWith(prefix));
|
|
3329
|
+
}
|
|
3330
|
+
function readAssetManifests(root) {
|
|
3331
|
+
const dir = path7.join(root, RENDER_REL);
|
|
3332
|
+
let entries;
|
|
3333
|
+
try {
|
|
3334
|
+
entries = fs8.readdirSync(dir);
|
|
3335
|
+
} catch {
|
|
3336
|
+
return [];
|
|
3337
|
+
}
|
|
3338
|
+
const out = [];
|
|
3339
|
+
for (const name of entries) {
|
|
3340
|
+
let raw;
|
|
3341
|
+
try {
|
|
3342
|
+
raw = fs8.readFileSync(path7.join(dir, name, "manifest.json"), "utf8");
|
|
3343
|
+
} catch {
|
|
3344
|
+
continue;
|
|
3345
|
+
}
|
|
3346
|
+
try {
|
|
3347
|
+
const parsed = JSON.parse(raw);
|
|
3348
|
+
if (parsed.profile === "asset") out.push(parsed);
|
|
3349
|
+
} catch {
|
|
3350
|
+
}
|
|
3351
|
+
}
|
|
3352
|
+
return out;
|
|
3353
|
+
}
|
|
3354
|
+
function dischargeFor(manifests, digest) {
|
|
3355
|
+
let staticOnly = false;
|
|
3356
|
+
for (const m of manifests) {
|
|
3357
|
+
if (m.verification === "verified" && m.asset?.digest === digest && !hasErrorFinding(m)) {
|
|
3358
|
+
return "verified";
|
|
3359
|
+
}
|
|
3360
|
+
if (m.reason === "renderer-absent" && m.static?.digest === digest && m.static.errors === 0) {
|
|
3361
|
+
staticOnly = true;
|
|
3362
|
+
}
|
|
3363
|
+
}
|
|
3364
|
+
return staticOnly ? "static-only" : null;
|
|
3365
|
+
}
|
|
3366
|
+
var TRANSCRIPT_FALLBACK_REASON = "transcript fallback: no readable `post_tool_use` render record exists for this turn \u2014 no live recorder on this host (`agent-config hooks:status`), or a render whose exit status the host did not report \u2014 so the manifest was read under the transcript rule \u2014 an omission check, not an attestation";
|
|
3367
|
+
function recordVerdict(root, abs, digest, records) {
|
|
3368
|
+
let changed = false;
|
|
3369
|
+
for (const r of records) {
|
|
3370
|
+
if (path7.resolve(root, r.file) !== abs || r.file_digest !== digest) continue;
|
|
3371
|
+
const read = recordedManifest(root, r);
|
|
3372
|
+
if (read === null) continue;
|
|
3373
|
+
if ("changed" in read) {
|
|
3374
|
+
changed = true;
|
|
3375
|
+
continue;
|
|
3376
|
+
}
|
|
3377
|
+
const kind = dischargeFor([read.manifest], digest);
|
|
3378
|
+
if (kind !== null) return kind;
|
|
3379
|
+
}
|
|
3380
|
+
return changed ? "the manifest the observed render left has changed since, so it is no longer the record of that render" : "no successful `ui:render --profile asset` of these bytes was observed by the hook this turn with a manifest that discharges them \u2014 a manifest written by any other route discharges nothing";
|
|
3381
|
+
}
|
|
3382
|
+
function readSvgObligations(root, inputs) {
|
|
3383
|
+
const open = [];
|
|
3384
|
+
const discharged = [];
|
|
3385
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3386
|
+
let manifests = null;
|
|
3387
|
+
for (const { path: raw, rendered } of inputs.edits) {
|
|
3388
|
+
if (!/\.svg$/i.test(raw)) continue;
|
|
3389
|
+
const relPath = rel(root, raw);
|
|
3390
|
+
if (seen.has(relPath)) continue;
|
|
3391
|
+
seen.add(relPath);
|
|
3392
|
+
if (isPlantedFixture(relPath, root)) continue;
|
|
3393
|
+
const abs = path7.isAbsolute(raw) ? raw : path7.join(root, relPath);
|
|
3394
|
+
let bytes;
|
|
3395
|
+
try {
|
|
3396
|
+
bytes = fs8.readFileSync(abs);
|
|
3397
|
+
} catch {
|
|
3398
|
+
continue;
|
|
3399
|
+
}
|
|
3400
|
+
const digest = crypto.createHash("sha256").update(bytes).digest("hex");
|
|
3401
|
+
if (Array.isArray(inputs.recorded)) {
|
|
3402
|
+
const verdict = recordVerdict(root, path7.resolve(root, abs), digest, inputs.recorded);
|
|
3403
|
+
if (verdict === "verified" || verdict === "static-only") discharged.push({ file: relPath, kind: verdict });
|
|
3404
|
+
else open.push({ file: relPath, reason: verdict });
|
|
3405
|
+
continue;
|
|
3406
|
+
}
|
|
3407
|
+
if (!renderNames(rendered, relPath)) {
|
|
3408
|
+
open.push({
|
|
3409
|
+
file: relPath,
|
|
3410
|
+
reason: "no `ui:render --profile asset` naming this file ran after THIS file's last edit, so no manifest on disk can be attributed to it \u2014 a manifest written by any other route, and a render of some other file, both discharge nothing"
|
|
3411
|
+
});
|
|
3412
|
+
continue;
|
|
3413
|
+
}
|
|
3414
|
+
if (inputs.renderDirTampered) {
|
|
3415
|
+
open.push({
|
|
3416
|
+
file: relPath,
|
|
3417
|
+
reason: "this turn wrote into the render directory by a route other than `ui:render`, so no manifest there is evidence of a render \u2014 re-run the render in a turn that does not touch it"
|
|
3418
|
+
});
|
|
3419
|
+
continue;
|
|
3420
|
+
}
|
|
3421
|
+
manifests ??= readAssetManifests(root);
|
|
3422
|
+
const kind = dischargeFor(manifests, digest);
|
|
3423
|
+
if (kind === null) {
|
|
3424
|
+
open.push({
|
|
3425
|
+
file: relPath,
|
|
3426
|
+
reason: "no asset manifest matches this file's current digest \u2014 a render that is `verified`, or a `renderer-absent` one whose static witness reports 0 errors on the same digest, discharges it"
|
|
3427
|
+
});
|
|
3428
|
+
continue;
|
|
3429
|
+
}
|
|
3430
|
+
discharged.push({ file: relPath, kind });
|
|
3431
|
+
}
|
|
3432
|
+
return { open, discharged };
|
|
3433
|
+
}
|
|
3434
|
+
function renderNames(commands, relPath) {
|
|
3435
|
+
const base = relPath.split("/").pop() ?? relPath;
|
|
3436
|
+
return commands.some((c) => {
|
|
3437
|
+
const slashed = c.split(path7.sep).join("/");
|
|
3438
|
+
const bounded = (needle) => new RegExp(`(^|[\\s/'"])${escapeRe(needle)}(\\s|$|['"])`).test(slashed);
|
|
3439
|
+
return bounded(relPath) || bounded(base);
|
|
3440
|
+
});
|
|
3441
|
+
}
|
|
3442
|
+
function writesRenderDir(command) {
|
|
3443
|
+
if (isPureRender(command)) return false;
|
|
3444
|
+
const slashed = command.split(path7.sep).join("/");
|
|
3445
|
+
const names = /(^|[\s/'"])(render\/|manifest\.json\b)/.test(slashed) || slashed.includes("state/render");
|
|
3446
|
+
const writes = />(?!&)|\b(tee|sponge)\b|\b(cp|mv|ln|install|rsync|dd)\s|\bsed\s+-i|\bwriteFile|\b(python[\d.]*|perl|ruby|node|deno|bun|php|osascript)\b/.test(
|
|
3447
|
+
slashed.replace(/\s\d?>&\d\b/g, " ").replace(/\s2>\s*\/dev\/null\b/g, " ")
|
|
3448
|
+
);
|
|
3449
|
+
return names && writes;
|
|
3450
|
+
}
|
|
3451
|
+
function escapeRe(s) {
|
|
3452
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3453
|
+
}
|
|
3454
|
+
function openSvgObligation(workspaceRoot, toolCalls, recordedRaw = null) {
|
|
3455
|
+
const recordedRenders = recordedRaw === null || hasInstrumentGap(recordedRaw) ? null : recordedRaw;
|
|
3456
|
+
const lastEditOf = /* @__PURE__ */ new Map();
|
|
3457
|
+
for (let i = 0; i < toolCalls.length; i += 1) {
|
|
3458
|
+
const c = toolCalls[i];
|
|
3459
|
+
if (!EDIT_TOOLS.has(c.name) || c.path === void 0) continue;
|
|
3460
|
+
lastEditOf.set(c.path, i);
|
|
3461
|
+
}
|
|
3462
|
+
if (lastEditOf.size === 0) return null;
|
|
3463
|
+
const edits = [...lastEditOf].map(([p, at]) => {
|
|
3464
|
+
const rendered = [];
|
|
3465
|
+
for (let i = at + 1; i < toolCalls.length; i += 1) {
|
|
3466
|
+
const c = toolCalls[i];
|
|
3467
|
+
if (c.name === "Bash" && c.command !== void 0 && isPureRender(c.command)) {
|
|
3468
|
+
rendered.push(c.command);
|
|
3469
|
+
}
|
|
3470
|
+
}
|
|
3471
|
+
return { path: p, rendered };
|
|
3472
|
+
});
|
|
3473
|
+
const renderDir = RENDER_REL.split(path7.sep).join("/");
|
|
3474
|
+
const renderDirTampered = toolCalls.some((c) => {
|
|
3475
|
+
if (EDIT_TOOLS.has(c.name) && c.path !== void 0) {
|
|
3476
|
+
return rel(workspaceRoot, c.path).startsWith(`${renderDir}/`);
|
|
3477
|
+
}
|
|
3478
|
+
return c.name === "Bash" && c.command !== void 0 && writesRenderDir(c.command);
|
|
3479
|
+
});
|
|
3480
|
+
let reading;
|
|
3481
|
+
try {
|
|
3482
|
+
reading = readSvgObligations(workspaceRoot, {
|
|
3483
|
+
edits,
|
|
3484
|
+
renderDirTampered,
|
|
3485
|
+
recorded: recordedRenders === null ? null : readAssetRenderRecords(recordedRenders)
|
|
3486
|
+
});
|
|
3487
|
+
} catch {
|
|
3488
|
+
return null;
|
|
3489
|
+
}
|
|
3490
|
+
const first = reading.open[0];
|
|
3491
|
+
if (first === void 0) return null;
|
|
3492
|
+
const more = reading.open.length > 1 ? ` (and ${String(reading.open.length - 1)} more)` : "";
|
|
3493
|
+
return {
|
|
3494
|
+
// Reported under `verification` rather than a seventh detector id: it
|
|
3495
|
+
// IS a verification finding — a file changed and nothing that can fail
|
|
3496
|
+
// ran over it — and a new id would ripple through DETECTOR_IDS, the
|
|
3497
|
+
// per-detector counters and the demotion contract for a distinction the
|
|
3498
|
+
// operator never makes.
|
|
3499
|
+
detector: "verification",
|
|
3500
|
+
mode: "transcript",
|
|
3501
|
+
evidence: first.file,
|
|
3502
|
+
reason: `this turn edited an .svg and no render describes it${more} \u2014 ${first.reason}. A bare \`ui:render --profile asset\` that rendered nothing, and a test or lint run over other files, both discharge nothing: the gate reads the render, never the call.` + (recordedRenders === null ? ` (${TRANSCRIPT_FALLBACK_REASON})` : "")
|
|
3503
|
+
};
|
|
3504
|
+
}
|
|
3505
|
+
|
|
3281
3506
|
// src/scripts/hooks/envelope.ts
|
|
3282
3507
|
var ENVELOPE_KEYS = [
|
|
3283
3508
|
"schema_version",
|
|
@@ -3332,524 +3557,6 @@ function unwrap(stdin_text, default_platform = "generic") {
|
|
|
3332
3557
|
];
|
|
3333
3558
|
}
|
|
3334
3559
|
|
|
3335
|
-
// src/scripts/hooks/subagent_ledger_hook.ts
|
|
3336
|
-
import * as crypto from "node:crypto";
|
|
3337
|
-
import * as fs8 from "node:fs";
|
|
3338
|
-
import * as path7 from "node:path";
|
|
3339
|
-
import { fileURLToPath as fileURLToPath4, pathToFileURL as pathToFileURL4 } from "node:url";
|
|
3340
|
-
|
|
3341
|
-
// src/scripts/_lib/subagent_response.ts
|
|
3342
|
-
var MAX_SUMMARY_CHARS = 2e3;
|
|
3343
|
-
var MAX_RESPONSE_LINE_CHARS = 240;
|
|
3344
|
-
var MAX_RESPONSE_ENTRIES = 40;
|
|
3345
|
-
var MAX_ARTIFACT_REF_CHARS = 200;
|
|
3346
|
-
var MAX_ENVELOPE_CHARS = 12e3;
|
|
3347
|
-
var CONFIDENCE = /* @__PURE__ */ new Set(["low", "medium", "high"]);
|
|
3348
|
-
var RESPONSE_REQUIRED_FIELDS = [
|
|
3349
|
-
"summary",
|
|
3350
|
-
"handoff",
|
|
3351
|
-
"confidence",
|
|
3352
|
-
"findings",
|
|
3353
|
-
"risks"
|
|
3354
|
-
];
|
|
3355
|
-
function countContractFields(input) {
|
|
3356
|
-
if (input === null || typeof input !== "object") return 0;
|
|
3357
|
-
const r = input;
|
|
3358
|
-
return RESPONSE_REQUIRED_FIELDS.filter((k) => Object.hasOwn(r, k)).length;
|
|
3359
|
-
}
|
|
3360
|
-
function validateResponse(input) {
|
|
3361
|
-
const errors = [];
|
|
3362
|
-
if (input === null || typeof input !== "object") {
|
|
3363
|
-
return { valid: false, errors: ["response is not an object"] };
|
|
3364
|
-
}
|
|
3365
|
-
const r = input;
|
|
3366
|
-
if (typeof r.summary !== "string") errors.push("summary missing or not a string");
|
|
3367
|
-
if (typeof r.handoff !== "string") errors.push("handoff missing or not a string");
|
|
3368
|
-
if (!CONFIDENCE.has(r.confidence)) errors.push(`confidence must be low|medium|high (got ${String(r.confidence)})`);
|
|
3369
|
-
if (!Array.isArray(r.findings)) errors.push("findings missing or not an array");
|
|
3370
|
-
if (!Array.isArray(r.risks)) errors.push("risks missing or not an array");
|
|
3371
|
-
if (Array.isArray(r.findings)) {
|
|
3372
|
-
for (const [i, f] of r.findings.entries()) {
|
|
3373
|
-
if (!f || typeof f.title !== "string") errors.push(`finding[${i}] missing title`);
|
|
3374
|
-
const refs = f?.evidence_refs;
|
|
3375
|
-
if (refs && refs.some((x) => typeof x !== "string" || x.includes("\n"))) {
|
|
3376
|
-
errors.push(`finding[${i}] evidence_refs must be ref tokens, not bodies`);
|
|
3377
|
-
}
|
|
3378
|
-
}
|
|
3379
|
-
}
|
|
3380
|
-
if (r.assumptions !== void 0) {
|
|
3381
|
-
if (!Array.isArray(r.assumptions)) {
|
|
3382
|
-
errors.push("assumptions must be an array of {statement, basis, epistemic_state}");
|
|
3383
|
-
} else {
|
|
3384
|
-
for (const [i, a] of r.assumptions.entries()) {
|
|
3385
|
-
errors.push(...validateAssumption(a, `assumptions[${i}]`));
|
|
3386
|
-
}
|
|
3387
|
-
}
|
|
3388
|
-
}
|
|
3389
|
-
if (typeof r.summary === "string" && r.summary.length > MAX_SUMMARY_CHARS) {
|
|
3390
|
-
errors.push(`summary is ${r.summary.length} chars (max ${MAX_SUMMARY_CHARS}) \u2014 the envelope carries a bounded summary; the full result belongs on disk (artifact_paths)`);
|
|
3391
|
-
}
|
|
3392
|
-
if (typeof r.handoff === "string" && r.handoff.length > MAX_RESPONSE_LINE_CHARS) {
|
|
3393
|
-
errors.push(`handoff is ${r.handoff.length} chars (max ${MAX_RESPONSE_LINE_CHARS})`);
|
|
3394
|
-
}
|
|
3395
|
-
for (const [key, arr] of [
|
|
3396
|
-
["findings", r.findings],
|
|
3397
|
-
["risks", r.risks],
|
|
3398
|
-
["artifact_paths", r.artifact_paths]
|
|
3399
|
-
]) {
|
|
3400
|
-
if (Array.isArray(arr) && arr.length > MAX_RESPONSE_ENTRIES) {
|
|
3401
|
-
errors.push(`${key} carries ${arr.length} entries (max ${MAX_RESPONSE_ENTRIES}) \u2014 an envelope is a handoff, not a transcript`);
|
|
3402
|
-
}
|
|
3403
|
-
}
|
|
3404
|
-
if (Array.isArray(r.risks)) {
|
|
3405
|
-
for (const [i, risk] of r.risks.entries()) {
|
|
3406
|
-
if (typeof risk === "string" && risk.length > MAX_RESPONSE_LINE_CHARS) {
|
|
3407
|
-
errors.push(`risks[${i}] is ${risk.length} chars (max ${MAX_RESPONSE_LINE_CHARS})`);
|
|
3408
|
-
}
|
|
3409
|
-
}
|
|
3410
|
-
}
|
|
3411
|
-
if (Array.isArray(r.findings)) {
|
|
3412
|
-
for (const [i, f] of r.findings.entries()) {
|
|
3413
|
-
if (f && typeof f.title === "string" && f.title.length > MAX_RESPONSE_LINE_CHARS) {
|
|
3414
|
-
errors.push(`finding[${i}] title is ${f.title.length} chars (max ${MAX_RESPONSE_LINE_CHARS})`);
|
|
3415
|
-
}
|
|
3416
|
-
}
|
|
3417
|
-
}
|
|
3418
|
-
if (r.artifact_paths !== void 0) {
|
|
3419
|
-
if (!Array.isArray(r.artifact_paths)) {
|
|
3420
|
-
errors.push("artifact_paths must be an array of path ref tokens");
|
|
3421
|
-
} else {
|
|
3422
|
-
for (const [i, p] of r.artifact_paths.entries()) {
|
|
3423
|
-
if (typeof p !== "string" || p.includes("\n") || p.length > MAX_ARTIFACT_REF_CHARS) {
|
|
3424
|
-
errors.push(`artifact_paths[${i}] must be a single-line path ref \u2264 ${MAX_ARTIFACT_REF_CHARS} chars`);
|
|
3425
|
-
}
|
|
3426
|
-
}
|
|
3427
|
-
}
|
|
3428
|
-
}
|
|
3429
|
-
try {
|
|
3430
|
-
const serialized = JSON.stringify(input);
|
|
3431
|
-
if (serialized.length > MAX_ENVELOPE_CHARS) {
|
|
3432
|
-
errors.push(`envelope serializes to ${serialized.length} chars (max ${MAX_ENVELOPE_CHARS}) \u2014 move content to disk and reference it via artifact_paths`);
|
|
3433
|
-
}
|
|
3434
|
-
} catch {
|
|
3435
|
-
errors.push("envelope is not JSON-serializable");
|
|
3436
|
-
}
|
|
3437
|
-
return { valid: errors.length === 0, errors };
|
|
3438
|
-
}
|
|
3439
|
-
|
|
3440
|
-
// src/scripts/hooks/exit_codes.ts
|
|
3441
|
-
var EXIT_ALLOW3 = 0;
|
|
3442
|
-
var EXIT_BLOCK = 1;
|
|
3443
|
-
var EXIT_WARN2 = 2;
|
|
3444
|
-
var EXIT_ERROR = 3;
|
|
3445
|
-
var EXIT_CODES = Object.freeze([
|
|
3446
|
-
Object.freeze({
|
|
3447
|
-
code: EXIT_ALLOW3,
|
|
3448
|
-
name: "allow",
|
|
3449
|
-
meaning: "no objection; the dispatcher passes the call through",
|
|
3450
|
-
owner: "every concern \u2014 the default verdict",
|
|
3451
|
-
authorizedBy: "nothing; allowing needs no authority"
|
|
3452
|
-
}),
|
|
3453
|
-
Object.freeze({
|
|
3454
|
-
code: EXIT_BLOCK,
|
|
3455
|
-
name: "block",
|
|
3456
|
-
meaning: "refuse the call; the dispatcher lowers this onto the host deny channel",
|
|
3457
|
-
owner: "a concern declared `severity: blocking` in hook_manifest.yaml",
|
|
3458
|
-
authorizedBy: "the manifest entry plus its row in the BLOCKING_ALLOWLIST of tests/hooks/concern_severity.test.ts \u2014 an advisory concern emitting this is downgraded to warn by dispatch_hook._is_advisory"
|
|
3459
|
-
}),
|
|
3460
|
-
Object.freeze({
|
|
3461
|
-
code: EXIT_WARN2,
|
|
3462
|
-
name: "warn",
|
|
3463
|
-
meaning: "advisory; the dispatcher exits 0 and surfaces the reason",
|
|
3464
|
-
owner: "any concern",
|
|
3465
|
-
authorizedBy: "nothing; warning is the ceiling for an advisory concern and is always available to a blocking one"
|
|
3466
|
-
}),
|
|
3467
|
-
Object.freeze({
|
|
3468
|
-
code: EXIT_ERROR,
|
|
3469
|
-
name: "error",
|
|
3470
|
-
meaning: "the concern crashed, timed out, or could not decide \u2014 any rc >= 3. The dispatcher resolves it by the concern`s declared severity, never by the number itself",
|
|
3471
|
-
owner: "no concern emits this on purpose; the runtime does",
|
|
3472
|
-
authorizedBy: "hook_manifest.yaml `severity` alone \u2014 blocking refuses, anything else fails open; `fail_closed` is no longer read on this branch. See docs/contracts/hook-architecture-v1.md \xA7 Exit-code semantics"
|
|
3473
|
-
})
|
|
3474
|
-
]);
|
|
3475
|
-
|
|
3476
|
-
// src/scripts/hooks/subagent_ledger_hook.ts
|
|
3477
|
-
function isObject2(v) {
|
|
3478
|
-
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
3479
|
-
}
|
|
3480
|
-
var LEDGER_DIR = path7.join("agents", "runtime", "state", "subagent-ledger");
|
|
3481
|
-
var OPEN_SUBDIR = "open";
|
|
3482
|
-
var OPEN_RECORD_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
3483
|
-
function refFor(agentId) {
|
|
3484
|
-
return crypto.createHash("sha256").update(agentId, "utf8").digest("hex").slice(0, 12);
|
|
3485
|
-
}
|
|
3486
|
-
function unwrapPayload(envelope) {
|
|
3487
|
-
const inner = envelope["payload"];
|
|
3488
|
-
return isObject2(inner) ? inner : envelope;
|
|
3489
|
-
}
|
|
3490
|
-
function str(payload, ...keys) {
|
|
3491
|
-
for (const k of keys) {
|
|
3492
|
-
const v = payload[k];
|
|
3493
|
-
if (typeof v === "string" && v) return v;
|
|
3494
|
-
}
|
|
3495
|
-
return null;
|
|
3496
|
-
}
|
|
3497
|
-
function extractParentId(payload, ownId) {
|
|
3498
|
-
const explicit = str(payload, "parent_agent_id", "parentAgentId");
|
|
3499
|
-
if (explicit) return explicit;
|
|
3500
|
-
const session = payload["session"];
|
|
3501
|
-
if (isObject2(session)) {
|
|
3502
|
-
const sessionAgent = str(session, "agent_id", "agentId");
|
|
3503
|
-
if (sessionAgent && sessionAgent !== ownId) return sessionAgent;
|
|
3504
|
-
}
|
|
3505
|
-
return null;
|
|
3506
|
-
}
|
|
3507
|
-
function classifyEnvelope(message) {
|
|
3508
|
-
if (message === null || !message.trim()) {
|
|
3509
|
-
return { verdict: "no_message", error_count: 0, field_hits: 0 };
|
|
3510
|
-
}
|
|
3511
|
-
const candidates = _jsonObjectCandidates(message);
|
|
3512
|
-
if (candidates.length === 0) return { verdict: "no_envelope", error_count: 0, field_hits: 0 };
|
|
3513
|
-
let best = null;
|
|
3514
|
-
for (const candidate of candidates) {
|
|
3515
|
-
const result = validateResponse(candidate);
|
|
3516
|
-
const fieldHits = countContractFields(candidate);
|
|
3517
|
-
if (result.valid) return { verdict: "ok", error_count: 0, field_hits: fieldHits };
|
|
3518
|
-
if (best === null || fieldHits > best.field_hits) {
|
|
3519
|
-
best = {
|
|
3520
|
-
verdict: fieldHits === 0 ? "foreign_object" : "fail",
|
|
3521
|
-
error_count: result.errors.length,
|
|
3522
|
-
field_hits: fieldHits
|
|
3523
|
-
};
|
|
3524
|
-
}
|
|
3525
|
-
}
|
|
3526
|
-
return best ?? { verdict: "no_envelope", error_count: 0, field_hits: 0 };
|
|
3527
|
-
}
|
|
3528
|
-
function _jsonObjectCandidates(message) {
|
|
3529
|
-
const texts = [];
|
|
3530
|
-
for (const match of message.matchAll(/^[ \t]*```[ \t]*(?:json)?[ \t]*\r?\n([\s\S]*?)^[ \t]*```/gm)) {
|
|
3531
|
-
if (match[1]) texts.push(match[1]);
|
|
3532
|
-
}
|
|
3533
|
-
let depth = 0;
|
|
3534
|
-
let start = -1;
|
|
3535
|
-
let inString = false;
|
|
3536
|
-
let escaped = false;
|
|
3537
|
-
for (let i = 0; i < message.length; i++) {
|
|
3538
|
-
const ch = message[i];
|
|
3539
|
-
if (inString) {
|
|
3540
|
-
if (escaped) escaped = false;
|
|
3541
|
-
else if (ch === "\\") escaped = true;
|
|
3542
|
-
else if (ch === '"') inString = false;
|
|
3543
|
-
continue;
|
|
3544
|
-
}
|
|
3545
|
-
if (ch === '"') inString = true;
|
|
3546
|
-
else if (ch === "{") {
|
|
3547
|
-
if (depth === 0) start = i;
|
|
3548
|
-
depth++;
|
|
3549
|
-
} else if (ch === "}") {
|
|
3550
|
-
if (depth > 0) {
|
|
3551
|
-
depth--;
|
|
3552
|
-
if (depth === 0 && start !== -1) {
|
|
3553
|
-
texts.push(message.slice(start, i + 1));
|
|
3554
|
-
start = -1;
|
|
3555
|
-
}
|
|
3556
|
-
}
|
|
3557
|
-
}
|
|
3558
|
-
}
|
|
3559
|
-
const out = [];
|
|
3560
|
-
for (const text of texts) {
|
|
3561
|
-
try {
|
|
3562
|
-
const parsed = JSON.parse(text.trim());
|
|
3563
|
-
if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) out.push(parsed);
|
|
3564
|
-
} catch {
|
|
3565
|
-
}
|
|
3566
|
-
}
|
|
3567
|
-
return out;
|
|
3568
|
-
}
|
|
3569
|
-
function openDir(root) {
|
|
3570
|
-
return path7.join(root, LEDGER_DIR, OPEN_SUBDIR);
|
|
3571
|
-
}
|
|
3572
|
-
function openFile(root, ref) {
|
|
3573
|
-
return path7.join(openDir(root), `${ref}.json`);
|
|
3574
|
-
}
|
|
3575
|
-
var DEPTH_BASES = /* @__PURE__ */ new Set(["observed", "asserted-parent", "assumed-root"]);
|
|
3576
|
-
function _asOpenRecord(value, expectedRef) {
|
|
3577
|
-
if (!isObject2(value)) return null;
|
|
3578
|
-
const ref = value["ref"];
|
|
3579
|
-
if (typeof ref !== "string" || ref !== expectedRef) return null;
|
|
3580
|
-
if (typeof value["started_at"] !== "string") return null;
|
|
3581
|
-
if (typeof value["depth"] !== "number" || !Number.isFinite(value["depth"])) return null;
|
|
3582
|
-
if (typeof value["depth_basis"] !== "string" || !DEPTH_BASES.has(value["depth_basis"])) return null;
|
|
3583
|
-
const agentType = value["agent_type"];
|
|
3584
|
-
const parentRef = value["parent_ref"];
|
|
3585
|
-
const sessionId = value["session_id"];
|
|
3586
|
-
return {
|
|
3587
|
-
ref,
|
|
3588
|
-
agent_type: typeof agentType === "string" ? agentType : null,
|
|
3589
|
-
started_at: value["started_at"],
|
|
3590
|
-
parent_ref: typeof parentRef === "string" ? parentRef : null,
|
|
3591
|
-
depth: value["depth"],
|
|
3592
|
-
depth_basis: value["depth_basis"],
|
|
3593
|
-
session_id: typeof sessionId === "string" ? sessionId : null
|
|
3594
|
-
};
|
|
3595
|
-
}
|
|
3596
|
-
function readOpenRecords(root) {
|
|
3597
|
-
const out = /* @__PURE__ */ new Map();
|
|
3598
|
-
let names;
|
|
3599
|
-
try {
|
|
3600
|
-
names = fs8.readdirSync(openDir(root));
|
|
3601
|
-
} catch {
|
|
3602
|
-
return out;
|
|
3603
|
-
}
|
|
3604
|
-
for (const name of names) {
|
|
3605
|
-
if (!name.endsWith(".json")) continue;
|
|
3606
|
-
const expectedRef = name.slice(0, -".json".length);
|
|
3607
|
-
try {
|
|
3608
|
-
const raw = fs8.readFileSync(path7.join(openDir(root), name), "utf8");
|
|
3609
|
-
const rec = _asOpenRecord(JSON.parse(raw), expectedRef);
|
|
3610
|
-
if (rec) out.set(rec.ref, rec);
|
|
3611
|
-
} catch {
|
|
3612
|
-
}
|
|
3613
|
-
}
|
|
3614
|
-
return out;
|
|
3615
|
-
}
|
|
3616
|
-
function resolveDepth(parentRef, open) {
|
|
3617
|
-
if (parentRef === null) return { depth: 1, depth_basis: "assumed-root" };
|
|
3618
|
-
const parent = open.get(parentRef);
|
|
3619
|
-
if (!parent) return { depth: 2, depth_basis: "asserted-parent" };
|
|
3620
|
-
return { depth: parent.depth + 1, depth_basis: "observed" };
|
|
3621
|
-
}
|
|
3622
|
-
function ledgerFileFor2(root, ts) {
|
|
3623
|
-
return path7.join(root, LEDGER_DIR, `${ts.slice(0, 7)}.jsonl`);
|
|
3624
|
-
}
|
|
3625
|
-
function appendLedgerLine(root, ts, line) {
|
|
3626
|
-
if (is_replay_mode()) return;
|
|
3627
|
-
const file = ledgerFileFor2(root, ts);
|
|
3628
|
-
fs8.mkdirSync(path7.dirname(file), { recursive: true });
|
|
3629
|
-
fs8.appendFileSync(file, `${JSON.stringify(line)}
|
|
3630
|
-
`, "utf8");
|
|
3631
|
-
}
|
|
3632
|
-
var WALL_CLOCK_ARMS_MS = [
|
|
3633
|
-
{ label: "5m", ms: 5 * 60 * 1e3 },
|
|
3634
|
-
{ label: "15m", ms: 15 * 60 * 1e3 },
|
|
3635
|
-
{ label: "30m", ms: 30 * 60 * 1e3 },
|
|
3636
|
-
{ label: "2h", ms: 2 * 60 * 60 * 1e3 }
|
|
3637
|
-
];
|
|
3638
|
-
function armsExceeded(elapsedMs) {
|
|
3639
|
-
if (elapsedMs === null || !Number.isFinite(elapsedMs)) return [];
|
|
3640
|
-
return WALL_CLOCK_ARMS_MS.filter((a) => elapsedMs >= a.ms).map((a) => a.label);
|
|
3641
|
-
}
|
|
3642
|
-
function openRecordStats(root, nowMs = Date.now()) {
|
|
3643
|
-
const ledgerPresent = fs8.existsSync(path7.join(root, LEDGER_DIR));
|
|
3644
|
-
const open = readOpenRecords(root);
|
|
3645
|
-
let maxDepth = 0;
|
|
3646
|
-
let counted = 0;
|
|
3647
|
-
let stale = 0;
|
|
3648
|
-
for (const rec of open.values()) {
|
|
3649
|
-
const started = Date.parse(rec.started_at);
|
|
3650
|
-
const isStale = Number.isFinite(started) && nowMs - started >= OPEN_RECORD_TTL_MS;
|
|
3651
|
-
if (isStale) {
|
|
3652
|
-
stale++;
|
|
3653
|
-
continue;
|
|
3654
|
-
}
|
|
3655
|
-
counted++;
|
|
3656
|
-
if (rec.depth > maxDepth) maxDepth = rec.depth;
|
|
3657
|
-
}
|
|
3658
|
-
return {
|
|
3659
|
-
open_count: counted,
|
|
3660
|
-
max_depth: maxDepth,
|
|
3661
|
-
stale_excluded: stale,
|
|
3662
|
-
ledger_present: ledgerPresent
|
|
3663
|
-
};
|
|
3664
|
-
}
|
|
3665
|
-
function writeOpenRecord(root, rec) {
|
|
3666
|
-
atomic_write_json(openFile(root, rec.ref), rec);
|
|
3667
|
-
}
|
|
3668
|
-
function removeOpenRecord(root, ref) {
|
|
3669
|
-
if (is_replay_mode()) return;
|
|
3670
|
-
try {
|
|
3671
|
-
fs8.unlinkSync(openFile(root, ref));
|
|
3672
|
-
} catch {
|
|
3673
|
-
}
|
|
3674
|
-
}
|
|
3675
|
-
function countOpen(root) {
|
|
3676
|
-
try {
|
|
3677
|
-
return fs8.readdirSync(openDir(root)).filter((n) => n.endsWith(".json")).length;
|
|
3678
|
-
} catch {
|
|
3679
|
-
return 0;
|
|
3680
|
-
}
|
|
3681
|
-
}
|
|
3682
|
-
function reapStaleOpenRecords(root, nowIso) {
|
|
3683
|
-
const now = Date.parse(nowIso);
|
|
3684
|
-
if (!Number.isFinite(now)) return 0;
|
|
3685
|
-
let reaped = 0;
|
|
3686
|
-
for (const rec of readOpenRecords(root).values()) {
|
|
3687
|
-
const started = Date.parse(rec.started_at);
|
|
3688
|
-
if (!Number.isFinite(started) || now - started < OPEN_RECORD_TTL_MS) continue;
|
|
3689
|
-
removeOpenRecord(root, rec.ref);
|
|
3690
|
-
reaped++;
|
|
3691
|
-
appendLedgerLine(root, nowIso, {
|
|
3692
|
-
event: "subagent_reaped",
|
|
3693
|
-
ts: nowIso,
|
|
3694
|
-
ref: rec.ref,
|
|
3695
|
-
agent_type: rec.agent_type,
|
|
3696
|
-
depth: rec.depth,
|
|
3697
|
-
depth_basis: rec.depth_basis,
|
|
3698
|
-
// R2 round 2, finding 5: the arm list is NOT repeated here. A reap
|
|
3699
|
-
// fires only past OPEN_RECORD_TTL_MS (24 h), which exceeds every
|
|
3700
|
-
// arm (largest: 2 h), so `stop_loss_arms_exceeded` would be a
|
|
3701
|
-
// constant on this line — a field that cannot vary answers no
|
|
3702
|
-
// question. `age_ms` carries strictly more information and is what
|
|
3703
|
-
// a reader should aggregate over.
|
|
3704
|
-
age_ms: now - started,
|
|
3705
|
-
reason: "open record exceeded OPEN_RECORD_TTL_MS without a stop"
|
|
3706
|
-
});
|
|
3707
|
-
}
|
|
3708
|
-
return reaped;
|
|
3709
|
-
}
|
|
3710
|
-
function appendUnidentified(root, event, nowIso, payload) {
|
|
3711
|
-
appendLedgerLine(root, nowIso, {
|
|
3712
|
-
event,
|
|
3713
|
-
ts: nowIso,
|
|
3714
|
-
ref: null,
|
|
3715
|
-
unidentified: true,
|
|
3716
|
-
// The agent TYPE is an id-shaped enum and may still be present; it is
|
|
3717
|
-
// the only thing salvageable from a payload with no id.
|
|
3718
|
-
agent_type: str(payload, "agent_type", "agentType", "subagent_type", "subagentType"),
|
|
3719
|
-
reason: "payload carried no agent id \u2014 nothing to correlate start with stop"
|
|
3720
|
-
});
|
|
3721
|
-
}
|
|
3722
|
-
function handleStart(root, payload, nowIso, sessionId) {
|
|
3723
|
-
const agentId = str(payload, "agent_id", "agentId");
|
|
3724
|
-
if (agentId === null) {
|
|
3725
|
-
appendUnidentified(root, "subagent_start", nowIso, payload);
|
|
3726
|
-
return;
|
|
3727
|
-
}
|
|
3728
|
-
const ref = refFor(agentId);
|
|
3729
|
-
const parentId = extractParentId(payload, agentId);
|
|
3730
|
-
const parentRef = parentId ? refFor(parentId) : null;
|
|
3731
|
-
const { depth, depth_basis } = resolveDepth(parentRef, readOpenRecords(root));
|
|
3732
|
-
const rec = {
|
|
3733
|
-
ref,
|
|
3734
|
-
agent_type: str(payload, "agent_type", "agentType", "subagent_type", "subagentType"),
|
|
3735
|
-
started_at: nowIso,
|
|
3736
|
-
parent_ref: parentRef,
|
|
3737
|
-
depth,
|
|
3738
|
-
depth_basis,
|
|
3739
|
-
session_id: sessionId
|
|
3740
|
-
};
|
|
3741
|
-
writeOpenRecord(root, rec);
|
|
3742
|
-
appendLedgerLine(root, nowIso, {
|
|
3743
|
-
event: "subagent_start",
|
|
3744
|
-
ts: nowIso,
|
|
3745
|
-
ref,
|
|
3746
|
-
// Phase 1 Step 4 correction (b): without this the dispatch denominator
|
|
3747
|
-
// is not per-session. Three sessions share one ledger file, so a rate
|
|
3748
|
-
// computed over the file aggregates strangers — the measured window
|
|
3749
|
-
// held 7 starts against 25 stops, one of them an agent type this
|
|
3750
|
-
// session never dispatched. The open record already carried it; the
|
|
3751
|
-
// appended line did not, and the line is what a rate is computed from.
|
|
3752
|
-
session_id: sessionId,
|
|
3753
|
-
agent_type: rec.agent_type,
|
|
3754
|
-
parent_ref: parentRef,
|
|
3755
|
-
depth,
|
|
3756
|
-
depth_basis,
|
|
3757
|
-
concurrent_open: countOpen(root)
|
|
3758
|
-
});
|
|
3759
|
-
}
|
|
3760
|
-
function handleStop(root, payload, nowIso, sessionId) {
|
|
3761
|
-
const agentId = str(payload, "agent_id", "agentId");
|
|
3762
|
-
if (agentId === null) {
|
|
3763
|
-
appendUnidentified(root, "subagent_stop", nowIso, payload);
|
|
3764
|
-
return;
|
|
3765
|
-
}
|
|
3766
|
-
const ref = refFor(agentId);
|
|
3767
|
-
const rec = readOpenRecords(root).get(ref) ?? null;
|
|
3768
|
-
let durationMs = null;
|
|
3769
|
-
if (rec) {
|
|
3770
|
-
const started = Date.parse(rec.started_at);
|
|
3771
|
-
if (Number.isFinite(started)) durationMs = Math.max(0, Date.parse(nowIso) - started);
|
|
3772
|
-
}
|
|
3773
|
-
const parse2 = classifyEnvelope(str(payload, "last_assistant_message", "lastAssistantMessage"));
|
|
3774
|
-
removeOpenRecord(root, ref);
|
|
3775
|
-
appendLedgerLine(root, nowIso, {
|
|
3776
|
-
event: "subagent_stop",
|
|
3777
|
-
ts: nowIso,
|
|
3778
|
-
ref,
|
|
3779
|
-
// The session this stop was OBSERVED in, read from the same envelope
|
|
3780
|
-
// position as the start's — never back-filled from `rec`, which would
|
|
3781
|
-
// relabel a cross-session stop as belonging to the dispatching session
|
|
3782
|
-
// and hide exactly the mismatch this field exists to expose.
|
|
3783
|
-
session_id: sessionId,
|
|
3784
|
-
agent_type: rec?.agent_type ?? str(payload, "agent_type", "agentType", "subagent_type", "subagentType"),
|
|
3785
|
-
depth: rec?.depth ?? null,
|
|
3786
|
-
depth_basis: rec?.depth_basis ?? null,
|
|
3787
|
-
// `null` = the matching start was never seen. That is a finding about
|
|
3788
|
-
// the instrument's own coverage and is recorded as such, not as 0.
|
|
3789
|
-
duration_ms: durationMs,
|
|
3790
|
-
// Phase 3 Step 3, shadow: which wall-clock arms this dispatch would
|
|
3791
|
-
// have tripped. Recorded, never acted on.
|
|
3792
|
-
stop_loss_arms_exceeded: armsExceeded(durationMs),
|
|
3793
|
-
start_seen: rec !== null,
|
|
3794
|
-
envelope_parse: parse2.verdict,
|
|
3795
|
-
envelope_error_count: parse2.error_count,
|
|
3796
|
-
// Beside the count, never instead of it: the count says how wrong the
|
|
3797
|
-
// candidate was, this says whether it was aimed at the envelope.
|
|
3798
|
-
envelope_field_hits: parse2.field_hits,
|
|
3799
|
-
concurrent_open: countOpen(root)
|
|
3800
|
-
});
|
|
3801
|
-
}
|
|
3802
|
-
function processEnvelope(envelope, consumerRoot) {
|
|
3803
|
-
try {
|
|
3804
|
-
if (!isObject2(envelope)) return EXIT_ALLOW3;
|
|
3805
|
-
const event = envelope["event"];
|
|
3806
|
-
if (event !== "subagent_start" && event !== "subagent_stop") return EXIT_ALLOW3;
|
|
3807
|
-
const payload = unwrapPayload(envelope);
|
|
3808
|
-
const nowIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
3809
|
-
const sessionId = str(payload, "session_id", "sessionId") ?? str(envelope, "session_id", "sessionId");
|
|
3810
|
-
reapStaleOpenRecords(consumerRoot, nowIso);
|
|
3811
|
-
if (event === "subagent_start") handleStart(consumerRoot, payload, nowIso, sessionId);
|
|
3812
|
-
else handleStop(consumerRoot, payload, nowIso, sessionId);
|
|
3813
|
-
} catch {
|
|
3814
|
-
return EXIT_ALLOW3;
|
|
3815
|
-
}
|
|
3816
|
-
return EXIT_ALLOW3;
|
|
3817
|
-
}
|
|
3818
|
-
function resolveConsumerRoot(envelope) {
|
|
3819
|
-
if (isObject2(envelope)) {
|
|
3820
|
-
const pr = str(envelope, "workspace_root", "project_root");
|
|
3821
|
-
if (pr) return pr;
|
|
3822
|
-
const payload = unwrapPayload(envelope);
|
|
3823
|
-
const cwd = str(payload, "cwd");
|
|
3824
|
-
if (cwd) return cwd;
|
|
3825
|
-
}
|
|
3826
|
-
return process.cwd();
|
|
3827
|
-
}
|
|
3828
|
-
function main4() {
|
|
3829
|
-
const raw = readHookStdin();
|
|
3830
|
-
let envelope = {};
|
|
3831
|
-
try {
|
|
3832
|
-
envelope = raw.trim() ? JSON.parse(raw) : {};
|
|
3833
|
-
} catch {
|
|
3834
|
-
return EXIT_ALLOW3;
|
|
3835
|
-
}
|
|
3836
|
-
return processEnvelope(envelope, resolveConsumerRoot(envelope));
|
|
3837
|
-
}
|
|
3838
|
-
function _isCliEntry4() {
|
|
3839
|
-
if (true) {
|
|
3840
|
-
return false;
|
|
3841
|
-
}
|
|
3842
|
-
if (process.argv[1] === void 0) return false;
|
|
3843
|
-
const argvUrl = pathToFileURL4(path7.resolve(process.argv[1])).href;
|
|
3844
|
-
if (import.meta.url === argvUrl) return true;
|
|
3845
|
-
try {
|
|
3846
|
-
return fs8.realpathSync(fileURLToPath4(import.meta.url)) === fs8.realpathSync(path7.resolve(process.argv[1]));
|
|
3847
|
-
} catch {
|
|
3848
|
-
return false;
|
|
3849
|
-
}
|
|
3850
|
-
}
|
|
3851
|
-
if (_isCliEntry4()) process.exit(main4());
|
|
3852
|
-
|
|
3853
3560
|
// src/scripts/_lib/turn_end_transcript.ts
|
|
3854
3561
|
import * as fs11 from "node:fs";
|
|
3855
3562
|
|
|
@@ -3859,7 +3566,7 @@ import * as crypto2 from "node:crypto";
|
|
|
3859
3566
|
import * as fs10 from "node:fs";
|
|
3860
3567
|
import * as os from "node:os";
|
|
3861
3568
|
import * as path9 from "node:path";
|
|
3862
|
-
import { fileURLToPath as
|
|
3569
|
+
import { fileURLToPath as fileURLToPath4, pathToFileURL as pathToFileURL4 } from "node:url";
|
|
3863
3570
|
|
|
3864
3571
|
// src/scripts/_lib/review_baseline.ts
|
|
3865
3572
|
import { spawnSync } from "node:child_process";
|
|
@@ -4020,8 +3727,8 @@ function isSafeTranscriptPath(rawPath, opts = {}) {
|
|
|
4020
3727
|
try {
|
|
4021
3728
|
const realHome = fs10.realpathSync(homeDir);
|
|
4022
3729
|
const realPath = fs10.realpathSync(rawPath);
|
|
4023
|
-
const
|
|
4024
|
-
if (
|
|
3730
|
+
const relative6 = path9.relative(realHome, realPath);
|
|
3731
|
+
if (relative6 === "" || relative6.startsWith("..") || path9.isAbsolute(relative6)) {
|
|
4025
3732
|
return false;
|
|
4026
3733
|
}
|
|
4027
3734
|
const { size } = fs10.statSync(realPath);
|
|
@@ -4114,10 +3821,10 @@ function totalNonDocMutatedLinesWithMeasure(cwd) {
|
|
|
4114
3821
|
);
|
|
4115
3822
|
return { lines: trackedLines + untrackedLines, measure: "exact" };
|
|
4116
3823
|
}
|
|
4117
|
-
function
|
|
3824
|
+
function isObject2(v) {
|
|
4118
3825
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
4119
3826
|
}
|
|
4120
|
-
function
|
|
3827
|
+
function str(v) {
|
|
4121
3828
|
return typeof v === "string" ? v : "";
|
|
4122
3829
|
}
|
|
4123
3830
|
var DISPATCH_TOOL_RE = /^(agent|task)$/i;
|
|
@@ -4134,28 +3841,28 @@ function scanTranscriptForReviewer(transcriptText) {
|
|
|
4134
3841
|
} catch {
|
|
4135
3842
|
continue;
|
|
4136
3843
|
}
|
|
4137
|
-
if (!
|
|
3844
|
+
if (!isObject2(obj) || obj["type"] !== "assistant") continue;
|
|
4138
3845
|
const msg = obj["message"];
|
|
4139
|
-
if (!
|
|
3846
|
+
if (!isObject2(msg)) continue;
|
|
4140
3847
|
const content = msg["content"];
|
|
4141
3848
|
if (!Array.isArray(content)) continue;
|
|
4142
3849
|
for (const blk of content) {
|
|
4143
|
-
if (!
|
|
4144
|
-
const name =
|
|
3850
|
+
if (!isObject2(blk) || blk["type"] !== "tool_use") continue;
|
|
3851
|
+
const name = str(blk["name"]);
|
|
4145
3852
|
const input = blk["input"];
|
|
4146
|
-
const inputObj =
|
|
3853
|
+
const inputObj = isObject2(input) ? input : {};
|
|
4147
3854
|
if (DISPATCH_TOOL_RE.test(name)) {
|
|
4148
3855
|
const label = [
|
|
4149
|
-
|
|
4150
|
-
|
|
3856
|
+
str(inputObj["description"]),
|
|
3857
|
+
str(inputObj["subagent_type"])
|
|
4151
3858
|
].filter(Boolean).join(" ");
|
|
4152
3859
|
if (REVIEW_SHAPED_LABEL_RE.test(label)) return true;
|
|
4153
|
-
const prompt =
|
|
3860
|
+
const prompt = str(inputObj["prompt"]);
|
|
4154
3861
|
if (REVIEW_SHAPED_PROMPT_RE.test(prompt)) return true;
|
|
4155
3862
|
continue;
|
|
4156
3863
|
}
|
|
4157
3864
|
if (/^skill$/i.test(name)) {
|
|
4158
|
-
const skillName =
|
|
3865
|
+
const skillName = str(inputObj["skill"]) || str(inputObj["name"]) || str(inputObj["command"]);
|
|
4159
3866
|
if (REVIEW_SKILL_NAME_RE.test(skillName)) return true;
|
|
4160
3867
|
continue;
|
|
4161
3868
|
}
|
|
@@ -4194,7 +3901,7 @@ function sessionStateFile(workspaceRoot, sessionKey) {
|
|
|
4194
3901
|
return path9.join(sessionStateDir(workspaceRoot), `${sessionKey}.json`);
|
|
4195
3902
|
}
|
|
4196
3903
|
function deriveSessionKey2(envelope, payload) {
|
|
4197
|
-
const raw =
|
|
3904
|
+
const raw = str(envelope["session_id"]) || str(payload["transcript_path"] ?? payload["transcriptPath"]);
|
|
4198
3905
|
const material = raw || "unknown-session";
|
|
4199
3906
|
return crypto2.createHash("sha256").update(material).digest("hex");
|
|
4200
3907
|
}
|
|
@@ -4220,7 +3927,7 @@ var FALLBACK_TO_TELEMETRY = {
|
|
|
4220
3927
|
"head-moved": "head_moved",
|
|
4221
3928
|
"mixed-measure": "mixed_measure"
|
|
4222
3929
|
};
|
|
4223
|
-
function
|
|
3930
|
+
function main4() {
|
|
4224
3931
|
const [envelope, payload] = unwrap(_read_stdin(), "claude");
|
|
4225
3932
|
const event = String(envelope["event"] ?? "");
|
|
4226
3933
|
if (event !== "" && event !== "stop") {
|
|
@@ -4256,7 +3963,7 @@ function main5() {
|
|
|
4256
3963
|
if (hasFiredThisSession(workspace_root, sessionKey)) {
|
|
4257
3964
|
return 0;
|
|
4258
3965
|
}
|
|
4259
|
-
const transcriptPath =
|
|
3966
|
+
const transcriptPath = str(
|
|
4260
3967
|
payload["transcript_path"] ?? payload["transcriptPath"]
|
|
4261
3968
|
).trim();
|
|
4262
3969
|
let reviewerRan = false;
|
|
@@ -4288,29 +3995,29 @@ function main5() {
|
|
|
4288
3995
|
})}
|
|
4289
3996
|
`
|
|
4290
3997
|
);
|
|
4291
|
-
return
|
|
3998
|
+
return EXIT_WARN;
|
|
4292
3999
|
}
|
|
4293
|
-
function
|
|
4000
|
+
function _isCliEntry4() {
|
|
4294
4001
|
if (true) {
|
|
4295
4002
|
return false;
|
|
4296
4003
|
}
|
|
4297
4004
|
if (process.argv[1] === void 0) {
|
|
4298
4005
|
return false;
|
|
4299
4006
|
}
|
|
4300
|
-
const argvUrl =
|
|
4007
|
+
const argvUrl = pathToFileURL4(path9.resolve(process.argv[1])).href;
|
|
4301
4008
|
if (import.meta.url === argvUrl) {
|
|
4302
4009
|
return true;
|
|
4303
4010
|
}
|
|
4304
4011
|
try {
|
|
4305
|
-
const here = fs10.realpathSync(
|
|
4012
|
+
const here = fs10.realpathSync(fileURLToPath4(import.meta.url));
|
|
4306
4013
|
const argv = fs10.realpathSync(path9.resolve(process.argv[1]));
|
|
4307
4014
|
return here === argv;
|
|
4308
4015
|
} catch {
|
|
4309
4016
|
return false;
|
|
4310
4017
|
}
|
|
4311
4018
|
}
|
|
4312
|
-
if (
|
|
4313
|
-
process.exit(
|
|
4019
|
+
if (_isCliEntry4()) {
|
|
4020
|
+
process.exit(main4());
|
|
4314
4021
|
}
|
|
4315
4022
|
|
|
4316
4023
|
// src/scripts/_lib/turn_end_transcript.ts
|
|
@@ -4598,7 +4305,7 @@ function detectUnverifiedEdit(toolCalls, runState = null) {
|
|
|
4598
4305
|
}
|
|
4599
4306
|
for (let i = lastEdit + 1; i < toolCalls.length; i += 1) {
|
|
4600
4307
|
const c = toolCalls[i];
|
|
4601
|
-
if (c.name === "Bash" && c.command !== void 0 &&
|
|
4308
|
+
if (c.name === "Bash" && c.command !== void 0 && isVerificationAttempt(c.command)) {
|
|
4602
4309
|
return null;
|
|
4603
4310
|
}
|
|
4604
4311
|
}
|
|
@@ -4607,7 +4314,7 @@ function detectUnverifiedEdit(toolCalls, runState = null) {
|
|
|
4607
4314
|
// The path, never the diff: the evidence span is quoted into a refusal,
|
|
4608
4315
|
// and `ToolCall` is shaped so a file body cannot reach it.
|
|
4609
4316
|
evidence: edited,
|
|
4610
|
-
reason: "this turn changed a file and then ran no verification command \u2014 no test, type-check, lint or
|
|
4317
|
+
reason: "this turn changed a file and then ran no verification command \u2014 no test, type-check, lint, build or asset render follows the last edit (verify-before-complete: a claim without a fresh run is unverified)",
|
|
4611
4318
|
mode: "transcript"
|
|
4612
4319
|
};
|
|
4613
4320
|
}
|
|
@@ -4697,17 +4404,17 @@ function markRefusedTurn(workspaceRoot, sessionKey, turnOrdinal, detectors, prom
|
|
|
4697
4404
|
} catch {
|
|
4698
4405
|
}
|
|
4699
4406
|
}
|
|
4700
|
-
function
|
|
4407
|
+
function str2(v) {
|
|
4701
4408
|
return typeof v === "string" ? v : "";
|
|
4702
4409
|
}
|
|
4703
4410
|
function assembleDetectorInputs(envelope, payload) {
|
|
4704
|
-
const workspaceRoot =
|
|
4411
|
+
const workspaceRoot = str2(envelope["workspace_root"]) || process.cwd();
|
|
4705
4412
|
let dispatchOpen = false;
|
|
4706
4413
|
try {
|
|
4707
4414
|
dispatchOpen = openRecordStats(workspaceRoot).open_count > 0;
|
|
4708
4415
|
} catch {
|
|
4709
4416
|
}
|
|
4710
|
-
const transcriptPath =
|
|
4417
|
+
const transcriptPath = str2(
|
|
4711
4418
|
payload["transcript_path"] ?? payload["transcriptPath"]
|
|
4712
4419
|
);
|
|
4713
4420
|
const { lastAssistant, turnOrdinal, toolCalls, assistantTurnTexts } = readTranscriptTail(
|
|
@@ -4715,13 +4422,13 @@ function assembleDetectorInputs(envelope, payload) {
|
|
|
4715
4422
|
{ maxBytes: TRANSCRIPT_READ_MAX_BYTES }
|
|
4716
4423
|
);
|
|
4717
4424
|
if (!lastAssistant) return null;
|
|
4718
|
-
const payloadClosing =
|
|
4425
|
+
const payloadClosing = str2(
|
|
4719
4426
|
payload["last_assistant_message"] ?? payload["lastAssistantMessage"]
|
|
4720
4427
|
);
|
|
4721
4428
|
const closingFromPayload = payloadClosing !== "" && !assistantTurnTexts.includes(payloadClosing);
|
|
4722
4429
|
const turnTexts = closingFromPayload ? [...assistantTurnTexts, payloadClosing] : assistantTurnTexts;
|
|
4723
|
-
const promptId =
|
|
4724
|
-
const rawSessionId =
|
|
4430
|
+
const promptId = str2(payload["prompt_id"] ?? payload["promptId"]);
|
|
4431
|
+
const rawSessionId = str2(envelope["session_id"]) || "";
|
|
4725
4432
|
const sessionKey = deriveSessionKey(rawSessionId || "unknown-session");
|
|
4726
4433
|
const runState = readTurnRunState(workspaceRoot, rawSessionId);
|
|
4727
4434
|
return {
|
|
@@ -4771,6 +4478,7 @@ function runDetectors(inputs) {
|
|
|
4771
4478
|
// on a completion CLAIM, and a turn waiting on a subagent has not
|
|
4772
4479
|
// finished — so its closing is not the claim F is about. Same slot,
|
|
4773
4480
|
// opposite trigger, opposite treatment of `dispatchOpen`.
|
|
4481
|
+
openSvgObligation(workspaceRoot, toolCalls, runState?.asset_renders ?? null),
|
|
4774
4482
|
dispatchOpen ? null : detectUntestedChange(lastAssistant, toolCalls, runState)
|
|
4775
4483
|
]) {
|
|
4776
4484
|
if (f) findings.push(f);
|
|
@@ -4831,13 +4539,13 @@ function recordShadow(inputs, layer) {
|
|
|
4831
4539
|
} catch {
|
|
4832
4540
|
}
|
|
4833
4541
|
}
|
|
4834
|
-
function
|
|
4542
|
+
function main5() {
|
|
4835
4543
|
let envelope;
|
|
4836
4544
|
let payload;
|
|
4837
4545
|
try {
|
|
4838
4546
|
[envelope, payload] = unwrap(readHookStdin(), "claude");
|
|
4839
4547
|
} catch {
|
|
4840
|
-
return
|
|
4548
|
+
return EXIT_ALLOW;
|
|
4841
4549
|
}
|
|
4842
4550
|
if (payload["stop_hook_active"] === true) {
|
|
4843
4551
|
try {
|
|
@@ -4845,17 +4553,17 @@ function main6() {
|
|
|
4845
4553
|
if (retryInputs !== null) recordShadow(retryInputs, "stop_hook_active");
|
|
4846
4554
|
} catch {
|
|
4847
4555
|
}
|
|
4848
|
-
return
|
|
4556
|
+
return EXIT_ALLOW;
|
|
4849
4557
|
}
|
|
4850
4558
|
const inputs = assembleDetectorInputs(envelope, payload);
|
|
4851
|
-
if (inputs === null) return
|
|
4559
|
+
if (inputs === null) return EXIT_ALLOW;
|
|
4852
4560
|
if (alreadyRefusedTurn(inputs.workspaceRoot, inputs.sessionKey, inputs.turnOrdinal)) {
|
|
4853
4561
|
recordShadow(inputs, "refused_turn");
|
|
4854
|
-
return
|
|
4562
|
+
return EXIT_ALLOW;
|
|
4855
4563
|
}
|
|
4856
4564
|
const findings = runDetectors(inputs);
|
|
4857
4565
|
recordGraphFeeder(inputs, findings, "live");
|
|
4858
|
-
if (findings.length === 0) return
|
|
4566
|
+
if (findings.length === 0) return EXIT_ALLOW;
|
|
4859
4567
|
markRefusedTurn(
|
|
4860
4568
|
inputs.workspaceRoot,
|
|
4861
4569
|
inputs.sessionKey,
|
|
@@ -4876,27 +4584,27 @@ ${lines.join("\n")}
|
|
|
4876
4584
|
);
|
|
4877
4585
|
return EXIT_BLOCK;
|
|
4878
4586
|
}
|
|
4879
|
-
function
|
|
4587
|
+
function _isCliEntry5() {
|
|
4880
4588
|
if (true) {
|
|
4881
4589
|
return false;
|
|
4882
4590
|
}
|
|
4883
4591
|
if (process.argv[1] === void 0) {
|
|
4884
4592
|
return false;
|
|
4885
4593
|
}
|
|
4886
|
-
const argvUrl =
|
|
4594
|
+
const argvUrl = pathToFileURL5(path10.resolve(process.argv[1])).href;
|
|
4887
4595
|
if (import.meta.url === argvUrl) {
|
|
4888
4596
|
return true;
|
|
4889
4597
|
}
|
|
4890
4598
|
try {
|
|
4891
|
-
const here = fs12.realpathSync(
|
|
4599
|
+
const here = fs12.realpathSync(fileURLToPath5(import.meta.url));
|
|
4892
4600
|
const argv = fs12.realpathSync(path10.resolve(process.argv[1]));
|
|
4893
4601
|
return here === argv;
|
|
4894
4602
|
} catch {
|
|
4895
4603
|
return false;
|
|
4896
4604
|
}
|
|
4897
4605
|
}
|
|
4898
|
-
if (
|
|
4899
|
-
process.exit(
|
|
4606
|
+
if (_isCliEntry5()) {
|
|
4607
|
+
process.exit(main5());
|
|
4900
4608
|
}
|
|
4901
4609
|
|
|
4902
4610
|
// src/scripts/hooks/evidence_independence.ts
|
|
@@ -4904,7 +4612,7 @@ import { spawnSync as spawnSync3 } from "node:child_process";
|
|
|
4904
4612
|
import crypto3 from "node:crypto";
|
|
4905
4613
|
import fs13 from "node:fs";
|
|
4906
4614
|
import path11 from "node:path";
|
|
4907
|
-
import { fileURLToPath as
|
|
4615
|
+
import { fileURLToPath as fileURLToPath6, pathToFileURL as pathToFileURL6 } from "node:url";
|
|
4908
4616
|
|
|
4909
4617
|
// src/scripts/_lib/test_delta.ts
|
|
4910
4618
|
function isCodePath(p) {
|
|
@@ -5013,7 +4721,7 @@ function _load(target) {
|
|
|
5013
4721
|
var WARN_TEXT = "First evaluation dispatch this turn. Two shapes fabricated a binding honest-null in the audited sessions \u2014 check your prompt for both before it goes out: (1) a verdict pre-loaded into the prompt, and (2) a scope narrowed to files you chose. A review you commissioned on your own work is admissible as gate evidence only when the prompt is recorded alongside the verdict.";
|
|
5014
4722
|
function decide(tool, prompt, priorEvaluations) {
|
|
5015
4723
|
if (!isDispatchTool(tool) || !isEvaluationPrompt(prompt)) {
|
|
5016
|
-
return { exit:
|
|
4724
|
+
return { exit: EXIT_ALLOW, stdout: "", stderr: "", evaluations: priorEvaluations };
|
|
5017
4725
|
}
|
|
5018
4726
|
const preloaded = preloadedVerdict(prompt);
|
|
5019
4727
|
if (preloaded !== null) {
|
|
@@ -5026,11 +4734,11 @@ function decide(tool, prompt, priorEvaluations) {
|
|
|
5026
4734
|
};
|
|
5027
4735
|
}
|
|
5028
4736
|
if (!isSelfScoped(prompt)) {
|
|
5029
|
-
return { exit:
|
|
4737
|
+
return { exit: EXIT_ALLOW, stdout: "", stderr: "", evaluations: priorEvaluations };
|
|
5030
4738
|
}
|
|
5031
4739
|
if (priorEvaluations >= 1) {
|
|
5032
4740
|
return {
|
|
5033
|
-
exit:
|
|
4741
|
+
exit: EXIT_ALLOW,
|
|
5034
4742
|
stdout: `${JSON.stringify({
|
|
5035
4743
|
decision: "warn",
|
|
5036
4744
|
reason: `Second evaluation dispatch of your own work in this turn. If both passes judge the SAME subject, that is verdict shopping \u2014 commissioning another with a different prompt or scope selects the answer instead of measuring it. Report what the first pass returned, then re-plan. If this is an implementation fan-out rather than a second review, carry on: this check reads prose and cannot tell the two apart with certainty.`
|
|
@@ -5041,7 +4749,7 @@ function decide(tool, prompt, priorEvaluations) {
|
|
|
5041
4749
|
};
|
|
5042
4750
|
}
|
|
5043
4751
|
return {
|
|
5044
|
-
exit:
|
|
4752
|
+
exit: EXIT_ALLOW,
|
|
5045
4753
|
stdout: `${JSON.stringify({ decision: "warn", reason: WARN_TEXT })}
|
|
5046
4754
|
`,
|
|
5047
4755
|
stderr: "",
|
|
@@ -5083,7 +4791,7 @@ function run3(stdin_text, options) {
|
|
|
5083
4791
|
envelope = decoded;
|
|
5084
4792
|
}
|
|
5085
4793
|
} catch {
|
|
5086
|
-
return
|
|
4794
|
+
return EXIT_ALLOW;
|
|
5087
4795
|
}
|
|
5088
4796
|
}
|
|
5089
4797
|
const target = path11.join(options.consumer_root, STATE_FILE3);
|
|
@@ -5102,7 +4810,7 @@ function run3(stdin_text, options) {
|
|
|
5102
4810
|
if (staged !== null && touchesTestAndCode(staged)) {
|
|
5103
4811
|
process.stdout.write(`${JSON.stringify({ decision: "warn", reason: flag })}
|
|
5104
4812
|
`);
|
|
5105
|
-
return
|
|
4813
|
+
return EXIT_ALLOW;
|
|
5106
4814
|
}
|
|
5107
4815
|
}
|
|
5108
4816
|
const decision = decide(tool, prompt, state.evaluations.length);
|
|
@@ -5133,7 +4841,7 @@ function _errText3(err) {
|
|
|
5133
4841
|
const t = err instanceof Error ? err.message : String(err);
|
|
5134
4842
|
return t.replace(/\s+/g, " ").trim().slice(0, 200);
|
|
5135
4843
|
}
|
|
5136
|
-
function
|
|
4844
|
+
function main6(argv) {
|
|
5137
4845
|
const args = argv ?? process.argv.slice(2);
|
|
5138
4846
|
let consumer_root = process.cwd();
|
|
5139
4847
|
for (let i = 0; i < args.length; i += 1) {
|
|
@@ -5147,33 +4855,33 @@ function main7(argv) {
|
|
|
5147
4855
|
}
|
|
5148
4856
|
return run3(readHookStdin(), { consumer_root });
|
|
5149
4857
|
}
|
|
5150
|
-
function
|
|
4858
|
+
function _isCliEntry6() {
|
|
5151
4859
|
if (true) {
|
|
5152
4860
|
return false;
|
|
5153
4861
|
}
|
|
5154
4862
|
if (process.argv[1] === void 0) {
|
|
5155
4863
|
return false;
|
|
5156
4864
|
}
|
|
5157
|
-
const argvUrl =
|
|
4865
|
+
const argvUrl = pathToFileURL6(path11.resolve(process.argv[1])).href;
|
|
5158
4866
|
if (import.meta.url === argvUrl) {
|
|
5159
4867
|
return true;
|
|
5160
4868
|
}
|
|
5161
4869
|
try {
|
|
5162
|
-
const here = fs13.realpathSync(
|
|
4870
|
+
const here = fs13.realpathSync(fileURLToPath6(import.meta.url));
|
|
5163
4871
|
const argv = fs13.realpathSync(path11.resolve(process.argv[1]));
|
|
5164
4872
|
return here === argv;
|
|
5165
4873
|
} catch {
|
|
5166
4874
|
return false;
|
|
5167
4875
|
}
|
|
5168
4876
|
}
|
|
5169
|
-
if (
|
|
5170
|
-
process.exit(
|
|
4877
|
+
if (_isCliEntry6()) {
|
|
4878
|
+
process.exit(main6());
|
|
5171
4879
|
}
|
|
5172
4880
|
|
|
5173
4881
|
// src/scripts/hooks/delegation_nudge_hook.ts
|
|
5174
|
-
import
|
|
5175
|
-
import
|
|
5176
|
-
import { fileURLToPath as
|
|
4882
|
+
import fs16 from "node:fs";
|
|
4883
|
+
import path13 from "node:path";
|
|
4884
|
+
import { fileURLToPath as fileURLToPath7, pathToFileURL as pathToFileURL7 } from "node:url";
|
|
5177
4885
|
|
|
5178
4886
|
// src/scripts/_lib/auto_dispatch.ts
|
|
5179
4887
|
var SIZE_FLOOR = 1;
|
|
@@ -5243,6 +4951,29 @@ function classifyLookup(taskText, opts = {}) {
|
|
|
5243
4951
|
reason: "not lookup-shaped \u2014 regular classification path (never down-guessed)"
|
|
5244
4952
|
};
|
|
5245
4953
|
}
|
|
4954
|
+
function inferSliceTier(signals) {
|
|
4955
|
+
const guard = signals.exceeds_mechanical_envelope === true;
|
|
4956
|
+
switch (signals.slice_type) {
|
|
4957
|
+
case "read-only-fanout":
|
|
4958
|
+
case "mechanical-covered": {
|
|
4959
|
+
if (guard) {
|
|
4960
|
+
return {
|
|
4961
|
+
tier: "medium",
|
|
4962
|
+
tier_source: "inferred",
|
|
4963
|
+
reason: `${signals.slice_type} slice, but scope exceeds the mechanical envelope \u2014 lite candidacy revoked`
|
|
4964
|
+
};
|
|
4965
|
+
}
|
|
4966
|
+
const cascade = signals.slice_type === "mechanical-covered" ? " (verify-fail escalates to medium)" : "";
|
|
4967
|
+
return { tier: "lite", tier_source: "inferred", reason: `${signals.slice_type} slice${cascade}` };
|
|
4968
|
+
}
|
|
4969
|
+
case "mutating-uncovered":
|
|
4970
|
+
return { tier: "medium", tier_source: "inferred", reason: "mutating slice without test coverage" };
|
|
4971
|
+
case "synthesis":
|
|
4972
|
+
return { tier: "medium", tier_source: "inferred", reason: "synthesis/judgment slice \u2014 judge one tier up" };
|
|
4973
|
+
default:
|
|
4974
|
+
return { tier: "inherit", tier_source: "inherit", reason: "unknown/ambiguous slice type \u2014 session tier, never guess down" };
|
|
4975
|
+
}
|
|
4976
|
+
}
|
|
5246
4977
|
|
|
5247
4978
|
// src/scripts/_lib/judgment_ladder.ts
|
|
5248
4979
|
var RENAME_RE = /\brename\s+\S+\s+to\s+\S+\b/i;
|
|
@@ -5452,6 +5183,86 @@ function resolveSubagentRouting(inp) {
|
|
|
5452
5183
|
};
|
|
5453
5184
|
}
|
|
5454
5185
|
|
|
5186
|
+
// src/scripts/_lib/hand_kinds.ts
|
|
5187
|
+
var HAND_KINDS = [
|
|
5188
|
+
"classify",
|
|
5189
|
+
"extract",
|
|
5190
|
+
"summarise-given-text",
|
|
5191
|
+
"draft-candidate",
|
|
5192
|
+
"test-candidates",
|
|
5193
|
+
"finding-proposal"
|
|
5194
|
+
];
|
|
5195
|
+
var HEAD_ONLY_KINDS = ["plan", "decide", "chair", "final-review", "write"];
|
|
5196
|
+
var _KINDS = new Set(HAND_KINDS);
|
|
5197
|
+
var _HEAD_ONLY = new Set(HEAD_ONLY_KINDS);
|
|
5198
|
+
var KIND_FROM_PROMPT = [
|
|
5199
|
+
[/^\s*(?:propose|suggest|draft|write)\s+(?:unit\s+)?test(?:s|\s+cases?|\s+candidates?)?\b/i, "test-candidates"],
|
|
5200
|
+
[/^\s*(?:propose|list)\s+(?:review\s+)?findings?\b/i, "finding-proposal"],
|
|
5201
|
+
[/^\s*(?:classify|categori[sz]e|label)\b/i, "classify"],
|
|
5202
|
+
[/^\s*extract\b/i, "extract"],
|
|
5203
|
+
[/^\s*summari[sz]e\b/i, "summarise-given-text"],
|
|
5204
|
+
[/^\s*draft\b/i, "draft-candidate"]
|
|
5205
|
+
];
|
|
5206
|
+
function handKindFromPrompt(text) {
|
|
5207
|
+
for (const [re, kind] of KIND_FROM_PROMPT) if (re.test(text)) return kind;
|
|
5208
|
+
return null;
|
|
5209
|
+
}
|
|
5210
|
+
|
|
5211
|
+
// src/scripts/ai_council/free_rung.ts
|
|
5212
|
+
var import_yaml = __toESM(require_dist(), 1);
|
|
5213
|
+
import * as fs15 from "node:fs";
|
|
5214
|
+
|
|
5215
|
+
// src/scripts/ai_council/kind_flip_state.ts
|
|
5216
|
+
import * as fs14 from "node:fs";
|
|
5217
|
+
import * as path12 from "node:path";
|
|
5218
|
+
var KIND_FLIPS_RELPATH = path12.join("agents", "runtime", "state", "hand-kind-flips.json");
|
|
5219
|
+
function isKindFlipped(stateRoot, kind) {
|
|
5220
|
+
try {
|
|
5221
|
+
const raw = JSON.parse(fs14.readFileSync(path12.join(stateRoot, KIND_FLIPS_RELPATH), "utf8"));
|
|
5222
|
+
return raw.kinds?.[kind]?.route === "free";
|
|
5223
|
+
} catch {
|
|
5224
|
+
return false;
|
|
5225
|
+
}
|
|
5226
|
+
}
|
|
5227
|
+
|
|
5228
|
+
// src/scripts/ai_council/free_rung.ts
|
|
5229
|
+
var COUNCIL_CONFIG_ENV = "AI_COUNCIL_CONFIG";
|
|
5230
|
+
var COUNCIL_CONFIG_REL = "settings/.ai-council.yml";
|
|
5231
|
+
function keyPresent(ref) {
|
|
5232
|
+
if (ref === void 0 || ref === null) return true;
|
|
5233
|
+
if (typeof ref !== "string" || !ref.startsWith("env:")) return false;
|
|
5234
|
+
return (process.env[ref.slice(4)] ?? "") !== "";
|
|
5235
|
+
}
|
|
5236
|
+
function freeRouteAvailable(configPath) {
|
|
5237
|
+
let raw;
|
|
5238
|
+
try {
|
|
5239
|
+
raw = (0, import_yaml.parse)(fs15.readFileSync(configPath, "utf-8"), { version: "1.1" });
|
|
5240
|
+
} catch {
|
|
5241
|
+
return false;
|
|
5242
|
+
}
|
|
5243
|
+
const members = raw?.members;
|
|
5244
|
+
if (members === null || typeof members !== "object") return false;
|
|
5245
|
+
for (const [name, value] of Object.entries(members)) {
|
|
5246
|
+
if (value === null || typeof value !== "object") continue;
|
|
5247
|
+
const cfg = value;
|
|
5248
|
+
if (cfg["enabled"] !== true) continue;
|
|
5249
|
+
const parsed = parseRouteFields(name, cfg, false);
|
|
5250
|
+
if ("error" in parsed || parsed.route === null) continue;
|
|
5251
|
+
const model = typeof cfg["model"] === "string" ? cfg["model"] : "";
|
|
5252
|
+
const t = resolveRouteTransport({ name, route: parsed.route, model, contentClass: "public-artifact", keyPresent: keyPresent(cfg["api_key_ref"]) });
|
|
5253
|
+
if (t.available && t.billing !== "per-token") return true;
|
|
5254
|
+
}
|
|
5255
|
+
return false;
|
|
5256
|
+
}
|
|
5257
|
+
function councilConfigPath() {
|
|
5258
|
+
const override = process.env[COUNCIL_CONFIG_ENV];
|
|
5259
|
+
if (override) return override.startsWith("~/") ? `${process.env["HOME"] ?? ""}${override.slice(1)}` : override;
|
|
5260
|
+
return resolve_with_fallback(COUNCIL_CONFIG_REL, { env: null });
|
|
5261
|
+
}
|
|
5262
|
+
function freeRungFor(stateRoot, kind, configPath) {
|
|
5263
|
+
return isKindFlipped(stateRoot, kind) && configPath !== null && freeRouteAvailable(configPath);
|
|
5264
|
+
}
|
|
5265
|
+
|
|
5455
5266
|
// src/scripts/hooks/delegation_nudge_hook.ts
|
|
5456
5267
|
function _isObject6(v) {
|
|
5457
5268
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -5544,10 +5355,10 @@ function resolveActivation(workspace_root, hostId) {
|
|
|
5544
5355
|
agentTeams: host_manifest.agent_teams
|
|
5545
5356
|
};
|
|
5546
5357
|
}
|
|
5547
|
-
function recommendSliceTier(downshift, separate_quota_pool) {
|
|
5358
|
+
function recommendSliceTier(downshift, separate_quota_pool, sliceKind = "unknown") {
|
|
5548
5359
|
const decision = resolveSubagentRouting({
|
|
5549
|
-
task_tier:
|
|
5550
|
-
session_tier: "
|
|
5360
|
+
task_tier: inferSliceTier({ slice_type: sliceKind }).tier,
|
|
5361
|
+
session_tier: "inherit",
|
|
5551
5362
|
downshift,
|
|
5552
5363
|
quota_arbitrage: false,
|
|
5553
5364
|
model_map: {},
|
|
@@ -5555,9 +5366,18 @@ function recommendSliceTier(downshift, separate_quota_pool) {
|
|
|
5555
5366
|
});
|
|
5556
5367
|
return decision.tier;
|
|
5557
5368
|
}
|
|
5558
|
-
|
|
5369
|
+
var READ_ONLY_FANOUT_RE = /\b(find|locate|search|grep|list|inventor(?:y|ise|ize)|enumerate|count|which files|where (?:is|are)|finde|suche|liste|z(?:ä|ae)hle|wo (?:ist|sind))\b/i;
|
|
5370
|
+
var MUTATING_RE = /\b(fix|implement|edit|write|refactor|change|add|create|remove|delete|update|rename|migrate|build|move|replace|mach|bau|implementier\w*|(?:ä|ae)nder\w*|erstell\w*|l(?:ö|oe)sch\w*|f(?:ü|ue)g\w*|schreib\w*)\b/i;
|
|
5371
|
+
function sliceKindFromPrompt(prompt) {
|
|
5372
|
+
return READ_ONLY_FANOUT_RE.test(prompt) && !MUTATING_RE.test(prompt) ? "read-only-fanout" : "unknown";
|
|
5373
|
+
}
|
|
5374
|
+
var LEG_COLD_START_UNCACHED_TOKENS = 182257;
|
|
5375
|
+
function buildNudgeLine(rung, classification, sliceCount, tier, sliceKind, handKind) {
|
|
5559
5376
|
const unit = sliceCount === 1 ? "slice" : "slices";
|
|
5560
5377
|
const rungLabel = rung === null ? "rung-?" : `rung-${rung}`;
|
|
5378
|
+
if (rung === 0.5 && handKind !== void 0) {
|
|
5379
|
+
return `<delegation-nudge>rung-0.5: free rung. This slice is a typed \`${handKind}\` task and an unpaid route is admissible \u2014 you may send it as ONE call via \`./scripts-run src/scripts/ask_transport --kind ${handKind} --content-class public-artifact "<slice>"\` (public-artifact text only; project content stays on a paid route). The return is a proposal: verify it before acting on it. Nothing was sent for you \u2014 ${classification.reason}.</delegation-nudge>`;
|
|
5380
|
+
}
|
|
5561
5381
|
if (rung === 0.5) {
|
|
5562
5382
|
return `<delegation-nudge>rung-0.5: ask, est. <1k tokens. This is a single bounded question \u2014 answer it via ONE completion (\`./scripts-run src/scripts/ask_transport "<question>"\`) instead of a subagent spawn (measured spawn floor: ~251k tokens) \u2014 ${classification.reason}.</delegation-nudge>`;
|
|
5563
5383
|
}
|
|
@@ -5568,9 +5388,12 @@ function buildNudgeLine(rung, classification, sliceCount, tier) {
|
|
|
5568
5388
|
return `<delegation-nudge>rung-3: team. These slices must see each other's state during the run, so a set of independent subagent spawns cannot express it \u2014 use the host teams primitive, or fall back to \`./scripts-run src/scripts/ask_transport "<question>"\` for a bounded sub-question. Not a spawn, and not run for you \u2014 ${classification.reason}.</delegation-nudge>`;
|
|
5569
5389
|
}
|
|
5570
5390
|
const modeLabel = classification.mode ?? "single-slice";
|
|
5571
|
-
|
|
5391
|
+
const coldStart = rung === 1 ? ` A leg starts cold (~${Math.round(LEG_COLD_START_UNCACHED_TOKENS / 1e3)}k uncached tokens): a slice of one to three direct reads does not amortise it.` : "";
|
|
5392
|
+
const model = tier === "lite" && sliceKind !== void 0 && sliceKind !== "unknown" ? TIER_TO_CLAUDE_MODEL[tier] : void 0;
|
|
5393
|
+
const carrier = model ? ` Pass \`model: "${model}"\` on each Agent call (${sliceKind} slices earn lite).` : "";
|
|
5394
|
+
return `<delegation-nudge>${rungLabel}: dispatch ${modeLabel} (${sliceCount} ${unit}, ${tier} tier recommended). Consider dispatching via subagent-orchestration instead of doing every slice in-session \u2014 ${classification.reason}.${carrier}${coldStart}</delegation-nudge>`;
|
|
5572
5395
|
}
|
|
5573
|
-
function classifyPrompt(prompt, workspace_root, hostId) {
|
|
5396
|
+
function classifyPrompt(prompt, workspace_root, hostId, opts = {}) {
|
|
5574
5397
|
try {
|
|
5575
5398
|
const { signals, sliceCountForLine } = extractTaskSignals(prompt);
|
|
5576
5399
|
const { activation, downshift, separate_quota_pool, agentTeams } = resolveActivation(
|
|
@@ -5590,13 +5413,28 @@ function classifyPrompt(prompt, workspace_root, hostId) {
|
|
|
5590
5413
|
classification: { delegable: false, action: "ask", mode: null, reason: ladder.reason },
|
|
5591
5414
|
sliceCount: 0,
|
|
5592
5415
|
tier: recommendSliceTier(downshift, separate_quota_pool),
|
|
5416
|
+
sliceKind: "unknown",
|
|
5593
5417
|
rung: ladder.rung
|
|
5594
5418
|
};
|
|
5595
5419
|
}
|
|
5420
|
+
if (ladder.rung === 0.5 && opts.freeRouteAdmissible !== void 0) {
|
|
5421
|
+
const handKind = handKindFromPrompt(prompt);
|
|
5422
|
+
if (handKind !== null && opts.freeRouteAdmissible(handKind)) {
|
|
5423
|
+
return {
|
|
5424
|
+
classification: { delegable: false, action: "ask", mode: null, reason: ladder.reason },
|
|
5425
|
+
sliceCount: 0,
|
|
5426
|
+
tier: recommendSliceTier(downshift, separate_quota_pool),
|
|
5427
|
+
sliceKind: "unknown",
|
|
5428
|
+
rung: ladder.rung,
|
|
5429
|
+
handKind
|
|
5430
|
+
};
|
|
5431
|
+
}
|
|
5432
|
+
}
|
|
5596
5433
|
if (ladder.verdict !== "subagent") {
|
|
5597
5434
|
return null;
|
|
5598
5435
|
}
|
|
5599
|
-
const
|
|
5436
|
+
const sliceKind = sliceKindFromPrompt(prompt);
|
|
5437
|
+
const tier = recommendSliceTier(downshift, separate_quota_pool, sliceKind);
|
|
5600
5438
|
const sliceCount = ladder.rung === 1 ? 1 : sliceCountForLine;
|
|
5601
5439
|
const classification = {
|
|
5602
5440
|
delegable: true,
|
|
@@ -5604,7 +5442,7 @@ function classifyPrompt(prompt, workspace_root, hostId) {
|
|
|
5604
5442
|
mode: ladder.mode ?? null,
|
|
5605
5443
|
reason: ladder.reason
|
|
5606
5444
|
};
|
|
5607
|
-
return { classification, sliceCount, tier, rung: ladder.rung };
|
|
5445
|
+
return { classification, sliceCount, tier, sliceKind, rung: ladder.rung };
|
|
5608
5446
|
} catch {
|
|
5609
5447
|
return null;
|
|
5610
5448
|
}
|
|
@@ -5625,70 +5463,79 @@ function _workspaceRoot(envelope) {
|
|
|
5625
5463
|
}
|
|
5626
5464
|
return process.cwd();
|
|
5627
5465
|
}
|
|
5628
|
-
function
|
|
5466
|
+
function main7() {
|
|
5629
5467
|
let envelope = {};
|
|
5630
5468
|
try {
|
|
5631
5469
|
const raw = readHookStdin();
|
|
5632
5470
|
envelope = raw.trim() ? JSON.parse(raw) : {};
|
|
5633
5471
|
} catch {
|
|
5634
|
-
return
|
|
5472
|
+
return EXIT_ALLOW;
|
|
5635
5473
|
}
|
|
5636
5474
|
const env = _isObject6(envelope) ? envelope : {};
|
|
5637
5475
|
const event = env["event"];
|
|
5638
5476
|
const slot = typeof event === "string" && event !== "" ? event : "user_prompt_submit";
|
|
5639
5477
|
if (slot !== "user_prompt_submit") {
|
|
5640
|
-
return
|
|
5478
|
+
return EXIT_ALLOW;
|
|
5641
5479
|
}
|
|
5642
5480
|
const payload = _isObject6(env["payload"]) ? env["payload"] : env;
|
|
5643
5481
|
const prompt = _extractPrompt2(payload);
|
|
5644
5482
|
if (!prompt) {
|
|
5645
|
-
return
|
|
5483
|
+
return EXIT_ALLOW;
|
|
5646
5484
|
}
|
|
5647
5485
|
if (isSyntheticPrompt(prompt)) {
|
|
5648
|
-
return
|
|
5486
|
+
return EXIT_ALLOW;
|
|
5649
5487
|
}
|
|
5650
5488
|
const root = _workspaceRoot(env);
|
|
5651
5489
|
const platform = env["platform"];
|
|
5652
5490
|
const hostId = typeof platform === "string" && platform ? platform : null;
|
|
5653
|
-
const result = classifyPrompt(prompt, root, hostId
|
|
5491
|
+
const result = classifyPrompt(prompt, root, hostId, {
|
|
5492
|
+
freeRouteAdmissible: (kind) => freeRungFor(root, kind, councilConfigPath())
|
|
5493
|
+
});
|
|
5654
5494
|
if (!result) {
|
|
5655
|
-
return
|
|
5495
|
+
return EXIT_ALLOW;
|
|
5656
5496
|
}
|
|
5657
5497
|
process.stdout.write(
|
|
5658
5498
|
`${JSON.stringify({
|
|
5659
5499
|
decision: "warn",
|
|
5660
5500
|
reason: `delegation-nudge: rung-${result.rung} verdict (${result.sliceCount} slices, ${result.tier} tier)`,
|
|
5661
|
-
additional_context: buildNudgeLine(
|
|
5501
|
+
additional_context: buildNudgeLine(
|
|
5502
|
+
result.rung,
|
|
5503
|
+
result.classification,
|
|
5504
|
+
result.sliceCount,
|
|
5505
|
+
result.tier,
|
|
5506
|
+
result.sliceKind,
|
|
5507
|
+
result.handKind
|
|
5508
|
+
)
|
|
5662
5509
|
})}
|
|
5663
5510
|
`
|
|
5664
5511
|
);
|
|
5665
|
-
return
|
|
5512
|
+
return EXIT_WARN;
|
|
5666
5513
|
}
|
|
5667
|
-
function
|
|
5514
|
+
function _isCliEntry7() {
|
|
5668
5515
|
if (true) {
|
|
5669
5516
|
return false;
|
|
5670
5517
|
}
|
|
5671
5518
|
if (process.argv[1] === void 0) {
|
|
5672
5519
|
return false;
|
|
5673
5520
|
}
|
|
5674
|
-
const argvUrl =
|
|
5521
|
+
const argvUrl = pathToFileURL7(path13.resolve(process.argv[1])).href;
|
|
5675
5522
|
if (import.meta.url === argvUrl) {
|
|
5676
5523
|
return true;
|
|
5677
5524
|
}
|
|
5678
5525
|
try {
|
|
5679
|
-
const here =
|
|
5680
|
-
const argv =
|
|
5526
|
+
const here = fs16.realpathSync(fileURLToPath7(import.meta.url));
|
|
5527
|
+
const argv = fs16.realpathSync(path13.resolve(process.argv[1]));
|
|
5681
5528
|
return here === argv;
|
|
5682
5529
|
} catch {
|
|
5683
5530
|
return false;
|
|
5684
5531
|
}
|
|
5685
5532
|
}
|
|
5686
|
-
if (
|
|
5687
|
-
process.exit(
|
|
5533
|
+
if (_isCliEntry7()) {
|
|
5534
|
+
process.exit(main7());
|
|
5688
5535
|
}
|
|
5689
5536
|
|
|
5690
5537
|
// src/scripts/conformance_scan.ts
|
|
5691
|
-
var REPO_ROOT =
|
|
5538
|
+
var REPO_ROOT = path14.resolve(path14.dirname(fileURLToPath8(import.meta.url)), "..", "..");
|
|
5692
5539
|
var OBSERVED_BAND = { low: 9.1, high: 39.2 };
|
|
5693
5540
|
var BAND_MIN_TURNS = 1978;
|
|
5694
5541
|
var CARRIER_CHANGES = [
|
|
@@ -6054,7 +5901,7 @@ function scanSession(sessionId, lines) {
|
|
|
6054
5901
|
closeWindow();
|
|
6055
5902
|
return report;
|
|
6056
5903
|
}
|
|
6057
|
-
var DEFAULT_RATE_SERIES =
|
|
5904
|
+
var DEFAULT_RATE_SERIES = path14.join(
|
|
6058
5905
|
REPO_ROOT,
|
|
6059
5906
|
"agents",
|
|
6060
5907
|
"runtime",
|
|
@@ -6063,7 +5910,7 @@ var DEFAULT_RATE_SERIES = path13.join(
|
|
|
6063
5910
|
);
|
|
6064
5911
|
function defaultStore(projectDir) {
|
|
6065
5912
|
const slug = projectStoreSlug(projectDir);
|
|
6066
|
-
return
|
|
5913
|
+
return path14.join(process.env["HOME"] ?? "", ".claude", "projects", slug);
|
|
6067
5914
|
}
|
|
6068
5915
|
function _tokens(chars) {
|
|
6069
5916
|
return Math.round(chars / 4);
|
|
@@ -6074,13 +5921,13 @@ function measureDelivered(projectRulesDir, globalRulesDir) {
|
|
|
6074
5921
|
return {
|
|
6075
5922
|
project: {
|
|
6076
5923
|
dir: projectRulesDir,
|
|
6077
|
-
present:
|
|
5924
|
+
present: fs17.existsSync(projectRulesDir),
|
|
6078
5925
|
files: p.files,
|
|
6079
5926
|
tokens: _tokens(p.chars)
|
|
6080
5927
|
},
|
|
6081
5928
|
global: {
|
|
6082
5929
|
dir: globalRulesDir,
|
|
6083
|
-
present:
|
|
5930
|
+
present: fs17.existsSync(globalRulesDir),
|
|
6084
5931
|
files: g.files,
|
|
6085
5932
|
tokens: _tokens(g.chars)
|
|
6086
5933
|
},
|
|
@@ -6088,13 +5935,13 @@ function measureDelivered(projectRulesDir, globalRulesDir) {
|
|
|
6088
5935
|
};
|
|
6089
5936
|
}
|
|
6090
5937
|
function storeKey(store) {
|
|
6091
|
-
return createHash4("sha256").update(
|
|
5938
|
+
return createHash4("sha256").update(path14.resolve(store)).digest("hex").slice(0, 12);
|
|
6092
5939
|
}
|
|
6093
5940
|
function scanStore(store, limit) {
|
|
6094
|
-
const files =
|
|
5941
|
+
const files = fs17.readdirSync(store).filter((f) => f.endsWith(".jsonl")).map((f) => ({ f, m: fs17.statSync(path14.join(store, f)).mtimeMs })).sort((a, b) => b.m - a.m).slice(0, limit).map((x) => x.f);
|
|
6095
5942
|
const per_session = [];
|
|
6096
5943
|
for (const f of files) {
|
|
6097
|
-
const lines =
|
|
5944
|
+
const lines = fs17.readFileSync(path14.join(store, f), "utf8").split("\n");
|
|
6098
5945
|
const r = scanSession(f.replace(/\.jsonl$/, "").slice(0, 8), lines);
|
|
6099
5946
|
if (r.assistant_turns > 0) {
|
|
6100
5947
|
per_session.push(r);
|
|
@@ -6122,10 +5969,10 @@ function scanStore(store, limit) {
|
|
|
6122
5969
|
const task_completeness_rate_pct = completeness_windows === 0 ? 0 : Number((100 * task_completeness / completeness_windows).toFixed(1));
|
|
6123
5970
|
const era = spansCarrierChange(per_session.map((s) => s.first_at));
|
|
6124
5971
|
const delivered = measureDelivered(
|
|
6125
|
-
|
|
6126
|
-
|
|
5972
|
+
path14.join(REPO_ROOT, ".claude", "rules"),
|
|
5973
|
+
path14.join(process.env["HOME"] ?? os2.homedir(), ".claude", "rules")
|
|
6127
5974
|
);
|
|
6128
|
-
const ownStore =
|
|
5975
|
+
const ownStore = path14.resolve(store) === path14.resolve(defaultStore(REPO_ROOT));
|
|
6129
5976
|
return {
|
|
6130
5977
|
scanned_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6131
5978
|
store,
|
|
@@ -6155,8 +6002,8 @@ function scanStore(store, limit) {
|
|
|
6155
6002
|
};
|
|
6156
6003
|
}
|
|
6157
6004
|
function recordRate(file, scanned_at, rate) {
|
|
6158
|
-
|
|
6159
|
-
|
|
6005
|
+
fs17.mkdirSync(path14.dirname(file), { recursive: true });
|
|
6006
|
+
fs17.appendFileSync(file, `${JSON.stringify({ measured_at: scanned_at, ...rate })}
|
|
6160
6007
|
`, "utf8");
|
|
6161
6008
|
}
|
|
6162
6009
|
function render(report) {
|
|
@@ -6255,7 +6102,7 @@ function render(report) {
|
|
|
6255
6102
|
lines.push(" checkbox batching \u2014 measured NOWHERE. ~5 low-severity findings.");
|
|
6256
6103
|
return lines.join("\n");
|
|
6257
6104
|
}
|
|
6258
|
-
function
|
|
6105
|
+
function main8(argv) {
|
|
6259
6106
|
const args = argv ?? process.argv.slice(2);
|
|
6260
6107
|
let store = null;
|
|
6261
6108
|
let limit = 30;
|
|
@@ -6287,14 +6134,14 @@ function main9(argv) {
|
|
|
6287
6134
|
return 2;
|
|
6288
6135
|
}
|
|
6289
6136
|
const resolved = store ?? defaultStore(process.cwd());
|
|
6290
|
-
if (!
|
|
6137
|
+
if (!fs17.existsSync(resolved)) {
|
|
6291
6138
|
process.stderr.write(`conformance:behavior: no transcript store at ${resolved}
|
|
6292
6139
|
`);
|
|
6293
6140
|
return 1;
|
|
6294
6141
|
}
|
|
6295
6142
|
const report = scanStore(resolved, Number.isFinite(limit) && limit > 0 ? limit : 30);
|
|
6296
6143
|
if (out) {
|
|
6297
|
-
|
|
6144
|
+
fs17.writeFileSync(out, `${JSON.stringify(report, null, 2)}
|
|
6298
6145
|
`, "utf8");
|
|
6299
6146
|
}
|
|
6300
6147
|
if (record) {
|
|
@@ -6302,7 +6149,7 @@ function main9(argv) {
|
|
|
6302
6149
|
}
|
|
6303
6150
|
if (why !== null) {
|
|
6304
6151
|
const id = why;
|
|
6305
|
-
|
|
6152
|
+
fs17.writeSync(
|
|
6306
6153
|
1,
|
|
6307
6154
|
json ? `${JSON.stringify(
|
|
6308
6155
|
{
|
|
@@ -6322,48 +6169,48 @@ function main9(argv) {
|
|
|
6322
6169
|
);
|
|
6323
6170
|
return 0;
|
|
6324
6171
|
}
|
|
6325
|
-
|
|
6172
|
+
fs17.writeSync(1, json ? `${JSON.stringify(report, null, 2)}
|
|
6326
6173
|
` : `${render(report)}
|
|
6327
6174
|
`);
|
|
6328
6175
|
return 0;
|
|
6329
6176
|
}
|
|
6330
|
-
function
|
|
6177
|
+
function _isCliEntry8() {
|
|
6331
6178
|
if (true) {
|
|
6332
6179
|
return false;
|
|
6333
6180
|
}
|
|
6334
6181
|
if (process.argv[1] === void 0) {
|
|
6335
6182
|
return false;
|
|
6336
6183
|
}
|
|
6337
|
-
const argvUrl =
|
|
6184
|
+
const argvUrl = pathToFileURL8(path14.resolve(process.argv[1])).href;
|
|
6338
6185
|
if (import.meta.url === argvUrl) {
|
|
6339
6186
|
return true;
|
|
6340
6187
|
}
|
|
6341
6188
|
try {
|
|
6342
|
-
const here =
|
|
6343
|
-
const argv =
|
|
6189
|
+
const here = fs17.realpathSync(fileURLToPath8(import.meta.url));
|
|
6190
|
+
const argv = fs17.realpathSync(path14.resolve(process.argv[1]));
|
|
6344
6191
|
return here === argv;
|
|
6345
6192
|
} catch {
|
|
6346
6193
|
return false;
|
|
6347
6194
|
}
|
|
6348
6195
|
}
|
|
6349
|
-
if (
|
|
6350
|
-
process.exit(
|
|
6196
|
+
if (_isCliEntry8()) {
|
|
6197
|
+
process.exit(main8());
|
|
6351
6198
|
}
|
|
6352
6199
|
|
|
6353
6200
|
// src/scripts/report_carrier_divergence.ts
|
|
6354
|
-
import * as
|
|
6201
|
+
import * as fs18 from "node:fs";
|
|
6355
6202
|
import * as os3 from "node:os";
|
|
6356
|
-
import * as
|
|
6203
|
+
import * as path15 from "node:path";
|
|
6357
6204
|
import process2 from "node:process";
|
|
6358
|
-
import { fileURLToPath as
|
|
6359
|
-
var _HERE2 =
|
|
6360
|
-
var REPO_ROOT2 =
|
|
6361
|
-
var PROJECT_RULES =
|
|
6362
|
-
var PROJECTION_SOURCE =
|
|
6363
|
-
var GLOBAL_RULES =
|
|
6205
|
+
import { fileURLToPath as fileURLToPath9, pathToFileURL as pathToFileURL9 } from "node:url";
|
|
6206
|
+
var _HERE2 = fileURLToPath9(import.meta.url);
|
|
6207
|
+
var REPO_ROOT2 = path15.resolve(path15.dirname(_HERE2), "..", "..");
|
|
6208
|
+
var PROJECT_RULES = path15.join(".claude", "rules");
|
|
6209
|
+
var PROJECTION_SOURCE = path15.join("dist", "agent-src", "rules");
|
|
6210
|
+
var GLOBAL_RULES = path15.join(".claude", "rules");
|
|
6364
6211
|
function _listRules(dir) {
|
|
6365
6212
|
try {
|
|
6366
|
-
return
|
|
6213
|
+
return fs18.readdirSync(dir).filter((f) => f.endsWith(".md")).sort();
|
|
6367
6214
|
} catch {
|
|
6368
6215
|
return [];
|
|
6369
6216
|
}
|
|
@@ -6371,7 +6218,7 @@ function _listRules(dir) {
|
|
|
6371
6218
|
function _ruleType(file) {
|
|
6372
6219
|
let text;
|
|
6373
6220
|
try {
|
|
6374
|
-
text =
|
|
6221
|
+
text = fs18.readFileSync(file, "utf-8");
|
|
6375
6222
|
} catch {
|
|
6376
6223
|
return "";
|
|
6377
6224
|
}
|
|
@@ -6382,8 +6229,8 @@ function compareCarriers(projectDir, globalDir, sourceDir) {
|
|
|
6382
6229
|
const out = {
|
|
6383
6230
|
projectDir,
|
|
6384
6231
|
globalDir,
|
|
6385
|
-
globalPresent:
|
|
6386
|
-
projectPresent:
|
|
6232
|
+
globalPresent: fs18.existsSync(globalDir),
|
|
6233
|
+
projectPresent: fs18.existsSync(projectDir),
|
|
6387
6234
|
shared: 0,
|
|
6388
6235
|
identical: [],
|
|
6389
6236
|
provenanceOnly: [],
|
|
@@ -6406,7 +6253,7 @@ function compareCarriers(projectDir, globalDir, sourceDir) {
|
|
|
6406
6253
|
}
|
|
6407
6254
|
if (!inP && inG) {
|
|
6408
6255
|
out.globalOnly.push(rule);
|
|
6409
|
-
if (sourceDir !== void 0 && _ruleType(
|
|
6256
|
+
if (sourceDir !== void 0 && _ruleType(path15.join(sourceDir, rule)) === "manual") {
|
|
6410
6257
|
out.manualOnlyGlobal.push(rule);
|
|
6411
6258
|
}
|
|
6412
6259
|
continue;
|
|
@@ -6416,8 +6263,8 @@ function compareCarriers(projectDir, globalDir, sourceDir) {
|
|
|
6416
6263
|
let projectCopy;
|
|
6417
6264
|
let globalCopy;
|
|
6418
6265
|
try {
|
|
6419
|
-
projectCopy =
|
|
6420
|
-
globalCopy =
|
|
6266
|
+
projectCopy = fs18.readFileSync(path15.join(projectDir, rule));
|
|
6267
|
+
globalCopy = fs18.readFileSync(path15.join(globalDir, rule));
|
|
6421
6268
|
verdict = comparePair(projectCopy, globalCopy);
|
|
6422
6269
|
} catch {
|
|
6423
6270
|
out.shared -= 1;
|
|
@@ -6562,11 +6409,11 @@ function render2(d) {
|
|
|
6562
6409
|
}
|
|
6563
6410
|
return lines.join("\n");
|
|
6564
6411
|
}
|
|
6565
|
-
function
|
|
6412
|
+
function main9(argv) {
|
|
6566
6413
|
const args = argv ?? process2.argv.slice(2);
|
|
6567
|
-
let projectDir =
|
|
6568
|
-
let globalDir =
|
|
6569
|
-
let sourceDir =
|
|
6414
|
+
let projectDir = path15.join(REPO_ROOT2, PROJECT_RULES);
|
|
6415
|
+
let globalDir = path15.join(os3.homedir(), GLOBAL_RULES);
|
|
6416
|
+
let sourceDir = path15.join(REPO_ROOT2, PROJECTION_SOURCE);
|
|
6570
6417
|
const value = (i) => {
|
|
6571
6418
|
const v = args[i + 1];
|
|
6572
6419
|
return v === void 0 || v.startsWith("-") ? null : v;
|
|
@@ -6580,7 +6427,7 @@ function main10(argv) {
|
|
|
6580
6427
|
`);
|
|
6581
6428
|
return 1;
|
|
6582
6429
|
}
|
|
6583
|
-
const resolved =
|
|
6430
|
+
const resolved = path15.resolve(v);
|
|
6584
6431
|
if (a === "--project") projectDir = resolved;
|
|
6585
6432
|
else if (a === "--global") globalDir = resolved;
|
|
6586
6433
|
else sourceDir = resolved;
|
|
@@ -6600,26 +6447,26 @@ function main10(argv) {
|
|
|
6600
6447
|
`);
|
|
6601
6448
|
return 0;
|
|
6602
6449
|
}
|
|
6603
|
-
function
|
|
6450
|
+
function _isCliEntry9() {
|
|
6604
6451
|
if (process2.argv[1] === void 0) return false;
|
|
6605
|
-
if (import.meta.url ===
|
|
6452
|
+
if (import.meta.url === pathToFileURL9(path15.resolve(process2.argv[1])).href) return true;
|
|
6606
6453
|
try {
|
|
6607
|
-
return
|
|
6454
|
+
return fs18.realpathSync(_HERE2) === fs18.realpathSync(path15.resolve(process2.argv[1]));
|
|
6608
6455
|
} catch {
|
|
6609
6456
|
return false;
|
|
6610
6457
|
}
|
|
6611
6458
|
}
|
|
6612
|
-
if (
|
|
6613
|
-
process2.exit(
|
|
6459
|
+
if (_isCliEntry9()) {
|
|
6460
|
+
process2.exit(main9());
|
|
6614
6461
|
}
|
|
6615
6462
|
|
|
6616
6463
|
// src/scripts/report_skill_activation.ts
|
|
6617
|
-
import * as
|
|
6464
|
+
import * as fs19 from "node:fs";
|
|
6618
6465
|
import * as os4 from "node:os";
|
|
6619
|
-
import * as
|
|
6620
|
-
import { fileURLToPath as
|
|
6621
|
-
var _HERE3 =
|
|
6622
|
-
var REPO_ROOT3 =
|
|
6466
|
+
import * as path16 from "node:path";
|
|
6467
|
+
import { fileURLToPath as fileURLToPath10, pathToFileURL as pathToFileURL10 } from "node:url";
|
|
6468
|
+
var _HERE3 = fileURLToPath10(import.meta.url);
|
|
6469
|
+
var REPO_ROOT3 = path16.resolve(path16.dirname(_HERE3), "..", "..");
|
|
6623
6470
|
var SKILLS_ROOT = "src/skills";
|
|
6624
6471
|
var TRIGGER_KEYS = ["triggers:", "trigger_description:", "file_pattern:", "path_prefix:"];
|
|
6625
6472
|
var DETERMINISTIC_RE = /^\s*(?:[-*]\s*)?(?:\*\*)?(MUST|NEVER|ALWAYS)\b/m;
|
|
@@ -6630,25 +6477,25 @@ function censusSkills(root) {
|
|
|
6630
6477
|
withTriggerCorpus: [],
|
|
6631
6478
|
withDeterministicObligation: []
|
|
6632
6479
|
};
|
|
6633
|
-
if (!
|
|
6480
|
+
if (!fs19.existsSync(root)) {
|
|
6634
6481
|
return out;
|
|
6635
6482
|
}
|
|
6636
|
-
for (const entry of
|
|
6483
|
+
for (const entry of fs19.readdirSync(root, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
6637
6484
|
if (!entry.isDirectory()) {
|
|
6638
6485
|
continue;
|
|
6639
6486
|
}
|
|
6640
|
-
const file =
|
|
6641
|
-
if (!
|
|
6487
|
+
const file = path16.join(root, entry.name, "SKILL.md");
|
|
6488
|
+
if (!fs19.existsSync(file)) {
|
|
6642
6489
|
continue;
|
|
6643
6490
|
}
|
|
6644
6491
|
out.total += 1;
|
|
6645
|
-
const text =
|
|
6492
|
+
const text = fs19.readFileSync(file, "utf8");
|
|
6646
6493
|
const fmEnd = text.startsWith("---") ? text.indexOf("\n---", 3) : -1;
|
|
6647
6494
|
const fm = fmEnd === -1 ? "" : text.slice(0, fmEnd);
|
|
6648
6495
|
if (TRIGGER_KEYS.some((k) => new RegExp(`^${k}`, "m").test(fm))) {
|
|
6649
6496
|
out.withTriggerKey.push(entry.name);
|
|
6650
6497
|
}
|
|
6651
|
-
if (
|
|
6498
|
+
if (fs19.existsSync(path16.join(root, entry.name, "evals", "triggers.json"))) {
|
|
6652
6499
|
out.withTriggerCorpus.push(entry.name);
|
|
6653
6500
|
}
|
|
6654
6501
|
const body = fmEnd === -1 ? text : text.slice(fmEnd + 4);
|
|
@@ -6659,17 +6506,17 @@ function censusSkills(root) {
|
|
|
6659
6506
|
return out;
|
|
6660
6507
|
}
|
|
6661
6508
|
function defaultStore2(cwd) {
|
|
6662
|
-
return
|
|
6509
|
+
return path16.join(os4.homedir(), ".claude", "projects", projectStoreSlug(cwd));
|
|
6663
6510
|
}
|
|
6664
6511
|
function measureUsage(store, limit) {
|
|
6665
6512
|
const rep = { store, sessions: 0, assistantTurns: 0, invocations: 0, bySkill: {} };
|
|
6666
|
-
if (!
|
|
6513
|
+
if (!fs19.existsSync(store)) {
|
|
6667
6514
|
return rep;
|
|
6668
6515
|
}
|
|
6669
|
-
const files =
|
|
6516
|
+
const files = fs19.readdirSync(store).filter((f) => f.endsWith(".jsonl")).map((f) => path16.join(store, f)).sort((a, b) => fs19.statSync(b).mtimeMs - fs19.statSync(a).mtimeMs).slice(0, limit);
|
|
6670
6517
|
rep.sessions = files.length;
|
|
6671
6518
|
for (const file of files) {
|
|
6672
|
-
for (const line of
|
|
6519
|
+
for (const line of fs19.readFileSync(file, "utf8").split("\n")) {
|
|
6673
6520
|
if (!line.trim()) {
|
|
6674
6521
|
continue;
|
|
6675
6522
|
}
|
|
@@ -6742,15 +6589,15 @@ function buildRecord(census, usage, today) {
|
|
|
6742
6589
|
assistant_turns: usage.reduce((a, u) => a + u.assistantTurns, 0),
|
|
6743
6590
|
invocations: usage.reduce((a, u) => a + u.invocations, 0),
|
|
6744
6591
|
distinct_skills_invoked: distinct.size,
|
|
6745
|
-
stores: usage.map((u) =>
|
|
6592
|
+
stores: usage.map((u) => path16.basename(u.store))
|
|
6746
6593
|
};
|
|
6747
6594
|
}
|
|
6748
6595
|
function readRecord(repoRoot) {
|
|
6749
|
-
const file =
|
|
6750
|
-
if (!
|
|
6596
|
+
const file = path16.join(repoRoot, RECORD_PATH);
|
|
6597
|
+
if (!fs19.existsSync(file)) {
|
|
6751
6598
|
return null;
|
|
6752
6599
|
}
|
|
6753
|
-
return JSON.parse(
|
|
6600
|
+
return JSON.parse(fs19.readFileSync(file, "utf8"));
|
|
6754
6601
|
}
|
|
6755
6602
|
function render3(census, usage, published = null) {
|
|
6756
6603
|
const lines = [];
|
|
@@ -6785,7 +6632,7 @@ function render3(census, usage, published = null) {
|
|
|
6785
6632
|
}
|
|
6786
6633
|
totalInv += u.invocations;
|
|
6787
6634
|
lines.push(
|
|
6788
|
-
` ${
|
|
6635
|
+
` ${path16.basename(u.store).slice(-38).padEnd(38)} sessions=${String(u.sessions).padStart(3)} asst=${String(u.assistantTurns).padStart(6)} Skill calls=${String(u.invocations).padStart(3)}`
|
|
6789
6636
|
);
|
|
6790
6637
|
}
|
|
6791
6638
|
lines.push("");
|
|
@@ -6856,7 +6703,7 @@ function render3(census, usage, published = null) {
|
|
|
6856
6703
|
return lines.join("\n");
|
|
6857
6704
|
}
|
|
6858
6705
|
var USAGE2 = "usage: report_skill_activation [--root DIR] [--limit N] [--store PATH]... [--emit] [--allow-empty-store]\n";
|
|
6859
|
-
function
|
|
6706
|
+
function main10(argv) {
|
|
6860
6707
|
let limit = 30;
|
|
6861
6708
|
let emit = false;
|
|
6862
6709
|
let allowEmpty = false;
|
|
@@ -6889,7 +6736,7 @@ function main11(argv) {
|
|
|
6889
6736
|
if (stores.length === 0) {
|
|
6890
6737
|
stores.push(defaultStore2(REPO_ROOT3));
|
|
6891
6738
|
}
|
|
6892
|
-
const census = censusSkills(
|
|
6739
|
+
const census = censusSkills(path16.join(root, SKILLS_ROOT));
|
|
6893
6740
|
const usage = stores.map((s) => measureUsage(s, limit));
|
|
6894
6741
|
process.stdout.write(`${render3(census, usage, readRecord(root))}
|
|
6895
6742
|
`);
|
|
@@ -6910,27 +6757,27 @@ function main11(argv) {
|
|
|
6910
6757
|
return 1;
|
|
6911
6758
|
}
|
|
6912
6759
|
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
6913
|
-
const file =
|
|
6914
|
-
|
|
6915
|
-
|
|
6760
|
+
const file = path16.join(root, RECORD_PATH);
|
|
6761
|
+
fs19.mkdirSync(path16.dirname(file), { recursive: true });
|
|
6762
|
+
fs19.writeFileSync(file, `${JSON.stringify(buildRecord(census, usage, today), null, 2)}
|
|
6916
6763
|
`);
|
|
6917
6764
|
process.stdout.write(`
|
|
6918
6765
|
wrote ${RECORD_PATH} (measured ${today})
|
|
6919
6766
|
`);
|
|
6920
6767
|
return 0;
|
|
6921
6768
|
}
|
|
6922
|
-
if (process.argv[1] !== void 0 && import.meta.url ===
|
|
6923
|
-
process.exit(
|
|
6769
|
+
if (process.argv[1] !== void 0 && import.meta.url === pathToFileURL10(path16.resolve(process.argv[1])).href) {
|
|
6770
|
+
process.exit(main10(process.argv.slice(2)));
|
|
6924
6771
|
}
|
|
6925
6772
|
|
|
6926
6773
|
// src/scripts/report_skill_obligation_violations.ts
|
|
6927
|
-
import * as
|
|
6774
|
+
import * as fs20 from "node:fs";
|
|
6928
6775
|
import * as os5 from "node:os";
|
|
6929
|
-
import * as
|
|
6776
|
+
import * as path17 from "node:path";
|
|
6930
6777
|
import process3 from "node:process";
|
|
6931
|
-
import { fileURLToPath as
|
|
6932
|
-
var _HERE4 =
|
|
6933
|
-
var REPO_ROOT4 =
|
|
6778
|
+
import { fileURLToPath as fileURLToPath11, pathToFileURL as pathToFileURL11 } from "node:url";
|
|
6779
|
+
var _HERE4 = fileURLToPath11(import.meta.url);
|
|
6780
|
+
var REPO_ROOT4 = path17.resolve(path17.dirname(_HERE4), "..", "..");
|
|
6934
6781
|
var OBLIGATION_LINE_RE = new RegExp(`${DETERMINISTIC_RE.source}.*`, "gm");
|
|
6935
6782
|
var PATH_RE = /`([A-Za-z0-9_./-]*\/[A-Za-z0-9_.-]+\.[a-z]{2,6})`/g;
|
|
6936
6783
|
var CMD_RE = /`([a-z][a-z0-9-]*(?: [a-z][a-z0-9:._-]*){1,3})`/g;
|
|
@@ -6968,7 +6815,7 @@ function _artefacts(line) {
|
|
|
6968
6815
|
return out;
|
|
6969
6816
|
}
|
|
6970
6817
|
function extractObligations(repoRoot) {
|
|
6971
|
-
const skillsRoot =
|
|
6818
|
+
const skillsRoot = path17.join(repoRoot, SKILLS_ROOT);
|
|
6972
6819
|
const census = censusSkills(skillsRoot);
|
|
6973
6820
|
const out = {
|
|
6974
6821
|
skills: census.withDeterministicObligation,
|
|
@@ -6982,7 +6829,7 @@ function extractObligations(repoRoot) {
|
|
|
6982
6829
|
for (const skill of census.withDeterministicObligation) {
|
|
6983
6830
|
let text;
|
|
6984
6831
|
try {
|
|
6985
|
-
text =
|
|
6832
|
+
text = fs20.readFileSync(path17.join(skillsRoot, skill, "SKILL.md"), "utf-8");
|
|
6986
6833
|
} catch {
|
|
6987
6834
|
continue;
|
|
6988
6835
|
}
|
|
@@ -7098,7 +6945,7 @@ function scanSessionForViolations(session, lines, forbidden, parsed) {
|
|
|
7098
6945
|
return flags;
|
|
7099
6946
|
}
|
|
7100
6947
|
function defaultStore3(cwd) {
|
|
7101
|
-
return
|
|
6948
|
+
return path17.join(os5.homedir(), ".claude", "projects", projectStoreSlug(cwd));
|
|
7102
6949
|
}
|
|
7103
6950
|
function scanStore2(repoRoot, store, limit) {
|
|
7104
6951
|
const census = extractObligations(repoRoot);
|
|
@@ -7111,14 +6958,14 @@ function scanStore2(repoRoot, store, limit) {
|
|
|
7111
6958
|
};
|
|
7112
6959
|
let files;
|
|
7113
6960
|
try {
|
|
7114
|
-
files =
|
|
6961
|
+
files = fs20.readdirSync(store).filter((f) => f.endsWith(".jsonl")).map((f) => ({ p: path17.join(store, f), m: fs20.statSync(path17.join(store, f)).mtimeMs })).sort((a, b) => b.m - a.m).slice(0, limit).map((x) => x.p);
|
|
7115
6962
|
} catch {
|
|
7116
6963
|
return report;
|
|
7117
6964
|
}
|
|
7118
6965
|
report.sessions = files.length;
|
|
7119
6966
|
for (const file of files) {
|
|
7120
|
-
const lines =
|
|
7121
|
-
const id =
|
|
6967
|
+
const lines = fs20.readFileSync(file, "utf-8").split("\n");
|
|
6968
|
+
const id = path17.basename(file).replace(/\.jsonl$/, "").slice(0, 8);
|
|
7122
6969
|
const entries = _parseSession(lines);
|
|
7123
6970
|
if (loadedSkillsFrom(entries).size > 0) report.sessionsWithASkill += 1;
|
|
7124
6971
|
report.flags.push(...scanSessionForViolations(id, lines, census.forbidden, entries));
|
|
@@ -7188,7 +7035,7 @@ function render4(r) {
|
|
|
7188
7035
|
lines.push(" ships as detection-only, and this one says so.");
|
|
7189
7036
|
return lines.join("\n");
|
|
7190
7037
|
}
|
|
7191
|
-
function
|
|
7038
|
+
function main11(argv) {
|
|
7192
7039
|
const args = argv ?? process3.argv.slice(2);
|
|
7193
7040
|
let limit = 30;
|
|
7194
7041
|
let json = false;
|
|
@@ -7241,35 +7088,35 @@ function main12(argv) {
|
|
|
7241
7088
|
}
|
|
7242
7089
|
return 0;
|
|
7243
7090
|
}
|
|
7244
|
-
function
|
|
7091
|
+
function _isCliEntry10() {
|
|
7245
7092
|
if (process3.argv[1] === void 0) return false;
|
|
7246
|
-
if (import.meta.url ===
|
|
7093
|
+
if (import.meta.url === pathToFileURL11(path17.resolve(process3.argv[1])).href) return true;
|
|
7247
7094
|
try {
|
|
7248
|
-
return
|
|
7095
|
+
return fs20.realpathSync(_HERE4) === fs20.realpathSync(path17.resolve(process3.argv[1]));
|
|
7249
7096
|
} catch {
|
|
7250
7097
|
return false;
|
|
7251
7098
|
}
|
|
7252
7099
|
}
|
|
7253
|
-
if (
|
|
7254
|
-
process3.exit(
|
|
7100
|
+
if (_isCliEntry10()) {
|
|
7101
|
+
process3.exit(main11());
|
|
7255
7102
|
}
|
|
7256
7103
|
|
|
7257
7104
|
// src/scripts/report_conformance_funnel.ts
|
|
7258
|
-
var _HERE5 =
|
|
7259
|
-
var REPO_ROOT5 =
|
|
7105
|
+
var _HERE5 = fileURLToPath12(import.meta.url);
|
|
7106
|
+
var REPO_ROOT5 = path18.resolve(path18.dirname(_HERE5), "..", "..");
|
|
7260
7107
|
function buildFunnel(opts = {}) {
|
|
7261
7108
|
const repoRoot = opts.repoRoot ?? REPO_ROOT5;
|
|
7262
|
-
const projectRulesDir = opts.projectRulesDir ??
|
|
7263
|
-
const globalRulesDir = opts.globalRulesDir ??
|
|
7264
|
-
const sourceDir = opts.sourceDir ??
|
|
7109
|
+
const projectRulesDir = opts.projectRulesDir ?? path18.join(repoRoot, PROJECT_RULES);
|
|
7110
|
+
const globalRulesDir = opts.globalRulesDir ?? path18.join(os6.homedir(), GLOBAL_RULES);
|
|
7111
|
+
const sourceDir = opts.sourceDir ?? path18.join(repoRoot, PROJECTION_SOURCE);
|
|
7265
7112
|
const store = opts.store ?? defaultStore(repoRoot);
|
|
7266
7113
|
const limit = opts.limit ?? 30;
|
|
7267
7114
|
return {
|
|
7268
7115
|
delivered: measureDelivered(projectRulesDir, globalRulesDir),
|
|
7269
7116
|
divergence: compareCarriers(projectRulesDir, globalRulesDir, sourceDir),
|
|
7270
|
-
skills: censusSkills(
|
|
7117
|
+
skills: censusSkills(path18.join(repoRoot, SKILLS_ROOT)),
|
|
7271
7118
|
usage: measureUsage(store, limit),
|
|
7272
|
-
storePresent:
|
|
7119
|
+
storePresent: fs21.existsSync(store),
|
|
7273
7120
|
sk2: scanStore2(repoRoot, store, limit)
|
|
7274
7121
|
};
|
|
7275
7122
|
}
|
|
@@ -7394,7 +7241,7 @@ function render5(r) {
|
|
|
7394
7241
|
lines.push("workflow without a measured false-positive rate first (locked policy).");
|
|
7395
7242
|
return lines.join("\n");
|
|
7396
7243
|
}
|
|
7397
|
-
function
|
|
7244
|
+
function main12(argv) {
|
|
7398
7245
|
const args = argv ?? process4.argv.slice(2);
|
|
7399
7246
|
const opts = {};
|
|
7400
7247
|
const value = (i) => {
|
|
@@ -7410,7 +7257,7 @@ function main13(argv) {
|
|
|
7410
7257
|
`);
|
|
7411
7258
|
return 1;
|
|
7412
7259
|
}
|
|
7413
|
-
const resolved =
|
|
7260
|
+
const resolved = path18.resolve(v);
|
|
7414
7261
|
if (a === "--store") opts.store = resolved;
|
|
7415
7262
|
else if (a === "--project") opts.projectRulesDir = resolved;
|
|
7416
7263
|
else if (a === "--global") opts.globalRulesDir = resolved;
|
|
@@ -7440,21 +7287,21 @@ function main13(argv) {
|
|
|
7440
7287
|
`);
|
|
7441
7288
|
return 0;
|
|
7442
7289
|
}
|
|
7443
|
-
function
|
|
7290
|
+
function _isCliEntry11() {
|
|
7444
7291
|
if (process4.argv[1] === void 0) return false;
|
|
7445
|
-
if (import.meta.url ===
|
|
7292
|
+
if (import.meta.url === pathToFileURL12(path18.resolve(process4.argv[1])).href) return true;
|
|
7446
7293
|
try {
|
|
7447
|
-
return
|
|
7294
|
+
return fs21.realpathSync(_HERE5) === fs21.realpathSync(path18.resolve(process4.argv[1]));
|
|
7448
7295
|
} catch {
|
|
7449
7296
|
return false;
|
|
7450
7297
|
}
|
|
7451
7298
|
}
|
|
7452
|
-
if (
|
|
7453
|
-
process4.exit(
|
|
7299
|
+
if (_isCliEntry11()) {
|
|
7300
|
+
process4.exit(main12());
|
|
7454
7301
|
}
|
|
7455
7302
|
|
|
7456
7303
|
// src/scripts/_cli/cmd_conformance.ts
|
|
7457
|
-
var _HERE6 =
|
|
7304
|
+
var _HERE6 = fileURLToPath13(import.meta.url);
|
|
7458
7305
|
var PACKAGE_ROOT = resolvePackageRoot(import.meta.url);
|
|
7459
7306
|
var CONFORMANCE_CHECK_IDS = [
|
|
7460
7307
|
"txlog-clean",
|
|
@@ -7481,20 +7328,20 @@ function conformanceLogPath() {
|
|
|
7481
7328
|
if (override && override.trim().length > 0) {
|
|
7482
7329
|
return override;
|
|
7483
7330
|
}
|
|
7484
|
-
return
|
|
7331
|
+
return path19.join(os7.homedir(), ".event4u", "agent-config", "conformance-log.jsonl");
|
|
7485
7332
|
}
|
|
7486
7333
|
function installLogPath() {
|
|
7487
7334
|
const override = process5.env["AGENT_CONFIG_INSTALL_LOG"];
|
|
7488
7335
|
if (override && override.trim().length > 0) {
|
|
7489
7336
|
return override;
|
|
7490
7337
|
}
|
|
7491
|
-
return
|
|
7338
|
+
return path19.join(os7.homedir(), ".event4u", "agent-config", "install-log.jsonl");
|
|
7492
7339
|
}
|
|
7493
7340
|
function _installLogExpected(projectRoot) {
|
|
7494
|
-
return
|
|
7341
|
+
return fs22.existsSync(manifest_path(projectRoot));
|
|
7495
7342
|
}
|
|
7496
7343
|
function _check_txlog_clean(logPath = installLogPath(), projectRoot = null) {
|
|
7497
|
-
const entries =
|
|
7344
|
+
const entries = fs22.existsSync(logPath) ? readRecentEntries(logPath) : [];
|
|
7498
7345
|
if (entries.length === 0) {
|
|
7499
7346
|
if (projectRoot !== null && _installLogExpected(projectRoot)) {
|
|
7500
7347
|
return {
|
|
@@ -7528,11 +7375,11 @@ function _check_txlog_clean(logPath = installLogPath(), projectRoot = null) {
|
|
|
7528
7375
|
};
|
|
7529
7376
|
}
|
|
7530
7377
|
function routeTargetPaths(target) {
|
|
7531
|
-
return routeTargetPathsPosix(target).map((
|
|
7378
|
+
return routeTargetPathsPosix(target).map((rel2) => path19.join(...rel2.split("/")));
|
|
7532
7379
|
}
|
|
7533
7380
|
function _check_router_pointers(packageRoot = PACKAGE_ROOT) {
|
|
7534
|
-
const routerPath =
|
|
7535
|
-
if (!
|
|
7381
|
+
const routerPath = path19.join(packageRoot, "dist", "router.json");
|
|
7382
|
+
if (!fs22.existsSync(routerPath)) {
|
|
7536
7383
|
return {
|
|
7537
7384
|
id: "router-pointers",
|
|
7538
7385
|
status: "fail",
|
|
@@ -7542,7 +7389,7 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT) {
|
|
|
7542
7389
|
}
|
|
7543
7390
|
let router;
|
|
7544
7391
|
try {
|
|
7545
|
-
router = JSON.parse(
|
|
7392
|
+
router = JSON.parse(fs22.readFileSync(routerPath, "utf8"));
|
|
7546
7393
|
} catch (exc) {
|
|
7547
7394
|
return {
|
|
7548
7395
|
id: "router-pointers",
|
|
@@ -7551,13 +7398,13 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT) {
|
|
|
7551
7398
|
remedy: "reinstall the package \u2014 dist/router.json is corrupt"
|
|
7552
7399
|
};
|
|
7553
7400
|
}
|
|
7554
|
-
const rulesDir =
|
|
7401
|
+
const rulesDir = path19.join(packageRoot, "dist", "agent-src", "rules");
|
|
7555
7402
|
const broken = [];
|
|
7556
7403
|
let ids = 0;
|
|
7557
7404
|
let targets = 0;
|
|
7558
7405
|
for (const kernelId of router["kernel"] ?? []) {
|
|
7559
7406
|
ids += 1;
|
|
7560
|
-
if (!
|
|
7407
|
+
if (!fs22.existsSync(path19.join(rulesDir, `${kernelId}.md`))) {
|
|
7561
7408
|
broken.push(`kernel:${kernelId} \u2192 rules/${kernelId}.md missing`);
|
|
7562
7409
|
}
|
|
7563
7410
|
}
|
|
@@ -7565,7 +7412,7 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT) {
|
|
|
7565
7412
|
for (const entry of router[tier] ?? []) {
|
|
7566
7413
|
const ruleId = String(entry["id"] ?? "");
|
|
7567
7414
|
ids += 1;
|
|
7568
|
-
if (!
|
|
7415
|
+
if (!fs22.existsSync(path19.join(rulesDir, `${ruleId}.md`))) {
|
|
7569
7416
|
broken.push(`${tier}:${ruleId} \u2192 rules/${ruleId}.md missing`);
|
|
7570
7417
|
}
|
|
7571
7418
|
for (const target of entry["routes_to"] ?? []) {
|
|
@@ -7575,7 +7422,7 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT) {
|
|
|
7575
7422
|
broken.push(`${ruleId} \u2192 unparseable routes_to ${JSON.stringify(target)}`);
|
|
7576
7423
|
continue;
|
|
7577
7424
|
}
|
|
7578
|
-
if (!candidates.some((
|
|
7425
|
+
if (!candidates.some((rel2) => fs22.existsSync(path19.join(packageRoot, rel2)))) {
|
|
7579
7426
|
broken.push(`${ruleId} \u2192 ${target} (${candidates[0]} missing)`);
|
|
7580
7427
|
}
|
|
7581
7428
|
}
|
|
@@ -7607,9 +7454,9 @@ function detectSmokePlatform(projectRoot) {
|
|
|
7607
7454
|
return "claude";
|
|
7608
7455
|
}
|
|
7609
7456
|
function dispatcherRunner(packageRoot) {
|
|
7610
|
-
const localTsx =
|
|
7611
|
-
const script =
|
|
7612
|
-
if (
|
|
7457
|
+
const localTsx = path19.join(packageRoot, "node_modules", ".bin", "tsx");
|
|
7458
|
+
const script = path19.join(packageRoot, "src", "scripts", "hooks", "dispatch_hook.ts");
|
|
7459
|
+
if (fs22.existsSync(localTsx)) {
|
|
7613
7460
|
return [localTsx, script];
|
|
7614
7461
|
}
|
|
7615
7462
|
return ["npx", "tsx", script];
|
|
@@ -7659,12 +7506,12 @@ function _check_hook_dispatcher(projectRoot, packageRoot = PACKAGE_ROOT, opts =
|
|
|
7659
7506
|
};
|
|
7660
7507
|
}
|
|
7661
7508
|
function readSettingsMode(projectRoot) {
|
|
7662
|
-
const settingsPath =
|
|
7663
|
-
if (!
|
|
7509
|
+
const settingsPath = path19.join(projectRoot, ".agent-settings.yml");
|
|
7510
|
+
if (!fs22.existsSync(settingsPath)) {
|
|
7664
7511
|
return "eager-all";
|
|
7665
7512
|
}
|
|
7666
7513
|
try {
|
|
7667
|
-
const parsed = YAML.parse(
|
|
7514
|
+
const parsed = YAML.parse(fs22.readFileSync(settingsPath, "utf8"));
|
|
7668
7515
|
const lean = parsed?.["lean_projection"] ?? null;
|
|
7669
7516
|
const mode = lean?.["mode"];
|
|
7670
7517
|
return typeof mode === "string" && mode.length > 0 ? mode : "eager-all";
|
|
@@ -7675,7 +7522,7 @@ function readSettingsMode(projectRoot) {
|
|
|
7675
7522
|
function kernelIdsFromRouter(packageRoot) {
|
|
7676
7523
|
try {
|
|
7677
7524
|
const router = JSON.parse(
|
|
7678
|
-
|
|
7525
|
+
fs22.readFileSync(path19.join(packageRoot, "dist", "router.json"), "utf8")
|
|
7679
7526
|
);
|
|
7680
7527
|
return new Set((router["kernel"] ?? []).map(String));
|
|
7681
7528
|
} catch {
|
|
@@ -7692,8 +7539,8 @@ function _check_lean_projection(projectRoot, packageRoot = PACKAGE_ROOT, project
|
|
|
7692
7539
|
remedy: "set lean_projection.mode to 'eager-all' or 'thin' in .agent-settings.yml"
|
|
7693
7540
|
};
|
|
7694
7541
|
}
|
|
7695
|
-
const rulesDir = projectedRulesDir ??
|
|
7696
|
-
if (!
|
|
7542
|
+
const rulesDir = projectedRulesDir ?? path19.join(projectRoot, ".augment", "rules");
|
|
7543
|
+
if (!fs22.existsSync(rulesDir)) {
|
|
7697
7544
|
return {
|
|
7698
7545
|
id: "lean-projection",
|
|
7699
7546
|
status: "skipped",
|
|
@@ -7702,7 +7549,7 @@ function _check_lean_projection(projectRoot, packageRoot = PACKAGE_ROOT, project
|
|
|
7702
7549
|
};
|
|
7703
7550
|
}
|
|
7704
7551
|
const kernel = kernelIdsFromRouter(packageRoot);
|
|
7705
|
-
const files =
|
|
7552
|
+
const files = fs22.readdirSync(rulesDir).filter((f) => f.endsWith(".md") && f !== "INDEX.md").sort();
|
|
7706
7553
|
const nonKernel = files.filter((f) => !kernel.has(f.replace(/\.md$/, "")));
|
|
7707
7554
|
if (nonKernel.length === 0) {
|
|
7708
7555
|
return {
|
|
@@ -7716,7 +7563,7 @@ function _check_lean_projection(projectRoot, packageRoot = PACKAGE_ROOT, project
|
|
|
7716
7563
|
for (const f of nonKernel) {
|
|
7717
7564
|
let text = "";
|
|
7718
7565
|
try {
|
|
7719
|
-
text =
|
|
7566
|
+
text = fs22.readFileSync(path19.join(rulesDir, f), "utf8");
|
|
7720
7567
|
} catch {
|
|
7721
7568
|
continue;
|
|
7722
7569
|
}
|
|
@@ -7747,8 +7594,8 @@ function _check_lean_projection(projectRoot, packageRoot = PACKAGE_ROOT, project
|
|
|
7747
7594
|
function _check_host_manifest(projectRoot) {
|
|
7748
7595
|
const detected = Object.entries(detectToolPresence(projectRoot)).filter(([, v]) => v === true).map(([k]) => k);
|
|
7749
7596
|
const detectedNote = detected.length > 0 ? `detected surfaces: ${detected.join(", ")}` : "no surfaces detected";
|
|
7750
|
-
const settingsPath =
|
|
7751
|
-
if (!
|
|
7597
|
+
const settingsPath = path19.join(projectRoot, ".agent-settings.yml");
|
|
7598
|
+
if (!fs22.existsSync(settingsPath)) {
|
|
7752
7599
|
return {
|
|
7753
7600
|
id: "host-manifest",
|
|
7754
7601
|
status: "ok",
|
|
@@ -7758,7 +7605,7 @@ function _check_host_manifest(projectRoot) {
|
|
|
7758
7605
|
}
|
|
7759
7606
|
let parsed = null;
|
|
7760
7607
|
try {
|
|
7761
|
-
parsed = YAML.parse(
|
|
7608
|
+
parsed = YAML.parse(fs22.readFileSync(settingsPath, "utf8"));
|
|
7762
7609
|
} catch (exc) {
|
|
7763
7610
|
return {
|
|
7764
7611
|
id: "host-manifest",
|
|
@@ -7857,7 +7704,7 @@ function _parse(argv) {
|
|
|
7857
7704
|
}
|
|
7858
7705
|
return opts;
|
|
7859
7706
|
}
|
|
7860
|
-
function
|
|
7707
|
+
function main13(argv = null) {
|
|
7861
7708
|
const opts = _parse(argv !== null ? Array.from(argv) : process5.argv.slice(2));
|
|
7862
7709
|
if (opts.funnel) {
|
|
7863
7710
|
print(render5(buildFunnel()));
|
|
@@ -7928,25 +7775,25 @@ function main14(argv = null) {
|
|
|
7928
7775
|
}
|
|
7929
7776
|
return failed ? 1 : 0;
|
|
7930
7777
|
}
|
|
7931
|
-
function
|
|
7778
|
+
function _isCliEntry12() {
|
|
7932
7779
|
if (process5.argv[1] === void 0) {
|
|
7933
7780
|
return false;
|
|
7934
7781
|
}
|
|
7935
|
-
const argvUrl =
|
|
7782
|
+
const argvUrl = pathToFileURL13(path19.resolve(process5.argv[1])).href;
|
|
7936
7783
|
if (import.meta.url === argvUrl) {
|
|
7937
7784
|
return true;
|
|
7938
7785
|
}
|
|
7939
7786
|
try {
|
|
7940
|
-
const here =
|
|
7941
|
-
const argv =
|
|
7787
|
+
const here = fs22.realpathSync(fileURLToPath13(import.meta.url));
|
|
7788
|
+
const argv = fs22.realpathSync(path19.resolve(process5.argv[1]));
|
|
7942
7789
|
return here === argv;
|
|
7943
7790
|
} catch {
|
|
7944
7791
|
return false;
|
|
7945
7792
|
}
|
|
7946
7793
|
}
|
|
7947
|
-
if (
|
|
7794
|
+
if (_isCliEntry12() || process5.argv[1] === _HERE6) {
|
|
7948
7795
|
try {
|
|
7949
|
-
process5.exitCode =
|
|
7796
|
+
process5.exitCode = main13(process5.argv.slice(2));
|
|
7950
7797
|
} catch (e) {
|
|
7951
7798
|
if (e instanceof ArgparseExit) {
|
|
7952
7799
|
process5.exitCode = e.code;
|
|
@@ -7970,7 +7817,7 @@ export {
|
|
|
7970
7817
|
conformanceLogPath,
|
|
7971
7818
|
detectSmokePlatform,
|
|
7972
7819
|
installLogPath,
|
|
7973
|
-
|
|
7820
|
+
main13 as main,
|
|
7974
7821
|
routeTargetPaths,
|
|
7975
7822
|
runConformanceChecks
|
|
7976
7823
|
};
|