@mostra/cli 0.11.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.
@@ -1,9 +1,9 @@
1
- import { a as GLOBAL_FLAGS, c as parseCommandLine, d as EXIT, f as exitCodeFor, l as topWords, m as defineCommand, o as durationMs, p as commandName, r as progressReporter, s as globalFlags, u as usage } from "./bootstrap-_iCl_HaO.js";
2
- import { _ as packageRoot, a as detachedEnvironment, c as durationBucket, d as mcpSessionFields, f as buildEndpoint, g as fromSource, h as cliVersion, i as detachedDirectory, l as minute, m as truthy, n as startFlusher, o as TelemetryEvent, p as decide, r as TelemetryStore, s as catalogCodes, u as detectHarness } from "./flush-D648gCYs.js";
1
+ import { a as GLOBAL_FLAGS, c as parseCommandLine, d as EXIT, f as exitCodeFor, l as topWords, m as defineCommand, o as durationMs, p as commandName, r as progressReporter, s as globalFlags, u as usage } from "./bootstrap-3_Tdfdg7.js";
2
+ import { _ as packageRoot, a as detachedEnvironment, c as durationBucket, d as mcpSessionFields, f as buildEndpoint, g as fromSource, h as cliVersion, i as detachedDirectory, l as minute, m as truthy, n as startFlusher, o as TelemetryEvent, p as decide, r as TelemetryStore, s as catalogCodes, u as detectHarness } from "./flush-TPaIdwjy.js";
3
3
  import { spawn } from "node:child_process";
4
4
  import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, readlinkSync, rmSync, statSync, writeFileSync } from "node:fs";
5
5
  import { isAbsolute, join, resolve, win32 } from "node:path";
6
- import { ARTIFACT_PROGRESS, CLI_CLIENT_NAME, DEFAULT_DOCS_BASE, DEV_NOTIFY, FieldOp, HOST_PROTOCOL_REVISIONS, LineSplitter, MutationId, RpcError, RpcPeer, artifactCreateMethod, artifactExportMethod, artifactGetMethod, artifactImportMethod, artifactListMethod, artifactPauseMethod, artifactPublishMethod, artifactVerifyMethod, createDiagnostic, depsAddMethod, devStartMethod, devStopMethod, diagnosticCatalog, encodeLine, gcRunMethod, instanceCheckMethod, instanceStatusMethod, livePushMethod, mostraInitializeMethod, mostraShutdownMethod, remoteLinkMethod, remoteLoginMethod, remoteLoginWaitMethod, remoteLogoutMethod, resultsGetMethod, secretDeleteMethod, secretListMethod, secretSetMethod, shareListMethod, shareStartMethod, shareStopMethod, stateGetMethod, statePatchMethod, viewDefaultMethod, viewLaunchMethod, viewRevokeMethod, viewRotateMethod, viewUrlMethod, waitMethod } from "@mostra/protocol";
6
+ import { ARTIFACT_PROGRESS, CLI_CLIENT_NAME, DEFAULT_DOCS_BASE, DEV_NOTIFY, FieldOp, HOST_PROTOCOL_REVISIONS, LineSplitter, MutationId, RESULTS_LIST_MAX, RespondentSpec, RpcError, RpcPeer, artifactCreateMethod, artifactExportMethod, artifactGetMethod, artifactImportMethod, artifactListMethod, artifactPauseMethod, artifactPublishMethod, artifactVerifyMethod, createDiagnostic, depsAddMethod, devStartMethod, devStopMethod, diagnosticCatalog, encodeLine, gcRunMethod, instanceCheckMethod, instanceStatusMethod, livePushMethod, mostraInitializeMethod, mostraShutdownMethod, remoteLinkMethod, remoteLoginMethod, remoteLoginWaitMethod, remoteLogoutMethod, resultsGetMethod, resultsListMethod, rosterAddMethod, rosterGetMethod, rosterRemoveMethod, secretDeleteMethod, secretListMethod, secretSetMethod, shareListMethod, shareStartMethod, shareStopMethod, stateGetMethod, statePatchMethod, viewDefaultMethod, viewLaunchMethod, viewRevokeMethod, viewRotateMethod, viewUrlMethod, waitMethod } from "@mostra/protocol";
7
7
  import { checkBrowser, checkFiles, connectControl, enclosingBundle, readBundle, readSetup, resolveRuntime } from "@mostra/sdk";
8
8
  import { MCP_GUIDE_LINKS, MCP_PATH, createHttpEndpoint, createMcpServerFactory, defaultWorkspaceRoot, docsIndex, fileDocs, indexMarkdown, localWorkspace, nearestTopics, topicMarkdown } from "@mostra/mcp";
9
9
  import { homedir, tmpdir } from "node:os";
@@ -2458,7 +2458,7 @@ const waitCommand = defineCommand({
2458
2458
  name: "until",
2459
2459
  kind: "string",
2460
2460
  value: "<condition>",
2461
- summary: "submitted, signal:<name>, state:<fieldId> or event:<type>."
2461
+ summary: "submitted, submitted:all (every expected respondent), submitted:<N>, signal:<name>, state:<fieldId> or event:<type>."
2462
2462
  },
2463
2463
  {
2464
2464
  name: "after",
@@ -2523,18 +2523,32 @@ const resultsCommand = defineCommand({
2523
2523
  name: "artifact",
2524
2524
  summary: "The artifact: its source path or its ID."
2525
2525
  }],
2526
- flags: [{
2527
- name: "submission",
2528
- kind: "string",
2529
- value: "<id>",
2530
- summary: "This submission instead of the latest."
2531
- }, {
2532
- name: "format",
2533
- kind: "string",
2534
- value: "<format>",
2535
- choices: ["md", "json"],
2536
- summary: "Markdown or JSON. Default: Markdown, or JSON with --json."
2537
- }],
2526
+ flags: [
2527
+ {
2528
+ name: "submission",
2529
+ kind: "string",
2530
+ value: "<id>",
2531
+ summary: "This submission instead of the latest."
2532
+ },
2533
+ {
2534
+ name: "all",
2535
+ kind: "boolean",
2536
+ summary: "Every submission, oldest first (a survey's, a team's), instead of the latest."
2537
+ },
2538
+ {
2539
+ name: "after",
2540
+ kind: "string",
2541
+ value: "<cursor>",
2542
+ summary: "With --all, only submissions after this cursor."
2543
+ },
2544
+ {
2545
+ name: "format",
2546
+ kind: "string",
2547
+ value: "<format>",
2548
+ choices: ["md", "json"],
2549
+ summary: "Markdown or JSON. Default: Markdown, or JSON with --json."
2550
+ }
2551
+ ],
2538
2552
  output: {
2539
2553
  type: "Results",
2540
2554
  topic: "cli"
@@ -2544,8 +2558,34 @@ const resultsCommand = defineCommand({
2544
2558
  async run(context) {
2545
2559
  const format = flag(context, "format") ?? (context.json ? "json" : "md");
2546
2560
  const submission = flag(context, "submission");
2561
+ const artifactArg = artifactRef(arg(context, "artifact"), context.cwd);
2562
+ if (context.flags["all"] === true) {
2563
+ if (submission !== void 0) throw usage("--all reads every submission: drop --submission.");
2564
+ const results = [];
2565
+ let after = flag(context, "after");
2566
+ for (;;) {
2567
+ const page = await context.call(resultsListMethod, {
2568
+ artifact: artifactArg,
2569
+ format,
2570
+ limit: RESULTS_LIST_MAX,
2571
+ ...after !== void 0 ? { after } : {}
2572
+ });
2573
+ results.push(...page.results);
2574
+ after = page.cursor;
2575
+ if (!page.more) break;
2576
+ }
2577
+ const human = format === "md" ? results.length === 0 ? "No submissions.\n" : `${results.map((one) => one.markdown.trimEnd()).join("\n\n---\n\n")}\n` : pretty(results);
2578
+ return {
2579
+ result: {
2580
+ results,
2581
+ cursor: after
2582
+ },
2583
+ human
2584
+ };
2585
+ }
2586
+ if (flag(context, "after") !== void 0) throw usage("--after reads from a cursor with --all.");
2547
2587
  const result = await context.call(resultsGetMethod, {
2548
- artifact: artifactRef(arg(context, "artifact"), context.cwd),
2588
+ artifact: artifactArg,
2549
2589
  format,
2550
2590
  ...submission !== void 0 ? { submission } : {}
2551
2591
  });
@@ -3828,6 +3868,12 @@ const shareCommand = defineCommand({
3828
3868
  value: "<name>",
3829
3869
  summary: "The display name of --viewer."
3830
3870
  },
3871
+ {
3872
+ name: "respondent",
3873
+ kind: "list",
3874
+ value: "<ref,…>",
3875
+ summary: "With --cloud, the people you expect answers from, by your own key for each: each gets a personal link (mostra roster)."
3876
+ },
3831
3877
  {
3832
3878
  name: "request-id",
3833
3879
  kind: "string",
@@ -3862,6 +3908,9 @@ const shareCommand = defineCommand({
3862
3908
  const viewerName = flag(context, "viewer-name");
3863
3909
  const requestId = flag(context, "request-id");
3864
3910
  if (viewerName !== void 0 && viewerRef === void 0) throw usage("--viewer-name needs --viewer.");
3911
+ const respondents = context.flags["respondent"];
3912
+ if (respondents !== void 0 && !cloud) throw usage("--respondent names people on a hosted share: add --cloud, or use mostra roster add.");
3913
+ if (respondents !== void 0 && viewerRef !== void 0) throw usage("Give --viewer for one person's link, or --respondent for each one's: not both.");
3865
3914
  const share = await context.call(shareStartMethod, {
3866
3915
  artifact,
3867
3916
  via,
@@ -3872,16 +3921,18 @@ const shareCommand = defineCommand({
3872
3921
  ref: viewerRef,
3873
3922
  ...viewerName !== void 0 ? { name: viewerName } : {}
3874
3923
  } } : {},
3924
+ ...respondents !== void 0 ? { respondents: respondents.map((ref) => ({ ref })) } : {},
3875
3925
  ...requestId !== void 0 ? { requestId } : {}
3876
3926
  });
3877
3927
  context.record({
3878
3928
  event: "share.done",
3879
3929
  fields: { kind: via }
3880
3930
  });
3931
+ const personal = (share.respondents ?? []).map((entry) => `${entry.ref} ${entry.link.url}\n`);
3881
3932
  const until = share.expiresAt ? `until ${share.expiresAt}` : "until you stop it";
3882
3933
  return {
3883
3934
  result: share,
3884
- human: `${share.url}\nShared through ${THROUGH[via]}, ${until}.\n${via === "tailnet" ? tailnetReach(share) : ""}Stop it with: mostra share stop ${share.shareId}\n`
3935
+ human: `${share.url}\nShared through ${THROUGH[via]}, ${until}.\n${via === "tailnet" ? tailnetReach(share) : ""}${personal.length > 0 ? `Personal links:\n${personal.join("")}` : ""}Stop it with: mostra share stop ${share.shareId}\n`
3885
3936
  };
3886
3937
  }
3887
3938
  });
@@ -3942,6 +3993,181 @@ const shareListCommand = defineCommand({
3942
3993
  }
3943
3994
  });
3944
3995
  //#endregion
3996
+ //#region src/commands/team.ts
3997
+ /**
3998
+ * Teams (D121, D168): `roster get|add|remove`, thin clients of `roster/*`. A respondent is named by
3999
+ * the caller's own stable key for them (`ref`, an email or an account ID) and gets a personal link
4000
+ * that acts as them; `mostra wait --until submitted:all` waits for every one of them.
4001
+ */
4002
+ /** One line per respondent and the round's tally: what `roster get` prints. */
4003
+ function rosterText(roster) {
4004
+ const { counts } = roster;
4005
+ const head = counts.total === 0 ? "No expected respondents.\n" : `Round ${roster.round}: ${counts.submitted} of ${counts.total} submitted, ${counts.drafting} drafting, ${counts.notOpened} not opened${roster.complete ? " (complete)" : ""}.\n`;
4006
+ const width = Math.max(0, ...roster.respondents.map((one) => one.ref.length));
4007
+ return `${head}${roster.respondents.map((one) => ` ${one.status.padEnd(10)} ${one.ref.padEnd(width)}${one.name !== void 0 ? ` ${one.name}` : ""}\n`).join("")}`;
4008
+ }
4009
+ /** `mostra roster get <artifact>`. */
4010
+ const rosterGetCommand = defineCommand({
4011
+ path: ["roster", "get"],
4012
+ summary: "Show who an artifact expects answers from and where each stands: not opened, drafting or submitted.",
4013
+ args: [{
4014
+ name: "artifact",
4015
+ summary: "The artifact: its source path or its ID."
4016
+ }],
4017
+ output: {
4018
+ type: "Roster",
4019
+ topic: "cli"
4020
+ },
4021
+ exits: [EXIT.failure],
4022
+ example: "roster get ./retro",
4023
+ async run(context) {
4024
+ const result = await context.call(rosterGetMethod, { artifact: artifactRef(arg(context, "artifact"), context.cwd) });
4025
+ return {
4026
+ result,
4027
+ human: rosterText(result)
4028
+ };
4029
+ }
4030
+ });
4031
+ /** `mostra roster add <artifact> [ref…]`. */
4032
+ const rosterAddCommand = defineCommand({
4033
+ path: ["roster", "add"],
4034
+ summary: "Name the people an artifact expects answers from; each gets a personal link that acts as them.",
4035
+ args: [{
4036
+ name: "artifact",
4037
+ summary: "The artifact: its source path or its ID."
4038
+ }, {
4039
+ name: "ref",
4040
+ summary: "Each respondent, by your own stable key for them (an email, an account ID).",
4041
+ optional: true,
4042
+ variadic: true
4043
+ }],
4044
+ flags: [
4045
+ {
4046
+ name: "name",
4047
+ kind: "string",
4048
+ value: "<name>",
4049
+ summary: "The display name of the one respondent given."
4050
+ },
4051
+ {
4052
+ name: "email",
4053
+ kind: "string",
4054
+ value: "<address>",
4055
+ summary: "Where a remote server that sends invitations writes to the one respondent given."
4056
+ },
4057
+ {
4058
+ name: "file",
4059
+ kind: "string",
4060
+ value: "<path>",
4061
+ summary: "Read respondents from a JSON file: [{ ref, name?, email? }]."
4062
+ },
4063
+ {
4064
+ name: "stdin",
4065
+ kind: "boolean",
4066
+ summary: "Read respondents as JSON from stdin."
4067
+ },
4068
+ {
4069
+ name: "scope",
4070
+ kind: "list",
4071
+ value: "<a,b>",
4072
+ summary: "The personal links' scopes: view, draft, submit, review, signal, action:*. Default: all."
4073
+ },
4074
+ {
4075
+ name: "ttl",
4076
+ kind: "duration",
4077
+ value: "<d>",
4078
+ summary: "How long the personal links work, such as 7d. Default: no limit."
4079
+ },
4080
+ {
4081
+ name: "request-id",
4082
+ kind: "string",
4083
+ value: "<id>",
4084
+ summary: "Make a retry return the first attempt's links."
4085
+ }
4086
+ ],
4087
+ output: {
4088
+ type: "RosterAddResult",
4089
+ topic: "cli"
4090
+ },
4091
+ exits: [EXIT.failure],
4092
+ example: "roster add ./retro ada@example.com grace@example.com",
4093
+ readsStdin: (flags) => flags["stdin"] === true,
4094
+ async run(context) {
4095
+ const refs = context.args["ref"] ?? [];
4096
+ const name = flag(context, "name");
4097
+ const email = flag(context, "email");
4098
+ const fromJson = context.flags["file"] !== void 0 || context.flags["stdin"] === true;
4099
+ let respondents;
4100
+ if (fromJson) {
4101
+ if (refs.length > 0 || name !== void 0 || email !== void 0) throw usage("Give respondents either as arguments or with --file or --stdin, not both.");
4102
+ const parsed = RespondentSpec.array().min(1).safeParse(await jsonInput(context, "respondents"));
4103
+ if (!parsed.success) throw usage("The respondents must be a non-empty JSON array of { ref, name?, email? }.");
4104
+ respondents = parsed.data;
4105
+ } else {
4106
+ if (refs.length === 0) throw usage("Name at least one respondent, or give --file or --stdin.");
4107
+ if ((name !== void 0 || email !== void 0) && refs.length !== 1) throw usage("--name and --email describe one respondent: give one ref with them.");
4108
+ respondents = refs.map((ref) => ({
4109
+ ref,
4110
+ ...name !== void 0 ? { name } : {},
4111
+ ...email !== void 0 ? { email } : {}
4112
+ }));
4113
+ }
4114
+ const scopes = context.flags["scope"];
4115
+ const ttl = flag(context, "ttl");
4116
+ const requestId = flag(context, "request-id");
4117
+ const result = await context.call(rosterAddMethod, {
4118
+ artifact: artifactRef(arg(context, "artifact"), context.cwd),
4119
+ respondents,
4120
+ ...scopes !== void 0 ? { scopes } : {},
4121
+ ...ttl !== void 0 ? { ttl } : {},
4122
+ ...requestId !== void 0 ? { requestId } : {}
4123
+ });
4124
+ const width = Math.max(0, ...result.links.map((entry) => entry.ref.length));
4125
+ return {
4126
+ result,
4127
+ human: `${result.links.map((entry) => `${entry.ref.padEnd(width)} ${entry.link.url}\n`).join("")}Send each person their own link. Wait for everyone with: mostra wait ${arg(context, "artifact")} --until submitted:all\n`
4128
+ };
4129
+ }
4130
+ });
4131
+ /** `mostra roster remove <artifact> <ref…>`. */
4132
+ const rosterRemoveCommand = defineCommand({
4133
+ path: ["roster", "remove"],
4134
+ summary: "Stop expecting answers from respondents; their links, drafts and submissions stay as they are.",
4135
+ args: [{
4136
+ name: "artifact",
4137
+ summary: "The artifact: its source path or its ID."
4138
+ }, {
4139
+ name: "ref",
4140
+ summary: "Each respondent to remove, by their ref.",
4141
+ variadic: true
4142
+ }],
4143
+ flags: [{
4144
+ name: "request-id",
4145
+ kind: "string",
4146
+ value: "<id>",
4147
+ summary: "Make a retry return the first attempt's result."
4148
+ }],
4149
+ output: {
4150
+ type: "RosterRemoveResult",
4151
+ topic: "cli"
4152
+ },
4153
+ exits: [EXIT.failure],
4154
+ example: "roster remove ./retro grace@example.com",
4155
+ async run(context) {
4156
+ const refs = context.args["ref"] ?? [];
4157
+ if (refs.length === 0) throw usage("Name at least one respondent to remove.");
4158
+ const requestId = flag(context, "request-id");
4159
+ const result = await context.call(rosterRemoveMethod, {
4160
+ artifact: artifactRef(arg(context, "artifact"), context.cwd),
4161
+ refs: [...refs],
4162
+ ...requestId !== void 0 ? { requestId } : {}
4163
+ });
4164
+ return {
4165
+ result,
4166
+ human: `${result.removed.length === 0 ? "No one removed.\n" : `Removed ${result.removed.join(", ")}.\n`}${rosterText(result.roster)}`
4167
+ };
4168
+ }
4169
+ });
4170
+ //#endregion
3945
4171
  //#region src/commands/viewing.ts
3946
4172
  /**
3947
4173
  * `mostra open`: the artifact's link on stdout, and a browser opened on a one-time launch URL that
@@ -4121,6 +4347,9 @@ const COMMANDS = [
4121
4347
  logoutCommand,
4122
4348
  pauseCommand,
4123
4349
  resumeCommand,
4350
+ rosterAddCommand,
4351
+ rosterGetCommand,
4352
+ rosterRemoveCommand,
4124
4353
  waitCommand,
4125
4354
  resultsCommand,
4126
4355
  stateGetCommand,
@@ -4588,4 +4817,4 @@ async function runRuntime(io, args, stdio) {
4588
4817
  //#endregion
4589
4818
  export { COMMANDS as a, referenceMarkdown as i, commandDefinition as n, commandHelp as r, run as t };
4590
4819
 
4591
- //# sourceMappingURL=run-BxYL-DaX.js.map
4820
+ //# sourceMappingURL=run-CtR0PFMj.js.map