@event4u/agent-config 16.2.0 → 16.4.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 +1 -1
- package/CHANGELOG.md +337 -234
- package/README.md +15 -13
- package/agents/templates/.ai-council.yml.example +26 -8
- package/dist/agent-src/commands/analyze/inbox.md +11 -8
- package/dist/agent-src/commands/analyze/roadmap-repos.md +1 -1
- package/dist/agent-src/commands/bug/fix.md +17 -2
- package/dist/agent-src/commands/bug/investigate.md +1 -1
- package/dist/agent-src/commands/commit/in-chunks.md +40 -31
- package/dist/agent-src/commands/commit.md +72 -33
- package/dist/agent-src/commands/condense.md +2 -8
- package/dist/agent-src/commands/council/debate.md +11 -7
- package/dist/agent-src/commands/council/default.md +10 -9
- package/dist/agent-src/commands/council.md +1 -1
- package/dist/agent-src/commands/estimate-ticket.md +1 -1
- package/dist/agent-src/commands/feature/explore.md +3 -3
- package/dist/agent-src/commands/feature/plan.md +2 -2
- package/dist/agent-src/commands/feature/roadmap.md +1 -1
- package/dist/agent-src/commands/fix/ci.md +18 -4
- package/dist/agent-src/commands/fix/commit-messages.md +48 -23
- package/dist/agent-src/commands/fix/pr-comments.md +3 -6
- package/dist/agent-src/commands/implement-ticket.md +4 -4
- package/dist/agent-src/commands/jira-ticket.md +1 -1
- package/dist/agent-src/commands/memory/add.md +4 -16
- package/dist/agent-src/commands/memory/load.md +5 -6
- package/dist/agent-src/commands/memory/promote.md +3 -16
- package/dist/agent-src/commands/mission/upgrade.md +3 -2
- package/dist/agent-src/commands/optimize/agents-dir.md +2 -2
- package/dist/agent-src/commands/optimize/deep.md +4 -2
- package/dist/agent-src/commands/optimize/rtk.md +4 -26
- package/dist/agent-src/commands/pr/create/description-only.md +18 -15
- package/dist/agent-src/commands/pr/create.md +42 -34
- package/dist/agent-src/commands/pr/merge.md +136 -9
- package/dist/agent-src/commands/prepare-for-review.md +13 -11
- package/dist/agent-src/commands/project/analyze.md +7 -35
- package/dist/agent-src/commands/refine-ticket.md +1 -1
- package/dist/agent-src/commands/review/changes.md +14 -19
- package/dist/agent-src/commands/roadmap/create.md +1 -1
- package/dist/agent-src/commands/roadmap/materialize.md +1 -1
- package/dist/agent-src/commands/roadmap/next.md +10 -1
- package/dist/agent-src/commands/roadmap/process-full.md +56 -42
- package/dist/agent-src/commands/roadmap/resolve-blockers.md +411 -0
- package/dist/agent-src/commands/roadmap/triage-parked.md +325 -0
- package/dist/agent-src/commands/roadmap.md +18 -4
- package/dist/agent-src/commands/tests/create.md +17 -3
- package/dist/agent-src/commands/tests/execute.md +22 -5
- package/dist/agent-src/commands/worktree/create.md +7 -3
- package/dist/agent-src/commands/worktree/verify.md +2 -1
- package/dist/agent-src/contexts/authority/decision-revisit-gate-enforcement.md +43 -0
- package/dist/agent-src/contexts/communication/rules-auto/design-fidelity-enforcement.md +24 -0
- package/dist/agent-src/contexts/communication/rules-auto/think-before-action-mechanics.md +5 -3
- package/dist/agent-src/contexts/communication/rules-auto/token-efficiency-mechanics.md +7 -9
- package/dist/agent-src/contexts/contracts/command-suggestion-flow.md +8 -6
- package/dist/agent-src/contexts/contracts/frugality-charter.md +8 -5
- package/dist/agent-src/contexts/execution/auto-dispatch-classification.md +7 -7
- package/dist/agent-src/contexts/execution/auto-orchestration-activation.md +0 -1
- package/dist/agent-src/contexts/execution/evidence-discipline.md +2 -2
- package/dist/agent-src/contexts/execution/non-interactive-contract.md +5 -8
- package/dist/agent-src/contexts/execution/rdp-gate.md +4 -4
- package/dist/agent-src/contexts/execution/roadmap-execution-contract.md +9 -8
- package/dist/agent-src/contexts/execution/roadmap-process-loop.md +99 -54
- package/dist/agent-src/contexts/execution/session-canary-enforcement-history.md +67 -0
- package/dist/agent-src/contexts/execution/subagent-routing.md +8 -8
- package/dist/agent-src/contexts/execution/subagent-steering.md +6 -4
- package/dist/agent-src/contexts/execution/terminal-states.md +2 -2
- package/dist/agent-src/contexts/execution/toolchain-resolver.md +95 -7
- package/dist/agent-src/contexts/subagent-configuration.md +1 -1
- package/dist/agent-src/guidelines/agent-infra/active-remediation-mechanics.md +39 -0
- package/dist/agent-src/guidelines/agent-infra/context-hygiene-mechanics.md +1 -1
- package/dist/agent-src/guidelines/agent-infra/cross-source-consistency-mechanics.md +8 -10
- package/dist/agent-src/guidelines/agent-infra/frontier-reasoning-operating-profile.md +3 -2
- package/dist/agent-src/guidelines/agent-infra/layered-settings.md +13 -1
- package/dist/agent-src/guidelines/agent-infra/roadmap-progress-mechanics.md +1 -1
- package/dist/agent-src/guidelines/agent-infra/self-improvement-pipeline.md +10 -3
- package/dist/agent-src/guidelines/agent-infra/size-and-scope.md +36 -0
- package/dist/agent-src/guidelines/php/git.md +15 -2
- package/dist/agent-src/rules/active-remediation.md +1 -2
- package/dist/agent-src/rules/analysis-skill-routing.md +0 -1
- package/dist/agent-src/rules/architecture.md +0 -1
- package/dist/agent-src/rules/artifact-drafting-protocol.md +0 -1
- package/dist/agent-src/rules/artifact-engagement-recording.md +0 -1
- package/dist/agent-src/rules/augment-edit-discipline.md +0 -1
- package/dist/agent-src/rules/autonomous-execution.md +1 -1
- package/dist/agent-src/rules/brand-consistency.md +0 -1
- package/dist/agent-src/rules/brand-source-of-truth.md +0 -1
- package/dist/agent-src/rules/broken-access-control.md +1 -1
- package/dist/agent-src/rules/cli-output-handling.md +0 -1
- package/dist/agent-src/rules/code-comment-discipline.md +0 -1
- package/dist/agent-src/rules/code-provenance.md +0 -1
- package/dist/agent-src/rules/command-suggestion-policy.md +1 -1
- package/dist/agent-src/rules/commit-conventions.md +1 -2
- package/dist/agent-src/rules/communication-through-line.md +1 -2
- package/dist/agent-src/rules/content-quoting-floor.md +1 -2
- package/dist/agent-src/rules/context-hygiene.md +6 -6
- package/dist/agent-src/rules/copilot-routing.md +1 -2
- package/dist/agent-src/rules/council-availability.md +4 -4
- package/dist/agent-src/rules/cross-source-consistency.md +4 -6
- package/dist/agent-src/rules/decision-revisit-gate.md +17 -35
- package/dist/agent-src/rules/delegation-policy.md +2 -3
- package/dist/agent-src/rules/design-fidelity.md +12 -16
- package/dist/agent-src/rules/design-review-after-ui-write.md +3 -3
- package/dist/agent-src/rules/devcontainer-routing.md +1 -2
- package/dist/agent-src/rules/doc-screenshot-hygiene.md +1 -1
- package/dist/agent-src/rules/docker-commands.md +0 -1
- package/dist/agent-src/rules/domain-adoption-policy.md +0 -1
- package/dist/agent-src/rules/domain-safety-disclaimer.md +1 -1
- package/dist/agent-src/rules/domain-safety-pii.md +1 -1
- package/dist/agent-src/rules/domain-safety-retention.md +1 -1
- package/dist/agent-src/rules/downstream-changes.md +0 -1
- package/dist/agent-src/rules/engineering-safety-floor.md +1 -1
- package/dist/agent-src/rules/evaluator-independence.md +3 -2
- package/dist/agent-src/rules/external-code-graph-interop.md +0 -1
- package/dist/agent-src/rules/external-reference-deep-dive.md +0 -1
- package/dist/agent-src/rules/fast-path-marker-visibility.md +2 -2
- package/dist/agent-src/rules/finance-safety-floor.md +1 -1
- package/dist/agent-src/rules/fix-what-you-see.md +6 -32
- package/dist/agent-src/rules/framework-neutrality-in-generic-skills.md +0 -1
- package/dist/agent-src/rules/git-history-discipline.md +2 -2
- package/dist/agent-src/rules/guidelines.md +0 -1
- package/dist/agent-src/rules/history-discipline.md +0 -1
- package/dist/agent-src/rules/icon-consistency.md +0 -1
- package/dist/agent-src/rules/image-likeness-and-rights.md +1 -1
- package/dist/agent-src/rules/improve-before-implement.md +0 -1
- package/dist/agent-src/rules/invite-challenge.md +0 -1
- package/dist/agent-src/rules/laravel-routing.md +1 -2
- package/dist/agent-src/rules/laravel-translations.md +0 -1
- package/dist/agent-src/rules/legal-safety-floor.md +3 -3
- package/dist/agent-src/rules/lethal-trifecta-guard.md +1 -1
- package/dist/agent-src/rules/linked-projects-onboarding-gate.md +0 -1
- package/dist/agent-src/rules/low-impact-corpus-privacy-floor.md +1 -1
- package/dist/agent-src/rules/markdown-safe-codeblocks.md +0 -1
- package/dist/agent-src/rules/media-governance-routing.md +13 -17
- package/dist/agent-src/rules/media-sync-ground-truth.md +0 -1
- package/dist/agent-src/rules/minimal-safe-diff.md +0 -1
- package/dist/agent-src/rules/missing-skill-recovery.md +0 -1
- package/dist/agent-src/rules/missing-tool-handling.md +0 -1
- package/dist/agent-src/rules/model-recommendation.md +0 -1
- package/dist/agent-src/rules/neighbour-precedence.md +64 -0
- package/dist/agent-src/rules/no-attribution-footers.md +0 -1
- package/dist/agent-src/rules/no-decorative-emojis-in-git-surfaces.md +0 -1
- package/dist/agent-src/rules/no-pr-progress-comments.md +0 -1
- package/dist/agent-src/rules/no-roadmap-references.md +0 -1
- package/dist/agent-src/rules/notes-first-reasoning.md +0 -1
- package/dist/agent-src/rules/onboarding-gate.md +0 -1
- package/dist/agent-src/rules/output-discipline.md +0 -1
- package/dist/agent-src/rules/package-ci-checks.md +0 -1
- package/dist/agent-src/rules/persona-governance.md +4 -5
- package/dist/agent-src/rules/php-coding.md +0 -1
- package/dist/agent-src/rules/prefer-enums-over-literals.md +0 -1
- package/dist/agent-src/rules/preservation-guard.md +0 -1
- package/dist/agent-src/rules/provider-lifecycle-discipline.md +3 -4
- package/dist/agent-src/rules/question-not-instruction.md +1 -1
- package/dist/agent-src/rules/reviewer-awareness.md +0 -1
- package/dist/agent-src/rules/roadmap-ci-steps-policy.md +0 -1
- package/dist/agent-src/rules/roadmap-progress-sync.md +4 -7
- package/dist/agent-src/rules/role-mode-adherence.md +0 -1
- package/dist/agent-src/rules/rule-type-governance.md +0 -1
- package/dist/agent-src/rules/runtime-safety.md +1 -1
- package/dist/agent-src/rules/scale-discipline.md +0 -1
- package/dist/agent-src/rules/secret-vcs-guard.md +1 -1
- package/dist/agent-src/rules/security-sensitive-stop.md +3 -3
- package/dist/agent-src/rules/self-repair-loop.md +0 -1
- package/dist/agent-src/rules/senior-engineering-discipline.md +0 -1
- package/dist/agent-src/rules/session-canary.md +7 -62
- package/dist/agent-src/rules/settings-ask-protocol.md +6 -6
- package/dist/agent-src/rules/size-enforcement.md +0 -1
- package/dist/agent-src/rules/skill-improvement-trigger.md +2 -3
- package/dist/agent-src/rules/skill-quality.md +0 -1
- package/dist/agent-src/rules/slash-command-routing-policy.md +0 -1
- package/dist/agent-src/rules/source-confidentiality.md +1 -1
- package/dist/agent-src/rules/source-discovery-gate.md +0 -1
- package/dist/agent-src/rules/source-of-truth.md +0 -1
- package/dist/agent-src/rules/spreadsheet-source-quality.md +1 -2
- package/dist/agent-src/rules/strategy-safety-floor.md +1 -1
- package/dist/agent-src/rules/symfony-routing.md +1 -2
- package/dist/agent-src/rules/think-before-action.md +0 -1
- package/dist/agent-src/rules/token-budget-discipline.md +12 -46
- package/dist/agent-src/rules/token-efficiency.md +0 -1
- package/dist/agent-src/rules/token-optimizer-maintenance.md +0 -1
- package/dist/agent-src/rules/tool-safety.md +1 -1
- package/dist/agent-src/rules/ui-audit-gate.md +1 -2
- package/dist/agent-src/rules/untrusted-input-defense.md +1 -1
- package/dist/agent-src/rules/upstream-proposal.md +0 -1
- package/dist/agent-src/rules/user-interaction.md +0 -1
- package/dist/agent-src/rules/user-interrupt-priority.md +1 -1
- package/dist/agent-src/scripts/archive_completed_roadmaps.ts +115 -20
- package/dist/agent-src/scripts/deferral_carry.ts +339 -0
- package/dist/agent-src/scripts/gate_budget.ts +47 -23
- package/dist/agent-src/scripts/gate_execute.ts +12 -4
- package/dist/agent-src/scripts/update_roadmap_progress.ts +4 -1
- package/dist/agent-src/skills/ai-council/SKILL.md +7 -4
- package/dist/agent-src/skills/ai-council/references/cost-and-redaction.md +21 -11
- package/dist/agent-src/skills/ai-council/references/procedure.md +12 -6
- package/dist/agent-src/skills/analysis-autonomous-mode/SKILL.md +1 -1
- package/dist/agent-src/skills/api-design/data/manifest.json +2 -2
- package/dist/agent-src/skills/api-testing/SKILL.md +17 -0
- package/dist/agent-src/skills/bug-analyzer/SKILL.md +1 -1
- package/dist/agent-src/skills/code-intelligence/SKILL.md +14 -2
- package/dist/agent-src/skills/command-routing/SKILL.md +3 -4
- package/dist/agent-src/skills/conventional-commits-writing/SKILL.md +127 -139
- package/dist/agent-src/skills/corpus-grounding/ATTRIBUTION.md +39 -0
- package/dist/agent-src/skills/corpus-grounding/SKILL.md +8 -2
- package/dist/agent-src/skills/database/data/manifest.json +2 -2
- package/dist/agent-src/skills/database/data/query-tuning.csv +13 -13
- package/dist/agent-src/skills/design-system-capture/SKILL.md +0 -3
- package/dist/agent-src/skills/design-system-capture/references/import-procedure.md +1 -1
- package/dist/agent-src/skills/estimate-ticket/SKILL.md +1 -1
- package/dist/agent-src/skills/existing-ui-audit/SKILL.md +2 -2
- package/dist/agent-src/skills/fe-design/SKILL.md +1 -1
- package/dist/agent-src/skills/feature-planning/SKILL.md +1 -1
- package/dist/agent-src/skills/git-workflow/SKILL.md +44 -44
- package/dist/agent-src/skills/git-workflow/references/branch-update.md +312 -0
- package/dist/agent-src/skills/git-workflow/references/commit-subject.md +205 -0
- package/dist/agent-src/skills/iconography/SKILL.md +1 -1
- package/dist/agent-src/skills/jira-integration/SKILL.md +3 -3
- package/dist/agent-src/skills/js-library-packaging/SKILL.md +2 -2
- package/dist/agent-src/skills/merge-conflicts/SKILL.md +10 -4
- package/dist/agent-src/skills/monorepo-workspace/SKILL.md +1 -1
- package/dist/agent-src/skills/po-discovery/SKILL.md +1 -1
- package/dist/agent-src/skills/quality-tools/SKILL.md +11 -1
- package/dist/agent-src/skills/quality-tools/references/go-tools.md +76 -0
- package/dist/agent-src/skills/quality-tools/references/python-tools.md +104 -0
- package/dist/agent-src/skills/refine-ticket/SKILL.md +4 -4
- package/dist/agent-src/skills/review-routing/SKILL.md +2 -2
- package/dist/agent-src/skills/roadmap-writing/SKILL.md +2 -2
- package/dist/agent-src/skills/skill-improvement-pipeline/SKILL.md +5 -3
- package/dist/agent-src/skills/source-discovery/SKILL.md +1 -1
- package/dist/agent-src/skills/storybook-workshop/SKILL.md +3 -3
- package/dist/agent-src/skills/tailwind-engineer/SKILL.md +4 -2
- package/dist/agent-src/skills/test-case-discovery/SKILL.md +7 -0
- package/dist/agent-src/skills/test-driven-development/SKILL.md +17 -0
- package/dist/agent-src/skills/test-performance/SKILL.md +19 -1
- package/dist/agent-src/skills/testing-anti-patterns/SKILL.md +1 -1
- package/dist/agent-src/skills/ui-component-architect/SKILL.md +2 -2
- package/dist/agent-src/skills/using-git-worktrees/SKILL.md +1 -1
- package/dist/agent-src/skills/verify-repair-loop/SKILL.md +2 -2
- package/dist/agent-src/templates/AGENTS.md +1 -1
- package/dist/agent-src/templates/agent-settings.md +46 -129
- package/dist/agent-src/templates/agents/agent-project-settings.example.yml +3 -3
- package/dist/agent-src/templates/command.md +2 -2
- package/dist/agent-src/templates/roadmaps.md +6 -1
- package/dist/agent-src/templates/scripts/work_engine/_lib/agent_settings.ts +0 -6
- package/dist/agent-src/templates/scripts/work_engine/directives/backend/_self_fix.ts +11 -7
- package/dist/agent-src/templates/scripts/work_engine/directives/ui/apply.ts +48 -6
- package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/decision_trace.ts +3 -2
- package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/memory_visibility.ts +2 -1
- package/dist/agent-src/templates/scripts/work_engine/hooks/settings.ts +0 -6
- package/dist/agent-src/templates/scripts/work_engine/scoring/decision_engine.ts +9 -12
- package/dist/agent-src/templates/scripts/work_engine/scoring/memory_visibility.ts +2 -1
- package/dist/agent-src/templates/scripts/work_engine/stack/runner.ts +774 -109
- package/dist/agent-src/templates/skill.md +1 -1
- package/dist/cli/registry.js +2 -1
- package/dist/cli-delegate/archive_completed_roadmaps.js +92 -12
- package/dist/cli-delegate/check_update_banner.js +207 -120
- package/dist/cli-delegate/chunk-523HCFYO.js +90 -0
- package/dist/cli-delegate/{chunk-FP36SWJD.js → chunk-5GPULQBE.js} +2797 -338
- package/dist/cli-delegate/{chunk-IGD6ERX6.js → chunk-6SRJTYJS.js} +42 -176
- package/dist/cli-delegate/chunk-6V5FMA3P.js +186 -0
- package/dist/cli-delegate/{chunk-M2DPGFZ4.js → chunk-6V6TA25H.js} +22 -152
- package/dist/cli-delegate/chunk-6YQC2HLF.js +415 -0
- package/dist/cli-delegate/{chunk-E4XIZDIB.js → chunk-7HKRE54K.js} +1 -64
- package/dist/cli-delegate/chunk-7IQE3D5S.js +191 -0
- package/dist/cli-delegate/{chunk-YJ72UIAK.js → chunk-AED2VQGM.js} +1245 -249
- package/dist/cli-delegate/{chunk-7HQ52DHU.js → chunk-AL3RZ22D.js} +1 -1
- package/dist/cli-delegate/chunk-DEIV7XP7.js +108 -0
- package/dist/cli-delegate/{chunk-DBH4AHDK.js → chunk-ED7KCMLB.js} +9 -11
- package/dist/cli-delegate/chunk-F3QDG2GT.js +2569 -0
- package/dist/cli-delegate/{chunk-6KFEC3G7.js → chunk-G5VVIZRC.js} +3 -3
- package/dist/cli-delegate/{chunk-FC75PGJE.js → chunk-H76PHZBI.js} +149 -61
- package/dist/cli-delegate/chunk-IAYTIIQW.js +67 -0
- package/dist/cli-delegate/chunk-JQOM7TTM.js +1201 -0
- package/dist/cli-delegate/chunk-KB5FZ655.js +208 -0
- package/dist/cli-delegate/{chunk-7RQP4UDH.js → chunk-KR6EM23A.js} +235 -1455
- package/dist/cli-delegate/{chunk-LTYVIY76.js → chunk-KXXWJTDO.js} +6 -11
- package/dist/cli-delegate/{chunk-T7L2QK3K.js → chunk-LQOCRFWT.js} +1 -1
- package/dist/cli-delegate/{chunk-6KM6ORRY.js → chunk-MDPPKQCQ.js} +58 -9
- package/dist/cli-delegate/{chunk-4XFP2Y3E.js → chunk-MSUL5NYP.js} +5 -5
- package/dist/cli-delegate/chunk-OAFSJBHH.js +272 -0
- package/dist/cli-delegate/{chunk-4E2W63DA.js → chunk-OKJUIAPS.js} +62 -1
- package/dist/cli-delegate/{chunk-QAJS5YWY.js → chunk-PHD7OOLE.js} +2 -1
- package/dist/cli-delegate/{chunk-P6ZHP5W2.js → chunk-PWX7CKMD.js} +4 -4
- package/dist/cli-delegate/{chunk-NDJLNC6Q.js → chunk-T6BP34WI.js} +1 -0
- package/dist/cli-delegate/{chunk-7XGBX6ZH.js → chunk-T7XSJSUQ.js} +1144 -589
- package/dist/cli-delegate/chunk-ULQRUR23.js +208 -0
- package/dist/cli-delegate/chunk-WQWXGIWB.js +1779 -0
- package/dist/cli-delegate/{chunk-RGNIWTEA.js → chunk-XQTPXKFA.js} +1 -1
- package/dist/cli-delegate/{chunk-NUHLI2RX.js → chunk-YCU3TIXH.js} +2 -0
- package/dist/cli-delegate/chunk-ZBZV2G5R.js +210 -0
- package/dist/cli-delegate/{chunk-WGXTVKCQ.js → chunk-ZUZKZYCN.js} +5 -3
- package/dist/cli-delegate/cmd_analyze_session.js +223 -43
- package/dist/cli-delegate/cmd_brand_status.js +3 -2
- package/dist/cli-delegate/cmd_conformance.js +1252 -249
- package/dist/cli-delegate/cmd_converge.js +3 -3
- package/dist/cli-delegate/cmd_doctor.js +19 -9
- package/dist/cli-delegate/cmd_doctor_neighbours.js +30 -0
- package/dist/cli-delegate/cmd_explain.js +45 -21
- package/dist/cli-delegate/cmd_export.js +13 -10
- package/dist/cli-delegate/cmd_fleet.js +3 -3
- package/dist/cli-delegate/cmd_git_convention.js +1851 -0
- package/dist/cli-delegate/cmd_handoff.js +44 -22
- package/dist/cli-delegate/cmd_mcp_available.js +3 -2
- package/dist/cli-delegate/cmd_memory_get.js +3 -1
- package/dist/cli-delegate/cmd_migrate.js +3 -3
- package/dist/cli-delegate/cmd_packs_active.js +5 -4
- package/dist/cli-delegate/cmd_preflight.js +6 -6
- package/dist/cli-delegate/cmd_prune.js +14 -11
- package/dist/cli-delegate/cmd_refresh.js +2 -1
- package/dist/cli-delegate/cmd_route_audit.js +10 -8
- package/dist/cli-delegate/cmd_route_explain.js +4 -4
- package/dist/cli-delegate/cmd_session_recycle.js +10 -7
- package/dist/cli-delegate/cmd_settings_check.js +54 -7
- package/dist/cli-delegate/cmd_settings_get.js +18 -8
- package/dist/cli-delegate/cmd_settings_migrate.js +13 -10
- package/dist/cli-delegate/cmd_settings_set.js +4 -4
- package/dist/cli-delegate/cmd_sync.js +14 -11
- package/dist/cli-delegate/cmd_uninstall.js +15 -12
- package/dist/cli-delegate/cmd_update.js +7 -7
- package/dist/cli-delegate/cmd_upgrade.js +9 -8
- package/dist/cli-delegate/cmd_validate.js +15 -12
- package/dist/cli-delegate/cmd_versions.js +5 -5
- package/dist/cli-delegate/deferral_carry.js +16 -0
- package/dist/cli-delegate/gate_budget.js +1 -1
- package/dist/cli-delegate/gate_execute.js +3 -3
- package/dist/cli-delegate/roadmap_gates.js +6 -6
- package/dist/cli-delegate/update_roadmap_progress.js +1 -1
- package/dist/discovery/deprecation-report.md +1 -1
- package/dist/discovery/discovery-manifest.json +232 -141
- package/dist/discovery/discovery-manifest.json.sha256 +1 -1
- package/dist/discovery/discovery-manifest.summary.md +3 -3
- package/dist/discovery/dormancy-report.md +1 -1
- package/dist/discovery/orphan-report.md +1 -1
- package/dist/discovery/packs.json +26 -9
- package/dist/discovery/trust-report.md +3 -3
- package/dist/discovery/workspaces.json +7 -4
- package/dist/hooks/dispatch.js +5655 -6623
- package/dist/hooks/dispatch.sha256 +1 -1
- package/dist/install/claudePathsPlan.js +47 -6
- package/dist/install/claudeRuleRewrite.js +7 -0
- package/dist/install/emit_host_rules_cli.js +39 -36
- package/dist/install/globalRuleScope.js +87 -0
- package/dist/install/host_rule_ownership.js +160 -0
- package/dist/install/install.mjs +2336 -1249
- package/dist/install/installThinLayer.js +289 -0
- package/dist/install/installedRuleLinks.js +262 -0
- package/dist/install/wizard-plan.js +24 -0
- package/dist/mcp/awesome-mcp-servers.row.md +1 -1
- package/dist/mcp/mcp-cloudflare-catalogue.json +2 -2
- package/dist/mcp/registry-manifest.json +5 -5
- package/dist/mcp/server.json +2 -2
- package/dist/mcp/server.mjs +36504 -30986
- package/dist/router.json +1 -1
- package/dist/scripts/_lib/agent_settings.js +26 -120
- package/dist/scripts/_lib/claude_settings_hooks.js +10 -8
- package/dist/scripts/_lib/compile_time_toggles.js +12 -21
- package/dist/scripts/_lib/git_convention.js +232 -0
- package/dist/scripts/_lib/global_deploy_inventory.js +730 -0
- package/dist/scripts/_lib/installed_layer.js +704 -0
- package/dist/scripts/_lib/lean_projection_mode.js +218 -15
- package/dist/scripts/_lib/package_root.js +68 -0
- package/dist/scripts/_lib/rule_consequence_class.js +45 -0
- package/dist/scripts/_lib/rule_injection.js +67 -10
- package/dist/scripts/_lib/rule_law_section.js +122 -0
- package/dist/scripts/_lib/settings_removed_keys.js +168 -0
- package/dist/scripts/_lib/thin_rules.js +535 -0
- package/dist/scripts/_lib/windsurf_render.js +60 -0
- package/dist/scripts/condense.js +14 -26
- package/dist/scripts/project_thin_rules.js +14 -294
- package/dist/server/app.js +2 -1
- package/dist/server/gitKeysGate.js +105 -0
- package/dist/server/routes/settings.js +67 -8
- package/dist/server/routes/wizard.js +4 -0
- package/dist/server/schemas/settings.js +29 -81
- package/dist/shared/skillRanking.js +103 -16
- package/dist/ui/assets/{index-Cwq4d0hX.js → index-C3djEJah.js} +2 -2
- package/dist/ui/index.html +1 -1
- package/docs/MIGRATION.md +72 -1
- package/docs/contracts/settings-classes.md +39 -67
- package/docs/guidelines/agent-infra/active-remediation-mechanics.md +39 -0
- package/docs/guidelines/agent-infra/context-hygiene-mechanics.md +1 -1
- package/docs/guidelines/agent-infra/cross-source-consistency-mechanics.md +8 -10
- package/docs/guidelines/agent-infra/frontier-reasoning-operating-profile.md +3 -2
- package/docs/guidelines/agent-infra/layered-settings.md +13 -1
- package/docs/guidelines/agent-infra/roadmap-progress-mechanics.md +1 -1
- package/docs/guidelines/agent-infra/self-improvement-pipeline.md +10 -3
- package/docs/guidelines/agent-infra/size-and-scope.md +36 -0
- package/docs/guidelines/php/git.md +15 -2
- package/package.json +1 -1
- package/src/agent-src/scripts/archive_completed_roadmaps.ts +115 -20
- package/src/agent-src/scripts/deferral_carry.ts +339 -0
- package/src/agent-src/scripts/gate_budget.ts +47 -23
- package/src/agent-src/scripts/gate_execute.ts +12 -4
- package/src/agent-src/scripts/update_roadmap_progress.ts +4 -1
- package/src/agent-src/templates/AGENTS.md +1 -1
- package/src/agent-src/templates/scripts/work_engine/_lib/agent_settings.ts +0 -6
- package/src/agent-src/templates/scripts/work_engine/directives/backend/_self_fix.ts +11 -7
- package/src/agent-src/templates/scripts/work_engine/directives/ui/apply.ts +48 -6
- package/src/agent-src/templates/scripts/work_engine/hooks/builtin/decision_trace.ts +3 -2
- package/src/agent-src/templates/scripts/work_engine/hooks/builtin/memory_visibility.ts +2 -1
- package/src/agent-src/templates/scripts/work_engine/hooks/settings.ts +0 -6
- package/src/agent-src/templates/scripts/work_engine/scoring/decision_engine.ts +9 -12
- package/src/agent-src/templates/scripts/work_engine/scoring/memory_visibility.ts +2 -1
- package/src/agent-src/templates/scripts/work_engine/stack/runner.ts +774 -109
- package/src/config/agent-settings.template.yml +141 -334
- package/src/config/agents-paths.yml +16 -0
- package/src/config/assurance-capability-registry.json +7 -3
- package/src/config/ci-local-parity.yml +3 -0
- package/src/config/continuity-surface.json +10 -3
- package/src/config/discovery/packs.yml +17 -1
- package/src/config/evaluator-budgets.json +23 -10
- package/src/config/gate-coverage.yml +138 -3
- package/src/config/gate-violation-baselines.json +64 -16
- package/src/config/gitignore-block.txt +19 -0
- package/src/config/hook-bundle-budget.json +25 -0
- package/src/config/hook-token-budget.json +6 -1
- package/src/config/host-instruction-limits.json +33 -0
- package/src/config/release-gate-locality.yml +2 -1
- package/src/config/routing-coverage-seed.json +67 -4
- package/src/config/rule-activation-census.json +7 -3
- package/src/config/rule-consequence-class.json +161 -0
- package/src/config/rule-law-ceilings.json +105 -0
- package/src/config/rule-obligations.json +833 -0
- package/src/install/claudePathsPlan.ts +46 -4
- package/src/install/claudeRuleRewrite.ts +10 -1
- package/src/install/emit_host_rules_cli.ts +43 -34
- package/src/install/globalRuleScope.ts +109 -0
- package/src/install/host_rule_ownership.ts +170 -0
- package/src/install/installThinLayer.ts +378 -0
- package/src/install/installedRuleLinks.ts +308 -0
- package/src/install/wizard-plan.ts +24 -0
- package/src/scripts/_cli/cmd_analyze_session.ts +9 -15
- package/src/scripts/_cli/cmd_conformance.ts +13 -2
- package/src/scripts/_cli/cmd_doctor.ts +33 -81
- package/src/scripts/_cli/cmd_doctor_neighbours.ts +426 -0
- package/src/scripts/_cli/cmd_explain.ts +72 -14
- package/src/scripts/_cli/cmd_git_convention.ts +637 -0
- package/src/scripts/_cli/cmd_settings_check.ts +66 -8
- package/src/scripts/_cli/cmd_settings_get.ts +18 -3
- package/src/scripts/_cli/doctor_execution.ts +72 -1
- package/src/scripts/_dispatch.bash +53 -4
- package/src/scripts/_lib/agent_settings.ts +26 -124
- package/src/scripts/_lib/blocked_by_marker.ts +1 -1
- package/src/scripts/_lib/claude_settings_hooks.ts +10 -8
- package/src/scripts/_lib/compile_time_toggles.ts +12 -21
- package/src/scripts/_lib/dispatch_import_closure.ts +163 -0
- package/src/scripts/_lib/estate_offsets.ts +241 -0
- package/src/scripts/_lib/exemption_shape.ts +143 -0
- package/src/scripts/_lib/fnv.ts +23 -0
- package/src/scripts/_lib/foreign_scan.ts +106 -0
- package/src/scripts/_lib/git_base_ref.ts +92 -0
- package/src/scripts/_lib/git_convention.ts +291 -0
- package/src/scripts/_lib/git_convention_carrier.ts +389 -0
- package/src/scripts/_lib/git_convention_grammar.ts +246 -0
- package/src/scripts/_lib/git_convention_measure.ts +344 -0
- package/src/scripts/_lib/gitignore_block.ts +314 -0
- package/src/scripts/_lib/global_deploy_inventory.ts +106 -0
- package/src/scripts/_lib/graph_feeder_record.ts +437 -0
- package/src/scripts/_lib/hook_settings.ts +73 -0
- package/src/scripts/_lib/host_capability.ts +40 -19
- package/src/scripts/_lib/host_hook_merge.ts +165 -0
- package/src/scripts/_lib/installed_layer.ts +963 -0
- package/src/scripts/_lib/json_merge.ts +82 -0
- package/src/scripts/_lib/json_pointers.ts +93 -11
- package/src/scripts/_lib/knowledge_global.ts +14 -1
- package/src/scripts/_lib/lean_projection_mode.ts +275 -15
- package/src/scripts/_lib/machine_wake.ts +16 -3
- package/src/scripts/_lib/module_reach.ts +456 -0
- package/src/scripts/_lib/neighbour_census.ts +760 -0
- package/src/scripts/_lib/neighbour_contradictions.ts +236 -0
- package/src/scripts/_lib/neighbour_scan.ts +122 -0
- package/src/scripts/_lib/neighbour_tool_use.ts +187 -0
- package/src/scripts/_lib/prompt_shape.ts +46 -0
- package/src/scripts/_lib/ratification_artifact.ts +220 -1
- package/src/scripts/_lib/ratification_subject.ts +92 -0
- package/src/scripts/_lib/release_findings_ingest.ts +15 -7
- package/src/scripts/_lib/release_highlights.ts +5 -0
- package/src/scripts/_lib/release_migration_gate.ts +19 -3
- package/src/scripts/_lib/reserved_name_sweep.ts +73 -0
- package/src/scripts/_lib/review_coverage.ts +134 -0
- package/src/scripts/_lib/rule_consequence_class.ts +71 -0
- package/src/scripts/_lib/rule_injection.ts +130 -10
- package/src/scripts/_lib/rule_law_section.ts +147 -0
- package/src/scripts/_lib/rule_layer_overlap.ts +58 -0
- package/src/scripts/_lib/rule_obligations.ts +205 -0
- package/src/scripts/_lib/self_repair.ts +1 -1
- package/src/scripts/_lib/settings_removed_keys.ts +173 -0
- package/src/scripts/_lib/skill_origin.ts +254 -0
- package/src/scripts/_lib/structured_ask.ts +64 -21
- package/src/scripts/_lib/test_red_state.ts +5 -0
- package/src/scripts/_lib/thin_rules.ts +620 -0
- package/src/scripts/_lib/touched_file_quality.ts +570 -0
- package/src/scripts/_lib/turn_end_refusals.ts +77 -2
- package/src/scripts/_lib/windsurf_render.ts +63 -0
- package/src/scripts/_lib/worker_budget.ts +1 -1
- package/src/scripts/adr/regenerate_index.ts +16 -1
- package/src/scripts/ai_council/cli_call_budget.ts +13 -5
- package/src/scripts/ai_council/clients.ts +26 -57
- package/src/scripts/ai_council/config.ts +8 -8
- package/src/scripts/ai_council/modification_review.ts +100 -0
- package/src/scripts/ai_council/modification_review_questions.ts +90 -0
- package/src/scripts/ai_council/orchestrator.ts +5 -5
- package/src/scripts/ai_council/spend_gate.ts +18 -7
- package/src/scripts/ai_council/vendor_defaults.ts +45 -0
- package/src/scripts/ai_team/config.ts +11 -16
- package/src/scripts/audit_skill_overlap.ts +261 -0
- package/src/scripts/audit_user_type_axis.ts +20 -8
- package/src/scripts/before_complete_hook.ts +243 -12
- package/src/scripts/bench_ab_clone.ts +1 -2
- package/src/scripts/bench_concern_spawn_path.ts +129 -0
- package/src/scripts/bench_graph_feeder_latency.ts +584 -0
- package/src/scripts/bench_touched_file_quality.ts +238 -0
- package/src/scripts/check_agent_artifact_location.ts +36 -0
- package/src/scripts/check_branch_freshness.ts +147 -24
- package/src/scripts/check_enforcement_coverage.ts +130 -0
- package/src/scripts/check_enforcement_matrix.ts +377 -20
- package/src/scripts/check_estate_count.ts +130 -153
- package/src/scripts/check_evaluator_budgets.ts +4 -0
- package/src/scripts/check_finding_dispositions.ts +196 -21
- package/src/scripts/check_gate_coverage.ts +4 -3
- package/src/scripts/check_gate_reachability.ts +48 -1
- package/src/scripts/check_generator_sync.ts +48 -0
- package/src/scripts/check_hook_bundle_composition.ts +477 -0
- package/src/scripts/check_kernel_edit_ratified.ts +132 -14
- package/src/scripts/check_memory.ts +7 -1
- package/src/scripts/check_pack_size.ts +1 -1
- package/src/scripts/check_release_highlights.ts +10 -0
- package/src/scripts/check_release_manifest_content.ts +189 -0
- package/src/scripts/check_release_pr_shape.ts +38 -15
- package/src/scripts/check_standing_rule_delivery.ts +129 -13
- package/src/scripts/check_suppression_hygiene.ts +2 -5
- package/src/scripts/check_verify_expectation_delta.ts +521 -0
- package/src/scripts/ci_settle.ts +42 -5
- package/src/scripts/classify_merge_risk.ts +320 -0
- package/src/scripts/closure_scan.ts +91 -1
- package/src/scripts/code_graph/detect.ts +127 -7
- package/src/scripts/code_graph/foreign.ts +194 -0
- package/src/scripts/code_graph/query.ts +217 -4
- package/src/scripts/code_graph/types.ts +26 -2
- package/src/scripts/code_graph/validate.ts +3 -1
- package/src/scripts/code_graph/verbs.ts +103 -0
- package/src/scripts/command_suggester/settings.ts +8 -108
- package/src/scripts/command_suggester/types.ts +4 -5
- package/src/scripts/compile_hook_manifest.ts +33 -1
- package/src/scripts/condense.ts +14 -27
- package/src/scripts/consumer_matrix.ts +102 -0
- package/src/scripts/context_hygiene_hook.ts +13 -23
- package/src/scripts/cost/preflight.mjs +12 -1
- package/src/scripts/council_cli.ts +7 -7
- package/src/scripts/dispatch_r2_reviewer.ts +24 -11
- package/src/scripts/estate_exemption_shape.ts +202 -0
- package/src/scripts/explain_run.ts +8 -13
- package/src/scripts/generate_git_convention_grammar.ts +127 -0
- package/src/scripts/generate_host_cost_table.ts +21 -4
- package/src/scripts/handoff_context_hook.ts +86 -37
- package/src/scripts/hook_manifest.json +1 -1
- package/src/scripts/hook_manifest.yaml +175 -15
- package/src/scripts/hooks/block_config_weakening.ts +115 -7
- package/src/scripts/hooks/block_plumbing_writes.ts +37 -5
- package/src/scripts/hooks/code_graph_context_hook.ts +252 -23
- package/src/scripts/hooks/concern_failure_policy.ts +280 -0
- package/src/scripts/hooks/concern_registry.ts +2 -0
- package/src/scripts/hooks/delegation_nudge_hook.ts +2 -3
- package/src/scripts/hooks/dispatch_hook.ts +52 -52
- package/src/scripts/hooks/evidence_independence.ts +12 -4
- package/src/scripts/hooks/exit_codes.ts +2 -1
- package/src/scripts/hooks/host_lowering.json +1 -1
- package/src/scripts/hooks/host_lowering.ts +19 -1
- package/src/scripts/hooks/mcp_usage_observation_hook.ts +121 -0
- package/src/scripts/hooks/one_question_per_ask_hook.ts +41 -25
- package/src/scripts/hooks/payload_stub.ts +10 -1
- package/src/scripts/hooks/push_settle_hook.ts +4 -3
- package/src/scripts/hooks/rule_inject_hook.ts +795 -60
- package/src/scripts/hooks/state_io.ts +8 -4
- package/src/scripts/hooks/table_fingerprint.ts +21 -0
- package/src/scripts/hooks/telemetry_usage_hook.ts +24 -7
- package/src/scripts/hooks/turn_end_gate_hook.ts +85 -0
- package/src/scripts/hooks_status.ts +112 -0
- package/src/scripts/injection_scan_hook.ts +7 -0
- package/src/scripts/install-hooks.sh +42 -14
- package/src/scripts/install.ts +78 -215
- package/src/scripts/installed_layer_report.ts +103 -0
- package/src/scripts/language_mirror_hook.ts +15 -6
- package/src/scripts/learning_sidecar.ts +119 -8
- package/src/scripts/lint_blocker_citations.ts +198 -0
- package/src/scripts/lint_evidence_artifacts.ts +9 -0
- package/src/scripts/lint_hook_concern_budget.ts +10 -21
- package/src/scripts/lint_hook_manifest.ts +53 -0
- package/src/scripts/lint_major_migration_sections.ts +156 -26
- package/src/scripts/lint_pack_boundaries.ts +465 -29
- package/src/scripts/lint_roadmap_blockers.ts +282 -29
- package/src/scripts/lint_roadmap_complexity.ts +4 -2
- package/src/scripts/lint_rule_law_section.ts +647 -0
- package/src/scripts/lint_rule_skill_pack_reach.ts +17 -0
- package/src/scripts/lint_settings_classes.ts +1 -1
- package/src/scripts/lint_ticked_unmet_criteria.ts +165 -0
- package/src/scripts/lint_workflow_security.ts +173 -6
- package/src/scripts/mcp_server/consumer_tool_catalog.json +53 -0
- package/src/scripts/mcp_server/graph_tools.ts +72 -3
- package/src/scripts/measure_routing_signal.ts +54 -16
- package/src/scripts/measure_skill_ranker_baseline.ts +221 -8
- package/src/scripts/memory_learn_hook.ts +91 -6
- package/src/scripts/model_rule_injection.ts +55 -8
- package/src/scripts/onboarding_gate_hook.ts +7 -6
- package/src/scripts/print_required_checks.ts +15 -3
- package/src/scripts/probe_host_compliance.ts +33 -5
- package/src/scripts/probe_turnaround.ts +183 -3
- package/src/scripts/project_thin_rules.ts +34 -327
- package/src/scripts/ratification_header.ts +77 -0
- package/src/scripts/refusal_envelope.ts +138 -0
- package/src/scripts/release_publication.ts +29 -3
- package/src/scripts/report_dispatch_import_closure.ts +76 -0
- package/src/scripts/report_evidence_temperature.ts +657 -0
- package/src/scripts/report_installed_rule_links.ts +274 -0
- package/src/scripts/report_label_agreement.ts +233 -0
- package/src/scripts/report_module_reach.ts +212 -0
- package/src/scripts/report_obligation_mechanism.ts +228 -0
- package/src/scripts/report_parked_blockers.ts +222 -0
- package/src/scripts/report_required_checks_drift.ts +196 -0
- package/src/scripts/report_single_token_triggers.ts +277 -0
- package/src/scripts/report_skill_ranker_confusion.ts +543 -0
- package/src/scripts/report_standing_payload_by_host.ts +188 -15
- package/src/scripts/report_verification_record_coverage.ts +306 -0
- package/src/scripts/routing_doctor.ts +2 -2
- package/src/scripts/rule_activation_census.ts +5 -2
- package/src/scripts/rule_trigger_eval.ts +9 -9
- package/src/scripts/schemas/agent-settings.schema.json +17 -31
- package/src/scripts/schemas/command.schema.json +1 -1
- package/src/scripts/schemas/review-findings.schema.json +3 -2
- package/src/scripts/schemas/rule.schema.json +5 -0
- package/src/scripts/schemas/skill.schema.json +1 -1
- package/src/scripts/self_review_gate.ts +101 -9
- package/src/scripts/skill_tools/score_skill_relevance.ts +314 -40
- package/src/scripts/sweep_skill_ranker_signals.ts +129 -0
- package/src/scripts/sync_gitignore.ts +29 -235
- package/src/scripts/sync_pr_branch.ts +403 -132
- package/src/scripts/trigger_eval_grandfather.json +0 -21
- package/src/server/schemas/settings.ts +42 -176
- package/src/shared/skillRanking.ts +169 -14
- package/dist/cli-delegate/chunk-5R7HOLAF.js +0 -99
- package/dist/cli-delegate/chunk-JNMVLWLR.js +0 -4457
- package/dist/cli-delegate/chunk-YDPILCOL.js +0 -152
- package/src/scripts/_lib/config_chain.ts +0 -477
- package/src/scripts/_lib/conformance_report.ts +0 -403
- package/src/scripts/_lib/eval_discrimination.ts +0 -95
- package/src/scripts/_lib/evaluator_promotion.ts +0 -225
- package/src/scripts/_lib/file_slicer.ts +0 -117
- package/src/scripts/_lib/legacy_boundary_map.ts +0 -228
- package/src/scripts/_lib/minimality_tiebreak.ts +0 -168
- package/src/scripts/_lib/overbuild_lens_contract.ts +0 -196
- package/src/scripts/_lib/role_split.ts +0 -338
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
THIN_ENTRY_MARKER,
|
|
4
|
+
readRecentEntries
|
|
5
|
+
} from "./chunk-6YQC2HLF.js";
|
|
6
|
+
import {
|
|
7
|
+
detectToolPresence
|
|
8
|
+
} from "./chunk-A4QJ6ENT.js";
|
|
2
9
|
import {
|
|
3
10
|
NO_RED_EVIDENCE_REASON,
|
|
4
11
|
deriveSessionKey,
|
|
@@ -17,17 +24,18 @@ import {
|
|
|
17
24
|
readTurnRunState,
|
|
18
25
|
sessionRefusalFile,
|
|
19
26
|
sessionShadowFile,
|
|
27
|
+
shadowSetBy,
|
|
20
28
|
statePathFor,
|
|
21
29
|
validateAssumption
|
|
22
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-AED2VQGM.js";
|
|
23
31
|
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
} from "./chunk-
|
|
32
|
+
LexicalIndex,
|
|
33
|
+
isSqliteAvailableSync,
|
|
34
|
+
loadSqliteSync,
|
|
35
|
+
readUserVersion,
|
|
36
|
+
stampUserVersion,
|
|
37
|
+
tokenize
|
|
38
|
+
} from "./chunk-ZBZV2G5R.js";
|
|
31
39
|
import {
|
|
32
40
|
ArgparseExit,
|
|
33
41
|
STATUS_SYMBOLS,
|
|
@@ -44,16 +52,25 @@ import {
|
|
|
44
52
|
comparePair,
|
|
45
53
|
frontmatterPaths,
|
|
46
54
|
proseEqual,
|
|
55
|
+
resolveSessionRole,
|
|
47
56
|
splitFrontmatter
|
|
48
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-5GPULQBE.js";
|
|
49
58
|
import "./chunk-FTAISGDQ.js";
|
|
50
|
-
import "./chunk-
|
|
59
|
+
import "./chunk-6V6TA25H.js";
|
|
51
60
|
import "./chunk-ROYYTEZU.js";
|
|
52
61
|
import "./chunk-BTWUYDGN.js";
|
|
53
62
|
import {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
} from "./chunk-
|
|
63
|
+
atomicAppendLine,
|
|
64
|
+
probeHostCapabilities
|
|
65
|
+
} from "./chunk-MDPPKQCQ.js";
|
|
66
|
+
import "./chunk-DMSZHXZS.js";
|
|
67
|
+
import "./chunk-ULQRUR23.js";
|
|
68
|
+
import {
|
|
69
|
+
hardenedSpawnEnv,
|
|
70
|
+
projectStoreSlug
|
|
71
|
+
} from "./chunk-OAFSJBHH.js";
|
|
72
|
+
import "./chunk-IAYTIIQW.js";
|
|
73
|
+
import "./chunk-LQOCRFWT.js";
|
|
57
74
|
import {
|
|
58
75
|
atomic_write_json,
|
|
59
76
|
atomic_write_text,
|
|
@@ -63,46 +80,48 @@ import {
|
|
|
63
80
|
prune_legacy_state_file,
|
|
64
81
|
prune_stale_session_states,
|
|
65
82
|
session_state_file
|
|
66
|
-
} from "./chunk-
|
|
67
|
-
import
|
|
68
|
-
|
|
69
|
-
} from "./chunk-NUHLI2RX.js";
|
|
70
|
-
import {
|
|
71
|
-
readRecentEntries
|
|
72
|
-
} from "./chunk-5R7HOLAF.js";
|
|
73
|
-
import {
|
|
74
|
-
detectToolPresence
|
|
75
|
-
} from "./chunk-A4QJ6ENT.js";
|
|
76
|
-
import {
|
|
77
|
-
atomicAppendLine,
|
|
78
|
-
probeHostCapabilities
|
|
79
|
-
} from "./chunk-6KM6ORRY.js";
|
|
80
|
-
import "./chunk-T7L2QK3K.js";
|
|
81
|
-
import "./chunk-DMSZHXZS.js";
|
|
83
|
+
} from "./chunk-7HKRE54K.js";
|
|
84
|
+
import "./chunk-F3QDG2GT.js";
|
|
85
|
+
import "./chunk-DEIV7XP7.js";
|
|
82
86
|
import {
|
|
83
87
|
manifest_path,
|
|
84
88
|
read_manifest
|
|
85
|
-
} from "./chunk-
|
|
89
|
+
} from "./chunk-OKJUIAPS.js";
|
|
90
|
+
import "./chunk-WQWXGIWB.js";
|
|
91
|
+
import "./chunk-KB5FZ655.js";
|
|
86
92
|
import "./chunk-MWRD5YOH.js";
|
|
93
|
+
import "./chunk-JQOM7TTM.js";
|
|
94
|
+
import {
|
|
95
|
+
DeadScopeError,
|
|
96
|
+
assertScanned,
|
|
97
|
+
reportScanned
|
|
98
|
+
} from "./chunk-I3EIN2YG.js";
|
|
99
|
+
import {
|
|
100
|
+
readHookStdin
|
|
101
|
+
} from "./chunk-F7DQWYR5.js";
|
|
87
102
|
import {
|
|
88
103
|
require_dist
|
|
89
104
|
} from "./chunk-OY53J6II.js";
|
|
105
|
+
import "./chunk-LF2KKJ4Q.js";
|
|
106
|
+
import {
|
|
107
|
+
load_agent_settings
|
|
108
|
+
} from "./chunk-H76PHZBI.js";
|
|
109
|
+
import {
|
|
110
|
+
artefact_roots
|
|
111
|
+
} from "./chunk-YCU3TIXH.js";
|
|
112
|
+
import "./chunk-T6BP34WI.js";
|
|
90
113
|
import {
|
|
91
114
|
resolvePackageRoot
|
|
92
115
|
} from "./chunk-MCJYCQPF.js";
|
|
93
|
-
import {
|
|
94
|
-
load_agent_settings
|
|
95
|
-
} from "./chunk-FC75PGJE.js";
|
|
96
|
-
import "./chunk-NDJLNC6Q.js";
|
|
97
116
|
import {
|
|
98
117
|
__toESM
|
|
99
118
|
} from "./chunk-J55WI3RR.js";
|
|
100
119
|
|
|
101
120
|
// src/scripts/_cli/cmd_conformance.ts
|
|
102
121
|
var YAML = __toESM(require_dist(), 1);
|
|
103
|
-
import * as
|
|
122
|
+
import * as fs20 from "node:fs";
|
|
104
123
|
import * as os7 from "node:os";
|
|
105
|
-
import * as
|
|
124
|
+
import * as path18 from "node:path";
|
|
106
125
|
import process5 from "node:process";
|
|
107
126
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
108
127
|
import { fileURLToPath as fileURLToPath14, pathToFileURL as pathToFileURL14 } from "node:url";
|
|
@@ -118,10 +137,10 @@ var ROUTE_TARGET_TEMPLATES = Object.freeze({
|
|
|
118
137
|
])
|
|
119
138
|
});
|
|
120
139
|
function parseRouteTarget(target) {
|
|
121
|
-
const
|
|
122
|
-
if (
|
|
123
|
-
const kind = target.slice(0,
|
|
124
|
-
const id = target.slice(
|
|
140
|
+
const sep4 = target.indexOf(":");
|
|
141
|
+
if (sep4 <= 0) return null;
|
|
142
|
+
const kind = target.slice(0, sep4);
|
|
143
|
+
const id = target.slice(sep4 + 1);
|
|
125
144
|
if (!id) return null;
|
|
126
145
|
if (!Object.prototype.hasOwnProperty.call(ROUTE_TARGET_TEMPLATES, kind)) return null;
|
|
127
146
|
return { kind, id };
|
|
@@ -133,17 +152,17 @@ function routeTargetPathsPosix(target) {
|
|
|
133
152
|
}
|
|
134
153
|
|
|
135
154
|
// src/scripts/report_conformance_funnel.ts
|
|
136
|
-
import * as
|
|
155
|
+
import * as fs19 from "node:fs";
|
|
137
156
|
import * as os6 from "node:os";
|
|
138
|
-
import * as
|
|
157
|
+
import * as path17 from "node:path";
|
|
139
158
|
import process4 from "node:process";
|
|
140
159
|
import { fileURLToPath as fileURLToPath13, pathToFileURL as pathToFileURL13 } from "node:url";
|
|
141
160
|
|
|
142
161
|
// src/scripts/conformance_scan.ts
|
|
143
|
-
import { createHash as
|
|
144
|
-
import
|
|
162
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
163
|
+
import fs15 from "node:fs";
|
|
145
164
|
import os2 from "node:os";
|
|
146
|
-
import
|
|
165
|
+
import path13 from "node:path";
|
|
147
166
|
import { fileURLToPath as fileURLToPath9, pathToFileURL as pathToFileURL9 } from "node:url";
|
|
148
167
|
|
|
149
168
|
// src/scripts/_lib/transcript_entry.ts
|
|
@@ -191,7 +210,7 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
191
210
|
// src/scripts/_lib/prompt_shape.ts
|
|
192
211
|
function isSyntheticPrompt(prompt) {
|
|
193
212
|
const head = prompt.trimStart().slice(0, 400);
|
|
194
|
-
return head.startsWith("[SYSTEM NOTIFICATION - NOT USER INPUT]") || head.startsWith("<task-notification>") || head.startsWith("<system-reminder>") || head.startsWith("<local-command-caveat>") || /^\[SYSTEM NOTIFICATION\b/.test(head);
|
|
213
|
+
return head.startsWith("[SYSTEM NOTIFICATION - NOT USER INPUT]") || head.startsWith("<task-notification>") || head.startsWith("<system-reminder>") || head.startsWith("<local-command-caveat>") || head.startsWith("<agent-message") || head.startsWith("Your claude.ai usage limit has reset") || /^\[SYSTEM NOTIFICATION\b/.test(head);
|
|
195
214
|
}
|
|
196
215
|
var DOCUMENT_HEAD = /^\s*(#{1,6}\s|-{3,}\s*$|={3,}\s*$|<[A-Za-z][\w-]*>\s*$)/;
|
|
197
216
|
function humanAuthoredLead(text) {
|
|
@@ -348,7 +367,7 @@ This is the WEAKER of the two provenances \u2014 it reflects the machine, not th
|
|
|
348
367
|
return `<language-pin>
|
|
349
368
|
The user submitted this turn's prompt in ${name}. That is the mirror target for EVERY user-visible token of your replies this turn \u2014 including the short inter-tool lines between tool calls, headings, table cells, bullets, status lines, and the recommendation label under any numbered-options block.
|
|
350
369
|
|
|
351
|
-
|
|
370
|
+
Tool output, file contents, and an injected skill body are NOT the trigger \u2014 this pin is.
|
|
352
371
|
</language-pin>`;
|
|
353
372
|
}
|
|
354
373
|
function _loadState(target) {
|
|
@@ -716,7 +735,8 @@ import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL2 } from
|
|
|
716
735
|
// src/scripts/_lib/machine_wake.ts
|
|
717
736
|
var MACHINE_WAKE_PREFIXES = [
|
|
718
737
|
"<task-notification>",
|
|
719
|
-
"<system-reminder>"
|
|
738
|
+
"<system-reminder>",
|
|
739
|
+
"<agent-message"
|
|
720
740
|
];
|
|
721
741
|
function humanTypedThisTurn(prompt) {
|
|
722
742
|
const head = prompt.trimStart();
|
|
@@ -1927,8 +1947,8 @@ var COMMAND_OBJECTS = {
|
|
|
1927
1947
|
};
|
|
1928
1948
|
|
|
1929
1949
|
// src/scripts/hooks/turn_end_gate_hook.ts
|
|
1930
|
-
import * as
|
|
1931
|
-
import * as
|
|
1950
|
+
import * as fs12 from "node:fs";
|
|
1951
|
+
import * as path10 from "node:path";
|
|
1932
1952
|
import { fileURLToPath as fileURLToPath6, pathToFileURL as pathToFileURL6 } from "node:url";
|
|
1933
1953
|
|
|
1934
1954
|
// src/scripts/check_reply_consistency.ts
|
|
@@ -2307,6 +2327,957 @@ function detectDroppedDecision(assistantTurnTexts, closingFromPayload = false) {
|
|
|
2307
2327
|
return null;
|
|
2308
2328
|
}
|
|
2309
2329
|
|
|
2330
|
+
// src/scripts/_lib/graph_feeder_record.ts
|
|
2331
|
+
import * as fs7 from "node:fs";
|
|
2332
|
+
import * as path6 from "node:path";
|
|
2333
|
+
|
|
2334
|
+
// src/scripts/code_graph/detect.ts
|
|
2335
|
+
import { execFileSync } from "node:child_process";
|
|
2336
|
+
import * as fs4 from "node:fs";
|
|
2337
|
+
import * as path4 from "node:path";
|
|
2338
|
+
|
|
2339
|
+
// src/scripts/code_graph/types.ts
|
|
2340
|
+
var GUESS_RESOLVED_VIA = /* @__PURE__ */ new Set([
|
|
2341
|
+
"name-lookup",
|
|
2342
|
+
"dynamic",
|
|
2343
|
+
// The accepted-edge filter is a DENYLIST, so a new value is accepted by
|
|
2344
|
+
// default — which is exactly backwards for this one. `foreign` must be
|
|
2345
|
+
// listed here or a consumer's graph would silently answer the gate verbs
|
|
2346
|
+
// as if this package had resolved its edges.
|
|
2347
|
+
"foreign"
|
|
2348
|
+
]);
|
|
2349
|
+
function isStatedResolution(resolved_via) {
|
|
2350
|
+
return !GUESS_RESOLVED_VIA.has(resolved_via);
|
|
2351
|
+
}
|
|
2352
|
+
var SCHEMA_VERSION = 4;
|
|
2353
|
+
var EXT_LANG = {
|
|
2354
|
+
".php": "php",
|
|
2355
|
+
".ts": "typescript",
|
|
2356
|
+
".tsx": "typescript",
|
|
2357
|
+
".mts": "typescript",
|
|
2358
|
+
".cts": "typescript",
|
|
2359
|
+
".js": "javascript",
|
|
2360
|
+
".jsx": "javascript",
|
|
2361
|
+
".mjs": "javascript",
|
|
2362
|
+
".cjs": "javascript"
|
|
2363
|
+
};
|
|
2364
|
+
|
|
2365
|
+
// src/scripts/code_graph/validate.ts
|
|
2366
|
+
var RELATIONS = /* @__PURE__ */ new Set(["calls", "imports", "uses", "inherits", "member", "tests"]);
|
|
2367
|
+
var CONFIDENCES = /* @__PURE__ */ new Set(["EXTRACTED", "INFERRED", "AMBIGUOUS"]);
|
|
2368
|
+
var RESOLVED_VIA = /* @__PURE__ */ new Set([
|
|
2369
|
+
"same-file",
|
|
2370
|
+
"import-specifier",
|
|
2371
|
+
"path-alias",
|
|
2372
|
+
"psr4",
|
|
2373
|
+
"route-table",
|
|
2374
|
+
"test-import",
|
|
2375
|
+
"name-lookup",
|
|
2376
|
+
"dynamic",
|
|
2377
|
+
// Adapted from a consumer's own graph file; see `foreign.ts`.
|
|
2378
|
+
"foreign"
|
|
2379
|
+
]);
|
|
2380
|
+
var PROVIDERS = /* @__PURE__ */ new Set(["native", "foreign"]);
|
|
2381
|
+
var KINDS = /* @__PURE__ */ new Set([
|
|
2382
|
+
"file",
|
|
2383
|
+
"class",
|
|
2384
|
+
"interface",
|
|
2385
|
+
"trait",
|
|
2386
|
+
"function",
|
|
2387
|
+
"method",
|
|
2388
|
+
"constant",
|
|
2389
|
+
"type",
|
|
2390
|
+
"enum",
|
|
2391
|
+
"skipped"
|
|
2392
|
+
]);
|
|
2393
|
+
function validateGraph(g) {
|
|
2394
|
+
const errors = [];
|
|
2395
|
+
const push = (m) => {
|
|
2396
|
+
if (errors.length < 50) errors.push(m);
|
|
2397
|
+
};
|
|
2398
|
+
if (typeof g !== "object" || g === null) return { ok: false, errors: ["graph is not an object"] };
|
|
2399
|
+
const obj = g;
|
|
2400
|
+
if (typeof obj["schema_version"] !== "number") push("schema_version must be a number");
|
|
2401
|
+
if (typeof obj["source_checksum"] !== "string") push("source_checksum must be a string");
|
|
2402
|
+
if (!Array.isArray(obj["nodes"])) push("nodes must be an array");
|
|
2403
|
+
if (!Array.isArray(obj["edges"])) push("edges must be an array");
|
|
2404
|
+
if (errors.length) return { ok: false, errors };
|
|
2405
|
+
const nodes = obj["nodes"];
|
|
2406
|
+
const ids = /* @__PURE__ */ new Set();
|
|
2407
|
+
nodes.forEach((n, i) => {
|
|
2408
|
+
if (typeof n !== "object" || n === null) return push(`node[${i}] not an object`);
|
|
2409
|
+
const nn = n;
|
|
2410
|
+
if (typeof nn["id"] !== "string") push(`node[${i}].id must be a string`);
|
|
2411
|
+
else ids.add(nn["id"]);
|
|
2412
|
+
if (!KINDS.has(nn["kind"])) push(`node[${i}].kind invalid: ${String(nn["kind"])}`);
|
|
2413
|
+
if (typeof nn["source_file"] !== "string") push(`node[${i}].source_file must be a string`);
|
|
2414
|
+
if (!Array.isArray(nn["source_location"])) push(`node[${i}].source_location must be an array`);
|
|
2415
|
+
});
|
|
2416
|
+
obj["edges"].forEach((e, i) => {
|
|
2417
|
+
if (typeof e !== "object" || e === null) return push(`edge[${i}] not an object`);
|
|
2418
|
+
const ee = e;
|
|
2419
|
+
if (typeof ee["source"] !== "string") push(`edge[${i}].source must be a string`);
|
|
2420
|
+
if (typeof ee["target"] !== "string") push(`edge[${i}].target must be a string`);
|
|
2421
|
+
if (!RELATIONS.has(ee["relation"])) push(`edge[${i}].relation invalid: ${String(ee["relation"])}`);
|
|
2422
|
+
if (!CONFIDENCES.has(ee["confidence"]))
|
|
2423
|
+
push(`edge[${i}].confidence invalid: ${String(ee["confidence"])}`);
|
|
2424
|
+
if (ee["resolved_via"] === void 0) push(`edge[${i}].resolved_via is required`);
|
|
2425
|
+
else if (!RESOLVED_VIA.has(ee["resolved_via"]))
|
|
2426
|
+
push(`edge[${i}].resolved_via invalid: ${String(ee["resolved_via"])}`);
|
|
2427
|
+
if (ee["provider"] === void 0) push(`edge[${i}].provider is required`);
|
|
2428
|
+
else if (!PROVIDERS.has(ee["provider"]))
|
|
2429
|
+
push(`edge[${i}].provider invalid: ${String(ee["provider"])}`);
|
|
2430
|
+
if (typeof ee["source"] === "string" && !ids.has(ee["source"]))
|
|
2431
|
+
push(`edge[${i}].source is not a known node: ${String(ee["source"])}`);
|
|
2432
|
+
if (ee["candidates"] !== void 0 && !Array.isArray(ee["candidates"]))
|
|
2433
|
+
push(`edge[${i}].candidates must be an array when present`);
|
|
2434
|
+
});
|
|
2435
|
+
return { ok: errors.length === 0, errors };
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2438
|
+
// src/scripts/code_graph/detect.ts
|
|
2439
|
+
var CONSUMER_CANDIDATES = ["graph.json", "code-graph.json", ".code-graph/graph.json"];
|
|
2440
|
+
function consumerCandidates(root) {
|
|
2441
|
+
let declared;
|
|
2442
|
+
try {
|
|
2443
|
+
const settings = load_agent_settings({ cwd: root }) ?? {};
|
|
2444
|
+
const section = settings["code_graph"];
|
|
2445
|
+
declared = section !== null && typeof section === "object" && !Array.isArray(section) ? section["consumer_index_paths"] : void 0;
|
|
2446
|
+
} catch {
|
|
2447
|
+
declared = void 0;
|
|
2448
|
+
}
|
|
2449
|
+
const extra = Array.isArray(declared) ? declared.filter(
|
|
2450
|
+
(p) => typeof p === "string" && p !== "" && !path4.isAbsolute(p) && !path4.normalize(p).startsWith("..")
|
|
2451
|
+
) : [];
|
|
2452
|
+
return [...CONSUMER_CANDIDATES, ...extra.filter((p) => !CONSUMER_CANDIDATES.includes(p))];
|
|
2453
|
+
}
|
|
2454
|
+
function gitLastCommitEpoch(root) {
|
|
2455
|
+
try {
|
|
2456
|
+
const out = execFileSync("git", ["-C", root, "log", "-1", "--format=%ct"], {
|
|
2457
|
+
env: hardenedSpawnEnv(),
|
|
2458
|
+
encoding: "utf-8",
|
|
2459
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
2460
|
+
}).trim();
|
|
2461
|
+
const n = Number(out);
|
|
2462
|
+
return Number.isFinite(n) ? n : null;
|
|
2463
|
+
} catch {
|
|
2464
|
+
return null;
|
|
2465
|
+
}
|
|
2466
|
+
}
|
|
2467
|
+
function commitsBehind(root, sha) {
|
|
2468
|
+
try {
|
|
2469
|
+
const out = execFileSync("git", ["-C", root, "rev-list", "--count", `${sha}..HEAD`], {
|
|
2470
|
+
env: hardenedSpawnEnv(),
|
|
2471
|
+
encoding: "utf-8",
|
|
2472
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
2473
|
+
}).trim();
|
|
2474
|
+
const n = Number(out);
|
|
2475
|
+
return Number.isFinite(n) ? n : null;
|
|
2476
|
+
} catch {
|
|
2477
|
+
return null;
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
function freshness(root, file, embeddedSha) {
|
|
2481
|
+
if (embeddedSha) {
|
|
2482
|
+
const behind = commitsBehind(root, embeddedSha);
|
|
2483
|
+
if (behind !== null) return { stale: behind > 0, commits_behind: behind };
|
|
2484
|
+
}
|
|
2485
|
+
const last = gitLastCommitEpoch(root);
|
|
2486
|
+
if (last === null) return {};
|
|
2487
|
+
try {
|
|
2488
|
+
const mtime = Math.floor(fs4.statSync(file).mtimeMs / 1e3);
|
|
2489
|
+
return { stale: mtime < last };
|
|
2490
|
+
} catch {
|
|
2491
|
+
return {};
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
function looksLikeGraph(p) {
|
|
2495
|
+
try {
|
|
2496
|
+
const raw = JSON.parse(fs4.readFileSync(p, "utf-8"));
|
|
2497
|
+
if (validateGraph(raw).ok) return { ok: true, sha: raw["head_at_build"] ?? null };
|
|
2498
|
+
const nodes = raw["nodes"];
|
|
2499
|
+
const edges = raw["edges"] ?? raw["links"];
|
|
2500
|
+
const okShape = Array.isArray(nodes) && Array.isArray(edges) && (edges.length === 0 || typeof edges[0] === "object" && edges[0] !== null && "source" in edges[0] && "target" in edges[0]);
|
|
2501
|
+
return { ok: okShape, sha: raw["head_at_build"] ?? null };
|
|
2502
|
+
} catch {
|
|
2503
|
+
return { ok: false, sha: null };
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
function detectSources(root, nativeCache) {
|
|
2507
|
+
const abs = path4.resolve(root);
|
|
2508
|
+
const out = [];
|
|
2509
|
+
for (const rel of consumerCandidates(abs)) {
|
|
2510
|
+
const p = path4.join(abs, rel);
|
|
2511
|
+
if (fs4.existsSync(p)) {
|
|
2512
|
+
const { ok, sha } = looksLikeGraph(p);
|
|
2513
|
+
if (ok) out.push({ kind: "consumer", path: p, present: true, ...freshness(abs, p, sha) });
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2516
|
+
const scipCandidates = [path4.join(abs, "index.scip")];
|
|
2517
|
+
try {
|
|
2518
|
+
for (const e of fs4.readdirSync(abs)) if (e.endsWith(".scip")) scipCandidates.push(path4.join(abs, e));
|
|
2519
|
+
} catch {
|
|
2520
|
+
}
|
|
2521
|
+
const scip = scipCandidates.find((p) => fs4.existsSync(p));
|
|
2522
|
+
if (scip) out.push({ kind: "scip", path: scip, present: true, note: "SCIP detected \u2014 peer tooling required (no owned reader)" });
|
|
2523
|
+
if (fs4.existsSync(nativeCache)) out.push({ kind: "native", path: nativeCache, present: true, ...freshness(abs, nativeCache, null) });
|
|
2524
|
+
return out;
|
|
2525
|
+
}
|
|
2526
|
+
function pickSource(verdicts) {
|
|
2527
|
+
const consumer = verdicts.find((v) => v.kind === "consumer" && v.stale !== true);
|
|
2528
|
+
if (consumer) return consumer;
|
|
2529
|
+
const native = verdicts.find((v) => v.kind === "native");
|
|
2530
|
+
if (native) return native;
|
|
2531
|
+
return verdicts.find((v) => v.kind === "consumer") ?? null;
|
|
2532
|
+
}
|
|
2533
|
+
var NATIVE_CACHE_REL = path4.join("agents", "runtime", "state", "code-graph-v1.json");
|
|
2534
|
+
function hasUncommittedIndexedEdit(root) {
|
|
2535
|
+
let out;
|
|
2536
|
+
try {
|
|
2537
|
+
out = execFileSync("git", ["-C", root, "status", "--porcelain", "--untracked-files=all"], {
|
|
2538
|
+
env: hardenedSpawnEnv(),
|
|
2539
|
+
encoding: "utf-8",
|
|
2540
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
2541
|
+
// Both bounds are the review's: Node's 1 MB default would throw
|
|
2542
|
+
// ENOBUFS on a large working tree, the catch below would return
|
|
2543
|
+
// false, and the state would read `fresh` — a second silent
|
|
2544
|
+
// under-report on a probe that runs at PreToolUse and at every stop.
|
|
2545
|
+
// The timeout bounds the other failure: this probe sits in front of
|
|
2546
|
+
// a tool call, so a hung git must not hold one up.
|
|
2547
|
+
maxBuffer: 32 * 1024 * 1024,
|
|
2548
|
+
timeout: 5e3
|
|
2549
|
+
});
|
|
2550
|
+
} catch {
|
|
2551
|
+
return false;
|
|
2552
|
+
}
|
|
2553
|
+
for (const raw of out.split("\n")) {
|
|
2554
|
+
if (raw.length < 4) continue;
|
|
2555
|
+
let p = raw.slice(3);
|
|
2556
|
+
const arrow = p.indexOf(" -> ");
|
|
2557
|
+
if (arrow !== -1) p = p.slice(arrow + 4);
|
|
2558
|
+
p = p.trim().replace(/^"|"$/g, "");
|
|
2559
|
+
const dot = p.lastIndexOf(".");
|
|
2560
|
+
if (dot === -1) continue;
|
|
2561
|
+
if (p.slice(dot).toLowerCase() in EXT_LANG) return true;
|
|
2562
|
+
}
|
|
2563
|
+
return false;
|
|
2564
|
+
}
|
|
2565
|
+
function graphState(root, nativeCache) {
|
|
2566
|
+
const picked = pickSource(detectSources(root, nativeCache ?? path4.join(root, NATIVE_CACHE_REL)));
|
|
2567
|
+
if (!picked) return "absent";
|
|
2568
|
+
if (picked.stale === true) {
|
|
2569
|
+
const behind = picked.commits_behind;
|
|
2570
|
+
return `behind:${typeof behind === "number" ? behind : 0}`;
|
|
2571
|
+
}
|
|
2572
|
+
return hasUncommittedIndexedEdit(root) ? "edited" : "fresh";
|
|
2573
|
+
}
|
|
2574
|
+
|
|
2575
|
+
// src/scripts/code_graph/query.ts
|
|
2576
|
+
import * as fs6 from "node:fs";
|
|
2577
|
+
|
|
2578
|
+
// src/scripts/code_graph/sqlite_store.ts
|
|
2579
|
+
import * as fs5 from "node:fs";
|
|
2580
|
+
var GRAPH_STORE_VERSION = 4;
|
|
2581
|
+
var INDEXED_READ_MIN_EDGES = 5e4;
|
|
2582
|
+
function sqliteTwinPath(jsonPath) {
|
|
2583
|
+
return jsonPath.endsWith(".json") ? `${jsonPath.slice(0, -5)}.sqlite3` : `${jsonPath}.sqlite3`;
|
|
2584
|
+
}
|
|
2585
|
+
function emitSqliteTwin(graph, serialized, jsonPath) {
|
|
2586
|
+
if (!isSqliteAvailableSync()) return false;
|
|
2587
|
+
const twin = sqliteTwinPath(jsonPath);
|
|
2588
|
+
const tmp = `${twin}.tmp-${process.pid}`;
|
|
2589
|
+
try {
|
|
2590
|
+
const { DatabaseSync } = loadSqliteSync("code_graph.sqlite_store");
|
|
2591
|
+
let stat;
|
|
2592
|
+
try {
|
|
2593
|
+
stat = fs5.statSync(jsonPath);
|
|
2594
|
+
} catch {
|
|
2595
|
+
return false;
|
|
2596
|
+
}
|
|
2597
|
+
fs5.rmSync(tmp, { force: true });
|
|
2598
|
+
const db = new DatabaseSync(tmp);
|
|
2599
|
+
try {
|
|
2600
|
+
db.exec("PRAGMA journal_mode = MEMORY");
|
|
2601
|
+
db.exec(
|
|
2602
|
+
"CREATE TABLE meta (key TEXT PRIMARY KEY, value TEXT NOT NULL);CREATE TABLE nodes (id TEXT PRIMARY KEY, label TEXT NOT NULL, kind TEXT, source_file TEXT, l0 INTEGER, l1 INTEGER, l2 INTEGER, l3 INTEGER);CREATE TABLE edges (source TEXT NOT NULL, target TEXT NOT NULL, relation TEXT NOT NULL, confidence TEXT NOT NULL, candidates TEXT, ambiguity_reason TEXT, resolved_via TEXT, provider TEXT);CREATE INDEX edges_source ON edges(source);CREATE INDEX edges_target ON edges(target);CREATE INDEX nodes_label ON nodes(label);CREATE INDEX nodes_source_file ON nodes(source_file);"
|
|
2603
|
+
);
|
|
2604
|
+
const meta = db.prepare("INSERT INTO meta (key, value) VALUES (?, ?)");
|
|
2605
|
+
meta.run("source_checksum", graph.source_checksum);
|
|
2606
|
+
meta.run("json_size", String(stat.size));
|
|
2607
|
+
meta.run("json_mtime_ms", String(stat.mtimeMs));
|
|
2608
|
+
meta.run("graph_json", serialized);
|
|
2609
|
+
meta.run("node_count", String(graph.nodes.length));
|
|
2610
|
+
meta.run("edge_count", String(graph.edges.length));
|
|
2611
|
+
const insNode = db.prepare(
|
|
2612
|
+
"INSERT INTO nodes (id, label, kind, source_file, l0, l1, l2, l3) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
|
|
2613
|
+
);
|
|
2614
|
+
for (const n of graph.nodes) {
|
|
2615
|
+
const loc = n.source_location ?? [];
|
|
2616
|
+
insNode.run(
|
|
2617
|
+
n.id,
|
|
2618
|
+
n.label,
|
|
2619
|
+
n.kind ?? null,
|
|
2620
|
+
n.source_file ?? null,
|
|
2621
|
+
loc[0] ?? null,
|
|
2622
|
+
loc[1] ?? null,
|
|
2623
|
+
loc[2] ?? null,
|
|
2624
|
+
loc[3] ?? null
|
|
2625
|
+
);
|
|
2626
|
+
}
|
|
2627
|
+
const insEdge = db.prepare(
|
|
2628
|
+
"INSERT INTO edges (source, target, relation, confidence, candidates, ambiguity_reason, resolved_via, provider) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
|
|
2629
|
+
);
|
|
2630
|
+
for (const e of graph.edges) {
|
|
2631
|
+
insEdge.run(
|
|
2632
|
+
e.source,
|
|
2633
|
+
e.target,
|
|
2634
|
+
e.relation,
|
|
2635
|
+
e.confidence,
|
|
2636
|
+
e.candidates ? JSON.stringify(e.candidates) : null,
|
|
2637
|
+
e.ambiguity_reason ?? null,
|
|
2638
|
+
e.resolved_via,
|
|
2639
|
+
e.provider
|
|
2640
|
+
);
|
|
2641
|
+
}
|
|
2642
|
+
stampUserVersion(db, GRAPH_STORE_VERSION);
|
|
2643
|
+
} finally {
|
|
2644
|
+
db.close();
|
|
2645
|
+
}
|
|
2646
|
+
fs5.renameSync(tmp, twin);
|
|
2647
|
+
return true;
|
|
2648
|
+
} catch {
|
|
2649
|
+
fs5.rmSync(tmp, { force: true });
|
|
2650
|
+
return false;
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
function loadSerializedFromTwin(jsonPath) {
|
|
2654
|
+
if (!isSqliteAvailableSync()) return null;
|
|
2655
|
+
const twin = sqliteTwinPath(jsonPath);
|
|
2656
|
+
if (!fs5.existsSync(twin)) return null;
|
|
2657
|
+
let stat;
|
|
2658
|
+
try {
|
|
2659
|
+
stat = fs5.statSync(jsonPath);
|
|
2660
|
+
} catch {
|
|
2661
|
+
return null;
|
|
2662
|
+
}
|
|
2663
|
+
try {
|
|
2664
|
+
const { DatabaseSync } = loadSqliteSync("code_graph.sqlite_store");
|
|
2665
|
+
const db = new DatabaseSync(twin, { readOnly: true });
|
|
2666
|
+
try {
|
|
2667
|
+
if (readUserVersion(db) !== GRAPH_STORE_VERSION) return null;
|
|
2668
|
+
const rows = db.prepare("SELECT key, value FROM meta").all();
|
|
2669
|
+
const meta = new Map(rows.map((r) => [r.key, r.value]));
|
|
2670
|
+
if (meta.get("json_size") !== String(stat.size)) return null;
|
|
2671
|
+
if (meta.get("json_mtime_ms") !== String(stat.mtimeMs)) return null;
|
|
2672
|
+
const serialized = meta.get("graph_json");
|
|
2673
|
+
return serialized && serialized.length > 0 ? serialized : null;
|
|
2674
|
+
} finally {
|
|
2675
|
+
db.close();
|
|
2676
|
+
}
|
|
2677
|
+
} catch {
|
|
2678
|
+
fs5.rmSync(twin, { force: true });
|
|
2679
|
+
return null;
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
function toNode(r) {
|
|
2683
|
+
const loc = [r.l0, r.l1, r.l2, r.l3].filter((v) => typeof v === "number");
|
|
2684
|
+
return {
|
|
2685
|
+
id: r.id,
|
|
2686
|
+
label: r.label,
|
|
2687
|
+
kind: r.kind ?? "file",
|
|
2688
|
+
source_file: r.source_file ?? "",
|
|
2689
|
+
source_location: loc
|
|
2690
|
+
};
|
|
2691
|
+
}
|
|
2692
|
+
function toEdge(r) {
|
|
2693
|
+
const e = {
|
|
2694
|
+
source: r.source,
|
|
2695
|
+
target: r.target,
|
|
2696
|
+
relation: r.relation,
|
|
2697
|
+
confidence: r.confidence,
|
|
2698
|
+
// The SQL columns are nullable, the TypeScript fields are not. A null
|
|
2699
|
+
// can only come from a twin emitted before these fields existed, which
|
|
2700
|
+
// GRAPH_STORE_VERSION already refuses — so this coalesce is unreachable
|
|
2701
|
+
// in a healthy tree and is written to fail READABLE rather than to
|
|
2702
|
+
// fabricate: `name-lookup` is the weakest mechanism, so a mislabelled
|
|
2703
|
+
// edge is under-trusted rather than over-trusted by Phase 3's filter.
|
|
2704
|
+
resolved_via: r.resolved_via ?? "name-lookup",
|
|
2705
|
+
provider: r.provider ?? "native"
|
|
2706
|
+
};
|
|
2707
|
+
if (r.candidates) e.candidates = JSON.parse(r.candidates);
|
|
2708
|
+
if (r.ambiguity_reason === "receiver-unknown" || r.ambiguity_reason === "hierarchy-unresolved") {
|
|
2709
|
+
e.ambiguity_reason = r.ambiguity_reason;
|
|
2710
|
+
}
|
|
2711
|
+
return e;
|
|
2712
|
+
}
|
|
2713
|
+
function openGraphIndex(jsonPath) {
|
|
2714
|
+
if (!isSqliteAvailableSync()) return null;
|
|
2715
|
+
const twin = sqliteTwinPath(jsonPath);
|
|
2716
|
+
if (!fs5.existsSync(twin)) return null;
|
|
2717
|
+
let stat;
|
|
2718
|
+
try {
|
|
2719
|
+
stat = fs5.statSync(jsonPath);
|
|
2720
|
+
} catch {
|
|
2721
|
+
return null;
|
|
2722
|
+
}
|
|
2723
|
+
try {
|
|
2724
|
+
const { DatabaseSync } = loadSqliteSync("code_graph.sqlite_store");
|
|
2725
|
+
const db = new DatabaseSync(twin, { readOnly: true });
|
|
2726
|
+
try {
|
|
2727
|
+
if (readUserVersion(db) !== GRAPH_STORE_VERSION) {
|
|
2728
|
+
db.close();
|
|
2729
|
+
return null;
|
|
2730
|
+
}
|
|
2731
|
+
const rows = db.prepare("SELECT key, value FROM meta").all();
|
|
2732
|
+
const meta = new Map(rows.map((r) => [r.key, r.value]));
|
|
2733
|
+
if (meta.get("json_size") !== String(stat.size) || meta.get("json_mtime_ms") !== String(stat.mtimeMs)) {
|
|
2734
|
+
db.close();
|
|
2735
|
+
return null;
|
|
2736
|
+
}
|
|
2737
|
+
const nodeCount = Number(meta.get("node_count") ?? NaN);
|
|
2738
|
+
const edgeCount = Number(meta.get("edge_count") ?? NaN);
|
|
2739
|
+
if (!Number.isFinite(nodeCount) || !Number.isFinite(edgeCount)) {
|
|
2740
|
+
db.close();
|
|
2741
|
+
return null;
|
|
2742
|
+
}
|
|
2743
|
+
const qNode = db.prepare("SELECT * FROM nodes WHERE id = ?");
|
|
2744
|
+
const qFrom = db.prepare("SELECT * FROM edges WHERE source = ?");
|
|
2745
|
+
const qTo = db.prepare("SELECT * FROM edges WHERE target = ?");
|
|
2746
|
+
const qLabel = db.prepare("SELECT id FROM nodes WHERE label = ? LIMIT ?");
|
|
2747
|
+
return {
|
|
2748
|
+
nodeCount,
|
|
2749
|
+
edgeCount,
|
|
2750
|
+
sourceChecksum: meta.get("source_checksum") ?? "",
|
|
2751
|
+
getNode(id) {
|
|
2752
|
+
const r = qNode.get(id);
|
|
2753
|
+
return r ? toNode(r) : void 0;
|
|
2754
|
+
},
|
|
2755
|
+
hasNode(id) {
|
|
2756
|
+
return qNode.get(id) !== void 0;
|
|
2757
|
+
},
|
|
2758
|
+
edgesFrom(id) {
|
|
2759
|
+
return qFrom.all(id).map(toEdge);
|
|
2760
|
+
},
|
|
2761
|
+
edgesTo(id) {
|
|
2762
|
+
return qTo.all(id).map(toEdge);
|
|
2763
|
+
},
|
|
2764
|
+
idsByLabel(labelText, limit) {
|
|
2765
|
+
return qLabel.all(labelText, limit).map((r) => r.id);
|
|
2766
|
+
},
|
|
2767
|
+
idsInFiles(files) {
|
|
2768
|
+
if (files.length === 0) return [];
|
|
2769
|
+
const out = [];
|
|
2770
|
+
const CHUNK = 400;
|
|
2771
|
+
for (let i = 0; i < files.length; i += CHUNK) {
|
|
2772
|
+
const slice = files.slice(i, i + CHUNK);
|
|
2773
|
+
const marks = slice.map(() => "?").join(",");
|
|
2774
|
+
const stmt = db.prepare(
|
|
2775
|
+
`SELECT id FROM nodes WHERE kind != 'file' AND source_file IN (${marks})`
|
|
2776
|
+
);
|
|
2777
|
+
for (const r of stmt.all(...slice)) out.push(r.id);
|
|
2778
|
+
}
|
|
2779
|
+
return out;
|
|
2780
|
+
},
|
|
2781
|
+
allNodeIds() {
|
|
2782
|
+
return db.prepare("SELECT id FROM nodes ORDER BY id").all().map(
|
|
2783
|
+
(r) => r.id
|
|
2784
|
+
);
|
|
2785
|
+
},
|
|
2786
|
+
lexicalCorpus() {
|
|
2787
|
+
return db.prepare("SELECT id, label FROM nodes").all().map(
|
|
2788
|
+
(r) => ({ id: r.id, text: `${r.label} ${r.id}` })
|
|
2789
|
+
);
|
|
2790
|
+
},
|
|
2791
|
+
close() {
|
|
2792
|
+
db.close();
|
|
2793
|
+
}
|
|
2794
|
+
};
|
|
2795
|
+
} catch (err) {
|
|
2796
|
+
db.close();
|
|
2797
|
+
throw err;
|
|
2798
|
+
}
|
|
2799
|
+
} catch {
|
|
2800
|
+
return null;
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
|
|
2804
|
+
// src/scripts/code_graph/foreign.ts
|
|
2805
|
+
import { createHash } from "node:crypto";
|
|
2806
|
+
var RELATION_MAP = {
|
|
2807
|
+
calls: "calls",
|
|
2808
|
+
call: "calls",
|
|
2809
|
+
invokes: "calls",
|
|
2810
|
+
imports: "imports",
|
|
2811
|
+
import: "imports",
|
|
2812
|
+
requires: "imports",
|
|
2813
|
+
uses: "uses",
|
|
2814
|
+
use: "uses",
|
|
2815
|
+
references: "uses",
|
|
2816
|
+
inherits: "inherits",
|
|
2817
|
+
extends: "inherits",
|
|
2818
|
+
implements: "inherits",
|
|
2819
|
+
member: "member",
|
|
2820
|
+
contains: "member",
|
|
2821
|
+
tests: "tests",
|
|
2822
|
+
test: "tests"
|
|
2823
|
+
};
|
|
2824
|
+
var KINDS2 = /* @__PURE__ */ new Set([
|
|
2825
|
+
"file",
|
|
2826
|
+
"class",
|
|
2827
|
+
"interface",
|
|
2828
|
+
"trait",
|
|
2829
|
+
"function",
|
|
2830
|
+
"method",
|
|
2831
|
+
"constant",
|
|
2832
|
+
"type",
|
|
2833
|
+
"enum",
|
|
2834
|
+
"skipped"
|
|
2835
|
+
]);
|
|
2836
|
+
function isObject(v) {
|
|
2837
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
2838
|
+
}
|
|
2839
|
+
function looksForeign(doc) {
|
|
2840
|
+
if (!isObject(doc)) return false;
|
|
2841
|
+
if (!Array.isArray(doc["nodes"])) return false;
|
|
2842
|
+
if (Array.isArray(doc["links"])) return true;
|
|
2843
|
+
return Array.isArray(doc["edges"]) && typeof doc["schema_version"] !== "number";
|
|
2844
|
+
}
|
|
2845
|
+
function adaptForeignGraph(doc) {
|
|
2846
|
+
if (!isObject(doc)) return null;
|
|
2847
|
+
const rawNodes = doc["nodes"];
|
|
2848
|
+
const rawEdges = doc["links"] ?? doc["edges"];
|
|
2849
|
+
if (!Array.isArray(rawNodes) || !Array.isArray(rawEdges)) return null;
|
|
2850
|
+
const nodes = [];
|
|
2851
|
+
const ids = /* @__PURE__ */ new Set();
|
|
2852
|
+
for (const n of rawNodes) {
|
|
2853
|
+
if (!isObject(n)) continue;
|
|
2854
|
+
const id = n["id"];
|
|
2855
|
+
if (typeof id !== "string" || id === "") continue;
|
|
2856
|
+
const kind = typeof n["kind"] === "string" && KINDS2.has(n["kind"]) ? n["kind"] : "skipped";
|
|
2857
|
+
const sourceFile = typeof n["source_file"] === "string" ? n["source_file"] : typeof n["file"] === "string" ? n["file"] : "";
|
|
2858
|
+
nodes.push({
|
|
2859
|
+
id,
|
|
2860
|
+
label: typeof n["label"] === "string" ? n["label"] : id,
|
|
2861
|
+
kind,
|
|
2862
|
+
source_file: sourceFile,
|
|
2863
|
+
// A foreign node rarely carries a span. An empty one is honest —
|
|
2864
|
+
// it says "no location recorded", where a fabricated [1,1] would
|
|
2865
|
+
// point a reader at the top of a file for no reason.
|
|
2866
|
+
source_location: Array.isArray(n["source_location"]) ? n["source_location"] : []
|
|
2867
|
+
});
|
|
2868
|
+
ids.add(id);
|
|
2869
|
+
}
|
|
2870
|
+
const edges = [];
|
|
2871
|
+
const unmapped = {};
|
|
2872
|
+
let malformed = 0;
|
|
2873
|
+
for (const e of rawEdges) {
|
|
2874
|
+
if (!isObject(e)) {
|
|
2875
|
+
malformed += 1;
|
|
2876
|
+
continue;
|
|
2877
|
+
}
|
|
2878
|
+
const source = e["source"];
|
|
2879
|
+
const target = e["target"];
|
|
2880
|
+
if (typeof source !== "string" || typeof target !== "string" || !ids.has(source)) {
|
|
2881
|
+
malformed += 1;
|
|
2882
|
+
continue;
|
|
2883
|
+
}
|
|
2884
|
+
const rawRelation = typeof e["relation"] === "string" ? e["relation"] : "";
|
|
2885
|
+
const relation = RELATION_MAP[rawRelation.toLowerCase()];
|
|
2886
|
+
if (relation === void 0) {
|
|
2887
|
+
const key = rawRelation === "" ? "(none)" : rawRelation;
|
|
2888
|
+
unmapped[key] = (unmapped[key] ?? 0) + 1;
|
|
2889
|
+
continue;
|
|
2890
|
+
}
|
|
2891
|
+
edges.push({
|
|
2892
|
+
source,
|
|
2893
|
+
target,
|
|
2894
|
+
relation,
|
|
2895
|
+
// Not EXTRACTED: this package did not extract it and cannot say
|
|
2896
|
+
// how the tool that did arrived at it.
|
|
2897
|
+
confidence: "AMBIGUOUS",
|
|
2898
|
+
resolved_via: "foreign",
|
|
2899
|
+
provider: "foreign"
|
|
2900
|
+
});
|
|
2901
|
+
}
|
|
2902
|
+
const counts = { EXTRACTED: 0, INFERRED: 0, AMBIGUOUS: edges.length };
|
|
2903
|
+
const graph = {
|
|
2904
|
+
schema_version: SCHEMA_VERSION,
|
|
2905
|
+
source_checksum: createHash("sha256").update(JSON.stringify(doc), "utf-8").digest("hex"),
|
|
2906
|
+
languages: [],
|
|
2907
|
+
grammar_abi: 0,
|
|
2908
|
+
edge_confidence_counts: counts,
|
|
2909
|
+
suppressed_edge_counts: { dynamic_no_candidate: 0 },
|
|
2910
|
+
nodes,
|
|
2911
|
+
edges
|
|
2912
|
+
};
|
|
2913
|
+
return { graph, unmapped_relations: unmapped, malformed_edges: malformed };
|
|
2914
|
+
}
|
|
2915
|
+
|
|
2916
|
+
// src/scripts/code_graph/query.ts
|
|
2917
|
+
function indexBackedGraph(index, source, answeredBy) {
|
|
2918
|
+
const nodeCache = /* @__PURE__ */ new Map();
|
|
2919
|
+
const readNode = (id) => {
|
|
2920
|
+
if (nodeCache.has(id)) return nodeCache.get(id);
|
|
2921
|
+
const n = index.getNode(id);
|
|
2922
|
+
nodeCache.set(id, n);
|
|
2923
|
+
return n;
|
|
2924
|
+
};
|
|
2925
|
+
let lexical = null;
|
|
2926
|
+
return {
|
|
2927
|
+
graph: null,
|
|
2928
|
+
source,
|
|
2929
|
+
answeredBy,
|
|
2930
|
+
byId: { get: readNode, has: (id) => readNode(id) !== void 0 },
|
|
2931
|
+
out: { get: (id) => index.edgesFrom(id) },
|
|
2932
|
+
in: { get: (id) => index.edgesTo(id) },
|
|
2933
|
+
idsByLabel: (labelText, limit) => index.idsByLabel(labelText, limit),
|
|
2934
|
+
idsInFiles: (files) => index.idsInFiles(files),
|
|
2935
|
+
allNodeIds: () => index.allNodeIds(),
|
|
2936
|
+
lex: () => {
|
|
2937
|
+
lexical ??= new LexicalIndex(index.lexicalCorpus());
|
|
2938
|
+
return lexical;
|
|
2939
|
+
},
|
|
2940
|
+
close: () => index.close()
|
|
2941
|
+
};
|
|
2942
|
+
}
|
|
2943
|
+
function loadGraph(graphPath, source = graphPath) {
|
|
2944
|
+
const index = openGraphIndex(graphPath);
|
|
2945
|
+
if (index) {
|
|
2946
|
+
if (index.edgeCount >= INDEXED_READ_MIN_EDGES) return indexBackedGraph(index, source, graphPath);
|
|
2947
|
+
index.close();
|
|
2948
|
+
}
|
|
2949
|
+
const fromTwin = loadSerializedFromTwin(graphPath);
|
|
2950
|
+
const raw = fromTwin ?? fs6.readFileSync(graphPath, "utf-8");
|
|
2951
|
+
const parsed = JSON.parse(raw);
|
|
2952
|
+
let foreignAdapted = false;
|
|
2953
|
+
let candidate = parsed;
|
|
2954
|
+
if (looksForeign(parsed)) {
|
|
2955
|
+
const adapted = adaptForeignGraph(parsed);
|
|
2956
|
+
if (adapted !== null) {
|
|
2957
|
+
candidate = adapted.graph;
|
|
2958
|
+
foreignAdapted = true;
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
const v = validateGraph(candidate);
|
|
2962
|
+
if (!v.ok) throw new Error(`invalid graph at ${graphPath}: ${v.errors.slice(0, 3).join("; ")}`);
|
|
2963
|
+
const graph = candidate;
|
|
2964
|
+
if (fromTwin === null && !foreignAdapted) {
|
|
2965
|
+
emitSqliteTwin(graph, raw, graphPath);
|
|
2966
|
+
}
|
|
2967
|
+
const byId = new Map(graph.nodes.map((n) => [n.id, n]));
|
|
2968
|
+
const outM = /* @__PURE__ */ new Map();
|
|
2969
|
+
const inM = /* @__PURE__ */ new Map();
|
|
2970
|
+
const add = (m, k, e) => {
|
|
2971
|
+
const arr = m.get(k);
|
|
2972
|
+
if (arr) arr.push(e);
|
|
2973
|
+
else m.set(k, [e]);
|
|
2974
|
+
};
|
|
2975
|
+
for (const e of graph.edges) {
|
|
2976
|
+
add(outM, e.source, e);
|
|
2977
|
+
add(inM, e.target, e);
|
|
2978
|
+
}
|
|
2979
|
+
const lex = new LexicalIndex(graph.nodes.map((n) => ({ id: n.id, text: `${n.label} ${n.id}` })));
|
|
2980
|
+
return {
|
|
2981
|
+
graph,
|
|
2982
|
+
source,
|
|
2983
|
+
answeredBy: graphPath,
|
|
2984
|
+
byId,
|
|
2985
|
+
out: outM,
|
|
2986
|
+
in: inM,
|
|
2987
|
+
idsByLabel: (labelText, limit) => graph.nodes.filter((n) => n.label === labelText).slice(0, limit).map((n) => n.id),
|
|
2988
|
+
idsInFiles: (files) => {
|
|
2989
|
+
const set = new Set(files);
|
|
2990
|
+
return graph.nodes.filter((n) => set.has(n.source_file) && n.kind !== "file").map((n) => n.id);
|
|
2991
|
+
},
|
|
2992
|
+
allNodeIds: () => graph.nodes.map((n) => n.id).sort((a, b) => a < b ? -1 : a > b ? 1 : 0),
|
|
2993
|
+
lex: () => lex,
|
|
2994
|
+
close: () => {
|
|
2995
|
+
}
|
|
2996
|
+
};
|
|
2997
|
+
}
|
|
2998
|
+
function resolveSeedsTiered(g, seed, limit = 5) {
|
|
2999
|
+
if (g.byId.has(seed)) return { ids: [seed], weak: false };
|
|
3000
|
+
const exactLabel = g.idsByLabel(seed, limit);
|
|
3001
|
+
if (exactLabel.length) return { ids: exactLabel, weak: false };
|
|
3002
|
+
const ranked = g.lex().rank(tokenize(seed)).filter((r) => r.score > 0);
|
|
3003
|
+
return { ids: ranked.slice(0, limit).map((r) => r.id), weak: true };
|
|
3004
|
+
}
|
|
3005
|
+
function resolveSeeds(g, seed, limit = 5) {
|
|
3006
|
+
return resolveSeedsTiered(g, seed, limit).ids;
|
|
3007
|
+
}
|
|
3008
|
+
|
|
3009
|
+
// src/scripts/code_graph/verbs.ts
|
|
3010
|
+
import * as path5 from "node:path";
|
|
3011
|
+
function isAcceptedEdge(e) {
|
|
3012
|
+
return isStatedResolution(e.resolved_via);
|
|
3013
|
+
}
|
|
3014
|
+
function foreignRefusal(g) {
|
|
3015
|
+
const edges = g.graph?.edges ?? [];
|
|
3016
|
+
if (edges.length === 0) return null;
|
|
3017
|
+
if (!edges.every((e) => e.resolved_via === "foreign")) return null;
|
|
3018
|
+
return 'every edge in this graph was read from a file this package did not build, so all of them are guesses and none is gate-grade. A gate verb would accept no edge and report an empty answer, which reads as "nothing found" rather than "nothing trusted". Build a native graph (`agent-config graph build`) to use this verb, or use `query` and `explain`, which answer from foreign edges and say so.';
|
|
3019
|
+
}
|
|
3020
|
+
function viaHistogram(edges) {
|
|
3021
|
+
const counts = /* @__PURE__ */ new Map();
|
|
3022
|
+
for (const e of edges) counts.set(e.resolved_via, (counts.get(e.resolved_via) ?? 0) + 1);
|
|
3023
|
+
if (counts.size === 0) return "(none)";
|
|
3024
|
+
return [...counts.entries()].sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1)).map(([via, n]) => `${via} ${n}`).join(" \xB7 ");
|
|
3025
|
+
}
|
|
3026
|
+
function readFor(g, id) {
|
|
3027
|
+
const n = g.byId.get(id);
|
|
3028
|
+
if (!n) return null;
|
|
3029
|
+
const loc = n.source_location;
|
|
3030
|
+
return { path: n.source_file, lines: loc.length >= 3 ? [loc[0], loc[2]] : null };
|
|
3031
|
+
}
|
|
3032
|
+
function dedupeReads(reads) {
|
|
3033
|
+
const m = /* @__PURE__ */ new Map();
|
|
3034
|
+
for (const r of reads) {
|
|
3035
|
+
if (!r) continue;
|
|
3036
|
+
m.set(r.lines ? `${r.path}:${r.lines[0]}-${r.lines[1]}` : r.path, r);
|
|
3037
|
+
}
|
|
3038
|
+
return [...m.values()];
|
|
3039
|
+
}
|
|
3040
|
+
function seedsForFiles(g, files) {
|
|
3041
|
+
const symbols = g.idsInFiles(files);
|
|
3042
|
+
const seeds = new Set(symbols);
|
|
3043
|
+
const unresolved = [];
|
|
3044
|
+
const notIndexed = [];
|
|
3045
|
+
for (const f of files) {
|
|
3046
|
+
if (g.byId.has(f)) {
|
|
3047
|
+
seeds.add(f);
|
|
3048
|
+
continue;
|
|
3049
|
+
}
|
|
3050
|
+
if (symbols.some((s) => s.startsWith(`${f}#`))) continue;
|
|
3051
|
+
if (EXT_LANG[path5.extname(f).toLowerCase()] === void 0) notIndexed.push(f);
|
|
3052
|
+
else unresolved.push(f);
|
|
3053
|
+
}
|
|
3054
|
+
return {
|
|
3055
|
+
seeds: [...seeds].sort(),
|
|
3056
|
+
unresolved: unresolved.sort(),
|
|
3057
|
+
not_indexed: notIndexed.sort()
|
|
3058
|
+
};
|
|
3059
|
+
}
|
|
3060
|
+
function testsFor(g, symbol, state) {
|
|
3061
|
+
const seeds = resolveSeeds(g, symbol);
|
|
3062
|
+
const targets = new Set(seeds);
|
|
3063
|
+
for (const s of seeds) {
|
|
3064
|
+
const f = g.byId.get(s)?.source_file;
|
|
3065
|
+
if (f && g.byId.has(f)) targets.add(f);
|
|
3066
|
+
}
|
|
3067
|
+
const accepted = [];
|
|
3068
|
+
const rejected = [];
|
|
3069
|
+
const tests = /* @__PURE__ */ new Set();
|
|
3070
|
+
for (const t of targets) {
|
|
3071
|
+
for (const e of g.in.get(t) ?? []) {
|
|
3072
|
+
if (e.relation !== "tests") continue;
|
|
3073
|
+
if (!isAcceptedEdge(e)) {
|
|
3074
|
+
rejected.push(e);
|
|
3075
|
+
continue;
|
|
3076
|
+
}
|
|
3077
|
+
accepted.push(e);
|
|
3078
|
+
tests.add(e.source);
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
const list = [...tests].sort();
|
|
3082
|
+
return {
|
|
3083
|
+
source: g.source,
|
|
3084
|
+
state,
|
|
3085
|
+
accepted_via: viaHistogram(accepted),
|
|
3086
|
+
rejected_via: viaHistogram(rejected),
|
|
3087
|
+
seeds,
|
|
3088
|
+
tests: list,
|
|
3089
|
+
accepted_edges: accepted,
|
|
3090
|
+
rejected_edges: rejected,
|
|
3091
|
+
lines: list,
|
|
3092
|
+
recommended_reads: dedupeReads(list.map((t) => readFor(g, t)))
|
|
3093
|
+
};
|
|
3094
|
+
}
|
|
3095
|
+
function untested(g, files, state) {
|
|
3096
|
+
const foreign = foreignRefusal(g);
|
|
3097
|
+
if (foreign !== null) {
|
|
3098
|
+
return {
|
|
3099
|
+
source: g.source,
|
|
3100
|
+
state,
|
|
3101
|
+
accepted_via: "(none)",
|
|
3102
|
+
rejected_via: "(none)",
|
|
3103
|
+
refusal: foreign,
|
|
3104
|
+
refusal_reason: "foreign-edges-not-accepted",
|
|
3105
|
+
seeds: [],
|
|
3106
|
+
unresolved_files: [],
|
|
3107
|
+
not_indexed_files: [],
|
|
3108
|
+
untested: [],
|
|
3109
|
+
tested: [],
|
|
3110
|
+
lines: [],
|
|
3111
|
+
recommended_reads: []
|
|
3112
|
+
};
|
|
3113
|
+
}
|
|
3114
|
+
const { seeds, unresolved, not_indexed } = seedsForFiles(g, files);
|
|
3115
|
+
const accepted = [];
|
|
3116
|
+
const rejected = [];
|
|
3117
|
+
const tested = [];
|
|
3118
|
+
const bare = [];
|
|
3119
|
+
for (const s of seeds) {
|
|
3120
|
+
if (g.byId.get(s)?.kind === "file") continue;
|
|
3121
|
+
const r = testsFor(g, s, state);
|
|
3122
|
+
accepted.push(...r.accepted_edges);
|
|
3123
|
+
rejected.push(...r.rejected_edges);
|
|
3124
|
+
if (r.tests.length) tested.push(s);
|
|
3125
|
+
else bare.push(s);
|
|
3126
|
+
}
|
|
3127
|
+
return {
|
|
3128
|
+
source: g.source,
|
|
3129
|
+
state,
|
|
3130
|
+
accepted_via: viaHistogram(accepted),
|
|
3131
|
+
rejected_via: viaHistogram(rejected),
|
|
3132
|
+
refusal: null,
|
|
3133
|
+
refusal_reason: null,
|
|
3134
|
+
seeds,
|
|
3135
|
+
unresolved_files: unresolved,
|
|
3136
|
+
not_indexed_files: not_indexed,
|
|
3137
|
+
untested: bare.sort(),
|
|
3138
|
+
tested: tested.sort(),
|
|
3139
|
+
lines: bare.sort(),
|
|
3140
|
+
recommended_reads: dedupeReads(bare.map((b) => readFor(g, b)))
|
|
3141
|
+
};
|
|
3142
|
+
}
|
|
3143
|
+
|
|
3144
|
+
// src/scripts/_lib/graph_feeder_record.ts
|
|
3145
|
+
var MAX_PATHS = 5;
|
|
3146
|
+
var OUTSIDE_WORKSPACE = "<outside-workspace>";
|
|
3147
|
+
var MAX_ROWS_PER_SESSION = 200;
|
|
3148
|
+
function feederFile(workspaceRoot, sessionKey) {
|
|
3149
|
+
return path6.join(workspaceRoot, "agents", "state", "graph-feeder", `${sessionKey}.jsonl`);
|
|
3150
|
+
}
|
|
3151
|
+
function toRepoRelative(root, paths) {
|
|
3152
|
+
let realRoot = null;
|
|
3153
|
+
return paths.map((p) => {
|
|
3154
|
+
if (!path6.isAbsolute(p)) return p;
|
|
3155
|
+
const raw = _relativeInside(root, p);
|
|
3156
|
+
if (raw !== null) return raw;
|
|
3157
|
+
realRoot ??= _resolveReal(root);
|
|
3158
|
+
return _relativeInside(realRoot, _resolveReal(p)) ?? p;
|
|
3159
|
+
});
|
|
3160
|
+
}
|
|
3161
|
+
function _relativeInside(from, to) {
|
|
3162
|
+
let rel;
|
|
3163
|
+
try {
|
|
3164
|
+
rel = path6.relative(from, to);
|
|
3165
|
+
} catch {
|
|
3166
|
+
return null;
|
|
3167
|
+
}
|
|
3168
|
+
if (rel === "") return ".";
|
|
3169
|
+
if (rel === ".." || rel.startsWith(`..${path6.sep}`) || path6.isAbsolute(rel)) return null;
|
|
3170
|
+
return rel.split(path6.sep).join("/");
|
|
3171
|
+
}
|
|
3172
|
+
function _resolveReal(p) {
|
|
3173
|
+
const abs = path6.resolve(p);
|
|
3174
|
+
const tail = [];
|
|
3175
|
+
let cur = abs;
|
|
3176
|
+
for (; ; ) {
|
|
3177
|
+
try {
|
|
3178
|
+
const real = fs7.realpathSync(cur);
|
|
3179
|
+
return tail.length === 0 ? real : path6.join(real, ...[...tail].reverse());
|
|
3180
|
+
} catch {
|
|
3181
|
+
const parent = path6.dirname(cur);
|
|
3182
|
+
if (parent === cur) return abs;
|
|
3183
|
+
tail.push(path6.basename(cur));
|
|
3184
|
+
cur = parent;
|
|
3185
|
+
}
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3188
|
+
function _escapesWorkspace(p) {
|
|
3189
|
+
return path6.isAbsolute(p) || path6.win32.isAbsolute(p) || p === ".." || p.startsWith("../") || p.startsWith(`..${path6.sep}`);
|
|
3190
|
+
}
|
|
3191
|
+
function graphUntestedVerdict(root, state, paths) {
|
|
3192
|
+
const none = { verdict: null, untested: 0, tested: 0 };
|
|
3193
|
+
if (state !== "fresh" && state !== "edited") return none;
|
|
3194
|
+
if (paths.length === 0) return none;
|
|
3195
|
+
let picked;
|
|
3196
|
+
try {
|
|
3197
|
+
picked = pickSource(detectSources(root, path6.join(root, NATIVE_CACHE_REL)));
|
|
3198
|
+
} catch {
|
|
3199
|
+
return none;
|
|
3200
|
+
}
|
|
3201
|
+
if (!picked || picked.kind === "scip") return none;
|
|
3202
|
+
let g;
|
|
3203
|
+
try {
|
|
3204
|
+
g = loadGraph(picked.path, `${picked.kind}:${path6.relative(root, picked.path)}`);
|
|
3205
|
+
} catch {
|
|
3206
|
+
return none;
|
|
3207
|
+
}
|
|
3208
|
+
try {
|
|
3209
|
+
const r = untested(g, toRepoRelative(root, paths), state);
|
|
3210
|
+
if (r.seeds.length === 0) return { verdict: "no-seeds", untested: 0, tested: 0 };
|
|
3211
|
+
return {
|
|
3212
|
+
verdict: r.untested.length > 0 ? "untested" : "tested",
|
|
3213
|
+
untested: r.untested.length,
|
|
3214
|
+
tested: r.tested.length
|
|
3215
|
+
};
|
|
3216
|
+
} catch {
|
|
3217
|
+
return none;
|
|
3218
|
+
} finally {
|
|
3219
|
+
try {
|
|
3220
|
+
g.close();
|
|
3221
|
+
} catch {
|
|
3222
|
+
}
|
|
3223
|
+
}
|
|
3224
|
+
}
|
|
3225
|
+
function appendFeederRow(workspaceRoot, sessionKey, row) {
|
|
3226
|
+
try {
|
|
3227
|
+
const file = feederFile(workspaceRoot, sessionKey);
|
|
3228
|
+
let existing = 0;
|
|
3229
|
+
try {
|
|
3230
|
+
existing = fs7.readFileSync(file, "utf-8").split("\n").filter((l) => l.trim() !== "").length;
|
|
3231
|
+
} catch {
|
|
3232
|
+
}
|
|
3233
|
+
if (existing >= MAX_ROWS_PER_SESSION) return;
|
|
3234
|
+
fs7.mkdirSync(path6.dirname(file), { recursive: true });
|
|
3235
|
+
fs7.appendFileSync(file, `${JSON.stringify(row)}
|
|
3236
|
+
`);
|
|
3237
|
+
} catch {
|
|
3238
|
+
}
|
|
3239
|
+
}
|
|
3240
|
+
function buildFeederRow(input) {
|
|
3241
|
+
return {
|
|
3242
|
+
at: input.at ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
3243
|
+
turn: input.turn,
|
|
3244
|
+
layer: input.layer,
|
|
3245
|
+
graph_state: input.state,
|
|
3246
|
+
f: input.fFired,
|
|
3247
|
+
f_mode: input.fMode,
|
|
3248
|
+
graph: input.graph.verdict,
|
|
3249
|
+
graph_untested: input.graph.untested,
|
|
3250
|
+
graph_tested: input.graph.tested,
|
|
3251
|
+
// An out-of-workspace edit is REDACTED, not dropped and not stored
|
|
3252
|
+
// verbatim. After relativising, a still-absolute path is exactly one
|
|
3253
|
+
// that lay outside the root.
|
|
3254
|
+
//
|
|
3255
|
+
// Verbatim is an egress surface: `paths` is handed to external council
|
|
3256
|
+
// seats at step 3.3's labelling, and a home-rooted path names a real
|
|
3257
|
+
// user and an unrelated project.
|
|
3258
|
+
//
|
|
3259
|
+
// Dropping it looked right and was worse, which a completion review
|
|
3260
|
+
// caught before it shipped. It would have shortened `paths` below
|
|
3261
|
+
// `path_count` and so reused the protocol's truncation signal for a
|
|
3262
|
+
// second, different cause — two meanings on one wire, with no field
|
|
3263
|
+
// separating them. Worse, a turn editing one in-repo file and one file
|
|
3264
|
+
// outside the root would then be excluded from labelling altogether,
|
|
3265
|
+
// losing a perfectly labellable in-repo path from a corpus that is
|
|
3266
|
+
// blocked precisely for want of rows.
|
|
3267
|
+
//
|
|
3268
|
+
// The marker keeps the lengths equal, so truncation stays the only
|
|
3269
|
+
// cause of `path_count > paths.length`; keeps the row honest that an
|
|
3270
|
+
// edit happened outside the tree, so a labeller can answer
|
|
3271
|
+
// `cannot tell` rather than be silently misled; and carries nothing
|
|
3272
|
+
// identifying. The graph's answer is unchanged either way — the probe
|
|
3273
|
+
// sees the real path and resolves no seeds for it.
|
|
3274
|
+
paths: toRepoRelative(input.root, input.paths.slice(0, MAX_PATHS)).map(
|
|
3275
|
+
(p) => _escapesWorkspace(p) ? OUTSIDE_WORKSPACE : p
|
|
3276
|
+
),
|
|
3277
|
+
path_count: input.paths.length
|
|
3278
|
+
};
|
|
3279
|
+
}
|
|
3280
|
+
|
|
2310
3281
|
// src/scripts/hooks/envelope.ts
|
|
2311
3282
|
var ENVELOPE_KEYS = [
|
|
2312
3283
|
"schema_version",
|
|
@@ -2363,8 +3334,8 @@ function unwrap(stdin_text, default_platform = "generic") {
|
|
|
2363
3334
|
|
|
2364
3335
|
// src/scripts/hooks/subagent_ledger_hook.ts
|
|
2365
3336
|
import * as crypto from "node:crypto";
|
|
2366
|
-
import * as
|
|
2367
|
-
import * as
|
|
3337
|
+
import * as fs8 from "node:fs";
|
|
3338
|
+
import * as path7 from "node:path";
|
|
2368
3339
|
import { fileURLToPath as fileURLToPath4, pathToFileURL as pathToFileURL4 } from "node:url";
|
|
2369
3340
|
|
|
2370
3341
|
// src/scripts/_lib/subagent_response.ts
|
|
@@ -2498,15 +3469,15 @@ var EXIT_CODES = Object.freeze([
|
|
|
2498
3469
|
name: "error",
|
|
2499
3470
|
meaning: "the concern crashed, timed out, or could not decide \u2014 any rc >= 3. The dispatcher resolves it by the concern`s declared severity, never by the number itself",
|
|
2500
3471
|
owner: "no concern emits this on purpose; the runtime does",
|
|
2501
|
-
authorizedBy: "hook_manifest.yaml `
|
|
3472
|
+
authorizedBy: "hook_manifest.yaml `severity` alone \u2014 blocking refuses, anything else fails open; `fail_closed` is no longer read on this branch. See docs/contracts/hook-architecture-v1.md \xA7 Exit-code semantics"
|
|
2502
3473
|
})
|
|
2503
3474
|
]);
|
|
2504
3475
|
|
|
2505
3476
|
// src/scripts/hooks/subagent_ledger_hook.ts
|
|
2506
|
-
function
|
|
3477
|
+
function isObject2(v) {
|
|
2507
3478
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
2508
3479
|
}
|
|
2509
|
-
var LEDGER_DIR =
|
|
3480
|
+
var LEDGER_DIR = path7.join("agents", "runtime", "state", "subagent-ledger");
|
|
2510
3481
|
var OPEN_SUBDIR = "open";
|
|
2511
3482
|
var OPEN_RECORD_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
2512
3483
|
function refFor(agentId) {
|
|
@@ -2514,7 +3485,7 @@ function refFor(agentId) {
|
|
|
2514
3485
|
}
|
|
2515
3486
|
function unwrapPayload(envelope) {
|
|
2516
3487
|
const inner = envelope["payload"];
|
|
2517
|
-
return
|
|
3488
|
+
return isObject2(inner) ? inner : envelope;
|
|
2518
3489
|
}
|
|
2519
3490
|
function str(payload, ...keys) {
|
|
2520
3491
|
for (const k of keys) {
|
|
@@ -2527,7 +3498,7 @@ function extractParentId(payload, ownId) {
|
|
|
2527
3498
|
const explicit = str(payload, "parent_agent_id", "parentAgentId");
|
|
2528
3499
|
if (explicit) return explicit;
|
|
2529
3500
|
const session = payload["session"];
|
|
2530
|
-
if (
|
|
3501
|
+
if (isObject2(session)) {
|
|
2531
3502
|
const sessionAgent = str(session, "agent_id", "agentId");
|
|
2532
3503
|
if (sessionAgent && sessionAgent !== ownId) return sessionAgent;
|
|
2533
3504
|
}
|
|
@@ -2596,14 +3567,14 @@ function _jsonObjectCandidates(message) {
|
|
|
2596
3567
|
return out;
|
|
2597
3568
|
}
|
|
2598
3569
|
function openDir(root) {
|
|
2599
|
-
return
|
|
3570
|
+
return path7.join(root, LEDGER_DIR, OPEN_SUBDIR);
|
|
2600
3571
|
}
|
|
2601
3572
|
function openFile(root, ref) {
|
|
2602
|
-
return
|
|
3573
|
+
return path7.join(openDir(root), `${ref}.json`);
|
|
2603
3574
|
}
|
|
2604
3575
|
var DEPTH_BASES = /* @__PURE__ */ new Set(["observed", "asserted-parent", "assumed-root"]);
|
|
2605
3576
|
function _asOpenRecord(value, expectedRef) {
|
|
2606
|
-
if (!
|
|
3577
|
+
if (!isObject2(value)) return null;
|
|
2607
3578
|
const ref = value["ref"];
|
|
2608
3579
|
if (typeof ref !== "string" || ref !== expectedRef) return null;
|
|
2609
3580
|
if (typeof value["started_at"] !== "string") return null;
|
|
@@ -2626,7 +3597,7 @@ function readOpenRecords(root) {
|
|
|
2626
3597
|
const out = /* @__PURE__ */ new Map();
|
|
2627
3598
|
let names;
|
|
2628
3599
|
try {
|
|
2629
|
-
names =
|
|
3600
|
+
names = fs8.readdirSync(openDir(root));
|
|
2630
3601
|
} catch {
|
|
2631
3602
|
return out;
|
|
2632
3603
|
}
|
|
@@ -2634,7 +3605,7 @@ function readOpenRecords(root) {
|
|
|
2634
3605
|
if (!name.endsWith(".json")) continue;
|
|
2635
3606
|
const expectedRef = name.slice(0, -".json".length);
|
|
2636
3607
|
try {
|
|
2637
|
-
const raw =
|
|
3608
|
+
const raw = fs8.readFileSync(path7.join(openDir(root), name), "utf8");
|
|
2638
3609
|
const rec = _asOpenRecord(JSON.parse(raw), expectedRef);
|
|
2639
3610
|
if (rec) out.set(rec.ref, rec);
|
|
2640
3611
|
} catch {
|
|
@@ -2649,13 +3620,13 @@ function resolveDepth(parentRef, open) {
|
|
|
2649
3620
|
return { depth: parent.depth + 1, depth_basis: "observed" };
|
|
2650
3621
|
}
|
|
2651
3622
|
function ledgerFileFor2(root, ts) {
|
|
2652
|
-
return
|
|
3623
|
+
return path7.join(root, LEDGER_DIR, `${ts.slice(0, 7)}.jsonl`);
|
|
2653
3624
|
}
|
|
2654
3625
|
function appendLedgerLine(root, ts, line) {
|
|
2655
3626
|
if (is_replay_mode()) return;
|
|
2656
3627
|
const file = ledgerFileFor2(root, ts);
|
|
2657
|
-
|
|
2658
|
-
|
|
3628
|
+
fs8.mkdirSync(path7.dirname(file), { recursive: true });
|
|
3629
|
+
fs8.appendFileSync(file, `${JSON.stringify(line)}
|
|
2659
3630
|
`, "utf8");
|
|
2660
3631
|
}
|
|
2661
3632
|
var WALL_CLOCK_ARMS_MS = [
|
|
@@ -2669,7 +3640,7 @@ function armsExceeded(elapsedMs) {
|
|
|
2669
3640
|
return WALL_CLOCK_ARMS_MS.filter((a) => elapsedMs >= a.ms).map((a) => a.label);
|
|
2670
3641
|
}
|
|
2671
3642
|
function openRecordStats(root, nowMs = Date.now()) {
|
|
2672
|
-
const ledgerPresent =
|
|
3643
|
+
const ledgerPresent = fs8.existsSync(path7.join(root, LEDGER_DIR));
|
|
2673
3644
|
const open = readOpenRecords(root);
|
|
2674
3645
|
let maxDepth = 0;
|
|
2675
3646
|
let counted = 0;
|
|
@@ -2697,13 +3668,13 @@ function writeOpenRecord(root, rec) {
|
|
|
2697
3668
|
function removeOpenRecord(root, ref) {
|
|
2698
3669
|
if (is_replay_mode()) return;
|
|
2699
3670
|
try {
|
|
2700
|
-
|
|
3671
|
+
fs8.unlinkSync(openFile(root, ref));
|
|
2701
3672
|
} catch {
|
|
2702
3673
|
}
|
|
2703
3674
|
}
|
|
2704
3675
|
function countOpen(root) {
|
|
2705
3676
|
try {
|
|
2706
|
-
return
|
|
3677
|
+
return fs8.readdirSync(openDir(root)).filter((n) => n.endsWith(".json")).length;
|
|
2707
3678
|
} catch {
|
|
2708
3679
|
return 0;
|
|
2709
3680
|
}
|
|
@@ -2830,7 +3801,7 @@ function handleStop(root, payload, nowIso, sessionId) {
|
|
|
2830
3801
|
}
|
|
2831
3802
|
function processEnvelope(envelope, consumerRoot) {
|
|
2832
3803
|
try {
|
|
2833
|
-
if (!
|
|
3804
|
+
if (!isObject2(envelope)) return EXIT_ALLOW3;
|
|
2834
3805
|
const event = envelope["event"];
|
|
2835
3806
|
if (event !== "subagent_start" && event !== "subagent_stop") return EXIT_ALLOW3;
|
|
2836
3807
|
const payload = unwrapPayload(envelope);
|
|
@@ -2845,7 +3816,7 @@ function processEnvelope(envelope, consumerRoot) {
|
|
|
2845
3816
|
return EXIT_ALLOW3;
|
|
2846
3817
|
}
|
|
2847
3818
|
function resolveConsumerRoot(envelope) {
|
|
2848
|
-
if (
|
|
3819
|
+
if (isObject2(envelope)) {
|
|
2849
3820
|
const pr = str(envelope, "workspace_root", "project_root");
|
|
2850
3821
|
if (pr) return pr;
|
|
2851
3822
|
const payload = unwrapPayload(envelope);
|
|
@@ -2869,10 +3840,10 @@ function _isCliEntry4() {
|
|
|
2869
3840
|
return false;
|
|
2870
3841
|
}
|
|
2871
3842
|
if (process.argv[1] === void 0) return false;
|
|
2872
|
-
const argvUrl = pathToFileURL4(
|
|
3843
|
+
const argvUrl = pathToFileURL4(path7.resolve(process.argv[1])).href;
|
|
2873
3844
|
if (import.meta.url === argvUrl) return true;
|
|
2874
3845
|
try {
|
|
2875
|
-
return
|
|
3846
|
+
return fs8.realpathSync(fileURLToPath4(import.meta.url)) === fs8.realpathSync(path7.resolve(process.argv[1]));
|
|
2876
3847
|
} catch {
|
|
2877
3848
|
return false;
|
|
2878
3849
|
}
|
|
@@ -2880,20 +3851,20 @@ function _isCliEntry4() {
|
|
|
2880
3851
|
if (_isCliEntry4()) process.exit(main4());
|
|
2881
3852
|
|
|
2882
3853
|
// src/scripts/_lib/turn_end_transcript.ts
|
|
2883
|
-
import * as
|
|
3854
|
+
import * as fs11 from "node:fs";
|
|
2884
3855
|
|
|
2885
3856
|
// src/scripts/hooks/end_review_nudge_hook.ts
|
|
2886
3857
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
2887
3858
|
import * as crypto2 from "node:crypto";
|
|
2888
|
-
import * as
|
|
3859
|
+
import * as fs10 from "node:fs";
|
|
2889
3860
|
import * as os from "node:os";
|
|
2890
|
-
import * as
|
|
3861
|
+
import * as path9 from "node:path";
|
|
2891
3862
|
import { fileURLToPath as fileURLToPath5, pathToFileURL as pathToFileURL5 } from "node:url";
|
|
2892
3863
|
|
|
2893
3864
|
// src/scripts/_lib/review_baseline.ts
|
|
2894
3865
|
import { spawnSync } from "node:child_process";
|
|
2895
|
-
import * as
|
|
2896
|
-
import * as
|
|
3866
|
+
import * as fs9 from "node:fs";
|
|
3867
|
+
import * as path8 from "node:path";
|
|
2897
3868
|
function currentHeadSha(cwd) {
|
|
2898
3869
|
try {
|
|
2899
3870
|
const r = spawnSync("git", ["rev-parse", "HEAD"], { cwd, encoding: "utf8" });
|
|
@@ -2904,12 +3875,12 @@ function currentHeadSha(cwd) {
|
|
|
2904
3875
|
return null;
|
|
2905
3876
|
}
|
|
2906
3877
|
}
|
|
2907
|
-
var BASELINE_STATE_REL =
|
|
3878
|
+
var BASELINE_STATE_REL = path8.join("agents", "runtime", "state", "review-baseline");
|
|
2908
3879
|
function baselineStateDir(workspaceRoot) {
|
|
2909
|
-
return
|
|
3880
|
+
return path8.join(workspaceRoot, BASELINE_STATE_REL);
|
|
2910
3881
|
}
|
|
2911
3882
|
function baselineStateFile(workspaceRoot, sessionKey) {
|
|
2912
|
-
return
|
|
3883
|
+
return path8.join(baselineStateDir(workspaceRoot), `${sessionKey}.json`);
|
|
2913
3884
|
}
|
|
2914
3885
|
function parseBaseline(raw) {
|
|
2915
3886
|
let decoded;
|
|
@@ -2937,7 +3908,7 @@ function readBaseline(workspaceRoot, sessionKey) {
|
|
|
2937
3908
|
const file = baselineStateFile(workspaceRoot, sessionKey);
|
|
2938
3909
|
let raw;
|
|
2939
3910
|
try {
|
|
2940
|
-
raw =
|
|
3911
|
+
raw = fs9.readFileSync(file, "utf-8");
|
|
2941
3912
|
} catch (exc) {
|
|
2942
3913
|
const code = exc?.code;
|
|
2943
3914
|
return code === "ENOENT" ? "absent" : "unreadable";
|
|
@@ -3047,13 +4018,13 @@ function isSafeTranscriptPath(rawPath, opts = {}) {
|
|
|
3047
4018
|
const homeDir = opts.homeDir ?? os.homedir();
|
|
3048
4019
|
const maxBytes = opts.maxBytes ?? TRANSCRIPT_SCAN_MAX_BYTES;
|
|
3049
4020
|
try {
|
|
3050
|
-
const realHome =
|
|
3051
|
-
const realPath =
|
|
3052
|
-
const
|
|
3053
|
-
if (
|
|
4021
|
+
const realHome = fs10.realpathSync(homeDir);
|
|
4022
|
+
const realPath = fs10.realpathSync(rawPath);
|
|
4023
|
+
const relative5 = path9.relative(realHome, realPath);
|
|
4024
|
+
if (relative5 === "" || relative5.startsWith("..") || path9.isAbsolute(relative5)) {
|
|
3054
4025
|
return false;
|
|
3055
4026
|
}
|
|
3056
|
-
const { size } =
|
|
4027
|
+
const { size } = fs10.statSync(realPath);
|
|
3057
4028
|
return size <= maxBytes;
|
|
3058
4029
|
} catch {
|
|
3059
4030
|
return false;
|
|
@@ -3111,13 +4082,13 @@ var BINARY_PROBE_BYTES = 8e3;
|
|
|
3111
4082
|
var UNTRACKED_FILE_READ_CAP_BYTES = 8 * 1024 * 1024;
|
|
3112
4083
|
function untrackedFileLineCount(cwd, relPath) {
|
|
3113
4084
|
try {
|
|
3114
|
-
const abs =
|
|
3115
|
-
const size =
|
|
4085
|
+
const abs = path9.resolve(cwd, relPath);
|
|
4086
|
+
const size = fs10.statSync(abs).size;
|
|
3116
4087
|
if (size === 0) return 0;
|
|
3117
4088
|
if (size > UNTRACKED_FILE_READ_CAP_BYTES) {
|
|
3118
4089
|
return MUTATION_LINE_THRESHOLD + 1;
|
|
3119
4090
|
}
|
|
3120
|
-
const buf =
|
|
4091
|
+
const buf = fs10.readFileSync(abs);
|
|
3121
4092
|
if (buf.length === 0) return 0;
|
|
3122
4093
|
const probe = buf.subarray(0, Math.min(buf.length, BINARY_PROBE_BYTES));
|
|
3123
4094
|
if (probe.includes(0)) return 0;
|
|
@@ -3143,7 +4114,7 @@ function totalNonDocMutatedLinesWithMeasure(cwd) {
|
|
|
3143
4114
|
);
|
|
3144
4115
|
return { lines: trackedLines + untrackedLines, measure: "exact" };
|
|
3145
4116
|
}
|
|
3146
|
-
function
|
|
4117
|
+
function isObject3(v) {
|
|
3147
4118
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
3148
4119
|
}
|
|
3149
4120
|
function str2(v) {
|
|
@@ -3163,16 +4134,16 @@ function scanTranscriptForReviewer(transcriptText) {
|
|
|
3163
4134
|
} catch {
|
|
3164
4135
|
continue;
|
|
3165
4136
|
}
|
|
3166
|
-
if (!
|
|
4137
|
+
if (!isObject3(obj) || obj["type"] !== "assistant") continue;
|
|
3167
4138
|
const msg = obj["message"];
|
|
3168
|
-
if (!
|
|
4139
|
+
if (!isObject3(msg)) continue;
|
|
3169
4140
|
const content = msg["content"];
|
|
3170
4141
|
if (!Array.isArray(content)) continue;
|
|
3171
4142
|
for (const blk of content) {
|
|
3172
|
-
if (!
|
|
4143
|
+
if (!isObject3(blk) || blk["type"] !== "tool_use") continue;
|
|
3173
4144
|
const name = str2(blk["name"]);
|
|
3174
4145
|
const input = blk["input"];
|
|
3175
|
-
const inputObj =
|
|
4146
|
+
const inputObj = isObject3(input) ? input : {};
|
|
3176
4147
|
if (DISPATCH_TOOL_RE.test(name)) {
|
|
3177
4148
|
const label = [
|
|
3178
4149
|
str2(inputObj["description"]),
|
|
@@ -3208,19 +4179,19 @@ function appendReviewSkippedTelemetry(workspaceRoot, diffLines, mutationMeasure,
|
|
|
3208
4179
|
});
|
|
3209
4180
|
if (errors.length || line === null) return;
|
|
3210
4181
|
try {
|
|
3211
|
-
const dir =
|
|
3212
|
-
|
|
3213
|
-
const file =
|
|
3214
|
-
|
|
4182
|
+
const dir = path9.join(workspaceRoot, "agents", "runtime", "state", "audit");
|
|
4183
|
+
fs10.mkdirSync(dir, { recursive: true });
|
|
4184
|
+
const file = path9.join(dir, `${ts.slice(0, 7)}.jsonl`);
|
|
4185
|
+
fs10.appendFileSync(file, `${JSON.stringify(line)}
|
|
3215
4186
|
`, "utf8");
|
|
3216
4187
|
} catch {
|
|
3217
4188
|
}
|
|
3218
4189
|
}
|
|
3219
4190
|
function sessionStateDir(workspaceRoot) {
|
|
3220
|
-
return
|
|
4191
|
+
return path9.join(workspaceRoot, "agents", "runtime", "state", "end-review-nudge");
|
|
3221
4192
|
}
|
|
3222
4193
|
function sessionStateFile(workspaceRoot, sessionKey) {
|
|
3223
|
-
return
|
|
4194
|
+
return path9.join(sessionStateDir(workspaceRoot), `${sessionKey}.json`);
|
|
3224
4195
|
}
|
|
3225
4196
|
function deriveSessionKey2(envelope, payload) {
|
|
3226
4197
|
const raw = str2(envelope["session_id"]) || str2(payload["transcript_path"] ?? payload["transcriptPath"]);
|
|
@@ -3229,7 +4200,7 @@ function deriveSessionKey2(envelope, payload) {
|
|
|
3229
4200
|
}
|
|
3230
4201
|
function hasFiredThisSession(workspaceRoot, sessionKey) {
|
|
3231
4202
|
try {
|
|
3232
|
-
return
|
|
4203
|
+
return fs10.existsSync(sessionStateFile(workspaceRoot, sessionKey));
|
|
3233
4204
|
} catch {
|
|
3234
4205
|
return false;
|
|
3235
4206
|
}
|
|
@@ -3291,7 +4262,7 @@ function main5() {
|
|
|
3291
4262
|
let reviewerRan = false;
|
|
3292
4263
|
if (transcriptPath && isSafeTranscriptPath(transcriptPath)) {
|
|
3293
4264
|
try {
|
|
3294
|
-
reviewerRan = scanTranscriptForReviewer(
|
|
4265
|
+
reviewerRan = scanTranscriptForReviewer(fs10.readFileSync(transcriptPath, "utf-8"));
|
|
3295
4266
|
} catch {
|
|
3296
4267
|
reviewerRan = false;
|
|
3297
4268
|
}
|
|
@@ -3326,13 +4297,13 @@ function _isCliEntry5() {
|
|
|
3326
4297
|
if (process.argv[1] === void 0) {
|
|
3327
4298
|
return false;
|
|
3328
4299
|
}
|
|
3329
|
-
const argvUrl = pathToFileURL5(
|
|
4300
|
+
const argvUrl = pathToFileURL5(path9.resolve(process.argv[1])).href;
|
|
3330
4301
|
if (import.meta.url === argvUrl) {
|
|
3331
4302
|
return true;
|
|
3332
4303
|
}
|
|
3333
4304
|
try {
|
|
3334
|
-
const here =
|
|
3335
|
-
const argv =
|
|
4305
|
+
const here = fs10.realpathSync(fileURLToPath5(import.meta.url));
|
|
4306
|
+
const argv = fs10.realpathSync(path9.resolve(process.argv[1]));
|
|
3336
4307
|
return here === argv;
|
|
3337
4308
|
} catch {
|
|
3338
4309
|
return false;
|
|
@@ -3353,10 +4324,10 @@ function readTranscriptTail(transcriptPath, opts = {}) {
|
|
|
3353
4324
|
if (!transcriptPath || !isSafeTranscriptPath(transcriptPath, opts)) return empty;
|
|
3354
4325
|
let lines;
|
|
3355
4326
|
try {
|
|
3356
|
-
if (opts.maxBytes !== void 0 &&
|
|
4327
|
+
if (opts.maxBytes !== void 0 && fs11.statSync(transcriptPath).size > opts.maxBytes) {
|
|
3357
4328
|
return empty;
|
|
3358
4329
|
}
|
|
3359
|
-
lines =
|
|
4330
|
+
lines = fs11.readFileSync(transcriptPath, "utf-8").split("\n");
|
|
3360
4331
|
} catch {
|
|
3361
4332
|
return empty;
|
|
3362
4333
|
}
|
|
@@ -3543,7 +4514,7 @@ function detectPromissory(reply) {
|
|
|
3543
4514
|
function readCiSettled(workspaceRoot, session_id) {
|
|
3544
4515
|
if (!hasStableSessionId(session_id)) return { seen: false, settled: false };
|
|
3545
4516
|
try {
|
|
3546
|
-
const raw =
|
|
4517
|
+
const raw = fs12.readFileSync(path10.join(workspaceRoot, statePathFor(session_id)), "utf-8");
|
|
3547
4518
|
const decoded = JSON.parse(raw);
|
|
3548
4519
|
if (!owns_session_state(decoded, session_id)) return { seen: false, settled: false };
|
|
3549
4520
|
if (typeof decoded === "object" && decoded !== null && !Array.isArray(decoded)) {
|
|
@@ -3579,8 +4550,8 @@ function detectCompletionClaim(reply, ci) {
|
|
|
3579
4550
|
function readLanguagePin(workspaceRoot, session_id) {
|
|
3580
4551
|
if (!hasStableSessionId(session_id)) return "und";
|
|
3581
4552
|
try {
|
|
3582
|
-
const raw =
|
|
3583
|
-
|
|
4553
|
+
const raw = fs12.readFileSync(
|
|
4554
|
+
path10.join(workspaceRoot, statePathFor2(session_id)),
|
|
3584
4555
|
"utf-8"
|
|
3585
4556
|
);
|
|
3586
4557
|
const decoded = JSON.parse(raw);
|
|
@@ -3689,7 +4660,7 @@ function sessionStateFile2(workspaceRoot, sessionKey) {
|
|
|
3689
4660
|
}
|
|
3690
4661
|
function alreadyRefusedTurn(workspaceRoot, sessionKey, turnOrdinal) {
|
|
3691
4662
|
try {
|
|
3692
|
-
const raw =
|
|
4663
|
+
const raw = fs12.readFileSync(sessionStateFile2(workspaceRoot, sessionKey), "utf-8");
|
|
3693
4664
|
const decoded = JSON.parse(raw);
|
|
3694
4665
|
if (typeof decoded === "object" && decoded !== null && !Array.isArray(decoded)) {
|
|
3695
4666
|
return decoded["refused_turn"] === turnOrdinal;
|
|
@@ -3703,7 +4674,7 @@ function markRefusedTurn(workspaceRoot, sessionKey, turnOrdinal, detectors, prom
|
|
|
3703
4674
|
const file = sessionStateFile2(workspaceRoot, sessionKey);
|
|
3704
4675
|
let prev = null;
|
|
3705
4676
|
try {
|
|
3706
|
-
prev = parseRecord(
|
|
4677
|
+
prev = parseRecord(fs12.readFileSync(file, "utf-8"));
|
|
3707
4678
|
} catch {
|
|
3708
4679
|
}
|
|
3709
4680
|
let version;
|
|
@@ -3806,14 +4777,45 @@ function runDetectors(inputs) {
|
|
|
3806
4777
|
}
|
|
3807
4778
|
return findings;
|
|
3808
4779
|
}
|
|
4780
|
+
function recordGraphFeeder(inputs, findings, layer) {
|
|
4781
|
+
if (is_replay_mode()) return;
|
|
4782
|
+
try {
|
|
4783
|
+
let state;
|
|
4784
|
+
try {
|
|
4785
|
+
state = graphState(inputs.workspaceRoot);
|
|
4786
|
+
} catch {
|
|
4787
|
+
return;
|
|
4788
|
+
}
|
|
4789
|
+
if (state === "absent") return;
|
|
4790
|
+
const paths = inputs.toolCalls.filter((c) => _EDIT_TOOLS.has(c.name) && c.path !== void 0).map((c) => c.path).filter(_isProductionSource);
|
|
4791
|
+
const f = findings.find((x) => x.detector === "untested");
|
|
4792
|
+
appendFeederRow(
|
|
4793
|
+
inputs.workspaceRoot,
|
|
4794
|
+
inputs.sessionKey,
|
|
4795
|
+
buildFeederRow({
|
|
4796
|
+
root: inputs.workspaceRoot,
|
|
4797
|
+
turn: inputs.turnOrdinal,
|
|
4798
|
+
layer,
|
|
4799
|
+
state,
|
|
4800
|
+
fFired: f !== void 0,
|
|
4801
|
+
fMode: f?.mode ?? null,
|
|
4802
|
+
paths,
|
|
4803
|
+
graph: graphUntestedVerdict(inputs.workspaceRoot, state, paths)
|
|
4804
|
+
})
|
|
4805
|
+
);
|
|
4806
|
+
} catch {
|
|
4807
|
+
}
|
|
4808
|
+
}
|
|
3809
4809
|
function recordShadow(inputs, layer) {
|
|
3810
4810
|
if (is_replay_mode()) return;
|
|
3811
4811
|
try {
|
|
3812
4812
|
const findings = runDetectors(inputs);
|
|
4813
|
+
const setBy = layer === "refused_turn" ? "ours" : shadowSetBy(inputs.workspaceRoot, inputs.sessionKey);
|
|
4814
|
+
recordGraphFeeder(inputs, findings, layer);
|
|
3813
4815
|
const file = sessionShadowFile(inputs.workspaceRoot, inputs.sessionKey);
|
|
3814
4816
|
let prev = null;
|
|
3815
4817
|
try {
|
|
3816
|
-
prev = parseShadowRecord(
|
|
4818
|
+
prev = parseShadowRecord(fs12.readFileSync(file, "utf-8"));
|
|
3817
4819
|
} catch {
|
|
3818
4820
|
}
|
|
3819
4821
|
atomic_write_json(
|
|
@@ -3822,7 +4824,8 @@ function recordShadow(inputs, layer) {
|
|
|
3822
4824
|
detectors: findings.map((f) => f.detector),
|
|
3823
4825
|
turnOrdinal: inputs.turnOrdinal,
|
|
3824
4826
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3825
|
-
layer
|
|
4827
|
+
layer,
|
|
4828
|
+
setBy
|
|
3826
4829
|
})
|
|
3827
4830
|
);
|
|
3828
4831
|
} catch {
|
|
@@ -3851,6 +4854,7 @@ function main6() {
|
|
|
3851
4854
|
return EXIT_ALLOW3;
|
|
3852
4855
|
}
|
|
3853
4856
|
const findings = runDetectors(inputs);
|
|
4857
|
+
recordGraphFeeder(inputs, findings, "live");
|
|
3854
4858
|
if (findings.length === 0) return EXIT_ALLOW3;
|
|
3855
4859
|
markRefusedTurn(
|
|
3856
4860
|
inputs.workspaceRoot,
|
|
@@ -3879,13 +4883,13 @@ function _isCliEntry6() {
|
|
|
3879
4883
|
if (process.argv[1] === void 0) {
|
|
3880
4884
|
return false;
|
|
3881
4885
|
}
|
|
3882
|
-
const argvUrl = pathToFileURL6(
|
|
4886
|
+
const argvUrl = pathToFileURL6(path10.resolve(process.argv[1])).href;
|
|
3883
4887
|
if (import.meta.url === argvUrl) {
|
|
3884
4888
|
return true;
|
|
3885
4889
|
}
|
|
3886
4890
|
try {
|
|
3887
|
-
const here =
|
|
3888
|
-
const argv =
|
|
4891
|
+
const here = fs12.realpathSync(fileURLToPath6(import.meta.url));
|
|
4892
|
+
const argv = fs12.realpathSync(path10.resolve(process.argv[1]));
|
|
3889
4893
|
return here === argv;
|
|
3890
4894
|
} catch {
|
|
3891
4895
|
return false;
|
|
@@ -3898,8 +4902,8 @@ if (_isCliEntry6()) {
|
|
|
3898
4902
|
// src/scripts/hooks/evidence_independence.ts
|
|
3899
4903
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
3900
4904
|
import crypto3 from "node:crypto";
|
|
3901
|
-
import
|
|
3902
|
-
import
|
|
4905
|
+
import fs13 from "node:fs";
|
|
4906
|
+
import path11 from "node:path";
|
|
3903
4907
|
import { fileURLToPath as fileURLToPath7, pathToFileURL as pathToFileURL7 } from "node:url";
|
|
3904
4908
|
|
|
3905
4909
|
// src/scripts/_lib/test_delta.ts
|
|
@@ -3918,7 +4922,7 @@ function isTestPath(p) {
|
|
|
3918
4922
|
}
|
|
3919
4923
|
|
|
3920
4924
|
// src/scripts/hooks/evidence_independence.ts
|
|
3921
|
-
var STATE_FILE3 =
|
|
4925
|
+
var STATE_FILE3 = path11.join("agents", "state", "evidence-dispatch.json");
|
|
3922
4926
|
function _isObject5(v) {
|
|
3923
4927
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
3924
4928
|
}
|
|
@@ -3984,10 +4988,10 @@ function extractDispatch(envelope) {
|
|
|
3984
4988
|
}
|
|
3985
4989
|
return [tool, ""];
|
|
3986
4990
|
}
|
|
3987
|
-
function _ledgerStamp(consumer_root) {
|
|
4991
|
+
function _ledgerStamp(consumer_root, session_id) {
|
|
3988
4992
|
try {
|
|
3989
|
-
const raw =
|
|
3990
|
-
|
|
4993
|
+
const raw = fs13.readFileSync(
|
|
4994
|
+
path11.join(consumer_root, ledgerFileFor(session_id)),
|
|
3991
4995
|
"utf8"
|
|
3992
4996
|
);
|
|
3993
4997
|
const d = JSON.parse(raw);
|
|
@@ -3998,7 +5002,7 @@ function _ledgerStamp(consumer_root) {
|
|
|
3998
5002
|
}
|
|
3999
5003
|
function _load(target) {
|
|
4000
5004
|
try {
|
|
4001
|
-
const decoded = JSON.parse(
|
|
5005
|
+
const decoded = JSON.parse(fs13.readFileSync(target, "utf8"));
|
|
4002
5006
|
if (_isObject5(decoded) && Array.isArray(decoded["evaluations"])) {
|
|
4003
5007
|
return decoded;
|
|
4004
5008
|
}
|
|
@@ -4082,10 +5086,10 @@ function run3(stdin_text, options) {
|
|
|
4082
5086
|
return EXIT_ALLOW3;
|
|
4083
5087
|
}
|
|
4084
5088
|
}
|
|
4085
|
-
const target =
|
|
5089
|
+
const target = path11.join(options.consumer_root, STATE_FILE3);
|
|
4086
5090
|
const state = _load(target);
|
|
4087
5091
|
const session_id = typeof envelope["session_id"] === "string" ? envelope["session_id"] : "";
|
|
4088
|
-
const turnMarker = `${session_id}:${_ledgerStamp(options.consumer_root)}`;
|
|
5092
|
+
const turnMarker = `${session_id}:${_ledgerStamp(options.consumer_root, session_id)}`;
|
|
4089
5093
|
if (state.session_id !== turnMarker) {
|
|
4090
5094
|
state.session_id = turnMarker;
|
|
4091
5095
|
state.turn_started_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -4150,13 +5154,13 @@ function _isCliEntry7() {
|
|
|
4150
5154
|
if (process.argv[1] === void 0) {
|
|
4151
5155
|
return false;
|
|
4152
5156
|
}
|
|
4153
|
-
const argvUrl = pathToFileURL7(
|
|
5157
|
+
const argvUrl = pathToFileURL7(path11.resolve(process.argv[1])).href;
|
|
4154
5158
|
if (import.meta.url === argvUrl) {
|
|
4155
5159
|
return true;
|
|
4156
5160
|
}
|
|
4157
5161
|
try {
|
|
4158
|
-
const here =
|
|
4159
|
-
const argv =
|
|
5162
|
+
const here = fs13.realpathSync(fileURLToPath7(import.meta.url));
|
|
5163
|
+
const argv = fs13.realpathSync(path11.resolve(process.argv[1]));
|
|
4160
5164
|
return here === argv;
|
|
4161
5165
|
} catch {
|
|
4162
5166
|
return false;
|
|
@@ -4167,8 +5171,8 @@ if (_isCliEntry7()) {
|
|
|
4167
5171
|
}
|
|
4168
5172
|
|
|
4169
5173
|
// src/scripts/hooks/delegation_nudge_hook.ts
|
|
4170
|
-
import
|
|
4171
|
-
import
|
|
5174
|
+
import fs14 from "node:fs";
|
|
5175
|
+
import path12 from "node:path";
|
|
4172
5176
|
import { fileURLToPath as fileURLToPath8, pathToFileURL as pathToFileURL8 } from "node:url";
|
|
4173
5177
|
|
|
4174
5178
|
// src/scripts/_lib/auto_dispatch.ts
|
|
@@ -4532,11 +5536,10 @@ function resolveActivation(workspace_root, hostId) {
|
|
|
4532
5536
|
const emergency = settings["emergency"] ?? {};
|
|
4533
5537
|
const halted = emergency["orchestration_halt"] === true;
|
|
4534
5538
|
const host_manifest = probeHostCapabilities(hostId);
|
|
4535
|
-
const sub = settings["subagents"] ?? {};
|
|
4536
|
-
const downshift = sub["downshift"] !== false;
|
|
4537
5539
|
return {
|
|
4538
5540
|
activation: { halted, subagent_spawn: host_manifest.subagent_spawn },
|
|
4539
|
-
downshift
|
|
5541
|
+
// Fixed on: the `subagents.downshift` key was retired with this default.
|
|
5542
|
+
downshift: true,
|
|
4540
5543
|
separate_quota_pool: host_manifest.separate_quota_pool,
|
|
4541
5544
|
agentTeams: host_manifest.agent_teams
|
|
4542
5545
|
};
|
|
@@ -4668,13 +5671,13 @@ function _isCliEntry8() {
|
|
|
4668
5671
|
if (process.argv[1] === void 0) {
|
|
4669
5672
|
return false;
|
|
4670
5673
|
}
|
|
4671
|
-
const argvUrl = pathToFileURL8(
|
|
5674
|
+
const argvUrl = pathToFileURL8(path12.resolve(process.argv[1])).href;
|
|
4672
5675
|
if (import.meta.url === argvUrl) {
|
|
4673
5676
|
return true;
|
|
4674
5677
|
}
|
|
4675
5678
|
try {
|
|
4676
|
-
const here =
|
|
4677
|
-
const argv =
|
|
5679
|
+
const here = fs14.realpathSync(fileURLToPath8(import.meta.url));
|
|
5680
|
+
const argv = fs14.realpathSync(path12.resolve(process.argv[1]));
|
|
4678
5681
|
return here === argv;
|
|
4679
5682
|
} catch {
|
|
4680
5683
|
return false;
|
|
@@ -4685,7 +5688,7 @@ if (_isCliEntry8()) {
|
|
|
4685
5688
|
}
|
|
4686
5689
|
|
|
4687
5690
|
// src/scripts/conformance_scan.ts
|
|
4688
|
-
var REPO_ROOT =
|
|
5691
|
+
var REPO_ROOT = path13.resolve(path13.dirname(fileURLToPath9(import.meta.url)), "..", "..");
|
|
4689
5692
|
var OBSERVED_BAND = { low: 9.1, high: 39.2 };
|
|
4690
5693
|
var BAND_MIN_TURNS = 1978;
|
|
4691
5694
|
var CARRIER_CHANGES = [
|
|
@@ -5051,7 +6054,7 @@ function scanSession(sessionId, lines) {
|
|
|
5051
6054
|
closeWindow();
|
|
5052
6055
|
return report;
|
|
5053
6056
|
}
|
|
5054
|
-
var DEFAULT_RATE_SERIES =
|
|
6057
|
+
var DEFAULT_RATE_SERIES = path13.join(
|
|
5055
6058
|
REPO_ROOT,
|
|
5056
6059
|
"agents",
|
|
5057
6060
|
"runtime",
|
|
@@ -5060,7 +6063,7 @@ var DEFAULT_RATE_SERIES = path10.join(
|
|
|
5060
6063
|
);
|
|
5061
6064
|
function defaultStore(projectDir) {
|
|
5062
6065
|
const slug = projectStoreSlug(projectDir);
|
|
5063
|
-
return
|
|
6066
|
+
return path13.join(process.env["HOME"] ?? "", ".claude", "projects", slug);
|
|
5064
6067
|
}
|
|
5065
6068
|
function _tokens(chars) {
|
|
5066
6069
|
return Math.round(chars / 4);
|
|
@@ -5071,13 +6074,13 @@ function measureDelivered(projectRulesDir, globalRulesDir) {
|
|
|
5071
6074
|
return {
|
|
5072
6075
|
project: {
|
|
5073
6076
|
dir: projectRulesDir,
|
|
5074
|
-
present:
|
|
6077
|
+
present: fs15.existsSync(projectRulesDir),
|
|
5075
6078
|
files: p.files,
|
|
5076
6079
|
tokens: _tokens(p.chars)
|
|
5077
6080
|
},
|
|
5078
6081
|
global: {
|
|
5079
6082
|
dir: globalRulesDir,
|
|
5080
|
-
present:
|
|
6083
|
+
present: fs15.existsSync(globalRulesDir),
|
|
5081
6084
|
files: g.files,
|
|
5082
6085
|
tokens: _tokens(g.chars)
|
|
5083
6086
|
},
|
|
@@ -5085,13 +6088,13 @@ function measureDelivered(projectRulesDir, globalRulesDir) {
|
|
|
5085
6088
|
};
|
|
5086
6089
|
}
|
|
5087
6090
|
function storeKey(store) {
|
|
5088
|
-
return
|
|
6091
|
+
return createHash4("sha256").update(path13.resolve(store)).digest("hex").slice(0, 12);
|
|
5089
6092
|
}
|
|
5090
6093
|
function scanStore(store, limit) {
|
|
5091
|
-
const files =
|
|
6094
|
+
const files = fs15.readdirSync(store).filter((f) => f.endsWith(".jsonl")).map((f) => ({ f, m: fs15.statSync(path13.join(store, f)).mtimeMs })).sort((a, b) => b.m - a.m).slice(0, limit).map((x) => x.f);
|
|
5092
6095
|
const per_session = [];
|
|
5093
6096
|
for (const f of files) {
|
|
5094
|
-
const lines =
|
|
6097
|
+
const lines = fs15.readFileSync(path13.join(store, f), "utf8").split("\n");
|
|
5095
6098
|
const r = scanSession(f.replace(/\.jsonl$/, "").slice(0, 8), lines);
|
|
5096
6099
|
if (r.assistant_turns > 0) {
|
|
5097
6100
|
per_session.push(r);
|
|
@@ -5119,10 +6122,10 @@ function scanStore(store, limit) {
|
|
|
5119
6122
|
const task_completeness_rate_pct = completeness_windows === 0 ? 0 : Number((100 * task_completeness / completeness_windows).toFixed(1));
|
|
5120
6123
|
const era = spansCarrierChange(per_session.map((s) => s.first_at));
|
|
5121
6124
|
const delivered = measureDelivered(
|
|
5122
|
-
|
|
5123
|
-
|
|
6125
|
+
path13.join(REPO_ROOT, ".claude", "rules"),
|
|
6126
|
+
path13.join(process.env["HOME"] ?? os2.homedir(), ".claude", "rules")
|
|
5124
6127
|
);
|
|
5125
|
-
const ownStore =
|
|
6128
|
+
const ownStore = path13.resolve(store) === path13.resolve(defaultStore(REPO_ROOT));
|
|
5126
6129
|
return {
|
|
5127
6130
|
scanned_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5128
6131
|
store,
|
|
@@ -5152,8 +6155,8 @@ function scanStore(store, limit) {
|
|
|
5152
6155
|
};
|
|
5153
6156
|
}
|
|
5154
6157
|
function recordRate(file, scanned_at, rate) {
|
|
5155
|
-
|
|
5156
|
-
|
|
6158
|
+
fs15.mkdirSync(path13.dirname(file), { recursive: true });
|
|
6159
|
+
fs15.appendFileSync(file, `${JSON.stringify({ measured_at: scanned_at, ...rate })}
|
|
5157
6160
|
`, "utf8");
|
|
5158
6161
|
}
|
|
5159
6162
|
function render(report) {
|
|
@@ -5284,14 +6287,14 @@ function main9(argv) {
|
|
|
5284
6287
|
return 2;
|
|
5285
6288
|
}
|
|
5286
6289
|
const resolved = store ?? defaultStore(process.cwd());
|
|
5287
|
-
if (!
|
|
6290
|
+
if (!fs15.existsSync(resolved)) {
|
|
5288
6291
|
process.stderr.write(`conformance:behavior: no transcript store at ${resolved}
|
|
5289
6292
|
`);
|
|
5290
6293
|
return 1;
|
|
5291
6294
|
}
|
|
5292
6295
|
const report = scanStore(resolved, Number.isFinite(limit) && limit > 0 ? limit : 30);
|
|
5293
6296
|
if (out) {
|
|
5294
|
-
|
|
6297
|
+
fs15.writeFileSync(out, `${JSON.stringify(report, null, 2)}
|
|
5295
6298
|
`, "utf8");
|
|
5296
6299
|
}
|
|
5297
6300
|
if (record) {
|
|
@@ -5299,7 +6302,7 @@ function main9(argv) {
|
|
|
5299
6302
|
}
|
|
5300
6303
|
if (why !== null) {
|
|
5301
6304
|
const id = why;
|
|
5302
|
-
|
|
6305
|
+
fs15.writeSync(
|
|
5303
6306
|
1,
|
|
5304
6307
|
json ? `${JSON.stringify(
|
|
5305
6308
|
{
|
|
@@ -5319,7 +6322,7 @@ function main9(argv) {
|
|
|
5319
6322
|
);
|
|
5320
6323
|
return 0;
|
|
5321
6324
|
}
|
|
5322
|
-
|
|
6325
|
+
fs15.writeSync(1, json ? `${JSON.stringify(report, null, 2)}
|
|
5323
6326
|
` : `${render(report)}
|
|
5324
6327
|
`);
|
|
5325
6328
|
return 0;
|
|
@@ -5331,13 +6334,13 @@ function _isCliEntry9() {
|
|
|
5331
6334
|
if (process.argv[1] === void 0) {
|
|
5332
6335
|
return false;
|
|
5333
6336
|
}
|
|
5334
|
-
const argvUrl = pathToFileURL9(
|
|
6337
|
+
const argvUrl = pathToFileURL9(path13.resolve(process.argv[1])).href;
|
|
5335
6338
|
if (import.meta.url === argvUrl) {
|
|
5336
6339
|
return true;
|
|
5337
6340
|
}
|
|
5338
6341
|
try {
|
|
5339
|
-
const here =
|
|
5340
|
-
const argv =
|
|
6342
|
+
const here = fs15.realpathSync(fileURLToPath9(import.meta.url));
|
|
6343
|
+
const argv = fs15.realpathSync(path13.resolve(process.argv[1]));
|
|
5341
6344
|
return here === argv;
|
|
5342
6345
|
} catch {
|
|
5343
6346
|
return false;
|
|
@@ -5348,19 +6351,19 @@ if (_isCliEntry9()) {
|
|
|
5348
6351
|
}
|
|
5349
6352
|
|
|
5350
6353
|
// src/scripts/report_carrier_divergence.ts
|
|
5351
|
-
import * as
|
|
6354
|
+
import * as fs16 from "node:fs";
|
|
5352
6355
|
import * as os3 from "node:os";
|
|
5353
|
-
import * as
|
|
6356
|
+
import * as path14 from "node:path";
|
|
5354
6357
|
import process2 from "node:process";
|
|
5355
6358
|
import { fileURLToPath as fileURLToPath10, pathToFileURL as pathToFileURL10 } from "node:url";
|
|
5356
6359
|
var _HERE2 = fileURLToPath10(import.meta.url);
|
|
5357
|
-
var REPO_ROOT2 =
|
|
5358
|
-
var PROJECT_RULES =
|
|
5359
|
-
var PROJECTION_SOURCE =
|
|
5360
|
-
var GLOBAL_RULES =
|
|
6360
|
+
var REPO_ROOT2 = path14.resolve(path14.dirname(_HERE2), "..", "..");
|
|
6361
|
+
var PROJECT_RULES = path14.join(".claude", "rules");
|
|
6362
|
+
var PROJECTION_SOURCE = path14.join("dist", "agent-src", "rules");
|
|
6363
|
+
var GLOBAL_RULES = path14.join(".claude", "rules");
|
|
5361
6364
|
function _listRules(dir) {
|
|
5362
6365
|
try {
|
|
5363
|
-
return
|
|
6366
|
+
return fs16.readdirSync(dir).filter((f) => f.endsWith(".md")).sort();
|
|
5364
6367
|
} catch {
|
|
5365
6368
|
return [];
|
|
5366
6369
|
}
|
|
@@ -5368,7 +6371,7 @@ function _listRules(dir) {
|
|
|
5368
6371
|
function _ruleType(file) {
|
|
5369
6372
|
let text;
|
|
5370
6373
|
try {
|
|
5371
|
-
text =
|
|
6374
|
+
text = fs16.readFileSync(file, "utf-8");
|
|
5372
6375
|
} catch {
|
|
5373
6376
|
return "";
|
|
5374
6377
|
}
|
|
@@ -5379,8 +6382,8 @@ function compareCarriers(projectDir, globalDir, sourceDir) {
|
|
|
5379
6382
|
const out = {
|
|
5380
6383
|
projectDir,
|
|
5381
6384
|
globalDir,
|
|
5382
|
-
globalPresent:
|
|
5383
|
-
projectPresent:
|
|
6385
|
+
globalPresent: fs16.existsSync(globalDir),
|
|
6386
|
+
projectPresent: fs16.existsSync(projectDir),
|
|
5384
6387
|
shared: 0,
|
|
5385
6388
|
identical: [],
|
|
5386
6389
|
provenanceOnly: [],
|
|
@@ -5403,7 +6406,7 @@ function compareCarriers(projectDir, globalDir, sourceDir) {
|
|
|
5403
6406
|
}
|
|
5404
6407
|
if (!inP && inG) {
|
|
5405
6408
|
out.globalOnly.push(rule);
|
|
5406
|
-
if (sourceDir !== void 0 && _ruleType(
|
|
6409
|
+
if (sourceDir !== void 0 && _ruleType(path14.join(sourceDir, rule)) === "manual") {
|
|
5407
6410
|
out.manualOnlyGlobal.push(rule);
|
|
5408
6411
|
}
|
|
5409
6412
|
continue;
|
|
@@ -5413,8 +6416,8 @@ function compareCarriers(projectDir, globalDir, sourceDir) {
|
|
|
5413
6416
|
let projectCopy;
|
|
5414
6417
|
let globalCopy;
|
|
5415
6418
|
try {
|
|
5416
|
-
projectCopy =
|
|
5417
|
-
globalCopy =
|
|
6419
|
+
projectCopy = fs16.readFileSync(path14.join(projectDir, rule));
|
|
6420
|
+
globalCopy = fs16.readFileSync(path14.join(globalDir, rule));
|
|
5418
6421
|
verdict = comparePair(projectCopy, globalCopy);
|
|
5419
6422
|
} catch {
|
|
5420
6423
|
out.shared -= 1;
|
|
@@ -5561,9 +6564,9 @@ function render2(d) {
|
|
|
5561
6564
|
}
|
|
5562
6565
|
function main10(argv) {
|
|
5563
6566
|
const args = argv ?? process2.argv.slice(2);
|
|
5564
|
-
let projectDir =
|
|
5565
|
-
let globalDir =
|
|
5566
|
-
let sourceDir =
|
|
6567
|
+
let projectDir = path14.join(REPO_ROOT2, PROJECT_RULES);
|
|
6568
|
+
let globalDir = path14.join(os3.homedir(), GLOBAL_RULES);
|
|
6569
|
+
let sourceDir = path14.join(REPO_ROOT2, PROJECTION_SOURCE);
|
|
5567
6570
|
const value = (i) => {
|
|
5568
6571
|
const v = args[i + 1];
|
|
5569
6572
|
return v === void 0 || v.startsWith("-") ? null : v;
|
|
@@ -5577,7 +6580,7 @@ function main10(argv) {
|
|
|
5577
6580
|
`);
|
|
5578
6581
|
return 1;
|
|
5579
6582
|
}
|
|
5580
|
-
const resolved =
|
|
6583
|
+
const resolved = path14.resolve(v);
|
|
5581
6584
|
if (a === "--project") projectDir = resolved;
|
|
5582
6585
|
else if (a === "--global") globalDir = resolved;
|
|
5583
6586
|
else sourceDir = resolved;
|
|
@@ -5599,9 +6602,9 @@ function main10(argv) {
|
|
|
5599
6602
|
}
|
|
5600
6603
|
function _isCliEntry10() {
|
|
5601
6604
|
if (process2.argv[1] === void 0) return false;
|
|
5602
|
-
if (import.meta.url === pathToFileURL10(
|
|
6605
|
+
if (import.meta.url === pathToFileURL10(path14.resolve(process2.argv[1])).href) return true;
|
|
5603
6606
|
try {
|
|
5604
|
-
return
|
|
6607
|
+
return fs16.realpathSync(_HERE2) === fs16.realpathSync(path14.resolve(process2.argv[1]));
|
|
5605
6608
|
} catch {
|
|
5606
6609
|
return false;
|
|
5607
6610
|
}
|
|
@@ -5611,12 +6614,12 @@ if (_isCliEntry10()) {
|
|
|
5611
6614
|
}
|
|
5612
6615
|
|
|
5613
6616
|
// src/scripts/report_skill_activation.ts
|
|
5614
|
-
import * as
|
|
6617
|
+
import * as fs17 from "node:fs";
|
|
5615
6618
|
import * as os4 from "node:os";
|
|
5616
|
-
import * as
|
|
6619
|
+
import * as path15 from "node:path";
|
|
5617
6620
|
import { fileURLToPath as fileURLToPath11, pathToFileURL as pathToFileURL11 } from "node:url";
|
|
5618
6621
|
var _HERE3 = fileURLToPath11(import.meta.url);
|
|
5619
|
-
var REPO_ROOT3 =
|
|
6622
|
+
var REPO_ROOT3 = path15.resolve(path15.dirname(_HERE3), "..", "..");
|
|
5620
6623
|
var SKILLS_ROOT = "src/skills";
|
|
5621
6624
|
var TRIGGER_KEYS = ["triggers:", "trigger_description:", "file_pattern:", "path_prefix:"];
|
|
5622
6625
|
var DETERMINISTIC_RE = /^\s*(?:[-*]\s*)?(?:\*\*)?(MUST|NEVER|ALWAYS)\b/m;
|
|
@@ -5627,25 +6630,25 @@ function censusSkills(root) {
|
|
|
5627
6630
|
withTriggerCorpus: [],
|
|
5628
6631
|
withDeterministicObligation: []
|
|
5629
6632
|
};
|
|
5630
|
-
if (!
|
|
6633
|
+
if (!fs17.existsSync(root)) {
|
|
5631
6634
|
return out;
|
|
5632
6635
|
}
|
|
5633
|
-
for (const entry of
|
|
6636
|
+
for (const entry of fs17.readdirSync(root, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
5634
6637
|
if (!entry.isDirectory()) {
|
|
5635
6638
|
continue;
|
|
5636
6639
|
}
|
|
5637
|
-
const file =
|
|
5638
|
-
if (!
|
|
6640
|
+
const file = path15.join(root, entry.name, "SKILL.md");
|
|
6641
|
+
if (!fs17.existsSync(file)) {
|
|
5639
6642
|
continue;
|
|
5640
6643
|
}
|
|
5641
6644
|
out.total += 1;
|
|
5642
|
-
const text =
|
|
6645
|
+
const text = fs17.readFileSync(file, "utf8");
|
|
5643
6646
|
const fmEnd = text.startsWith("---") ? text.indexOf("\n---", 3) : -1;
|
|
5644
6647
|
const fm = fmEnd === -1 ? "" : text.slice(0, fmEnd);
|
|
5645
6648
|
if (TRIGGER_KEYS.some((k) => new RegExp(`^${k}`, "m").test(fm))) {
|
|
5646
6649
|
out.withTriggerKey.push(entry.name);
|
|
5647
6650
|
}
|
|
5648
|
-
if (
|
|
6651
|
+
if (fs17.existsSync(path15.join(root, entry.name, "evals", "triggers.json"))) {
|
|
5649
6652
|
out.withTriggerCorpus.push(entry.name);
|
|
5650
6653
|
}
|
|
5651
6654
|
const body = fmEnd === -1 ? text : text.slice(fmEnd + 4);
|
|
@@ -5656,17 +6659,17 @@ function censusSkills(root) {
|
|
|
5656
6659
|
return out;
|
|
5657
6660
|
}
|
|
5658
6661
|
function defaultStore2(cwd) {
|
|
5659
|
-
return
|
|
6662
|
+
return path15.join(os4.homedir(), ".claude", "projects", projectStoreSlug(cwd));
|
|
5660
6663
|
}
|
|
5661
6664
|
function measureUsage(store, limit) {
|
|
5662
6665
|
const rep = { store, sessions: 0, assistantTurns: 0, invocations: 0, bySkill: {} };
|
|
5663
|
-
if (!
|
|
6666
|
+
if (!fs17.existsSync(store)) {
|
|
5664
6667
|
return rep;
|
|
5665
6668
|
}
|
|
5666
|
-
const files =
|
|
6669
|
+
const files = fs17.readdirSync(store).filter((f) => f.endsWith(".jsonl")).map((f) => path15.join(store, f)).sort((a, b) => fs17.statSync(b).mtimeMs - fs17.statSync(a).mtimeMs).slice(0, limit);
|
|
5667
6670
|
rep.sessions = files.length;
|
|
5668
6671
|
for (const file of files) {
|
|
5669
|
-
for (const line of
|
|
6672
|
+
for (const line of fs17.readFileSync(file, "utf8").split("\n")) {
|
|
5670
6673
|
if (!line.trim()) {
|
|
5671
6674
|
continue;
|
|
5672
6675
|
}
|
|
@@ -5739,15 +6742,15 @@ function buildRecord(census, usage, today) {
|
|
|
5739
6742
|
assistant_turns: usage.reduce((a, u) => a + u.assistantTurns, 0),
|
|
5740
6743
|
invocations: usage.reduce((a, u) => a + u.invocations, 0),
|
|
5741
6744
|
distinct_skills_invoked: distinct.size,
|
|
5742
|
-
stores: usage.map((u) =>
|
|
6745
|
+
stores: usage.map((u) => path15.basename(u.store))
|
|
5743
6746
|
};
|
|
5744
6747
|
}
|
|
5745
6748
|
function readRecord(repoRoot) {
|
|
5746
|
-
const file =
|
|
5747
|
-
if (!
|
|
6749
|
+
const file = path15.join(repoRoot, RECORD_PATH);
|
|
6750
|
+
if (!fs17.existsSync(file)) {
|
|
5748
6751
|
return null;
|
|
5749
6752
|
}
|
|
5750
|
-
return JSON.parse(
|
|
6753
|
+
return JSON.parse(fs17.readFileSync(file, "utf8"));
|
|
5751
6754
|
}
|
|
5752
6755
|
function render3(census, usage, published = null) {
|
|
5753
6756
|
const lines = [];
|
|
@@ -5782,7 +6785,7 @@ function render3(census, usage, published = null) {
|
|
|
5782
6785
|
}
|
|
5783
6786
|
totalInv += u.invocations;
|
|
5784
6787
|
lines.push(
|
|
5785
|
-
` ${
|
|
6788
|
+
` ${path15.basename(u.store).slice(-38).padEnd(38)} sessions=${String(u.sessions).padStart(3)} asst=${String(u.assistantTurns).padStart(6)} Skill calls=${String(u.invocations).padStart(3)}`
|
|
5786
6789
|
);
|
|
5787
6790
|
}
|
|
5788
6791
|
lines.push("");
|
|
@@ -5886,7 +6889,7 @@ function main11(argv) {
|
|
|
5886
6889
|
if (stores.length === 0) {
|
|
5887
6890
|
stores.push(defaultStore2(REPO_ROOT3));
|
|
5888
6891
|
}
|
|
5889
|
-
const census = censusSkills(
|
|
6892
|
+
const census = censusSkills(path15.join(root, SKILLS_ROOT));
|
|
5890
6893
|
const usage = stores.map((s) => measureUsage(s, limit));
|
|
5891
6894
|
process.stdout.write(`${render3(census, usage, readRecord(root))}
|
|
5892
6895
|
`);
|
|
@@ -5907,27 +6910,27 @@ function main11(argv) {
|
|
|
5907
6910
|
return 1;
|
|
5908
6911
|
}
|
|
5909
6912
|
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
5910
|
-
const file =
|
|
5911
|
-
|
|
5912
|
-
|
|
6913
|
+
const file = path15.join(root, RECORD_PATH);
|
|
6914
|
+
fs17.mkdirSync(path15.dirname(file), { recursive: true });
|
|
6915
|
+
fs17.writeFileSync(file, `${JSON.stringify(buildRecord(census, usage, today), null, 2)}
|
|
5913
6916
|
`);
|
|
5914
6917
|
process.stdout.write(`
|
|
5915
6918
|
wrote ${RECORD_PATH} (measured ${today})
|
|
5916
6919
|
`);
|
|
5917
6920
|
return 0;
|
|
5918
6921
|
}
|
|
5919
|
-
if (process.argv[1] !== void 0 && import.meta.url === pathToFileURL11(
|
|
6922
|
+
if (process.argv[1] !== void 0 && import.meta.url === pathToFileURL11(path15.resolve(process.argv[1])).href) {
|
|
5920
6923
|
process.exit(main11(process.argv.slice(2)));
|
|
5921
6924
|
}
|
|
5922
6925
|
|
|
5923
6926
|
// src/scripts/report_skill_obligation_violations.ts
|
|
5924
|
-
import * as
|
|
6927
|
+
import * as fs18 from "node:fs";
|
|
5925
6928
|
import * as os5 from "node:os";
|
|
5926
|
-
import * as
|
|
6929
|
+
import * as path16 from "node:path";
|
|
5927
6930
|
import process3 from "node:process";
|
|
5928
6931
|
import { fileURLToPath as fileURLToPath12, pathToFileURL as pathToFileURL12 } from "node:url";
|
|
5929
6932
|
var _HERE4 = fileURLToPath12(import.meta.url);
|
|
5930
|
-
var REPO_ROOT4 =
|
|
6933
|
+
var REPO_ROOT4 = path16.resolve(path16.dirname(_HERE4), "..", "..");
|
|
5931
6934
|
var OBLIGATION_LINE_RE = new RegExp(`${DETERMINISTIC_RE.source}.*`, "gm");
|
|
5932
6935
|
var PATH_RE = /`([A-Za-z0-9_./-]*\/[A-Za-z0-9_.-]+\.[a-z]{2,6})`/g;
|
|
5933
6936
|
var CMD_RE = /`([a-z][a-z0-9-]*(?: [a-z][a-z0-9:._-]*){1,3})`/g;
|
|
@@ -5965,7 +6968,7 @@ function _artefacts(line) {
|
|
|
5965
6968
|
return out;
|
|
5966
6969
|
}
|
|
5967
6970
|
function extractObligations(repoRoot) {
|
|
5968
|
-
const skillsRoot =
|
|
6971
|
+
const skillsRoot = path16.join(repoRoot, SKILLS_ROOT);
|
|
5969
6972
|
const census = censusSkills(skillsRoot);
|
|
5970
6973
|
const out = {
|
|
5971
6974
|
skills: census.withDeterministicObligation,
|
|
@@ -5979,7 +6982,7 @@ function extractObligations(repoRoot) {
|
|
|
5979
6982
|
for (const skill of census.withDeterministicObligation) {
|
|
5980
6983
|
let text;
|
|
5981
6984
|
try {
|
|
5982
|
-
text =
|
|
6985
|
+
text = fs18.readFileSync(path16.join(skillsRoot, skill, "SKILL.md"), "utf-8");
|
|
5983
6986
|
} catch {
|
|
5984
6987
|
continue;
|
|
5985
6988
|
}
|
|
@@ -6095,7 +7098,7 @@ function scanSessionForViolations(session, lines, forbidden, parsed) {
|
|
|
6095
7098
|
return flags;
|
|
6096
7099
|
}
|
|
6097
7100
|
function defaultStore3(cwd) {
|
|
6098
|
-
return
|
|
7101
|
+
return path16.join(os5.homedir(), ".claude", "projects", projectStoreSlug(cwd));
|
|
6099
7102
|
}
|
|
6100
7103
|
function scanStore2(repoRoot, store, limit) {
|
|
6101
7104
|
const census = extractObligations(repoRoot);
|
|
@@ -6108,14 +7111,14 @@ function scanStore2(repoRoot, store, limit) {
|
|
|
6108
7111
|
};
|
|
6109
7112
|
let files;
|
|
6110
7113
|
try {
|
|
6111
|
-
files =
|
|
7114
|
+
files = fs18.readdirSync(store).filter((f) => f.endsWith(".jsonl")).map((f) => ({ p: path16.join(store, f), m: fs18.statSync(path16.join(store, f)).mtimeMs })).sort((a, b) => b.m - a.m).slice(0, limit).map((x) => x.p);
|
|
6112
7115
|
} catch {
|
|
6113
7116
|
return report;
|
|
6114
7117
|
}
|
|
6115
7118
|
report.sessions = files.length;
|
|
6116
7119
|
for (const file of files) {
|
|
6117
|
-
const lines =
|
|
6118
|
-
const id =
|
|
7120
|
+
const lines = fs18.readFileSync(file, "utf-8").split("\n");
|
|
7121
|
+
const id = path16.basename(file).replace(/\.jsonl$/, "").slice(0, 8);
|
|
6119
7122
|
const entries = _parseSession(lines);
|
|
6120
7123
|
if (loadedSkillsFrom(entries).size > 0) report.sessionsWithASkill += 1;
|
|
6121
7124
|
report.flags.push(...scanSessionForViolations(id, lines, census.forbidden, entries));
|
|
@@ -6240,9 +7243,9 @@ function main12(argv) {
|
|
|
6240
7243
|
}
|
|
6241
7244
|
function _isCliEntry11() {
|
|
6242
7245
|
if (process3.argv[1] === void 0) return false;
|
|
6243
|
-
if (import.meta.url === pathToFileURL12(
|
|
7246
|
+
if (import.meta.url === pathToFileURL12(path16.resolve(process3.argv[1])).href) return true;
|
|
6244
7247
|
try {
|
|
6245
|
-
return
|
|
7248
|
+
return fs18.realpathSync(_HERE4) === fs18.realpathSync(path16.resolve(process3.argv[1]));
|
|
6246
7249
|
} catch {
|
|
6247
7250
|
return false;
|
|
6248
7251
|
}
|
|
@@ -6253,20 +7256,20 @@ if (_isCliEntry11()) {
|
|
|
6253
7256
|
|
|
6254
7257
|
// src/scripts/report_conformance_funnel.ts
|
|
6255
7258
|
var _HERE5 = fileURLToPath13(import.meta.url);
|
|
6256
|
-
var REPO_ROOT5 =
|
|
7259
|
+
var REPO_ROOT5 = path17.resolve(path17.dirname(_HERE5), "..", "..");
|
|
6257
7260
|
function buildFunnel(opts = {}) {
|
|
6258
7261
|
const repoRoot = opts.repoRoot ?? REPO_ROOT5;
|
|
6259
|
-
const projectRulesDir = opts.projectRulesDir ??
|
|
6260
|
-
const globalRulesDir = opts.globalRulesDir ??
|
|
6261
|
-
const sourceDir = opts.sourceDir ??
|
|
7262
|
+
const projectRulesDir = opts.projectRulesDir ?? path17.join(repoRoot, PROJECT_RULES);
|
|
7263
|
+
const globalRulesDir = opts.globalRulesDir ?? path17.join(os6.homedir(), GLOBAL_RULES);
|
|
7264
|
+
const sourceDir = opts.sourceDir ?? path17.join(repoRoot, PROJECTION_SOURCE);
|
|
6262
7265
|
const store = opts.store ?? defaultStore(repoRoot);
|
|
6263
7266
|
const limit = opts.limit ?? 30;
|
|
6264
7267
|
return {
|
|
6265
7268
|
delivered: measureDelivered(projectRulesDir, globalRulesDir),
|
|
6266
7269
|
divergence: compareCarriers(projectRulesDir, globalRulesDir, sourceDir),
|
|
6267
|
-
skills: censusSkills(
|
|
7270
|
+
skills: censusSkills(path17.join(repoRoot, SKILLS_ROOT)),
|
|
6268
7271
|
usage: measureUsage(store, limit),
|
|
6269
|
-
storePresent:
|
|
7272
|
+
storePresent: fs19.existsSync(store),
|
|
6270
7273
|
sk2: scanStore2(repoRoot, store, limit)
|
|
6271
7274
|
};
|
|
6272
7275
|
}
|
|
@@ -6407,7 +7410,7 @@ function main13(argv) {
|
|
|
6407
7410
|
`);
|
|
6408
7411
|
return 1;
|
|
6409
7412
|
}
|
|
6410
|
-
const resolved =
|
|
7413
|
+
const resolved = path17.resolve(v);
|
|
6411
7414
|
if (a === "--store") opts.store = resolved;
|
|
6412
7415
|
else if (a === "--project") opts.projectRulesDir = resolved;
|
|
6413
7416
|
else if (a === "--global") opts.globalRulesDir = resolved;
|
|
@@ -6439,9 +7442,9 @@ function main13(argv) {
|
|
|
6439
7442
|
}
|
|
6440
7443
|
function _isCliEntry12() {
|
|
6441
7444
|
if (process4.argv[1] === void 0) return false;
|
|
6442
|
-
if (import.meta.url === pathToFileURL13(
|
|
7445
|
+
if (import.meta.url === pathToFileURL13(path17.resolve(process4.argv[1])).href) return true;
|
|
6443
7446
|
try {
|
|
6444
|
-
return
|
|
7447
|
+
return fs19.realpathSync(_HERE5) === fs19.realpathSync(path17.resolve(process4.argv[1]));
|
|
6445
7448
|
} catch {
|
|
6446
7449
|
return false;
|
|
6447
7450
|
}
|
|
@@ -6460,7 +7463,7 @@ var CONFORMANCE_CHECK_IDS = [
|
|
|
6460
7463
|
"lean-projection",
|
|
6461
7464
|
"host-manifest"
|
|
6462
7465
|
];
|
|
6463
|
-
var THIN_STUB_MARKER =
|
|
7466
|
+
var THIN_STUB_MARKER = THIN_ENTRY_MARKER;
|
|
6464
7467
|
var CONFORMANCE_STATUS_SYMBOLS = {
|
|
6465
7468
|
...STATUS_SYMBOLS,
|
|
6466
7469
|
unknown: "\u2754"
|
|
@@ -6478,20 +7481,20 @@ function conformanceLogPath() {
|
|
|
6478
7481
|
if (override && override.trim().length > 0) {
|
|
6479
7482
|
return override;
|
|
6480
7483
|
}
|
|
6481
|
-
return
|
|
7484
|
+
return path18.join(os7.homedir(), ".event4u", "agent-config", "conformance-log.jsonl");
|
|
6482
7485
|
}
|
|
6483
7486
|
function installLogPath() {
|
|
6484
7487
|
const override = process5.env["AGENT_CONFIG_INSTALL_LOG"];
|
|
6485
7488
|
if (override && override.trim().length > 0) {
|
|
6486
7489
|
return override;
|
|
6487
7490
|
}
|
|
6488
|
-
return
|
|
7491
|
+
return path18.join(os7.homedir(), ".event4u", "agent-config", "install-log.jsonl");
|
|
6489
7492
|
}
|
|
6490
7493
|
function _installLogExpected(projectRoot) {
|
|
6491
|
-
return
|
|
7494
|
+
return fs20.existsSync(manifest_path(projectRoot));
|
|
6492
7495
|
}
|
|
6493
7496
|
function _check_txlog_clean(logPath = installLogPath(), projectRoot = null) {
|
|
6494
|
-
const entries =
|
|
7497
|
+
const entries = fs20.existsSync(logPath) ? readRecentEntries(logPath) : [];
|
|
6495
7498
|
if (entries.length === 0) {
|
|
6496
7499
|
if (projectRoot !== null && _installLogExpected(projectRoot)) {
|
|
6497
7500
|
return {
|
|
@@ -6525,11 +7528,11 @@ function _check_txlog_clean(logPath = installLogPath(), projectRoot = null) {
|
|
|
6525
7528
|
};
|
|
6526
7529
|
}
|
|
6527
7530
|
function routeTargetPaths(target) {
|
|
6528
|
-
return routeTargetPathsPosix(target).map((rel) =>
|
|
7531
|
+
return routeTargetPathsPosix(target).map((rel) => path18.join(...rel.split("/")));
|
|
6529
7532
|
}
|
|
6530
7533
|
function _check_router_pointers(packageRoot = PACKAGE_ROOT) {
|
|
6531
|
-
const routerPath =
|
|
6532
|
-
if (!
|
|
7534
|
+
const routerPath = path18.join(packageRoot, "dist", "router.json");
|
|
7535
|
+
if (!fs20.existsSync(routerPath)) {
|
|
6533
7536
|
return {
|
|
6534
7537
|
id: "router-pointers",
|
|
6535
7538
|
status: "fail",
|
|
@@ -6539,7 +7542,7 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT) {
|
|
|
6539
7542
|
}
|
|
6540
7543
|
let router;
|
|
6541
7544
|
try {
|
|
6542
|
-
router = JSON.parse(
|
|
7545
|
+
router = JSON.parse(fs20.readFileSync(routerPath, "utf8"));
|
|
6543
7546
|
} catch (exc) {
|
|
6544
7547
|
return {
|
|
6545
7548
|
id: "router-pointers",
|
|
@@ -6548,13 +7551,13 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT) {
|
|
|
6548
7551
|
remedy: "reinstall the package \u2014 dist/router.json is corrupt"
|
|
6549
7552
|
};
|
|
6550
7553
|
}
|
|
6551
|
-
const rulesDir =
|
|
7554
|
+
const rulesDir = path18.join(packageRoot, "dist", "agent-src", "rules");
|
|
6552
7555
|
const broken = [];
|
|
6553
7556
|
let ids = 0;
|
|
6554
7557
|
let targets = 0;
|
|
6555
7558
|
for (const kernelId of router["kernel"] ?? []) {
|
|
6556
7559
|
ids += 1;
|
|
6557
|
-
if (!
|
|
7560
|
+
if (!fs20.existsSync(path18.join(rulesDir, `${kernelId}.md`))) {
|
|
6558
7561
|
broken.push(`kernel:${kernelId} \u2192 rules/${kernelId}.md missing`);
|
|
6559
7562
|
}
|
|
6560
7563
|
}
|
|
@@ -6562,7 +7565,7 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT) {
|
|
|
6562
7565
|
for (const entry of router[tier] ?? []) {
|
|
6563
7566
|
const ruleId = String(entry["id"] ?? "");
|
|
6564
7567
|
ids += 1;
|
|
6565
|
-
if (!
|
|
7568
|
+
if (!fs20.existsSync(path18.join(rulesDir, `${ruleId}.md`))) {
|
|
6566
7569
|
broken.push(`${tier}:${ruleId} \u2192 rules/${ruleId}.md missing`);
|
|
6567
7570
|
}
|
|
6568
7571
|
for (const target of entry["routes_to"] ?? []) {
|
|
@@ -6572,7 +7575,7 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT) {
|
|
|
6572
7575
|
broken.push(`${ruleId} \u2192 unparseable routes_to ${JSON.stringify(target)}`);
|
|
6573
7576
|
continue;
|
|
6574
7577
|
}
|
|
6575
|
-
if (!candidates.some((rel) =>
|
|
7578
|
+
if (!candidates.some((rel) => fs20.existsSync(path18.join(packageRoot, rel)))) {
|
|
6576
7579
|
broken.push(`${ruleId} \u2192 ${target} (${candidates[0]} missing)`);
|
|
6577
7580
|
}
|
|
6578
7581
|
}
|
|
@@ -6604,9 +7607,9 @@ function detectSmokePlatform(projectRoot) {
|
|
|
6604
7607
|
return "claude";
|
|
6605
7608
|
}
|
|
6606
7609
|
function dispatcherRunner(packageRoot) {
|
|
6607
|
-
const localTsx =
|
|
6608
|
-
const script =
|
|
6609
|
-
if (
|
|
7610
|
+
const localTsx = path18.join(packageRoot, "node_modules", ".bin", "tsx");
|
|
7611
|
+
const script = path18.join(packageRoot, "src", "scripts", "hooks", "dispatch_hook.ts");
|
|
7612
|
+
if (fs20.existsSync(localTsx)) {
|
|
6610
7613
|
return [localTsx, script];
|
|
6611
7614
|
}
|
|
6612
7615
|
return ["npx", "tsx", script];
|
|
@@ -6656,12 +7659,12 @@ function _check_hook_dispatcher(projectRoot, packageRoot = PACKAGE_ROOT, opts =
|
|
|
6656
7659
|
};
|
|
6657
7660
|
}
|
|
6658
7661
|
function readSettingsMode(projectRoot) {
|
|
6659
|
-
const settingsPath =
|
|
6660
|
-
if (!
|
|
7662
|
+
const settingsPath = path18.join(projectRoot, ".agent-settings.yml");
|
|
7663
|
+
if (!fs20.existsSync(settingsPath)) {
|
|
6661
7664
|
return "eager-all";
|
|
6662
7665
|
}
|
|
6663
7666
|
try {
|
|
6664
|
-
const parsed = YAML.parse(
|
|
7667
|
+
const parsed = YAML.parse(fs20.readFileSync(settingsPath, "utf8"));
|
|
6665
7668
|
const lean = parsed?.["lean_projection"] ?? null;
|
|
6666
7669
|
const mode = lean?.["mode"];
|
|
6667
7670
|
return typeof mode === "string" && mode.length > 0 ? mode : "eager-all";
|
|
@@ -6672,7 +7675,7 @@ function readSettingsMode(projectRoot) {
|
|
|
6672
7675
|
function kernelIdsFromRouter(packageRoot) {
|
|
6673
7676
|
try {
|
|
6674
7677
|
const router = JSON.parse(
|
|
6675
|
-
|
|
7678
|
+
fs20.readFileSync(path18.join(packageRoot, "dist", "router.json"), "utf8")
|
|
6676
7679
|
);
|
|
6677
7680
|
return new Set((router["kernel"] ?? []).map(String));
|
|
6678
7681
|
} catch {
|
|
@@ -6689,8 +7692,8 @@ function _check_lean_projection(projectRoot, packageRoot = PACKAGE_ROOT, project
|
|
|
6689
7692
|
remedy: "set lean_projection.mode to 'eager-all' or 'thin' in .agent-settings.yml"
|
|
6690
7693
|
};
|
|
6691
7694
|
}
|
|
6692
|
-
const rulesDir = projectedRulesDir ??
|
|
6693
|
-
if (!
|
|
7695
|
+
const rulesDir = projectedRulesDir ?? path18.join(projectRoot, ".augment", "rules");
|
|
7696
|
+
if (!fs20.existsSync(rulesDir)) {
|
|
6694
7697
|
return {
|
|
6695
7698
|
id: "lean-projection",
|
|
6696
7699
|
status: "skipped",
|
|
@@ -6699,7 +7702,7 @@ function _check_lean_projection(projectRoot, packageRoot = PACKAGE_ROOT, project
|
|
|
6699
7702
|
};
|
|
6700
7703
|
}
|
|
6701
7704
|
const kernel = kernelIdsFromRouter(packageRoot);
|
|
6702
|
-
const files =
|
|
7705
|
+
const files = fs20.readdirSync(rulesDir).filter((f) => f.endsWith(".md") && f !== "INDEX.md").sort();
|
|
6703
7706
|
const nonKernel = files.filter((f) => !kernel.has(f.replace(/\.md$/, "")));
|
|
6704
7707
|
if (nonKernel.length === 0) {
|
|
6705
7708
|
return {
|
|
@@ -6713,7 +7716,7 @@ function _check_lean_projection(projectRoot, packageRoot = PACKAGE_ROOT, project
|
|
|
6713
7716
|
for (const f of nonKernel) {
|
|
6714
7717
|
let text = "";
|
|
6715
7718
|
try {
|
|
6716
|
-
text =
|
|
7719
|
+
text = fs20.readFileSync(path18.join(rulesDir, f), "utf8");
|
|
6717
7720
|
} catch {
|
|
6718
7721
|
continue;
|
|
6719
7722
|
}
|
|
@@ -6744,8 +7747,8 @@ function _check_lean_projection(projectRoot, packageRoot = PACKAGE_ROOT, project
|
|
|
6744
7747
|
function _check_host_manifest(projectRoot) {
|
|
6745
7748
|
const detected = Object.entries(detectToolPresence(projectRoot)).filter(([, v]) => v === true).map(([k]) => k);
|
|
6746
7749
|
const detectedNote = detected.length > 0 ? `detected surfaces: ${detected.join(", ")}` : "no surfaces detected";
|
|
6747
|
-
const settingsPath =
|
|
6748
|
-
if (!
|
|
7750
|
+
const settingsPath = path18.join(projectRoot, ".agent-settings.yml");
|
|
7751
|
+
if (!fs20.existsSync(settingsPath)) {
|
|
6749
7752
|
return {
|
|
6750
7753
|
id: "host-manifest",
|
|
6751
7754
|
status: "ok",
|
|
@@ -6755,7 +7758,7 @@ function _check_host_manifest(projectRoot) {
|
|
|
6755
7758
|
}
|
|
6756
7759
|
let parsed = null;
|
|
6757
7760
|
try {
|
|
6758
|
-
parsed = YAML.parse(
|
|
7761
|
+
parsed = YAML.parse(fs20.readFileSync(settingsPath, "utf8"));
|
|
6759
7762
|
} catch (exc) {
|
|
6760
7763
|
return {
|
|
6761
7764
|
id: "host-manifest",
|
|
@@ -6929,13 +7932,13 @@ function _isCliEntry13() {
|
|
|
6929
7932
|
if (process5.argv[1] === void 0) {
|
|
6930
7933
|
return false;
|
|
6931
7934
|
}
|
|
6932
|
-
const argvUrl = pathToFileURL14(
|
|
7935
|
+
const argvUrl = pathToFileURL14(path18.resolve(process5.argv[1])).href;
|
|
6933
7936
|
if (import.meta.url === argvUrl) {
|
|
6934
7937
|
return true;
|
|
6935
7938
|
}
|
|
6936
7939
|
try {
|
|
6937
|
-
const here =
|
|
6938
|
-
const argv =
|
|
7940
|
+
const here = fs20.realpathSync(fileURLToPath14(import.meta.url));
|
|
7941
|
+
const argv = fs20.realpathSync(path18.resolve(process5.argv[1]));
|
|
6939
7942
|
return here === argv;
|
|
6940
7943
|
} catch {
|
|
6941
7944
|
return false;
|