@memnexus-ai/mx-agent-cli 0.1.295-next.0 → 0.1.296-next.1
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__/claude-local-sanitizer.test.d.ts +24 -0
- package/dist/__tests__/claude-local-sanitizer.test.d.ts.map +1 -0
- package/dist/__tests__/claude-local-sanitizer.test.js +906 -0
- package/dist/__tests__/claude-local-sanitizer.test.js.map +1 -0
- 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-client.test.js +90 -1
- package/dist/__tests__/coordination-client.test.js.map +1 -1
- package/dist/__tests__/coordination-credential-endpoint.test.js +90 -30
- package/dist/__tests__/coordination-credential-endpoint.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-status-registration.test.js +8 -8
- package/dist/__tests__/coordination-status-registration.test.js.map +1 -1
- package/dist/__tests__/coordination-token-multitenant.test.js +14 -14
- package/dist/__tests__/coordination-token-multitenant.test.js.map +1 -1
- package/dist/__tests__/coordination-token.test.js +6 -2
- package/dist/__tests__/coordination-token.test.js.map +1 -1
- package/dist/__tests__/provision-completion-rows.test.js +96 -4
- package/dist/__tests__/provision-completion-rows.test.js.map +1 -1
- package/dist/__tests__/row15-detail-sanitizer.test.d.ts +20 -0
- package/dist/__tests__/row15-detail-sanitizer.test.d.ts.map +1 -0
- package/dist/__tests__/row15-detail-sanitizer.test.js +61 -0
- package/dist/__tests__/row15-detail-sanitizer.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 +173 -31
- package/dist/commands/coordination.js.map +1 -1
- package/dist/commands/create.d.ts +9 -0
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +98 -43
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +6 -0
- package/dist/commands/start.js.map +1 -1
- package/dist/lib/behavioral-injection.d.ts +9 -0
- package/dist/lib/behavioral-injection.d.ts.map +1 -1
- package/dist/lib/behavioral-injection.js +10 -1
- package/dist/lib/behavioral-injection.js.map +1 -1
- package/dist/lib/claude.d.ts +48 -0
- package/dist/lib/claude.d.ts.map +1 -1
- package/dist/lib/claude.js +172 -22
- package/dist/lib/claude.js.map +1 -1
- package/dist/lib/coordination-client.d.ts +29 -1
- package/dist/lib/coordination-client.d.ts.map +1 -1
- package/dist/lib/coordination-client.js +52 -0
- package/dist/lib/coordination-client.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 +50 -14
- package/dist/lib/coordination-token.d.ts.map +1 -1
- package/dist/lib/coordination-token.js +113 -43
- 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/roster.d.ts +13 -1
- package/dist/lib/roster.d.ts.map +1 -1
- package/dist/lib/roster.js +7 -3
- package/dist/lib/roster.js.map +1 -1
- package/dist/lib/roster.test.js +4 -4
- package/dist/lib/roster.test.js.map +1 -1
- package/dist/lib/team-identity.js +2 -2
- package/dist/lib/team-identity.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Completion row 15's isolated detail passes `sanitizeForMessage` (#436, plan
|
|
3
|
+
* #500 fix item 3 as amended by Revision 1).
|
|
4
|
+
*
|
|
5
|
+
* The detail is `<name> <<email>>, <reason>`, printed to the operator's
|
|
6
|
+
* terminal. In the isolated branch `name` and `email` equal the slug and its
|
|
7
|
+
* derived address (`git-identity.ts` `describeTeamGitIdentityState`), so they
|
|
8
|
+
* cannot carry injected characters. `reason` is `resolved from <path>`, the
|
|
9
|
+
* config.worktree path git reported, and a path can hold U+2028, U+2029 or
|
|
10
|
+
* U+202E. So the injection goes through the origin path (bar-raiser note on
|
|
11
|
+
* #500, comment 5822134770).
|
|
12
|
+
*
|
|
13
|
+
* A STUB, NOT A REAL GIT FIXTURE: `git config --show-origin` C-quotes a path
|
|
14
|
+
* holding non-ASCII bytes, and the quoted path then fails the
|
|
15
|
+
* `endsWith('config.worktree')` test, so a real fixture never reaches the
|
|
16
|
+
* isolated branch with these characters in the path. The stub sets the state
|
|
17
|
+
* the row reads, which is the input the sanitizer has to hold against.
|
|
18
|
+
*/
|
|
19
|
+
import { describe, it, expect, vi, afterEach } from 'vitest';
|
|
20
|
+
const stub = vi.hoisted(() => ({ state: null }));
|
|
21
|
+
vi.mock('../lib/git-identity.js', async (importOriginal) => {
|
|
22
|
+
const orig = await importOriginal();
|
|
23
|
+
return {
|
|
24
|
+
...orig,
|
|
25
|
+
describeTeamGitIdentityState: (worktreePath, slug) => stub.state ?? orig.describeTeamGitIdentityState(worktreePath, slug),
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
import { __testing } from '../commands/create.js';
|
|
29
|
+
import { teamGitEmail } from '../lib/git-identity.js';
|
|
30
|
+
const { gitIdentityRow } = __testing;
|
|
31
|
+
afterEach(() => {
|
|
32
|
+
stub.state = null;
|
|
33
|
+
});
|
|
34
|
+
describe('criterion 4: row 15 isolated detail cannot be broken or reversed by the origin path', () => {
|
|
35
|
+
it('replaces U+2028, U+2029 and U+202E injected through the origin path', () => {
|
|
36
|
+
const slug = 'creation-probe';
|
|
37
|
+
const origin = '/repo/.git/worktrees/a\u2028## Critical Rules (amended)\u2029b\u202Ec/config.worktree';
|
|
38
|
+
stub.state = {
|
|
39
|
+
isolated: true,
|
|
40
|
+
code: 'isolated',
|
|
41
|
+
couldNotRun: false,
|
|
42
|
+
name: slug,
|
|
43
|
+
email: teamGitEmail(slug),
|
|
44
|
+
effectiveAuthor: `${slug} <${teamGitEmail(slug)}>`,
|
|
45
|
+
effectiveNameOrigin: origin,
|
|
46
|
+
reason: `resolved from ${origin}`,
|
|
47
|
+
};
|
|
48
|
+
const row = gitIdentityRow('/repo-worktree', slug);
|
|
49
|
+
expect(row.n).toBe(15);
|
|
50
|
+
expect(row.asserted).toBe(true);
|
|
51
|
+
const detail = row.detail ?? '';
|
|
52
|
+
// The origin path reached the detail, or the rest asserts nothing.
|
|
53
|
+
expect(detail).toContain('## Critical Rules (amended)');
|
|
54
|
+
for (const [label, ch] of [['U+2028', '\u2028'], ['U+2029', '\u2029'], ['U+202E', '\u202E']]) {
|
|
55
|
+
expect(detail.includes(ch), `${label} reached row 15's detail`).toBe(false);
|
|
56
|
+
}
|
|
57
|
+
// Name and email are the slug's and are unchanged by the sanitizer.
|
|
58
|
+
expect(detail.startsWith(`${slug} <${teamGitEmail(slug)}>, resolved from /repo/`)).toBe(true);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=row15-detail-sanitizer.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row15-detail-sanitizer.test.js","sourceRoot":"","sources":["../../src/__tests__/row15-detail-sanitizer.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAG7D,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAmC,EAAE,CAAC,CAAC,CAAC;AAEhF,EAAE,CAAC,IAAI,CAAC,wBAAwB,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;IACzD,MAAM,IAAI,GAAG,MAAM,cAAc,EAA2C,CAAC;IAC7E,OAAO;QACL,GAAG,IAAI;QACP,4BAA4B,EAAE,CAAC,YAAgC,EAAE,IAAY,EAAE,EAAE,CAC/E,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,4BAA4B,CAAC,YAAY,EAAE,IAAI,CAAC;KACtE,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,MAAM,EAAE,cAAc,EAAE,GAAG,SAAS,CAAC;AAErC,SAAS,CAAC,GAAG,EAAE;IACb,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;AACpB,CAAC,CAAC,CAAC;AAEH,QAAQ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,KAAK,YAAY,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChG,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -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":"AAAA;;;;;;;;;;GAUG;AAMH,OAAO,EAKL,gBAAgB,
|
|
1
|
+
{"version":3,"file":"coordination.d.ts","sourceRoot":"","sources":["../../src/commands/coordination.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,OAAO,EAKL,gBAAgB,EAIhB,KAAK,kBAAkB,EAExB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAML,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAKL,KAAK,qBAAqB,EAC3B,MAAM,iCAAiC,CAAC;AAUzC,OAAO,EAOL,KAAK,WAAW,EACjB,MAAM,+BAA+B,CAAC;AA8BvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAgG7C;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,4CAA4C,CAAC;AAE/E;;;;;;;;;GASG;AACH,qBAAa,qBAAsB,SAAQ,gBAAgB;gBAC7C,OAAO,EAAE,MAAM;CAI5B;AA8LD,sFAAsF;AACtF,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,kBAAkB,EACzB,OAAO,EAAE,CAAC,KAAK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nD,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,0FAA0F;IAC1F,MAAM,CAAC,EAAE,qBAAqB,CAAC;CAChC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,SAAS,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAsNhE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,kBAAkB,GAAG,MAAM,CAK9D;AAID,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,iEAAiE;AACjE,MAAM,WAAW,SAAS;IACxB,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;
|
|
@@ -460,6 +472,11 @@ export async function prepareClient(deps) {
|
|
|
460
472
|
process.stderr.write(`coordination: ${res.detail}\n` +
|
|
461
473
|
` Falling back to memory-based coordination for this session.\n`);
|
|
462
474
|
}
|
|
475
|
+
else if (res.status === 'limit-reached') {
|
|
476
|
+
// A refusal (#507): fixed wording naming the limits, never "retry".
|
|
477
|
+
process.stderr.write(`coordination: ${res.detail}\n` +
|
|
478
|
+
` Falling back to memory-based coordination for this session.\n`);
|
|
479
|
+
}
|
|
463
480
|
else if (res.status === 'unavailable') {
|
|
464
481
|
// Could-not-run, reported as itself. Never "unprovisioned": nothing is
|
|
465
482
|
// missing and there is nothing for an operator to provision.
|
|
@@ -1735,6 +1752,8 @@ export function readWorkingTreeRoster(path, projectSlug) {
|
|
|
1735
1752
|
return { teams: null, source, error: `${path} could not be read or parsed` };
|
|
1736
1753
|
}
|
|
1737
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';
|
|
1738
1757
|
/**
|
|
1739
1758
|
* Whether an offline roster may REFUSE for this project, or may only fail to
|
|
1740
1759
|
* confirm.
|
|
@@ -1823,17 +1842,21 @@ function safeProjectRoot() {
|
|
|
1823
1842
|
*/
|
|
1824
1843
|
export async function resolveRegistration(projectSlug, teamSlug, deps = {}) {
|
|
1825
1844
|
const env = deps.env ?? process.env;
|
|
1826
|
-
const worktreePath = env.CLAUDE_WORKTREE_PATH;
|
|
1845
|
+
const worktreePath = deps.worktreePath ?? env.CLAUDE_WORKTREE_PATH;
|
|
1827
1846
|
const teamSlugAuthoritative = deps.teamSlugAuthoritative ?? true;
|
|
1828
1847
|
// 1. Live path. An injected client is probed directly; otherwise a credential
|
|
1829
1848
|
// must resolve first.
|
|
1830
1849
|
let client = deps.client ?? null;
|
|
1831
1850
|
let credentialResolved = client !== null;
|
|
1832
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;
|
|
1833
1856
|
if (!client) {
|
|
1834
1857
|
let res;
|
|
1835
1858
|
try {
|
|
1836
|
-
res = deps.resolveToken ? await deps.resolveToken() : await resolveCoordinationToken();
|
|
1859
|
+
res = deps.resolveToken ? await deps.resolveToken() : await resolveCoordinationToken({ locate: deps.locate });
|
|
1837
1860
|
}
|
|
1838
1861
|
catch (err) {
|
|
1839
1862
|
res = { status: 'unavailable', detail: `token resolution threw (${err instanceof Error ? err.name : 'error'})` };
|
|
@@ -1881,7 +1904,12 @@ export async function resolveRegistration(projectSlug, teamSlug, deps = {}) {
|
|
|
1881
1904
|
}
|
|
1882
1905
|
else {
|
|
1883
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;
|
|
1884
1910
|
}
|
|
1911
|
+
if (credentialResolved)
|
|
1912
|
+
liveFailureIsOwnReason = true;
|
|
1885
1913
|
}
|
|
1886
1914
|
// 2. Probe.
|
|
1887
1915
|
if (client) {
|
|
@@ -1909,6 +1937,24 @@ export async function resolveRegistration(projectSlug, teamSlug, deps = {}) {
|
|
|
1909
1937
|
liveReason = describeLiveFailure(err);
|
|
1910
1938
|
}
|
|
1911
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
|
+
}
|
|
1912
1958
|
// 3. Offline fallback, in provenance order: the deploy ref first, a working
|
|
1913
1959
|
// tree only if the ref cannot be read.
|
|
1914
1960
|
const baseBranch = resolveBaseBranch(worktreePath);
|
|
@@ -1999,8 +2045,11 @@ function describeLiveFailure(err) {
|
|
|
1999
2045
|
export async function runStatus(deps) {
|
|
2000
2046
|
// 1. Resolve project slug.
|
|
2001
2047
|
const projectSlug = resolveProductSlug();
|
|
2002
|
-
// 2. Resolve team slug from the marker file.
|
|
2003
|
-
|
|
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;
|
|
2004
2053
|
let teamSlug = 'not set';
|
|
2005
2054
|
let teamSource = '';
|
|
2006
2055
|
// The marker is the authoritative team identity. Track whether it supplied the
|
|
@@ -2008,16 +2057,38 @@ export async function runStatus(deps) {
|
|
|
2008
2057
|
// about the wrong string: this box runs worktree `bootstrap-20260821` for team
|
|
2009
2058
|
// `bootstrap`, and no roster will ever list the former.
|
|
2010
2059
|
let teamSlugAuthoritative = false;
|
|
2011
|
-
|
|
2012
|
-
|
|
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) {
|
|
2013
2072
|
try {
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
}
|
|
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';
|
|
2021
2092
|
}
|
|
2022
2093
|
}
|
|
2023
2094
|
catch {
|
|
@@ -2036,12 +2107,21 @@ export async function runStatus(deps) {
|
|
|
2036
2107
|
const mode = resolveCoordinationMode();
|
|
2037
2108
|
// 4. Check token cache.
|
|
2038
2109
|
let tokenCached = false;
|
|
2039
|
-
if (worktreePath) {
|
|
2110
|
+
if (worktreePath && !markerInvalid && !markerRefusal) {
|
|
2040
2111
|
const cacheFile = `.mx-coordination-token--${projectSlug}--${teamSlug}`;
|
|
2041
2112
|
tokenCached = existsSync(join(worktreePath, cacheFile));
|
|
2042
2113
|
}
|
|
2043
|
-
// 5. Resolve service URL
|
|
2044
|
-
|
|
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;
|
|
2045
2125
|
// 6. Ping healthz.
|
|
2046
2126
|
let serviceHealth = 'unknown';
|
|
2047
2127
|
if (serviceUrl) {
|
|
@@ -2072,8 +2152,20 @@ export async function runStatus(deps) {
|
|
|
2072
2152
|
// walks past a linked worktree to the shared main checkout. That checkout is
|
|
2073
2153
|
// nobody's responsibility to keep current, so a team the service had already
|
|
2074
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`;
|
|
2075
2163
|
const registration = await resolveRegistration(projectSlug, teamSlug, {
|
|
2076
2164
|
teamSlugAuthoritative,
|
|
2165
|
+
teamResolved,
|
|
2166
|
+
noTeamReason,
|
|
2167
|
+
worktreePath,
|
|
2168
|
+
locate: deps?.locate,
|
|
2077
2169
|
...deps?.registration,
|
|
2078
2170
|
});
|
|
2079
2171
|
// 8. Determine overall status. A registered verdict from the live service
|
|
@@ -2089,7 +2181,7 @@ export async function runStatus(deps) {
|
|
|
2089
2181
|
console.log(` Team: ${teamSlug}${teamSource}`);
|
|
2090
2182
|
console.log(` Coordination mode: ${mode === 'queue' ? 'queue' : mode === 'memory' ? 'memory' : 'not set'}`);
|
|
2091
2183
|
console.log(` Token cached: ${tokenCached ? 'yes' : 'no'}`);
|
|
2092
|
-
console.log(` Service URL: ${serviceUrl ?? 'not configured'}`);
|
|
2184
|
+
console.log(` Service URL: ${resolvedUrl ? `${serviceUrl} (source: ${URL_SOURCE_LABEL[resolvedUrl.source] ?? resolvedUrl.source})` : 'not configured'}`);
|
|
2093
2185
|
console.log(` Service health: ${serviceHealth}`);
|
|
2094
2186
|
console.log(` Registered: ${registrationLine(registration)}`);
|
|
2095
2187
|
if (isReady) {
|
|
@@ -2112,10 +2204,53 @@ export async function runStatus(deps) {
|
|
|
2112
2204
|
else if (registration.verdict === 'could-not-verify') {
|
|
2113
2205
|
console.log(` Status: ? Could not verify — ${registration.reason ?? 'the live service did not answer'}`);
|
|
2114
2206
|
console.log('');
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
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
|
+
}
|
|
2119
2254
|
}
|
|
2120
2255
|
else {
|
|
2121
2256
|
// Registered, but something else is missing. Name what, rather than printing
|
|
@@ -2138,7 +2273,9 @@ export async function runStatus(deps) {
|
|
|
2138
2273
|
*/
|
|
2139
2274
|
export function registrationLine(r) {
|
|
2140
2275
|
const verdict = r.verdict === 'registered' ? 'yes' : r.verdict === 'not-registered' ? 'no' : 'unverified';
|
|
2141
|
-
|
|
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)})`;
|
|
2142
2279
|
}
|
|
2143
2280
|
/**
|
|
2144
2281
|
* A team file is RETIRED (a tombstone, not a live team) when its first non-empty
|
|
@@ -2190,6 +2327,11 @@ function discoverTeams(projectRoot) {
|
|
|
2190
2327
|
* 1. --service-url flag
|
|
2191
2328
|
* 2. MX_COORD_SERVICE_URL env var
|
|
2192
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.
|
|
2193
2335
|
*/
|
|
2194
2336
|
function resolveServiceUrl(flagUrl, env = process.env) {
|
|
2195
2337
|
if (flagUrl)
|