@mostra/cli 0.10.0 → 0.12.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/bin.js +2 -2
- package/dist/{bootstrap-_iCl_HaO.js → bootstrap-3_Tdfdg7.js} +3 -2
- package/dist/bootstrap-3_Tdfdg7.js.map +1 -0
- package/dist/bootstrap-C9a2gSWf.js +1 -0
- package/dist/{flush-znWmNZA1.js → flush-TPaIdwjy.js} +3 -1
- package/dist/flush-TPaIdwjy.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/reference/cli.md +178 -2
- package/dist/reference/diagnostics.json +108 -0
- package/dist/reference/errors/MOSTRA_ACTION_PAUSED.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_HOME_MOVING.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_HOME_SUSPENDED.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_LIMIT_REACHED.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_NO_INSTANCE.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_OPERATOR_UNAVAILABLE.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_PAUSED_BY_OPERATOR.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_UNDER_REVIEW.md +23 -0
- package/dist/reference/errors/MOSTRA_SUBMIT_PAUSED.md +23 -0
- package/dist/reference/errors/MOSTRA_TEAM_PRESENCE_RATE_LIMITED.md +23 -0
- package/dist/reference/errors/MOSTRA_TEAM_ROSTER_POLICY.md +23 -0
- package/dist/reference/errors/MOSTRA_TEAM_ROSTER_TOO_LARGE.md +23 -0
- package/dist/reference/self-hosting.md +130 -0
- package/dist/{run-Aq4HVIY0.js → run-CtR0PFMj.js} +349 -231
- package/dist/run-CtR0PFMj.js.map +1 -0
- package/dist/run-NWeQcyh9.js +1 -0
- package/dist/skill/SKILL.md +7 -3
- package/dist/skill/references/answers.md +3 -1
- package/dist/skill/references/mcp.md +8 -3
- package/dist/skill/references/sharing.md +1 -0
- package/dist/skill/references/teams.md +78 -0
- package/dist/telemetry/flush-main.js +1 -1
- package/package.json +5 -5
- package/src/commands/admin.ts +2 -2
- package/src/commands/index.ts +7 -1
- package/src/commands/interaction.ts +43 -2
- package/src/commands/remote.ts +99 -3
- package/src/commands/sharing.ts +19 -1
- package/src/commands/team.ts +191 -0
- package/src/detached.ts +2 -0
- package/src/docs.ts +12 -217
- package/src/exit.ts +2 -0
- package/src/mcp.ts +3 -21
- package/dist/bootstrap-BStzS_41.js +0 -1
- package/dist/bootstrap-_iCl_HaO.js.map +0 -1
- package/dist/flush-znWmNZA1.js.map +0 -1
- package/dist/run-Aq4HVIY0.js.map +0 -1
- package/dist/run-D1U_RFEP.js +0 -1
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Teams (D121, D168): `roster get|add|remove`, thin clients of `roster/*`. A respondent is named by
|
|
3
|
+
* the caller's own stable key for them (`ref`, an email or an account ID) and gets a personal link
|
|
4
|
+
* that acts as them; `mostra wait --until submitted:all` waits for every one of them.
|
|
5
|
+
*/
|
|
6
|
+
import {
|
|
7
|
+
type CapabilityScope,
|
|
8
|
+
RespondentSpec,
|
|
9
|
+
type Roster,
|
|
10
|
+
rosterAddMethod,
|
|
11
|
+
rosterGetMethod,
|
|
12
|
+
rosterRemoveMethod,
|
|
13
|
+
} from "@mostra/protocol";
|
|
14
|
+
import { type CommandDef, defineCommand } from "../command.ts";
|
|
15
|
+
import { EXIT } from "../exit.ts";
|
|
16
|
+
import { usage } from "../parse.ts";
|
|
17
|
+
import { arg, artifactRef, flag, jsonInput } from "./shared.ts";
|
|
18
|
+
|
|
19
|
+
/** One line per respondent and the round's tally: what `roster get` prints. */
|
|
20
|
+
export function rosterText(roster: Roster): string {
|
|
21
|
+
const { counts } = roster;
|
|
22
|
+
const head =
|
|
23
|
+
counts.total === 0
|
|
24
|
+
? "No expected respondents.\n"
|
|
25
|
+
: `Round ${roster.round}: ${counts.submitted} of ${counts.total} submitted, ${counts.drafting} drafting, ${counts.notOpened} not opened${roster.complete ? " (complete)" : ""}.\n`;
|
|
26
|
+
const width = Math.max(0, ...roster.respondents.map((one) => one.ref.length));
|
|
27
|
+
const lines = roster.respondents.map(
|
|
28
|
+
(one) =>
|
|
29
|
+
` ${one.status.padEnd(10)} ${one.ref.padEnd(width)}${one.name !== undefined ? ` ${one.name}` : ""}\n`,
|
|
30
|
+
);
|
|
31
|
+
return `${head}${lines.join("")}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** `mostra roster get <artifact>`. */
|
|
35
|
+
export const rosterGetCommand: CommandDef = defineCommand({
|
|
36
|
+
path: ["roster", "get"],
|
|
37
|
+
summary:
|
|
38
|
+
"Show who an artifact expects answers from and where each stands: not opened, drafting or submitted.",
|
|
39
|
+
args: [{ name: "artifact", summary: "The artifact: its source path or its ID." }],
|
|
40
|
+
output: { type: "Roster", topic: "cli" },
|
|
41
|
+
exits: [EXIT.failure],
|
|
42
|
+
example: "roster get ./retro",
|
|
43
|
+
async run(context) {
|
|
44
|
+
const result = await context.call(rosterGetMethod, {
|
|
45
|
+
artifact: artifactRef(arg(context, "artifact"), context.cwd),
|
|
46
|
+
});
|
|
47
|
+
return { result, human: rosterText(result) };
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/** `mostra roster add <artifact> [ref…]`. */
|
|
52
|
+
export const rosterAddCommand: CommandDef = defineCommand({
|
|
53
|
+
path: ["roster", "add"],
|
|
54
|
+
summary:
|
|
55
|
+
"Name the people an artifact expects answers from; each gets a personal link that acts as them.",
|
|
56
|
+
args: [
|
|
57
|
+
{ name: "artifact", summary: "The artifact: its source path or its ID." },
|
|
58
|
+
{
|
|
59
|
+
name: "ref",
|
|
60
|
+
summary: "Each respondent, by your own stable key for them (an email, an account ID).",
|
|
61
|
+
optional: true,
|
|
62
|
+
variadic: true,
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
flags: [
|
|
66
|
+
{
|
|
67
|
+
name: "name",
|
|
68
|
+
kind: "string",
|
|
69
|
+
value: "<name>",
|
|
70
|
+
summary: "The display name of the one respondent given.",
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "email",
|
|
74
|
+
kind: "string",
|
|
75
|
+
value: "<address>",
|
|
76
|
+
summary: "Where a remote server that sends invitations writes to the one respondent given.",
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "file",
|
|
80
|
+
kind: "string",
|
|
81
|
+
value: "<path>",
|
|
82
|
+
summary: "Read respondents from a JSON file: [{ ref, name?, email? }].",
|
|
83
|
+
},
|
|
84
|
+
{ name: "stdin", kind: "boolean", summary: "Read respondents as JSON from stdin." },
|
|
85
|
+
{
|
|
86
|
+
name: "scope",
|
|
87
|
+
kind: "list",
|
|
88
|
+
value: "<a,b>",
|
|
89
|
+
summary:
|
|
90
|
+
"The personal links' scopes: view, draft, submit, review, signal, action:*. Default: all.",
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: "ttl",
|
|
94
|
+
kind: "duration",
|
|
95
|
+
value: "<d>",
|
|
96
|
+
summary: "How long the personal links work, such as 7d. Default: no limit.",
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "request-id",
|
|
100
|
+
kind: "string",
|
|
101
|
+
value: "<id>",
|
|
102
|
+
summary: "Make a retry return the first attempt's links.",
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
output: { type: "RosterAddResult", topic: "cli" },
|
|
106
|
+
exits: [EXIT.failure],
|
|
107
|
+
example: "roster add ./retro ada@example.com grace@example.com",
|
|
108
|
+
readsStdin: (flags) => flags["stdin"] === true,
|
|
109
|
+
async run(context) {
|
|
110
|
+
const refs = (context.args["ref"] as readonly string[] | undefined) ?? [];
|
|
111
|
+
const name = flag(context, "name");
|
|
112
|
+
const email = flag(context, "email");
|
|
113
|
+
const fromJson = context.flags["file"] !== undefined || context.flags["stdin"] === true;
|
|
114
|
+
let respondents: RespondentSpec[];
|
|
115
|
+
if (fromJson) {
|
|
116
|
+
if (refs.length > 0 || name !== undefined || email !== undefined) {
|
|
117
|
+
throw usage("Give respondents either as arguments or with --file or --stdin, not both.");
|
|
118
|
+
}
|
|
119
|
+
const parsed = RespondentSpec.array()
|
|
120
|
+
.min(1)
|
|
121
|
+
.safeParse(await jsonInput(context, "respondents"));
|
|
122
|
+
if (!parsed.success) {
|
|
123
|
+
throw usage("The respondents must be a non-empty JSON array of { ref, name?, email? }.");
|
|
124
|
+
}
|
|
125
|
+
respondents = parsed.data;
|
|
126
|
+
} else {
|
|
127
|
+
if (refs.length === 0)
|
|
128
|
+
throw usage("Name at least one respondent, or give --file or --stdin.");
|
|
129
|
+
if ((name !== undefined || email !== undefined) && refs.length !== 1) {
|
|
130
|
+
throw usage("--name and --email describe one respondent: give one ref with them.");
|
|
131
|
+
}
|
|
132
|
+
respondents = refs.map((ref) => ({
|
|
133
|
+
ref,
|
|
134
|
+
...(name !== undefined ? { name } : {}),
|
|
135
|
+
...(email !== undefined ? { email } : {}),
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
const scopes = context.flags["scope"] as readonly string[] | undefined;
|
|
139
|
+
const ttl = flag(context, "ttl");
|
|
140
|
+
const requestId = flag(context, "request-id");
|
|
141
|
+
const result = await context.call(rosterAddMethod, {
|
|
142
|
+
artifact: artifactRef(arg(context, "artifact"), context.cwd),
|
|
143
|
+
respondents,
|
|
144
|
+
...(scopes !== undefined ? { scopes: scopes as CapabilityScope[] } : {}),
|
|
145
|
+
...(ttl !== undefined ? { ttl: ttl as `${number}${"s" | "m" | "h" | "d"}` } : {}),
|
|
146
|
+
...(requestId !== undefined ? { requestId } : {}),
|
|
147
|
+
});
|
|
148
|
+
const width = Math.max(0, ...result.links.map((entry) => entry.ref.length));
|
|
149
|
+
const links = result.links.map((entry) => `${entry.ref.padEnd(width)} ${entry.link.url}\n`);
|
|
150
|
+
return {
|
|
151
|
+
result,
|
|
152
|
+
human: `${links.join("")}Send each person their own link. Wait for everyone with: mostra wait ${arg(context, "artifact")} --until submitted:all\n`,
|
|
153
|
+
};
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
/** `mostra roster remove <artifact> <ref…>`. */
|
|
158
|
+
export const rosterRemoveCommand: CommandDef = defineCommand({
|
|
159
|
+
path: ["roster", "remove"],
|
|
160
|
+
summary:
|
|
161
|
+
"Stop expecting answers from respondents; their links, drafts and submissions stay as they are.",
|
|
162
|
+
args: [
|
|
163
|
+
{ name: "artifact", summary: "The artifact: its source path or its ID." },
|
|
164
|
+
{ name: "ref", summary: "Each respondent to remove, by their ref.", variadic: true },
|
|
165
|
+
],
|
|
166
|
+
flags: [
|
|
167
|
+
{
|
|
168
|
+
name: "request-id",
|
|
169
|
+
kind: "string",
|
|
170
|
+
value: "<id>",
|
|
171
|
+
summary: "Make a retry return the first attempt's result.",
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
output: { type: "RosterRemoveResult", topic: "cli" },
|
|
175
|
+
exits: [EXIT.failure],
|
|
176
|
+
example: "roster remove ./retro grace@example.com",
|
|
177
|
+
async run(context) {
|
|
178
|
+
const refs = (context.args["ref"] as readonly string[] | undefined) ?? [];
|
|
179
|
+
if (refs.length === 0) throw usage("Name at least one respondent to remove.");
|
|
180
|
+
const requestId = flag(context, "request-id");
|
|
181
|
+
const result = await context.call(rosterRemoveMethod, {
|
|
182
|
+
artifact: artifactRef(arg(context, "artifact"), context.cwd),
|
|
183
|
+
refs: [...refs],
|
|
184
|
+
...(requestId !== undefined ? { requestId } : {}),
|
|
185
|
+
});
|
|
186
|
+
return {
|
|
187
|
+
result,
|
|
188
|
+
human: `${result.removed.length === 0 ? "No one removed.\n" : `Removed ${result.removed.join(", ")}.\n`}${rosterText(result.roster)}`,
|
|
189
|
+
};
|
|
190
|
+
},
|
|
191
|
+
});
|
package/src/detached.ts
CHANGED
|
@@ -28,6 +28,8 @@ export const PATH_VARIABLES: readonly string[] = [
|
|
|
28
28
|
"MOSTRA_TEST_NETWORK_FILESYSTEM",
|
|
29
29
|
"MOSTRA_TEST_BINDING_TRACE",
|
|
30
30
|
"MOSTRA_TEST_BUNDLE_PINS",
|
|
31
|
+
"MOSTRA_TEST_VERIFY_FAIL_ONCE",
|
|
32
|
+
"MOSTRA_TEST_VERIFY_COLLIDE_ONCE",
|
|
31
33
|
"MOSTRA_TAILSCALE",
|
|
32
34
|
"MOSTRA_CLOUDFLARED",
|
|
33
35
|
"MOSTRA_TEST_TUNNELS",
|
package/src/docs.ts
CHANGED
|
@@ -5,28 +5,11 @@
|
|
|
5
5
|
* `guide` and `guide/<name>`, so an agent whose harness has no Skill reads the same text through
|
|
6
6
|
* the CLI. This index is the one source WP-15's `docs_search` and WP-26's site read.
|
|
7
7
|
*/
|
|
8
|
-
import { existsSync
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import { existsSync } from "node:fs";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
import { type DocsTopic, docsIndex as indexOf } from "@mostra/mcp";
|
|
11
11
|
import { fromSource, packageRoot } from "./version.ts";
|
|
12
12
|
|
|
13
|
-
/** One topic of the reference. */
|
|
14
|
-
export interface DocsTopic {
|
|
15
|
-
/** Its stable slug: `cli`, `telemetry`, a diagnostic code, `guide` or `guide/<name>`. */
|
|
16
|
-
readonly topic: string;
|
|
17
|
-
/** Its title, from the page's first heading. */
|
|
18
|
-
readonly title: string;
|
|
19
|
-
/** Where the docs site serves it. */
|
|
20
|
-
readonly url: string;
|
|
21
|
-
/** Its Markdown file, or a guide topic's first file. */
|
|
22
|
-
readonly file: string;
|
|
23
|
-
/**
|
|
24
|
-
* A guide topic that isn't one Markdown page (a stylesheet, an example): its files, relative to
|
|
25
|
-
* the Skill's `assets/`, each shown as code.
|
|
26
|
-
*/
|
|
27
|
-
readonly files?: readonly string[];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
13
|
/** Where the reference is: bundled in the build (`dist/reference`), or the repository's. */
|
|
31
14
|
export function referenceDir(): string {
|
|
32
15
|
const bundled = join(packageRoot(), "dist", "reference");
|
|
@@ -43,203 +26,15 @@ export function skillDir(): string {
|
|
|
43
26
|
: join(packageRoot(), "..", "..", "skills", "mostra");
|
|
44
27
|
}
|
|
45
28
|
|
|
46
|
-
|
|
47
|
-
const first = readFileSync(file, "utf8")
|
|
48
|
-
.split("\n")
|
|
49
|
-
.find((line) => line.startsWith("# "));
|
|
50
|
-
return first ? first.slice(2).trim() : "";
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** Every topic, the pages first and then the codes, sorted. */
|
|
29
|
+
/** Every topic of the reference this CLI ships, the pages first and then the codes, sorted. */
|
|
54
30
|
export function docsIndex(dir: string = referenceDir()): DocsTopic[] {
|
|
55
|
-
|
|
56
|
-
const pages: DocsTopic[] = [];
|
|
57
|
-
for (const topic of ["cli", "telemetry"]) {
|
|
58
|
-
const file = join(dir, `${topic}.md`);
|
|
59
|
-
if (existsSync(file))
|
|
60
|
-
pages.push({ topic, title: titleOf(file), url: `${base}/${topic}`, file });
|
|
61
|
-
}
|
|
62
|
-
const errorsDir = join(dir, "errors");
|
|
63
|
-
const codes = existsSync(errorsDir)
|
|
64
|
-
? readdirSync(errorsDir)
|
|
65
|
-
.filter((name) => /^MOSTRA_[A-Z0-9_]+\.md$/.test(name))
|
|
66
|
-
.sort()
|
|
67
|
-
: [];
|
|
68
|
-
const errors: DocsTopic[] = codes.map((name) => {
|
|
69
|
-
const code = name.slice(0, -3);
|
|
70
|
-
const file = join(errorsDir, name);
|
|
71
|
-
return { topic: code, title: titleOf(file), url: `${base}/errors/${code}`, file };
|
|
72
|
-
});
|
|
73
|
-
return [...pages, ...guideTopics(skillDir(), base), ...errors];
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const byName = (a: { name: string }, b: { name: string }): number => (a.name < b.name ? -1 : 1);
|
|
77
|
-
|
|
78
|
-
/** Every file below `root`'s `prefix`, relative to `root`, sorted. */
|
|
79
|
-
function filesBelow(root: string, prefix: string): string[] {
|
|
80
|
-
return readdirSync(join(root, prefix), { withFileTypes: true })
|
|
81
|
-
.sort(byName)
|
|
82
|
-
.flatMap((entry) => {
|
|
83
|
-
const path = `${prefix}/${entry.name}`;
|
|
84
|
-
return entry.isDirectory() ? filesBelow(root, path) : [path];
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* The Skill as topics: `guide` (its SKILL.md), `guide/<name>` for each reference,
|
|
90
|
-
* `guide/<file>` for each asset (the baseline stylesheet), and `guide/examples/<name>` for each
|
|
91
|
-
* example, every file of it.
|
|
92
|
-
*/
|
|
93
|
-
export function guideTopics(dir: string, base: string): DocsTopic[] {
|
|
94
|
-
const skill = join(dir, "SKILL.md");
|
|
95
|
-
if (!existsSync(skill)) return [];
|
|
96
|
-
const topics: DocsTopic[] = [
|
|
97
|
-
{ topic: "guide", title: "Using Mostra", url: `${base}/guide`, file: skill },
|
|
98
|
-
];
|
|
99
|
-
const references = join(dir, "references");
|
|
100
|
-
if (existsSync(references)) {
|
|
101
|
-
for (const name of readdirSync(references)
|
|
102
|
-
.filter((entry) => entry.endsWith(".md"))
|
|
103
|
-
.sort()) {
|
|
104
|
-
const file = join(references, name);
|
|
105
|
-
const slug = name.slice(0, -3);
|
|
106
|
-
topics.push({
|
|
107
|
-
topic: `guide/${slug}`,
|
|
108
|
-
title: titleOf(file),
|
|
109
|
-
url: `${base}/guide/${slug}`,
|
|
110
|
-
file,
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
const assets = join(dir, "assets");
|
|
115
|
-
if (!existsSync(assets)) return topics;
|
|
116
|
-
for (const entry of readdirSync(assets, { withFileTypes: true }).sort(byName)) {
|
|
117
|
-
if (!entry.isFile()) continue;
|
|
118
|
-
topics.push({
|
|
119
|
-
topic: `guide/${entry.name}`,
|
|
120
|
-
title: entry.name,
|
|
121
|
-
url: `${base}/guide/${entry.name}`,
|
|
122
|
-
file: join(assets, entry.name),
|
|
123
|
-
files: [entry.name],
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
const examples = join(assets, "examples");
|
|
127
|
-
if (!existsSync(examples)) return topics;
|
|
128
|
-
for (const entry of readdirSync(examples, { withFileTypes: true }).sort(byName)) {
|
|
129
|
-
if (!entry.isDirectory()) continue;
|
|
130
|
-
const files = filesBelow(assets, `examples/${entry.name}`);
|
|
131
|
-
if (files.length === 0) continue;
|
|
132
|
-
topics.push({
|
|
133
|
-
topic: `guide/examples/${entry.name}`,
|
|
134
|
-
title: `Example: ${entry.name}`,
|
|
135
|
-
url: `${base}/guide/examples/${entry.name}`,
|
|
136
|
-
file: join(assets, files[0] as string),
|
|
137
|
-
files,
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
return topics;
|
|
31
|
+
return indexOf(dir, skillDir());
|
|
141
32
|
}
|
|
142
33
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
/** How the guide's relative links read through the CLI, before each of its pages. */
|
|
153
|
-
export const GUIDE_LINKS: string =
|
|
154
|
-
"> Read through `mostra docs`: a link to `references/<name>.md` is `mostra docs guide/<name>`, `assets/<file>` is `mostra docs guide/<file>`, and `assets/examples/<name>/` is `mostra docs guide/examples/<name>`.";
|
|
155
|
-
|
|
156
|
-
/** The same for the guide read through `mostra mcp` (D164): topics of `docs_search`, or resources. */
|
|
157
|
-
export const MCP_GUIDE_LINKS: string =
|
|
158
|
-
"> Read through Mostra's MCP server: a link to `references/<name>.md` is the topic `guide/<name>`, `assets/<file>` is `guide/<file>`, and `assets/examples/<name>/` is `guide/examples/<name>`; read one with docs_search (`topic`) or the resource `mostra://docs/<topic>`. Where the guide runs a `mostra` command, use the tool of the same step (artifact_verify for `mostra verify`, artifact_wait for `mostra wait`).";
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* A topic's Markdown. A guide page loses its frontmatter and says how its links read (through the
|
|
162
|
-
* CLI by default, or `links`); a guide topic made of files shows each one as code under its path.
|
|
163
|
-
*/
|
|
164
|
-
export function topicMarkdown(
|
|
165
|
-
topic: DocsTopic,
|
|
166
|
-
dir: string = skillDir(),
|
|
167
|
-
links: string = GUIDE_LINKS,
|
|
168
|
-
): string {
|
|
169
|
-
if (topic.files !== undefined) {
|
|
170
|
-
const parts = topic.files.map((path) => {
|
|
171
|
-
const text = readFileSync(join(dir, "assets", path), "utf8");
|
|
172
|
-
const fence = text.includes("```") ? "````" : "```";
|
|
173
|
-
const body = text.endsWith("\n") ? text : `${text}\n`;
|
|
174
|
-
return `## \`${path}\`\n\n${fence}${FENCE_LANGUAGES[extname(path)] ?? ""}\n${body}${fence}\n`;
|
|
175
|
-
});
|
|
176
|
-
return [`# ${topic.title}`, "", links, "", ...parts].join("\n");
|
|
177
|
-
}
|
|
178
|
-
const text = readFileSync(topic.file, "utf8");
|
|
179
|
-
if (topic.topic !== "guide" && !topic.topic.startsWith("guide/")) return text;
|
|
180
|
-
return [links, "", text.replace(/^---\n[\s\S]*?\n---\n+/, "")].join("\n");
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/** The index as Markdown: what `mostra docs` prints without a topic. */
|
|
184
|
-
export function indexMarkdown(topics: readonly DocsTopic[]): string {
|
|
185
|
-
const pages = topics.filter(
|
|
186
|
-
(topic) => !topic.topic.startsWith("MOSTRA_") && !topic.topic.startsWith("guide"),
|
|
187
|
-
);
|
|
188
|
-
const guide = topics.filter(
|
|
189
|
-
(topic) => topic.topic === "guide" || topic.topic.startsWith("guide/"),
|
|
190
|
-
);
|
|
191
|
-
const codes = topics.filter((topic) => topic.topic.startsWith("MOSTRA_"));
|
|
192
|
-
return [
|
|
193
|
-
"# Mostra reference",
|
|
194
|
-
"",
|
|
195
|
-
"Run `mostra docs <topic>` to read one. Diagnostic codes are topics too.",
|
|
196
|
-
"",
|
|
197
|
-
...pages.map((topic) => `- \`${topic.topic}\`: ${topic.title}`),
|
|
198
|
-
"",
|
|
199
|
-
...(guide.length > 0
|
|
200
|
-
? [
|
|
201
|
-
"## Writing artifacts",
|
|
202
|
-
"",
|
|
203
|
-
...guide.map((topic) => `- \`${topic.topic}\`: ${topic.title}`),
|
|
204
|
-
"",
|
|
205
|
-
]
|
|
206
|
-
: []),
|
|
207
|
-
"## Diagnostic codes",
|
|
208
|
-
"",
|
|
209
|
-
...codes.map((topic) => `- \`${topic.topic}\`: ${topic.title}`),
|
|
210
|
-
"",
|
|
211
|
-
].join("\n");
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/** The topics nearest an unknown one, for its usage error. */
|
|
215
|
-
export function nearestTopics(wanted: string, topics: readonly DocsTopic[], count = 3): string[] {
|
|
216
|
-
const target = wanted.toUpperCase();
|
|
217
|
-
const scored = topics.map((topic) => {
|
|
218
|
-
const name = topic.topic.toUpperCase();
|
|
219
|
-
const contains = name.includes(target) || target.includes(name) ? 0 : 1;
|
|
220
|
-
return { topic: topic.topic, score: contains * 100 + distance(name, target) };
|
|
221
|
-
});
|
|
222
|
-
return scored
|
|
223
|
-
.sort((a, b) => a.score - b.score || (a.topic < b.topic ? -1 : 1))
|
|
224
|
-
.slice(0, count)
|
|
225
|
-
.map((item) => item.topic);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/** Levenshtein distance. */
|
|
229
|
-
function distance(a: string, b: string): number {
|
|
230
|
-
const row = Array.from({ length: b.length + 1 }, (_, index) => index);
|
|
231
|
-
for (let i = 1; i <= a.length; i += 1) {
|
|
232
|
-
let previous = row[0] as number;
|
|
233
|
-
row[0] = i;
|
|
234
|
-
for (let j = 1; j <= b.length; j += 1) {
|
|
235
|
-
const current = row[j] as number;
|
|
236
|
-
row[j] = Math.min(
|
|
237
|
-
(row[j] as number) + 1,
|
|
238
|
-
(row[j - 1] as number) + 1,
|
|
239
|
-
previous + (a[i - 1] === b[j - 1] ? 0 : 1),
|
|
240
|
-
);
|
|
241
|
-
previous = current;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return row[b.length] as number;
|
|
245
|
-
}
|
|
34
|
+
export {
|
|
35
|
+
type DocsTopic,
|
|
36
|
+
indexMarkdown,
|
|
37
|
+
MCP_GUIDE_LINKS,
|
|
38
|
+
nearestTopics,
|
|
39
|
+
topicMarkdown,
|
|
40
|
+
} from "@mostra/mcp";
|
package/src/exit.ts
CHANGED
|
@@ -61,6 +61,8 @@ const BY_AREA: Readonly<Record<DiagnosticArea, ExitCode>> = {
|
|
|
61
61
|
CLI: EXIT.usage,
|
|
62
62
|
// A remote server or the link to one: the environment, like a share's tunnel (D165).
|
|
63
63
|
REMOTE: EXIT.environment,
|
|
64
|
+
// A roster or a team wait the artifact can't take (D168): the artifact's, like a refused submit.
|
|
65
|
+
TEAM: EXIT.failure,
|
|
64
66
|
};
|
|
65
67
|
|
|
66
68
|
/** Codes whose exit code isn't their area's. */
|
package/src/mcp.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
|
14
14
|
import {
|
|
15
15
|
createHttpEndpoint,
|
|
16
16
|
createMcpServerFactory,
|
|
17
|
-
|
|
17
|
+
fileDocs,
|
|
18
18
|
localWorkspace,
|
|
19
19
|
MCP_PATH,
|
|
20
20
|
type McpClientInfo,
|
|
@@ -32,7 +32,7 @@ import { resolveRuntime } from "@mostra/sdk";
|
|
|
32
32
|
import { progressReporter } from "./bootstrap.ts";
|
|
33
33
|
import { openInBrowser } from "./browser.ts";
|
|
34
34
|
import { connect, type InstanceConnection } from "./client.ts";
|
|
35
|
-
import {
|
|
35
|
+
import { MCP_GUIDE_LINKS, referenceDir, skillDir } from "./docs.ts";
|
|
36
36
|
import type { Environment } from "./home.ts";
|
|
37
37
|
|
|
38
38
|
/** How long the session with the daemon stays open after the last call. */
|
|
@@ -238,25 +238,7 @@ export function daemonInstance(options: {
|
|
|
238
238
|
|
|
239
239
|
/** The bundled reference (`mostra docs`), read as the MCP server's docs. */
|
|
240
240
|
export function bundledDocs(): McpDocs {
|
|
241
|
-
|
|
242
|
-
const all = (): ReturnType<typeof docsIndex> => {
|
|
243
|
-
topics ??= docsIndex();
|
|
244
|
-
return topics;
|
|
245
|
-
};
|
|
246
|
-
const cache = new Map<string, string>();
|
|
247
|
-
return {
|
|
248
|
-
topics: (): DocsTopicSummary[] =>
|
|
249
|
-
all().map((topic) => ({ topic: topic.topic, title: topic.title, url: topic.url })),
|
|
250
|
-
read(topic) {
|
|
251
|
-
const cached = cache.get(topic);
|
|
252
|
-
if (cached !== undefined) return cached;
|
|
253
|
-
const found = all().find((entry) => entry.topic === topic);
|
|
254
|
-
if (found === undefined) return undefined;
|
|
255
|
-
const markdown = topicMarkdown(found, skillDir(), MCP_GUIDE_LINKS);
|
|
256
|
-
cache.set(topic, markdown);
|
|
257
|
-
return markdown;
|
|
258
|
-
},
|
|
259
|
-
};
|
|
241
|
+
return fileDocs({ referenceDir: referenceDir(), skillDir: skillDir(), links: MCP_GUIDE_LINKS });
|
|
260
242
|
}
|
|
261
243
|
|
|
262
244
|
/** What both transports are given. */
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { t as bootstrap } from "./bootstrap-_iCl_HaO.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap-_iCl_HaO.js","names":[],"sources":["../src/command.ts","../src/exit.ts","../src/parse.ts","../src/bootstrap.ts"],"sourcesContent":["/**\n * What a command is (D140 items 13, 16): a definition the parser, the help, the reference page,\n * `--help --json`, telemetry's command names and the contract tests all read. Commands never\n * print or exit on their own; they return a result (or throw a diagnostic) and the runner decides\n * the envelope, the human text and the exit code.\n */\nimport type { Diagnostic, MethodDefinition } from \"@mostra/protocol\";\nimport type { InstanceConnection } from \"./client.ts\";\n\n/** A flag's value kind. Every flag is `--long`; booleans take no value. */\nexport type FlagKind = \"boolean\" | \"string\" | \"number\" | \"duration\" | \"list\";\n\n/** One flag of a command. */\nexport interface FlagDef {\n /** The flag's name, without the dashes. */\n readonly name: string;\n /** What it takes. */\n readonly kind: FlagKind;\n /** One line for help: what it does. */\n readonly summary: string;\n /** The placeholder in usage and help: `<path>`, `<d>` … */\n readonly value?: string;\n /** The allowed values, for a closed set. */\n readonly choices?: readonly string[];\n /** The default, as help shows it. */\n readonly default?: string;\n}\n\n/** One positional argument. */\nexport interface ArgDef {\n /** The argument's name, as help shows it. */\n readonly name: string;\n /** One line for help: what it is. */\n readonly summary: string;\n /** Whether it may be left out. */\n readonly optional?: boolean;\n /** Whether it takes every remaining word (`<package…>`). */\n readonly variadic?: boolean;\n}\n\n/** What the runner gives a command. */\nexport interface CommandContext {\n /** The positional arguments, after the command path, by name. */\n readonly args: Readonly<Record<string, string | readonly string[] | undefined>>;\n /** The command's flags, parsed by kind (durations in milliseconds, lists as arrays). */\n readonly flags: Readonly<\n Record<string, string | number | boolean | readonly string[] | undefined>\n >;\n /** The working directory relative paths resolve from (`--cwd`, else the process's). */\n readonly cwd: string;\n /** Whether `--json` was given. */\n readonly json: boolean;\n /** The request timeout from `--timeout`, in milliseconds. */\n readonly timeoutMs: number | undefined;\n /** Calls a host protocol method on the home's instance, starting its daemon when needed. */\n call<P, R>(method: MethodDefinition<P, R>, params: P): Promise<R>;\n /** Reads the whole of stdin, for commands that take a value there. */\n readStdin(): Promise<string>;\n /** Writes one line of progress or a log line to stderr (never stdout). */\n log(line: string): void;\n /** Emits one event of a streaming command (an NDJSON line in `--json` mode). */\n emit(event: unknown, human?: string): void;\n /** Adds a warning to the envelope (and stderr). */\n warn(diagnostic: Diagnostic): void;\n /** The environment the CLI runs in. */\n readonly env: Readonly<Record<string, string | undefined>>;\n /** Whether stdout and stdin are terminals. */\n readonly tty: { readonly stdin: boolean; readonly stdout: boolean; readonly stderr: boolean };\n /** The resolved home and the CLI's own facts, for commands that report them. */\n readonly home: string;\n /** Records a telemetry event of this command (D140 item 8), when telemetry allows it. */\n record(event: TelemetryEventInput): void;\n /**\n * Queues the events recorded so far, for a command that runs until it is stopped (`mcp`);\n * `hostInstance` says whether the instance it reached was host-spawned (then nothing is sent).\n */\n checkpoint(hostInstance: boolean): void;\n /**\n * The session with the home's instance, starting its daemon unless `autostart` is false; then\n * `undefined` when none runs. `call` uses the same session.\n */\n connection(autostart?: boolean): Promise<InstanceConnection | undefined>;\n /** Runs the runtime binary (`mostra-runtime …`) and returns its exit code and stdout. */\n runtime(\n args: readonly string[],\n stdio?: \"pipe\" | \"inherit\",\n ): Promise<{ code: number; stdout: string }>;\n /** The CLI's config directory (D140 item 5). */\n readonly configDir: string;\n /** Writes to stderr. */\n readonly stderr: (text: string) => void;\n /** Writes to stdout as the command runs (`host`, `dev`'s stream without `--json`). */\n readonly stdout: (text: string) => void;\n}\n\n/** A command-specific telemetry event: its name and its own fields. */\nexport interface TelemetryEventInput {\n /** The event's name. */\n readonly event: \"verify.result\" | \"publish.done\" | \"share.done\" | \"mcp.session\";\n /** Its own fields; the schema keeps only the published ones. */\n readonly fields: Readonly<Record<string, unknown>>;\n}\n\n/** What a command's run returns. */\nexport interface CommandOutcome {\n /** The `result` of the envelope. */\n readonly result: unknown;\n /** The text for people (stdout); default: the result as indented JSON. */\n readonly human?: string;\n /** The exit code when it isn't 0: a failing verdict (1), `still_waiting` (5), conflicts (6). */\n readonly exit?: number;\n /** The command wrote its own stdout (`host`): the runner prints no envelope and no text. */\n readonly raw?: boolean;\n /** The instance the command reached on a session of its own was host-spawned (`mcp`). */\n readonly hostInstance?: boolean;\n}\n\n/** One command. */\nexport interface CommandDef {\n /** Its words after `mostra`: `[\"daemon\", \"install\"]`. */\n readonly path: readonly string[];\n /** One line: what it does. */\n readonly summary: string;\n /** Its positional arguments, in order. */\n readonly args?: readonly ArgDef[];\n /** Its own flags, besides the global ones. */\n readonly flags?: readonly FlagDef[];\n /** The result type `--json` puts in `result`, and its `mostra docs` topic. */\n readonly output: { readonly type: string; readonly topic: string };\n /** The exit codes it can end with, besides 2 and 3, which every command can. */\n readonly exits: readonly number[];\n /** One example invocation, without `mostra`. */\n readonly example: string;\n /** It reads stdin, so telemetry's question is never asked before it (D140 item 11). */\n readonly readsStdin?: boolean | ((flags: CommandContext[\"flags\"]) => boolean);\n /** It never reaches an instance (`docs`, `telemetry`): no `instance` in its envelope. */\n readonly local?: boolean;\n /** It writes a stream of events before its result (NDJSON in `--json` mode). */\n readonly streams?: boolean;\n /**\n * Telemetry and its question leave it alone (`telemetry`, `docs`, D140 item 11), or, as a\n * function of its flags, when it runs on someone's behalf (`mcp --embedded`, D148).\n */\n readonly quiet?: boolean | ((flags: CommandContext[\"flags\"]) => boolean);\n /** Does the command's work. */\n run(context: CommandContext): Promise<CommandOutcome>;\n}\n\n/** Defines a command; the identity function, for types. */\nexport function defineCommand(command: CommandDef): CommandDef {\n return command;\n}\n\n/** The command path as one string: `daemon install`. */\nexport function commandName(command: Pick<CommandDef, \"path\">): string {\n return command.path.join(\" \");\n}\n","/**\n * The exit codes (INTERFACES §9, D140 item 16): one table keyed by diagnostic code, so every\n * command ends the same way for the same failure. Each area has a code, and a few codes differ\n * from their area; the table is total over the catalog by construction, and a test checks every\n * catalog code against it.\n */\nimport type { DiagnosticArea } from \"@mostra/protocol\";\n\n/** The exit codes of INTERFACES §9. */\nexport const EXIT = {\n /** Success, or `verify` passed. */\n ok: 0,\n /** Artifact failure: verify failed, publish refused, a request the artifact's state refused. */\n failure: 1,\n /** Usage error. */\n usage: 2,\n /** Environment error: no runtime, browser or socket; the home; an unsupported platform. */\n environment: 3,\n /** Timeout: `--timeout` passed before the instance answered. */\n timeout: 4,\n /** `wait` ended `still_waiting`: not an error, the status is in the result. */\n stillWaiting: 5,\n /** Conflict: `once` already submitted, a compare-and-set mismatch, a reused request ID. */\n conflict: 6,\n} as const;\n\n/** One of {@link EXIT}'s codes. */\nexport type ExitCode = (typeof EXIT)[keyof typeof EXIT];\n\n/** Each area's exit code. Every area is here: a new one fails the type check until it is. */\nconst BY_AREA: Readonly<Record<DiagnosticArea, ExitCode>> = {\n MANIFEST: EXIT.failure,\n BUILD: EXIT.failure,\n TYPE: EXIT.failure,\n LINT: EXIT.failure,\n DEP: EXIT.failure,\n KIT: EXIT.failure,\n FIELD: EXIT.failure,\n ACTION: EXIT.failure,\n LIVE: EXIT.failure,\n RUNTIME: EXIT.failure,\n CONSOLE: EXIT.failure,\n NETWORK: EXIT.failure,\n A11Y: EXIT.failure,\n VISUAL: EXIT.failure,\n SMOKE: EXIT.failure,\n REGRESSION: EXIT.failure,\n TERM: EXIT.failure,\n PUBLISH: EXIT.failure,\n SUBMIT: EXIT.failure,\n HOST: EXIT.environment,\n HOME: EXIT.environment,\n HYGIENE: EXIT.failure,\n SECRET: EXIT.failure,\n SHARE: EXIT.environment,\n VERIFY: EXIT.failure,\n TARGET: EXIT.failure,\n ENV: EXIT.environment,\n PLATFORM: EXIT.environment,\n ARTIFACT: EXIT.failure,\n CLI: EXIT.usage,\n // A remote server or the link to one: the environment, like a share's tunnel (D165).\n REMOTE: EXIT.environment,\n};\n\n/** Codes whose exit code isn't their area's. */\nconst BY_CODE: Readonly<Record<string, ExitCode>> = {\n MOSTRA_HOST_TIMEOUT: EXIT.timeout,\n // The CLI can't record a choice: its environment, not its command line.\n MOSTRA_CLI_CONFIG_UNWRITABLE: EXIT.environment,\n MOSTRA_HOST_INVALID_PARAMS: EXIT.usage,\n MOSTRA_HOST_REQUEST_ID_REUSED: EXIT.conflict,\n MOSTRA_HOST_CURSOR_COMPACTED: EXIT.failure,\n MOSTRA_HOST_SUBSCRIPTION_UNKNOWN: EXIT.usage,\n MOSTRA_SUBMIT_ALREADY: EXIT.conflict,\n MOSTRA_SUBMIT_REVISION_MOVED: EXIT.conflict,\n MOSTRA_FIELD_CONFLICT: EXIT.conflict,\n MOSTRA_FIELD_MUTATION_ID_REUSED: EXIT.conflict,\n MOSTRA_PUBLISH_ID_CONFLICT: EXIT.failure,\n MOSTRA_HOME_INTEGRITY: EXIT.failure,\n MOSTRA_HOME_NOT_ALWAYS_ON: EXIT.ok,\n MOSTRA_VERIFY_CRASHED: EXIT.environment,\n};\n\n/** The exit code a diagnostic ends a command with. An unknown area is an environment error. */\nexport function exitCodeFor(code: string): ExitCode {\n const exact = BY_CODE[code];\n if (exact !== undefined) return exact;\n const area = /^MOSTRA_([A-Z0-9]+)_/.exec(code)?.[1];\n return (area !== undefined ? BY_AREA[area as DiagnosticArea] : undefined) ?? EXIT.environment;\n}\n","/**\n * The command line, read against the command definitions (D140 item 13): the global flags, the\n * command path, its arguments and flags. Every failure is `MOSTRA_CLI_USAGE` or\n * `MOSTRA_CLI_UNKNOWN_COMMAND`, so `--json` mode reports it like any other error.\n */\nimport { parseArgs } from \"node:util\";\nimport { createDiagnostic, RpcError } from \"@mostra/protocol\";\nimport { type CommandDef, commandName, type FlagDef } from \"./command.ts\";\n\n/** The flags every command takes (INTERFACES §9). */\nexport const GLOBAL_FLAGS: readonly FlagDef[] = [\n {\n name: \"json\",\n kind: \"boolean\",\n summary: \"Print one JSON envelope on stdout (NDJSON for streams).\",\n },\n {\n name: \"home\",\n kind: \"string\",\n value: \"<dir>\",\n summary: \"Use this Mostra home instead of MOSTRA_HOME or the default.\",\n },\n {\n name: \"cwd\",\n kind: \"string\",\n value: \"<dir>\",\n summary: \"Resolve relative paths from this directory.\",\n },\n {\n name: \"timeout\",\n kind: \"duration\",\n value: \"<d>\",\n summary: \"Give up on the instance after this long (exit 4), such as 30s or 5m.\",\n },\n {\n name: \"help\",\n kind: \"boolean\",\n summary: \"Show this command's help; with --json, its definition.\",\n },\n];\n\n/** What the command line asks for. */\nexport type Parsed =\n | { readonly kind: \"version\" }\n | { readonly kind: \"help\"; readonly command?: CommandDef; readonly group?: string }\n | {\n readonly kind: \"run\";\n readonly command: CommandDef;\n readonly args: Record<string, string | readonly string[] | undefined>;\n readonly flags: Record<string, string | number | boolean | readonly string[] | undefined>;\n };\n\n/** The global flags' values, read before anything else so a usage error still honors them. */\nexport interface GlobalFlags {\n readonly json: boolean;\n readonly home?: string;\n readonly cwd?: string;\n readonly timeoutMs?: number;\n}\n\n/** A usage error. */\nexport function usage(message: string): RpcError {\n return new RpcError(createDiagnostic(\"MOSTRA_CLI_USAGE\", { message }));\n}\n\nconst DURATION = /^([1-9][0-9]*)(ms|s|m|h|d)$/;\nconst UNIT_MS: Readonly<Record<string, number>> = {\n ms: 1,\n s: 1000,\n m: 60_000,\n h: 3_600_000,\n d: 86_400_000,\n};\n\n/** A duration flag's milliseconds: `30s`, `5m`, `2h`, `7d`, `500ms`. */\nexport function durationMs(value: string): number {\n const match = DURATION.exec(value);\n if (!match)\n throw usage(`\"${value}\" isn't a duration; use a number with ms, s, m, h or d, such as 30s.`);\n return Number(match[1]) * (UNIT_MS[match[2] as string] as number);\n}\n\n/**\n * Reads the global flags wherever they stand, before the command is known: `--json` anywhere\n * before `--` makes even a usage error a JSON envelope (D140 item 16).\n */\nexport function globalFlags(argv: readonly string[]): GlobalFlags {\n const end = argv.indexOf(\"--\");\n const words = end === -1 ? argv : argv.slice(0, end);\n const value = (name: string): string | undefined => {\n for (let index = 0; index < words.length; index += 1) {\n const word = words[index] as string;\n if (word === `--${name}`) return words[index + 1];\n if (word.startsWith(`--${name}=`)) return word.slice(name.length + 3);\n }\n return undefined;\n };\n const timeout = value(\"timeout\");\n let timeoutMs: number | undefined;\n try {\n timeoutMs = timeout === undefined ? undefined : durationMs(timeout);\n } catch {\n timeoutMs = undefined;\n }\n const home = value(\"home\");\n const cwd = value(\"cwd\");\n return {\n json: words.includes(\"--json\"),\n ...(home !== undefined ? { home } : {}),\n ...(cwd !== undefined ? { cwd } : {}),\n ...(timeoutMs !== undefined ? { timeoutMs } : {}),\n };\n}\n\n/** The command that names `words`' longest prefix. */\nfunction findCommand(\n commands: readonly CommandDef[],\n words: readonly string[],\n): { command: CommandDef; used: number } | undefined {\n let best: { command: CommandDef; used: number } | undefined;\n for (const command of commands) {\n const { path } = command;\n if (path.length <= words.length && path.every((word, index) => words[index] === word)) {\n if (!best || path.length > best.used) best = { command, used: path.length };\n }\n }\n return best;\n}\n\n/** The first words of every command: the groups and the single-word commands. */\nexport function topWords(commands: readonly CommandDef[]): string[] {\n return [...new Set(commands.map((command) => command.path[0] as string))].sort();\n}\n\n/**\n * The command path's candidates: the leading words that aren't flags, with the global flags (and\n * their values) that may stand before them skipped, and where each stands in `argv`.\n */\nfunction leadingWords(argv: readonly string[]): { words: string[]; pathAt: number[] } {\n const words: string[] = [];\n const pathAt: number[] = [];\n for (let index = 0; index < argv.length; index += 1) {\n const word = argv[index] as string;\n if (word === \"--json\" || word === \"--help\" || word === \"-h\") continue;\n if (word === \"--home\" || word === \"--cwd\" || word === \"--timeout\") {\n index += 1;\n continue;\n }\n if (/^--(home|cwd|timeout)=/.test(word)) continue;\n if (word.startsWith(\"-\")) break;\n words.push(word);\n pathAt.push(index);\n }\n return { words, pathAt };\n}\n\n/** The words a command line starts its command with (`[\"mcp\"]`, `[\"share\", \"stop\", …]`). */\nexport function commandWords(argv: readonly string[]): string[] {\n return leadingWords(argv).words;\n}\n\n/** Parses the command line against the definitions. Throws a usage diagnostic. */\nexport function parseCommandLine(commands: readonly CommandDef[], argv: readonly string[]): Parsed {\n const bare = argv.filter((word) => word !== \"--json\");\n if (bare.length === 1 && (bare[0] === \"--version\" || bare[0] === \"-v\"))\n return { kind: \"version\" };\n // The command path is the leading words that aren't flags; global flags may stand before it.\n const { words, pathAt } = leadingWords(argv);\n const helpAsked = argv.includes(\"--help\") || argv.includes(\"-h\");\n if (words.length === 0) {\n if (helpAsked || argv.every((word) => word === \"--json\")) return { kind: \"help\" };\n throw usage(`Name a command first; ${argv[0]} isn't one.`);\n }\n const found = findCommand(commands, words);\n if (!found) {\n const group = commands.filter((command) => command.path[0] === words[0]);\n if (group.length > 0) {\n if (helpAsked) return { kind: \"help\", group: words[0] as string };\n throw usage(\n `\"mostra ${words[0]}\" needs one of: ${group.map((command) => command.path.slice(1).join(\" \")).join(\", \")}.`,\n );\n }\n throw new RpcError(\n createDiagnostic(\"MOSTRA_CLI_UNKNOWN_COMMAND\", {\n message: `\"${words[0]}\" isn't a mostra command. The commands are: ${topWords(commands).join(\", \")}.`,\n }),\n );\n }\n const { command } = found;\n if (helpAsked) return { kind: \"help\", command };\n const used = new Set(pathAt.slice(0, found.used));\n const rest = argv.filter((_, index) => !used.has(index));\n const flagDefs = [...GLOBAL_FLAGS, ...(command.flags ?? [])];\n let parsed: ReturnType<typeof parseArgs>;\n try {\n parsed = parseArgs({\n args: [...rest],\n allowPositionals: true,\n strict: true,\n options: Object.fromEntries(\n flagDefs.map((flag) => [\n flag.name,\n { type: flag.kind === \"boolean\" ? \"boolean\" : \"string\" },\n ]),\n ) as Parameters<typeof parseArgs>[0] extends { options?: infer O } ? NonNullable<O> : never,\n });\n } catch (error) {\n throw usage(\n `${(error as Error).message.split(\". To specify\")[0]}. Run \"mostra ${commandName(command)} --help\".`,\n );\n }\n const flags: Record<string, string | number | boolean | readonly string[] | undefined> = {};\n for (const flag of command.flags ?? []) {\n const raw = parsed.values[flag.name];\n if (raw === undefined) continue;\n if (flag.kind === \"boolean\") {\n flags[flag.name] = raw === true;\n continue;\n }\n const text = String(raw);\n if (flag.choices && !flag.choices.includes(text)) {\n throw usage(`--${flag.name} takes one of ${flag.choices.join(\", \")}; \"${text}\" isn't one.`);\n }\n if (flag.kind === \"number\") {\n const number = Number(text);\n if (!Number.isInteger(number) || number < 0)\n throw usage(`--${flag.name} takes a whole number; \"${text}\" isn't one.`);\n flags[flag.name] = number;\n } else if (flag.kind === \"duration\") {\n durationMs(text);\n flags[flag.name] = text;\n } else if (flag.kind === \"list\") {\n flags[flag.name] = text\n .split(\",\")\n .map((item) => item.trim())\n .filter((item) => item.length > 0);\n } else flags[flag.name] = text;\n }\n const positionals = [...parsed.positionals];\n const args: Record<string, string | readonly string[] | undefined> = {};\n for (const arg of command.args ?? []) {\n if (arg.variadic) {\n if (positionals.length === 0 && !arg.optional)\n throw usage(`\"mostra ${commandName(command)}\" needs <${arg.name}…>.`);\n args[arg.name] = positionals.splice(0);\n continue;\n }\n const value = positionals.shift();\n if (value === undefined && !arg.optional)\n throw usage(`\"mostra ${commandName(command)}\" needs <${arg.name}>.`);\n args[arg.name] = value;\n }\n if (positionals.length > 0) {\n throw usage(\n `\"mostra ${commandName(command)}\" takes no argument \"${positionals[0]}\". Run \"mostra ${commandName(command)} --help\".`,\n );\n }\n if (typeof parsed.values[\"timeout\"] === \"string\") durationMs(parsed.values[\"timeout\"]);\n return { kind: \"run\", command, args, flags };\n}\n","/**\n * The npm bootstrap (RT-01, D142): a `mostra` installed from npm runs on whatever Node.js the\n * system has, so before anything else it finds the runtime bundle its release pins (from the\n * cache, or downloaded once, with progress on stderr) and runs the bundle's own `mostra` with the\n * same arguments on the bundle's private Node.js. Every command, telemetry included, then runs in\n * the bundle, and this process only waits and passes the exit code on.\n *\n * Inside a bundle, in a development checkout, or with `MOSTRA_BUNDLE`/`MOSTRA_RUNTIME_BIN` set,\n * there is nothing to bootstrap and the CLI runs in this process.\n *\n * This module runs on the system's Node.js, so it uses nothing newer than Node.js 22.19 and loads\n * none of the CLI's commands.\n */\nimport { spawn } from \"node:child_process\";\nimport { constants } from \"node:os\";\nimport { createDiagnostic, type Diagnostic, RpcError } from \"@mostra/protocol\";\nimport { enclosingBundle, type InstallProgress, readPins, resolveRuntime } from \"@mostra/sdk\";\nimport { exitCodeFor } from \"./exit.ts\";\nimport type { Environment } from \"./home.ts\";\nimport { commandWords } from \"./parse.ts\";\n\n/** How the bootstrap talks to the terminal. */\nexport interface BootstrapIo {\n readonly argv: readonly string[];\n readonly env: Environment;\n readonly stdout: (text: string) => void;\n readonly stderr: (text: string) => void;\n /** Whether stderr is a terminal: progress then rewrites one line. */\n readonly stderrTty: boolean;\n /**\n * Whether a terminal is attached (stdin, stdout or stderr is one). Ctrl-C there signals the\n * whole foreground process group, the bundle's `mostra` included, so SIGINT isn't forwarded:\n * a second one would cut short a command that stops gracefully on the first (`mostra dev`).\n */\n readonly terminal: boolean;\n}\n\n/** Whether this CLI should move into its pinned bundle before running a command. */\nexport function needsBootstrap(env: Environment): boolean {\n if (env[\"MOSTRA_BUNDLE\"] || env[\"MOSTRA_RUNTIME_BIN\"]) return false;\n if (enclosingBundle() !== undefined) return false;\n return readPins(env) !== undefined;\n}\n\n/**\n * Whether the command serves in this process instead of in the bundle (D164 item 7): `mostra mcp`\n * answers its client at once and installs the bundle in the background, since a client gives a\n * server only seconds to start (Codex 10 s) and a first install takes minutes.\n */\nexport function servesBeforeBundle(argv: readonly string[]): boolean {\n return commandWords(argv)[0] === \"mcp\";\n}\n\n/** Progress lines for a person waiting on the first download. */\nexport function progressReporter(\n io: Pick<BootstrapIo, \"stderr\" | \"stderrTty\">,\n): (progress: InstallProgress) => void {\n let lastPercent = -1;\n let lastStep = \"\";\n return (progress) => {\n if (progress.step === \"download\") {\n const percent = Math.floor((progress.received / progress.total) * 100);\n const mb = (bytes: number): string => `${Math.round(bytes / 1e6)} MB`;\n if (io.stderrTty) {\n if (percent !== lastPercent)\n io.stderr(\n `\\rmostra: downloading the Mostra runtime, ${mb(progress.received)} of ${mb(progress.total)} (${percent}%)`,\n );\n } else if (\n lastStep !== \"download\" ||\n Math.floor(percent / 25) > Math.floor(lastPercent / 25)\n ) {\n io.stderr(`mostra: downloading the Mostra runtime (${mb(progress.total)}): ${percent}%\\n`);\n }\n lastPercent = percent;\n lastStep = \"download\";\n return;\n }\n if (progress.step === lastStep) return;\n if (lastStep === \"download\" && io.stderrTty) io.stderr(\"\\n\");\n lastStep = progress.step;\n const words: Partial<Record<InstallProgress[\"step\"], string>> = {\n files: \"checking the runtime's files\",\n browser: \"fetching the browser verify uses\",\n };\n const said = words[progress.step];\n if (said !== undefined) io.stderr(`mostra: ${said}…\\n`);\n };\n}\n\n/** The envelope `--json` promises, for a bootstrap that fails before any command runs. */\nfunction failed(io: BootstrapIo, diagnostic: Diagnostic): number {\n io.stderr(`mostra: ${diagnostic.message}\\n`);\n if (diagnostic.hint) io.stderr(`mostra: ${diagnostic.hint}\\n`);\n if (io.argv.includes(\"--json\")) {\n io.stdout(`${JSON.stringify({ ok: false, error: diagnostic, warnings: [] })}\\n`);\n }\n return exitCodeFor(diagnostic.code);\n}\n\n/**\n * When this copy needs the bundle its release pins (`needsBootstrap`), runs the bundle's\n * `mostra` with `io.argv` and resolves with its exit code; otherwise, or for `mostra mcp`, which\n * installs the bundle itself while it serves (`servesBeforeBundle`), resolves `undefined`, and the\n * caller runs the command itself. Any failure, deciding included, is a diagnostic (one envelope\n * with `--json`) and its exit code. Signals this process gets are passed on to the child.\n */\nexport async function bootstrap(io: BootstrapIo): Promise<number | undefined> {\n try {\n // Deciding is inside the boundary too: pins that can't be read are a diagnostic, never a\n // stack trace (GPT review finding 3).\n if (!needsBootstrap(io.env) || servesBeforeBundle(io.argv)) return undefined;\n return await runInBundle(io);\n } catch (error) {\n // Whatever goes wrong, `--json` still gets exactly one envelope (D140 item 16).\n if (error instanceof RpcError) return failed(io, error.diagnostic);\n return failed(\n io,\n createDiagnostic(\"MOSTRA_HOST_INTERNAL_ERROR\", {\n message: `The npm bootstrap failed: ${error instanceof Error ? error.message : String(error)}`,\n }),\n );\n }\n}\n\nasync function runInBundle(io: BootstrapIo): Promise<number> {\n const runtime = await resolveRuntime({ env: io.env, onProgress: progressReporter(io) });\n if (runtime.cliEntry === undefined) {\n throw new RpcError(\n createDiagnostic(\"MOSTRA_ENV_RUNTIME_MISSING\", {\n message: \"The runtime the bootstrap found has no CLI entry.\",\n }),\n );\n }\n const cli = runtime.cliEntry;\n return new Promise((resolve) => {\n const child = spawn(runtime.node, [cli, ...io.argv], {\n stdio: \"inherit\",\n env: io.env as NodeJS.ProcessEnv,\n });\n const forward = (signal: NodeJS.Signals): void => {\n if (signal === \"SIGINT\" && io.terminal) return; // the child got the terminal's own\n child.kill(signal);\n };\n const signals: NodeJS.Signals[] = [\"SIGINT\", \"SIGTERM\", \"SIGHUP\"];\n for (const signal of signals) process.on(signal, forward);\n let settled = false;\n const settle = (code: number): void => {\n if (settled) return;\n settled = true;\n for (const signal of signals) process.off(signal, forward);\n resolve(code);\n };\n child.on(\"error\", (error) =>\n settle(\n failed(\n io,\n createDiagnostic(\"MOSTRA_ENV_RUNTIME_MISSING\", {\n message: `The runtime bundle's CLI couldn't be started (${runtime.node}): ${error.message}`,\n }),\n ),\n ),\n );\n // A child ended by a signal exits as a shell reports it: 128 plus the signal's number.\n child.on(\"exit\", (code, signal) =>\n settle(code ?? 128 + (signal ? (constants.signals[signal] ?? 0) : 0)),\n );\n });\n}\n"],"mappings":";;;;;;;AAqJA,SAAgB,cAAc,SAAiC;CAC7D,OAAO;AACT;;AAGA,SAAgB,YAAY,SAA2C;CACrE,OAAO,QAAQ,KAAK,KAAK,GAAG;AAC9B;;;;ACnJA,MAAa,OAAO;;CAElB,IAAI;;CAEJ,SAAS;;CAET,OAAO;;CAEP,aAAa;;CAEb,SAAS;;CAET,cAAc;;CAEd,UAAU;AACZ;;AAMA,MAAM,UAAsD;CAC1D,UAAU,KAAK;CACf,OAAO,KAAK;CACZ,MAAM,KAAK;CACX,MAAM,KAAK;CACX,KAAK,KAAK;CACV,KAAK,KAAK;CACV,OAAO,KAAK;CACZ,QAAQ,KAAK;CACb,MAAM,KAAK;CACX,SAAS,KAAK;CACd,SAAS,KAAK;CACd,SAAS,KAAK;CACd,MAAM,KAAK;CACX,QAAQ,KAAK;CACb,OAAO,KAAK;CACZ,YAAY,KAAK;CACjB,MAAM,KAAK;CACX,SAAS,KAAK;CACd,QAAQ,KAAK;CACb,MAAM,KAAK;CACX,MAAM,KAAK;CACX,SAAS,KAAK;CACd,QAAQ,KAAK;CACb,OAAO,KAAK;CACZ,QAAQ,KAAK;CACb,QAAQ,KAAK;CACb,KAAK,KAAK;CACV,UAAU,KAAK;CACf,UAAU,KAAK;CACf,KAAK,KAAK;CAEV,QAAQ,KAAK;AACf;;AAGA,MAAM,UAA8C;CA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