@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/dist/cli/cli.js
CHANGED
|
@@ -22,7 +22,7 @@ import { DEFAULT_RUNNER_CONFIG, parseRunnerConfig } from "../runner/config.js";
|
|
|
22
22
|
import { DESK_FOLDER, deskFiles, deskServicesOf, deskWebTitleOf, personDeskFiles, } from "../runner/desk.js";
|
|
23
23
|
import { quotedLines } from "../runner/message.js";
|
|
24
24
|
import { ownRunnerModules } from "../runner/modules.js";
|
|
25
|
-
import { createRunner, GIT_TOKEN_SECRET
|
|
25
|
+
import { createRunner, GIT_TOKEN_SECRET } from "../runner/runner.js";
|
|
26
26
|
import { hostOfLogin, } from "../schemas.js";
|
|
27
27
|
import { agentLoginOf, deskRemoteOf } from "../services.js";
|
|
28
28
|
import { setupGuideOf, setupGuideText, setupSentenceOf } from "../setup-guide.js";
|
|
@@ -31,11 +31,12 @@ import { loadWebRoot, WebRootError } from "../web.js";
|
|
|
31
31
|
import { commandLine, commandWord, NO_LINE_TO_RUN } from "./command-words.js";
|
|
32
32
|
import { CredentialsError, EMPTY_CREDENTIALS, fitsFile, keepsNothing, lasts, loginsAt, pendingAt, resolveLogin, withLogin, withoutLogin, withoutPending, withPending, } from "./credentials.js";
|
|
33
33
|
import { DIRECTORY_FILE, THE_SENTENCE, } from "./directory.js";
|
|
34
|
-
import { calledOf, deciderLogins, formatAgent, formatAgentLine, formatAnswer, formatCategoryLine, formatComment, formatDecision, formatDecisionLine, formatDocument, formatDocuments, formatGoal, formatGoalLine, formatInvocation, formatListingLine, formatMemberLine, formatMore, formatNotificationSettings, formatNotifications, formatOptions, formatOwnWakeLine, formatPersonLine, formatPersonWork, formatPlugin, formatPluginAsks, formatPluginEvents, formatPluginGrantLine, formatPluginHelp, formatPluginRecord, formatPluginRecords, formatPluginRecordVersions, formatPluginSettingLine, formatPlugins, formatProject, formatProjectLine, formatRules, formatRulesChanged, formatRulesLeftOut, formatRun, formatRunLine, formatSecretLine, formatSignalLine, formatTask, formatTaskFollow, formatTaskLine, formatTeamLine, formatVersion, formatVersionLine, formatWork, formatWorkspace, localized, moment, pageLine, rulesMark, setMomentZone, } from "./format.js";
|
|
35
|
-
import {
|
|
34
|
+
import { calledOf, deciderLogins, formatAgent, formatAgentLine, formatAnswer, formatCategoryLine, formatComment, formatDecision, formatDecisionLine, formatDocument, formatDocuments, formatGoal, formatGoalLine, formatInvocation, formatListingLine, formatMemberLine, formatMore, formatNotificationSettings, formatNotifications, formatOptions, formatOwnWakeLine, formatPersonLine, formatPersonWork, formatPlugin, formatPluginAsks, formatPluginEvents, formatPluginGrantLine, formatPluginHelp, formatPluginRecord, formatPluginRecords, formatPluginRecordVersions, formatPluginSettingLine, formatPlugins, formatProject, formatProjectLine, formatRules, formatRulesChanged, formatRulesLeftOut, formatRun, formatRunLine, formatSecretLine, formatSecretOffer, formatSignalLine, formatTask, formatTaskFollow, formatTaskLine, formatTeamLine, formatVersion, formatVersionLine, formatWork, formatWorkspace, localized, moment, pageLine, rulesMark, setMomentZone, } from "./format.js";
|
|
35
|
+
import { COMMAND_ALIASES, formTyped, held, helpFor, nearestCommands, ownSkillPath, usage, } from "./help.js";
|
|
36
36
|
import { describeInstall, updateCommandFor } from "./install.js";
|
|
37
37
|
import { awakeWords, heldAwake, lookAtMachine, standsInTheWay, } from "./machine-check.js";
|
|
38
38
|
import { consolePack, formatSkills, holdsNothing, ORGANIZATION_PACK_LINE, PackRefusal, packWords, refusalWords, skillPathIn, skillsAround, } from "./pack.js";
|
|
39
|
+
import { keptBySourceOf, keptFileOf, runnerStateOf } from "./runner-files.js";
|
|
39
40
|
import { workPath } from "./runner-host.js";
|
|
40
41
|
import { secretNotes } from "./secret-notes.js";
|
|
41
42
|
import { createServeHandler, DEFAULT_SERVE_PORT, loadRecordsRoot, RecordsRootError, } from "./serve.js";
|
|
@@ -107,9 +108,42 @@ function parse(args, options, allowPositionals = true) {
|
|
|
107
108
|
});
|
|
108
109
|
}
|
|
109
110
|
catch (error) {
|
|
110
|
-
throw misuse(error
|
|
111
|
+
throw misuse(refusedByParser(error, options));
|
|
111
112
|
}
|
|
112
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* What the parser refused, in the command's own words (ADR-0167): an option that is none of
|
|
116
|
+
* the command's is answered with those it takes, so that the next try needs no page of help;
|
|
117
|
+
* what the parser says of a value is said as it says it, without its advice on other things.
|
|
118
|
+
*/
|
|
119
|
+
function refusedByParser(error, options) {
|
|
120
|
+
if (!(error instanceof Error)) {
|
|
121
|
+
return "The arguments were not understood.";
|
|
122
|
+
}
|
|
123
|
+
const code = "code" in error ? String(error.code) : "";
|
|
124
|
+
// What was typed is between the parser's first quote and the one its sentence goes on
|
|
125
|
+
// after: a word may hold a quote of its own (`it's`), and is said whole.
|
|
126
|
+
const ADVICE = ". To specify a positional argument ";
|
|
127
|
+
const named = (code === "ERR_PARSE_ARGS_UNKNOWN_OPTION"
|
|
128
|
+
? /^Unknown option '(.*?)'(?:\. To specify a positional argument .*)?$/s
|
|
129
|
+
: /^Unexpected argument '(.*)'\. This command does not take positional arguments$/s).exec(error.message)?.[1] ??
|
|
130
|
+
/'([^']*)'/.exec(error.message)?.[1] ??
|
|
131
|
+
"";
|
|
132
|
+
if (code === "ERR_PARSE_ARGS_UNKNOWN_OPTION") {
|
|
133
|
+
const own = Object.keys(options).map((name) => `--${name}`);
|
|
134
|
+
const takes = own.length === 0 ? "It takes none of its own" : `Its own are ${own.join(", ")}`;
|
|
135
|
+
// A word of a report or a title may begin with a dash, and is then no option at all:
|
|
136
|
+
// said where the command takes a word, and what was typed does not read as an option.
|
|
137
|
+
const dashed = !error.message.includes(ADVICE) || /^--[a-z][a-z0-9-]*$/.test(named)
|
|
138
|
+
? ""
|
|
139
|
+
: " A word that begins with - and is no option goes after --.";
|
|
140
|
+
return `Not an option of this command: ${named}. ${takes}; --json, --project, --url and --account go with every command.${dashed}`;
|
|
141
|
+
}
|
|
142
|
+
if (code === "ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL") {
|
|
143
|
+
return `This command takes no word beside its options: ${named}.`;
|
|
144
|
+
}
|
|
145
|
+
return error.message;
|
|
146
|
+
}
|
|
113
147
|
const text = (values, name) => {
|
|
114
148
|
const value = values[name];
|
|
115
149
|
return typeof value === "string" ? value : undefined;
|
|
@@ -1057,7 +1091,7 @@ const whoami = async (args, io) => {
|
|
|
1057
1091
|
// agent here for where the skill is, and the workspace has rules whatever the project.
|
|
1058
1092
|
// The skill's path stands last, with nothing after it, to be copied as it is.
|
|
1059
1093
|
io.skillsDir === undefined
|
|
1060
|
-
? "Before the first task, read console rules and the skill working-the-board (
|
|
1094
|
+
? "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>."
|
|
1061
1095
|
: `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)}`,
|
|
1062
1096
|
`This command is ${io.version ?? "of a version it does not know"}${io.install === undefined ? "" : `, ${describeInstall(io.install)}`}; ${consoleWords}.`,
|
|
1063
1097
|
...(verdict === "behind"
|
|
@@ -1289,6 +1323,7 @@ async function readThrough(io, session, owner, pack, read, options) {
|
|
|
1289
1323
|
words: options.words,
|
|
1290
1324
|
json: session.json,
|
|
1291
1325
|
nextPart: options.nextPart,
|
|
1326
|
+
browseFolder: options.browseFolder,
|
|
1292
1327
|
room: roomFor(owner, options.beside ?? []),
|
|
1293
1328
|
});
|
|
1294
1329
|
}
|
|
@@ -1499,15 +1534,36 @@ async function readSkills(io, session, reader, values, positionals, extras) {
|
|
|
1499
1534
|
});
|
|
1500
1535
|
return EXIT.ok;
|
|
1501
1536
|
}
|
|
1537
|
+
// The command that reads the next page of a folder or of a search (SkillCDN 0.6.3): this
|
|
1538
|
+
// one again, asked as it was, with the cursor the page ended on. Where a word of it has no
|
|
1539
|
+
// spelling both shells take, the command that was run is run again, and the line says why.
|
|
1540
|
+
const nextPage = (asked) => (next) => commandLine(extras.command, [
|
|
1541
|
+
...asked,
|
|
1542
|
+
...(limit === undefined ? [] : ["--limit", limit]),
|
|
1543
|
+
"--cursor",
|
|
1544
|
+
next,
|
|
1545
|
+
...(extras.again ?? []),
|
|
1546
|
+
]) ??
|
|
1547
|
+
`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}`;
|
|
1502
1548
|
if (words !== undefined) {
|
|
1503
|
-
// One page of what the words find
|
|
1504
|
-
|
|
1505
|
-
|
|
1549
|
+
// One page of what the words find, which ends with the command that reads the next where
|
|
1550
|
+
// more was found. How a skill is loaded stands above it then, so that the command is last.
|
|
1551
|
+
const found = await readThrough(io, session, owner, pack, { read: "find", words, path: folder, cursor, limit }, {
|
|
1552
|
+
words: toolWords,
|
|
1553
|
+
beside: [loading],
|
|
1554
|
+
nextPart: nextPage([
|
|
1555
|
+
"--search",
|
|
1556
|
+
words,
|
|
1557
|
+
...(given === undefined ? [] : [given]),
|
|
1558
|
+
...(within === undefined ? [] : ["--path", within]),
|
|
1559
|
+
]),
|
|
1560
|
+
});
|
|
1561
|
+
say(jsonOfRead(session, pack, found), () => found.next === undefined ? `${found.text}\n${loading}` : `${loading}\n${found.text}`);
|
|
1506
1562
|
return EXIT.ok;
|
|
1507
1563
|
}
|
|
1508
1564
|
// One page of the folder, or of a file's outline, as the skillcdn command browses: a page
|
|
1509
|
-
// that ends before the folder does
|
|
1510
|
-
const browsed = await readThrough(io, session, owner, pack, { read: "browse", path: folder, cursor, limit }, { words: toolWords });
|
|
1565
|
+
// that ends before the folder does ends with the command that reads the next.
|
|
1566
|
+
const browsed = await readThrough(io, session, owner, pack, { read: "browse", path: folder, cursor, limit }, { words: toolWords, nextPart: nextPage(given === undefined ? [] : [given]) });
|
|
1511
1567
|
say(jsonOfRead(session, pack, browsed), () => browsed.text);
|
|
1512
1568
|
return EXIT.ok;
|
|
1513
1569
|
}
|
|
@@ -1596,6 +1652,11 @@ async function readSkill(io, session, reader, values, positionals, command, owne
|
|
|
1596
1652
|
// the command that was run is run again, with the cursor, and the line says why.
|
|
1597
1653
|
nextPart: (next) => commandLine(command, [given, "--cursor", next, ...again]) ??
|
|
1598
1654
|
`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}`,
|
|
1655
|
+
// The skill's own folder, where it does not list every file of it, as the command that
|
|
1656
|
+
// lists a folder of this pack (SkillCDN 0.6.3): the dot for the root, since the command
|
|
1657
|
+
// without a folder is the listing.
|
|
1658
|
+
browseFolder: (path) => commandLine(`${command}s`, [path.length === 0 ? "." : path, ...again]) ??
|
|
1659
|
+
`${command}s with this skill's folder, quoted for your shell. ${NO_LINE_TO_RUN}`,
|
|
1599
1660
|
});
|
|
1600
1661
|
say(jsonOfRead(session, pack, loaded), () => loaded.text);
|
|
1601
1662
|
return EXIT.ok;
|
|
@@ -2497,6 +2558,9 @@ const task = async (args, io) => {
|
|
|
2497
2558
|
if (args[0] === "restore") {
|
|
2498
2559
|
return taskRestore(args.slice(1), io);
|
|
2499
2560
|
}
|
|
2561
|
+
if (args[0] === "follow" || args[0] === "mute") {
|
|
2562
|
+
return following(args[0] === "follow")(args.slice(1), io);
|
|
2563
|
+
}
|
|
2500
2564
|
const { values, positionals } = parse(args, {});
|
|
2501
2565
|
const ref = theOne(positionals, "Say which task: console task <number|id>");
|
|
2502
2566
|
const session = await open(io, values);
|
|
@@ -2646,12 +2710,12 @@ const notify = async (args, io) => {
|
|
|
2646
2710
|
...(ownAgents === undefined ? {} : { ownAgents }),
|
|
2647
2711
|
})));
|
|
2648
2712
|
};
|
|
2649
|
-
// Whether one task tells a member anything (ADR-0157): `follow` turns its notifications
|
|
2650
|
-
// `mute` off. A task turned on that their settings would be silent of tells them of
|
|
2713
|
+
// Whether one task tells a member anything (ADR-0157): `task follow` turns its notifications
|
|
2714
|
+
// on, `task mute` off. A task turned on that their settings would be silent of tells them of
|
|
2651
2715
|
// everything on it; one turned to what their settings say already is told by their kinds.
|
|
2652
2716
|
const following = (turned) => async (args, io) => {
|
|
2653
2717
|
const { values, positionals } = parse(args, {});
|
|
2654
|
-
const ref = theOne(positionals, `Say which task: console ${turned ? "follow" : "mute"} <number|id>`);
|
|
2718
|
+
const ref = theOne(positionals, `Say which task: console task ${turned ? "follow" : "mute"} <number|id>`);
|
|
2655
2719
|
const session = await open(io, values);
|
|
2656
2720
|
const project = await session.project();
|
|
2657
2721
|
const found = await project.task(ref);
|
|
@@ -3170,11 +3234,29 @@ const docs = async (args, io) => {
|
|
|
3170
3234
|
answer(io, session, found, () => formatDocuments(found));
|
|
3171
3235
|
return EXIT.ok;
|
|
3172
3236
|
};
|
|
3237
|
+
/** What a read of one page takes beside its path. */
|
|
3238
|
+
const DOC_READ_FLAGS = {
|
|
3239
|
+
version: { type: "string" },
|
|
3240
|
+
versions: { type: "boolean" },
|
|
3241
|
+
};
|
|
3242
|
+
/** Whether the words are a read of one page: one path, and no flag but a read's own. */
|
|
3243
|
+
function readsOnePage(args) {
|
|
3244
|
+
try {
|
|
3245
|
+
return parse(args, DOC_READ_FLAGS).positionals.length === 1;
|
|
3246
|
+
}
|
|
3247
|
+
catch {
|
|
3248
|
+
return false;
|
|
3249
|
+
}
|
|
3250
|
+
}
|
|
3173
3251
|
const doc = async (args, io) => {
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3252
|
+
// A page may be called by a form's word, `write`, and is read as any page is (ADR-0167):
|
|
3253
|
+
// the word is the form wherever more follows it than a read of one page takes, a path or a
|
|
3254
|
+
// flag of the form's own, before the path as after it.
|
|
3255
|
+
const form = held(DOC_FORMS, args[0]);
|
|
3256
|
+
if (form !== undefined && !readsOnePage(args)) {
|
|
3257
|
+
return form(args.slice(1), io);
|
|
3258
|
+
}
|
|
3259
|
+
const { values, positionals } = parse(args, DOC_READ_FLAGS);
|
|
3178
3260
|
const path = theOne(positionals, "Say which page: console doc <path> [--version <n>|--versions]");
|
|
3179
3261
|
const session = await open(io, values);
|
|
3180
3262
|
const project = await session.project();
|
|
@@ -3204,7 +3286,7 @@ const write = async (args, io) => {
|
|
|
3204
3286
|
file: { type: "string" },
|
|
3205
3287
|
base: { type: "string" },
|
|
3206
3288
|
});
|
|
3207
|
-
const path = theOne(positionals, 'Say which page: console write <path> --title "<title>" --body <markdown>|--file <path>');
|
|
3289
|
+
const path = theOne(positionals, 'Say which page: console doc write <path> --title "<title>" --body <markdown>|--file <path>');
|
|
3208
3290
|
const body = await bodyOf(io, values, text(values, "body"));
|
|
3209
3291
|
if (body === undefined) {
|
|
3210
3292
|
throw misuse("Say what the page is to say: --body <markdown>, --file <path>, or --body - to read standard input.");
|
|
@@ -3244,7 +3326,7 @@ const attach = async (args, io) => {
|
|
|
3244
3326
|
const { values, positionals } = parse(args, { label: { type: "string" } });
|
|
3245
3327
|
const [path, file] = positionals;
|
|
3246
3328
|
if (path === undefined || file === undefined || positionals.length > 2) {
|
|
3247
|
-
throw misuse("Say the page and the file: console attach <path> <file> [--label <words>]");
|
|
3329
|
+
throw misuse("Say the page and the file: console doc attach <path> <file> [--label <words>]");
|
|
3248
3330
|
}
|
|
3249
3331
|
const label = text(values, "label");
|
|
3250
3332
|
const session = await open(io, values);
|
|
@@ -3269,7 +3351,7 @@ const attach = async (args, io) => {
|
|
|
3269
3351
|
};
|
|
3270
3352
|
const archive = async (args, io) => {
|
|
3271
3353
|
const { values, positionals } = parse(args, {});
|
|
3272
|
-
const path = theOne(positionals, "Say which page: console archive <path>");
|
|
3354
|
+
const path = theOne(positionals, "Say which page: console doc archive <path>");
|
|
3273
3355
|
const session = await open(io, values);
|
|
3274
3356
|
const project = await session.project();
|
|
3275
3357
|
const put = await project.archiveDocument(path);
|
|
@@ -3278,13 +3360,15 @@ const archive = async (args, io) => {
|
|
|
3278
3360
|
};
|
|
3279
3361
|
const restore = async (args, io) => {
|
|
3280
3362
|
const { values, positionals } = parse(args, {});
|
|
3281
|
-
const path = theOne(positionals, "Say which page: console restore <path>");
|
|
3363
|
+
const path = theOne(positionals, "Say which page: console doc restore <path>");
|
|
3282
3364
|
const session = await open(io, values);
|
|
3283
3365
|
const project = await session.project();
|
|
3284
3366
|
const back = await project.restoreDocument(path);
|
|
3285
3367
|
answer(io, session, back, () => `Restored ${back.path} (${back.title}).`);
|
|
3286
3368
|
return EXIT.ok;
|
|
3287
3369
|
};
|
|
3370
|
+
/** The forms of `console doc` that change a page, by the word that picks each. */
|
|
3371
|
+
const DOC_FORMS = { write, attach, archive, restore };
|
|
3288
3372
|
const goals = async (args, io) => {
|
|
3289
3373
|
const { values } = parse(args, {
|
|
3290
3374
|
category: { type: "string" },
|
|
@@ -3627,65 +3711,6 @@ const serve = async (args, io) => {
|
|
|
3627
3711
|
await listening.closed;
|
|
3628
3712
|
return EXIT.ok;
|
|
3629
3713
|
};
|
|
3630
|
-
/** What the runner keeps between its own restarts, as its file says it; nothing for a file that does not read. */
|
|
3631
|
-
function runnerStateOf(text) {
|
|
3632
|
-
if (text === undefined) {
|
|
3633
|
-
return undefined;
|
|
3634
|
-
}
|
|
3635
|
-
let json;
|
|
3636
|
-
try {
|
|
3637
|
-
json = JSON.parse(text);
|
|
3638
|
-
}
|
|
3639
|
-
catch {
|
|
3640
|
-
return undefined;
|
|
3641
|
-
}
|
|
3642
|
-
if (typeof json !== "object" || json === null) {
|
|
3643
|
-
return undefined;
|
|
3644
|
-
}
|
|
3645
|
-
const delivered = "delivered" in json ? json.delivered : undefined;
|
|
3646
|
-
const conversation = "conversation" in json ? json.conversation : undefined;
|
|
3647
|
-
const driver = "driver" in json ? json.driver : undefined;
|
|
3648
|
-
const limited = "limited" in json ? json.limited : undefined;
|
|
3649
|
-
const kept = "kept" in json ? json.kept : undefined;
|
|
3650
|
-
if (typeof delivered !== "number" || !Number.isSafeInteger(delivered) || delivered < 0) {
|
|
3651
|
-
return undefined;
|
|
3652
|
-
}
|
|
3653
|
-
/**
|
|
3654
|
-
* A moment in milliseconds since the epoch, or nothing for anything else: a number past what
|
|
3655
|
-
* a date holds would fail the runner at every start, where it says the moment in words.
|
|
3656
|
-
*/
|
|
3657
|
-
const momentOf = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0 && value < 1e14
|
|
3658
|
-
? value
|
|
3659
|
-
: undefined;
|
|
3660
|
-
const since = typeof limited === "object" && limited !== null && "since" in limited
|
|
3661
|
-
? momentOf(limited.since)
|
|
3662
|
-
: undefined;
|
|
3663
|
-
return {
|
|
3664
|
-
delivered,
|
|
3665
|
-
conversation: typeof conversation === "string" && conversation.length > 0 && conversation.length <= 200
|
|
3666
|
-
? conversation
|
|
3667
|
-
: undefined,
|
|
3668
|
-
// The driver the conversation was begun under, as a registry spells one.
|
|
3669
|
-
driver: typeof driver === "string" && /^[a-z][a-z0-9-]{0,39}$/.test(driver) ? driver : undefined,
|
|
3670
|
-
// The usage limit the agent is not back from (ADR-0150): since when, and until when where the product said.
|
|
3671
|
-
...(since === undefined || typeof limited !== "object" || limited === null
|
|
3672
|
-
? {}
|
|
3673
|
-
: {
|
|
3674
|
-
limited: {
|
|
3675
|
-
since,
|
|
3676
|
-
until: "until" in limited ? momentOf(limited.until) : undefined,
|
|
3677
|
-
},
|
|
3678
|
-
}),
|
|
3679
|
-
// The signals the record has as delivered that the agent never read: taken from the stream once more.
|
|
3680
|
-
...(Array.isArray(kept)
|
|
3681
|
-
? {
|
|
3682
|
-
kept: kept
|
|
3683
|
-
.filter((number) => momentOf(number) !== undefined)
|
|
3684
|
-
.slice(0, 50),
|
|
3685
|
-
}
|
|
3686
|
-
: {}),
|
|
3687
|
-
};
|
|
3688
|
-
}
|
|
3689
3714
|
/** A line a runner says of its machine, within what the console takes one in. */
|
|
3690
3715
|
const machineLine = (text) => {
|
|
3691
3716
|
const line = [...text]
|
|
@@ -3801,6 +3826,8 @@ const runner = async (args, io) => {
|
|
|
3801
3826
|
});
|
|
3802
3827
|
}
|
|
3803
3828
|
const statePath = workPath("runner-state.json");
|
|
3829
|
+
// A wake source is named as a registry spells one, which is a file's name as it stands.
|
|
3830
|
+
const keptPath = (source) => workPath(`runner-kept-${source.replaceAll(/[^a-z0-9-]/g, "_")}.json`);
|
|
3804
3831
|
const person = me.person;
|
|
3805
3832
|
/** A runner for the desk's runner.json as it is read now: begun again whenever the file changed (ADR-0144). */
|
|
3806
3833
|
const runnerOf = (read) => {
|
|
@@ -3835,6 +3862,8 @@ const runner = async (args, io) => {
|
|
|
3835
3862
|
now: io.now,
|
|
3836
3863
|
random: host.random,
|
|
3837
3864
|
time: (iso) => clock.format(new Date(iso)),
|
|
3865
|
+
// What a wake source shows of the agent at its messenger is in the workspace's language (ADR-0170).
|
|
3866
|
+
language: me.workspace.language ?? undefined,
|
|
3838
3867
|
// A moment that may be on another day, a stretch the runner did not run in or when a
|
|
3839
3868
|
// usage limit resets, is said as the command prints any moment: with its day, in the
|
|
3840
3869
|
// workspace's zone where the login kept one.
|
|
@@ -3845,7 +3874,7 @@ const runner = async (args, io) => {
|
|
|
3845
3874
|
},
|
|
3846
3875
|
state: {
|
|
3847
3876
|
load: async () => runnerStateOf(await host.readText(statePath)),
|
|
3848
|
-
save: (state) => host.
|
|
3877
|
+
save: (state) => host.replacePrivate(statePath, `${JSON.stringify(state)}\n`),
|
|
3849
3878
|
},
|
|
3850
3879
|
log: (line) => io.stdout(`${new Date(io.now()).toISOString()} ${line}\n`),
|
|
3851
3880
|
// The autosave's git: in the desk, asking nobody at a terminal, its words read and let go.
|
|
@@ -3874,6 +3903,12 @@ const runner = async (args, io) => {
|
|
|
3874
3903
|
}),
|
|
3875
3904
|
fetch: (url, init) => io.fetch(url, { ...init, headers: { ...init.headers } }),
|
|
3876
3905
|
socket: (url) => host.socket(url),
|
|
3906
|
+
// What a source keeps of what it brought the agent, ids and moments and never a word,
|
|
3907
|
+
// in a file of its own beside the runner's state: a runner started again reads it.
|
|
3908
|
+
kept: {
|
|
3909
|
+
load: async (source) => keptBySourceOf(await host.readText(keptPath(source))),
|
|
3910
|
+
save: (source, kept) => host.replacePrivate(keptPath(source), keptFileOf(kept)),
|
|
3911
|
+
},
|
|
3877
3912
|
},
|
|
3878
3913
|
});
|
|
3879
3914
|
};
|
|
@@ -3960,7 +3995,7 @@ const agents = async (args, io) => {
|
|
|
3960
3995
|
: found.items.map(formatAgentLine).join("\n"));
|
|
3961
3996
|
return EXIT.ok;
|
|
3962
3997
|
};
|
|
3963
|
-
const AGENT_USAGE =
|
|
3998
|
+
const AGENT_USAGE = "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 ...";
|
|
3964
3999
|
// An administrator makes an agent account with flags, where the pages make one from a form
|
|
3965
4000
|
// (ADR-0084): the member's row at once, its login let in. What is left out is proposed: the
|
|
3966
4001
|
// name is the handle's, capitalized, and the console rolls the avatar from the seed, or from one
|
|
@@ -4065,11 +4100,20 @@ const SECRET_FLAGS = {
|
|
|
4065
4100
|
file: { type: "string" },
|
|
4066
4101
|
expires: { type: "string" },
|
|
4067
4102
|
};
|
|
4103
|
+
/** What ends the listing of the offers that wait: the two things the account does with one. */
|
|
4104
|
+
const OFFERED_NEXT = "Take one into your store: console secret --accept <offer id> [--as <name>] [--replace] | leave one: console secret --decline <offer id>";
|
|
4068
4105
|
// An agent account's own secret store (ADR-0087): the names it keeps, for the account itself,
|
|
4069
|
-
// signed in as itself.
|
|
4106
|
+
// signed in as itself; and, with --offered, what members offered it that waits (ADR-0169).
|
|
4070
4107
|
const secrets = async (args, io) => {
|
|
4071
|
-
const { values } = parse(args, {}, false);
|
|
4108
|
+
const { values } = parse(args, { offered: { type: "boolean" } }, false);
|
|
4072
4109
|
const session = await open(io, values);
|
|
4110
|
+
if (on(values, "offered")) {
|
|
4111
|
+
const offered = await session.client.secretOffers();
|
|
4112
|
+
answer(io, session, offered, () => offered.items.length === 0
|
|
4113
|
+
? "No offered secret waits for you."
|
|
4114
|
+
: [...offered.items.map((item) => formatSecretOffer(item)), OFFERED_NEXT].join("\n"));
|
|
4115
|
+
return EXIT.ok;
|
|
4116
|
+
}
|
|
4073
4117
|
const found = await session.client.secrets();
|
|
4074
4118
|
answer(io, session, found, () => found.items.length === 0
|
|
4075
4119
|
? "No secret is kept yet: console secret <name> --set keeps one."
|
|
@@ -4077,9 +4121,59 @@ const secrets = async (args, io) => {
|
|
|
4077
4121
|
return EXIT.ok;
|
|
4078
4122
|
};
|
|
4079
4123
|
const SECRET_USAGE = "Say which secret: console secret <name> | secret <name> --set [--file <path>] [--expires <day|none>] | secret <name> --remove";
|
|
4124
|
+
const OFFER_USAGE = "Say which offer, by its id as console secrets --offered lists it: console secret --accept <offer id> [--as <name>] [--replace] | secret --decline <offer id>";
|
|
4125
|
+
/**
|
|
4126
|
+
* An offer the account takes into its store or leaves (ADR-0169): named by its id, since the
|
|
4127
|
+
* name an offerer proposed is theirs to choose and two may propose the same.
|
|
4128
|
+
*/
|
|
4129
|
+
async function offeredSecret(io, values, positionals) {
|
|
4130
|
+
const taking = on(values, "accept");
|
|
4131
|
+
if ((taking && on(values, "decline")) || on(values, "set") || on(values, "remove")) {
|
|
4132
|
+
throw misuse("Say one of --accept, --decline, --set and --remove.");
|
|
4133
|
+
}
|
|
4134
|
+
const as = text(values, "as");
|
|
4135
|
+
if (!taking && (as !== undefined || on(values, "replace"))) {
|
|
4136
|
+
throw misuse("--as and --replace go with --accept: an offer that is left is kept under no name.");
|
|
4137
|
+
}
|
|
4138
|
+
const id = theOne(positionals, OFFER_USAGE);
|
|
4139
|
+
const session = await open(io, values);
|
|
4140
|
+
if (!taking) {
|
|
4141
|
+
await session.client.leaveSecretOffer(id);
|
|
4142
|
+
answer(io, session, { left: id }, () => `The offer ${id} is left, and its value is gone.`);
|
|
4143
|
+
return EXIT.ok;
|
|
4144
|
+
}
|
|
4145
|
+
let kept;
|
|
4146
|
+
try {
|
|
4147
|
+
kept = await session.client.takeSecretOffer(id, {
|
|
4148
|
+
...(as === undefined ? {} : { as }),
|
|
4149
|
+
...(on(values, "replace") ? { replace: true } : {}),
|
|
4150
|
+
});
|
|
4151
|
+
}
|
|
4152
|
+
catch (error) {
|
|
4153
|
+
if (error instanceof ApiError && error.code === "secret.exists") {
|
|
4154
|
+
throw failed(`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.`);
|
|
4155
|
+
}
|
|
4156
|
+
throw error;
|
|
4157
|
+
}
|
|
4158
|
+
answer(io, session, kept, () => `Taken into your store: ${formatSecretLine(kept)}`);
|
|
4159
|
+
return EXIT.ok;
|
|
4160
|
+
}
|
|
4080
4161
|
// One secret of the account's own: its value, read and noted; or set, typed unseen; or removed.
|
|
4162
|
+
// And one offered to it, taken or left.
|
|
4081
4163
|
const secret = async (args, io) => {
|
|
4082
|
-
const { values, positionals } = parse(args,
|
|
4164
|
+
const { values, positionals } = parse(args, {
|
|
4165
|
+
...SECRET_FLAGS,
|
|
4166
|
+
accept: { type: "boolean" },
|
|
4167
|
+
decline: { type: "boolean" },
|
|
4168
|
+
as: { type: "string" },
|
|
4169
|
+
replace: { type: "boolean" },
|
|
4170
|
+
});
|
|
4171
|
+
if (on(values, "accept") || on(values, "decline")) {
|
|
4172
|
+
return offeredSecret(io, values, positionals);
|
|
4173
|
+
}
|
|
4174
|
+
if (text(values, "as") !== undefined || on(values, "replace")) {
|
|
4175
|
+
throw misuse(`--as and --replace go with --accept. ${OFFER_USAGE}`);
|
|
4176
|
+
}
|
|
4083
4177
|
const name = theOne(positionals, SECRET_USAGE);
|
|
4084
4178
|
const session = await open(io, values);
|
|
4085
4179
|
if (on(values, "remove")) {
|
|
@@ -4107,9 +4201,18 @@ const secret = async (args, io) => {
|
|
|
4107
4201
|
// A supervisor's part of an agent account's store (ADR-0087): the names; a secret seeded,
|
|
4108
4202
|
// write-only, which only the account reads back; one removed. Never a value.
|
|
4109
4203
|
const agentSecrets = async (args, io) => {
|
|
4110
|
-
const { values, positionals } = parse(args, {});
|
|
4111
|
-
const handle = handleOf(theOne(positionals, "Say whose: console agent secrets <handle>"));
|
|
4204
|
+
const { values, positionals } = parse(args, { offered: { type: "boolean" } });
|
|
4205
|
+
const handle = handleOf(theOne(positionals, "Say whose: console agent secrets <handle> [--offered]"));
|
|
4112
4206
|
const session = await open(io, values);
|
|
4207
|
+
if (on(values, "offered")) {
|
|
4208
|
+
// What the account was offered (ADR-0169): its record whole for a supervisor, and for any
|
|
4209
|
+
// other member what they offered it themselves.
|
|
4210
|
+
const offered = await session.client.agentSecretOffers(handle);
|
|
4211
|
+
answer(io, session, offered, () => offered.items.length === 0
|
|
4212
|
+
? `Nothing was offered to @${handle} that is yours to read.`
|
|
4213
|
+
: offered.items.map((item) => formatSecretOffer(item)).join("\n"));
|
|
4214
|
+
return EXIT.ok;
|
|
4215
|
+
}
|
|
4113
4216
|
let found;
|
|
4114
4217
|
try {
|
|
4115
4218
|
found = await session.client.agentSecrets(handle);
|
|
@@ -4131,10 +4234,39 @@ const agentSecrets = async (args, io) => {
|
|
|
4131
4234
|
return EXIT.ok;
|
|
4132
4235
|
};
|
|
4133
4236
|
const agentSecret = async (args, io) => {
|
|
4134
|
-
const { values, positionals } = parse(args,
|
|
4135
|
-
|
|
4237
|
+
const { values, positionals } = parse(args, {
|
|
4238
|
+
...SECRET_FLAGS,
|
|
4239
|
+
offer: { type: "boolean" },
|
|
4240
|
+
note: { type: "string" },
|
|
4241
|
+
});
|
|
4242
|
+
const [given, name] = theTwo(positionals, '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');
|
|
4136
4243
|
const handle = handleOf(given);
|
|
4244
|
+
const offering = on(values, "offer");
|
|
4245
|
+
const said = text(values, "note")?.trim();
|
|
4246
|
+
if (offering && on(values, "remove")) {
|
|
4247
|
+
throw misuse("Say one of --offer and --remove.");
|
|
4248
|
+
}
|
|
4249
|
+
if (said !== undefined && !offering) {
|
|
4250
|
+
throw misuse("--note says what an offered secret is for, and goes with --offer.");
|
|
4251
|
+
}
|
|
4137
4252
|
const session = await open(io, values);
|
|
4253
|
+
if (offering) {
|
|
4254
|
+
// Any member's (ADR-0169): the value waits, sealed, for the account to take or leave, and
|
|
4255
|
+
// nothing of what the account keeps changes.
|
|
4256
|
+
const expiresOn = expiryOf(io, values);
|
|
4257
|
+
const value = await secretValue(io, values, `Value of ${name} to offer @${handle} (typed unseen; Enter ends it): `);
|
|
4258
|
+
const offered = await session.client.offerAgentSecret(handle, {
|
|
4259
|
+
name,
|
|
4260
|
+
value,
|
|
4261
|
+
...(said === undefined || said === "" ? {} : { note: said }),
|
|
4262
|
+
...(expiresOn === undefined ? {} : { expiresOn }),
|
|
4263
|
+
});
|
|
4264
|
+
answer(io, session, offered, () => [
|
|
4265
|
+
`Offered to @${handle}, which is told and takes it into its store or leaves it: ${formatSecretOffer(offered)}`,
|
|
4266
|
+
`Nothing @${handle} keeps changed, and nobody is answered the value. How it stands: console agent secrets ${handle} --offered`,
|
|
4267
|
+
].join("\n"));
|
|
4268
|
+
return EXIT.ok;
|
|
4269
|
+
}
|
|
4138
4270
|
if (on(values, "remove")) {
|
|
4139
4271
|
await session.client.removeAgentSecret(handle, name);
|
|
4140
4272
|
answer(io, session, { handle, removed: name }, () => `The secret ${name} of @${handle} is removed.`);
|
|
@@ -4143,10 +4275,20 @@ const agentSecret = async (args, io) => {
|
|
|
4143
4275
|
const expiresOn = expiryOf(io, values);
|
|
4144
4276
|
const value = await secretValue(io, values, `Value of ${name} for @${handle} (typed unseen; Enter ends it): `);
|
|
4145
4277
|
const host = await gitHostFor(session.client, name);
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4278
|
+
let kept;
|
|
4279
|
+
try {
|
|
4280
|
+
kept = await session.client.seedAgentSecret(handle, name, {
|
|
4281
|
+
value,
|
|
4282
|
+
...(expiresOn === undefined ? {} : { expiresOn }),
|
|
4283
|
+
});
|
|
4284
|
+
}
|
|
4285
|
+
catch (error) {
|
|
4286
|
+
// Whoever supervises the account not is told what is theirs to do in its place.
|
|
4287
|
+
if (error instanceof ApiError && error.code === "auth.forbidden") {
|
|
4288
|
+
throw failed(`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>".`);
|
|
4289
|
+
}
|
|
4290
|
+
throw error;
|
|
4291
|
+
}
|
|
4150
4292
|
const notes = secretNotes(name, value, host);
|
|
4151
4293
|
answer(io, session, kept, () => [`Seeded for @${handle}, which alone reads it back: ${formatSecretLine(kept)}`, ...notes].join("\n"));
|
|
4152
4294
|
return EXIT.ok;
|
|
@@ -4290,36 +4432,32 @@ const WORDED_SIGNALS = {
|
|
|
4290
4432
|
reset: { needs: false },
|
|
4291
4433
|
wake: { needs: false },
|
|
4292
4434
|
};
|
|
4435
|
+
/**
|
|
4436
|
+
* Whether the words after `agent wake` or `agent reset` are the account's own form: `me` where
|
|
4437
|
+
* the handle stands, wherever that is among the form's flags. Read without refusing a word, so
|
|
4438
|
+
* that a mistake among them is answered by the form that was typed, and not by the other's.
|
|
4439
|
+
*/
|
|
4440
|
+
function isOwnForm(args, flags) {
|
|
4441
|
+
const { positionals } = parseArgs({
|
|
4442
|
+
args: [...args],
|
|
4443
|
+
options: { ...GLOBAL_OPTIONS, ...flags },
|
|
4444
|
+
allowPositionals: true,
|
|
4445
|
+
strict: false,
|
|
4446
|
+
});
|
|
4447
|
+
return positionals[0] === "me";
|
|
4448
|
+
}
|
|
4293
4449
|
// A supervisor's signal to an agent account (ADR-0085): a tell, an interruption, a stop, a start
|
|
4294
4450
|
// with the same conversation or with a new one, a wake; in their own name, on the account's
|
|
4295
4451
|
// record. What it says is given as words, or with --file, or on standard input as `-`.
|
|
4296
4452
|
const agentSignal = async (kind, args, io) => {
|
|
4297
4453
|
// An account's own wake is another command under the same word: console agent wake me,
|
|
4298
4454
|
// wherever `me` stands among its flags.
|
|
4299
|
-
if (kind === "wake") {
|
|
4300
|
-
|
|
4301
|
-
try {
|
|
4302
|
-
whom = parse(args, OWN_WAKE_FLAGS).positionals[0];
|
|
4303
|
-
}
|
|
4304
|
-
catch {
|
|
4305
|
-
whom = undefined;
|
|
4306
|
-
}
|
|
4307
|
-
if (whom === "me") {
|
|
4308
|
-
return ownWake(args, io);
|
|
4309
|
-
}
|
|
4455
|
+
if (kind === "wake" && isOwnForm(args, OWN_WAKE_FLAGS)) {
|
|
4456
|
+
return ownWake(args, io);
|
|
4310
4457
|
}
|
|
4311
4458
|
// And so is its own reset: console agent reset me.
|
|
4312
|
-
if (kind === "reset") {
|
|
4313
|
-
|
|
4314
|
-
try {
|
|
4315
|
-
whom = parse(args, { file: { type: "string" } }).positionals[0];
|
|
4316
|
-
}
|
|
4317
|
-
catch {
|
|
4318
|
-
whom = undefined;
|
|
4319
|
-
}
|
|
4320
|
-
if (whom === "me") {
|
|
4321
|
-
return ownReset(args, io);
|
|
4322
|
-
}
|
|
4459
|
+
if (kind === "reset" && isOwnForm(args, { file: { type: "string" } })) {
|
|
4460
|
+
return ownReset(args, io);
|
|
4323
4461
|
}
|
|
4324
4462
|
const { values, positionals } = parse(args, { file: { type: "string" } });
|
|
4325
4463
|
const [given, words, ...rest] = positionals;
|
|
@@ -5084,7 +5222,7 @@ const DESK_USAGE = "Say at most one directory: console desk [<directory>] [--web
|
|
|
5084
5222
|
function deskNext(web, skillsDir) {
|
|
5085
5223
|
return [
|
|
5086
5224
|
`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`,
|
|
5087
|
-
`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 ? " (
|
|
5225
|
+
`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")}`}`,
|
|
5088
5226
|
];
|
|
5089
5227
|
}
|
|
5090
5228
|
/** The files of the shell of a desk's pages as they are written: the two words the template leaves filled in. */
|
|
@@ -5959,22 +6097,50 @@ const COMMANDS = {
|
|
|
5959
6097
|
run,
|
|
5960
6098
|
docs,
|
|
5961
6099
|
doc,
|
|
6100
|
+
// The words of before (COMMAND_ALIASES, ADR-0167): they run as they did, and no list names them.
|
|
5962
6101
|
write,
|
|
5963
6102
|
attach,
|
|
5964
6103
|
archive,
|
|
5965
6104
|
restore,
|
|
5966
6105
|
};
|
|
5967
|
-
|
|
5968
|
-
|
|
6106
|
+
/** The words the dispatch takes: what a test holds to the pages of help and to the words of before. */
|
|
6107
|
+
export const COMMAND_WORDS = Object.keys(COMMANDS);
|
|
6108
|
+
/** What a word that is no command is answered with: the nearest there are, and where all are listed. */
|
|
6109
|
+
function notCommand(word, near = nearestCommands(word)) {
|
|
6110
|
+
return misuse(`Not a command: ${word}.${near.length === 0 ? "" : ` Nearest: ${near.join(", ")}.`} console help lists the commands.`);
|
|
6111
|
+
}
|
|
6112
|
+
/**
|
|
6113
|
+
* The help the words ask for (ADR-0167): the table of the commands for none, else the page of
|
|
6114
|
+
* a command, or of one of its forms. Flags among the words are left unread.
|
|
6115
|
+
*/
|
|
6116
|
+
function help(io, words) {
|
|
6117
|
+
const named = words.filter((word) => !word.startsWith("-"));
|
|
6118
|
+
// Help asked of help is the table too.
|
|
6119
|
+
if (named.length === 0 || (named.length === 1 && named[0] === "help")) {
|
|
5969
6120
|
io.stdout(usage(io.version, io.skillsDir));
|
|
5970
6121
|
return EXIT.ok;
|
|
5971
6122
|
}
|
|
5972
|
-
const found = helpFor(
|
|
5973
|
-
if (
|
|
5974
|
-
|
|
6123
|
+
const found = helpFor(named, io.skillsDir);
|
|
6124
|
+
if ("page" in found) {
|
|
6125
|
+
io.stdout(found.page);
|
|
6126
|
+
return EXIT.ok;
|
|
5975
6127
|
}
|
|
5976
|
-
|
|
5977
|
-
|
|
6128
|
+
if ("notCommand" in found) {
|
|
6129
|
+
throw notCommand(found.notCommand, found.near);
|
|
6130
|
+
}
|
|
6131
|
+
throw misuse(`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.`);
|
|
6132
|
+
}
|
|
6133
|
+
/**
|
|
6134
|
+
* The line after a command that was not understood (ADR-0167): where its forms and flags are,
|
|
6135
|
+
* the page of the form that was tried where it has one. Nothing where the words say it already.
|
|
6136
|
+
*/
|
|
6137
|
+
function helpPointer(name, rest, said) {
|
|
6138
|
+
if (said.includes("console help")) {
|
|
6139
|
+
return "";
|
|
6140
|
+
}
|
|
6141
|
+
const [command, aliased] = held(COMMAND_ALIASES, name) ?? [name, undefined];
|
|
6142
|
+
const form = aliased ?? formTyped(command, rest);
|
|
6143
|
+
return `Its forms and flags: console help ${command}${form === undefined ? "" : ` ${form}`}\n`;
|
|
5978
6144
|
}
|
|
5979
6145
|
/**
|
|
5980
6146
|
* A client of the console at `url`, naming the command on every request (ADR-0025). A redirect
|
|
@@ -6074,11 +6240,11 @@ function hintFor(error, io, seen) {
|
|
|
6074
6240
|
case "project.not_found":
|
|
6075
6241
|
return "No project has this key, or it is not yours to see. console projects lists the projects you may work in.\n";
|
|
6076
6242
|
case "document.not_found":
|
|
6077
|
-
return "No page has this path, in this project. console docs lists the pages of a folder; console write <path> writes one.\n";
|
|
6243
|
+
return "No page has this path, in this project. console docs lists the pages of a folder; console doc write <path> writes one.\n";
|
|
6078
6244
|
case "document.conflict":
|
|
6079
6245
|
return "The page has moved on since the version you started from. Read it again, and write from there.\n";
|
|
6080
6246
|
case "document.archived":
|
|
6081
|
-
return "The page is archived. console restore <path> brings it back first.\n";
|
|
6247
|
+
return "The page is archived. console doc restore <path> brings it back first.\n";
|
|
6082
6248
|
case "task.invalid_category":
|
|
6083
6249
|
return "No category has that key. console categories lists them.\n";
|
|
6084
6250
|
case "task.invalid_goal":
|
|
@@ -6171,14 +6337,18 @@ export async function runCli(argv, io) {
|
|
|
6171
6337
|
return EXIT.ok;
|
|
6172
6338
|
}
|
|
6173
6339
|
if (name === undefined || name === "help" || name === "--help" || name === "-h") {
|
|
6174
|
-
return help(io, rest
|
|
6340
|
+
return help(io, rest);
|
|
6175
6341
|
}
|
|
6176
6342
|
if (rest.includes("--help") || rest.includes("-h")) {
|
|
6177
|
-
|
|
6343
|
+
// The page of the form that was being typed, where it has one.
|
|
6344
|
+
const [command, aliased] = held(COMMAND_ALIASES, name) ?? [name, undefined];
|
|
6345
|
+
const form = aliased ??
|
|
6346
|
+
formTyped(command, rest.filter((word) => word !== "--help" && word !== "-h"));
|
|
6347
|
+
return help(io, form === undefined ? [command] : [command, form]);
|
|
6178
6348
|
}
|
|
6179
|
-
const command = COMMANDS
|
|
6349
|
+
const command = held(COMMANDS, name);
|
|
6180
6350
|
if (command === undefined) {
|
|
6181
|
-
throw
|
|
6351
|
+
throw notCommand(name);
|
|
6182
6352
|
}
|
|
6183
6353
|
const exit = await command(rest, watched);
|
|
6184
6354
|
if (name !== "whoami") {
|
|
@@ -6188,7 +6358,11 @@ export async function runCli(argv, io) {
|
|
|
6188
6358
|
}
|
|
6189
6359
|
catch (error) {
|
|
6190
6360
|
if (error instanceof CliExit) {
|
|
6191
|
-
|
|
6361
|
+
// A command that was not understood says where its forms and flags are, in a line.
|
|
6362
|
+
const pointer = error.exit === EXIT.usage && name !== undefined && held(COMMANDS, name) !== undefined
|
|
6363
|
+
? helpPointer(name, rest, error.message)
|
|
6364
|
+
: "";
|
|
6365
|
+
io.stderr(`${error.message}\n${pointer}`);
|
|
6192
6366
|
return error.exit;
|
|
6193
6367
|
}
|
|
6194
6368
|
if (error instanceof UnseenProject) {
|