@event4u/agent-config 9.9.0 → 9.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +212 -194
- package/README.md +13 -16
- package/agents/templates/.ai-council.yml.example +481 -0
- package/agents/templates/.ai-video.xml.example +247 -0
- package/dist/agent-src/commands/agent-status.md +12 -11
- package/dist/agent-src/commands/agents/user/accept.md +115 -30
- package/dist/agent-src/commands/agents/user/delete.md +147 -0
- package/dist/agent-src/commands/agents/user/review.md +65 -28
- package/dist/agent-src/commands/agents/user/show.md +82 -29
- package/dist/agent-src/commands/agents/user/update.md +2 -2
- package/dist/agent-src/commands/agents/user.md +16 -3
- package/dist/agent-src/commands/check-current-md.md +0 -10
- package/dist/agent-src/commands/condense.md +28 -97
- package/dist/agent-src/commands/cost/report.md +7 -0
- package/dist/agent-src/commands/fix/portability.md +0 -8
- package/dist/agent-src/commands/fix/refs.md +0 -8
- package/dist/agent-src/commands/humanize.md +2 -2
- package/dist/agent-src/commands/jira-ticket.md +1 -1
- package/dist/agent-src/commands/memory/load.md +11 -0
- package/dist/agent-src/commands/optimize/skills.md +1 -1
- package/dist/agent-src/commands/pr/create.md +4 -4
- package/dist/agent-src/commands/profile/show.md +3 -3
- package/dist/agent-src/commands/rule-compliance-audit.md +5 -4
- package/dist/agent-src/commands/security-audit-config.md +1 -1
- package/dist/agent-src/commands/sync/gitignore/fix.md +1 -1
- package/dist/agent-src/commands/tdd.md +21 -0
- package/dist/agent-src/commands/team/delegate.md +2 -2
- package/dist/agent-src/commands/team-knowledge/bootstrap.md +9 -8
- package/dist/agent-src/commands/team-knowledge/consolidate.md +8 -7
- package/dist/agent-src/commands/team.md +4 -1
- package/dist/agent-src/commands/upstream-contribute.md +0 -1
- package/dist/agent-src/contexts/authority/commit-mechanics.md +7 -0
- package/dist/agent-src/contexts/authority/destructive-mechanics.md +16 -0
- package/dist/agent-src/contexts/authority/scope-mechanics.md +61 -0
- package/dist/agent-src/contexts/communication/rules-auto/reply-close-mechanics.md +20 -18
- package/dist/agent-src/contexts/communication/rules-auto/skill-quality-mechanics.md +1 -1
- package/dist/agent-src/contexts/communication/rules-auto/slash-command-routing-policy-mechanics.md +1 -1
- package/dist/agent-src/contexts/communication/rules-auto/source-of-truth-mechanics.md +9 -10
- package/dist/agent-src/contexts/communication/rules-auto/think-before-action-mechanics.md +1 -1
- package/dist/agent-src/contexts/communication/rules-auto/user-interaction-mechanics.md +11 -0
- package/dist/agent-src/contexts/contracts/artifact-engagement-flow.md +26 -15
- package/dist/agent-src/contexts/contracts/command-suggestion-flow.md +3 -0
- package/dist/agent-src/contexts/execution/auto-dispatch-classification.md +67 -37
- package/dist/agent-src/contexts/execution/auto-orchestration-activation.md +1 -1
- package/dist/agent-src/contexts/execution/autonomy-examples.md +1 -1
- package/dist/agent-src/contexts/execution/autonomy-mechanics.md +7 -6
- package/dist/agent-src/contexts/execution/evidence-discipline.md +92 -77
- package/dist/agent-src/contexts/execution/orchestration-benchmark-gate.md +22 -21
- package/dist/agent-src/contexts/execution/orchestration-telemetry.md +24 -0
- package/dist/agent-src/contexts/execution/project-intelligence.md +122 -103
- package/dist/agent-src/contexts/execution/roadmap-execution-contract.md +23 -21
- package/dist/agent-src/contexts/execution/subagent-response-contract.md +5 -5
- package/dist/agent-src/contexts/execution/subagent-routing.md +11 -0
- package/dist/agent-src/contexts/execution/subagent-spawn-contract.md +13 -13
- package/dist/agent-src/contexts/execution/subagent-steering.md +36 -34
- package/dist/agent-src/contexts/execution/toolchain-resolver.md +1 -1
- package/dist/agent-src/contexts/execution/user-memory-channels.md +189 -0
- package/dist/agent-src/contexts/execution/verification-mechanics.md +9 -0
- package/dist/agent-src/contexts/model-recommendations.md +3 -2
- package/dist/agent-src/contexts/subagent-configuration.md +3 -3
- package/dist/agent-src/ghostwriter/README.md +2 -2
- package/dist/agent-src/packs/README.md +1 -1
- package/dist/agent-src/personas/README.md +5 -5
- package/dist/agent-src/personas/_template-specialist/persona.md +3 -3
- package/dist/agent-src/personas/backend-architect.md +24 -23
- package/dist/agent-src/personas/eloquent-tamer.md +30 -30
- package/dist/agent-src/personas/frontend-engineer.md +30 -30
- package/dist/agent-src/personas/product-owner.md +41 -38
- package/dist/agent-src/personas/qa.md +13 -13
- package/dist/agent-src/personas/security-engineer.md +22 -22
- package/dist/agent-src/presets/README.md +3 -3
- package/dist/agent-src/profiles/README.md +3 -3
- package/dist/agent-src/rules/active-remediation.md +2 -2
- package/dist/agent-src/rules/artifact-engagement-recording.md +4 -4
- package/dist/agent-src/rules/ask-when-uncertain.md +0 -4
- package/dist/agent-src/rules/augment-edit-discipline.md +1 -1
- package/dist/agent-src/rules/broken-access-control.md +4 -4
- package/dist/agent-src/rules/code-comment-discipline.md +1 -1
- package/dist/agent-src/rules/code-provenance.md +2 -2
- package/dist/agent-src/rules/commit-policy.md +4 -9
- package/dist/agent-src/rules/communication-through-line.md +5 -5
- package/dist/agent-src/rules/decision-revisit-gate.md +1 -1
- package/dist/agent-src/rules/design-fidelity.md +1 -1
- package/dist/agent-src/rules/doc-screenshot-hygiene.md +1 -1
- package/dist/agent-src/rules/domain-adoption-policy.md +1 -1
- package/dist/agent-src/rules/domain-safety-pii.md +1 -1
- package/dist/agent-src/rules/external-code-graph-interop.md +1 -1
- package/dist/agent-src/rules/fast-path-marker-visibility.md +43 -7
- package/dist/agent-src/rules/finance-safety-floor.md +1 -1
- package/dist/agent-src/rules/framework-neutrality-in-generic-skills.md +3 -3
- package/dist/agent-src/rules/history-discipline.md +1 -1
- package/dist/agent-src/rules/legal-safety-floor.md +1 -1
- package/dist/agent-src/rules/lethal-trifecta-guard.md +5 -5
- package/dist/agent-src/rules/low-impact-corpus-privacy-floor.md +10 -8
- package/dist/agent-src/rules/media-governance-routing.md +13 -13
- package/dist/agent-src/rules/media-sync-ground-truth.md +29 -11
- package/dist/agent-src/rules/no-cheap-questions.md +7 -7
- package/dist/agent-src/rules/no-decorative-emojis-in-git-surfaces.md +29 -18
- package/dist/agent-src/rules/non-destructive-by-default.md +5 -23
- package/dist/agent-src/rules/onboarding-gate.md +14 -4
- package/dist/agent-src/rules/persona-governance.md +2 -2
- package/dist/agent-src/rules/prefer-enums-over-literals.md +9 -9
- package/dist/agent-src/rules/preservation-guard.md +10 -2
- package/dist/agent-src/rules/question-not-instruction.md +1 -1
- package/dist/agent-src/rules/roadmap-progress-sync.md +6 -6
- package/dist/agent-src/rules/rule-type-governance.md +1 -1
- package/dist/agent-src/rules/scale-discipline.md +1 -1
- package/dist/agent-src/rules/scope-control.md +1 -1
- package/dist/agent-src/rules/secret-vcs-guard.md +1 -1
- package/dist/agent-src/rules/security-sensitive-stop.md +17 -11
- package/dist/agent-src/rules/senior-engineering-discipline.md +17 -17
- package/dist/agent-src/rules/session-canary.md +1 -1
- package/dist/agent-src/rules/skill-quality.md +1 -1
- package/dist/agent-src/rules/source-confidentiality.md +21 -19
- package/dist/agent-src/rules/source-of-truth.md +6 -5
- package/dist/agent-src/rules/spreadsheet-source-quality.md +2 -2
- package/dist/agent-src/rules/strategy-safety-floor.md +1 -1
- package/dist/agent-src/rules/think-before-action.md +5 -5
- package/dist/agent-src/rules/token-budget-discipline.md +5 -3
- package/dist/agent-src/rules/token-efficiency.md +2 -2
- package/dist/agent-src/rules/untrusted-input-defense.md +4 -4
- package/dist/agent-src/rules/user-interaction.md +12 -0
- package/dist/agent-src/rules/verify-before-complete.md +4 -24
- package/dist/agent-src/skills/adversarial-review/SKILL.md +2 -2
- package/dist/agent-src/skills/agent-security-review/SKILL.md +52 -45
- package/dist/agent-src/skills/agents-md-thin-root/SKILL.md +2 -2
- package/dist/agent-src/skills/ai-code-blindspots/SKILL.md +20 -20
- package/dist/agent-src/skills/ai-council/SKILL.md +185 -128
- package/dist/agent-src/skills/analysis-skill-router/SKILL.md +3 -3
- package/dist/agent-src/skills/api-endpoint/SKILL.md +2 -2
- package/dist/agent-src/skills/artisan-commands/SKILL.md +2 -2
- package/dist/agent-src/skills/async-python-patterns/SKILL.md +8 -7
- package/dist/agent-src/skills/authz-review/SKILL.md +16 -15
- package/dist/agent-src/skills/aws-infrastructure/SKILL.md +5 -5
- package/dist/agent-src/skills/blade-ui/SKILL.md +1 -1
- package/dist/agent-src/skills/bug-analyzer/SKILL.md +30 -12
- package/dist/agent-src/skills/code-intelligence/SKILL.md +0 -1
- package/dist/agent-src/skills/code-intelligence/evals/triggers.json +52 -0
- package/dist/agent-src/skills/code-review/SKILL.md +6 -6
- package/dist/agent-src/skills/command-routing/SKILL.md +5 -4
- package/dist/agent-src/skills/composer-packages/SKILL.md +2 -2
- package/dist/agent-src/skills/condense-memory/SKILL.md +43 -41
- package/dist/agent-src/skills/context-document/SKILL.md +23 -21
- package/dist/agent-src/skills/copilot-config/SKILL.md +6 -1
- package/dist/agent-src/skills/decision-record/SKILL.md +20 -18
- package/dist/agent-src/skills/design-intelligence/SKILL.md +4 -4
- package/dist/agent-src/skills/design-review/SKILL.md +15 -14
- package/dist/agent-src/skills/design-system-capture/reference/design-system-json.md +28 -25
- package/dist/agent-src/skills/devcontainer/SKILL.md +2 -2
- package/dist/agent-src/skills/docker/SKILL.md +1 -1
- package/dist/agent-src/skills/docx-authoring/evals/triggers.json +52 -0
- package/dist/agent-src/skills/emit-tickets/SKILL.md +2 -2
- package/dist/agent-src/skills/error-handling-patterns/SKILL.md +1 -1
- package/dist/agent-src/skills/estimate-ticket/SKILL.md +2 -2
- package/dist/agent-src/skills/evaluate-llm-feature/SKILL.md +0 -1
- package/dist/agent-src/skills/evaluate-llm-feature/evals/triggers.json +52 -0
- package/dist/agent-src/skills/existing-ui-audit/SKILL.md +21 -7
- package/dist/agent-src/skills/fe-design/SKILL.md +10 -0
- package/dist/agent-src/skills/feature-planning/SKILL.md +2 -2
- package/dist/agent-src/skills/finishing-a-development-branch/SKILL.md +3 -3
- package/dist/agent-src/skills/flux/SKILL.md +1 -1
- package/dist/agent-src/skills/frontend-render-security/SKILL.md +13 -13
- package/dist/agent-src/skills/git-workflow/SKILL.md +33 -33
- package/dist/agent-src/skills/grafana/SKILL.md +5 -0
- package/dist/agent-src/skills/humanizer/SKILL.md +83 -66
- package/dist/agent-src/skills/humanizer/data/patterns.md +14 -14
- package/dist/agent-src/skills/humanizer/references/anti-aiisms.md +4 -4
- package/dist/agent-src/skills/judge-artifact-completeness/SKILL.md +82 -37
- package/dist/agent-src/skills/judge-bug-hunter/SKILL.md +17 -5
- package/dist/agent-src/skills/judge-injection-defense/SKILL.md +63 -25
- package/dist/agent-src/skills/judge-security-auditor/SKILL.md +2 -0
- package/dist/agent-src/skills/judge-synthesis/SKILL.md +72 -28
- package/dist/agent-src/skills/laravel-horizon/SKILL.md +5 -0
- package/dist/agent-src/skills/laravel-mail/SKILL.md +5 -4
- package/dist/agent-src/skills/laravel-middleware/SKILL.md +5 -4
- package/dist/agent-src/skills/laravel-notifications/SKILL.md +10 -9
- package/dist/agent-src/skills/laravel-pennant/SKILL.md +1 -1
- package/dist/agent-src/skills/laravel-pulse/SKILL.md +9 -8
- package/dist/agent-src/skills/laravel-reverb/SKILL.md +6 -5
- package/dist/agent-src/skills/laravel-scheduling/SKILL.md +6 -1
- package/dist/agent-src/skills/laravel-validation/SKILL.md +12 -0
- package/dist/agent-src/skills/launch-readiness/SKILL.md +1 -1
- package/dist/agent-src/skills/learning-to-rule-or-skill/SKILL.md +7 -7
- package/dist/agent-src/skills/learning-tutor/SKILL.md +44 -43
- package/dist/agent-src/skills/learning-tutor/evals/triggers.json +52 -0
- package/dist/agent-src/skills/license-compliance-audit/SKILL.md +7 -7
- package/dist/agent-src/skills/license-compliance-borrow-check/SKILL.md +3 -3
- package/dist/agent-src/skills/license-compliance-credits/SKILL.md +4 -4
- package/dist/agent-src/skills/llm-provider-knowledge/SKILL.md +0 -1
- package/dist/agent-src/skills/memory-consolidation/SKILL.md +69 -64
- package/dist/agent-src/skills/motion-choreographer/SKILL.md +6 -6
- package/dist/agent-src/skills/pdf-tools/evals/triggers.json +52 -0
- package/dist/agent-src/skills/performance-analysis/SKILL.md +7 -3
- package/dist/agent-src/skills/persona-improvement/SKILL.md +0 -2
- package/dist/agent-src/skills/persona-improvement/evals/triggers.json +52 -0
- package/dist/agent-src/skills/php-coder/SKILL.md +10 -0
- package/dist/agent-src/skills/prediction-pool-optimizer/SKILL.md +129 -120
- package/dist/agent-src/skills/prediction-pool-optimizer/reference/ev-fixtures.md +36 -35
- package/dist/agent-src/skills/prediction-pool-optimizer/reference/odds-and-bonus.md +45 -41
- package/dist/agent-src/skills/project-analysis-core/SKILL.md +4 -4
- package/dist/agent-src/skills/project-analysis-hypothesis-driven/SKILL.md +3 -3
- package/dist/agent-src/skills/project-analysis-react/SKILL.md +1 -1
- package/dist/agent-src/skills/project-analysis-symfony/SKILL.md +1 -1
- package/dist/agent-src/skills/project-analysis-zend-laminas/SKILL.md +2 -2
- package/dist/agent-src/skills/prompt-engineering-patterns/SKILL.md +1 -1
- package/dist/agent-src/skills/prompt-validator/SKILL.md +39 -39
- package/dist/agent-src/skills/quality-tools/SKILL.md +15 -15
- package/dist/agent-src/skills/react-shadcn-ui/SKILL.md +55 -19
- package/dist/agent-src/skills/react-shadcn-ui/reference/registry.md +29 -27
- package/dist/agent-src/skills/readme-writing-package/SKILL.md +2 -2
- package/dist/agent-src/skills/reasoning-orchestrator/SKILL.md +25 -25
- package/dist/agent-src/skills/recursive-verification/SKILL.md +6 -5
- package/dist/agent-src/skills/refine-prompt/SKILL.md +1 -1
- package/dist/agent-src/skills/refine-ticket/SKILL.md +20 -2
- package/dist/agent-src/skills/repomix-packer/SKILL.md +1 -1
- package/dist/agent-src/skills/requesting-code-review/SKILL.md +2 -2
- package/dist/agent-src/skills/roadmap-management/SKILL.md +80 -66
- package/dist/agent-src/skills/roadmap-writing/SKILL.md +84 -77
- package/dist/agent-src/skills/rule-refactor/SKILL.md +1 -1
- package/dist/agent-src/skills/screenshot-hygiene/evals/triggers.json +52 -0
- package/dist/agent-src/skills/security-audit/SKILL.md +26 -9
- package/dist/agent-src/skills/security-maturity-assessment/SKILL.md +38 -16
- package/dist/agent-src/skills/skill-improvement-pipeline/SKILL.md +14 -11
- package/dist/agent-src/skills/skill-writing/SKILL.md +9 -8
- package/dist/agent-src/skills/song-to-script/SKILL.md +93 -85
- package/dist/agent-src/skills/sql-writing/SKILL.md +2 -2
- package/dist/agent-src/skills/stakeholder-tradeoff/SKILL.md +4 -3
- package/dist/agent-src/skills/standards-from-config/SKILL.md +61 -43
- package/dist/agent-src/skills/subagent-orchestration/SKILL.md +22 -8
- package/dist/agent-src/skills/subagent-orchestration/prompts/README.md +28 -2
- package/dist/agent-src/skills/supply-chain-intake/SKILL.md +13 -13
- package/dist/agent-src/skills/systematic-debugging/SKILL.md +22 -21
- package/dist/agent-src/skills/tailwind-engineer/SKILL.md +1 -1
- package/dist/agent-src/skills/technical-specification/SKILL.md +5 -0
- package/dist/agent-src/skills/terraform/SKILL.md +2 -2
- package/dist/agent-src/skills/terragrunt/SKILL.md +8 -8
- package/dist/agent-src/skills/testing-anti-patterns/process-anti-patterns.md +1 -1
- package/dist/agent-src/skills/threat-modeling/SKILL.md +19 -13
- package/dist/agent-src/skills/universal-project-analysis/SKILL.md +1 -1
- package/dist/agent-src/skills/upstream-contribute/SKILL.md +0 -1
- package/dist/agent-src/skills/using-git-worktrees/SKILL.md +9 -9
- package/dist/agent-src/skills/validate-feature-fit/SKILL.md +3 -1
- package/dist/agent-src/skills/verify-completion-evidence/SKILL.md +4 -6
- package/dist/agent-src/skills/verify-repair-loop/SKILL.md +67 -61
- package/dist/agent-src/skills/video-director/SKILL.md +7 -7
- package/dist/agent-src/skills/worktree-lifecycle/SKILL.md +3 -3
- package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
- package/dist/agent-src/templates/contexts/knowledge-pages.md +47 -45
- package/dist/agent-src/templates/contexts/lesson-card.md +2 -2
- package/dist/agent-src/templates/contexts/tenant-boundaries.md +2 -2
- package/dist/agent-src/templates/contexts.md +1 -1
- package/dist/agent-src/templates/features.md +1 -1
- package/dist/agent-src/templates/roadmaps.md +125 -116
- package/dist/agent-src/templates/rule.md +2 -1
- package/dist/agent-src/templates/scripts/pr_risk_review.ts +0 -0
- package/dist/agent-src/templates/scripts/telemetry/aggregator.ts +0 -0
- package/dist/agent-src/templates/scripts/tier_usage_report.ts +2 -2
- package/dist/agent-src/templates/scripts/work_engine/directives/ui/apply.ts +30 -30
- package/dist/agent-src/templates/scripts/work_engine/directives/ui/design.ts +88 -33
- package/dist/agent-src/templates/scripts/work_engine/directives/ui/polish.ts +22 -2
- package/dist/agent-src/templates/scripts/work_engine/directives/ui/review.ts +21 -2
- package/dist/agent-src/templates/scripts/work_engine/directives/ui/stack_bundles.ts +179 -0
- package/dist/agent-src/templates/scripts/work_engine/stack/detect.ts +155 -4
- package/dist/agent-src/templates/scripts/work_engine/state.ts +21 -4
- package/dist/agent-src/user-types/README.md +8 -8
- package/dist/agent-src/user-types/galabau-field-crew.md +34 -33
- package/dist/agent-src/user-types/metalworking-shop.md +35 -34
- package/dist/agent-src/user-types/truck-driver.md +22 -20
- package/dist/cli/initRouting.js +74 -11
- package/dist/cli/initRouting.js.map +1 -1
- package/dist/cli/main.js +14 -3
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/python/workspace_roles.js +2 -2
- package/dist/cli/python/workspace_roles.js.map +1 -1
- package/dist/cli-delegate/chunk-4SV3XGFA.js +6910 -0
- package/dist/cli-delegate/chunk-736JCWLM.js +1104 -0
- package/dist/cli-delegate/chunk-7DSAMZFU.js +356 -0
- package/dist/cli-delegate/chunk-7HQ52DHU.js +74 -0
- package/dist/cli-delegate/chunk-BJGXZNPM.js +266 -0
- package/dist/cli-delegate/chunk-FTAISGDQ.js +117 -0
- package/dist/cli-delegate/chunk-GME3Q44L.js +82 -0
- package/dist/cli-delegate/chunk-GRRPEPRN.js +336 -0
- package/dist/cli-delegate/chunk-HJ6DAJHR.js +502 -0
- package/dist/cli-delegate/chunk-IR7P7JWA.js +872 -0
- package/dist/cli-delegate/chunk-J55WI3RR.js +47 -0
- package/dist/cli-delegate/chunk-MCJYCQPF.js +35 -0
- package/dist/cli-delegate/chunk-NDJLNC6Q.js +169 -0
- package/dist/cli-delegate/chunk-OMIVVCG2.js +26 -0
- package/dist/cli-delegate/chunk-OY53J6II.js +7336 -0
- package/dist/cli-delegate/chunk-RDGRHAAB.js +259 -0
- package/dist/cli-delegate/chunk-TFG57JJM.js +1969 -0
- package/dist/cli-delegate/chunk-XX6TOPD7.js +715 -0
- package/dist/cli-delegate/chunk-YMFO6FDN.js +10603 -0
- package/dist/cli-delegate/cmd_analyze_session.js +294 -0
- package/dist/cli-delegate/cmd_conformance.js +646 -0
- package/dist/cli-delegate/cmd_converge.js +326 -0
- package/dist/cli-delegate/cmd_doctor.js +144 -0
- package/dist/cli-delegate/cmd_explain.js +2508 -0
- package/dist/cli-delegate/cmd_export.js +296 -0
- package/dist/cli-delegate/cmd_fleet.js +332 -0
- package/dist/cli-delegate/cmd_memory_get.js +3878 -0
- package/dist/cli-delegate/cmd_migrate.js +11 -0
- package/dist/cli-delegate/cmd_preflight.js +270 -0
- package/dist/cli-delegate/cmd_prune.js +444 -0
- package/dist/cli-delegate/cmd_refresh.js +28 -0
- package/dist/cli-delegate/cmd_settings_check.js +574 -0
- package/dist/cli-delegate/cmd_settings_migrate.js +223 -0
- package/dist/cli-delegate/cmd_sync.js +264 -0
- package/dist/cli-delegate/cmd_uninstall.js +656 -0
- package/dist/cli-delegate/cmd_update.js +425 -0
- package/dist/cli-delegate/cmd_upgrade.js +444 -0
- package/dist/cli-delegate/cmd_validate.js +305 -0
- package/dist/cli-delegate/cmd_versions.js +370 -0
- package/dist/discovery/deprecation-report.md +1 -1
- package/dist/discovery/discovery-manifest.json +100 -67
- package/dist/discovery/discovery-manifest.json.sha256 +1 -1
- package/dist/discovery/discovery-manifest.summary.md +4 -4
- package/dist/discovery/orphan-report.md +1 -1
- package/dist/discovery/packs.json +16 -10
- package/dist/discovery/trust-report.md +2 -2
- package/dist/discovery/workspaces.json +7 -5
- package/dist/hooks/dispatch.js +186 -12
- package/dist/install/emit_host_rules_cli.js +2 -1
- package/dist/install/emit_host_rules_cli.js.map +1 -1
- package/dist/install/install.mjs +418 -378
- package/dist/install/rule_scope.js +5 -1
- package/dist/install/rule_scope.js.map +1 -1
- package/dist/install/toolDetection.js +40 -12
- package/dist/install/toolDetection.js.map +1 -1
- package/dist/install/wizard-plan.js +2 -2
- package/dist/install/wizard-plan.js.map +1 -1
- package/dist/mcp/registry-manifest.json +3 -3
- package/dist/mcp/server.json +2 -2
- package/dist/mcp/server.mjs +2194 -1003
- package/dist/router.json +1 -1
- package/dist/scripts/_lib/compile_time_toggles.js +48 -0
- package/dist/scripts/_lib/compile_time_toggles.js.map +1 -0
- package/dist/scripts/condense.js +234 -217
- package/dist/scripts/condense.js.map +1 -1
- package/dist/server/schemas/settings.js +4 -0
- package/dist/server/schemas/settings.js.map +1 -1
- package/dist/shared/userMd/utils.js +30 -0
- package/dist/shared/userMd/utils.js.map +1 -1
- package/dist/ui/assets/index-BpSQt5vm.js.map +1 -1
- package/docs/guidelines/agent-infra/api-cost-levers.md +56 -5
- package/docs/guidelines/agent-infra/simplicity-and-goal-demos.md +93 -33
- package/package.json +4 -2
- package/src/agent-src/templates/scripts/pr_risk_review.ts +0 -0
- package/src/agent-src/templates/scripts/telemetry/aggregator.ts +0 -0
- package/src/agent-src/templates/scripts/tier_usage_report.ts +2 -2
- package/src/agent-src/templates/scripts/work_engine/directives/ui/apply.ts +30 -30
- package/src/agent-src/templates/scripts/work_engine/directives/ui/design.ts +88 -33
- package/src/agent-src/templates/scripts/work_engine/directives/ui/polish.ts +22 -2
- package/src/agent-src/templates/scripts/work_engine/directives/ui/review.ts +21 -2
- package/src/agent-src/templates/scripts/work_engine/directives/ui/stack_bundles.ts +179 -0
- package/src/agent-src/templates/scripts/work_engine/stack/detect.ts +155 -4
- package/src/agent-src/templates/scripts/work_engine/state.ts +21 -4
- package/src/config/agent-settings.template.yml +32 -2
- package/src/config/ci-local-parity.yml +142 -0
- package/src/config/discovery/packs.yml +7 -0
- package/src/config/evaluator-budgets.json +1 -1
- package/src/config/gate-coverage.yml +127 -0
- package/src/config/pack-size-budget.json +27 -0
- package/src/config/preamble-payload-budget.json +44 -0
- package/src/install/emit_host_rules_cli.ts +2 -1
- package/src/install/rule_scope.ts +5 -1
- package/src/install/toolDetection.ts +39 -8
- package/src/install/wizard-plan.ts +2 -2
- package/src/scripts/_cli/cmd_conformance.ts +2 -1
- package/src/scripts/_cli/cmd_converge.ts +2 -1
- package/src/scripts/_cli/cmd_doctor.ts +292 -15
- package/src/scripts/_cli/cmd_export.ts +2 -1
- package/src/scripts/_cli/cmd_fleet.ts +2 -1
- package/src/scripts/_cli/cmd_migrate.ts +2 -1
- package/src/scripts/_cli/cmd_preflight.ts +2 -1
- package/src/scripts/_cli/cmd_refresh.ts +2 -1
- package/src/scripts/_cli/cmd_update.ts +2 -1
- package/src/scripts/_cli/cmd_upgrade.ts +2 -1
- package/src/scripts/_cli/cmd_versions.ts +2 -1
- package/src/scripts/_cli/detection_report.ts +480 -0
- package/src/scripts/_dispatch.bash +52 -14
- package/src/scripts/_lib/agent_user_profile.ts +381 -0
- package/src/scripts/_lib/agents_overlay.ts +9 -0
- package/src/scripts/_lib/anchor_eval.ts +311 -0
- package/src/scripts/_lib/cc_transcript.ts +316 -0
- package/src/scripts/_lib/changelog_eras.ts +103 -9
- package/src/scripts/_lib/compile_time_toggles.ts +79 -0
- package/src/scripts/_lib/confusables.ts +101 -0
- package/src/scripts/_lib/duplicate_scope_census.ts +77 -0
- package/src/scripts/_lib/environment_detector.ts +441 -0
- package/src/scripts/_lib/managed_agents_folder.ts +181 -0
- package/src/scripts/_lib/package_root.ts +72 -0
- package/src/scripts/_lib/payload_hash_drift.ts +126 -0
- package/src/scripts/_lib/preservation_migration.ts +291 -0
- package/src/scripts/_lib/retrieval_sanitize.ts +166 -2
- package/src/scripts/_lib/scan_scope.ts +115 -0
- package/src/scripts/_lib/user_global_memory_audit.ts +187 -0
- package/src/scripts/_lib/user_global_observations.ts +830 -0
- package/src/scripts/_lib/user_global_revocations.ts +110 -0
- package/src/scripts/_lib/user_memory_gate_counters.ts +291 -0
- package/src/scripts/ai_council/blind_review.ts +0 -0
- package/src/scripts/ai_council/budget_guard.ts +90 -11
- package/src/scripts/ai_council/bundler.ts +2 -2
- package/src/scripts/ai_council/clients.ts +59 -3
- package/src/scripts/ai_council/config.ts +53 -7
- package/src/scripts/ai_council/modes.ts +68 -2
- package/src/scripts/ai_council/orchestrator.ts +54 -9
- package/src/scripts/ai_council/transport_resolver.ts +331 -0
- package/src/scripts/ai_team/team_dispatch.ts +17 -6
- package/src/scripts/anchor_eval_falsify.ts +198 -0
- package/src/scripts/anchor_scoring_run.ts +239 -0
- package/src/scripts/annotate_discovery.ts +1 -65
- package/src/scripts/bench_quality_run.ts +168 -4
- package/src/scripts/cache_realization_report.ts +782 -0
- package/src/scripts/check_artefact_count_messaging.ts +5 -1
- package/src/scripts/check_augment_description_cap.ts +15 -4
- package/src/scripts/check_bundle_path_leakage.ts +10 -4
- package/src/scripts/check_ci_local_parity.ts +317 -0
- package/src/scripts/check_condensation.ts +96 -191
- package/src/scripts/check_context_paths.ts +38 -9
- package/src/scripts/check_dependency_floors.ts +153 -0
- package/src/scripts/check_gate_coverage.ts +299 -0
- package/src/scripts/check_iron_law_prominence.ts +22 -1
- package/src/scripts/check_kernel_prefix_stability.ts +0 -0
- package/src/scripts/check_no_new_legacy_path.ts +16 -6
- package/src/scripts/check_no_roadmap_refs.ts +22 -9
- package/src/scripts/check_originality_freshness.ts +167 -0
- package/src/scripts/check_pack_size.ts +188 -0
- package/src/scripts/check_preamble_payload_budget.ts +130 -0
- package/src/scripts/check_proposal.ts +0 -0
- package/src/scripts/check_references.ts +0 -1
- package/src/scripts/check_safety_floor_untouched.ts +171 -24
- package/src/scripts/check_site_links.ts +62 -3
- package/src/scripts/ci_status.ts +0 -0
- package/src/scripts/cluster_near_miss_patterns.ts +0 -0
- package/src/scripts/code_graph/build.ts +0 -0
- package/src/scripts/command_suggester/types.ts +0 -0
- package/src/scripts/compile_router.ts +10 -14
- package/src/scripts/condense.sh +3 -4
- package/src/scripts/condense.ts +247 -228
- package/src/scripts/cost/track.mjs +168 -33
- package/src/scripts/cost_summary.ts +33 -1
- package/src/scripts/council_cli.ts +51 -5
- package/src/scripts/discovery_graph.ts +0 -0
- package/src/scripts/encoding_corpus.ts +500 -0
- package/src/scripts/encoding_corpus_report.ts +216 -0
- package/src/scripts/evaluator_umbrella.sh +34 -1
- package/src/scripts/generate_index.ts +19 -2
- package/src/scripts/install-hooks.sh +2 -2
- package/src/scripts/learning_sidecar.ts +0 -0
- package/src/scripts/lint_confusables.ts +10 -72
- package/src/scripts/lint_eval_fixture_citations.ts +113 -0
- package/src/scripts/lint_featured_skills.ts +0 -0
- package/src/scripts/lint_hidden_unicode.ts +208 -0
- package/src/scripts/lint_load_context.ts +17 -5
- package/src/scripts/lint_new_skill_gate.ts +9 -3
- package/src/scripts/lint_no_python_twin_rationale.ts +17 -2
- package/src/scripts/lint_originality.ts +1 -1
- package/src/scripts/lint_skill_originality.ts +1 -1
- package/src/scripts/lint_ticket_buildable.ts +1 -1
- package/src/scripts/lint_ui_stack_bundles.ts +170 -0
- package/src/scripts/mcp_server/tools.ts +4 -4
- package/src/scripts/measure_scope_dedup.ts +224 -0
- package/src/scripts/memory_lookup.ts +0 -0
- package/src/scripts/mine_session.ts +98 -0
- package/src/scripts/orchestration_payload_hash_drift.ts +145 -0
- package/src/scripts/preamble_byte_census.ts +574 -0
- package/src/scripts/probe_skill_registration.ts +2 -2
- package/src/scripts/redact_hook_capture.ts +13 -0
- package/src/scripts/release.ts +65 -10
- package/src/scripts/router_telemetry.ts +1 -1
- package/src/scripts/second_brain_retrieval.ts +14 -4
- package/src/scripts/skill_linter.ts +5 -0
- package/src/scripts/surface-tiers.yml +2 -0
- package/src/scripts/validate_pack_yaml.ts +0 -0
- package/src/server/schemas/settings.ts +8 -0
- package/src/shared/userMd/utils.ts +31 -0
- package/dist/agent-src/rules/telegraph-speak.md +0 -87
|
@@ -0,0 +1,872 @@
|
|
|
1
|
+
import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
write_target
|
|
4
|
+
} from "./chunk-NDJLNC6Q.js";
|
|
5
|
+
import {
|
|
6
|
+
__export
|
|
7
|
+
} from "./chunk-J55WI3RR.js";
|
|
8
|
+
|
|
9
|
+
// src/scripts/_lib/fs_atomic.ts
|
|
10
|
+
import fs from "node:fs";
|
|
11
|
+
import path from "node:path";
|
|
12
|
+
import { randomBytes } from "node:crypto";
|
|
13
|
+
function _normalize_encoding(encoding) {
|
|
14
|
+
const compact = encoding.toLowerCase().replace(/[-_\s]/g, "");
|
|
15
|
+
const candidates = [encoding, compact];
|
|
16
|
+
if (compact === "latin1" || compact === "iso88591") candidates.push("latin1");
|
|
17
|
+
if (compact === "utf8") candidates.push("utf8");
|
|
18
|
+
if (compact === "utf16le" || compact === "utf16") candidates.push("utf16le");
|
|
19
|
+
if (compact === "usascii") candidates.push("ascii");
|
|
20
|
+
for (const c of candidates) {
|
|
21
|
+
if (Buffer.isEncoding(c)) return c;
|
|
22
|
+
}
|
|
23
|
+
throw new Error(`unknown encoding: ${encoding}`);
|
|
24
|
+
}
|
|
25
|
+
function write_atomic(p, data, options = {}) {
|
|
26
|
+
const encoding = options.encoding ?? "utf-8";
|
|
27
|
+
const target = path.normalize(p);
|
|
28
|
+
const parent = path.dirname(target);
|
|
29
|
+
fs.mkdirSync(parent, { recursive: true });
|
|
30
|
+
let payload;
|
|
31
|
+
if (typeof data === "string") {
|
|
32
|
+
payload = Buffer.from(data, _normalize_encoding(encoding));
|
|
33
|
+
} else if (data instanceof Uint8Array) {
|
|
34
|
+
payload = Buffer.from(data);
|
|
35
|
+
} else {
|
|
36
|
+
throw new TypeError(
|
|
37
|
+
`write_atomic: data must be str or bytes, got ${typeof data}`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
let fd = null;
|
|
41
|
+
let tmp_path = "";
|
|
42
|
+
for (let attempt = 0; attempt < 32; attempt += 1) {
|
|
43
|
+
tmp_path = path.join(
|
|
44
|
+
parent,
|
|
45
|
+
`.${path.basename(target)}.tmp.${randomBytes(6).toString("hex")}`
|
|
46
|
+
);
|
|
47
|
+
try {
|
|
48
|
+
fd = fs.openSync(tmp_path, "wx", 384);
|
|
49
|
+
break;
|
|
50
|
+
} catch (err) {
|
|
51
|
+
if (err.code === "EEXIST") continue;
|
|
52
|
+
throw err;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (fd === null) {
|
|
56
|
+
throw new Error("write_atomic: could not create a unique temp file");
|
|
57
|
+
}
|
|
58
|
+
let closed = false;
|
|
59
|
+
try {
|
|
60
|
+
let offset = 0;
|
|
61
|
+
while (offset < payload.length) {
|
|
62
|
+
offset += fs.writeSync(fd, payload, offset, payload.length - offset);
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
fs.fsyncSync(fd);
|
|
66
|
+
} catch {
|
|
67
|
+
}
|
|
68
|
+
fs.closeSync(fd);
|
|
69
|
+
closed = true;
|
|
70
|
+
fs.renameSync(tmp_path, target);
|
|
71
|
+
} catch (err) {
|
|
72
|
+
if (!closed) {
|
|
73
|
+
try {
|
|
74
|
+
fs.closeSync(fd);
|
|
75
|
+
} catch {
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
fs.unlinkSync(tmp_path);
|
|
80
|
+
} catch {
|
|
81
|
+
}
|
|
82
|
+
throw err;
|
|
83
|
+
}
|
|
84
|
+
_fsync_dir(parent);
|
|
85
|
+
return target;
|
|
86
|
+
}
|
|
87
|
+
function _fsync_dir(directory) {
|
|
88
|
+
let dir_fd;
|
|
89
|
+
try {
|
|
90
|
+
dir_fd = fs.openSync(directory, fs.constants.O_RDONLY);
|
|
91
|
+
} catch {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
try {
|
|
96
|
+
fs.fsyncSync(dir_fd);
|
|
97
|
+
} catch {
|
|
98
|
+
}
|
|
99
|
+
} finally {
|
|
100
|
+
fs.closeSync(dir_fd);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// src/scripts/_lib/installed_tools.ts
|
|
105
|
+
import * as fs2 from "node:fs";
|
|
106
|
+
import * as os from "node:os";
|
|
107
|
+
import * as fsPath from "node:path";
|
|
108
|
+
var MANIFEST_ENV = "AGENT_CONFIG_INSTALLED_TOOLS";
|
|
109
|
+
var DEFAULT_MANIFEST_RELATIVE = fsPath.join("agents", "installed-tools.lock");
|
|
110
|
+
var SCHEMA_VERSION = 2;
|
|
111
|
+
var SCHEMA_VERSIONS_SUPPORTED = [1, 2];
|
|
112
|
+
var _VALID_SCOPES = ["global", "project"];
|
|
113
|
+
var DEFAULT_DEPLOY_ROOTS = [
|
|
114
|
+
".augment/rules",
|
|
115
|
+
".augment/skills",
|
|
116
|
+
".augment/commands",
|
|
117
|
+
".cursor/rules",
|
|
118
|
+
".claude/skills",
|
|
119
|
+
".claude/commands",
|
|
120
|
+
".clinerules",
|
|
121
|
+
".windsurf/rules"
|
|
122
|
+
];
|
|
123
|
+
function expanduser(p) {
|
|
124
|
+
if (p === "~") {
|
|
125
|
+
return os.homedir();
|
|
126
|
+
}
|
|
127
|
+
if (p.startsWith("~/") || process.platform === "win32" && p.startsWith("~\\")) {
|
|
128
|
+
return fsPath.join(os.homedir(), p.slice(2));
|
|
129
|
+
}
|
|
130
|
+
return p;
|
|
131
|
+
}
|
|
132
|
+
function manifest_path(project_root, env) {
|
|
133
|
+
const env_map = env ?? process.env;
|
|
134
|
+
const override = env_map[MANIFEST_ENV];
|
|
135
|
+
if (override) {
|
|
136
|
+
return expanduser(override);
|
|
137
|
+
}
|
|
138
|
+
return fsPath.join(project_root, DEFAULT_MANIFEST_RELATIVE);
|
|
139
|
+
}
|
|
140
|
+
var _TOP_KEY_RE = /^([A-Za-z_][A-Za-z0-9_]*)\s*:\s*"?([^"\n]*?)"?\s*$/;
|
|
141
|
+
var _LIST_DASH_RE = /^\s*-\s*(.+?)\s*$/;
|
|
142
|
+
var _INDENT_KEY_RE = /^\s+([A-Za-z_][A-Za-z0-9_]*)\s*:\s*"?([^"\n]*?)"?\s*$/;
|
|
143
|
+
function read_manifest(path3) {
|
|
144
|
+
let text;
|
|
145
|
+
try {
|
|
146
|
+
text = require_read_text(path3);
|
|
147
|
+
} catch {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
const data = _parse_manual(text);
|
|
151
|
+
return _normalise_v2_shape(data);
|
|
152
|
+
}
|
|
153
|
+
function require_read_text(path3) {
|
|
154
|
+
return fs2.readFileSync(path3, { encoding: "utf-8" });
|
|
155
|
+
}
|
|
156
|
+
function _normalise_v2_shape(data) {
|
|
157
|
+
if (data["tools"] === void 0 || data["tools"] === null) {
|
|
158
|
+
data["tools"] = [];
|
|
159
|
+
}
|
|
160
|
+
if (data["deploy_roots"] === void 0 || data["deploy_roots"] === null) {
|
|
161
|
+
data["deploy_roots"] = [];
|
|
162
|
+
}
|
|
163
|
+
const tools = data["tools"];
|
|
164
|
+
for (const tool of tools) {
|
|
165
|
+
if (typeof tool !== "object" || tool === null) {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
const t = tool;
|
|
169
|
+
if (t["files"] === void 0 || t["files"] === null) {
|
|
170
|
+
t["files"] = [];
|
|
171
|
+
}
|
|
172
|
+
if (t["merged_keys"] === void 0 || t["merged_keys"] === null) {
|
|
173
|
+
t["merged_keys"] = [];
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return data;
|
|
177
|
+
}
|
|
178
|
+
function _parse_manual(text) {
|
|
179
|
+
const data = { tools: [] };
|
|
180
|
+
const tools = data["tools"];
|
|
181
|
+
let in_tools = false;
|
|
182
|
+
let current = null;
|
|
183
|
+
let skip_until_outdent = false;
|
|
184
|
+
for (const raw of splitlines(text)) {
|
|
185
|
+
const stripped = raw.trim();
|
|
186
|
+
if (!stripped || stripped.startsWith("#")) {
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
if (stripped === "tools:") {
|
|
190
|
+
in_tools = true;
|
|
191
|
+
current = null;
|
|
192
|
+
skip_until_outdent = false;
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
if (in_tools) {
|
|
196
|
+
const indent = raw.length - lstrip_spaces(raw).length;
|
|
197
|
+
if (skip_until_outdent && indent > 4) {
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
skip_until_outdent = false;
|
|
201
|
+
const m = _LIST_DASH_RE.exec(raw);
|
|
202
|
+
if (m && indent === 2) {
|
|
203
|
+
const first = m[1];
|
|
204
|
+
current = {};
|
|
205
|
+
tools.push(current);
|
|
206
|
+
const inline = _TOP_KEY_RE.exec(first);
|
|
207
|
+
if (inline) {
|
|
208
|
+
current[inline[1]] = inline[2];
|
|
209
|
+
}
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
const mk = _INDENT_KEY_RE.exec(raw);
|
|
213
|
+
if (mk && current !== null && indent === 4) {
|
|
214
|
+
const key = mk[1];
|
|
215
|
+
const val = mk[2];
|
|
216
|
+
if ((key === "files" || key === "merged_keys") && !val) {
|
|
217
|
+
skip_until_outdent = true;
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
current[key] = val;
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
const m_top = _TOP_KEY_RE.exec(raw);
|
|
225
|
+
if (m_top) {
|
|
226
|
+
const key = m_top[1];
|
|
227
|
+
const value = m_top[2];
|
|
228
|
+
if (key === "deploy_roots" && !value) {
|
|
229
|
+
in_tools = false;
|
|
230
|
+
current = null;
|
|
231
|
+
skip_until_outdent = true;
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
if (key === "schema_version") {
|
|
235
|
+
const parsed = parse_int_strict(value);
|
|
236
|
+
data[key] = parsed === null ? value : parsed;
|
|
237
|
+
} else {
|
|
238
|
+
data[key] = value;
|
|
239
|
+
}
|
|
240
|
+
in_tools = false;
|
|
241
|
+
current = null;
|
|
242
|
+
skip_until_outdent = false;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return data;
|
|
246
|
+
}
|
|
247
|
+
function splitlines(text) {
|
|
248
|
+
const parts = text.split("\n");
|
|
249
|
+
if (parts.length > 0 && parts[parts.length - 1] === "") {
|
|
250
|
+
parts.pop();
|
|
251
|
+
}
|
|
252
|
+
return parts;
|
|
253
|
+
}
|
|
254
|
+
function lstrip_spaces(s) {
|
|
255
|
+
let i = 0;
|
|
256
|
+
while (i < s.length && s[i] === " ") {
|
|
257
|
+
i += 1;
|
|
258
|
+
}
|
|
259
|
+
return s.slice(i);
|
|
260
|
+
}
|
|
261
|
+
function parse_int_strict(value) {
|
|
262
|
+
if (!/^[+-]?\d+$/.test(value.trim())) {
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
return Number.parseInt(value, 10);
|
|
266
|
+
}
|
|
267
|
+
function _render(version, tools, options = {}) {
|
|
268
|
+
const deploy_roots = options.deploy_roots ?? null;
|
|
269
|
+
const lines = [
|
|
270
|
+
`schema_version: ${SCHEMA_VERSION}`,
|
|
271
|
+
`agent_config_version: "${version}"`
|
|
272
|
+
];
|
|
273
|
+
if (deploy_roots && deploy_roots.length > 0) {
|
|
274
|
+
lines.push("deploy_roots:");
|
|
275
|
+
for (const root of deploy_roots) {
|
|
276
|
+
lines.push(` - ${root}`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
lines.push("tools:");
|
|
280
|
+
for (const tool of tools) {
|
|
281
|
+
lines.push(` - name: ${String(tool["name"])}`);
|
|
282
|
+
lines.push(` scope: ${String(tool["scope"])}`);
|
|
283
|
+
lines.push(` bridge_marker: ${String(tool["bridge_marker"])}`);
|
|
284
|
+
lines.push(` installed_at: "${String(tool["installed_at"])}"`);
|
|
285
|
+
const status = tool["status"];
|
|
286
|
+
if (status) {
|
|
287
|
+
lines.push(` status: ${String(status)}`);
|
|
288
|
+
}
|
|
289
|
+
let files = tool["files"] ?? [];
|
|
290
|
+
if (files.length > 0) {
|
|
291
|
+
files = stable_sort(files, (f) => [String(f["path"])]);
|
|
292
|
+
lines.push(" files:");
|
|
293
|
+
for (const entry of files) {
|
|
294
|
+
lines.push(` - path: ${String(entry["path"])}`);
|
|
295
|
+
lines.push(` kind: ${String(entry["kind"])}`);
|
|
296
|
+
const sha = entry["sha256"];
|
|
297
|
+
if (sha === null || sha === void 0) {
|
|
298
|
+
lines.push(" sha256: null");
|
|
299
|
+
} else {
|
|
300
|
+
lines.push(` sha256: "${String(sha)}"`);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
let merged = tool["merged_keys"] ?? [];
|
|
305
|
+
if (merged.length > 0) {
|
|
306
|
+
merged = stable_sort(merged, (e) => [
|
|
307
|
+
String(e["file"]),
|
|
308
|
+
String(e["json_pointer"])
|
|
309
|
+
]);
|
|
310
|
+
lines.push(" merged_keys:");
|
|
311
|
+
for (const entry of merged) {
|
|
312
|
+
lines.push(` - file: ${String(entry["file"])}`);
|
|
313
|
+
lines.push(` json_pointer: "${String(entry["json_pointer"])}"`);
|
|
314
|
+
const vh = entry["value_hash"];
|
|
315
|
+
if (vh !== null && vh !== void 0) {
|
|
316
|
+
lines.push(` value_hash: "${String(vh)}"`);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return lines.join("\n") + "\n";
|
|
322
|
+
}
|
|
323
|
+
function stable_sort(items, key) {
|
|
324
|
+
return items.map((item, index) => ({ item, index, k: key(item) })).sort((a, b) => {
|
|
325
|
+
const len = Math.max(a.k.length, b.k.length);
|
|
326
|
+
for (let i = 0; i < len; i += 1) {
|
|
327
|
+
const av = a.k[i] ?? "";
|
|
328
|
+
const bv = b.k[i] ?? "";
|
|
329
|
+
if (av < bv) return -1;
|
|
330
|
+
if (av > bv) return 1;
|
|
331
|
+
}
|
|
332
|
+
return a.index - b.index;
|
|
333
|
+
}).map((entry) => entry.item);
|
|
334
|
+
}
|
|
335
|
+
function write_manifest(path3, version, tools, options = {}) {
|
|
336
|
+
const rendered = _render(version, tools, { deploy_roots: options.deploy_roots ?? null });
|
|
337
|
+
return write_atomic(path3, rendered);
|
|
338
|
+
}
|
|
339
|
+
var ScopeMismatchError = class extends Error {
|
|
340
|
+
name_;
|
|
341
|
+
recorded_scope;
|
|
342
|
+
new_scope;
|
|
343
|
+
constructor(name, recorded_scope, new_scope) {
|
|
344
|
+
super(
|
|
345
|
+
`tool '${name}' is committed as scope=${recorded_scope}; refusing to change it to scope=${new_scope} without --force`
|
|
346
|
+
);
|
|
347
|
+
this.name = "ScopeMismatchError";
|
|
348
|
+
this.name_ = name;
|
|
349
|
+
this.recorded_scope = recorded_scope;
|
|
350
|
+
this.new_scope = new_scope;
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
function upsert_tool(existing, options) {
|
|
354
|
+
const {
|
|
355
|
+
name,
|
|
356
|
+
scope,
|
|
357
|
+
bridge_marker,
|
|
358
|
+
installed_at = null,
|
|
359
|
+
force = false,
|
|
360
|
+
files = null,
|
|
361
|
+
merged_keys = null
|
|
362
|
+
} = options;
|
|
363
|
+
if (!_VALID_SCOPES.includes(scope)) {
|
|
364
|
+
throw new ValueError(`scope must be one of ${_VALID_SCOPES.join(",")}: '${scope}'`);
|
|
365
|
+
}
|
|
366
|
+
const stamp = installed_at || _today();
|
|
367
|
+
const _build = (prior = null) => {
|
|
368
|
+
const entry = {
|
|
369
|
+
name,
|
|
370
|
+
scope,
|
|
371
|
+
bridge_marker,
|
|
372
|
+
installed_at: stamp
|
|
373
|
+
};
|
|
374
|
+
if (files !== null) {
|
|
375
|
+
entry["files"] = [...files];
|
|
376
|
+
} else if (prior !== null && Array.isArray(prior["files"]) && prior["files"].length > 0) {
|
|
377
|
+
entry["files"] = [...prior["files"]];
|
|
378
|
+
}
|
|
379
|
+
if (merged_keys !== null) {
|
|
380
|
+
entry["merged_keys"] = [...merged_keys];
|
|
381
|
+
} else if (prior !== null && Array.isArray(prior["merged_keys"]) && prior["merged_keys"].length > 0) {
|
|
382
|
+
entry["merged_keys"] = [...prior["merged_keys"]];
|
|
383
|
+
}
|
|
384
|
+
return entry;
|
|
385
|
+
};
|
|
386
|
+
const result = [];
|
|
387
|
+
let found = false;
|
|
388
|
+
for (const entry of existing) {
|
|
389
|
+
if (entry["name"] === name) {
|
|
390
|
+
found = true;
|
|
391
|
+
const recorded = String(entry["scope"] ?? "");
|
|
392
|
+
if (recorded === scope) {
|
|
393
|
+
if (files === null && merged_keys === null) {
|
|
394
|
+
result.push(entry);
|
|
395
|
+
} else {
|
|
396
|
+
const refreshed = _build(entry);
|
|
397
|
+
refreshed["installed_at"] = entry["installed_at"] ?? stamp;
|
|
398
|
+
result.push(refreshed);
|
|
399
|
+
}
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
if (!force) {
|
|
403
|
+
throw new ScopeMismatchError(name, recorded, scope);
|
|
404
|
+
}
|
|
405
|
+
result.push(_build(entry));
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
result.push(entry);
|
|
409
|
+
}
|
|
410
|
+
if (!found) {
|
|
411
|
+
result.push(_build());
|
|
412
|
+
}
|
|
413
|
+
return result;
|
|
414
|
+
}
|
|
415
|
+
var ValueError = class extends Error {
|
|
416
|
+
constructor(message) {
|
|
417
|
+
super(message);
|
|
418
|
+
this.name = "ValueError";
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
function _today() {
|
|
422
|
+
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// src/scripts/_lib/global_deploy_inventory.ts
|
|
426
|
+
var global_deploy_inventory_exports = {};
|
|
427
|
+
__export(global_deploy_inventory_exports, {
|
|
428
|
+
INVENTORY_BASENAME: () => INVENTORY_BASENAME,
|
|
429
|
+
INVENTORY_ENV: () => INVENTORY_ENV,
|
|
430
|
+
SCHEMA_VERSION: () => SCHEMA_VERSION2,
|
|
431
|
+
expected_deploy_files: () => expected_deploy_files,
|
|
432
|
+
inventory_path: () => inventory_path,
|
|
433
|
+
load_inventory: () => load_inventory,
|
|
434
|
+
reap_stale: () => reap_stale,
|
|
435
|
+
reap_tagged_orphans: () => reap_tagged_orphans,
|
|
436
|
+
record_deploy: () => record_deploy,
|
|
437
|
+
save_inventory: () => save_inventory
|
|
438
|
+
});
|
|
439
|
+
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
440
|
+
import * as fs3 from "node:fs";
|
|
441
|
+
import * as os2 from "node:os";
|
|
442
|
+
import * as path2 from "node:path";
|
|
443
|
+
var SCHEMA_VERSION2 = 1;
|
|
444
|
+
var INVENTORY_BASENAME = "deployed-files.json";
|
|
445
|
+
var INVENTORY_ENV = "AGENT_CONFIG_DEPLOY_INVENTORY";
|
|
446
|
+
function expanduser2(p) {
|
|
447
|
+
if (p === "~") {
|
|
448
|
+
return os2.homedir();
|
|
449
|
+
}
|
|
450
|
+
if (p.startsWith("~/") || process.platform === "win32" && p.startsWith("~\\")) {
|
|
451
|
+
return path2.join(os2.homedir(), p.slice(2));
|
|
452
|
+
}
|
|
453
|
+
return p;
|
|
454
|
+
}
|
|
455
|
+
function resolve_path(p) {
|
|
456
|
+
try {
|
|
457
|
+
return fs3.realpathSync(p);
|
|
458
|
+
} catch {
|
|
459
|
+
const abs = path2.resolve(p);
|
|
460
|
+
const parts = abs.split(path2.sep);
|
|
461
|
+
for (let i = parts.length; i > 0; i -= 1) {
|
|
462
|
+
const prefix = parts.slice(0, i).join(path2.sep) || path2.sep;
|
|
463
|
+
try {
|
|
464
|
+
const real = fs3.realpathSync(prefix);
|
|
465
|
+
const rest = parts.slice(i);
|
|
466
|
+
return rest.length > 0 ? path2.join(real, ...rest) : real;
|
|
467
|
+
} catch {
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
return abs;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
function path_exists(p) {
|
|
475
|
+
try {
|
|
476
|
+
fs3.statSync(p);
|
|
477
|
+
return true;
|
|
478
|
+
} catch {
|
|
479
|
+
return false;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
function inventory_path(env) {
|
|
483
|
+
const env_map = env ?? process.env;
|
|
484
|
+
const override = env_map[INVENTORY_ENV];
|
|
485
|
+
if (override) {
|
|
486
|
+
return expanduser2(override);
|
|
487
|
+
}
|
|
488
|
+
return write_target(INVENTORY_BASENAME, { env: env ?? null });
|
|
489
|
+
}
|
|
490
|
+
function load_inventory(p) {
|
|
491
|
+
const target = p ?? inventory_path();
|
|
492
|
+
let data;
|
|
493
|
+
try {
|
|
494
|
+
data = JSON.parse(fs3.readFileSync(target, { encoding: "utf-8" }));
|
|
495
|
+
} catch {
|
|
496
|
+
return { schema_version: SCHEMA_VERSION2, tools: {} };
|
|
497
|
+
}
|
|
498
|
+
if (typeof data !== "object" || data === null || Array.isArray(data) || typeof data["tools"] !== "object" || data["tools"] === null || Array.isArray(data["tools"])) {
|
|
499
|
+
return { schema_version: SCHEMA_VERSION2, tools: {} };
|
|
500
|
+
}
|
|
501
|
+
return data;
|
|
502
|
+
}
|
|
503
|
+
function save_inventory(data, p) {
|
|
504
|
+
const target = p ?? inventory_path();
|
|
505
|
+
fs3.mkdirSync(path2.dirname(target), { recursive: true });
|
|
506
|
+
const payload = json_dumps_sorted(data, 2) + "\n";
|
|
507
|
+
const parent = path2.dirname(target);
|
|
508
|
+
let fd = null;
|
|
509
|
+
let tmp_name = "";
|
|
510
|
+
for (let attempt = 0; attempt < 32; attempt += 1) {
|
|
511
|
+
tmp_name = path2.join(parent, `${path2.basename(target)}.${randomBytes2(6).toString("hex")}`);
|
|
512
|
+
try {
|
|
513
|
+
fd = fs3.openSync(tmp_name, "wx", 384);
|
|
514
|
+
break;
|
|
515
|
+
} catch (err) {
|
|
516
|
+
if (err.code === "EEXIST") {
|
|
517
|
+
continue;
|
|
518
|
+
}
|
|
519
|
+
throw err;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
if (fd === null) {
|
|
523
|
+
throw new Error("save_inventory: could not create a unique temp file");
|
|
524
|
+
}
|
|
525
|
+
try {
|
|
526
|
+
fs3.writeFileSync(fd, payload, { encoding: "utf-8" });
|
|
527
|
+
fs3.closeSync(fd);
|
|
528
|
+
fs3.renameSync(tmp_name, target);
|
|
529
|
+
} catch (err) {
|
|
530
|
+
try {
|
|
531
|
+
fs3.closeSync(fd);
|
|
532
|
+
} catch {
|
|
533
|
+
}
|
|
534
|
+
try {
|
|
535
|
+
fs3.unlinkSync(tmp_name);
|
|
536
|
+
} catch {
|
|
537
|
+
}
|
|
538
|
+
throw err;
|
|
539
|
+
}
|
|
540
|
+
return target;
|
|
541
|
+
}
|
|
542
|
+
function json_dumps_sorted(value, indent) {
|
|
543
|
+
return render_json(value, indent, 0);
|
|
544
|
+
}
|
|
545
|
+
function render_json(value, indent, depth) {
|
|
546
|
+
if (value === null) {
|
|
547
|
+
return "null";
|
|
548
|
+
}
|
|
549
|
+
if (typeof value === "boolean" || typeof value === "number") {
|
|
550
|
+
return JSON.stringify(value);
|
|
551
|
+
}
|
|
552
|
+
if (typeof value === "string") {
|
|
553
|
+
return json_string_ascii(value);
|
|
554
|
+
}
|
|
555
|
+
const pad = " ".repeat(indent * (depth + 1));
|
|
556
|
+
const close_pad = " ".repeat(indent * depth);
|
|
557
|
+
if (Array.isArray(value)) {
|
|
558
|
+
if (value.length === 0) {
|
|
559
|
+
return "[]";
|
|
560
|
+
}
|
|
561
|
+
const items = value.map((v) => pad + render_json(v, indent, depth + 1));
|
|
562
|
+
return "[\n" + items.join(",\n") + "\n" + close_pad + "]";
|
|
563
|
+
}
|
|
564
|
+
if (typeof value === "object") {
|
|
565
|
+
const obj = value;
|
|
566
|
+
const keys = Object.keys(obj).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
567
|
+
if (keys.length === 0) {
|
|
568
|
+
return "{}";
|
|
569
|
+
}
|
|
570
|
+
const items = keys.map(
|
|
571
|
+
(k) => pad + json_string_ascii(k) + ": " + render_json(obj[k], indent, depth + 1)
|
|
572
|
+
);
|
|
573
|
+
return "{\n" + items.join(",\n") + "\n" + close_pad + "}";
|
|
574
|
+
}
|
|
575
|
+
return "null";
|
|
576
|
+
}
|
|
577
|
+
function json_string_ascii(s) {
|
|
578
|
+
const base = JSON.stringify(s);
|
|
579
|
+
let out = "";
|
|
580
|
+
for (let i = 0; i < base.length; i += 1) {
|
|
581
|
+
const code = base.charCodeAt(i);
|
|
582
|
+
if (code > 126) {
|
|
583
|
+
out += "\\u" + code.toString(16).padStart(4, "0");
|
|
584
|
+
} else {
|
|
585
|
+
out += base[i];
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
return out;
|
|
589
|
+
}
|
|
590
|
+
function expected_deploy_files(src, dest_rel) {
|
|
591
|
+
const out = /* @__PURE__ */ new Set();
|
|
592
|
+
let src_stat;
|
|
593
|
+
try {
|
|
594
|
+
src_stat = fs3.statSync(src);
|
|
595
|
+
} catch {
|
|
596
|
+
return out;
|
|
597
|
+
}
|
|
598
|
+
if (!src_stat.isDirectory()) {
|
|
599
|
+
out.add(as_posix(dest_rel));
|
|
600
|
+
return out;
|
|
601
|
+
}
|
|
602
|
+
const _walk = (node, prefix) => {
|
|
603
|
+
const entries = fs3.readdirSync(node).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
604
|
+
for (const name of entries) {
|
|
605
|
+
const entry = path2.join(node, name);
|
|
606
|
+
const rel = join_rel(prefix, name);
|
|
607
|
+
const lst = fs3.lstatSync(entry);
|
|
608
|
+
if (lst.isDirectory() && !lst.isSymbolicLink()) {
|
|
609
|
+
_walk(entry, rel);
|
|
610
|
+
continue;
|
|
611
|
+
}
|
|
612
|
+
let resolved_is_dir = false;
|
|
613
|
+
try {
|
|
614
|
+
resolved_is_dir = fs3.statSync(entry).isDirectory();
|
|
615
|
+
} catch {
|
|
616
|
+
resolved_is_dir = false;
|
|
617
|
+
}
|
|
618
|
+
if (resolved_is_dir) {
|
|
619
|
+
_walk(fs3.realpathSync(entry), rel);
|
|
620
|
+
continue;
|
|
621
|
+
}
|
|
622
|
+
out.add(as_posix(rel));
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
_walk(src, dest_rel);
|
|
626
|
+
return out;
|
|
627
|
+
}
|
|
628
|
+
function join_rel(prefix, name) {
|
|
629
|
+
return prefix ? path2.join(prefix, name) : name;
|
|
630
|
+
}
|
|
631
|
+
function as_posix(p) {
|
|
632
|
+
if (p === "") {
|
|
633
|
+
return ".";
|
|
634
|
+
}
|
|
635
|
+
return p.split(path2.sep).join("/");
|
|
636
|
+
}
|
|
637
|
+
function reap_stale(tool_id, anchor, current_files, inventory, dry_run = false) {
|
|
638
|
+
const tools = inventory["tools"] ?? {};
|
|
639
|
+
const entry = tools[tool_id];
|
|
640
|
+
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) {
|
|
641
|
+
return [];
|
|
642
|
+
}
|
|
643
|
+
const e = entry;
|
|
644
|
+
const recorded_anchor = e["anchor"];
|
|
645
|
+
const prev_files = e["files"];
|
|
646
|
+
if (typeof recorded_anchor !== "string" || !Array.isArray(prev_files)) {
|
|
647
|
+
return [];
|
|
648
|
+
}
|
|
649
|
+
const anchor_resolved = resolve_path(expanduser2(anchor));
|
|
650
|
+
if (resolve_path(expanduser2(recorded_anchor)) !== anchor_resolved) {
|
|
651
|
+
return [];
|
|
652
|
+
}
|
|
653
|
+
const deleted = [];
|
|
654
|
+
const prune_candidates = /* @__PURE__ */ new Set();
|
|
655
|
+
const orphans = difference(prev_files, current_files);
|
|
656
|
+
for (const rel of sorted_strings(orphans)) {
|
|
657
|
+
if (typeof rel !== "string" || !rel || rel.startsWith("/") || rel.startsWith("..")) {
|
|
658
|
+
continue;
|
|
659
|
+
}
|
|
660
|
+
const target = path2.join(anchor_resolved, rel);
|
|
661
|
+
try {
|
|
662
|
+
relative_to(resolve_path(path2.dirname(target)), anchor_resolved);
|
|
663
|
+
} catch {
|
|
664
|
+
continue;
|
|
665
|
+
}
|
|
666
|
+
let lst = null;
|
|
667
|
+
try {
|
|
668
|
+
lst = fs3.lstatSync(target);
|
|
669
|
+
} catch {
|
|
670
|
+
lst = null;
|
|
671
|
+
}
|
|
672
|
+
if (lst && lst.isDirectory() && !lst.isSymbolicLink()) {
|
|
673
|
+
continue;
|
|
674
|
+
}
|
|
675
|
+
if (dry_run) {
|
|
676
|
+
if (path_exists(target) || lst !== null && lst.isSymbolicLink()) {
|
|
677
|
+
deleted.push(target);
|
|
678
|
+
}
|
|
679
|
+
continue;
|
|
680
|
+
}
|
|
681
|
+
try {
|
|
682
|
+
fs3.unlinkSync(target);
|
|
683
|
+
} catch {
|
|
684
|
+
continue;
|
|
685
|
+
}
|
|
686
|
+
deleted.push(target);
|
|
687
|
+
prune_candidates.add(path2.dirname(target));
|
|
688
|
+
}
|
|
689
|
+
prune_empty_dirs(prune_candidates, anchor_resolved);
|
|
690
|
+
return deleted;
|
|
691
|
+
}
|
|
692
|
+
function reap_tagged_orphans(anchor, dest_subs, current_files, package_tag, dry_run = false) {
|
|
693
|
+
const anchor_resolved = resolve_path(expanduser2(anchor));
|
|
694
|
+
const deleted = [];
|
|
695
|
+
const prune_candidates = /* @__PURE__ */ new Set();
|
|
696
|
+
const needle = `package: ${package_tag}`;
|
|
697
|
+
for (const dest_sub of dest_subs) {
|
|
698
|
+
const root = dest_sub ? path2.join(anchor_resolved, dest_sub) : anchor_resolved;
|
|
699
|
+
let root_stat;
|
|
700
|
+
try {
|
|
701
|
+
root_stat = fs3.statSync(root);
|
|
702
|
+
} catch {
|
|
703
|
+
continue;
|
|
704
|
+
}
|
|
705
|
+
if (!root_stat.isDirectory()) {
|
|
706
|
+
continue;
|
|
707
|
+
}
|
|
708
|
+
for (const md of rglob_md(root)) {
|
|
709
|
+
let md_lst;
|
|
710
|
+
try {
|
|
711
|
+
md_lst = fs3.lstatSync(md);
|
|
712
|
+
} catch {
|
|
713
|
+
continue;
|
|
714
|
+
}
|
|
715
|
+
if (md_lst.isDirectory()) {
|
|
716
|
+
continue;
|
|
717
|
+
}
|
|
718
|
+
const rel = relative_to_posix(md, anchor_resolved);
|
|
719
|
+
if (current_files.has(rel)) {
|
|
720
|
+
continue;
|
|
721
|
+
}
|
|
722
|
+
try {
|
|
723
|
+
relative_to(resolve_path(path2.dirname(md)), anchor_resolved);
|
|
724
|
+
} catch {
|
|
725
|
+
continue;
|
|
726
|
+
}
|
|
727
|
+
let head;
|
|
728
|
+
try {
|
|
729
|
+
head = fs3.readFileSync(md, { encoding: "utf-8" });
|
|
730
|
+
} catch {
|
|
731
|
+
continue;
|
|
732
|
+
}
|
|
733
|
+
if (!head.startsWith("---")) {
|
|
734
|
+
continue;
|
|
735
|
+
}
|
|
736
|
+
const end = head.indexOf("\n---", 3);
|
|
737
|
+
const block = head.slice(0, end !== -1 ? end : head.length);
|
|
738
|
+
const hit = splitlines2(block).some((line) => line.trim() === needle);
|
|
739
|
+
if (!hit) {
|
|
740
|
+
continue;
|
|
741
|
+
}
|
|
742
|
+
if (dry_run) {
|
|
743
|
+
deleted.push(md);
|
|
744
|
+
continue;
|
|
745
|
+
}
|
|
746
|
+
try {
|
|
747
|
+
fs3.unlinkSync(md);
|
|
748
|
+
} catch {
|
|
749
|
+
continue;
|
|
750
|
+
}
|
|
751
|
+
deleted.push(md);
|
|
752
|
+
prune_candidates.add(path2.dirname(md));
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
prune_empty_dirs(prune_candidates, anchor_resolved);
|
|
756
|
+
return deleted;
|
|
757
|
+
}
|
|
758
|
+
function record_deploy(tool_id, anchor, current_files, inventory) {
|
|
759
|
+
if (typeof inventory["tools"] !== "object" || inventory["tools"] === null || Array.isArray(inventory["tools"])) {
|
|
760
|
+
inventory["tools"] = {};
|
|
761
|
+
}
|
|
762
|
+
const tools = inventory["tools"];
|
|
763
|
+
tools[tool_id] = {
|
|
764
|
+
anchor: String(anchor),
|
|
765
|
+
files: sorted_strings([...current_files])
|
|
766
|
+
};
|
|
767
|
+
inventory["schema_version"] = SCHEMA_VERSION2;
|
|
768
|
+
return inventory;
|
|
769
|
+
}
|
|
770
|
+
function prune_empty_dirs(prune_candidates, anchor_resolved) {
|
|
771
|
+
const ordered = [...prune_candidates].sort(
|
|
772
|
+
(a, b) => b.split(path2.sep).length - a.split(path2.sep).length
|
|
773
|
+
);
|
|
774
|
+
for (const start of ordered) {
|
|
775
|
+
let node = start;
|
|
776
|
+
while (node !== anchor_resolved && is_ancestor(anchor_resolved, node)) {
|
|
777
|
+
try {
|
|
778
|
+
fs3.rmdirSync(node);
|
|
779
|
+
} catch {
|
|
780
|
+
break;
|
|
781
|
+
}
|
|
782
|
+
node = path2.dirname(node);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
function is_ancestor(anchor, node) {
|
|
787
|
+
const rel = path2.relative(anchor, node);
|
|
788
|
+
return rel !== "" && !rel.startsWith("..") && !path2.isAbsolute(rel);
|
|
789
|
+
}
|
|
790
|
+
function relative_to(child, parent) {
|
|
791
|
+
if (child === parent) {
|
|
792
|
+
return "";
|
|
793
|
+
}
|
|
794
|
+
const rel = path2.relative(parent, child);
|
|
795
|
+
if (rel.startsWith("..") || path2.isAbsolute(rel)) {
|
|
796
|
+
throw new Error(`'${child}' is not in the subpath of '${parent}'`);
|
|
797
|
+
}
|
|
798
|
+
return rel;
|
|
799
|
+
}
|
|
800
|
+
function relative_to_posix(child, parent) {
|
|
801
|
+
return path2.relative(parent, child).split(path2.sep).join("/");
|
|
802
|
+
}
|
|
803
|
+
function rglob_md(root) {
|
|
804
|
+
const out = [];
|
|
805
|
+
const walk = (dir) => {
|
|
806
|
+
let names;
|
|
807
|
+
try {
|
|
808
|
+
names = fs3.readdirSync(dir).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
809
|
+
} catch {
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
812
|
+
for (const name of names) {
|
|
813
|
+
const full = path2.join(dir, name);
|
|
814
|
+
let lst;
|
|
815
|
+
try {
|
|
816
|
+
lst = fs3.lstatSync(full);
|
|
817
|
+
} catch {
|
|
818
|
+
continue;
|
|
819
|
+
}
|
|
820
|
+
if (lst.isDirectory() && !lst.isSymbolicLink()) {
|
|
821
|
+
walk(full);
|
|
822
|
+
} else if (name.endsWith(".md")) {
|
|
823
|
+
out.push(full);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
};
|
|
827
|
+
walk(root);
|
|
828
|
+
return out;
|
|
829
|
+
}
|
|
830
|
+
function difference(prev, current) {
|
|
831
|
+
const seen = /* @__PURE__ */ new Set();
|
|
832
|
+
const out = [];
|
|
833
|
+
for (const item of prev) {
|
|
834
|
+
if (typeof item === "string" && current.has(item)) {
|
|
835
|
+
continue;
|
|
836
|
+
}
|
|
837
|
+
if (seen.has(item)) {
|
|
838
|
+
continue;
|
|
839
|
+
}
|
|
840
|
+
seen.add(item);
|
|
841
|
+
out.push(item);
|
|
842
|
+
}
|
|
843
|
+
return out;
|
|
844
|
+
}
|
|
845
|
+
function sorted_strings(items) {
|
|
846
|
+
return items.filter((i) => typeof i === "string").sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
847
|
+
}
|
|
848
|
+
function splitlines2(text) {
|
|
849
|
+
const parts = text.split("\n");
|
|
850
|
+
if (parts.length > 0 && parts[parts.length - 1] === "") {
|
|
851
|
+
parts.pop();
|
|
852
|
+
}
|
|
853
|
+
return parts;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
export {
|
|
857
|
+
write_atomic,
|
|
858
|
+
SCHEMA_VERSIONS_SUPPORTED,
|
|
859
|
+
DEFAULT_DEPLOY_ROOTS,
|
|
860
|
+
manifest_path,
|
|
861
|
+
read_manifest,
|
|
862
|
+
write_manifest,
|
|
863
|
+
ScopeMismatchError,
|
|
864
|
+
upsert_tool,
|
|
865
|
+
load_inventory,
|
|
866
|
+
save_inventory,
|
|
867
|
+
expected_deploy_files,
|
|
868
|
+
reap_stale,
|
|
869
|
+
reap_tagged_orphans,
|
|
870
|
+
record_deploy,
|
|
871
|
+
global_deploy_inventory_exports
|
|
872
|
+
};
|