@skillcdn/console 0.6.2 → 0.6.3
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 +13 -6
- package/SKILLCDN.md +3 -2
- package/dist/agent-page.d.ts +2 -0
- package/dist/agent-page.d.ts.map +1 -1
- package/dist/agent-page.js +40 -3
- package/dist/agent-page.js.map +1 -1
- package/dist/agent-state.d.ts +9 -0
- package/dist/agent-state.d.ts.map +1 -0
- package/dist/agent-state.js +28 -0
- package/dist/agent-state.js.map +1 -0
- package/dist/api.d.ts +4 -3
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +4 -3
- package/dist/api.js.map +1 -1
- package/dist/cli/cli.d.ts +2 -0
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +304 -130
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/format.d.ts +13 -4
- package/dist/cli/format.d.ts.map +1 -1
- package/dist/cli/format.js +43 -9
- package/dist/cli/format.js.map +1 -1
- package/dist/cli/help.d.ts +82 -9
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +780 -318
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/pack.d.ts +2 -2
- package/dist/cli/pack.d.ts.map +1 -1
- package/dist/cli/pack.js +6 -4
- package/dist/cli/pack.js.map +1 -1
- package/dist/cli/runner-files.d.ts +16 -0
- package/dist/cli/runner-files.d.ts.map +1 -0
- package/dist/cli/runner-files.js +110 -0
- package/dist/cli/runner-files.js.map +1 -0
- package/dist/cli/runner-host.d.ts +7 -0
- package/dist/cli/runner-host.d.ts.map +1 -1
- package/dist/cli/runner-host.js +40 -2
- package/dist/cli/runner-host.js.map +1 -1
- package/dist/client.d.ts +16 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +6 -1
- package/dist/client.js.map +1 -1
- package/dist/components/agent-page.d.ts +28 -3
- package/dist/components/agent-page.d.ts.map +1 -1
- package/dist/components/agent-page.js +48 -3
- package/dist/components/agent-page.js.map +1 -1
- package/dist/components/agents.d.ts +3 -2
- package/dist/components/agents.d.ts.map +1 -1
- package/dist/components/agents.js +9 -3
- package/dist/components/agents.js.map +1 -1
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js +1 -1
- package/dist/console.js.map +1 -1
- package/dist/feed-words.d.ts.map +1 -1
- package/dist/feed-words.js +12 -1
- package/dist/feed-words.js.map +1 -1
- package/dist/i18n/en.d.ts +45 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +36 -1
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/ko.d.ts.map +1 -1
- package/dist/i18n/ko.js +28 -0
- package/dist/i18n/ko.js.map +1 -1
- package/dist/limits.d.ts +10 -0
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +10 -0
- package/dist/limits.js.map +1 -1
- package/dist/plugin/context.d.ts +39 -7
- package/dist/plugin/context.d.ts.map +1 -1
- package/dist/runner/acp.d.ts.map +1 -1
- package/dist/runner/acp.js +9 -3
- package/dist/runner/acp.js.map +1 -1
- package/dist/runner/claude.d.ts.map +1 -1
- package/dist/runner/claude.js +5 -1
- package/dist/runner/claude.js.map +1 -1
- package/dist/runner/codex.d.ts.map +1 -1
- package/dist/runner/codex.js +14 -2
- package/dist/runner/codex.js.map +1 -1
- package/dist/runner/config.d.ts +18 -0
- package/dist/runner/config.d.ts.map +1 -1
- package/dist/runner/config.js +77 -1
- package/dist/runner/config.js.map +1 -1
- package/dist/runner/desk.d.ts +7 -0
- package/dist/runner/desk.d.ts.map +1 -1
- package/dist/runner/desk.js +9 -0
- package/dist/runner/desk.js.map +1 -1
- package/dist/runner/message.d.ts +16 -22
- package/dist/runner/message.d.ts.map +1 -1
- package/dist/runner/message.js +72 -120
- package/dist/runner/message.js.map +1 -1
- package/dist/runner/runner.d.ts +25 -1
- package/dist/runner/runner.d.ts.map +1 -1
- package/dist/runner/runner.js +404 -19
- package/dist/runner/runner.js.map +1 -1
- package/dist/runner/slack-status.d.ts +19 -0
- package/dist/runner/slack-status.d.ts.map +1 -0
- package/dist/runner/slack-status.js +332 -0
- package/dist/runner/slack-status.js.map +1 -0
- package/dist/runner/slack.d.ts.map +1 -1
- package/dist/runner/slack.js +245 -57
- package/dist/runner/slack.js.map +1 -1
- package/dist/runner/types.d.ts +109 -15
- package/dist/runner/types.d.ts.map +1 -1
- package/dist/runner/types.js.map +1 -1
- package/dist/runner/usage.d.ts +6 -1
- package/dist/runner/usage.d.ts.map +1 -1
- package/dist/runner/usage.js +9 -2
- package/dist/runner/usage.js.map +1 -1
- package/dist/runner.d.ts +2 -2
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js.map +1 -1
- package/dist/schemas.d.ts +160 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +82 -5
- package/dist/schemas.js.map +1 -1
- package/dist/vocabulary.d.ts +7 -0
- package/dist/vocabulary.d.ts.map +1 -1
- package/dist/vocabulary.js +6 -0
- package/dist/vocabulary.js.map +1 -1
- package/dist/wake-text.d.ts +43 -0
- package/dist/wake-text.d.ts.map +1 -0
- package/dist/wake-text.js +115 -0
- package/dist/wake-text.js.map +1 -0
- package/docs/specs/cli.md +19 -11
- package/docs/specs/plugins.md +5 -5
- package/docs/specs/rest.md +10 -3
- package/docs/specs/runner.md +96 -20
- package/docs/start.md +26 -5
- package/package.json +3 -3
- package/skills/building-a-plugin/SKILL.md +2 -2
- package/skills/deploying-a-console/SKILL.md +3 -3
- package/skills/deploying-a-console/references/access.md +15 -1
- package/skills/deploying-a-console/references/resources.md +2 -2
- package/skills/deploying-a-console/scripts/github-app.mjs +593 -0
- package/skills/running-an-agent/SKILL.md +13 -10
- package/skills/running-an-agent/references/preparing-the-machine.md +1 -1
- package/skills/running-an-agent/references/slack-app.md +25 -8
- package/skills/running-an-agent/references/the-account-and-the-invitation.md +1 -1
- package/skills/running-an-agent/references/what-was-not-seen-run-yet.md +1 -1
- package/skills/running-an-agent/references/when-the-agent-could-not-go-on.md +1 -1
- package/skills/running-an-agent/references/your-first-task.md +7 -2
- package/skills/trying-a-console/SKILL.md +136 -0
- package/skills/trying-a-console/references/when-it-does-not-go.md +30 -0
- package/skills/working-the-board/SKILL.md +3 -3
- package/skills/working-the-board/references/the-pack.md +3 -3
- package/skills/working-the-board/references/what-they-were-told.md +1 -1
- package/src/agent-page.tsx +92 -1
- package/src/agent-state.ts +33 -0
- package/src/api.ts +16 -0
- package/src/cli/cli.ts +359 -137
- package/src/cli/format.ts +49 -9
- package/src/cli/help.ts +904 -359
- package/src/cli/pack.ts +6 -4
- package/src/cli/runner-files.ts +120 -0
- package/src/cli/runner-host.ts +48 -2
- package/src/client.ts +53 -0
- package/src/components/agent-page.tsx +150 -3
- package/src/components/agents.tsx +20 -5
- package/src/console.tsx +1 -0
- package/src/feed-words.ts +14 -1
- package/src/i18n/en.ts +39 -1
- package/src/i18n/ko.ts +32 -0
- package/src/limits.ts +10 -0
- package/src/plugin/context.ts +40 -7
- package/src/runner/acp.ts +9 -3
- package/src/runner/claude.ts +5 -1
- package/src/runner/codex.ts +14 -2
- package/src/runner/config.ts +114 -1
- package/src/runner/desk.ts +10 -0
- package/src/runner/message.ts +88 -126
- package/src/runner/runner.ts +487 -22
- package/src/runner/slack-status.ts +423 -0
- package/src/runner/slack.ts +293 -61
- package/src/runner/types.ts +108 -13
- package/src/runner/usage.ts +16 -3
- package/src/runner.ts +4 -0
- package/src/schemas.ts +97 -3
- package/src/vocabulary.ts +9 -0
- package/src/wake-text.ts +133 -0
package/src/cli/cli.ts
CHANGED
|
@@ -76,13 +76,7 @@ import {
|
|
|
76
76
|
} from "../runner/desk.js";
|
|
77
77
|
import { quotedLines } from "../runner/message.js";
|
|
78
78
|
import { ownRunnerModules } from "../runner/modules.js";
|
|
79
|
-
import {
|
|
80
|
-
createRunner,
|
|
81
|
-
GIT_TOKEN_SECRET,
|
|
82
|
-
type Runner,
|
|
83
|
-
type RunnerEnd,
|
|
84
|
-
type RunnerState,
|
|
85
|
-
} from "../runner/runner.js";
|
|
79
|
+
import { createRunner, GIT_TOKEN_SECRET, type Runner, type RunnerEnd } from "../runner/runner.js";
|
|
86
80
|
import type { ServiceCommand } from "../runner/types.js";
|
|
87
81
|
import {
|
|
88
82
|
hostOfLogin,
|
|
@@ -199,6 +193,7 @@ import {
|
|
|
199
193
|
formatRun,
|
|
200
194
|
formatRunLine,
|
|
201
195
|
formatSecretLine,
|
|
196
|
+
formatSecretOffer,
|
|
202
197
|
formatSignalLine,
|
|
203
198
|
formatTask,
|
|
204
199
|
formatTaskFollow,
|
|
@@ -214,7 +209,15 @@ import {
|
|
|
214
209
|
rulesMark,
|
|
215
210
|
setMomentZone,
|
|
216
211
|
} from "./format.js";
|
|
217
|
-
import {
|
|
212
|
+
import {
|
|
213
|
+
COMMAND_ALIASES,
|
|
214
|
+
formTyped,
|
|
215
|
+
held,
|
|
216
|
+
helpFor,
|
|
217
|
+
nearestCommands,
|
|
218
|
+
ownSkillPath,
|
|
219
|
+
usage,
|
|
220
|
+
} from "./help.js";
|
|
218
221
|
import { describeInstall, type Install, updateCommandFor } from "./install.js";
|
|
219
222
|
import {
|
|
220
223
|
awakeWords,
|
|
@@ -238,6 +241,7 @@ import {
|
|
|
238
241
|
skillPathIn,
|
|
239
242
|
skillsAround,
|
|
240
243
|
} from "./pack.js";
|
|
244
|
+
import { keptBySourceOf, keptFileOf, runnerStateOf } from "./runner-files.js";
|
|
241
245
|
import { type RunnerHost, workPath } from "./runner-host.js";
|
|
242
246
|
import { secretNotes } from "./secret-notes.js";
|
|
243
247
|
import {
|
|
@@ -417,10 +421,47 @@ function parse(args: readonly string[], options: OptionSpec, allowPositionals =
|
|
|
417
421
|
strict: true,
|
|
418
422
|
});
|
|
419
423
|
} catch (error) {
|
|
420
|
-
throw misuse(error
|
|
424
|
+
throw misuse(refusedByParser(error, options));
|
|
421
425
|
}
|
|
422
426
|
}
|
|
423
427
|
|
|
428
|
+
/**
|
|
429
|
+
* What the parser refused, in the command's own words (ADR-0167): an option that is none of
|
|
430
|
+
* the command's is answered with those it takes, so that the next try needs no page of help;
|
|
431
|
+
* what the parser says of a value is said as it says it, without its advice on other things.
|
|
432
|
+
*/
|
|
433
|
+
function refusedByParser(error: unknown, options: OptionSpec): string {
|
|
434
|
+
if (!(error instanceof Error)) {
|
|
435
|
+
return "The arguments were not understood.";
|
|
436
|
+
}
|
|
437
|
+
const code = "code" in error ? String(error.code) : "";
|
|
438
|
+
// What was typed is between the parser's first quote and the one its sentence goes on
|
|
439
|
+
// after: a word may hold a quote of its own (`it's`), and is said whole.
|
|
440
|
+
const ADVICE = ". To specify a positional argument ";
|
|
441
|
+
const named =
|
|
442
|
+
(code === "ERR_PARSE_ARGS_UNKNOWN_OPTION"
|
|
443
|
+
? /^Unknown option '(.*?)'(?:\. To specify a positional argument .*)?$/s
|
|
444
|
+
: /^Unexpected argument '(.*)'\. This command does not take positional arguments$/s
|
|
445
|
+
).exec(error.message)?.[1] ??
|
|
446
|
+
/'([^']*)'/.exec(error.message)?.[1] ??
|
|
447
|
+
"";
|
|
448
|
+
if (code === "ERR_PARSE_ARGS_UNKNOWN_OPTION") {
|
|
449
|
+
const own = Object.keys(options).map((name) => `--${name}`);
|
|
450
|
+
const takes = own.length === 0 ? "It takes none of its own" : `Its own are ${own.join(", ")}`;
|
|
451
|
+
// A word of a report or a title may begin with a dash, and is then no option at all:
|
|
452
|
+
// said where the command takes a word, and what was typed does not read as an option.
|
|
453
|
+
const dashed =
|
|
454
|
+
!error.message.includes(ADVICE) || /^--[a-z][a-z0-9-]*$/.test(named)
|
|
455
|
+
? ""
|
|
456
|
+
: " A word that begins with - and is no option goes after --.";
|
|
457
|
+
return `Not an option of this command: ${named}. ${takes}; --json, --project, --url and --account go with every command.${dashed}`;
|
|
458
|
+
}
|
|
459
|
+
if (code === "ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL") {
|
|
460
|
+
return `This command takes no word beside its options: ${named}.`;
|
|
461
|
+
}
|
|
462
|
+
return error.message;
|
|
463
|
+
}
|
|
464
|
+
|
|
424
465
|
type Values = ReturnType<typeof parse>["values"];
|
|
425
466
|
|
|
426
467
|
const text = (values: Values, name: string): string | undefined => {
|
|
@@ -1608,7 +1649,7 @@ const whoami: Command = async (args, io) => {
|
|
|
1608
1649
|
// agent here for where the skill is, and the workspace has rules whatever the project.
|
|
1609
1650
|
// The skill's path stands last, with nothing after it, to be copied as it is.
|
|
1610
1651
|
io.skillsDir === undefined
|
|
1611
|
-
? "Before the first task, read console rules and the skill working-the-board (
|
|
1652
|
+
? "Before the first task, read console rules and the skill working-the-board (in the skills folder of the package @skillcdn/console, which this build has none of beside it); for one command's flags, console help <command>."
|
|
1612
1653
|
: `Before the first task, read console rules and the skill working-the-board; for one command's flags, console help <command>. The skill: ${ownSkillPath(io.skillsDir)}`,
|
|
1613
1654
|
`This command is ${io.version ?? "of a version it does not know"}${io.install === undefined ? "" : `, ${describeInstall(io.install)}`}; ${consoleWords}.`,
|
|
1614
1655
|
...(verdict === "behind"
|
|
@@ -1896,6 +1937,7 @@ async function readThrough(
|
|
|
1896
1937
|
options: {
|
|
1897
1938
|
readonly words: ToolWords;
|
|
1898
1939
|
readonly nextPart?: ((cursor: string) => string) | undefined;
|
|
1940
|
+
readonly browseFolder?: ((path: string) => string) | undefined;
|
|
1899
1941
|
readonly data?: boolean | undefined;
|
|
1900
1942
|
readonly beside?: readonly (string | undefined)[] | undefined;
|
|
1901
1943
|
},
|
|
@@ -1905,6 +1947,7 @@ async function readThrough(
|
|
|
1905
1947
|
words: options.words,
|
|
1906
1948
|
json: session.json,
|
|
1907
1949
|
nextPart: options.nextPart,
|
|
1950
|
+
browseFolder: options.browseFolder,
|
|
1908
1951
|
room: roomFor(owner, options.beside ?? []),
|
|
1909
1952
|
});
|
|
1910
1953
|
} catch (error) {
|
|
@@ -2184,28 +2227,54 @@ async function readSkills(
|
|
|
2184
2227
|
});
|
|
2185
2228
|
return EXIT.ok;
|
|
2186
2229
|
}
|
|
2230
|
+
// The command that reads the next page of a folder or of a search (SkillCDN 0.6.3): this
|
|
2231
|
+
// one again, asked as it was, with the cursor the page ended on. Where a word of it has no
|
|
2232
|
+
// spelling both shells take, the command that was run is run again, and the line says why.
|
|
2233
|
+
const nextPage =
|
|
2234
|
+
(asked: readonly string[]) =>
|
|
2235
|
+
(next: string): string =>
|
|
2236
|
+
commandLine(extras.command, [
|
|
2237
|
+
...asked,
|
|
2238
|
+
...(limit === undefined ? [] : ["--limit", limit]),
|
|
2239
|
+
"--cursor",
|
|
2240
|
+
next,
|
|
2241
|
+
...(extras.again ?? []),
|
|
2242
|
+
]) ??
|
|
2243
|
+
`the command you ran, with --cursor ${commandWord(next) ?? JSON.stringify(next)} in place of any it had, each word quoted for your shell. ${NO_LINE_TO_RUN}`;
|
|
2187
2244
|
if (words !== undefined) {
|
|
2188
|
-
// One page of what the words find
|
|
2245
|
+
// One page of what the words find, which ends with the command that reads the next where
|
|
2246
|
+
// more was found. How a skill is loaded stands above it then, so that the command is last.
|
|
2189
2247
|
const found = await readThrough(
|
|
2190
2248
|
io,
|
|
2191
2249
|
session,
|
|
2192
2250
|
owner,
|
|
2193
2251
|
pack,
|
|
2194
2252
|
{ read: "find", words, path: folder, cursor, limit },
|
|
2195
|
-
{
|
|
2253
|
+
{
|
|
2254
|
+
words: toolWords,
|
|
2255
|
+
beside: [loading],
|
|
2256
|
+
nextPart: nextPage([
|
|
2257
|
+
"--search",
|
|
2258
|
+
words,
|
|
2259
|
+
...(given === undefined ? [] : [given]),
|
|
2260
|
+
...(within === undefined ? [] : ["--path", within]),
|
|
2261
|
+
]),
|
|
2262
|
+
},
|
|
2263
|
+
);
|
|
2264
|
+
say(jsonOfRead(session, pack, found), () =>
|
|
2265
|
+
found.next === undefined ? `${found.text}\n${loading}` : `${loading}\n${found.text}`,
|
|
2196
2266
|
);
|
|
2197
|
-
say(jsonOfRead(session, pack, found), () => `${found.text}\n${loading}`);
|
|
2198
2267
|
return EXIT.ok;
|
|
2199
2268
|
}
|
|
2200
2269
|
// One page of the folder, or of a file's outline, as the skillcdn command browses: a page
|
|
2201
|
-
// that ends before the folder does
|
|
2270
|
+
// that ends before the folder does ends with the command that reads the next.
|
|
2202
2271
|
const browsed = await readThrough(
|
|
2203
2272
|
io,
|
|
2204
2273
|
session,
|
|
2205
2274
|
owner,
|
|
2206
2275
|
pack,
|
|
2207
2276
|
{ read: "browse", path: folder, cursor, limit },
|
|
2208
|
-
{ words: toolWords },
|
|
2277
|
+
{ words: toolWords, nextPart: nextPage(given === undefined ? [] : [given]) },
|
|
2209
2278
|
);
|
|
2210
2279
|
say(jsonOfRead(session, pack, browsed), () => browsed.text);
|
|
2211
2280
|
return EXIT.ok;
|
|
@@ -2350,6 +2419,12 @@ async function readSkill(
|
|
|
2350
2419
|
nextPart: (next) =>
|
|
2351
2420
|
commandLine(command, [given, "--cursor", next, ...again]) ??
|
|
2352
2421
|
`the command you ran, with --cursor ${commandWord(next) ?? JSON.stringify(next)} in place of any it had, each word quoted for your shell. ${NO_LINE_TO_RUN}`,
|
|
2422
|
+
// The skill's own folder, where it does not list every file of it, as the command that
|
|
2423
|
+
// lists a folder of this pack (SkillCDN 0.6.3): the dot for the root, since the command
|
|
2424
|
+
// without a folder is the listing.
|
|
2425
|
+
browseFolder: (path) =>
|
|
2426
|
+
commandLine(`${command}s`, [path.length === 0 ? "." : path, ...again]) ??
|
|
2427
|
+
`${command}s with this skill's folder, quoted for your shell. ${NO_LINE_TO_RUN}`,
|
|
2353
2428
|
},
|
|
2354
2429
|
);
|
|
2355
2430
|
say(jsonOfRead(session, pack, loaded), () => loaded.text);
|
|
@@ -3464,6 +3539,9 @@ const task: Command = async (args, io) => {
|
|
|
3464
3539
|
if (args[0] === "restore") {
|
|
3465
3540
|
return taskRestore(args.slice(1), io);
|
|
3466
3541
|
}
|
|
3542
|
+
if (args[0] === "follow" || args[0] === "mute") {
|
|
3543
|
+
return following(args[0] === "follow")(args.slice(1), io);
|
|
3544
|
+
}
|
|
3467
3545
|
const { values, positionals } = parse(args, {});
|
|
3468
3546
|
const ref = theOne(positionals, "Say which task: console task <number|id>");
|
|
3469
3547
|
const session = await open(io, values);
|
|
@@ -3656,8 +3734,8 @@ const notify: Command = async (args, io) => {
|
|
|
3656
3734
|
);
|
|
3657
3735
|
};
|
|
3658
3736
|
|
|
3659
|
-
// Whether one task tells a member anything (ADR-0157): `follow` turns its notifications
|
|
3660
|
-
// `mute` off. A task turned on that their settings would be silent of tells them of
|
|
3737
|
+
// Whether one task tells a member anything (ADR-0157): `task follow` turns its notifications
|
|
3738
|
+
// on, `task mute` off. A task turned on that their settings would be silent of tells them of
|
|
3661
3739
|
// everything on it; one turned to what their settings say already is told by their kinds.
|
|
3662
3740
|
const following =
|
|
3663
3741
|
(turned: boolean): Command =>
|
|
@@ -3665,7 +3743,7 @@ const following =
|
|
|
3665
3743
|
const { values, positionals } = parse(args, {});
|
|
3666
3744
|
const ref = theOne(
|
|
3667
3745
|
positionals,
|
|
3668
|
-
`Say which task: console ${turned ? "follow" : "mute"} <number|id>`,
|
|
3746
|
+
`Say which task: console task ${turned ? "follow" : "mute"} <number|id>`,
|
|
3669
3747
|
);
|
|
3670
3748
|
const session = await open(io, values);
|
|
3671
3749
|
const project = await session.project();
|
|
@@ -4285,11 +4363,30 @@ const docs: Command = async (args, io) => {
|
|
|
4285
4363
|
return EXIT.ok;
|
|
4286
4364
|
};
|
|
4287
4365
|
|
|
4366
|
+
/** What a read of one page takes beside its path. */
|
|
4367
|
+
const DOC_READ_FLAGS: OptionSpec = {
|
|
4368
|
+
version: { type: "string" },
|
|
4369
|
+
versions: { type: "boolean" },
|
|
4370
|
+
};
|
|
4371
|
+
|
|
4372
|
+
/** Whether the words are a read of one page: one path, and no flag but a read's own. */
|
|
4373
|
+
function readsOnePage(args: readonly string[]): boolean {
|
|
4374
|
+
try {
|
|
4375
|
+
return parse(args, DOC_READ_FLAGS).positionals.length === 1;
|
|
4376
|
+
} catch {
|
|
4377
|
+
return false;
|
|
4378
|
+
}
|
|
4379
|
+
}
|
|
4380
|
+
|
|
4288
4381
|
const doc: Command = async (args, io) => {
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4382
|
+
// A page may be called by a form's word, `write`, and is read as any page is (ADR-0167):
|
|
4383
|
+
// the word is the form wherever more follows it than a read of one page takes, a path or a
|
|
4384
|
+
// flag of the form's own, before the path as after it.
|
|
4385
|
+
const form = held(DOC_FORMS, args[0]);
|
|
4386
|
+
if (form !== undefined && !readsOnePage(args)) {
|
|
4387
|
+
return form(args.slice(1), io);
|
|
4388
|
+
}
|
|
4389
|
+
const { values, positionals } = parse(args, DOC_READ_FLAGS);
|
|
4293
4390
|
const path = theOne(positionals, "Say which page: console doc <path> [--version <n>|--versions]");
|
|
4294
4391
|
const session = await open(io, values);
|
|
4295
4392
|
const project = await session.project();
|
|
@@ -4324,7 +4421,7 @@ const write: Command = async (args, io) => {
|
|
|
4324
4421
|
});
|
|
4325
4422
|
const path = theOne(
|
|
4326
4423
|
positionals,
|
|
4327
|
-
'Say which page: console write <path> --title "<title>" --body <markdown>|--file <path>',
|
|
4424
|
+
'Say which page: console doc write <path> --title "<title>" --body <markdown>|--file <path>',
|
|
4328
4425
|
);
|
|
4329
4426
|
const body = await bodyOf(io, values, text(values, "body"));
|
|
4330
4427
|
if (body === undefined) {
|
|
@@ -4373,7 +4470,7 @@ const attach: Command = async (args, io) => {
|
|
|
4373
4470
|
const { values, positionals } = parse(args, { label: { type: "string" } });
|
|
4374
4471
|
const [path, file] = positionals;
|
|
4375
4472
|
if (path === undefined || file === undefined || positionals.length > 2) {
|
|
4376
|
-
throw misuse("Say the page and the file: console attach <path> <file> [--label <words>]");
|
|
4473
|
+
throw misuse("Say the page and the file: console doc attach <path> <file> [--label <words>]");
|
|
4377
4474
|
}
|
|
4378
4475
|
const label = text(values, "label");
|
|
4379
4476
|
const session = await open(io, values);
|
|
@@ -4404,7 +4501,7 @@ const attach: Command = async (args, io) => {
|
|
|
4404
4501
|
|
|
4405
4502
|
const archive: Command = async (args, io) => {
|
|
4406
4503
|
const { values, positionals } = parse(args, {});
|
|
4407
|
-
const path = theOne(positionals, "Say which page: console archive <path>");
|
|
4504
|
+
const path = theOne(positionals, "Say which page: console doc archive <path>");
|
|
4408
4505
|
const session = await open(io, values);
|
|
4409
4506
|
const project = await session.project();
|
|
4410
4507
|
const put = await project.archiveDocument(path);
|
|
@@ -4420,7 +4517,7 @@ const archive: Command = async (args, io) => {
|
|
|
4420
4517
|
|
|
4421
4518
|
const restore: Command = async (args, io) => {
|
|
4422
4519
|
const { values, positionals } = parse(args, {});
|
|
4423
|
-
const path = theOne(positionals, "Say which page: console restore <path>");
|
|
4520
|
+
const path = theOne(positionals, "Say which page: console doc restore <path>");
|
|
4424
4521
|
const session = await open(io, values);
|
|
4425
4522
|
const project = await session.project();
|
|
4426
4523
|
const back = await project.restoreDocument(path);
|
|
@@ -4428,6 +4525,9 @@ const restore: Command = async (args, io) => {
|
|
|
4428
4525
|
return EXIT.ok;
|
|
4429
4526
|
};
|
|
4430
4527
|
|
|
4528
|
+
/** The forms of `console doc` that change a page, by the word that picks each. */
|
|
4529
|
+
const DOC_FORMS: Readonly<Record<string, Command>> = { write, attach, archive, restore };
|
|
4530
|
+
|
|
4431
4531
|
const goals: Command = async (args, io) => {
|
|
4432
4532
|
const { values } = parse(
|
|
4433
4533
|
args,
|
|
@@ -4830,69 +4930,6 @@ const serve: Command = async (args, io) => {
|
|
|
4830
4930
|
return EXIT.ok;
|
|
4831
4931
|
};
|
|
4832
4932
|
|
|
4833
|
-
/** What the runner keeps between its own restarts, as its file says it; nothing for a file that does not read. */
|
|
4834
|
-
function runnerStateOf(text: string | undefined): RunnerState | undefined {
|
|
4835
|
-
if (text === undefined) {
|
|
4836
|
-
return undefined;
|
|
4837
|
-
}
|
|
4838
|
-
let json: unknown;
|
|
4839
|
-
try {
|
|
4840
|
-
json = JSON.parse(text);
|
|
4841
|
-
} catch {
|
|
4842
|
-
return undefined;
|
|
4843
|
-
}
|
|
4844
|
-
if (typeof json !== "object" || json === null) {
|
|
4845
|
-
return undefined;
|
|
4846
|
-
}
|
|
4847
|
-
const delivered = "delivered" in json ? json.delivered : undefined;
|
|
4848
|
-
const conversation = "conversation" in json ? json.conversation : undefined;
|
|
4849
|
-
const driver = "driver" in json ? json.driver : undefined;
|
|
4850
|
-
const limited = "limited" in json ? json.limited : undefined;
|
|
4851
|
-
const kept: unknown = "kept" in json ? json.kept : undefined;
|
|
4852
|
-
if (typeof delivered !== "number" || !Number.isSafeInteger(delivered) || delivered < 0) {
|
|
4853
|
-
return undefined;
|
|
4854
|
-
}
|
|
4855
|
-
/**
|
|
4856
|
-
* A moment in milliseconds since the epoch, or nothing for anything else: a number past what
|
|
4857
|
-
* a date holds would fail the runner at every start, where it says the moment in words.
|
|
4858
|
-
*/
|
|
4859
|
-
const momentOf = (value: unknown): number | undefined =>
|
|
4860
|
-
typeof value === "number" && Number.isSafeInteger(value) && value > 0 && value < 1e14
|
|
4861
|
-
? value
|
|
4862
|
-
: undefined;
|
|
4863
|
-
const since =
|
|
4864
|
-
typeof limited === "object" && limited !== null && "since" in limited
|
|
4865
|
-
? momentOf(limited.since)
|
|
4866
|
-
: undefined;
|
|
4867
|
-
return {
|
|
4868
|
-
delivered,
|
|
4869
|
-
conversation:
|
|
4870
|
-
typeof conversation === "string" && conversation.length > 0 && conversation.length <= 200
|
|
4871
|
-
? conversation
|
|
4872
|
-
: undefined,
|
|
4873
|
-
// The driver the conversation was begun under, as a registry spells one.
|
|
4874
|
-
driver:
|
|
4875
|
-
typeof driver === "string" && /^[a-z][a-z0-9-]{0,39}$/.test(driver) ? driver : undefined,
|
|
4876
|
-
// The usage limit the agent is not back from (ADR-0150): since when, and until when where the product said.
|
|
4877
|
-
...(since === undefined || typeof limited !== "object" || limited === null
|
|
4878
|
-
? {}
|
|
4879
|
-
: {
|
|
4880
|
-
limited: {
|
|
4881
|
-
since,
|
|
4882
|
-
until: "until" in limited ? momentOf(limited.until) : undefined,
|
|
4883
|
-
},
|
|
4884
|
-
}),
|
|
4885
|
-
// The signals the record has as delivered that the agent never read: taken from the stream once more.
|
|
4886
|
-
...(Array.isArray(kept)
|
|
4887
|
-
? {
|
|
4888
|
-
kept: kept
|
|
4889
|
-
.filter((number): number is number => momentOf(number) !== undefined)
|
|
4890
|
-
.slice(0, 50),
|
|
4891
|
-
}
|
|
4892
|
-
: {}),
|
|
4893
|
-
};
|
|
4894
|
-
}
|
|
4895
|
-
|
|
4896
4933
|
/** A line a runner says of its machine, within what the console takes one in. */
|
|
4897
4934
|
const machineLine = (text: string): string => {
|
|
4898
4935
|
const line = [...text]
|
|
@@ -5022,6 +5059,9 @@ const runner: Command = async (args, io) => {
|
|
|
5022
5059
|
});
|
|
5023
5060
|
}
|
|
5024
5061
|
const statePath = workPath("runner-state.json");
|
|
5062
|
+
// A wake source is named as a registry spells one, which is a file's name as it stands.
|
|
5063
|
+
const keptPath = (source: string): string =>
|
|
5064
|
+
workPath(`runner-kept-${source.replaceAll(/[^a-z0-9-]/g, "_")}.json`);
|
|
5025
5065
|
const person = me.person;
|
|
5026
5066
|
/** A runner for the desk's runner.json as it is read now: begun again whenever the file changed (ADR-0144). */
|
|
5027
5067
|
const runnerOf = (read: Extract<Awaited<ReturnType<typeof readConfig>>, { ok: true }>) => {
|
|
@@ -5056,6 +5096,8 @@ const runner: Command = async (args, io) => {
|
|
|
5056
5096
|
now: io.now,
|
|
5057
5097
|
random: host.random,
|
|
5058
5098
|
time: (iso) => clock.format(new Date(iso)),
|
|
5099
|
+
// What a wake source shows of the agent at its messenger is in the workspace's language (ADR-0170).
|
|
5100
|
+
language: me.workspace.language ?? undefined,
|
|
5059
5101
|
// A moment that may be on another day, a stretch the runner did not run in or when a
|
|
5060
5102
|
// usage limit resets, is said as the command prints any moment: with its day, in the
|
|
5061
5103
|
// workspace's zone where the login kept one.
|
|
@@ -5066,7 +5108,7 @@ const runner: Command = async (args, io) => {
|
|
|
5066
5108
|
},
|
|
5067
5109
|
state: {
|
|
5068
5110
|
load: async () => runnerStateOf(await host.readText(statePath)),
|
|
5069
|
-
save: (state) => host.
|
|
5111
|
+
save: (state) => host.replacePrivate(statePath, `${JSON.stringify(state)}\n`),
|
|
5070
5112
|
},
|
|
5071
5113
|
log: (line) => io.stdout(`${new Date(io.now()).toISOString()} ${line}\n`),
|
|
5072
5114
|
// The autosave's git: in the desk, asking nobody at a terminal, its words read and let go.
|
|
@@ -5096,6 +5138,12 @@ const runner: Command = async (args, io) => {
|
|
|
5096
5138
|
}),
|
|
5097
5139
|
fetch: (url, init) => io.fetch(url, { ...init, headers: { ...init.headers } }),
|
|
5098
5140
|
socket: (url) => host.socket(url),
|
|
5141
|
+
// What a source keeps of what it brought the agent, ids and moments and never a word,
|
|
5142
|
+
// in a file of its own beside the runner's state: a runner started again reads it.
|
|
5143
|
+
kept: {
|
|
5144
|
+
load: async (source) => keptBySourceOf(await host.readText(keptPath(source))),
|
|
5145
|
+
save: (source, kept) => host.replacePrivate(keptPath(source), keptFileOf(kept)),
|
|
5146
|
+
},
|
|
5099
5147
|
},
|
|
5100
5148
|
});
|
|
5101
5149
|
};
|
|
@@ -5210,7 +5258,7 @@ const agents: Command = async (args, io) => {
|
|
|
5210
5258
|
};
|
|
5211
5259
|
|
|
5212
5260
|
const AGENT_USAGE =
|
|
5213
|
-
|
|
5261
|
+
"Say which agent account, or what to do: console agent <handle>, or console agent new|tell|interrupt|stop|restart|reset|wake|set|signals|messages|secrets|secret|invite|setup ...";
|
|
5214
5262
|
|
|
5215
5263
|
// An administrator makes an agent account with flags, where the pages make one from a form
|
|
5216
5264
|
// (ADR-0084): the member's row at once, its login let in. What is left out is proposed: the
|
|
@@ -5330,11 +5378,24 @@ const SECRET_FLAGS: OptionSpec = {
|
|
|
5330
5378
|
expires: { type: "string" },
|
|
5331
5379
|
};
|
|
5332
5380
|
|
|
5381
|
+
/** What ends the listing of the offers that wait: the two things the account does with one. */
|
|
5382
|
+
const OFFERED_NEXT =
|
|
5383
|
+
"Take one into your store: console secret --accept <offer id> [--as <name>] [--replace] | leave one: console secret --decline <offer id>";
|
|
5384
|
+
|
|
5333
5385
|
// An agent account's own secret store (ADR-0087): the names it keeps, for the account itself,
|
|
5334
|
-
// signed in as itself.
|
|
5386
|
+
// signed in as itself; and, with --offered, what members offered it that waits (ADR-0169).
|
|
5335
5387
|
const secrets: Command = async (args, io) => {
|
|
5336
|
-
const { values } = parse(args, {}, false);
|
|
5388
|
+
const { values } = parse(args, { offered: { type: "boolean" } }, false);
|
|
5337
5389
|
const session = await open(io, values);
|
|
5390
|
+
if (on(values, "offered")) {
|
|
5391
|
+
const offered = await session.client.secretOffers();
|
|
5392
|
+
answer(io, session, offered, () =>
|
|
5393
|
+
offered.items.length === 0
|
|
5394
|
+
? "No offered secret waits for you."
|
|
5395
|
+
: [...offered.items.map((item) => formatSecretOffer(item)), OFFERED_NEXT].join("\n"),
|
|
5396
|
+
);
|
|
5397
|
+
return EXIT.ok;
|
|
5398
|
+
}
|
|
5338
5399
|
const found = await session.client.secrets();
|
|
5339
5400
|
answer(io, session, found, () =>
|
|
5340
5401
|
found.items.length === 0
|
|
@@ -5346,10 +5407,65 @@ const secrets: Command = async (args, io) => {
|
|
|
5346
5407
|
|
|
5347
5408
|
const SECRET_USAGE =
|
|
5348
5409
|
"Say which secret: console secret <name> | secret <name> --set [--file <path>] [--expires <day|none>] | secret <name> --remove";
|
|
5410
|
+
const OFFER_USAGE =
|
|
5411
|
+
"Say which offer, by its id as console secrets --offered lists it: console secret --accept <offer id> [--as <name>] [--replace] | secret --decline <offer id>";
|
|
5412
|
+
|
|
5413
|
+
/**
|
|
5414
|
+
* An offer the account takes into its store or leaves (ADR-0169): named by its id, since the
|
|
5415
|
+
* name an offerer proposed is theirs to choose and two may propose the same.
|
|
5416
|
+
*/
|
|
5417
|
+
async function offeredSecret(io: CliIo, values: Values, positionals: readonly string[]) {
|
|
5418
|
+
const taking = on(values, "accept");
|
|
5419
|
+
if ((taking && on(values, "decline")) || on(values, "set") || on(values, "remove")) {
|
|
5420
|
+
throw misuse("Say one of --accept, --decline, --set and --remove.");
|
|
5421
|
+
}
|
|
5422
|
+
const as = text(values, "as");
|
|
5423
|
+
if (!taking && (as !== undefined || on(values, "replace"))) {
|
|
5424
|
+
throw misuse(
|
|
5425
|
+
"--as and --replace go with --accept: an offer that is left is kept under no name.",
|
|
5426
|
+
);
|
|
5427
|
+
}
|
|
5428
|
+
const id = theOne(positionals, OFFER_USAGE);
|
|
5429
|
+
const session = await open(io, values);
|
|
5430
|
+
if (!taking) {
|
|
5431
|
+
await session.client.leaveSecretOffer(id);
|
|
5432
|
+
answer(io, session, { left: id }, () => `The offer ${id} is left, and its value is gone.`);
|
|
5433
|
+
return EXIT.ok;
|
|
5434
|
+
}
|
|
5435
|
+
let kept: Awaited<ReturnType<ConsoleClient["takeSecretOffer"]>>;
|
|
5436
|
+
try {
|
|
5437
|
+
kept = await session.client.takeSecretOffer(id, {
|
|
5438
|
+
...(as === undefined ? {} : { as }),
|
|
5439
|
+
...(on(values, "replace") ? { replace: true } : {}),
|
|
5440
|
+
});
|
|
5441
|
+
} catch (error) {
|
|
5442
|
+
if (error instanceof ApiError && error.code === "secret.exists") {
|
|
5443
|
+
throw failed(
|
|
5444
|
+
`secret.exists: you keep a secret ${as === undefined ? "of the name it was offered under" : `named ${as}`} already, and the offer still waits. Take it under another name with --as <name>, or in the place of the one you keep with --replace.`,
|
|
5445
|
+
);
|
|
5446
|
+
}
|
|
5447
|
+
throw error;
|
|
5448
|
+
}
|
|
5449
|
+
answer(io, session, kept, () => `Taken into your store: ${formatSecretLine(kept)}`);
|
|
5450
|
+
return EXIT.ok;
|
|
5451
|
+
}
|
|
5349
5452
|
|
|
5350
5453
|
// One secret of the account's own: its value, read and noted; or set, typed unseen; or removed.
|
|
5454
|
+
// And one offered to it, taken or left.
|
|
5351
5455
|
const secret: Command = async (args, io) => {
|
|
5352
|
-
const { values, positionals } = parse(args,
|
|
5456
|
+
const { values, positionals } = parse(args, {
|
|
5457
|
+
...SECRET_FLAGS,
|
|
5458
|
+
accept: { type: "boolean" },
|
|
5459
|
+
decline: { type: "boolean" },
|
|
5460
|
+
as: { type: "string" },
|
|
5461
|
+
replace: { type: "boolean" },
|
|
5462
|
+
});
|
|
5463
|
+
if (on(values, "accept") || on(values, "decline")) {
|
|
5464
|
+
return offeredSecret(io, values, positionals);
|
|
5465
|
+
}
|
|
5466
|
+
if (text(values, "as") !== undefined || on(values, "replace")) {
|
|
5467
|
+
throw misuse(`--as and --replace go with --accept. ${OFFER_USAGE}`);
|
|
5468
|
+
}
|
|
5353
5469
|
const name = theOne(positionals, SECRET_USAGE);
|
|
5354
5470
|
const session = await open(io, values);
|
|
5355
5471
|
if (on(values, "remove")) {
|
|
@@ -5378,9 +5494,22 @@ const secret: Command = async (args, io) => {
|
|
|
5378
5494
|
// A supervisor's part of an agent account's store (ADR-0087): the names; a secret seeded,
|
|
5379
5495
|
// write-only, which only the account reads back; one removed. Never a value.
|
|
5380
5496
|
const agentSecrets = async (args: readonly string[], io: CliIo): Promise<number> => {
|
|
5381
|
-
const { values, positionals } = parse(args, {});
|
|
5382
|
-
const handle = handleOf(
|
|
5497
|
+
const { values, positionals } = parse(args, { offered: { type: "boolean" } });
|
|
5498
|
+
const handle = handleOf(
|
|
5499
|
+
theOne(positionals, "Say whose: console agent secrets <handle> [--offered]"),
|
|
5500
|
+
);
|
|
5383
5501
|
const session = await open(io, values);
|
|
5502
|
+
if (on(values, "offered")) {
|
|
5503
|
+
// What the account was offered (ADR-0169): its record whole for a supervisor, and for any
|
|
5504
|
+
// other member what they offered it themselves.
|
|
5505
|
+
const offered = await session.client.agentSecretOffers(handle);
|
|
5506
|
+
answer(io, session, offered, () =>
|
|
5507
|
+
offered.items.length === 0
|
|
5508
|
+
? `Nothing was offered to @${handle} that is yours to read.`
|
|
5509
|
+
: offered.items.map((item) => formatSecretOffer(item)).join("\n"),
|
|
5510
|
+
);
|
|
5511
|
+
return EXIT.ok;
|
|
5512
|
+
}
|
|
5384
5513
|
let found: Awaited<ReturnType<ConsoleClient["agentSecrets"]>>;
|
|
5385
5514
|
try {
|
|
5386
5515
|
found = await session.client.agentSecrets(handle);
|
|
@@ -5406,13 +5535,48 @@ const agentSecrets = async (args: readonly string[], io: CliIo): Promise<number>
|
|
|
5406
5535
|
};
|
|
5407
5536
|
|
|
5408
5537
|
const agentSecret = async (args: readonly string[], io: CliIo): Promise<number> => {
|
|
5409
|
-
const { values, positionals } = parse(args,
|
|
5538
|
+
const { values, positionals } = parse(args, {
|
|
5539
|
+
...SECRET_FLAGS,
|
|
5540
|
+
offer: { type: "boolean" },
|
|
5541
|
+
note: { type: "string" },
|
|
5542
|
+
});
|
|
5410
5543
|
const [given, name] = theTwo(
|
|
5411
5544
|
positionals,
|
|
5412
|
-
|
|
5545
|
+
'Say whose and which: console agent secret <handle> <name> [--file <path>] [--expires <day|none>] | agent secret <handle> <name> --offer [--note "<what it is for>"] [--file <path>] [--expires <day|none>] | agent secret <handle> <name> --remove',
|
|
5413
5546
|
);
|
|
5414
5547
|
const handle = handleOf(given);
|
|
5548
|
+
const offering = on(values, "offer");
|
|
5549
|
+
const said = text(values, "note")?.trim();
|
|
5550
|
+
if (offering && on(values, "remove")) {
|
|
5551
|
+
throw misuse("Say one of --offer and --remove.");
|
|
5552
|
+
}
|
|
5553
|
+
if (said !== undefined && !offering) {
|
|
5554
|
+
throw misuse("--note says what an offered secret is for, and goes with --offer.");
|
|
5555
|
+
}
|
|
5415
5556
|
const session = await open(io, values);
|
|
5557
|
+
if (offering) {
|
|
5558
|
+
// Any member's (ADR-0169): the value waits, sealed, for the account to take or leave, and
|
|
5559
|
+
// nothing of what the account keeps changes.
|
|
5560
|
+
const expiresOn = expiryOf(io, values);
|
|
5561
|
+
const value = await secretValue(
|
|
5562
|
+
io,
|
|
5563
|
+
values,
|
|
5564
|
+
`Value of ${name} to offer @${handle} (typed unseen; Enter ends it): `,
|
|
5565
|
+
);
|
|
5566
|
+
const offered = await session.client.offerAgentSecret(handle, {
|
|
5567
|
+
name,
|
|
5568
|
+
value,
|
|
5569
|
+
...(said === undefined || said === "" ? {} : { note: said }),
|
|
5570
|
+
...(expiresOn === undefined ? {} : { expiresOn }),
|
|
5571
|
+
});
|
|
5572
|
+
answer(io, session, offered, () =>
|
|
5573
|
+
[
|
|
5574
|
+
`Offered to @${handle}, which is told and takes it into its store or leaves it: ${formatSecretOffer(offered)}`,
|
|
5575
|
+
`Nothing @${handle} keeps changed, and nobody is answered the value. How it stands: console agent secrets ${handle} --offered`,
|
|
5576
|
+
].join("\n"),
|
|
5577
|
+
);
|
|
5578
|
+
return EXIT.ok;
|
|
5579
|
+
}
|
|
5416
5580
|
if (on(values, "remove")) {
|
|
5417
5581
|
await session.client.removeAgentSecret(handle, name);
|
|
5418
5582
|
answer(
|
|
@@ -5430,10 +5594,21 @@ const agentSecret = async (args: readonly string[], io: CliIo): Promise<number>
|
|
|
5430
5594
|
`Value of ${name} for @${handle} (typed unseen; Enter ends it): `,
|
|
5431
5595
|
);
|
|
5432
5596
|
const host = await gitHostFor(session.client, name);
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5597
|
+
let kept: Awaited<ReturnType<ConsoleClient["seedAgentSecret"]>>;
|
|
5598
|
+
try {
|
|
5599
|
+
kept = await session.client.seedAgentSecret(handle, name, {
|
|
5600
|
+
value,
|
|
5601
|
+
...(expiresOn === undefined ? {} : { expiresOn }),
|
|
5602
|
+
});
|
|
5603
|
+
} catch (error) {
|
|
5604
|
+
// Whoever supervises the account not is told what is theirs to do in its place.
|
|
5605
|
+
if (error instanceof ApiError && error.code === "auth.forbidden") {
|
|
5606
|
+
throw failed(
|
|
5607
|
+
`auth.forbidden: only a supervisor of @${handle} sets a secret in its store. Any member may offer one, which @${handle} takes or leaves itself: say the same again with --offer, and with --note "<what it is for>".`,
|
|
5608
|
+
);
|
|
5609
|
+
}
|
|
5610
|
+
throw error;
|
|
5611
|
+
}
|
|
5437
5612
|
const notes = secretNotes(name, value, host);
|
|
5438
5613
|
answer(io, session, kept, () =>
|
|
5439
5614
|
[`Seeded for @${handle}, which alone reads it back: ${formatSecretLine(kept)}`, ...notes].join(
|
|
@@ -5613,6 +5788,21 @@ const WORDED_SIGNALS: Readonly<Record<string, { readonly needs: boolean }>> = {
|
|
|
5613
5788
|
wake: { needs: false },
|
|
5614
5789
|
};
|
|
5615
5790
|
|
|
5791
|
+
/**
|
|
5792
|
+
* Whether the words after `agent wake` or `agent reset` are the account's own form: `me` where
|
|
5793
|
+
* the handle stands, wherever that is among the form's flags. Read without refusing a word, so
|
|
5794
|
+
* that a mistake among them is answered by the form that was typed, and not by the other's.
|
|
5795
|
+
*/
|
|
5796
|
+
function isOwnForm(args: readonly string[], flags: OptionSpec): boolean {
|
|
5797
|
+
const { positionals } = parseArgs({
|
|
5798
|
+
args: [...args],
|
|
5799
|
+
options: { ...GLOBAL_OPTIONS, ...flags },
|
|
5800
|
+
allowPositionals: true,
|
|
5801
|
+
strict: false,
|
|
5802
|
+
});
|
|
5803
|
+
return positionals[0] === "me";
|
|
5804
|
+
}
|
|
5805
|
+
|
|
5616
5806
|
// A supervisor's signal to an agent account (ADR-0085): a tell, an interruption, a stop, a start
|
|
5617
5807
|
// with the same conversation or with a new one, a wake; in their own name, on the account's
|
|
5618
5808
|
// record. What it says is given as words, or with --file, or on standard input as `-`.
|
|
@@ -5623,28 +5813,12 @@ const agentSignal = async (
|
|
|
5623
5813
|
): Promise<number> => {
|
|
5624
5814
|
// An account's own wake is another command under the same word: console agent wake me,
|
|
5625
5815
|
// wherever `me` stands among its flags.
|
|
5626
|
-
if (kind === "wake") {
|
|
5627
|
-
|
|
5628
|
-
try {
|
|
5629
|
-
whom = parse(args, OWN_WAKE_FLAGS).positionals[0];
|
|
5630
|
-
} catch {
|
|
5631
|
-
whom = undefined;
|
|
5632
|
-
}
|
|
5633
|
-
if (whom === "me") {
|
|
5634
|
-
return ownWake(args, io);
|
|
5635
|
-
}
|
|
5816
|
+
if (kind === "wake" && isOwnForm(args, OWN_WAKE_FLAGS)) {
|
|
5817
|
+
return ownWake(args, io);
|
|
5636
5818
|
}
|
|
5637
5819
|
// And so is its own reset: console agent reset me.
|
|
5638
|
-
if (kind === "reset") {
|
|
5639
|
-
|
|
5640
|
-
try {
|
|
5641
|
-
whom = parse(args, { file: { type: "string" } }).positionals[0];
|
|
5642
|
-
} catch {
|
|
5643
|
-
whom = undefined;
|
|
5644
|
-
}
|
|
5645
|
-
if (whom === "me") {
|
|
5646
|
-
return ownReset(args, io);
|
|
5647
|
-
}
|
|
5820
|
+
if (kind === "reset" && isOwnForm(args, { file: { type: "string" } })) {
|
|
5821
|
+
return ownReset(args, io);
|
|
5648
5822
|
}
|
|
5649
5823
|
const { values, positionals } = parse(args, { file: { type: "string" } });
|
|
5650
5824
|
const [given, words, ...rest] = positionals;
|
|
@@ -6593,7 +6767,7 @@ const DESK_USAGE = "Say at most one directory: console desk [<directory>] [--web
|
|
|
6593
6767
|
function deskNext(web: boolean, skillsDir: string | undefined): [string, string] {
|
|
6594
6768
|
return [
|
|
6595
6769
|
`Set this desk up as a repository of mine${web ? " and bring its pages up" : ""}, with the skill for it in the organization's pack where it has one: console skills --search "desk setup" --limit 5`,
|
|
6596
|
-
`Ask me what I want to keep and to see here, and shape the desk to it, as the skill keeping-a-desk says, shipped with the console command${skillsDir === undefined ? " (
|
|
6770
|
+
`Ask me what I want to keep and to see here, and shape the desk to it, as the skill keeping-a-desk says, shipped with the console command${skillsDir === undefined ? " (in the skills folder of the package @skillcdn/console, which this build has none of beside it)" : `: ${ownSkillPath(skillsDir, "keeping-a-desk")}`}`,
|
|
6597
6771
|
];
|
|
6598
6772
|
}
|
|
6599
6773
|
|
|
@@ -7671,23 +7845,58 @@ const COMMANDS: Readonly<Record<string, Command>> = {
|
|
|
7671
7845
|
run,
|
|
7672
7846
|
docs,
|
|
7673
7847
|
doc,
|
|
7848
|
+
// The words of before (COMMAND_ALIASES, ADR-0167): they run as they did, and no list names them.
|
|
7674
7849
|
write,
|
|
7675
7850
|
attach,
|
|
7676
7851
|
archive,
|
|
7677
7852
|
restore,
|
|
7678
7853
|
};
|
|
7679
7854
|
|
|
7680
|
-
|
|
7681
|
-
|
|
7855
|
+
/** The words the dispatch takes: what a test holds to the pages of help and to the words of before. */
|
|
7856
|
+
export const COMMAND_WORDS: readonly string[] = Object.keys(COMMANDS);
|
|
7857
|
+
|
|
7858
|
+
/** What a word that is no command is answered with: the nearest there are, and where all are listed. */
|
|
7859
|
+
function notCommand(word: string, near: readonly string[] = nearestCommands(word)): CliExit {
|
|
7860
|
+
return misuse(
|
|
7861
|
+
`Not a command: ${word}.${near.length === 0 ? "" : ` Nearest: ${near.join(", ")}.`} console help lists the commands.`,
|
|
7862
|
+
);
|
|
7863
|
+
}
|
|
7864
|
+
|
|
7865
|
+
/**
|
|
7866
|
+
* The help the words ask for (ADR-0167): the table of the commands for none, else the page of
|
|
7867
|
+
* a command, or of one of its forms. Flags among the words are left unread.
|
|
7868
|
+
*/
|
|
7869
|
+
function help(io: CliIo, words: readonly string[]): number {
|
|
7870
|
+
const named = words.filter((word) => !word.startsWith("-"));
|
|
7871
|
+
// Help asked of help is the table too.
|
|
7872
|
+
if (named.length === 0 || (named.length === 1 && named[0] === "help")) {
|
|
7682
7873
|
io.stdout(usage(io.version, io.skillsDir));
|
|
7683
7874
|
return EXIT.ok;
|
|
7684
7875
|
}
|
|
7685
|
-
const found = helpFor(
|
|
7686
|
-
if (
|
|
7687
|
-
|
|
7876
|
+
const found = helpFor(named, io.skillsDir);
|
|
7877
|
+
if ("page" in found) {
|
|
7878
|
+
io.stdout(found.page);
|
|
7879
|
+
return EXIT.ok;
|
|
7688
7880
|
}
|
|
7689
|
-
|
|
7690
|
-
|
|
7881
|
+
if ("notCommand" in found) {
|
|
7882
|
+
throw notCommand(found.notCommand, found.near);
|
|
7883
|
+
}
|
|
7884
|
+
throw misuse(
|
|
7885
|
+
`Not a form of console ${found.command}: ${found.notForm}. Its forms with a page: ${found.forms.join(", ")}. console help ${found.command} says each in a line.`,
|
|
7886
|
+
);
|
|
7887
|
+
}
|
|
7888
|
+
|
|
7889
|
+
/**
|
|
7890
|
+
* The line after a command that was not understood (ADR-0167): where its forms and flags are,
|
|
7891
|
+
* the page of the form that was tried where it has one. Nothing where the words say it already.
|
|
7892
|
+
*/
|
|
7893
|
+
function helpPointer(name: string, rest: readonly string[], said: string): string {
|
|
7894
|
+
if (said.includes("console help")) {
|
|
7895
|
+
return "";
|
|
7896
|
+
}
|
|
7897
|
+
const [command, aliased] = held(COMMAND_ALIASES, name) ?? [name, undefined];
|
|
7898
|
+
const form = aliased ?? formTyped(command, rest);
|
|
7899
|
+
return `Its forms and flags: console help ${command}${form === undefined ? "" : ` ${form}`}\n`;
|
|
7691
7900
|
}
|
|
7692
7901
|
|
|
7693
7902
|
/**
|
|
@@ -7807,11 +8016,11 @@ function hintFor(error: ApiError, io: CliIo, seen: ConsoleSeen): string {
|
|
|
7807
8016
|
case "project.not_found":
|
|
7808
8017
|
return "No project has this key, or it is not yours to see. console projects lists the projects you may work in.\n";
|
|
7809
8018
|
case "document.not_found":
|
|
7810
|
-
return "No page has this path, in this project. console docs lists the pages of a folder; console write <path> writes one.\n";
|
|
8019
|
+
return "No page has this path, in this project. console docs lists the pages of a folder; console doc write <path> writes one.\n";
|
|
7811
8020
|
case "document.conflict":
|
|
7812
8021
|
return "The page has moved on since the version you started from. Read it again, and write from there.\n";
|
|
7813
8022
|
case "document.archived":
|
|
7814
|
-
return "The page is archived. console restore <path> brings it back first.\n";
|
|
8023
|
+
return "The page is archived. console doc restore <path> brings it back first.\n";
|
|
7815
8024
|
case "task.invalid_category":
|
|
7816
8025
|
return "No category has that key. console categories lists them.\n";
|
|
7817
8026
|
case "task.invalid_goal":
|
|
@@ -7909,14 +8118,22 @@ export async function runCli(argv: readonly string[], io: CliIo): Promise<number
|
|
|
7909
8118
|
return EXIT.ok;
|
|
7910
8119
|
}
|
|
7911
8120
|
if (name === undefined || name === "help" || name === "--help" || name === "-h") {
|
|
7912
|
-
return help(io, rest
|
|
8121
|
+
return help(io, rest);
|
|
7913
8122
|
}
|
|
7914
8123
|
if (rest.includes("--help") || rest.includes("-h")) {
|
|
7915
|
-
|
|
8124
|
+
// The page of the form that was being typed, where it has one.
|
|
8125
|
+
const [command, aliased] = held(COMMAND_ALIASES, name) ?? [name, undefined];
|
|
8126
|
+
const form =
|
|
8127
|
+
aliased ??
|
|
8128
|
+
formTyped(
|
|
8129
|
+
command,
|
|
8130
|
+
rest.filter((word) => word !== "--help" && word !== "-h"),
|
|
8131
|
+
);
|
|
8132
|
+
return help(io, form === undefined ? [command] : [command, form]);
|
|
7916
8133
|
}
|
|
7917
|
-
const command = COMMANDS
|
|
8134
|
+
const command = held(COMMANDS, name);
|
|
7918
8135
|
if (command === undefined) {
|
|
7919
|
-
throw
|
|
8136
|
+
throw notCommand(name);
|
|
7920
8137
|
}
|
|
7921
8138
|
const exit = await command(rest, watched);
|
|
7922
8139
|
if (name !== "whoami") {
|
|
@@ -7925,7 +8142,12 @@ export async function runCli(argv: readonly string[], io: CliIo): Promise<number
|
|
|
7925
8142
|
return exit;
|
|
7926
8143
|
} catch (error) {
|
|
7927
8144
|
if (error instanceof CliExit) {
|
|
7928
|
-
|
|
8145
|
+
// A command that was not understood says where its forms and flags are, in a line.
|
|
8146
|
+
const pointer =
|
|
8147
|
+
error.exit === EXIT.usage && name !== undefined && held(COMMANDS, name) !== undefined
|
|
8148
|
+
? helpPointer(name, rest, error.message)
|
|
8149
|
+
: "";
|
|
8150
|
+
io.stderr(`${error.message}\n${pointer}`);
|
|
7929
8151
|
return error.exit;
|
|
7930
8152
|
}
|
|
7931
8153
|
if (error instanceof UnseenProject) {
|