@event4u/agent-config 16.5.0 → 17.1.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 +114 -530
- package/CONTRIBUTING.md +47 -0
- package/README.md +25 -24
- package/dist/agent-src/commands/{design.md → agent-design.md} +10 -6
- 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 +10 -2
- 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 +5 -0
- 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 +1 -1
- 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/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 +12 -2
- 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 +14 -14
- 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 +16 -2
- 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/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/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 +9 -3
- 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 +7 -1
- 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/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 +44 -2
- 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 +72 -17
- package/dist/cli/commands/uiRenderAsset.js +10 -2
- package/dist/cli/commands/uiRenderAssetFonts.js +158 -0
- package/dist/cli/commands/uiRenderAssetTypes.js +8 -20
- package/dist/cli/initRouting.js +1 -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 +4 -1
- 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-TMWYUOK4.js → chunk-2CX7NWRB.js} +224 -437
- package/dist/cli-delegate/chunk-2Y5AMLMY.js +136 -0
- package/dist/cli-delegate/chunk-3PK3VZHB.js +235 -0
- package/dist/cli-delegate/{chunk-OKJUIAPS.js → chunk-4E2W63DA.js} +1 -62
- 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-F3QDG2GT.js → chunk-BZJ4Y3CI.js} +259 -159
- package/dist/cli-delegate/{chunk-5GPULQBE.js → chunk-CMZEKSNN.js} +4280 -705
- package/dist/cli-delegate/chunk-DSY6LLCQ.js +127 -0
- package/dist/cli-delegate/{chunk-ZUZKZYCN.js → chunk-E3CFULNX.js} +67 -13
- 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-I4KJYVPB.js +69 -0
- package/dist/cli-delegate/{chunk-JQOM7TTM.js → chunk-IDAOTDPE.js} +1 -100
- package/dist/cli-delegate/chunk-J2SJZICO.js +698 -0
- package/dist/cli-delegate/chunk-KR5ZIFPO.js +581 -0
- 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-QBHEI5N4.js +919 -0
- package/dist/cli-delegate/{chunk-F7DQWYR5.js → chunk-RAXQOETZ.js} +6 -2
- 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-T7XSJSUQ.js → chunk-VYZGJLCA.js} +1000 -814
- package/dist/cli-delegate/chunk-W5JXMF2T.js +77 -0
- 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-6SRJTYJS.js → chunk-XIAPY44N.js} +37 -16
- package/dist/cli-delegate/{chunk-H76PHZBI.js → chunk-XLY5G3CM.js} +14 -19
- package/dist/cli-delegate/{chunk-6YQC2HLF.js → chunk-YHAPONWV.js} +54 -40
- 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 +487 -820
- 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 +15 -12
- package/dist/cli-delegate/cmd_fleet.js +6 -4
- 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 +8 -6
- package/dist/cli-delegate/cmd_prune.js +17 -14
- 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 +15 -12
- package/dist/cli-delegate/cmd_settings_set.js +1 -1
- package/dist/cli-delegate/cmd_sync.js +17 -14
- package/dist/cli-delegate/cmd_uninstall.js +186 -32
- package/dist/cli-delegate/cmd_update.js +76 -16
- package/dist/cli-delegate/cmd_upgrade.js +38 -7
- package/dist/cli-delegate/cmd_validate.js +17 -14
- 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 +373 -190
- package/dist/discovery/discovery-manifest.json.sha256 +1 -1
- package/dist/discovery/discovery-manifest.summary.md +5 -5
- package/dist/discovery/dormancy-report.md +1 -1
- package/dist/discovery/orphan-report.md +1 -1
- package/dist/discovery/packs.json +21 -16
- package/dist/discovery/trust-report.md +3 -3
- package/dist/discovery/workspaces.json +16 -11
- package/dist/hooks/chat_history.chunk.cjs +6852 -0
- package/dist/hooks/chat_history.chunk.cjs.sha256 +1 -0
- package/dist/hooks/dispatch.js +17450 -18612
- 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 +281 -49
- package/dist/hooks/svg_rules.chunk.cjs.sha256 +1 -1
- package/dist/install/claudeRuleRewrite.js +10 -3
- package/dist/install/conflict.js +59 -7
- package/dist/install/conflictTracker.js +93 -8
- package/dist/install/detect.js +3 -3
- package/dist/install/hostPermissionsAdapter.js +106 -0
- package/dist/install/install.mjs +3234 -1961
- package/dist/install/installThinLayer.js +2 -1
- package/dist/install/loggedWrites.js +142 -0
- 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/paths.js +12 -2
- package/dist/install/plan.js +1 -1
- package/dist/install/preflight.js +39 -8
- package/dist/install/preserve.js +96 -13
- 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/txlog.js +10 -6
- 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 +10716 -5880
- 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 +769 -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 +57 -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/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_filled_counter.js +285 -0
- package/dist/scripts/_lib/svg_rules.js +2 -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 +33 -0
- package/dist/scripts/ai_council/transport_resolver.js +9 -10
- package/dist/scripts/condense.js +25 -29
- 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 +5 -0
- 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 +13 -4
- 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 +45 -1
- 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 +176 -10
- package/src/config/gate-reachability-exemptions.json +3 -5
- package/src/config/gate-violation-baselines.json +32 -22
- 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/production-entries.json +18 -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/release-gate-locality.yml +0 -7
- package/src/config/roadmap-step-size-baseline.json +118 -0
- package/src/config/routing-coverage-seed.json +93 -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/claudeRuleRewrite.ts +10 -1
- package/src/install/conflict.ts +61 -6
- package/src/install/conflictTracker.ts +143 -9
- package/src/install/detect.ts +3 -3
- package/src/install/hostPermissionsAdapter.ts +136 -0
- package/src/install/installThinLayer.ts +12 -1
- package/src/install/loggedWrites.ts +148 -0
- 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/paths.ts +11 -2
- package/src/install/plan.ts +1 -1
- package/src/install/preflight.ts +42 -10
- package/src/install/preserve.ts +131 -13
- 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/txlog.ts +10 -6
- 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_conformance.ts +3 -2
- 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 +49 -18
- 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/council_settings_block.ts +9 -2
- 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 +899 -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 +44 -7
- 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 +62 -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/price_freshness.ts +112 -0
- package/src/scripts/_lib/procedure_checks.ts +5 -0
- package/src/scripts/_lib/production_reach.ts +194 -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 +29 -14
- 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 +36 -311
- 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_filled_counter.ts +287 -0
- package/src/scripts/_lib/svg_rules.ts +2 -0
- package/src/scripts/_lib/test_delta.ts +89 -6
- package/src/scripts/_lib/tier_downshift_verdict.ts +268 -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/verify_clause.ts +4 -2
- 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 +20 -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 +56 -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 +288 -0
- package/src/scripts/ai_council/free_route.ts +216 -0
- package/src/scripts/ai_council/free_route_catalog.ts +310 -0
- package/src/scripts/ai_council/free_route_client.ts +99 -0
- package/src/scripts/ai_council/free_rung.ts +61 -0
- package/src/scripts/ai_council/hand_payload.ts +338 -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 +23 -26
- 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 +114 -0
- package/src/scripts/ai_council/seat_policy.ts +47 -0
- package/src/scripts/ai_council/seat_resume.ts +40 -0
- package/src/scripts/ai_council/self_hosted_probe.ts +327 -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 +39 -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 +406 -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 +174 -73
- 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 +8 -3
- 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_production_reach.ts +257 -0
- 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 +56 -44
- 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 +68 -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 +38 -7
- 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 +42 -10
- package/src/scripts/hooks/dispatch_hook.ts +14 -13
- 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 +43 -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 +162 -10
- package/src/scripts/hooks/state_io.ts +2 -2
- package/src/scripts/hooks/subagent_ledger_hook.ts +80 -0
- package/src/scripts/hooks/svg_obligation.ts +75 -19
- package/src/scripts/hooks/tool_result_bytes_hook.ts +14 -5
- package/src/scripts/hooks/turn_end_gate_hook.ts +1 -1
- 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 +61 -92
- 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 +144 -16
- package/src/scripts/lint_consumer_internal_refs.ts +90 -42
- package/src/scripts/lint_context_spine_usage.ts +21 -0
- package/src/scripts/lint_decision_classes.ts +34 -0
- package/src/scripts/lint_design_antipattern_parity.ts +39 -7
- 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 +118 -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_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 +114 -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_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 +31 -64
- package/src/scripts/release_drill.ts +63 -188
- package/src/scripts/release_env.ts +37 -0
- package/src/scripts/release_publication.ts +11 -10
- package/src/scripts/report_consumer_gate_reach.ts +233 -0
- package/src/scripts/report_merge_gate_load.ts +295 -0
- package/src/scripts/report_production_reach.ts +35 -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 +519 -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-4DBG5K7M.js +0 -1123
- package/dist/cli-delegate/chunk-523HCFYO.js +0 -90
- package/dist/cli-delegate/chunk-A4QJ6ENT.js +0 -50
- 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-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,34 +1,40 @@
|
|
|
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-YHAPONWV.js";
|
|
7
|
+
import "./chunk-LF2KKJ4Q.js";
|
|
6
8
|
import {
|
|
7
|
-
detectToolPresence
|
|
8
|
-
|
|
9
|
+
detectToolPresence,
|
|
10
|
+
getLogPath
|
|
11
|
+
} from "./chunk-W5JXMF2T.js";
|
|
9
12
|
import {
|
|
10
13
|
NO_RED_EVIDENCE_REASON,
|
|
14
|
+
RENDER_REL,
|
|
11
15
|
deriveSessionKey,
|
|
12
16
|
describeRecordFinding,
|
|
13
17
|
foldRefusal,
|
|
14
18
|
foldShadow,
|
|
19
|
+
hasInstrumentGap,
|
|
15
20
|
hasRedThenGreen,
|
|
16
|
-
isAssetRenderCommand,
|
|
17
21
|
isCiPoll,
|
|
22
|
+
isPureRender,
|
|
18
23
|
isVacuousOutput,
|
|
19
24
|
isVerificationAttempt,
|
|
20
25
|
parseRecord,
|
|
21
26
|
parseShadowRecord,
|
|
22
27
|
pendingCount,
|
|
28
|
+
readAssetRenderRecords,
|
|
23
29
|
readInstallBoundary,
|
|
24
30
|
readRunEvidence,
|
|
25
31
|
readTurnRunState,
|
|
32
|
+
recordedManifest,
|
|
26
33
|
sessionRefusalFile,
|
|
27
34
|
sessionShadowFile,
|
|
28
35
|
shadowSetBy,
|
|
29
|
-
statePathFor
|
|
30
|
-
|
|
31
|
-
} from "./chunk-TMWYUOK4.js";
|
|
36
|
+
statePathFor
|
|
37
|
+
} from "./chunk-2CX7NWRB.js";
|
|
32
38
|
import {
|
|
33
39
|
LexicalIndex,
|
|
34
40
|
isSqliteAvailableSync,
|
|
@@ -43,7 +49,6 @@ import {
|
|
|
43
49
|
_classify,
|
|
44
50
|
_collect_manifest_entries,
|
|
45
51
|
_foreign_records,
|
|
46
|
-
_is_global_only_consumer,
|
|
47
52
|
_jsonDumpsIndentAscii,
|
|
48
53
|
_resolve_project_root,
|
|
49
54
|
_run_checks,
|
|
@@ -52,25 +57,38 @@ import {
|
|
|
52
57
|
censusRuleDir,
|
|
53
58
|
comparePair,
|
|
54
59
|
frontmatterPaths,
|
|
60
|
+
openRecordStats,
|
|
55
61
|
proseEqual,
|
|
56
62
|
resolveSessionRole,
|
|
57
63
|
splitFrontmatter
|
|
58
|
-
} from "./chunk-
|
|
59
|
-
import
|
|
60
|
-
|
|
64
|
+
} from "./chunk-CMZEKSNN.js";
|
|
65
|
+
import {
|
|
66
|
+
_is_global_only_consumer
|
|
67
|
+
} from "./chunk-2Y5AMLMY.js";
|
|
61
68
|
import "./chunk-ROYYTEZU.js";
|
|
62
69
|
import "./chunk-BTWUYDGN.js";
|
|
70
|
+
import "./chunk-UUYEKXKR.js";
|
|
71
|
+
import "./chunk-FTAISGDQ.js";
|
|
72
|
+
import "./chunk-5VO3RTMV.js";
|
|
73
|
+
import "./chunk-6V6TA25H.js";
|
|
74
|
+
import "./chunk-AX3U3UWJ.js";
|
|
63
75
|
import {
|
|
64
76
|
atomicAppendLine,
|
|
65
77
|
probeHostCapabilities
|
|
66
|
-
} from "./chunk-
|
|
67
|
-
import "./chunk-
|
|
78
|
+
} from "./chunk-QBHEI5N4.js";
|
|
79
|
+
import "./chunk-7DRWULEQ.js";
|
|
68
80
|
import "./chunk-ULQRUR23.js";
|
|
69
81
|
import {
|
|
70
|
-
hardenedSpawnEnv
|
|
82
|
+
hardenedSpawnEnv
|
|
83
|
+
} from "./chunk-I4KJYVPB.js";
|
|
84
|
+
import {
|
|
85
|
+
EXIT_ALLOW,
|
|
86
|
+
EXIT_BLOCK,
|
|
87
|
+
EXIT_WARN,
|
|
71
88
|
projectStoreSlug
|
|
72
|
-
} from "./chunk-
|
|
89
|
+
} from "./chunk-FKYZOWVD.js";
|
|
73
90
|
import "./chunk-IAYTIIQW.js";
|
|
91
|
+
import "./chunk-PV7S5DPJ.js";
|
|
74
92
|
import "./chunk-LQOCRFWT.js";
|
|
75
93
|
import {
|
|
76
94
|
atomic_write_json,
|
|
@@ -82,35 +100,42 @@ import {
|
|
|
82
100
|
prune_stale_session_states,
|
|
83
101
|
session_state_file
|
|
84
102
|
} from "./chunk-7HKRE54K.js";
|
|
85
|
-
import
|
|
103
|
+
import {
|
|
104
|
+
load_agent_settings
|
|
105
|
+
} from "./chunk-XLY5G3CM.js";
|
|
106
|
+
import "./chunk-BZJ4Y3CI.js";
|
|
107
|
+
import "./chunk-FIEEOH5C.js";
|
|
108
|
+
import "./chunk-KR5ZIFPO.js";
|
|
109
|
+
import {
|
|
110
|
+
artefact_roots
|
|
111
|
+
} from "./chunk-YCU3TIXH.js";
|
|
86
112
|
import "./chunk-DEIV7XP7.js";
|
|
113
|
+
import "./chunk-J2SJZICO.js";
|
|
87
114
|
import {
|
|
88
115
|
manifest_path,
|
|
89
116
|
read_manifest
|
|
90
|
-
} from "./chunk-
|
|
91
|
-
import
|
|
92
|
-
|
|
117
|
+
} from "./chunk-4E2W63DA.js";
|
|
118
|
+
import {
|
|
119
|
+
parseRouteFields,
|
|
120
|
+
resolveRouteTransport
|
|
121
|
+
} from "./chunk-M6CRG5O6.js";
|
|
93
122
|
import "./chunk-MWRD5YOH.js";
|
|
94
|
-
import "./chunk-
|
|
123
|
+
import "./chunk-BMGUGSY6.js";
|
|
124
|
+
import {
|
|
125
|
+
readHookStdin
|
|
126
|
+
} from "./chunk-RAXQOETZ.js";
|
|
127
|
+
import "./chunk-IDAOTDPE.js";
|
|
95
128
|
import {
|
|
96
129
|
DeadScopeError,
|
|
97
130
|
assertScanned,
|
|
98
131
|
reportScanned
|
|
99
132
|
} from "./chunk-I3EIN2YG.js";
|
|
100
|
-
import {
|
|
101
|
-
readHookStdin
|
|
102
|
-
} from "./chunk-F7DQWYR5.js";
|
|
103
133
|
import {
|
|
104
134
|
require_dist
|
|
105
135
|
} from "./chunk-OY53J6II.js";
|
|
106
|
-
import "./chunk-LF2KKJ4Q.js";
|
|
107
136
|
import {
|
|
108
|
-
|
|
109
|
-
} from "./chunk-
|
|
110
|
-
import {
|
|
111
|
-
artefact_roots
|
|
112
|
-
} from "./chunk-YCU3TIXH.js";
|
|
113
|
-
import "./chunk-T6BP34WI.js";
|
|
137
|
+
resolve_with_fallback
|
|
138
|
+
} from "./chunk-T6BP34WI.js";
|
|
114
139
|
import {
|
|
115
140
|
resolvePackageRoot
|
|
116
141
|
} from "./chunk-MCJYCQPF.js";
|
|
@@ -120,12 +145,12 @@ import {
|
|
|
120
145
|
|
|
121
146
|
// src/scripts/_cli/cmd_conformance.ts
|
|
122
147
|
var YAML = __toESM(require_dist(), 1);
|
|
123
|
-
import * as
|
|
148
|
+
import * as fs22 from "node:fs";
|
|
124
149
|
import * as os7 from "node:os";
|
|
125
150
|
import * as path19 from "node:path";
|
|
126
151
|
import process5 from "node:process";
|
|
127
152
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
128
|
-
import { fileURLToPath as
|
|
153
|
+
import { fileURLToPath as fileURLToPath13, pathToFileURL as pathToFileURL13 } from "node:url";
|
|
129
154
|
|
|
130
155
|
// src/scripts/router_target_paths.mjs
|
|
131
156
|
var ROUTE_TARGET_TEMPLATES = Object.freeze({
|
|
@@ -153,18 +178,18 @@ function routeTargetPathsPosix(target) {
|
|
|
153
178
|
}
|
|
154
179
|
|
|
155
180
|
// src/scripts/report_conformance_funnel.ts
|
|
156
|
-
import * as
|
|
181
|
+
import * as fs21 from "node:fs";
|
|
157
182
|
import * as os6 from "node:os";
|
|
158
183
|
import * as path18 from "node:path";
|
|
159
184
|
import process4 from "node:process";
|
|
160
|
-
import { fileURLToPath as
|
|
185
|
+
import { fileURLToPath as fileURLToPath12, pathToFileURL as pathToFileURL12 } from "node:url";
|
|
161
186
|
|
|
162
187
|
// src/scripts/conformance_scan.ts
|
|
163
|
-
import { createHash as
|
|
164
|
-
import
|
|
188
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
189
|
+
import fs17 from "node:fs";
|
|
165
190
|
import os2 from "node:os";
|
|
166
191
|
import path14 from "node:path";
|
|
167
|
-
import { fileURLToPath as
|
|
192
|
+
import { fileURLToPath as fileURLToPath8, pathToFileURL as pathToFileURL8 } from "node:url";
|
|
168
193
|
|
|
169
194
|
// src/scripts/_lib/transcript_entry.ts
|
|
170
195
|
function _isObject(v) {
|
|
@@ -211,8 +236,9 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
211
236
|
// src/scripts/_lib/prompt_shape.ts
|
|
212
237
|
function isSyntheticPrompt(prompt) {
|
|
213
238
|
const head = prompt.trimStart().slice(0, 400);
|
|
214
|
-
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);
|
|
239
|
+
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);
|
|
215
240
|
}
|
|
241
|
+
var AGENT_MESSAGE_FRAME = /^Another Claude session sent a message:\s*\n\s*<(?:agent-message|cross-session-message)\b/;
|
|
216
242
|
var DOCUMENT_HEAD = /^\s*(#{1,6}\s|-{3,}\s*$|={3,}\s*$|<[A-Za-z][\w-]*>\s*$)/;
|
|
217
243
|
function humanAuthoredLead(text) {
|
|
218
244
|
const kept = [];
|
|
@@ -263,8 +289,8 @@ function stripInjectedRegions(text) {
|
|
|
263
289
|
}
|
|
264
290
|
|
|
265
291
|
// src/scripts/language_mirror_hook.ts
|
|
266
|
-
var
|
|
267
|
-
var
|
|
292
|
+
var EXIT_ALLOW2 = 0;
|
|
293
|
+
var EXIT_WARN2 = 2;
|
|
268
294
|
var STATE_FILE = path.join("agents", "state", "language-mirror.json");
|
|
269
295
|
var STATE_DIR = path.join("agents", "state", "language-mirror");
|
|
270
296
|
var STATE_RETENTION_DAYS = 7;
|
|
@@ -464,24 +490,24 @@ function _clearPinLost(consumer_root, session_id) {
|
|
|
464
490
|
}
|
|
465
491
|
function _reEmitAfterCompaction(consumer_root, session_id, write_json = atomic_write_json) {
|
|
466
492
|
if (!hasStableSessionId(session_id)) {
|
|
467
|
-
return
|
|
493
|
+
return EXIT_ALLOW2;
|
|
468
494
|
}
|
|
469
495
|
if (!_pinLost(consumer_root, session_id)) {
|
|
470
|
-
return
|
|
496
|
+
return EXIT_ALLOW2;
|
|
471
497
|
}
|
|
472
|
-
return _withToolWriteLock(consumer_root, session_id,
|
|
498
|
+
return _withToolWriteLock(consumer_root, session_id, EXIT_ALLOW2, () => {
|
|
473
499
|
const previous = _loadState(path.join(consumer_root, statePathFor2(session_id)));
|
|
474
500
|
const language = previous.language;
|
|
475
501
|
const source = previous.source === "system-locale" ? "system-locale" : "prompt";
|
|
476
502
|
_clearPinLost(consumer_root, session_id);
|
|
477
503
|
if (language !== "de" && language !== "en") {
|
|
478
|
-
return
|
|
504
|
+
return EXIT_ALLOW2;
|
|
479
505
|
}
|
|
480
506
|
if (!_ownsPin(previous, session_id)) {
|
|
481
|
-
return
|
|
507
|
+
return EXIT_ALLOW2;
|
|
482
508
|
}
|
|
483
509
|
if (!_resetDistance(consumer_root, previous, session_id, write_json)) {
|
|
484
|
-
return
|
|
510
|
+
return EXIT_ALLOW2;
|
|
485
511
|
}
|
|
486
512
|
process.stdout.write(
|
|
487
513
|
`${JSON.stringify({
|
|
@@ -491,7 +517,7 @@ function _reEmitAfterCompaction(consumer_root, session_id, write_json = atomic_w
|
|
|
491
517
|
})}
|
|
492
518
|
`
|
|
493
519
|
);
|
|
494
|
-
return
|
|
520
|
+
return EXIT_WARN2;
|
|
495
521
|
});
|
|
496
522
|
}
|
|
497
523
|
function _pruneLegacyState(consumer_root) {
|
|
@@ -571,19 +597,19 @@ function _resetDistance(consumer_root, expected, session_id, write_json = atomic
|
|
|
571
597
|
}
|
|
572
598
|
function _reEmitAfterDistance(consumer_root, session_id, write_json = atomic_write_json) {
|
|
573
599
|
if (is_replay_mode()) {
|
|
574
|
-
return
|
|
600
|
+
return EXIT_ALLOW2;
|
|
575
601
|
}
|
|
576
602
|
if (!hasStableSessionId(session_id)) {
|
|
577
|
-
return
|
|
603
|
+
return EXIT_ALLOW2;
|
|
578
604
|
}
|
|
579
|
-
return _withToolWriteLock(consumer_root, session_id,
|
|
605
|
+
return _withToolWriteLock(consumer_root, session_id, EXIT_ALLOW2, () => {
|
|
580
606
|
const previous = _loadState(path.join(consumer_root, statePathFor2(session_id)));
|
|
581
607
|
const language = previous.language;
|
|
582
608
|
if (language !== "de" && language !== "en") {
|
|
583
|
-
return
|
|
609
|
+
return EXIT_ALLOW2;
|
|
584
610
|
}
|
|
585
611
|
if (!_ownsPin(previous, session_id)) {
|
|
586
|
-
return
|
|
612
|
+
return EXIT_ALLOW2;
|
|
587
613
|
}
|
|
588
614
|
const seen = typeof previous.tool_calls_since_pin === "number" && previous.tool_calls_since_pin >= 0 ? previous.tool_calls_since_pin : 0;
|
|
589
615
|
const advanced = seen + 1;
|
|
@@ -596,10 +622,10 @@ function _reEmitAfterDistance(consumer_root, session_id, write_json = atomic_wri
|
|
|
596
622
|
write_json
|
|
597
623
|
);
|
|
598
624
|
if (!due) {
|
|
599
|
-
return
|
|
625
|
+
return EXIT_ALLOW2;
|
|
600
626
|
}
|
|
601
627
|
if (!written) {
|
|
602
|
-
return
|
|
628
|
+
return EXIT_ALLOW2;
|
|
603
629
|
}
|
|
604
630
|
const source = previous.source === "system-locale" ? "system-locale" : "prompt";
|
|
605
631
|
process.stdout.write(
|
|
@@ -610,7 +636,7 @@ function _reEmitAfterDistance(consumer_root, session_id, write_json = atomic_wri
|
|
|
610
636
|
})}
|
|
611
637
|
`
|
|
612
638
|
);
|
|
613
|
-
return
|
|
639
|
+
return EXIT_WARN2;
|
|
614
640
|
});
|
|
615
641
|
}
|
|
616
642
|
function _onToolUse(consumer_root, session_id, write_json = atomic_write_json) {
|
|
@@ -628,24 +654,24 @@ function run(stdin_text, options) {
|
|
|
628
654
|
envelope = decoded;
|
|
629
655
|
}
|
|
630
656
|
} catch {
|
|
631
|
-
return
|
|
657
|
+
return EXIT_ALLOW2;
|
|
632
658
|
}
|
|
633
659
|
}
|
|
634
660
|
const payload = _isObject2(envelope["payload"]) ? envelope["payload"] : envelope;
|
|
635
661
|
const event = typeof envelope["event"] === "string" ? envelope["event"] : "";
|
|
636
662
|
if (event === "pre_compact") {
|
|
637
663
|
_setPinLost(options.consumer_root, _sessionId(envelope));
|
|
638
|
-
return
|
|
664
|
+
return EXIT_ALLOW2;
|
|
639
665
|
}
|
|
640
666
|
if (event === "post_tool_use") {
|
|
641
667
|
return _onToolUse(options.consumer_root, _sessionId(envelope), options.write_json);
|
|
642
668
|
}
|
|
643
669
|
const prompt = _extractPrompt(payload);
|
|
644
670
|
if (!prompt) {
|
|
645
|
-
return
|
|
671
|
+
return EXIT_ALLOW2;
|
|
646
672
|
}
|
|
647
673
|
if (isSyntheticPrompt(prompt)) {
|
|
648
|
-
return
|
|
674
|
+
return EXIT_ALLOW2;
|
|
649
675
|
}
|
|
650
676
|
const session_id = typeof envelope["session_id"] === "string" ? envelope["session_id"] : "";
|
|
651
677
|
const stateful = hasStableSessionId(session_id);
|
|
@@ -683,9 +709,9 @@ function run(stdin_text, options) {
|
|
|
683
709
|
`${JSON.stringify({ decision: "warn", reason: noticeText(effective, effectiveSource), additional_context: pinText(effective, effectiveSource) })}
|
|
684
710
|
`
|
|
685
711
|
);
|
|
686
|
-
return
|
|
712
|
+
return EXIT_WARN2;
|
|
687
713
|
}
|
|
688
|
-
return
|
|
714
|
+
return EXIT_ALLOW2;
|
|
689
715
|
}
|
|
690
716
|
function _errText(err) {
|
|
691
717
|
const t = err instanceof Error ? err.message : String(err);
|
|
@@ -872,7 +898,7 @@ function extractObjects(op, text) {
|
|
|
872
898
|
}
|
|
873
899
|
|
|
874
900
|
// src/scripts/git_authorization_hook.ts
|
|
875
|
-
var
|
|
901
|
+
var EXIT_ALLOW3 = 0;
|
|
876
902
|
var STATE_FILE2 = path2.join("agents", "state", "git-authorization.json");
|
|
877
903
|
var STATE_DIR2 = path2.join("agents", "state", "git-authorization");
|
|
878
904
|
var PENDING_DIR = path2.join("agents", "state", "git-authorization-pending");
|
|
@@ -1432,7 +1458,7 @@ function run2(stdin_text, options) {
|
|
|
1432
1458
|
envelope = decoded;
|
|
1433
1459
|
}
|
|
1434
1460
|
} catch {
|
|
1435
|
-
return
|
|
1461
|
+
return EXIT_ALLOW3;
|
|
1436
1462
|
}
|
|
1437
1463
|
}
|
|
1438
1464
|
const payload = _isObject3(envelope["payload"]) ? envelope["payload"] : envelope;
|
|
@@ -1445,11 +1471,11 @@ function run2(stdin_text, options) {
|
|
|
1445
1471
|
}
|
|
1446
1472
|
}
|
|
1447
1473
|
if (!prompt) {
|
|
1448
|
-
return
|
|
1474
|
+
return EXIT_ALLOW3;
|
|
1449
1475
|
}
|
|
1450
1476
|
const session = typeof envelope["session_id"] === "string" ? envelope["session_id"] : "";
|
|
1451
1477
|
if (!humanTypedThisTurn(prompt)) {
|
|
1452
|
-
return
|
|
1478
|
+
return EXIT_ALLOW3;
|
|
1453
1479
|
}
|
|
1454
1480
|
const { authorized, evidence } = classifyAuthorization(prompt);
|
|
1455
1481
|
const pending = takePending(options.consumer_root, session, Date.now());
|
|
@@ -1490,7 +1516,7 @@ function run2(stdin_text, options) {
|
|
|
1490
1516
|
`
|
|
1491
1517
|
);
|
|
1492
1518
|
}
|
|
1493
|
-
return
|
|
1519
|
+
return EXIT_ALLOW3;
|
|
1494
1520
|
}
|
|
1495
1521
|
function main2(argv) {
|
|
1496
1522
|
const args = argv ?? process.argv.slice(2);
|
|
@@ -1948,9 +1974,9 @@ var COMMAND_OBJECTS = {
|
|
|
1948
1974
|
};
|
|
1949
1975
|
|
|
1950
1976
|
// src/scripts/hooks/turn_end_gate_hook.ts
|
|
1951
|
-
import * as
|
|
1952
|
-
import * as
|
|
1953
|
-
import { fileURLToPath as
|
|
1977
|
+
import * as fs12 from "node:fs";
|
|
1978
|
+
import * as path10 from "node:path";
|
|
1979
|
+
import { fileURLToPath as fileURLToPath5, pathToFileURL as pathToFileURL5 } from "node:url";
|
|
1954
1980
|
|
|
1955
1981
|
// src/scripts/check_reply_consistency.ts
|
|
1956
1982
|
import * as fs3 from "node:fs";
|
|
@@ -3284,7 +3310,6 @@ import * as crypto from "node:crypto";
|
|
|
3284
3310
|
import * as fs8 from "node:fs";
|
|
3285
3311
|
import * as path7 from "node:path";
|
|
3286
3312
|
var EDIT_TOOLS = /* @__PURE__ */ new Set(["Edit", "Write", "MultiEdit", "NotebookEdit"]);
|
|
3287
|
-
var RENDER_REL = path7.join("agents", "runtime", "state", "render");
|
|
3288
3313
|
var PLANTED_PREFIXES = [
|
|
3289
3314
|
"tests/design-artifacts/fixtures/",
|
|
3290
3315
|
"tests/design-artifacts/scenarios/"
|
|
@@ -3339,6 +3364,22 @@ function dischargeFor(manifests, digest) {
|
|
|
3339
3364
|
}
|
|
3340
3365
|
return staticOnly ? "static-only" : null;
|
|
3341
3366
|
}
|
|
3367
|
+
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";
|
|
3368
|
+
function recordVerdict(root, abs, digest, records) {
|
|
3369
|
+
let changed = false;
|
|
3370
|
+
for (const r of records) {
|
|
3371
|
+
if (path7.resolve(root, r.file) !== abs || r.file_digest !== digest) continue;
|
|
3372
|
+
const read = recordedManifest(root, r);
|
|
3373
|
+
if (read === null) continue;
|
|
3374
|
+
if ("changed" in read) {
|
|
3375
|
+
changed = true;
|
|
3376
|
+
continue;
|
|
3377
|
+
}
|
|
3378
|
+
const kind = dischargeFor([read.manifest], digest);
|
|
3379
|
+
if (kind !== null) return kind;
|
|
3380
|
+
}
|
|
3381
|
+
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";
|
|
3382
|
+
}
|
|
3342
3383
|
function readSvgObligations(root, inputs) {
|
|
3343
3384
|
const open = [];
|
|
3344
3385
|
const discharged = [];
|
|
@@ -3358,6 +3399,12 @@ function readSvgObligations(root, inputs) {
|
|
|
3358
3399
|
continue;
|
|
3359
3400
|
}
|
|
3360
3401
|
const digest = crypto.createHash("sha256").update(bytes).digest("hex");
|
|
3402
|
+
if (Array.isArray(inputs.recorded)) {
|
|
3403
|
+
const verdict = recordVerdict(root, path7.resolve(root, abs), digest, inputs.recorded);
|
|
3404
|
+
if (verdict === "verified" || verdict === "static-only") discharged.push({ file: relPath, kind: verdict });
|
|
3405
|
+
else open.push({ file: relPath, reason: verdict });
|
|
3406
|
+
continue;
|
|
3407
|
+
}
|
|
3361
3408
|
if (!renderNames(rendered, relPath)) {
|
|
3362
3409
|
open.push({
|
|
3363
3410
|
file: relPath,
|
|
@@ -3393,12 +3440,6 @@ function renderNames(commands, relPath) {
|
|
|
3393
3440
|
return bounded(relPath) || bounded(base);
|
|
3394
3441
|
});
|
|
3395
3442
|
}
|
|
3396
|
-
function isPureRender(command) {
|
|
3397
|
-
if (!isAssetRenderCommand(command)) return false;
|
|
3398
|
-
const [head, ...pipes] = command.replace(/^\s*cd\s+[^;&|<>`$\n]+&&\s*/, "").replace(/\s\d?>&\d\b/g, " ").replace(/\s2>\s*\/dev\/null\b/g, " ").split("|");
|
|
3399
|
-
if (/[;&<>`\n]|\$\(/.test(head ?? "")) return false;
|
|
3400
|
-
return pipes.every((p) => /^\s*(tail|head|grep|jq|cat|less|wc)\b[^;&<>`|]*$/.test(p) && !/\$\(/.test(p));
|
|
3401
|
-
}
|
|
3402
3443
|
function writesRenderDir(command) {
|
|
3403
3444
|
if (isPureRender(command)) return false;
|
|
3404
3445
|
const slashed = command.split(path7.sep).join("/");
|
|
@@ -3411,7 +3452,8 @@ function writesRenderDir(command) {
|
|
|
3411
3452
|
function escapeRe(s) {
|
|
3412
3453
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3413
3454
|
}
|
|
3414
|
-
function openSvgObligation(workspaceRoot, toolCalls) {
|
|
3455
|
+
function openSvgObligation(workspaceRoot, toolCalls, recordedRaw = null) {
|
|
3456
|
+
const recordedRenders = recordedRaw === null || hasInstrumentGap(recordedRaw) ? null : recordedRaw;
|
|
3415
3457
|
const lastEditOf = /* @__PURE__ */ new Map();
|
|
3416
3458
|
for (let i = 0; i < toolCalls.length; i += 1) {
|
|
3417
3459
|
const c = toolCalls[i];
|
|
@@ -3438,7 +3480,11 @@ function openSvgObligation(workspaceRoot, toolCalls) {
|
|
|
3438
3480
|
});
|
|
3439
3481
|
let reading;
|
|
3440
3482
|
try {
|
|
3441
|
-
reading = readSvgObligations(workspaceRoot, {
|
|
3483
|
+
reading = readSvgObligations(workspaceRoot, {
|
|
3484
|
+
edits,
|
|
3485
|
+
renderDirTampered,
|
|
3486
|
+
recorded: recordedRenders === null ? null : readAssetRenderRecords(recordedRenders)
|
|
3487
|
+
});
|
|
3442
3488
|
} catch {
|
|
3443
3489
|
return null;
|
|
3444
3490
|
}
|
|
@@ -3454,7 +3500,7 @@ function openSvgObligation(workspaceRoot, toolCalls) {
|
|
|
3454
3500
|
detector: "verification",
|
|
3455
3501
|
mode: "transcript",
|
|
3456
3502
|
evidence: first.file,
|
|
3457
|
-
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.`
|
|
3503
|
+
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})` : "")
|
|
3458
3504
|
};
|
|
3459
3505
|
}
|
|
3460
3506
|
|
|
@@ -3512,539 +3558,21 @@ function unwrap(stdin_text, default_platform = "generic") {
|
|
|
3512
3558
|
];
|
|
3513
3559
|
}
|
|
3514
3560
|
|
|
3515
|
-
// src/scripts/hooks/subagent_ledger_hook.ts
|
|
3516
|
-
import * as crypto2 from "node:crypto";
|
|
3517
|
-
import * as fs9 from "node:fs";
|
|
3518
|
-
import * as path8 from "node:path";
|
|
3519
|
-
import { fileURLToPath as fileURLToPath4, pathToFileURL as pathToFileURL4 } from "node:url";
|
|
3520
|
-
|
|
3521
|
-
// src/scripts/_lib/subagent_response.ts
|
|
3522
|
-
var MAX_SUMMARY_CHARS = 2e3;
|
|
3523
|
-
var MAX_RESPONSE_LINE_CHARS = 240;
|
|
3524
|
-
var MAX_RESPONSE_ENTRIES = 40;
|
|
3525
|
-
var MAX_ARTIFACT_REF_CHARS = 200;
|
|
3526
|
-
var MAX_ENVELOPE_CHARS = 12e3;
|
|
3527
|
-
var CONFIDENCE = /* @__PURE__ */ new Set(["low", "medium", "high"]);
|
|
3528
|
-
var RESPONSE_REQUIRED_FIELDS = [
|
|
3529
|
-
"summary",
|
|
3530
|
-
"handoff",
|
|
3531
|
-
"confidence",
|
|
3532
|
-
"findings",
|
|
3533
|
-
"risks"
|
|
3534
|
-
];
|
|
3535
|
-
function countContractFields(input) {
|
|
3536
|
-
if (input === null || typeof input !== "object") return 0;
|
|
3537
|
-
const r = input;
|
|
3538
|
-
return RESPONSE_REQUIRED_FIELDS.filter((k) => Object.hasOwn(r, k)).length;
|
|
3539
|
-
}
|
|
3540
|
-
function validateResponse(input) {
|
|
3541
|
-
const errors = [];
|
|
3542
|
-
if (input === null || typeof input !== "object") {
|
|
3543
|
-
return { valid: false, errors: ["response is not an object"] };
|
|
3544
|
-
}
|
|
3545
|
-
const r = input;
|
|
3546
|
-
if (typeof r.summary !== "string") errors.push("summary missing or not a string");
|
|
3547
|
-
if (typeof r.handoff !== "string") errors.push("handoff missing or not a string");
|
|
3548
|
-
if (!CONFIDENCE.has(r.confidence)) errors.push(`confidence must be low|medium|high (got ${String(r.confidence)})`);
|
|
3549
|
-
if (!Array.isArray(r.findings)) errors.push("findings missing or not an array");
|
|
3550
|
-
if (!Array.isArray(r.risks)) errors.push("risks missing or not an array");
|
|
3551
|
-
if (Array.isArray(r.findings)) {
|
|
3552
|
-
for (const [i, f] of r.findings.entries()) {
|
|
3553
|
-
if (!f || typeof f.title !== "string") errors.push(`finding[${i}] missing title`);
|
|
3554
|
-
const refs = f?.evidence_refs;
|
|
3555
|
-
if (refs && refs.some((x) => typeof x !== "string" || x.includes("\n"))) {
|
|
3556
|
-
errors.push(`finding[${i}] evidence_refs must be ref tokens, not bodies`);
|
|
3557
|
-
}
|
|
3558
|
-
}
|
|
3559
|
-
}
|
|
3560
|
-
if (r.assumptions !== void 0) {
|
|
3561
|
-
if (!Array.isArray(r.assumptions)) {
|
|
3562
|
-
errors.push("assumptions must be an array of {statement, basis, epistemic_state}");
|
|
3563
|
-
} else {
|
|
3564
|
-
for (const [i, a] of r.assumptions.entries()) {
|
|
3565
|
-
errors.push(...validateAssumption(a, `assumptions[${i}]`));
|
|
3566
|
-
}
|
|
3567
|
-
}
|
|
3568
|
-
}
|
|
3569
|
-
if (typeof r.summary === "string" && r.summary.length > MAX_SUMMARY_CHARS) {
|
|
3570
|
-
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)`);
|
|
3571
|
-
}
|
|
3572
|
-
if (typeof r.handoff === "string" && r.handoff.length > MAX_RESPONSE_LINE_CHARS) {
|
|
3573
|
-
errors.push(`handoff is ${r.handoff.length} chars (max ${MAX_RESPONSE_LINE_CHARS})`);
|
|
3574
|
-
}
|
|
3575
|
-
for (const [key, arr] of [
|
|
3576
|
-
["findings", r.findings],
|
|
3577
|
-
["risks", r.risks],
|
|
3578
|
-
["artifact_paths", r.artifact_paths]
|
|
3579
|
-
]) {
|
|
3580
|
-
if (Array.isArray(arr) && arr.length > MAX_RESPONSE_ENTRIES) {
|
|
3581
|
-
errors.push(`${key} carries ${arr.length} entries (max ${MAX_RESPONSE_ENTRIES}) \u2014 an envelope is a handoff, not a transcript`);
|
|
3582
|
-
}
|
|
3583
|
-
}
|
|
3584
|
-
if (Array.isArray(r.risks)) {
|
|
3585
|
-
for (const [i, risk] of r.risks.entries()) {
|
|
3586
|
-
if (typeof risk === "string" && risk.length > MAX_RESPONSE_LINE_CHARS) {
|
|
3587
|
-
errors.push(`risks[${i}] is ${risk.length} chars (max ${MAX_RESPONSE_LINE_CHARS})`);
|
|
3588
|
-
}
|
|
3589
|
-
}
|
|
3590
|
-
}
|
|
3591
|
-
if (Array.isArray(r.findings)) {
|
|
3592
|
-
for (const [i, f] of r.findings.entries()) {
|
|
3593
|
-
if (f && typeof f.title === "string" && f.title.length > MAX_RESPONSE_LINE_CHARS) {
|
|
3594
|
-
errors.push(`finding[${i}] title is ${f.title.length} chars (max ${MAX_RESPONSE_LINE_CHARS})`);
|
|
3595
|
-
}
|
|
3596
|
-
}
|
|
3597
|
-
}
|
|
3598
|
-
if (r.artifact_paths !== void 0) {
|
|
3599
|
-
if (!Array.isArray(r.artifact_paths)) {
|
|
3600
|
-
errors.push("artifact_paths must be an array of path ref tokens");
|
|
3601
|
-
} else {
|
|
3602
|
-
for (const [i, p] of r.artifact_paths.entries()) {
|
|
3603
|
-
if (typeof p !== "string" || p.includes("\n") || p.length > MAX_ARTIFACT_REF_CHARS) {
|
|
3604
|
-
errors.push(`artifact_paths[${i}] must be a single-line path ref \u2264 ${MAX_ARTIFACT_REF_CHARS} chars`);
|
|
3605
|
-
}
|
|
3606
|
-
}
|
|
3607
|
-
}
|
|
3608
|
-
}
|
|
3609
|
-
try {
|
|
3610
|
-
const serialized = JSON.stringify(input);
|
|
3611
|
-
if (serialized.length > MAX_ENVELOPE_CHARS) {
|
|
3612
|
-
errors.push(`envelope serializes to ${serialized.length} chars (max ${MAX_ENVELOPE_CHARS}) \u2014 move content to disk and reference it via artifact_paths`);
|
|
3613
|
-
}
|
|
3614
|
-
} catch {
|
|
3615
|
-
errors.push("envelope is not JSON-serializable");
|
|
3616
|
-
}
|
|
3617
|
-
return { valid: errors.length === 0, errors };
|
|
3618
|
-
}
|
|
3619
|
-
|
|
3620
|
-
// src/scripts/hooks/exit_codes.ts
|
|
3621
|
-
var EXIT_ALLOW3 = 0;
|
|
3622
|
-
var EXIT_BLOCK = 1;
|
|
3623
|
-
var EXIT_WARN2 = 2;
|
|
3624
|
-
var EXIT_ERROR = 3;
|
|
3625
|
-
var EXIT_CODES = Object.freeze([
|
|
3626
|
-
Object.freeze({
|
|
3627
|
-
code: EXIT_ALLOW3,
|
|
3628
|
-
name: "allow",
|
|
3629
|
-
meaning: "no objection; the dispatcher passes the call through",
|
|
3630
|
-
owner: "every concern \u2014 the default verdict",
|
|
3631
|
-
authorizedBy: "nothing; allowing needs no authority"
|
|
3632
|
-
}),
|
|
3633
|
-
Object.freeze({
|
|
3634
|
-
code: EXIT_BLOCK,
|
|
3635
|
-
name: "block",
|
|
3636
|
-
meaning: "refuse the call; the dispatcher lowers this onto the host deny channel",
|
|
3637
|
-
owner: "a concern declared `severity: blocking` in hook_manifest.yaml",
|
|
3638
|
-
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"
|
|
3639
|
-
}),
|
|
3640
|
-
Object.freeze({
|
|
3641
|
-
code: EXIT_WARN2,
|
|
3642
|
-
name: "warn",
|
|
3643
|
-
meaning: "advisory; the dispatcher exits 0 and surfaces the reason",
|
|
3644
|
-
owner: "any concern",
|
|
3645
|
-
authorizedBy: "nothing; warning is the ceiling for an advisory concern and is always available to a blocking one"
|
|
3646
|
-
}),
|
|
3647
|
-
Object.freeze({
|
|
3648
|
-
code: EXIT_ERROR,
|
|
3649
|
-
name: "error",
|
|
3650
|
-
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",
|
|
3651
|
-
owner: "no concern emits this on purpose; the runtime does",
|
|
3652
|
-
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"
|
|
3653
|
-
})
|
|
3654
|
-
]);
|
|
3655
|
-
|
|
3656
|
-
// src/scripts/hooks/subagent_ledger_hook.ts
|
|
3657
|
-
function isObject2(v) {
|
|
3658
|
-
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
3659
|
-
}
|
|
3660
|
-
var LEDGER_DIR = path8.join("agents", "runtime", "state", "subagent-ledger");
|
|
3661
|
-
var OPEN_SUBDIR = "open";
|
|
3662
|
-
var OPEN_RECORD_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
3663
|
-
function refFor(agentId) {
|
|
3664
|
-
return crypto2.createHash("sha256").update(agentId, "utf8").digest("hex").slice(0, 12);
|
|
3665
|
-
}
|
|
3666
|
-
function unwrapPayload(envelope) {
|
|
3667
|
-
const inner = envelope["payload"];
|
|
3668
|
-
return isObject2(inner) ? inner : envelope;
|
|
3669
|
-
}
|
|
3670
|
-
function str(payload, ...keys) {
|
|
3671
|
-
for (const k of keys) {
|
|
3672
|
-
const v = payload[k];
|
|
3673
|
-
if (typeof v === "string" && v) return v;
|
|
3674
|
-
}
|
|
3675
|
-
return null;
|
|
3676
|
-
}
|
|
3677
|
-
function extractParentId(payload, ownId) {
|
|
3678
|
-
const explicit = str(payload, "parent_agent_id", "parentAgentId");
|
|
3679
|
-
if (explicit) return explicit;
|
|
3680
|
-
const session = payload["session"];
|
|
3681
|
-
if (isObject2(session)) {
|
|
3682
|
-
const sessionAgent = str(session, "agent_id", "agentId");
|
|
3683
|
-
if (sessionAgent && sessionAgent !== ownId) return sessionAgent;
|
|
3684
|
-
}
|
|
3685
|
-
return null;
|
|
3686
|
-
}
|
|
3687
|
-
function classifyEnvelope(message) {
|
|
3688
|
-
if (message === null || !message.trim()) {
|
|
3689
|
-
return { verdict: "no_message", error_count: 0, field_hits: 0 };
|
|
3690
|
-
}
|
|
3691
|
-
const candidates = _jsonObjectCandidates(message);
|
|
3692
|
-
if (candidates.length === 0) return { verdict: "no_envelope", error_count: 0, field_hits: 0 };
|
|
3693
|
-
let best = null;
|
|
3694
|
-
for (const candidate of candidates) {
|
|
3695
|
-
const result = validateResponse(candidate);
|
|
3696
|
-
const fieldHits = countContractFields(candidate);
|
|
3697
|
-
if (result.valid) return { verdict: "ok", error_count: 0, field_hits: fieldHits };
|
|
3698
|
-
if (best === null || fieldHits > best.field_hits) {
|
|
3699
|
-
best = {
|
|
3700
|
-
verdict: fieldHits === 0 ? "foreign_object" : "fail",
|
|
3701
|
-
error_count: result.errors.length,
|
|
3702
|
-
field_hits: fieldHits
|
|
3703
|
-
};
|
|
3704
|
-
}
|
|
3705
|
-
}
|
|
3706
|
-
return best ?? { verdict: "no_envelope", error_count: 0, field_hits: 0 };
|
|
3707
|
-
}
|
|
3708
|
-
function _jsonObjectCandidates(message) {
|
|
3709
|
-
const texts = [];
|
|
3710
|
-
for (const match of message.matchAll(/^[ \t]*```[ \t]*(?:json)?[ \t]*\r?\n([\s\S]*?)^[ \t]*```/gm)) {
|
|
3711
|
-
if (match[1]) texts.push(match[1]);
|
|
3712
|
-
}
|
|
3713
|
-
let depth = 0;
|
|
3714
|
-
let start = -1;
|
|
3715
|
-
let inString = false;
|
|
3716
|
-
let escaped = false;
|
|
3717
|
-
for (let i = 0; i < message.length; i++) {
|
|
3718
|
-
const ch = message[i];
|
|
3719
|
-
if (inString) {
|
|
3720
|
-
if (escaped) escaped = false;
|
|
3721
|
-
else if (ch === "\\") escaped = true;
|
|
3722
|
-
else if (ch === '"') inString = false;
|
|
3723
|
-
continue;
|
|
3724
|
-
}
|
|
3725
|
-
if (ch === '"') inString = true;
|
|
3726
|
-
else if (ch === "{") {
|
|
3727
|
-
if (depth === 0) start = i;
|
|
3728
|
-
depth++;
|
|
3729
|
-
} else if (ch === "}") {
|
|
3730
|
-
if (depth > 0) {
|
|
3731
|
-
depth--;
|
|
3732
|
-
if (depth === 0 && start !== -1) {
|
|
3733
|
-
texts.push(message.slice(start, i + 1));
|
|
3734
|
-
start = -1;
|
|
3735
|
-
}
|
|
3736
|
-
}
|
|
3737
|
-
}
|
|
3738
|
-
}
|
|
3739
|
-
const out = [];
|
|
3740
|
-
for (const text of texts) {
|
|
3741
|
-
try {
|
|
3742
|
-
const parsed = JSON.parse(text.trim());
|
|
3743
|
-
if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) out.push(parsed);
|
|
3744
|
-
} catch {
|
|
3745
|
-
}
|
|
3746
|
-
}
|
|
3747
|
-
return out;
|
|
3748
|
-
}
|
|
3749
|
-
function openDir(root) {
|
|
3750
|
-
return path8.join(root, LEDGER_DIR, OPEN_SUBDIR);
|
|
3751
|
-
}
|
|
3752
|
-
function openFile(root, ref) {
|
|
3753
|
-
return path8.join(openDir(root), `${ref}.json`);
|
|
3754
|
-
}
|
|
3755
|
-
var DEPTH_BASES = /* @__PURE__ */ new Set(["observed", "asserted-parent", "assumed-root"]);
|
|
3756
|
-
function _asOpenRecord(value, expectedRef) {
|
|
3757
|
-
if (!isObject2(value)) return null;
|
|
3758
|
-
const ref = value["ref"];
|
|
3759
|
-
if (typeof ref !== "string" || ref !== expectedRef) return null;
|
|
3760
|
-
if (typeof value["started_at"] !== "string") return null;
|
|
3761
|
-
if (typeof value["depth"] !== "number" || !Number.isFinite(value["depth"])) return null;
|
|
3762
|
-
if (typeof value["depth_basis"] !== "string" || !DEPTH_BASES.has(value["depth_basis"])) return null;
|
|
3763
|
-
const agentType = value["agent_type"];
|
|
3764
|
-
const parentRef = value["parent_ref"];
|
|
3765
|
-
const sessionId = value["session_id"];
|
|
3766
|
-
return {
|
|
3767
|
-
ref,
|
|
3768
|
-
agent_type: typeof agentType === "string" ? agentType : null,
|
|
3769
|
-
started_at: value["started_at"],
|
|
3770
|
-
parent_ref: typeof parentRef === "string" ? parentRef : null,
|
|
3771
|
-
depth: value["depth"],
|
|
3772
|
-
depth_basis: value["depth_basis"],
|
|
3773
|
-
session_id: typeof sessionId === "string" ? sessionId : null
|
|
3774
|
-
};
|
|
3775
|
-
}
|
|
3776
|
-
function readOpenRecords(root) {
|
|
3777
|
-
const out = /* @__PURE__ */ new Map();
|
|
3778
|
-
let names;
|
|
3779
|
-
try {
|
|
3780
|
-
names = fs9.readdirSync(openDir(root));
|
|
3781
|
-
} catch {
|
|
3782
|
-
return out;
|
|
3783
|
-
}
|
|
3784
|
-
for (const name of names) {
|
|
3785
|
-
if (!name.endsWith(".json")) continue;
|
|
3786
|
-
const expectedRef = name.slice(0, -".json".length);
|
|
3787
|
-
try {
|
|
3788
|
-
const raw = fs9.readFileSync(path8.join(openDir(root), name), "utf8");
|
|
3789
|
-
const rec = _asOpenRecord(JSON.parse(raw), expectedRef);
|
|
3790
|
-
if (rec) out.set(rec.ref, rec);
|
|
3791
|
-
} catch {
|
|
3792
|
-
}
|
|
3793
|
-
}
|
|
3794
|
-
return out;
|
|
3795
|
-
}
|
|
3796
|
-
function resolveDepth(parentRef, open) {
|
|
3797
|
-
if (parentRef === null) return { depth: 1, depth_basis: "assumed-root" };
|
|
3798
|
-
const parent = open.get(parentRef);
|
|
3799
|
-
if (!parent) return { depth: 2, depth_basis: "asserted-parent" };
|
|
3800
|
-
return { depth: parent.depth + 1, depth_basis: "observed" };
|
|
3801
|
-
}
|
|
3802
|
-
function ledgerFileFor2(root, ts) {
|
|
3803
|
-
return path8.join(root, LEDGER_DIR, `${ts.slice(0, 7)}.jsonl`);
|
|
3804
|
-
}
|
|
3805
|
-
function appendLedgerLine(root, ts, line) {
|
|
3806
|
-
if (is_replay_mode()) return;
|
|
3807
|
-
const file = ledgerFileFor2(root, ts);
|
|
3808
|
-
fs9.mkdirSync(path8.dirname(file), { recursive: true });
|
|
3809
|
-
fs9.appendFileSync(file, `${JSON.stringify(line)}
|
|
3810
|
-
`, "utf8");
|
|
3811
|
-
}
|
|
3812
|
-
var WALL_CLOCK_ARMS_MS = [
|
|
3813
|
-
{ label: "5m", ms: 5 * 60 * 1e3 },
|
|
3814
|
-
{ label: "15m", ms: 15 * 60 * 1e3 },
|
|
3815
|
-
{ label: "30m", ms: 30 * 60 * 1e3 },
|
|
3816
|
-
{ label: "2h", ms: 2 * 60 * 60 * 1e3 }
|
|
3817
|
-
];
|
|
3818
|
-
function armsExceeded(elapsedMs) {
|
|
3819
|
-
if (elapsedMs === null || !Number.isFinite(elapsedMs)) return [];
|
|
3820
|
-
return WALL_CLOCK_ARMS_MS.filter((a) => elapsedMs >= a.ms).map((a) => a.label);
|
|
3821
|
-
}
|
|
3822
|
-
function openRecordStats(root, nowMs = Date.now()) {
|
|
3823
|
-
const ledgerPresent = fs9.existsSync(path8.join(root, LEDGER_DIR));
|
|
3824
|
-
const open = readOpenRecords(root);
|
|
3825
|
-
let maxDepth = 0;
|
|
3826
|
-
let counted = 0;
|
|
3827
|
-
let stale = 0;
|
|
3828
|
-
for (const rec of open.values()) {
|
|
3829
|
-
const started = Date.parse(rec.started_at);
|
|
3830
|
-
const isStale = Number.isFinite(started) && nowMs - started >= OPEN_RECORD_TTL_MS;
|
|
3831
|
-
if (isStale) {
|
|
3832
|
-
stale++;
|
|
3833
|
-
continue;
|
|
3834
|
-
}
|
|
3835
|
-
counted++;
|
|
3836
|
-
if (rec.depth > maxDepth) maxDepth = rec.depth;
|
|
3837
|
-
}
|
|
3838
|
-
return {
|
|
3839
|
-
open_count: counted,
|
|
3840
|
-
max_depth: maxDepth,
|
|
3841
|
-
stale_excluded: stale,
|
|
3842
|
-
ledger_present: ledgerPresent
|
|
3843
|
-
};
|
|
3844
|
-
}
|
|
3845
|
-
function writeOpenRecord(root, rec) {
|
|
3846
|
-
atomic_write_json(openFile(root, rec.ref), rec);
|
|
3847
|
-
}
|
|
3848
|
-
function removeOpenRecord(root, ref) {
|
|
3849
|
-
if (is_replay_mode()) return;
|
|
3850
|
-
try {
|
|
3851
|
-
fs9.unlinkSync(openFile(root, ref));
|
|
3852
|
-
} catch {
|
|
3853
|
-
}
|
|
3854
|
-
}
|
|
3855
|
-
function countOpen(root) {
|
|
3856
|
-
try {
|
|
3857
|
-
return fs9.readdirSync(openDir(root)).filter((n) => n.endsWith(".json")).length;
|
|
3858
|
-
} catch {
|
|
3859
|
-
return 0;
|
|
3860
|
-
}
|
|
3861
|
-
}
|
|
3862
|
-
function reapStaleOpenRecords(root, nowIso) {
|
|
3863
|
-
const now = Date.parse(nowIso);
|
|
3864
|
-
if (!Number.isFinite(now)) return 0;
|
|
3865
|
-
let reaped = 0;
|
|
3866
|
-
for (const rec of readOpenRecords(root).values()) {
|
|
3867
|
-
const started = Date.parse(rec.started_at);
|
|
3868
|
-
if (!Number.isFinite(started) || now - started < OPEN_RECORD_TTL_MS) continue;
|
|
3869
|
-
removeOpenRecord(root, rec.ref);
|
|
3870
|
-
reaped++;
|
|
3871
|
-
appendLedgerLine(root, nowIso, {
|
|
3872
|
-
event: "subagent_reaped",
|
|
3873
|
-
ts: nowIso,
|
|
3874
|
-
ref: rec.ref,
|
|
3875
|
-
agent_type: rec.agent_type,
|
|
3876
|
-
depth: rec.depth,
|
|
3877
|
-
depth_basis: rec.depth_basis,
|
|
3878
|
-
// R2 round 2, finding 5: the arm list is NOT repeated here. A reap
|
|
3879
|
-
// fires only past OPEN_RECORD_TTL_MS (24 h), which exceeds every
|
|
3880
|
-
// arm (largest: 2 h), so `stop_loss_arms_exceeded` would be a
|
|
3881
|
-
// constant on this line — a field that cannot vary answers no
|
|
3882
|
-
// question. `age_ms` carries strictly more information and is what
|
|
3883
|
-
// a reader should aggregate over.
|
|
3884
|
-
age_ms: now - started,
|
|
3885
|
-
reason: "open record exceeded OPEN_RECORD_TTL_MS without a stop"
|
|
3886
|
-
});
|
|
3887
|
-
}
|
|
3888
|
-
return reaped;
|
|
3889
|
-
}
|
|
3890
|
-
function appendUnidentified(root, event, nowIso, payload) {
|
|
3891
|
-
appendLedgerLine(root, nowIso, {
|
|
3892
|
-
event,
|
|
3893
|
-
ts: nowIso,
|
|
3894
|
-
ref: null,
|
|
3895
|
-
unidentified: true,
|
|
3896
|
-
// The agent TYPE is an id-shaped enum and may still be present; it is
|
|
3897
|
-
// the only thing salvageable from a payload with no id.
|
|
3898
|
-
agent_type: str(payload, "agent_type", "agentType", "subagent_type", "subagentType"),
|
|
3899
|
-
reason: "payload carried no agent id \u2014 nothing to correlate start with stop"
|
|
3900
|
-
});
|
|
3901
|
-
}
|
|
3902
|
-
function handleStart(root, payload, nowIso, sessionId) {
|
|
3903
|
-
const agentId = str(payload, "agent_id", "agentId");
|
|
3904
|
-
if (agentId === null) {
|
|
3905
|
-
appendUnidentified(root, "subagent_start", nowIso, payload);
|
|
3906
|
-
return;
|
|
3907
|
-
}
|
|
3908
|
-
const ref = refFor(agentId);
|
|
3909
|
-
const parentId = extractParentId(payload, agentId);
|
|
3910
|
-
const parentRef = parentId ? refFor(parentId) : null;
|
|
3911
|
-
const { depth, depth_basis } = resolveDepth(parentRef, readOpenRecords(root));
|
|
3912
|
-
const rec = {
|
|
3913
|
-
ref,
|
|
3914
|
-
agent_type: str(payload, "agent_type", "agentType", "subagent_type", "subagentType"),
|
|
3915
|
-
started_at: nowIso,
|
|
3916
|
-
parent_ref: parentRef,
|
|
3917
|
-
depth,
|
|
3918
|
-
depth_basis,
|
|
3919
|
-
session_id: sessionId
|
|
3920
|
-
};
|
|
3921
|
-
writeOpenRecord(root, rec);
|
|
3922
|
-
appendLedgerLine(root, nowIso, {
|
|
3923
|
-
event: "subagent_start",
|
|
3924
|
-
ts: nowIso,
|
|
3925
|
-
ref,
|
|
3926
|
-
// Phase 1 Step 4 correction (b): without this the dispatch denominator
|
|
3927
|
-
// is not per-session. Three sessions share one ledger file, so a rate
|
|
3928
|
-
// computed over the file aggregates strangers — the measured window
|
|
3929
|
-
// held 7 starts against 25 stops, one of them an agent type this
|
|
3930
|
-
// session never dispatched. The open record already carried it; the
|
|
3931
|
-
// appended line did not, and the line is what a rate is computed from.
|
|
3932
|
-
session_id: sessionId,
|
|
3933
|
-
agent_type: rec.agent_type,
|
|
3934
|
-
parent_ref: parentRef,
|
|
3935
|
-
depth,
|
|
3936
|
-
depth_basis,
|
|
3937
|
-
concurrent_open: countOpen(root)
|
|
3938
|
-
});
|
|
3939
|
-
}
|
|
3940
|
-
function handleStop(root, payload, nowIso, sessionId) {
|
|
3941
|
-
const agentId = str(payload, "agent_id", "agentId");
|
|
3942
|
-
if (agentId === null) {
|
|
3943
|
-
appendUnidentified(root, "subagent_stop", nowIso, payload);
|
|
3944
|
-
return;
|
|
3945
|
-
}
|
|
3946
|
-
const ref = refFor(agentId);
|
|
3947
|
-
const rec = readOpenRecords(root).get(ref) ?? null;
|
|
3948
|
-
let durationMs = null;
|
|
3949
|
-
if (rec) {
|
|
3950
|
-
const started = Date.parse(rec.started_at);
|
|
3951
|
-
if (Number.isFinite(started)) durationMs = Math.max(0, Date.parse(nowIso) - started);
|
|
3952
|
-
}
|
|
3953
|
-
const parse2 = classifyEnvelope(str(payload, "last_assistant_message", "lastAssistantMessage"));
|
|
3954
|
-
removeOpenRecord(root, ref);
|
|
3955
|
-
appendLedgerLine(root, nowIso, {
|
|
3956
|
-
event: "subagent_stop",
|
|
3957
|
-
ts: nowIso,
|
|
3958
|
-
ref,
|
|
3959
|
-
// The session this stop was OBSERVED in, read from the same envelope
|
|
3960
|
-
// position as the start's — never back-filled from `rec`, which would
|
|
3961
|
-
// relabel a cross-session stop as belonging to the dispatching session
|
|
3962
|
-
// and hide exactly the mismatch this field exists to expose.
|
|
3963
|
-
session_id: sessionId,
|
|
3964
|
-
agent_type: rec?.agent_type ?? str(payload, "agent_type", "agentType", "subagent_type", "subagentType"),
|
|
3965
|
-
depth: rec?.depth ?? null,
|
|
3966
|
-
depth_basis: rec?.depth_basis ?? null,
|
|
3967
|
-
// `null` = the matching start was never seen. That is a finding about
|
|
3968
|
-
// the instrument's own coverage and is recorded as such, not as 0.
|
|
3969
|
-
duration_ms: durationMs,
|
|
3970
|
-
// Phase 3 Step 3, shadow: which wall-clock arms this dispatch would
|
|
3971
|
-
// have tripped. Recorded, never acted on.
|
|
3972
|
-
stop_loss_arms_exceeded: armsExceeded(durationMs),
|
|
3973
|
-
start_seen: rec !== null,
|
|
3974
|
-
envelope_parse: parse2.verdict,
|
|
3975
|
-
envelope_error_count: parse2.error_count,
|
|
3976
|
-
// Beside the count, never instead of it: the count says how wrong the
|
|
3977
|
-
// candidate was, this says whether it was aimed at the envelope.
|
|
3978
|
-
envelope_field_hits: parse2.field_hits,
|
|
3979
|
-
concurrent_open: countOpen(root)
|
|
3980
|
-
});
|
|
3981
|
-
}
|
|
3982
|
-
function processEnvelope(envelope, consumerRoot) {
|
|
3983
|
-
try {
|
|
3984
|
-
if (!isObject2(envelope)) return EXIT_ALLOW3;
|
|
3985
|
-
const event = envelope["event"];
|
|
3986
|
-
if (event !== "subagent_start" && event !== "subagent_stop") return EXIT_ALLOW3;
|
|
3987
|
-
const payload = unwrapPayload(envelope);
|
|
3988
|
-
const nowIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
3989
|
-
const sessionId = str(payload, "session_id", "sessionId") ?? str(envelope, "session_id", "sessionId");
|
|
3990
|
-
reapStaleOpenRecords(consumerRoot, nowIso);
|
|
3991
|
-
if (event === "subagent_start") handleStart(consumerRoot, payload, nowIso, sessionId);
|
|
3992
|
-
else handleStop(consumerRoot, payload, nowIso, sessionId);
|
|
3993
|
-
} catch {
|
|
3994
|
-
return EXIT_ALLOW3;
|
|
3995
|
-
}
|
|
3996
|
-
return EXIT_ALLOW3;
|
|
3997
|
-
}
|
|
3998
|
-
function resolveConsumerRoot(envelope) {
|
|
3999
|
-
if (isObject2(envelope)) {
|
|
4000
|
-
const pr = str(envelope, "workspace_root", "project_root");
|
|
4001
|
-
if (pr) return pr;
|
|
4002
|
-
const payload = unwrapPayload(envelope);
|
|
4003
|
-
const cwd = str(payload, "cwd");
|
|
4004
|
-
if (cwd) return cwd;
|
|
4005
|
-
}
|
|
4006
|
-
return process.cwd();
|
|
4007
|
-
}
|
|
4008
|
-
function main4() {
|
|
4009
|
-
const raw = readHookStdin();
|
|
4010
|
-
let envelope = {};
|
|
4011
|
-
try {
|
|
4012
|
-
envelope = raw.trim() ? JSON.parse(raw) : {};
|
|
4013
|
-
} catch {
|
|
4014
|
-
return EXIT_ALLOW3;
|
|
4015
|
-
}
|
|
4016
|
-
return processEnvelope(envelope, resolveConsumerRoot(envelope));
|
|
4017
|
-
}
|
|
4018
|
-
function _isCliEntry4() {
|
|
4019
|
-
if (true) {
|
|
4020
|
-
return false;
|
|
4021
|
-
}
|
|
4022
|
-
if (process.argv[1] === void 0) return false;
|
|
4023
|
-
const argvUrl = pathToFileURL4(path8.resolve(process.argv[1])).href;
|
|
4024
|
-
if (import.meta.url === argvUrl) return true;
|
|
4025
|
-
try {
|
|
4026
|
-
return fs9.realpathSync(fileURLToPath4(import.meta.url)) === fs9.realpathSync(path8.resolve(process.argv[1]));
|
|
4027
|
-
} catch {
|
|
4028
|
-
return false;
|
|
4029
|
-
}
|
|
4030
|
-
}
|
|
4031
|
-
if (_isCliEntry4()) process.exit(main4());
|
|
4032
|
-
|
|
4033
3561
|
// src/scripts/_lib/turn_end_transcript.ts
|
|
4034
|
-
import * as
|
|
3562
|
+
import * as fs11 from "node:fs";
|
|
4035
3563
|
|
|
4036
3564
|
// src/scripts/hooks/end_review_nudge_hook.ts
|
|
4037
3565
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
4038
|
-
import * as
|
|
4039
|
-
import * as
|
|
3566
|
+
import * as crypto2 from "node:crypto";
|
|
3567
|
+
import * as fs10 from "node:fs";
|
|
4040
3568
|
import * as os from "node:os";
|
|
4041
|
-
import * as
|
|
4042
|
-
import { fileURLToPath as
|
|
3569
|
+
import * as path9 from "node:path";
|
|
3570
|
+
import { fileURLToPath as fileURLToPath4, pathToFileURL as pathToFileURL4 } from "node:url";
|
|
4043
3571
|
|
|
4044
3572
|
// src/scripts/_lib/review_baseline.ts
|
|
4045
3573
|
import { spawnSync } from "node:child_process";
|
|
4046
|
-
import * as
|
|
4047
|
-
import * as
|
|
3574
|
+
import * as fs9 from "node:fs";
|
|
3575
|
+
import * as path8 from "node:path";
|
|
4048
3576
|
function currentHeadSha(cwd) {
|
|
4049
3577
|
try {
|
|
4050
3578
|
const r = spawnSync("git", ["rev-parse", "HEAD"], { cwd, encoding: "utf8" });
|
|
@@ -4055,12 +3583,12 @@ function currentHeadSha(cwd) {
|
|
|
4055
3583
|
return null;
|
|
4056
3584
|
}
|
|
4057
3585
|
}
|
|
4058
|
-
var BASELINE_STATE_REL =
|
|
3586
|
+
var BASELINE_STATE_REL = path8.join("agents", "runtime", "state", "review-baseline");
|
|
4059
3587
|
function baselineStateDir(workspaceRoot) {
|
|
4060
|
-
return
|
|
3588
|
+
return path8.join(workspaceRoot, BASELINE_STATE_REL);
|
|
4061
3589
|
}
|
|
4062
3590
|
function baselineStateFile(workspaceRoot, sessionKey) {
|
|
4063
|
-
return
|
|
3591
|
+
return path8.join(baselineStateDir(workspaceRoot), `${sessionKey}.json`);
|
|
4064
3592
|
}
|
|
4065
3593
|
function parseBaseline(raw) {
|
|
4066
3594
|
let decoded;
|
|
@@ -4088,7 +3616,7 @@ function readBaseline(workspaceRoot, sessionKey) {
|
|
|
4088
3616
|
const file = baselineStateFile(workspaceRoot, sessionKey);
|
|
4089
3617
|
let raw;
|
|
4090
3618
|
try {
|
|
4091
|
-
raw =
|
|
3619
|
+
raw = fs9.readFileSync(file, "utf-8");
|
|
4092
3620
|
} catch (exc) {
|
|
4093
3621
|
const code = exc?.code;
|
|
4094
3622
|
return code === "ENOENT" ? "absent" : "unreadable";
|
|
@@ -4198,13 +3726,13 @@ function isSafeTranscriptPath(rawPath, opts = {}) {
|
|
|
4198
3726
|
const homeDir = opts.homeDir ?? os.homedir();
|
|
4199
3727
|
const maxBytes = opts.maxBytes ?? TRANSCRIPT_SCAN_MAX_BYTES;
|
|
4200
3728
|
try {
|
|
4201
|
-
const realHome =
|
|
4202
|
-
const realPath =
|
|
4203
|
-
const relative6 =
|
|
4204
|
-
if (relative6 === "" || relative6.startsWith("..") ||
|
|
3729
|
+
const realHome = fs10.realpathSync(homeDir);
|
|
3730
|
+
const realPath = fs10.realpathSync(rawPath);
|
|
3731
|
+
const relative6 = path9.relative(realHome, realPath);
|
|
3732
|
+
if (relative6 === "" || relative6.startsWith("..") || path9.isAbsolute(relative6)) {
|
|
4205
3733
|
return false;
|
|
4206
3734
|
}
|
|
4207
|
-
const { size } =
|
|
3735
|
+
const { size } = fs10.statSync(realPath);
|
|
4208
3736
|
return size <= maxBytes;
|
|
4209
3737
|
} catch {
|
|
4210
3738
|
return false;
|
|
@@ -4262,13 +3790,13 @@ var BINARY_PROBE_BYTES = 8e3;
|
|
|
4262
3790
|
var UNTRACKED_FILE_READ_CAP_BYTES = 8 * 1024 * 1024;
|
|
4263
3791
|
function untrackedFileLineCount(cwd, relPath) {
|
|
4264
3792
|
try {
|
|
4265
|
-
const abs =
|
|
4266
|
-
const size =
|
|
3793
|
+
const abs = path9.resolve(cwd, relPath);
|
|
3794
|
+
const size = fs10.statSync(abs).size;
|
|
4267
3795
|
if (size === 0) return 0;
|
|
4268
3796
|
if (size > UNTRACKED_FILE_READ_CAP_BYTES) {
|
|
4269
3797
|
return MUTATION_LINE_THRESHOLD + 1;
|
|
4270
3798
|
}
|
|
4271
|
-
const buf =
|
|
3799
|
+
const buf = fs10.readFileSync(abs);
|
|
4272
3800
|
if (buf.length === 0) return 0;
|
|
4273
3801
|
const probe = buf.subarray(0, Math.min(buf.length, BINARY_PROBE_BYTES));
|
|
4274
3802
|
if (probe.includes(0)) return 0;
|
|
@@ -4294,10 +3822,10 @@ function totalNonDocMutatedLinesWithMeasure(cwd) {
|
|
|
4294
3822
|
);
|
|
4295
3823
|
return { lines: trackedLines + untrackedLines, measure: "exact" };
|
|
4296
3824
|
}
|
|
4297
|
-
function
|
|
3825
|
+
function isObject2(v) {
|
|
4298
3826
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
4299
3827
|
}
|
|
4300
|
-
function
|
|
3828
|
+
function str(v) {
|
|
4301
3829
|
return typeof v === "string" ? v : "";
|
|
4302
3830
|
}
|
|
4303
3831
|
var DISPATCH_TOOL_RE = /^(agent|task)$/i;
|
|
@@ -4314,28 +3842,28 @@ function scanTranscriptForReviewer(transcriptText) {
|
|
|
4314
3842
|
} catch {
|
|
4315
3843
|
continue;
|
|
4316
3844
|
}
|
|
4317
|
-
if (!
|
|
3845
|
+
if (!isObject2(obj) || obj["type"] !== "assistant") continue;
|
|
4318
3846
|
const msg = obj["message"];
|
|
4319
|
-
if (!
|
|
3847
|
+
if (!isObject2(msg)) continue;
|
|
4320
3848
|
const content = msg["content"];
|
|
4321
3849
|
if (!Array.isArray(content)) continue;
|
|
4322
3850
|
for (const blk of content) {
|
|
4323
|
-
if (!
|
|
4324
|
-
const name =
|
|
3851
|
+
if (!isObject2(blk) || blk["type"] !== "tool_use") continue;
|
|
3852
|
+
const name = str(blk["name"]);
|
|
4325
3853
|
const input = blk["input"];
|
|
4326
|
-
const inputObj =
|
|
3854
|
+
const inputObj = isObject2(input) ? input : {};
|
|
4327
3855
|
if (DISPATCH_TOOL_RE.test(name)) {
|
|
4328
3856
|
const label = [
|
|
4329
|
-
|
|
4330
|
-
|
|
3857
|
+
str(inputObj["description"]),
|
|
3858
|
+
str(inputObj["subagent_type"])
|
|
4331
3859
|
].filter(Boolean).join(" ");
|
|
4332
3860
|
if (REVIEW_SHAPED_LABEL_RE.test(label)) return true;
|
|
4333
|
-
const prompt =
|
|
3861
|
+
const prompt = str(inputObj["prompt"]);
|
|
4334
3862
|
if (REVIEW_SHAPED_PROMPT_RE.test(prompt)) return true;
|
|
4335
3863
|
continue;
|
|
4336
3864
|
}
|
|
4337
3865
|
if (/^skill$/i.test(name)) {
|
|
4338
|
-
const skillName =
|
|
3866
|
+
const skillName = str(inputObj["skill"]) || str(inputObj["name"]) || str(inputObj["command"]);
|
|
4339
3867
|
if (REVIEW_SKILL_NAME_RE.test(skillName)) return true;
|
|
4340
3868
|
continue;
|
|
4341
3869
|
}
|
|
@@ -4354,33 +3882,33 @@ function appendReviewSkippedTelemetry(workspaceRoot, diffLines, mutationMeasure,
|
|
|
4354
3882
|
diff_lines: diffLines,
|
|
4355
3883
|
mutation_measure: mutationMeasure,
|
|
4356
3884
|
ts,
|
|
4357
|
-
id:
|
|
3885
|
+
id: crypto2.randomUUID(),
|
|
4358
3886
|
baseline
|
|
4359
3887
|
});
|
|
4360
3888
|
if (errors.length || line === null) return;
|
|
4361
3889
|
try {
|
|
4362
|
-
const dir =
|
|
4363
|
-
|
|
4364
|
-
const file =
|
|
4365
|
-
|
|
3890
|
+
const dir = path9.join(workspaceRoot, "agents", "runtime", "state", "audit");
|
|
3891
|
+
fs10.mkdirSync(dir, { recursive: true });
|
|
3892
|
+
const file = path9.join(dir, `${ts.slice(0, 7)}.jsonl`);
|
|
3893
|
+
fs10.appendFileSync(file, `${JSON.stringify(line)}
|
|
4366
3894
|
`, "utf8");
|
|
4367
3895
|
} catch {
|
|
4368
3896
|
}
|
|
4369
3897
|
}
|
|
4370
3898
|
function sessionStateDir(workspaceRoot) {
|
|
4371
|
-
return
|
|
3899
|
+
return path9.join(workspaceRoot, "agents", "runtime", "state", "end-review-nudge");
|
|
4372
3900
|
}
|
|
4373
3901
|
function sessionStateFile(workspaceRoot, sessionKey) {
|
|
4374
|
-
return
|
|
3902
|
+
return path9.join(sessionStateDir(workspaceRoot), `${sessionKey}.json`);
|
|
4375
3903
|
}
|
|
4376
3904
|
function deriveSessionKey2(envelope, payload) {
|
|
4377
|
-
const raw =
|
|
3905
|
+
const raw = str(envelope["session_id"]) || str(payload["transcript_path"] ?? payload["transcriptPath"]);
|
|
4378
3906
|
const material = raw || "unknown-session";
|
|
4379
|
-
return
|
|
3907
|
+
return crypto2.createHash("sha256").update(material).digest("hex");
|
|
4380
3908
|
}
|
|
4381
3909
|
function hasFiredThisSession(workspaceRoot, sessionKey) {
|
|
4382
3910
|
try {
|
|
4383
|
-
return
|
|
3911
|
+
return fs10.existsSync(sessionStateFile(workspaceRoot, sessionKey));
|
|
4384
3912
|
} catch {
|
|
4385
3913
|
return false;
|
|
4386
3914
|
}
|
|
@@ -4400,7 +3928,7 @@ var FALLBACK_TO_TELEMETRY = {
|
|
|
4400
3928
|
"head-moved": "head_moved",
|
|
4401
3929
|
"mixed-measure": "mixed_measure"
|
|
4402
3930
|
};
|
|
4403
|
-
function
|
|
3931
|
+
function main4() {
|
|
4404
3932
|
const [envelope, payload] = unwrap(_read_stdin(), "claude");
|
|
4405
3933
|
const event = String(envelope["event"] ?? "");
|
|
4406
3934
|
if (event !== "" && event !== "stop") {
|
|
@@ -4436,13 +3964,13 @@ function main5() {
|
|
|
4436
3964
|
if (hasFiredThisSession(workspace_root, sessionKey)) {
|
|
4437
3965
|
return 0;
|
|
4438
3966
|
}
|
|
4439
|
-
const transcriptPath =
|
|
3967
|
+
const transcriptPath = str(
|
|
4440
3968
|
payload["transcript_path"] ?? payload["transcriptPath"]
|
|
4441
3969
|
).trim();
|
|
4442
3970
|
let reviewerRan = false;
|
|
4443
3971
|
if (transcriptPath && isSafeTranscriptPath(transcriptPath)) {
|
|
4444
3972
|
try {
|
|
4445
|
-
reviewerRan = scanTranscriptForReviewer(
|
|
3973
|
+
reviewerRan = scanTranscriptForReviewer(fs10.readFileSync(transcriptPath, "utf-8"));
|
|
4446
3974
|
} catch {
|
|
4447
3975
|
reviewerRan = false;
|
|
4448
3976
|
}
|
|
@@ -4468,29 +3996,29 @@ function main5() {
|
|
|
4468
3996
|
})}
|
|
4469
3997
|
`
|
|
4470
3998
|
);
|
|
4471
|
-
return
|
|
3999
|
+
return EXIT_WARN;
|
|
4472
4000
|
}
|
|
4473
|
-
function
|
|
4001
|
+
function _isCliEntry4() {
|
|
4474
4002
|
if (true) {
|
|
4475
4003
|
return false;
|
|
4476
4004
|
}
|
|
4477
4005
|
if (process.argv[1] === void 0) {
|
|
4478
4006
|
return false;
|
|
4479
4007
|
}
|
|
4480
|
-
const argvUrl =
|
|
4008
|
+
const argvUrl = pathToFileURL4(path9.resolve(process.argv[1])).href;
|
|
4481
4009
|
if (import.meta.url === argvUrl) {
|
|
4482
4010
|
return true;
|
|
4483
4011
|
}
|
|
4484
4012
|
try {
|
|
4485
|
-
const here =
|
|
4486
|
-
const argv =
|
|
4013
|
+
const here = fs10.realpathSync(fileURLToPath4(import.meta.url));
|
|
4014
|
+
const argv = fs10.realpathSync(path9.resolve(process.argv[1]));
|
|
4487
4015
|
return here === argv;
|
|
4488
4016
|
} catch {
|
|
4489
4017
|
return false;
|
|
4490
4018
|
}
|
|
4491
4019
|
}
|
|
4492
|
-
if (
|
|
4493
|
-
process.exit(
|
|
4020
|
+
if (_isCliEntry4()) {
|
|
4021
|
+
process.exit(main4());
|
|
4494
4022
|
}
|
|
4495
4023
|
|
|
4496
4024
|
// src/scripts/_lib/turn_end_transcript.ts
|
|
@@ -4504,10 +4032,10 @@ function readTranscriptTail(transcriptPath, opts = {}) {
|
|
|
4504
4032
|
if (!transcriptPath || !isSafeTranscriptPath(transcriptPath, opts)) return empty;
|
|
4505
4033
|
let lines;
|
|
4506
4034
|
try {
|
|
4507
|
-
if (opts.maxBytes !== void 0 &&
|
|
4035
|
+
if (opts.maxBytes !== void 0 && fs11.statSync(transcriptPath).size > opts.maxBytes) {
|
|
4508
4036
|
return empty;
|
|
4509
4037
|
}
|
|
4510
|
-
lines =
|
|
4038
|
+
lines = fs11.readFileSync(transcriptPath, "utf-8").split("\n");
|
|
4511
4039
|
} catch {
|
|
4512
4040
|
return empty;
|
|
4513
4041
|
}
|
|
@@ -4694,7 +4222,7 @@ function detectPromissory(reply) {
|
|
|
4694
4222
|
function readCiSettled(workspaceRoot, session_id) {
|
|
4695
4223
|
if (!hasStableSessionId(session_id)) return { seen: false, settled: false };
|
|
4696
4224
|
try {
|
|
4697
|
-
const raw =
|
|
4225
|
+
const raw = fs12.readFileSync(path10.join(workspaceRoot, statePathFor(session_id)), "utf-8");
|
|
4698
4226
|
const decoded = JSON.parse(raw);
|
|
4699
4227
|
if (!owns_session_state(decoded, session_id)) return { seen: false, settled: false };
|
|
4700
4228
|
if (typeof decoded === "object" && decoded !== null && !Array.isArray(decoded)) {
|
|
@@ -4730,8 +4258,8 @@ function detectCompletionClaim(reply, ci) {
|
|
|
4730
4258
|
function readLanguagePin(workspaceRoot, session_id) {
|
|
4731
4259
|
if (!hasStableSessionId(session_id)) return "und";
|
|
4732
4260
|
try {
|
|
4733
|
-
const raw =
|
|
4734
|
-
|
|
4261
|
+
const raw = fs12.readFileSync(
|
|
4262
|
+
path10.join(workspaceRoot, statePathFor2(session_id)),
|
|
4735
4263
|
"utf-8"
|
|
4736
4264
|
);
|
|
4737
4265
|
const decoded = JSON.parse(raw);
|
|
@@ -4840,7 +4368,7 @@ function sessionStateFile2(workspaceRoot, sessionKey) {
|
|
|
4840
4368
|
}
|
|
4841
4369
|
function alreadyRefusedTurn(workspaceRoot, sessionKey, turnOrdinal) {
|
|
4842
4370
|
try {
|
|
4843
|
-
const raw =
|
|
4371
|
+
const raw = fs12.readFileSync(sessionStateFile2(workspaceRoot, sessionKey), "utf-8");
|
|
4844
4372
|
const decoded = JSON.parse(raw);
|
|
4845
4373
|
if (typeof decoded === "object" && decoded !== null && !Array.isArray(decoded)) {
|
|
4846
4374
|
return decoded["refused_turn"] === turnOrdinal;
|
|
@@ -4854,7 +4382,7 @@ function markRefusedTurn(workspaceRoot, sessionKey, turnOrdinal, detectors, prom
|
|
|
4854
4382
|
const file = sessionStateFile2(workspaceRoot, sessionKey);
|
|
4855
4383
|
let prev = null;
|
|
4856
4384
|
try {
|
|
4857
|
-
prev = parseRecord(
|
|
4385
|
+
prev = parseRecord(fs12.readFileSync(file, "utf-8"));
|
|
4858
4386
|
} catch {
|
|
4859
4387
|
}
|
|
4860
4388
|
let version;
|
|
@@ -4877,17 +4405,17 @@ function markRefusedTurn(workspaceRoot, sessionKey, turnOrdinal, detectors, prom
|
|
|
4877
4405
|
} catch {
|
|
4878
4406
|
}
|
|
4879
4407
|
}
|
|
4880
|
-
function
|
|
4408
|
+
function str2(v) {
|
|
4881
4409
|
return typeof v === "string" ? v : "";
|
|
4882
4410
|
}
|
|
4883
4411
|
function assembleDetectorInputs(envelope, payload) {
|
|
4884
|
-
const workspaceRoot =
|
|
4412
|
+
const workspaceRoot = str2(envelope["workspace_root"]) || process.cwd();
|
|
4885
4413
|
let dispatchOpen = false;
|
|
4886
4414
|
try {
|
|
4887
4415
|
dispatchOpen = openRecordStats(workspaceRoot).open_count > 0;
|
|
4888
4416
|
} catch {
|
|
4889
4417
|
}
|
|
4890
|
-
const transcriptPath =
|
|
4418
|
+
const transcriptPath = str2(
|
|
4891
4419
|
payload["transcript_path"] ?? payload["transcriptPath"]
|
|
4892
4420
|
);
|
|
4893
4421
|
const { lastAssistant, turnOrdinal, toolCalls, assistantTurnTexts } = readTranscriptTail(
|
|
@@ -4895,13 +4423,13 @@ function assembleDetectorInputs(envelope, payload) {
|
|
|
4895
4423
|
{ maxBytes: TRANSCRIPT_READ_MAX_BYTES }
|
|
4896
4424
|
);
|
|
4897
4425
|
if (!lastAssistant) return null;
|
|
4898
|
-
const payloadClosing =
|
|
4426
|
+
const payloadClosing = str2(
|
|
4899
4427
|
payload["last_assistant_message"] ?? payload["lastAssistantMessage"]
|
|
4900
4428
|
);
|
|
4901
4429
|
const closingFromPayload = payloadClosing !== "" && !assistantTurnTexts.includes(payloadClosing);
|
|
4902
4430
|
const turnTexts = closingFromPayload ? [...assistantTurnTexts, payloadClosing] : assistantTurnTexts;
|
|
4903
|
-
const promptId =
|
|
4904
|
-
const rawSessionId =
|
|
4431
|
+
const promptId = str2(payload["prompt_id"] ?? payload["promptId"]);
|
|
4432
|
+
const rawSessionId = str2(envelope["session_id"]) || "";
|
|
4905
4433
|
const sessionKey = deriveSessionKey(rawSessionId || "unknown-session");
|
|
4906
4434
|
const runState = readTurnRunState(workspaceRoot, rawSessionId);
|
|
4907
4435
|
return {
|
|
@@ -4951,7 +4479,7 @@ function runDetectors(inputs) {
|
|
|
4951
4479
|
// on a completion CLAIM, and a turn waiting on a subagent has not
|
|
4952
4480
|
// finished — so its closing is not the claim F is about. Same slot,
|
|
4953
4481
|
// opposite trigger, opposite treatment of `dispatchOpen`.
|
|
4954
|
-
openSvgObligation(workspaceRoot, toolCalls),
|
|
4482
|
+
openSvgObligation(workspaceRoot, toolCalls, runState?.asset_renders ?? null),
|
|
4955
4483
|
dispatchOpen ? null : detectUntestedChange(lastAssistant, toolCalls, runState)
|
|
4956
4484
|
]) {
|
|
4957
4485
|
if (f) findings.push(f);
|
|
@@ -4996,7 +4524,7 @@ function recordShadow(inputs, layer) {
|
|
|
4996
4524
|
const file = sessionShadowFile(inputs.workspaceRoot, inputs.sessionKey);
|
|
4997
4525
|
let prev = null;
|
|
4998
4526
|
try {
|
|
4999
|
-
prev = parseShadowRecord(
|
|
4527
|
+
prev = parseShadowRecord(fs12.readFileSync(file, "utf-8"));
|
|
5000
4528
|
} catch {
|
|
5001
4529
|
}
|
|
5002
4530
|
atomic_write_json(
|
|
@@ -5012,13 +4540,13 @@ function recordShadow(inputs, layer) {
|
|
|
5012
4540
|
} catch {
|
|
5013
4541
|
}
|
|
5014
4542
|
}
|
|
5015
|
-
function
|
|
4543
|
+
function main5() {
|
|
5016
4544
|
let envelope;
|
|
5017
4545
|
let payload;
|
|
5018
4546
|
try {
|
|
5019
4547
|
[envelope, payload] = unwrap(readHookStdin(), "claude");
|
|
5020
4548
|
} catch {
|
|
5021
|
-
return
|
|
4549
|
+
return EXIT_ALLOW;
|
|
5022
4550
|
}
|
|
5023
4551
|
if (payload["stop_hook_active"] === true) {
|
|
5024
4552
|
try {
|
|
@@ -5026,17 +4554,17 @@ function main6() {
|
|
|
5026
4554
|
if (retryInputs !== null) recordShadow(retryInputs, "stop_hook_active");
|
|
5027
4555
|
} catch {
|
|
5028
4556
|
}
|
|
5029
|
-
return
|
|
4557
|
+
return EXIT_ALLOW;
|
|
5030
4558
|
}
|
|
5031
4559
|
const inputs = assembleDetectorInputs(envelope, payload);
|
|
5032
|
-
if (inputs === null) return
|
|
4560
|
+
if (inputs === null) return EXIT_ALLOW;
|
|
5033
4561
|
if (alreadyRefusedTurn(inputs.workspaceRoot, inputs.sessionKey, inputs.turnOrdinal)) {
|
|
5034
4562
|
recordShadow(inputs, "refused_turn");
|
|
5035
|
-
return
|
|
4563
|
+
return EXIT_ALLOW;
|
|
5036
4564
|
}
|
|
5037
4565
|
const findings = runDetectors(inputs);
|
|
5038
4566
|
recordGraphFeeder(inputs, findings, "live");
|
|
5039
|
-
if (findings.length === 0) return
|
|
4567
|
+
if (findings.length === 0) return EXIT_ALLOW;
|
|
5040
4568
|
markRefusedTurn(
|
|
5041
4569
|
inputs.workspaceRoot,
|
|
5042
4570
|
inputs.sessionKey,
|
|
@@ -5057,35 +4585,35 @@ ${lines.join("\n")}
|
|
|
5057
4585
|
);
|
|
5058
4586
|
return EXIT_BLOCK;
|
|
5059
4587
|
}
|
|
5060
|
-
function
|
|
4588
|
+
function _isCliEntry5() {
|
|
5061
4589
|
if (true) {
|
|
5062
4590
|
return false;
|
|
5063
4591
|
}
|
|
5064
4592
|
if (process.argv[1] === void 0) {
|
|
5065
4593
|
return false;
|
|
5066
4594
|
}
|
|
5067
|
-
const argvUrl =
|
|
4595
|
+
const argvUrl = pathToFileURL5(path10.resolve(process.argv[1])).href;
|
|
5068
4596
|
if (import.meta.url === argvUrl) {
|
|
5069
4597
|
return true;
|
|
5070
4598
|
}
|
|
5071
4599
|
try {
|
|
5072
|
-
const here =
|
|
5073
|
-
const argv =
|
|
4600
|
+
const here = fs12.realpathSync(fileURLToPath5(import.meta.url));
|
|
4601
|
+
const argv = fs12.realpathSync(path10.resolve(process.argv[1]));
|
|
5074
4602
|
return here === argv;
|
|
5075
4603
|
} catch {
|
|
5076
4604
|
return false;
|
|
5077
4605
|
}
|
|
5078
4606
|
}
|
|
5079
|
-
if (
|
|
5080
|
-
process.exit(
|
|
4607
|
+
if (_isCliEntry5()) {
|
|
4608
|
+
process.exit(main5());
|
|
5081
4609
|
}
|
|
5082
4610
|
|
|
5083
4611
|
// src/scripts/hooks/evidence_independence.ts
|
|
5084
4612
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
5085
|
-
import
|
|
5086
|
-
import
|
|
5087
|
-
import
|
|
5088
|
-
import { fileURLToPath as
|
|
4613
|
+
import crypto3 from "node:crypto";
|
|
4614
|
+
import fs13 from "node:fs";
|
|
4615
|
+
import path11 from "node:path";
|
|
4616
|
+
import { fileURLToPath as fileURLToPath6, pathToFileURL as pathToFileURL6 } from "node:url";
|
|
5089
4617
|
|
|
5090
4618
|
// src/scripts/_lib/test_delta.ts
|
|
5091
4619
|
function isCodePath(p) {
|
|
@@ -5103,7 +4631,7 @@ function isTestPath(p) {
|
|
|
5103
4631
|
}
|
|
5104
4632
|
|
|
5105
4633
|
// src/scripts/hooks/evidence_independence.ts
|
|
5106
|
-
var STATE_FILE3 =
|
|
4634
|
+
var STATE_FILE3 = path11.join("agents", "state", "evidence-dispatch.json");
|
|
5107
4635
|
function _isObject5(v) {
|
|
5108
4636
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
5109
4637
|
}
|
|
@@ -5171,8 +4699,8 @@ function extractDispatch(envelope) {
|
|
|
5171
4699
|
}
|
|
5172
4700
|
function _ledgerStamp(consumer_root, session_id) {
|
|
5173
4701
|
try {
|
|
5174
|
-
const raw =
|
|
5175
|
-
|
|
4702
|
+
const raw = fs13.readFileSync(
|
|
4703
|
+
path11.join(consumer_root, ledgerFileFor(session_id)),
|
|
5176
4704
|
"utf8"
|
|
5177
4705
|
);
|
|
5178
4706
|
const d = JSON.parse(raw);
|
|
@@ -5183,7 +4711,7 @@ function _ledgerStamp(consumer_root, session_id) {
|
|
|
5183
4711
|
}
|
|
5184
4712
|
function _load(target) {
|
|
5185
4713
|
try {
|
|
5186
|
-
const decoded = JSON.parse(
|
|
4714
|
+
const decoded = JSON.parse(fs13.readFileSync(target, "utf8"));
|
|
5187
4715
|
if (_isObject5(decoded) && Array.isArray(decoded["evaluations"])) {
|
|
5188
4716
|
return decoded;
|
|
5189
4717
|
}
|
|
@@ -5194,7 +4722,7 @@ function _load(target) {
|
|
|
5194
4722
|
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.";
|
|
5195
4723
|
function decide(tool, prompt, priorEvaluations) {
|
|
5196
4724
|
if (!isDispatchTool(tool) || !isEvaluationPrompt(prompt)) {
|
|
5197
|
-
return { exit:
|
|
4725
|
+
return { exit: EXIT_ALLOW, stdout: "", stderr: "", evaluations: priorEvaluations };
|
|
5198
4726
|
}
|
|
5199
4727
|
const preloaded = preloadedVerdict(prompt);
|
|
5200
4728
|
if (preloaded !== null) {
|
|
@@ -5207,11 +4735,11 @@ function decide(tool, prompt, priorEvaluations) {
|
|
|
5207
4735
|
};
|
|
5208
4736
|
}
|
|
5209
4737
|
if (!isSelfScoped(prompt)) {
|
|
5210
|
-
return { exit:
|
|
4738
|
+
return { exit: EXIT_ALLOW, stdout: "", stderr: "", evaluations: priorEvaluations };
|
|
5211
4739
|
}
|
|
5212
4740
|
if (priorEvaluations >= 1) {
|
|
5213
4741
|
return {
|
|
5214
|
-
exit:
|
|
4742
|
+
exit: EXIT_ALLOW,
|
|
5215
4743
|
stdout: `${JSON.stringify({
|
|
5216
4744
|
decision: "warn",
|
|
5217
4745
|
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.`
|
|
@@ -5222,7 +4750,7 @@ function decide(tool, prompt, priorEvaluations) {
|
|
|
5222
4750
|
};
|
|
5223
4751
|
}
|
|
5224
4752
|
return {
|
|
5225
|
-
exit:
|
|
4753
|
+
exit: EXIT_ALLOW,
|
|
5226
4754
|
stdout: `${JSON.stringify({ decision: "warn", reason: WARN_TEXT })}
|
|
5227
4755
|
`,
|
|
5228
4756
|
stderr: "",
|
|
@@ -5264,10 +4792,10 @@ function run3(stdin_text, options) {
|
|
|
5264
4792
|
envelope = decoded;
|
|
5265
4793
|
}
|
|
5266
4794
|
} catch {
|
|
5267
|
-
return
|
|
4795
|
+
return EXIT_ALLOW;
|
|
5268
4796
|
}
|
|
5269
4797
|
}
|
|
5270
|
-
const target =
|
|
4798
|
+
const target = path11.join(options.consumer_root, STATE_FILE3);
|
|
5271
4799
|
const state = _load(target);
|
|
5272
4800
|
const session_id = typeof envelope["session_id"] === "string" ? envelope["session_id"] : "";
|
|
5273
4801
|
const turnMarker = `${session_id}:${_ledgerStamp(options.consumer_root, session_id)}`;
|
|
@@ -5283,14 +4811,14 @@ function run3(stdin_text, options) {
|
|
|
5283
4811
|
if (staged !== null && touchesTestAndCode(staged)) {
|
|
5284
4812
|
process.stdout.write(`${JSON.stringify({ decision: "warn", reason: flag })}
|
|
5285
4813
|
`);
|
|
5286
|
-
return
|
|
4814
|
+
return EXIT_ALLOW;
|
|
5287
4815
|
}
|
|
5288
4816
|
}
|
|
5289
4817
|
const decision = decide(tool, prompt, state.evaluations.length);
|
|
5290
4818
|
if (decision.evaluations > state.evaluations.length) {
|
|
5291
4819
|
state.evaluations.push({
|
|
5292
4820
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5293
|
-
digest:
|
|
4821
|
+
digest: crypto3.createHash("sha256").update(prompt).digest("hex").slice(0, 16),
|
|
5294
4822
|
prompt_chars: prompt.length
|
|
5295
4823
|
});
|
|
5296
4824
|
try {
|
|
@@ -5314,7 +4842,7 @@ function _errText3(err) {
|
|
|
5314
4842
|
const t = err instanceof Error ? err.message : String(err);
|
|
5315
4843
|
return t.replace(/\s+/g, " ").trim().slice(0, 200);
|
|
5316
4844
|
}
|
|
5317
|
-
function
|
|
4845
|
+
function main6(argv) {
|
|
5318
4846
|
const args = argv ?? process.argv.slice(2);
|
|
5319
4847
|
let consumer_root = process.cwd();
|
|
5320
4848
|
for (let i = 0; i < args.length; i += 1) {
|
|
@@ -5328,33 +4856,33 @@ function main7(argv) {
|
|
|
5328
4856
|
}
|
|
5329
4857
|
return run3(readHookStdin(), { consumer_root });
|
|
5330
4858
|
}
|
|
5331
|
-
function
|
|
4859
|
+
function _isCliEntry6() {
|
|
5332
4860
|
if (true) {
|
|
5333
4861
|
return false;
|
|
5334
4862
|
}
|
|
5335
4863
|
if (process.argv[1] === void 0) {
|
|
5336
4864
|
return false;
|
|
5337
4865
|
}
|
|
5338
|
-
const argvUrl =
|
|
4866
|
+
const argvUrl = pathToFileURL6(path11.resolve(process.argv[1])).href;
|
|
5339
4867
|
if (import.meta.url === argvUrl) {
|
|
5340
4868
|
return true;
|
|
5341
4869
|
}
|
|
5342
4870
|
try {
|
|
5343
|
-
const here =
|
|
5344
|
-
const argv =
|
|
4871
|
+
const here = fs13.realpathSync(fileURLToPath6(import.meta.url));
|
|
4872
|
+
const argv = fs13.realpathSync(path11.resolve(process.argv[1]));
|
|
5345
4873
|
return here === argv;
|
|
5346
4874
|
} catch {
|
|
5347
4875
|
return false;
|
|
5348
4876
|
}
|
|
5349
4877
|
}
|
|
5350
|
-
if (
|
|
5351
|
-
process.exit(
|
|
4878
|
+
if (_isCliEntry6()) {
|
|
4879
|
+
process.exit(main6());
|
|
5352
4880
|
}
|
|
5353
4881
|
|
|
5354
4882
|
// src/scripts/hooks/delegation_nudge_hook.ts
|
|
5355
|
-
import
|
|
4883
|
+
import fs16 from "node:fs";
|
|
5356
4884
|
import path13 from "node:path";
|
|
5357
|
-
import { fileURLToPath as
|
|
4885
|
+
import { fileURLToPath as fileURLToPath7, pathToFileURL as pathToFileURL7 } from "node:url";
|
|
5358
4886
|
|
|
5359
4887
|
// src/scripts/_lib/auto_dispatch.ts
|
|
5360
4888
|
var SIZE_FLOOR = 1;
|
|
@@ -5424,6 +4952,29 @@ function classifyLookup(taskText, opts = {}) {
|
|
|
5424
4952
|
reason: "not lookup-shaped \u2014 regular classification path (never down-guessed)"
|
|
5425
4953
|
};
|
|
5426
4954
|
}
|
|
4955
|
+
function inferSliceTier(signals) {
|
|
4956
|
+
const guard = signals.exceeds_mechanical_envelope === true;
|
|
4957
|
+
switch (signals.slice_type) {
|
|
4958
|
+
case "read-only-fanout":
|
|
4959
|
+
case "mechanical-covered": {
|
|
4960
|
+
if (guard) {
|
|
4961
|
+
return {
|
|
4962
|
+
tier: "medium",
|
|
4963
|
+
tier_source: "inferred",
|
|
4964
|
+
reason: `${signals.slice_type} slice, but scope exceeds the mechanical envelope \u2014 lite candidacy revoked`
|
|
4965
|
+
};
|
|
4966
|
+
}
|
|
4967
|
+
const cascade = signals.slice_type === "mechanical-covered" ? " (verify-fail escalates to medium)" : "";
|
|
4968
|
+
return { tier: "lite", tier_source: "inferred", reason: `${signals.slice_type} slice${cascade}` };
|
|
4969
|
+
}
|
|
4970
|
+
case "mutating-uncovered":
|
|
4971
|
+
return { tier: "medium", tier_source: "inferred", reason: "mutating slice without test coverage" };
|
|
4972
|
+
case "synthesis":
|
|
4973
|
+
return { tier: "medium", tier_source: "inferred", reason: "synthesis/judgment slice \u2014 judge one tier up" };
|
|
4974
|
+
default:
|
|
4975
|
+
return { tier: "inherit", tier_source: "inherit", reason: "unknown/ambiguous slice type \u2014 session tier, never guess down" };
|
|
4976
|
+
}
|
|
4977
|
+
}
|
|
5427
4978
|
|
|
5428
4979
|
// src/scripts/_lib/judgment_ladder.ts
|
|
5429
4980
|
var RENAME_RE = /\brename\s+\S+\s+to\s+\S+\b/i;
|
|
@@ -5633,6 +5184,86 @@ function resolveSubagentRouting(inp) {
|
|
|
5633
5184
|
};
|
|
5634
5185
|
}
|
|
5635
5186
|
|
|
5187
|
+
// src/scripts/_lib/hand_kinds.ts
|
|
5188
|
+
var HAND_KINDS = [
|
|
5189
|
+
"classify",
|
|
5190
|
+
"extract",
|
|
5191
|
+
"summarise-given-text",
|
|
5192
|
+
"draft-candidate",
|
|
5193
|
+
"test-candidates",
|
|
5194
|
+
"finding-proposal"
|
|
5195
|
+
];
|
|
5196
|
+
var HEAD_ONLY_KINDS = ["plan", "decide", "chair", "final-review", "write"];
|
|
5197
|
+
var _KINDS = new Set(HAND_KINDS);
|
|
5198
|
+
var _HEAD_ONLY = new Set(HEAD_ONLY_KINDS);
|
|
5199
|
+
var KIND_FROM_PROMPT = [
|
|
5200
|
+
[/^\s*(?:propose|suggest|draft|write)\s+(?:unit\s+)?test(?:s|\s+cases?|\s+candidates?)?\b/i, "test-candidates"],
|
|
5201
|
+
[/^\s*(?:propose|list)\s+(?:review\s+)?findings?\b/i, "finding-proposal"],
|
|
5202
|
+
[/^\s*(?:classify|categori[sz]e|label)\b/i, "classify"],
|
|
5203
|
+
[/^\s*extract\b/i, "extract"],
|
|
5204
|
+
[/^\s*summari[sz]e\b/i, "summarise-given-text"],
|
|
5205
|
+
[/^\s*draft\b/i, "draft-candidate"]
|
|
5206
|
+
];
|
|
5207
|
+
function handKindFromPrompt(text) {
|
|
5208
|
+
for (const [re, kind] of KIND_FROM_PROMPT) if (re.test(text)) return kind;
|
|
5209
|
+
return null;
|
|
5210
|
+
}
|
|
5211
|
+
|
|
5212
|
+
// src/scripts/ai_council/free_rung.ts
|
|
5213
|
+
var import_yaml = __toESM(require_dist(), 1);
|
|
5214
|
+
import * as fs15 from "node:fs";
|
|
5215
|
+
|
|
5216
|
+
// src/scripts/ai_council/kind_flip_state.ts
|
|
5217
|
+
import * as fs14 from "node:fs";
|
|
5218
|
+
import * as path12 from "node:path";
|
|
5219
|
+
var KIND_FLIPS_RELPATH = path12.join("agents", "runtime", "state", "hand-kind-flips.json");
|
|
5220
|
+
function isKindFlipped(stateRoot, kind) {
|
|
5221
|
+
try {
|
|
5222
|
+
const raw = JSON.parse(fs14.readFileSync(path12.join(stateRoot, KIND_FLIPS_RELPATH), "utf8"));
|
|
5223
|
+
return raw.kinds?.[kind]?.route === "free";
|
|
5224
|
+
} catch {
|
|
5225
|
+
return false;
|
|
5226
|
+
}
|
|
5227
|
+
}
|
|
5228
|
+
|
|
5229
|
+
// src/scripts/ai_council/free_rung.ts
|
|
5230
|
+
var COUNCIL_CONFIG_ENV = "AI_COUNCIL_CONFIG";
|
|
5231
|
+
var COUNCIL_CONFIG_REL = "settings/.ai-council.yml";
|
|
5232
|
+
function keyPresent(ref) {
|
|
5233
|
+
if (ref === void 0 || ref === null) return true;
|
|
5234
|
+
if (typeof ref !== "string" || !ref.startsWith("env:")) return false;
|
|
5235
|
+
return (process.env[ref.slice(4)] ?? "") !== "";
|
|
5236
|
+
}
|
|
5237
|
+
function freeRouteAvailable(configPath) {
|
|
5238
|
+
let raw;
|
|
5239
|
+
try {
|
|
5240
|
+
raw = (0, import_yaml.parse)(fs15.readFileSync(configPath, "utf-8"), { version: "1.1" });
|
|
5241
|
+
} catch {
|
|
5242
|
+
return false;
|
|
5243
|
+
}
|
|
5244
|
+
const members = raw?.members;
|
|
5245
|
+
if (members === null || typeof members !== "object") return false;
|
|
5246
|
+
for (const [name, value] of Object.entries(members)) {
|
|
5247
|
+
if (value === null || typeof value !== "object") continue;
|
|
5248
|
+
const cfg = value;
|
|
5249
|
+
if (cfg["enabled"] !== true) continue;
|
|
5250
|
+
const parsed = parseRouteFields(name, cfg, false);
|
|
5251
|
+
if ("error" in parsed || parsed.route === null) continue;
|
|
5252
|
+
const model = typeof cfg["model"] === "string" ? cfg["model"] : "";
|
|
5253
|
+
const t = resolveRouteTransport({ name, route: parsed.route, model, contentClass: "public-artifact", keyPresent: keyPresent(cfg["api_key_ref"]) });
|
|
5254
|
+
if (t.available && t.billing !== "per-token") return true;
|
|
5255
|
+
}
|
|
5256
|
+
return false;
|
|
5257
|
+
}
|
|
5258
|
+
function councilConfigPath() {
|
|
5259
|
+
const override = process.env[COUNCIL_CONFIG_ENV];
|
|
5260
|
+
if (override) return override.startsWith("~/") ? `${process.env["HOME"] ?? ""}${override.slice(1)}` : override;
|
|
5261
|
+
return resolve_with_fallback(COUNCIL_CONFIG_REL, { env: null });
|
|
5262
|
+
}
|
|
5263
|
+
function freeRungFor(stateRoot, kind, configPath) {
|
|
5264
|
+
return isKindFlipped(stateRoot, kind) && configPath !== null && freeRouteAvailable(configPath);
|
|
5265
|
+
}
|
|
5266
|
+
|
|
5636
5267
|
// src/scripts/hooks/delegation_nudge_hook.ts
|
|
5637
5268
|
function _isObject6(v) {
|
|
5638
5269
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -5725,10 +5356,10 @@ function resolveActivation(workspace_root, hostId) {
|
|
|
5725
5356
|
agentTeams: host_manifest.agent_teams
|
|
5726
5357
|
};
|
|
5727
5358
|
}
|
|
5728
|
-
function recommendSliceTier(downshift, separate_quota_pool) {
|
|
5359
|
+
function recommendSliceTier(downshift, separate_quota_pool, sliceKind = "unknown") {
|
|
5729
5360
|
const decision = resolveSubagentRouting({
|
|
5730
|
-
task_tier:
|
|
5731
|
-
session_tier: "
|
|
5361
|
+
task_tier: inferSliceTier({ slice_type: sliceKind }).tier,
|
|
5362
|
+
session_tier: "inherit",
|
|
5732
5363
|
downshift,
|
|
5733
5364
|
quota_arbitrage: false,
|
|
5734
5365
|
model_map: {},
|
|
@@ -5736,9 +5367,18 @@ function recommendSliceTier(downshift, separate_quota_pool) {
|
|
|
5736
5367
|
});
|
|
5737
5368
|
return decision.tier;
|
|
5738
5369
|
}
|
|
5739
|
-
|
|
5370
|
+
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;
|
|
5371
|
+
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;
|
|
5372
|
+
function sliceKindFromPrompt(prompt) {
|
|
5373
|
+
return READ_ONLY_FANOUT_RE.test(prompt) && !MUTATING_RE.test(prompt) ? "read-only-fanout" : "unknown";
|
|
5374
|
+
}
|
|
5375
|
+
var LEG_COLD_START_UNCACHED_TOKENS = 182257;
|
|
5376
|
+
function buildNudgeLine(rung, classification, sliceCount, tier, sliceKind, handKind) {
|
|
5740
5377
|
const unit = sliceCount === 1 ? "slice" : "slices";
|
|
5741
5378
|
const rungLabel = rung === null ? "rung-?" : `rung-${rung}`;
|
|
5379
|
+
if (rung === 0.5 && handKind !== void 0) {
|
|
5380
|
+
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>`;
|
|
5381
|
+
}
|
|
5742
5382
|
if (rung === 0.5) {
|
|
5743
5383
|
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>`;
|
|
5744
5384
|
}
|
|
@@ -5749,9 +5389,12 @@ function buildNudgeLine(rung, classification, sliceCount, tier) {
|
|
|
5749
5389
|
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>`;
|
|
5750
5390
|
}
|
|
5751
5391
|
const modeLabel = classification.mode ?? "single-slice";
|
|
5752
|
-
|
|
5392
|
+
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.` : "";
|
|
5393
|
+
const model = tier === "lite" && sliceKind !== void 0 && sliceKind !== "unknown" ? TIER_TO_CLAUDE_MODEL[tier] : void 0;
|
|
5394
|
+
const carrier = model ? ` Pass \`model: "${model}"\` on each Agent call (${sliceKind} slices earn lite).` : "";
|
|
5395
|
+
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>`;
|
|
5753
5396
|
}
|
|
5754
|
-
function classifyPrompt(prompt, workspace_root, hostId) {
|
|
5397
|
+
function classifyPrompt(prompt, workspace_root, hostId, opts = {}) {
|
|
5755
5398
|
try {
|
|
5756
5399
|
const { signals, sliceCountForLine } = extractTaskSignals(prompt);
|
|
5757
5400
|
const { activation, downshift, separate_quota_pool, agentTeams } = resolveActivation(
|
|
@@ -5771,13 +5414,28 @@ function classifyPrompt(prompt, workspace_root, hostId) {
|
|
|
5771
5414
|
classification: { delegable: false, action: "ask", mode: null, reason: ladder.reason },
|
|
5772
5415
|
sliceCount: 0,
|
|
5773
5416
|
tier: recommendSliceTier(downshift, separate_quota_pool),
|
|
5417
|
+
sliceKind: "unknown",
|
|
5774
5418
|
rung: ladder.rung
|
|
5775
5419
|
};
|
|
5776
5420
|
}
|
|
5421
|
+
if (ladder.rung === 0.5 && opts.freeRouteAdmissible !== void 0) {
|
|
5422
|
+
const handKind = handKindFromPrompt(prompt);
|
|
5423
|
+
if (handKind !== null && opts.freeRouteAdmissible(handKind)) {
|
|
5424
|
+
return {
|
|
5425
|
+
classification: { delegable: false, action: "ask", mode: null, reason: ladder.reason },
|
|
5426
|
+
sliceCount: 0,
|
|
5427
|
+
tier: recommendSliceTier(downshift, separate_quota_pool),
|
|
5428
|
+
sliceKind: "unknown",
|
|
5429
|
+
rung: ladder.rung,
|
|
5430
|
+
handKind
|
|
5431
|
+
};
|
|
5432
|
+
}
|
|
5433
|
+
}
|
|
5777
5434
|
if (ladder.verdict !== "subagent") {
|
|
5778
5435
|
return null;
|
|
5779
5436
|
}
|
|
5780
|
-
const
|
|
5437
|
+
const sliceKind = sliceKindFromPrompt(prompt);
|
|
5438
|
+
const tier = recommendSliceTier(downshift, separate_quota_pool, sliceKind);
|
|
5781
5439
|
const sliceCount = ladder.rung === 1 ? 1 : sliceCountForLine;
|
|
5782
5440
|
const classification = {
|
|
5783
5441
|
delegable: true,
|
|
@@ -5785,7 +5443,7 @@ function classifyPrompt(prompt, workspace_root, hostId) {
|
|
|
5785
5443
|
mode: ladder.mode ?? null,
|
|
5786
5444
|
reason: ladder.reason
|
|
5787
5445
|
};
|
|
5788
|
-
return { classification, sliceCount, tier, rung: ladder.rung };
|
|
5446
|
+
return { classification, sliceCount, tier, sliceKind, rung: ladder.rung };
|
|
5789
5447
|
} catch {
|
|
5790
5448
|
return null;
|
|
5791
5449
|
}
|
|
@@ -5806,70 +5464,79 @@ function _workspaceRoot(envelope) {
|
|
|
5806
5464
|
}
|
|
5807
5465
|
return process.cwd();
|
|
5808
5466
|
}
|
|
5809
|
-
function
|
|
5467
|
+
function main7() {
|
|
5810
5468
|
let envelope = {};
|
|
5811
5469
|
try {
|
|
5812
5470
|
const raw = readHookStdin();
|
|
5813
5471
|
envelope = raw.trim() ? JSON.parse(raw) : {};
|
|
5814
5472
|
} catch {
|
|
5815
|
-
return
|
|
5473
|
+
return EXIT_ALLOW;
|
|
5816
5474
|
}
|
|
5817
5475
|
const env = _isObject6(envelope) ? envelope : {};
|
|
5818
5476
|
const event = env["event"];
|
|
5819
5477
|
const slot = typeof event === "string" && event !== "" ? event : "user_prompt_submit";
|
|
5820
5478
|
if (slot !== "user_prompt_submit") {
|
|
5821
|
-
return
|
|
5479
|
+
return EXIT_ALLOW;
|
|
5822
5480
|
}
|
|
5823
5481
|
const payload = _isObject6(env["payload"]) ? env["payload"] : env;
|
|
5824
5482
|
const prompt = _extractPrompt2(payload);
|
|
5825
5483
|
if (!prompt) {
|
|
5826
|
-
return
|
|
5484
|
+
return EXIT_ALLOW;
|
|
5827
5485
|
}
|
|
5828
5486
|
if (isSyntheticPrompt(prompt)) {
|
|
5829
|
-
return
|
|
5487
|
+
return EXIT_ALLOW;
|
|
5830
5488
|
}
|
|
5831
5489
|
const root = _workspaceRoot(env);
|
|
5832
5490
|
const platform = env["platform"];
|
|
5833
5491
|
const hostId = typeof platform === "string" && platform ? platform : null;
|
|
5834
|
-
const result = classifyPrompt(prompt, root, hostId
|
|
5492
|
+
const result = classifyPrompt(prompt, root, hostId, {
|
|
5493
|
+
freeRouteAdmissible: (kind) => freeRungFor(root, kind, councilConfigPath())
|
|
5494
|
+
});
|
|
5835
5495
|
if (!result) {
|
|
5836
|
-
return
|
|
5496
|
+
return EXIT_ALLOW;
|
|
5837
5497
|
}
|
|
5838
5498
|
process.stdout.write(
|
|
5839
5499
|
`${JSON.stringify({
|
|
5840
5500
|
decision: "warn",
|
|
5841
5501
|
reason: `delegation-nudge: rung-${result.rung} verdict (${result.sliceCount} slices, ${result.tier} tier)`,
|
|
5842
|
-
additional_context: buildNudgeLine(
|
|
5502
|
+
additional_context: buildNudgeLine(
|
|
5503
|
+
result.rung,
|
|
5504
|
+
result.classification,
|
|
5505
|
+
result.sliceCount,
|
|
5506
|
+
result.tier,
|
|
5507
|
+
result.sliceKind,
|
|
5508
|
+
result.handKind
|
|
5509
|
+
)
|
|
5843
5510
|
})}
|
|
5844
5511
|
`
|
|
5845
5512
|
);
|
|
5846
|
-
return
|
|
5513
|
+
return EXIT_WARN;
|
|
5847
5514
|
}
|
|
5848
|
-
function
|
|
5515
|
+
function _isCliEntry7() {
|
|
5849
5516
|
if (true) {
|
|
5850
5517
|
return false;
|
|
5851
5518
|
}
|
|
5852
5519
|
if (process.argv[1] === void 0) {
|
|
5853
5520
|
return false;
|
|
5854
5521
|
}
|
|
5855
|
-
const argvUrl =
|
|
5522
|
+
const argvUrl = pathToFileURL7(path13.resolve(process.argv[1])).href;
|
|
5856
5523
|
if (import.meta.url === argvUrl) {
|
|
5857
5524
|
return true;
|
|
5858
5525
|
}
|
|
5859
5526
|
try {
|
|
5860
|
-
const here =
|
|
5861
|
-
const argv =
|
|
5527
|
+
const here = fs16.realpathSync(fileURLToPath7(import.meta.url));
|
|
5528
|
+
const argv = fs16.realpathSync(path13.resolve(process.argv[1]));
|
|
5862
5529
|
return here === argv;
|
|
5863
5530
|
} catch {
|
|
5864
5531
|
return false;
|
|
5865
5532
|
}
|
|
5866
5533
|
}
|
|
5867
|
-
if (
|
|
5868
|
-
process.exit(
|
|
5534
|
+
if (_isCliEntry7()) {
|
|
5535
|
+
process.exit(main7());
|
|
5869
5536
|
}
|
|
5870
5537
|
|
|
5871
5538
|
// src/scripts/conformance_scan.ts
|
|
5872
|
-
var REPO_ROOT = path14.resolve(path14.dirname(
|
|
5539
|
+
var REPO_ROOT = path14.resolve(path14.dirname(fileURLToPath8(import.meta.url)), "..", "..");
|
|
5873
5540
|
var OBSERVED_BAND = { low: 9.1, high: 39.2 };
|
|
5874
5541
|
var BAND_MIN_TURNS = 1978;
|
|
5875
5542
|
var CARRIER_CHANGES = [
|
|
@@ -6255,13 +5922,13 @@ function measureDelivered(projectRulesDir, globalRulesDir) {
|
|
|
6255
5922
|
return {
|
|
6256
5923
|
project: {
|
|
6257
5924
|
dir: projectRulesDir,
|
|
6258
|
-
present:
|
|
5925
|
+
present: fs17.existsSync(projectRulesDir),
|
|
6259
5926
|
files: p.files,
|
|
6260
5927
|
tokens: _tokens(p.chars)
|
|
6261
5928
|
},
|
|
6262
5929
|
global: {
|
|
6263
5930
|
dir: globalRulesDir,
|
|
6264
|
-
present:
|
|
5931
|
+
present: fs17.existsSync(globalRulesDir),
|
|
6265
5932
|
files: g.files,
|
|
6266
5933
|
tokens: _tokens(g.chars)
|
|
6267
5934
|
},
|
|
@@ -6269,13 +5936,13 @@ function measureDelivered(projectRulesDir, globalRulesDir) {
|
|
|
6269
5936
|
};
|
|
6270
5937
|
}
|
|
6271
5938
|
function storeKey(store) {
|
|
6272
|
-
return
|
|
5939
|
+
return createHash4("sha256").update(path14.resolve(store)).digest("hex").slice(0, 12);
|
|
6273
5940
|
}
|
|
6274
5941
|
function scanStore(store, limit) {
|
|
6275
|
-
const files =
|
|
5942
|
+
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);
|
|
6276
5943
|
const per_session = [];
|
|
6277
5944
|
for (const f of files) {
|
|
6278
|
-
const lines =
|
|
5945
|
+
const lines = fs17.readFileSync(path14.join(store, f), "utf8").split("\n");
|
|
6279
5946
|
const r = scanSession(f.replace(/\.jsonl$/, "").slice(0, 8), lines);
|
|
6280
5947
|
if (r.assistant_turns > 0) {
|
|
6281
5948
|
per_session.push(r);
|
|
@@ -6336,8 +6003,8 @@ function scanStore(store, limit) {
|
|
|
6336
6003
|
};
|
|
6337
6004
|
}
|
|
6338
6005
|
function recordRate(file, scanned_at, rate) {
|
|
6339
|
-
|
|
6340
|
-
|
|
6006
|
+
fs17.mkdirSync(path14.dirname(file), { recursive: true });
|
|
6007
|
+
fs17.appendFileSync(file, `${JSON.stringify({ measured_at: scanned_at, ...rate })}
|
|
6341
6008
|
`, "utf8");
|
|
6342
6009
|
}
|
|
6343
6010
|
function render(report) {
|
|
@@ -6436,7 +6103,7 @@ function render(report) {
|
|
|
6436
6103
|
lines.push(" checkbox batching \u2014 measured NOWHERE. ~5 low-severity findings.");
|
|
6437
6104
|
return lines.join("\n");
|
|
6438
6105
|
}
|
|
6439
|
-
function
|
|
6106
|
+
function main8(argv) {
|
|
6440
6107
|
const args = argv ?? process.argv.slice(2);
|
|
6441
6108
|
let store = null;
|
|
6442
6109
|
let limit = 30;
|
|
@@ -6468,14 +6135,14 @@ function main9(argv) {
|
|
|
6468
6135
|
return 2;
|
|
6469
6136
|
}
|
|
6470
6137
|
const resolved = store ?? defaultStore(process.cwd());
|
|
6471
|
-
if (!
|
|
6138
|
+
if (!fs17.existsSync(resolved)) {
|
|
6472
6139
|
process.stderr.write(`conformance:behavior: no transcript store at ${resolved}
|
|
6473
6140
|
`);
|
|
6474
6141
|
return 1;
|
|
6475
6142
|
}
|
|
6476
6143
|
const report = scanStore(resolved, Number.isFinite(limit) && limit > 0 ? limit : 30);
|
|
6477
6144
|
if (out) {
|
|
6478
|
-
|
|
6145
|
+
fs17.writeFileSync(out, `${JSON.stringify(report, null, 2)}
|
|
6479
6146
|
`, "utf8");
|
|
6480
6147
|
}
|
|
6481
6148
|
if (record) {
|
|
@@ -6483,7 +6150,7 @@ function main9(argv) {
|
|
|
6483
6150
|
}
|
|
6484
6151
|
if (why !== null) {
|
|
6485
6152
|
const id = why;
|
|
6486
|
-
|
|
6153
|
+
fs17.writeSync(
|
|
6487
6154
|
1,
|
|
6488
6155
|
json ? `${JSON.stringify(
|
|
6489
6156
|
{
|
|
@@ -6503,48 +6170,48 @@ function main9(argv) {
|
|
|
6503
6170
|
);
|
|
6504
6171
|
return 0;
|
|
6505
6172
|
}
|
|
6506
|
-
|
|
6173
|
+
fs17.writeSync(1, json ? `${JSON.stringify(report, null, 2)}
|
|
6507
6174
|
` : `${render(report)}
|
|
6508
6175
|
`);
|
|
6509
6176
|
return 0;
|
|
6510
6177
|
}
|
|
6511
|
-
function
|
|
6178
|
+
function _isCliEntry8() {
|
|
6512
6179
|
if (true) {
|
|
6513
6180
|
return false;
|
|
6514
6181
|
}
|
|
6515
6182
|
if (process.argv[1] === void 0) {
|
|
6516
6183
|
return false;
|
|
6517
6184
|
}
|
|
6518
|
-
const argvUrl =
|
|
6185
|
+
const argvUrl = pathToFileURL8(path14.resolve(process.argv[1])).href;
|
|
6519
6186
|
if (import.meta.url === argvUrl) {
|
|
6520
6187
|
return true;
|
|
6521
6188
|
}
|
|
6522
6189
|
try {
|
|
6523
|
-
const here =
|
|
6524
|
-
const argv =
|
|
6190
|
+
const here = fs17.realpathSync(fileURLToPath8(import.meta.url));
|
|
6191
|
+
const argv = fs17.realpathSync(path14.resolve(process.argv[1]));
|
|
6525
6192
|
return here === argv;
|
|
6526
6193
|
} catch {
|
|
6527
6194
|
return false;
|
|
6528
6195
|
}
|
|
6529
6196
|
}
|
|
6530
|
-
if (
|
|
6531
|
-
process.exit(
|
|
6197
|
+
if (_isCliEntry8()) {
|
|
6198
|
+
process.exit(main8());
|
|
6532
6199
|
}
|
|
6533
6200
|
|
|
6534
6201
|
// src/scripts/report_carrier_divergence.ts
|
|
6535
|
-
import * as
|
|
6202
|
+
import * as fs18 from "node:fs";
|
|
6536
6203
|
import * as os3 from "node:os";
|
|
6537
6204
|
import * as path15 from "node:path";
|
|
6538
6205
|
import process2 from "node:process";
|
|
6539
|
-
import { fileURLToPath as
|
|
6540
|
-
var _HERE2 =
|
|
6206
|
+
import { fileURLToPath as fileURLToPath9, pathToFileURL as pathToFileURL9 } from "node:url";
|
|
6207
|
+
var _HERE2 = fileURLToPath9(import.meta.url);
|
|
6541
6208
|
var REPO_ROOT2 = path15.resolve(path15.dirname(_HERE2), "..", "..");
|
|
6542
6209
|
var PROJECT_RULES = path15.join(".claude", "rules");
|
|
6543
6210
|
var PROJECTION_SOURCE = path15.join("dist", "agent-src", "rules");
|
|
6544
6211
|
var GLOBAL_RULES = path15.join(".claude", "rules");
|
|
6545
6212
|
function _listRules(dir) {
|
|
6546
6213
|
try {
|
|
6547
|
-
return
|
|
6214
|
+
return fs18.readdirSync(dir).filter((f) => f.endsWith(".md")).sort();
|
|
6548
6215
|
} catch {
|
|
6549
6216
|
return [];
|
|
6550
6217
|
}
|
|
@@ -6552,7 +6219,7 @@ function _listRules(dir) {
|
|
|
6552
6219
|
function _ruleType(file) {
|
|
6553
6220
|
let text;
|
|
6554
6221
|
try {
|
|
6555
|
-
text =
|
|
6222
|
+
text = fs18.readFileSync(file, "utf-8");
|
|
6556
6223
|
} catch {
|
|
6557
6224
|
return "";
|
|
6558
6225
|
}
|
|
@@ -6563,8 +6230,8 @@ function compareCarriers(projectDir, globalDir, sourceDir) {
|
|
|
6563
6230
|
const out = {
|
|
6564
6231
|
projectDir,
|
|
6565
6232
|
globalDir,
|
|
6566
|
-
globalPresent:
|
|
6567
|
-
projectPresent:
|
|
6233
|
+
globalPresent: fs18.existsSync(globalDir),
|
|
6234
|
+
projectPresent: fs18.existsSync(projectDir),
|
|
6568
6235
|
shared: 0,
|
|
6569
6236
|
identical: [],
|
|
6570
6237
|
provenanceOnly: [],
|
|
@@ -6597,8 +6264,8 @@ function compareCarriers(projectDir, globalDir, sourceDir) {
|
|
|
6597
6264
|
let projectCopy;
|
|
6598
6265
|
let globalCopy;
|
|
6599
6266
|
try {
|
|
6600
|
-
projectCopy =
|
|
6601
|
-
globalCopy =
|
|
6267
|
+
projectCopy = fs18.readFileSync(path15.join(projectDir, rule));
|
|
6268
|
+
globalCopy = fs18.readFileSync(path15.join(globalDir, rule));
|
|
6602
6269
|
verdict = comparePair(projectCopy, globalCopy);
|
|
6603
6270
|
} catch {
|
|
6604
6271
|
out.shared -= 1;
|
|
@@ -6743,7 +6410,7 @@ function render2(d) {
|
|
|
6743
6410
|
}
|
|
6744
6411
|
return lines.join("\n");
|
|
6745
6412
|
}
|
|
6746
|
-
function
|
|
6413
|
+
function main9(argv) {
|
|
6747
6414
|
const args = argv ?? process2.argv.slice(2);
|
|
6748
6415
|
let projectDir = path15.join(REPO_ROOT2, PROJECT_RULES);
|
|
6749
6416
|
let globalDir = path15.join(os3.homedir(), GLOBAL_RULES);
|
|
@@ -6781,25 +6448,25 @@ function main10(argv) {
|
|
|
6781
6448
|
`);
|
|
6782
6449
|
return 0;
|
|
6783
6450
|
}
|
|
6784
|
-
function
|
|
6451
|
+
function _isCliEntry9() {
|
|
6785
6452
|
if (process2.argv[1] === void 0) return false;
|
|
6786
|
-
if (import.meta.url ===
|
|
6453
|
+
if (import.meta.url === pathToFileURL9(path15.resolve(process2.argv[1])).href) return true;
|
|
6787
6454
|
try {
|
|
6788
|
-
return
|
|
6455
|
+
return fs18.realpathSync(_HERE2) === fs18.realpathSync(path15.resolve(process2.argv[1]));
|
|
6789
6456
|
} catch {
|
|
6790
6457
|
return false;
|
|
6791
6458
|
}
|
|
6792
6459
|
}
|
|
6793
|
-
if (
|
|
6794
|
-
process2.exit(
|
|
6460
|
+
if (_isCliEntry9()) {
|
|
6461
|
+
process2.exit(main9());
|
|
6795
6462
|
}
|
|
6796
6463
|
|
|
6797
6464
|
// src/scripts/report_skill_activation.ts
|
|
6798
|
-
import * as
|
|
6465
|
+
import * as fs19 from "node:fs";
|
|
6799
6466
|
import * as os4 from "node:os";
|
|
6800
6467
|
import * as path16 from "node:path";
|
|
6801
|
-
import { fileURLToPath as
|
|
6802
|
-
var _HERE3 =
|
|
6468
|
+
import { fileURLToPath as fileURLToPath10, pathToFileURL as pathToFileURL10 } from "node:url";
|
|
6469
|
+
var _HERE3 = fileURLToPath10(import.meta.url);
|
|
6803
6470
|
var REPO_ROOT3 = path16.resolve(path16.dirname(_HERE3), "..", "..");
|
|
6804
6471
|
var SKILLS_ROOT = "src/skills";
|
|
6805
6472
|
var TRIGGER_KEYS = ["triggers:", "trigger_description:", "file_pattern:", "path_prefix:"];
|
|
@@ -6811,25 +6478,25 @@ function censusSkills(root) {
|
|
|
6811
6478
|
withTriggerCorpus: [],
|
|
6812
6479
|
withDeterministicObligation: []
|
|
6813
6480
|
};
|
|
6814
|
-
if (!
|
|
6481
|
+
if (!fs19.existsSync(root)) {
|
|
6815
6482
|
return out;
|
|
6816
6483
|
}
|
|
6817
|
-
for (const entry of
|
|
6484
|
+
for (const entry of fs19.readdirSync(root, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
6818
6485
|
if (!entry.isDirectory()) {
|
|
6819
6486
|
continue;
|
|
6820
6487
|
}
|
|
6821
6488
|
const file = path16.join(root, entry.name, "SKILL.md");
|
|
6822
|
-
if (!
|
|
6489
|
+
if (!fs19.existsSync(file)) {
|
|
6823
6490
|
continue;
|
|
6824
6491
|
}
|
|
6825
6492
|
out.total += 1;
|
|
6826
|
-
const text =
|
|
6493
|
+
const text = fs19.readFileSync(file, "utf8");
|
|
6827
6494
|
const fmEnd = text.startsWith("---") ? text.indexOf("\n---", 3) : -1;
|
|
6828
6495
|
const fm = fmEnd === -1 ? "" : text.slice(0, fmEnd);
|
|
6829
6496
|
if (TRIGGER_KEYS.some((k) => new RegExp(`^${k}`, "m").test(fm))) {
|
|
6830
6497
|
out.withTriggerKey.push(entry.name);
|
|
6831
6498
|
}
|
|
6832
|
-
if (
|
|
6499
|
+
if (fs19.existsSync(path16.join(root, entry.name, "evals", "triggers.json"))) {
|
|
6833
6500
|
out.withTriggerCorpus.push(entry.name);
|
|
6834
6501
|
}
|
|
6835
6502
|
const body = fmEnd === -1 ? text : text.slice(fmEnd + 4);
|
|
@@ -6844,13 +6511,13 @@ function defaultStore2(cwd) {
|
|
|
6844
6511
|
}
|
|
6845
6512
|
function measureUsage(store, limit) {
|
|
6846
6513
|
const rep = { store, sessions: 0, assistantTurns: 0, invocations: 0, bySkill: {} };
|
|
6847
|
-
if (!
|
|
6514
|
+
if (!fs19.existsSync(store)) {
|
|
6848
6515
|
return rep;
|
|
6849
6516
|
}
|
|
6850
|
-
const files =
|
|
6517
|
+
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);
|
|
6851
6518
|
rep.sessions = files.length;
|
|
6852
6519
|
for (const file of files) {
|
|
6853
|
-
for (const line of
|
|
6520
|
+
for (const line of fs19.readFileSync(file, "utf8").split("\n")) {
|
|
6854
6521
|
if (!line.trim()) {
|
|
6855
6522
|
continue;
|
|
6856
6523
|
}
|
|
@@ -6928,10 +6595,10 @@ function buildRecord(census, usage, today) {
|
|
|
6928
6595
|
}
|
|
6929
6596
|
function readRecord(repoRoot) {
|
|
6930
6597
|
const file = path16.join(repoRoot, RECORD_PATH);
|
|
6931
|
-
if (!
|
|
6598
|
+
if (!fs19.existsSync(file)) {
|
|
6932
6599
|
return null;
|
|
6933
6600
|
}
|
|
6934
|
-
return JSON.parse(
|
|
6601
|
+
return JSON.parse(fs19.readFileSync(file, "utf8"));
|
|
6935
6602
|
}
|
|
6936
6603
|
function render3(census, usage, published = null) {
|
|
6937
6604
|
const lines = [];
|
|
@@ -7037,7 +6704,7 @@ function render3(census, usage, published = null) {
|
|
|
7037
6704
|
return lines.join("\n");
|
|
7038
6705
|
}
|
|
7039
6706
|
var USAGE2 = "usage: report_skill_activation [--root DIR] [--limit N] [--store PATH]... [--emit] [--allow-empty-store]\n";
|
|
7040
|
-
function
|
|
6707
|
+
function main10(argv) {
|
|
7041
6708
|
let limit = 30;
|
|
7042
6709
|
let emit = false;
|
|
7043
6710
|
let allowEmpty = false;
|
|
@@ -7092,25 +6759,25 @@ function main11(argv) {
|
|
|
7092
6759
|
}
|
|
7093
6760
|
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
7094
6761
|
const file = path16.join(root, RECORD_PATH);
|
|
7095
|
-
|
|
7096
|
-
|
|
6762
|
+
fs19.mkdirSync(path16.dirname(file), { recursive: true });
|
|
6763
|
+
fs19.writeFileSync(file, `${JSON.stringify(buildRecord(census, usage, today), null, 2)}
|
|
7097
6764
|
`);
|
|
7098
6765
|
process.stdout.write(`
|
|
7099
6766
|
wrote ${RECORD_PATH} (measured ${today})
|
|
7100
6767
|
`);
|
|
7101
6768
|
return 0;
|
|
7102
6769
|
}
|
|
7103
|
-
if (process.argv[1] !== void 0 && import.meta.url ===
|
|
7104
|
-
process.exit(
|
|
6770
|
+
if (process.argv[1] !== void 0 && import.meta.url === pathToFileURL10(path16.resolve(process.argv[1])).href) {
|
|
6771
|
+
process.exit(main10(process.argv.slice(2)));
|
|
7105
6772
|
}
|
|
7106
6773
|
|
|
7107
6774
|
// src/scripts/report_skill_obligation_violations.ts
|
|
7108
|
-
import * as
|
|
6775
|
+
import * as fs20 from "node:fs";
|
|
7109
6776
|
import * as os5 from "node:os";
|
|
7110
6777
|
import * as path17 from "node:path";
|
|
7111
6778
|
import process3 from "node:process";
|
|
7112
|
-
import { fileURLToPath as
|
|
7113
|
-
var _HERE4 =
|
|
6779
|
+
import { fileURLToPath as fileURLToPath11, pathToFileURL as pathToFileURL11 } from "node:url";
|
|
6780
|
+
var _HERE4 = fileURLToPath11(import.meta.url);
|
|
7114
6781
|
var REPO_ROOT4 = path17.resolve(path17.dirname(_HERE4), "..", "..");
|
|
7115
6782
|
var OBLIGATION_LINE_RE = new RegExp(`${DETERMINISTIC_RE.source}.*`, "gm");
|
|
7116
6783
|
var PATH_RE = /`([A-Za-z0-9_./-]*\/[A-Za-z0-9_.-]+\.[a-z]{2,6})`/g;
|
|
@@ -7163,7 +6830,7 @@ function extractObligations(repoRoot) {
|
|
|
7163
6830
|
for (const skill of census.withDeterministicObligation) {
|
|
7164
6831
|
let text;
|
|
7165
6832
|
try {
|
|
7166
|
-
text =
|
|
6833
|
+
text = fs20.readFileSync(path17.join(skillsRoot, skill, "SKILL.md"), "utf-8");
|
|
7167
6834
|
} catch {
|
|
7168
6835
|
continue;
|
|
7169
6836
|
}
|
|
@@ -7292,13 +6959,13 @@ function scanStore2(repoRoot, store, limit) {
|
|
|
7292
6959
|
};
|
|
7293
6960
|
let files;
|
|
7294
6961
|
try {
|
|
7295
|
-
files =
|
|
6962
|
+
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);
|
|
7296
6963
|
} catch {
|
|
7297
6964
|
return report;
|
|
7298
6965
|
}
|
|
7299
6966
|
report.sessions = files.length;
|
|
7300
6967
|
for (const file of files) {
|
|
7301
|
-
const lines =
|
|
6968
|
+
const lines = fs20.readFileSync(file, "utf-8").split("\n");
|
|
7302
6969
|
const id = path17.basename(file).replace(/\.jsonl$/, "").slice(0, 8);
|
|
7303
6970
|
const entries = _parseSession(lines);
|
|
7304
6971
|
if (loadedSkillsFrom(entries).size > 0) report.sessionsWithASkill += 1;
|
|
@@ -7369,7 +7036,7 @@ function render4(r) {
|
|
|
7369
7036
|
lines.push(" ships as detection-only, and this one says so.");
|
|
7370
7037
|
return lines.join("\n");
|
|
7371
7038
|
}
|
|
7372
|
-
function
|
|
7039
|
+
function main11(argv) {
|
|
7373
7040
|
const args = argv ?? process3.argv.slice(2);
|
|
7374
7041
|
let limit = 30;
|
|
7375
7042
|
let json = false;
|
|
@@ -7422,21 +7089,21 @@ function main12(argv) {
|
|
|
7422
7089
|
}
|
|
7423
7090
|
return 0;
|
|
7424
7091
|
}
|
|
7425
|
-
function
|
|
7092
|
+
function _isCliEntry10() {
|
|
7426
7093
|
if (process3.argv[1] === void 0) return false;
|
|
7427
|
-
if (import.meta.url ===
|
|
7094
|
+
if (import.meta.url === pathToFileURL11(path17.resolve(process3.argv[1])).href) return true;
|
|
7428
7095
|
try {
|
|
7429
|
-
return
|
|
7096
|
+
return fs20.realpathSync(_HERE4) === fs20.realpathSync(path17.resolve(process3.argv[1]));
|
|
7430
7097
|
} catch {
|
|
7431
7098
|
return false;
|
|
7432
7099
|
}
|
|
7433
7100
|
}
|
|
7434
|
-
if (
|
|
7435
|
-
process3.exit(
|
|
7101
|
+
if (_isCliEntry10()) {
|
|
7102
|
+
process3.exit(main11());
|
|
7436
7103
|
}
|
|
7437
7104
|
|
|
7438
7105
|
// src/scripts/report_conformance_funnel.ts
|
|
7439
|
-
var _HERE5 =
|
|
7106
|
+
var _HERE5 = fileURLToPath12(import.meta.url);
|
|
7440
7107
|
var REPO_ROOT5 = path18.resolve(path18.dirname(_HERE5), "..", "..");
|
|
7441
7108
|
function buildFunnel(opts = {}) {
|
|
7442
7109
|
const repoRoot = opts.repoRoot ?? REPO_ROOT5;
|
|
@@ -7450,7 +7117,7 @@ function buildFunnel(opts = {}) {
|
|
|
7450
7117
|
divergence: compareCarriers(projectRulesDir, globalRulesDir, sourceDir),
|
|
7451
7118
|
skills: censusSkills(path18.join(repoRoot, SKILLS_ROOT)),
|
|
7452
7119
|
usage: measureUsage(store, limit),
|
|
7453
|
-
storePresent:
|
|
7120
|
+
storePresent: fs21.existsSync(store),
|
|
7454
7121
|
sk2: scanStore2(repoRoot, store, limit)
|
|
7455
7122
|
};
|
|
7456
7123
|
}
|
|
@@ -7575,7 +7242,7 @@ function render5(r) {
|
|
|
7575
7242
|
lines.push("workflow without a measured false-positive rate first (locked policy).");
|
|
7576
7243
|
return lines.join("\n");
|
|
7577
7244
|
}
|
|
7578
|
-
function
|
|
7245
|
+
function main12(argv) {
|
|
7579
7246
|
const args = argv ?? process4.argv.slice(2);
|
|
7580
7247
|
const opts = {};
|
|
7581
7248
|
const value = (i) => {
|
|
@@ -7621,21 +7288,21 @@ function main13(argv) {
|
|
|
7621
7288
|
`);
|
|
7622
7289
|
return 0;
|
|
7623
7290
|
}
|
|
7624
|
-
function
|
|
7291
|
+
function _isCliEntry11() {
|
|
7625
7292
|
if (process4.argv[1] === void 0) return false;
|
|
7626
|
-
if (import.meta.url ===
|
|
7293
|
+
if (import.meta.url === pathToFileURL12(path18.resolve(process4.argv[1])).href) return true;
|
|
7627
7294
|
try {
|
|
7628
|
-
return
|
|
7295
|
+
return fs21.realpathSync(_HERE5) === fs21.realpathSync(path18.resolve(process4.argv[1]));
|
|
7629
7296
|
} catch {
|
|
7630
7297
|
return false;
|
|
7631
7298
|
}
|
|
7632
7299
|
}
|
|
7633
|
-
if (
|
|
7634
|
-
process4.exit(
|
|
7300
|
+
if (_isCliEntry11()) {
|
|
7301
|
+
process4.exit(main12());
|
|
7635
7302
|
}
|
|
7636
7303
|
|
|
7637
7304
|
// src/scripts/_cli/cmd_conformance.ts
|
|
7638
|
-
var _HERE6 =
|
|
7305
|
+
var _HERE6 = fileURLToPath13(import.meta.url);
|
|
7639
7306
|
var PACKAGE_ROOT = resolvePackageRoot(import.meta.url);
|
|
7640
7307
|
var CONFORMANCE_CHECK_IDS = [
|
|
7641
7308
|
"txlog-clean",
|
|
@@ -7669,13 +7336,13 @@ function installLogPath() {
|
|
|
7669
7336
|
if (override && override.trim().length > 0) {
|
|
7670
7337
|
return override;
|
|
7671
7338
|
}
|
|
7672
|
-
return
|
|
7339
|
+
return getLogPath();
|
|
7673
7340
|
}
|
|
7674
7341
|
function _installLogExpected(projectRoot) {
|
|
7675
|
-
return
|
|
7342
|
+
return fs22.existsSync(manifest_path(projectRoot));
|
|
7676
7343
|
}
|
|
7677
7344
|
function _check_txlog_clean(logPath = installLogPath(), projectRoot = null) {
|
|
7678
|
-
const entries =
|
|
7345
|
+
const entries = fs22.existsSync(logPath) ? readRecentEntries(logPath) : [];
|
|
7679
7346
|
if (entries.length === 0) {
|
|
7680
7347
|
if (projectRoot !== null && _installLogExpected(projectRoot)) {
|
|
7681
7348
|
return {
|
|
@@ -7713,7 +7380,7 @@ function routeTargetPaths(target) {
|
|
|
7713
7380
|
}
|
|
7714
7381
|
function _check_router_pointers(packageRoot = PACKAGE_ROOT) {
|
|
7715
7382
|
const routerPath = path19.join(packageRoot, "dist", "router.json");
|
|
7716
|
-
if (!
|
|
7383
|
+
if (!fs22.existsSync(routerPath)) {
|
|
7717
7384
|
return {
|
|
7718
7385
|
id: "router-pointers",
|
|
7719
7386
|
status: "fail",
|
|
@@ -7723,7 +7390,7 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT) {
|
|
|
7723
7390
|
}
|
|
7724
7391
|
let router;
|
|
7725
7392
|
try {
|
|
7726
|
-
router = JSON.parse(
|
|
7393
|
+
router = JSON.parse(fs22.readFileSync(routerPath, "utf8"));
|
|
7727
7394
|
} catch (exc) {
|
|
7728
7395
|
return {
|
|
7729
7396
|
id: "router-pointers",
|
|
@@ -7738,7 +7405,7 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT) {
|
|
|
7738
7405
|
let targets = 0;
|
|
7739
7406
|
for (const kernelId of router["kernel"] ?? []) {
|
|
7740
7407
|
ids += 1;
|
|
7741
|
-
if (!
|
|
7408
|
+
if (!fs22.existsSync(path19.join(rulesDir, `${kernelId}.md`))) {
|
|
7742
7409
|
broken.push(`kernel:${kernelId} \u2192 rules/${kernelId}.md missing`);
|
|
7743
7410
|
}
|
|
7744
7411
|
}
|
|
@@ -7746,7 +7413,7 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT) {
|
|
|
7746
7413
|
for (const entry of router[tier] ?? []) {
|
|
7747
7414
|
const ruleId = String(entry["id"] ?? "");
|
|
7748
7415
|
ids += 1;
|
|
7749
|
-
if (!
|
|
7416
|
+
if (!fs22.existsSync(path19.join(rulesDir, `${ruleId}.md`))) {
|
|
7750
7417
|
broken.push(`${tier}:${ruleId} \u2192 rules/${ruleId}.md missing`);
|
|
7751
7418
|
}
|
|
7752
7419
|
for (const target of entry["routes_to"] ?? []) {
|
|
@@ -7756,7 +7423,7 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT) {
|
|
|
7756
7423
|
broken.push(`${ruleId} \u2192 unparseable routes_to ${JSON.stringify(target)}`);
|
|
7757
7424
|
continue;
|
|
7758
7425
|
}
|
|
7759
|
-
if (!candidates.some((rel2) =>
|
|
7426
|
+
if (!candidates.some((rel2) => fs22.existsSync(path19.join(packageRoot, rel2)))) {
|
|
7760
7427
|
broken.push(`${ruleId} \u2192 ${target} (${candidates[0]} missing)`);
|
|
7761
7428
|
}
|
|
7762
7429
|
}
|
|
@@ -7790,7 +7457,7 @@ function detectSmokePlatform(projectRoot) {
|
|
|
7790
7457
|
function dispatcherRunner(packageRoot) {
|
|
7791
7458
|
const localTsx = path19.join(packageRoot, "node_modules", ".bin", "tsx");
|
|
7792
7459
|
const script = path19.join(packageRoot, "src", "scripts", "hooks", "dispatch_hook.ts");
|
|
7793
|
-
if (
|
|
7460
|
+
if (fs22.existsSync(localTsx)) {
|
|
7794
7461
|
return [localTsx, script];
|
|
7795
7462
|
}
|
|
7796
7463
|
return ["npx", "tsx", script];
|
|
@@ -7841,11 +7508,11 @@ function _check_hook_dispatcher(projectRoot, packageRoot = PACKAGE_ROOT, opts =
|
|
|
7841
7508
|
}
|
|
7842
7509
|
function readSettingsMode(projectRoot) {
|
|
7843
7510
|
const settingsPath = path19.join(projectRoot, ".agent-settings.yml");
|
|
7844
|
-
if (!
|
|
7511
|
+
if (!fs22.existsSync(settingsPath)) {
|
|
7845
7512
|
return "eager-all";
|
|
7846
7513
|
}
|
|
7847
7514
|
try {
|
|
7848
|
-
const parsed = YAML.parse(
|
|
7515
|
+
const parsed = YAML.parse(fs22.readFileSync(settingsPath, "utf8"));
|
|
7849
7516
|
const lean = parsed?.["lean_projection"] ?? null;
|
|
7850
7517
|
const mode = lean?.["mode"];
|
|
7851
7518
|
return typeof mode === "string" && mode.length > 0 ? mode : "eager-all";
|
|
@@ -7856,7 +7523,7 @@ function readSettingsMode(projectRoot) {
|
|
|
7856
7523
|
function kernelIdsFromRouter(packageRoot) {
|
|
7857
7524
|
try {
|
|
7858
7525
|
const router = JSON.parse(
|
|
7859
|
-
|
|
7526
|
+
fs22.readFileSync(path19.join(packageRoot, "dist", "router.json"), "utf8")
|
|
7860
7527
|
);
|
|
7861
7528
|
return new Set((router["kernel"] ?? []).map(String));
|
|
7862
7529
|
} catch {
|
|
@@ -7874,7 +7541,7 @@ function _check_lean_projection(projectRoot, packageRoot = PACKAGE_ROOT, project
|
|
|
7874
7541
|
};
|
|
7875
7542
|
}
|
|
7876
7543
|
const rulesDir = projectedRulesDir ?? path19.join(projectRoot, ".augment", "rules");
|
|
7877
|
-
if (!
|
|
7544
|
+
if (!fs22.existsSync(rulesDir)) {
|
|
7878
7545
|
return {
|
|
7879
7546
|
id: "lean-projection",
|
|
7880
7547
|
status: "skipped",
|
|
@@ -7883,7 +7550,7 @@ function _check_lean_projection(projectRoot, packageRoot = PACKAGE_ROOT, project
|
|
|
7883
7550
|
};
|
|
7884
7551
|
}
|
|
7885
7552
|
const kernel = kernelIdsFromRouter(packageRoot);
|
|
7886
|
-
const files =
|
|
7553
|
+
const files = fs22.readdirSync(rulesDir).filter((f) => f.endsWith(".md") && f !== "INDEX.md").sort();
|
|
7887
7554
|
const nonKernel = files.filter((f) => !kernel.has(f.replace(/\.md$/, "")));
|
|
7888
7555
|
if (nonKernel.length === 0) {
|
|
7889
7556
|
return {
|
|
@@ -7897,7 +7564,7 @@ function _check_lean_projection(projectRoot, packageRoot = PACKAGE_ROOT, project
|
|
|
7897
7564
|
for (const f of nonKernel) {
|
|
7898
7565
|
let text = "";
|
|
7899
7566
|
try {
|
|
7900
|
-
text =
|
|
7567
|
+
text = fs22.readFileSync(path19.join(rulesDir, f), "utf8");
|
|
7901
7568
|
} catch {
|
|
7902
7569
|
continue;
|
|
7903
7570
|
}
|
|
@@ -7929,7 +7596,7 @@ function _check_host_manifest(projectRoot) {
|
|
|
7929
7596
|
const detected = Object.entries(detectToolPresence(projectRoot)).filter(([, v]) => v === true).map(([k]) => k);
|
|
7930
7597
|
const detectedNote = detected.length > 0 ? `detected surfaces: ${detected.join(", ")}` : "no surfaces detected";
|
|
7931
7598
|
const settingsPath = path19.join(projectRoot, ".agent-settings.yml");
|
|
7932
|
-
if (!
|
|
7599
|
+
if (!fs22.existsSync(settingsPath)) {
|
|
7933
7600
|
return {
|
|
7934
7601
|
id: "host-manifest",
|
|
7935
7602
|
status: "ok",
|
|
@@ -7939,7 +7606,7 @@ function _check_host_manifest(projectRoot) {
|
|
|
7939
7606
|
}
|
|
7940
7607
|
let parsed = null;
|
|
7941
7608
|
try {
|
|
7942
|
-
parsed = YAML.parse(
|
|
7609
|
+
parsed = YAML.parse(fs22.readFileSync(settingsPath, "utf8"));
|
|
7943
7610
|
} catch (exc) {
|
|
7944
7611
|
return {
|
|
7945
7612
|
id: "host-manifest",
|
|
@@ -8038,7 +7705,7 @@ function _parse(argv) {
|
|
|
8038
7705
|
}
|
|
8039
7706
|
return opts;
|
|
8040
7707
|
}
|
|
8041
|
-
function
|
|
7708
|
+
function main13(argv = null) {
|
|
8042
7709
|
const opts = _parse(argv !== null ? Array.from(argv) : process5.argv.slice(2));
|
|
8043
7710
|
if (opts.funnel) {
|
|
8044
7711
|
print(render5(buildFunnel()));
|
|
@@ -8109,25 +7776,25 @@ function main14(argv = null) {
|
|
|
8109
7776
|
}
|
|
8110
7777
|
return failed ? 1 : 0;
|
|
8111
7778
|
}
|
|
8112
|
-
function
|
|
7779
|
+
function _isCliEntry12() {
|
|
8113
7780
|
if (process5.argv[1] === void 0) {
|
|
8114
7781
|
return false;
|
|
8115
7782
|
}
|
|
8116
|
-
const argvUrl =
|
|
7783
|
+
const argvUrl = pathToFileURL13(path19.resolve(process5.argv[1])).href;
|
|
8117
7784
|
if (import.meta.url === argvUrl) {
|
|
8118
7785
|
return true;
|
|
8119
7786
|
}
|
|
8120
7787
|
try {
|
|
8121
|
-
const here =
|
|
8122
|
-
const argv =
|
|
7788
|
+
const here = fs22.realpathSync(fileURLToPath13(import.meta.url));
|
|
7789
|
+
const argv = fs22.realpathSync(path19.resolve(process5.argv[1]));
|
|
8123
7790
|
return here === argv;
|
|
8124
7791
|
} catch {
|
|
8125
7792
|
return false;
|
|
8126
7793
|
}
|
|
8127
7794
|
}
|
|
8128
|
-
if (
|
|
7795
|
+
if (_isCliEntry12() || process5.argv[1] === _HERE6) {
|
|
8129
7796
|
try {
|
|
8130
|
-
process5.exitCode =
|
|
7797
|
+
process5.exitCode = main13(process5.argv.slice(2));
|
|
8131
7798
|
} catch (e) {
|
|
8132
7799
|
if (e instanceof ArgparseExit) {
|
|
8133
7800
|
process5.exitCode = e.code;
|
|
@@ -8151,7 +7818,7 @@ export {
|
|
|
8151
7818
|
conformanceLogPath,
|
|
8152
7819
|
detectSmokePlatform,
|
|
8153
7820
|
installLogPath,
|
|
8154
|
-
|
|
7821
|
+
main13 as main,
|
|
8155
7822
|
routeTargetPaths,
|
|
8156
7823
|
runConformanceChecks
|
|
8157
7824
|
};
|