@memnexus-ai/mx-agent-cli 0.1.296-next.0 → 0.1.296-next.2
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__/coordination-401-recovery.test.js +15 -1
- package/dist/__tests__/coordination-401-recovery.test.js.map +1 -1
- package/dist/__tests__/coordination-brief.test.js +18 -0
- package/dist/__tests__/coordination-brief.test.js.map +1 -1
- package/dist/__tests__/coordination-fallback.test.js +11 -0
- package/dist/__tests__/coordination-fallback.test.js.map +1 -1
- package/dist/__tests__/coordination-file-guards.test.d.ts +29 -0
- package/dist/__tests__/coordination-file-guards.test.d.ts.map +1 -0
- package/dist/__tests__/coordination-file-guards.test.js +380 -0
- package/dist/__tests__/coordination-file-guards.test.js.map +1 -0
- package/dist/__tests__/coordination-memory.test.js +5 -0
- package/dist/__tests__/coordination-memory.test.js.map +1 -1
- package/dist/__tests__/coordination-plain-shell-commands.test.d.ts +22 -0
- package/dist/__tests__/coordination-plain-shell-commands.test.d.ts.map +1 -0
- package/dist/__tests__/coordination-plain-shell-commands.test.js +1407 -0
- package/dist/__tests__/coordination-plain-shell-commands.test.js.map +1 -0
- package/dist/__tests__/coordination-status-plain-shell.test.d.ts +19 -0
- package/dist/__tests__/coordination-status-plain-shell.test.d.ts.map +1 -0
- package/dist/__tests__/coordination-status-plain-shell.test.js +332 -0
- package/dist/__tests__/coordination-status-plain-shell.test.js.map +1 -0
- package/dist/__tests__/coordination-token.test.js +6 -2
- package/dist/__tests__/coordination-token.test.js.map +1 -1
- package/dist/__tests__/tracked-instruction-files.test.d.ts +21 -0
- package/dist/__tests__/tracked-instruction-files.test.d.ts.map +1 -0
- package/dist/__tests__/tracked-instruction-files.test.js +489 -0
- package/dist/__tests__/tracked-instruction-files.test.js.map +1 -0
- package/dist/commands/coordination.d.ts +22 -0
- package/dist/commands/coordination.d.ts.map +1 -1
- package/dist/commands/coordination.js +168 -31
- package/dist/commands/coordination.js.map +1 -1
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +3 -1
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/start.d.ts +28 -0
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +68 -4
- package/dist/commands/start.js.map +1 -1
- package/dist/lib/claude.d.ts +25 -1
- package/dist/lib/claude.d.ts.map +1 -1
- package/dist/lib/claude.js +113 -25
- package/dist/lib/claude.js.map +1 -1
- package/dist/lib/coordination-fallback.d.ts +35 -0
- package/dist/lib/coordination-fallback.d.ts.map +1 -1
- package/dist/lib/coordination-fallback.js +76 -8
- package/dist/lib/coordination-fallback.js.map +1 -1
- package/dist/lib/coordination-memory.d.ts +4 -0
- package/dist/lib/coordination-memory.d.ts.map +1 -1
- package/dist/lib/coordination-memory.js +14 -16
- package/dist/lib/coordination-memory.js.map +1 -1
- package/dist/lib/coordination-token.d.ts +8 -1
- package/dist/lib/coordination-token.d.ts.map +1 -1
- package/dist/lib/coordination-token.js +61 -15
- package/dist/lib/coordination-token.js.map +1 -1
- package/dist/lib/coordination-worktree.d.ts +286 -0
- package/dist/lib/coordination-worktree.d.ts.map +1 -0
- package/dist/lib/coordination-worktree.js +657 -0
- package/dist/lib/coordination-worktree.js.map +1 -0
- package/dist/lib/instruction-files.d.ts +30 -0
- package/dist/lib/instruction-files.d.ts.map +1 -0
- package/dist/lib/instruction-files.js +45 -0
- package/dist/lib/instruction-files.js.map +1 -0
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { ServiceHttpError, type CoordinationClient } from '../lib/coordination-client.js';
|
|
13
13
|
import { type TokenResolveResult, type TokenRefreshResult } from '../lib/coordination-token.js';
|
|
14
|
+
import { type LocateWorktreeOptions } from '../lib/coordination-worktree.js';
|
|
14
15
|
import { type MemoryStore } from '../lib/coordination-memory.js';
|
|
15
16
|
/**
|
|
16
17
|
* Truncate each body to this many chars where a full message is rendered LIVE
|
|
@@ -491,7 +492,26 @@ export interface RegistrationDeps {
|
|
|
491
492
|
* Defaults to true, which is the marker case and every direct caller in tests.
|
|
492
493
|
*/
|
|
493
494
|
teamSlugAuthoritative?: boolean;
|
|
495
|
+
/**
|
|
496
|
+
* The team worktree `status` located (#507 follow-up). Overrides
|
|
497
|
+
* CLAUDE_WORKTREE_PATH for the offline roster read, so a plain-shell run reads
|
|
498
|
+
* the same worktree its marker came from.
|
|
499
|
+
*/
|
|
500
|
+
worktreePath?: string;
|
|
501
|
+
/** Passed to the default token resolution (test seam; production: cwd). */
|
|
502
|
+
locate?: LocateWorktreeOptions;
|
|
503
|
+
/**
|
|
504
|
+
* False when `status` resolved NO team at all: no marker, an invalid marker,
|
|
505
|
+
* and no worktree name. Defaults to true. With no team there is no name to
|
|
506
|
+
* look up, so the offline roster is not consulted and the result says so,
|
|
507
|
+
* rather than reporting that a roster "does not list this team" (#525).
|
|
508
|
+
*/
|
|
509
|
+
teamResolved?: boolean;
|
|
510
|
+
/** Why no team was resolved, printed as the could-not-verify reason. */
|
|
511
|
+
noTeamReason?: string;
|
|
494
512
|
}
|
|
513
|
+
/** The provenance clause when no team was resolved and so nothing was looked up. */
|
|
514
|
+
export declare const NO_TEAM_SOURCE = "no roster consulted: no team was resolved";
|
|
495
515
|
/**
|
|
496
516
|
* Answer "is this team on the coordination queue?" and say who answered.
|
|
497
517
|
*
|
|
@@ -524,6 +544,8 @@ export interface StatusDeps {
|
|
|
524
544
|
fetch?: typeof globalThis.fetch;
|
|
525
545
|
/** Override the registration check (test seam). */
|
|
526
546
|
registration?: RegistrationDeps;
|
|
547
|
+
/** Where to look for the team worktree when CLAUDE_WORKTREE_PATH is unset (test seam). */
|
|
548
|
+
locate?: LocateWorktreeOptions;
|
|
527
549
|
}
|
|
528
550
|
/**
|
|
529
551
|
* `mx-agent coordination status` — display coordination state, service health,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordination.d.ts","sourceRoot":"","sources":["../../src/commands/coordination.ts"],"names":[],"mappings":"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wDAAwD;IACxD,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,2CAA2C;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAK1D;AAsDD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CA8RlF"}
|
|
@@ -12,11 +12,12 @@
|
|
|
12
12
|
import { existsSync, readFileSync, writeFileSync, readdirSync, statSync, realpathSync } from 'node:fs';
|
|
13
13
|
import { spawnSync } from 'node:child_process';
|
|
14
14
|
import { join } from 'node:path';
|
|
15
|
-
import { HttpCoordinationClient, resolveClientConfig, resolveCoordinationMode, ServiceUnreachableError, ServiceHttpError, CONFIG_KEY_URL, } from '../lib/coordination-client.js';
|
|
15
|
+
import { HttpCoordinationClient, resolveClientConfig, resolveCoordinationMode, ServiceUnreachableError, ServiceHttpError, CONFIG_KEY_URL, URL_SOURCE_LABEL, resolveCoordinationUrl, } from '../lib/coordination-client.js';
|
|
16
16
|
import { resolveCoordinationToken, refreshCoordinationToken, usesCredentialEndpoint, ENV_KEY_EXPECT_PROJECT, ENV_KEY_EXPECT_TEAM, } from '../lib/coordination-token.js';
|
|
17
|
-
import {
|
|
17
|
+
import { locateCoordinationWorktree, noMarkerLines, readMarkerLine, readTeamMarker, } from '../lib/coordination-worktree.js';
|
|
18
|
+
import { isValidProjectSlug, invalidProjectSlugMessage, PROJECT_SLUG_RE_SOURCE } from '../lib/slug.js';
|
|
18
19
|
import { appendFallbackEntry, flushFallback } from '../lib/coordination-fallback.js';
|
|
19
|
-
import { renderMessages, renderRoutingDescription, renderPipelineExtractionWarning, findOverBudgetDropped, } from '../lib/coordination-render.js';
|
|
20
|
+
import { sanitizeField, renderMessages, renderRoutingDescription, renderPipelineExtractionWarning, findOverBudgetDropped, } from '../lib/coordination-render.js';
|
|
20
21
|
import { escalateToOutbox, UnreadableOutboxError, readEscalationsForTeam, renderEscalationBlocks, resolveMemoryTeam, resolveProductSlug, } from '../lib/coordination-memory.js';
|
|
21
22
|
import { loadProjectConfig } from '../lib/project-config.js';
|
|
22
23
|
import { findProjectRoot } from '../lib/worktree.js';
|
|
@@ -82,16 +83,19 @@ const WATCH_BACKOFF_CAP_MS = 5 * 60 * 1000;
|
|
|
82
83
|
* (.mx-coordination-team). Returns undefined when there is no marker / it is
|
|
83
84
|
* unreadable. This is the same slug the coordination token is provisioned under,
|
|
84
85
|
* so using it for `from` matches the token the service now verifies against.
|
|
86
|
+
*
|
|
87
|
+
* The worktree is found by `locateCoordinationWorktree`, the rule the token path
|
|
88
|
+
* uses: CLAUDE_WORKTREE_PATH when set and nothing else, otherwise the git
|
|
89
|
+
* worktree of the current directory. Before the #507 follow-up this read only
|
|
90
|
+
* CLAUDE_WORKTREE_PATH, so in a plain shell `status` found the team and
|
|
91
|
+
* `escalate` exited 1.
|
|
85
92
|
*/
|
|
86
93
|
function readMarkerTeam() {
|
|
87
|
-
const worktreePath = process.env.CLAUDE_WORKTREE_PATH;
|
|
88
|
-
if (!worktreePath)
|
|
89
|
-
return undefined;
|
|
90
94
|
try {
|
|
91
|
-
const
|
|
92
|
-
if (!
|
|
95
|
+
const located = locateCoordinationWorktree(process.env);
|
|
96
|
+
if (!located.ok)
|
|
93
97
|
return undefined;
|
|
94
|
-
const raw =
|
|
98
|
+
const raw = readMarkerLine(located)?.trim() ?? '';
|
|
95
99
|
return raw || undefined;
|
|
96
100
|
}
|
|
97
101
|
catch {
|
|
@@ -115,6 +119,14 @@ function resolveTeam(explicit) {
|
|
|
115
119
|
console.error('Error: could not determine your team for the coordination `from` field. ' +
|
|
116
120
|
'Pass --team <team>, or run from a configured worktree ' +
|
|
117
121
|
'(the .mx-coordination-team marker or CLAUDE_WORKTREE_NAME must be set).');
|
|
122
|
+
// The same next step `status` prints, so the refusal names a command that works.
|
|
123
|
+
try {
|
|
124
|
+
for (const line of noMarkerLines(locateCoordinationWorktree(process.env)))
|
|
125
|
+
console.error(` ${line}`);
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
/* the next step is advice; the refusal above stands without it */
|
|
129
|
+
}
|
|
118
130
|
process.exit(1);
|
|
119
131
|
}
|
|
120
132
|
return team;
|
|
@@ -1740,6 +1752,8 @@ export function readWorkingTreeRoster(path, projectSlug) {
|
|
|
1740
1752
|
return { teams: null, source, error: `${path} could not be read or parsed` };
|
|
1741
1753
|
}
|
|
1742
1754
|
}
|
|
1755
|
+
/** The provenance clause when no team was resolved and so nothing was looked up. */
|
|
1756
|
+
export const NO_TEAM_SOURCE = 'no roster consulted: no team was resolved';
|
|
1743
1757
|
/**
|
|
1744
1758
|
* Whether an offline roster may REFUSE for this project, or may only fail to
|
|
1745
1759
|
* confirm.
|
|
@@ -1828,17 +1842,21 @@ function safeProjectRoot() {
|
|
|
1828
1842
|
*/
|
|
1829
1843
|
export async function resolveRegistration(projectSlug, teamSlug, deps = {}) {
|
|
1830
1844
|
const env = deps.env ?? process.env;
|
|
1831
|
-
const worktreePath = env.CLAUDE_WORKTREE_PATH;
|
|
1845
|
+
const worktreePath = deps.worktreePath ?? env.CLAUDE_WORKTREE_PATH;
|
|
1832
1846
|
const teamSlugAuthoritative = deps.teamSlugAuthoritative ?? true;
|
|
1833
1847
|
// 1. Live path. An injected client is probed directly; otherwise a credential
|
|
1834
1848
|
// must resolve first.
|
|
1835
1849
|
let client = deps.client ?? null;
|
|
1836
1850
|
let credentialResolved = client !== null;
|
|
1837
1851
|
let liveReason = 'no live check was attempted';
|
|
1852
|
+
// Whether the live path failed for a reason other than the missing team.
|
|
1853
|
+
let liveFailureIsOwnReason = client !== null;
|
|
1854
|
+
// The token path's own sentence, kept so the no-team branch does not print it twice.
|
|
1855
|
+
let liveDetail;
|
|
1838
1856
|
if (!client) {
|
|
1839
1857
|
let res;
|
|
1840
1858
|
try {
|
|
1841
|
-
res = deps.resolveToken ? await deps.resolveToken() : await resolveCoordinationToken();
|
|
1859
|
+
res = deps.resolveToken ? await deps.resolveToken() : await resolveCoordinationToken({ locate: deps.locate });
|
|
1842
1860
|
}
|
|
1843
1861
|
catch (err) {
|
|
1844
1862
|
res = { status: 'unavailable', detail: `token resolution threw (${err instanceof Error ? err.name : 'error'})` };
|
|
@@ -1886,7 +1904,12 @@ export async function resolveRegistration(projectSlug, teamSlug, deps = {}) {
|
|
|
1886
1904
|
}
|
|
1887
1905
|
else {
|
|
1888
1906
|
liveReason = `no coordination credential resolved (${res.status}${res.detail ? `: ${res.detail}` : ''})`;
|
|
1907
|
+
// `unprovisioned` with no team is the missing marker again, in other words.
|
|
1908
|
+
liveFailureIsOwnReason = res.status !== 'unprovisioned';
|
|
1909
|
+
liveDetail = res.detail;
|
|
1889
1910
|
}
|
|
1911
|
+
if (credentialResolved)
|
|
1912
|
+
liveFailureIsOwnReason = true;
|
|
1890
1913
|
}
|
|
1891
1914
|
// 2. Probe.
|
|
1892
1915
|
if (client) {
|
|
@@ -1914,6 +1937,24 @@ export async function resolveRegistration(projectSlug, teamSlug, deps = {}) {
|
|
|
1914
1937
|
liveReason = describeLiveFailure(err);
|
|
1915
1938
|
}
|
|
1916
1939
|
}
|
|
1940
|
+
// 2b. No team was resolved, so there is no name to look up offline. Saying a
|
|
1941
|
+
// roster "does not list this team", or that the name "came from the
|
|
1942
|
+
// worktree name", would describe a lookup that had no subject (#525: the
|
|
1943
|
+
// product owner's run from a main checkout printed both).
|
|
1944
|
+
if (deps.teamResolved === false) {
|
|
1945
|
+
const noTeam = deps.noTeamReason ?? 'no team was resolved for this directory';
|
|
1946
|
+
return {
|
|
1947
|
+
verdict: 'could-not-verify',
|
|
1948
|
+
kind: 'none',
|
|
1949
|
+
source: NO_TEAM_SOURCE,
|
|
1950
|
+
// A refused marker is the reason for both: the token path refuses with the
|
|
1951
|
+
// same sentence `status` already holds, and it is printed once.
|
|
1952
|
+
reason: liveFailureIsOwnReason && !(liveDetail && liveDetail.startsWith(noTeam.replace(/^no team was resolved: /, '')))
|
|
1953
|
+
? `${noTeam}. The live service gave no answer either: ${liveReason}`
|
|
1954
|
+
: noTeam,
|
|
1955
|
+
credentialResolved,
|
|
1956
|
+
};
|
|
1957
|
+
}
|
|
1917
1958
|
// 3. Offline fallback, in provenance order: the deploy ref first, a working
|
|
1918
1959
|
// tree only if the ref cannot be read.
|
|
1919
1960
|
const baseBranch = resolveBaseBranch(worktreePath);
|
|
@@ -2004,8 +2045,11 @@ function describeLiveFailure(err) {
|
|
|
2004
2045
|
export async function runStatus(deps) {
|
|
2005
2046
|
// 1. Resolve project slug.
|
|
2006
2047
|
const projectSlug = resolveProductSlug();
|
|
2007
|
-
// 2. Resolve team slug from the marker file.
|
|
2008
|
-
|
|
2048
|
+
// 2. Resolve team slug from the marker file. CLAUDE_WORKTREE_PATH first; in a
|
|
2049
|
+
// plain shell, the git top-level of the current directory, under the same
|
|
2050
|
+
// rule the token path uses (locateCoordinationWorktree, #507 follow-up).
|
|
2051
|
+
const located = locateCoordinationWorktree(process.env, deps?.locate);
|
|
2052
|
+
const worktreePath = located.ok ? located.root : undefined;
|
|
2009
2053
|
let teamSlug = 'not set';
|
|
2010
2054
|
let teamSource = '';
|
|
2011
2055
|
// The marker is the authoritative team identity. Track whether it supplied the
|
|
@@ -2013,16 +2057,38 @@ export async function runStatus(deps) {
|
|
|
2013
2057
|
// about the wrong string: this box runs worktree `bootstrap-20260821` for team
|
|
2014
2058
|
// `bootstrap`, and no roster will ever list the former.
|
|
2015
2059
|
let teamSlugAuthoritative = false;
|
|
2016
|
-
|
|
2017
|
-
|
|
2060
|
+
// A marker that holds something other than a team slug. Its bytes are never
|
|
2061
|
+
// printed: before this check `status` wrote them to the terminal as they were,
|
|
2062
|
+
// escape sequences included (security review of #525, Informational 1).
|
|
2063
|
+
let markerInvalid = false;
|
|
2064
|
+
// A marker that is there and was not used: unreadable, tracked in git, or in
|
|
2065
|
+
// disagreement with the worktree's code-context file (#525 red-team finding
|
|
2066
|
+
// 1). The reason is a full sentence. No team is printed as resolved from it.
|
|
2067
|
+
let markerRefusal;
|
|
2068
|
+
// The remedy for a refused marker. Printed once, under the Status line that
|
|
2069
|
+
// holds the reason.
|
|
2070
|
+
let markerRemedy = [];
|
|
2071
|
+
if (located.ok) {
|
|
2018
2072
|
try {
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
}
|
|
2073
|
+
const marker = readTeamMarker(located, deps?.locate);
|
|
2074
|
+
if (marker.kind === 'refused') {
|
|
2075
|
+
markerRefusal = marker.why;
|
|
2076
|
+
markerRemedy = marker.remedy;
|
|
2077
|
+
}
|
|
2078
|
+
if (marker.kind === 'unreadable') {
|
|
2079
|
+
markerRefusal = `the .mx-coordination-team marker in ${sanitizeField(located.root)} was not read: ${marker.why}`;
|
|
2080
|
+
}
|
|
2081
|
+
const raw = marker.kind === 'ok' ? marker.line.replace(/\s+/g, '') : '';
|
|
2082
|
+
if (raw && isValidProjectSlug(raw)) {
|
|
2083
|
+
teamSlug = raw;
|
|
2084
|
+
teamSource = located.source === 'git-toplevel'
|
|
2085
|
+
? ` (marker in ${sanitizeField(located.root)}, the git worktree of the current directory)`
|
|
2086
|
+
: '';
|
|
2087
|
+
teamSlugAuthoritative = true;
|
|
2088
|
+
}
|
|
2089
|
+
else if (raw) {
|
|
2090
|
+
markerInvalid = true;
|
|
2091
|
+
teamSlug = 'invalid marker';
|
|
2026
2092
|
}
|
|
2027
2093
|
}
|
|
2028
2094
|
catch {
|
|
@@ -2041,12 +2107,21 @@ export async function runStatus(deps) {
|
|
|
2041
2107
|
const mode = resolveCoordinationMode();
|
|
2042
2108
|
// 4. Check token cache.
|
|
2043
2109
|
let tokenCached = false;
|
|
2044
|
-
if (worktreePath) {
|
|
2110
|
+
if (worktreePath && !markerInvalid && !markerRefusal) {
|
|
2045
2111
|
const cacheFile = `.mx-coordination-token--${projectSlug}--${teamSlug}`;
|
|
2046
2112
|
tokenCached = existsSync(join(worktreePath, cacheFile));
|
|
2047
2113
|
}
|
|
2048
|
-
// 5. Resolve service URL
|
|
2049
|
-
|
|
2114
|
+
// 5. Resolve service URL with the resolution every other coordination command
|
|
2115
|
+
// uses, so status checks the URL the token and the client actually use,
|
|
2116
|
+
// including the #507 default for a credential-endpoint project. Never throws.
|
|
2117
|
+
let resolvedUrl = null;
|
|
2118
|
+
try {
|
|
2119
|
+
resolvedUrl = resolveCoordinationUrl();
|
|
2120
|
+
}
|
|
2121
|
+
catch {
|
|
2122
|
+
resolvedUrl = null;
|
|
2123
|
+
}
|
|
2124
|
+
const serviceUrl = resolvedUrl ? resolvedUrl.url.replace(/\/+$/, '') : undefined;
|
|
2050
2125
|
// 6. Ping healthz.
|
|
2051
2126
|
let serviceHealth = 'unknown';
|
|
2052
2127
|
if (serviceUrl) {
|
|
@@ -2077,8 +2152,20 @@ export async function runStatus(deps) {
|
|
|
2077
2152
|
// walks past a linked worktree to the shared main checkout. That checkout is
|
|
2078
2153
|
// nobody's responsibility to keep current, so a team the service had already
|
|
2079
2154
|
// registered read as absent and `status` printed a refusal.
|
|
2155
|
+
const teamResolved = teamSlug !== 'not set' && !markerInvalid;
|
|
2156
|
+
const noTeamReason = !located.ok
|
|
2157
|
+
? `no team was resolved: ${located.detail}`
|
|
2158
|
+
: markerInvalid
|
|
2159
|
+
? `no team was resolved: the .mx-coordination-team marker in ${sanitizeField(located.root)} does not hold a valid team slug`
|
|
2160
|
+
: markerRefusal
|
|
2161
|
+
? `no team was resolved: ${markerRefusal}`
|
|
2162
|
+
: `no team was resolved: ${sanitizeField(located.root)} holds no .mx-coordination-team marker`;
|
|
2080
2163
|
const registration = await resolveRegistration(projectSlug, teamSlug, {
|
|
2081
2164
|
teamSlugAuthoritative,
|
|
2165
|
+
teamResolved,
|
|
2166
|
+
noTeamReason,
|
|
2167
|
+
worktreePath,
|
|
2168
|
+
locate: deps?.locate,
|
|
2082
2169
|
...deps?.registration,
|
|
2083
2170
|
});
|
|
2084
2171
|
// 8. Determine overall status. A registered verdict from the live service
|
|
@@ -2094,7 +2181,7 @@ export async function runStatus(deps) {
|
|
|
2094
2181
|
console.log(` Team: ${teamSlug}${teamSource}`);
|
|
2095
2182
|
console.log(` Coordination mode: ${mode === 'queue' ? 'queue' : mode === 'memory' ? 'memory' : 'not set'}`);
|
|
2096
2183
|
console.log(` Token cached: ${tokenCached ? 'yes' : 'no'}`);
|
|
2097
|
-
console.log(` Service URL: ${serviceUrl ?? 'not configured'}`);
|
|
2184
|
+
console.log(` Service URL: ${resolvedUrl ? `${serviceUrl} (source: ${URL_SOURCE_LABEL[resolvedUrl.source] ?? resolvedUrl.source})` : 'not configured'}`);
|
|
2098
2185
|
console.log(` Service health: ${serviceHealth}`);
|
|
2099
2186
|
console.log(` Registered: ${registrationLine(registration)}`);
|
|
2100
2187
|
if (isReady) {
|
|
@@ -2117,10 +2204,53 @@ export async function runStatus(deps) {
|
|
|
2117
2204
|
else if (registration.verdict === 'could-not-verify') {
|
|
2118
2205
|
console.log(` Status: ? Could not verify — ${registration.reason ?? 'the live service did not answer'}`);
|
|
2119
2206
|
console.log('');
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2207
|
+
if (!teamResolved) {
|
|
2208
|
+
// No team, so nothing was looked up, and neither `brief` nor `setup` can
|
|
2209
|
+
// answer for a team this directory does not name. The next step is named
|
|
2210
|
+
// for the directory this ran in: the team worktrees that hold a marker, or
|
|
2211
|
+
// the command that writes one (#525 red-team F1).
|
|
2212
|
+
// A worktree the locator refused (owner or mode) may well name a team: it
|
|
2213
|
+
// was not read. Saying it "names none" would be false (#525 red-team N1).
|
|
2214
|
+
const worktreeRefused = !located.ok && located.reason === 'not-owned';
|
|
2215
|
+
console.log(worktreeRefused
|
|
2216
|
+
? ' This is not a refusal. No team was looked up, because the worktree of this directory was not used.'
|
|
2217
|
+
: markerRefusal
|
|
2218
|
+
? ' This is not a refusal. No team was looked up, because the marker in this worktree was not used.'
|
|
2219
|
+
: ' This is not a refusal. No team was looked up, because this directory names none.');
|
|
2220
|
+
console.log('');
|
|
2221
|
+
if (markerInvalid) {
|
|
2222
|
+
console.log(' The .mx-coordination-team marker in this worktree does not hold a valid team slug');
|
|
2223
|
+
console.log(` (it must match ${PROJECT_SLUG_RE_SOURCE}, with no '--').`);
|
|
2224
|
+
}
|
|
2225
|
+
else if (markerRemedy.length > 0) {
|
|
2226
|
+
// The Status line above holds the reason. The remedy follows it once.
|
|
2227
|
+
for (const line of markerRemedy)
|
|
2228
|
+
console.log(` ${line}`);
|
|
2229
|
+
}
|
|
2230
|
+
else {
|
|
2231
|
+
for (const line of noMarkerLines(located, deps?.locate))
|
|
2232
|
+
console.log(` ${line}`);
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
else {
|
|
2236
|
+
console.log(' This is not a refusal. The queue may hold this team; nothing here could');
|
|
2237
|
+
console.log(' confirm it. To get a live answer:');
|
|
2238
|
+
console.log(' mx-agent coordination brief # drains this team\'s own inbox');
|
|
2239
|
+
if (usesCredentialEndpoint(projectSlug)) {
|
|
2240
|
+
// #507: the service creates this project's teams on their first
|
|
2241
|
+
// credential request. `setup` needs an admin token and is not the remedy.
|
|
2242
|
+
console.log(' This project needs no `coordination setup`: the service registers a team on its');
|
|
2243
|
+
console.log(' first credential request. The reason above names what stopped that request.');
|
|
2244
|
+
}
|
|
2245
|
+
else {
|
|
2246
|
+
console.log(' mx-agent coordination setup # registers the team if it is absent');
|
|
2247
|
+
}
|
|
2248
|
+
if (!teamSlugAuthoritative) {
|
|
2249
|
+
console.log('');
|
|
2250
|
+
for (const line of noMarkerLines(located, deps?.locate))
|
|
2251
|
+
console.log(` ${line}`);
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2124
2254
|
}
|
|
2125
2255
|
else {
|
|
2126
2256
|
// Registered, but something else is missing. Name what, rather than printing
|
|
@@ -2143,7 +2273,9 @@ export async function runStatus(deps) {
|
|
|
2143
2273
|
*/
|
|
2144
2274
|
export function registrationLine(r) {
|
|
2145
2275
|
const verdict = r.verdict === 'registered' ? 'yes' : r.verdict === 'not-registered' ? 'no' : 'unverified';
|
|
2146
|
-
|
|
2276
|
+
// The source can hold a worktree path (the working-tree roster file), and a
|
|
2277
|
+
// path is printed only through sanitizeField (security review of #525, Informational 1).
|
|
2278
|
+
return `${verdict} (source: ${sanitizeField(r.source)})`;
|
|
2147
2279
|
}
|
|
2148
2280
|
/**
|
|
2149
2281
|
* A team file is RETIRED (a tombstone, not a live team) when its first non-empty
|
|
@@ -2195,6 +2327,11 @@ function discoverTeams(projectRoot) {
|
|
|
2195
2327
|
* 1. --service-url flag
|
|
2196
2328
|
* 2. MX_COORD_SERVICE_URL env var
|
|
2197
2329
|
* 3. coordination-service-url config key
|
|
2330
|
+
*
|
|
2331
|
+
* Used by `setup` only. `status` uses resolveCoordinationUrl, as the token path
|
|
2332
|
+
* and the client do (#507 follow-up). `setup` deliberately gets no #507 default:
|
|
2333
|
+
* it sends MX_COORD_ADMIN_TOKEN to POST /admin/provision, and an admin token
|
|
2334
|
+
* must go only to a service the operator named, not to a built-in fallback.
|
|
2198
2335
|
*/
|
|
2199
2336
|
function resolveServiceUrl(flagUrl, env = process.env) {
|
|
2200
2337
|
if (flagUrl)
|