@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
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* identity.ts — the one place a session says who it belongs to.
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS EXISTS. Two adapters were building the same environment block by hand
|
|
5
|
+
* (`lib/claude.ts` and `runtime/codex-adapter.ts`), and a third consumer is coming:
|
|
6
|
+
* telemetry that has to attribute token spend to a team. Three hand-written copies
|
|
7
|
+
* of the same names drift, and a drifted name does not fail loudly — it produces
|
|
8
|
+
* telemetry that looks correct in every log and joins to nothing.
|
|
9
|
+
*
|
|
10
|
+
* THE VALUES ARE NOT FREE CHOICES. `mx-agent sync` posts `team` as the team SLUG
|
|
11
|
+
* and `worktree` as the worktree DIRECTORY NAME (commands/sync.ts), and the
|
|
12
|
+
* observability `sessions` table is keyed on exactly those. An identity block that
|
|
13
|
+
* sent a worktree PATH instead would be indistinguishable from a correct one until
|
|
14
|
+
* someone noticed every join returning zero rows. The tests pin this.
|
|
15
|
+
*
|
|
16
|
+
* HEADER-SAFE BY CONSTRUCTION. These values are destined for HTTP headers — Claude
|
|
17
|
+
* Code carries them via ANTHROPIC_CUSTOM_HEADERS, Codex via a `model_providers`
|
|
18
|
+
* block's `env_http_headers` (probed on codex-cli 0.145.0, 2026-09-02: the map's
|
|
19
|
+
* values are ENV VAR NAMES, resolved per request; see IDENTITY_HTTP_HEADERS below).
|
|
20
|
+
* A branch name is attacker-influenceable (anyone who can push a branch picks the
|
|
21
|
+
* string), so a value carrying CR or LF would be header injection with a git push as
|
|
22
|
+
* the delivery mechanism. Sanitising at the source rather than at each call site means
|
|
23
|
+
* a future consumer cannot forget.
|
|
24
|
+
*
|
|
25
|
+
* WHY THERE IS NO MX_SESSION_ID HERE. The `sessions` table keys on Claude's own
|
|
26
|
+
* session UUID, which this process does not know at launch. `claude --session-id`
|
|
27
|
+
* can pin one, but that changes the argv of every Claude launch, and Design
|
|
28
|
+
* Principle 1 (runtime/types.ts) forbids regressing that path — an unrecognised
|
|
29
|
+
* flag on an older binary would break every start. Exporting a session id we made
|
|
30
|
+
* up would be worse than exporting none: it would join to nothing while looking
|
|
31
|
+
* authoritative. Deliberately absent until session pinning is a decision of its own.
|
|
32
|
+
*/
|
|
33
|
+
import { hostname } from 'os';
|
|
34
|
+
/** Longest value we will emit. Generous for a branch name, short of any header limit. */
|
|
35
|
+
export const MAX_IDENTITY_VALUE = 256;
|
|
36
|
+
/**
|
|
37
|
+
* Reduce a value to something safe to put in an HTTP header field value.
|
|
38
|
+
*
|
|
39
|
+
* RFC 9110 field values admit visible ASCII, space and horizontal tab. Everything
|
|
40
|
+
* else — CR, LF, NUL, control characters, non-ASCII — is dropped rather than
|
|
41
|
+
* escaped, because there is no value here whose meaning depends on those bytes and
|
|
42
|
+
* dropping cannot produce a second header. Over-long values are truncated.
|
|
43
|
+
*
|
|
44
|
+
* Returns '' for anything that reduces to nothing, and callers omit empty values
|
|
45
|
+
* entirely rather than emitting a blank one.
|
|
46
|
+
*/
|
|
47
|
+
export function sanitizeIdentityValue(raw) {
|
|
48
|
+
if (typeof raw !== 'string')
|
|
49
|
+
return '';
|
|
50
|
+
let out = '';
|
|
51
|
+
for (const ch of raw) {
|
|
52
|
+
const code = ch.codePointAt(0);
|
|
53
|
+
// Visible ASCII (0x21-0x7E), plus space and tab.
|
|
54
|
+
const printable = (code >= 0x21 && code <= 0x7e) || code === 0x20 || code === 0x09;
|
|
55
|
+
if (printable)
|
|
56
|
+
out += ch;
|
|
57
|
+
if (out.length >= MAX_IDENTITY_VALUE)
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
return out.trim();
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Build the identity for a launch.
|
|
64
|
+
*
|
|
65
|
+
* `machine` is injectable so tests do not depend on the host they run on; nothing
|
|
66
|
+
* in production passes it.
|
|
67
|
+
*/
|
|
68
|
+
export function sessionIdentity(ctx, opts = {}) {
|
|
69
|
+
return {
|
|
70
|
+
team: sanitizeIdentityValue(ctx.teamName),
|
|
71
|
+
worktree: sanitizeIdentityValue(ctx.worktreeName),
|
|
72
|
+
machine: sanitizeIdentityValue(opts.machine ?? hostname()),
|
|
73
|
+
branch: sanitizeIdentityValue(ctx.branch),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The environment block both runtimes export.
|
|
78
|
+
*
|
|
79
|
+
* Empty values are omitted rather than exported blank: an absent variable reads as
|
|
80
|
+
* "not known here", while `MX_TEAM=''` reads as a team whose name is the empty
|
|
81
|
+
* string, and only one of those is true.
|
|
82
|
+
*/
|
|
83
|
+
export function identityEnv(id) {
|
|
84
|
+
const env = {};
|
|
85
|
+
if (id.team)
|
|
86
|
+
env.MX_TEAM = id.team;
|
|
87
|
+
if (id.worktree)
|
|
88
|
+
env.MX_WORKTREE = id.worktree;
|
|
89
|
+
if (id.machine)
|
|
90
|
+
env.MX_MACHINE = id.machine;
|
|
91
|
+
if (id.branch)
|
|
92
|
+
env.MX_BRANCH = id.branch;
|
|
93
|
+
return env;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Identity as HTTP headers: header name -> the ENVIRONMENT VARIABLE NAME holding its value.
|
|
97
|
+
*
|
|
98
|
+
* THE VALUES ARE VARIABLE NAMES, NOT VALUES. That is what Codex's
|
|
99
|
+
* `model_providers.<id>.env_http_headers` map means, established by probe rather than
|
|
100
|
+
* documentation (codex-cli 0.145.0, 2026-09-02, isolated CODEX_HOME, request captured on a
|
|
101
|
+
* loopback listener): `env_http_headers = { "X-MX-Team" = "MX_TEAM" }` with `MX_TEAM=gateway`
|
|
102
|
+
* put `x-mx-team: gateway` on the wire. The sibling key `http_headers` takes LITERAL values.
|
|
103
|
+
* Both keys exist on 0.145.0; `headers` and `env_headers` do not and are silently ignored.
|
|
104
|
+
*
|
|
105
|
+
* WHY THE VARIABLE NAMES ARE NOT WRITTEN OUT AT THE CALL SITE. `identityEnv` above decides
|
|
106
|
+
* what a session exports. A header map that named a variable `identityEnv` does not export
|
|
107
|
+
* would omit that header on every request, silently, and the telemetry would look correct in
|
|
108
|
+
* every log while joining to nothing, the failure the top of this file exists to prevent.
|
|
109
|
+
* The tests assert these values equal the keys `identityEnv` produces.
|
|
110
|
+
*
|
|
111
|
+
* ABSENT AND EMPTY BOTH OMIT THE HEADER (same probe). A named variable that is unset, or set
|
|
112
|
+
* to the empty string, produced NO header rather than a blank one, which is the same rule
|
|
113
|
+
* `identityEnv` follows for the environment.
|
|
114
|
+
*
|
|
115
|
+
* These four values are not secrets: a team slug, a worktree directory name, a host name and
|
|
116
|
+
* a branch name. Nothing here authenticates anything.
|
|
117
|
+
*/
|
|
118
|
+
export const IDENTITY_HTTP_HEADERS = Object.freeze({
|
|
119
|
+
'X-MX-Team': 'MX_TEAM',
|
|
120
|
+
'X-MX-Worktree': 'MX_WORKTREE',
|
|
121
|
+
'X-MX-Machine': 'MX_MACHINE',
|
|
122
|
+
'X-MX-Branch': 'MX_BRANCH',
|
|
123
|
+
});
|
|
124
|
+
/** Convenience for the launch path: identity and its environment in one step. */
|
|
125
|
+
export function launchIdentityEnv(ctx, opts = {}) {
|
|
126
|
+
return identityEnv(sessionIdentity(ctx, opts));
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../../src/lib/runtime/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAG9B,yFAAyF;AACzF,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AActC;;;;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QAAE,GAAG,CAAC,UAAU,GAAG,EAAE,CAAC,OAAO,CAAC;IAC5C,IAAI,EAAE,CAAC,MAAM;QAAE,GAAG,CAAC,SAAS,GAAG,EAAE,CAAC,MAAM,CAAC;IACzC,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAqC,MAAM,CAAC,MAAM,CAAC;IACnF,WAAW,EAAE,SAAS;IACtB,eAAe,EAAE,aAAa;IAC9B,cAAc,EAAE,YAAY;IAC5B,aAAa,EAAE,WAAW;CAC3B,CAAC,CAAC;AAEH,iFAAiF;AACjF,MAAM,UAAU,iBAAiB,CAC/B,GAAgE,EAChE,OAA6B,EAAE;IAE/B,OAAO,WAAW,CAAC,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;AACjD,CAAC"}
|
package/dist/lib/standards.d.ts
CHANGED
|
@@ -31,8 +31,17 @@
|
|
|
31
31
|
* problem, continue. The fail-closed control for this pair is
|
|
32
32
|
* `mx-agent report check`, which refuses a report rather than a session.
|
|
33
33
|
*/
|
|
34
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Files read from the standards directory, in the order they are injected.
|
|
36
|
+
*
|
|
37
|
+
* `po-communication-standard.md` is first because it overrides the writing
|
|
38
|
+
* standard and the report format for messages addressed to the product owner,
|
|
39
|
+
* and a reader has to meet the override before the rules it overrides.
|
|
40
|
+
*/
|
|
35
41
|
export declare const INJECTED_STANDARDS: readonly [{
|
|
42
|
+
readonly file: "po-communication-standard.md";
|
|
43
|
+
readonly title: "How to talk to the product owner";
|
|
44
|
+
}, {
|
|
36
45
|
readonly file: "writing-standard.md";
|
|
37
46
|
readonly title: "Writing standard";
|
|
38
47
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards.d.ts","sourceRoot":"","sources":["../../src/lib/standards.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;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AmB,CA4D1E;AAED,qEAAqE;AACrE,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,CAc/D"}
|
package/dist/lib/standards.js
CHANGED
|
@@ -35,8 +35,15 @@ import { existsSync, readFileSync, statSync } from 'fs';
|
|
|
35
35
|
import { dirname, join } from 'path';
|
|
36
36
|
import { fileURLToPath } from 'url';
|
|
37
37
|
import { extractMarkerBlock, sanitizeForMessage } from './behavioral-injection.js';
|
|
38
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Files read from the standards directory, in the order they are injected.
|
|
40
|
+
*
|
|
41
|
+
* `po-communication-standard.md` is first because it overrides the writing
|
|
42
|
+
* standard and the report format for messages addressed to the product owner,
|
|
43
|
+
* and a reader has to meet the override before the rules it overrides.
|
|
44
|
+
*/
|
|
39
45
|
export const INJECTED_STANDARDS = [
|
|
46
|
+
{ file: 'po-communication-standard.md', title: 'How to talk to the product owner' },
|
|
40
47
|
{ file: 'writing-standard.md', title: 'Writing standard' },
|
|
41
48
|
{ file: 'report-format.md', title: 'Report format' },
|
|
42
49
|
{ file: 'decision-request.md', title: 'Decision request' },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards.js","sourceRoot":"","sources":["../../src/lib/standards.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEnF
|
|
1
|
+
{"version":3,"file":"standards.js","sourceRoot":"","sources":["../../src/lib/standards.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;G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,+EAA+E;oBAC/E,uEAAuE;oBACvE,GAAG,kBAAkB,CAAC,GAAG,CAAC,GAAG;aAChC;SACF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,GAAG;QACH,MAAM;QACN,QAAQ;QACR,QAAQ,EAAE,MAAM,CAAC,MAAM,KAAK,kBAAkB,CAAC,MAAM;QACrD,QAAQ;KACT,CAAC;AACJ,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,eAAe,CAAC,MAAuB;IACrD,MAAM,KAAK,GAAG;QACZ,kDAAkD;QAClD,EAAE;QACF,sFAAsF;YACpF,4EAA4E;QAC9E,EAAE;KACH,CAAC;IACF,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;YAAE,SAAS;QAC1C,KAAK,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACzD,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACtB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* team-identity -- which team `mx-agent start` resolves to, and whether that is
|
|
3
|
+
* the team the worktree records (#410).
|
|
4
|
+
*
|
|
5
|
+
* WHAT WENT WRONG. `start.ts` derived its team slug as
|
|
6
|
+
* `process.env.CLAUDE_TEAM_NAME || name`, so an inherited environment variable
|
|
7
|
+
* outranked the command's own positional argument. Every other identity in the
|
|
8
|
+
* command comes from that argument — the worktree (`start.ts:646`), the catalog
|
|
9
|
+
* entry and the roleguide (`start.ts:749-756`) — and only the every-turn
|
|
10
|
+
* behavioral block written into `CLAUDE.local.md` came from the variable. A
|
|
11
|
+
* session started for one team could therefore be given another team's block,
|
|
12
|
+
* with no refusal and no diagnostic. `CLAUDE_TEAM_NAME` is exported into every
|
|
13
|
+
* spawned session (`lib/agent-session.ts:286`, `lib/claude.ts:1716`), so a
|
|
14
|
+
* leader running `mx-agent start <other-team>` reproduces it without anyone
|
|
15
|
+
* setting a variable by hand.
|
|
16
|
+
*
|
|
17
|
+
* THE RULE IS HERE AND NOWHERE ELSE. `start.ts` holds no precedence expression
|
|
18
|
+
* of its own; it calls `checkStartTeamIdentity` and uses what comes back. The
|
|
19
|
+
* completion check's row 8 (`commands/create.ts`) calls the same function. One
|
|
20
|
+
* rule, two readers: the row cannot report a precedence the command does not
|
|
21
|
+
* apply, which is what lets the row report the failing value against the pre-fix
|
|
22
|
+
* rule rather than only once the fix is in (#428 criterion 6).
|
|
23
|
+
*
|
|
24
|
+
* IT WARNS; IT DOES NOT REFUSE. Per #4123's tiering — recorded at
|
|
25
|
+
* `lib/claude.ts:860-862` and quoted in #428 — the fail-CLOSED tier is reserved
|
|
26
|
+
* for the hooks / settings.json / agent-config security subclass, and this is
|
|
27
|
+
* not that. Every warning carries a code, so a degraded start is machine-visible
|
|
28
|
+
* in the structured startup report rather than living only in a scrollback.
|
|
29
|
+
* Whether a mismatch should refuse is a product-owner decision, not this
|
|
30
|
+
* module's.
|
|
31
|
+
*
|
|
32
|
+
* NOTHING HERE THROWS AND NOTHING HERE WRITES. Both functions are pure given
|
|
33
|
+
* their inputs plus one read of `.mx-code-context.json`, which
|
|
34
|
+
* `readCodeContextValues` already performs without throwing.
|
|
35
|
+
*/
|
|
36
|
+
/** The environment variable the pre-fix rule let outrank the argument. */
|
|
37
|
+
export declare const TEAM_NAME_ENV = "CLAUDE_TEAM_NAME";
|
|
38
|
+
/** Which input the resolved slug came from. `none` means neither was given. */
|
|
39
|
+
export type TeamSlugSource = 'argument' | 'environment' | 'none';
|
|
40
|
+
export interface StartTeamSlugResolution {
|
|
41
|
+
/** The team whose behavioral block a start would write. Empty when neither input held one. */
|
|
42
|
+
slug: string;
|
|
43
|
+
source: TeamSlugSource;
|
|
44
|
+
/** `CLAUDE_TEAM_NAME` as read, or null when it is unset or empty. */
|
|
45
|
+
envSlug: string | null;
|
|
46
|
+
/** True when the environment named a team and the argument outranked it. */
|
|
47
|
+
envOverridden: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Resolve the team slug for a `start`: THE ARGUMENT WINS, and the environment
|
|
51
|
+
* variable is the fallback when no argument is given (#410 remedy 1, #428 part
|
|
52
|
+
* 1).
|
|
53
|
+
*
|
|
54
|
+
* An empty string reads as absent on both sides, which is what the pre-fix `||`
|
|
55
|
+
* expression did and what commander's `<name>` already guarantees for the
|
|
56
|
+
* argument on the command path. Neither value is trimmed or validated here: the
|
|
57
|
+
* slug goes on to `resolveBehavioralInjection`, which refuses an unsafe one and
|
|
58
|
+
* names it (`lib/behavioral-injection.ts:202`), and validating twice in two
|
|
59
|
+
* places is how the two come to disagree.
|
|
60
|
+
*/
|
|
61
|
+
export declare function resolveStartTeamSlug(argSlug: string | undefined, env?: NodeJS.ProcessEnv): StartTeamSlugResolution;
|
|
62
|
+
/**
|
|
63
|
+
* `match` when the resolved slug is the team the worktree records, `mismatch`
|
|
64
|
+
* when the two are known and differ, `unresolvable` when there is nothing to
|
|
65
|
+
* compare against.
|
|
66
|
+
*
|
|
67
|
+
* `unresolvable` is its own outcome and is never collapsed into either of the
|
|
68
|
+
* others, for the reason row 7 states about its own third value: a check that
|
|
69
|
+
* could not look is not a check that passed, and it is not a check that failed.
|
|
70
|
+
*/
|
|
71
|
+
export type StartIdentityVerdict = 'match' | 'mismatch' | 'unresolvable';
|
|
72
|
+
/** The three machine-visible codes a degraded start emits. */
|
|
73
|
+
export type StartIdentityWarningCode =
|
|
74
|
+
/** The environment named one team, the argument named another; the argument won. */
|
|
75
|
+
'start-team-env-ignored'
|
|
76
|
+
/** The resolved team is not the team `.mx-code-context.json` records. */
|
|
77
|
+
| 'start-team-worktree-mismatch'
|
|
78
|
+
/** There was a worktree to read and it recorded no readable team, so nothing was compared. */
|
|
79
|
+
| 'start-team-identity-unreadable';
|
|
80
|
+
export interface StartIdentityWarning {
|
|
81
|
+
message: string;
|
|
82
|
+
code: StartIdentityWarningCode;
|
|
83
|
+
}
|
|
84
|
+
export interface StartTeamIdentity {
|
|
85
|
+
resolution: StartTeamSlugResolution;
|
|
86
|
+
/** `team` from the worktree's `.mx-code-context.json`, or null when absent or unreadable. */
|
|
87
|
+
recorded: string | null;
|
|
88
|
+
verdict: StartIdentityVerdict;
|
|
89
|
+
/** Every warning to emit, in order. The caller logs them; nothing is printed here. */
|
|
90
|
+
warnings: StartIdentityWarning[];
|
|
91
|
+
}
|
|
92
|
+
export interface StartTeamIdentityOptions {
|
|
93
|
+
/** The positional team slug the command was given. */
|
|
94
|
+
argSlug: string | undefined;
|
|
95
|
+
/** The worktree whose `.mx-code-context.json` records the team, or null when there is none to read. */
|
|
96
|
+
worktreePath: string | null;
|
|
97
|
+
/** Defaults to this process's environment, which is the one a launched session inherits. */
|
|
98
|
+
env?: NodeJS.ProcessEnv;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Resolve the team slug and compare it with the worktree's own recorded
|
|
102
|
+
* identity (#410 remedy 2, #428 part 2).
|
|
103
|
+
*
|
|
104
|
+
* THREE WARNINGS, NOT ONE, because the three states have different remedies and
|
|
105
|
+
* any can hold without the others. A start whose environment disagrees with
|
|
106
|
+
* its argument is now correct and still worth saying out loud: the operator
|
|
107
|
+
* asked for one team in a shell that names another, and until #410 that
|
|
108
|
+
* combination silently produced the other team's block. A resolved slug that
|
|
109
|
+
* disagrees with `.mx-code-context.json` is the state #410 observed on
|
|
110
|
+
* `creation-probe`, and it is reachable without any environment variable at all
|
|
111
|
+
* — a worktree provisioned for one team and started under another name.
|
|
112
|
+
*
|
|
113
|
+
* COULD-NOT-LOOK IS THE THIRD, and it has its own code because a check reduced
|
|
114
|
+
* to silence reads exactly like a check that agreed. There was a worktree to
|
|
115
|
+
* read and it recorded no team the reader could use: no file, a file that does
|
|
116
|
+
* not parse, a file holding no `team`, or a symlink, which
|
|
117
|
+
* `readCodeContextValues` declines to follow (`lib/code-context-file.ts:227-228`).
|
|
118
|
+
* All four return the same null, and all four mean the mismatch detector above
|
|
119
|
+
* never ran. Removing or corrupting one file must not buy the same output as a
|
|
120
|
+
* clean start. It warns and does not refuse, at the same tier as the other two.
|
|
121
|
+
*
|
|
122
|
+
* The code is emitted only when there WAS a worktree to read and something was
|
|
123
|
+
* resolved to compare. With no worktree path, and with an empty resolved slug,
|
|
124
|
+
* `unresolvable` is the caller's own doing rather than a degraded worktree, and
|
|
125
|
+
* the caller already knows which input it withheld.
|
|
126
|
+
*
|
|
127
|
+
* VALUES FROM DISK AND FROM THE ENVIRONMENT ARE SANITISED INTO THE MESSAGE.
|
|
128
|
+
* `.mx-code-context.json` is a file this repository writes but does not own at
|
|
129
|
+
* runtime (`lib/code-context-file.ts:175-186`), and `CLAUDE_TEAM_NAME` is
|
|
130
|
+
* whatever the parent shell exported; both reach a terminal through
|
|
131
|
+
* `logWarning`, which is the sink `sanitizeForMessage` exists for.
|
|
132
|
+
*/
|
|
133
|
+
export declare function checkStartTeamIdentity(opts: StartTeamIdentityOptions): StartTeamIdentity;
|
|
134
|
+
//# sourceMappingURL=team-identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"team-identity.d.ts","sourceRoot":"","sources":["../../src/lib/team-identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAKH,0EAA0E;AAC1E,eAAO,MAAM,aAAa,qBAAqB,CAAC;AAEhD,+EAA+E;AAC/E,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,aAAa,GAAG,MAAM,CAAC;AAEjE,MAAM,WAAW,uBAAuB;IACtC,8FAA8F;IAC9F,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,cAAc,CAAC;IACvB,qEAAqE;IACrE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,4EAA4E;IAC5E,aAAa,EAAE,OAAO,CAAC;CACxB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,uBAAuB,CAWzB;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,UAAU,GAAG,cAAc,CAAC;AAEzE,8DAA8D;AAC9D,MAAM,MAAM,wBAAwB;AAClC,oFAAoF;AAClF,wBAAwB;AAC1B,yEAAyE;GACvE,8BAA8B;AAChC,8FAA8F;GAC5F,gCAAgC,CAAC;AAErC,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,wBAAwB,CAAC;CAChC;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,uBAAuB,CAAC;IACpC,6FAA6F;IAC7F,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,sFAAsF;IACtF,QAAQ,EAAE,oBAAoB,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,wBAAwB;IACvC,sDAAsD;IACtD,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,uGAAuG;IACvG,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,4FAA4F;IAC5F,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,wBAAwB,GAAG,iBAAiB,CA0GxF"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* team-identity -- which team `mx-agent start` resolves to, and whether that is
|
|
3
|
+
* the team the worktree records (#410).
|
|
4
|
+
*
|
|
5
|
+
* WHAT WENT WRONG. `start.ts` derived its team slug as
|
|
6
|
+
* `process.env.CLAUDE_TEAM_NAME || name`, so an inherited environment variable
|
|
7
|
+
* outranked the command's own positional argument. Every other identity in the
|
|
8
|
+
* command comes from that argument — the worktree (`start.ts:646`), the catalog
|
|
9
|
+
* entry and the roleguide (`start.ts:749-756`) — and only the every-turn
|
|
10
|
+
* behavioral block written into `CLAUDE.local.md` came from the variable. A
|
|
11
|
+
* session started for one team could therefore be given another team's block,
|
|
12
|
+
* with no refusal and no diagnostic. `CLAUDE_TEAM_NAME` is exported into every
|
|
13
|
+
* spawned session (`lib/agent-session.ts:286`, `lib/claude.ts:1716`), so a
|
|
14
|
+
* leader running `mx-agent start <other-team>` reproduces it without anyone
|
|
15
|
+
* setting a variable by hand.
|
|
16
|
+
*
|
|
17
|
+
* THE RULE IS HERE AND NOWHERE ELSE. `start.ts` holds no precedence expression
|
|
18
|
+
* of its own; it calls `checkStartTeamIdentity` and uses what comes back. The
|
|
19
|
+
* completion check's row 8 (`commands/create.ts`) calls the same function. One
|
|
20
|
+
* rule, two readers: the row cannot report a precedence the command does not
|
|
21
|
+
* apply, which is what lets the row report the failing value against the pre-fix
|
|
22
|
+
* rule rather than only once the fix is in (#428 criterion 6).
|
|
23
|
+
*
|
|
24
|
+
* IT WARNS; IT DOES NOT REFUSE. Per #4123's tiering — recorded at
|
|
25
|
+
* `lib/claude.ts:860-862` and quoted in #428 — the fail-CLOSED tier is reserved
|
|
26
|
+
* for the hooks / settings.json / agent-config security subclass, and this is
|
|
27
|
+
* not that. Every warning carries a code, so a degraded start is machine-visible
|
|
28
|
+
* in the structured startup report rather than living only in a scrollback.
|
|
29
|
+
* Whether a mismatch should refuse is a product-owner decision, not this
|
|
30
|
+
* module's.
|
|
31
|
+
*
|
|
32
|
+
* NOTHING HERE THROWS AND NOTHING HERE WRITES. Both functions are pure given
|
|
33
|
+
* their inputs plus one read of `.mx-code-context.json`, which
|
|
34
|
+
* `readCodeContextValues` already performs without throwing.
|
|
35
|
+
*/
|
|
36
|
+
import { readCodeContextValues, CODE_CONTEXT_FILENAME } from './code-context-file.js';
|
|
37
|
+
import { sanitizeForMessage } from './behavioral-injection.js';
|
|
38
|
+
/** The environment variable the pre-fix rule let outrank the argument. */
|
|
39
|
+
export const TEAM_NAME_ENV = 'CLAUDE_TEAM_NAME';
|
|
40
|
+
/**
|
|
41
|
+
* Resolve the team slug for a `start`: THE ARGUMENT WINS, and the environment
|
|
42
|
+
* variable is the fallback when no argument is given (#410 remedy 1, #428 part
|
|
43
|
+
* 1).
|
|
44
|
+
*
|
|
45
|
+
* An empty string reads as absent on both sides, which is what the pre-fix `||`
|
|
46
|
+
* expression did and what commander's `<name>` already guarantees for the
|
|
47
|
+
* argument on the command path. Neither value is trimmed or validated here: the
|
|
48
|
+
* slug goes on to `resolveBehavioralInjection`, which refuses an unsafe one and
|
|
49
|
+
* names it (`lib/behavioral-injection.ts:202`), and validating twice in two
|
|
50
|
+
* places is how the two come to disagree.
|
|
51
|
+
*/
|
|
52
|
+
export function resolveStartTeamSlug(argSlug, env = process.env) {
|
|
53
|
+
const envSlug = env[TEAM_NAME_ENV] || null;
|
|
54
|
+
const arg = argSlug || '';
|
|
55
|
+
if (arg) {
|
|
56
|
+
return { slug: arg, source: 'argument', envSlug, envOverridden: envSlug !== null && envSlug !== arg };
|
|
57
|
+
}
|
|
58
|
+
if (envSlug) {
|
|
59
|
+
return { slug: envSlug, source: 'environment', envSlug, envOverridden: false };
|
|
60
|
+
}
|
|
61
|
+
return { slug: '', source: 'none', envSlug: null, envOverridden: false };
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Resolve the team slug and compare it with the worktree's own recorded
|
|
65
|
+
* identity (#410 remedy 2, #428 part 2).
|
|
66
|
+
*
|
|
67
|
+
* THREE WARNINGS, NOT ONE, because the three states have different remedies and
|
|
68
|
+
* any can hold without the others. A start whose environment disagrees with
|
|
69
|
+
* its argument is now correct and still worth saying out loud: the operator
|
|
70
|
+
* asked for one team in a shell that names another, and until #410 that
|
|
71
|
+
* combination silently produced the other team's block. A resolved slug that
|
|
72
|
+
* disagrees with `.mx-code-context.json` is the state #410 observed on
|
|
73
|
+
* `creation-probe`, and it is reachable without any environment variable at all
|
|
74
|
+
* — a worktree provisioned for one team and started under another name.
|
|
75
|
+
*
|
|
76
|
+
* COULD-NOT-LOOK IS THE THIRD, and it has its own code because a check reduced
|
|
77
|
+
* to silence reads exactly like a check that agreed. There was a worktree to
|
|
78
|
+
* read and it recorded no team the reader could use: no file, a file that does
|
|
79
|
+
* not parse, a file holding no `team`, or a symlink, which
|
|
80
|
+
* `readCodeContextValues` declines to follow (`lib/code-context-file.ts:227-228`).
|
|
81
|
+
* All four return the same null, and all four mean the mismatch detector above
|
|
82
|
+
* never ran. Removing or corrupting one file must not buy the same output as a
|
|
83
|
+
* clean start. It warns and does not refuse, at the same tier as the other two.
|
|
84
|
+
*
|
|
85
|
+
* The code is emitted only when there WAS a worktree to read and something was
|
|
86
|
+
* resolved to compare. With no worktree path, and with an empty resolved slug,
|
|
87
|
+
* `unresolvable` is the caller's own doing rather than a degraded worktree, and
|
|
88
|
+
* the caller already knows which input it withheld.
|
|
89
|
+
*
|
|
90
|
+
* VALUES FROM DISK AND FROM THE ENVIRONMENT ARE SANITISED INTO THE MESSAGE.
|
|
91
|
+
* `.mx-code-context.json` is a file this repository writes but does not own at
|
|
92
|
+
* runtime (`lib/code-context-file.ts:175-186`), and `CLAUDE_TEAM_NAME` is
|
|
93
|
+
* whatever the parent shell exported; both reach a terminal through
|
|
94
|
+
* `logWarning`, which is the sink `sanitizeForMessage` exists for.
|
|
95
|
+
*/
|
|
96
|
+
export function checkStartTeamIdentity(opts) {
|
|
97
|
+
const resolution = resolveStartTeamSlug(opts.argSlug, opts.env ?? process.env);
|
|
98
|
+
const recorded = opts.worktreePath
|
|
99
|
+
? readCodeContextValues(opts.worktreePath)?.team ?? null
|
|
100
|
+
: null;
|
|
101
|
+
const verdict = recorded === null || resolution.slug === ''
|
|
102
|
+
? 'unresolvable'
|
|
103
|
+
: recorded === resolution.slug
|
|
104
|
+
? 'match'
|
|
105
|
+
: 'mismatch';
|
|
106
|
+
const warnings = [];
|
|
107
|
+
if (resolution.envOverridden) {
|
|
108
|
+
warnings.push({
|
|
109
|
+
code: 'start-team-env-ignored',
|
|
110
|
+
message: `${TEAM_NAME_ENV} names team "${sanitizeForMessage(resolution.envSlug ?? '', 80)}" and this ` +
|
|
111
|
+
`command was given "${sanitizeForMessage(resolution.slug, 80)}". The argument wins (#410): the ` +
|
|
112
|
+
`every-turn behavioral block written into CLAUDE.local.md is ` +
|
|
113
|
+
`"${sanitizeForMessage(resolution.slug, 80)}"'s. If you meant the other team, run ` +
|
|
114
|
+
`mx-agent start ${sanitizeForMessage(resolution.envSlug ?? '', 80)} in its own worktree; ` +
|
|
115
|
+
`otherwise unset ${TEAM_NAME_ENV}.`,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (verdict === 'mismatch') {
|
|
119
|
+
warnings.push({
|
|
120
|
+
code: 'start-team-worktree-mismatch',
|
|
121
|
+
message: `Team MISMATCH: this start resolved to "${sanitizeForMessage(resolution.slug, 80)}" ` +
|
|
122
|
+
`(from the ${resolution.source}), but ${CODE_CONTEXT_FILENAME} in this worktree records ` +
|
|
123
|
+
`"${sanitizeForMessage(recorded ?? '', 80)}". The every-turn behavioral block, the memory ` +
|
|
124
|
+
`scope and the coordination identity would name different teams. Fix: run mx-agent start ` +
|
|
125
|
+
`${sanitizeForMessage(recorded ?? '', 80)} in this worktree, or start ` +
|
|
126
|
+
`"${sanitizeForMessage(resolution.slug, 80)}" in its own. Session continues.`,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
// THE REMEDIATION IS A COMMAND THAT RUNS, and it was measured rather than
|
|
130
|
+
// read off the argument parser (security re-review, Should Fix 1 on #429).
|
|
131
|
+
// `mx-agent create <slug>` does not run: `--roleguide` is a `requiredOption`
|
|
132
|
+
// (`src/index.ts:185`) and commander exits 1 during parse, before any action.
|
|
133
|
+
// Measured 2026-09-05: `node dist/index.js create platform` exits 1 with
|
|
134
|
+
// `error: required option '--roleguide <path>' not specified`, and `create`
|
|
135
|
+
// is a deprecated alias of `provision` besides (`src/index.ts:184`).
|
|
136
|
+
//
|
|
137
|
+
// `mx-agent provision --roleguide <path> --name <slug>` is the one that
|
|
138
|
+
// repairs this state. A worktree that already exists is RESUMED
|
|
139
|
+
// (`commands/create.ts:5218-5219`) and step 6a rewrites the file
|
|
140
|
+
// (`commands/create.ts:5307`). Measured 2026-09-05 against a sandbox project
|
|
141
|
+
// outside this repository, twice: with the worktree holding neither file
|
|
142
|
+
// (`Identity: neither .mx-code-context.json nor CLAUDE.local.md exists yet`)
|
|
143
|
+
// and with `CLAUDE.local.md` present and the scope file removed, which is the
|
|
144
|
+
// state real team worktrees are in. Both wrote the file and both then
|
|
145
|
+
// reported row 8 asserted. It works from inside the worktree too: the run
|
|
146
|
+
// resolves the main checkout as its root. `--recheck` is NOT the repair. It
|
|
147
|
+
// writes nothing (`src/index.ts:135`), and the file stayed absent when run.
|
|
148
|
+
//
|
|
149
|
+
// THE MESSAGE STATES THE SCOPE OF THAT COMMAND, because a resume does far
|
|
150
|
+
// more than rewrite one file and an operator clearing this warning has not
|
|
151
|
+
// asked for the rest (security re-review, Should Fix 1 on #429). The
|
|
152
|
+
// `if (resuming)` block closes at `commands/create.ts:5231`; the only later
|
|
153
|
+
// `resuming` branches are step 7's memory-attribution rows (`:5628`) and
|
|
154
|
+
// step 8's catalog entry (`:5751`). Everything else runs unconditionally.
|
|
155
|
+
// Read at `42b2f5d`, not carried from the review:
|
|
156
|
+
// step 5 (`:5253`) `syncClaudeConfig` regenerates the WHOLE `.claude/`
|
|
157
|
+
// tree — settings.json, hooks, agents, skills, commands, rules —
|
|
158
|
+
// from `origin/<baseBranch>` via the generator's `--from-git` mode
|
|
159
|
+
// (`lib/claude.ts:1150`, `:1203-1215`), then `deployClaudeMd`
|
|
160
|
+
// rewrites CLAUDE.md (`:5254`).
|
|
161
|
+
// step 6 (`:5264`) `writeClaudeLocal` rewrites CLAUDE.local.md.
|
|
162
|
+
// step 6e (`:5493`) `buildCliInWorktree` runs npm ci and npm run build in
|
|
163
|
+
// the worktree, skipped only when row 13 or the anchors refuse.
|
|
164
|
+
// step 8b (`:5813`, call at `:5832`) requests a coordination credential when
|
|
165
|
+
// `usesCredentialEndpoint(cfg.projectSlug)` and the team is on the
|
|
166
|
+
// roster. `CREDENTIAL_ENDPOINT_PROJECTS` holds `'mx-agent'`
|
|
167
|
+
// (`lib/coordination-token.ts:141`) and this project's slug is
|
|
168
|
+
// `mx-agent` (`mx-agent.config.json:8`), so it fires here. The
|
|
169
|
+
// message says "where the project uses one" because this library
|
|
170
|
+
// also runs for projects that take the Key Vault path instead.
|
|
171
|
+
// TWO ITEMS FROM THE REVIEW ARE NOT IN THE MESSAGE. Step 6d (`:5443`) does
|
|
172
|
+
// NOT edit the roleguide's anchors table: `anchorStage` (`:1753`) only stats,
|
|
173
|
+
// reads and parses, and contains no write call. And a resume neither
|
|
174
|
+
// overwrites a memory that already exists nor rewrites an existing catalog
|
|
175
|
+
// entry (`:5764`, "a resume leaves it byte for byte"), so naming those as
|
|
176
|
+
// effects would overstate what an operator gets.
|
|
177
|
+
if (verdict === 'unresolvable' && opts.worktreePath && resolution.slug !== '') {
|
|
178
|
+
warnings.push({
|
|
179
|
+
code: 'start-team-identity-unreadable',
|
|
180
|
+
message: `Team identity NOT CHECKED: ${CODE_CONTEXT_FILENAME} in this worktree records no readable ` +
|
|
181
|
+
`team, so the resolved team "${sanitizeForMessage(resolution.slug, 80)}" (from the ` +
|
|
182
|
+
`${resolution.source}) was not compared against anything. The file is missing, does not ` +
|
|
183
|
+
`parse, holds no team, or is a symlink, which is not followed. Fix: run mx-agent provision ` +
|
|
184
|
+
`--roleguide <path> --name ${sanitizeForMessage(resolution.slug, 80)}. That RE-PROVISIONS ` +
|
|
185
|
+
`this worktree rather than restoring one file: it also regenerates .claude/ (settings.json ` +
|
|
186
|
+
`and hooks) and CLAUDE.md from origin, rewrites CLAUDE.local.md, rebuilds the CLI here, and ` +
|
|
187
|
+
`requests this team's coordination credential where the project uses one. To repair only ` +
|
|
188
|
+
`this file, restore it by hand. Session continues.`,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
return { resolution, recorded, verdict, warnings };
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=team-identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"team-identity.js","sourceRoot":"","sources":["../../src/lib/team-identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,0EAA0E;AAC1E,MAAM,CAAC,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAehD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAA2B,EAC3B,MAAyB,OAAO,CAAC,GAAG;IAEpC,MAAM,OAAO,GAAG,GAAG,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC;IAC3C,MAAM,GAAG,GAAG,OAAO,IAAI,EAAE,CAAC;IAE1B,IAAI,GAAG,EAAE,CAAC;QACR,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,GAAG,EAAE,CAAC;IACxG,CAAC;IACD,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;IACjF,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,MA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