@skillcdn/console 0.4.5 → 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 (138) 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 +83 -42
  9. package/dist/cli/cli.js.map +1 -1
  10. package/dist/cli/format.d.ts +8 -1
  11. package/dist/cli/format.d.ts.map +1 -1
  12. package/dist/cli/format.js +11 -2
  13. package/dist/cli/format.js.map +1 -1
  14. package/dist/cli/help.d.ts.map +1 -1
  15. package/dist/cli/help.js +22 -10
  16. package/dist/cli/help.js.map +1 -1
  17. package/dist/cli/keys.d.ts +10 -0
  18. package/dist/cli/keys.d.ts.map +1 -0
  19. package/dist/cli/keys.js +59 -0
  20. package/dist/cli/keys.js.map +1 -0
  21. package/dist/cli/main.js +2 -1
  22. package/dist/cli/main.js.map +1 -1
  23. package/dist/cli/terminal.d.ts +7 -0
  24. package/dist/cli/terminal.d.ts.map +1 -1
  25. package/dist/cli/terminal.js +39 -0
  26. package/dist/cli/terminal.js.map +1 -1
  27. package/dist/client.d.ts +9 -1
  28. package/dist/client.d.ts.map +1 -1
  29. package/dist/client.js +5 -1
  30. package/dist/client.js.map +1 -1
  31. package/dist/components/plugin-frame.d.ts.map +1 -1
  32. package/dist/components/plugin-frame.js +73 -17
  33. package/dist/components/plugin-frame.js.map +1 -1
  34. package/dist/components/sessions.d.ts +15 -0
  35. package/dist/components/sessions.d.ts.map +1 -0
  36. package/dist/components/sessions.js +17 -0
  37. package/dist/components/sessions.js.map +1 -0
  38. package/dist/components/shell.d.ts.map +1 -1
  39. package/dist/components/shell.js +198 -28
  40. package/dist/components/shell.js.map +1 -1
  41. package/dist/components/workspace.d.ts +2 -0
  42. package/dist/components/workspace.d.ts.map +1 -1
  43. package/dist/components/workspace.js +19 -4
  44. package/dist/components/workspace.js.map +1 -1
  45. package/dist/console.css +228 -21
  46. package/dist/console.d.ts +5 -2
  47. package/dist/console.d.ts.map +1 -1
  48. package/dist/console.js +106 -21
  49. package/dist/console.js.map +1 -1
  50. package/dist/data.d.ts +7 -1
  51. package/dist/data.d.ts.map +1 -1
  52. package/dist/data.js +26 -5
  53. package/dist/data.js.map +1 -1
  54. package/dist/i18n/en.d.ts +24 -0
  55. package/dist/i18n/en.d.ts.map +1 -1
  56. package/dist/i18n/en.js +21 -0
  57. package/dist/i18n/en.js.map +1 -1
  58. package/dist/i18n/index.d.ts +2 -2
  59. package/dist/i18n/index.d.ts.map +1 -1
  60. package/dist/i18n/index.js +7 -3
  61. package/dist/i18n/index.js.map +1 -1
  62. package/dist/i18n/ko.d.ts.map +1 -1
  63. package/dist/i18n/ko.js +23 -2
  64. package/dist/i18n/ko.js.map +1 -1
  65. package/dist/index.d.ts +1 -0
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +1 -0
  68. package/dist/index.js.map +1 -1
  69. package/dist/plugin/bridge.d.ts +7 -3
  70. package/dist/plugin/bridge.d.ts.map +1 -1
  71. package/dist/plugin/bridge.js +1 -0
  72. package/dist/plugin/bridge.js.map +1 -1
  73. package/dist/plugin/context.d.ts +16 -1
  74. package/dist/plugin/context.d.ts.map +1 -1
  75. package/dist/plugin/define.d.ts.map +1 -1
  76. package/dist/plugin/define.js +6 -3
  77. package/dist/plugin/define.js.map +1 -1
  78. package/dist/plugin/sandbox.d.ts.map +1 -1
  79. package/dist/plugin/sandbox.js +8 -1
  80. package/dist/plugin/sandbox.js.map +1 -1
  81. package/dist/plugin/web.d.ts +16 -3
  82. package/dist/plugin/web.d.ts.map +1 -1
  83. package/dist/plugin/web.js +8 -1
  84. package/dist/plugin/web.js.map +1 -1
  85. package/dist/router.d.ts +6 -0
  86. package/dist/router.d.ts.map +1 -1
  87. package/dist/router.js +5 -0
  88. package/dist/router.js.map +1 -1
  89. package/dist/routes.d.ts +3 -1
  90. package/dist/routes.d.ts.map +1 -1
  91. package/dist/routes.js +2 -0
  92. package/dist/routes.js.map +1 -1
  93. package/dist/schemas.d.ts +38 -0
  94. package/dist/schemas.d.ts.map +1 -1
  95. package/dist/schemas.js +37 -1
  96. package/dist/schemas.js.map +1 -1
  97. package/dist/tokens.d.ts.map +1 -1
  98. package/dist/tokens.js +1 -0
  99. package/dist/tokens.js.map +1 -1
  100. package/dist/vocabulary.d.ts +6 -0
  101. package/dist/vocabulary.d.ts.map +1 -1
  102. package/dist/vocabulary.js +7 -0
  103. package/dist/vocabulary.js.map +1 -1
  104. package/docs/specs/cli.md +5 -5
  105. package/docs/specs/plugins.md +28 -15
  106. package/docs/specs/rest.md +12 -8
  107. package/package.json +1 -1
  108. package/skills/building-a-plugin/SKILL.md +3 -3
  109. package/skills/planning-the-board/references/setting-up.md +1 -1
  110. package/src/api.ts +6 -0
  111. package/src/cli/cli.ts +115 -43
  112. package/src/cli/format.ts +15 -2
  113. package/src/cli/help.ts +22 -10
  114. package/src/cli/keys.ts +69 -0
  115. package/src/cli/main.ts +2 -1
  116. package/src/cli/terminal.ts +40 -0
  117. package/src/client.ts +18 -0
  118. package/src/components/plugin-frame.tsx +92 -24
  119. package/src/components/sessions.tsx +108 -0
  120. package/src/components/shell.tsx +265 -52
  121. package/src/components/workspace.tsx +46 -2
  122. package/src/console.tsx +181 -16
  123. package/src/data.ts +33 -5
  124. package/src/i18n/en.ts +25 -0
  125. package/src/i18n/index.ts +11 -3
  126. package/src/i18n/ko.ts +27 -2
  127. package/src/index.ts +1 -0
  128. package/src/plugin/bridge.ts +8 -3
  129. package/src/plugin/context.ts +16 -1
  130. package/src/plugin/define.ts +10 -2
  131. package/src/plugin/sandbox.ts +9 -1
  132. package/src/plugin/web.ts +21 -4
  133. package/src/router.ts +7 -0
  134. package/src/routes.ts +3 -1
  135. package/src/schemas.ts +41 -0
  136. package/src/styles/console.css +228 -21
  137. package/src/tokens.ts +1 -0
  138. package/src/vocabulary.ts +9 -0
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
 
@@ -2434,14 +2471,25 @@ async function attachmentsOf(io: CliIo, paths: readonly string[]): Promise<FileU
2434
2471
  /**
2435
2472
  * A file of the project, read from the console and written on this machine: one a run handed
2436
2473
  * in, one put in a comment or on a decision, or one attached to a page, by its id, so that an
2437
- * agent can look at a picture a person put on the board.
2474
+ * agent can look at a picture a person put on the board. With `--decision`, a file of that
2475
+ * decision, read at the decision's own address (ADR-0068): wherever it is, in the project the
2476
+ * command works in or one it does not name.
2438
2477
  */
2439
2478
  const file: Command = async (args, io) => {
2440
- const { values, positionals } = parse(args, { out: { type: "string" } });
2441
- const id = theOne(positionals, "Say which file: console file <id> [--out <path>]");
2479
+ const { values, positionals } = parse(args, {
2480
+ out: { type: "string" },
2481
+ decision: { type: "string" },
2482
+ });
2483
+ const id = theOne(
2484
+ positionals,
2485
+ "Say which file: console file <id> [--decision <id>] [--out <path>]",
2486
+ );
2487
+ const decisionId = text(values, "decision");
2442
2488
  const session = await open(io, values);
2443
- const project = await session.project();
2444
- const read = await project.readFile(id);
2489
+ const read =
2490
+ decisionId === undefined
2491
+ ? await (await session.project()).readFile(id)
2492
+ : await session.client.readDecisionFile(decisionId, id);
2445
2493
  const target = text(values, "out") ?? read.name;
2446
2494
  let saved: string;
2447
2495
  try {
@@ -2497,8 +2545,8 @@ const take: Command = async (args, io) => {
2497
2545
  ? ""
2498
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.`;
2499
2547
  const rules = {
2500
- workspace: forPerson(ruling.workspace, me.language),
2501
- project: forPerson(ruling.project, me.language),
2548
+ workspace: forPerson(ruling.workspace, readingLanguage(me)),
2549
+ project: forPerson(ruling.project, readingLanguage(me)),
2502
2550
  ...(ruling.plugins === undefined ? {} : { plugins: ruling.plugins }),
2503
2551
  };
2504
2552
  answer(io, session, { run, task: taken, comments: comments.items, rules }, () =>
@@ -2510,7 +2558,7 @@ const take: Command = async (args, io) => {
2510
2558
  "",
2511
2559
  formatTask(taken, undefined, undefined, comments.items),
2512
2560
  "",
2513
- formatRules(rules, me.language),
2561
+ formatRules(rules, readingLanguage(me)),
2514
2562
  "",
2515
2563
  'Say how it goes: console report "<what you found or did>". Hand in what you make: console hand-in <https url | file path>.',
2516
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>".',
@@ -2712,11 +2760,11 @@ const answering: Command = async (args, io) => {
2712
2760
  }
2713
2761
  const note = await bodyOf(io, values, text(values, "note"));
2714
2762
  const session = await open(io, values);
2715
- const answered = await answerReached(session, id, {
2763
+ const { decision: answered, atItsAddress } = await answerReached(session, id, {
2716
2764
  ...(own === undefined ? { option } : { own }),
2717
2765
  ...(note === undefined ? {} : { note }),
2718
2766
  });
2719
- answer(io, session, answered, () => formatDecision(answered));
2767
+ answer(io, session, answered, () => formatDecision(answered, { atItsAddress }));
2720
2768
  return EXIT.ok;
2721
2769
  };
2722
2770
 
@@ -2735,11 +2783,16 @@ const notInProject = (error: unknown): boolean =>
2735
2783
  async function reachDecision(
2736
2784
  session: Session,
2737
2785
  id: string,
2738
- ): Promise<{ readonly decision: RestDecision; readonly waiter: Waiter }> {
2786
+ ): Promise<{
2787
+ readonly decision: RestDecision;
2788
+ readonly waiter: Waiter;
2789
+ /** Whether it was reached at its own address, outside the project the command works in. */
2790
+ readonly atItsAddress: boolean;
2791
+ }> {
2739
2792
  if ((await session.projectKey()) !== undefined) {
2740
2793
  const project = await session.project();
2741
2794
  try {
2742
- return { decision: await project.decision(id), waiter: project };
2795
+ return { decision: await project.decision(id), waiter: project, atItsAddress: false };
2743
2796
  } catch (error) {
2744
2797
  if (!notInProject(error)) {
2745
2798
  throw error;
@@ -2755,6 +2808,7 @@ async function reachDecision(
2755
2808
  awaitDecision: async (decisionId, seconds) =>
2756
2809
  (await anywhere.awaitDecision(decisionId, seconds)).decision,
2757
2810
  },
2811
+ atItsAddress: true,
2758
2812
  };
2759
2813
  } catch (error) {
2760
2814
  if (error instanceof ApiError && error.status === 404) {
@@ -2769,10 +2823,13 @@ async function answerReached(
2769
2823
  session: Session,
2770
2824
  id: string,
2771
2825
  input: RestAnswerInput,
2772
- ): Promise<RestDecision> {
2826
+ ): Promise<{ readonly decision: RestDecision; readonly atItsAddress: boolean }> {
2773
2827
  if ((await session.projectKey()) !== undefined) {
2774
2828
  try {
2775
- return await (await session.project()).answerDecision(id, input);
2829
+ return {
2830
+ decision: await (await session.project()).answerDecision(id, input),
2831
+ atItsAddress: false,
2832
+ };
2776
2833
  } catch (error) {
2777
2834
  if (!notInProject(error)) {
2778
2835
  throw error;
@@ -2780,7 +2837,7 @@ async function answerReached(
2780
2837
  }
2781
2838
  }
2782
2839
  try {
2783
- return await session.client.answerDecision(id, input);
2840
+ return { decision: await session.client.answerDecision(id, input), atItsAddress: true };
2784
2841
  } catch (error) {
2785
2842
  if (error instanceof ApiError && error.status === 404) {
2786
2843
  throw new ApiError(404, "decision.not_found", "The decision was not found.");
@@ -2809,9 +2866,9 @@ const decision: Command = async (args, io) => {
2809
2866
  answer(io, session, grown, () => formatDecision(grown));
2810
2867
  return EXIT.ok;
2811
2868
  }
2812
- const { decision: found, waiter } = await reachDecision(session, id);
2869
+ const { decision: found, waiter, atItsAddress } = await reachDecision(session, id);
2813
2870
  if (seconds === 0) {
2814
- answer(io, session, found, () => formatDecision(found));
2871
+ answer(io, session, found, () => formatDecision(found, { atItsAddress }));
2815
2872
  return EXIT.ok;
2816
2873
  }
2817
2874
  return settle(io, session, waiter, found, seconds);
@@ -3390,7 +3447,7 @@ const team: Command = async (args, io) => {
3390
3447
  // The workspace's settings (ADR-0035): read by everyone, changed by an administrator, themselves
3391
3448
  // on the Settings page or through their agent here (ADR-0021).
3392
3449
  const WORKSPACE_FLAGS =
3393
- "--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>";
3394
3451
  const WORKSPACE_USAGE = `Say what to do: console workspace | console workspace edit [${WORKSPACE_FLAGS.replaceAll(", ", "] [")}] | console workspace pack-token --connect|--stdin|--remove`;
3395
3452
 
3396
3453
  const workspace: Command = async (args, io) => {
@@ -3410,13 +3467,20 @@ const workspace: Command = async (args, io) => {
3410
3467
  "people-visibility": { type: "string" },
3411
3468
  "week-start": { type: "string" },
3412
3469
  "time-zone": { type: "string" },
3470
+ language: { type: "string" },
3413
3471
  },
3414
3472
  false,
3415
3473
  );
3416
3474
  const visibility = text(values, "people-visibility");
3417
3475
  const weekStart = text(values, "week-start");
3418
3476
  const zone = text(values, "time-zone");
3419
- 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
+ ) {
3420
3484
  throw misuse(`Say what to change: ${WORKSPACE_FLAGS}`);
3421
3485
  }
3422
3486
  const session = await open(io, values);
@@ -3426,6 +3490,14 @@ const workspace: Command = async (args, io) => {
3426
3490
  ? {}
3427
3491
  : { weekStart: wordOf(weekStart, WEEK_STARTS, "a day the week begins on") }),
3428
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
+ }),
3429
3501
  });
3430
3502
  await rememberZone(io, session, changed.timeZone ?? undefined);
3431
3503
  answer(io, session, changed, () => formatWorkspace(changed));
@@ -3628,7 +3700,7 @@ const wayOf = (values: Values): "connect" | "stdin" | "remove" => {
3628
3700
  const [way] = ways;
3629
3701
  if (way === undefined || ways.length !== 1) {
3630
3702
  throw misuse(
3631
- "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.",
3632
3704
  );
3633
3705
  }
3634
3706
  return way;
@@ -3650,8 +3722,8 @@ interface TokenHolder<T> {
3650
3722
 
3651
3723
  /**
3652
3724
  * The SkillCDN token (ADR-0028): connected with a code a person approves at SkillCDN (ADR-0036),
3653
- * or read from standard input and never from an argument, so that no shell keeps it; or taken
3654
- * 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.
3655
3727
  */
3656
3728
  async function packToken<T>(
3657
3729
  io: CliIo,
@@ -3688,9 +3760,9 @@ async function packToken<T>(
3688
3760
  );
3689
3761
  }
3690
3762
  }
3691
- const token = (await io.readStdin()).trim();
3763
+ const token = (await secretGiven(io, "SkillCDN token (typed unseen; Enter ends it): ")).trim();
3692
3764
  if (token.length === 0) {
3693
- throw failed("No token was given on standard input.");
3765
+ throw failed("No token was given.");
3694
3766
  }
3695
3767
  const changed = await holder.set(token);
3696
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"}`,
@@ -489,7 +490,19 @@ export function formatAnswer(decision: RestDecision): string {
489
490
  return lines.join("\n");
490
491
  }
491
492
 
492
- export function formatDecision(decision: RestDecision): string {
493
+ /**
494
+ * One decision in full. A decision reached at its own address (ADR-0068), outside the project the
495
+ * command works in, names its files with the command that reads them there, by the decision too:
496
+ * the project's own address knows nothing of it.
497
+ */
498
+ export function formatDecision(
499
+ decision: RestDecision,
500
+ options: { readonly atItsAddress?: boolean } = {},
501
+ ): string {
502
+ const reads = (fileId: string): string =>
503
+ options.atItsAddress === true
504
+ ? `console file ${fileId} --decision ${decision.id}`
505
+ : `console file ${fileId}`;
493
506
  const lines = [
494
507
  `decision ${decision.id}: ${decision.question}`,
495
508
  `asked by ${asker(decision)}${addressed(decision)}${decision.taskNumber === null ? "" : `, about task #${decision.taskNumber}`}`,
@@ -504,7 +517,7 @@ export function formatDecision(decision: RestDecision): string {
504
517
  "",
505
518
  ...files.map(
506
519
  (attached) =>
507
- `file: ${attached.file.name} (${attached.file.size} bytes, ${attached.file.contentType}): console file ${attached.id}`,
520
+ `file: ${attached.file.name} (${attached.file.size} bytes, ${attached.file.contentType}): ${reads(attached.id)}`,
508
521
  ),
509
522
  );
510
523
  }
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",
@@ -589,11 +589,13 @@ export const COMMAND_HELP: Readonly<Record<string, CommandHelp>> = {
589
589
  ],
590
590
  },
591
591
  file: {
592
- usage: "file <id> [--out <path>]",
593
- synopsis: "Reads a file of the project to this machine, by its id.",
592
+ usage: "file <id> [--decision <id>] [--out <path>]",
593
+ synopsis: "Reads a file of the project, or of a decision, to this machine, by its id.",
594
594
  about:
595
- "Reads a file of the project from the console and writes it on this machine: one a run handed in, one put in a comment or on a decision, or one attached to a page, by the id the task, the run, the decision or the page shows. Written under its own name in the working directory, at --out <path>, or into --out <directory>. Then look at it with your own tools.",
596
- refusals: ["file.not_found: no file of this project has that id"],
595
+ "Reads a file of the project from the console and writes it on this machine: one a run handed in, one put in a comment or on a decision, or one attached to a page, by the id the task, the run, the decision or the page shows. With --decision <id>, a file put on that decision, read at the decision's own address (ADR-0068): wherever the decision is, in this project or in one this directory does not name, as console decision reaches it and names the command for each of its files. Written under its own name in the working directory, at --out <path>, or into --out <directory>. Then look at it with your own tools.",
596
+ refusals: [
597
+ "file.not_found: no file of this project has that id, or, with --decision, none of that decision that reaches you",
598
+ ],
597
599
  },
598
600
  docs: {
599
601
  usage: "docs [<folder>] [--search <words>] [--archived]",
@@ -763,7 +765,17 @@ const SECTIONS: readonly { readonly title: string; readonly commands: readonly s
763
765
  {
764
766
  title:
765
767
  "Configuring, as the person: what an administrator or an owner does on the pages, their agent does here, named on it",
766
- commands: ["workspace", "people", "person", "project", "members", "member", "category"],
768
+ commands: [
769
+ "workspace",
770
+ "people",
771
+ "person",
772
+ "teams",
773
+ "team",
774
+ "project",
775
+ "members",
776
+ "member",
777
+ "category",
778
+ ],
767
779
  },
768
780
  ];
769
781
 
@@ -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,