@event4u/agent-config 8.1.0 → 8.3.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 +3 -3
- package/CHANGELOG.md +83 -292
- package/MIGRATION.md +18 -0
- package/README.md +86 -3
- package/dist/agent-src/commands/agents/init.md +3 -3
- package/dist/agent-src/commands/chat-history/import.md +5 -5
- package/dist/agent-src/commands/chat-history.md +1 -1
- package/dist/agent-src/commands/condense.md +1 -1
- package/dist/agent-src/commands/context/create.md +1 -1
- package/dist/agent-src/commands/council/analysis.md +2 -2
- package/dist/agent-src/commands/council/default.md +3 -3
- package/dist/agent-src/commands/council/design.md +2 -2
- package/dist/agent-src/commands/council/optimize.md +1 -1
- package/dist/agent-src/commands/council/pr.md +2 -2
- package/dist/agent-src/commands/council.md +1 -1
- package/dist/agent-src/commands/feature/plan.md +1 -1
- package/dist/agent-src/commands/ghostwriter/list.md +1 -1
- package/dist/agent-src/commands/ghostwriter/write.md +1 -1
- package/dist/agent-src/commands/ghostwriter.md +1 -1
- package/dist/agent-src/commands/implement-ticket.md +2 -2
- package/dist/agent-src/commands/judge/on-diff.md +1 -1
- package/dist/agent-src/commands/judge/steps.md +3 -1
- package/dist/agent-src/commands/memory/add.md +2 -2
- package/dist/agent-src/commands/memory/learn-low-impact.md +1 -1
- package/dist/agent-src/commands/memory/load.md +1 -1
- package/dist/agent-src/commands/memory/mine-session.md +1 -1
- package/dist/agent-src/commands/memory/promote.md +1 -1
- package/dist/agent-src/commands/memory/propose.md +1 -1
- package/dist/agent-src/commands/mission/upgrade.md +1 -1
- package/dist/agent-src/commands/module/explore.md +3 -3
- package/dist/agent-src/commands/optimize/agents-dir.md +1 -1
- package/dist/agent-src/commands/optimize/skills.md +1 -1
- package/dist/agent-src/commands/optimize-project.md +1 -1
- package/dist/agent-src/commands/orchestrate.md +2 -2
- package/dist/agent-src/commands/project-analyze.md +1 -1
- package/dist/agent-src/commands/project-health.md +1 -1
- package/dist/agent-src/commands/roadmap/ai-council.md +1 -1
- package/dist/agent-src/commands/roadmap/create.md +2 -2
- package/dist/agent-src/commands/roadmap/process-full.md +3 -1
- package/dist/agent-src/commands/roadmap/process-phase.md +4 -2
- package/dist/agent-src/commands/roadmap/process-step.md +3 -1
- package/dist/agent-src/commands/security-audit-config.md +1 -1
- package/dist/agent-src/commands/sync-agent-settings.md +7 -7
- package/dist/agent-src/commands/sync-gitignore/fix.md +3 -3
- package/dist/agent-src/commands/sync-gitignore.md +4 -4
- package/dist/agent-src/commands/work.md +3 -3
- 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 +2 -2
- package/dist/agent-src/contexts/contracts/artifact-engagement-flow.md +1 -1
- package/dist/agent-src/contexts/contracts/command-suggestion-flow.md +8 -7
- package/dist/agent-src/contexts/execution/evidence-discipline.md +2 -2
- package/dist/agent-src/contexts/execution/roadmap-process-loop.md +9 -4
- package/dist/agent-src/contexts/execution/toolchain-resolver.md +10 -9
- package/dist/agent-src/contexts/execution/verification-mechanics.md +13 -1
- package/dist/agent-src/packs/README.md +1 -1
- package/dist/agent-src/presets/README.md +1 -1
- package/dist/agent-src/profiles/README.md +1 -1
- package/dist/agent-src/rules/architecture.md +2 -2
- package/dist/agent-src/rules/context-hygiene.md +2 -2
- package/dist/agent-src/rules/fast-path-marker-visibility.md +1 -1
- package/dist/agent-src/rules/framework-neutrality-in-generic-skills.md +1 -1
- package/dist/agent-src/rules/linked-projects-onboarding-gate.md +1 -1
- package/dist/agent-src/rules/low-impact-corpus-privacy-floor.md +3 -3
- package/dist/agent-src/rules/media-governance-routing.md +1 -1
- package/dist/agent-src/rules/no-roadmap-references.md +3 -3
- package/dist/agent-src/rules/preservation-guard.md +2 -2
- package/dist/agent-src/rules/roadmap-ci-steps-policy.md +6 -5
- package/dist/agent-src/rules/roadmap-progress-sync.md +3 -3
- package/dist/agent-src/rules/security-sensitive-stop.md +7 -9
- package/dist/agent-src/rules/source-confidentiality.md +1 -1
- package/dist/agent-src/rules/telegraph-speak.md +1 -1
- package/dist/agent-src/rules/token-optimizer-maintenance.md +1 -1
- package/dist/agent-src/rules/ui-audit-gate.md +1 -1
- package/dist/agent-src/scripts/archive_completed_roadmaps.ts +22 -4
- package/dist/agent-src/scripts/update_roadmap_progress.ts +29 -1
- package/dist/agent-src/skills/accessibility-auditor/SKILL.md +3 -2
- package/dist/agent-src/skills/adr-create/SKILL.md +8 -6
- package/dist/agent-src/skills/agent-docs-writing/SKILL.md +1 -1
- package/dist/agent-src/skills/agents-md-thin-root/SKILL.md +2 -2
- package/dist/agent-src/skills/ai-council/SKILL.md +15 -15
- package/dist/agent-src/skills/api-design/SKILL.md +1 -1
- package/dist/agent-src/skills/api-endpoint/SKILL.md +2 -1
- package/dist/agent-src/skills/authz-review/SKILL.md +1 -1
- package/dist/agent-src/skills/blade-ui/SKILL.md +11 -10
- package/dist/agent-src/skills/blameless-post-mortem/SKILL.md +9 -8
- package/dist/agent-src/skills/code-review/SKILL.md +3 -4
- package/dist/agent-src/skills/command-routing/SKILL.md +3 -3
- package/dist/agent-src/skills/command-writing/SKILL.md +3 -3
- package/dist/agent-src/skills/condense-memory/SKILL.md +2 -2
- package/dist/agent-src/skills/context-authoring/SKILL.md +1 -1
- package/dist/agent-src/skills/context-document/SKILL.md +1 -1
- package/dist/agent-src/skills/copilot-agents-optimization/SKILL.md +1 -1
- package/dist/agent-src/skills/corpus-grounding/SKILL.md +16 -11
- package/dist/agent-src/skills/corpus-grounding/scripts/ground.ts +24 -3
- package/dist/agent-src/skills/dashboard-design/SKILL.md +2 -1
- package/dist/agent-src/skills/database/SKILL.md +2 -1
- package/dist/agent-src/skills/description-assist/SKILL.md +6 -6
- package/dist/agent-src/skills/design-intelligence/SKILL.md +6 -5
- package/dist/agent-src/skills/design-tokens/SKILL.md +5 -5
- package/dist/agent-src/skills/design-tokens/scripts/tokens.ts +24 -3
- package/dist/agent-src/skills/existing-ui-audit/SKILL.md +3 -3
- package/dist/agent-src/skills/fe-design/SKILL.md +7 -7
- package/dist/agent-src/skills/finishing-a-development-branch/SKILL.md +11 -4
- package/dist/agent-src/skills/flux/SKILL.md +10 -9
- package/dist/agent-src/skills/git-workflow/SKILL.md +4 -5
- package/dist/agent-src/skills/guideline-writing/SKILL.md +2 -2
- package/dist/agent-src/skills/learning-to-rule-or-skill/SKILL.md +2 -2
- package/dist/agent-src/skills/livewire/SKILL.md +10 -9
- package/dist/agent-src/skills/memory-consolidation/SKILL.md +2 -2
- package/dist/agent-src/skills/module-detect-on-the-fly/SKILL.md +5 -5
- package/dist/agent-src/skills/module-management/SKILL.md +2 -2
- package/dist/agent-src/skills/prediction-pool-optimizer/SKILL.md +11 -11
- package/dist/agent-src/skills/prediction-pool-optimizer/reference/ev-fixtures.md +6 -6
- package/dist/agent-src/skills/prediction-pool-optimizer/reference/odds-and-bonus.md +1 -1
- package/dist/agent-src/skills/premortem/SKILL.md +1 -1
- package/dist/agent-src/skills/project-docs/SKILL.md +1 -1
- package/dist/agent-src/skills/quality-tools/SKILL.md +26 -2
- package/dist/agent-src/skills/react-shadcn-ui/SKILL.md +8 -7
- package/dist/agent-src/skills/react-shadcn-ui/scripts/shadcn_add.ts +31 -10
- package/dist/agent-src/skills/refine-prompt/SKILL.md +14 -14
- package/dist/agent-src/skills/refine-ticket/SKILL.md +24 -25
- package/dist/agent-src/skills/refine-ticket/detection-map.yml +1 -1
- package/dist/agent-src/skills/review-routing/SKILL.md +6 -7
- package/dist/agent-src/skills/roadmap-management/SKILL.md +11 -6
- package/dist/agent-src/skills/rule-refactor/SKILL.md +1 -1
- package/dist/agent-src/skills/rule-writing/SKILL.md +5 -5
- package/dist/agent-src/skills/script-writing/SKILL.md +28 -41
- package/dist/agent-src/skills/skill-writing/SKILL.md +3 -3
- package/dist/agent-src/skills/source-discovery/SKILL.md +3 -3
- package/dist/agent-src/skills/sql-writing/SKILL.md +2 -1
- package/dist/agent-src/skills/subagent-orchestration/SKILL.md +1 -1
- package/dist/agent-src/skills/systematic-debugging/SKILL.md +5 -7
- package/dist/agent-src/skills/tailwind-engineer/SKILL.md +2 -2
- package/dist/agent-src/skills/tailwind-engineer/scripts/tailwind_config_gen.ts +25 -4
- package/dist/agent-src/skills/token-optimizer/SKILL.md +1 -1
- package/dist/agent-src/skills/typography-system/SKILL.md +1 -1
- package/dist/agent-src/skills/validate-feature-fit/SKILL.md +5 -7
- package/dist/agent-src/skills/verify-completion-evidence/SKILL.md +13 -1
- package/dist/agent-src/templates/agent-settings.md +34 -25
- package/dist/agent-src/templates/agents/agent-project-settings.example.yml +3 -3
- package/dist/agent-src/templates/agents/memory/incident-learnings.example.yml +1 -1
- package/dist/agent-src/templates/agents/proposal.example.md +4 -4
- package/dist/agent-src/templates/copilot-instructions.md +1 -1
- package/dist/agent-src/templates/github-workflows/memory-hygiene.yml +10 -10
- package/dist/agent-src/templates/github-workflows/pr-risk-review.yml +19 -8
- package/dist/agent-src/templates/github-workflows/proposal-drift.yml +11 -8
- package/dist/agent-src/templates/github-workflows/roadmap-progress-check.yml +10 -12
- package/dist/agent-src/templates/hooks/pre-commit-frontmatter +21 -11
- package/dist/agent-src/templates/hooks/pre-commit-roadmap-progress +43 -29
- package/dist/agent-src/templates/roadmaps.md +9 -4
- package/dist/agent-src/templates/rule.md +3 -3
- package/dist/agent-src/templates/scripts/README.md +6 -6
- package/dist/agent-src/templates/scripts/check_memory.ts +24 -2
- package/dist/agent-src/templates/scripts/check_memory_proposal.ts +23 -4
- package/dist/agent-src/templates/scripts/historical-bug-patterns.example.yml +1 -1
- package/dist/agent-src/templates/scripts/memory_hash.ts +24 -2
- package/dist/agent-src/templates/scripts/memory_lookup.ts +24 -2
- package/dist/agent-src/templates/scripts/memory_report.ts +24 -2
- package/dist/agent-src/templates/scripts/memory_signal.ts +24 -2
- package/dist/agent-src/templates/scripts/memory_status.ts +26 -2
- package/dist/agent-src/templates/scripts/ownership-map.example.yml +1 -1
- package/dist/agent-src/templates/scripts/pr-risk-config.example.yml +1 -1
- package/dist/agent-src/templates/scripts/pr_review_routing.ts +24 -3
- package/dist/agent-src/templates/scripts/pr_risk_review.ts +0 -0
- package/dist/agent-src/templates/scripts/telemetry_record.ts +24 -3
- package/dist/agent-src/templates/scripts/telemetry_report.ts +25 -3
- package/dist/agent-src/templates/scripts/telemetry_status.ts +24 -3
- package/dist/agent-src/templates/scripts/tier_usage_report.ts +24 -2
- package/dist/agent-src/templates/scripts/work_engine/_lib/agent_settings.ts +44 -10
- package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/_chat_history_base.ts +26 -13
- package/dist/agent-src/templates/skill.md +2 -2
- package/dist/cli/python/knowledge_ingest.js +24 -3
- package/dist/cli/python/knowledge_ingest.js.map +1 -1
- package/dist/cli/python/workspace_analytics.js +23 -3
- package/dist/cli/python/workspace_analytics.js.map +1 -1
- package/dist/cli/python/workspace_crypto.js +23 -3
- package/dist/cli/python/workspace_crypto.js.map +1 -1
- package/dist/cli/python/workspace_documents.js +23 -3
- package/dist/cli/python/workspace_documents.js.map +1 -1
- package/dist/cli/python/workspace_drive.js +24 -3
- package/dist/cli/python/workspace_drive.js.map +1 -1
- package/dist/cli/python/workspace_drive_health.js +23 -3
- package/dist/cli/python/workspace_drive_health.js.map +1 -1
- package/dist/cli/python/workspace_explain.js +23 -3
- package/dist/cli/python/workspace_explain.js.map +1 -1
- package/dist/cli/python/workspace_hosts.js +23 -3
- package/dist/cli/python/workspace_hosts.js.map +1 -1
- package/dist/cli/python/workspace_inbox.js +23 -3
- package/dist/cli/python/workspace_inbox.js.map +1 -1
- package/dist/cli/python/workspace_render.js +23 -3
- package/dist/cli/python/workspace_render.js.map +1 -1
- package/dist/cli/python/workspace_roles.js +23 -3
- package/dist/cli/python/workspace_roles.js.map +1 -1
- package/dist/cli/python/workspace_sessions.js +23 -3
- package/dist/cli/python/workspace_sessions.js.map +1 -1
- package/dist/cli/python/workspace_skills.js +23 -3
- package/dist/cli/python/workspace_skills.js.map +1 -1
- package/dist/cli/registry.js +2 -0
- package/dist/cli/registry.js.map +1 -1
- package/dist/discovery/deprecation-report.md +1 -1
- package/dist/discovery/discovery-manifest.json +118 -118
- package/dist/discovery/discovery-manifest.json.sha256 +1 -1
- package/dist/discovery/discovery-manifest.summary.md +2 -2
- package/dist/discovery/orphan-report.md +1 -1
- package/dist/discovery/packs.json +3 -3
- package/dist/discovery/trust-report.md +1 -1
- package/dist/discovery/workspaces.json +3 -3
- package/dist/install/install.mjs +647 -408
- package/dist/mcp/registry-manifest.json +3 -3
- package/dist/server/routes/settings.js +4 -4
- package/dist/server/routes/settings.js.map +1 -1
- package/dist/server/schemas/settings.js +1 -1
- package/dist/server/schemas/settings.js.map +1 -1
- package/docs/CLAIMS.md +2 -2
- package/docs/archive/CHANGELOG-pre-8.1.0.md +316 -0
- package/docs/benchmark.md +40 -0
- package/docs/contracts/CHANGELOG-conventions.md +8 -5
- package/docs/contracts/branch-protection-policy.md +14 -5
- package/docs/contracts/mcp-phase-1-scope.md +75 -0
- package/docs/contracts/mcp-tool-inventory.md +22 -15
- package/docs/contracts/release-pr-gating.md +22 -11
- package/docs/contracts/skill-bundled-assets.md +2 -2
- package/docs/customization.md +1 -1
- package/docs/decisions/ADR-110-discipline-profile-resolution-locus.md +9 -4
- package/docs/decisions/ADR-111-canonical-glama-listing.md +97 -0
- package/docs/decisions/ADR-112-stdio-lite-stays-read-only.md +92 -0
- package/docs/decisions/ADR-113-ci-native-release-label-trigger.md +201 -0
- package/docs/decisions/INDEX.md +3 -0
- package/docs/distribution/registry-submissions.md +1 -1
- package/docs/getting-started.md +8 -6
- package/docs/guidelines/agent-infra/corpus-grounding-authoring.md +2 -2
- package/docs/guidelines/agent-infra/engineering-memory-data-format.md +4 -4
- package/docs/guidelines/agent-infra/installed-tools-manifest.md +3 -3
- package/docs/guidelines/agent-infra/language-and-tone-examples.md +2 -2
- package/docs/guidelines/agent-infra/layered-settings.md +4 -4
- package/docs/guidelines/agent-infra/memory-access.md +19 -18
- package/docs/guidelines/agent-infra/naming.md +1 -1
- package/docs/guidelines/agent-infra/roadmap-progress-mechanics.md +5 -5
- package/docs/guidelines/agent-infra/role-contracts.md +1 -1
- package/docs/guidelines/agent-infra/security-lint-containment.md +2 -2
- package/docs/guidelines/agent-infra/self-improvement-pipeline.md +1 -1
- package/docs/guidelines/agent-infra/size-and-scope.md +1 -1
- package/docs/guidelines/agent-infra/skill-quality-checklist.md +5 -5
- package/docs/guidelines/augment-portability-patterns.md +1 -1
- package/docs/installation.md +13 -14
- package/docs/mcp-server.md +32 -20
- package/docs/proof.md +1 -1
- package/docs/setup/mcp-cloud-endpoints.md +9 -2
- package/docs/setup/per-ide/claude-code.md +10 -4
- package/package.json +4 -3
- package/src/config/agent-settings.template.yml +31 -17
- package/src/config/host-capabilities.yml +25 -16
- package/src/config/profiles/balanced.ini +5 -3
- package/src/scripts/_cli/cmd_analyze_session.ts +23 -4
- package/src/scripts/_cli/cmd_conformance.ts +23 -4
- package/src/scripts/_cli/cmd_doctor.ts +196 -8
- package/src/scripts/_cli/cmd_explain.ts +23 -4
- package/src/scripts/_cli/cmd_export.ts +23 -4
- package/src/scripts/_cli/cmd_fleet.ts +23 -4
- package/src/scripts/_cli/cmd_migrate.ts +23 -4
- package/src/scripts/_cli/cmd_preflight.ts +24 -4
- package/src/scripts/_cli/cmd_prune.ts +23 -4
- package/src/scripts/_cli/cmd_refresh.ts +23 -4
- package/src/scripts/_cli/cmd_settings_check.ts +23 -4
- package/src/scripts/_cli/cmd_settings_migrate.ts +23 -4
- package/src/scripts/_cli/cmd_sync.ts +23 -4
- package/src/scripts/_cli/cmd_uninstall.ts +45 -4
- package/src/scripts/_cli/cmd_update.ts +23 -4
- package/src/scripts/_cli/cmd_upgrade.ts +307 -17
- package/src/scripts/_cli/cmd_validate.ts +23 -4
- package/src/scripts/_cli/cmd_versions.ts +23 -4
- package/src/scripts/_dispatch.bash +62 -19
- package/src/scripts/_lib/claude_plugin.ts +83 -0
- package/src/scripts/_lib/claude_settings_hooks.ts +251 -0
- package/src/scripts/_lib/knowledge_global.ts +24 -2
- package/src/scripts/_lib/knowledge_global_promote.ts +24 -2
- package/src/scripts/_lib/knowledge_global_redaction.ts +24 -2
- package/src/scripts/_lib/link_crypto.ts +24 -5
- package/src/scripts/_lib/pin_resolver.ts +24 -3
- package/src/scripts/adoption_report.ts +23 -4
- package/src/scripts/adoption_snapshot.ts +23 -1
- package/src/scripts/adoption_status.ts +23 -4
- package/src/scripts/adr/regenerate_index.ts +24 -3
- package/src/scripts/ai_council/airgap.ts +25 -2
- package/src/scripts/ai_council/compile_corpus.ts +24 -2
- package/src/scripts/ai_council/pricing.ts +11 -1
- package/src/scripts/analysis_freshness.ts +23 -4
- package/src/scripts/annotate_discovery.ts +23 -1
- package/src/scripts/apply_modules_config.ts +23 -4
- package/src/scripts/audit_adr_coverage.ts +23 -4
- package/src/scripts/audit_auto_rules.ts +23 -1
- package/src/scripts/audit_cloud_compatibility.ts +23 -4
- package/src/scripts/audit_command_surface.ts +23 -4
- package/src/scripts/audit_initial_context.ts +23 -3
- package/src/scripts/audit_likelihood.ts +23 -1
- package/src/scripts/audit_mcp_tools.ts +23 -3
- package/src/scripts/audit_overlap.ts +23 -1
- package/src/scripts/audit_skill_descriptions.ts +24 -2
- package/src/scripts/audit_skill_overlap.ts +23 -1
- package/src/scripts/audit_user_type_axis.ts +23 -4
- package/src/scripts/backfill_model_tier.ts +23 -4
- package/src/scripts/bench_ab_cache_dispatch.ts +23 -1
- package/src/scripts/bench_ab_clone.ts +23 -1
- package/src/scripts/bench_ab_diff.ts +23 -1
- package/src/scripts/bench_ab_integrity.ts +23 -1
- package/src/scripts/bench_ab_run.ts +23 -2
- package/src/scripts/bench_ab_task_runner.ts +23 -1
- package/src/scripts/bench_ab_tracka_run.ts +23 -2
- package/src/scripts/bench_ab_v2_run.ts +23 -1
- package/src/scripts/bench_ab_v2_stats.ts +23 -1
- package/src/scripts/bench_baseline_ready.ts +23 -1
- package/src/scripts/bench_condense_memory.ts +23 -1
- package/src/scripts/bench_drift_check.ts +23 -2
- package/src/scripts/bench_matrix.ts +23 -4
- package/src/scripts/bench_per_tool.ts +23 -1
- package/src/scripts/bench_quality_run.ts +23 -2
- package/src/scripts/bench_rtk_savings.ts +23 -1
- package/src/scripts/bench_rule_load_latency.ts +23 -2
- package/src/scripts/bench_run.ts +23 -2
- package/src/scripts/bench_runner.ts +23 -1
- package/src/scripts/build_cloud_bundle.ts +23 -3
- package/src/scripts/build_discovery_manifest.ts +23 -4
- package/src/scripts/build_linear_digest.ts +23 -3
- package/src/scripts/build_mcp_registry_manifest.ts +23 -4
- package/src/scripts/build_rule_trigger_matrix.ts +23 -4
- package/src/scripts/capture_showcase_session.ts +23 -1
- package/src/scripts/chat_history.ts +24 -3
- package/src/scripts/check_always_budget.ts +23 -2
- package/src/scripts/check_artefact_checksums.ts +23 -4
- package/src/scripts/check_augment_description_cap.ts +23 -4
- package/src/scripts/check_augmentignore.ts +23 -4
- package/src/scripts/check_beta_review_markers.ts +23 -4
- package/src/scripts/check_cluster_patterns.ts +23 -4
- package/src/scripts/check_command_count_messaging.ts +23 -4
- package/src/scripts/check_comparison.ts +23 -1
- package/src/scripts/check_condensation.ts +24 -3
- package/src/scripts/check_condensed_paths.ts +23 -2
- package/src/scripts/check_context_paths.ts +23 -4
- package/src/scripts/check_council_config_location.ts +23 -4
- package/src/scripts/check_council_layout.ts +23 -4
- package/src/scripts/check_council_references.ts +23 -4
- package/src/scripts/check_discovery_determinism.ts +24 -4
- package/src/scripts/check_gate_paths.ts +23 -4
- package/src/scripts/check_generated_artefact_headers.ts +23 -4
- package/src/scripts/check_generator_output_coverage.ts +23 -4
- package/src/scripts/check_gitignore_freshness.ts +23 -4
- package/src/scripts/check_iron_law_prominence.ts +23 -4
- package/src/scripts/check_kernel_prefix_stability.ts +0 -0
- package/src/scripts/check_kernel_rule_bundle.ts +23 -4
- package/src/scripts/check_knowledge_cards.ts +23 -1
- package/src/scripts/check_md_language.ts +23 -4
- package/src/scripts/check_media_deps.ts +24 -1
- package/src/scripts/check_memory.ts +24 -2
- package/src/scripts/check_memory_proposal.ts +23 -4
- package/src/scripts/check_module_management_neutral.ts +23 -4
- package/src/scripts/check_no_conflict_markers.ts +23 -4
- package/src/scripts/check_no_external_sources.ts +23 -4
- package/src/scripts/check_no_local_settings_committed.ts +24 -4
- package/src/scripts/check_no_new_legacy_path.ts +23 -4
- package/src/scripts/check_no_roadmap_refs.ts +23 -4
- package/src/scripts/check_one_off_location.ts +23 -4
- package/src/scripts/check_overlay_cascade_subdirs.ts +23 -4
- package/src/scripts/check_portability.ts +24 -3
- package/src/scripts/check_proposal.ts +0 -0
- package/src/scripts/check_public_catalog_links.ts +23 -4
- package/src/scripts/check_public_links.ts +23 -4
- package/src/scripts/check_quality_regression.ts +23 -2
- package/src/scripts/check_references.ts +23 -4
- package/src/scripts/check_release_includes_discovery.ts +23 -4
- package/src/scripts/check_release_pr_shape.ts +23 -4
- package/src/scripts/check_release_published.ts +23 -4
- package/src/scripts/check_release_trunk_sync.ts +23 -4
- package/src/scripts/check_reply_consistency.ts +23 -4
- package/src/scripts/check_roadmap_trackable.ts +23 -4
- package/src/scripts/check_role_doc_links.ts +23 -4
- package/src/scripts/check_safety_floor_untouched.ts +24 -4
- package/src/scripts/check_site_links.ts +23 -1
- package/src/scripts/check_skill_gaps.ts +23 -1
- package/src/scripts/check_skill_requires.ts +23 -4
- package/src/scripts/check_structural_breaking.ts +24 -4
- package/src/scripts/check_surface_tiers.ts +23 -4
- package/src/scripts/check_template_pin_drift.ts +23 -4
- package/src/scripts/check_test_coverage_diff.ts +23 -4
- package/src/scripts/check_token_optimizer_freshness.ts +23 -4
- package/src/scripts/check_token_quality_golden.ts +23 -2
- package/src/scripts/check_token_regression.ts +23 -2
- package/src/scripts/check_tracked_but_ignored.ts +24 -4
- package/src/scripts/check_trigger_evals.ts +23 -4
- package/src/scripts/check_trunk_drift.ts +24 -1
- package/src/scripts/check_update_banner.ts +23 -4
- package/src/scripts/ci_summary.ts +23 -4
- package/src/scripts/ci_time_ratio.ts +23 -4
- package/src/scripts/cluster_near_miss_patterns.ts +0 -0
- package/src/scripts/compile_router.ts +23 -4
- package/src/scripts/condense.ts +30 -31
- package/src/scripts/condense_memory.ts +24 -2
- package/src/scripts/config/packs.ts +24 -4
- package/src/scripts/config/session_profiles.ts +23 -4
- package/src/scripts/context_hygiene_hook.ts +24 -3
- package/src/scripts/cost_by_conversation.ts +23 -4
- package/src/scripts/cost_summary.ts +23 -4
- package/src/scripts/council_cli.ts +35 -7
- package/src/scripts/council_prune.ts +25 -2
- package/src/scripts/cross_repo_retrieve.ts +23 -4
- package/src/scripts/discovery_stats.ts +23 -4
- package/src/scripts/evidence_report.ts +23 -1
- package/src/scripts/export_replay_corpus.ts +23 -2
- package/src/scripts/extract_audit_patterns.ts +23 -1
- package/src/scripts/first_run_gate_hook.ts +24 -3
- package/src/scripts/gen_discovery_baseline.ts +23 -4
- package/src/scripts/generate_capabilities_index.ts +24 -5
- package/src/scripts/generate_capability_matrix.ts +23 -4
- package/src/scripts/generate_catalog.ts +23 -1
- package/src/scripts/generate_command_flows.ts +23 -4
- package/src/scripts/generate_cookbook.ts +23 -4
- package/src/scripts/generate_index.ts +23 -4
- package/src/scripts/generate_ownership_matrix.ts +23 -1
- package/src/scripts/generate_pack_manifests.ts +24 -5
- package/src/scripts/generate_role_experiences_catalog.ts +23 -4
- package/src/scripts/hooks/block_no_verify.ts +23 -4
- package/src/scripts/hooks/design_slop_hook.ts +24 -3
- package/src/scripts/hooks/dispatch_hook.ts +47 -14
- package/src/scripts/hooks/replay_hook.ts +23 -2
- package/src/scripts/hooks/rtk_wrap_hook.ts +24 -5
- package/src/scripts/hooks_doctor.ts +23 -2
- package/src/scripts/hooks_status.ts +23 -2
- package/src/scripts/injection_scan_hook.ts +24 -5
- package/src/scripts/install +23 -4
- package/src/scripts/install.ts +102 -44
- package/src/scripts/inventory_abstraction_budget.ts +23 -1
- package/src/scripts/inventory_frontmatter.ts +23 -1
- package/src/scripts/inventory_meta_layers.ts +23 -1
- package/src/scripts/iron_law_sha.ts +23 -4
- package/src/scripts/janitor.ts +23 -4
- package/src/scripts/knowledge_global_cli.ts +24 -2
- package/src/scripts/linked_projects_list.ts +23 -4
- package/src/scripts/lint_agent_security.ts +23 -4
- package/src/scripts/lint_agent_skill_names.ts +23 -4
- package/src/scripts/lint_agents_layout.ts +23 -4
- package/src/scripts/lint_agents_md.ts +23 -4
- package/src/scripts/lint_archived_skills.ts +23 -4
- package/src/scripts/lint_artefact_frontmatter.ts +23 -4
- package/src/scripts/lint_bench_ab.ts +23 -4
- package/src/scripts/lint_bench_corpus.ts +23 -2
- package/src/scripts/lint_command_flow_coverage.ts +23 -4
- package/src/scripts/lint_command_routing.ts +23 -4
- package/src/scripts/lint_command_tiers.ts +23 -2
- package/src/scripts/lint_command_verbs.ts +23 -4
- package/src/scripts/lint_commit_subjects.ts +24 -4
- package/src/scripts/lint_confusables.ts +25 -5
- package/src/scripts/lint_context_spine_usage.ts +23 -4
- package/src/scripts/lint_discovery_manifest.ts +23 -4
- package/src/scripts/lint_discovery_vocabulary.ts +23 -4
- package/src/scripts/lint_empty_roadmaps.ts +23 -4
- package/src/scripts/lint_eval_freshness.ts +23 -4
- package/src/scripts/lint_examples.ts +23 -4
- package/src/scripts/lint_explain_trace.ts +23 -4
- package/src/scripts/lint_featured_skills.ts +0 -0
- package/src/scripts/lint_flows.ts +23 -4
- package/src/scripts/lint_framework_leakage.ts +23 -4
- package/src/scripts/lint_frontmatter_boilerplate.ts +23 -4
- package/src/scripts/lint_ghostwriter_source.ts +23 -4
- package/src/scripts/lint_glama_drift.ts +75 -0
- package/src/scripts/lint_global_paths.ts +23 -2
- package/src/scripts/lint_handoffs.ts +23 -4
- package/src/scripts/lint_hidden_unicode.ts +24 -5
- package/src/scripts/lint_hook_concern_budget.ts +23 -4
- package/src/scripts/lint_hook_manifest.ts +23 -2
- package/src/scripts/lint_instruction_smuggling.ts +25 -5
- package/src/scripts/lint_legal_pack.ts +23 -1
- package/src/scripts/lint_load_context.ts +23 -4
- package/src/scripts/lint_marketplace.ts +24 -3
- package/src/scripts/lint_marketplace_install_completeness.ts +23 -4
- package/src/scripts/lint_mcp_config_security.ts +25 -5
- package/src/scripts/lint_mcp_registry_manifest.ts +23 -4
- package/src/scripts/lint_media_policy_linkage.ts +23 -4
- package/src/scripts/lint_missions.ts +23 -4
- package/src/scripts/lint_model_tier_coverage.ts +23 -4
- package/src/scripts/lint_namespace.ts +23 -4
- package/src/scripts/lint_namespace_collisions.ts +23 -4
- package/src/scripts/lint_new_skill_gate.ts +23 -4
- package/src/scripts/lint_no_new_atomic_commands.ts +23 -4
- package/src/scripts/lint_one_off_age.ts +23 -4
- package/src/scripts/lint_orchestration_dsl.ts +23 -4
- package/src/scripts/lint_orchestrator_auto_detect.ts +23 -4
- package/src/scripts/lint_pack_boundaries.ts +23 -4
- package/src/scripts/lint_pack_dependencies.ts +23 -2
- package/src/scripts/lint_pack_first_win.ts +23 -4
- package/src/scripts/lint_pack_risk_class.ts +23 -1
- package/src/scripts/lint_persona_governance.ts +23 -4
- package/src/scripts/lint_positioning.ts +23 -4
- package/src/scripts/lint_profile_overlay_set_only.ts +23 -4
- package/src/scripts/lint_readme_jargon.ts +23 -4
- package/src/scripts/lint_readme_size.ts +23 -4
- package/src/scripts/lint_regression.ts +23 -4
- package/src/scripts/lint_roadmap_blockers.ts +23 -4
- package/src/scripts/lint_roadmap_ci_steps.ts +23 -4
- package/src/scripts/lint_roadmap_complexity.ts +23 -4
- package/src/scripts/lint_roadmap_later_disposition.ts +23 -4
- package/src/scripts/lint_role_experiences.ts +23 -4
- package/src/scripts/lint_rule_interactions.ts +23 -4
- package/src/scripts/lint_rule_tiers.ts +24 -3
- package/src/scripts/lint_showcase_sessions.ts +23 -4
- package/src/scripts/lint_skill_frontmatter_safety.ts +25 -5
- package/src/scripts/lint_skill_originality.ts +23 -4
- package/src/scripts/lint_skill_tools.ts +23 -4
- package/src/scripts/lint_subagent_determinism.ts +23 -4
- package/src/scripts/lint_ticket_buildable.ts +23 -4
- package/src/scripts/lint_topics_yaml.ts +23 -4
- package/src/scripts/lint_trust_coherence.ts +23 -4
- package/src/scripts/lint_value_dashboard.ts +23 -4
- package/src/scripts/lint_workflow_security.ts +23 -4
- package/src/scripts/lint_workspace_boundary.ts +23 -4
- package/src/scripts/mcp_exec/safety_envelope.ts +105 -0
- package/src/scripts/mcp_parity_smoke.ts +23 -2
- package/src/scripts/mcp_registry_submit.sh +14 -3
- package/src/scripts/mcp_render.ts +23 -4
- package/src/scripts/mcp_server/__main__.ts +6 -8
- package/src/scripts/mcp_server/consumer_tool_catalog.json +78 -3
- package/src/scripts/mcp_server/tools.ts +731 -0
- package/src/scripts/mcp_telemetry_health.ts +23 -4
- package/src/scripts/mcp_telemetry_query.ts +23 -4
- package/src/scripts/mcp_telemetry_store.ts +23 -4
- package/src/scripts/measure_augment_budget.ts +23 -1
- package/src/scripts/measure_density.ts +23 -1
- package/src/scripts/measure_frugality_savings.ts +23 -1
- package/src/scripts/measure_markitdown_lift.ts +23 -1
- package/src/scripts/measure_patterns.ts +23 -1
- package/src/scripts/measure_projection_bytes.ts +23 -1
- package/src/scripts/measure_rule_budget.ts +23 -4
- package/src/scripts/measure_skill_reduction.ts +23 -1
- package/src/scripts/memory_hash.ts +24 -2
- package/src/scripts/memory_lookup.ts +24 -2
- package/src/scripts/memory_report.ts +24 -2
- package/src/scripts/memory_signal.ts +24 -2
- package/src/scripts/memory_status.ts +26 -2
- package/src/scripts/migrate_command_suggestions.ts +23 -4
- package/src/scripts/migrate_frontmatter_defaults.ts +23 -4
- package/src/scripts/migration_status.ts +25 -4
- package/src/scripts/mine_missing_guardrails.ts +23 -1
- package/src/scripts/mine_session.ts +23 -1
- package/src/scripts/minimal_safe_diff_hook.ts +24 -3
- package/src/scripts/new_skill.ts +23 -3
- package/src/scripts/onboarding_gate_hook.ts +24 -3
- package/src/scripts/parity/coverage_diff.ts +25 -3
- package/src/scripts/parity/phase_gate.ts +25 -4
- package/src/scripts/parity/replay.ts +25 -3
- package/src/scripts/pattern_share.ts +23 -4
- package/src/scripts/plan_physical_move.ts +23 -4
- package/src/scripts/prediction-pool/poisson_sim.ts +24 -3
- package/src/scripts/prediction-pool/pool_winsim.ts +24 -3
- package/src/scripts/prediction-pool/score_ev.ts +24 -3
- package/src/scripts/print_required_checks.ts +24 -4
- package/src/scripts/probe_host_compliance.ts +23 -2
- package/src/scripts/probe_projection_fidelity.ts +23 -1
- package/src/scripts/probe_skill_registration.ts +24 -2
- package/src/scripts/profile_staleness_hook.ts +24 -3
- package/src/scripts/profile_use.ts +23 -4
- package/src/scripts/project_thin_rules.ts +23 -3
- package/src/scripts/propose_modules_config.ts +23 -4
- package/src/scripts/prototype_lint_contradictions.ts +23 -1
- package/src/scripts/prove_pack_extractable.ts +23 -4
- package/src/scripts/readme_linter.ts +23 -3
- package/src/scripts/redact_hook_capture.ts +23 -4
- package/src/scripts/refine_ticket_detect.ts +23 -4
- package/src/scripts/release.ts +226 -43
- package/src/scripts/render_benchmark_composite.ts +23 -4
- package/src/scripts/render_benchmark_md.ts +23 -4
- package/src/scripts/roadmap_progress_hook.ts +46 -16
- package/src/scripts/run_skill_evals.ts +23 -4
- package/src/scripts/runtime_dispatcher.ts +23 -4
- package/src/scripts/runtime_registry.ts +23 -4
- package/src/scripts/score_skill_selection.ts +23 -1
- package/src/scripts/security_audit_config.ts +24 -5
- package/src/scripts/skill_collision_clusters.ts +23 -4
- package/src/scripts/skill_discovery.ts +23 -4
- package/src/scripts/skill_linter.ts +23 -2
- package/src/scripts/skill_preview.ts +23 -4
- package/src/scripts/skill_tools/audit_persona_coverage.ts +23 -1
- package/src/scripts/skill_tools/audit_user_type_coverage.ts +23 -1
- package/src/scripts/skill_tools/run_block_d_eval.ts +23 -1
- package/src/scripts/skill_tools/score_skill_relevance.ts +23 -1
- package/src/scripts/skill_tools/suggest_skill_for_task.ts +24 -1
- package/src/scripts/skill_usage_collect.ts +23 -4
- package/src/scripts/smoke_path_resolution.ts +23 -4
- package/src/scripts/smoke_quickstart.ts +23 -4
- package/src/scripts/snapshot_agent_outputs.ts +23 -4
- package/src/scripts/spotcheck_thin_root.ts +23 -4
- package/src/scripts/sync_agent_settings.ts +23 -4
- package/src/scripts/sync_github_metadata.ts +23 -4
- package/src/scripts/sync_gitignore.ts +23 -4
- package/src/scripts/telegraph_stats.ts +23 -4
- package/src/scripts/tool_registry.ts +24 -4
- package/src/scripts/trigger_coverage.ts +23 -4
- package/src/scripts/update_counts.ts +23 -4
- package/src/scripts/update_prices.ts +23 -1
- package/src/scripts/validate_agent_settings.ts +23 -4
- package/src/scripts/validate_decision_engine.ts +23 -4
- package/src/scripts/validate_discovery_manifest.ts +23 -4
- package/src/scripts/validate_frontmatter.ts +23 -2
- package/src/scripts/validate_pack_yaml.ts +0 -0
- package/src/scripts/validate_safe_paths.ts +24 -4
- package/src/scripts/validate_telegraph_carveouts.ts +23 -4
- package/src/scripts/verify_before_complete_hook.ts +24 -3
- package/src/scripts/verify_physical_move.ts +23 -4
- package/src/scripts/wrapper_freshness_hook.ts +107 -8
- package/tests/fixtures/hooks/README.md +92 -0
- package/tests/fixtures/hooks/agent_error.json +7 -0
- package/tests/fixtures/hooks/post_tool_use.json +13 -0
- package/tests/fixtures/hooks/pre_compact.json +7 -0
- package/tests/fixtures/hooks/pre_tool_use.json +9 -0
- package/tests/fixtures/hooks/session_end.json +6 -0
- package/tests/fixtures/hooks/session_start.json +6 -0
- package/tests/fixtures/hooks/stop.json +6 -0
- package/tests/fixtures/hooks/user_prompt_submit.json +7 -0
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# * CWD on entry is the consumer's repo root — we keep it that way
|
|
14
14
|
# so underlying scripts resolve paths correctly.
|
|
15
15
|
# * PACKAGE_ROOT is derived from this script's location, used only to
|
|
16
|
-
# locate the package-internal
|
|
16
|
+
# locate the package-internal TypeScript scripts (mcp_render.ts, …).
|
|
17
17
|
# * Unknown arguments are forwarded verbatim to the underlying script.
|
|
18
18
|
|
|
19
19
|
set -euo pipefail
|
|
@@ -138,19 +138,26 @@ Tier 2 — maintenance / internal (hooks, MCP, memory, telemetry):
|
|
|
138
138
|
mcp:render Render mcp.json → .cursor/mcp.json, .windsurf/mcp.json
|
|
139
139
|
(pass --claude-desktop to also write user-scope config)
|
|
140
140
|
mcp:check Dry-run mcp:render; exit non-zero if targets are stale
|
|
141
|
-
mcp:setup
|
|
141
|
+
mcp:setup Verify the tsx runtime + MCP server module and
|
|
142
|
+
print the client config snippet
|
|
142
143
|
(one-line MCP server onboarding; idempotent)
|
|
143
144
|
mcp:run Run the built-in MCP server over stdio
|
|
144
145
|
(requires `mcp:setup` first; see docs/mcp-server.md)
|
|
145
146
|
(experimental — beta gates: docs/contracts/mcp-beta-criteria.md)
|
|
146
147
|
roadmap:progress Regenerate agents/roadmaps-progress.md from open roadmaps
|
|
147
148
|
roadmap:progress-check Fail if agents/roadmaps-progress.md is stale (for CI)
|
|
149
|
+
roadmap:archive Archive completed roadmaps (branch-touched by default;
|
|
150
|
+
--all for every complete one; --dry-run to preview)
|
|
148
151
|
capabilities:index Regenerate CAPABILITIES.yaml — the package coverage index
|
|
149
152
|
(capability area → coverage → backing skills/commands → gaps).
|
|
150
153
|
Pass --check to fail if stale (for CI). Reads src/ (package repo).
|
|
151
154
|
settings:check Validate .agent-settings.yml against the YAML-subset contract
|
|
152
155
|
(docs/contracts/settings-sync-yaml-subset.md). Read-only.
|
|
153
156
|
Exit 0 clean, 1 finding(s), 2 file absent / unreadable.
|
|
157
|
+
settings:sync Additively merge new template keys into an existing
|
|
158
|
+
.agent-settings.yml (user lines preserved verbatim).
|
|
159
|
+
Run automatically by `upgrade`. Flags: --path <file>
|
|
160
|
+
| --dry-run | --check (exit 2 on drift) | --profile.
|
|
154
161
|
settings:migrate Lift project-local .agent-settings.yml / .agent-user.yml into
|
|
155
162
|
~/.event4u/agent-config/ (the global-only consumer surface,
|
|
156
163
|
ADR-020). Idempotent; --force overwrites a non-empty global
|
|
@@ -284,20 +291,35 @@ print_version() {
|
|
|
284
291
|
fi
|
|
285
292
|
}
|
|
286
293
|
|
|
287
|
-
# Resolve the tsx runner (Python→TypeScript migration).
|
|
288
|
-
#
|
|
289
|
-
#
|
|
294
|
+
# Resolve the tsx runner (Python→TypeScript migration). tsx ships as a
|
|
295
|
+
# RUNTIME dependency of the package, so the package-local install is the
|
|
296
|
+
# canonical source — first via node_modules/.bin, then via the module's CLI
|
|
297
|
+
# entry (covers installs where .bin shims are missing). `npx tsx` is a last
|
|
298
|
+
# resort only: npx runs against the CONSUMER project's cwd, so its npm config
|
|
299
|
+
# and devEngines/engines constraints apply — a consumer pinning e.g.
|
|
300
|
+
# `node <24` hard-fails every hook and TS command with EBADDEVENGINES (the
|
|
301
|
+
# 8.1.0 regression that silently broke hooks + roadmap:progress in consumer
|
|
302
|
+
# projects). Exits 127 when nothing works — the runtime is Node/tsx, there is
|
|
303
|
+
# no Python fallback.
|
|
290
304
|
require_tsx() {
|
|
291
305
|
if [[ -x "$PACKAGE_ROOT/node_modules/.bin/tsx" ]]; then
|
|
292
306
|
TSX_BIN="$PACKAGE_ROOT/node_modules/.bin/tsx"
|
|
293
307
|
return 0
|
|
294
308
|
fi
|
|
309
|
+
if [[ -f "$PACKAGE_ROOT/node_modules/tsx/dist/cli.mjs" ]] && command -v node >/dev/null 2>&1; then
|
|
310
|
+
TSX_BIN="node $PACKAGE_ROOT/node_modules/tsx/dist/cli.mjs"
|
|
311
|
+
return 0
|
|
312
|
+
fi
|
|
295
313
|
if command -v npx >/dev/null 2>&1; then
|
|
314
|
+
echo "⚠️ agent-config: package-local tsx not found — falling back to \`npx tsx\`" >&2
|
|
315
|
+
echo " (subject to this project's npm config; reinstall the package to fix:" >&2
|
|
316
|
+
echo " npm install -g @event4u/agent-config)" >&2
|
|
296
317
|
TSX_BIN="npx tsx"
|
|
297
318
|
return 0
|
|
298
319
|
fi
|
|
299
|
-
echo "❌ agent-config: tsx runner not found
|
|
300
|
-
echo "
|
|
320
|
+
echo "❌ agent-config: tsx runner not found" >&2
|
|
321
|
+
echo " Reinstall the package (npm install -g @event4u/agent-config) to provide" >&2
|
|
322
|
+
echo " node_modules/tsx, or run \`npm install\` at the package root." >&2
|
|
301
323
|
exit 127
|
|
302
324
|
}
|
|
303
325
|
|
|
@@ -335,7 +357,7 @@ exec_hook() {
|
|
|
335
357
|
|
|
336
358
|
# Locate a script. First argument is relative to PACKAGE_ROOT, second is
|
|
337
359
|
# an optional fallback relative to CONSUMER_ROOT (for scripts that ship
|
|
338
|
-
# to the consumer via .augment/, e.g. update_roadmap_progress.
|
|
360
|
+
# to the consumer via .augment/, e.g. update_roadmap_progress.ts).
|
|
339
361
|
resolve_script() {
|
|
340
362
|
local pkg_rel="$1"
|
|
341
363
|
local consumer_rel="${2-}"
|
|
@@ -422,6 +444,14 @@ cmd_roadmap_progress_check() {
|
|
|
422
444
|
exec_ts "$script" --check "$@"
|
|
423
445
|
}
|
|
424
446
|
|
|
447
|
+
# The PR-gate archival sweep (`/create-pr` § 1c and roadmap-progress-sync's
|
|
448
|
+
# PR-gate) instructs `./agent-config roadmap:archive` — this is that command.
|
|
449
|
+
cmd_roadmap_archive() {
|
|
450
|
+
local script
|
|
451
|
+
script="$(resolve_script "dist/agent-src/scripts/archive_completed_roadmaps.ts" ".augment/scripts/archive_completed_roadmaps.ts")"
|
|
452
|
+
exec_ts "$script" "$@"
|
|
453
|
+
}
|
|
454
|
+
|
|
425
455
|
cmd_capabilities_index() {
|
|
426
456
|
local script
|
|
427
457
|
script="$(resolve_script "src/scripts/generate_capabilities_index.ts")"
|
|
@@ -593,7 +623,7 @@ Three modes, picked by flag combination:
|
|
|
593
623
|
at the consumer root. Idempotent.
|
|
594
624
|
|
|
595
625
|
--regen Provision the roadmap-progress regenerator at
|
|
596
|
-
.augment/scripts/update_roadmap_progress.
|
|
626
|
+
.augment/scripts/update_roadmap_progress.ts
|
|
597
627
|
(canonical path per docs/contracts/hook-architecture-v1.md
|
|
598
628
|
§ Regenerator location). Idempotent.
|
|
599
629
|
|
|
@@ -793,7 +823,7 @@ cmd_keys_install_openai() {
|
|
|
793
823
|
|
|
794
824
|
# Council CLI — non-interactive wrapper around scripts.ai_council.orchestrator.
|
|
795
825
|
# Three subcommands share one Python entry point; we forward the subcommand
|
|
796
|
-
# verb so `./agent-config council:run --confirm` lands on `council_cli.
|
|
826
|
+
# verb so `./agent-config council:run --confirm` lands on `council_cli.ts run`.
|
|
797
827
|
cmd_council() {
|
|
798
828
|
local sub="$1"; shift || true
|
|
799
829
|
local script
|
|
@@ -811,7 +841,7 @@ cmd_use() {
|
|
|
811
841
|
}
|
|
812
842
|
|
|
813
843
|
# `agent-config update` — flip the agent_config_version pin in
|
|
814
|
-
# .agent-settings.yml. See scripts/_cli/cmd_update.
|
|
844
|
+
# .agent-settings.yml. See scripts/_cli/cmd_update.ts (P3.1 of
|
|
815
845
|
# road-to-portable-runtime-and-update-check.md).
|
|
816
846
|
cmd_update() {
|
|
817
847
|
exec_ts "$PACKAGE_ROOT/src/scripts/_cli/cmd_update.ts" "$@"
|
|
@@ -826,7 +856,7 @@ cmd_refresh() {
|
|
|
826
856
|
}
|
|
827
857
|
|
|
828
858
|
# `agent-config migrate` — one-shot migration off legacy composer / npm
|
|
829
|
-
# install paths onto the npx-only runtime. See scripts/_cli/cmd_migrate.
|
|
859
|
+
# install paths onto the npx-only runtime. See scripts/_cli/cmd_migrate.ts
|
|
830
860
|
# (P3.5 of road-to-portable-runtime-and-update-check.md).
|
|
831
861
|
cmd_migrate() {
|
|
832
862
|
exec_ts "$PACKAGE_ROOT/src/scripts/_cli/cmd_migrate.ts" "$@"
|
|
@@ -845,7 +875,7 @@ cmd_init() {
|
|
|
845
875
|
# `agent-config global` — user-scope install entry point. Forwards to the
|
|
846
876
|
# bash installer with `--global` set (ADR-007). Phase 1.2 of
|
|
847
877
|
# road-to-global-first-install.md. The bash wrapper handles option parsing
|
|
848
|
-
# and forwards to `scripts/install.
|
|
878
|
+
# and forwards to `scripts/install.ts --global`, where `install_global()`
|
|
849
879
|
# currently scaffolds the per-tool anchor paths from USER_SCOPE_PATHS.
|
|
850
880
|
# Concrete writes land in Phase 1.5 (export) and Phase 1.6 (lockfile).
|
|
851
881
|
cmd_global() {
|
|
@@ -857,7 +887,7 @@ cmd_global() {
|
|
|
857
887
|
# `agent-config export` — write a tool's canonical content into a
|
|
858
888
|
# user-chosen path. ADR-007 D3 / Phase 1.5 of
|
|
859
889
|
# road-to-global-first-install.md. Replaces the rejected symlink-bridge.
|
|
860
|
-
# See scripts/_cli/cmd_export.
|
|
890
|
+
# See scripts/_cli/cmd_export.ts for the registry and idempotency logic.
|
|
861
891
|
cmd_export() {
|
|
862
892
|
exec_ts "$PACKAGE_ROOT/src/scripts/_cli/cmd_export.ts" "$@"
|
|
863
893
|
}
|
|
@@ -884,6 +914,17 @@ cmd_settings_check() {
|
|
|
884
914
|
exec_ts "$PACKAGE_ROOT/src/scripts/_cli/cmd_settings_check.ts" "$@"
|
|
885
915
|
}
|
|
886
916
|
|
|
917
|
+
# `agent-config settings:sync` — additive merge of the current
|
|
918
|
+
# agent-settings template into an existing .agent-settings.yml. User lines
|
|
919
|
+
# are preserved verbatim; only missing template keys are inserted.
|
|
920
|
+
# Idempotent. Invoked automatically by `agent-config upgrade` for every
|
|
921
|
+
# existing settings file (global + project) so nobody keeps stale settings
|
|
922
|
+
# after a release. Flags: --path <file> | --dry-run | --check | --profile.
|
|
923
|
+
# Exit 0 in-sync / updated, 2 drift under --check or bad input.
|
|
924
|
+
cmd_settings_sync() {
|
|
925
|
+
exec_ts "$PACKAGE_ROOT/src/scripts/sync_agent_settings.ts" "$@"
|
|
926
|
+
}
|
|
927
|
+
|
|
887
928
|
# `agent-config settings:migrate` — lift project-local
|
|
888
929
|
# .agent-settings.yml / .agent-user.yml into ~/.event4u/agent-config/.
|
|
889
930
|
# Phase 2.4 of road-to-global-only-install.md. Read-only on the source —
|
|
@@ -897,7 +938,7 @@ cmd_settings_migrate() {
|
|
|
897
938
|
# `agent-config uninstall` — remove bridge markers (project) or lockfile
|
|
898
939
|
# entries (global). Idempotent. Pass `--purge` to also delete deployed
|
|
899
940
|
# content directories under user-scope anchors (destructive). See
|
|
900
|
-
# scripts/_cli/cmd_uninstall.
|
|
941
|
+
# scripts/_cli/cmd_uninstall.ts.
|
|
901
942
|
cmd_uninstall() {
|
|
902
943
|
exec_ts "$PACKAGE_ROOT/src/scripts/_cli/cmd_uninstall.ts" "$@"
|
|
903
944
|
}
|
|
@@ -906,14 +947,14 @@ cmd_uninstall() {
|
|
|
906
947
|
# Drift-cleanup sibling to `uninstall`: compares on-disk markers
|
|
907
948
|
# against agents/installed-tools.lock and unlinks anything not
|
|
908
949
|
# declared. Hard-floors when lockfile is absent. See
|
|
909
|
-
# scripts/_cli/cmd_prune.
|
|
950
|
+
# scripts/_cli/cmd_prune.ts.
|
|
910
951
|
cmd_prune() {
|
|
911
952
|
exec_ts "$PACKAGE_ROOT/src/scripts/_cli/cmd_prune.ts" "$@"
|
|
912
953
|
}
|
|
913
954
|
|
|
914
955
|
# `agent-config doctor` — read-only drift report against the manifest.
|
|
915
956
|
# Surfaces missing / modified / foreign files. Exit 0 clean, 1 drift,
|
|
916
|
-
# 2 manifest-absent. See scripts/_cli/cmd_doctor.
|
|
957
|
+
# 2 manifest-absent. See scripts/_cli/cmd_doctor.ts.
|
|
917
958
|
cmd_doctor() {
|
|
918
959
|
exec_ts "$PACKAGE_ROOT/src/scripts/_cli/cmd_doctor.ts" "$@"
|
|
919
960
|
}
|
|
@@ -930,14 +971,14 @@ cmd_conformance() {
|
|
|
930
971
|
# `agent-config versions` — list available @event4u/agent-config versions
|
|
931
972
|
# on the npm registry. Marks the current pin (from .agent-settings.yml)
|
|
932
973
|
# and the latest published version. Offline-tolerant. See
|
|
933
|
-
# scripts/_cli/cmd_versions.
|
|
974
|
+
# scripts/_cli/cmd_versions.ts.
|
|
934
975
|
cmd_versions() {
|
|
935
976
|
exec_ts "$PACKAGE_ROOT/src/scripts/_cli/cmd_versions.ts" "$@"
|
|
936
977
|
}
|
|
937
978
|
|
|
938
979
|
# `agent-config explain <config|rule|route>` — print the decision chain
|
|
939
980
|
# behind a configuration or routing outcome. Read-only diagnostic; never
|
|
940
|
-
# edits state. See scripts/_cli/cmd_explain.
|
|
981
|
+
# edits state. See scripts/_cli/cmd_explain.ts.
|
|
941
982
|
cmd_explain() {
|
|
942
983
|
exec_ts "$PACKAGE_ROOT/src/scripts/_cli/cmd_explain.ts" "$@"
|
|
943
984
|
}
|
|
@@ -961,6 +1002,7 @@ main() {
|
|
|
961
1002
|
use) cmd_use "$@" ;;
|
|
962
1003
|
roadmap:progress) cmd_roadmap_progress "$@" ;;
|
|
963
1004
|
roadmap:progress-check) cmd_roadmap_progress_check "$@" ;;
|
|
1005
|
+
roadmap:archive) cmd_roadmap_archive "$@" ;;
|
|
964
1006
|
capabilities:index) cmd_capabilities_index "$@" ;;
|
|
965
1007
|
hooks:install) cmd_hooks_install "$@" ;;
|
|
966
1008
|
keys:install-anthropic) cmd_keys_install_anthropic "$@" ;;
|
|
@@ -1001,6 +1043,7 @@ main() {
|
|
|
1001
1043
|
sync) cmd_sync "$@" ;;
|
|
1002
1044
|
validate) cmd_validate "$@" ;;
|
|
1003
1045
|
settings:check) cmd_settings_check "$@" ;;
|
|
1046
|
+
settings:sync) cmd_settings_sync "$@" ;;
|
|
1004
1047
|
settings:migrate) cmd_settings_migrate "$@" ;;
|
|
1005
1048
|
uninstall) cmd_uninstall "$@" ;;
|
|
1006
1049
|
prune) cmd_prune "$@" ;;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code plugin detection helpers — shared by `cmd_upgrade`,
|
|
3
|
+
* `cmd_doctor`, and the installer.
|
|
4
|
+
*
|
|
5
|
+
* Claude Code loads the FULL top-level command set (`/implement-ticket`,
|
|
6
|
+
* `/work`, `/review-changes`, …) from the installed plugin
|
|
7
|
+
* (`agent-config@event4u-agent-config`), NOT from the `~/.claude/commands/`
|
|
8
|
+
* file projection. A file-only install therefore silently misses top-level
|
|
9
|
+
* commands while namespaced subcommands (`/fix:pr-comments`, …) keep working
|
|
10
|
+
* — and an installed plugin stays pinned to its install-time git SHA until
|
|
11
|
+
* `claude plugin update` runs. These helpers detect both states so
|
|
12
|
+
* upgrade / doctor / install can refresh the plugin or surface the gap.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import * as fs from 'node:fs';
|
|
16
|
+
import * as os from 'node:os';
|
|
17
|
+
import * as path from 'node:path';
|
|
18
|
+
import process from 'node:process';
|
|
19
|
+
|
|
20
|
+
export const CLAUDE_PLUGIN_ID = 'agent-config';
|
|
21
|
+
export const CLAUDE_MARKETPLACE_NAME = 'event4u-agent-config';
|
|
22
|
+
export const CLAUDE_MARKETPLACE_REPO = 'event4u-app/agent-config';
|
|
23
|
+
|
|
24
|
+
/** The one-time install commands surfaced when the plugin is missing. */
|
|
25
|
+
export const CLAUDE_PLUGIN_INSTALL_HINT: readonly string[] = [
|
|
26
|
+
`claude plugin marketplace add ${CLAUDE_MARKETPLACE_REPO}`,
|
|
27
|
+
`claude plugin install ${CLAUDE_PLUGIN_ID}@${CLAUDE_MARKETPLACE_NAME}`,
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
/** Claude Code config dir — `CLAUDE_CONFIG_DIR` env override, else `~/.claude`. */
|
|
31
|
+
export function claude_config_dir(): string {
|
|
32
|
+
const env = (process.env['CLAUDE_CONFIG_DIR'] ?? '').trim();
|
|
33
|
+
return env !== '' ? env : path.join(os.homedir(), '.claude');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* True when the agent-config plugin is recorded in Claude Code's
|
|
38
|
+
* `plugins/installed_plugins.json` (any marketplace — matched by the
|
|
39
|
+
* `agent-config@` id prefix). Unreadable / absent file → false.
|
|
40
|
+
*/
|
|
41
|
+
export function claude_plugin_installed(): boolean {
|
|
42
|
+
const p = path.join(claude_config_dir(), 'plugins', 'installed_plugins.json');
|
|
43
|
+
let data: unknown;
|
|
44
|
+
try {
|
|
45
|
+
data = JSON.parse(fs.readFileSync(p, 'utf-8'));
|
|
46
|
+
} catch {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
if (data === null || typeof data !== 'object') return false;
|
|
50
|
+
const plugins = (data as { plugins?: unknown }).plugins;
|
|
51
|
+
if (plugins === null || plugins === undefined || typeof plugins !== 'object') return false;
|
|
52
|
+
return Object.keys(plugins as Record<string, unknown>).some((k) =>
|
|
53
|
+
k.startsWith(`${CLAUDE_PLUGIN_ID}@`),
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Version recorded in the installed marketplace snapshot's
|
|
59
|
+
* `.claude-plugin/marketplace.json` (`metadata.version` — bumped per
|
|
60
|
+
* release, so it tracks the package version the snapshot was taken from).
|
|
61
|
+
* Null when the snapshot is absent or unreadable.
|
|
62
|
+
*/
|
|
63
|
+
export function claude_plugin_snapshot_version(): string | null {
|
|
64
|
+
const p = path.join(
|
|
65
|
+
claude_config_dir(),
|
|
66
|
+
'plugins',
|
|
67
|
+
'marketplaces',
|
|
68
|
+
CLAUDE_MARKETPLACE_NAME,
|
|
69
|
+
'.claude-plugin',
|
|
70
|
+
'marketplace.json',
|
|
71
|
+
);
|
|
72
|
+
let data: unknown;
|
|
73
|
+
try {
|
|
74
|
+
data = JSON.parse(fs.readFileSync(p, 'utf-8'));
|
|
75
|
+
} catch {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
if (data === null || typeof data !== 'object') return null;
|
|
79
|
+
const metadata = (data as { metadata?: unknown }).metadata;
|
|
80
|
+
if (metadata === null || metadata === undefined || typeof metadata !== 'object') return null;
|
|
81
|
+
const v = (metadata as { version?: unknown }).version;
|
|
82
|
+
return typeof v === 'string' && v.trim() !== '' ? v.trim() : null;
|
|
83
|
+
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Managed Claude Code hook registration in settings.json.
|
|
3
|
+
*
|
|
4
|
+
* road-to-claude-code-single-surface Phase 1: the marketplace plugin used to
|
|
5
|
+
* be the only carrier of the deterministic hook matrix (hooks/hooks.json).
|
|
6
|
+
* This module registers the same matrix directly in a Claude Code settings
|
|
7
|
+
* file (`~/.claude/settings.json` for the global install) so the plugin is
|
|
8
|
+
* no longer required for hooks.
|
|
9
|
+
*
|
|
10
|
+
* Contract (parity findings: agents/settings/contexts/claude-code-hook-parity.md):
|
|
11
|
+
*
|
|
12
|
+
* - The hook schema is identical between plugin hooks.json and settings.json;
|
|
13
|
+
* Claude Code fires all sources in parallel and dedupes identical command
|
|
14
|
+
* strings — so a still-installed plugin never double-fires during the
|
|
15
|
+
* migration window.
|
|
16
|
+
* - Managed entries are identified by the dispatch signature inside the
|
|
17
|
+
* command string (MANAGED_SIGNATURE). No extra marker field is written —
|
|
18
|
+
* content-derived identity keeps the entry byte-identical to the plugin's,
|
|
19
|
+
* which is what makes the dedup guarantee hold.
|
|
20
|
+
* - User-owned entries (anything without the signature) are never touched,
|
|
21
|
+
* reordered, or removed. Managed entries are replaced in place per event.
|
|
22
|
+
* - Writes are atomic (temp file + rename via atomicWriteFile) and guarded
|
|
23
|
+
* by a sidecar lockfile so two concurrent installers cannot tear the file.
|
|
24
|
+
* - A settings file that exists but does not parse as JSON is NEVER
|
|
25
|
+
* overwritten — the operation throws CorruptSettingsError and leaves the
|
|
26
|
+
* file byte-identical (the user's file outranks our convenience).
|
|
27
|
+
*
|
|
28
|
+
* The hook matrix itself derives from src/scripts/hook_manifest.yaml via
|
|
29
|
+
* build_claude_hook_matrix() — the same single source generate_plugin_hooks()
|
|
30
|
+
* (condense.ts) uses for the plugin's hooks/hooks.json.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
import * as fs from 'node:fs';
|
|
34
|
+
import * as path from 'node:path';
|
|
35
|
+
|
|
36
|
+
import * as YAML from 'yaml';
|
|
37
|
+
|
|
38
|
+
import { atomicWriteFile } from '../../install/atomic.js';
|
|
39
|
+
|
|
40
|
+
// Bundle note: a static import of the CJS `yaml` package requires the
|
|
41
|
+
// createRequire banner in `build:install-bundle` (package.json) — without it
|
|
42
|
+
// the esbuild ESM bundle throws `Dynamic require of "process" is not
|
|
43
|
+
// supported` at module init. A bare lazy `require('yaml')` is NOT an
|
|
44
|
+
// alternative: it is a ReferenceError under plain tsx/node ESM (CI).
|
|
45
|
+
function _yaml_parse(text: string): unknown {
|
|
46
|
+
return YAML.parse(text);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Substring that identifies an entry as agent-config-managed. */
|
|
50
|
+
export const MANAGED_SIGNATURE = 'dispatch:hook --platform claude';
|
|
51
|
+
|
|
52
|
+
export class CorruptSettingsError extends Error {
|
|
53
|
+
constructor(file: string, cause: string) {
|
|
54
|
+
super(
|
|
55
|
+
`${file} exists but is not valid JSON (${cause}). ` +
|
|
56
|
+
'Refusing to overwrite a user-owned settings file — fix or remove it, then re-run.',
|
|
57
|
+
);
|
|
58
|
+
this.name = 'CorruptSettingsError';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export class SettingsLockError extends Error {
|
|
63
|
+
constructor(lockPath: string) {
|
|
64
|
+
super(
|
|
65
|
+
`settings lock ${lockPath} is held by another process. ` +
|
|
66
|
+
'Re-run when the concurrent install finishes (stale lock: delete the file).',
|
|
67
|
+
);
|
|
68
|
+
this.name = 'SettingsLockError';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
interface HookCommand {
|
|
73
|
+
type: string;
|
|
74
|
+
command: string;
|
|
75
|
+
[k: string]: unknown;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
interface HookGroup {
|
|
79
|
+
matcher?: string;
|
|
80
|
+
hooks: HookCommand[];
|
|
81
|
+
[k: string]: unknown;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** native event name → full shell command, e.g. { SessionStart: "BIN=..." }. */
|
|
85
|
+
export type ClaudeHookMatrix = Record<string, string>;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Derive the Claude hook matrix from hook_manifest.yaml — the SAME source
|
|
89
|
+
* generate_plugin_hooks() uses, so settings-registered hooks and the plugin's
|
|
90
|
+
* hooks.json can never drift from each other.
|
|
91
|
+
*/
|
|
92
|
+
export function build_claude_hook_matrix(manifest_path: string): ClaudeHookMatrix {
|
|
93
|
+
const raw = fs.readFileSync(manifest_path, 'utf8');
|
|
94
|
+
const manifest = (_yaml_parse(raw) ?? {}) as Record<string, unknown>;
|
|
95
|
+
const hook_spec = (manifest['schema_version'] as unknown) ?? 1;
|
|
96
|
+
const platforms = (manifest['platforms'] ?? {}) as Record<string, unknown>;
|
|
97
|
+
const claude_events = ((platforms['claude'] ?? {}) as Record<string, unknown>) || {};
|
|
98
|
+
const aliasesAll = (manifest['native_event_aliases'] ?? {}) as Record<string, unknown>;
|
|
99
|
+
const aliases = ((aliasesAll['claude'] ?? {}) as Record<string, unknown>) || {};
|
|
100
|
+
|
|
101
|
+
const ac_to_native: Record<string, string> = {};
|
|
102
|
+
for (const [native, ac] of Object.entries(aliases)) {
|
|
103
|
+
ac_to_native[String(ac)] = native;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const matrix: ClaudeHookMatrix = {};
|
|
107
|
+
for (const [ac_event, concerns] of Object.entries(claude_events)) {
|
|
108
|
+
if (!concerns || (Array.isArray(concerns) && concerns.length === 0)) continue;
|
|
109
|
+
const native = ac_to_native[ac_event];
|
|
110
|
+
if (native === undefined) continue;
|
|
111
|
+
matrix[native] =
|
|
112
|
+
'BIN="$CLAUDE_PROJECT_DIR/agent-config"; [ -x "$BIN" ] || BIN=agent-config; ' +
|
|
113
|
+
`"$BIN" dispatch:hook --platform claude --event ${ac_event} ` +
|
|
114
|
+
`--native-event ${native} --project-dir "$CLAUDE_PROJECT_DIR" ` +
|
|
115
|
+
`--min-version ${String(hook_spec)}`;
|
|
116
|
+
}
|
|
117
|
+
return matrix;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function _is_managed_group(group: unknown): boolean {
|
|
121
|
+
if (typeof group !== 'object' || group === null || Array.isArray(group)) return false;
|
|
122
|
+
const hooks = (group as HookGroup).hooks;
|
|
123
|
+
if (!Array.isArray(hooks)) return false;
|
|
124
|
+
return hooks.some(
|
|
125
|
+
(h) =>
|
|
126
|
+
typeof h === 'object' &&
|
|
127
|
+
h !== null &&
|
|
128
|
+
typeof (h as HookCommand).command === 'string' &&
|
|
129
|
+
(h as HookCommand).command.includes(MANAGED_SIGNATURE),
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function _read_settings(settings_path: string): Record<string, unknown> {
|
|
134
|
+
if (!fs.existsSync(settings_path)) return {};
|
|
135
|
+
const raw = fs.readFileSync(settings_path, 'utf8');
|
|
136
|
+
if (raw.trim() === '') return {};
|
|
137
|
+
let parsed: unknown;
|
|
138
|
+
try {
|
|
139
|
+
parsed = JSON.parse(raw);
|
|
140
|
+
} catch (e) {
|
|
141
|
+
throw new CorruptSettingsError(settings_path, (e as Error).message);
|
|
142
|
+
}
|
|
143
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
144
|
+
throw new CorruptSettingsError(settings_path, 'top level is not an object');
|
|
145
|
+
}
|
|
146
|
+
return parsed as Record<string, unknown>;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function _with_lock<T>(settings_path: string, fn: () => T): T {
|
|
150
|
+
const lockPath = settings_path + '.agent-config.lock';
|
|
151
|
+
fs.mkdirSync(path.dirname(lockPath), { recursive: true });
|
|
152
|
+
let fd: number;
|
|
153
|
+
try {
|
|
154
|
+
fd = fs.openSync(lockPath, 'wx');
|
|
155
|
+
} catch {
|
|
156
|
+
throw new SettingsLockError(lockPath);
|
|
157
|
+
}
|
|
158
|
+
try {
|
|
159
|
+
return fn();
|
|
160
|
+
} finally {
|
|
161
|
+
fs.closeSync(fd);
|
|
162
|
+
fs.rmSync(lockPath, { force: true });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface EnsureResult {
|
|
167
|
+
/** true when the file content changed on disk. */
|
|
168
|
+
changed: boolean;
|
|
169
|
+
/** native events whose managed entry was added or replaced. */
|
|
170
|
+
events: string[];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Idempotently register the managed hook matrix in a Claude settings file.
|
|
175
|
+
* User entries are preserved untouched; managed entries are replaced in
|
|
176
|
+
* place; a second run with the same matrix produces zero diff.
|
|
177
|
+
*/
|
|
178
|
+
export function ensure_managed_hooks(
|
|
179
|
+
settings_path: string,
|
|
180
|
+
matrix: ClaudeHookMatrix,
|
|
181
|
+
): EnsureResult {
|
|
182
|
+
return _with_lock(settings_path, () => {
|
|
183
|
+
const settings = _read_settings(settings_path);
|
|
184
|
+
const before = JSON.stringify(settings);
|
|
185
|
+
|
|
186
|
+
const hooks = ((settings['hooks'] ?? {}) as Record<string, unknown>) || {};
|
|
187
|
+
const touched: string[] = [];
|
|
188
|
+
|
|
189
|
+
for (const [native, command] of Object.entries(matrix)) {
|
|
190
|
+
const existing = Array.isArray(hooks[native]) ? (hooks[native] as unknown[]) : [];
|
|
191
|
+
const user_groups = existing.filter((g) => !_is_managed_group(g));
|
|
192
|
+
const managed_group: HookGroup = {
|
|
193
|
+
hooks: [{ type: 'command', command }],
|
|
194
|
+
};
|
|
195
|
+
const next = [...user_groups, managed_group];
|
|
196
|
+
if (JSON.stringify(next) !== JSON.stringify(existing)) touched.push(native);
|
|
197
|
+
hooks[native] = next;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
settings['hooks'] = hooks;
|
|
201
|
+
const after = JSON.stringify(settings);
|
|
202
|
+
if (after === before) {
|
|
203
|
+
return { changed: false, events: [] };
|
|
204
|
+
}
|
|
205
|
+
atomicWriteFile(settings_path, JSON.stringify(settings, null, 2) + '\n');
|
|
206
|
+
return { changed: true, events: touched };
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export interface RemoveResult {
|
|
211
|
+
changed: boolean;
|
|
212
|
+
/** native events a managed entry was removed from. */
|
|
213
|
+
events: string[];
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Remove exactly the managed entries (dispatch-signature match) from a
|
|
218
|
+
* Claude settings file. User entries, other settings keys, and files
|
|
219
|
+
* without managed entries are left byte-identical. Missing file → no-op.
|
|
220
|
+
*/
|
|
221
|
+
export function remove_managed_hooks(settings_path: string): RemoveResult {
|
|
222
|
+
if (!fs.existsSync(settings_path)) return { changed: false, events: [] };
|
|
223
|
+
return _with_lock(settings_path, () => {
|
|
224
|
+
const settings = _read_settings(settings_path);
|
|
225
|
+
const hooks = settings['hooks'];
|
|
226
|
+
if (typeof hooks !== 'object' || hooks === null || Array.isArray(hooks)) {
|
|
227
|
+
return { changed: false, events: [] };
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const hooksRec = hooks as Record<string, unknown>;
|
|
231
|
+
const touched: string[] = [];
|
|
232
|
+
for (const [native, groups] of Object.entries(hooksRec)) {
|
|
233
|
+
if (!Array.isArray(groups)) continue;
|
|
234
|
+
const kept = groups.filter((g) => !_is_managed_group(g));
|
|
235
|
+
if (kept.length !== groups.length) {
|
|
236
|
+
touched.push(native);
|
|
237
|
+
if (kept.length === 0) {
|
|
238
|
+
delete hooksRec[native];
|
|
239
|
+
} else {
|
|
240
|
+
hooksRec[native] = kept;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (touched.length === 0) return { changed: false, events: [] };
|
|
245
|
+
if (Object.keys(hooksRec).length === 0) {
|
|
246
|
+
delete settings['hooks'];
|
|
247
|
+
}
|
|
248
|
+
atomicWriteFile(settings_path, JSON.stringify(settings, null, 2) + '\n');
|
|
249
|
+
return { changed: true, events: touched };
|
|
250
|
+
});
|
|
251
|
+
}
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
import * as fs from 'node:fs';
|
|
34
34
|
import * as path from 'node:path';
|
|
35
35
|
import process from 'node:process';
|
|
36
|
-
import { pathToFileURL } from 'node:url';
|
|
36
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
37
37
|
|
|
38
38
|
import { load_agent_settings } from './agent_settings.js';
|
|
39
39
|
import type { SettingsDict, SettingsValue } from './agent_settings.js';
|
|
@@ -761,8 +761,30 @@ function _escapeNonAscii(s: string): string {
|
|
|
761
761
|
return out;
|
|
762
762
|
}
|
|
763
763
|
|
|
764
|
+
function _isCliEntry(): boolean {
|
|
765
|
+
if (process.argv[1] === undefined) {
|
|
766
|
+
return false;
|
|
767
|
+
}
|
|
768
|
+
const argvUrl = pathToFileURL(path.resolve(process.argv[1])).href;
|
|
769
|
+
if (import.meta.url === argvUrl) {
|
|
770
|
+
return true;
|
|
771
|
+
}
|
|
772
|
+
// A symlinked invocation (e.g. via an installed `.augment/` projection,
|
|
773
|
+
// or macOS /var → /private/var temp dirs) makes the raw URLs differ:
|
|
774
|
+
// import.meta.url is the resolved real path while argv[1] keeps the
|
|
775
|
+
// symlink path. Compare realpaths so the entry guard still fires
|
|
776
|
+
// (without this the CLI silently no-ops when run through a symlink).
|
|
777
|
+
try {
|
|
778
|
+
const here = fs.realpathSync(fileURLToPath(import.meta.url));
|
|
779
|
+
const argv = fs.realpathSync(path.resolve(process.argv[1]));
|
|
780
|
+
return here === argv;
|
|
781
|
+
} catch {
|
|
782
|
+
return false;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
|
|
764
786
|
const _isMain =
|
|
765
|
-
|
|
787
|
+
_isCliEntry();
|
|
766
788
|
if (_isMain) {
|
|
767
789
|
// Mirror `raise SystemExit(main())`: the process exit code is main()'s
|
|
768
790
|
// return value (help/error paths set process.exitCode AND return the code).
|
|
@@ -32,7 +32,7 @@ import { spawnSync } from 'node:child_process';
|
|
|
32
32
|
import * as fs from 'node:fs';
|
|
33
33
|
import * as path from 'node:path';
|
|
34
34
|
import process from 'node:process';
|
|
35
|
-
import { pathToFileURL } from 'node:url';
|
|
35
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
36
36
|
|
|
37
37
|
import { write_atomic } from './fs_atomic.js';
|
|
38
38
|
import * as knowledge_global from './knowledge_global.js';
|
|
@@ -445,8 +445,30 @@ function pyJsonDumps(value: unknown, indent: number, sortKeys: boolean): string
|
|
|
445
445
|
return knowledge_global.pyJsonDumps(value, indent, sortKeys);
|
|
446
446
|
}
|
|
447
447
|
|
|
448
|
+
function _isCliEntry(): boolean {
|
|
449
|
+
if (process.argv[1] === undefined) {
|
|
450
|
+
return false;
|
|
451
|
+
}
|
|
452
|
+
const argvUrl = pathToFileURL(path.resolve(process.argv[1])).href;
|
|
453
|
+
if (import.meta.url === argvUrl) {
|
|
454
|
+
return true;
|
|
455
|
+
}
|
|
456
|
+
// A symlinked invocation (e.g. via an installed `.augment/` projection,
|
|
457
|
+
// or macOS /var → /private/var temp dirs) makes the raw URLs differ:
|
|
458
|
+
// import.meta.url is the resolved real path while argv[1] keeps the
|
|
459
|
+
// symlink path. Compare realpaths so the entry guard still fires
|
|
460
|
+
// (without this the CLI silently no-ops when run through a symlink).
|
|
461
|
+
try {
|
|
462
|
+
const here = fs.realpathSync(fileURLToPath(import.meta.url));
|
|
463
|
+
const argv = fs.realpathSync(path.resolve(process.argv[1]));
|
|
464
|
+
return here === argv;
|
|
465
|
+
} catch {
|
|
466
|
+
return false;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
448
470
|
const _isMain =
|
|
449
|
-
|
|
471
|
+
_isCliEntry();
|
|
450
472
|
if (_isMain) {
|
|
451
473
|
// Mirror `raise SystemExit(main())`.
|
|
452
474
|
process.exit(main());
|