@skillcdn/console 0.4.6 → 0.4.7

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.
Files changed (131) hide show
  1. package/README.md +4 -4
  2. package/dist/api.d.ts +2 -2
  3. package/dist/api.d.ts.map +1 -1
  4. package/dist/api.js +2 -2
  5. package/dist/api.js.map +1 -1
  6. package/dist/cli/cli.d.ts +6 -0
  7. package/dist/cli/cli.d.ts.map +1 -1
  8. package/dist/cli/cli.js +60 -30
  9. package/dist/cli/cli.js.map +1 -1
  10. package/dist/cli/format.d.ts.map +1 -1
  11. package/dist/cli/format.js +1 -0
  12. package/dist/cli/format.js.map +1 -1
  13. package/dist/cli/help.js +5 -5
  14. package/dist/cli/help.js.map +1 -1
  15. package/dist/cli/keys.d.ts +10 -0
  16. package/dist/cli/keys.d.ts.map +1 -0
  17. package/dist/cli/keys.js +59 -0
  18. package/dist/cli/keys.js.map +1 -0
  19. package/dist/cli/main.js +2 -1
  20. package/dist/cli/main.js.map +1 -1
  21. package/dist/cli/terminal.d.ts +7 -0
  22. package/dist/cli/terminal.d.ts.map +1 -1
  23. package/dist/cli/terminal.js +39 -0
  24. package/dist/cli/terminal.js.map +1 -1
  25. package/dist/client.d.ts +7 -1
  26. package/dist/client.d.ts.map +1 -1
  27. package/dist/client.js +4 -1
  28. package/dist/client.js.map +1 -1
  29. package/dist/components/plugin-frame.d.ts.map +1 -1
  30. package/dist/components/plugin-frame.js +53 -10
  31. package/dist/components/plugin-frame.js.map +1 -1
  32. package/dist/components/sessions.d.ts +15 -0
  33. package/dist/components/sessions.d.ts.map +1 -0
  34. package/dist/components/sessions.js +17 -0
  35. package/dist/components/sessions.js.map +1 -0
  36. package/dist/components/shell.d.ts.map +1 -1
  37. package/dist/components/shell.js +198 -28
  38. package/dist/components/shell.js.map +1 -1
  39. package/dist/components/workspace.d.ts +2 -0
  40. package/dist/components/workspace.d.ts.map +1 -1
  41. package/dist/components/workspace.js +19 -4
  42. package/dist/components/workspace.js.map +1 -1
  43. package/dist/console.css +228 -21
  44. package/dist/console.d.ts +5 -2
  45. package/dist/console.d.ts.map +1 -1
  46. package/dist/console.js +106 -21
  47. package/dist/console.js.map +1 -1
  48. package/dist/data.d.ts +7 -1
  49. package/dist/data.d.ts.map +1 -1
  50. package/dist/data.js +26 -5
  51. package/dist/data.js.map +1 -1
  52. package/dist/i18n/en.d.ts +24 -0
  53. package/dist/i18n/en.d.ts.map +1 -1
  54. package/dist/i18n/en.js +21 -0
  55. package/dist/i18n/en.js.map +1 -1
  56. package/dist/i18n/index.d.ts +2 -2
  57. package/dist/i18n/index.d.ts.map +1 -1
  58. package/dist/i18n/index.js +7 -3
  59. package/dist/i18n/index.js.map +1 -1
  60. package/dist/i18n/ko.d.ts.map +1 -1
  61. package/dist/i18n/ko.js +23 -2
  62. package/dist/i18n/ko.js.map +1 -1
  63. package/dist/index.d.ts +1 -0
  64. package/dist/index.d.ts.map +1 -1
  65. package/dist/index.js +1 -0
  66. package/dist/index.js.map +1 -1
  67. package/dist/plugin/bridge.d.ts +3 -0
  68. package/dist/plugin/bridge.d.ts.map +1 -1
  69. package/dist/plugin/bridge.js +1 -0
  70. package/dist/plugin/bridge.js.map +1 -1
  71. package/dist/plugin/context.d.ts +9 -0
  72. package/dist/plugin/context.d.ts.map +1 -1
  73. package/dist/plugin/define.d.ts.map +1 -1
  74. package/dist/plugin/define.js +6 -3
  75. package/dist/plugin/define.js.map +1 -1
  76. package/dist/plugin/sandbox.d.ts.map +1 -1
  77. package/dist/plugin/sandbox.js +8 -1
  78. package/dist/plugin/sandbox.js.map +1 -1
  79. package/dist/router.d.ts +6 -0
  80. package/dist/router.d.ts.map +1 -1
  81. package/dist/router.js +5 -0
  82. package/dist/router.js.map +1 -1
  83. package/dist/routes.d.ts +3 -1
  84. package/dist/routes.d.ts.map +1 -1
  85. package/dist/routes.js +2 -0
  86. package/dist/routes.js.map +1 -1
  87. package/dist/schemas.d.ts +38 -0
  88. package/dist/schemas.d.ts.map +1 -1
  89. package/dist/schemas.js +37 -1
  90. package/dist/schemas.js.map +1 -1
  91. package/dist/tokens.d.ts.map +1 -1
  92. package/dist/tokens.js +1 -0
  93. package/dist/tokens.js.map +1 -1
  94. package/dist/vocabulary.d.ts +6 -0
  95. package/dist/vocabulary.d.ts.map +1 -1
  96. package/dist/vocabulary.js +7 -0
  97. package/dist/vocabulary.js.map +1 -1
  98. package/docs/specs/cli.md +3 -3
  99. package/docs/specs/plugins.md +7 -6
  100. package/docs/specs/rest.md +9 -5
  101. package/package.json +1 -1
  102. package/skills/building-a-plugin/SKILL.md +2 -2
  103. package/skills/planning-the-board/references/setting-up.md +1 -1
  104. package/src/api.ts +6 -0
  105. package/src/cli/cli.ts +81 -29
  106. package/src/cli/format.ts +1 -0
  107. package/src/cli/help.ts +5 -5
  108. package/src/cli/keys.ts +69 -0
  109. package/src/cli/main.ts +2 -1
  110. package/src/cli/terminal.ts +40 -0
  111. package/src/client.ts +14 -0
  112. package/src/components/plugin-frame.tsx +72 -17
  113. package/src/components/sessions.tsx +108 -0
  114. package/src/components/shell.tsx +265 -52
  115. package/src/components/workspace.tsx +46 -2
  116. package/src/console.tsx +181 -16
  117. package/src/data.ts +33 -5
  118. package/src/i18n/en.ts +25 -0
  119. package/src/i18n/index.ts +11 -3
  120. package/src/i18n/ko.ts +27 -2
  121. package/src/index.ts +1 -0
  122. package/src/plugin/bridge.ts +4 -0
  123. package/src/plugin/context.ts +9 -0
  124. package/src/plugin/define.ts +10 -2
  125. package/src/plugin/sandbox.ts +9 -1
  126. package/src/router.ts +7 -0
  127. package/src/routes.ts +3 -1
  128. package/src/schemas.ts +41 -0
  129. package/src/styles/console.css +228 -21
  130. package/src/tokens.ts +1 -0
  131. package/src/vocabulary.ts +9 -0
@@ -71,7 +71,7 @@ Produces the **design**: one table, a row per thing the feature does, saying who
71
71
  |---|---|
72
72
  | An agent does it for a person, and something changes | A **command**: `defineCommand({ about, args, roles, run })`. Its `text` answer is for people, its `data` for agents (`--json`); it does one thing and does it again safely where it can. |
73
73
  | An agent, or a page, looks something up | A **query**: `defineQuery(...)`, which writes nothing; a query may answer a file. |
74
- | A person must approve, choose or confirm | A **decision** the command raises with `ctx.console.decisions.ask`, with options, addressed to the person a setting or the record names (`deciderId`), or to several of them (`deciderIds`, any of whom may answer), anyone active of the workspace, in the board project or not: they find it among their decisions and answer it there, and whoever manages them up the reporting line may answer it too ([ADR-0068](/docs/adr/0068-a-decision-reaches-whom-it-is-addressed-to-wherever-it-is-and-a-plugins-reaches-the-managers-above-them.md)); raised in the board project for whoever called the command, in the project or not, who reads it back as its raiser and nothing else of the project, so that a requester needs no place in the project ([ADR-0080](/docs/adr/0080-a-plugin-reaches-the-projects-it-is-placed-on-and-whoever-may-use-it-is-a-requester-in-its-board-project.md)); a page sends a person to it with `frame.navigate("/decisions/<id>")`, which opens for them though the project does not; `about` the record it is for, its question, body and labels written once, in the language of whoever is to answer: `ctx.console.people.get(id)` says it as `language`, and where that is `null`, a person who has not opened the console yet, the plugin writes in the first of `ctx.console.workspace().languages` ([ADR-0065](/docs/adr/0065-a-plugin-writes-one-text-and-a-persons-language-is-kept-from-the-first-time-the-pages-see-them.md)); the command answers `waiting`, the agent waits as the console's own `ask` is waited for, and the plugin hears the answer in a hook on `console:decision.answered` and goes on. The plugin never answers one, and never computes what a person must choose. |
74
+ | A person must approve, choose or confirm | A **decision** the command raises with `ctx.console.decisions.ask`, with options, addressed to the person a setting or the record names (`deciderId`), or to several of them (`deciderIds`, any of whom may answer), anyone active of the workspace, in the board project or not: they find it among their decisions and answer it there, and whoever manages them up the reporting line may answer it too ([ADR-0068](/docs/adr/0068-a-decision-reaches-whom-it-is-addressed-to-wherever-it-is-and-a-plugins-reaches-the-managers-above-them.md)); raised in the board project for whoever called the command, in the project or not, who reads it back as its raiser and nothing else of the project, so that a requester needs no place in the project ([ADR-0080](/docs/adr/0080-a-plugin-reaches-the-projects-it-is-placed-on-and-whoever-may-use-it-is-a-requester-in-its-board-project.md)); a page sends a person to it with `frame.navigate("/decisions/<id>")`, which opens for them though the project does not; `about` the record it is for, its question, body and labels written once, in the language of whoever is to answer: `ctx.console.people.get(id)` says it as `language`, and where that is `null`, a person who has not opened the console yet, the plugin writes in `ctx.console.workspace().language`, the workspace's language, `en` where an administrator set none as `languageSet` says ([ADR-0065](/docs/adr/0065-a-plugin-writes-one-text-and-a-persons-language-is-kept-from-the-first-time-the-pages-see-them.md), [ADR-0081](/docs/adr/0081-a-workspace-has-a-language-for-whoever-has-none-of-their-own.md)); the command answers `waiting`, the agent waits as the console's own `ask` is waited for, and the plugin hears the answer in a hook on `console:decision.answered` and goes on. The plugin never answers one, and never computes what a person must choose. |
75
75
  | Someone must do something later | A **task** on the board project with `ctx.console.tasks.create`, marked as the plugin's, worked by whoever takes it; its title and body, and a comment on it, one text each, written as a decision's words are, in the language of whoever it is for. |
76
76
  | The console must tell the plugin something happened | A **hook**, `on["console:<kind>"]` (`events:console`): the plugin's board project, the projects it is on and the items it made are what it hears of. Delivery is at least once: a handler reads the record first and does nothing twice, and the event's `id` (one across both streams) with its `attempt` is what it keeps to tell a delivery repeated; a service that says to come back later is told to the console as `retryAfterMs` on the refusal, and the next try waits that long. A collection that grows with every event, deliveries, log lines, gets `retention: { days }` and `history: false`, so that it never reaches the quota. |
77
77
  | Another plugin must tell it | A **hook** on `plugin:<key>:<kind>` (`events:plugins`), or a call on the other's `api` (`plugins:<key>`). |
@@ -90,7 +90,7 @@ Then the capabilities: the list the split needs, each read as the sentence the a
90
90
 
91
91
  Produces the **plugin as source**. `console-plugin init <dir> --key <key> --name "<Name>"` writes the smallest complete plugin: the manifest, a server module with one collection, one command and one query, a web bundle with one page and one widget, one skill with its `SKILLCDN.md`, the tests, the build and a README that says where things are; `--console` names the version of `@skillcdn/console` it depends on, the command's own unless said, and for a plugin written for a deployed console, the version that console runs (`console whoami` says it), and the manifest's `console` is written from it, the line of that version (`>=0.4.3 <0.5.0`): the consoles the plugin runs on, which the console checks when it reads the plugin and `console-plugin check` holds the dependency to; narrow it to the patch that brought what the plugin depends on, and widen it to the next line once the plugin is built against it; `--package <name>` the package's name where it is not `console-plugin-<key>`, a scoped one (`@<scope>/console-plugin-<key>`) for a repository of several plugins, published as public; `--repository <url>` with `--directory <path>` where the plugin lives in a repository, which fill `repository`, `homepage` and `bugs` and the manifest's `store`; and `--languages en,ko` the languages of its words, `en` first, which gives every language map and both manifests' translations the others as English words to translate, of which `console-plugin check` warns while they stay English. Then, in `<dir>`: `npm install`, `npm run build`, `npm test`, `npm run check`, all green before a line is changed, and `git init`.
92
92
 
93
- Then the design goes in, file by file: the manifest `console-plugin.json` from the design, its `key`, names and descriptions per language, `agentNote`, `capabilities`, `roles` (a role for managers is `follows: "reports"`, held by whoever someone reports to and granted by nobody) and `defaultRole`, `board`, `settings`, `menu`, `pages`, `widgets`, `dataVersion`; the server module `src/server/index.ts`, one `defineCollection` per collection, one `defineCommand` or `defineQuery` per row, `endpoints`, `on`, `jobs`, `api`, `onEnable` and `onDisable` where the design has them, exported by name for the tests and gathered in `definePlugin(...)` as the default export; the web bundle `src/web/index.ts` and `index.css`, where `connect()` gives the page the context (who looks, at what, in which language), `command`, `query`, `records`, `files`, `navigate` (a path of the console's), `open` (a link to the web or to mail, from the press itself, which the console's page opens in a new tab), `download`, `setTitle` and the events, every class prefixed `pl-<key>-`, the console's `sc-` classes and `--sc-*` tokens for the look, and every word a person wrote put in as text; the skills under `skills/<name>/SKILL.md`, one per kind of work, in the SkillCDN Format, and the README of the package. The server module imports only what the host allows and bundles everything it imports; it keeps no state between calls but in records, since its thread is started afresh after a fault. Where the design has `storage:sql`, `migrations/0001-<words>.sql` makes the tables, and `manifest.migrations` names the directory.
93
+ Then the design goes in, file by file: the manifest `console-plugin.json` from the design, its `key`, names and descriptions per language (a name of a word or two, which a tab shows and stops short with an ellipsis past about 28 characters; the description is what the plugin's settings page says of it, and what an agent reads in the rules where there is no `agentNote`), `agentNote`, `capabilities`, `roles` (a role for managers is `follows: "reports"`, held by whoever someone reports to and granted by nobody) and `defaultRole`, `board`, `settings`, `menu`, `pages`, `widgets`, `dataVersion`; the server module `src/server/index.ts`, one `defineCollection` per collection, one `defineCommand` or `defineQuery` per row, `endpoints`, `on`, `jobs`, `api`, `onEnable` and `onDisable` where the design has them, exported by name for the tests and gathered in `definePlugin(...)` as the default export; the web bundle `src/web/index.ts` and `index.css`, where `connect()` gives the page the context (who looks, at what, in which language), `command`, `query`, `records`, `files`, `navigate` (a path of the console's), `open` (a link to the web or to mail, from the press itself, which the console's page opens in a new tab), `download`, `setTitle` and the events, every class prefixed `pl-<key>-`, the console's `sc-` classes and `--sc-*` tokens for the look, and every word a person wrote put in as text; the skills under `skills/<name>/SKILL.md`, one per kind of work, in the SkillCDN Format, and the README of the package. The server module imports only what the host allows and bundles everything it imports; it keeps no state between calls but in records, since its thread is started afresh after a fault. Where the design has `storage:sql`, `migrations/0001-<words>.sql` makes the tables, and `manifest.migrations` names the directory.
94
94
 
95
95
  ### Phase 3: Test it as the console runs it
96
96
 
@@ -10,7 +10,7 @@ What an administrator or an owner does on the pages, their agent does here with
10
10
 
11
11
  ## A plugin's board project, for an administrator
12
12
 
13
- A plugin the deployment installed ([building-a-plugin](/skills/building-a-plugin/SKILL.md) writes one; the deployment installs it) does nothing until an administrator enables it, consenting to what it requires and turning on what they choose of what it can go without (`console plugin <key> capabilities` says which, and turns them on or off later), and one that puts decisions, tasks and pages on a board names its project then: `console plugin <key> enable --consent <capability>,... --board new|<key> [--projects all|<key>,...] [--set <setting>=<value>]...`, `new` making a private project from the plugin's own defaults (its key, name and description, which `console plugin <key>` shows beforehand, with what each capability opens), `<key>` binding a project that exists; several plugins may share one. `--consent` must name every capability the manifest asks, each read as the sentence it is: what the plugin may do and reach. The project's members are listed as any project's; the plugin's own roles are granted apart, `console plugin <key> grant <role> --person <login>|--project <key>|--everyone`, and taken back with `console plugin <key> revoke <grant>`; `console plugin <key> settings --set <setting>=<value>` fills its settings, and a secret is read from standard input by `console plugin <key> secret <name>`, never an argument. From then on the rules an agent reads in that project end with `## Plugins`, naming it ([working-the-board](/skills/working-the-board/SKILL.md)), and what the plugin writes there carries its name beside the person's. `console plugin <key> disable` stops it and keeps its data. An owner who is not an administrator enables no plugin: the step goes back to the administrator, with the command.
13
+ A plugin the deployment installed ([building-a-plugin](/skills/building-a-plugin/SKILL.md) writes one; the deployment installs it) does nothing until an administrator enables it, consenting to what it requires and turning on what they choose of what it can go without (`console plugin <key> capabilities` says which, and turns them on or off later), and one that puts decisions, tasks and pages on a board names its project then: `console plugin <key> enable --consent <capability>,... --board new|<key> [--projects all|<key>,...] [--set <setting>=<value>]...`, `new` making a private project from the plugin's own defaults (its key, name and description, which `console plugin <key>` shows beforehand, with what each capability opens), `<key>` binding a project that exists; several plugins may share one. `--consent` must name every capability the manifest asks, each read as the sentence it is: what the plugin may do and reach. The project's members are listed as any project's; the plugin's own roles are granted apart, `console plugin <key> grant <role> --person <login>|--project <key>|--everyone`, and taken back with `console plugin <key> revoke <grant>`; `console plugin <key> settings --set <setting>=<value>` fills its settings, and a secret is set by a person: typed unseen at the prompt of `console plugin <key> secret <name>` in their own terminal, or on the plugin's settings page; never an argument, which a shell keeps, and never through an agent, whose transcript would keep it (a script redirects a file into the command). From then on the rules an agent reads in that project end with `## Plugins`, naming it ([working-the-board](/skills/working-the-board/SKILL.md)), and what the plugin writes there carries its name beside the person's. `console plugin <key> disable` stops it and keeps its data. An owner who is not an administrator enables no plugin: the step goes back to the administrator, with the command.
14
14
 
15
15
  ## The members, for an owner
16
16
 
package/src/api.ts CHANGED
@@ -239,6 +239,8 @@ export {
239
239
  type RestRunEndInput,
240
240
  type RestRunInput,
241
241
  type RestRuns,
242
+ type RestSession,
243
+ type RestSessions,
242
244
  type RestSkill,
243
245
  type RestSkillBrowse,
244
246
  type RestSkillFile,
@@ -345,6 +347,8 @@ export {
345
347
  restRunInputSchema,
346
348
  restRunSchema,
347
349
  restRunsSchema,
350
+ restSessionSchema,
351
+ restSessionsSchema,
348
352
  restSkillBrowseSchema,
349
353
  restSkillFileSchema,
350
354
  restSkillFindSchema,
@@ -383,6 +387,7 @@ export {
383
387
  COLOR_NAMES,
384
388
  CONSOLE_LANGUAGES,
385
389
  type ColorName,
390
+ type ConsoleLanguage,
386
391
  EVENT_KINDS,
387
392
  type EventKind,
388
393
  GOAL_STATES,
@@ -390,6 +395,7 @@ export {
390
395
  isProviderKey,
391
396
  LINK_SOURCES,
392
397
  type LinkSource,
398
+ languagesFirst,
393
399
  MEMBERSHIP_SOURCES,
394
400
  type MembershipSource,
395
401
  OPEN_GOAL_STATES,
package/src/cli/cli.ts CHANGED
@@ -51,6 +51,7 @@ import {
51
51
  } from "../schemas.js";
52
52
  import {
53
53
  COLOR_NAMES,
54
+ CONSOLE_LANGUAGES,
54
55
  type ColorName,
55
56
  GOAL_STATES,
56
57
  type GoalState,
@@ -185,6 +186,12 @@ export interface CliIo {
185
186
  readonly fetch: FetchLike;
186
187
  /** All of standard input, for a body given as `-`, or a token given to login. */
187
188
  readonly readStdin: () => Promise<string>;
189
+ /**
190
+ * A secret the command asks for: typed unseen at the terminal after the prompt, or all of
191
+ * standard input where that is a pipe or a file. Left out, standard input as `readStdin` reads
192
+ * it, which the tests hand the command.
193
+ */
194
+ readonly readSecret?: ((prompt: string) => Promise<string>) | undefined;
188
195
  /** The name of the machine, for the agent to say where it runs; nothing when unknown. */
189
196
  readonly hostname?: string | undefined;
190
197
  /** A file named with `--file`, as text. */
@@ -230,6 +237,15 @@ class CliExit extends Error {
230
237
  const failed = (message: string): CliExit => new CliExit(EXIT.failed, message);
231
238
  const misuse = (message: string): CliExit => new CliExit(EXIT.usage, message);
232
239
 
240
+ /**
241
+ * A secret given to the command, never as an argument, which a shell keeps in its history and a
242
+ * process list shows: typed unseen at the terminal after `prompt`, or piped in; one line.
243
+ */
244
+ async function secretGiven(io: CliIo, prompt: string): Promise<string> {
245
+ const given = io.readSecret === undefined ? await io.readStdin() : await io.readSecret(prompt);
246
+ return given.replace(/\r?\n$/, "");
247
+ }
248
+
233
249
  type OptionSpec = Readonly<
234
250
  Record<string, { readonly type: "string" | "boolean"; readonly multiple?: boolean }>
235
251
  >;
@@ -753,7 +769,7 @@ const login: Command = async (args, io) => {
753
769
  const url = originOf(wanted);
754
770
  const asDefault = on(values, "default");
755
771
  if (on(values, "token-stdin")) {
756
- const token = (await io.readStdin()).trim();
772
+ const token = (await secretGiven(io, "Token (typed unseen; Enter ends it): ")).trim();
757
773
  if (token.length === 0) {
758
774
  throw failed("No token was given.");
759
775
  }
@@ -1034,13 +1050,24 @@ const use: Command = async (args, io) => {
1034
1050
  return EXIT.ok;
1035
1051
  };
1036
1052
 
1053
+ /**
1054
+ * The language a person reads the plugins' words and the rules in: their own, else the
1055
+ * workspace's (ADR-0081), else none, which the formats take for English.
1056
+ */
1057
+ function readingLanguage(me: {
1058
+ readonly language: string | null;
1059
+ readonly workspace: { readonly language?: string | null | undefined };
1060
+ }): string | null {
1061
+ return me.language ?? me.workspace.language ?? null;
1062
+ }
1063
+
1037
1064
  /**
1038
1065
  * The last day of this week (ADR-0039): the week begins as the workspace says, or, left to the
1039
1066
  * language, as the person's language has it, else this machine's.
1040
1067
  */
1041
1068
  async function endOfWeek(io: CliIo, session: Session, today: string): Promise<string> {
1042
1069
  const me = await session.client.me();
1043
- const language = me.language ?? io.locale ?? "en";
1070
+ const language = me.language ?? io.locale ?? me.workspace.language ?? "en";
1044
1071
  return weekOf(today, firstDayOfWeek(language, me.workspace.weekStart ?? "auto")).at(-1) ?? today;
1045
1072
  }
1046
1073
 
@@ -1409,7 +1436,7 @@ const plugins: Command = async (args, io) => {
1409
1436
  const { values } = parse(args, {}, false);
1410
1437
  const session = await open(io, values);
1411
1438
  const [listed, me] = await Promise.all([session.client.plugins(), session.client.me()]);
1412
- answer(io, session, listed, () => formatPlugins(listed, me.language));
1439
+ answer(io, session, listed, () => formatPlugins(listed, readingLanguage(me)));
1413
1440
  return EXIT.ok;
1414
1441
  };
1415
1442
 
@@ -1487,7 +1514,7 @@ const plugin: Command = async (args, io) => {
1487
1514
  switch (verb) {
1488
1515
  case undefined: {
1489
1516
  const [detail, me] = await Promise.all([client.get(), session.client.me()]);
1490
- answer(io, session, detail, () => formatPlugin(detail, me.language));
1517
+ answer(io, session, detail, () => formatPlugin(detail, readingLanguage(me)));
1491
1518
  return EXIT.ok;
1492
1519
  }
1493
1520
  case "help": {
@@ -1776,7 +1803,7 @@ function settingValuesOf(
1776
1803
  }
1777
1804
  if (setting.type === "secret") {
1778
1805
  throw misuse(
1779
- `${key} is a secret: console plugin ${detail.key} secret ${key} reads it from standard input.`,
1806
+ `${key} is a secret: console plugin ${detail.key} secret ${key} asks for it, typed unseen.`,
1780
1807
  );
1781
1808
  }
1782
1809
  if (word.length === 0) {
@@ -1906,8 +1933,8 @@ async function pluginEnable(
1906
1933
  board = {
1907
1934
  create: {
1908
1935
  key: detail.boardDefaults.key,
1909
- name: localized(detail.boardDefaults.name, me.language),
1910
- description: localized(detail.boardDefaults.description, me.language),
1936
+ name: localized(detail.boardDefaults.name, readingLanguage(me)),
1937
+ description: localized(detail.boardDefaults.description, readingLanguage(me)),
1911
1938
  },
1912
1939
  };
1913
1940
  } else if (boardFlag !== undefined) {
@@ -1936,9 +1963,11 @@ async function pluginEnable(
1936
1963
  ? []
1937
1964
  : [
1938
1965
  "Settings:",
1939
- ...enabled.settings.map((setting) => formatPluginSettingLine(setting, me.language)),
1966
+ ...enabled.settings.map((setting) =>
1967
+ formatPluginSettingLine(setting, readingLanguage(me)),
1968
+ ),
1940
1969
  ]),
1941
- ...formatPluginAsks(enabled, me.language),
1970
+ ...formatPluginAsks(enabled, readingLanguage(me)),
1942
1971
  ].join("\n"),
1943
1972
  );
1944
1973
  return EXIT.ok;
@@ -1965,7 +1994,9 @@ async function pluginSettings(
1965
1994
  ? `${detail.key} has no settings.`
1966
1995
  : [
1967
1996
  `Settings of ${detail.key}:`,
1968
- ...detail.settings.map((setting) => formatPluginSettingLine(setting, me.language)),
1997
+ ...detail.settings.map((setting) =>
1998
+ formatPluginSettingLine(setting, readingLanguage(me)),
1999
+ ),
1969
2000
  ].join("\n"),
1970
2001
  );
1971
2002
  return EXIT.ok;
@@ -1974,13 +2005,16 @@ async function pluginSettings(
1974
2005
  answer(io, session, changed.settings, () =>
1975
2006
  [
1976
2007
  `Changed the settings of ${changed.key}:`,
1977
- ...changed.settings.map((setting) => formatPluginSettingLine(setting, me.language)),
2008
+ ...changed.settings.map((setting) => formatPluginSettingLine(setting, readingLanguage(me))),
1978
2009
  ].join("\n"),
1979
2010
  );
1980
2011
  return EXIT.ok;
1981
2012
  }
1982
2013
 
1983
- /** Seals a secret of the plugin, read from standard input and shown never; or takes it away. */
2014
+ /**
2015
+ * Seals a secret of the plugin, typed unseen at the terminal or piped in, never an argument, and
2016
+ * shown never; or takes it away.
2017
+ */
1984
2018
  async function pluginSecret(
1985
2019
  io: CliIo,
1986
2020
  session: Session,
@@ -1990,17 +2024,20 @@ async function pluginSecret(
1990
2024
  const { values, positionals } = parse(rest, { remove: { type: "boolean" } });
1991
2025
  const name = theOne(
1992
2026
  positionals,
1993
- `Say which secret: console plugin ${client.key} secret <name> [--remove]; the value is read from standard input.`,
2027
+ `Say which secret: console plugin ${client.key} secret <name> [--remove]; the value is typed at the prompt, unseen, or piped in.`,
1994
2028
  );
1995
2029
  if (on(values, "remove")) {
1996
2030
  await client.removeSecret(name);
1997
2031
  answer(io, session, { name, set: false }, () => `Removed the secret ${name} of ${client.key}.`);
1998
2032
  return EXIT.ok;
1999
2033
  }
2000
- const value = (await io.readStdin()).replace(/\r?\n$/, "");
2034
+ const value = await secretGiven(
2035
+ io,
2036
+ `Secret ${name} of ${client.key} (typed unseen; Enter ends it): `,
2037
+ );
2001
2038
  if (value.length === 0) {
2002
2039
  throw misuse(
2003
- `Pipe the value in: console plugin ${client.key} secret ${name} < file. It is sealed by the console and shown never.`,
2040
+ `Type the value at the prompt, or redirect a file into it: console plugin ${client.key} secret ${name} < file. Never give it on the command line or through echo, which a shell keeps; the console seals it and shows it never.`,
2004
2041
  );
2005
2042
  }
2006
2043
  await client.setSecret(name, value);
@@ -2157,12 +2194,12 @@ const rules: Command = async (args, io) => {
2157
2194
  const read =
2158
2195
  "workspace" in found
2159
2196
  ? {
2160
- workspace: forPerson(found.workspace, me.language),
2161
- project: forPerson(found.project, me.language),
2197
+ workspace: forPerson(found.workspace, readingLanguage(me)),
2198
+ project: forPerson(found.project, readingLanguage(me)),
2162
2199
  ...(found.plugins === undefined ? {} : { plugins: found.plugins }),
2163
2200
  }
2164
- : forPerson(found, me.language);
2165
- answer(io, session, read, () => formatRules(read, me.language));
2201
+ : forPerson(found, readingLanguage(me));
2202
+ answer(io, session, read, () => formatRules(read, readingLanguage(me)));
2166
2203
  return EXIT.ok;
2167
2204
  };
2168
2205
 
@@ -2508,8 +2545,8 @@ const take: Command = async (args, io) => {
2508
2545
  ? ""
2509
2546
  : `\nOther runs of yours are open in this project (${others.map((item) => `#${item.taskNumber}`).join(", ")}): say which run on report, hand-in, ask, finish and fail, --run ${run.id} for this one.`;
2510
2547
  const rules = {
2511
- workspace: forPerson(ruling.workspace, me.language),
2512
- project: forPerson(ruling.project, me.language),
2548
+ workspace: forPerson(ruling.workspace, readingLanguage(me)),
2549
+ project: forPerson(ruling.project, readingLanguage(me)),
2513
2550
  ...(ruling.plugins === undefined ? {} : { plugins: ruling.plugins }),
2514
2551
  };
2515
2552
  answer(io, session, { run, task: taken, comments: comments.items, rules }, () =>
@@ -2521,7 +2558,7 @@ const take: Command = async (args, io) => {
2521
2558
  "",
2522
2559
  formatTask(taken, undefined, undefined, comments.items),
2523
2560
  "",
2524
- formatRules(rules, me.language),
2561
+ formatRules(rules, readingLanguage(me)),
2525
2562
  "",
2526
2563
  'Say how it goes: console report "<what you found or did>". Hand in what you make: console hand-in <https url | file path>.',
2527
2564
  'Ask when a person must decide: console ask "<question>" --option "..." --option "...". A word for the task\'s people that is not a report: console comment <number> "<markdown>". End with: console finish --summary "<what was done, what is left>".',
@@ -3410,7 +3447,7 @@ const team: Command = async (args, io) => {
3410
3447
  // The workspace's settings (ADR-0035): read by everyone, changed by an administrator, themselves
3411
3448
  // on the Settings page or through their agent here (ADR-0021).
3412
3449
  const WORKSPACE_FLAGS =
3413
- "--people-visibility <everyone|shared-projects>, --week-start <auto|monday|sunday>, --time-zone <zone|none>";
3450
+ "--people-visibility <everyone|shared-projects>, --week-start <auto|monday|sunday>, --time-zone <zone|none>, --language <en|ko|none>";
3414
3451
  const WORKSPACE_USAGE = `Say what to do: console workspace | console workspace edit [${WORKSPACE_FLAGS.replaceAll(", ", "] [")}] | console workspace pack-token --connect|--stdin|--remove`;
3415
3452
 
3416
3453
  const workspace: Command = async (args, io) => {
@@ -3430,13 +3467,20 @@ const workspace: Command = async (args, io) => {
3430
3467
  "people-visibility": { type: "string" },
3431
3468
  "week-start": { type: "string" },
3432
3469
  "time-zone": { type: "string" },
3470
+ language: { type: "string" },
3433
3471
  },
3434
3472
  false,
3435
3473
  );
3436
3474
  const visibility = text(values, "people-visibility");
3437
3475
  const weekStart = text(values, "week-start");
3438
3476
  const zone = text(values, "time-zone");
3439
- if (visibility === undefined && weekStart === undefined && zone === undefined) {
3477
+ const language = text(values, "language");
3478
+ if (
3479
+ visibility === undefined &&
3480
+ weekStart === undefined &&
3481
+ zone === undefined &&
3482
+ language === undefined
3483
+ ) {
3440
3484
  throw misuse(`Say what to change: ${WORKSPACE_FLAGS}`);
3441
3485
  }
3442
3486
  const session = await open(io, values);
@@ -3446,6 +3490,14 @@ const workspace: Command = async (args, io) => {
3446
3490
  ? {}
3447
3491
  : { weekStart: wordOf(weekStart, WEEK_STARTS, "a day the week begins on") }),
3448
3492
  ...(zone === undefined ? {} : { timeZone: zone === "none" ? null : zone }),
3493
+ ...(language === undefined
3494
+ ? {}
3495
+ : {
3496
+ language:
3497
+ language === "none"
3498
+ ? null
3499
+ : wordOf(language, CONSOLE_LANGUAGES, "a language the console speaks, or none"),
3500
+ }),
3449
3501
  });
3450
3502
  await rememberZone(io, session, changed.timeZone ?? undefined);
3451
3503
  answer(io, session, changed, () => formatWorkspace(changed));
@@ -3648,7 +3700,7 @@ const wayOf = (values: Values): "connect" | "stdin" | "remove" => {
3648
3700
  const [way] = ways;
3649
3701
  if (way === undefined || ways.length !== 1) {
3650
3702
  throw misuse(
3651
- "Say one of --connect, which asks SkillCDN for a code a person approves; --stdin, which reads a token made by hand from standard input; and --remove, which takes the token away.",
3703
+ "Say one of --connect, which asks SkillCDN for a code a person approves; --stdin, which takes a token made by hand, typed unseen at the terminal or piped in; and --remove, which takes the token away.",
3652
3704
  );
3653
3705
  }
3654
3706
  return way;
@@ -3670,8 +3722,8 @@ interface TokenHolder<T> {
3670
3722
 
3671
3723
  /**
3672
3724
  * The SkillCDN token (ADR-0028): connected with a code a person approves at SkillCDN (ADR-0036),
3673
- * or read from standard input and never from an argument, so that no shell keeps it; or taken
3674
- * away. The same for a project's and for the workspace's.
3725
+ * or typed unseen at the terminal or piped in, never an argument, so that no shell keeps it; or
3726
+ * taken away. The same for a project's and for the workspace's.
3675
3727
  */
3676
3728
  async function packToken<T>(
3677
3729
  io: CliIo,
@@ -3708,9 +3760,9 @@ async function packToken<T>(
3708
3760
  );
3709
3761
  }
3710
3762
  }
3711
- const token = (await io.readStdin()).trim();
3763
+ const token = (await secretGiven(io, "SkillCDN token (typed unseen; Enter ends it): ")).trim();
3712
3764
  if (token.length === 0) {
3713
- throw failed("No token was given on standard input.");
3765
+ throw failed("No token was given.");
3714
3766
  }
3715
3767
  const changed = await holder.set(token);
3716
3768
  answer(io, session, changed, () => format(changed));
package/src/cli/format.ts CHANGED
@@ -149,6 +149,7 @@ export function formatWorkspace(workspace: RestWorkspace): string {
149
149
  `people visibility: ${visibility} (${visibility === "everyone" ? "everyone sees everyone" : "a member sees only the people they share a project with; an administrator sees everyone"})`,
150
150
  `week begins on: ${workspace.weekStart ?? "auto"} (auto: the system default, as each device has it)`,
151
151
  `time zone: ${zone ?? "none"} (${zone === null ? "moments are printed as the API gives them, in UTC" : "moments are printed in it, as ISO 8601 with its offset"})`,
152
+ `language: ${workspace.language ?? "none"} (${workspace.language == null ? "whoever has not chosen a language reads English, and the plugins write to them in it" : "whoever has not chosen a language reads it, and the plugins write to them in it"})`,
152
153
  `skills: ${workspace.skills.address ?? "no address of the organization's"} at ${workspace.skills.source}`,
153
154
  `SkillCDN token: ${token === null ? "none" : `set ${moment(token.setAt)}`} (${token === null ? "the organization's pack is read with none" : "the organization's pack is read with it by a project with no address and no token of its own"})`,
154
155
  `token days at most: ${workspace.tokenDaysAtMost ?? "a person chooses"}`,
package/src/cli/help.ts CHANGED
@@ -116,7 +116,7 @@ export const COMMAND_HELP: Readonly<Record<string, CommandHelp>> = {
116
116
  synopsis:
117
117
  "Connects this agent to the console with a code a person approves; keeps the token, never shows it.",
118
118
  about:
119
- "Connects this agent to the console: shows an address and a code, which a person opens signed in, names the agent and approves; the command then receives a token of its own and keeps it, with the console's address and the account, in your home directory, never showing it. One login per console and account: a second console adds a login beside the first, the first is the default console a directory that names none works at, and --default makes this one that. A login repeated for the same console and account replaces its token, which is given up at the console. An agent running the command relays the address and the code to its person and waits. --agent says what the agent calls itself; left out, the command names the agent it runs under where its environment says so (Claude Code, Codex), else An agent; the machine's name follows, and the pages show the name before 'on' with the whole on hover. --token-stdin reads a token made by hand from standard input instead, for a script or a job.",
119
+ "Connects this agent to the console: shows an address and a code, which a person opens signed in, names the agent and approves; the command then receives a token of its own and keeps it, with the console's address and the account, in your home directory, never showing it. One login per console and account: a second console adds a login beside the first, the first is the default console a directory that names none works at, and --default makes this one that. A login repeated for the same console and account replaces its token, which is given up at the console. An agent running the command relays the address and the code to its person and waits. --agent says what the agent calls itself; left out, the command names the agent it runs under where its environment says so (Claude Code, Codex), else An agent; the machine's name follows, and the pages show the name before 'on' with the whole on hover. --token-stdin takes a token made by hand instead, typed unseen at the terminal, or from standard input for a script or a job; never an argument, which a shell would keep.",
120
120
  refusals: [
121
121
  "connect.not_found: the code was not approved in time, or the person said it was not theirs; run login again",
122
122
  "the console does not know the token given: make one on the Agents page and try again",
@@ -255,13 +255,13 @@ export const COMMAND_HELP: Readonly<Record<string, CommandHelp>> = {
255
255
  },
256
256
  workspace: {
257
257
  usage:
258
- "workspace | workspace edit [--people-visibility <everyone|shared-projects>] [--week-start <auto|monday|sunday>] [--time-zone <zone|none>] | workspace pack-token --connect | workspace pack-token --stdin | workspace pack-token --remove",
258
+ "workspace | workspace edit [--people-visibility <everyone|shared-projects>] [--week-start <auto|monday|sunday>] [--time-zone <zone|none>] [--language <en|ko|none>] | workspace pack-token --connect | workspace pack-token --stdin | workspace pack-token --remove",
259
259
  overview:
260
260
  "workspace | workspace edit [flags] | workspace pack-token --connect|--stdin|--remove",
261
261
  synopsis:
262
262
  "The workspace's settings; or some changed, or its SkillCDN token set, for an administrator.",
263
263
  about:
264
- "What the workspace is called; who sees whom on the People page and in the pickers (everyone; or shared-projects: a member sees only the people they share a project with, an administrator everyone; a project open to the workspace has everyone in it, so a member of one sees everyone); the day the calendars begin a week on (auto: the system default, as each device has it); the workspace's time zone, an IANA name such as Asia/Seoul, in which this command prints moments as ISO 8601 with its offset, as the login kept it at login or whoami, or none, which leaves them as the API gives them, in UTC; where the organization's skills come from; and the most days a token may last. edit changes any of the first three, for an administrator; --json leaves moments as the API gives them. pack-token is the SkillCDN token the organization's pack is read with, by every project that names no address of its own and holds no token of its own (ADR-0036), for an administrator: with --connect, the console asks SkillCDN for a code, this command prints the page and the code, a person who may open the repository approves there, signed in at SkillCDN, and the console receives the token, shown to nobody; with --stdin, a token made by hand at SkillCDN is read from standard input and never an argument; --remove takes the token away.",
264
+ "What the workspace is called; who sees whom on the People page and in the pickers (everyone; or shared-projects: a member sees only the people they share a project with, an administrator everyone; a project open to the workspace has everyone in it, so a member of one sees everyone); the day the calendars begin a week on (auto: the system default, as each device has it); the workspace's time zone, an IANA name such as Asia/Seoul, in which this command prints moments as ISO 8601 with its offset, as the login kept it at login or whoami, or none, which leaves them as the API gives them, in UTC; the workspace's language (ADR-0081), en or ko, for whoever has not chosen one: what the pages speak to someone whose browser asks for no language the console speaks, and what the plugins write to someone who has never opened the pages, or none, English then; where the organization's skills come from; and the most days a token may last. edit changes any of the first four, for an administrator; --json leaves moments as the API gives them. pack-token is the SkillCDN token the organization's pack is read with, by every project that names no address of its own and holds no token of its own (ADR-0036), for an administrator: with --connect, the console asks SkillCDN for a code, this command prints the page and the code, a person who may open the repository approves there, signed in at SkillCDN, and the console receives the token, shown to nobody; with --stdin, a token made by hand at SkillCDN is typed unseen at the terminal, or read from standard input when piped, and never an argument; --remove takes the token away.",
265
265
  refusals: [
266
266
  "auth.forbidden: only an administrator changes the workspace's settings or its token",
267
267
  "request.invalid: the time zone is not a name the console knows",
@@ -295,7 +295,7 @@ export const COMMAND_HELP: Readonly<Record<string, CommandHelp>> = {
295
295
  synopsis:
296
296
  "One project in full; or a project made, changed, given its mark or its SkillCDN token.",
297
297
  about:
298
- "One project in full; or a project made, with you as its owner, private unless --visibility workspace says everyone of the workspace works in it; or one changed, only in what the flags say, for an owner; or its image for its mark, set from a file of this machine or taken away; or its SkillCDN token (pack-token, ADR-0028), which the console keeps sealed to read a private pack with, and which a project that reads the organization's pack may leave to the workspace's (console workspace pack-token): with --connect, the console asks SkillCDN for a code, this command prints the page and the code, a person who may open the repository approves there, signed in at SkillCDN, and the console receives the token, shown to nobody (ADR-0036); with --stdin, a token a person made by hand at SkillCDN is read from standard input and never an argument; --remove takes the token away. The organization's skills are the project's unless --skills names an address of its own.",
298
+ "One project in full; or a project made, with you as its owner, private unless --visibility workspace says everyone of the workspace works in it; or one changed, only in what the flags say, for an owner; or its image for its mark, set from a file of this machine or taken away; or its SkillCDN token (pack-token, ADR-0028), which the console keeps sealed to read a private pack with, and which a project that reads the organization's pack may leave to the workspace's (console workspace pack-token): with --connect, the console asks SkillCDN for a code, this command prints the page and the code, a person who may open the repository approves there, signed in at SkillCDN, and the console receives the token, shown to nobody (ADR-0036); with --stdin, a token a person made by hand at SkillCDN is typed unseen at the terminal, or read from standard input when piped, and never an argument; --remove takes the token away. The organization's skills are the project's unless --skills names an address of its own.",
299
299
  limits: [
300
300
  `key: ${KEY}, up to ${MAX_PROJECT_KEY_LENGTH} characters; it does not change once made`,
301
301
  `name: one line, up to ${MAX_PROJECT_NAME_LENGTH} characters; description: up to ${MAX_PROJECT_DESCRIPTION_LENGTH}`,
@@ -411,7 +411,7 @@ export const COMMAND_HELP: Readonly<Record<string, CommandHelp>> = {
411
411
  synopsis:
412
412
  "One plugin: what it is for and its commands; a command run as you; its records, its skills; its settings, for an administrator.",
413
413
  about:
414
- "One plugin of this console, by its key. Alone: what it is, the sentence for agents, its state, the roles you hold in it, its board project, then one line per command and query you may run, with its usage, where its skills are, and its settings. help [<command>]: one command or query in full, as console help prints one: its arguments, their types and bounds, and the refusals; every argument is given by its place when positional, else as --<name> <value> or --<name>=<value>; a boolean as --<name> alone; a list as the flag given again, or with commas between; a day as YYYY-MM-DD; a person by login, or me; a project by key; a file by --file <path>, or - for standard input, which the command uploads first, with the plugin's files capability. <command> [<args>]: runs the command or the query as the person whose token you hold; the console parses the words against the definition and refuses the first that does not fit; prints what the command says, or a query's answer as JSON, a file a query answers saved under its name; --json prints the whole answer. A command that raised a decision prints its id and exits with 3: console decision <id> --wait 100 waits for the answer. The event the command leaves names your open run in the plugin's board project, --run <id> saying which when several are open; an argument marked secret is hidden in it. records <collection>: the records you may read, one a line, newest first; --where <field>=<value>, given again for several, narrows by a field the collection indexes (id, owner and project always; a number, true, false and null are read as such); --search <words> by words; --project <key> to those linked to a project; --order <field>, with :desc for the newest first; a page of --limit with --after <cursor> as the last page printed; --archived the ones put away; <id> reads one record whole, --versions its versions. skills and skill: the plugin's own skills, a pack read from its package, exactly as console skills and console skill read a project's pack. enable, disable, settings, secret, grant and revoke are an administrator's. enable prints what each capability the plugin asks opens and what a malicious plugin would reach through it, and refuses unless --consent names every capability again; --board new makes the board project the manifest proposes, --board <key> chooses one, left out where the plugin needs none; --projects all, or the keys of the projects the plugin is on; --set a setting's value, which settings changes afterwards too, an empty value clearing one, a number or true and false read as such. secret <name> reads the value from standard input, seals it and shows it never; --remove takes it away. grant gives a role to a person by login, to the members of a project by key, to another plugin by key, to the members of a team by key, or to everyone, and revoke takes a grant back by its id, which console plugin <key> lists to an administrator.",
414
+ "One plugin of this console, by its key. Alone: what it is, the sentence for agents, its state, the roles you hold in it, its board project, then one line per command and query you may run, with its usage, where its skills are, and its settings. help [<command>]: one command or query in full, as console help prints one: its arguments, their types and bounds, and the refusals; every argument is given by its place when positional, else as --<name> <value> or --<name>=<value>; a boolean as --<name> alone; a list as the flag given again, or with commas between; a day as YYYY-MM-DD; a person by login, or me; a project by key; a file by --file <path>, or - for standard input, which the command uploads first, with the plugin's files capability. <command> [<args>]: runs the command or the query as the person whose token you hold; the console parses the words against the definition and refuses the first that does not fit; prints what the command says, or a query's answer as JSON, a file a query answers saved under its name; --json prints the whole answer. A command that raised a decision prints its id and exits with 3: console decision <id> --wait 100 waits for the answer. The event the command leaves names your open run in the plugin's board project, --run <id> saying which when several are open; an argument marked secret is hidden in it. records <collection>: the records you may read, one a line, newest first; --where <field>=<value>, given again for several, narrows by a field the collection indexes (id, owner and project always; a number, true, false and null are read as such); --search <words> by words; --project <key> to those linked to a project; --order <field>, with :desc for the newest first; a page of --limit with --after <cursor> as the last page printed; --archived the ones put away; <id> reads one record whole, --versions its versions. skills and skill: the plugin's own skills, a pack read from its package, exactly as console skills and console skill read a project's pack. enable, disable, settings, secret, grant and revoke are an administrator's. enable prints what each capability the plugin asks opens and what a malicious plugin would reach through it, and refuses unless --consent names every capability again; --board new makes the board project the manifest proposes, --board <key> chooses one, left out where the plugin needs none; --projects all, or the keys of the projects the plugin is on; --set a setting's value, which settings changes afterwards too, an empty value clearing one, a number or true and false read as such. secret <name> asks for the value at the terminal, typed unseen, or reads it from standard input when piped or redirected from a file, never from an argument, which a shell would keep; the console seals it and shows it never; --remove takes it away. grant gives a role to a person by login, to the members of a project by key, to another plugin by key, to the members of a team by key, or to everyone, and revoke takes a grant back by its id, which console plugin <key> lists to an administrator.",
415
415
  limits: [
416
416
  "a command line: up to 200 words of up to 50,000 characters each; one file, up to the file bound (console help hand-in), with the plugin's files capability",
417
417
  "records: a page of up to 200; where: a field the collection indexes",
@@ -0,0 +1,69 @@
1
+ // What is typed at a hidden prompt, read key by key from a terminal in raw mode: the characters
2
+ // of the secret, Backspace taking one back, Enter or Ctrl-D ending it, Ctrl-C giving it up; and
3
+ // nothing of what a terminal sends for a key that types nothing. Pure, for the tests: the
4
+ // terminal itself is `terminal.ts`'s.
5
+
6
+ /** Where a prompt stands after what the terminal sent: still reading, done, or given up. */
7
+ export type SecretKeysState = "reading" | "done" | "interrupted";
8
+
9
+ export interface SecretKeys {
10
+ /** Takes what the terminal sent; once done or given up, takes nothing more. */
11
+ take(chunk: string): SecretKeysState;
12
+ /** What was typed so far. */
13
+ readonly typed: string;
14
+ }
15
+
16
+ export function secretKeys(): SecretKeys {
17
+ let typed = "";
18
+ let state: SecretKeysState = "reading";
19
+ // What a terminal sends for an arrow, Delete, Home, a function key, or around a paste, begins
20
+ // with an escape: `ESC [` and parameters up to a final byte, `ESC O` and one more, or `ESC`
21
+ // and one more for a key held with Alt. None of it is the secret; a paste between its marks is.
22
+ let control: "none" | "begun" | "sequence" | "one" = "none";
23
+ return {
24
+ get typed() {
25
+ return typed;
26
+ },
27
+ take(chunk) {
28
+ for (const character of chunk) {
29
+ if (state !== "reading") {
30
+ break;
31
+ }
32
+ if (control === "begun") {
33
+ control = character === "[" ? "sequence" : character === "O" ? "one" : "none";
34
+ continue;
35
+ }
36
+ if (control === "one") {
37
+ control = "none";
38
+ continue;
39
+ }
40
+ if (control === "sequence") {
41
+ if (character >= "@" && character <= "~") {
42
+ control = "none";
43
+ }
44
+ continue;
45
+ }
46
+ switch (character) {
47
+ case "\u001b":
48
+ control = "begun";
49
+ break;
50
+ case "\u0003":
51
+ state = "interrupted";
52
+ break;
53
+ case "\r":
54
+ case "\n":
55
+ case "\u0004":
56
+ state = "done";
57
+ break;
58
+ case "\u007f":
59
+ case "\b":
60
+ typed = Array.from(typed).slice(0, -1).join("");
61
+ break;
62
+ default:
63
+ typed += character;
64
+ }
65
+ }
66
+ return state;
67
+ },
68
+ };
69
+ }
package/src/cli/main.ts CHANGED
@@ -12,7 +12,7 @@ import { createDirectoryStore } from "./directory.js";
12
12
  import { detectInstall } from "./install.js";
13
13
  import { createNoticeStore } from "./notices.js";
14
14
  import { listenOn } from "./serve.js";
15
- import { readBytesAt, readFileAt, readStdin, writeBytesAt } from "./terminal.js";
15
+ import { readBytesAt, readFileAt, readSecret, readStdin, writeBytesAt } from "./terminal.js";
16
16
 
17
17
  // The `console` command: the only place the command reads the process. Everything it does is in
18
18
  // cli.ts, which takes what it needs and is what the tests run.
@@ -38,6 +38,7 @@ process.exitCode = await runCli(process.argv.slice(2), {
38
38
  },
39
39
  fetch: (input, init) => fetch(input, init),
40
40
  readStdin,
41
+ readSecret,
41
42
  hostname: hostname(),
42
43
  readFile: readFileAt,
43
44
  readBytes: readBytesAt,
@@ -1,6 +1,7 @@
1
1
  import { readFile, stat, writeFile } from "node:fs/promises";
2
2
  import { join, resolve } from "node:path";
3
3
  import process from "node:process";
4
+ import { secretKeys } from "./keys.js";
4
5
 
5
6
  // The terminal's side of the command: what is read from it. Nothing here is reached by tests,
6
7
  // which hand the command readers of their own.
@@ -18,6 +19,45 @@ export function readStdin(): Promise<string> {
18
19
  });
19
20
  }
20
21
 
22
+ /**
23
+ * A secret typed at the terminal, unseen: the prompt goes to standard error, what is typed is
24
+ * echoed nowhere, Enter ends it, Backspace takes a character back, and Ctrl-C gives the command
25
+ * up as it does elsewhere; what a key that types nothing sends is not taken ({@link secretKeys}). A pipe or a file in place of the terminal is read whole, as
26
+ * {@link readStdin} reads it, so that a script hands the value over as before.
27
+ */
28
+ export function readSecret(prompt: string): Promise<string> {
29
+ const { stdin, stderr } = process;
30
+ if (!stdin.isTTY) {
31
+ return readStdin();
32
+ }
33
+ stderr.write(prompt);
34
+ stdin.setRawMode(true);
35
+ stdin.resume();
36
+ stdin.setEncoding("utf8");
37
+ return new Promise((resolve) => {
38
+ const keys = secretKeys();
39
+ const finish = (interrupted: boolean): void => {
40
+ stdin.off("data", onData);
41
+ stdin.setRawMode(false);
42
+ stdin.pause();
43
+ stderr.write("\n");
44
+ if (interrupted) {
45
+ // Raw mode delivers no signal for Ctrl-C: the command ends as any does on one.
46
+ process.kill(process.pid, "SIGINT");
47
+ return;
48
+ }
49
+ resolve(keys.typed);
50
+ };
51
+ const onData = (chunk: string): void => {
52
+ const state = keys.take(chunk);
53
+ if (state !== "reading") {
54
+ finish(state === "interrupted");
55
+ }
56
+ };
57
+ stdin.on("data", onData);
58
+ });
59
+ }
60
+
21
61
  /** A file named on the command line, as text. */
22
62
  export function readFileAt(path: string): Promise<string> {
23
63
  return readFile(path, "utf8");
package/src/client.ts CHANGED
@@ -83,6 +83,7 @@ import {
83
83
  type RestRunEndInput,
84
84
  type RestRunInput,
85
85
  type RestRuns,
86
+ type RestSessions,
86
87
  type RestSkillBrowse,
87
88
  type RestSkillFile,
88
89
  type RestSkillFind,
@@ -148,6 +149,7 @@ import {
148
149
  restRulesSchema,
149
150
  restRunSchema,
150
151
  restRunsSchema,
152
+ restSessionsSchema,
151
153
  restSkillBrowseSchema,
152
154
  restSkillFileSchema,
153
155
  restSkillFindSchema,
@@ -671,6 +673,12 @@ export interface ConsoleClient {
671
673
  personWork(personId: string, signal?: AbortSignal): Promise<RestPersonWork>;
672
674
  /** The tokens of whoever asks. */
673
675
  tokens(signal?: AbortSignal): Promise<RestTokens>;
676
+ /** The browsers whoever asks is signed in on (board #309): the current first, then the last used first. */
677
+ sessions(signal?: AbortSignal): Promise<RestSessions>;
678
+ /** Ends one of the asker's sessions; the current one ends with the cookie. */
679
+ endSession(id: string): Promise<void>;
680
+ /** Ends every session of the asker but the one the request is made on. */
681
+ endOtherSessions(): Promise<void>;
674
682
  /** The tokens of another person: for an administrator. */
675
683
  personTokens(personId: string, signal?: AbortSignal): Promise<RestTokens>;
676
684
  /** Takes another person's token away: for an administrator. */
@@ -1409,6 +1417,12 @@ export function createClient(options: ClientOptions = {}): ConsoleClient {
1409
1417
  request("GET", `${base}${personWorkPath(personId)}`, undefined, restPersonWorkSchema, signal),
1410
1418
  tokens: (signal) =>
1411
1419
  request("GET", `${base}${REST_ROUTES.tokens}`, undefined, restTokensSchema, signal),
1420
+ sessions: (signal) =>
1421
+ request("GET", `${base}${REST_ROUTES.sessions}`, undefined, restSessionsSchema, signal),
1422
+ endSession: (id) =>
1423
+ request("DELETE", `${base}${restPath("sessions", id)}`, undefined, undefined),
1424
+ endOtherSessions: () =>
1425
+ request("DELETE", `${base}${REST_ROUTES.sessions}/others`, undefined, undefined),
1412
1426
  createToken: (input) =>
1413
1427
  request("POST", `${base}${REST_ROUTES.tokens}`, input, restTokenCreatedSchema),
1414
1428
  revokeToken: (id) =>