@event4u/agent-config 16.2.0 → 16.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/.augment-plugin/marketplace.json +3 -3
- package/.augment-plugin/plugin.json +1 -1
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +89 -237
- package/README.md +14 -12
- package/dist/agent-src/commands/analyze/inbox.md +1 -1
- package/dist/agent-src/commands/analyze/roadmap-repos.md +1 -1
- package/dist/agent-src/commands/bug/fix.md +17 -2
- package/dist/agent-src/commands/feature/plan.md +1 -1
- package/dist/agent-src/commands/feature/roadmap.md +1 -1
- package/dist/agent-src/commands/fix/ci.md +1 -1
- package/dist/agent-src/commands/implement-ticket.md +1 -1
- package/dist/agent-src/commands/jira-ticket.md +1 -1
- package/dist/agent-src/commands/roadmap/create.md +1 -1
- package/dist/agent-src/commands/roadmap/materialize.md +1 -1
- package/dist/agent-src/commands/roadmap/process-full.md +4 -4
- package/dist/agent-src/commands/roadmap/resolve-blockers.md +361 -0
- package/dist/agent-src/commands/roadmap/triage-parked.md +325 -0
- package/dist/agent-src/commands/roadmap.md +18 -4
- package/dist/agent-src/commands/tests/create.md +17 -3
- package/dist/agent-src/commands/tests/execute.md +22 -5
- package/dist/agent-src/contexts/authority/decision-revisit-gate-enforcement.md +43 -0
- package/dist/agent-src/contexts/communication/rules-auto/design-fidelity-enforcement.md +24 -0
- package/dist/agent-src/contexts/execution/auto-dispatch-classification.md +6 -6
- package/dist/agent-src/contexts/execution/roadmap-process-loop.md +32 -2
- package/dist/agent-src/contexts/execution/session-canary-enforcement-history.md +67 -0
- package/dist/agent-src/contexts/execution/toolchain-resolver.md +101 -7
- package/dist/agent-src/rules/active-remediation.md +1 -1
- package/dist/agent-src/rules/autonomous-execution.md +1 -0
- package/dist/agent-src/rules/broken-access-control.md +1 -0
- package/dist/agent-src/rules/command-suggestion-policy.md +1 -0
- package/dist/agent-src/rules/context-hygiene.md +1 -1
- package/dist/agent-src/rules/decision-revisit-gate.md +16 -33
- package/dist/agent-src/rules/design-fidelity.md +13 -16
- package/dist/agent-src/rules/doc-screenshot-hygiene.md +1 -0
- package/dist/agent-src/rules/domain-safety-disclaimer.md +1 -0
- package/dist/agent-src/rules/domain-safety-pii.md +1 -0
- package/dist/agent-src/rules/domain-safety-retention.md +1 -0
- package/dist/agent-src/rules/engineering-safety-floor.md +1 -0
- package/dist/agent-src/rules/evaluator-independence.md +3 -2
- package/dist/agent-src/rules/fast-path-marker-visibility.md +1 -0
- package/dist/agent-src/rules/finance-safety-floor.md +1 -0
- package/dist/agent-src/rules/git-history-discipline.md +1 -0
- package/dist/agent-src/rules/image-likeness-and-rights.md +1 -0
- package/dist/agent-src/rules/legal-safety-floor.md +3 -2
- package/dist/agent-src/rules/lethal-trifecta-guard.md +1 -0
- package/dist/agent-src/rules/low-impact-corpus-privacy-floor.md +1 -0
- package/dist/agent-src/rules/media-governance-routing.md +14 -17
- package/dist/agent-src/rules/persona-governance.md +2 -2
- package/dist/agent-src/rules/provider-lifecycle-discipline.md +1 -1
- package/dist/agent-src/rules/question-not-instruction.md +1 -0
- package/dist/agent-src/rules/roadmap-progress-sync.md +1 -1
- package/dist/agent-src/rules/runtime-safety.md +1 -0
- package/dist/agent-src/rules/secret-vcs-guard.md +1 -0
- package/dist/agent-src/rules/security-sensitive-stop.md +3 -2
- package/dist/agent-src/rules/session-canary.md +8 -62
- package/dist/agent-src/rules/settings-ask-protocol.md +1 -0
- package/dist/agent-src/rules/source-confidentiality.md +1 -0
- package/dist/agent-src/rules/strategy-safety-floor.md +1 -0
- package/dist/agent-src/rules/tool-safety.md +1 -0
- package/dist/agent-src/rules/untrusted-input-defense.md +1 -0
- package/dist/agent-src/rules/user-interrupt-priority.md +1 -0
- package/dist/agent-src/scripts/archive_completed_roadmaps.ts +115 -20
- package/dist/agent-src/scripts/deferral_carry.ts +339 -0
- package/dist/agent-src/scripts/update_roadmap_progress.ts +4 -1
- package/dist/agent-src/skills/api-design/data/manifest.json +2 -2
- package/dist/agent-src/skills/api-testing/SKILL.md +17 -0
- package/dist/agent-src/skills/code-intelligence/SKILL.md +14 -2
- package/dist/agent-src/skills/design-system-capture/references/import-procedure.md +1 -1
- package/dist/agent-src/skills/existing-ui-audit/SKILL.md +2 -2
- package/dist/agent-src/skills/fe-design/SKILL.md +1 -1
- package/dist/agent-src/skills/iconography/SKILL.md +1 -1
- package/dist/agent-src/skills/js-library-packaging/SKILL.md +2 -2
- package/dist/agent-src/skills/monorepo-workspace/SKILL.md +1 -1
- package/dist/agent-src/skills/quality-tools/SKILL.md +11 -1
- package/dist/agent-src/skills/quality-tools/references/go-tools.md +76 -0
- package/dist/agent-src/skills/quality-tools/references/python-tools.md +104 -0
- package/dist/agent-src/skills/review-routing/SKILL.md +2 -2
- package/dist/agent-src/skills/skill-improvement-pipeline/SKILL.md +1 -1
- package/dist/agent-src/skills/storybook-workshop/SKILL.md +3 -3
- package/dist/agent-src/skills/tailwind-engineer/SKILL.md +1 -1
- package/dist/agent-src/skills/test-case-discovery/SKILL.md +7 -0
- package/dist/agent-src/skills/test-driven-development/SKILL.md +17 -0
- package/dist/agent-src/skills/test-performance/SKILL.md +19 -1
- package/dist/agent-src/skills/ui-component-architect/SKILL.md +2 -2
- package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
- package/dist/agent-src/templates/scripts/work_engine/directives/ui/apply.ts +48 -6
- package/dist/agent-src/templates/scripts/work_engine/stack/runner.ts +774 -109
- package/dist/cli/registry.js +1 -1
- package/dist/cli-delegate/archive_completed_roadmaps.js +92 -12
- package/dist/cli-delegate/check_update_banner.js +12 -1
- package/dist/cli-delegate/chunk-523HCFYO.js +90 -0
- package/dist/cli-delegate/{chunk-M2DPGFZ4.js → chunk-6V6TA25H.js} +22 -152
- package/dist/cli-delegate/chunk-7IQE3D5S.js +191 -0
- package/dist/cli-delegate/{chunk-6KFEC3G7.js → chunk-CQWX336L.js} +1 -1
- package/dist/cli-delegate/chunk-DEIV7XP7.js +108 -0
- package/dist/cli-delegate/chunk-EEHDXSYD.js +2040 -0
- package/dist/cli-delegate/{chunk-P6ZHP5W2.js → chunk-GKE7ZVFA.js} +4 -4
- package/dist/cli-delegate/chunk-JQOM7TTM.js +1201 -0
- package/dist/cli-delegate/{chunk-IGD6ERX6.js → chunk-JQVYKIZA.js} +10 -0
- package/dist/cli-delegate/{chunk-FC75PGJE.js → chunk-JY2I2DXV.js} +12 -1
- package/dist/cli-delegate/chunk-KB5FZ655.js +208 -0
- package/dist/cli-delegate/{chunk-7RQP4UDH.js → chunk-KR6EM23A.js} +235 -1455
- package/dist/cli-delegate/{chunk-LTYVIY76.js → chunk-LIYTLH6O.js} +1 -1
- package/dist/cli-delegate/{chunk-YJ72UIAK.js → chunk-NQ7WT43P.js} +1186 -244
- package/dist/cli-delegate/chunk-NXEILF2K.js +2160 -0
- package/dist/cli-delegate/{chunk-5R7HOLAF.js → chunk-NYX3L2PZ.js} +1 -1
- package/dist/cli-delegate/{chunk-4E2W63DA.js → chunk-OKJUIAPS.js} +62 -1
- package/dist/cli-delegate/{chunk-QAJS5YWY.js → chunk-PHD7OOLE.js} +2 -1
- package/dist/cli-delegate/{chunk-RGNIWTEA.js → chunk-QLDHIPWR.js} +1 -1
- package/dist/cli-delegate/{chunk-7XGBX6ZH.js → chunk-RQNNW7IF.js} +1314 -560
- package/dist/cli-delegate/{chunk-4XFP2Y3E.js → chunk-S4UMZNES.js} +1 -1
- package/dist/cli-delegate/{chunk-6KM6ORRY.js → chunk-S4YWNRKO.js} +24 -8
- package/dist/cli-delegate/{chunk-FP36SWJD.js → chunk-TRI6DQZ6.js} +2781 -340
- package/dist/cli-delegate/chunk-ULQRUR23.js +208 -0
- package/dist/cli-delegate/{chunk-NUHLI2RX.js → chunk-YCU3TIXH.js} +2 -0
- package/dist/cli-delegate/chunk-ZBZV2G5R.js +210 -0
- package/dist/cli-delegate/{chunk-WGXTVKCQ.js → chunk-ZUZKZYCN.js} +5 -3
- package/dist/cli-delegate/cmd_analyze_session.js +1 -1
- package/dist/cli-delegate/cmd_brand_status.js +1 -1
- package/dist/cli-delegate/cmd_conformance.js +1167 -234
- package/dist/cli-delegate/cmd_doctor.js +13 -6
- package/dist/cli-delegate/cmd_doctor_neighbours.js +23 -0
- package/dist/cli-delegate/cmd_explain.js +5 -5
- package/dist/cli-delegate/cmd_export.js +11 -8
- package/dist/cli-delegate/cmd_fleet.js +3 -3
- package/dist/cli-delegate/cmd_handoff.js +10 -7
- package/dist/cli-delegate/cmd_mcp_available.js +1 -1
- package/dist/cli-delegate/cmd_memory_get.js +3 -1
- package/dist/cli-delegate/cmd_migrate.js +2 -2
- package/dist/cli-delegate/cmd_packs_active.js +3 -3
- package/dist/cli-delegate/cmd_preflight.js +6 -6
- package/dist/cli-delegate/cmd_prune.js +11 -8
- package/dist/cli-delegate/cmd_refresh.js +2 -1
- package/dist/cli-delegate/cmd_route_audit.js +8 -6
- package/dist/cli-delegate/cmd_route_explain.js +4 -4
- package/dist/cli-delegate/cmd_session_recycle.js +4 -3
- package/dist/cli-delegate/cmd_settings_get.js +1 -1
- package/dist/cli-delegate/cmd_settings_migrate.js +11 -8
- package/dist/cli-delegate/cmd_settings_set.js +4 -4
- package/dist/cli-delegate/cmd_sync.js +11 -8
- package/dist/cli-delegate/cmd_uninstall.js +11 -8
- package/dist/cli-delegate/cmd_update.js +1 -1
- package/dist/cli-delegate/cmd_upgrade.js +3 -2
- package/dist/cli-delegate/cmd_validate.js +11 -8
- package/dist/cli-delegate/cmd_versions.js +1 -1
- package/dist/cli-delegate/deferral_carry.js +16 -0
- package/dist/cli-delegate/gate_execute.js +2 -2
- package/dist/cli-delegate/roadmap_gates.js +5 -5
- package/dist/cli-delegate/update_roadmap_progress.js +1 -1
- package/dist/discovery/deprecation-report.md +1 -1
- package/dist/discovery/discovery-manifest.json +127 -75
- package/dist/discovery/discovery-manifest.json.sha256 +1 -1
- package/dist/discovery/discovery-manifest.summary.md +3 -3
- package/dist/discovery/dormancy-report.md +1 -1
- package/dist/discovery/orphan-report.md +1 -1
- package/dist/discovery/packs.json +7 -5
- package/dist/discovery/trust-report.md +2 -2
- package/dist/discovery/workspaces.json +6 -4
- package/dist/hooks/dispatch.js +5357 -6656
- package/dist/hooks/dispatch.sha256 +1 -1
- package/dist/install/claudePathsPlan.js +47 -6
- package/dist/install/claudeRuleRewrite.js +7 -0
- package/dist/install/emit_host_rules_cli.js +39 -36
- package/dist/install/globalRuleScope.js +87 -0
- package/dist/install/host_rule_ownership.js +160 -0
- package/dist/install/install.mjs +2080 -1024
- package/dist/install/installThinLayer.js +261 -0
- package/dist/install/installedRuleLinks.js +176 -0
- package/dist/install/wizard-plan.js +24 -0
- package/dist/mcp/registry-manifest.json +3 -3
- package/dist/mcp/server.json +2 -2
- package/dist/mcp/server.mjs +31965 -27154
- package/dist/scripts/_lib/agent_settings.js +11 -0
- package/dist/scripts/_lib/claude_settings_hooks.js +10 -8
- package/dist/scripts/_lib/installed_layer.js +378 -0
- package/dist/scripts/_lib/lean_projection_mode.js +218 -15
- package/dist/scripts/_lib/rule_consequence_class.js +45 -0
- package/dist/scripts/_lib/rule_injection.js +67 -10
- package/dist/scripts/_lib/rule_law_section.js +122 -0
- package/dist/scripts/_lib/thin_rules.js +458 -0
- package/dist/scripts/_lib/windsurf_render.js +60 -0
- package/dist/scripts/condense.js +14 -26
- package/dist/scripts/project_thin_rules.js +14 -294
- package/dist/server/schemas/settings.js +6 -0
- package/dist/shared/skillRanking.js +74 -13
- package/docs/contracts/settings-classes.md +7 -5
- package/package.json +1 -1
- package/src/agent-src/scripts/archive_completed_roadmaps.ts +115 -20
- package/src/agent-src/scripts/deferral_carry.ts +339 -0
- package/src/agent-src/scripts/update_roadmap_progress.ts +4 -1
- package/src/agent-src/templates/scripts/work_engine/directives/ui/apply.ts +48 -6
- package/src/agent-src/templates/scripts/work_engine/stack/runner.ts +774 -109
- package/src/config/agent-settings.template.yml +62 -22
- package/src/config/continuity-surface.json +7 -0
- package/src/config/evaluator-budgets.json +4 -4
- package/src/config/gate-coverage.yml +96 -3
- package/src/config/gate-violation-baselines.json +17 -9
- package/src/config/hook-bundle-budget.json +25 -0
- package/src/config/hook-token-budget.json +6 -1
- package/src/config/host-instruction-limits.json +33 -0
- package/src/config/routing-coverage-seed.json +24 -3
- package/src/config/rule-activation-census.json +7 -3
- package/src/config/rule-consequence-class.json +161 -0
- package/src/config/rule-law-ceilings.json +99 -0
- package/src/install/claudePathsPlan.ts +46 -4
- package/src/install/claudeRuleRewrite.ts +10 -1
- package/src/install/emit_host_rules_cli.ts +43 -34
- package/src/install/globalRuleScope.ts +109 -0
- package/src/install/host_rule_ownership.ts +170 -0
- package/src/install/installThinLayer.ts +312 -0
- package/src/install/installedRuleLinks.ts +220 -0
- package/src/install/wizard-plan.ts +24 -0
- package/src/scripts/_cli/cmd_doctor.ts +23 -71
- package/src/scripts/_cli/cmd_doctor_neighbours.ts +293 -0
- package/src/scripts/_dispatch.bash +16 -2
- package/src/scripts/_lib/agent_settings.ts +11 -0
- package/src/scripts/_lib/claude_settings_hooks.ts +10 -8
- package/src/scripts/_lib/estate_offsets.ts +241 -0
- package/src/scripts/_lib/exemption_shape.ts +143 -0
- package/src/scripts/_lib/fnv.ts +23 -0
- package/src/scripts/_lib/foreign_scan.ts +106 -0
- package/src/scripts/_lib/gitignore_block.ts +314 -0
- package/src/scripts/_lib/global_deploy_inventory.ts +32 -0
- package/src/scripts/_lib/graph_feeder_record.ts +214 -0
- package/src/scripts/_lib/hook_settings.ts +73 -0
- package/src/scripts/_lib/host_capability.ts +40 -19
- package/src/scripts/_lib/host_hook_merge.ts +165 -0
- package/src/scripts/_lib/installed_layer.ts +538 -0
- package/src/scripts/_lib/json_merge.ts +82 -0
- package/src/scripts/_lib/json_pointers.ts +93 -11
- package/src/scripts/_lib/lean_projection_mode.ts +275 -15
- package/src/scripts/_lib/machine_wake.ts +16 -3
- package/src/scripts/_lib/neighbour_census.ts +760 -0
- package/src/scripts/_lib/neighbour_scan.ts +122 -0
- package/src/scripts/_lib/neighbour_tool_use.ts +189 -0
- package/src/scripts/_lib/prompt_shape.ts +46 -0
- package/src/scripts/_lib/release_migration_gate.ts +19 -3
- package/src/scripts/_lib/reserved_name_sweep.ts +73 -0
- package/src/scripts/_lib/review_coverage.ts +134 -0
- package/src/scripts/_lib/rule_consequence_class.ts +71 -0
- package/src/scripts/_lib/rule_injection.ts +130 -10
- package/src/scripts/_lib/rule_law_section.ts +147 -0
- package/src/scripts/_lib/rule_layer_overlap.ts +58 -0
- package/src/scripts/_lib/skill_origin.ts +254 -0
- package/src/scripts/_lib/structured_ask.ts +64 -21
- package/src/scripts/_lib/thin_rules.ts +540 -0
- package/src/scripts/_lib/touched_file_quality.ts +434 -0
- package/src/scripts/_lib/turn_end_refusals.ts +77 -2
- package/src/scripts/_lib/windsurf_render.ts +63 -0
- package/src/scripts/ai_council/cli_call_budget.ts +13 -5
- package/src/scripts/ai_council/clients.ts +26 -57
- package/src/scripts/ai_council/config.ts +1 -1
- package/src/scripts/ai_council/vendor_defaults.ts +45 -0
- package/src/scripts/audit_skill_overlap.ts +261 -0
- package/src/scripts/before_complete_hook.ts +243 -12
- package/src/scripts/bench_touched_file_quality.ts +238 -0
- package/src/scripts/check_enforcement_matrix.ts +377 -20
- package/src/scripts/check_estate_count.ts +130 -153
- package/src/scripts/check_finding_dispositions.ts +116 -4
- package/src/scripts/check_hook_bundle_composition.ts +370 -0
- package/src/scripts/check_kernel_edit_ratified.ts +49 -11
- package/src/scripts/check_memory.ts +7 -1
- package/src/scripts/check_release_highlights.ts +10 -0
- package/src/scripts/check_release_pr_shape.ts +38 -15
- package/src/scripts/check_standing_rule_delivery.ts +33 -13
- package/src/scripts/check_verify_expectation_delta.ts +521 -0
- package/src/scripts/code_graph/detect.ts +127 -7
- package/src/scripts/code_graph/foreign.ts +194 -0
- package/src/scripts/code_graph/query.ts +217 -4
- package/src/scripts/code_graph/types.ts +26 -2
- package/src/scripts/code_graph/validate.ts +3 -1
- package/src/scripts/code_graph/verbs.ts +103 -0
- package/src/scripts/compile_hook_manifest.ts +33 -1
- package/src/scripts/condense.ts +14 -27
- package/src/scripts/estate_exemption_shape.ts +202 -0
- package/src/scripts/generate_host_cost_table.ts +1 -1
- package/src/scripts/hook_manifest.json +1 -1
- package/src/scripts/hook_manifest.yaml +150 -9
- package/src/scripts/hooks/block_config_weakening.ts +67 -2
- package/src/scripts/hooks/block_plumbing_writes.ts +29 -1
- package/src/scripts/hooks/code_graph_context_hook.ts +252 -23
- package/src/scripts/hooks/concern_failure_policy.ts +280 -0
- package/src/scripts/hooks/dispatch_hook.ts +52 -52
- package/src/scripts/hooks/exit_codes.ts +2 -1
- package/src/scripts/hooks/host_lowering.json +1 -1
- package/src/scripts/hooks/host_lowering.ts +19 -1
- package/src/scripts/hooks/one_question_per_ask_hook.ts +41 -25
- package/src/scripts/hooks/payload_stub.ts +10 -1
- package/src/scripts/hooks/rule_inject_hook.ts +757 -63
- package/src/scripts/hooks/table_fingerprint.ts +21 -0
- package/src/scripts/hooks/telemetry_usage_hook.ts +64 -8
- package/src/scripts/hooks/turn_end_gate_hook.ts +84 -0
- package/src/scripts/hooks_status.ts +112 -0
- package/src/scripts/injection_scan_hook.ts +7 -0
- package/src/scripts/install.ts +72 -185
- package/src/scripts/installed_layer_report.ts +103 -0
- package/src/scripts/language_mirror_hook.ts +15 -6
- package/src/scripts/learning_sidecar.ts +119 -8
- package/src/scripts/lint_hook_manifest.ts +53 -0
- package/src/scripts/lint_major_migration_sections.ts +156 -26
- package/src/scripts/lint_pack_boundaries.ts +63 -5
- package/src/scripts/lint_rule_law_section.ts +517 -0
- package/src/scripts/lint_workflow_security.ts +161 -5
- package/src/scripts/mcp_server/consumer_tool_catalog.json +53 -0
- package/src/scripts/mcp_server/graph_tools.ts +72 -3
- package/src/scripts/measure_routing_signal.ts +54 -16
- package/src/scripts/measure_skill_ranker_baseline.ts +216 -8
- package/src/scripts/memory_learn_hook.ts +91 -6
- package/src/scripts/model_rule_injection.ts +52 -5
- package/src/scripts/project_thin_rules.ts +34 -327
- package/src/scripts/report_evidence_temperature.ts +657 -0
- package/src/scripts/report_installed_rule_links.ts +157 -0
- package/src/scripts/report_label_agreement.ts +233 -0
- package/src/scripts/report_obligation_mechanism.ts +230 -0
- package/src/scripts/report_single_token_triggers.ts +277 -0
- package/src/scripts/report_skill_ranker_confusion.ts +442 -0
- package/src/scripts/report_standing_payload_by_host.ts +188 -15
- package/src/scripts/report_verification_record_coverage.ts +306 -0
- package/src/scripts/rule_activation_census.ts +5 -2
- package/src/scripts/rule_trigger_eval.ts +9 -9
- package/src/scripts/schemas/review-findings.schema.json +3 -2
- package/src/scripts/schemas/rule.schema.json +5 -0
- package/src/scripts/self_review_gate.ts +62 -7
- package/src/scripts/skill_tools/score_skill_relevance.ts +290 -25
- package/src/scripts/sweep_skill_ranker_signals.ts +129 -0
- package/src/scripts/sync_gitignore.ts +29 -235
- package/src/scripts/trigger_eval_grandfather.json +0 -5
- package/src/server/schemas/settings.ts +10 -0
- package/src/shared/skillRanking.ts +117 -11
- package/dist/cli-delegate/chunk-JNMVLWLR.js +0 -4457
- package/dist/cli-delegate/chunk-YDPILCOL.js +0 -152
package/dist/cli/registry.js
CHANGED
|
@@ -94,7 +94,7 @@ export const REGISTRY = [
|
|
|
94
94
|
{ name: 'memory:hash', disposition: 'delegate', synopsis: 'Hash a memory entry (YAML or JSON stdin).' },
|
|
95
95
|
{ name: 'memory:check', disposition: 'delegate', synopsis: 'Validate memory YAML schema + staleness.' },
|
|
96
96
|
{ name: 'memory:check-proposal', disposition: 'delegate', synopsis: 'Run the admission gate on a memory proposal.' },
|
|
97
|
-
{ name: 'memory:learn', disposition: 'delegate', synopsis: 'Aggregate memory intake signals into the local learning sidecar (read-only; --write to emit).' },
|
|
97
|
+
{ name: 'memory:learn', disposition: 'delegate', synopsis: 'Aggregate memory intake signals into the local learning sidecar (read-only; --write to emit, --format status for the one-screen view).' },
|
|
98
98
|
{ name: 'analytics', disposition: 'delegate', synopsis: 'Local-only workspace analytics: emit|show|prune|migrate (never leaves the machine).' },
|
|
99
99
|
{ name: 'knowledge', disposition: 'delegate', synopsis: 'Global knowledge-card store: list|show|trace|forget|promote|validate|lead-check|purge.' },
|
|
100
100
|
{ name: 'proposal:check', disposition: 'delegate', synopsis: 'Validate a learning/skill/rule proposal markdown.' },
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env tsx
|
|
2
2
|
import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
BLOCK_END_RE,
|
|
5
|
+
DEFERRED_RESOLUTION_RE,
|
|
6
|
+
DEFERRED_STEP_RE,
|
|
7
|
+
planCarry
|
|
8
|
+
} from "./chunk-7IQE3D5S.js";
|
|
3
9
|
import {
|
|
4
10
|
blocker_is_resolved,
|
|
5
11
|
collect,
|
|
6
12
|
parse_blockers
|
|
7
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-PHD7OOLE.js";
|
|
8
14
|
import "./chunk-ULET4BYS.js";
|
|
9
15
|
import {
|
|
10
16
|
isCliEntry
|
|
@@ -199,9 +205,6 @@ function _fs_grep_files(root, needle) {
|
|
|
199
205
|
walk(root);
|
|
200
206
|
return hits;
|
|
201
207
|
}
|
|
202
|
-
var DEFERRED_RESOLUTION_RE = /<!--\s*deferred-resolution:\s*(carried-to|merged-into)\s*=\s*([A-Za-z0-9._-]+)\s*-->/;
|
|
203
|
-
var DEFERRED_STEP_RE = /^[ \t]*[-*][ \t]+\[~\][ \t]*(.*)$/;
|
|
204
|
-
var BLOCK_END_RE = /^[ \t]*[-*][ \t]+\[[ xX~-]\]|^#{1,6}[ \t]/;
|
|
205
208
|
function _escapeRe(v) {
|
|
206
209
|
return v.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
207
210
|
}
|
|
@@ -292,6 +295,7 @@ function deferralProblems(root, rel, text, alsoArchiving = /* @__PURE__ */ new S
|
|
|
292
295
|
}
|
|
293
296
|
function archive_completed(root, opts) {
|
|
294
297
|
const { changed_only, base, dry_run } = opts;
|
|
298
|
+
const carry = opts.carry ?? true;
|
|
295
299
|
const roadmap_root = path.join(root, "agents", "roadmaps");
|
|
296
300
|
if (!_isDir(roadmap_root)) {
|
|
297
301
|
return [];
|
|
@@ -308,8 +312,10 @@ function archive_completed(root, opts) {
|
|
|
308
312
|
collect(roadmap_root).filter((s2) => s2.open_ === 0).map((s2) => s2.rel.replace(/\.md$/, ""))
|
|
309
313
|
);
|
|
310
314
|
const archived = [];
|
|
315
|
+
const only = opts.only ? opts.only.replace(/^.*\//, "").replace(/\.md$/, "") + ".md" : null;
|
|
311
316
|
for (const stats of collect(roadmap_root)) {
|
|
312
|
-
|
|
317
|
+
if (only !== null && stats.rel !== only) continue;
|
|
318
|
+
let roadmapText = fs.readFileSync(path.join(roadmap_root, stats.rel), "utf-8");
|
|
313
319
|
const guarded = parseGuardedBaselines(roadmapText);
|
|
314
320
|
if (guarded.length > 0) {
|
|
315
321
|
process.stderr.write(
|
|
@@ -325,11 +331,41 @@ function archive_completed(root, opts) {
|
|
|
325
331
|
if (stats.open_ !== 0) {
|
|
326
332
|
continue;
|
|
327
333
|
}
|
|
334
|
+
const old_rel = `agents/roadmaps/${stats.rel}`;
|
|
335
|
+
let open_blockers = stats.open_blockers.map((b) => b.id);
|
|
328
336
|
if (stats.deferred !== 0) {
|
|
329
337
|
const abs = path.join(roadmap_root, stats.rel);
|
|
330
338
|
const others = new Set(sweepSet);
|
|
331
339
|
others.delete(stats.rel.replace(/\.md$/, ""));
|
|
332
|
-
const
|
|
340
|
+
const inScope = !changed_only || touched.has(old_rel);
|
|
341
|
+
const bare = parseDeferredItems(roadmapText).some((d) => d.kind === null);
|
|
342
|
+
if (carry && inScope && bare) {
|
|
343
|
+
const outcome = planCarry(root, stats.rel, roadmapText, open_blockers, _today(), opts.owner_decision ?? "ask");
|
|
344
|
+
if ("refused" in outcome) {
|
|
345
|
+
process.stderr.write(` \u26A0\uFE0F ${stats.rel}: deferrals not carried \u2014 ${outcome.refused}.
|
|
346
|
+
`);
|
|
347
|
+
} else if (outcome.plan.ownerBlockers.length > 0 && !outcome.plan.parked) {
|
|
348
|
+
process.stdout.write(_ownerDecisionBlock(stats.rel, outcome.plan));
|
|
349
|
+
continue;
|
|
350
|
+
} else {
|
|
351
|
+
const { plan } = outcome;
|
|
352
|
+
process.stdout.write(
|
|
353
|
+
` \u21AA ${stats.rel}: carried ${plan.carried} deferred step(s)` + (plan.movedBlockers.length > 0 ? ` and blocker(s) ${plan.movedBlockers.join(", ")}` : "") + ` \u2192 ${plan.destRel}
|
|
354
|
+
`
|
|
355
|
+
);
|
|
356
|
+
if (dry_run) {
|
|
357
|
+
archived.push({ roadmap: old_rel, archived_to: `agents/roadmaps/archive/${stats.rel}`, refs_migrated: [] });
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
fs.mkdirSync(path.dirname(path.join(root, plan.destRel)), { recursive: true });
|
|
361
|
+
fs.writeFileSync(path.join(root, plan.destRel), plan.destText, "utf-8");
|
|
362
|
+
fs.writeFileSync(abs, plan.sourceText, "utf-8");
|
|
363
|
+
_run(["git", "add", "--", plan.destRel, old_rel], root);
|
|
364
|
+
roadmapText = plan.sourceText;
|
|
365
|
+
open_blockers = open_blockers.filter((id) => !plan.movedBlockers.includes(id));
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
const problems = deferralProblems(root, stats.rel, roadmapText, others);
|
|
333
369
|
if (problems.length > 0) {
|
|
334
370
|
process.stderr.write(
|
|
335
371
|
` \u26A0\uFE0F ${stats.rel}: ${problems.length} unresolved deferral(s) \u2014 not archived.
|
|
@@ -340,16 +376,14 @@ function archive_completed(root, opts) {
|
|
|
340
376
|
continue;
|
|
341
377
|
}
|
|
342
378
|
}
|
|
343
|
-
const open_blockers = stats.open_blockers;
|
|
344
379
|
if (open_blockers.length > 0) {
|
|
345
|
-
const ids = open_blockers.
|
|
380
|
+
const ids = open_blockers.join(", ");
|
|
346
381
|
process.stderr.write(
|
|
347
382
|
` \u26A0\uFE0F ${stats.rel}: all steps closed but ${open_blockers.length} blocker(s) still open (${ids}) \u2014 not archived. Resolve them, or record the decision, then re-run the sweep.
|
|
348
383
|
`
|
|
349
384
|
);
|
|
350
385
|
continue;
|
|
351
386
|
}
|
|
352
|
-
const old_rel = `agents/roadmaps/${stats.rel}`;
|
|
353
387
|
if (changed_only && !touched.has(old_rel)) {
|
|
354
388
|
continue;
|
|
355
389
|
}
|
|
@@ -383,6 +417,29 @@ function archive_completed(root, opts) {
|
|
|
383
417
|
}
|
|
384
418
|
return archived;
|
|
385
419
|
}
|
|
420
|
+
function _ownerDecisionBlock(rel, plan) {
|
|
421
|
+
const ids = plan.ownerBlockers.join(", ");
|
|
422
|
+
const park = `agents/roadmaps/later/${plan.destSlug}.md`;
|
|
423
|
+
const step = plan.firstStep.split("\n").map((l) => ` ${l}`).join("\n");
|
|
424
|
+
const record = {
|
|
425
|
+
roadmap: `agents/roadmaps/${rel}`,
|
|
426
|
+
owner_blockers: plan.ownerBlockers,
|
|
427
|
+
deferred_steps: plan.carried,
|
|
428
|
+
park_to: park,
|
|
429
|
+
archive_command: `./agent-config roadmap:archive --all --owner-decision later --only ${rel}`,
|
|
430
|
+
first_step: plan.firstStep
|
|
431
|
+
};
|
|
432
|
+
return ` \u2753 ${rel}: ${plan.carried} deferred step(s) wait on owner blocker(s) ${ids} \u2014 not archived; the owner decides:
|
|
433
|
+
1. Archive it \u2014 the steps and their blockers park in ${park}
|
|
434
|
+
(${record.archive_command})
|
|
435
|
+
2. Work them step by step, starting with:
|
|
436
|
+
${step}
|
|
437
|
+
OWNER-DECISION ${JSON.stringify(record)}
|
|
438
|
+
`;
|
|
439
|
+
}
|
|
440
|
+
function _today() {
|
|
441
|
+
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
442
|
+
}
|
|
386
443
|
function _isDir(p) {
|
|
387
444
|
try {
|
|
388
445
|
return fs.statSync(p).isDirectory();
|
|
@@ -443,13 +500,16 @@ function _runTwin(root, script) {
|
|
|
443
500
|
}
|
|
444
501
|
var _PROG = "archive_completed_roadmaps.py";
|
|
445
502
|
function _usage() {
|
|
446
|
-
return `usage: ${_PROG} [-h] [--all] [--base BASE] [--dry-run] [--repo-root REPO_ROOT]
|
|
503
|
+
return `usage: ${_PROG} [-h] [--all] [--base BASE] [--dry-run] [--no-carry] [--owner-decision later] [--only ROADMAP] [--repo-root REPO_ROOT]
|
|
447
504
|
`;
|
|
448
505
|
}
|
|
449
506
|
function _parseArgs(argv) {
|
|
450
507
|
let all = false;
|
|
451
508
|
let base = "origin/main";
|
|
452
509
|
let dry_run = false;
|
|
510
|
+
let carry = true;
|
|
511
|
+
let owner_decision = "ask";
|
|
512
|
+
let only = null;
|
|
453
513
|
let repo_root = null;
|
|
454
514
|
const emitError = (msg) => {
|
|
455
515
|
process.stderr.write(_usage());
|
|
@@ -469,6 +529,23 @@ function _parseArgs(argv) {
|
|
|
469
529
|
} else if (tok === "--dry-run") {
|
|
470
530
|
dry_run = true;
|
|
471
531
|
i += 1;
|
|
532
|
+
} else if (tok === "--no-carry") {
|
|
533
|
+
carry = false;
|
|
534
|
+
i += 1;
|
|
535
|
+
} else if (tok === "--only" || tok.startsWith("--only=")) {
|
|
536
|
+
const val = tok.includes("=") ? tok.slice(tok.indexOf("=") + 1) : argv[i + 1];
|
|
537
|
+
if (val === void 0 || val === "") {
|
|
538
|
+
emitError("argument --only: expected one argument");
|
|
539
|
+
}
|
|
540
|
+
only = val;
|
|
541
|
+
i += tok.includes("=") ? 1 : 2;
|
|
542
|
+
} else if (tok === "--owner-decision" || tok.startsWith("--owner-decision=")) {
|
|
543
|
+
const val = tok.includes("=") ? tok.slice(tok.indexOf("=") + 1) : argv[i + 1];
|
|
544
|
+
if (val !== "later" && val !== "ask") {
|
|
545
|
+
emitError("argument --owner-decision: expected 'later' or 'ask'");
|
|
546
|
+
}
|
|
547
|
+
owner_decision = val;
|
|
548
|
+
i += tok.includes("=") ? 1 : 2;
|
|
472
549
|
} else if (tok === "--base") {
|
|
473
550
|
const val = argv[i + 1];
|
|
474
551
|
if (val === void 0) {
|
|
@@ -493,7 +570,7 @@ function _parseArgs(argv) {
|
|
|
493
570
|
emitError(`unrecognized arguments: ${tok}`);
|
|
494
571
|
}
|
|
495
572
|
}
|
|
496
|
-
return { all, base, dry_run, repo_root };
|
|
573
|
+
return { all, base, dry_run, carry, owner_decision, only, repo_root };
|
|
497
574
|
}
|
|
498
575
|
function main(argv) {
|
|
499
576
|
const ns = _parseArgs(argv ?? process.argv.slice(2));
|
|
@@ -501,7 +578,10 @@ function main(argv) {
|
|
|
501
578
|
const archived = archive_completed(root, {
|
|
502
579
|
changed_only: !ns.all,
|
|
503
580
|
base: ns.base,
|
|
504
|
-
dry_run: ns.dry_run
|
|
581
|
+
dry_run: ns.dry_run,
|
|
582
|
+
carry: ns.carry,
|
|
583
|
+
owner_decision: ns.owner_decision,
|
|
584
|
+
only: ns.only
|
|
505
585
|
});
|
|
506
586
|
if (archived.length === 0) {
|
|
507
587
|
process.stdout.write(" \u2139\uFE0F No completed roadmaps to archive.\n");
|
|
@@ -267,7 +267,18 @@ var MERGEABLE_KEYS = [
|
|
|
267
267
|
// be followed. Class C, so a user still sets it by hand or through the
|
|
268
268
|
// GUI; whitelisting decides only whether the value SURVIVES the merge
|
|
269
269
|
// (ADR-271, road-to-design-intent-conformance 2.3).
|
|
270
|
-
"design.fidelity_mode"
|
|
270
|
+
"design.fidelity_mode",
|
|
271
|
+
// `lean_projection.*` is a per-MACHINE setting and the install it governs is
|
|
272
|
+
// a user-scope one: the layer being thinned is `~/.claude/rules`, which
|
|
273
|
+
// belongs to the machine and not to any checkout. Without these two rows a
|
|
274
|
+
// consumer who wrote the opt-in into the user-global file got no error, no
|
|
275
|
+
// warning and no effect — the same silent-filter defect the two entries
|
|
276
|
+
// above repair, reaching a third key, and unsatisfiable-by-construction on
|
|
277
|
+
// an ADR-020 global-only install, where no project layer exists to carry it.
|
|
278
|
+
// Whitelisting decides only whether a value SURVIVES the merge: it sets
|
|
279
|
+
// nothing, and `installerThinsHost` still refuses a template-only value.
|
|
280
|
+
"lean_projection.mode",
|
|
281
|
+
"lean_projection.hosts"
|
|
271
282
|
];
|
|
272
283
|
var TEMPLATE_RELATIVE = path2.join("src", "config", "agent-settings.template.yml");
|
|
273
284
|
var _PACKAGE_ROOT = path2.resolve(path2.dirname(fileURLToPath(import.meta.url)), "..", "..", "..");
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/install/plan.ts
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
6
|
+
import { join, relative, resolve } from "node:path";
|
|
7
|
+
function sha256File(path) {
|
|
8
|
+
try {
|
|
9
|
+
const data = readFileSync(path);
|
|
10
|
+
return createHash("sha256").update(data).digest("hex");
|
|
11
|
+
} catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function fileEntry(path, kind, options) {
|
|
16
|
+
return {
|
|
17
|
+
path,
|
|
18
|
+
kind,
|
|
19
|
+
sha256: options.hashContent ? sha256File(path) : null
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function walkSourceTree(dir) {
|
|
23
|
+
const out = [];
|
|
24
|
+
walkInto(dir, out);
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
function walkInto(dir, out) {
|
|
28
|
+
let entries;
|
|
29
|
+
try {
|
|
30
|
+
entries = readdirSync(dir).sort();
|
|
31
|
+
} catch {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
for (const name of entries) {
|
|
35
|
+
const full = join(dir, name);
|
|
36
|
+
let isDir;
|
|
37
|
+
try {
|
|
38
|
+
isDir = statSync(full).isDirectory();
|
|
39
|
+
} catch {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (isDir) {
|
|
43
|
+
walkInto(full, out);
|
|
44
|
+
} else {
|
|
45
|
+
out.push(full);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function buildInstallPlan(inputs) {
|
|
50
|
+
const filesByTool = {};
|
|
51
|
+
for (const source of inputs.sources) {
|
|
52
|
+
const bucket = filesByTool[source.toolId] ?? [];
|
|
53
|
+
let files = walkSourceTree(source.srcDir);
|
|
54
|
+
if (source.fileFilter !== void 0) {
|
|
55
|
+
files = files.filter(source.fileFilter);
|
|
56
|
+
}
|
|
57
|
+
for (const srcFile of files) {
|
|
58
|
+
const rel = relative(source.srcDir, srcFile);
|
|
59
|
+
const destPath = resolve(source.destDir, rel);
|
|
60
|
+
bucket.push(
|
|
61
|
+
fileEntry(srcFile, source.kind, {
|
|
62
|
+
hashContent: source.kind !== "bridge"
|
|
63
|
+
})
|
|
64
|
+
);
|
|
65
|
+
bucket[bucket.length - 1] = {
|
|
66
|
+
...bucket[bucket.length - 1],
|
|
67
|
+
path: destPath
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
filesByTool[source.toolId] = bucket;
|
|
71
|
+
}
|
|
72
|
+
for (const source of inputs.sources) {
|
|
73
|
+
if (!(source.toolId in filesByTool)) {
|
|
74
|
+
filesByTool[source.toolId] = [];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
version: 2,
|
|
79
|
+
target: inputs.target,
|
|
80
|
+
root: inputs.root,
|
|
81
|
+
filesByTool,
|
|
82
|
+
mergedKeysByTool: {},
|
|
83
|
+
policy: inputs.policy
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export {
|
|
88
|
+
sha256File,
|
|
89
|
+
buildInstallPlan
|
|
90
|
+
};
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_GITIGNORE,
|
|
4
|
+
DEFAULT_TEMPLATE,
|
|
5
|
+
LEGACY_PATTERNS,
|
|
6
|
+
SECTION_FOOTER,
|
|
7
|
+
SECTION_HEADER,
|
|
8
|
+
TemplateNotFoundError,
|
|
9
|
+
_isFile,
|
|
10
|
+
_splitlines,
|
|
11
|
+
_strip,
|
|
12
|
+
block_entries,
|
|
13
|
+
build_fresh_block,
|
|
14
|
+
cleanup_legacy,
|
|
15
|
+
find_block,
|
|
16
|
+
format_file,
|
|
17
|
+
load_template,
|
|
18
|
+
sync_block,
|
|
19
|
+
template_entries
|
|
20
|
+
} from "./chunk-ULQRUR23.js";
|
|
2
21
|
import {
|
|
3
22
|
resolvePackageRoot
|
|
4
23
|
} from "./chunk-MCJYCQPF.js";
|
|
@@ -82,156 +101,7 @@ import * as fs2 from "node:fs";
|
|
|
82
101
|
import * as path2 from "node:path";
|
|
83
102
|
import process from "node:process";
|
|
84
103
|
import { fileURLToPath as fileURLToPath2, pathToFileURL } from "node:url";
|
|
85
|
-
var SECTION_HEADER = "# event4u/agent-config";
|
|
86
|
-
var SECTION_FOOTER = "# event4u/agent-config \u2014 END";
|
|
87
|
-
var DEFAULT_GITIGNORE = ".gitignore";
|
|
88
104
|
var _HERE = fileURLToPath2(import.meta.url);
|
|
89
|
-
var DEFAULT_TEMPLATE = path2.join(
|
|
90
|
-
path2.dirname(_HERE),
|
|
91
|
-
"..",
|
|
92
|
-
"..",
|
|
93
|
-
"src",
|
|
94
|
-
"config",
|
|
95
|
-
"gitignore-block.txt"
|
|
96
|
-
);
|
|
97
|
-
var LEGACY_PATTERNS = [
|
|
98
|
-
".agent-chat-history",
|
|
99
|
-
".agent-chat-history.bak",
|
|
100
|
-
".agent-chat-history.*.bak",
|
|
101
|
-
".agent-prices.md",
|
|
102
|
-
".council-tmp/",
|
|
103
|
-
// 2.x intermediate: prices cache lived directly under agents/ before
|
|
104
|
-
// consolidating under agents/runtime/.
|
|
105
|
-
"agents/.agent-prices.md",
|
|
106
|
-
// Budget history JSONLs — previously listed explicitly at project
|
|
107
|
-
// root or under agents/; now covered by the /agents/runtime/
|
|
108
|
-
// catch-all in the managed block.
|
|
109
|
-
".augment-budget-history.jsonl",
|
|
110
|
-
".rule-budget-history.jsonl",
|
|
111
|
-
"agents/.augment-budget-history.jsonl",
|
|
112
|
-
"agents/.rule-budget-history.jsonl"
|
|
113
|
-
];
|
|
114
|
-
function _strip(ln) {
|
|
115
|
-
return ln.replace(/\n+$/, "").replace(/\s+$/, "");
|
|
116
|
-
}
|
|
117
|
-
function _is_entry(ln) {
|
|
118
|
-
const s = _strip(ln).replace(/^\s+/, "");
|
|
119
|
-
return Boolean(s) && !s.startsWith("#");
|
|
120
|
-
}
|
|
121
|
-
var TemplateNotFoundError = class extends Error {
|
|
122
|
-
constructor(p) {
|
|
123
|
-
super(`template not found: ${p}`);
|
|
124
|
-
this.name = "TemplateNotFoundError";
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
function _isFile(p) {
|
|
128
|
-
try {
|
|
129
|
-
return fs2.statSync(p).isFile();
|
|
130
|
-
} catch {
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
function _splitlines(text) {
|
|
135
|
-
if (text === "") return [];
|
|
136
|
-
const parts = text.split(/\r\n|\r|\n/);
|
|
137
|
-
if (parts.length > 0 && parts[parts.length - 1] === "") parts.pop();
|
|
138
|
-
return parts;
|
|
139
|
-
}
|
|
140
|
-
function load_template(p) {
|
|
141
|
-
if (!_isFile(p)) {
|
|
142
|
-
throw new TemplateNotFoundError(p);
|
|
143
|
-
}
|
|
144
|
-
const text = fs2.readFileSync(p, "utf-8");
|
|
145
|
-
return _splitlines(text).map(_strip);
|
|
146
|
-
}
|
|
147
|
-
function find_block(lines) {
|
|
148
|
-
for (let i = 0; i < lines.length; i += 1) {
|
|
149
|
-
if (_strip(lines[i]) === SECTION_HEADER) {
|
|
150
|
-
const start = i;
|
|
151
|
-
for (let j = i + 1; j < lines.length; j += 1) {
|
|
152
|
-
if (_strip(lines[j]) === SECTION_FOOTER) {
|
|
153
|
-
return [start, j + 1];
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
let end = lines.length;
|
|
157
|
-
for (let j = i + 1; j < lines.length; j += 1) {
|
|
158
|
-
const s = _strip(lines[j]).replace(/^\s+/, "");
|
|
159
|
-
if (s.startsWith("#") && !s.startsWith("# Agent config") && s !== SECTION_HEADER) {
|
|
160
|
-
end = j;
|
|
161
|
-
while (end > i + 1 && _strip(lines[end - 1]) === "") {
|
|
162
|
-
end -= 1;
|
|
163
|
-
}
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return [start, end];
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return null;
|
|
171
|
-
}
|
|
172
|
-
function block_entries(block_lines) {
|
|
173
|
-
return block_lines.filter((ln) => _is_entry(ln)).map((ln) => _strip(ln).replace(/^\s+/, ""));
|
|
174
|
-
}
|
|
175
|
-
function template_entries(template_lines) {
|
|
176
|
-
return template_lines.filter((ln) => _is_entry(ln)).map((ln) => ln.replace(/^\s+/, ""));
|
|
177
|
-
}
|
|
178
|
-
function build_fresh_block(template_lines) {
|
|
179
|
-
return [SECTION_HEADER, ...template_lines, SECTION_FOOTER];
|
|
180
|
-
}
|
|
181
|
-
function sync_block(existing_lines, template_lines, options = {}) {
|
|
182
|
-
const replace = options.replace ?? false;
|
|
183
|
-
const loc = find_block(existing_lines);
|
|
184
|
-
const fresh = build_fresh_block(template_lines);
|
|
185
|
-
if (loc === null) {
|
|
186
|
-
const newLines = [...existing_lines];
|
|
187
|
-
if (newLines.length > 0 && _strip(newLines[newLines.length - 1]) !== "") {
|
|
188
|
-
newLines.push("");
|
|
189
|
-
}
|
|
190
|
-
newLines.push(...fresh);
|
|
191
|
-
return [newLines, template_entries(template_lines)];
|
|
192
|
-
}
|
|
193
|
-
const [start, end] = loc;
|
|
194
|
-
const head = existing_lines.slice(0, start);
|
|
195
|
-
let block = existing_lines.slice(start, end);
|
|
196
|
-
const tail = existing_lines.slice(end);
|
|
197
|
-
if (replace) {
|
|
198
|
-
const existing = new Set(block_entries(block));
|
|
199
|
-
const added = template_entries(template_lines).filter((e) => !existing.has(e));
|
|
200
|
-
return [[...head, ...fresh, ...tail], added];
|
|
201
|
-
}
|
|
202
|
-
const existing_entries = new Set(block_entries(block));
|
|
203
|
-
const missing = template_entries(template_lines).filter((e) => !existing_entries.has(e));
|
|
204
|
-
if (missing.length === 0) {
|
|
205
|
-
return [[...existing_lines], []];
|
|
206
|
-
}
|
|
207
|
-
let insert_at;
|
|
208
|
-
if (block.length > 0 && _strip(block[block.length - 1]) === SECTION_FOOTER) {
|
|
209
|
-
insert_at = block.length - 1;
|
|
210
|
-
} else {
|
|
211
|
-
block = [...block, SECTION_FOOTER];
|
|
212
|
-
insert_at = block.length - 1;
|
|
213
|
-
}
|
|
214
|
-
const new_block = [...block.slice(0, insert_at), ...missing, ...block.slice(insert_at)];
|
|
215
|
-
return [[...head, ...new_block, ...tail], missing];
|
|
216
|
-
}
|
|
217
|
-
function cleanup_legacy(lines) {
|
|
218
|
-
const legacy = new Set(LEGACY_PATTERNS);
|
|
219
|
-
const kept = [];
|
|
220
|
-
const removed = [];
|
|
221
|
-
for (const ln of lines) {
|
|
222
|
-
const s = _strip(ln).replace(/^\s+/, "");
|
|
223
|
-
if (legacy.has(s) || s.startsWith("/") && legacy.has(s.slice(1))) {
|
|
224
|
-
removed.push(s);
|
|
225
|
-
continue;
|
|
226
|
-
}
|
|
227
|
-
kept.push(ln);
|
|
228
|
-
}
|
|
229
|
-
return [kept, removed];
|
|
230
|
-
}
|
|
231
|
-
function format_file(lines) {
|
|
232
|
-
const text = lines.join("\n");
|
|
233
|
-
return text.replace(/\n+$/, "") + "\n";
|
|
234
|
-
}
|
|
235
105
|
function render_diff(old_text, new_text, p) {
|
|
236
106
|
return unified_diff(
|
|
237
107
|
_splitlinesKeepends(old_text),
|
|
@@ -591,7 +461,7 @@ var DEFAULT_TEMPLATE2 = path3.join(
|
|
|
591
461
|
function _strip2(ln) {
|
|
592
462
|
return ln.replace(/\n+$/, "").replace(/\s+$/, "");
|
|
593
463
|
}
|
|
594
|
-
function
|
|
464
|
+
function _is_entry(ln) {
|
|
595
465
|
const s = _strip2(ln).replace(/^\s+/, "");
|
|
596
466
|
return Boolean(s) && !s.startsWith("#");
|
|
597
467
|
}
|
|
@@ -635,10 +505,10 @@ function find_block2(lines) {
|
|
|
635
505
|
return null;
|
|
636
506
|
}
|
|
637
507
|
function block_entries2(block_lines) {
|
|
638
|
-
return block_lines.filter((ln) =>
|
|
508
|
+
return block_lines.filter((ln) => _is_entry(ln)).map((ln) => _strip2(ln).replace(/^\s+/, ""));
|
|
639
509
|
}
|
|
640
510
|
function template_entries2(template_lines) {
|
|
641
|
-
return template_lines.filter((ln) =>
|
|
511
|
+
return template_lines.filter((ln) => _is_entry(ln)).map((ln) => ln.replace(/^\s+/, ""));
|
|
642
512
|
}
|
|
643
513
|
function build_fresh_block2(template_lines) {
|
|
644
514
|
return [SECTION_HEADER2, ...template_lines, SECTION_FOOTER2];
|