spur-board 0.170.2 → 0.171.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/{chunk-BbohDnMm.mjs → chunk-BRiD3EcI.mjs} +1 -1
- package/dist/{chunk-BebxFmW0.mjs → chunk-CqjDrIzS.mjs} +78 -8
- package/dist/{chunk-DEHqpoRe.mjs → chunk-CqtrnYE5.mjs} +23 -7
- package/dist/cli.mjs +47 -9
- package/dist/client.mjs +1 -1
- package/dist/daemon.mjs +222 -14
- package/dist/mcp.mjs +3 -3
- package/dist/web/assets/index-CqfuJHHS.js +64 -0
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/skills/spur-board/SKILL.md +6 -6
- package/skills/spur-board/references/how-board-works-done.md +2 -1
- package/skills/spur-board/references/tasks.md +2 -2
- package/dist/web/assets/index-CGVxiJUl.js +0 -64
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as tokenRequestStatusSchema, gt as errorEnvelopeSchema, ht as errorContextSchema, l as tokenRequestResultSchema, pt as ERRORS, vt as successEnvelopeSchema, x as renderJsonError } from "./chunk-
|
|
1
|
+
import { d as tokenRequestStatusSchema, gt as errorEnvelopeSchema, ht as errorContextSchema, l as tokenRequestResultSchema, pt as ERRORS, vt as successEnvelopeSchema, x as renderJsonError } from "./chunk-CqjDrIzS.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { request } from "node:http";
|
|
@@ -254,6 +254,27 @@ const TASK_HOLDS = [
|
|
|
254
254
|
"cycle_limit",
|
|
255
255
|
"work_not_started"
|
|
256
256
|
];
|
|
257
|
+
/**
|
|
258
|
+
* What a task waits for, as `board task --why` names it in `why.waitsFor`: an open turn, a merge,
|
|
259
|
+
* a human approval, the ticket, CI checks, GitHub, Spur, the board itself, an answer to a block,
|
|
260
|
+
* work to start or end, a failing gate, nothing (`done`, `archived`), or the project config.
|
|
261
|
+
*/
|
|
262
|
+
const WAITS_FOR_KINDS = [
|
|
263
|
+
"turn",
|
|
264
|
+
"merge",
|
|
265
|
+
"approval",
|
|
266
|
+
"ticket",
|
|
267
|
+
"checks",
|
|
268
|
+
"github",
|
|
269
|
+
"spur",
|
|
270
|
+
"board",
|
|
271
|
+
"answer",
|
|
272
|
+
"work",
|
|
273
|
+
"gate",
|
|
274
|
+
"done",
|
|
275
|
+
"archived",
|
|
276
|
+
"config"
|
|
277
|
+
];
|
|
257
278
|
/** Every operator item kind; core's `ITEM_POLICY` gives each one a policy. */
|
|
258
279
|
const ITEM_KINDS = [
|
|
259
280
|
"token_request",
|
|
@@ -1561,7 +1582,7 @@ const ERRORS = {
|
|
|
1561
1582
|
status: null,
|
|
1562
1583
|
exit: EXIT_CODES.config,
|
|
1563
1584
|
message: "No caller identity was found: this is not a Spur session and no .spur-board/token was found walking up from the current folder.",
|
|
1564
|
-
hint: "Run the command in a Spur session of a project listed in config.yaml, or run `board token create --name <name> --into <folder>` and ask the operator to approve the request in Slack.",
|
|
1585
|
+
hint: "Run the command in a Spur session of a project listed in config.yaml, or send that session the request with `spur send <session id> \"<request>\"`. With Slack (slack.channels set in config.yaml), you can instead run `board token create --name <name> --into <folder>` and ask the operator to approve the request in Slack.",
|
|
1565
1586
|
recovery: noRetry("Get a caller identity as the fix says, then run the command again.")
|
|
1566
1587
|
}),
|
|
1567
1588
|
service_start_failed: spec("service_start_failed", {
|
|
@@ -3016,6 +3037,7 @@ function defineOperation(spec) {
|
|
|
3016
3037
|
const mutation = spec.kind === "mutation";
|
|
3017
3038
|
for (const mode of [...spec.explicitKeyModes ?? [], ...spec.cli.defaultMode === void 0 ? [] : [spec.cli.defaultMode]]) if (!spec.cli.modes?.some((entry) => entry.mode === mode)) throw new Error(`Unknown mode ${mode} in ${spec.id}.`);
|
|
3018
3039
|
if (!mutation && spec.explicitKeyModes?.length) throw new Error("Only mutations require explicit keys.");
|
|
3040
|
+
if (spec.cli.view !== void 0) checkView(spec.id, spec.input, spec.cli.modes ?? [], spec.cli.view);
|
|
3019
3041
|
const order = Object.keys(ERRORS);
|
|
3020
3042
|
const errors = [.../* @__PURE__ */ new Set([
|
|
3021
3043
|
...COMMON_ERRORS,
|
|
@@ -3032,7 +3054,8 @@ function defineOperation(spec) {
|
|
|
3032
3054
|
args: spec.cli.args,
|
|
3033
3055
|
modes: spec.cli.modes ?? null,
|
|
3034
3056
|
...spec.cli.defaultMode === void 0 ? {} : { defaultMode: spec.cli.defaultMode },
|
|
3035
|
-
key: mutation ? "--key" : null
|
|
3057
|
+
key: mutation ? "--key" : null,
|
|
3058
|
+
...spec.cli.view === void 0 ? {} : { view: spec.cli.view }
|
|
3036
3059
|
},
|
|
3037
3060
|
mcp: {
|
|
3038
3061
|
name: spec.id.replace(".", "_"),
|
|
@@ -3042,6 +3065,24 @@ function defineOperation(spec) {
|
|
|
3042
3065
|
}
|
|
3043
3066
|
};
|
|
3044
3067
|
}
|
|
3068
|
+
/** The CLI flag of an input field: `--` and the field name in kebab case. */
|
|
3069
|
+
const fieldFlag = (field) => `--${field.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}`;
|
|
3070
|
+
/**
|
|
3071
|
+
* A CLI view reads a boolean input field and binds a flag no input field, mode, `--key` or
|
|
3072
|
+
* `--json` already takes.
|
|
3073
|
+
*/
|
|
3074
|
+
function checkView(id, input, modes, view) {
|
|
3075
|
+
const fields = (input instanceof z.ZodDiscriminatedUnion ? input.options : [input]).flatMap((shape) => Object.entries(shape.shape));
|
|
3076
|
+
const when = fields.filter(([name]) => name === view.when).map(([, schema]) => schema);
|
|
3077
|
+
const boolean = (schema) => (schema instanceof z.ZodOptional ? schema.unwrap() : schema) instanceof z.ZodBoolean;
|
|
3078
|
+
if (when.length === 0 || !when.every(boolean)) throw new Error(`CLI view of ${id} needs a boolean input field ${view.when}.`);
|
|
3079
|
+
if ((/* @__PURE__ */ new Set([
|
|
3080
|
+
...fields.map(([name]) => fieldFlag(name)),
|
|
3081
|
+
...modes.map((mode) => mode.flag),
|
|
3082
|
+
"--key",
|
|
3083
|
+
"--json"
|
|
3084
|
+
])).has(view.hide.flag)) throw new Error(`CLI view flag ${view.hide.flag} of ${id} is already taken.`);
|
|
3085
|
+
}
|
|
3045
3086
|
// ../contracts/src/ops/turn-schemas.ts
|
|
3046
3087
|
/** One pull request comment or review a turn handed to its executor. */
|
|
3047
3088
|
const turnHandedSchema = z.strictObject({
|
|
@@ -3233,6 +3274,11 @@ const gateConditionSchema = z.strictObject({
|
|
|
3233
3274
|
}).describe("One exit condition of a column and its state.");
|
|
3234
3275
|
/** Why a task is where it is, from the dispatcher's point of view. */
|
|
3235
3276
|
const taskWhySchema = z.strictObject({
|
|
3277
|
+
waitsFor: z.strictObject({
|
|
3278
|
+
kind: z.enum(WAITS_FOR_KINDS).describe("What the task waits for, e.g. turn or merge."),
|
|
3279
|
+
text: z.string().describe("The wait in one line; ends with (<actor>) when one acts next."),
|
|
3280
|
+
actor: z.enum([...ADDRESSEE_ROLES, "human"]).nullable().describe("Who acts next: a role, human on GitHub, or null for the board, GitHub or Spur.")
|
|
3281
|
+
}).optional().describe("What the task waits for and who acts next; absent only from an older daemon."),
|
|
3236
3282
|
column: z.enum(COLUMN_IDS).describe("Column the dispatcher works from: the shadow column in shadow mode."),
|
|
3237
3283
|
dispatcher: z.enum(DISPATCHER_MODES).nullable().describe("The project's dispatcher mode; null when the project is not configured."),
|
|
3238
3284
|
holds: z.array(z.enum(TASK_HOLDS)).describe("What holds the dispatcher from acting on the task; empty when nothing does."),
|
|
@@ -3253,8 +3299,9 @@ const taskWhySchema = z.strictObject({
|
|
|
3253
3299
|
enabled: z.boolean().describe("Whether the column is enabled in the project."),
|
|
3254
3300
|
ok: z.boolean().describe("Whether the column's own exit conditions pass. Dev's threads_resolved counts once any enabled column requires resolved threads, while the gates left of that column ignore it."),
|
|
3255
3301
|
blockedIn: z.enum(COLUMN_IDS).nullable().describe("Leftmost enabled column at or left of this one whose exit conditions fail; null when the cumulative gate passes."),
|
|
3256
|
-
conditions: z.array(gateConditionSchema).describe("The column's exit conditions, empty for a column without any.")
|
|
3257
|
-
|
|
3302
|
+
conditions: z.array(gateConditionSchema).describe("The column's exit conditions, empty for a column without any."),
|
|
3303
|
+
waitsFor: z.string().optional().describe("What an enabled Done gate, or the To Do group gate the task sits in, waits for; absent otherwise.")
|
|
3304
|
+
}).describe("The gate of one column.")).describe("The gate of every column, To Do to Done; empty when the pull request facts are missing. A terminal leaves out disabled columns unless --all; JSON lists every column."),
|
|
3258
3305
|
checksWaivedBy: z.literal("reposWithoutCi").nullable().describe("The config key that passed Dev's check condition for a repo without checks; null otherwise."),
|
|
3259
3306
|
turn: turnViewSchema.nullable().describe("The open turn of the task; null when none is open."),
|
|
3260
3307
|
moves: z.array(moveViewSchema).describe("The last 5 column moves, oldest first."),
|
|
@@ -3834,7 +3881,7 @@ const taskGetInputSchema = z.strictObject({
|
|
|
3834
3881
|
task: taskKeyInputSchema,
|
|
3835
3882
|
refresh: z.boolean().optional().describe("Read every linked pull request from GitHub before showing the task; unavailable reads fail visibly."),
|
|
3836
3883
|
detail: z.boolean().optional().describe("Also list the last 5 closed turns, newest first; absent means none."),
|
|
3837
|
-
why: z.boolean().optional().describe("Explain why the task is in its column: gates, holds, the open turn and the last moves; absent means no explanation.")
|
|
3884
|
+
why: z.boolean().optional().describe("Explain why the task is in its column: what it waits for, gates, holds, the open turn and the last moves; absent means no explanation.")
|
|
3838
3885
|
});
|
|
3839
3886
|
const taskGetOutputSchema = z.strictObject({
|
|
3840
3887
|
submission: latestSubmissionSchema,
|
|
@@ -4140,7 +4187,8 @@ const reviewGates = [
|
|
|
4140
4187
|
enabled: true,
|
|
4141
4188
|
ok: true,
|
|
4142
4189
|
blockedIn: "review",
|
|
4143
|
-
conditions: []
|
|
4190
|
+
conditions: [],
|
|
4191
|
+
waitsFor: "merge of example/web#9, then the ticket to close"
|
|
4144
4192
|
}
|
|
4145
4193
|
];
|
|
4146
4194
|
const taskOutput = z.strictObject({ task: taskViewSchema });
|
|
@@ -4328,7 +4376,7 @@ const OPERATIONS = [
|
|
|
4328
4376
|
kind: "query",
|
|
4329
4377
|
description: "Show a task; refresh reads GitHub PRs.",
|
|
4330
4378
|
mcp: {
|
|
4331
|
-
whenToUse: "Inspect a task; detail adds closed turns.",
|
|
4379
|
+
whenToUse: "Inspect a task; why starts with what it waits for, detail adds closed turns.",
|
|
4332
4380
|
whenNotToUse: "Use task_history for past events."
|
|
4333
4381
|
},
|
|
4334
4382
|
input: taskGetInputSchema,
|
|
@@ -4341,7 +4389,24 @@ const OPERATIONS = [
|
|
|
4341
4389
|
],
|
|
4342
4390
|
cli: {
|
|
4343
4391
|
command: "task",
|
|
4344
|
-
args: ["task"]
|
|
4392
|
+
args: ["task"],
|
|
4393
|
+
view: {
|
|
4394
|
+
when: "why",
|
|
4395
|
+
lead: {
|
|
4396
|
+
label: "waits for",
|
|
4397
|
+
path: [
|
|
4398
|
+
"why",
|
|
4399
|
+
"waitsFor",
|
|
4400
|
+
"text"
|
|
4401
|
+
]
|
|
4402
|
+
},
|
|
4403
|
+
hide: {
|
|
4404
|
+
path: ["why", "gates"],
|
|
4405
|
+
field: "enabled",
|
|
4406
|
+
flag: "--all",
|
|
4407
|
+
description: "With --why on a terminal, also list the gates of disabled columns; JSON always lists every column."
|
|
4408
|
+
}
|
|
4409
|
+
}
|
|
4345
4410
|
},
|
|
4346
4411
|
slack: {
|
|
4347
4412
|
kind: "slash-command",
|
|
@@ -4396,6 +4461,11 @@ const OPERATIONS = [
|
|
|
4396
4461
|
blocks: [],
|
|
4397
4462
|
comments: [],
|
|
4398
4463
|
why: {
|
|
4464
|
+
waitsFor: {
|
|
4465
|
+
kind: "turn",
|
|
4466
|
+
text: "Review turn T4 (orchestrator:review)",
|
|
4467
|
+
actor: "orchestrator:review"
|
|
4468
|
+
},
|
|
4399
4469
|
column: "review",
|
|
4400
4470
|
dispatcher: "on",
|
|
4401
4471
|
holds: [],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Mt as plainHttpAllowed, g as OPERATIONS, kt as configSchema, m as buildCatalogSnapshot } from "./chunk-
|
|
2
|
-
import { o as CliError, t as fetchCatalogVersion } from "./chunk-
|
|
1
|
+
import { It as slackConfigured, Mt as plainHttpAllowed, g as OPERATIONS, kt as configSchema, m as buildCatalogSnapshot } from "./chunk-CqjDrIzS.mjs";
|
|
2
|
+
import { o as CliError, t as fetchCatalogVersion } from "./chunk-BRiD3EcI.mjs";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { closeSync, constants, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { homedir } from "node:os";
|
|
@@ -27,16 +27,31 @@ function dataDirectory(env, home, cwd = process.cwd()) {
|
|
|
27
27
|
const xdg = env["XDG_DATA_HOME"];
|
|
28
28
|
return join(xdg && isAbsolute(xdg) ? xdg : join(home, ".local", "share"), "spur-board");
|
|
29
29
|
}
|
|
30
|
-
/** The
|
|
31
|
-
function
|
|
30
|
+
/** The parsed config.yaml, or undefined when the file is missing, unreadable or invalid. */
|
|
31
|
+
function readBoardConfig(env, home) {
|
|
32
32
|
try {
|
|
33
33
|
const parsed = YAML.parseDocument(readFileSync(configFile(env, home), "utf8"));
|
|
34
34
|
if (parsed.errors.length === 0) {
|
|
35
35
|
const config = configSchema.safeParse(parsed.toJS());
|
|
36
|
-
if (config.success) return config.data
|
|
36
|
+
if (config.success) return config.data;
|
|
37
37
|
}
|
|
38
38
|
} catch {}
|
|
39
39
|
}
|
|
40
|
+
/** The http.port in config.yaml, or undefined when the file is missing or invalid. */
|
|
41
|
+
function readConfiguredPort(env, home) {
|
|
42
|
+
return readBoardConfig(env, home)?.http.port;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Whether config.yaml turns Slack on, or undefined when the file is missing or invalid, or when
|
|
46
|
+
* BOARD_DAEMON_URL selects the daemon.
|
|
47
|
+
*/
|
|
48
|
+
function boardSlackState(env, home) {
|
|
49
|
+
if (env["BOARD_DAEMON_URL"]) return void 0;
|
|
50
|
+
const config = readBoardConfig(env, home);
|
|
51
|
+
return config && slackConfigured(config);
|
|
52
|
+
}
|
|
53
|
+
const SLACK_IDENTITY_HINT = "Run the command in a Spur session of a project listed in config.yaml, or run `board token create --name <name> --into <folder>` and ask the operator to approve the request in Slack.";
|
|
54
|
+
const SPUR_IDENTITY_HINT = "Run the command in a Spur session of a project listed in config.yaml, such as one whose spurProjects role is operator, or send that session the request with `spur send <session id> \"<request>\"`.";
|
|
40
55
|
function resolveDaemonAddress(env = process.env, home = homedir(), configuredPort) {
|
|
41
56
|
const rawAddress = env["BOARD_DAEMON_URL"];
|
|
42
57
|
if (rawAddress === void 0) {
|
|
@@ -126,7 +141,8 @@ function loadClientConfig(env = process.env, paths = {
|
|
|
126
141
|
const token = session ? void 0 : env["BOARD_TOKEN"] === void 0 ? findTokenFile(paths.cwd, paths.home) : env["BOARD_TOKEN"];
|
|
127
142
|
if (!session && !token) {
|
|
128
143
|
if (env["BOARD_TOKEN"] === "") throw new CliError("config", { environmentVariable: "BOARD_TOKEN" });
|
|
129
|
-
|
|
144
|
+
const slack = boardSlackState(env, paths.home);
|
|
145
|
+
throw new CliError("identity_missing", void 0, void 0, slack === void 0 ? void 0 : slack ? SLACK_IDENTITY_HINT : SPUR_IDENTITY_HINT);
|
|
130
146
|
}
|
|
131
147
|
return {
|
|
132
148
|
address,
|
|
@@ -261,4 +277,4 @@ function fileVerdictCache(path, cliVersion) {
|
|
|
261
277
|
return verdict;
|
|
262
278
|
} };
|
|
263
279
|
}
|
|
264
|
-
export { memoryVerdictCache as a,
|
|
280
|
+
export { memoryVerdictCache as a, dataDirectory as c, readConfiguredPort as d, resolveDaemonAddress as f, fileVerdictCache as i, loadClientConfig as l, cliPackageVersion as n, boardSlackState as o, tokenInFolder as p, compareCatalogs as r, configFile as s, checkCatalog as t, loadEnrollmentConfig as u };
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Ct as DEFAULT_STAND_PORT_RANGE, Ft as resolveWebOrigin, It as slackConfigured, Pt as requiredSecretKeys, Ut as SLACK_BOT_SCOPES, c as requestHashOf, ct as actorIdSchema, g as OPERATIONS, h as roleCanUseOperation, j as sortSkillFiles, k as skillReloadFileSchema, kt as configSchema, n as SLACK_OFF_FIX, o as remoteDoctorReportSchema, p as SYSTEMD_SERVICE_SETTINGS, pt as ERRORS, r as SLACK_PARTLY_FIX, vt as successEnvelopeSchema } from "./chunk-
|
|
1
|
+
import { Ct as DEFAULT_STAND_PORT_RANGE, Ft as resolveWebOrigin, It as slackConfigured, Pt as requiredSecretKeys, Ut as SLACK_BOT_SCOPES, c as requestHashOf, ct as actorIdSchema, g as OPERATIONS, h as roleCanUseOperation, j as sortSkillFiles, k as skillReloadFileSchema, kt as configSchema, n as SLACK_OFF_FIX, o as remoteDoctorReportSchema, p as SYSTEMD_SERVICE_SETTINGS, pt as ERRORS, r as SLACK_PARTLY_FIX, vt as successEnvelopeSchema } from "./chunk-CqjDrIzS.mjs";
|
|
2
2
|
import { t as apiBaseUrl } from "./chunk-Bzb7aI8R.mjs";
|
|
3
|
-
import { a as requestTokenEnrollment, c as renderCliError, i as requestSkillReload, l as escapeTerminalControls, n as fetchTokenStatus, o as CliError, r as requestOperation, s as errorExitCode } from "./chunk-
|
|
4
|
-
import { a as memoryVerdictCache, c as
|
|
3
|
+
import { a as requestTokenEnrollment, c as renderCliError, i as requestSkillReload, l as escapeTerminalControls, n as fetchTokenStatus, o as CliError, r as requestOperation, s as errorExitCode } from "./chunk-BRiD3EcI.mjs";
|
|
4
|
+
import { a as memoryVerdictCache, c as dataDirectory, d as readConfiguredPort, f as resolveDaemonAddress, i as fileVerdictCache, l as loadClientConfig, n as cliPackageVersion, o as boardSlackState, p as tokenInFolder, s as configFile, t as checkCatalog, u as loadEnrollmentConfig } from "./chunk-CqtrnYE5.mjs";
|
|
5
5
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
6
6
|
import { accessSync, chmodSync, closeSync, constants, cpSync, existsSync, ftruncateSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
7
7
|
import { homedir, hostname, tmpdir, userInfo } from "node:os";
|
|
@@ -2379,18 +2379,22 @@ function shellValue(value) {
|
|
|
2379
2379
|
return /^[A-Za-z0-9_./#:@-]+$/.test(text) ? text : JSON.stringify(text);
|
|
2380
2380
|
}
|
|
2381
2381
|
/** The identity an operation in the selected input mode needs, when only one kind of caller can run it. */
|
|
2382
|
-
function identityHint(op, mode) {
|
|
2382
|
+
function identityHint(op, mode, slack) {
|
|
2383
2383
|
const flag = op.cli.modes?.find((item) => item.mode === mode)?.flag;
|
|
2384
2384
|
const command = `\`board ${op.cli.command}${flag ? ` ${flag}` : ""}\``;
|
|
2385
|
-
if (!roleCanUseOperation(op, "worker", mode) && !roleCanUseOperation(op, "orchestrator", mode))
|
|
2385
|
+
if (!roleCanUseOperation(op, "worker", mode) && !roleCanUseOperation(op, "orchestrator", mode)) {
|
|
2386
|
+
if (slack === false) return `${command} needs operator identity: run it in a Spur session of a project whose spurProjects role is operator, or send that session the request with \`spur send <session id> "<request>"\`.`;
|
|
2387
|
+
return `${command} needs operator identity: run it in a Spur session of a project whose spurProjects role is operator, or run \`board token create --name <name> --into <folder>\` and ask the operator to approve the request in Slack.`;
|
|
2388
|
+
}
|
|
2386
2389
|
if (!roleCanUseOperation(op, "operator", mode)) return `${command} needs an agent identity: run it in a Spur session of a project listed in config.yaml.`;
|
|
2387
2390
|
}
|
|
2388
2391
|
function loadOperationConfig(op, input, env) {
|
|
2389
2392
|
try {
|
|
2390
2393
|
return loadClientConfig(env);
|
|
2391
2394
|
} catch (error) {
|
|
2392
|
-
|
|
2393
|
-
|
|
2395
|
+
if (!(error instanceof CliError) || error.code !== "identity_missing") throw error;
|
|
2396
|
+
const hint = identityHint(op, typeof input === "object" && input !== null && "mode" in input && typeof input.mode === "string" ? input.mode : void 0, boardSlackState(env, homedir()));
|
|
2397
|
+
if (hint) throw new CliError(error.code, error.context, error.requestId, hint);
|
|
2394
2398
|
throw error;
|
|
2395
2399
|
}
|
|
2396
2400
|
}
|
|
@@ -2426,6 +2430,35 @@ function formatHuman(value, indent = 0) {
|
|
|
2426
2430
|
}
|
|
2427
2431
|
return `${prefix}${escapeTerminalControls(String(value))}`;
|
|
2428
2432
|
}
|
|
2433
|
+
/** The value at `path` of a JSON result, or undefined when the path does not reach one. */
|
|
2434
|
+
function valueAt(value, path) {
|
|
2435
|
+
let current = value;
|
|
2436
|
+
for (const key of path) {
|
|
2437
|
+
if (current === null || typeof current !== "object" || Array.isArray(current)) return void 0;
|
|
2438
|
+
current = current[key];
|
|
2439
|
+
}
|
|
2440
|
+
return current;
|
|
2441
|
+
}
|
|
2442
|
+
/**
|
|
2443
|
+
* The result without the entries of the array at `path` whose `field` is false, keys in place.
|
|
2444
|
+
* A path that does not reach an array leaves the result as it is.
|
|
2445
|
+
*/
|
|
2446
|
+
function withoutEntries(value, path, field) {
|
|
2447
|
+
const [key, ...rest] = path;
|
|
2448
|
+
if (key === void 0) return Array.isArray(value) ? value.filter((entry) => !(entry && typeof entry === "object" && entry[field] === false)) : value;
|
|
2449
|
+
if (value === null || typeof value !== "object" || Array.isArray(value) || !(key in value)) return value;
|
|
2450
|
+
const object = value;
|
|
2451
|
+
return {
|
|
2452
|
+
...object,
|
|
2453
|
+
[key]: withoutEntries(object[key], rest, field)
|
|
2454
|
+
};
|
|
2455
|
+
}
|
|
2456
|
+
/** Terminal output shaped by a catalog `cli.view`: the lead line, then the result. */
|
|
2457
|
+
function formatView(result, view, all) {
|
|
2458
|
+
const lead = valueAt(result, view.lead.path);
|
|
2459
|
+
const body = formatHuman(all ? result : withoutEntries(result, view.hide.path, view.hide.field));
|
|
2460
|
+
return typeof lead === "string" ? `${escapeTerminalControls(view.lead.label)}: ${escapeTerminalControls(lead)}\n${body}` : body;
|
|
2461
|
+
}
|
|
2429
2462
|
function commandFor(root, path) {
|
|
2430
2463
|
let parent = root;
|
|
2431
2464
|
for (const segment of path.split(" ")) {
|
|
@@ -2466,6 +2499,7 @@ function registerOptions(command, op) {
|
|
|
2466
2499
|
const description = schema.description ?? bareSchema(schema).description ?? mode.value;
|
|
2467
2500
|
command.option(`${mode.flag} ${value}`, description);
|
|
2468
2501
|
}
|
|
2502
|
+
if (op.cli.view !== void 0) command.option(op.cli.view.hide.flag, op.cli.view.hide.description);
|
|
2469
2503
|
if (op.kind === "mutation") command.option("--key <key>", "Idempotency key for this action.");
|
|
2470
2504
|
command.option("--json", "Print JSON output or a JSON error.");
|
|
2471
2505
|
}
|
|
@@ -2631,6 +2665,10 @@ function createProgram(options = {}) {
|
|
|
2631
2665
|
const invoked = parts.at(-1);
|
|
2632
2666
|
const json = Boolean(invoked.opts()["json"] || program.opts()["json"]);
|
|
2633
2667
|
const input = buildInput(op, parts.slice(0, -1), invoked.opts());
|
|
2668
|
+
const view = op.cli.view;
|
|
2669
|
+
const viewOn = view !== void 0 && input[view.when] === true;
|
|
2670
|
+
const all = view !== void 0 && invoked.opts()[optionField(view.hide.flag)] === true;
|
|
2671
|
+
if (view !== void 0 && all && !viewOn) throw new CliError("usage", void 0, void 0, `${view.hide.flag} needs ${optionName(view.when)}.`);
|
|
2634
2672
|
const keyOption = invoked.opts()["key"];
|
|
2635
2673
|
if (op.explicitKeyModes?.includes(input["mode"] ?? "") && (typeof keyOption !== "string" || keyOption.trim() === "")) throw new CliError("usage", void 0, void 0, "Pass an explicit non-blank --key for this mode.");
|
|
2636
2674
|
if (keyOption !== void 0 && (typeof keyOption !== "string" || keyOption === "")) throw new CliError("usage", void 0, void 0, "Pass a nonempty --key, or omit it to have one generated.");
|
|
@@ -2657,7 +2695,7 @@ function createProgram(options = {}) {
|
|
|
2657
2695
|
try {
|
|
2658
2696
|
if ("error" in outcome) throw outcome.error;
|
|
2659
2697
|
const result = outcome.value;
|
|
2660
|
-
io.stdout(`${json || !io.isTTY ? JSON.stringify(result) : formatHuman(result)}\n`);
|
|
2698
|
+
io.stdout(`${json || !io.isTTY ? JSON.stringify(result) : view !== void 0 && viewOn ? formatView(result, view, all) : formatHuman(result)}\n`);
|
|
2661
2699
|
} catch (error) {
|
|
2662
2700
|
if (error instanceof CliError) {
|
|
2663
2701
|
io.stderr(`${renderCliError(error, json, key)}\n`);
|
|
@@ -2796,4 +2834,4 @@ async function runCli(argv, options = {}) {
|
|
|
2796
2834
|
return errorExitCode(cliError);
|
|
2797
2835
|
}
|
|
2798
2836
|
}
|
|
2799
|
-
export { createProgram, exampleCommand, runCli };
|
|
2837
|
+
export { createProgram, exampleCommand, formatView, runCli };
|
package/dist/client.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as fetchCatalogVersion, n as fetchTokenStatus, r as requestOperation, i as requestSkillReload, a as requestTokenEnrollment } from "./chunk-
|
|
1
|
+
export { t as fetchCatalogVersion, n as fetchTokenStatus, r as requestOperation, i as requestSkillReload, a as requestTokenEnrollment } from "./chunk-BRiD3EcI.mjs";
|