@memnexus-ai/mx-agent-cli 0.1.294 → 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 +89 -1
- 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__/decision-check.test.d.ts +2 -0
- package/dist/__tests__/decision-check.test.d.ts.map +1 -0
- package/dist/__tests__/decision-check.test.js +105 -0
- package/dist/__tests__/decision-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__/harness-extract.test.d.ts +19 -0
- package/dist/__tests__/harness-extract.test.d.ts.map +1 -0
- package/dist/__tests__/harness-extract.test.js +566 -0
- package/dist/__tests__/harness-extract.test.js.map +1 -0
- package/dist/__tests__/harness-wiring.test.d.ts +16 -0
- package/dist/__tests__/harness-wiring.test.d.ts.map +1 -0
- package/dist/__tests__/harness-wiring.test.js +469 -0
- package/dist/__tests__/harness-wiring.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__/report-format.test.d.ts +2 -0
- package/dist/__tests__/report-format.test.d.ts.map +1 -0
- package/dist/__tests__/report-format.test.js +219 -0
- package/dist/__tests__/report-format.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.d.ts +2 -0
- package/dist/__tests__/standards-injection.test.d.ts.map +1 -0
- package/dist/__tests__/standards-injection.test.js +179 -0
- package/dist/__tests__/standards-injection.test.js.map +1 -0
- 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 +180 -83
- package/dist/agent-config/hooks/auto-capture-session-end.sh +216 -87
- package/dist/agent-config/hooks/auto-checkpoint.sh +75 -5
- 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/observability-sync.sh +46 -9
- 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-sync.d.ts +37 -0
- package/dist/commands/config-sync.d.ts.map +1 -1
- package/dist/commands/config-sync.js +36 -18
- package/dist/commands/config-sync.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/dashboard.d.ts.map +1 -1
- package/dist/commands/dashboard.js +10 -2
- package/dist/commands/dashboard.js.map +1 -1
- package/dist/commands/decision.d.ts +20 -0
- package/dist/commands/decision.d.ts.map +1 -0
- package/dist/commands/decision.js +54 -0
- package/dist/commands/decision.js.map +1 -0
- 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/monitor.d.ts.map +1 -1
- package/dist/commands/monitor.js +8 -2
- package/dist/commands/monitor.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/report.d.ts +33 -0
- package/dist/commands/report.d.ts.map +1 -0
- package/dist/commands/report.js +73 -0
- package/dist/commands/report.js.map +1 -0
- package/dist/commands/session.js +1 -1
- package/dist/commands/session.js.map +1 -1
- package/dist/commands/start.d.ts +42 -0
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +177 -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/update.d.ts +13 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +50 -1
- package/dist/commands/update.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 +189 -14
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-session.d.ts +12 -0
- package/dist/lib/agent-session.d.ts.map +1 -1
- package/dist/lib/agent-session.js +189 -42
- 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 +65 -23
- package/dist/lib/claude.d.ts.map +1 -1
- package/dist/lib/claude.js +335 -19
- 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/decision-check.d.ts +48 -0
- package/dist/lib/decision-check.d.ts.map +1 -0
- package/dist/lib/decision-check.js +149 -0
- package/dist/lib/decision-check.js.map +1 -0
- 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/harness/console/announce.d.ts +45 -0
- package/dist/lib/harness/console/announce.d.ts.map +1 -0
- package/dist/lib/harness/console/announce.js +48 -0
- package/dist/lib/harness/console/announce.js.map +1 -0
- package/dist/lib/harness/console/announce.test.d.ts +2 -0
- package/dist/lib/harness/console/announce.test.d.ts.map +1 -0
- package/dist/lib/harness/console/announce.test.js +104 -0
- package/dist/lib/harness/console/announce.test.js.map +1 -0
- package/dist/lib/harness/console/by-session.d.ts +50 -0
- package/dist/lib/harness/console/by-session.d.ts.map +1 -0
- package/dist/lib/harness/console/by-session.js +83 -0
- package/dist/lib/harness/console/by-session.js.map +1 -0
- package/dist/lib/harness/console/by-session.test.d.ts +2 -0
- package/dist/lib/harness/console/by-session.test.d.ts.map +1 -0
- package/dist/lib/harness/console/by-session.test.js +86 -0
- package/dist/lib/harness/console/by-session.test.js.map +1 -0
- package/dist/lib/harness/console/console.d.ts +67 -0
- package/dist/lib/harness/console/console.d.ts.map +1 -0
- package/dist/lib/harness/console/console.js +373 -0
- package/dist/lib/harness/console/console.js.map +1 -0
- package/dist/lib/harness/console/console.test.d.ts +2 -0
- package/dist/lib/harness/console/console.test.d.ts.map +1 -0
- package/dist/lib/harness/console/console.test.js +269 -0
- package/dist/lib/harness/console/console.test.js.map +1 -0
- package/dist/lib/harness/console/decision-request.d.ts +32 -0
- package/dist/lib/harness/console/decision-request.d.ts.map +1 -0
- package/dist/lib/harness/console/decision-request.js +112 -0
- package/dist/lib/harness/console/decision-request.js.map +1 -0
- package/dist/lib/harness/console/decision-request.test.d.ts +2 -0
- package/dist/lib/harness/console/decision-request.test.d.ts.map +1 -0
- package/dist/lib/harness/console/decision-request.test.js +75 -0
- package/dist/lib/harness/console/decision-request.test.js.map +1 -0
- package/dist/lib/harness/console/fixtures.d.ts +16 -0
- package/dist/lib/harness/console/fixtures.d.ts.map +1 -0
- package/dist/lib/harness/console/fixtures.js +49 -0
- package/dist/lib/harness/console/fixtures.js.map +1 -0
- package/dist/lib/harness/console/index.d.ts +15 -0
- package/dist/lib/harness/console/index.d.ts.map +1 -0
- package/dist/lib/harness/console/index.js +14 -0
- package/dist/lib/harness/console/index.js.map +1 -0
- package/dist/lib/harness/console/rank.d.ts +73 -0
- package/dist/lib/harness/console/rank.d.ts.map +1 -0
- package/dist/lib/harness/console/rank.js +113 -0
- package/dist/lib/harness/console/rank.js.map +1 -0
- package/dist/lib/harness/console/rank.test.d.ts +2 -0
- package/dist/lib/harness/console/rank.test.d.ts.map +1 -0
- package/dist/lib/harness/console/rank.test.js +124 -0
- package/dist/lib/harness/console/rank.test.js.map +1 -0
- package/dist/lib/harness/console/render.d.ts +22 -0
- package/dist/lib/harness/console/render.d.ts.map +1 -0
- package/dist/lib/harness/console/render.js +65 -0
- package/dist/lib/harness/console/render.js.map +1 -0
- package/dist/lib/harness/console/render.test.d.ts +2 -0
- package/dist/lib/harness/console/render.test.d.ts.map +1 -0
- package/dist/lib/harness/console/render.test.js +96 -0
- package/dist/lib/harness/console/render.test.js.map +1 -0
- package/dist/lib/harness/console/replay-cli.test.d.ts +2 -0
- package/dist/lib/harness/console/replay-cli.test.d.ts.map +1 -0
- package/dist/lib/harness/console/replay-cli.test.js +96 -0
- package/dist/lib/harness/console/replay-cli.test.js.map +1 -0
- package/dist/lib/harness/console/replay.d.ts +36 -0
- package/dist/lib/harness/console/replay.d.ts.map +1 -0
- package/dist/lib/harness/console/replay.js +59 -0
- package/dist/lib/harness/console/replay.js.map +1 -0
- package/dist/lib/harness/console/replay.test.d.ts +2 -0
- package/dist/lib/harness/console/replay.test.d.ts.map +1 -0
- package/dist/lib/harness/console/replay.test.js +81 -0
- package/dist/lib/harness/console/replay.test.js.map +1 -0
- package/dist/lib/harness/console/turn-reader.d.ts +50 -0
- package/dist/lib/harness/console/turn-reader.d.ts.map +1 -0
- package/dist/lib/harness/console/turn-reader.js +184 -0
- package/dist/lib/harness/console/turn-reader.js.map +1 -0
- package/dist/lib/harness/console/turn-reader.test.d.ts +2 -0
- package/dist/lib/harness/console/turn-reader.test.d.ts.map +1 -0
- package/dist/lib/harness/console/turn-reader.test.js +108 -0
- package/dist/lib/harness/console/turn-reader.test.js.map +1 -0
- package/dist/lib/harness/console/types.d.ts +109 -0
- package/dist/lib/harness/console/types.d.ts.map +1 -0
- package/dist/lib/harness/console/types.js +2 -0
- package/dist/lib/harness/console/types.js.map +1 -0
- package/dist/lib/harness/contract.d.ts +229 -0
- package/dist/lib/harness/contract.d.ts.map +1 -0
- package/dist/lib/harness/contract.js +22 -0
- package/dist/lib/harness/contract.js.map +1 -0
- package/dist/lib/harness/credential.d.ts +23 -0
- package/dist/lib/harness/credential.d.ts.map +1 -0
- package/dist/lib/harness/credential.js +81 -0
- package/dist/lib/harness/credential.js.map +1 -0
- package/dist/lib/harness/credential.test.d.ts +2 -0
- package/dist/lib/harness/credential.test.d.ts.map +1 -0
- package/dist/lib/harness/credential.test.js +74 -0
- package/dist/lib/harness/credential.test.js.map +1 -0
- package/dist/lib/harness/evaluate.d.ts +390 -0
- package/dist/lib/harness/evaluate.d.ts.map +1 -0
- package/dist/lib/harness/evaluate.js +988 -0
- package/dist/lib/harness/evaluate.js.map +1 -0
- package/dist/lib/harness/evaluate.test.d.ts +2 -0
- package/dist/lib/harness/evaluate.test.d.ts.map +1 -0
- package/dist/lib/harness/evaluate.test.js +621 -0
- package/dist/lib/harness/evaluate.test.js.map +1 -0
- package/dist/lib/harness/extract.d.ts +152 -0
- package/dist/lib/harness/extract.d.ts.map +1 -0
- package/dist/lib/harness/extract.js +1601 -0
- package/dist/lib/harness/extract.js.map +1 -0
- package/dist/lib/harness/gate.d.ts +48 -0
- package/dist/lib/harness/gate.d.ts.map +1 -0
- package/dist/lib/harness/gate.js +60 -0
- package/dist/lib/harness/gate.js.map +1 -0
- package/dist/lib/harness/gate.test.d.ts +2 -0
- package/dist/lib/harness/gate.test.d.ts.map +1 -0
- package/dist/lib/harness/gate.test.js +111 -0
- package/dist/lib/harness/gate.test.js.map +1 -0
- package/dist/lib/harness/self-check.d.ts +59 -0
- package/dist/lib/harness/self-check.d.ts.map +1 -0
- package/dist/lib/harness/self-check.js +56 -0
- package/dist/lib/harness/self-check.js.map +1 -0
- package/dist/lib/harness/self-check.test.d.ts +2 -0
- package/dist/lib/harness/self-check.test.d.ts.map +1 -0
- package/dist/lib/harness/self-check.test.js +43 -0
- package/dist/lib/harness/self-check.test.js.map +1 -0
- package/dist/lib/harness/transcript.d.ts +65 -0
- package/dist/lib/harness/transcript.d.ts.map +1 -0
- package/dist/lib/harness/transcript.js +144 -0
- package/dist/lib/harness/transcript.js.map +1 -0
- package/dist/lib/harness/transcript.test.d.ts +2 -0
- package/dist/lib/harness/transcript.test.d.ts.map +1 -0
- package/dist/lib/harness/transcript.test.js +118 -0
- package/dist/lib/harness/transcript.test.js.map +1 -0
- package/dist/lib/harness-wiring.d.ts +145 -0
- package/dist/lib/harness-wiring.d.ts.map +1 -0
- package/dist/lib/harness-wiring.js +280 -0
- package/dist/lib/harness-wiring.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/report-format.d.ts +132 -0
- package/dist/lib/report-format.d.ts.map +1 -0
- package/dist/lib/report-format.js +317 -0
- package/dist/lib/report-format.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 +99 -0
- package/dist/lib/standards.d.ts.map +1 -0
- package/dist/lib/standards.js +201 -0
- package/dist/lib/standards.js.map +1 -0
- 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/terminal-ui.d.ts.map +1 -1
- package/dist/lib/terminal-ui.js +12 -1
- package/dist/lib/terminal-ui.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 +98 -0
- package/dist/standards/fail-loud-standard.md +495 -0
- package/dist/standards/po-communication-standard.md +126 -0
- package/dist/standards/report-format.md +128 -0
- package/dist/standards/writing-standard.md +382 -0
- package/package.json +3 -2
- package/scripts/generate-claude.mjs +119 -46
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { existsSync, readFileSync } from 'fs';
|
|
10
10
|
import { join } from 'path';
|
|
11
|
+
// config.ts imports only fs, path and os, so this direction cannot cycle. The
|
|
12
|
+
// reader is injectable anyway, so a future import in the other direction does not
|
|
13
|
+
// force this module to reach for the filesystem.
|
|
14
|
+
import { getConfigValue } from './config.js';
|
|
11
15
|
/**
|
|
12
16
|
* Model every fleet session launches with unless a project overrides it.
|
|
13
17
|
* Single source of truth for both session runtimes (claude.ts spawn + the
|
|
@@ -22,11 +26,23 @@ export const PROJECT_CONFIG_DEFAULTS = {
|
|
|
22
26
|
roleguidesDir: 'mx-agent-system/roleguides',
|
|
23
27
|
projectSlug: '',
|
|
24
28
|
observabilityApiUrl: '',
|
|
29
|
+
gatewayUrl: '',
|
|
30
|
+
codexGatewayPilot: { enabled: false, url: '' },
|
|
25
31
|
coordinationMode: '',
|
|
26
32
|
sessionModel: DEFAULT_SESSION_MODEL,
|
|
33
|
+
coordinationServiceUrl: '',
|
|
27
34
|
};
|
|
28
|
-
/**
|
|
29
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Characters that must not appear in config values used in shell commands.
|
|
37
|
+
*
|
|
38
|
+
* The C0 range and DEL are rejected whole (`\x00-\x1f\x7f`), which subsumes the
|
|
39
|
+
* newline, carriage return and NUL this listed before. Config strings reach
|
|
40
|
+
* operator-facing refusal messages: `baseBranch` and `teamsDir` are both named
|
|
41
|
+
* in the catalog-entry precondition (#51). ESC is the one that matters there,
|
|
42
|
+
* because a value holding `\x1b[` writes terminal escapes into whatever prints
|
|
43
|
+
* it (security review, 2026-08-22).
|
|
44
|
+
*/
|
|
45
|
+
const SHELL_UNSAFE_RE = /[;|&`$(){}!#\\<>\x00-\x1f\x7f]/;
|
|
30
46
|
/**
|
|
31
47
|
* Positive allowlist for `sessionModel` (#4487). Unlike the shared denylist
|
|
32
48
|
* below, this is anchored: the value must START with a letter or digit, so it
|
|
@@ -35,19 +51,285 @@ const SHELL_UNSAFE_RE = /[;|&`$(){}!#\\<>\n\r\x00]/;
|
|
|
35
51
|
* like the legacy `claude-opus-4-6[1m]` rollback value valid.
|
|
36
52
|
*/
|
|
37
53
|
const SESSION_MODEL_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*(\[[0-9]+[km]\])?$/;
|
|
54
|
+
/**
|
|
55
|
+
* Hosts for which a plaintext `http:` coordination URL is accepted. Everything
|
|
56
|
+
* else must be `https:`, so a committed config cannot point a fleet's bearer
|
|
57
|
+
* token at a cleartext endpoint.
|
|
58
|
+
*/
|
|
59
|
+
const PLAINTEXT_URL_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]']);
|
|
60
|
+
/**
|
|
61
|
+
* Host suffixes an `https:` coordination URL may end with, built in. A committed
|
|
62
|
+
* config points a fleet's bearer token at whatever host it names, so the set of
|
|
63
|
+
* hosts a checked-in file may choose is closed rather than open (#59 amendment,
|
|
64
|
+
* security review at 577576c). The PRD's per-project hostnames decision is why
|
|
65
|
+
* the suffix rather than a single host.
|
|
66
|
+
*
|
|
67
|
+
* The leading dot is load-bearing: `evil-memnexus.ai` is a different domain, and
|
|
68
|
+
* the bare apex `memnexus.ai` is not a service host.
|
|
69
|
+
*
|
|
70
|
+
* An operator extends this set through the global config key below. THE SET IS
|
|
71
|
+
* NEVER READ FROM A PROJECT-CONTROLLED FILE. If it ever is, the allowlist stops
|
|
72
|
+
* being a control: a repository could then name its own host as allowed, which is
|
|
73
|
+
* the decision the allowlist exists to keep with the operator (#59 amendment 3).
|
|
74
|
+
*/
|
|
75
|
+
const COORDINATION_URL_ALLOWED_SUFFIXES = ['.memnexus.ai'];
|
|
76
|
+
/**
|
|
77
|
+
* Optional global config key holding extra suffixes, comma-separated, each
|
|
78
|
+
* starting with a dot. `~/.mx-agent/config.json` only: a project on another
|
|
79
|
+
* domain needs `--coordination-service-url` to work, and the operator is the one
|
|
80
|
+
* who decides that their machine trusts that domain.
|
|
81
|
+
*/
|
|
82
|
+
export const COORDINATION_URL_SUFFIX_CONFIG_KEY = 'coordination-url-allowed-suffixes';
|
|
83
|
+
/**
|
|
84
|
+
* The extension key for the CREDENTIAL path, which is a different decision from
|
|
85
|
+
* the key above and is therefore a different key (#290 delta 2, Should Fix 1).
|
|
86
|
+
*
|
|
87
|
+
* The two requests carry different credentials. Ordinary coordination traffic
|
|
88
|
+
* carries a per-team bearer token: scoped to one team, revocable, and reissued by
|
|
89
|
+
* the endpoint this file is about. A credential request carries the operator's
|
|
90
|
+
* MemNexus user key, which has no expiry and is valid for every grant that
|
|
91
|
+
* operator holds. Widening the set of hosts you will send the first to is not the
|
|
92
|
+
* same decision as widening the set you will send the second to, and one key
|
|
93
|
+
* meant an operator who made the first decision had silently made the second.
|
|
94
|
+
*
|
|
95
|
+
* Nothing defaults it to the other key's value. An operator who runs a
|
|
96
|
+
* self-hosted coordination service on another domain sets both, deliberately.
|
|
97
|
+
*/
|
|
98
|
+
export const COORDINATION_CREDENTIAL_SUFFIX_CONFIG_KEY = 'coordination-credential-allowed-suffixes';
|
|
99
|
+
/**
|
|
100
|
+
* Shape of one accepted suffix: a leading dot, then letters, digits, dots and
|
|
101
|
+
* hyphens. Anything else, whitespace or a shell metacharacter included, is
|
|
102
|
+
* dropped rather than refused, so one bad entry cannot make every URL unusable.
|
|
103
|
+
*/
|
|
104
|
+
const COORDINATION_URL_SUFFIX_RE = /^\.[A-Za-z0-9][A-Za-z0-9.-]*$/;
|
|
105
|
+
const defaultSuffixReader = () => {
|
|
106
|
+
try {
|
|
107
|
+
return getConfigValue(COORDINATION_URL_SUFFIX_CONFIG_KEY);
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
// A config read failure is not an extension. Fall back to the built-in set.
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* The suffixes in force: the built-in set, plus valid operator entries.
|
|
116
|
+
*
|
|
117
|
+
* Exported for the refusal message and for tests. Order is stable, built-in
|
|
118
|
+
* first, so the message reads the same way twice.
|
|
119
|
+
*/
|
|
120
|
+
export function allowedCoordinationUrlSuffixes(read = defaultSuffixReader) {
|
|
121
|
+
const raw = read();
|
|
122
|
+
if (!raw)
|
|
123
|
+
return [...COORDINATION_URL_ALLOWED_SUFFIXES];
|
|
124
|
+
const extra = raw
|
|
125
|
+
.split(',')
|
|
126
|
+
// Lowercased because `new URL` lowercases the hostname it parses, so an entry
|
|
127
|
+
// configured as `.EXAMPLE.COM` could never match anything and would read as
|
|
128
|
+
// an allowlist that quietly does nothing.
|
|
129
|
+
.map((entry) => entry.trim().toLowerCase())
|
|
130
|
+
.filter((entry) => COORDINATION_URL_SUFFIX_RE.test(entry));
|
|
131
|
+
return [...new Set([...COORDINATION_URL_ALLOWED_SUFFIXES, ...extra])];
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* The checks every committed-config URL gets, whatever field it came from.
|
|
135
|
+
*
|
|
136
|
+
* WHY THIS IS SHARED RATHER THAN COPIED. A URL in mx-agent.config.json is CHECKED IN.
|
|
137
|
+
* `git ls-files mx-agent.config.json` lists it, so a credential written into one enters
|
|
138
|
+
* git history permanently and no code-level backstop removes it. That risk belongs to the
|
|
139
|
+
* FILE, not to any one key in it, which is why the check lives here and every URL field
|
|
140
|
+
* calls it. The alternative is a second copy that drifts: one field gets the next fix and
|
|
141
|
+
* the other silently does not (#290 Must Fix 1 is the precedent — `coordinationServiceUrl`
|
|
142
|
+
* learned this lesson, `gatewayUrl` was added without it, and this function is the repair).
|
|
143
|
+
*
|
|
144
|
+
* NO BRANCH PRINTS THE VALUE BACK. A rejected value may hold a password in its userinfo,
|
|
145
|
+
* and an error message reaches transcripts, logs and CI output. The field name and the rule
|
|
146
|
+
* are enough for the operator to find and fix it; the value would add nothing and would
|
|
147
|
+
* copy the credential into a second place.
|
|
148
|
+
*
|
|
149
|
+
* `http:` is accepted only for loopback hosts. A committed config that points fleet traffic
|
|
150
|
+
* at a plaintext host on the network is a config that leaks it, but a gateway under
|
|
151
|
+
* development genuinely runs on localhost, so the loopback exception is real rather than a
|
|
152
|
+
* courtesy.
|
|
153
|
+
*
|
|
154
|
+
* Returns the parsed URL alongside the trimmed string so a caller can add its own
|
|
155
|
+
* field-specific rules without parsing twice.
|
|
156
|
+
*/
|
|
157
|
+
function validateCommittedUrl(value, prefix, example) {
|
|
158
|
+
// Trimmed before parsing AND before storing, so the value a caller gets is the
|
|
159
|
+
// one this function examined. Surrounding spaces from a copied value are what
|
|
160
|
+
// reach here: the shared metacharacter check rejects control characters first,
|
|
161
|
+
// and this function also runs on the `new project` flag, which the shared check
|
|
162
|
+
// does not see until the assembled config is validated.
|
|
163
|
+
const trimmed = value.trim();
|
|
164
|
+
let parsed;
|
|
165
|
+
try {
|
|
166
|
+
parsed = new URL(trimmed);
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
throw new Error(`${prefix} is not a URL. Expected an absolute https URL, e.g. ${example}`);
|
|
170
|
+
}
|
|
171
|
+
if (parsed.username || parsed.password) {
|
|
172
|
+
throw new Error(`${prefix} must not embed credentials (user:password@host).`);
|
|
173
|
+
}
|
|
174
|
+
if (parsed.search) {
|
|
175
|
+
throw new Error(`${prefix} must not contain a query string.`);
|
|
176
|
+
}
|
|
177
|
+
if (parsed.hash) {
|
|
178
|
+
throw new Error(`${prefix} must not contain a fragment.`);
|
|
179
|
+
}
|
|
180
|
+
if (parsed.protocol !== 'https:' && !(parsed.protocol === 'http:' && PLAINTEXT_URL_HOSTS.has(parsed.hostname))) {
|
|
181
|
+
throw new Error(`${prefix} must use https. Plain http is accepted only for host localhost, 127.0.0.1 or [::1].`);
|
|
182
|
+
}
|
|
183
|
+
// `canonical` is what callers that EMIT the value must use. `trimmed` is the operator's
|
|
184
|
+
// original text, kept for messages. See validateGatewayUrl below for why emitting the
|
|
185
|
+
// original is a defect rather than a courtesy.
|
|
186
|
+
return { parsed, trimmed, canonical: parsed.href };
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Check `gatewayUrl` and return the trimmed value the check ran against.
|
|
190
|
+
*
|
|
191
|
+
* WHY A COMMITTED GATEWAY URL IS A CREDENTIAL SURFACE. The value is written verbatim into
|
|
192
|
+
* `base_url` in every session's generated `.codex/config.toml`, and it is read from a
|
|
193
|
+
* git-tracked file. `https://user:token@host/v1` would satisfy the generic metacharacter
|
|
194
|
+
* sweep in `validateProjectConfig` below, which rejects neither `:` nor `@`, and would then
|
|
195
|
+
* exist in git history and in every generated config on disk. The gateway block emits no
|
|
196
|
+
* `env_key` precisely so that no credential travels with it; a credential smuggled through
|
|
197
|
+
* the URL's userinfo would defeat that, so it is refused here.
|
|
198
|
+
*
|
|
199
|
+
* NO SUFFIX ALLOWLIST, DELIBERATELY, and this is the one rule `coordinationServiceUrl` gets
|
|
200
|
+
* that this field does not. That allowlist exists because the coordination URL is seeded
|
|
201
|
+
* into the operator's GLOBAL config and then receives a MemNexus user key with no expiry
|
|
202
|
+
* (#290 Must Fix 1). `gatewayUrl` is seeded nowhere and receives no credential. Closing the
|
|
203
|
+
* host set here would refuse every gateway host an operator has not registered as a
|
|
204
|
+
* coordination host, which is a restriction with no matching risk.
|
|
205
|
+
*
|
|
206
|
+
* The rejected query string and fragment are also a functional requirement, not only a
|
|
207
|
+
* hygiene rule: codex-cli appends `/responses` to `base_url` (probed 0.145.0), so
|
|
208
|
+
* `https://h/v1?x=1` would produce the path `/v1?x=1/responses`.
|
|
209
|
+
*/
|
|
210
|
+
export function validateGatewayUrl(value, fieldLabel = 'mx-agent.config.json: "gatewayUrl"') {
|
|
211
|
+
// RETURNS THE CANONICAL FORM, NOT THE OPERATOR'S TEXT. Every check above reads
|
|
212
|
+
// `parsed.hostname`, which the URL parser has already normalised, while the value that
|
|
213
|
+
// reaches `base_url` used to be the raw string. Those are two different strings, and
|
|
214
|
+
// validating one while emitting the other is the host-confusion pattern: measured,
|
|
215
|
+
// `http://0x7f000001/v1` and `http://127.1/v1` both present `hostname` as `127.0.0.1`
|
|
216
|
+
// to the check and would have been written to the config verbatim. Emitting
|
|
217
|
+
// `parsed.href` makes the host in the file the host that was approved.
|
|
218
|
+
return validateCommittedUrl(value, fieldLabel, 'https://gw.example.com/v1').canonical;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Hosts a PILOT relay URL may name. Loopback only.
|
|
222
|
+
*
|
|
223
|
+
* Deliberately its own constant rather than a reuse of PLAINTEXT_URL_HOSTS above. That set
|
|
224
|
+
* answers a different question, which schemes may be plaintext, and widening it for some
|
|
225
|
+
* future plaintext host must not silently widen where a selector may point.
|
|
226
|
+
*/
|
|
227
|
+
const CODEX_PILOT_ALLOWED_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]']);
|
|
228
|
+
/**
|
|
229
|
+
* Check `codexGatewayPilot` and return it normalised.
|
|
230
|
+
*
|
|
231
|
+
* FAILS LOUDLY, BY DESIGN. Every rejection below throws rather than disabling the pilot
|
|
232
|
+
* and continuing. A silent downgrade would leave an operator believing traffic is being
|
|
233
|
+
* relayed and measured when it is going direct to the provider, and the pilot's whole
|
|
234
|
+
* purpose is a reconciliation measurement; a wrong belief about which path served the
|
|
235
|
+
* traffic makes that measurement meaningless.
|
|
236
|
+
*
|
|
237
|
+
* The url is checked whenever it is non-empty, enabled or not, so a host that would be
|
|
238
|
+
* refused cannot sit dormant in a committed file and take effect later when someone flips
|
|
239
|
+
* `enabled` without re-reading this rule.
|
|
240
|
+
*/
|
|
241
|
+
export function validateCodexGatewayPilot(value, fieldLabel = 'mx-agent.config.json: "codexGatewayPilot"') {
|
|
242
|
+
if (value === undefined || value === null)
|
|
243
|
+
return { enabled: false, url: '' };
|
|
244
|
+
if (typeof value !== 'object' || Array.isArray(value)) {
|
|
245
|
+
throw new Error(`${fieldLabel} must be an object with "enabled" and "url".`);
|
|
246
|
+
}
|
|
247
|
+
const raw = value;
|
|
248
|
+
const enabled = raw.enabled ?? false;
|
|
249
|
+
const url = raw.url ?? '';
|
|
250
|
+
if (typeof enabled !== 'boolean') {
|
|
251
|
+
throw new Error(`${fieldLabel}.enabled must be true or false.`);
|
|
252
|
+
}
|
|
253
|
+
if (typeof url !== 'string') {
|
|
254
|
+
throw new Error(`${fieldLabel}.url must be a string.`);
|
|
255
|
+
}
|
|
256
|
+
const trimmedUrl = url.trim();
|
|
257
|
+
if (enabled && trimmedUrl === '') {
|
|
258
|
+
throw new Error(`${fieldLabel}.enabled is true but .url is empty. ` +
|
|
259
|
+
'Set the relay URL, e.g. http://127.0.0.1:8080/v1, or set enabled to false.');
|
|
260
|
+
}
|
|
261
|
+
if (trimmedUrl === '')
|
|
262
|
+
return { enabled, url: '' };
|
|
263
|
+
// Same committed-URL rules gatewayUrl gets: no credentials, no query, no fragment.
|
|
264
|
+
const { parsed, canonical } = validateCommittedUrl(trimmedUrl, `${fieldLabel}.url`, 'http://127.0.0.1:8080/v1');
|
|
265
|
+
if (!CODEX_PILOT_ALLOWED_HOSTS.has(parsed.hostname)) {
|
|
266
|
+
throw new Error(`${fieldLabel}.url must name a loopback host. ` +
|
|
267
|
+
`Allowed: ${[...CODEX_PILOT_ALLOWED_HOSTS].join(', ')}. ` +
|
|
268
|
+
'The pilot authorized on 2026-09-02 runs one worktree against a local relay; ' +
|
|
269
|
+
'a non-loopback host is outside it. The selector is not written and no config ' +
|
|
270
|
+
'is generated.');
|
|
271
|
+
}
|
|
272
|
+
// Canonical, for the reason given on validateGatewayUrl: the loopback check below reads
|
|
273
|
+
// parsed.hostname, so the emitted base_url must be the string that check examined.
|
|
274
|
+
return { enabled, url: canonical };
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Check `coordinationServiceUrl` and return the trimmed value the check ran
|
|
278
|
+
* against. Throws with the field named when the value is not a URL, embeds
|
|
279
|
+
* credentials, carries a query string or a fragment, uses a scheme other than
|
|
280
|
+
* https (http is accepted only for the loopback hosts above), or names an https
|
|
281
|
+
* host outside the allowed suffixes.
|
|
282
|
+
*
|
|
283
|
+
* Exported because the read path and the write path must agree: `loadProjectConfig`
|
|
284
|
+
* runs it on a config it reads, and `new project` runs it on the
|
|
285
|
+
* `--coordination-service-url` value before that value reaches a banner line or a
|
|
286
|
+
* scaffolded file. Since #290 Must Fix 1 the CREDENTIAL path runs it too, on
|
|
287
|
+
* whichever source supplied the URL, before the operator's MemNexus user key is
|
|
288
|
+
* read: that URL used to receive a revocable team token and now receives a key
|
|
289
|
+
* with no expiry that is valid for every grant its holder has.
|
|
290
|
+
*
|
|
291
|
+
* `fieldLabel` names the source in the refusal, because "mx-agent.config.json"
|
|
292
|
+
* is the wrong remedy for a value that came from an environment variable. It
|
|
293
|
+
* defaults to the committed-config label, so every caller written before this
|
|
294
|
+
* parameter existed produces the same message it did.
|
|
295
|
+
*
|
|
296
|
+
* No branch prints the value back. A rejected value may hold a password in its
|
|
297
|
+
* userinfo, and an error message reaches transcripts and logs.
|
|
298
|
+
*/
|
|
299
|
+
export function validateCoordinationServiceUrl(value, readSuffixes = defaultSuffixReader, fieldLabel = 'mx-agent.config.json: "coordinationServiceUrl"') {
|
|
300
|
+
const prefix = fieldLabel;
|
|
301
|
+
// Parse, userinfo, query, fragment and scheme are the checks every committed URL gets;
|
|
302
|
+
// the host allowlist below is the one rule that is specific to this field. Every refusal
|
|
303
|
+
// message is byte-identical to the one this function raised before the shared helper
|
|
304
|
+
// existed, and the existing tests pin them.
|
|
305
|
+
const { parsed, trimmed } = validateCommittedUrl(value, prefix, 'https://coord.memnexus.ai');
|
|
306
|
+
if (parsed.protocol === 'https:') {
|
|
307
|
+
const allowed = allowedCoordinationUrlSuffixes(readSuffixes);
|
|
308
|
+
if (allowed.some((suffix) => parsed.hostname.endsWith(suffix))) {
|
|
309
|
+
return trimmed;
|
|
310
|
+
}
|
|
311
|
+
throw new Error(`${prefix} names a host outside the allowed set. A committed config may only ` +
|
|
312
|
+
`point at a host ending in: ${allowed.join(', ')}. ` +
|
|
313
|
+
`Add one with: mx-agent config set ${COORDINATION_URL_SUFFIX_CONFIG_KEY} .example.com`);
|
|
314
|
+
}
|
|
315
|
+
return trimmed;
|
|
316
|
+
}
|
|
38
317
|
/**
|
|
39
318
|
* Validate that config field values are safe for use in shell commands and path joins.
|
|
40
319
|
* Throws a descriptive error if any field contains disallowed characters.
|
|
41
|
-
*
|
|
320
|
+
*
|
|
321
|
+
* Called by loadProjectConfig on the read path, and exported so `new project` runs
|
|
322
|
+
* the same check on the config it assembles before writing it. A scaffolded file
|
|
323
|
+
* that this function would refuse on the next read is a project broken at birth.
|
|
42
324
|
*/
|
|
43
|
-
function validateProjectConfig(config) {
|
|
325
|
+
export function validateProjectConfig(config) {
|
|
44
326
|
for (const [key, value] of Object.entries(config)) {
|
|
45
327
|
if (typeof value !== 'string')
|
|
46
328
|
continue;
|
|
47
329
|
if (SHELL_UNSAFE_RE.test(value)) {
|
|
48
330
|
throw new Error(`mx-agent.config.json: "${key}" contains disallowed characters. ` +
|
|
49
331
|
`Shell metacharacters and control characters are rejected: ; | & \` $ ( ) { } ! # \\ < > ` +
|
|
50
|
-
`and
|
|
332
|
+
`and every control character (C0 range and DEL), which includes newline, NUL and ESC.`);
|
|
51
333
|
}
|
|
52
334
|
// sessionModel additionally gets a positive, anchored allowlist (#4487).
|
|
53
335
|
if (key === 'sessionModel' && value !== '' && !SESSION_MODEL_RE.test(value)) {
|
|
@@ -55,10 +337,28 @@ function validateProjectConfig(config) {
|
|
|
55
337
|
'letters, digits, dots, hyphens, underscores, optional [1m]-style suffix. ' +
|
|
56
338
|
'It must not begin with "-".');
|
|
57
339
|
}
|
|
340
|
+
// The only field with a scheme check: it is seeded into the operator's global
|
|
341
|
+
// config, so a bad value there is a write outside the project (#32).
|
|
342
|
+
if (key === 'coordinationServiceUrl' && value !== '') {
|
|
343
|
+
// Stores the trimmed value the check ran against, so no caller sees a
|
|
344
|
+
// string the validator never examined.
|
|
345
|
+
config.coordinationServiceUrl = validateCoordinationServiceUrl(value);
|
|
346
|
+
}
|
|
347
|
+
// Same treatment, same reason: the value is committed, and `:` and `@` are not in the
|
|
348
|
+
// metacharacter class above, so `https://user:token@host` would otherwise load clean
|
|
349
|
+
// and reach every generated .codex/config.toml.
|
|
350
|
+
if (key === 'gatewayUrl' && value !== '') {
|
|
351
|
+
config.gatewayUrl = validateGatewayUrl(value);
|
|
352
|
+
}
|
|
58
353
|
if (value.includes('..')) {
|
|
59
354
|
throw new Error(`mx-agent.config.json: "${key}" must not contain ".." (path traversal not allowed).`);
|
|
60
355
|
}
|
|
61
356
|
}
|
|
357
|
+
// Outside the loop above: that loop skips non-strings, and this field is an object.
|
|
358
|
+
// Normalised in place so every later reader sees the checked value, never the raw one.
|
|
359
|
+
if (config.codexGatewayPilot !== undefined) {
|
|
360
|
+
config.codexGatewayPilot = validateCodexGatewayPilot(config.codexGatewayPilot);
|
|
361
|
+
}
|
|
62
362
|
return config;
|
|
63
363
|
}
|
|
64
364
|
/**
|
|
@@ -92,8 +392,21 @@ export function loadProjectConfig(projectRoot) {
|
|
|
92
392
|
config.projectSlug = parsed.projectSlug;
|
|
93
393
|
if (typeof parsed.observabilityApiUrl === 'string')
|
|
94
394
|
config.observabilityApiUrl = parsed.observabilityApiUrl;
|
|
395
|
+
if (typeof parsed.gatewayUrl === 'string')
|
|
396
|
+
config.gatewayUrl = parsed.gatewayUrl;
|
|
397
|
+
// Shape-checked in validateProjectConfig (below, and OUTSIDE this try) for the same
|
|
398
|
+
// reason as sessionModel and coordinationServiceUrl: a refusal has to reach the
|
|
399
|
+
// operator rather than be swallowed by the parse-error catch and silently defaulted
|
|
400
|
+
// to a disabled pilot.
|
|
401
|
+
if (parsed.codexGatewayPilot !== undefined) {
|
|
402
|
+
config.codexGatewayPilot = parsed.codexGatewayPilot;
|
|
403
|
+
}
|
|
95
404
|
if (typeof parsed.coordinationMode === 'string')
|
|
96
405
|
config.coordinationMode = parsed.coordinationMode;
|
|
406
|
+
// Scheme-checked in validateProjectConfig (below, and OUTSIDE this try) for the
|
|
407
|
+
// same reason as sessionModel: a rejected value must reach the operator.
|
|
408
|
+
if (typeof parsed.coordinationServiceUrl === 'string')
|
|
409
|
+
config.coordinationServiceUrl = parsed.coordinationServiceUrl;
|
|
97
410
|
// sessionModel is allowlist-checked in validateProjectConfig (below, and
|
|
98
411
|
// OUTSIDE this try) so a rejected value surfaces to the operator instead of
|
|
99
412
|
// being swallowed by the parse-error catch and silently defaulted.
|
|
@@ -123,8 +436,11 @@ export function resolveProjectConfig(c) {
|
|
|
123
436
|
roleguidesDir: c?.roleguidesDir ?? PROJECT_CONFIG_DEFAULTS.roleguidesDir,
|
|
124
437
|
projectSlug: c?.projectSlug ?? PROJECT_CONFIG_DEFAULTS.projectSlug,
|
|
125
438
|
observabilityApiUrl: c?.observabilityApiUrl ?? PROJECT_CONFIG_DEFAULTS.observabilityApiUrl,
|
|
439
|
+
gatewayUrl: c?.gatewayUrl ?? PROJECT_CONFIG_DEFAULTS.gatewayUrl,
|
|
440
|
+
codexGatewayPilot: c?.codexGatewayPilot ?? PROJECT_CONFIG_DEFAULTS.codexGatewayPilot,
|
|
126
441
|
coordinationMode: c?.coordinationMode ?? PROJECT_CONFIG_DEFAULTS.coordinationMode,
|
|
127
442
|
sessionModel: c?.sessionModel || PROJECT_CONFIG_DEFAULTS.sessionModel,
|
|
443
|
+
coordinationServiceUrl: c?.coordinationServiceUrl ?? PROJECT_CONFIG_DEFAULTS.coordinationServiceUrl,
|
|
128
444
|
};
|
|
129
445
|
}
|
|
130
446
|
//# sourceMappingURL=project-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-config.js","sourceRoot":"","sources":["../../src/lib/project-config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"project-config.js","sourceRoot":"","sources":["../../src/lib/project-config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EA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AAE,UAAU,IAAI,uBAAuB,CAAC,UAAU;QAC/D,iBAAiB,EAAE,CAAC,EAAE,iBAAiB,IAAI,uBAAuB,CAAC,iBAAiB;QACpF,gBAAgB,EAAE,CAAC,EAAE,gBAAgB,IAAI,uBAAuB,CAAC,gBAAgB;QACjF,YAAY,EAAE,CAAC,EAAE,YAAY,IAAI,uBAAuB,CAAC,YAAY;QACrE,sBAAsB,EAAE,CAAC,EAAE,sBAAsB,IAAI,uBAAuB,CAAC,sBAAsB;KACpG,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* projects-registry.ts — the list of projects that exist on this machine.
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS EXISTS. The desktop client shows every project the operator works
|
|
5
|
+
* in, grouped, because `product/mx-agent-prd.md:336` makes the operator the
|
|
6
|
+
* scope rather than the project. A window has no working directory to infer one
|
|
7
|
+
* from, so something has to tell it which projects exist. Nothing else can:
|
|
8
|
+
* `mx-agent start` and `mx-agent new project` are the two moments a project is
|
|
9
|
+
* known to be real, and until one of them records it the client can only offer
|
|
10
|
+
* to have a folder pointed out by hand.
|
|
11
|
+
*
|
|
12
|
+
* WHAT IT WRITES. `~/.mx-agent/projects.json`, beside the `config.json`,
|
|
13
|
+
* `hooks/` and `logs/` this tool already keeps there. A JSON array:
|
|
14
|
+
*
|
|
15
|
+
* [ { "slug": "mx-agent", "root": "/home/me/src/mx-agent-framework",
|
|
16
|
+
* "lastSeen": "2026-08-26T09:00:00.000Z" } ]
|
|
17
|
+
*
|
|
18
|
+
* An array rather than an object, because that is the shape the client reads
|
|
19
|
+
* and one of the two had to be chosen first.
|
|
20
|
+
*
|
|
21
|
+
* IT NEVER FAILS A COMMAND. Recording a project is a side effect of starting a
|
|
22
|
+
* team, not the point of it. Every error is caught and reported on stderr: a
|
|
23
|
+
* read-only home directory or a full disk must not stop a session launching.
|
|
24
|
+
*
|
|
25
|
+
* IT NEVER DESTROYS A FILE IT CANNOT READ. A registry that does not parse is
|
|
26
|
+
* left exactly where it is and the new one is written beside it, because the
|
|
27
|
+
* unreadable file may be the only record of where somebody's projects are, and
|
|
28
|
+
* because a writer that silently replaces what it cannot understand is how a
|
|
29
|
+
* list of twelve projects becomes a list of one.
|
|
30
|
+
*/
|
|
31
|
+
/** One project, as the file records it. */
|
|
32
|
+
export interface RegisteredProject {
|
|
33
|
+
slug: string;
|
|
34
|
+
root: string;
|
|
35
|
+
lastSeen: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Where the list lives. Pure: it creates nothing.
|
|
39
|
+
*
|
|
40
|
+
* `MX_AGENT_HOME` overrides the home directory this file is kept under. It
|
|
41
|
+
* exists because this module writes to a real operator's home as a side effect
|
|
42
|
+
* of two ordinary commands, and a test that runs either of them would otherwise
|
|
43
|
+
* append its temporary scaffold directories to that operator's project list.
|
|
44
|
+
* That is not hypothetical: writing this without the override put ten `/tmp`
|
|
45
|
+
* scaffolds and one `/fake/project` into this machine's own
|
|
46
|
+
* `~/.mx-agent/projects.json` on the first full run of the CLI suite.
|
|
47
|
+
* `vitest.config.ts` sets it for every test.
|
|
48
|
+
*/
|
|
49
|
+
export declare function getProjectsRegistryPath(home?: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Records that `root` is a project called `slug`, and when it was last seen.
|
|
52
|
+
*
|
|
53
|
+
* MATCHED BY SLUG, NOT BY ROOT. A project that moves keeps its identity: the
|
|
54
|
+
* entry's root is updated in place rather than a second entry appearing for the
|
|
55
|
+
* same project under a new path. Matching by root instead would leave the old
|
|
56
|
+
* location listed forever, and the client would show a project that is not
|
|
57
|
+
* there beside the same project that is.
|
|
58
|
+
*
|
|
59
|
+
* Returns what happened, so a caller can say so and a test can assert it
|
|
60
|
+
* without reading the file back.
|
|
61
|
+
*/
|
|
62
|
+
export declare function recordProject(project: {
|
|
63
|
+
slug: string;
|
|
64
|
+
root: string;
|
|
65
|
+
}, options?: {
|
|
66
|
+
path?: string;
|
|
67
|
+
now?: Date;
|
|
68
|
+
}): {
|
|
69
|
+
written: boolean;
|
|
70
|
+
preservedAs: string | null;
|
|
71
|
+
reason: string | null;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* `recordProject` for the two commands that call it: never throws, never fails
|
|
75
|
+
* the command it is a side effect of, and says on stderr when it could not do
|
|
76
|
+
* its job or had to set a broken file aside.
|
|
77
|
+
*/
|
|
78
|
+
export declare function recordProjectQuietly(project: {
|
|
79
|
+
slug: string;
|
|
80
|
+
root: string;
|
|
81
|
+
}): void;
|
|
82
|
+
//# sourceMappingURL=projects-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projects-registry.d.ts","sourceRoot":"","sources":["../../src/lib/projects-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAOH,2CAA2C;AAC3C,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAG7D;AA0BD;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EACvC,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,IAAI,CAAA;CAAO,GAC1C;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAsCzE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAqBlF"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* projects-registry.ts — the list of projects that exist on this machine.
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS EXISTS. The desktop client shows every project the operator works
|
|
5
|
+
* in, grouped, because `product/mx-agent-prd.md:336` makes the operator the
|
|
6
|
+
* scope rather than the project. A window has no working directory to infer one
|
|
7
|
+
* from, so something has to tell it which projects exist. Nothing else can:
|
|
8
|
+
* `mx-agent start` and `mx-agent new project` are the two moments a project is
|
|
9
|
+
* known to be real, and until one of them records it the client can only offer
|
|
10
|
+
* to have a folder pointed out by hand.
|
|
11
|
+
*
|
|
12
|
+
* WHAT IT WRITES. `~/.mx-agent/projects.json`, beside the `config.json`,
|
|
13
|
+
* `hooks/` and `logs/` this tool already keeps there. A JSON array:
|
|
14
|
+
*
|
|
15
|
+
* [ { "slug": "mx-agent", "root": "/home/me/src/mx-agent-framework",
|
|
16
|
+
* "lastSeen": "2026-08-26T09:00:00.000Z" } ]
|
|
17
|
+
*
|
|
18
|
+
* An array rather than an object, because that is the shape the client reads
|
|
19
|
+
* and one of the two had to be chosen first.
|
|
20
|
+
*
|
|
21
|
+
* IT NEVER FAILS A COMMAND. Recording a project is a side effect of starting a
|
|
22
|
+
* team, not the point of it. Every error is caught and reported on stderr: a
|
|
23
|
+
* read-only home directory or a full disk must not stop a session launching.
|
|
24
|
+
*
|
|
25
|
+
* IT NEVER DESTROYS A FILE IT CANNOT READ. A registry that does not parse is
|
|
26
|
+
* left exactly where it is and the new one is written beside it, because the
|
|
27
|
+
* unreadable file may be the only record of where somebody's projects are, and
|
|
28
|
+
* because a writer that silently replaces what it cannot understand is how a
|
|
29
|
+
* list of twelve projects becomes a list of one.
|
|
30
|
+
*/
|
|
31
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'fs';
|
|
32
|
+
import { join } from 'path';
|
|
33
|
+
import { homedir } from 'os';
|
|
34
|
+
import { basename } from 'path';
|
|
35
|
+
/**
|
|
36
|
+
* Where the list lives. Pure: it creates nothing.
|
|
37
|
+
*
|
|
38
|
+
* `MX_AGENT_HOME` overrides the home directory this file is kept under. It
|
|
39
|
+
* exists because this module writes to a real operator's home as a side effect
|
|
40
|
+
* of two ordinary commands, and a test that runs either of them would otherwise
|
|
41
|
+
* append its temporary scaffold directories to that operator's project list.
|
|
42
|
+
* That is not hypothetical: writing this without the override put ten `/tmp`
|
|
43
|
+
* scaffolds and one `/fake/project` into this machine's own
|
|
44
|
+
* `~/.mx-agent/projects.json` on the first full run of the CLI suite.
|
|
45
|
+
* `vitest.config.ts` sets it for every test.
|
|
46
|
+
*/
|
|
47
|
+
export function getProjectsRegistryPath(home) {
|
|
48
|
+
const base = home ?? process.env.MX_AGENT_HOME ?? homedir();
|
|
49
|
+
return join(base, '.mx-agent', 'projects.json');
|
|
50
|
+
}
|
|
51
|
+
/** The entries in `path`, or null when the file cannot be used. */
|
|
52
|
+
function readEntries(path) {
|
|
53
|
+
if (!existsSync(path))
|
|
54
|
+
return [];
|
|
55
|
+
try {
|
|
56
|
+
const parsed = JSON.parse(readFileSync(path, 'utf-8'));
|
|
57
|
+
if (!Array.isArray(parsed))
|
|
58
|
+
return null;
|
|
59
|
+
return parsed
|
|
60
|
+
.map((item) => item)
|
|
61
|
+
.filter((item) => typeof item?.root === 'string' && item.root !== '')
|
|
62
|
+
// Same key order as a new entry, so the file reads uniformly however many
|
|
63
|
+
// times it has been rewritten.
|
|
64
|
+
.map((item) => ({
|
|
65
|
+
slug: typeof item.slug === 'string' && item.slug !== ''
|
|
66
|
+
? item.slug
|
|
67
|
+
: basename(String(item.root)),
|
|
68
|
+
root: String(item.root),
|
|
69
|
+
lastSeen: typeof item.lastSeen === 'string' ? item.lastSeen : '',
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Records that `root` is a project called `slug`, and when it was last seen.
|
|
78
|
+
*
|
|
79
|
+
* MATCHED BY SLUG, NOT BY ROOT. A project that moves keeps its identity: the
|
|
80
|
+
* entry's root is updated in place rather than a second entry appearing for the
|
|
81
|
+
* same project under a new path. Matching by root instead would leave the old
|
|
82
|
+
* location listed forever, and the client would show a project that is not
|
|
83
|
+
* there beside the same project that is.
|
|
84
|
+
*
|
|
85
|
+
* Returns what happened, so a caller can say so and a test can assert it
|
|
86
|
+
* without reading the file back.
|
|
87
|
+
*/
|
|
88
|
+
export function recordProject(project, options = {}) {
|
|
89
|
+
const path = options.path ?? getProjectsRegistryPath();
|
|
90
|
+
const slug = project.slug.trim() !== '' ? project.slug.trim() : basename(project.root);
|
|
91
|
+
const entry = {
|
|
92
|
+
slug,
|
|
93
|
+
root: project.root,
|
|
94
|
+
lastSeen: (options.now ?? new Date()).toISOString(),
|
|
95
|
+
};
|
|
96
|
+
let preservedAs = null;
|
|
97
|
+
let existing = readEntries(path);
|
|
98
|
+
if (existing === null) {
|
|
99
|
+
// Unreadable. Keep it, under a name that says what it was, and start a new
|
|
100
|
+
// list rather than writing over the only copy.
|
|
101
|
+
preservedAs = `${path}.unreadable`;
|
|
102
|
+
try {
|
|
103
|
+
renameSync(path, preservedAs);
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
107
|
+
return { written: false, preservedAs: null, reason: `could not set aside ${path}: ${message}` };
|
|
108
|
+
}
|
|
109
|
+
existing = [];
|
|
110
|
+
}
|
|
111
|
+
const next = existing.filter((one) => one.slug !== slug);
|
|
112
|
+
next.push(entry);
|
|
113
|
+
next.sort((a, b) => a.slug.localeCompare(b.slug));
|
|
114
|
+
try {
|
|
115
|
+
mkdirSync(join(path, '..'), { recursive: true });
|
|
116
|
+
writeFileSync(path, `${JSON.stringify(next, null, 2)}\n`);
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
120
|
+
return { written: false, preservedAs, reason: `could not write ${path}: ${message}` };
|
|
121
|
+
}
|
|
122
|
+
return { written: true, preservedAs, reason: null };
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* `recordProject` for the two commands that call it: never throws, never fails
|
|
126
|
+
* the command it is a side effect of, and says on stderr when it could not do
|
|
127
|
+
* its job or had to set a broken file aside.
|
|
128
|
+
*/
|
|
129
|
+
export function recordProjectQuietly(project) {
|
|
130
|
+
let result;
|
|
131
|
+
try {
|
|
132
|
+
result = recordProject(project);
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
console.error(` note: could not record this project for the desktop client: ${err instanceof Error ? err.message : String(err)}`);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (result.preservedAs !== null) {
|
|
139
|
+
console.error(` note: ${getProjectsRegistryPath()} could not be read, so it was kept as ${result.preservedAs} and a new list started.`);
|
|
140
|
+
}
|
|
141
|
+
if (!result.written && result.reason !== null) {
|
|
142
|
+
console.error(` note: could not record this project for the desktop client: ${result.reason}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=projects-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projects-registry.js","sourceRoot":"","sources":["../../src/lib/projects-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACpF,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAShC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAa;IACn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