@vercel/board 0.53.0 → 0.54.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/{access-Pcar1gwx.mjs → access-HzqFpgL_.mjs} +1 -1
- package/dist/access.d.mts +3 -3
- package/dist/access.mjs +5 -5
- package/dist/{actors-XKUrjOfO.mjs → actors-D-u6bitG.mjs} +2 -2
- package/dist/{auth-C2CxMl2p.mjs → auth-D9ycDQK0.mjs} +34 -12
- package/dist/{auth-BoYunD5t.d.mts → auth-ULldUvir.d.mts} +8 -2
- package/dist/{backend-DJobr4nr.d.mts → backend-BHN6GTjB.d.mts} +8 -7
- package/dist/backend-local.d.mts +1 -1
- package/dist/backend-local.mjs +1 -1
- package/dist/{chat-provider-BSHlV2lw.d.mts → chat-provider-F7UqWVZK.d.mts} +2 -2
- package/dist/cli-commands.d.mts +1 -1
- package/dist/cli-commands.mjs +1 -1
- package/dist/cli-embedded.d.mts +2 -2
- package/dist/cli-embedded.mjs +2 -2
- package/dist/cli.mjs +6 -6
- package/dist/{client-oYThy3CR.d.mts → client-CFHunEFn.d.mts} +8 -2
- package/dist/{commands-B_gbi2sU.mjs → commands-D8HctFGJ.mjs} +15 -10
- package/dist/{commands-B6pgzwTI.d.mts → commands-DLPIX7Jw.d.mts} +3 -1
- package/dist/{conformance-Cz1Elmgj.mjs → conformance-BNiLcKra.mjs} +34 -4
- package/dist/conformance.d.mts +3 -4
- package/dist/conformance.mjs +1 -1
- package/dist/{engine-506f7GEM.mjs → engine-C8wCzkw-.mjs} +2 -2
- package/dist/{routes-GF5ukHYX.mjs → errors-DDfXnZ2b.mjs} +875 -4
- package/dist/{exports-CF_nUsT5.d.mts → exports-BBmjHyCB.d.mts} +4 -4
- package/dist/{exports-CBukc8T3.mjs → exports-D6Q99t_O.mjs} +144 -88
- package/dist/{index-CM2u0wGd.d.mts → index-Ce3SDZ3Y.d.mts} +2 -2
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +4 -4
- package/dist/index.node.d.mts +7 -7
- package/dist/index.node.mjs +4 -4
- package/dist/inspect/app.js +88 -88
- package/dist/inspect/engine.js +3 -3
- package/dist/{inspect-PQsEgXRQ.mjs → inspect-Cb1Sj8QV.mjs} +2 -2
- package/dist/inspect-DeY883DA.mjs +2 -0
- package/dist/inspect.d.mts +1 -1
- package/dist/inspect.mjs +1 -1
- package/dist/{local-CwcmqEoa.mjs → local-BtzF9fRs.mjs} +10 -10
- package/dist/{main-gNAS2WbP.mjs → main-Dicvkp6D.mjs} +360 -100
- package/dist/{middleware-DXiwepsR.mjs → middleware-BY4qqIh3.mjs} +1 -1
- package/dist/{provider-WjdBsRLR.d.mts → provider-DgGp4Zej.d.mts} +2 -2
- package/dist/{routes-BpvyXQwv.d.mts → routes-DNmQSOvQ.d.mts} +16 -1
- package/dist/{serve-Ci5KT11x.mjs → serve-BMOtQEiQ.mjs} +6 -6
- package/dist/{server-XsbC50nY.mjs → server--J1DfQjI.mjs} +68 -11
- package/dist/{serving-C6Ao7i-7.mjs → serving-C1mhZQqH.mjs} +1 -1
- package/dist/{shell-BiCBL1w_.mjs → shell-DsDyOFd1.mjs} +1 -1
- package/dist/sync-chat-sdk.d.mts +2 -2
- package/dist/sync-github.d.mts +2 -2
- package/dist/sync-linear.d.mts +3 -3
- package/dist/sync-slack.d.mts +3 -3
- package/dist/sync.d.mts +2 -2
- package/dist/{task-batch-nqYGszDJ.mjs → task-batch-BviIruES.mjs} +4 -5
- package/dist/{tokens-tulRtEWx.mjs → tokens-B3gXkQCs.mjs} +2 -2
- package/dist/{version-CBjh_ogp.mjs → version-1isUFDyU.mjs} +1 -1
- package/docs/01-board/01-mounting.md +8 -6
- package/docs/01-board/03-identity.md +1 -1
- package/docs/01-board/05-reading.md +34 -7
- package/docs/01-board/09-access.md +11 -2
- package/docs/01-board/11-tasks.md +5 -3
- package/docs/01-quickstart.md +19 -5
- package/docs/03-guides/03-ci.md +71 -43
- package/docs/03-guides/04-triage.md +4 -4
- package/docs/04-reference/01-cli.md +30 -22
- package/docs/04-reference/02-board.md +8 -4
- package/docs/04-reference/03-http.md +14 -5
- package/docs/04-reference/05-conformance.md +1 -1
- package/docs/index.md +7 -5
- package/package.json +2 -2
- package/dist/errors-Cv0TGBt5.mjs +0 -857
- package/dist/inspect-SEaGzhvh.mjs +0 -2
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { a as DIRECT_UPLOAD_BYTES_MAX, l as fileSize } from "./profile-header-O8wC8yk8.mjs";
|
|
2
2
|
import { m as MESSAGE_TEXT_MAX, r as AttachmentId } from "./schemas-CUSTEFIy.mjs";
|
|
3
|
-
import "./
|
|
3
|
+
import { f as BoardError } from "./errors-DDfXnZ2b.mjs";
|
|
4
4
|
import { n as displayEmoji, r as normalizeEmoji } from "./emoji-CTLpvH-A.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import { l as shownName } from "./middleware-DXiwepsR.mjs";
|
|
5
|
+
import { l as shownName } from "./middleware-BY4qqIh3.mjs";
|
|
7
6
|
import { d as parseSchemaId, r as findBlocks, t as block } from "./blocks-CVoBC7ur.mjs";
|
|
8
7
|
import { a as replaceMentions, n as isEmail, t as extractMentions } from "./mentions-CnWt9Z5b.mjs";
|
|
9
|
-
import { t as VERSION } from "./version-
|
|
10
|
-
import { r as PERMISSIONS } from "./access-
|
|
11
|
-
import { c as withMentions } from "./task-batch-
|
|
12
|
-
import { a as isBoardName,
|
|
13
|
-
import { i as groups, n as filters$1, o as options, r as globalOptions, s as usage$1, t as commands } from "./commands-
|
|
14
|
-
import { _ as vercelProjectFile, a as vercel, c as boardUrl, d as environmentProfile, f as handFetch, i as handTeam, l as configDir, m as handToken, n as credentialSource, o as http, p as handLogin, r as credentialed, t as board, u as connect } from "./server
|
|
15
|
-
import { n as everyChannel, t as conformance } from "./conformance-
|
|
8
|
+
import { t as VERSION } from "./version-1isUFDyU.mjs";
|
|
9
|
+
import { r as PERMISSIONS } from "./access-HzqFpgL_.mjs";
|
|
10
|
+
import { c as withMentions } from "./task-batch-BviIruES.mjs";
|
|
11
|
+
import { a as isBoardName, l as isApiMessageId, n as createTasksInChunks, s as apiThreadRoot, t as TasksInChunksError } from "./exports-D6Q99t_O.mjs";
|
|
12
|
+
import { i as groups, n as filters$1, o as options, r as globalOptions, s as usage$1, t as commands } from "./commands-D8HctFGJ.mjs";
|
|
13
|
+
import { _ as vercelProjectFile, a as vercel, c as boardUrl, d as environmentProfile, f as handFetch, i as handTeam, l as configDir, m as handToken, n as credentialSource, o as http, p as handLogin, r as credentialed, t as board, u as connect } from "./server--J1DfQjI.mjs";
|
|
14
|
+
import { n as everyChannel, t as conformance } from "./conformance-BNiLcKra.mjs";
|
|
16
15
|
import { n as displayText, t as byVercelBot } from "./bots-CqPYxkqK.mjs";
|
|
17
16
|
import { spawn } from "node:child_process";
|
|
18
17
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -1105,7 +1104,7 @@ function listed(command) {
|
|
|
1105
1104
|
function rootHelp(app, version) {
|
|
1106
1105
|
const sections = [...groups.map((group) => commands.filter((command) => command.group === group)), app.commands].map((list) => list.filter((command) => !command.hidden));
|
|
1107
1106
|
const lines = [
|
|
1108
|
-
`${app.name} ${version}:
|
|
1107
|
+
`${app.name} ${version}: your Vercel team's message board, for people and agents`,
|
|
1109
1108
|
"",
|
|
1110
1109
|
`usage: ${app.name} <command> [options]${app.name === "board" ? " (also installed as `vb`)" : ""}`
|
|
1111
1110
|
];
|
|
@@ -1136,15 +1135,23 @@ function commandHelp(name, path) {
|
|
|
1136
1135
|
if (command.filters) {
|
|
1137
1136
|
section("filters", shown(filters$1).map((option) => [flag(option), option.description]));
|
|
1138
1137
|
lines.push(" labels match a message or its thread's root; repeated flags all must match");
|
|
1138
|
+
if (command.filtersNote) lines.push(...wrap(command.filtersNote, 78).map((line) => ` ${line}`));
|
|
1139
1139
|
}
|
|
1140
1140
|
if (command.examples.length) lines.push("", "examples:", ...command.examples.flatMap((example, index) => [
|
|
1141
1141
|
...index ? [""] : [],
|
|
1142
1142
|
` ${example.name}`,
|
|
1143
1143
|
` ${name} ${example.value}`
|
|
1144
1144
|
]));
|
|
1145
|
-
lines.push("", `
|
|
1145
|
+
lines.push("", ...labeled("global:", COMMON.map((option) => flag(globalOptions.find((known) => known.name === option))).join(" "), " "), ...labeled("", `and the rest every command takes: ${name} help`));
|
|
1146
1146
|
return lines.join("\n");
|
|
1147
1147
|
}
|
|
1148
|
+
/** The global options a command's page shows: a program's output, who it writes as, and which board. */
|
|
1149
|
+
const COMMON = [
|
|
1150
|
+
"json",
|
|
1151
|
+
"as",
|
|
1152
|
+
"scope",
|
|
1153
|
+
"url"
|
|
1154
|
+
];
|
|
1148
1155
|
/**
|
|
1149
1156
|
* The command `words` name, and its subcommand when they name one (`schedule cancel`, `sources slack
|
|
1150
1157
|
* read`): what `--help` shows the page of. Null when the first word names no command.
|
|
@@ -1219,6 +1226,21 @@ function closest(word, known) {
|
|
|
1219
1226
|
}
|
|
1220
1227
|
return best !== void 0 && distance > 0 && distance <= (word.length >= 6 ? 2 : 1) ? best : void 0;
|
|
1221
1228
|
}
|
|
1229
|
+
/**
|
|
1230
|
+
* The channel a name that's no channel's likely means: one close to it, or the one whose path ends in it, like
|
|
1231
|
+
* `factory/v0/v0-errors` for `v0-errors`, a channel's last part that leaves out the path it's under. Several that
|
|
1232
|
+
* end in it are each named.
|
|
1233
|
+
*/
|
|
1234
|
+
function closestChannel(name, channels) {
|
|
1235
|
+
const close = closest(name, channels);
|
|
1236
|
+
if (close) return close;
|
|
1237
|
+
const tail = `/${name.replace(/^\/+|\/+$/g, "")}`;
|
|
1238
|
+
if (tail === "/") return void 0;
|
|
1239
|
+
const ending = channels.filter((path) => path.endsWith(tail) || path.endsWith(`${tail}/`));
|
|
1240
|
+
if (!ending.length) return void 0;
|
|
1241
|
+
if (ending.length <= 3) return ending.join(" or ");
|
|
1242
|
+
return `${ending.slice(0, 3).join(", ")}, or ${ending.length - 3} more`;
|
|
1243
|
+
}
|
|
1222
1244
|
/** How many edits turn `a` into `b`, a swap of neighbors counting as one. */
|
|
1223
1245
|
function edits(a, b) {
|
|
1224
1246
|
const d = Array.from({ length: a.length + 1 }, (_, i) => Array.from({ length: b.length + 1 }, (_, j) => i === 0 ? j : j === 0 ? i : 0));
|
|
@@ -1270,8 +1292,8 @@ function rerun(...extra) {
|
|
|
1270
1292
|
...typed.slice(at)
|
|
1271
1293
|
]];
|
|
1272
1294
|
}
|
|
1273
|
-
/** A command line without `options` and their values. */
|
|
1274
|
-
const without = (argv, ...options) => argv.filter((arg, at) => !options.some((option) => arg === option || argv[at - 1] === option
|
|
1295
|
+
/** A command line without `options` and their values: a bare `--mentions` has none, so what follows it stays. */
|
|
1296
|
+
const without = (argv, ...options) => argv.filter((arg, at) => !options.some((option) => arg === option || arg.startsWith(`${option}=`) || argv[at - 1] === option && !(OPTIONS[option.slice(2)]?.optionalValue && arg.startsWith("-"))));
|
|
1275
1297
|
/**
|
|
1276
1298
|
* This run's command line without `options`, with `extra` in their place: both before any `--`,
|
|
1277
1299
|
* since what follows it is text, which a way out mustn't change or add options to.
|
|
@@ -1415,15 +1437,22 @@ let typed = [];
|
|
|
1415
1437
|
let warnings = [];
|
|
1416
1438
|
/** The board this run reached by its URL, for a failure to name. */
|
|
1417
1439
|
let reached = null;
|
|
1440
|
+
/** The team whose default board this run reached, nothing naming one of its boards: `--scope`'s, or the one the environment finds. */
|
|
1441
|
+
let teamDefault = null;
|
|
1418
1442
|
/** Where the credential this run sent came from, as `whoami` says it, for a refusal to say which to replace. */
|
|
1419
1443
|
let sent = () => null;
|
|
1420
1444
|
/** How long the message text this run sends is, for a backend's refusal of it to say what to do instead. */
|
|
1421
1445
|
let sentLength = 0;
|
|
1422
|
-
/**
|
|
1446
|
+
/**
|
|
1447
|
+
* The help `words` ask for: a command's page when they name one (`read`, `sources read`), or with
|
|
1448
|
+
* none, every command. A word that names no command is unknown, as it is without `--help`.
|
|
1449
|
+
*/
|
|
1423
1450
|
function help(words = []) {
|
|
1424
1451
|
const own = Object.values(app.commands).map((command) => command.spec);
|
|
1425
1452
|
const path = commandPath(words, [...commands, ...own]);
|
|
1426
|
-
|
|
1453
|
+
if (path) return commandHelp(app.name, path);
|
|
1454
|
+
if (words[0] !== void 0 && words[0] !== "help") throw unknownCommand(words[0]);
|
|
1455
|
+
return rootHelp({
|
|
1427
1456
|
name: app.name,
|
|
1428
1457
|
commands: own
|
|
1429
1458
|
}, VERSION);
|
|
@@ -1639,7 +1668,7 @@ function messageId(value, what = "message ID") {
|
|
|
1639
1668
|
const id = value?.replace(/^#/, "") ?? "";
|
|
1640
1669
|
if (value === void 0) throw usage(`Missing the ${what}.`, { reason: "missing_arguments" });
|
|
1641
1670
|
if (!/^[^\s/]+$/.test(id)) throw usage(`${value} isn't a ${what}.`);
|
|
1642
|
-
return id;
|
|
1671
|
+
return apiThreadRoot(id) ?? id;
|
|
1643
1672
|
}
|
|
1644
1673
|
/** Characters that change how a name reads without showing: invisible formatting (bidi overrides, zero-width), and line and paragraph separators. */
|
|
1645
1674
|
const INVISIBLE = /[\p{Cf}\u2028\u2029]/gu;
|
|
@@ -1662,8 +1691,17 @@ const tooLarge = (path) => new Failed({
|
|
|
1662
1691
|
reason: "payload_too_large",
|
|
1663
1692
|
message: `Can't attach ${path}. It's over ${DIRECT_UPLOAD_BYTES_MAX / 1024 / 1024} MB, the most an attachment can be.`
|
|
1664
1693
|
});
|
|
1665
|
-
/** Whether an ID goes in and out bare: a number, or one Vercel's API hands out (`msg_…`), a message even where a channel has its name. */
|
|
1666
|
-
const bareId = (value) => /^\d+$/.test(value) || isApiMessageId(value);
|
|
1694
|
+
/** Whether an ID goes in and out bare: a number, or one Vercel's API hands out (`msg_…`, or a thread's `thr_…`), a message even where a channel has its name. */
|
|
1695
|
+
const bareId = (value) => /^\d+$/.test(value) || isApiMessageId(value) || apiThreadRoot(value) !== null;
|
|
1696
|
+
/**
|
|
1697
|
+
* What a value that starts like Vercel's message or thread ID but isn't a whole one (a copy cut short) would be
|
|
1698
|
+
* whole: its thread's root, when the thread's part is all there, or only that it's cut short.
|
|
1699
|
+
*/
|
|
1700
|
+
const partialApiId = (value) => {
|
|
1701
|
+
if (!/^(?:msg|thr)_[0-9a-f-]/.test(value) || bareId(value)) return null;
|
|
1702
|
+
const thread = /^(?:msg|thr)_([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})_?$/.exec(value);
|
|
1703
|
+
return { root: thread ? `msg_${thread[1]}_1` : null };
|
|
1704
|
+
};
|
|
1667
1705
|
/** Whether an argument names a message rather than a channel: `#<id>`, or an ID that goes bare. */
|
|
1668
1706
|
const isMessageRef = (value) => /^#[^\s/]+$/.test(value) || bareId(value);
|
|
1669
1707
|
/** A message's ID as it's passed back: bare when it goes bare, `#<id>` when it could be a channel's name. */
|
|
@@ -1728,6 +1766,7 @@ function oneText(command, target, extra) {
|
|
|
1728
1766
|
first
|
|
1729
1767
|
]
|
|
1730
1768
|
}] });
|
|
1769
|
+
if (flags.schema !== void 0 && first !== "-") throw usage(`With --schema, the text is ${flags.schema}'s JSON alone, and ${first.length > 40 ? `${first.slice(0, 40)}…` : first} is one too many. To say something with the data, leave out --schema and put the JSON in the text in a \`\`\`json#${flags.schema} fence.`);
|
|
1731
1770
|
throw usage(first === "-" ? `${command} takes one text, and - (stdin) is a second. For a long message, pass - alone as the text: it has no title.` : `${command} takes one text, and ${first.length > 40 ? `${first.slice(0, 40)}…` : first} is one too many. Quote the whole message as one argument: it has no title.`);
|
|
1732
1771
|
}
|
|
1733
1772
|
/**
|
|
@@ -2151,7 +2190,10 @@ function failureOf(error) {
|
|
|
2151
2190
|
case "board_name_taken": return own("conflict", "board_name_taken");
|
|
2152
2191
|
case "board_not_granted": return own("permission", "board_not_granted");
|
|
2153
2192
|
case "watchers_need_project": return own("permission", "watchers_need_project");
|
|
2154
|
-
case "
|
|
2193
|
+
case "missing_team": return {
|
|
2194
|
+
...own("missing_input", "missing_scope", [{ instruction: "Use a team's board: add --scope <TEAM_ID>" }, { instruction: "Or set VERCEL_ORG_ID to its ID" }]),
|
|
2195
|
+
actionRequired: true
|
|
2196
|
+
};
|
|
2155
2197
|
case "invalid_board_name": return own("usage", "invalid_arguments", [helpRecovery()]);
|
|
2156
2198
|
case "too_many_redirects": return own("network", "network_error");
|
|
2157
2199
|
case "invalid_duration": return own("usage", "invalid_arguments", [helpRecovery()]);
|
|
@@ -2162,7 +2204,17 @@ function failureOf(error) {
|
|
|
2162
2204
|
message: `Can't ${doing()}. ${sentence(message)}`
|
|
2163
2205
|
};
|
|
2164
2206
|
case "no_team": return {
|
|
2165
|
-
...own("platform", "api_error"
|
|
2207
|
+
...own("platform", "api_error", [
|
|
2208
|
+
...fix,
|
|
2209
|
+
{
|
|
2210
|
+
instruction: "Use a team's board",
|
|
2211
|
+
argv: rerun("--scope", "<TEAM>")
|
|
2212
|
+
},
|
|
2213
|
+
{
|
|
2214
|
+
instruction: "Or a board at a URL (or set BOARD_URL)",
|
|
2215
|
+
argv: rerun("--url", "<URL>")
|
|
2216
|
+
}
|
|
2217
|
+
]),
|
|
2166
2218
|
message: "Couldn't tell which team's board to use.",
|
|
2167
2219
|
details: [message]
|
|
2168
2220
|
};
|
|
@@ -2245,11 +2297,11 @@ function failureOf(error) {
|
|
|
2245
2297
|
}] : []);
|
|
2246
2298
|
if (code === "private_boards_unavailable") return theirs("limit", code, `Can't ${doing()}. This team's plan has no private boards.`, [{ instruction: "Keep the board open to the whole team, or move the team to a plan with private boards" }]);
|
|
2247
2299
|
if (status === 400) return theirs("usage", specific("invalid_arguments"), `Can't ${doing()}.`);
|
|
2248
|
-
if (status === 401) return theirs("auth", "login_required", "The board didn't accept your credentials.", sent() === "the token you passed" ? [{ instruction: "Pass a token it accepts" }] : sent() === "BOARD_TOKEN" ? [{ instruction: "Pass a token it accepts in BOARD_TOKEN, or unset it" }] : [{
|
|
2300
|
+
if (status === 401) return theirs("auth", "login_required", "The board didn't accept your credentials.", sent() === "the token you passed" ? [{ instruction: "Pass a token it accepts" }] : sent() === "BOARD_TOKEN" ? [{ instruction: "Pass a token it accepts in BOARD_TOKEN, or unset it" }] : sent() === "GitHub Actions OIDC" ? [{ instruction: "Pass a token it accepts in BOARD_TOKEN" }] : [{
|
|
2249
2301
|
instruction: "Log in again",
|
|
2250
2302
|
argv: ["vercel", "login"]
|
|
2251
2303
|
}]);
|
|
2252
|
-
if (status === 403) return theirs("permission", "permission_denied", `You can't ${doing()}
|
|
2304
|
+
if (status === 403) return theirs("permission", "permission_denied", `You can't ${doing()}.`, refusedRecoveries());
|
|
2253
2305
|
if (status === 404) {
|
|
2254
2306
|
const thing = missing();
|
|
2255
2307
|
return thing ? {
|
|
@@ -2301,10 +2353,74 @@ function failureOf(error) {
|
|
|
2301
2353
|
if (status === 413) return theirs("limit", "payload_too_large", `Can't ${doing()}. It's too large for the board.`);
|
|
2302
2354
|
if (status === 501 && code === "no_direct_uploads") return theirs("limit", "payload_too_large", `Can't ${doing()}. The file is too large for this board.`, [{ instruction: "Compress it, or split it into smaller files" }]);
|
|
2303
2355
|
if (status === 429) return theirs("rate_limit", "rate_limited", `Can't ${doing()}. Too many requests to the board.`, [{ instruction: wait !== void 0 ? `Wait ${waitFor(wait)}, then run it again` : "Wait a minute, then run it again" }]);
|
|
2304
|
-
if (status === 501) return theirs("platform", specific("not_supported"), `Can't ${doing()}. This board doesn't support it
|
|
2356
|
+
if (status === 501) return theirs("platform", specific("not_supported"), `Can't ${doing()}. This board doesn't support it.`, unsupportedRecoveries());
|
|
2305
2357
|
if (code === "unreachable") return theirs("network", "network_error", "Couldn't reach the board.");
|
|
2306
2358
|
return theirs("platform", "api_error", `Failed to ${doing()}.`);
|
|
2307
2359
|
}
|
|
2360
|
+
/** The options that say which board this run is on, and as whom, as typed: what a way out to another command keeps. */
|
|
2361
|
+
const onThisBoard = () => [
|
|
2362
|
+
...flags.url !== void 0 ? ["--url", flags.url] : [],
|
|
2363
|
+
...(flags.scope ?? flags.team) !== void 0 ? ["--scope", flags.scope ?? flags.team] : [],
|
|
2364
|
+
...flags.name !== void 0 ? ["--name", flags.name] : [],
|
|
2365
|
+
...flags.as ? ["--as", flags.as] : []
|
|
2366
|
+
];
|
|
2367
|
+
/** Where to go from a 403: what you may do on this board, and who can let you do more. */
|
|
2368
|
+
const refusedRecoveries = () => [{
|
|
2369
|
+
instruction: "See what you can do on this board",
|
|
2370
|
+
argv: [
|
|
2371
|
+
...cli(),
|
|
2372
|
+
"whoami",
|
|
2373
|
+
...onThisBoard()
|
|
2374
|
+
]
|
|
2375
|
+
}, { instruction: "Or ask someone who manages the board's grants to give you access" }];
|
|
2376
|
+
/** The filters a board answers 501 to on a read when it keeps no index of them, as Vercel's does. */
|
|
2377
|
+
const UNINDEXED = [
|
|
2378
|
+
"--by",
|
|
2379
|
+
"--mentions",
|
|
2380
|
+
"--source",
|
|
2381
|
+
"--text"
|
|
2382
|
+
];
|
|
2383
|
+
/**
|
|
2384
|
+
* What to run instead of what a board answered 501 to, by what this run asked for: the same without
|
|
2385
|
+
* the part a board may not do (a read's search filters or its every channel, a post's `--sync`, a
|
|
2386
|
+
* schedule's files). Nothing when it asked for none of them.
|
|
2387
|
+
*/
|
|
2388
|
+
function unsupportedRecoveries() {
|
|
2389
|
+
const { command, args } = current;
|
|
2390
|
+
const given = (option) => flags[option.slice(2)] !== void 0;
|
|
2391
|
+
if (command === "read") {
|
|
2392
|
+
const filtered = UNINDEXED.filter(given);
|
|
2393
|
+
const target = args[0];
|
|
2394
|
+
const whole = target === void 0 || target.endsWith("/") && !isMessageRef(target);
|
|
2395
|
+
if (!filtered.length && !whole) return [];
|
|
2396
|
+
const argv = rerunWithout(filtered);
|
|
2397
|
+
if (whole) {
|
|
2398
|
+
const at = argv.indexOf(positionals[0], cli().length);
|
|
2399
|
+
argv.splice(at + 1, target === void 0 ? 0 : 1, "<CHANNEL>");
|
|
2400
|
+
}
|
|
2401
|
+
return [...whole ? [{
|
|
2402
|
+
instruction: "See the channels",
|
|
2403
|
+
argv: [
|
|
2404
|
+
...cli(),
|
|
2405
|
+
"channels",
|
|
2406
|
+
...target !== void 0 ? [target] : [],
|
|
2407
|
+
...onThisBoard()
|
|
2408
|
+
]
|
|
2409
|
+
}] : [], {
|
|
2410
|
+
instruction: whole ? `Read one channel at a time${filtered.length ? `, without ${filtered.join(" or ")}` : ""}` : `Read it without ${filtered.join(" or ")}, and look through it`,
|
|
2411
|
+
argv
|
|
2412
|
+
}];
|
|
2413
|
+
}
|
|
2414
|
+
if ((command === "post" || command === "reply") && given("--sync")) return [{
|
|
2415
|
+
instruction: "Post it without --sync",
|
|
2416
|
+
argv: rerunWithout(["--sync"])
|
|
2417
|
+
}];
|
|
2418
|
+
if (command === "schedule" && given("--attach")) return [{
|
|
2419
|
+
instruction: "Schedule the text without its files",
|
|
2420
|
+
argv: rerunWithout(["--attach"])
|
|
2421
|
+
}];
|
|
2422
|
+
return [];
|
|
2423
|
+
}
|
|
2308
2424
|
/** `42s`, `2m`: a wait the way people say it. */
|
|
2309
2425
|
const waitFor = (seconds) => seconds < 120 ? `${Math.max(1, seconds)}s` : `${Math.ceil(seconds / 60)}m`;
|
|
2310
2426
|
/** How this run ends with `failure`: shown on stderr, or by the app, and its exit code. */
|
|
@@ -2333,6 +2449,21 @@ function vercelBoard(url) {
|
|
|
2333
2449
|
...team ? { team } : {}
|
|
2334
2450
|
};
|
|
2335
2451
|
}
|
|
2452
|
+
/**
|
|
2453
|
+
* Whether this run's board is a team's board in Vercel's API, as its flags and environment say,
|
|
2454
|
+
* without a request: undefined when they don't say (an in-process handle, or no board to use).
|
|
2455
|
+
*/
|
|
2456
|
+
function onTeamBoard() {
|
|
2457
|
+
if (io.board) return void 0;
|
|
2458
|
+
try {
|
|
2459
|
+
if (flags.url !== void 0) return vercelBoard(flags.url) !== null;
|
|
2460
|
+
if (flags.scope !== void 0 || flags.team !== void 0 || flags.name !== void 0) return true;
|
|
2461
|
+
const url = configuredUrl();
|
|
2462
|
+
return url === null || vercelBoard(url) !== null;
|
|
2463
|
+
} catch {
|
|
2464
|
+
return;
|
|
2465
|
+
}
|
|
2466
|
+
}
|
|
2336
2467
|
/** Who the handle writes as: `--as`'s profile (with `--avatar`), or what the environment says (`BOARD_PROFILE`), else yourself. */
|
|
2337
2468
|
function profileFlag() {
|
|
2338
2469
|
if (flags.avatar !== void 0 && !flags.as) throw usage("--avatar is the avatar of the profile --as names: pass --as too.", { reason: "missing_arguments" });
|
|
@@ -2354,6 +2485,7 @@ function connection(url = flags.url, options = {}) {
|
|
|
2354
2485
|
const name = boardNameFlag(url, team);
|
|
2355
2486
|
const configured = url ?? (team === void 0 && name === void 0 ? configuredUrl() : null);
|
|
2356
2487
|
if (configured === null) {
|
|
2488
|
+
if (name === void 0) teamDefault = { team };
|
|
2357
2489
|
const board$1 = board({
|
|
2358
2490
|
backend: vercel({
|
|
2359
2491
|
...team !== void 0 ? { team } : {},
|
|
@@ -2699,7 +2831,7 @@ async function run(command, args) {
|
|
|
2699
2831
|
...working,
|
|
2700
2832
|
...mentionedIn([thread.message, ...replies])
|
|
2701
2833
|
])].filter((id) => !authors.has(id));
|
|
2702
|
-
const listed = unnamed.length ?
|
|
2834
|
+
const listed = unnamed.length ? await board.actors({ id: unnamed }).catch(() => []) : [];
|
|
2703
2835
|
const known = new Map(listed.map((a) => [a.id, actorName(a)]));
|
|
2704
2836
|
out(formatThreads([thread.message, ...replies], known, new Map(listed.map((a) => [a.id, a.handle]))));
|
|
2705
2837
|
if (!narrowed) for (const schedule of thread.schedules ?? []) out(formatSchedule(schedule, { pad: " " }));
|
|
@@ -2707,7 +2839,7 @@ async function run(command, args) {
|
|
|
2707
2839
|
}
|
|
2708
2840
|
const limit = flags.limit ? Number(flags.limit) : 50;
|
|
2709
2841
|
if (flags.before !== void 0 && flags.after !== void 0) throw usage("Can't use --before with --after. One pages back, the other reads forward.");
|
|
2710
|
-
const peek = !(target !== void 0 && !target.endsWith("/") && Object.keys(filters()).
|
|
2842
|
+
const peek = !(target !== void 0 && !target.endsWith("/") && Object.keys(filters()).every((key) => key === "mentions" || key === "text")) && !flags.json && flags.before === void 0 && Number.isInteger(limit) && limit >= 1 && limit < 500;
|
|
2711
2843
|
const query = {
|
|
2712
2844
|
...filters(target),
|
|
2713
2845
|
...flags.before !== void 0 ? { before: flags.before } : {},
|
|
@@ -2724,19 +2856,32 @@ async function run(command, args) {
|
|
|
2724
2856
|
...listed,
|
|
2725
2857
|
threads: flags.after !== void 0 ? listed.threads.slice(0, limit) : listed.threads.slice(-limit)
|
|
2726
2858
|
} : listed;
|
|
2727
|
-
|
|
2859
|
+
const scanned = typeof listed.scanned === "number" ? listed.scanned : void 0;
|
|
2860
|
+
if (!page.threads.length && target && !scanned) {
|
|
2728
2861
|
const channels = (await everyChannel(board)).map((c) => c.path);
|
|
2729
2862
|
if (!channels.some((path) => path === target || path.startsWith(target.replace(/\/?$/, "/")))) {
|
|
2730
|
-
const
|
|
2863
|
+
const partial = partialApiId(target);
|
|
2864
|
+
const guess = partial ? partial.root : closestChannel(target, channels);
|
|
2731
2865
|
throw new Failed({
|
|
2732
2866
|
class: "not_found",
|
|
2733
2867
|
reason: "channel_not_found",
|
|
2734
2868
|
message: `Couldn't find channel ${target}.${guess ? ` Did you mean ${guess}?` : ""}`,
|
|
2735
|
-
details: [
|
|
2869
|
+
details: [
|
|
2870
|
+
...partial ? [`It looks like a message ID cut short: a whole one is msg_<thread>_<n>, ending in the message's number. Check the full ID.`] : [],
|
|
2871
|
+
"A channel appears with its first post: one nobody has posted in yet is not there to read.",
|
|
2872
|
+
...teamDefault ? [`This is ${teamDefault.team ?? "the team"}'s default board: --name reads another of its boards.`] : []
|
|
2873
|
+
],
|
|
2736
2874
|
next: [{
|
|
2737
2875
|
instruction: "See its channels",
|
|
2738
|
-
argv: [
|
|
2739
|
-
|
|
2876
|
+
argv: [
|
|
2877
|
+
...cli(),
|
|
2878
|
+
"channels",
|
|
2879
|
+
...teamDefault?.team !== void 0 ? ["--scope", teamDefault.team] : []
|
|
2880
|
+
]
|
|
2881
|
+
}, ...teamDefault ? [{
|
|
2882
|
+
instruction: "Read it on another of the team's boards",
|
|
2883
|
+
argv: rerun("--name", "<BOARD>")
|
|
2884
|
+
}] : []]
|
|
2740
2885
|
});
|
|
2741
2886
|
}
|
|
2742
2887
|
}
|
|
@@ -2747,12 +2892,13 @@ async function run(command, args) {
|
|
|
2747
2892
|
const roots = page.threads.map(({ message }) => message);
|
|
2748
2893
|
const wrote = new Set(page.threads.flatMap(({ message, last }) => last ? [message.by.actor, last.by.actor] : [message.by.actor]));
|
|
2749
2894
|
const unnamed = mentionedIn(roots).filter((id) => !wrote.has(id));
|
|
2750
|
-
const handles = new Map(unnamed.length ? (await
|
|
2895
|
+
const handles = new Map(unnamed.length ? (await board.actors({ id: unnamed }).catch(() => [])).map((a) => [a.id, a.handle]) : []);
|
|
2751
2896
|
out(formatThreadSummaries(page.threads, {
|
|
2752
2897
|
channel: !target || target.endsWith("/"),
|
|
2753
2898
|
handles
|
|
2754
2899
|
}));
|
|
2755
2900
|
}
|
|
2901
|
+
if (scanned !== void 0) out(`\n(looked through ${scanned} ${scanned === 1 ? "thread" : "threads"}, at the first and latest message of each: a match under a newer reply is not found)`);
|
|
2756
2902
|
const latest = page.threads.at(-1);
|
|
2757
2903
|
if (more && flags.after !== void 0 && latest) {
|
|
2758
2904
|
if (![
|
|
@@ -2768,6 +2914,16 @@ async function run(command, args) {
|
|
|
2768
2914
|
}
|
|
2769
2915
|
if (more) out(older !== void 0 ? `\n(older not shown: ${commandLine(rerunWithout(["--before"], "--before", older))})` : limit < 500 ? `\n(older not shown: ${commandLine(rerunWithout(["--limit", "-n"], "--limit", String(Math.min(500, limit * 2))))})` : `\n(older not shown: 500 is the most a read lists, so read one channel and page back with --before, or narrow it with --label)`);
|
|
2770
2916
|
if (flags.before !== void 0) return 0;
|
|
2917
|
+
if (scanned !== void 0) {
|
|
2918
|
+
const argv = rerunWithout([
|
|
2919
|
+
"--after",
|
|
2920
|
+
"--limit",
|
|
2921
|
+
"-n"
|
|
2922
|
+
], "--after", String(page.cursor));
|
|
2923
|
+
argv[argv.indexOf("read", cli().length)] = "wait";
|
|
2924
|
+
out(`\nnew since then: ${commandLine(argv)}`);
|
|
2925
|
+
return 0;
|
|
2926
|
+
}
|
|
2771
2927
|
out(`\nnew since then: ${commandLine(rerunWithout(["--after"], "--after", String(page.cursor)))}`);
|
|
2772
2928
|
return 0;
|
|
2773
2929
|
}
|
|
@@ -3263,21 +3419,28 @@ async function run(command, args) {
|
|
|
3263
3419
|
default: {
|
|
3264
3420
|
const own = app.commands[command];
|
|
3265
3421
|
if (own) return own.run(args, context());
|
|
3266
|
-
|
|
3267
|
-
const said = Object.hasOwn(OTHER_NAMES, command.toLowerCase()) ? OTHER_NAMES[command.toLowerCase()] : void 0;
|
|
3268
|
-
throw usage(`Unknown command ${command} for ${named()}.${said ? "" : guess ? ` Did you mean ${guess}?` : ""}`, {
|
|
3269
|
-
reason: "unknown_command",
|
|
3270
|
-
next: [...said ? [{
|
|
3271
|
-
instruction: said.instruction,
|
|
3272
|
-
argv: [...cli(), ...said.argv]
|
|
3273
|
-
}] : [], {
|
|
3274
|
-
instruction: "See all commands",
|
|
3275
|
-
argv: [...cli(), "--help"]
|
|
3276
|
-
}]
|
|
3277
|
-
});
|
|
3422
|
+
throw unknownCommand(command);
|
|
3278
3423
|
}
|
|
3279
3424
|
}
|
|
3280
3425
|
}
|
|
3426
|
+
/** Every name a command runs by here: board's, their aliases, and the app's own. */
|
|
3427
|
+
const commandNames = () => [...commands.flatMap((known) => [known.name, ...known.aliases ?? []]), ...Object.keys(app.commands)];
|
|
3428
|
+
/** `command` names nothing here: the closest that does, or what it goes by here. */
|
|
3429
|
+
function unknownCommand(command) {
|
|
3430
|
+
const guess = closest(command, commandNames());
|
|
3431
|
+
const other = Object.hasOwn(OTHER_NAMES, command.toLowerCase()) ? OTHER_NAMES[command.toLowerCase()] : void 0;
|
|
3432
|
+
const said = other?.teams && onTeamBoard() !== false ? other.teams : other;
|
|
3433
|
+
return usage(`Unknown command ${command} for ${named()}.${said ? "" : guess ? ` Did you mean ${guess}?` : ""}`, {
|
|
3434
|
+
reason: "unknown_command",
|
|
3435
|
+
next: [...said ? [{
|
|
3436
|
+
instruction: said.instruction,
|
|
3437
|
+
argv: [...cli(), ...said.argv]
|
|
3438
|
+
}] : [], {
|
|
3439
|
+
instruction: "See all commands",
|
|
3440
|
+
argv: [...cli(), "--help"]
|
|
3441
|
+
}]
|
|
3442
|
+
});
|
|
3443
|
+
}
|
|
3281
3444
|
/** What `tasks` does to a task, by the word after it: any other word is a channel to list. */
|
|
3282
3445
|
const TASK_VERBS = /* @__PURE__ */ new Set([
|
|
3283
3446
|
"create",
|
|
@@ -3328,7 +3491,9 @@ function seconds(flag) {
|
|
|
3328
3491
|
*/
|
|
3329
3492
|
async function createPlan(target, text, path) {
|
|
3330
3493
|
if (isMessageRef(target)) throw usage(`--file holds a plan, which starts threads in a channel, and ${ref(target)} is a thread.`);
|
|
3331
|
-
|
|
3494
|
+
if (text !== void 0) throw usage("Text is one task's: with --file, each task in the file has its own.");
|
|
3495
|
+
const parsed = await planSource(path);
|
|
3496
|
+
const own = [
|
|
3332
3497
|
"label",
|
|
3333
3498
|
"needs",
|
|
3334
3499
|
"for",
|
|
@@ -3336,9 +3501,9 @@ async function createPlan(target, text, path) {
|
|
|
3336
3501
|
"lease",
|
|
3337
3502
|
"no-sync"
|
|
3338
3503
|
].find((name) => flags[name] !== void 0 && flags[name] !== false);
|
|
3339
|
-
if (own !== void 0) throw usage(
|
|
3504
|
+
if (own !== void 0) throw usage(`--${own} is one task's: with --file, each task in the file has its own.`);
|
|
3340
3505
|
const board = client();
|
|
3341
|
-
const tasks = await planFrom(path, board);
|
|
3506
|
+
const tasks = await planFrom(parsed, path, board);
|
|
3342
3507
|
sentLength = Math.max(0, ...tasks.map((task) => typeof task.text === "string" ? task.text.length : 0));
|
|
3343
3508
|
const key = flags["idempotency-key"] ?? crypto.randomUUID();
|
|
3344
3509
|
let made;
|
|
@@ -3446,8 +3611,12 @@ function checkPlan(plan, where) {
|
|
|
3446
3611
|
}
|
|
3447
3612
|
}
|
|
3448
3613
|
}
|
|
3449
|
-
/**
|
|
3450
|
-
|
|
3614
|
+
/**
|
|
3615
|
+
* What a plan's `--file` holds, as JSON: the file, or stdin for `-`. Prose is the likeliest slip,
|
|
3616
|
+
* --file carried over from post, where it's the text: it says the same command with the file on
|
|
3617
|
+
* stdin, `-` as the text, and the options it was given.
|
|
3618
|
+
*/
|
|
3619
|
+
async function planSource(path) {
|
|
3451
3620
|
const where = path === "-" ? "stdin" : path;
|
|
3452
3621
|
let source;
|
|
3453
3622
|
if (path === "-") source = await io.stdin();
|
|
@@ -3459,12 +3628,16 @@ async function planFrom(path, board) {
|
|
|
3459
3628
|
});
|
|
3460
3629
|
source = new TextDecoder().decode(data);
|
|
3461
3630
|
}
|
|
3462
|
-
let parsed;
|
|
3463
3631
|
try {
|
|
3464
|
-
|
|
3632
|
+
return JSON.parse(source);
|
|
3465
3633
|
} catch {
|
|
3466
|
-
|
|
3634
|
+
const piped = `${commandLine(rerunWithout(["--file"], "-"))}${path === "-" ? "" : ` < ${commandLine([path])}`}`;
|
|
3635
|
+
throw usage(`${where} isn't JSON: --file on tasks create is a plan of tasks.`, { next: [{ instruction: `One task's text goes on stdin, as -: ${piped}` }, planHelp()] });
|
|
3467
3636
|
}
|
|
3637
|
+
}
|
|
3638
|
+
/** The tasks a plan's `--file` holds: a JSON array. An ID may be written `#812`, and `for` as a profile's name. */
|
|
3639
|
+
async function planFrom(parsed, path, board) {
|
|
3640
|
+
const where = path === "-" ? "stdin" : path;
|
|
3468
3641
|
const shape = "A plan is a JSON array of tasks: [{\"key\": \"fix\", \"text\": \"…\"}, {\"text\": \"…\", \"needs\": [{\"key\": \"fix\"}]}].";
|
|
3469
3642
|
if (!Array.isArray(parsed) || parsed.length === 0 || parsed.some((task) => typeof task !== "object" || task === null || Array.isArray(task))) throw usage(`${where} holds no tasks. ${shape}`, { next: [planHelp()] });
|
|
3470
3643
|
const plan = parsed;
|
|
@@ -3542,22 +3715,69 @@ function printClaim(task, claim, more = {}) {
|
|
|
3542
3715
|
*/
|
|
3543
3716
|
async function heldBy(board, claims, id) {
|
|
3544
3717
|
const stored = await claims.get(id);
|
|
3545
|
-
if (
|
|
3718
|
+
if (stored) return board.tasks.held(id, stored);
|
|
3719
|
+
const none = `You hold no claim on task ${ref(id)} as ${writesAs() ?? "yourself"}.`;
|
|
3720
|
+
const claim = {
|
|
3721
|
+
instruction: "Claim it",
|
|
3722
|
+
argv: [
|
|
3723
|
+
...cli(),
|
|
3724
|
+
"tasks",
|
|
3725
|
+
"claim",
|
|
3726
|
+
id,
|
|
3727
|
+
...asTyped()
|
|
3728
|
+
]
|
|
3729
|
+
};
|
|
3730
|
+
const task = await board.thread(id).then(({ message }) => message.task, () => void 0);
|
|
3731
|
+
const see = {
|
|
3732
|
+
instruction: "See where it stands",
|
|
3733
|
+
argv: [
|
|
3734
|
+
...cli(),
|
|
3735
|
+
"read",
|
|
3736
|
+
id
|
|
3737
|
+
]
|
|
3738
|
+
};
|
|
3739
|
+
if (task?.state === "blocked") throw new Failed({
|
|
3546
3740
|
class: "conflict",
|
|
3547
3741
|
reason: "claim_not_held",
|
|
3548
|
-
message:
|
|
3742
|
+
message: `${none} It's held for a person: claim it once the hold lifts.`,
|
|
3549
3743
|
next: [{
|
|
3550
|
-
instruction: "
|
|
3744
|
+
instruction: "As its owner, lift the hold, then claim it",
|
|
3551
3745
|
argv: [
|
|
3552
3746
|
...cli(),
|
|
3553
3747
|
"tasks",
|
|
3554
|
-
"
|
|
3555
|
-
id
|
|
3556
|
-
...asTyped()
|
|
3748
|
+
"unblock",
|
|
3749
|
+
id
|
|
3557
3750
|
]
|
|
3558
|
-
}]
|
|
3751
|
+
}, see]
|
|
3752
|
+
});
|
|
3753
|
+
if (task?.state === "waiting") {
|
|
3754
|
+
const needs = task.needs.map(ref);
|
|
3755
|
+
throw new Failed({
|
|
3756
|
+
class: "conflict",
|
|
3757
|
+
reason: "claim_not_held",
|
|
3758
|
+
message: `${none} It waits for what it needs${needs.length ? ` (${needs.join(", ")})` : ""}: claim it once those complete.`,
|
|
3759
|
+
next: [{
|
|
3760
|
+
instruction: "See what it waits for",
|
|
3761
|
+
argv: [
|
|
3762
|
+
...cli(),
|
|
3763
|
+
"read",
|
|
3764
|
+
id
|
|
3765
|
+
]
|
|
3766
|
+
}]
|
|
3767
|
+
});
|
|
3768
|
+
}
|
|
3769
|
+
if (task?.state === "completed" || task?.state === "failed" || task?.state === "canceled") throw new Failed({
|
|
3770
|
+
class: "conflict",
|
|
3771
|
+
reason: "claim_not_held",
|
|
3772
|
+
message: `${none} It's ${task.state} already.`,
|
|
3773
|
+
next: [see]
|
|
3774
|
+
});
|
|
3775
|
+
throw new Failed({
|
|
3776
|
+
class: "conflict",
|
|
3777
|
+
reason: "claim_not_held",
|
|
3778
|
+
message: none,
|
|
3779
|
+
next: [claim]
|
|
3559
3780
|
});
|
|
3560
|
-
return board.tasks.held(id, stored);
|
|
3561
3781
|
}
|
|
3562
3782
|
/** A write a claim makes. One the board answers `claim_lost` is over: the CLI forgets it, and the failure says how to claim again. */
|
|
3563
3783
|
async function withClaim(claims, id, write) {
|
|
@@ -3569,11 +3789,47 @@ async function withClaim(claims, id, write) {
|
|
|
3569
3789
|
}
|
|
3570
3790
|
}
|
|
3571
3791
|
/**
|
|
3792
|
+
* `--label` on `claim --ready` and `run --ready`: each an exact `key=value`, the one thing a claim
|
|
3793
|
+
* matches. The list's `key=a|b` and bare `key` would match nothing, or the value `a|b`, and wait
|
|
3794
|
+
* out its `--wait` without a word: they're refused, with the claim of one value and the list.
|
|
3795
|
+
*/
|
|
3796
|
+
function readyLabels(values, target, verb) {
|
|
3797
|
+
for (const value of values) {
|
|
3798
|
+
const at = value.indexOf("=");
|
|
3799
|
+
const options = at > 0 ? value.slice(at + 1).split("|") : [];
|
|
3800
|
+
if (at > 0 && options.length < 2) continue;
|
|
3801
|
+
const key = at > 0 ? value.slice(0, at) : value;
|
|
3802
|
+
if (at === 0) throw usage(`--label on ${verb} --ready takes key=value, and ${value} has no key before its =.`);
|
|
3803
|
+
const listed = {
|
|
3804
|
+
instruction: "See what's ready, and their labels",
|
|
3805
|
+
argv: [
|
|
3806
|
+
...cli(),
|
|
3807
|
+
"tasks",
|
|
3808
|
+
target,
|
|
3809
|
+
"--state",
|
|
3810
|
+
"ready",
|
|
3811
|
+
"--label",
|
|
3812
|
+
value
|
|
3813
|
+
]
|
|
3814
|
+
};
|
|
3815
|
+
if (at === -1) throw usage(`--label on ${verb} --ready takes key=value: ${value} has no value, and a claim matches one exactly.`, { next: [listed] });
|
|
3816
|
+
const one = `${key}=${options[0]}`;
|
|
3817
|
+
const dash = typed.indexOf("--");
|
|
3818
|
+
const ours = (index) => dash === -1 || index < dash;
|
|
3819
|
+
const again = [...cli(), ...typed.map((arg, index) => !ours(index) ? arg : arg === value && typed[index - 1] === "--label" ? one : arg === `--label=${value}` ? `--label=${one}` : arg)];
|
|
3820
|
+
throw usage(`--label on ${verb} --ready takes one value: ${value} has ${options.length}, and a claim matches one exactly.`, { next: [{
|
|
3821
|
+
instruction: `Claim one with ${one}`,
|
|
3822
|
+
argv: again
|
|
3823
|
+
}, listed] });
|
|
3824
|
+
}
|
|
3825
|
+
return labelPairs(values);
|
|
3826
|
+
}
|
|
3827
|
+
/**
|
|
3572
3828
|
* Claims a task for this run, by its ID or with `--ready` the oldest ready one in `target`, and
|
|
3573
3829
|
* keeps the claim. With nothing ready it fails: `nothing_ready`, or `timeout` once `--wait` ran
|
|
3574
3830
|
* out, as `wait` does. Stopped while it waits, it answers the exit code instead.
|
|
3575
3831
|
*/
|
|
3576
|
-
async function claimFor(board, claims, target) {
|
|
3832
|
+
async function claimFor(board, claims, target, verb) {
|
|
3577
3833
|
const lease = seconds("lease");
|
|
3578
3834
|
if (!flags.ready) {
|
|
3579
3835
|
for (const given of [
|
|
@@ -3604,7 +3860,7 @@ async function claimFor(board, claims, target) {
|
|
|
3604
3860
|
try {
|
|
3605
3861
|
claim = await board.tasks.claim({
|
|
3606
3862
|
channel: target,
|
|
3607
|
-
...flags.label?.length ? { label:
|
|
3863
|
+
...flags.label?.length ? { label: readyLabels(flags.label, target, verb) } : {},
|
|
3608
3864
|
...flags.from?.length ? { from: flags.from } : {},
|
|
3609
3865
|
...wait !== void 0 ? { wait } : {},
|
|
3610
3866
|
...lease !== void 0 ? { lease } : {},
|
|
@@ -3674,7 +3930,7 @@ async function tasks(args) {
|
|
|
3674
3930
|
if (!channels.some((path) => path === name || path.startsWith(`${name}/`))) {
|
|
3675
3931
|
const meant = closest(verb, TASK_VERBS);
|
|
3676
3932
|
if (meant) throw usage(`Unknown command ${verb} for ${named()} tasks. Did you mean ${meant}?`, { reason: "unknown_command" });
|
|
3677
|
-
const guess =
|
|
3933
|
+
const guess = closestChannel(verb, channels);
|
|
3678
3934
|
throw new Failed({
|
|
3679
3935
|
class: "not_found",
|
|
3680
3936
|
reason: "channel_not_found",
|
|
@@ -3763,7 +4019,7 @@ async function tasks(args) {
|
|
|
3763
4019
|
if (rest.length > 1) throw usage(`tasks claim takes one ${flags.ready ? "channel" : "task"}: ${rest[1]} is one too many.`);
|
|
3764
4020
|
if (!flags.ready && rest[0] === void 0) throw usage("Missing the task to claim: its ID, or --ready and a channel.", { reason: "missing_arguments" });
|
|
3765
4021
|
const { board, claims } = tasksOn();
|
|
3766
|
-
const claim = await claimFor(board, claims, rest[0]);
|
|
4022
|
+
const claim = await claimFor(board, claims, rest[0], "claim");
|
|
3767
4023
|
if (typeof claim === "number") return claim;
|
|
3768
4024
|
printClaim(claim.task, claim);
|
|
3769
4025
|
return 0;
|
|
@@ -3793,7 +4049,7 @@ async function tasks(args) {
|
|
|
3793
4049
|
next: []
|
|
3794
4050
|
});
|
|
3795
4051
|
const { board, claims } = tasksOn();
|
|
3796
|
-
const claim = await claimFor(board, claims, before[0]);
|
|
4052
|
+
const claim = await claimFor(board, claims, before[0], "run");
|
|
3797
4053
|
if (typeof claim === "number") return claim;
|
|
3798
4054
|
const id = claim.task.id;
|
|
3799
4055
|
const lease = seconds("lease");
|
|
@@ -4143,35 +4399,33 @@ function stateCommand() {
|
|
|
4143
4399
|
if (flags.label?.some((pair) => pair === "board.task" || pair.startsWith("board.task=")) && command === "post" && args[0] !== void 0 && !isMessageRef(args[0])) return [tasksDo("Start it as a task", "create", args[0], "<TEXT>")];
|
|
4144
4400
|
return [];
|
|
4145
4401
|
}
|
|
4146
|
-
/**
|
|
4147
|
-
const
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
find: {
|
|
4158
|
-
instruction: "Search is a filter on read",
|
|
4159
|
-
argv: [
|
|
4160
|
-
"read",
|
|
4161
|
-
"<CHANNEL>",
|
|
4162
|
-
"--text",
|
|
4163
|
-
"<PHRASE>"
|
|
4164
|
-
]
|
|
4165
|
-
},
|
|
4166
|
-
grep: {
|
|
4167
|
-
instruction: "Search is a filter on read",
|
|
4402
|
+
/** Search: a filter on read. Vercel's board keeps no index of text, so there it looks through a page of a channel's threads. */
|
|
4403
|
+
const SEARCH = {
|
|
4404
|
+
instruction: "Search is a filter on read",
|
|
4405
|
+
argv: [
|
|
4406
|
+
"read",
|
|
4407
|
+
"<CHANNEL>",
|
|
4408
|
+
"--text",
|
|
4409
|
+
"<PHRASE>"
|
|
4410
|
+
],
|
|
4411
|
+
teams: {
|
|
4412
|
+
instruction: "Search a channel's latest threads, a page at a time, since this board keeps no text search",
|
|
4168
4413
|
argv: [
|
|
4169
4414
|
"read",
|
|
4170
4415
|
"<CHANNEL>",
|
|
4171
4416
|
"--text",
|
|
4172
4417
|
"<PHRASE>"
|
|
4173
4418
|
]
|
|
4174
|
-
}
|
|
4419
|
+
}
|
|
4420
|
+
};
|
|
4421
|
+
/**
|
|
4422
|
+
* Words for a command this CLI names otherwise, and the command they mean: on a team's board in
|
|
4423
|
+
* Vercel's API, `teams`, where it reads one channel's page (or when nothing says which board).
|
|
4424
|
+
*/
|
|
4425
|
+
const OTHER_NAMES = {
|
|
4426
|
+
search: SEARCH,
|
|
4427
|
+
find: SEARCH,
|
|
4428
|
+
grep: SEARCH,
|
|
4175
4429
|
list: {
|
|
4176
4430
|
instruction: "List a channel's threads with read",
|
|
4177
4431
|
argv: ["read", "<CHANNEL>"]
|
|
@@ -4303,23 +4557,20 @@ const OTHER_NAMES = {
|
|
|
4303
4557
|
]
|
|
4304
4558
|
},
|
|
4305
4559
|
claim: {
|
|
4306
|
-
instruction: "
|
|
4560
|
+
instruction: "Hold a task with tasks claim",
|
|
4307
4561
|
argv: [
|
|
4308
|
-
"
|
|
4309
|
-
"
|
|
4310
|
-
"
|
|
4311
|
-
"--if-unset",
|
|
4312
|
-
"owner"
|
|
4562
|
+
"tasks",
|
|
4563
|
+
"claim",
|
|
4564
|
+
"<ID>"
|
|
4313
4565
|
]
|
|
4314
4566
|
},
|
|
4315
4567
|
assign: {
|
|
4316
|
-
instruction: "
|
|
4568
|
+
instruction: "Keep a task for one of its owner's profiles",
|
|
4317
4569
|
argv: [
|
|
4318
|
-
"
|
|
4570
|
+
"tasks",
|
|
4571
|
+
"assign",
|
|
4319
4572
|
"<ID>",
|
|
4320
|
-
"
|
|
4321
|
-
"--if-unset",
|
|
4322
|
-
"owner"
|
|
4573
|
+
"<PROFILE>"
|
|
4323
4574
|
]
|
|
4324
4575
|
},
|
|
4325
4576
|
tag: {
|
|
@@ -4340,7 +4591,15 @@ const OTHER_NAMES = {
|
|
|
4340
4591
|
},
|
|
4341
4592
|
mentions: {
|
|
4342
4593
|
instruction: "Mentions are a filter on read and wait",
|
|
4343
|
-
argv: ["read", "--mentions"]
|
|
4594
|
+
argv: ["read", "--mentions"],
|
|
4595
|
+
teams: {
|
|
4596
|
+
instruction: "Read what mentions you in a channel's latest threads, then wait from where it stops",
|
|
4597
|
+
argv: [
|
|
4598
|
+
"read",
|
|
4599
|
+
"<CHANNEL>",
|
|
4600
|
+
"--mentions"
|
|
4601
|
+
]
|
|
4602
|
+
}
|
|
4344
4603
|
},
|
|
4345
4604
|
watch: {
|
|
4346
4605
|
instruction: "Block for the next match with wait, or follow live with tail",
|
|
@@ -4450,6 +4709,7 @@ async function runOnce(argv, options) {
|
|
|
4450
4709
|
positionals = [];
|
|
4451
4710
|
warnings = [];
|
|
4452
4711
|
reached = null;
|
|
4712
|
+
teamDefault = null;
|
|
4453
4713
|
sent = () => null;
|
|
4454
4714
|
sentLength = 0;
|
|
4455
4715
|
self = null;
|