@event4u/agent-config 3.3.0 → 4.2.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/.agent-src/README.md +2 -2
- package/.agent-src/commands/agent-handoff.md +31 -2
- package/.agent-src/commands/agent-status.md +5 -5
- package/.agent-src/commands/agents/audit.md +8 -8
- package/.agent-src/commands/agents/init.md +25 -1
- package/.agent-src/commands/agents/optimize.md +3 -3
- package/.agent-src/commands/agents/user.md +1 -1
- package/.agent-src/commands/agents.md +1 -1
- package/.agent-src/commands/analyze-reference-repo.md +1 -1
- package/.agent-src/commands/check-current-md.md +8 -8
- package/.agent-src/commands/{compress.md → condense.md} +55 -55
- package/.agent-src/commands/context/create.md +7 -4
- package/.agent-src/commands/context/refactor.md +3 -1
- package/.agent-src/commands/feature/dev.md +1 -1
- package/.agent-src/commands/feature/explore.md +1 -1
- package/.agent-src/commands/feature/plan.md +10 -8
- package/.agent-src/commands/feature/refactor.md +3 -1
- package/.agent-src/commands/feature/roadmap.md +7 -4
- package/.agent-src/commands/fix/portability.md +3 -3
- package/.agent-src/commands/fix/refs.md +4 -4
- package/.agent-src/commands/ghostwriter.md +2 -2
- package/.agent-src/commands/memory/learn-low-impact.md +3 -3
- package/.agent-src/commands/module/explore.md +34 -8
- package/.agent-src/commands/optimize/agents-dir.md +9 -7
- package/.agent-src/commands/optimize/augmentignore.md +2 -2
- package/.agent-src/commands/optimize/skills.md +9 -9
- package/.agent-src/commands/post-as.md +1 -1
- package/.agent-src/commands/project-analyze.md +2 -2
- package/.agent-src/commands/project-health.md +3 -2
- package/.agent-src/commands/research/deep.md +1 -1
- package/.agent-src/commands/research/report.md +1 -1
- package/.agent-src/commands/research.md +1 -1
- package/.agent-src/commands/roadmap/ai-council.md +1 -1
- package/.agent-src/commands/roadmap/create.md +9 -4
- package/.agent-src/commands/rule-compliance-audit.md +1 -1
- package/.agent-src/commands/upstream-contribute.md +14 -14
- package/.agent-src/commands/video/from-script.md +1 -1
- package/.agent-src/commands/video/scene.md +1 -1
- package/.agent-src/commands/video/stitch.md +1 -1
- package/.agent-src/commands/video/storyboard.md +1 -1
- package/.agent-src/commands/video.md +1 -1
- package/.agent-src/contexts/augment-infrastructure.md +1 -1
- package/.agent-src/contexts/authority/commit-mechanics.md +15 -0
- package/.agent-src/contexts/authority/kernel-rule-edits.md +3 -3
- package/.agent-src/contexts/authority/scope-mechanics.md +1 -1
- package/.agent-src/contexts/communication/rules-auto/augment-source-of-truth-mechanics.md +28 -28
- package/.agent-src/contexts/communication/rules-auto/skill-quality-mechanics.md +4 -4
- package/.agent-src/contexts/communication/rules-auto/think-before-action-mechanics.md +2 -2
- package/.agent-src/contexts/contracts/artifact-engagement-flow.md +6 -6
- package/.agent-src/contexts/contracts/command-suggestion-flow.md +3 -3
- package/.agent-src/contexts/contracts/emergency-triage-block.md +4 -4
- package/.agent-src/contexts/contracts/frugality-charter.md +3 -3
- package/.agent-src/contexts/documentation-hierarchy.md +14 -7
- package/.agent-src/contexts/execution/autonomy-examples.md +1 -1
- package/.agent-src/contexts/execution/cheap-question-mechanics.md +39 -2
- package/.agent-src/contexts/execution/roadmap-process-loop.md +28 -5
- package/.agent-src/contexts/override-system.md +5 -5
- package/.agent-src/ghostwriter/fictional-fixture-v1.md +1 -1
- package/.agent-src/personas/advisors/first-principles.md +1 -1
- package/.agent-src/personas/hollywood-director.md +1 -1
- package/.agent-src/rules/architecture.md +5 -1
- package/.agent-src/rules/augment-edit-discipline.md +5 -5
- package/.agent-src/rules/augment-source-of-truth.md +15 -15
- package/.agent-src/rules/commit-conventions.md +1 -1
- package/.agent-src/rules/commit-policy.md +10 -0
- package/.agent-src/rules/domain-adoption-policy.md +3 -3
- package/.agent-src/rules/fast-path-marker-visibility.md +3 -3
- package/.agent-src/rules/finance-safety-floor.md +1 -1
- package/.agent-src/rules/framework-neutrality-in-generic-skills.md +8 -8
- package/.agent-src/rules/git-history-discipline.md +1 -1
- package/.agent-src/rules/improve-before-implement.md +2 -2
- package/.agent-src/rules/language-and-tone.md +2 -2
- package/.agent-src/rules/media-governance-routing.md +5 -5
- package/.agent-src/rules/no-attribution-footers.md +1 -0
- package/.agent-src/rules/no-cheap-questions.md +3 -0
- package/.agent-src/rules/no-decorative-emojis-in-git-surfaces.md +111 -0
- package/.agent-src/rules/no-pr-progress-comments.md +118 -0
- package/.agent-src/rules/no-roadmap-references.md +3 -3
- package/.agent-src/rules/non-destructive-by-default.md +1 -1
- package/.agent-src/rules/persona-governance.md +3 -3
- package/.agent-src/rules/preservation-guard.md +15 -15
- package/.agent-src/rules/roadmap-ci-steps-policy.md +7 -3
- package/.agent-src/rules/rule-type-governance.md +1 -1
- package/.agent-src/rules/skill-quality.md +1 -1
- package/.agent-src/rules/{caveman-speak.md → telegraph-speak.md} +15 -15
- package/.agent-src/rules/token-optimizer-maintenance.md +6 -6
- package/.agent-src/skills/agent-docs-writing/SKILL.md +17 -11
- package/.agent-src/skills/agents-md-thin-root/SKILL.md +9 -9
- package/.agent-src/skills/check-refs/SKILL.md +2 -2
- package/.agent-src/skills/code-refactoring/SKILL.md +2 -2
- package/.agent-src/skills/command-writing/SKILL.md +19 -19
- package/.agent-src/skills/comp-banding/SKILL.md +1 -1
- package/.agent-src/skills/condense-memory/SKILL.md +131 -0
- package/.agent-src/skills/context-authoring/SKILL.md +2 -2
- package/.agent-src/skills/context-document/SKILL.md +5 -3
- package/.agent-src/skills/copilot-agents-optimization/SKILL.md +3 -3
- package/.agent-src/skills/description-assist/SKILL.md +2 -2
- package/.agent-src/skills/git-workflow/SKILL.md +1 -1
- package/.agent-src/skills/guideline-writing/SKILL.md +5 -5
- package/.agent-src/skills/learning-to-rule-or-skill/SKILL.md +4 -4
- package/.agent-src/skills/lint-skills/SKILL.md +3 -3
- package/.agent-src/skills/md-language-check/SKILL.md +2 -2
- package/.agent-src/skills/module-detect-on-the-fly/SKILL.md +138 -0
- package/.agent-src/skills/module-management/SKILL.md +166 -94
- package/.agent-src/skills/override-management/SKILL.md +1 -1
- package/.agent-src/skills/persona-writing/SKILL.md +5 -5
- package/.agent-src/skills/positioning-strategy/SKILL.md +1 -1
- package/.agent-src/skills/project-docs/SKILL.md +6 -4
- package/.agent-src/skills/readme-reviewer/SKILL.md +2 -2
- package/.agent-src/skills/roadmap-management/SKILL.md +13 -1
- package/.agent-src/skills/roadmap-writing/SKILL.md +4 -2
- package/.agent-src/skills/rule-refactor/SKILL.md +5 -5
- package/.agent-src/skills/rule-writing/SKILL.md +18 -18
- package/.agent-src/skills/script-writing/SKILL.md +1 -1
- package/.agent-src/skills/skill-improvement-pipeline/SKILL.md +6 -6
- package/.agent-src/skills/skill-management/SKILL.md +21 -21
- package/.agent-src/skills/skill-reviewer/SKILL.md +2 -2
- package/.agent-src/skills/skill-writing/SKILL.md +8 -8
- package/.agent-src/skills/skill-writing/evals/triggers.json +1 -1
- package/.agent-src/skills/token-optimizer/SKILL.md +4 -4
- package/.agent-src/skills/unit-economics-modeling/SKILL.md +1 -1
- package/.agent-src/skills/upstream-contribute/SKILL.md +17 -17
- package/.agent-src/templates/AGENTS.md +1 -0
- package/.agent-src/templates/agent-settings.md +24 -13
- package/.agent-src/templates/agents/agent-project-settings.example.yml +61 -2
- package/.agent-src/templates/command.md +5 -5
- package/.agent-src/templates/contexts.md +1 -1
- package/.agent-src/templates/copilot-instructions.md +8 -8
- package/.agent-src/templates/features.md +1 -1
- package/.agent-src/templates/hooks/pre-commit-frontmatter +2 -2
- package/.agent-src/templates/hooks/pre-commit-roadmap-progress +3 -3
- package/.agent-src/templates/persona.md +2 -2
- package/.agent-src/templates/roadmaps.md +1 -1
- package/.agent-src/templates/rule.md +13 -13
- package/.agent-src/templates/scripts/memory_lookup.py +1 -1
- package/.agent-src/templates/scripts/memory_status.py +2 -2
- package/.agent-src/templates/scripts/work_engine/_lib/agent_settings.py +195 -1
- package/.agent-src/templates/scripts/work_engine/orchestration.py +1 -1
- package/.agent-src/templates/skill-archive-note.md +5 -5
- package/.agent-src/templates/skill.md +1 -1
- package/.claude-plugin/marketplace.json +4 -4
- package/AGENTS.md +16 -17
- package/CHANGELOG.md +216 -3
- package/CONTRIBUTING.md +31 -12
- package/README.md +21 -12
- package/config/agent-settings.template.yml +22 -2
- package/config/discovery/unassigned-artefacts.yml +24 -24
- package/config/profiles/full.ini +1 -1
- package/dist/cli/agent-config.js +52 -3
- package/dist/cli/agent-config.js.map +1 -1
- package/dist/cli/commands/uiServe.js +9 -0
- package/dist/cli/commands/uiServe.js.map +1 -1
- package/dist/cli/registry.js +2 -1
- package/dist/cli/registry.js.map +1 -1
- package/dist/discovery/deprecation-report.md +1 -1
- package/dist/discovery/discovery-manifest.json +649 -606
- 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 +439 -437
- package/dist/discovery/trust-report.md +5 -5
- package/dist/discovery/workspaces.json +450 -448
- package/dist/install/atomic.js +92 -0
- package/dist/install/atomic.js.map +1 -0
- package/dist/install/conflict.js +196 -0
- package/dist/install/conflict.js.map +1 -0
- package/dist/install/detect.js +218 -0
- package/dist/install/detect.js.map +1 -0
- package/dist/install/paths.js +82 -0
- package/dist/install/paths.js.map +1 -0
- package/dist/install/plan.js +157 -0
- package/dist/install/plan.js.map +1 -0
- package/dist/install/txlog.js +140 -0
- package/dist/install/txlog.js.map +1 -0
- package/dist/install/types.js +19 -0
- package/dist/install/types.js.map +1 -0
- package/dist/install/wizard-plan.js +184 -0
- package/dist/install/wizard-plan.js.map +1 -0
- package/dist/mcp/registry-manifest.json +4 -4
- package/dist/router.json +67 -19
- package/dist/server/app.js +6 -0
- package/dist/server/app.js.map +1 -1
- package/dist/server/routes/install.js +358 -0
- package/dist/server/routes/install.js.map +1 -0
- package/dist/server/routes/wizard.js +468 -32
- package/dist/server/routes/wizard.js.map +1 -1
- package/dist/server/routes/workspace.js +396 -0
- package/dist/server/routes/workspace.js.map +1 -0
- package/dist/server/schemas/settings.js +5 -3
- package/dist/server/schemas/settings.js.map +1 -1
- package/dist/ui/assets/index-BDAhhpDV.js +40 -0
- package/dist/ui/assets/index-BDAhhpDV.js.map +1 -0
- package/dist/ui/assets/index-BXZILUxe.css +1 -0
- package/dist/ui/index.html +2 -2
- package/docs/MIGRATION.md +1 -1
- package/docs/adrs/cost/0001-hard-stop-hook.md +1 -1
- package/docs/adrs/router/0001-three-tier-routing.md +4 -4
- package/docs/adrs/schema/0001-json-schema-frontmatter.md +1 -1
- package/docs/adrs/smoke/0001-per-tier-smoke-scripts.md +4 -4
- package/docs/adrs/{caveman → telegraph}/0001-default-off-until-bench.md +9 -9
- package/docs/adrs/telegraph/README.md +9 -0
- package/docs/architecture/augment-projection.md +4 -4
- package/docs/architecture/claude-bundle.md +1 -1
- package/docs/architecture/current-onboard-baseline.md +3 -3
- package/docs/architecture/multi-tool-projection.md +10 -10
- package/docs/architecture/source-projection.md +27 -27
- package/docs/architecture.md +19 -15
- package/docs/archive/CHANGELOG-pre-2.11.0.md +2 -2
- package/docs/archive/CHANGELOG-pre-2.15.0.md +3 -3
- package/docs/archive/CHANGELOG-pre-2.16.0.md +1 -1
- package/docs/archive/CHANGELOG-pre-2.2.0.md +70 -70
- package/docs/archive/CHANGELOG-pre-2.20.0.md +2 -2
- package/docs/archive/CHANGELOG-pre-2.25.0.md +15 -15
- package/docs/archive/CHANGELOG-pre-3.0.0.md +4 -4
- package/docs/archive/CHANGELOG-pre-3.1.0.md +2 -2
- package/docs/archive/CHANGELOG-pre-3.2.0.md +3 -3
- package/docs/benchmark.md +65 -0
- package/docs/benchmarks.md +16 -16
- package/docs/catalog.md +17 -15
- package/docs/contracts/CHANGELOG-conventions.md +1 -1
- package/docs/contracts/STABILITY.md +2 -2
- package/docs/contracts/adoption-signal-floor.md +110 -0
- package/docs/contracts/adr-chat-history-split.md +4 -4
- package/docs/contracts/adr-command-suggestion.md +4 -4
- package/docs/contracts/adr-gtm-context-spine.md +1 -1
- package/docs/contracts/adr-implement-ticket-runtime.md +4 -4
- package/docs/contracts/adr-install-user-type-axis.md +1 -1
- package/docs/contracts/adr-layout.md +2 -2
- package/docs/contracts/adr-product-ui-track.md +10 -10
- package/docs/contracts/adr-user-types-axis.md +3 -3
- package/docs/contracts/adr-wing4-context-spine.md +1 -1
- package/docs/contracts/agent-memory-contract.md +3 -3
- package/docs/contracts/agents-md-tech-stack.md +2 -2
- package/docs/contracts/ai-council-config.md +2 -2
- package/docs/contracts/at-rest-encryption.md +4 -0
- package/docs/contracts/audit-log-v1.md +1 -1
- package/docs/contracts/benchmark-ab-contract.md +101 -0
- package/docs/contracts/benchmark-corpus-spec.md +1 -1
- package/docs/contracts/branch-protection-policy.md +98 -0
- package/docs/contracts/ci-cost-budget.md +106 -0
- package/docs/contracts/ci-green-floor.md +141 -0
- package/docs/contracts/command-clusters.md +6 -6
- package/docs/contracts/command-surface-tiers.md +2 -2
- package/docs/contracts/command-taxonomy.md +2 -2
- package/docs/contracts/{compression-default-kill-criterion.md → condensation-default-kill-criterion.md} +29 -29
- package/docs/contracts/config-presets.md +1 -1
- package/docs/contracts/context-paths.md +3 -3
- package/docs/contracts/context-spine.md +1 -1
- package/docs/contracts/cost-summary-schema.md +12 -12
- package/docs/contracts/cross-wing-handoff.md +4 -4
- package/docs/contracts/daily-workspace.md +4 -0
- package/docs/contracts/decision-trace-v1.md +2 -2
- package/docs/contracts/discovery-manifest.md +4 -4
- package/docs/contracts/explain-modes.md +4 -0
- package/docs/contracts/file-ownership-matrix.json +3493 -3318
- package/docs/contracts/file-ownership-matrix.md +3 -3
- package/docs/contracts/frontmatter-contract.md +4 -4
- package/docs/contracts/ghostwriter-schema.md +3 -3
- package/docs/contracts/gui-wizard.md +110 -97
- package/docs/contracts/harness-expectations.md +123 -0
- package/docs/contracts/host-agent-protocol.md +4 -0
- package/docs/contracts/implement-ticket-flow.md +9 -9
- package/docs/contracts/install-scopes.md +77 -0
- package/docs/contracts/iron-law-overrides.txt +1 -1
- package/docs/contracts/kernel-membership.md +26 -26
- package/docs/contracts/linear-ai-rules-inclusion.md +1 -1
- package/docs/contracts/linter-structural-model.md +2 -2
- package/docs/contracts/load-context-budget-model.md +4 -4
- package/docs/contracts/load-context-schema.md +13 -13
- package/docs/contracts/local-analytics.md +4 -0
- package/docs/contracts/local-knowledge-ingestion.md +1 -1
- package/docs/contracts/mcp-cloud-scope.md +2 -2
- package/docs/contracts/mcp-phase-1-scope.md +3 -3
- package/docs/contracts/measurement-baseline.md +5 -5
- package/docs/contracts/mental-models.md +30 -30
- package/docs/contracts/multi-tool-projection-fidelity.md +4 -4
- package/docs/contracts/namespace.md +4 -4
- package/docs/contracts/orchestration-dsl-v1.md +7 -7
- package/docs/contracts/package-self-orientation.md +12 -12
- package/docs/contracts/persona-schema.md +6 -6
- package/docs/contracts/pilot/language-and-tone.md +1 -1
- package/docs/contracts/plain-language-surface.md +117 -0
- package/docs/contracts/profile-system.md +3 -3
- package/docs/contracts/release-pr-gating.md +103 -0
- package/docs/contracts/role-experience.md +3 -3
- package/docs/contracts/rule-classification.md +13 -13
- package/docs/contracts/rule-interactions.md +4 -4
- package/docs/contracts/rule-interactions.yml +30 -30
- package/docs/contracts/rule-priority-hierarchy.md +13 -13
- package/docs/contracts/rule-router.md +2 -2
- package/docs/contracts/safety-model.md +1 -1
- package/docs/contracts/skill-distribution-channels.md +61 -0
- package/docs/contracts/skill-domains.md +2 -2
- package/docs/contracts/smoke-contracts.md +5 -5
- package/docs/contracts/telegraph-telemetry.md +83 -0
- package/docs/contracts/trust-and-safety.md +5 -5
- package/docs/contracts/ui-stack-extension.md +7 -7
- package/docs/contracts/ui-track-flow.md +9 -9
- package/docs/contracts/user-type-schema.md +4 -4
- package/docs/contracts/workflow-packs.md +4 -4
- package/docs/contracts/workspace-documents.md +4 -0
- package/docs/customization.md +28 -8
- package/docs/decisions/ADR-001-kernel-swap-deferred.md +6 -6
- package/docs/decisions/ADR-002-kernel-bucket-overrides.md +11 -11
- package/docs/decisions/ADR-003-flat-cluster-subs-and-colon-syntax.md +2 -2
- package/docs/decisions/ADR-004-rule-governance-pruning.md +4 -4
- package/docs/decisions/ADR-005-subagent-worktrees.md +7 -7
- package/docs/decisions/ADR-011-domain-pack-readiness.md +6 -6
- package/docs/decisions/ADR-013-discovery-frontmatter-contract.md +3 -3
- package/docs/decisions/ADR-015-discovery-manifest-contract.md +3 -3
- package/docs/decisions/ADR-017-monorepo-physical-layout.md +10 -10
- package/docs/decisions/ADR-018-trust-and-safety-layer.md +6 -6
- package/docs/decisions/ADR-019-router-json-dist-location.md +2 -2
- package/docs/decisions/ADR-020-global-only-consumer-scope.md +2 -2
- package/docs/decisions/ADR-021-deployment-shape.md +3 -3
- package/docs/decisions/ADR-022-daily-workspace-decomposition.md +1 -1
- package/docs/decisions/ADR-027-changelog-machine-vs-manual.md +2 -2
- package/docs/decisions/ADR-028-root-layout.md +7 -7
- package/docs/decisions/ADR-029-multi-workspace-deferred.md +2 -2
- package/docs/decisions/ADR-rule-kernel-and-router.md +5 -5
- package/docs/deploy/connector-setup.md +2 -2
- package/docs/deploy/policy-cookbook.md +2 -2
- package/docs/deploy/team-deployment-posture.md +20 -0
- package/docs/development.md +17 -17
- package/docs/distribution/registries.md +32 -0
- package/docs/distribution/registry-submissions.md +85 -0
- package/docs/distribution/telemetry-schema.md +1 -1
- package/docs/getting-started-by-role.md +45 -3
- package/docs/getting-started.md +2 -2
- package/docs/guidelines/agent-infra/5w2h-analysis.md +3 -3
- package/docs/guidelines/agent-infra/ask-when-uncertain-demos.md +1 -1
- package/docs/guidelines/agent-infra/asking-and-brevity-examples.md +3 -3
- package/docs/guidelines/agent-infra/carve-out-predicates.md +3 -3
- package/docs/guidelines/agent-infra/critical-thinking.md +4 -4
- package/docs/guidelines/agent-infra/direct-answers-demos.md +1 -1
- package/docs/guidelines/agent-infra/first-principles.md +2 -2
- package/docs/guidelines/agent-infra/inversion-thinking.md +5 -5
- package/docs/guidelines/agent-infra/layered-settings.md +56 -2
- package/docs/guidelines/agent-infra/mental-models.md +3 -3
- package/docs/guidelines/agent-infra/roadmap-progress-mechanics.md +2 -2
- package/docs/guidelines/agent-infra/rule-type-governance.md +1 -1
- package/docs/guidelines/agent-infra/scqa-framework.md +5 -5
- package/docs/guidelines/agent-infra/self-improvement-pipeline.md +2 -2
- package/docs/guidelines/agent-infra/six-hats.md +3 -3
- package/docs/guidelines/agent-infra/skill-quality-checklist.md +5 -5
- package/docs/guidelines/agent-infra/systems-thinking.md +1 -1
- package/docs/guidelines/agent-infra/verify-before-complete-demos.md +1 -1
- package/docs/guidelines/augment-portability-patterns.md +4 -4
- package/docs/guidelines/cross-role-handoff.md +2 -2
- package/docs/guidelines/php/php-coding-patterns.md +1 -1
- package/docs/guidelines/prompt-templates.md +6 -6
- package/docs/maintainers/dev-mode.md +1 -1
- package/docs/mcp.md +1 -1
- package/docs/parity/bench.json +3 -3
- package/docs/parity/ruflo.md +2 -2
- package/docs/profiles.md +11 -11
- package/docs/quality.md +11 -11
- package/docs/safety.md +3 -3
- package/docs/setup/mcp-client-config.md +1 -1
- package/docs/setup/mcp-r2-bootstrap.md +1 -1
- package/docs/setup/mcp-server-docker.md +3 -3
- package/docs/setup/per-ide/windsurf.md +1 -1
- package/docs/skills-catalog.md +8 -7
- package/docs/troubleshooting.md +1 -1
- package/docs/walkthroughs/daily-workspace-a11y.md +87 -0
- package/llms.txt +7 -6
- package/package.json +1 -1
- package/scripts/__pycache__/validate_frontmatter.cpython-312.pyc +0 -0
- package/scripts/_archive/README.md +2 -2
- package/scripts/_archive/_backfill_skill_domains.py +3 -3
- package/scripts/_archive/_bootstrap_tier_frontmatter.py +3 -3
- package/scripts/_archive/_p43_bodies.py +10 -10
- package/scripts/_archive/{_p43_compress.py → _p43_condense.py} +5 -5
- package/scripts/_archive/_p4_migrate.py +7 -7
- package/scripts/_archive/_phase2_shim_helper.py +1 -1
- package/scripts/_archive/_pilot_council_question.py +5 -5
- package/scripts/_cli/explain_last/inputs.py +1 -1
- package/scripts/_lib/__pycache__/__init__.cpython-312.pyc +0 -0
- package/scripts/_lib/__pycache__/agent_src.cpython-312.pyc +0 -0
- package/scripts/_lib/agent_settings.py +195 -1
- package/scripts/_lib/agent_src.py +19 -19
- package/scripts/_lib/bench_ab_cache.py +162 -0
- package/scripts/_lib/bench_ab_scoring.py +209 -0
- package/scripts/_lib/{bench_caveman.py → bench_telegraph.py} +21 -21
- package/scripts/_lib/{bench_caveman_report.py → bench_telegraph_report.py} +21 -21
- package/scripts/_lib/claude_desktop_bundler.py +5 -5
- package/scripts/_lib/module_detection.py +223 -0
- package/scripts/_lib/scope_guard.sh +162 -0
- package/scripts/_phase4_bucket.py +3 -3
- package/scripts/_pilot_measure.py +4 -4
- package/scripts/_tmp_scan_framework_leakage.py +1 -1
- package/scripts/adoption_report.py +195 -0
- package/scripts/adoption_snapshot.py +219 -0
- package/scripts/adoption_status.py +166 -0
- package/scripts/ai-video/lib/parse-blueprint.sh +1 -1
- package/scripts/ai_council/advisors.py +5 -5
- package/scripts/ai_council/compile_corpus.py +1 -1
- package/scripts/ai_council/one_off_archive/2026-05/_one_off_budget_v2_audit.py +3 -3
- package/scripts/ai_council/one_off_archive/2026-05/_one_off_context_layer_v1_review.py +2 -2
- package/scripts/ai_council/one_off_archive/2026-05/_one_off_inject_quiet_flag.py +1 -1
- package/scripts/ai_council/one_off_archive/2026-05/_one_off_measure_v2.sh +1 -1
- package/scripts/ai_council/one_off_archive/2026-05/_one_off_measure_verbosity.sh +1 -1
- package/scripts/ai_council/one_off_archive/2026-05/_one_off_nondestructive_inline_audit.py +3 -3
- package/scripts/ai_council/one_off_archive/2026-05/_one_off_per_task.sh +1 -1
- package/scripts/ai_council/one_off_archive/2026-05/_one_off_phase6_trigger_jaccard.py +1 -1
- package/scripts/ai_council/one_off_archive/2026-05/_one_off_phase_2a_budget_rebalance.py +6 -6
- package/scripts/ai_council/one_off_archive/2026-05/_one_off_rebalancing_audit.py +1 -1
- package/scripts/ai_council/one_off_archive/2026-05/_one_off_tier_retrofit.py +6 -6
- package/scripts/annotate_discovery.py +13 -13
- package/scripts/apply_modules_config.py +290 -0
- package/scripts/audit_adr_coverage.py +2 -2
- package/scripts/audit_auto_rules.py +2 -2
- package/scripts/audit_cloud_compatibility.py +3 -3
- package/scripts/audit_command_surface.py +9 -9
- package/scripts/audit_likelihood.py +2 -2
- package/scripts/audit_user_type_axis.py +2 -2
- package/scripts/bench_ab_cache_dispatch.py +68 -0
- package/scripts/bench_ab_clone.py +170 -0
- package/scripts/bench_ab_diff.py +227 -0
- package/scripts/bench_ab_integrity.py +143 -0
- package/scripts/bench_ab_run.py +235 -0
- package/scripts/bench_ab_task_runner.py +369 -0
- package/scripts/bench_ab_tracka_run.py +202 -0
- package/scripts/{bench_compress_memory.py → bench_condense_memory.py} +16 -16
- package/scripts/bench_run.py +33 -33
- package/scripts/bench_runner.py +2 -2
- package/scripts/bootstrap.sh +99 -0
- package/scripts/build_cloud_bundle.py +6 -6
- package/scripts/build_discovery_manifest.py +7 -7
- package/scripts/build_linear_digest.py +3 -3
- package/scripts/build_rule_trigger_matrix.py +8 -8
- package/scripts/chat_history.py +5 -5
- package/scripts/check_always_budget.py +11 -5
- package/scripts/check_augment_description_cap.py +3 -3
- package/scripts/check_cluster_patterns.py +2 -2
- package/scripts/check_command_count_messaging.py +3 -3
- package/scripts/{check_compression.py → check_condensation.py} +34 -34
- package/scripts/{check_compressed_paths.py → check_condensed_paths.py} +8 -8
- package/scripts/check_context_paths.py +7 -7
- package/scripts/check_council_layout.py +2 -2
- package/scripts/check_council_references.py +9 -9
- package/scripts/check_iron_law_prominence.py +2 -2
- package/scripts/check_kernel_rule_bundle.py +2 -2
- package/scripts/check_module_management_neutral.py +149 -0
- package/scripts/check_no_roadmap_refs.py +9 -9
- package/scripts/check_portability.py +3 -3
- package/scripts/check_public_catalog_links.py +4 -4
- package/scripts/check_references.py +7 -6
- package/scripts/check_release_pr_shape.py +112 -0
- package/scripts/check_reply_consistency.py +3 -3
- package/scripts/check_safety_floor_untouched.py +1 -1
- package/scripts/check_template_pin_drift.py +5 -5
- package/scripts/check_token_optimizer_freshness.py +3 -3
- package/scripts/ci_status.py +301 -0
- package/scripts/ci_time_ratio.py +1 -1
- package/scripts/cleanup_other_scope.sh +146 -0
- package/scripts/compile_router.py +10 -10
- package/scripts/{compress.py → condense.py} +64 -64
- package/scripts/condense.sh +18 -0
- package/scripts/{compress_memory.py → condense_memory.py} +33 -33
- package/scripts/config/presets.py +2 -2
- package/scripts/config/profiles.py +1 -1
- package/scripts/cost_by_conversation.py +3 -3
- package/scripts/cost_summary.py +7 -7
- package/scripts/count_token_optimizer_usage.sh +1 -1
- package/scripts/gen_discovery_baseline.py +5 -5
- package/scripts/generate_index.py +6 -6
- package/scripts/generate_ownership_matrix.py +10 -10
- package/scripts/generate_pack_manifests.py +1 -1
- package/scripts/ghostwriter_fixture_allowlist.txt +1 -1
- package/scripts/install +3 -3
- package/scripts/install-hooks.sh +6 -6
- package/scripts/install.py +273 -45
- package/scripts/install.sh +187 -1
- package/scripts/inventory_frontmatter.py +2 -2
- package/scripts/iron_law_sha.py +3 -3
- package/scripts/lint_agents_layout.py +14 -7
- package/scripts/lint_agents_md.py +4 -4
- package/scripts/lint_archived_skills.py +3 -3
- package/scripts/lint_artefact_frontmatter.py +2 -2
- package/scripts/lint_bench_ab.py +172 -0
- package/scripts/lint_bench_corpus.py +1 -1
- package/scripts/lint_command_tiers.py +5 -5
- package/scripts/lint_context_spine_usage.py +1 -1
- package/scripts/lint_framework_leakage.py +7 -7
- package/scripts/lint_framework_leakage_allowlist.json +152 -84
- package/scripts/lint_ghostwriter_source.py +3 -3
- package/scripts/lint_handoffs.py +1 -1
- package/scripts/lint_load_context.py +11 -11
- package/scripts/lint_media_policy_linkage.py +5 -5
- package/scripts/lint_namespace.py +1 -1
- package/scripts/lint_no_new_atomic_commands.py +2 -2
- package/scripts/lint_orchestration_dsl.py +1 -1
- package/scripts/lint_pack_boundaries.py +2 -2
- package/scripts/lint_persona_governance.py +4 -4
- package/scripts/lint_role_experiences.py +237 -0
- package/scripts/lint_rule_interactions.py +2 -2
- package/scripts/lint_rule_tiers.py +1 -1
- package/scripts/lint_trust_coherence.py +2 -2
- package/scripts/mcp_registry_submit.sh +187 -0
- package/scripts/mcp_server/tools.py +1 -1
- package/scripts/measure_frugality_savings.py +10 -10
- package/scripts/measure_patterns.py +1 -1
- package/scripts/measure_projection_bytes.py +5 -5
- package/scripts/measure_rule_budget.py +3 -3
- package/scripts/measure_skill_reduction.py +1 -1
- package/scripts/memory_lookup.py +1 -1
- package/scripts/memory_status.py +2 -2
- package/scripts/migrate_command_suggestions.py +3 -3
- package/scripts/mine_session.py +1 -1
- package/scripts/move_artefact.py +3 -3
- package/scripts/new_skill.py +2 -2
- package/scripts/pack_mcp_content.py +9 -9
- package/scripts/plan_physical_move.py +6 -6
- package/scripts/print_required_checks.py +196 -0
- package/scripts/probe_skill_registration.py +413 -0
- package/scripts/propose_modules_config.py +145 -0
- package/scripts/prototype_lint_contradictions.py +1 -1
- package/scripts/recruit_preflight.sh +152 -0
- package/scripts/refine_ticket_detect.py +3 -3
- package/scripts/release.py +20 -0
- package/scripts/render_benchmark_md.py +308 -0
- package/scripts/roadmap_progress_hook.py +1 -1
- package/scripts/run_skill_evals.py +2 -2
- package/scripts/runtime_registry.py +4 -4
- package/scripts/schemas/command.schema.json +4 -4
- package/scripts/schemas/rule.schema.json +5 -5
- package/scripts/schemas/skill.schema.json +3 -3
- package/scripts/schemas/user-type.schema.json +1 -1
- package/scripts/score_skill_selection.py +1 -1
- package/scripts/skill_collision_clusters.py +2 -2
- package/scripts/skill_linter.py +81 -81
- package/scripts/skill_overlap.py +5 -5
- package/scripts/skill_tools/audit_persona_coverage.py +2 -2
- package/scripts/skill_tools/audit_user_type_coverage.py +2 -2
- package/scripts/skill_tools/run_block_d_eval.py +1 -1
- package/scripts/skill_tools/score_skill_relevance.py +1 -1
- package/scripts/skill_tools/suggest_skill_for_task.py +1 -1
- package/scripts/skill_trigger_eval.py +3 -3
- package/scripts/smoke/kernel.sh +7 -1
- package/scripts/smoke/router.sh +5 -5
- package/scripts/smoke/skills.sh +1 -1
- package/scripts/smoke_quickstart.py +1 -1
- package/scripts/snapshot_agent_outputs.py +3 -3
- package/scripts/spotcheck_thin_root.py +1 -1
- package/scripts/{caveman_stats.py → telegraph_stats.py} +18 -18
- package/scripts/update_counts.py +1 -1
- package/scripts/validate_decision_engine.py +1 -1
- package/scripts/validate_frontmatter.py +1 -1
- package/scripts/validate_safe_paths.py +3 -3
- package/scripts/{validate_caveman_carveouts.py → validate_telegraph_carveouts.py} +7 -7
- package/scripts/verify_roadmap_closure.py +6 -6
- package/templates/consumer-settings/ONBOARDING.md +41 -0
- package/.agent-src/commands/install-via-agent.md +0 -129
- package/.agent-src/skills/compress-memory/SKILL.md +0 -131
- package/dist/ui/assets/index-D-DY1ywI.js +0 -35
- package/dist/ui/assets/index-D-DY1ywI.js.map +0 -1
- package/dist/ui/assets/index-Dqfhmg-d.css +0 -1
- package/docs/adrs/caveman/README.md +0 -9
- package/docs/contracts/caveman-telemetry.md +0 -83
- package/scripts/compress.sh +0 -18
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Atomic file writer — Phase A4 primitive.
|
|
3
|
+
*
|
|
4
|
+
* 1:1 port of the `tempfile.mkstemp` + `os.replace` pattern used across
|
|
5
|
+
* `scripts/install.py` (see `_write_consumer_bridge_marker` ~line 3036).
|
|
6
|
+
*
|
|
7
|
+
* Contract:
|
|
8
|
+
* 1. Open a sibling `.tmp.<rand>` file in the destination directory
|
|
9
|
+
* so the rename below is a same-filesystem operation (POSIX rename
|
|
10
|
+
* atomicity guarantee).
|
|
11
|
+
* 2. Write the payload, `fsync` to durable storage.
|
|
12
|
+
* 3. `rename()` to the final target — atomic on POSIX and Windows
|
|
13
|
+
* (Node's `fs.renameSync` maps to `MoveFileExA` with REPLACE).
|
|
14
|
+
* 4. On any failure between (1) and (3), unlink the temp file so we
|
|
15
|
+
* do not leak `.tmp.*` siblings.
|
|
16
|
+
*
|
|
17
|
+
* Sync API on purpose — the apply phase is fundamentally sequential
|
|
18
|
+
* (transaction-log ordering matters) and async I/O would add a real
|
|
19
|
+
* cost without any throughput win on the workloads we hit (≤ a few
|
|
20
|
+
* thousand small files per install).
|
|
21
|
+
*/
|
|
22
|
+
import { closeSync, fsyncSync, mkdirSync, openSync, readFileSync, renameSync, unlinkSync, writeSync, } from 'node:fs';
|
|
23
|
+
import { dirname, join } from 'node:path';
|
|
24
|
+
/**
|
|
25
|
+
* Write `data` to `target` atomically.
|
|
26
|
+
*
|
|
27
|
+
* Throws on any I/O failure — the caller (apply phase) catches and
|
|
28
|
+
* surfaces an `E_DISK_FULL` / `E_PERM` SSE error frame (Phase B1).
|
|
29
|
+
*
|
|
30
|
+
* Parent directory is created with `recursive: true` so callers do not
|
|
31
|
+
* have to pre-mkdir each subtree.
|
|
32
|
+
*/
|
|
33
|
+
export function atomicWriteFile(target, data, options = {}) {
|
|
34
|
+
const mode = options.mode ?? 0o644;
|
|
35
|
+
const parent = dirname(target);
|
|
36
|
+
mkdirSync(parent, { recursive: true });
|
|
37
|
+
const tmp = join(parent, `.tmp.${process.pid}.${randSuffix()}`);
|
|
38
|
+
let fd = null;
|
|
39
|
+
try {
|
|
40
|
+
fd = openSync(tmp, 'w', mode);
|
|
41
|
+
const buf = typeof data === 'string' ? Buffer.from(data, 'utf8') : data;
|
|
42
|
+
writeSync(fd, buf, 0, buf.length, 0);
|
|
43
|
+
fsyncSync(fd);
|
|
44
|
+
closeSync(fd);
|
|
45
|
+
fd = null;
|
|
46
|
+
renameSync(tmp, target);
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
if (fd !== null) {
|
|
50
|
+
try {
|
|
51
|
+
closeSync(fd);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
/* swallow — outer error wins */
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
unlinkSync(tmp);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
/* file may not exist yet — swallow */
|
|
62
|
+
}
|
|
63
|
+
throw err;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Append `line` to `target` atomically (read-modify-write).
|
|
68
|
+
*
|
|
69
|
+
* Wraps {@link atomicWriteFile} after a read of the current contents.
|
|
70
|
+
* Used by the transaction-log writer (`txlog.ts`) to grow the JSONL
|
|
71
|
+
* file one entry at a time without leaving a half-written line on
|
|
72
|
+
* crash. Newline is enforced — caller passes the bare payload.
|
|
73
|
+
*/
|
|
74
|
+
export function atomicAppendLine(target, line) {
|
|
75
|
+
let existing = '';
|
|
76
|
+
try {
|
|
77
|
+
existing = readFileSync(target, 'utf8');
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
existing = '';
|
|
81
|
+
}
|
|
82
|
+
const sep = existing.length > 0 && !existing.endsWith('\n') ? '\n' : '';
|
|
83
|
+
atomicWriteFile(target, `${existing}${sep}${line}\n`);
|
|
84
|
+
}
|
|
85
|
+
function randSuffix() {
|
|
86
|
+
// 12 hex chars — sufficient to avoid collisions under concurrent
|
|
87
|
+
// installs (we do not run them in production, but tests do).
|
|
88
|
+
return Math.floor(Math.random() * 0xffffffffffff)
|
|
89
|
+
.toString(16)
|
|
90
|
+
.padStart(12, '0');
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=atomic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atomic.js","sourceRoot":"","sources":["../../src/install/atomic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACH,SAAS,EACT,SAAS,EACT,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,UAAU,EACV,SAAS,GACZ,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAA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D,MAAM,GAAG,CAAC;IACd,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAc,EAAE,IAAY;IACzD,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClB,IAAI,CAAC;QACD,QAAQ,GAAG,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACL,QAAQ,GAAG,EAAE,CAAC;IAClB,CAAC;IACD,MAAM,GAAG,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IACxE,eAAe,CAAC,MAAM,EAAE,GAAG,QAAQ,GAAG,GAAG,GAAG,IAAI,IAAI,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,UAAU;IACf,iEAAiE;IACjE,6DAA6D;IAC7D,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,cAAc,CAAC;SAC5C,QAAQ,CAAC,EAAE,CAAC;SACZ,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conflict resolution — Phase A5 (simplified, three modes).
|
|
3
|
+
*
|
|
4
|
+
* Three decisions only, replacing the legacy `prompt → write / skip /
|
|
5
|
+
* abort` triple from `scripts/install.py:_resolve_file_conflict`:
|
|
6
|
+
*
|
|
7
|
+
* - `write` — target either does not exist OR policy authorises overwrite.
|
|
8
|
+
* - `skip` — target exists, known path, not forced: leave it alone.
|
|
9
|
+
* - `surface` — foreign collision: defer to the wizard's conflict screen
|
|
10
|
+
* (Phase B3). Headless callers translate `surface` to `skip`
|
|
11
|
+
* unless `policy.force` is true.
|
|
12
|
+
*
|
|
13
|
+
* JSON-aware deep-merge stays: callers that detect a `.json` target with
|
|
14
|
+
* matching `knownPointers` route through {@link mergeJsonContent} instead
|
|
15
|
+
* of byte-equality.
|
|
16
|
+
*/
|
|
17
|
+
import { existsSync } from 'node:fs';
|
|
18
|
+
import { sha256File } from './plan.js';
|
|
19
|
+
/**
|
|
20
|
+
* Decide what to do with a single planned target.
|
|
21
|
+
*
|
|
22
|
+
* Decision matrix (mirrors the Python legacy with the 3-option prompt
|
|
23
|
+
* collapsed into `surface`):
|
|
24
|
+
*
|
|
25
|
+
* | Exists? | Idempotent? | Known? | Force? | → Outcome |
|
|
26
|
+
* |---------|-------------|--------|--------|------------|
|
|
27
|
+
* | no | — | — | — | `write` |
|
|
28
|
+
* | yes | yes | — | — | `skip` |
|
|
29
|
+
* | yes | no | yes | no | `skip` |
|
|
30
|
+
* | yes | no | yes | yes | `write` |
|
|
31
|
+
* | yes | no | no | yes | `write` |
|
|
32
|
+
* | yes | no | no | no | `surface` |
|
|
33
|
+
*
|
|
34
|
+
* Headless callers (B1 CLI) collapse `surface` to `skip` automatically
|
|
35
|
+
* because there is no UI to defer to; the apply layer records the entry
|
|
36
|
+
* under {@link ApplyResult.conflicts} so the wizard can pick it up next.
|
|
37
|
+
*/
|
|
38
|
+
export function resolveFileConflict(inputs) {
|
|
39
|
+
const { targetPath, idempotent, exists, policy } = inputs;
|
|
40
|
+
if (!exists)
|
|
41
|
+
return 'write';
|
|
42
|
+
if (idempotent)
|
|
43
|
+
return 'skip';
|
|
44
|
+
const isKnown = policy.knownPaths.has(targetPath);
|
|
45
|
+
if (isKnown) {
|
|
46
|
+
return policy.force ? 'write' : 'skip';
|
|
47
|
+
}
|
|
48
|
+
if (policy.force)
|
|
49
|
+
return 'write';
|
|
50
|
+
return 'surface';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Recursive object merge — overlay wins, nested dicts merged, arrays replaced.
|
|
54
|
+
*
|
|
55
|
+
* Mirrors `scripts/install.py:deep_merge`. Arrays do **not** concatenate;
|
|
56
|
+
* Claude / Cursor / Cline hook configs rely on whole-array replacement to
|
|
57
|
+
* stay idempotent across re-runs.
|
|
58
|
+
*
|
|
59
|
+
* Returns a fresh object — both inputs remain untouched.
|
|
60
|
+
*/
|
|
61
|
+
export function deepMerge(base, overlay) {
|
|
62
|
+
const out = { ...base };
|
|
63
|
+
for (const [key, value] of Object.entries(overlay)) {
|
|
64
|
+
const prev = out[key];
|
|
65
|
+
if (isPlainObject(prev) && isPlainObject(value)) {
|
|
66
|
+
out[key] = deepMerge(prev, value);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
out[key] = cloneValue(value);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Merge `overlay` into `existing` and return the canonical 4-space JSON.
|
|
76
|
+
*
|
|
77
|
+
* Format matches `write_json_file` in the Python installer (4-space indent,
|
|
78
|
+
* trailing newline, no ASCII-escape) so the apply layer can compare bytes
|
|
79
|
+
* to detect idempotent merges and skip the write.
|
|
80
|
+
*/
|
|
81
|
+
export function mergeJsonContent(existing, overlay) {
|
|
82
|
+
const merged = deepMerge(existing, overlay);
|
|
83
|
+
return `${JSON.stringify(merged, null, 4)}\n`;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Parse JSON bytes leniently — invalid / non-object payloads collapse to `{}`.
|
|
87
|
+
*
|
|
88
|
+
* Matches `read_json_file` in the legacy script: corrupt JSON is treated
|
|
89
|
+
* as an empty doc rather than a hard failure, so the merge step always
|
|
90
|
+
* produces a well-formed output even when an upstream tool wrote a
|
|
91
|
+
* truncated config.
|
|
92
|
+
*/
|
|
93
|
+
export function parseJsonLenient(content) {
|
|
94
|
+
try {
|
|
95
|
+
const parsed = JSON.parse(content);
|
|
96
|
+
if (parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
97
|
+
return parsed;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
/* fall through — treat as empty */
|
|
102
|
+
}
|
|
103
|
+
return {};
|
|
104
|
+
}
|
|
105
|
+
/** Heuristic for routing a {@link FileEntry} through JSON merge. */
|
|
106
|
+
export function isJsonTarget(entry) {
|
|
107
|
+
return entry.kind === 'deployed' && entry.path.endsWith('.json');
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Threshold at which the wizard switches the conflict screen from
|
|
111
|
+
* single-pick to batch-resolution mode (council Finding #19).
|
|
112
|
+
*
|
|
113
|
+
* Below the threshold the user picks a resolution per row; at or above
|
|
114
|
+
* it the screen renders a summary table + global CTAs to dodge the
|
|
115
|
+
* 50-click stale-tree problem.
|
|
116
|
+
*/
|
|
117
|
+
export const CONFLICT_BATCH_THRESHOLD = 5;
|
|
118
|
+
/**
|
|
119
|
+
* Walk an {@link InstallPlan} and return one {@link ConflictEntry} per
|
|
120
|
+
* planned target the policy would `surface` to the UI.
|
|
121
|
+
*
|
|
122
|
+
* Pure-ish — reads from the filesystem only to compute idempotency
|
|
123
|
+
* (`existsSync` + `sha256File`). Skips bridges (`sha256 === null`) since
|
|
124
|
+
* bridge writers own a separate idempotency model. Skips entries whose
|
|
125
|
+
* `path` is in `policy.knownPaths`, and skips entries that are
|
|
126
|
+
* byte-equal to the planned content. Returns an empty array when
|
|
127
|
+
* `policy.force` is true — overwrite mode silences the screen.
|
|
128
|
+
*/
|
|
129
|
+
export function computeConflicts(plan) {
|
|
130
|
+
if (plan.policy.force)
|
|
131
|
+
return [];
|
|
132
|
+
const out = [];
|
|
133
|
+
for (const entries of Object.values(plan.filesByTool)) {
|
|
134
|
+
for (const entry of entries) {
|
|
135
|
+
if (entry.kind === 'bridge')
|
|
136
|
+
continue;
|
|
137
|
+
if (entry.sha256 === null)
|
|
138
|
+
continue;
|
|
139
|
+
if (!existsSync(entry.path))
|
|
140
|
+
continue;
|
|
141
|
+
if (plan.policy.knownPaths.has(entry.path))
|
|
142
|
+
continue;
|
|
143
|
+
const onDisk = sha256File(entry.path);
|
|
144
|
+
if (onDisk === entry.sha256)
|
|
145
|
+
continue;
|
|
146
|
+
out.push({
|
|
147
|
+
path: entry.path,
|
|
148
|
+
kind: entry.kind,
|
|
149
|
+
plannedSha256: entry.sha256,
|
|
150
|
+
existingSha256: onDisk,
|
|
151
|
+
mergeable: isJsonTarget(entry),
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Expand a batch choice into a per-path {@link ConflictResolution} map.
|
|
159
|
+
*
|
|
160
|
+
* The wizard sends either `resolutions` directly (single-pick mode) or
|
|
161
|
+
* a `batchChoice` (≥ 5 conflicts) that the server fans out across every
|
|
162
|
+
* surfaced entry. `merge-json` maps non-JSON entries to `skip` since
|
|
163
|
+
* deep-merge is JSON-only — the council picked skip over overwrite so a
|
|
164
|
+
* single non-JSON file in a batch never silently overwrites.
|
|
165
|
+
*/
|
|
166
|
+
export function expandBatchChoice(conflicts, choice) {
|
|
167
|
+
const out = {};
|
|
168
|
+
for (const c of conflicts) {
|
|
169
|
+
if (choice === 'skip-all') {
|
|
170
|
+
out[c.path] = 'skip';
|
|
171
|
+
}
|
|
172
|
+
else if (choice === 'overwrite-all') {
|
|
173
|
+
out[c.path] = 'overwrite';
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
out[c.path] = c.mergeable ? 'merge' : 'skip';
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return out;
|
|
180
|
+
}
|
|
181
|
+
function isPlainObject(v) {
|
|
182
|
+
return v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
183
|
+
}
|
|
184
|
+
function cloneValue(v) {
|
|
185
|
+
if (Array.isArray(v)) {
|
|
186
|
+
return v.map(cloneValue);
|
|
187
|
+
}
|
|
188
|
+
if (isPlainObject(v)) {
|
|
189
|
+
const out = {};
|
|
190
|
+
for (const [k, val] of Object.entries(v))
|
|
191
|
+
out[k] = cloneValue(val);
|
|
192
|
+
return out;
|
|
193
|
+
}
|
|
194
|
+
return v;
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=conflict.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conflict.js","sourceRoot":"","sources":["../../src/install/conflict.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAwBvC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAqB;IACrD,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAC1D,IAAI,CAAC,MAAM;QAAE,OAAO,OAAO,CAAC;IAC5B,IAAI,UAAU;QAAE,OAAO,MAAM,CAAC;IAE9B,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAClD,IAAI,OAAO,EAAE,CAAC;QACV,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;IAC3C,CAAC;IACD,IAAI,MAAM,CAAC,KAAK;QAAE,OAAO,OAAO,CAAC;IACjC,OAAO,SAAS,CAAC;AACrB,CAAC;AASD;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAC,IAAgB,EAAE,OAAmB;IAC3D,MAAM,GAAG,GAA8B,EAAE,GAAG,IAAI,EAAE,CAAC;IACnD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QACtB,IAAI,aAAa,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;Y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aAAM,CAAC;YACJ,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;QACjD,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AAED,SAAS,aAAa,CAAC,CAAU;IAC7B,OAAO,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,UAAU,CAAC,CAAY;IAC5B,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QACnB,OAAO,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC7B,CAAC;IACD,IAAI,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;QACnB,MAAM,GAAG,GAA8B,EAAE,CAAC;QAC1C,KAAK,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;YAAE,GAAG,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;QACnE,OAAO,GAAG,CAAC;IACf,CAAC;IACD,OAAO,CAAC,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detection layer — Phase A2 port of `scripts/install.py:detect_*`.
|
|
3
|
+
*
|
|
4
|
+
* Pure functions only: read once, return a plan. No side effects in
|
|
5
|
+
* the detection itself — atomic writes and conflict resolution happen
|
|
6
|
+
* in later phases against the data this module returns.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors:
|
|
9
|
+
* - `SCOPE_DETECT_MANIFESTS` → {@link SCOPE_DETECT_MANIFESTS}
|
|
10
|
+
* - `SCOPE_DETECT_AI_DIRS` → {@link SCOPE_DETECT_AI_DIRS}
|
|
11
|
+
* - `SCOPE_DETECT_AI_FILES` → {@link SCOPE_DETECT_AI_FILES}
|
|
12
|
+
* - `detect_scope(cwd)` → {@link detectScope}
|
|
13
|
+
* - `detect_package_root(project_root)` → {@link detectPackageRoot}
|
|
14
|
+
* - `detect_package_type(...)` → {@link detectPackageType}
|
|
15
|
+
*
|
|
16
|
+
* v4 addition (no Python counterpart): {@link discoverPacks} walks the
|
|
17
|
+
* monorepo `packages/` tree to enumerate available packs.
|
|
18
|
+
*/
|
|
19
|
+
import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
|
|
20
|
+
import { homedir } from 'node:os';
|
|
21
|
+
import { join, resolve } from 'node:path';
|
|
22
|
+
/**
|
|
23
|
+
* Settings-file name used as the strongest project-scope signal.
|
|
24
|
+
*
|
|
25
|
+
* Matches `SETTINGS_FILE` in `scripts/install.py`. Presence in `cwd`
|
|
26
|
+
* short-circuits scope detection to `'project'` without consulting
|
|
27
|
+
* the manifest / AI-tool lists.
|
|
28
|
+
*/
|
|
29
|
+
export const SETTINGS_FILE = '.agent-settings.yml';
|
|
30
|
+
/**
|
|
31
|
+
* Manifest files that, when present, count as a project-shape signal.
|
|
32
|
+
*
|
|
33
|
+
* Listed in the order they are most commonly canonical; detection
|
|
34
|
+
* short-circuits on the first hit. `.git/` is intentionally absent —
|
|
35
|
+
* monorepos, dotfile-git repos, and non-Git workspaces all break it
|
|
36
|
+
* (ADR-007 D2).
|
|
37
|
+
*/
|
|
38
|
+
export const SCOPE_DETECT_MANIFESTS = [
|
|
39
|
+
'package.json',
|
|
40
|
+
'composer.json',
|
|
41
|
+
'pyproject.toml',
|
|
42
|
+
'Cargo.toml',
|
|
43
|
+
'go.mod',
|
|
44
|
+
'Gemfile',
|
|
45
|
+
];
|
|
46
|
+
/** Project-local AI-tool config directories that count as a presence signal. */
|
|
47
|
+
export const SCOPE_DETECT_AI_DIRS = [
|
|
48
|
+
'.claude',
|
|
49
|
+
'.cursor',
|
|
50
|
+
'.windsurf',
|
|
51
|
+
'.augment',
|
|
52
|
+
'.clinerules',
|
|
53
|
+
'.copilot',
|
|
54
|
+
'.gemini',
|
|
55
|
+
'.codex',
|
|
56
|
+
'.aider',
|
|
57
|
+
'.continue',
|
|
58
|
+
'.roo',
|
|
59
|
+
'.kilocode',
|
|
60
|
+
];
|
|
61
|
+
/** Project-local AI-tool config files that count as a presence signal. */
|
|
62
|
+
export const SCOPE_DETECT_AI_FILES = [
|
|
63
|
+
'CLAUDE.md',
|
|
64
|
+
'AGENTS.md',
|
|
65
|
+
'GEMINI.md',
|
|
66
|
+
'.windsurfrules',
|
|
67
|
+
'.aider.conf.yml',
|
|
68
|
+
];
|
|
69
|
+
/**
|
|
70
|
+
* Multi-signal scope detection (ADR-007 D2 / Phase 1.3).
|
|
71
|
+
*
|
|
72
|
+
* 1:1 port of `scripts/install.py:detect_scope`. Pure — no side effects.
|
|
73
|
+
*/
|
|
74
|
+
export function detectScope(cwd) {
|
|
75
|
+
if (existsSync(join(cwd, SETTINGS_FILE))) {
|
|
76
|
+
return { scope: 'project', reason: `existing ${SETTINGS_FILE}` };
|
|
77
|
+
}
|
|
78
|
+
const manifest = SCOPE_DETECT_MANIFESTS.find((m) => existsSync(join(cwd, m)));
|
|
79
|
+
const aiDir = SCOPE_DETECT_AI_DIRS.find((d) => isDir(join(cwd, d)));
|
|
80
|
+
const aiFile = SCOPE_DETECT_AI_FILES.find((f) => existsSync(join(cwd, f)));
|
|
81
|
+
if (manifest !== undefined && (aiDir !== undefined || aiFile !== undefined)) {
|
|
82
|
+
const marker = aiDir ?? aiFile;
|
|
83
|
+
return {
|
|
84
|
+
scope: 'prompt',
|
|
85
|
+
reason: `manifest (${manifest}) + AI-tool config (${marker ?? ''})`,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return { scope: 'global', reason: 'no project-scope signals' };
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Map a {@link Scope} to the {@link InstallTarget} consumed by plan builder.
|
|
92
|
+
*
|
|
93
|
+
* `prompt` is treated as ambiguous — caller resolves via CLI flag or UI.
|
|
94
|
+
* Defaulting `prompt` to `global` here would silently swallow the signal.
|
|
95
|
+
*/
|
|
96
|
+
export function scopeToTarget(scope) {
|
|
97
|
+
if (scope === 'project')
|
|
98
|
+
return 'project';
|
|
99
|
+
if (scope === 'global')
|
|
100
|
+
return 'global';
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Detect project shape from manifest markers — pure read of cwd.
|
|
105
|
+
*
|
|
106
|
+
* Manifest-to-kind mapping mirrors {@link SCOPE_DETECT_MANIFESTS}:
|
|
107
|
+
* `package.json` → npm, `composer.json` → composer, etc.
|
|
108
|
+
*/
|
|
109
|
+
export function detectProjectShape(root) {
|
|
110
|
+
const manifest = SCOPE_DETECT_MANIFESTS.find((m) => existsSync(join(root, m)));
|
|
111
|
+
if (manifest === undefined) {
|
|
112
|
+
return { kind: 'unknown', root, manifest: null };
|
|
113
|
+
}
|
|
114
|
+
const kind = {
|
|
115
|
+
'package.json': 'npm',
|
|
116
|
+
'composer.json': 'composer',
|
|
117
|
+
'pyproject.toml': 'pyproject',
|
|
118
|
+
'Cargo.toml': 'cargo',
|
|
119
|
+
'go.mod': 'go',
|
|
120
|
+
Gemfile: 'ruby',
|
|
121
|
+
}[manifest] ?? 'unknown';
|
|
122
|
+
return { kind, root, manifest };
|
|
123
|
+
}
|
|
124
|
+
/** Read AI-tool presence flags from `root`. Pure — no writes. */
|
|
125
|
+
export function detectToolPresence(root) {
|
|
126
|
+
return {
|
|
127
|
+
augment: isDir(join(root, '.augment')),
|
|
128
|
+
claude: isDir(join(root, '.claude')),
|
|
129
|
+
cursor: isDir(join(root, '.cursor')),
|
|
130
|
+
cline: isDir(join(root, '.clinerules')),
|
|
131
|
+
windsurf: isDir(join(root, '.windsurf')) || existsSync(join(root, '.windsurfrules')),
|
|
132
|
+
agentsMd: existsSync(join(root, 'AGENTS.md')),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Discover packs under a workspace root (`packages/pack-*` convention).
|
|
137
|
+
*
|
|
138
|
+
* Returns absolute paths to every directory under `<workspace>/packages/`
|
|
139
|
+
* whose name starts with `pack-`. v4-only addition — the legacy Python
|
|
140
|
+
* installer has no equivalent because packs are a v4 concept.
|
|
141
|
+
*/
|
|
142
|
+
export function discoverPacks(workspaceRoot) {
|
|
143
|
+
const packagesDir = join(workspaceRoot, 'packages');
|
|
144
|
+
if (!isDir(packagesDir)) {
|
|
145
|
+
return [];
|
|
146
|
+
}
|
|
147
|
+
return readdirSync(packagesDir)
|
|
148
|
+
.filter((name) => name.startsWith('pack-'))
|
|
149
|
+
.map((name) => resolve(packagesDir, name))
|
|
150
|
+
.filter(isDir);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Locate the agent-config package root from a project root.
|
|
154
|
+
*
|
|
155
|
+
* 1:1 port of `scripts/install.py:detect_package_root` — prefers an
|
|
156
|
+
* npm-installed copy under `node_modules/@event4u/agent-config/`,
|
|
157
|
+
* falls back to the project root itself for in-package development
|
|
158
|
+
* (presence of `config/profiles/minimal.ini` is the development-mode
|
|
159
|
+
* signal in the Python script; we mirror it).
|
|
160
|
+
*
|
|
161
|
+
* Returns `null` instead of failing — caller decides UX (Python `fail`
|
|
162
|
+
* exits the process; the TS engine surfaces the error to the wizard).
|
|
163
|
+
*/
|
|
164
|
+
export function detectPackageRoot(projectRoot) {
|
|
165
|
+
const npmPath = join(projectRoot, 'node_modules', '@event4u', 'agent-config');
|
|
166
|
+
if (isDir(npmPath)) {
|
|
167
|
+
return resolve(npmPath);
|
|
168
|
+
}
|
|
169
|
+
if (existsSync(join(projectRoot, 'config', 'profiles', 'minimal.ini'))) {
|
|
170
|
+
return projectRoot;
|
|
171
|
+
}
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
/** Classify a package root as `npm` (under node_modules) or `local`. */
|
|
175
|
+
export function detectPackageType(packageRoot) {
|
|
176
|
+
return packageRoot.split(/[\\/]/).includes('node_modules') ? 'npm' : 'local';
|
|
177
|
+
}
|
|
178
|
+
function isDir(path) {
|
|
179
|
+
try {
|
|
180
|
+
return statSync(path).isDirectory();
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Detect a v3.x install at `~/.event4u/agent-config/` (or the override
|
|
188
|
+
* passed in). Returns `present: false` when the directory or the
|
|
189
|
+
* `VERSION` file is missing, or when the recorded major version is not
|
|
190
|
+
* `3.x`. The caller decides what to do with `present: true` — the wire
|
|
191
|
+
* route in `installRoute` exposes the structure 1:1.
|
|
192
|
+
*/
|
|
193
|
+
export function detectLegacyV3(opts = {}) {
|
|
194
|
+
const home = opts.home ?? homedir();
|
|
195
|
+
const path = join(home, '.event4u', 'agent-config');
|
|
196
|
+
const backupTarget = join(home, '.event4u', 'agent-config.v3.bak');
|
|
197
|
+
if (!isDir(path)) {
|
|
198
|
+
return { present: false, path, version: null, backupTarget };
|
|
199
|
+
}
|
|
200
|
+
const versionFile = join(path, 'VERSION');
|
|
201
|
+
if (!existsSync(versionFile)) {
|
|
202
|
+
return { present: false, path, version: null, backupTarget };
|
|
203
|
+
}
|
|
204
|
+
let raw = '';
|
|
205
|
+
try {
|
|
206
|
+
raw = readFileSync(versionFile, 'utf8').trim();
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
return { present: false, path, version: null, backupTarget };
|
|
210
|
+
}
|
|
211
|
+
const firstLine = raw.split('\n', 1)[0]?.trim() ?? '';
|
|
212
|
+
const major = firstLine.split('.')[0]?.trim();
|
|
213
|
+
if (major !== '3') {
|
|
214
|
+
return { present: false, path, version: firstLine || null, backupTarget };
|
|
215
|
+
}
|
|
216
|
+
return { present: true, path, version: firstLine, backupTarget };
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=detect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.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AAI,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IACjE,CAAC;IACD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC1C,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAC3B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IACjE,CAAC;IACD,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,CAAC;QACD,GAAG,GAAG,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IACnD,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IACjE,CAAC;IACD,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACtD,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;IAC9C,IAAI,KAAK,KAAK,GAAG,EAAE,CAAC;QAChB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,IAAI,IAAI,EAAE,YAAY,EAAE,CAAC;IAC9E,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;AACrE,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralised path resolution for the unified TS install engine.
|
|
3
|
+
*
|
|
4
|
+
* Council Finding #16: every downstream module reads paths from one
|
|
5
|
+
* place — no inline `os.tmpdir()` or `~/.event4u/...` literals scattered
|
|
6
|
+
* across A2–A6.
|
|
7
|
+
*
|
|
8
|
+
* All helpers accept an optional `home` argument so tests can drive
|
|
9
|
+
* platform behaviour (POSIX vs Windows env-var fallback) without
|
|
10
|
+
* mocking `node:os`. Production callers omit it and `os.homedir()` is
|
|
11
|
+
* consulted lazily.
|
|
12
|
+
*
|
|
13
|
+
* Platform notes:
|
|
14
|
+
* - POSIX: `os.homedir()` reads `$HOME`.
|
|
15
|
+
* - Windows: `os.homedir()` reads `$USERPROFILE`, then `$HOMEDRIVE+$HOMEPATH`.
|
|
16
|
+
*
|
|
17
|
+
* The install root and log path live under a fixed `.event4u/agent-config/`
|
|
18
|
+
* sub-tree so both platforms land on the same logical location.
|
|
19
|
+
*/
|
|
20
|
+
import { homedir, tmpdir } from 'node:os';
|
|
21
|
+
import { join } from 'node:path';
|
|
22
|
+
/**
|
|
23
|
+
* Sub-tree under the user's home where v4 installs land.
|
|
24
|
+
*
|
|
25
|
+
* Matches the legacy Python installer's target (`~/.event4u/agent-config/`)
|
|
26
|
+
* so v3 and v4 read/write the same physical tree and v3-detection (Phase E2)
|
|
27
|
+
* can introspect a prior install without a migration step.
|
|
28
|
+
*/
|
|
29
|
+
export const INSTALL_ROOT_SUBPATH = '.event4u/agent-config';
|
|
30
|
+
/**
|
|
31
|
+
* Active transaction log filename written by Phase A4 atomic-writer.
|
|
32
|
+
*
|
|
33
|
+
* Per Phase A4 + council Finding #18: rotation produces sibling files
|
|
34
|
+
* (`install-log.<ISO>.jsonl.gz`); recovery only scans the active log.
|
|
35
|
+
*/
|
|
36
|
+
export const INSTALL_LOG_FILENAME = 'install-log.jsonl';
|
|
37
|
+
/**
|
|
38
|
+
* Resolve the home directory.
|
|
39
|
+
*
|
|
40
|
+
* `home` override is accepted so tests can pin platform behaviour
|
|
41
|
+
* without mocking the `node:os` module. Empty / falsy override falls
|
|
42
|
+
* back to `os.homedir()`.
|
|
43
|
+
*/
|
|
44
|
+
function resolveHome(home) {
|
|
45
|
+
if (home && home.length > 0) {
|
|
46
|
+
return home;
|
|
47
|
+
}
|
|
48
|
+
const fromOs = homedir();
|
|
49
|
+
if (!fromOs) {
|
|
50
|
+
throw new Error('Cannot resolve home directory — both $HOME (POSIX) and $USERPROFILE (Windows) are unset.');
|
|
51
|
+
}
|
|
52
|
+
return fromOs;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Absolute path to the v4 install root: `~/.event4u/agent-config/`.
|
|
56
|
+
*
|
|
57
|
+
* Stable across platforms because the suffix is a POSIX-style join
|
|
58
|
+
* applied via `path.join`, which normalises separators per platform.
|
|
59
|
+
*/
|
|
60
|
+
export function getInstallRoot(home) {
|
|
61
|
+
return join(resolveHome(home), INSTALL_ROOT_SUBPATH);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Absolute path to the active transaction log:
|
|
65
|
+
* `~/.event4u/agent-config/install-log.jsonl`.
|
|
66
|
+
*
|
|
67
|
+
* Phase A4 writers append here on every successful atomic rename.
|
|
68
|
+
*/
|
|
69
|
+
export function getLogPath(home) {
|
|
70
|
+
return join(getInstallRoot(home), INSTALL_LOG_FILENAME);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* OS-level temp directory.
|
|
74
|
+
*
|
|
75
|
+
* Wraps `os.tmpdir()` so callers funnel through one symbol — drop-in
|
|
76
|
+
* replacement when a future test harness needs to redirect temp writes
|
|
77
|
+
* to a scratch dir without monkey-patching `node:os`.
|
|
78
|
+
*/
|
|
79
|
+
export function getTempPath() {
|
|
80
|
+
return tmpdir();
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/install/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AAExD;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,IAAa;IAC9B,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,EAAE,CAAC;IACzB,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CACX,0FAA0F,CAC7F,CAAC;IACN,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,IAAa;IACxC,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,oBAAoB,CAAC,CAAC;AACzD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,IAAa;IACpC,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,oBAAoB,CAAC,CAAC;AAC5D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW;IACvB,OAAO,MAAM,EAAE,CAAC;AACpB,CAAC"}
|