@memnexus-ai/mx-agent-cli 0.1.294-next.0 → 0.1.295-next.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/dist/__tests__/agents-md-canonicalization.test.js +31 -1
- package/dist/__tests__/agents-md-canonicalization.test.js.map +1 -1
- package/dist/__tests__/behavioral-extraction.test.js +50 -0
- package/dist/__tests__/behavioral-extraction.test.js.map +1 -1
- package/dist/__tests__/bootstrap-behavioral-contract.test.js +6 -3
- package/dist/__tests__/bootstrap-behavioral-contract.test.js.map +1 -1
- package/dist/__tests__/bundle-config.test.js +28 -2
- package/dist/__tests__/bundle-config.test.js.map +1 -1
- package/dist/__tests__/catalog-interaction.test.d.ts +25 -0
- package/dist/__tests__/catalog-interaction.test.d.ts.map +1 -0
- package/dist/__tests__/catalog-interaction.test.js +269 -0
- package/dist/__tests__/catalog-interaction.test.js.map +1 -0
- package/dist/__tests__/catalog-named-memories.test.d.ts +2 -0
- package/dist/__tests__/catalog-named-memories.test.d.ts.map +1 -0
- package/dist/__tests__/catalog-named-memories.test.js +204 -0
- package/dist/__tests__/catalog-named-memories.test.js.map +1 -0
- package/dist/__tests__/catalog-origin-main.test.d.ts +15 -0
- package/dist/__tests__/catalog-origin-main.test.d.ts.map +1 -0
- package/dist/__tests__/catalog-origin-main.test.js +296 -0
- package/dist/__tests__/catalog-origin-main.test.js.map +1 -0
- package/dist/__tests__/catalog.test.d.ts +2 -0
- package/dist/__tests__/catalog.test.d.ts.map +1 -0
- package/dist/__tests__/catalog.test.js +131 -0
- package/dist/__tests__/catalog.test.js.map +1 -0
- package/dist/__tests__/cli-build-integration.test.d.ts +2 -0
- package/dist/__tests__/cli-build-integration.test.d.ts.map +1 -0
- package/dist/__tests__/cli-build-integration.test.js +64 -0
- package/dist/__tests__/cli-build-integration.test.js.map +1 -0
- package/dist/__tests__/cli-build.test.d.ts +2 -0
- package/dist/__tests__/cli-build.test.d.ts.map +1 -0
- package/dist/__tests__/cli-build.test.js +640 -0
- package/dist/__tests__/cli-build.test.js.map +1 -0
- package/dist/__tests__/codex-deploy-config.test.js +60 -0
- package/dist/__tests__/codex-deploy-config.test.js.map +1 -1
- package/dist/__tests__/completion-rows-discriminate.test.d.ts +20 -0
- package/dist/__tests__/completion-rows-discriminate.test.d.ts.map +1 -0
- package/dist/__tests__/completion-rows-discriminate.test.js +481 -0
- package/dist/__tests__/completion-rows-discriminate.test.js.map +1 -0
- package/dist/__tests__/config-fidelity-archived-symlinks.test.d.ts +2 -0
- package/dist/__tests__/config-fidelity-archived-symlinks.test.d.ts.map +1 -0
- package/dist/__tests__/config-fidelity-archived-symlinks.test.js +127 -0
- package/dist/__tests__/config-fidelity-archived-symlinks.test.js.map +1 -0
- package/dist/__tests__/config-fidelity-display.test.d.ts +2 -0
- package/dist/__tests__/config-fidelity-display.test.d.ts.map +1 -0
- package/dist/__tests__/config-fidelity-display.test.js +77 -0
- package/dist/__tests__/config-fidelity-display.test.js.map +1 -0
- package/dist/__tests__/config-fidelity.test.js +166 -33
- package/dist/__tests__/config-fidelity.test.js.map +1 -1
- package/dist/__tests__/config-generation-gate.test.js +78 -0
- package/dist/__tests__/config-generation-gate.test.js.map +1 -1
- package/dist/__tests__/config-sync.test.js +35 -0
- package/dist/__tests__/config-sync.test.js.map +1 -1
- package/dist/__tests__/coordination-401-production-wiring.test.js +12 -7
- package/dist/__tests__/coordination-401-production-wiring.test.js.map +1 -1
- package/dist/__tests__/coordination-401-recovery.test.js +39 -32
- package/dist/__tests__/coordination-401-recovery.test.js.map +1 -1
- package/dist/__tests__/coordination-brief-pin.test.js +21 -8
- package/dist/__tests__/coordination-brief-pin.test.js.map +1 -1
- package/dist/__tests__/coordination-client.test.js +227 -3
- package/dist/__tests__/coordination-client.test.js.map +1 -1
- package/dist/__tests__/coordination-credential-endpoint.test.d.ts +24 -0
- package/dist/__tests__/coordination-credential-endpoint.test.d.ts.map +1 -0
- package/dist/__tests__/coordination-credential-endpoint.test.js +1230 -0
- package/dist/__tests__/coordination-credential-endpoint.test.js.map +1 -0
- package/dist/__tests__/coordination-memory.test.js +20 -4
- package/dist/__tests__/coordination-memory.test.js.map +1 -1
- package/dist/__tests__/coordination-provision.test.js +22 -14
- package/dist/__tests__/coordination-provision.test.js.map +1 -1
- package/dist/__tests__/coordination-status-registration.test.d.ts +16 -0
- package/dist/__tests__/coordination-status-registration.test.d.ts.map +1 -0
- package/dist/__tests__/coordination-status-registration.test.js +480 -0
- package/dist/__tests__/coordination-status-registration.test.js.map +1 -0
- package/dist/__tests__/coordination-token-multitenant.test.js +11 -11
- package/dist/__tests__/coordination-token-multitenant.test.js.map +1 -1
- package/dist/__tests__/coordination-token.test.js +35 -28
- package/dist/__tests__/coordination-token.test.js.map +1 -1
- package/dist/__tests__/creation-pr-class-check.test.d.ts +17 -0
- package/dist/__tests__/creation-pr-class-check.test.d.ts.map +1 -0
- package/dist/__tests__/creation-pr-class-check.test.js +346 -0
- package/dist/__tests__/creation-pr-class-check.test.js.map +1 -0
- package/dist/__tests__/digest-team-omission.test.d.ts +15 -0
- package/dist/__tests__/digest-team-omission.test.d.ts.map +1 -0
- package/dist/__tests__/digest-team-omission.test.js +247 -0
- package/dist/__tests__/digest-team-omission.test.js.map +1 -0
- package/dist/__tests__/doctor-worktree-path.test.d.ts +17 -0
- package/dist/__tests__/doctor-worktree-path.test.d.ts.map +1 -0
- package/dist/__tests__/doctor-worktree-path.test.js +158 -0
- package/dist/__tests__/doctor-worktree-path.test.js.map +1 -0
- package/dist/__tests__/fleet-data.test.js +40 -7
- package/dist/__tests__/fleet-data.test.js.map +1 -1
- package/dist/__tests__/fleet-tmux.test.js +2 -2
- package/dist/__tests__/fleet-tmux.test.js.map +1 -1
- package/dist/__tests__/generate-claude.test.js +137 -3
- package/dist/__tests__/generate-claude.test.js.map +1 -1
- package/dist/__tests__/git-env.test.d.ts +14 -0
- package/dist/__tests__/git-env.test.d.ts.map +1 -0
- package/dist/__tests__/git-env.test.js +131 -0
- package/dist/__tests__/git-env.test.js.map +1 -0
- package/dist/__tests__/git-identity-isolation.test.d.ts +33 -0
- package/dist/__tests__/git-identity-isolation.test.d.ts.map +1 -0
- package/dist/__tests__/git-identity-isolation.test.js +626 -0
- package/dist/__tests__/git-identity-isolation.test.js.map +1 -0
- package/dist/__tests__/hook-heal.test.js +17 -0
- package/dist/__tests__/hook-heal.test.js.map +1 -1
- package/dist/__tests__/init-coordination-url.test.d.ts +11 -0
- package/dist/__tests__/init-coordination-url.test.d.ts.map +1 -0
- package/dist/__tests__/init-coordination-url.test.js +114 -0
- package/dist/__tests__/init-coordination-url.test.js.map +1 -0
- package/dist/__tests__/memory-autocreate.test.js +574 -8
- package/dist/__tests__/memory-autocreate.test.js.map +1 -1
- package/dist/__tests__/memory-log-result.test.d.ts +13 -0
- package/dist/__tests__/memory-log-result.test.d.ts.map +1 -0
- package/dist/__tests__/memory-log-result.test.js +113 -0
- package/dist/__tests__/memory-log-result.test.js.map +1 -0
- package/dist/__tests__/memory-named-exists.test.d.ts +16 -0
- package/dist/__tests__/memory-named-exists.test.d.ts.map +1 -0
- package/dist/__tests__/memory-named-exists.test.js +288 -0
- package/dist/__tests__/memory-named-exists.test.js.map +1 -0
- package/dist/__tests__/mx-agent-cli-pin-validation.test.js +23 -47
- package/dist/__tests__/mx-agent-cli-pin-validation.test.js.map +1 -1
- package/dist/__tests__/mx-agent-cli-version-pin.test.js +34 -88
- package/dist/__tests__/mx-agent-cli-version-pin.test.js.map +1 -1
- package/dist/__tests__/new-project-first-team.test.d.ts +15 -0
- package/dist/__tests__/new-project-first-team.test.d.ts.map +1 -0
- package/dist/__tests__/new-project-first-team.test.js +263 -0
- package/dist/__tests__/new-project-first-team.test.js.map +1 -0
- package/dist/__tests__/otel-env.test.d.ts +2 -0
- package/dist/__tests__/otel-env.test.d.ts.map +1 -0
- package/dist/__tests__/otel-env.test.js +127 -0
- package/dist/__tests__/otel-env.test.js.map +1 -0
- package/dist/__tests__/project-config.test.js +283 -1
- package/dist/__tests__/project-config.test.js.map +1 -1
- package/dist/__tests__/provision-behavioral-contract.test.js +96 -4
- package/dist/__tests__/provision-behavioral-contract.test.js.map +1 -1
- package/dist/__tests__/provision-catalog-precondition.test.d.ts +26 -0
- package/dist/__tests__/provision-catalog-precondition.test.d.ts.map +1 -0
- package/dist/__tests__/provision-catalog-precondition.test.js +620 -0
- package/dist/__tests__/provision-catalog-precondition.test.js.map +1 -0
- package/dist/__tests__/provision-completion-rows.test.d.ts +17 -0
- package/dist/__tests__/provision-completion-rows.test.d.ts.map +1 -0
- package/dist/__tests__/provision-completion-rows.test.js +3095 -0
- package/dist/__tests__/provision-completion-rows.test.js.map +1 -0
- package/dist/__tests__/provision-identity-gate.test.d.ts +20 -0
- package/dist/__tests__/provision-identity-gate.test.d.ts.map +1 -0
- package/dist/__tests__/provision-identity-gate.test.js +600 -0
- package/dist/__tests__/provision-identity-gate.test.js.map +1 -0
- package/dist/__tests__/provision-resume.test.d.ts +26 -0
- package/dist/__tests__/provision-resume.test.d.ts.map +1 -0
- package/dist/__tests__/provision-resume.test.js +1164 -0
- package/dist/__tests__/provision-resume.test.js.map +1 -0
- package/dist/__tests__/provision-roleguide-anchors.test.d.ts +27 -0
- package/dist/__tests__/provision-roleguide-anchors.test.d.ts.map +1 -0
- package/dist/__tests__/provision-roleguide-anchors.test.js +747 -0
- package/dist/__tests__/provision-roleguide-anchors.test.js.map +1 -0
- package/dist/__tests__/provision-skeleton-fill.test.d.ts +16 -0
- package/dist/__tests__/provision-skeleton-fill.test.d.ts.map +1 -0
- package/dist/__tests__/provision-skeleton-fill.test.js +488 -0
- package/dist/__tests__/provision-skeleton-fill.test.js.map +1 -0
- package/dist/__tests__/provision-teambuilder-flow.test.js +93 -7
- package/dist/__tests__/provision-teambuilder-flow.test.js.map +1 -1
- package/dist/__tests__/repo-guard-wiring.test.d.ts +21 -0
- package/dist/__tests__/repo-guard-wiring.test.d.ts.map +1 -0
- package/dist/__tests__/repo-guard-wiring.test.js +638 -0
- package/dist/__tests__/repo-guard-wiring.test.js.map +1 -0
- package/dist/__tests__/runtime-codex-gateway-pilot.test.d.ts +2 -0
- package/dist/__tests__/runtime-codex-gateway-pilot.test.d.ts.map +1 -0
- package/dist/__tests__/runtime-codex-gateway-pilot.test.js +309 -0
- package/dist/__tests__/runtime-codex-gateway-pilot.test.js.map +1 -0
- package/dist/__tests__/runtime-codex-gateway-provider.test.d.ts +2 -0
- package/dist/__tests__/runtime-codex-gateway-provider.test.d.ts.map +1 -0
- package/dist/__tests__/runtime-codex-gateway-provider.test.js +163 -0
- package/dist/__tests__/runtime-codex-gateway-provider.test.js.map +1 -0
- package/dist/__tests__/runtime-identity.test.d.ts +2 -0
- package/dist/__tests__/runtime-identity.test.d.ts.map +1 -0
- package/dist/__tests__/runtime-identity.test.js +117 -0
- package/dist/__tests__/runtime-identity.test.js.map +1 -0
- package/dist/__tests__/session-pause-provisioning.test.js +6 -1
- package/dist/__tests__/session-pause-provisioning.test.js.map +1 -1
- package/dist/__tests__/session-record-disclosure.test.d.ts +24 -0
- package/dist/__tests__/session-record-disclosure.test.d.ts.map +1 -0
- package/dist/__tests__/session-record-disclosure.test.js +494 -0
- package/dist/__tests__/session-record-disclosure.test.js.map +1 -0
- package/dist/__tests__/session.test.js +35 -0
- package/dist/__tests__/session.test.js.map +1 -1
- package/dist/__tests__/slug-validation.test.js +27 -21
- package/dist/__tests__/slug-validation.test.js.map +1 -1
- package/dist/__tests__/standards-injection.test.js +23 -1
- package/dist/__tests__/standards-injection.test.js.map +1 -1
- package/dist/__tests__/start-interactive-role.test.d.ts +22 -0
- package/dist/__tests__/start-interactive-role.test.d.ts.map +1 -0
- package/dist/__tests__/start-interactive-role.test.js +204 -0
- package/dist/__tests__/start-interactive-role.test.js.map +1 -0
- package/dist/__tests__/start-team-identity.test.d.ts +25 -0
- package/dist/__tests__/start-team-identity.test.d.ts.map +1 -0
- package/dist/__tests__/start-team-identity.test.js +307 -0
- package/dist/__tests__/start-team-identity.test.js.map +1 -0
- package/dist/__tests__/team-memory-commands.test.js +142 -19
- package/dist/__tests__/team-memory-commands.test.js.map +1 -1
- package/dist/__tests__/template-sync.test.d.ts +19 -0
- package/dist/__tests__/template-sync.test.d.ts.map +1 -0
- package/dist/__tests__/template-sync.test.js +270 -0
- package/dist/__tests__/template-sync.test.js.map +1 -0
- package/dist/__tests__/test-project.test.d.ts +18 -0
- package/dist/__tests__/test-project.test.d.ts.map +1 -0
- package/dist/__tests__/test-project.test.js +465 -0
- package/dist/__tests__/test-project.test.js.map +1 -0
- package/dist/__tests__/usage-per-call-grouping.test.d.ts +25 -0
- package/dist/__tests__/usage-per-call-grouping.test.d.ts.map +1 -0
- package/dist/__tests__/usage-per-call-grouping.test.js +952 -0
- package/dist/__tests__/usage-per-call-grouping.test.js.map +1 -0
- package/dist/__tests__/verify-hooks-check-all.test.d.ts +32 -0
- package/dist/__tests__/verify-hooks-check-all.test.d.ts.map +1 -0
- package/dist/__tests__/verify-hooks-check-all.test.js +553 -0
- package/dist/__tests__/verify-hooks-check-all.test.js.map +1 -0
- package/dist/__tests__/worktree-sync-fixture.test.d.ts +17 -0
- package/dist/__tests__/worktree-sync-fixture.test.d.ts.map +1 -0
- package/dist/__tests__/worktree-sync-fixture.test.js +519 -0
- package/dist/__tests__/worktree-sync-fixture.test.js.map +1 -0
- package/dist/__tests__/worktree-sync-hardening.test.d.ts +13 -0
- package/dist/__tests__/worktree-sync-hardening.test.d.ts.map +1 -0
- package/dist/__tests__/worktree-sync-hardening.test.js +919 -0
- package/dist/__tests__/worktree-sync-hardening.test.js.map +1 -0
- package/dist/__tests__/worktree-sync-shell-free.test.d.ts +25 -0
- package/dist/__tests__/worktree-sync-shell-free.test.d.ts.map +1 -0
- package/dist/__tests__/worktree-sync-shell-free.test.js +185 -0
- package/dist/__tests__/worktree-sync-shell-free.test.js.map +1 -0
- package/dist/__tests__/worktree.test.js +75 -1
- package/dist/__tests__/worktree.test.js.map +1 -1
- package/dist/agent-config/.mx-config-generation.json +2 -2
- package/dist/agent-config/AGENTS.md.template +2 -2
- package/dist/agent-config/agents/bar-raiser.md +34 -1
- package/dist/agent-config/agents/red-team.md +34 -1
- package/dist/agent-config/agents/security-reviewer.md +22 -1
- package/dist/agent-config/claude-md/CLAUDE.core.md +6 -1
- package/dist/agent-config/claude-md/CLAUDE.overlay.memnexus.md +1 -3
- package/dist/agent-config/coordination-rosters.generated.json +10 -0
- package/dist/agent-config/hooks/HOOK-TIMEOUTS.md +27 -1
- package/dist/agent-config/hooks/OR-TRUE-AUDIT.md +8 -8
- package/dist/agent-config/hooks/auto-capture-precompact.sh +279 -0
- package/dist/agent-config/hooks/auto-capture-session-end.sh +277 -0
- package/dist/agent-config/hooks/coordination-brief.sh +290 -245
- package/dist/agent-config/hooks/deploy-verification-reminder.sh +359 -22
- package/dist/agent-config/hooks/git-mutation-guard.sh +85 -13
- package/dist/agent-config/hooks/session-idle-gate.sh +177 -12
- package/dist/agent-config/hooks/subagent-write-guard.sh +670 -0
- package/dist/agent-config/hooks/worktree-guard.sh +36 -7
- package/dist/agent-config/settings.json +15 -2
- package/dist/agent-config/shared/creation-pr-review-checklist.md +317 -0
- package/dist/commands/bootstrap.d.ts.map +1 -1
- package/dist/commands/bootstrap.js +22 -10
- package/dist/commands/bootstrap.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +28 -1
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/coordination.d.ts +150 -8
- package/dist/commands/coordination.d.ts.map +1 -1
- package/dist/commands/coordination.js +519 -25
- package/dist/commands/coordination.js.map +1 -1
- package/dist/commands/create.d.ts +913 -1
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +4879 -345
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/digest.d.ts.map +1 -1
- package/dist/commands/digest.js +91 -7
- package/dist/commands/digest.js.map +1 -1
- package/dist/commands/fleet-tmux.js +1 -1
- package/dist/commands/fleet-tmux.js.map +1 -1
- package/dist/commands/init.d.ts +8 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +26 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/list.d.ts +32 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +98 -5
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/new.d.ts +2 -0
- package/dist/commands/new.d.ts.map +1 -1
- package/dist/commands/new.js +114 -21
- package/dist/commands/new.js.map +1 -1
- package/dist/commands/session.js +1 -1
- package/dist/commands/session.js.map +1 -1
- package/dist/commands/start.d.ts +38 -0
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +171 -8
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/sync.d.ts +57 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +117 -3
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/usage.d.ts +64 -0
- package/dist/commands/usage.d.ts.map +1 -1
- package/dist/commands/usage.js +96 -3
- package/dist/commands/usage.js.map +1 -1
- package/dist/commands/verify-hooks.d.ts +37 -1
- package/dist/commands/verify-hooks.d.ts.map +1 -1
- package/dist/commands/verify-hooks.js +114 -2
- package/dist/commands/verify-hooks.js.map +1 -1
- package/dist/commands/window.d.ts +10 -0
- package/dist/commands/window.d.ts.map +1 -0
- package/dist/commands/window.js +265 -0
- package/dist/commands/window.js.map +1 -0
- package/dist/commands/worktree-sync.d.ts +54 -0
- package/dist/commands/worktree-sync.d.ts.map +1 -0
- package/dist/commands/worktree-sync.js +135 -0
- package/dist/commands/worktree-sync.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +122 -11
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-session.d.ts.map +1 -1
- package/dist/lib/agent-session.js +6 -1
- package/dist/lib/agent-session.js.map +1 -1
- package/dist/lib/catalog.d.ts +321 -2
- package/dist/lib/catalog.d.ts.map +1 -1
- package/dist/lib/catalog.js +490 -11
- package/dist/lib/catalog.js.map +1 -1
- package/dist/lib/claude.d.ts +53 -23
- package/dist/lib/claude.d.ts.map +1 -1
- package/dist/lib/claude.js +306 -17
- package/dist/lib/claude.js.map +1 -1
- package/dist/lib/cli-build.d.ts +172 -0
- package/dist/lib/cli-build.d.ts.map +1 -0
- package/dist/lib/cli-build.js +654 -0
- package/dist/lib/cli-build.js.map +1 -0
- package/dist/lib/code-context-file.d.ts +109 -0
- package/dist/lib/code-context-file.d.ts.map +1 -0
- package/dist/lib/code-context-file.js +219 -0
- package/dist/lib/code-context-file.js.map +1 -0
- package/dist/lib/code-context-file.test.d.ts +19 -0
- package/dist/lib/code-context-file.test.d.ts.map +1 -0
- package/dist/lib/code-context-file.test.js +202 -0
- package/dist/lib/code-context-file.test.js.map +1 -0
- package/dist/lib/config-fidelity.d.ts +40 -20
- package/dist/lib/config-fidelity.d.ts.map +1 -1
- package/dist/lib/config-fidelity.js +144 -56
- package/dist/lib/config-fidelity.js.map +1 -1
- package/dist/lib/coordination-client.d.ts +73 -0
- package/dist/lib/coordination-client.d.ts.map +1 -1
- package/dist/lib/coordination-client.js +180 -8
- package/dist/lib/coordination-client.js.map +1 -1
- package/dist/lib/coordination-token.d.ts +304 -6
- package/dist/lib/coordination-token.d.ts.map +1 -1
- package/dist/lib/coordination-token.js +851 -52
- package/dist/lib/coordination-token.js.map +1 -1
- package/dist/lib/fleet-data.d.ts +34 -0
- package/dist/lib/fleet-data.d.ts.map +1 -1
- package/dist/lib/fleet-data.js +37 -9
- package/dist/lib/fleet-data.js.map +1 -1
- package/dist/lib/fleet-render.js +1 -1
- package/dist/lib/fleet-render.js.map +1 -1
- package/dist/lib/git-identity.d.ts +302 -0
- package/dist/lib/git-identity.d.ts.map +1 -0
- package/dist/lib/git-identity.js +546 -0
- package/dist/lib/git-identity.js.map +1 -0
- package/dist/lib/hook-staleness.d.ts +95 -0
- package/dist/lib/hook-staleness.d.ts.map +1 -0
- package/dist/lib/hook-staleness.js +304 -0
- package/dist/lib/hook-staleness.js.map +1 -0
- package/dist/lib/jsonl.d.ts +270 -2
- package/dist/lib/jsonl.d.ts.map +1 -1
- package/dist/lib/jsonl.js +472 -76
- package/dist/lib/jsonl.js.map +1 -1
- package/dist/lib/memory.d.ts +350 -23
- package/dist/lib/memory.d.ts.map +1 -1
- package/dist/lib/memory.js +751 -38
- package/dist/lib/memory.js.map +1 -1
- package/dist/lib/otel-env.d.ts +90 -0
- package/dist/lib/otel-env.d.ts.map +1 -0
- package/dist/lib/otel-env.js +98 -0
- package/dist/lib/otel-env.js.map +1 -0
- package/dist/lib/project-config.d.ts +167 -0
- package/dist/lib/project-config.d.ts.map +1 -1
- package/dist/lib/project-config.js +321 -5
- package/dist/lib/project-config.js.map +1 -1
- package/dist/lib/projects-registry.d.ts +82 -0
- package/dist/lib/projects-registry.d.ts.map +1 -0
- package/dist/lib/projects-registry.js +145 -0
- package/dist/lib/projects-registry.js.map +1 -0
- package/dist/lib/projects-registry.test.d.ts +2 -0
- package/dist/lib/projects-registry.test.d.ts.map +1 -0
- package/dist/lib/projects-registry.test.js +176 -0
- package/dist/lib/projects-registry.test.js.map +1 -0
- package/dist/lib/repo-guard-scope.d.ts +126 -0
- package/dist/lib/repo-guard-scope.d.ts.map +1 -0
- package/dist/lib/repo-guard-scope.js +249 -0
- package/dist/lib/repo-guard-scope.js.map +1 -0
- package/dist/lib/roster.d.ts +87 -0
- package/dist/lib/roster.d.ts.map +1 -0
- package/dist/lib/roster.js +332 -0
- package/dist/lib/roster.js.map +1 -0
- package/dist/lib/roster.test.d.ts +15 -0
- package/dist/lib/roster.test.d.ts.map +1 -0
- package/dist/lib/roster.test.js +299 -0
- package/dist/lib/roster.test.js.map +1 -0
- package/dist/lib/runtime/codex-adapter.d.ts.map +1 -1
- package/dist/lib/runtime/codex-adapter.js +5 -0
- package/dist/lib/runtime/codex-adapter.js.map +1 -1
- package/dist/lib/runtime/codex-config.d.ts +129 -0
- package/dist/lib/runtime/codex-config.d.ts.map +1 -1
- package/dist/lib/runtime/codex-config.js +225 -0
- package/dist/lib/runtime/codex-config.js.map +1 -1
- package/dist/lib/runtime/identity.d.ts +72 -0
- package/dist/lib/runtime/identity.d.ts.map +1 -0
- package/dist/lib/runtime/identity.js +128 -0
- package/dist/lib/runtime/identity.js.map +1 -0
- package/dist/lib/standards.d.ts +10 -1
- package/dist/lib/standards.d.ts.map +1 -1
- package/dist/lib/standards.js +8 -1
- package/dist/lib/standards.js.map +1 -1
- package/dist/lib/team-identity.d.ts +134 -0
- package/dist/lib/team-identity.d.ts.map +1 -0
- package/dist/lib/team-identity.js +193 -0
- package/dist/lib/team-identity.js.map +1 -0
- package/dist/lib/templates.d.ts +29 -2
- package/dist/lib/templates.d.ts.map +1 -1
- package/dist/lib/templates.js +1042 -82
- package/dist/lib/templates.js.map +1 -1
- package/dist/lib/test-project.d.ts +95 -0
- package/dist/lib/test-project.d.ts.map +1 -0
- package/dist/lib/test-project.js +103 -0
- package/dist/lib/test-project.js.map +1 -0
- package/dist/lib/vault.d.ts +60 -0
- package/dist/lib/vault.d.ts.map +1 -0
- package/dist/lib/vault.js +102 -0
- package/dist/lib/vault.js.map +1 -0
- package/dist/lib/vault.test.d.ts +17 -0
- package/dist/lib/vault.test.d.ts.map +1 -0
- package/dist/lib/vault.test.js +169 -0
- package/dist/lib/vault.test.js.map +1 -0
- package/dist/lib/window-view.d.ts +63 -0
- package/dist/lib/window-view.d.ts.map +1 -0
- package/dist/lib/window-view.js +217 -0
- package/dist/lib/window-view.js.map +1 -0
- package/dist/lib/window-view.test.d.ts +2 -0
- package/dist/lib/window-view.test.d.ts.map +1 -0
- package/dist/lib/window-view.test.js +168 -0
- package/dist/lib/window-view.test.js.map +1 -0
- package/dist/lib/worktree-sync.d.ts +439 -0
- package/dist/lib/worktree-sync.d.ts.map +1 -0
- package/dist/lib/worktree-sync.js +1167 -0
- package/dist/lib/worktree-sync.js.map +1 -0
- package/dist/lib/worktree.d.ts +58 -1
- package/dist/lib/worktree.d.ts.map +1 -1
- package/dist/lib/worktree.js +91 -4
- package/dist/lib/worktree.js.map +1 -1
- package/dist/standards/decision-request.md +8 -0
- package/dist/standards/po-communication-standard.md +126 -0
- package/dist/standards/report-format.md +8 -0
- package/dist/standards/writing-standard.md +146 -4
- package/package.json +1 -1
- package/scripts/generate-claude.mjs +119 -46
|
@@ -132,6 +132,48 @@ SESSION_ID=$(echo "$INPUT" | jq -r '.session_id // empty' 2>/dev/null) || SESSIO
|
|
|
132
132
|
# second field. It is only ever COMPARED, never printed into the agent-visible
|
|
133
133
|
# message, so no harness-supplied text reaches agent context through this hook.
|
|
134
134
|
SESSION_ID="${SESSION_ID//[^a-zA-Z0-9_-]/}"
|
|
135
|
+
# Bound the length as well as the alphabet, mirroring
|
|
136
|
+
# memory-checkpoint-reminder.sh:304-319. This value is a filename component
|
|
137
|
+
# further down, NAME_MAX is 255 bytes, and the composite key added for #50 makes
|
|
138
|
+
# that name longer. A real session id is a 36-character UUID, so nothing the
|
|
139
|
+
# harness sends is truncated. The same bound is applied to the value read back
|
|
140
|
+
# from the state file, so a long stored id still compares equal to its own
|
|
141
|
+
# session rather than silently becoming a different one.
|
|
142
|
+
SESSION_ID="${SESSION_ID:0:64}"
|
|
143
|
+
|
|
144
|
+
# -- Agent attribution (#50) --------------------------------------------------
|
|
145
|
+
# A dispatched subagent runs under its DISPATCHER'S session id. That is verified
|
|
146
|
+
# in the fleet's own transcripts and recorded at memory-checkpoint-reminder.sh:79-92:
|
|
147
|
+
# a subagent's records live at
|
|
148
|
+
# <projectDir>/<sessionId>/subagents/agent-<agentId>.jsonl, and every line in the
|
|
149
|
+
# child file carries the parent's session id.
|
|
150
|
+
#
|
|
151
|
+
# So .session_id alone cannot tell a lead apart from the subagents it dispatched.
|
|
152
|
+
# Once the lead merged, every teammate in the worktree matched the stored id, was
|
|
153
|
+
# classified `self`, and took the demanding branch on every Bash call. The
|
|
154
|
+
# one-shot suppression below covers `other` only, so that demand repeated until
|
|
155
|
+
# the state cleared or 30 minutes passed. Four witnesses saw it on 2026-08-21
|
|
156
|
+
# (#50); a larger count on 2026-08-22 is unsourced.
|
|
157
|
+
#
|
|
158
|
+
# .agent_id, not .agent_type: the harness sets agent_id only inside a dispatched
|
|
159
|
+
# subagent, while agent_type is ALSO set on the main thread of an --agent
|
|
160
|
+
# session. Branching on agent_type would reclassify a real lead as a subagent.
|
|
161
|
+
# The two sources for that are quoted in full at memory-checkpoint-reminder.sh:38-68.
|
|
162
|
+
#
|
|
163
|
+
# A MISSING agent_id FIELD KEEPS TODAY'S BEHAVIOUR. An older harness that never
|
|
164
|
+
# sends the field, and a main thread on a harness that does, both parse to the
|
|
165
|
+
# empty string. Empty on both sides compares equal, so attribution falls back to
|
|
166
|
+
# the session comparison exactly as before this change. An empty agent id never
|
|
167
|
+
# routes to `unknown`: absence is the normal main-thread case, not a failure to
|
|
168
|
+
# attribute.
|
|
169
|
+
#
|
|
170
|
+
# Same load-bearing `|| AGENT_ID=""` as the two captures above: a broken jq must
|
|
171
|
+
# degrade, not return non-zero into this script's ERR trap. The value is only
|
|
172
|
+
# compared and used as a filename component, and it is never printed into the
|
|
173
|
+
# agent-visible message, so no harness-supplied text reaches agent context.
|
|
174
|
+
AGENT_ID=$(echo "$INPUT" | jq -r '.agent_id // empty' 2>/dev/null) || AGENT_ID=""
|
|
175
|
+
AGENT_ID="${AGENT_ID//[^a-zA-Z0-9_-]/}"
|
|
176
|
+
AGENT_ID="${AGENT_ID:0:64}"
|
|
135
177
|
|
|
136
178
|
WORKTREE_NAME="${CLAUDE_WORKTREE_NAME:-default}"
|
|
137
179
|
# Sanitize: alphanumeric, hyphens, underscores only — prevent path traversal
|
|
@@ -173,10 +215,213 @@ emit_telemetry() {
|
|
|
173
215
|
>/dev/null 2>&1 || true
|
|
174
216
|
}
|
|
175
217
|
|
|
218
|
+
# ── Command text scan (#50, Must Fix 2) ──────────────────────────────────────
|
|
219
|
+
# Reduce the raw command to the text the shell actually RUNS, then match against
|
|
220
|
+
# that. Both matchers below use it, so the two halves of one merge-verify cycle
|
|
221
|
+
# are judged by one rule.
|
|
222
|
+
#
|
|
223
|
+
# WHY A PARSER AND NOT AN ANCHOR. .tool_input.command holds the whole multi-line
|
|
224
|
+
# text of one Bash call, heredoc body included; the Bash tool_input has only
|
|
225
|
+
# command, description and timeout, so there is no structured field to read
|
|
226
|
+
# instead. Piping that string into grep re-anchors ^ at every line, so a heredoc
|
|
227
|
+
# body naming a command set the latch with no command run. An earlier fix
|
|
228
|
+
# narrowed the anchor instead, and the security review of 70fca59 measured what
|
|
229
|
+
# that missed: `bash <<EOF` with a merge in the body, `echo "$(gh pr merge 5)"`,
|
|
230
|
+
# and a merge on any line after a line containing a quote. All three run a merge
|
|
231
|
+
# and none latched. Deciding on the PRESENCE of a quote cannot separate those
|
|
232
|
+
# from prose; only deciding on what the quote ENCLOSES can.
|
|
233
|
+
#
|
|
234
|
+
# THE THREE FUNCTIONS BELOW ARE COPIED VERBATIM from subagent-write-guard.sh
|
|
235
|
+
# (fold_continuations :312-315, strip_heredocs :330-372, split_segments
|
|
236
|
+
# :382-482), where they are the tested construction for this exact question.
|
|
237
|
+
# Copied rather than shared: a shared hook library would put a single defect in
|
|
238
|
+
# reach of every gate at once, which is the standing argument recorded in
|
|
239
|
+
# hook-timing-parity.test.sh. Divergence across the copies is tracked in #49.
|
|
240
|
+
# Do not edit them here without checking that file.
|
|
241
|
+
#
|
|
242
|
+
# fold_continuations joins a backslash line continuation, so `gh pr \<nl> merge`
|
|
243
|
+
# is one line to the matchers.
|
|
244
|
+
# strip_heredocs drops an inert body (quoted delimiter), keeps a body the
|
|
245
|
+
# consumer executes (bash/sh/eval/source or a pipe into
|
|
246
|
+
# one), and keeps only the substituting lines of a body the
|
|
247
|
+
# shell expands (unquoted delimiter).
|
|
248
|
+
# split_segments emits one command per line, splitting on unquoted ; && ||
|
|
249
|
+
# and |, and blanks quoted text in segments whose leading
|
|
250
|
+
# command is a text sink (echo, printf, cat, tee, grep, jq,
|
|
251
|
+
# mx --content, gh --body, git commit -m). A segment holding
|
|
252
|
+
# $( or a backtick is never a sink, because the blanker
|
|
253
|
+
# cannot tell text from an executed substitution.
|
|
254
|
+
fold_continuations() {
|
|
255
|
+
sed -e :a -e '/\\$/N; s/\\\n[[:space:]]*/ /; ta' 2>/dev/null || true
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
strip_heredocs() {
|
|
259
|
+
awk '
|
|
260
|
+
!inbody {
|
|
261
|
+
line = $0
|
|
262
|
+
if (match(line, /<<[-]?[[:space:]]*["'"'"']?[A-Za-z_][A-Za-z0-9_]*["'"'"']?/)) {
|
|
263
|
+
d = substr(line, RSTART, RLENGTH)
|
|
264
|
+
# ORDER IS LOAD-BEARING. Read the quoting off the RAW match, BEFORE the
|
|
265
|
+
# two gsubs below strip the quotes out of d. Computed after them this test
|
|
266
|
+
# is always true, and the <<QUOTED bodies the shell leaves inert would be
|
|
267
|
+
# scanned as if they expanded.
|
|
268
|
+
unquoted = (d !~ /["'"'"']/)
|
|
269
|
+
gsub(/<<[-]?[[:space:]]*["'"'"']?/, "", d)
|
|
270
|
+
gsub(/["'"'"'].*/, "", d)
|
|
271
|
+
delim = d
|
|
272
|
+
inbody = 1
|
|
273
|
+
keepbody = 0
|
|
274
|
+
if (line ~ /(^|[^[:alnum:]_])(bash|sh|zsh|dash|ksh|eval|source)([^[:alnum:]_]|$)/) keepbody = 1
|
|
275
|
+
if (line ~ /(^|[[:space:]])\.[[:space:]]/) keepbody = 1
|
|
276
|
+
if (line ~ /\|[^|]*(bash|sh|zsh|dash|ksh|eval)([^[:alnum:]_]|$)/) keepbody = 1
|
|
277
|
+
# WHO EXECUTES THE BODY IS TWO QUESTIONS, NOT ONE. The three tests above
|
|
278
|
+
# ask whether the CONSUMER runs the body. They never asked whether the
|
|
279
|
+
# SHELL expands it first. With an unquoted delimiter bash performs command
|
|
280
|
+
# substitution on every body line before the consumer sees anything, so
|
|
281
|
+
# `cat <<EOF` holding `$(gh pr merge 1)` runs the merge and hands cat the
|
|
282
|
+
# output. Measured on f90382b: that form, the <<-EOF form, the backtick
|
|
283
|
+
# form, `cat > f <<EOF` and `tee f <<EOF` were all allowed, while the
|
|
284
|
+
# shell expanded every one of them. keepbody 2 keeps ONLY the lines that
|
|
285
|
+
# carry a substitution, so a heredoc of plain prose naming a refused
|
|
286
|
+
# command stays allowed and the invariant in ACCEPTED COST holds again.
|
|
287
|
+
if (keepbody == 0 && unquoted) keepbody = 2
|
|
288
|
+
}
|
|
289
|
+
print line
|
|
290
|
+
next
|
|
291
|
+
}
|
|
292
|
+
{
|
|
293
|
+
t = $0
|
|
294
|
+
gsub(/^[[:space:]]+/, "", t)
|
|
295
|
+
if (t == delim) { inbody = 0; keepbody = 0; next }
|
|
296
|
+
if (keepbody == 1) print $0
|
|
297
|
+
else if (keepbody == 2 && ($0 ~ /\$\(/ || $0 ~ /`/)) print $0
|
|
298
|
+
}
|
|
299
|
+
' 2>/dev/null || true
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
split_segments() {
|
|
303
|
+
awk '
|
|
304
|
+
function get_lead_cmd(seg, s) {
|
|
305
|
+
s = seg; gsub(/^[[:space:]]+/, "", s)
|
|
306
|
+
while (match(s, /^[A-Za-z_][A-Za-z0-9_]*=[^[:space:]]*[[:space:]]+/))
|
|
307
|
+
s = substr(s, RSTART + RLENGTH)
|
|
308
|
+
while (match(s, /^[0-9]*[<>][>&]?[^[:space:]]*[[:space:]]+/))
|
|
309
|
+
s = substr(s, RSTART + RLENGTH)
|
|
310
|
+
if (match(s, /^[^[:space:]]+/)) return substr(s, RSTART, RLENGTH)
|
|
311
|
+
return ""
|
|
312
|
+
}
|
|
313
|
+
function check_sink(seg, cmd, s, sc) {
|
|
314
|
+
# A COMMAND SUBSTITUTION IS NEVER TEXT. This clause runs FIRST, before any
|
|
315
|
+
# carrier is recognised, and it is the whole reason blanking was unsafe: the
|
|
316
|
+
# blanker erases a quoted region, and `$( )` or a backtick inside that region
|
|
317
|
+
# is text to the blanker and an executed command to the shell. So
|
|
318
|
+
# `echo "$(gh pr merge 1)"` merged the pull request while this function
|
|
319
|
+
# classified it as prose. Measured on 6d6249c for echo, printf, cat, tee,
|
|
320
|
+
# git commit -m, gh --body and the backtick form: all seven allowed. The
|
|
321
|
+
# degraded no-jq branch does no blanking and caught every one of them, so the
|
|
322
|
+
# guard was WEAKER with jq than without. Returning 0 here means "not a sink",
|
|
323
|
+
# which leaves the quotes intact and lets the matcher see the invocation.
|
|
324
|
+
if (seg ~ /\$\(/ || seg ~ /`/) return 0
|
|
325
|
+
cmd = get_lead_cmd(seg)
|
|
326
|
+
if (cmd == "echo" || cmd == "printf" || cmd == "cat" || cmd == "tee" || cmd == "write")
|
|
327
|
+
return 1
|
|
328
|
+
# PATTERN CARRIERS. These take their argument as a pattern or a literal and
|
|
329
|
+
# never execute it. Without them a subagent cannot search for, or record, the
|
|
330
|
+
# name of a command this guard refuses.
|
|
331
|
+
if (cmd == "grep" || cmd == "rg" || cmd == "jq")
|
|
332
|
+
return 1
|
|
333
|
+
# THE MEMORY PATH. AGENTS.md makes MemNexus the sole memory store, so a
|
|
334
|
+
# memory-creator recording the lesson about this guard has to be able to name
|
|
335
|
+
# the command in --content. Measured on 6d6249c: it could not.
|
|
336
|
+
if ((cmd == "mx" || cmd == "mx-agent") && (seg ~ /--content/ || seg ~ /--body/ || seg ~ /--query/))
|
|
337
|
+
return 1
|
|
338
|
+
if (cmd == "gh" && (seg ~ /--body/ || seg ~ /--title/ || seg ~ /--comment/))
|
|
339
|
+
return 1
|
|
340
|
+
if (cmd == "git") {
|
|
341
|
+
s = seg; gsub(/^[[:space:]]+/, "", s); sub(/^git[[:space:]]+/, "", s)
|
|
342
|
+
while (match(s, /^(-C[[:space:]]+[^[:space:]]+|-c[[:space:]]+[^[:space:]]+|--[a-z][-a-z0-9]*(=[^[:space:]]*)?)[[:space:]]+/))
|
|
343
|
+
s = substr(s, RSTART + RLENGTH)
|
|
344
|
+
if (match(s, /^[^[:space:]]+/)) {
|
|
345
|
+
sc = substr(s, RSTART, RLENGTH)
|
|
346
|
+
if ((sc == "commit" || sc == "tag" || sc == "notes") && \
|
|
347
|
+
(seg ~ /-[a-zA-Z]*m[[:space:]]/ || seg ~ /--message/))
|
|
348
|
+
return 1
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return 0
|
|
352
|
+
}
|
|
353
|
+
function blank_quotes(seg, n, i, c, out, isq, idq) {
|
|
354
|
+
n = length(seg); out = ""; isq = 0; idq = 0
|
|
355
|
+
for (i = 1; i <= n; i++) {
|
|
356
|
+
c = substr(seg, i, 1)
|
|
357
|
+
if (isq) {
|
|
358
|
+
if (c == "'"'"'") { isq = 0; out = out c } else out = out " "
|
|
359
|
+
continue
|
|
360
|
+
}
|
|
361
|
+
if (idq) {
|
|
362
|
+
if (c == "\\") { out = out " "; i++; continue }
|
|
363
|
+
if (c == "\"") { idq = 0; out = out c } else out = out " "
|
|
364
|
+
continue
|
|
365
|
+
}
|
|
366
|
+
if (c == "'"'"'") { isq = 1; out = out c; continue }
|
|
367
|
+
if (c == "\"") { idq = 1; out = out c; continue }
|
|
368
|
+
out = out c
|
|
369
|
+
}
|
|
370
|
+
return out
|
|
371
|
+
}
|
|
372
|
+
{
|
|
373
|
+
line = $0; n = length(line)
|
|
374
|
+
isq = 0; idq = 0; num = 0; seg_s = 1
|
|
375
|
+
for (i = 1; i <= n; i++) {
|
|
376
|
+
c = substr(line, i, 1)
|
|
377
|
+
if (isq) { if (c == "'"'"'") isq = 0; continue }
|
|
378
|
+
if (idq) { if (c == "\\") { i++; continue }; if (c == "\"") idq = 0; continue }
|
|
379
|
+
if (c == "'"'"'") { isq = 1; continue }
|
|
380
|
+
if (c == "\"") { idq = 1; continue }
|
|
381
|
+
sp = 0; sl = 1
|
|
382
|
+
if (c == ";") sp = 1
|
|
383
|
+
else if (c == "&" && i < n && substr(line, i+1, 1) == "&") { sp = 1; sl = 2 }
|
|
384
|
+
else if (c == "|" && i < n && substr(line, i+1, 1) == "|") { sp = 1; sl = 2 }
|
|
385
|
+
else if (c == "|") sp = 1
|
|
386
|
+
if (sp) {
|
|
387
|
+
num++; segs[num] = substr(line, seg_s, i - seg_s)
|
|
388
|
+
seg_s = i + sl; if (sl == 2) i++
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
num++; segs[num] = substr(line, seg_s)
|
|
392
|
+
for (s = 1; s <= num; s++) {
|
|
393
|
+
if (check_sink(segs[s])) print blank_quotes(segs[s])
|
|
394
|
+
else print segs[s]
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
' 2>/dev/null || true
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
COMMAND_SCAN=$(printf '%s' "$COMMAND" | fold_continuations | strip_heredocs | split_segments)
|
|
401
|
+
# FAIL TOWARDS OVER-DETECTING, never towards silence. A missing or broken awk or
|
|
402
|
+
# sed empties the scan, and an empty scan matches nothing, which would leave the
|
|
403
|
+
# gate off for the session with no error. Degrade to the raw command instead:
|
|
404
|
+
# that is the pre-#50 behaviour, which over-detects. `:112` states the direction.
|
|
405
|
+
if [[ -z "$COMMAND_SCAN" && -n "$COMMAND" ]]; then
|
|
406
|
+
COMMAND_SCAN="$COMMAND"
|
|
407
|
+
fi
|
|
408
|
+
|
|
409
|
+
# One anchor for all three matchers. A match must open the segment, or follow a
|
|
410
|
+
# top-level separator, or open a command substitution. The substitution openers
|
|
411
|
+
# are load-bearing: `echo "$(gh pr merge 5)"` runs the merge, and split_segments
|
|
412
|
+
# deliberately leaves that segment unblanked so this anchor can see it.
|
|
413
|
+
DVR_SEP='(^|[;&|]|\$\(|`)[[:space:]]*'
|
|
414
|
+
DVR_VERIFY_RE="${DVR_SEP}gh[[:space:]]+run[[:space:]]+(list|view|watch)([[:space:]]|\$)"
|
|
415
|
+
DVR_MERGE_RE="${DVR_SEP}gh[[:space:]]+pr[[:space:]]+merge([[:space:]]|\$)"
|
|
416
|
+
DVR_CREATE_RE="${DVR_SEP}gh[[:space:]]+pr[[:space:]]+create([[:space:]]|\$)"
|
|
417
|
+
|
|
176
418
|
# ── 1. Detect verification signal (clears pending state) ─────────────────────
|
|
177
|
-
#
|
|
178
|
-
#
|
|
179
|
-
|
|
419
|
+
# Only clear on a gh run list/view/watch the shell RAN, never on the text of one.
|
|
420
|
+
# Converted to the shared scan by Must Fix 2: this matcher kept the old per-line
|
|
421
|
+
# shape while the merge matcher lost it, so naming the command in a heredoc or a
|
|
422
|
+
# multi-line string cleared a real latch. The security reviewer cleared a live
|
|
423
|
+
# latch that way during the review of 70fca59.
|
|
424
|
+
if printf '%s\n' "$COMMAND_SCAN" | grep -qE "$DVR_VERIFY_RE"; then
|
|
180
425
|
# Gate to one-shot per cycle: emit only if verify sentinel doesn't exist yet.
|
|
181
426
|
if [ ! -f "$VERIFY_SENT" ]; then
|
|
182
427
|
emit_telemetry "false" "true" "false"
|
|
@@ -192,18 +437,25 @@ if printf '%s\n' "$COMMAND" | grep -qE '(^|[;&|]\s*)gh\s+run\s+(list|view|watch)
|
|
|
192
437
|
fi
|
|
193
438
|
|
|
194
439
|
# ── 2. Detect merge signal (sets pending state) ───────────────────────────────
|
|
440
|
+
#
|
|
441
|
+
# Both matchers read $COMMAND_SCAN, so a merge inside an inert heredoc or a text
|
|
442
|
+
# sink's quoted argument is not seen, and a merge the shell runs is.
|
|
195
443
|
IS_MERGE=0
|
|
196
|
-
if printf '%s\n' "$
|
|
444
|
+
if printf '%s\n' "$COMMAND_SCAN" | grep -qE "$DVR_MERGE_RE"; then
|
|
197
445
|
IS_MERGE=1
|
|
198
446
|
fi
|
|
199
|
-
|
|
447
|
+
# --merge is an argument, not a command, so it has no segment to open. The
|
|
448
|
+
# command word it belongs to is what the anchored matcher constrains.
|
|
449
|
+
if printf '%s\n' "$COMMAND_SCAN" | grep -qE "$DVR_CREATE_RE" && printf '%s\n' "$COMMAND_SCAN" | grep -qE '\s--merge\b'; then
|
|
200
450
|
IS_MERGE=1
|
|
201
451
|
fi
|
|
202
452
|
|
|
203
453
|
if [[ "$IS_MERGE" -eq 1 ]]; then
|
|
204
454
|
# Extract PR number if possible
|
|
205
455
|
PR_NUMBER=""
|
|
206
|
-
|
|
456
|
+
# Read from the scan, not the raw command: a number inside quoted prose must
|
|
457
|
+
# not become the PR the reminder names.
|
|
458
|
+
if [[ "$COMMAND_SCAN" =~ gh[[:space:]]+pr[[:space:]]+merge[[:space:]]+([0-9]+) ]]; then
|
|
207
459
|
PR_NUMBER="${BASH_REMATCH[1]}"
|
|
208
460
|
fi
|
|
209
461
|
TIMESTAMP=$(date +%s)
|
|
@@ -217,7 +469,12 @@ if [[ "$IS_MERGE" -eq 1 ]]; then
|
|
|
217
469
|
# session apart from the others sharing this worktree-keyed state file. An empty
|
|
218
470
|
# value (no session_id on stdin, or jq unavailable) is written as an empty field
|
|
219
471
|
# and read back as "unknown" — the same branch legacy state files take.
|
|
220
|
-
|
|
472
|
+
#
|
|
473
|
+
# AGENT_ID records WHICH AGENT INSIDE THAT SESSION merged (#50). It is empty for
|
|
474
|
+
# a main thread and set inside a dispatched subagent. A state file written before
|
|
475
|
+
# this change carries no AGENT_ID line, so it reads back empty, which is the
|
|
476
|
+
# value a main-thread merge writes today.
|
|
477
|
+
printf 'PR_NUMBER=%s\nTIMESTAMP=%s\nSESSION_ID=%s\nAGENT_ID=%s\n' "$PR_NUMBER" "$TIMESTAMP" "$SESSION_ID" "$AGENT_ID" > "$STATE_FILE" 2>/dev/null || true
|
|
221
478
|
# A new merge starts a new cycle — clear verify sentinel so the next verify re-arms.
|
|
222
479
|
# Per-session `other` notices clear too (#4734), so sessions already notified
|
|
223
480
|
# about the PREVIOUS merge are notified once about this new one.
|
|
@@ -277,24 +534,96 @@ PR_REF="${STORED_PR:-<PR>}"
|
|
|
277
534
|
# misattribute the merge, which is the bug this block exists to prevent.
|
|
278
535
|
# Re-sanitized on read: the file lives in world-writable /tmp, so its contents are
|
|
279
536
|
# not trusted to be well-formed even though this hook wrote them.
|
|
280
|
-
|
|
537
|
+
# A FIELD THE FILTER CHANGES MAKES THE WHOLE FILE UNKNOWN (Must Fix 5, security
|
|
538
|
+
# review of 70fca59). Deleting the disallowed characters leaves a DIFFERENT
|
|
539
|
+
# string that is then compared as though it were genuine, so a planted value
|
|
540
|
+
# collides with a real id. Measured by the reviewer: `AGENT_ID=a!b` read by an
|
|
541
|
+
# agent whose real id is `ab` produced `self` and the repeating demand, for an
|
|
542
|
+
# agent that merged nothing. That is the #50 failure reached through the state
|
|
543
|
+
# file instead of the command text, and /tmp is mode 1777, so any process on this
|
|
544
|
+
# machine can write it.
|
|
545
|
+
#
|
|
546
|
+
# Three states, not two. Absent or empty is a real identity, the main thread or a
|
|
547
|
+
# pre-change file, and keeps the existing comparison. Present and unchanged by
|
|
548
|
+
# the filter is genuine. Present and changed means this hook did not write it, so
|
|
549
|
+
# the record is malformed and nothing may be asserted about it.
|
|
550
|
+
#
|
|
551
|
+
# `unknown` rather than "ignore the field": it prints and exits 2, so nothing is
|
|
552
|
+
# silenced, and its wording claims nothing about who merged. Emptying the field
|
|
553
|
+
# instead would convert a corrupt value into the positive claim "the main thread
|
|
554
|
+
# merged", which is the class of error #4734 exists to prevent.
|
|
555
|
+
#
|
|
556
|
+
# `grep -m1` because two `AGENT_ID=` lines otherwise concatenate: the strip
|
|
557
|
+
# removes the newline between them and the result is a third string that is
|
|
558
|
+
# neither. The length test is separate from the 64-character write bound, so a
|
|
559
|
+
# genuinely over-long id is rejected rather than truncated into a possible match.
|
|
560
|
+
STATE_MALFORMED=0
|
|
561
|
+
|
|
562
|
+
STORED_SESSION_RAW=""
|
|
281
563
|
if [[ -f "$STATE_FILE" ]]; then
|
|
282
|
-
|
|
564
|
+
STORED_SESSION_RAW=$(grep -m1 '^SESSION_ID=' "$STATE_FILE" 2>/dev/null | cut -d= -f2- || true)
|
|
565
|
+
fi
|
|
566
|
+
STORED_SESSION="${STORED_SESSION_RAW//[^a-zA-Z0-9_-]/}"
|
|
567
|
+
if [[ "$STORED_SESSION" != "$STORED_SESSION_RAW" || "${#STORED_SESSION_RAW}" -gt 64 ]]; then
|
|
568
|
+
STATE_MALFORMED=1
|
|
569
|
+
fi
|
|
570
|
+
|
|
571
|
+
# Read back the agent that recorded the merge (#50). Same parse, same
|
|
572
|
+
# sanitization and the same bound as the session field above, for the same
|
|
573
|
+
# reason: the file lives in world-writable /tmp, so its contents are not trusted
|
|
574
|
+
# to be well-formed. Every state file written before this change lacks the line,
|
|
575
|
+
# which reads back as the empty string and compares equal to a main thread's own
|
|
576
|
+
# empty agent id.
|
|
577
|
+
STORED_AGENT_RAW=""
|
|
578
|
+
if [[ -f "$STATE_FILE" ]]; then
|
|
579
|
+
STORED_AGENT_RAW=$(grep -m1 '^AGENT_ID=' "$STATE_FILE" 2>/dev/null | cut -d= -f2- || true)
|
|
580
|
+
fi
|
|
581
|
+
STORED_AGENT="${STORED_AGENT_RAW//[^a-zA-Z0-9_-]/}"
|
|
582
|
+
if [[ "$STORED_AGENT" != "$STORED_AGENT_RAW" || "${#STORED_AGENT_RAW}" -gt 64 ]]; then
|
|
583
|
+
STATE_MALFORMED=1
|
|
283
584
|
fi
|
|
284
|
-
STORED_SESSION="${STORED_SESSION//[^a-zA-Z0-9_-]/}"
|
|
285
585
|
|
|
286
586
|
# Three-way attribution. Every branch still emits a message and still exits 2 —
|
|
287
587
|
# failing to attribute must never SWALLOW the reminder, only soften its claim.
|
|
288
|
-
# self → this
|
|
289
|
-
#
|
|
588
|
+
# self → this agent merged it, OR this is the main thread of the session
|
|
589
|
+
# that merged it; the original directive wording applies.
|
|
590
|
+
# other → a different session, or a different SUBAGENT inside this session,
|
|
591
|
+
# merged it; non-actionable notice.
|
|
290
592
|
# unknown → no stored id (state file written by the pre-#4734 hook, or the
|
|
291
593
|
# harness supplied no session_id, or jq was unavailable on either
|
|
292
|
-
# side). Assert neither
|
|
293
|
-
if [[
|
|
594
|
+
# side), or a stored id this hook did not write. Assert neither.
|
|
595
|
+
if [[ "$STATE_MALFORMED" -eq 1 ]]; then
|
|
596
|
+
# A field this hook did not write. Assert nothing about who merged.
|
|
597
|
+
ATTRIBUTION="unknown"
|
|
598
|
+
elif [[ -z "$STORED_SESSION" || -z "$SESSION_ID" ]]; then
|
|
294
599
|
ATTRIBUTION="unknown"
|
|
295
|
-
elif [[ "$STORED_SESSION"
|
|
600
|
+
elif [[ "$STORED_SESSION" != "$SESSION_ID" ]]; then
|
|
601
|
+
# A different session. This is the #4734 case and it is decided FIRST, before
|
|
602
|
+
# any agent-id test, so no agent-id branch below can reach across sessions.
|
|
603
|
+
ATTRIBUTION="other"
|
|
604
|
+
elif [[ "$STORED_AGENT" == "$AGENT_ID" ]]; then
|
|
605
|
+
# Same session, same agent. A subagent shares its dispatcher's session id and
|
|
606
|
+
# carries a different agent id, so it does not reach this branch (#50).
|
|
607
|
+
ATTRIBUTION="self"
|
|
608
|
+
elif [[ -z "$AGENT_ID" ]]; then
|
|
609
|
+
# THE MAIN THREAD OF THE MERGING SESSION IS NEVER SILENCED (Must Fix 1,
|
|
610
|
+
# security review of 70fca59). A dispatched subagent can run the merge, and
|
|
611
|
+
# AGENTS.md makes the session that dispatched it responsible for verifying the
|
|
612
|
+
# deploy. Keying on the pair alone told that session once that the merge was
|
|
613
|
+
# somebody else's job and then went quiet, which turns the gate off for the
|
|
614
|
+
# only party that can clear it. An empty agent id is a positive reading, not a
|
|
615
|
+
# failure: the harness omits the field only on a main thread.
|
|
616
|
+
#
|
|
617
|
+
# SCOPED TO THE MERGING SESSION ON PURPOSE. The review's remedy reads
|
|
618
|
+
# `elif [[ -z "$AGENT_ID" ]]` placed after the both-match test. Applied to the
|
|
619
|
+
# chain as it stood, that also catches a main thread in a DIFFERENT session,
|
|
620
|
+
# which is #4734 exactly. Measured before this edit: with SESSION_ID=sess-A
|
|
621
|
+
# stored and sess-B reading, the literal form printed "Deploy verification
|
|
622
|
+
# required" where the committed code printed the notice. The `!=` branch above
|
|
623
|
+
# is what confines this one to the session that merged.
|
|
296
624
|
ATTRIBUTION="self"
|
|
297
625
|
else
|
|
626
|
+
# Same session, and both agents are named subagents that differ.
|
|
298
627
|
ATTRIBUTION="other"
|
|
299
628
|
fi
|
|
300
629
|
|
|
@@ -308,16 +637,20 @@ fi
|
|
|
308
637
|
# non-actionable notice repeated dozens of times would itself get escalated as an
|
|
309
638
|
# anomaly — a softer version of the failure this hook is being fixed for.
|
|
310
639
|
#
|
|
311
|
-
# Keyed by session
|
|
312
|
-
#
|
|
313
|
-
#
|
|
640
|
+
# Keyed by session AND agent (#50), so two subagents dispatched by one session are
|
|
641
|
+
# each told once instead of sharing one sentinel and silencing the second. Both
|
|
642
|
+
# components are constrained to [a-zA-Z0-9_-] and bounded to 64 characters at parse
|
|
643
|
+
# time, so the name is safe in a filename and stays well inside NAME_MAX. The agent
|
|
644
|
+
# component is appended only when it is non-empty, so a main thread's sentinel name
|
|
645
|
+
# is byte-identical to the one this hook wrote before the change. SESSION_ID on this
|
|
646
|
+
# branch is always non-empty (empty would have routed to `unknown`), and the
|
|
314
647
|
# `:-unknown` default is belt-and-braces.
|
|
315
648
|
#
|
|
316
649
|
# Suppressed repeats exit 0 with NO output, not exit 2. A non-zero exit with an
|
|
317
650
|
# empty stderr is what produced the "No stderr output" reports in
|
|
318
651
|
# KI-HOOKS-STDERR-SYSTEMIC; emitting nothing while claiming a warning is the bug,
|
|
319
652
|
# not the fix. Every branch that actually PRINTS still exits 2.
|
|
320
|
-
NOTICE_SENT="${STATE_FILE}.notice-${SESSION_ID:-unknown}"
|
|
653
|
+
NOTICE_SENT="${STATE_FILE}.notice-${SESSION_ID:-unknown}${AGENT_ID:+-$AGENT_ID}"
|
|
321
654
|
if [[ "$ATTRIBUTION" == "other" ]]; then
|
|
322
655
|
if [[ -f "$NOTICE_SENT" ]]; then
|
|
323
656
|
exit 0
|
|
@@ -360,9 +693,13 @@ CLI_PACKAGE="${CLI_PACKAGE:-@memnexus-ai/mx-agent-cli}"
|
|
|
360
693
|
# to "verify the deploy and retry your command" would be a false directive —
|
|
361
694
|
# exactly the misdirection that got read as prompt injection. No numbered
|
|
362
695
|
# steps here; steps are what made the previous message look actionable.
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
696
|
+
# "a different agent", not "a different agent session" (#50). A dispatched
|
|
697
|
+
# subagent shares its dispatcher's session id, so this branch is now reached
|
|
698
|
+
# by two agents inside ONE session as well as by two sessions. Naming a
|
|
699
|
+
# session here would state something the hook has not established.
|
|
700
|
+
echo "ℹ️ Notice: PR ${PR_REF} was merged by a different agent running concurrently in this worktree."
|
|
701
|
+
echo "No action is required from you. Verifying that deploy is the responsibility of the agent that ran the merge."
|
|
702
|
+
echo "You are seeing this because deploy-pending state is shared per worktree, not per agent."
|
|
366
703
|
elif [[ "$ATTRIBUTION" == "unknown" ]]; then
|
|
367
704
|
# Provenance genuinely undetermined — state the uncertainty instead of
|
|
368
705
|
# asserting either ownership. Steps are offered CONDITIONALLY.
|
|
@@ -41,16 +41,48 @@
|
|
|
41
41
|
# the log_override() header for the failure modes this had to be hardened
|
|
42
42
|
# against (a FIFO that blocked the append forever, a symlink that redirected it)
|
|
43
43
|
# and for the residual TOCTOU that is knowingly accepted.
|
|
44
|
-
# LAYERING CAVEAT: GIT_EXPERT=1
|
|
45
|
-
# reset forms, stash, checkout-file,
|
|
46
|
-
#
|
|
44
|
+
# LAYERING CAVEAT (corrected 2026-08-25, issue #144): GIT_EXPERT=1 clears THIS
|
|
45
|
+
# hook's blocks (bare-SHA/branch reset forms, stash, checkout-file,
|
|
46
|
+
# restore-worktree). The ONLY patterns it cannot clear are the two
|
|
47
|
+
# `git reset --hard HEAD~*` and `git reset --hard HEAD^*` forms, which stay
|
|
47
48
|
# hard-denied at the Claude Code permission layer (.claude/settings.json deny
|
|
48
|
-
# list)
|
|
49
|
-
# HEAD~/HEAD^ reset, debug the
|
|
49
|
+
# list). That layer decides BEFORE this hook runs, so the override never reaches
|
|
50
|
+
# it. If an override appears to "fail" on a HEAD~/HEAD^ reset, debug the
|
|
51
|
+
# settings.json deny list, not this script.
|
|
52
|
+
# Checkout-file and restore-worktree are HOOK-ONLY as of 2026-08-25. Their two
|
|
53
|
+
# settings entries, `Bash(git checkout -- *)` and `Bash(git restore --worktree*)`,
|
|
54
|
+
# were removed because they denied `GIT_EXPERT=1 git checkout -- <path>` before
|
|
55
|
+
# this hook saw it, so the override this script prints in its own block message
|
|
56
|
+
# could not work. A git-expert spent a full task discovering that dead end (#144,
|
|
57
|
+
# reported by the surface team 2026-08-24), and the same denial closed every exit
|
|
58
|
+
# from the post-squash-merge sync cycle (#156). This guard is now the sole
|
|
59
|
+
# enforcer for those two verbs, which is what its own header already described:
|
|
60
|
+
# instrumented friction with an audit line per override, not a lock.
|
|
50
61
|
#
|
|
51
62
|
# This guard ONLY inspects git mutation patterns; all non-git and read-only git
|
|
52
63
|
# commands (status, log, diff, stash list, stash show, restore --staged) pass.
|
|
53
64
|
#
|
|
65
|
+
# SANCTIONED IN-PROCESS EXCEPTION (issue #172, product owner approval given in
|
|
66
|
+
# the bootstrap lead's session 2026-08-25): `mx-agent worktree sync` runs git
|
|
67
|
+
# from Node via execFile/spawn with argv arrays, so no Bash tool call carries
|
|
68
|
+
# the mutation and this hook never sees it. That is a reviewed, deliberate
|
|
69
|
+
# carve-out with its own controls (leader-lock gate, checkpoint to
|
|
70
|
+
# refs/mx/checkpoint/<worktree>/<epoch-ms>-<rand6> before any destructive
|
|
71
|
+
# step, quiescence check, and an audit record in
|
|
72
|
+
# ~/.mx-agent/logs/worktree-sync.jsonl on every path). WORDING CORRECTED
|
|
73
|
+
# 2026-08-25 (Should Fix 1, security review of PR #182, comment 5415821643):
|
|
74
|
+
# this said "one audit line per run", which no longer describes the command. A
|
|
75
|
+
# run that reaches the destructive step writes TWO records, an `in-progress`
|
|
76
|
+
# record before that step and a terminal record after it, correlated by
|
|
77
|
+
# `runId`. The invariant is one TERMINAL record per run, and an `in-progress`
|
|
78
|
+
# record with no matching terminal record is the signal that a run was killed
|
|
79
|
+
# mid-step. It is NOT evidence that any hook can
|
|
80
|
+
# be routed around by moving an operation into a Node child process: the same
|
|
81
|
+
# technique applied to workflow-dispatch-guard.sh or gh-pr-edit-guard.sh
|
|
82
|
+
# without an equivalent review is a bypass, and AGENTS.md's rule stands that a
|
|
83
|
+
# blocked operation routes through the git-expert teammate, not around the
|
|
84
|
+
# guard. Plan and review record: issue #172, revisions 1 to 4.
|
|
85
|
+
#
|
|
54
86
|
# SCOPE (SF-2, QA probe audit 2026-07-06 — this is a guardrail, not a security
|
|
55
87
|
# boundary). INERT-CONSUMER HEREDOC BODIES ARE EXCLUDED FROM MATCHING: a git verb
|
|
56
88
|
# inside a heredoc whose consuming command does NOT execute the body (e.g. a
|
|
@@ -417,6 +449,33 @@ function get_lead_cmd(seg, s) {
|
|
|
417
449
|
if (match(s, /^[^[:space:]]+/)) return substr(s, RSTART, RLENGTH)
|
|
418
450
|
return ""
|
|
419
451
|
}
|
|
452
|
+
function peel_keywords(seg, s, i) {
|
|
453
|
+
# #225 MF-2 route (a): strip leading shell keywords so the segment starts at
|
|
454
|
+
# the command the keyword introduces. The segmenter splits only on `;` `&`
|
|
455
|
+
# `&&` `|` `||`, so `if git reset --hard; then` arrived as ONE segment
|
|
456
|
+
# beginning `if `. GITSEG matched nothing there (its boundary class named
|
|
457
|
+
# then/do/else and not if/elif/while/until) and OVSEG matched nothing either,
|
|
458
|
+
# because `if` is neither an assignment nor a launcher word. The verb was
|
|
459
|
+
# invisible AND the override was unusable in the same position. Peeling puts
|
|
460
|
+
# the verb at ^ where both patterns already work, which is the repair lines
|
|
461
|
+
# 241-243 name: widen the SEGMENTER, never widen OVSEG toward GITSEG.
|
|
462
|
+
# BOUNDED AT 8 ITERATIONS ON PURPOSE. Each pass is O(segment length), so the
|
|
463
|
+
# bound keeps this linear; an unbounded `while` with a per-pass substr is
|
|
464
|
+
# quadratic on an adversarial `if if if ...` prefix, and a hook killed by its
|
|
465
|
+
# 60s timeout loses its exit 2 (header, lines 155-161). Stacking more than 8
|
|
466
|
+
# keywords does not evade: the GITSEG alternative (^|\s)(if|elif|while|until|
|
|
467
|
+
# then|do|else)\s still matches the 9th, which is why both changes ship.
|
|
468
|
+
# NO APOSTROPHE MAY APPEAR IN THIS COMMENT. It sits inside the single-quoted
|
|
469
|
+
# awk program, so one apostrophe closes the quote and breaks the whole hook.
|
|
470
|
+
# `!` is deliberately NOT peeled — `! V`, `if ! V` and `while ! V` stay open
|
|
471
|
+
# and are recorded as such (#228).
|
|
472
|
+
s = seg
|
|
473
|
+
for (i = 0; i < 8; i++) {
|
|
474
|
+
if (!match(s, /^[[:space:]]*(if|elif|while|until|then|do|else)[[:space:]]+/)) break
|
|
475
|
+
s = substr(s, RSTART + RLENGTH)
|
|
476
|
+
}
|
|
477
|
+
return s
|
|
478
|
+
}
|
|
420
479
|
function is_exec(cmd) {
|
|
421
480
|
return (cmd == "bash" || cmd == "sh" || cmd == "zsh" || cmd == "dash" || \
|
|
422
481
|
cmd == "ksh" || cmd == "eval" || cmd == "source" || cmd == "ssh" || \
|
|
@@ -517,27 +576,32 @@ function extract_quotes(seg, n, i, c, ct, isq, idq, res) {
|
|
|
517
576
|
}
|
|
518
577
|
num++; segs[num] = substr(line, seg_s); stypes[num] = ""
|
|
519
578
|
# classify each segment
|
|
520
|
-
|
|
579
|
+
# psegs[] is segs[] with leading shell keywords peeled (#225 MF-2). Every
|
|
580
|
+
# consumer below reads psegs, so classification, executor detection, the
|
|
581
|
+
# override stamp and the emitted text all see the same string. Peeling for
|
|
582
|
+
# the emit alone would leave check_sink deciding on `if` as the lead command,
|
|
583
|
+
# which is the kind of half-applied transform that becomes its own defect.
|
|
584
|
+
for (s = 1; s <= num; s++) { psegs[s] = peel_keywords(segs[s]); snk[s] = check_sink(psegs[s]); pxe[s] = 0 }
|
|
521
585
|
# backward-propagate executor status through pipes
|
|
522
586
|
for (s = num; s >= 2; s--) {
|
|
523
587
|
if (stypes[s-1] == "pipe") {
|
|
524
|
-
cmd = get_lead_cmd(
|
|
588
|
+
cmd = get_lead_cmd(psegs[s])
|
|
525
589
|
if (is_exec(cmd) || pxe[s]) { snk[s-1] = 0; pxe[s-1] = 1 }
|
|
526
590
|
}
|
|
527
591
|
}
|
|
528
592
|
# emit processed segments
|
|
529
593
|
for (s = 1; s <= num; s++) {
|
|
530
|
-
if (snk[s]) { print blank_quotes(
|
|
594
|
+
if (snk[s]) { print blank_quotes(psegs[s]) }
|
|
531
595
|
else {
|
|
532
|
-
print
|
|
533
|
-
cmd = get_lead_cmd(
|
|
596
|
+
print psegs[s]
|
|
597
|
+
cmd = get_lead_cmd(psegs[s])
|
|
534
598
|
if (is_exec(cmd) || pxe[s]) {
|
|
535
|
-
ex = extract_quotes(
|
|
599
|
+
ex = extract_quotes(psegs[s])
|
|
536
600
|
if (ex != "") {
|
|
537
601
|
# An executor payload is executed BY this segment, so an
|
|
538
602
|
# anchored override on the segment applies to it (#4804).
|
|
539
603
|
# Stamp each extracted line, which is its own scan segment.
|
|
540
|
-
if (
|
|
604
|
+
if (psegs[s] ~ ovre) {
|
|
541
605
|
nx = split(ex, xa, "\n")
|
|
542
606
|
for (k = 1; k <= nx; k++) print "GIT_EXPERT=1 " xa[k]
|
|
543
607
|
} else print ex
|
|
@@ -600,6 +664,14 @@ refuse() {
|
|
|
600
664
|
echo "If you truly must run this, prefix it with GIT_EXPERT=1 to override,"
|
|
601
665
|
echo "e.g. GIT_EXPERT=1 $what ..."
|
|
602
666
|
echo ""
|
|
667
|
+
echo "In a compound command, put the token on the command itself, NOT on the"
|
|
668
|
+
echo "keyword (#225). Bash rejects a token before if/while/until with a"
|
|
669
|
+
echo "syntax error, so these are the forms that work:"
|
|
670
|
+
echo " if GIT_EXPERT=1 $what ...; then ...; fi"
|
|
671
|
+
echo " while GIT_EXPERT=1 $what ...; do ...; done"
|
|
672
|
+
echo " if true; then GIT_EXPERT=1 $what ...; fi"
|
|
673
|
+
echo " GIT_EXPERT=1 bash -c '<the whole compound command>'"
|
|
674
|
+
echo ""
|
|
603
675
|
echo "IF YOU OVERRIDE, YOU MUST REPORT IT. Your report back to whoever asked"
|
|
604
676
|
echo "for this work has to state: the command that was blocked, that"
|
|
605
677
|
echo "git-mutation-guard blocked it, that you used GIT_EXPERT=1 to override,"
|
|
@@ -643,7 +715,7 @@ refuse() {
|
|
|
643
715
|
# mx-guard-hook.sh. Applied per-segment to the heredoc- and quote-stripped SCAN.
|
|
644
716
|
# GIT_EXPERT=1 clears any accepted false positive. `echo` is deliberately NOT a
|
|
645
717
|
# wrapper word, so `echo "use timeout 5 git reset --hard"` stays allowed.
|
|
646
|
-
GITSEG='(^|[;&|({`]
|
|
718
|
+
GITSEG='(^|[;&|({`]|(^|\s)(then|do|else|if|elif|while|until)\s)\s*([0-9]*[<>][^[:space:]]*\s+|[A-Za-z_][A-Za-z0-9_]*=[^[:space:];&|]*\s+|(sudo|env|nice|nohup|time|timeout|ionice|stdbuf|command|xargs|setsid|doas|nsenter)\s+([0-9]+\s+)?)*git(\s+(-C\s+[^[:space:];&|]+|-c\s+[^[:space:];&|]+|--(git-dir|work-tree|namespace|super-prefix)(=[^[:space:];&|]*|\s+[^[:space:];&|]+)|--[A-Za-z][A-Za-z0-9-]*=[^[:space:];&|]*|--[A-Za-z][A-Za-z0-9-]*|-[A-Za-z]))*\s+'
|
|
647
719
|
|
|
648
720
|
# --- per-segment evaluation (item 3, #3934; sink scoping, #3938) --------------
|
|
649
721
|
# Each allow-check (stash list|show; restore --staged-without-worktree) must be
|