@skillcdn/console 0.6.2 → 0.6.4
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 +16 -9
- 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 +46 -5
- 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 +6 -4
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +6 -4
- 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 +948 -252
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/format.d.ts +44 -7
- package/dist/cli/format.d.ts.map +1 -1
- package/dist/cli/format.js +168 -13
- 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 +855 -331
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/pack.d.ts +13 -12
- package/dist/cli/pack.d.ts.map +1 -1
- package/dist/cli/pack.js +33 -45
- package/dist/cli/pack.js.map +1 -1
- package/dist/cli/plugin-cli.d.ts.map +1 -1
- package/dist/cli/plugin-cli.js +8 -5
- package/dist/cli/plugin-cli.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 +125 -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/cli/skill-path.d.ts +11 -0
- package/dist/cli/skill-path.d.ts.map +1 -0
- package/dist/cli/skill-path.js +44 -0
- package/dist/cli/skill-path.js.map +1 -0
- package/dist/client.d.ts +32 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +15 -1
- package/dist/client.js.map +1 -1
- package/dist/components/agent-page.d.ts +93 -6
- package/dist/components/agent-page.d.ts.map +1 -1
- package/dist/components/agent-page.js +202 -10
- package/dist/components/agent-page.js.map +1 -1
- package/dist/components/agents.d.ts +6 -6
- package/dist/components/agents.d.ts.map +1 -1
- package/dist/components/agents.js +16 -9
- package/dist/components/agents.js.map +1 -1
- package/dist/components/people.d.ts.map +1 -1
- package/dist/components/people.js +7 -2
- package/dist/components/people.js.map +1 -1
- package/dist/components/picker.d.ts +16 -0
- package/dist/components/picker.d.ts.map +1 -1
- package/dist/components/picker.js +69 -4
- package/dist/components/picker.js.map +1 -1
- package/dist/console.css +40 -0
- package/dist/console.js +2 -2
- 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 +64 -6
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +59 -10
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/ko.d.ts.map +1 -1
- package/dist/i18n/ko.js +49 -9
- package/dist/i18n/ko.js.map +1 -1
- package/dist/limits.d.ts +26 -0
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +26 -0
- package/dist/limits.js.map +1 -1
- package/dist/onboarding.d.ts +18 -6
- package/dist/onboarding.d.ts.map +1 -1
- package/dist/onboarding.js +42 -7
- package/dist/onboarding.js.map +1 -1
- package/dist/plugin/args.d.ts +24 -2
- package/dist/plugin/args.d.ts.map +1 -1
- package/dist/plugin/args.js +20 -2
- package/dist/plugin/args.js.map +1 -1
- package/dist/plugin/context.d.ts +39 -7
- package/dist/plugin/context.d.ts.map +1 -1
- package/dist/plugin/define.d.ts.map +1 -1
- package/dist/plugin/define.js +12 -3
- package/dist/plugin/define.js.map +1 -1
- package/dist/plugin/rest-schemas.d.ts +2 -0
- package/dist/plugin/rest-schemas.d.ts.map +1 -1
- package/dist/plugin/rest-schemas.js +1 -0
- package/dist/plugin/rest-schemas.js.map +1 -1
- package/dist/routes.d.ts +2 -0
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +2 -0
- package/dist/routes.js.map +1 -1
- package/dist/rules.d.ts +4 -1
- package/dist/rules.d.ts.map +1 -1
- package/dist/rules.js +5 -2
- package/dist/rules.js.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 +53 -1
- package/dist/runner/claude.js.map +1 -1
- package/dist/runner/codex.d.ts.map +1 -1
- package/dist/runner/codex.js +18 -3
- 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 +14 -4
- 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 +41 -1
- package/dist/runner/runner.d.ts.map +1 -1
- package/dist/runner/runner.js +557 -23
- 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 +258 -59
- package/dist/runner/slack.js.map +1 -1
- package/dist/runner/types.d.ts +128 -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 +635 -6
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +197 -15
- package/dist/schemas.js.map +1 -1
- package/dist/secret-file.d.ts +21 -0
- package/dist/secret-file.d.ts.map +1 -0
- package/dist/secret-file.js +59 -0
- package/dist/secret-file.js.map +1 -0
- package/dist/services.d.ts.map +1 -1
- package/dist/services.js +3 -2
- package/dist/services.js.map +1 -1
- package/dist/setup-guide.d.ts +2 -2
- package/dist/setup-guide.d.ts.map +1 -1
- package/dist/setup-guide.js +6 -5
- package/dist/setup-guide.js.map +1 -1
- package/dist/vocabulary.d.ts +17 -2
- package/dist/vocabulary.d.ts.map +1 -1
- package/dist/vocabulary.js +15 -2
- 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 +39 -25
- package/docs/specs/plugins.md +10 -9
- package/docs/specs/rest.md +34 -15
- package/docs/specs/runner.md +108 -25
- package/docs/start.md +28 -6
- 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/keeping-the-pack/SKILL.md +87 -0
- package/skills/planning-the-board/SKILL.md +6 -6
- package/skills/planning-the-board/references/a-task.md +1 -1
- package/skills/planning-the-board/references/setting-up.md +9 -5
- package/skills/running-an-agent/SKILL.md +21 -17
- package/skills/running-an-agent/references/preparing-the-machine.md +4 -3
- package/skills/running-an-agent/references/several-tasks.md +8 -2
- package/skills/running-an-agent/references/slack-app.md +31 -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 +3 -1
- package/skills/running-an-agent/references/when-the-agent-could-not-go-on.md +4 -4
- package/skills/running-an-agent/references/your-first-task.md +11 -5
- 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 +6 -6
- package/skills/working-the-board/references/terms.md +3 -1
- package/skills/working-the-board/references/the-pack.md +14 -7
- package/skills/working-the-board/references/what-they-were-told.md +1 -1
- package/src/agent-page.tsx +111 -4
- package/src/agent-state.ts +33 -0
- package/src/api.ts +43 -0
- package/src/cli/cli.ts +1190 -313
- package/src/cli/format.ts +207 -13
- package/src/cli/help.ts +991 -372
- package/src/cli/pack.ts +55 -62
- package/src/cli/plugin-cli.ts +8 -5
- package/src/cli/runner-files.ts +137 -0
- package/src/cli/runner-host.ts +48 -2
- package/src/cli/skill-path.ts +51 -0
- package/src/client.ts +103 -0
- package/src/components/agent-page.tsx +446 -20
- package/src/components/agents.tsx +27 -28
- package/src/components/people.tsx +7 -3
- package/src/components/picker.tsx +79 -5
- package/src/console.tsx +1 -1
- package/src/feed-words.ts +14 -1
- package/src/i18n/en.ts +64 -11
- package/src/i18n/ko.ts +55 -9
- package/src/limits.ts +26 -0
- package/src/onboarding.ts +60 -21
- package/src/plugin/args.ts +29 -3
- package/src/plugin/context.ts +40 -7
- package/src/plugin/define.ts +18 -3
- package/src/plugin/rest-schemas.ts +3 -0
- package/src/routes.ts +2 -0
- package/src/rules.ts +5 -2
- package/src/runner/acp.ts +9 -3
- package/src/runner/claude.ts +58 -1
- package/src/runner/codex.ts +18 -3
- package/src/runner/config.ts +114 -1
- package/src/runner/desk.ts +15 -4
- package/src/runner/message.ts +88 -126
- package/src/runner/runner.ts +682 -27
- package/src/runner/slack-status.ts +423 -0
- package/src/runner/slack.ts +310 -67
- package/src/runner/types.ts +124 -13
- package/src/runner/usage.ts +16 -3
- package/src/runner.ts +4 -0
- package/src/schemas.ts +245 -13
- package/src/secret-file.ts +76 -0
- package/src/services.ts +3 -2
- package/src/setup-guide.ts +6 -5
- package/src/styles/README.md +1 -1
- package/src/styles/pages/agents.css +40 -0
- package/src/vocabulary.ts +21 -2
- package/src/wake-text.ts +133 -0
- package/dist/cli/command-words.d.ts +0 -20
- package/dist/cli/command-words.d.ts.map +0 -1
- package/dist/cli/command-words.js +0 -51
- package/dist/cli/command-words.js.map +0 -1
- package/src/cli/command-words.ts +0 -56
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { MAX_AGENT_SECRET_BYTES } from "./limits.js";
|
|
2
|
+
|
|
3
|
+
// A file as the value of an agent account's secret (ADR-0087, ADR-0184): the command takes one
|
|
4
|
+
// with --file, and the pages take one a person chose, a `.env` of several lines among them. What
|
|
5
|
+
// a file comes to as a value is said here once, for both: its text whole, but for the one
|
|
6
|
+
// newline a file ends with. The pages read a file a person chose as bytes, so they also say
|
|
7
|
+
// here what is no value at all: what is no text, what is empty, what is longer than a value
|
|
8
|
+
// may be. A file's text is a secret from the moment it is read: nothing here says any of it back.
|
|
9
|
+
|
|
10
|
+
/** Why a file a person chose is not taken as a secret's value. */
|
|
11
|
+
export type SecretFileRefusal = "too_large" | "not_text" | "empty";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The most a file may be for its text to be read at all, in bytes: twice a value's bound, for a
|
|
15
|
+
* text written two bytes a character, and the mark of its encoding with the newline it ends on.
|
|
16
|
+
* A larger file is refused by its size, unread.
|
|
17
|
+
*/
|
|
18
|
+
export const MAX_SECRET_FILE_BYTES = 2 * MAX_AGENT_SECRET_BYTES + 4;
|
|
19
|
+
|
|
20
|
+
/** A file's text as a secret's value: whole, but for the one newline a file ends with. */
|
|
21
|
+
export function secretOfText(text: string): string {
|
|
22
|
+
return text.replace(/\r?\n$/, "");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Whether a character is one a text does not hold: a control other than a tab and the ends of a line. */
|
|
26
|
+
const isControl = (code: number): boolean =>
|
|
27
|
+
(code < 0x20 && code !== 0x09 && code !== 0x0a && code !== 0x0d) || code === 0x7f;
|
|
28
|
+
|
|
29
|
+
/** The text the bytes are, by the mark they begin with: UTF-8 unless they say otherwise. Nothing where they are no text. */
|
|
30
|
+
function textOf(bytes: Uint8Array): string | undefined {
|
|
31
|
+
const [first, second] = bytes;
|
|
32
|
+
const encoding =
|
|
33
|
+
first === 0xff && second === 0xfe
|
|
34
|
+
? "utf-16le"
|
|
35
|
+
: first === 0xfe && second === 0xff
|
|
36
|
+
? "utf-16be"
|
|
37
|
+
: "utf-8";
|
|
38
|
+
let text: string;
|
|
39
|
+
try {
|
|
40
|
+
// The decoder takes the mark off, and refuses bytes that are no text in the encoding.
|
|
41
|
+
text = new TextDecoder(encoding, { fatal: true }).decode(bytes);
|
|
42
|
+
} catch {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
for (let at = 0; at < text.length; at += 1) {
|
|
46
|
+
if (isControl(text.charCodeAt(at))) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return text;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The value a chosen file's bytes are, or why they are none: a file larger than is read at all,
|
|
55
|
+
* bytes that are no text, a file with nothing in it, and a text longer than a value may be, in
|
|
56
|
+
* the bytes the console counts it in (UTF-8).
|
|
57
|
+
*/
|
|
58
|
+
export function secretOfFile(
|
|
59
|
+
bytes: Uint8Array,
|
|
60
|
+
): { readonly value: string } | { readonly refused: SecretFileRefusal } {
|
|
61
|
+
if (bytes.byteLength > MAX_SECRET_FILE_BYTES) {
|
|
62
|
+
return { refused: "too_large" };
|
|
63
|
+
}
|
|
64
|
+
const text = textOf(bytes);
|
|
65
|
+
if (text === undefined) {
|
|
66
|
+
return { refused: "not_text" };
|
|
67
|
+
}
|
|
68
|
+
const value = secretOfText(text);
|
|
69
|
+
if (value.length === 0) {
|
|
70
|
+
return { refused: "empty" };
|
|
71
|
+
}
|
|
72
|
+
if (new TextEncoder().encode(value).byteLength > MAX_AGENT_SECRET_BYTES) {
|
|
73
|
+
return { refused: "too_large" };
|
|
74
|
+
}
|
|
75
|
+
return { value };
|
|
76
|
+
}
|
package/src/services.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { agentHref } from "./router.js";
|
|
1
2
|
import type { RestWorkspace, RestWorkspaceService } from "./schemas.js";
|
|
2
3
|
import type { ProviderKey, ServiceRole } from "./vocabulary.js";
|
|
3
4
|
|
|
@@ -168,7 +169,7 @@ const gitlab: ServiceProvider = {
|
|
|
168
169
|
service.form === "service"
|
|
169
170
|
? [
|
|
170
171
|
`An owner of ${service.group === undefined ? "the group" : `the group \`${service.group}\``} at ${gitlabHost(service)} makes a service account for the agent, ${called(account, "under its name")}: the form of account the host has for a machine, which signs in at no page and takes no seat.`,
|
|
171
|
-
`They give it the role its work needs in the group and no more, make it a token that reads and writes repositories and nothing else, and
|
|
172
|
+
`They give it the role its work needs in the group and no more, make it a token that reads and writes repositories and nothing else, and put the token in where only the agent reads it, on the agent's page of the console under Settings (${agentHref(names.agent, "settings")}): as the secret git.token, with the day it ends.`,
|
|
172
173
|
]
|
|
173
174
|
: [
|
|
174
175
|
`The account ${called(account, "of the agent")} at ${gitlabHost(service)}, made if it is not there yet, with the agent's own mailbox where it has one.`,
|
|
@@ -210,7 +211,7 @@ const gitlab: ServiceProvider = {
|
|
|
210
211
|
? [
|
|
211
212
|
{
|
|
212
213
|
title: `Make a service account for ${names.agent} at GitLab`,
|
|
213
|
-
body: `In the settings of ${service.group === undefined ? "the group" : `the group \`${service.group}\``}, under Service accounts, add one${account === undefined ? "" : ` named \`${account}\``}, give it the role its work needs in the group and no more, and make it a token that reads and writes repositories.
|
|
214
|
+
body: `In the settings of ${service.group === undefined ? "the group" : `the group \`${service.group}\``}, under Service accounts, add one${account === undefined ? "" : ` named \`${account}\``}, give it the role its work needs in the group and no more, and make it a token that reads and writes repositories. Put the token in where only the agent reads it, on the agent's page of the console under Settings (${agentHref(names.agent, "settings")}): as the secret git.token, with the day it ends.`,
|
|
214
215
|
},
|
|
215
216
|
]
|
|
216
217
|
: [
|
package/src/setup-guide.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { en } from "./i18n/en.js";
|
|
2
|
+
import { agentHref } from "./router.js";
|
|
2
3
|
import type { RestAgentSetup, RestWorkspace } from "./schemas.js";
|
|
3
4
|
import {
|
|
4
5
|
agentAddressOf,
|
|
@@ -205,7 +206,7 @@ export function setupGuideOf(setup: RestAgentSetup, code: string): SetupGuide {
|
|
|
205
206
|
},
|
|
206
207
|
{
|
|
207
208
|
title: "The sign-in",
|
|
208
|
-
body: `Then the command opens an address in the machine's browser, prints it with a code, and waits. Say to the person at the machine: "Sign in there through ${provider} as \`${account.login}\`, check that the page shows this code, and say that it is you." They sign in themselves, and no password is written in a chat: a secret the agent is to hold, they
|
|
209
|
+
body: `Then the command opens an address in the machine's browser, prints it with a code, and waits. Say to the person at the machine: "Sign in there through ${provider} as \`${account.login}\`, check that the page shows this code, and say that it is you." They sign in themselves, and no password is written in a chat: a secret the agent is to hold, they put in on the agent's page of the console, ${setup.console.url}${agentHref(account.handle, "settings")}. Nobody else's sign-in answers for the account; where the page shows another member, they sign out there first.`,
|
|
209
210
|
},
|
|
210
211
|
{
|
|
211
212
|
title: "What the command does then",
|
|
@@ -213,7 +214,7 @@ export function setupGuideOf(setup: RestAgentSetup, code: string): SetupGuide {
|
|
|
213
214
|
},
|
|
214
215
|
{
|
|
215
216
|
title: "Then stop",
|
|
216
|
-
body: `That is the machine prepared. What comes after is the agent's own, done in its own session from
|
|
217
|
+
body: `That is the machine prepared. What comes after is the agent's own, done in its own session from the console's first message to it: its sign-ins at the services, its tokens, its desk's repository, its profile, its messenger. Do none of it for it. What you change on this machine afterwards, say to it: \`console agent wake me "<what changed>"\`.`,
|
|
217
218
|
},
|
|
218
219
|
];
|
|
219
220
|
|
|
@@ -262,7 +263,7 @@ export function setupGuideOf(setup: RestAgentSetup, code: string): SetupGuide {
|
|
|
262
263
|
who: "agent" as const,
|
|
263
264
|
title: "When the agent starts",
|
|
264
265
|
about:
|
|
265
|
-
"What the agent does itself, in its own session, as
|
|
266
|
+
"What the agent does itself, in its own session, as the console's first message to it says. What it signs in with it keeps in its store (console secret), never in a file or a message.",
|
|
266
267
|
steps: start,
|
|
267
268
|
},
|
|
268
269
|
]),
|
|
@@ -308,8 +309,8 @@ const WHO: Readonly<Record<SetupRole, string>> = {
|
|
|
308
309
|
/**
|
|
309
310
|
* The guide as the command prints it (ADR-0140): Markdown, every line to run on a line of its
|
|
310
311
|
* own, and of its sections only those of whoever prepares the machine, since the command is run
|
|
311
|
-
* by them. What the agent does when it starts and what it asks for are the
|
|
312
|
-
* read by the agent in its own session: a session at the machine that read them took them for
|
|
312
|
+
* by them. What the agent does when it starts and what it asks for are the console's first
|
|
313
|
+
* message to the agent (ADR-0181), read by the agent in its own session: a session at the machine that read them took them for
|
|
313
314
|
* its own work. `moment` says the invitation's day as the command says a moment; left out, as
|
|
314
315
|
* the API gives it.
|
|
315
316
|
*/
|
package/src/styles/README.md
CHANGED
|
@@ -52,7 +52,7 @@ A part is a file under `parts/` and a row here, with the classes that are its ow
|
|
|
52
52
|
| `form` | `sc-form*`, `sc-field*`, `sc-check*`, `sc-member-form` | | A form: a field under its label with a hint (`sc-field`, `-label`, `-hint`), fields side by side (`sc-field-row`), parts under headings (`sc-form-part`), its buttons (`sc-form-actions`), what went wrong (`sc-form-error`), a tick with its words (`sc-check`), a small form on one line (`sc-member-form`). |
|
|
53
53
|
| `files` | `sc-file*`, `sc-chosen*` | | Files to choose, and the ones chosen with the way to take each out. |
|
|
54
54
|
| `toggle` | `sc-toggle*` | | One choice among a few, each a chip, the chosen one filled. |
|
|
55
|
-
| `picker` | `sc-picker*`, `sc-person-option*` | `Picker` | One thing chosen out of a listing that is searched: a person, a project, a goal, a task. `sc-picker-quiet` where it is a fact changed in place, `sc-picker-add` at the end of a row of chips. |
|
|
55
|
+
| `picker` | `sc-picker*`, `sc-person-option*` | `Picker` | One thing chosen out of a listing that is searched: a person, a project, a goal, a task. `sc-picker-quiet` where it is a fact changed in place, `sc-picker-add` at the end of a row of chips. The press on what is chosen clears it; where something is always chosen (`required`, an agent account's manager), it opens the field over it and saves nothing, and what stood stands again unless another is chosen. |
|
|
56
56
|
| `menu` | `sc-menu*` | `NotificationsMenu` | What opens from a button over the page: the person's menu, a card's. `sc-menu-popover` is a panel opened in the top layer, over whatever around its button would clip or cover it, as a front page tile's sizes are. `sc-menu-summary-glyph` is a menu opened from a glyph alone, the bell; `sc-menu-panel-list` a menu that is a list of what happened, the notifications: a head that stays (`sc-menu-head`, `-title`, `-head-link`), rows that each lead somewhere (`sc-menu-rows` of `sc-menu-row`: a picture, two lines of what happened at most, a line of why and where that gives way to when; `sc-menu-row-new` for one that is new), what stands in their place (`sc-menu-note`) and a foot for more (`sc-menu-foot`). |
|
|
57
57
|
| `tabs` | `sc-tab*`, `sc-tabs*`, `sc-subtabs*` | | The pages of a project (`sc-tabs`), and the views of one page (`sc-subtabs` of `sc-tab`s), the current one marked. |
|
|
58
58
|
| `pager` | `sc-pager*`, `sc-show*` | `Pager`, `ShowMore` | A long list a page at a time: turned by pages, or grown by "show more". |
|
|
@@ -1232,6 +1232,46 @@
|
|
|
1232
1232
|
width: 100%;
|
|
1233
1233
|
}
|
|
1234
1234
|
|
|
1235
|
+
/* A view that is not the asker's to open, and under it what is theirs to do there. */
|
|
1236
|
+
.sc-agent-closed {
|
|
1237
|
+
display: grid;
|
|
1238
|
+
gap: var(--sc-space-5);
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
/* Under a secret's fields: the way to choose a file as the value, and the day it ends on. */
|
|
1242
|
+
.sc-agent-secret-more {
|
|
1243
|
+
display: flex;
|
|
1244
|
+
flex-wrap: wrap;
|
|
1245
|
+
align-items: center;
|
|
1246
|
+
gap: var(--sc-space-2) var(--sc-space-4);
|
|
1247
|
+
grid-column: 1 / -1;
|
|
1248
|
+
min-width: 0;
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
/* A file chosen as the value gives way to its cell: a long name is cut, never the form widened. */
|
|
1252
|
+
.sc-agent-secret-form > .sc-chosen-files {
|
|
1253
|
+
min-width: 0;
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
.sc-agent-secret-file {
|
|
1257
|
+
max-width: 100%;
|
|
1258
|
+
min-width: 0;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
.sc-agent-secret-file-name {
|
|
1262
|
+
flex: 0 1 auto;
|
|
1263
|
+
min-width: 0;
|
|
1264
|
+
overflow: hidden;
|
|
1265
|
+
text-overflow: ellipsis;
|
|
1266
|
+
white-space: nowrap;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
/* Its size stays on one line beside it: the name is what gives way. */
|
|
1270
|
+
.sc-agent-secret-file > .sc-muted {
|
|
1271
|
+
flex: none;
|
|
1272
|
+
white-space: nowrap;
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1235
1275
|
@media (max-width: 40rem) {
|
|
1236
1276
|
.sc-agent-secret-form {
|
|
1237
1277
|
grid-template-columns: minmax(0, 1fr) auto;
|
package/src/vocabulary.ts
CHANGED
|
@@ -87,8 +87,8 @@ export type PersonRole = (typeof PERSON_ROLES)[number];
|
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
89
|
* What a member is (ADR-0084): a person, as every member has been, or an agent account, an
|
|
90
|
-
* agent that is a member of its own. The rules make no difference between them
|
|
91
|
-
* agent account is
|
|
90
|
+
* agent that is a member of its own. The rules make no difference between them in what a
|
|
91
|
+
* member may do: an agent account is an administrator where it is made one (ADR-0180).
|
|
92
92
|
*/
|
|
93
93
|
export const PERSON_KINDS = ["person", "agent"] as const;
|
|
94
94
|
|
|
@@ -231,6 +231,25 @@ export const SECRET_ACCESSES = ["set", "read", "removed"] as const;
|
|
|
231
231
|
|
|
232
232
|
export type SecretAccess = (typeof SECRET_ACCESSES)[number];
|
|
233
233
|
|
|
234
|
+
/**
|
|
235
|
+
* How a secret offered to an agent account stands (ADR-0169): it waits for the account; the
|
|
236
|
+
* account took it into its store; the account left it; or its days ran out. Only one that waits
|
|
237
|
+
* holds a value.
|
|
238
|
+
*/
|
|
239
|
+
export const SECRET_OFFER_STATES = ["waiting", "taken", "left", "lapsed"] as const;
|
|
240
|
+
|
|
241
|
+
export type SecretOfferState = (typeof SECRET_OFFER_STATES)[number];
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* How a note on the pack stands (ADR-0178): `open`, it waits for whoever keeps the pack; `done`,
|
|
245
|
+
* what it asked for is in the pack, was there already, or is before a person as a proposal;
|
|
246
|
+
* `dropped`, nothing follows from it, or its author took it back. A note that is closed says what
|
|
247
|
+
* became of it.
|
|
248
|
+
*/
|
|
249
|
+
export const PACK_NOTE_STATES = ["open", "done", "dropped"] as const;
|
|
250
|
+
|
|
251
|
+
export type PackNoteState = (typeof PACK_NOTE_STATES)[number];
|
|
252
|
+
|
|
234
253
|
/**
|
|
235
254
|
* How an agent account stands, in one word (ADR-0085): `running`, its runner heard from and the
|
|
236
255
|
* agent at work or ready for it; `stopped`, by a supervisor, until one starts it again; `refused`,
|
package/src/wake-text.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { MAX_SIGNAL_LENGTH } from "./limits.js";
|
|
2
|
+
|
|
3
|
+
// A wake as the one text a signal carries (ADR-0163, ADR-0166): the lines of whoever raised it,
|
|
4
|
+
// a wake source or the console itself, apart from what someone else wrote, so that no word of a
|
|
5
|
+
// message or of a comment ever reads as a line of the console's. Written here once, for the
|
|
6
|
+
// runner, which writes what its wake sources raise and reads every such text back, and for the
|
|
7
|
+
// console, which writes a wake of the board's that carries a member's words. Pure: no I/O.
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A part of a wake (ADR-0163): a line of the source's own, or what someone else wrote. The
|
|
11
|
+
* runner hands the agent each line under the session's mark and the words in a block of their
|
|
12
|
+
* own, so that nothing a message holds reads as a line of the source's. A line holds what the
|
|
13
|
+
* source says itself, an id and a moment among it, and never a word someone else wrote.
|
|
14
|
+
*/
|
|
15
|
+
export type WakePart = { readonly says: string } | { readonly words: string };
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The first version whose runner reads a wake of the board's, and one of the console's own
|
|
19
|
+
* (ADR-0169), in parts (ADR-0166): the console's
|
|
20
|
+
* lines under the session's mark, and what a member wrote, a comment say, in a block. A runner
|
|
21
|
+
* of before prints such a text whole under its header, as the console's own words, so the
|
|
22
|
+
* console writes one in parts only for an account whose runner last said this version or a
|
|
23
|
+
* later one.
|
|
24
|
+
*/
|
|
25
|
+
export const BOARD_PARTS_FROM = "0.6.3";
|
|
26
|
+
|
|
27
|
+
/** A word of a header on one line, with nothing in it that ends the header early. */
|
|
28
|
+
export const inHeader = (text: string): string => text.replaceAll(/[[\]\r\n]+/g, " ").trim();
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* What a line of a wake's text begins with, as the console keeps the text (ADR-0163): a line of
|
|
32
|
+
* the wake source's own, and a line of someone else's words. Every line of someone's words is
|
|
33
|
+
* begun so where the text is written, so that no word of theirs is ever a line of the source's.
|
|
34
|
+
*/
|
|
35
|
+
const SAYS = "#";
|
|
36
|
+
const WORDS = ">";
|
|
37
|
+
/** What a wake's text ends on where its parts came to more than a signal carries. */
|
|
38
|
+
const WAKE_CUT = "The wake came to more than a signal carries, and was cut here";
|
|
39
|
+
|
|
40
|
+
/** The first `most` characters of a text, never half of a character that takes two. */
|
|
41
|
+
function firstOf(text: string, most: number): string {
|
|
42
|
+
const last = text.charCodeAt(most - 1);
|
|
43
|
+
return text.slice(0, last >= 0xd800 && last <= 0xdbff ? most - 1 : most);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* What someone wrote, a line each behind `>`. A line break of any spelling ends a line, so that
|
|
48
|
+
* none is left in one to end it for a reader.
|
|
49
|
+
*/
|
|
50
|
+
export function quotedLines(words: string): string[] {
|
|
51
|
+
return words.split(/\r\n?|\n/).map((line) => (line === "" ? WORDS : `${WORDS} ${line}`));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The parts of a wake as the one text a signal carries: a line of the source's own behind `#`,
|
|
56
|
+
* and each line of someone else's words behind `>`, in the order given. The runner writes it so
|
|
57
|
+
* for every wake a source raises, whatever the source handed it, and reads it back so when the
|
|
58
|
+
* signal returns (`wakePartsOf`). Two runs of words with no line between them are parted by a
|
|
59
|
+
* line that says nothing. Within `most` characters, the most a signal carries: what comes to
|
|
60
|
+
* more is cut at the end of a line, or within a line of words, and the text's last line says so.
|
|
61
|
+
*/
|
|
62
|
+
export function wakeTextOf(parts: readonly WakePart[], most = MAX_SIGNAL_LENGTH): string {
|
|
63
|
+
const lines: string[] = [];
|
|
64
|
+
let afterWords = false;
|
|
65
|
+
for (const part of parts) {
|
|
66
|
+
if ("says" in part) {
|
|
67
|
+
const says = inHeader(part.says);
|
|
68
|
+
if (says !== "") {
|
|
69
|
+
lines.push(`${SAYS} ${says}`);
|
|
70
|
+
afterWords = false;
|
|
71
|
+
}
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (part.words === "") {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (afterWords) {
|
|
78
|
+
lines.push(SAYS);
|
|
79
|
+
}
|
|
80
|
+
lines.push(...quotedLines(part.words));
|
|
81
|
+
afterWords = true;
|
|
82
|
+
}
|
|
83
|
+
const whole = lines.join("\n");
|
|
84
|
+
if (whole.length <= most) {
|
|
85
|
+
return whole;
|
|
86
|
+
}
|
|
87
|
+
const cut = `${SAYS} ${WAKE_CUT}`;
|
|
88
|
+
const kept: string[] = [];
|
|
89
|
+
let room = most - cut.length;
|
|
90
|
+
for (const line of lines) {
|
|
91
|
+
if (line.length + 1 > room) {
|
|
92
|
+
// A line of words is carried as far as it goes; one of the source's own, whole or not at all.
|
|
93
|
+
if (line.startsWith(`${WORDS} `) && room > WORDS.length + 2) {
|
|
94
|
+
kept.push(firstOf(line, room - 1));
|
|
95
|
+
}
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
kept.push(line);
|
|
99
|
+
room -= line.length + 1;
|
|
100
|
+
}
|
|
101
|
+
return [...kept, cut].join("\n");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The parts of a wake read back from its text, or nothing where the text is not written as
|
|
106
|
+
* `wakeTextOf` writes one: a wake raised by a runner of before, which is then carried whole as
|
|
107
|
+
* someone else's words, as it was.
|
|
108
|
+
*/
|
|
109
|
+
export function wakePartsOf(text: string): readonly WakePart[] | undefined {
|
|
110
|
+
const parts: WakePart[] = [];
|
|
111
|
+
let words: string[] | undefined;
|
|
112
|
+
const close = (): void => {
|
|
113
|
+
if (words !== undefined) {
|
|
114
|
+
parts.push({ words: words.join("\n") });
|
|
115
|
+
words = undefined;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
for (const line of text.split("\n")) {
|
|
119
|
+
if (line === WORDS || line.startsWith(`${WORDS} `)) {
|
|
120
|
+
words ??= [];
|
|
121
|
+
words.push(line.slice(WORDS.length + 1));
|
|
122
|
+
} else if (line === SAYS || line.startsWith(`${SAYS} `)) {
|
|
123
|
+
close();
|
|
124
|
+
if (line.length > SAYS.length + 1) {
|
|
125
|
+
parts.push({ says: line.slice(SAYS.length + 1) });
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
close();
|
|
132
|
+
return parts;
|
|
133
|
+
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A word of a line printed for a person or an agent to run, spelled so that bash and PowerShell
|
|
3
|
-
* both take it whole as it is, expanding nothing in it: as it is where it is plain, else in
|
|
4
|
-
* single quotes, inside which neither reads anything. A single quote has no spelling inside
|
|
5
|
-
* those that both take (bash ends the word there; PowerShell doubles it, which bash reads as two
|
|
6
|
-
* words joined into one), so a word that holds one is in double quotes, inside which neither
|
|
7
|
-
* reads anything of a word without `$`, a backtick, a double quote, a backslash or `!`. Nothing
|
|
8
|
-
* for a word that holds a single quote and one of those, which no one spelling keeps whole in
|
|
9
|
-
* both, nor for one with a character that does not show or makes it look like another.
|
|
10
|
-
*/
|
|
11
|
-
export declare function commandWord(word: string): string | undefined;
|
|
12
|
-
/**
|
|
13
|
-
* Words as one line printed for a person or an agent to run, after `command`, the command's own
|
|
14
|
-
* words, each spelled as `commandWord` spells it; nothing where one of them has no spelling that
|
|
15
|
-
* bash and PowerShell both take whole.
|
|
16
|
-
*/
|
|
17
|
-
export declare function commandLine(command: string, words: readonly string[]): string | undefined;
|
|
18
|
-
/** Why a line is not printed for a person or an agent to run, said in its place. */
|
|
19
|
-
export declare const NO_LINE_TO_RUN = "No line is printed to run: a word of it holds a single quote with a $, a backtick, a double quote, a backslash or a !, or a character that does not show, and no one spelling keeps such a word whole in both bash and PowerShell.";
|
|
20
|
-
//# sourceMappingURL=command-words.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"command-words.d.ts","sourceRoot":"","sources":["../../src/cli/command-words.ts"],"names":[],"mappings":"AAaA;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAW5D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAUzF;AAED,oFAAoF;AACpF,eAAO,MAAM,cAAc,uOAC2M,CAAC"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { hasForbiddenCodePoint } from "../text.js";
|
|
2
|
-
// The lines the commands print for a person or an agent to run, a path of a pack or a folder
|
|
3
|
-
// among their words: spelled so that bash and PowerShell both run them as they are, since an
|
|
4
|
-
// agent runs what it is told in whichever of the two it has.
|
|
5
|
-
/** A word bash and PowerShell both take as it is: no character either reads as more than a letter, and no `@` first, which PowerShell reads as a variable spread. */
|
|
6
|
-
const PLAIN_WORD = /^[\w./+:=-][\w./@+:=-]*$/;
|
|
7
|
-
/** A single quote, as PowerShell reads one: its curly forms close a quoted word too. */
|
|
8
|
-
const SINGLE_QUOTE = /['\u2018-\u201b]/;
|
|
9
|
-
/** What either shell reads inside double quotes: `$`, a backtick, a double quote of any form, a backslash, `!`. */
|
|
10
|
-
const READ_IN_DOUBLE_QUOTES = /[$`"\u201c-\u201e\\!]/;
|
|
11
|
-
/**
|
|
12
|
-
* A word of a line printed for a person or an agent to run, spelled so that bash and PowerShell
|
|
13
|
-
* both take it whole as it is, expanding nothing in it: as it is where it is plain, else in
|
|
14
|
-
* single quotes, inside which neither reads anything. A single quote has no spelling inside
|
|
15
|
-
* those that both take (bash ends the word there; PowerShell doubles it, which bash reads as two
|
|
16
|
-
* words joined into one), so a word that holds one is in double quotes, inside which neither
|
|
17
|
-
* reads anything of a word without `$`, a backtick, a double quote, a backslash or `!`. Nothing
|
|
18
|
-
* for a word that holds a single quote and one of those, which no one spelling keeps whole in
|
|
19
|
-
* both, nor for one with a character that does not show or makes it look like another.
|
|
20
|
-
*/
|
|
21
|
-
export function commandWord(word) {
|
|
22
|
-
if (word.length === 0 || hasForbiddenCodePoint(word)) {
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
25
|
-
if (PLAIN_WORD.test(word)) {
|
|
26
|
-
return word;
|
|
27
|
-
}
|
|
28
|
-
if (!SINGLE_QUOTE.test(word)) {
|
|
29
|
-
return `'${word}'`;
|
|
30
|
-
}
|
|
31
|
-
return READ_IN_DOUBLE_QUOTES.test(word) ? undefined : `"${word}"`;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Words as one line printed for a person or an agent to run, after `command`, the command's own
|
|
35
|
-
* words, each spelled as `commandWord` spells it; nothing where one of them has no spelling that
|
|
36
|
-
* bash and PowerShell both take whole.
|
|
37
|
-
*/
|
|
38
|
-
export function commandLine(command, words) {
|
|
39
|
-
const spelled = [];
|
|
40
|
-
for (const word of words) {
|
|
41
|
-
const one = commandWord(word);
|
|
42
|
-
if (one === undefined) {
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
spelled.push(one);
|
|
46
|
-
}
|
|
47
|
-
return [command, ...spelled].join(" ");
|
|
48
|
-
}
|
|
49
|
-
/** Why a line is not printed for a person or an agent to run, said in its place. */
|
|
50
|
-
export const NO_LINE_TO_RUN = "No line is printed to run: a word of it holds a single quote with a $, a backtick, a double quote, a backslash or a !, or a character that does not show, and no one spelling keeps such a word whole in both bash and PowerShell.";
|
|
51
|
-
//# sourceMappingURL=command-words.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"command-words.js","sourceRoot":"","sources":["../../src/cli/command-words.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,6FAA6F;AAC7F,6FAA6F;AAC7F,6DAA6D;AAE7D,qKAAqK;AACrK,MAAM,UAAU,GAAG,0BAA0B,CAAC;AAC9C,wFAAwF;AACxF,MAAM,YAAY,GAAG,kBAAkB,CAAC;AACxC,mHAAmH;AACnH,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAEtD;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC;QACrD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAI,IAAI,GAAG,CAAC;IACrB,CAAC;IACD,OAAO,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC;AACpE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,KAAwB;IACnE,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC;AAED,oFAAoF;AACpF,MAAM,CAAC,MAAM,cAAc,GACzB,oOAAoO,CAAC"}
|
package/src/cli/command-words.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { hasForbiddenCodePoint } from "../text.js";
|
|
2
|
-
|
|
3
|
-
// The lines the commands print for a person or an agent to run, a path of a pack or a folder
|
|
4
|
-
// among their words: spelled so that bash and PowerShell both run them as they are, since an
|
|
5
|
-
// agent runs what it is told in whichever of the two it has.
|
|
6
|
-
|
|
7
|
-
/** A word bash and PowerShell both take as it is: no character either reads as more than a letter, and no `@` first, which PowerShell reads as a variable spread. */
|
|
8
|
-
const PLAIN_WORD = /^[\w./+:=-][\w./@+:=-]*$/;
|
|
9
|
-
/** A single quote, as PowerShell reads one: its curly forms close a quoted word too. */
|
|
10
|
-
const SINGLE_QUOTE = /['\u2018-\u201b]/;
|
|
11
|
-
/** What either shell reads inside double quotes: `$`, a backtick, a double quote of any form, a backslash, `!`. */
|
|
12
|
-
const READ_IN_DOUBLE_QUOTES = /[$`"\u201c-\u201e\\!]/;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* A word of a line printed for a person or an agent to run, spelled so that bash and PowerShell
|
|
16
|
-
* both take it whole as it is, expanding nothing in it: as it is where it is plain, else in
|
|
17
|
-
* single quotes, inside which neither reads anything. A single quote has no spelling inside
|
|
18
|
-
* those that both take (bash ends the word there; PowerShell doubles it, which bash reads as two
|
|
19
|
-
* words joined into one), so a word that holds one is in double quotes, inside which neither
|
|
20
|
-
* reads anything of a word without `$`, a backtick, a double quote, a backslash or `!`. Nothing
|
|
21
|
-
* for a word that holds a single quote and one of those, which no one spelling keeps whole in
|
|
22
|
-
* both, nor for one with a character that does not show or makes it look like another.
|
|
23
|
-
*/
|
|
24
|
-
export function commandWord(word: string): string | undefined {
|
|
25
|
-
if (word.length === 0 || hasForbiddenCodePoint(word)) {
|
|
26
|
-
return undefined;
|
|
27
|
-
}
|
|
28
|
-
if (PLAIN_WORD.test(word)) {
|
|
29
|
-
return word;
|
|
30
|
-
}
|
|
31
|
-
if (!SINGLE_QUOTE.test(word)) {
|
|
32
|
-
return `'${word}'`;
|
|
33
|
-
}
|
|
34
|
-
return READ_IN_DOUBLE_QUOTES.test(word) ? undefined : `"${word}"`;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Words as one line printed for a person or an agent to run, after `command`, the command's own
|
|
39
|
-
* words, each spelled as `commandWord` spells it; nothing where one of them has no spelling that
|
|
40
|
-
* bash and PowerShell both take whole.
|
|
41
|
-
*/
|
|
42
|
-
export function commandLine(command: string, words: readonly string[]): string | undefined {
|
|
43
|
-
const spelled: string[] = [];
|
|
44
|
-
for (const word of words) {
|
|
45
|
-
const one = commandWord(word);
|
|
46
|
-
if (one === undefined) {
|
|
47
|
-
return undefined;
|
|
48
|
-
}
|
|
49
|
-
spelled.push(one);
|
|
50
|
-
}
|
|
51
|
-
return [command, ...spelled].join(" ");
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** Why a line is not printed for a person or an agent to run, said in its place. */
|
|
55
|
-
export const NO_LINE_TO_RUN =
|
|
56
|
-
"No line is printed to run: a word of it holds a single quote with a $, a backtick, a double quote, a backslash or a !, or a character that does not show, and no one spelling keeps such a word whole in both bash and PowerShell.";
|