@skillcdn/console 0.6.3 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/README.md +6 -6
  2. package/dist/agent-page.d.ts.map +1 -1
  3. package/dist/agent-page.js +7 -3
  4. package/dist/agent-page.js.map +1 -1
  5. package/dist/api.d.ts +5 -4
  6. package/dist/api.d.ts.map +1 -1
  7. package/dist/api.js +5 -4
  8. package/dist/api.js.map +1 -1
  9. package/dist/cli/cli.d.ts.map +1 -1
  10. package/dist/cli/cli.js +660 -138
  11. package/dist/cli/cli.js.map +1 -1
  12. package/dist/cli/format.d.ts +32 -4
  13. package/dist/cli/format.d.ts.map +1 -1
  14. package/dist/cli/format.js +125 -4
  15. package/dist/cli/format.js.map +1 -1
  16. package/dist/cli/help.d.ts.map +1 -1
  17. package/dist/cli/help.js +91 -29
  18. package/dist/cli/help.js.map +1 -1
  19. package/dist/cli/pack.d.ts +11 -10
  20. package/dist/cli/pack.d.ts.map +1 -1
  21. package/dist/cli/pack.js +27 -41
  22. package/dist/cli/pack.js.map +1 -1
  23. package/dist/cli/plugin-cli.d.ts.map +1 -1
  24. package/dist/cli/plugin-cli.js +8 -5
  25. package/dist/cli/plugin-cli.js.map +1 -1
  26. package/dist/cli/runner-files.d.ts.map +1 -1
  27. package/dist/cli/runner-files.js +15 -0
  28. package/dist/cli/runner-files.js.map +1 -1
  29. package/dist/cli/skill-path.d.ts +11 -0
  30. package/dist/cli/skill-path.d.ts.map +1 -0
  31. package/dist/cli/skill-path.js +44 -0
  32. package/dist/cli/skill-path.js.map +1 -0
  33. package/dist/client.d.ts +17 -1
  34. package/dist/client.d.ts.map +1 -1
  35. package/dist/client.js +10 -1
  36. package/dist/client.js.map +1 -1
  37. package/dist/components/agent-page.d.ts +67 -5
  38. package/dist/components/agent-page.d.ts.map +1 -1
  39. package/dist/components/agent-page.js +161 -14
  40. package/dist/components/agent-page.js.map +1 -1
  41. package/dist/components/agents.d.ts +3 -4
  42. package/dist/components/agents.d.ts.map +1 -1
  43. package/dist/components/agents.js +7 -6
  44. package/dist/components/agents.js.map +1 -1
  45. package/dist/components/people.d.ts.map +1 -1
  46. package/dist/components/people.js +7 -2
  47. package/dist/components/people.js.map +1 -1
  48. package/dist/components/picker.d.ts +16 -0
  49. package/dist/components/picker.d.ts.map +1 -1
  50. package/dist/components/picker.js +69 -4
  51. package/dist/components/picker.js.map +1 -1
  52. package/dist/console.css +40 -0
  53. package/dist/console.d.ts.map +1 -1
  54. package/dist/console.js +1 -1
  55. package/dist/console.js.map +1 -1
  56. package/dist/i18n/en.d.ts +19 -5
  57. package/dist/i18n/en.d.ts.map +1 -1
  58. package/dist/i18n/en.js +26 -12
  59. package/dist/i18n/en.js.map +1 -1
  60. package/dist/i18n/ko.d.ts.map +1 -1
  61. package/dist/i18n/ko.js +22 -10
  62. package/dist/i18n/ko.js.map +1 -1
  63. package/dist/limits.d.ts +16 -0
  64. package/dist/limits.d.ts.map +1 -1
  65. package/dist/limits.js +16 -0
  66. package/dist/limits.js.map +1 -1
  67. package/dist/onboarding.d.ts +18 -6
  68. package/dist/onboarding.d.ts.map +1 -1
  69. package/dist/onboarding.js +42 -7
  70. package/dist/onboarding.js.map +1 -1
  71. package/dist/plugin/args.d.ts +24 -2
  72. package/dist/plugin/args.d.ts.map +1 -1
  73. package/dist/plugin/args.js +20 -2
  74. package/dist/plugin/args.js.map +1 -1
  75. package/dist/plugin/define.d.ts.map +1 -1
  76. package/dist/plugin/define.js +12 -3
  77. package/dist/plugin/define.js.map +1 -1
  78. package/dist/plugin/rest-schemas.d.ts +2 -0
  79. package/dist/plugin/rest-schemas.d.ts.map +1 -1
  80. package/dist/plugin/rest-schemas.js +1 -0
  81. package/dist/plugin/rest-schemas.js.map +1 -1
  82. package/dist/routes.d.ts +2 -0
  83. package/dist/routes.d.ts.map +1 -1
  84. package/dist/routes.js +2 -0
  85. package/dist/routes.js.map +1 -1
  86. package/dist/rules.d.ts +4 -1
  87. package/dist/rules.d.ts.map +1 -1
  88. package/dist/rules.js +5 -2
  89. package/dist/rules.js.map +1 -1
  90. package/dist/runner/claude.d.ts.map +1 -1
  91. package/dist/runner/claude.js +48 -0
  92. package/dist/runner/claude.js.map +1 -1
  93. package/dist/runner/codex.d.ts.map +1 -1
  94. package/dist/runner/codex.js +4 -1
  95. package/dist/runner/codex.js.map +1 -1
  96. package/dist/runner/desk.d.ts.map +1 -1
  97. package/dist/runner/desk.js +5 -4
  98. package/dist/runner/desk.js.map +1 -1
  99. package/dist/runner/runner.d.ts +16 -0
  100. package/dist/runner/runner.d.ts.map +1 -1
  101. package/dist/runner/runner.js +157 -8
  102. package/dist/runner/runner.js.map +1 -1
  103. package/dist/runner/slack.d.ts.map +1 -1
  104. package/dist/runner/slack.js +14 -3
  105. package/dist/runner/slack.js.map +1 -1
  106. package/dist/runner/types.d.ts +19 -0
  107. package/dist/runner/types.d.ts.map +1 -1
  108. package/dist/runner/types.js.map +1 -1
  109. package/dist/schemas.d.ts +475 -5
  110. package/dist/schemas.d.ts.map +1 -1
  111. package/dist/schemas.js +117 -12
  112. package/dist/schemas.js.map +1 -1
  113. package/dist/secret-file.d.ts +21 -0
  114. package/dist/secret-file.d.ts.map +1 -0
  115. package/dist/secret-file.js +59 -0
  116. package/dist/secret-file.js.map +1 -0
  117. package/dist/services.d.ts.map +1 -1
  118. package/dist/services.js +3 -2
  119. package/dist/services.js.map +1 -1
  120. package/dist/setup-guide.d.ts +2 -2
  121. package/dist/setup-guide.d.ts.map +1 -1
  122. package/dist/setup-guide.js +6 -5
  123. package/dist/setup-guide.js.map +1 -1
  124. package/dist/vocabulary.d.ts +10 -2
  125. package/dist/vocabulary.d.ts.map +1 -1
  126. package/dist/vocabulary.js +9 -2
  127. package/dist/vocabulary.js.map +1 -1
  128. package/docs/specs/cli.md +22 -16
  129. package/docs/specs/plugins.md +5 -4
  130. package/docs/specs/rest.md +24 -12
  131. package/docs/specs/runner.md +19 -12
  132. package/docs/start.md +4 -3
  133. package/package.json +3 -3
  134. package/skills/building-a-plugin/SKILL.md +2 -2
  135. package/skills/keeping-the-pack/SKILL.md +87 -0
  136. package/skills/planning-the-board/SKILL.md +6 -6
  137. package/skills/planning-the-board/references/a-task.md +1 -1
  138. package/skills/planning-the-board/references/setting-up.md +9 -5
  139. package/skills/running-an-agent/SKILL.md +15 -14
  140. package/skills/running-an-agent/references/preparing-the-machine.md +3 -2
  141. package/skills/running-an-agent/references/several-tasks.md +8 -2
  142. package/skills/running-an-agent/references/slack-app.md +10 -4
  143. package/skills/running-an-agent/references/the-account-and-the-invitation.md +1 -1
  144. package/skills/running-an-agent/references/what-was-not-seen-run-yet.md +3 -1
  145. package/skills/running-an-agent/references/when-the-agent-could-not-go-on.md +3 -3
  146. package/skills/running-an-agent/references/your-first-task.md +4 -3
  147. package/skills/working-the-board/SKILL.md +4 -4
  148. package/skills/working-the-board/references/terms.md +3 -1
  149. package/skills/working-the-board/references/the-pack.md +12 -5
  150. package/src/agent-page.tsx +19 -3
  151. package/src/api.ts +27 -0
  152. package/src/cli/cli.ts +847 -192
  153. package/src/cli/format.ts +158 -4
  154. package/src/cli/help.ts +102 -28
  155. package/src/cli/pack.ts +49 -58
  156. package/src/cli/plugin-cli.ts +8 -5
  157. package/src/cli/runner-files.ts +17 -0
  158. package/src/cli/skill-path.ts +51 -0
  159. package/src/client.ts +50 -0
  160. package/src/components/agent-page.tsx +309 -30
  161. package/src/components/agents.tsx +7 -23
  162. package/src/components/people.tsx +7 -3
  163. package/src/components/picker.tsx +79 -5
  164. package/src/console.tsx +0 -1
  165. package/src/i18n/en.ts +28 -13
  166. package/src/i18n/ko.ts +24 -10
  167. package/src/limits.ts +16 -0
  168. package/src/onboarding.ts +60 -21
  169. package/src/plugin/args.ts +29 -3
  170. package/src/plugin/define.ts +18 -3
  171. package/src/plugin/rest-schemas.ts +3 -0
  172. package/src/routes.ts +2 -0
  173. package/src/rules.ts +5 -2
  174. package/src/runner/claude.ts +53 -0
  175. package/src/runner/codex.ts +4 -1
  176. package/src/runner/desk.ts +5 -4
  177. package/src/runner/runner.ts +199 -9
  178. package/src/runner/slack.ts +18 -7
  179. package/src/runner/types.ts +16 -0
  180. package/src/schemas.ts +148 -10
  181. package/src/secret-file.ts +76 -0
  182. package/src/services.ts +3 -2
  183. package/src/setup-guide.ts +6 -5
  184. package/src/styles/README.md +1 -1
  185. package/src/styles/pages/agents.css +40 -0
  186. package/src/vocabulary.ts +12 -2
  187. package/dist/cli/command-words.d.ts +0 -20
  188. package/dist/cli/command-words.d.ts.map +0 -1
  189. package/dist/cli/command-words.js +0 -51
  190. package/dist/cli/command-words.js.map +0 -1
  191. package/src/cli/command-words.ts +0 -56
package/src/schemas.ts CHANGED
@@ -2,6 +2,8 @@
2
2
  // most of what a page downloads. The server validates what it is sent with the input schemas
3
3
  // and builds the output shapes; the pages and a custom console parse answers with the rest.
4
4
  // Absent values are `null` on the wire, never missing keys. Changes within a version are additive.
5
+
6
+ import { parseRepoPath } from "@skillcdn/core/address";
5
7
  import {
6
8
  restBrowseSchema as packBrowseSchema,
7
9
  restCodeSchema as packCodeSchema,
@@ -10,7 +12,7 @@ import {
10
12
  restMountSchema as packMountSchema,
11
13
  restRowsSchema as packRowsSchema,
12
14
  restSkillSchema as packSkillSchema,
13
- } from "@skillcdn/core";
15
+ } from "@skillcdn/core/rest";
14
16
  import * as z from "zod/mini";
15
17
  import { isDocumentPath } from "./documents.js";
16
18
  import { isIconName } from "./icons/index.js";
@@ -38,6 +40,9 @@ import {
38
40
  MAX_NOTIFICATION_KIND_LENGTH,
39
41
  MAX_OPTION_LABEL_LENGTH,
40
42
  MAX_OPTIONS,
43
+ MAX_PACK_NOTE_LENGTH,
44
+ MAX_PACK_NOTE_OUTCOME_LENGTH,
45
+ MAX_PACK_NOTE_PATH_LENGTH,
41
46
  MAX_PERSON_NAME_LENGTH,
42
47
  MAX_PERSON_TITLE_LENGTH,
43
48
  MAX_PROJECT_DESCRIPTION_LENGTH,
@@ -92,6 +97,7 @@ import {
92
97
  LINK_SOURCES,
93
98
  MEMBERSHIP_SOURCES,
94
99
  PACK_CONNECT_ENDINGS,
100
+ PACK_NOTE_STATES,
95
101
  PEOPLE_VISIBILITIES,
96
102
  PERSON_KINDS,
97
103
  PERSON_ROLES,
@@ -163,6 +169,8 @@ const instant = z.iso.datetime();
163
169
  /** A calendar day (`2026-10-20`): a plan is made in days, wherever the people are (ADR-0019). */
164
170
  const day = z.iso.date();
165
171
  const count = z.int().check(z.nonnegative());
172
+ /** An hour and a minute of the day, as `09:00`. */
173
+ const clockTime = z.string().check(z.regex(/^(?:[01][0-9]|2[0-3]):[0-5][0-9]$/));
166
174
 
167
175
  /** A person of the workspace, as the pages show them. Nothing here is a secret. */
168
176
  /** A language tag as a browser sends one (`en`, `ko-KR`). */
@@ -611,6 +619,15 @@ export const restWorkspaceSchema = z.object({
611
619
  * for none. Optional, so that a console older than it still answers.
612
620
  */
613
621
  packToken: z.optional(z.nullable(z.object({ setAt: instant }))),
622
+ /**
623
+ * Who keeps the organization's skills (ADR-0178), the member the notes on them wait for, by
624
+ * their id; `null` for nobody, when they wait for the administrators. And the hour of the
625
+ * keeper's round, in the workspace's time zone, at which the console wakes a keeper that is
626
+ * an agent account where a note was left since the last; `null` for no round. Answered from
627
+ * the release that carries the notes and read as optional.
628
+ */
629
+ keeperId: z.optional(z.nullable(uuid)),
630
+ roundAt: z.optional(z.nullable(clockTime)),
614
631
  }),
615
632
  /**
616
633
  * Who sees whom on the People page (ADR-0035): everyone, or the people one shares a project
@@ -648,6 +665,10 @@ export const restWorkspacePatchSchema = z
648
665
  handle: z.optional(z.nullable(z.string().check(z.refine(isHandle, "is a short name")))),
649
666
  /** Its mail and web domain, in small letters; `null` for none. */
650
667
  domain: z.optional(z.nullable(z.string().check(z.refine(isDomain, "is a domain")))),
668
+ /** Who keeps the organization's skills (ADR-0178), a member by their id; `null` for nobody. */
669
+ packKeeperId: z.optional(z.nullable(uuid)),
670
+ /** The hour of the keeper's round, `HH:MM` in the workspace's time zone; `null` for no round. */
671
+ packRoundAt: z.optional(z.nullable(clockTime)),
651
672
  /** The services named anew, by role: one left out stays as it is, `null` takes one away. */
652
673
  services: z.optional(
653
674
  z.object({
@@ -1516,8 +1537,9 @@ export type RestAgentSecretOfferTakeInput = z.infer<typeof restAgentSecretOfferT
1516
1537
  /**
1517
1538
  * `GET /api/v1/me/manager`: whom whoever asks reports to, a person or an agent account, `null`
1518
1539
  * for nobody; and the administrators of the workspace, who stand in where there is nobody, or
1519
- * the manager is out (ADR-0084). A manager is whom a member turns to first, not a rule of the
1520
- * board: a decision is addressed to whomever the asker names.
1540
+ * the manager is out (ADR-0084), whoever asks left out where they are one (ADR-0180). A manager
1541
+ * is whom a member turns to first, not a rule of the board: a decision is addressed to whomever
1542
+ * the asker names.
1521
1543
  */
1522
1544
  export const restManagerSchema = z.object({
1523
1545
  manager: z.nullable(restPersonSchema),
@@ -1525,6 +1547,116 @@ export const restManagerSchema = z.object({
1525
1547
  });
1526
1548
  export type RestManager = z.infer<typeof restManagerSchema>;
1527
1549
 
1550
+ /**
1551
+ * A note on the pack (ADR-0178): what a run showed a skill, or a page of the pack, to lack or to
1552
+ * say wrong, left by whoever met it for whoever keeps the pack; or, with no path, a job of a kind
1553
+ * that comes again for which the pack has no skill. Kept by the console and never in the pack,
1554
+ * which may be public. Who left it and through which agent, the project it was left from where
1555
+ * one was named, how it stands, and, once closed, what became of it and who said so.
1556
+ */
1557
+ export const restPackNoteSchema = z.object({
1558
+ id: uuid,
1559
+ /** The address of the pack it is on, as the console read it then; `null` where it names none. */
1560
+ pack: z.nullable(z.string()),
1561
+ /** The skill or the page it is on, by its path in the pack; `null` for a job no skill fit. */
1562
+ path: z.nullable(z.string()),
1563
+ body: z.string(),
1564
+ /** One of `PACK_NOTE_STATES`. */
1565
+ state: z.enum(PACK_NOTE_STATES),
1566
+ /** Who left it; `null` for a member the asker may not see (ADR-0035). */
1567
+ by: z.nullable(restPersonSchema),
1568
+ /** The agent they left it through, when they acted with a token; `null` when they did it themselves, or the asker may not see them. */
1569
+ agent: z.nullable(z.string()),
1570
+ /** The key of the project it was left from; `null` where none was named, or the asker may not see it. */
1571
+ project: z.nullable(z.string()),
1572
+ at: instant,
1573
+ /** What became of it, in its closer's words; `null` while it is open. */
1574
+ outcome: z.nullable(z.string()),
1575
+ /** Who closed it, and the agent they closed it through; `null` while it is open, and for a member the asker may not see. */
1576
+ closedBy: z.nullable(restPersonSchema),
1577
+ closedAgent: z.nullable(z.string()),
1578
+ closedAt: z.nullable(instant),
1579
+ });
1580
+ export type RestPackNote = z.infer<typeof restPackNoteSchema>;
1581
+
1582
+ /**
1583
+ * `GET /api/v1/pack-notes`: a page of the notes the asker reads, the oldest first, everyone's
1584
+ * for whoever keeps the pack and for an administrator (`everyones`), their own for anyone else;
1585
+ * how many of all of them are open; whether a member keeps the pack (`kept`), and who, `null`
1586
+ * for nobody and for a keeper the asker may not see; and the hour of their round, `null` for
1587
+ * none.
1588
+ */
1589
+ export const restPackNotesSchema = z.object({
1590
+ items: z.array(restPackNoteSchema),
1591
+ open: count,
1592
+ everyones: z.boolean(),
1593
+ kept: z.boolean(),
1594
+ keeper: z.nullable(restPersonSchema),
1595
+ roundAt: z.nullable(clockTime),
1596
+ });
1597
+ export type RestPackNotes = z.infer<typeof restPackNotesSchema>;
1598
+
1599
+ /** What a note's text is: a few sentences, with their line breaks, and something in them. */
1600
+ const packNoteText = (maxLength: number) =>
1601
+ z.string().check(
1602
+ z.trim(),
1603
+ z.minLength(1),
1604
+ z.maxLength(maxLength),
1605
+ z.refine((value) => !hasForbiddenCodePoint(value, true), "must not contain control characters"),
1606
+ );
1607
+
1608
+ /**
1609
+ * Whether a note may be on this path: a path of the pack from its root, as the pack's own
1610
+ * reads hold one (`parseRepoPath` of @skillcdn/core), with no slash at either end and no `.`
1611
+ * or `..` among its parts, or `.` alone, a pack that is one skill at its root. A note names
1612
+ * what it is on and reads nothing there, yet what is listed as a path is one.
1613
+ */
1614
+ export const isPackNotePath = (path: string): boolean =>
1615
+ path === "." || (path.length > 0 && parseRepoPath(path).ok && !path.endsWith("/"));
1616
+
1617
+ /**
1618
+ * What `POST /api/v1/pack-notes` is sent: what the note says; the path of the skill or the page
1619
+ * it is on, left out or `null` for a job no skill fit; and the key of the project it is left
1620
+ * from, where the command names one, whose pack it is then on.
1621
+ */
1622
+ export const restPackNoteInputSchema = z.object({
1623
+ path: z.optional(
1624
+ z.nullable(
1625
+ line(MAX_PACK_NOTE_PATH_LENGTH).check(
1626
+ z.refine(
1627
+ isPackNotePath,
1628
+ "is a path of the pack from its root, with no slash at either end, no backslash and no . or .. among its parts",
1629
+ ),
1630
+ ),
1631
+ ),
1632
+ ),
1633
+ body: packNoteText(MAX_PACK_NOTE_LENGTH),
1634
+ project: z.optional(z.string().check(z.minLength(1), z.maxLength(MAX_PROJECT_KEY_LENGTH))),
1635
+ });
1636
+ export type RestPackNoteInput = z.infer<typeof restPackNoteInputSchema>;
1637
+
1638
+ /**
1639
+ * What leaving a note answers: the note, whether a member keeps the pack it waits for (`kept`),
1640
+ * and who, `null` for nobody and for a keeper the asker may not see.
1641
+ */
1642
+ export const restPackNoteLeftSchema = z.object({
1643
+ note: restPackNoteSchema,
1644
+ kept: z.boolean(),
1645
+ keeper: z.nullable(restPersonSchema),
1646
+ });
1647
+ export type RestPackNoteLeft = z.infer<typeof restPackNoteLeftSchema>;
1648
+
1649
+ /**
1650
+ * What `POST /api/v1/pack-notes/<id>/close` is sent: how the note ends, `done` where what it
1651
+ * asked for is in the pack or before a person as a proposal and `dropped` where nothing follows
1652
+ * from it, and what became of it, in a sentence or two.
1653
+ */
1654
+ export const restPackNoteCloseInputSchema = z.object({
1655
+ state: z.enum(["done", "dropped"]),
1656
+ outcome: packNoteText(MAX_PACK_NOTE_OUTCOME_LENGTH),
1657
+ });
1658
+ export type RestPackNoteCloseInput = z.infer<typeof restPackNoteCloseInputSchema>;
1659
+
1528
1660
  /** What an avatar's parts were rolled from: a short text of letters, digits, hyphens and underscores. */
1529
1661
  const avatarSeed = z.string().check(z.minLength(1), z.maxLength(64), z.regex(/^[A-Za-z0-9_-]+$/));
1530
1662
 
@@ -1549,8 +1681,6 @@ export type RestAgentProposals = z.infer<typeof restAgentProposalsSchema>;
1549
1681
  const elsewhereService = z.string().check(z.regex(/^[a-z][a-z0-9-]{0,39}$/));
1550
1682
  /** What the agent is called at a service: a line, and no secret. */
1551
1683
  const elsewhereName = line(MAX_ELSEWHERE_NAME_LENGTH);
1552
- /** An hour and a minute of the day, as `09:00`. */
1553
- const clockTime = z.string().check(z.regex(/^(?:[01][0-9]|2[0-3]):[0-5][0-9]$/));
1554
1684
  /**
1555
1685
  * The hours an agent account keeps (ADR-0085, point 11), in the workspace's time zone: when its
1556
1686
  * day starts, which is when its day's briefing is sent, and when it ends, with a wrap then, or
@@ -1651,7 +1781,11 @@ export const restAgentSchema = z.object({
1651
1781
  accounts: z.optional(restAgentElsewhereSchema),
1652
1782
  /** The hours it keeps: answered where one account is read, to its supervisors and to the account. */
1653
1783
  hours: z.optional(restAgentHoursSchema),
1654
- /** Its onboarding task (ADR-0088), where the console made one with the account: answered when the account is made. */
1784
+ /**
1785
+ * The onboarding task a console before 0.6.4 made with the account (ADR-0088), answered there
1786
+ * when the account was made. A console from 0.6.4 on makes none and leaves this out: the
1787
+ * onboarding is its first message to the account (ADR-0181).
1788
+ */
1655
1789
  onboarding: z.optional(
1656
1790
  z.nullable(z.object({ project: z.string(), number: z.number().check(z.int()) })),
1657
1791
  ),
@@ -1673,8 +1807,9 @@ export type RestAgents = z.infer<typeof restAgentsSchema>;
1673
1807
  /**
1674
1808
  * What `POST /api/v1/agents` is sent, by an administrator: the account the agent will sign in
1675
1809
  * with, at one of the providers the deployment has, as a listing names one; its persona; its
1676
- * manager, whoever makes it where none is named; and the project it starts in. A login a member
1677
- * already carries is made an agent account only where `convert` asks for it, once (ADR-0104).
1810
+ * manager, whoever makes it where none is named. A login a member already carries is made an
1811
+ * agent account only where `convert` asks for it, once (ADR-0104). An account is made in no
1812
+ * project (ADR-0181): it is put in one later, as any member is.
1678
1813
  */
1679
1814
  export const restAgentInputSchema = z
1680
1815
  .object({
@@ -1688,8 +1823,11 @@ export const restAgentInputSchema = z
1688
1823
  /** Left out, the console rolls them: from the seed where one is given, from one of its own otherwise. */
1689
1824
  avatarParts: z.optional(restAvatarPartsSchema),
1690
1825
  managerId: z.optional(uuid),
1691
- /** The key of the project it starts in. */
1692
- project: z.string().check(z.minLength(1), z.maxLength(MAX_PROJECT_KEY_LENGTH)),
1826
+ /**
1827
+ * Taken and not used (ADR-0181): the key of the project an account started in, which a
1828
+ * console before 0.6.4 required and a command of before still sends.
1829
+ */
1830
+ project: z.optional(z.string().check(z.minLength(1), z.maxLength(MAX_PROJECT_KEY_LENGTH))),
1693
1831
  /**
1694
1832
  * `true` says that the member who carries the login already is to become the account, for
1695
1833
  * good (ADR-0104); left out, such a login is refused (`agent.login_is_member`). It asks
@@ -0,0 +1,76 @@
1
+ import { MAX_AGENT_SECRET_BYTES } from "./limits.js";
2
+
3
+ // A file as the value of an agent account's secret (ADR-0087, ADR-0184): the command takes one
4
+ // with --file, and the pages take one a person chose, a `.env` of several lines among them. What
5
+ // a file comes to as a value is said here once, for both: its text whole, but for the one
6
+ // newline a file ends with. The pages read a file a person chose as bytes, so they also say
7
+ // here what is no value at all: what is no text, what is empty, what is longer than a value
8
+ // may be. A file's text is a secret from the moment it is read: nothing here says any of it back.
9
+
10
+ /** Why a file a person chose is not taken as a secret's value. */
11
+ export type SecretFileRefusal = "too_large" | "not_text" | "empty";
12
+
13
+ /**
14
+ * The most a file may be for its text to be read at all, in bytes: twice a value's bound, for a
15
+ * text written two bytes a character, and the mark of its encoding with the newline it ends on.
16
+ * A larger file is refused by its size, unread.
17
+ */
18
+ export const MAX_SECRET_FILE_BYTES = 2 * MAX_AGENT_SECRET_BYTES + 4;
19
+
20
+ /** A file's text as a secret's value: whole, but for the one newline a file ends with. */
21
+ export function secretOfText(text: string): string {
22
+ return text.replace(/\r?\n$/, "");
23
+ }
24
+
25
+ /** Whether a character is one a text does not hold: a control other than a tab and the ends of a line. */
26
+ const isControl = (code: number): boolean =>
27
+ (code < 0x20 && code !== 0x09 && code !== 0x0a && code !== 0x0d) || code === 0x7f;
28
+
29
+ /** The text the bytes are, by the mark they begin with: UTF-8 unless they say otherwise. Nothing where they are no text. */
30
+ function textOf(bytes: Uint8Array): string | undefined {
31
+ const [first, second] = bytes;
32
+ const encoding =
33
+ first === 0xff && second === 0xfe
34
+ ? "utf-16le"
35
+ : first === 0xfe && second === 0xff
36
+ ? "utf-16be"
37
+ : "utf-8";
38
+ let text: string;
39
+ try {
40
+ // The decoder takes the mark off, and refuses bytes that are no text in the encoding.
41
+ text = new TextDecoder(encoding, { fatal: true }).decode(bytes);
42
+ } catch {
43
+ return undefined;
44
+ }
45
+ for (let at = 0; at < text.length; at += 1) {
46
+ if (isControl(text.charCodeAt(at))) {
47
+ return undefined;
48
+ }
49
+ }
50
+ return text;
51
+ }
52
+
53
+ /**
54
+ * The value a chosen file's bytes are, or why they are none: a file larger than is read at all,
55
+ * bytes that are no text, a file with nothing in it, and a text longer than a value may be, in
56
+ * the bytes the console counts it in (UTF-8).
57
+ */
58
+ export function secretOfFile(
59
+ bytes: Uint8Array,
60
+ ): { readonly value: string } | { readonly refused: SecretFileRefusal } {
61
+ if (bytes.byteLength > MAX_SECRET_FILE_BYTES) {
62
+ return { refused: "too_large" };
63
+ }
64
+ const text = textOf(bytes);
65
+ if (text === undefined) {
66
+ return { refused: "not_text" };
67
+ }
68
+ const value = secretOfText(text);
69
+ if (value.length === 0) {
70
+ return { refused: "empty" };
71
+ }
72
+ if (new TextEncoder().encode(value).byteLength > MAX_AGENT_SECRET_BYTES) {
73
+ return { refused: "too_large" };
74
+ }
75
+ return { value };
76
+ }
package/src/services.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { agentHref } from "./router.js";
1
2
  import type { RestWorkspace, RestWorkspaceService } from "./schemas.js";
2
3
  import type { ProviderKey, ServiceRole } from "./vocabulary.js";
3
4
 
@@ -168,7 +169,7 @@ const gitlab: ServiceProvider = {
168
169
  service.form === "service"
169
170
  ? [
170
171
  `An owner of ${service.group === undefined ? "the group" : `the group \`${service.group}\``} at ${gitlabHost(service)} makes a service account for the agent, ${called(account, "under its name")}: the form of account the host has for a machine, which signs in at no page and takes no seat.`,
171
- `They give it the role its work needs in the group and no more, make it a token that reads and writes repositories and nothing else, and seed the token where only the agent reads it, with the day it ends: console agent secret ${names.agent} git.token --expires <day>.`,
172
+ `They give it the role its work needs in the group and no more, make it a token that reads and writes repositories and nothing else, and put the token in where only the agent reads it, on the agent's page of the console under Settings (${agentHref(names.agent, "settings")}): as the secret git.token, with the day it ends.`,
172
173
  ]
173
174
  : [
174
175
  `The account ${called(account, "of the agent")} at ${gitlabHost(service)}, made if it is not there yet, with the agent's own mailbox where it has one.`,
@@ -210,7 +211,7 @@ const gitlab: ServiceProvider = {
210
211
  ? [
211
212
  {
212
213
  title: `Make a service account for ${names.agent} at GitLab`,
213
- body: `In the settings of ${service.group === undefined ? "the group" : `the group \`${service.group}\``}, under Service accounts, add one${account === undefined ? "" : ` named \`${account}\``}, give it the role its work needs in the group and no more, and make it a token that reads and writes repositories. Seed the token where only the agent reads it, with the day it ends: console agent secret ${names.agent} git.token --expires <day>.`,
214
+ body: `In the settings of ${service.group === undefined ? "the group" : `the group \`${service.group}\``}, under Service accounts, add one${account === undefined ? "" : ` named \`${account}\``}, give it the role its work needs in the group and no more, and make it a token that reads and writes repositories. Put the token in where only the agent reads it, on the agent's page of the console under Settings (${agentHref(names.agent, "settings")}): as the secret git.token, with the day it ends.`,
214
215
  },
215
216
  ]
216
217
  : [
@@ -1,4 +1,5 @@
1
1
  import { en } from "./i18n/en.js";
2
+ import { agentHref } from "./router.js";
2
3
  import type { RestAgentSetup, RestWorkspace } from "./schemas.js";
3
4
  import {
4
5
  agentAddressOf,
@@ -205,7 +206,7 @@ export function setupGuideOf(setup: RestAgentSetup, code: string): SetupGuide {
205
206
  },
206
207
  {
207
208
  title: "The sign-in",
208
- body: `Then the command opens an address in the machine's browser, prints it with a code, and waits. Say to the person at the machine: "Sign in there through ${provider} as \`${account.login}\`, check that the page shows this code, and say that it is you." They sign in themselves, and no password is written in a chat: a secret the agent is to hold, they seed from their own machine (\`console agent secret ${account.handle} <name>\`). Nobody else's sign-in answers for the account; where the page shows another member, they sign out there first.`,
209
+ body: `Then the command opens an address in the machine's browser, prints it with a code, and waits. Say to the person at the machine: "Sign in there through ${provider} as \`${account.login}\`, check that the page shows this code, and say that it is you." They sign in themselves, and no password is written in a chat: a secret the agent is to hold, they put in on the agent's page of the console, ${setup.console.url}${agentHref(account.handle, "settings")}. Nobody else's sign-in answers for the account; where the page shows another member, they sign out there first.`,
209
210
  },
210
211
  {
211
212
  title: "What the command does then",
@@ -213,7 +214,7 @@ export function setupGuideOf(setup: RestAgentSetup, code: string): SetupGuide {
213
214
  },
214
215
  {
215
216
  title: "Then stop",
216
- body: `That is the machine prepared. What comes after is the agent's own, done in its own session from its first task: its sign-ins at the services, its tokens, its desk's repository, its profile, its messenger. Do none of it for it. What you change on this machine afterwards, say to it: \`console agent wake me "<what changed>"\`.`,
217
+ body: `That is the machine prepared. What comes after is the agent's own, done in its own session from the console's first message to it: its sign-ins at the services, its tokens, its desk's repository, its profile, its messenger. Do none of it for it. What you change on this machine afterwards, say to it: \`console agent wake me "<what changed>"\`.`,
217
218
  },
218
219
  ];
219
220
 
@@ -262,7 +263,7 @@ export function setupGuideOf(setup: RestAgentSetup, code: string): SetupGuide {
262
263
  who: "agent" as const,
263
264
  title: "When the agent starts",
264
265
  about:
265
- "What the agent does itself, in its own session, as its first task says. What it signs in with it keeps in its store (console secret), never in a file or a message.",
266
+ "What the agent does itself, in its own session, as the console's first message to it says. What it signs in with it keeps in its store (console secret), never in a file or a message.",
266
267
  steps: start,
267
268
  },
268
269
  ]),
@@ -308,8 +309,8 @@ const WHO: Readonly<Record<SetupRole, string>> = {
308
309
  /**
309
310
  * The guide as the command prints it (ADR-0140): Markdown, every line to run on a line of its
310
311
  * own, and of its sections only those of whoever prepares the machine, since the command is run
311
- * by them. What the agent does when it starts and what it asks for are the agent's first task,
312
- * read by the agent in its own session: a session at the machine that read them took them for
312
+ * by them. What the agent does when it starts and what it asks for are the console's first
313
+ * message to the agent (ADR-0181), read by the agent in its own session: a session at the machine that read them took them for
313
314
  * its own work. `moment` says the invitation's day as the command says a moment; left out, as
314
315
  * the API gives it.
315
316
  */
@@ -52,7 +52,7 @@ A part is a file under `parts/` and a row here, with the classes that are its ow
52
52
  | `form` | `sc-form*`, `sc-field*`, `sc-check*`, `sc-member-form` | | A form: a field under its label with a hint (`sc-field`, `-label`, `-hint`), fields side by side (`sc-field-row`), parts under headings (`sc-form-part`), its buttons (`sc-form-actions`), what went wrong (`sc-form-error`), a tick with its words (`sc-check`), a small form on one line (`sc-member-form`). |
53
53
  | `files` | `sc-file*`, `sc-chosen*` | | Files to choose, and the ones chosen with the way to take each out. |
54
54
  | `toggle` | `sc-toggle*` | | One choice among a few, each a chip, the chosen one filled. |
55
- | `picker` | `sc-picker*`, `sc-person-option*` | `Picker` | One thing chosen out of a listing that is searched: a person, a project, a goal, a task. `sc-picker-quiet` where it is a fact changed in place, `sc-picker-add` at the end of a row of chips. |
55
+ | `picker` | `sc-picker*`, `sc-person-option*` | `Picker` | One thing chosen out of a listing that is searched: a person, a project, a goal, a task. `sc-picker-quiet` where it is a fact changed in place, `sc-picker-add` at the end of a row of chips. The press on what is chosen clears it; where something is always chosen (`required`, an agent account's manager), it opens the field over it and saves nothing, and what stood stands again unless another is chosen. |
56
56
  | `menu` | `sc-menu*` | `NotificationsMenu` | What opens from a button over the page: the person's menu, a card's. `sc-menu-popover` is a panel opened in the top layer, over whatever around its button would clip or cover it, as a front page tile's sizes are. `sc-menu-summary-glyph` is a menu opened from a glyph alone, the bell; `sc-menu-panel-list` a menu that is a list of what happened, the notifications: a head that stays (`sc-menu-head`, `-title`, `-head-link`), rows that each lead somewhere (`sc-menu-rows` of `sc-menu-row`: a picture, two lines of what happened at most, a line of why and where that gives way to when; `sc-menu-row-new` for one that is new), what stands in their place (`sc-menu-note`) and a foot for more (`sc-menu-foot`). |
57
57
  | `tabs` | `sc-tab*`, `sc-tabs*`, `sc-subtabs*` | | The pages of a project (`sc-tabs`), and the views of one page (`sc-subtabs` of `sc-tab`s), the current one marked. |
58
58
  | `pager` | `sc-pager*`, `sc-show*` | `Pager`, `ShowMore` | A long list a page at a time: turned by pages, or grown by "show more". |
@@ -1232,6 +1232,46 @@
1232
1232
  width: 100%;
1233
1233
  }
1234
1234
 
1235
+ /* A view that is not the asker's to open, and under it what is theirs to do there. */
1236
+ .sc-agent-closed {
1237
+ display: grid;
1238
+ gap: var(--sc-space-5);
1239
+ }
1240
+
1241
+ /* Under a secret's fields: the way to choose a file as the value, and the day it ends on. */
1242
+ .sc-agent-secret-more {
1243
+ display: flex;
1244
+ flex-wrap: wrap;
1245
+ align-items: center;
1246
+ gap: var(--sc-space-2) var(--sc-space-4);
1247
+ grid-column: 1 / -1;
1248
+ min-width: 0;
1249
+ }
1250
+
1251
+ /* A file chosen as the value gives way to its cell: a long name is cut, never the form widened. */
1252
+ .sc-agent-secret-form > .sc-chosen-files {
1253
+ min-width: 0;
1254
+ }
1255
+
1256
+ .sc-agent-secret-file {
1257
+ max-width: 100%;
1258
+ min-width: 0;
1259
+ }
1260
+
1261
+ .sc-agent-secret-file-name {
1262
+ flex: 0 1 auto;
1263
+ min-width: 0;
1264
+ overflow: hidden;
1265
+ text-overflow: ellipsis;
1266
+ white-space: nowrap;
1267
+ }
1268
+
1269
+ /* Its size stays on one line beside it: the name is what gives way. */
1270
+ .sc-agent-secret-file > .sc-muted {
1271
+ flex: none;
1272
+ white-space: nowrap;
1273
+ }
1274
+
1235
1275
  @media (max-width: 40rem) {
1236
1276
  .sc-agent-secret-form {
1237
1277
  grid-template-columns: minmax(0, 1fr) auto;
package/src/vocabulary.ts CHANGED
@@ -87,8 +87,8 @@ export type PersonRole = (typeof PERSON_ROLES)[number];
87
87
 
88
88
  /**
89
89
  * What a member is (ADR-0084): a person, as every member has been, or an agent account, an
90
- * agent that is a member of its own. The rules make no difference between them but one: an
91
- * agent account is never a workspace administrator.
90
+ * agent that is a member of its own. The rules make no difference between them in what a
91
+ * member may do: an agent account is an administrator where it is made one (ADR-0180).
92
92
  */
93
93
  export const PERSON_KINDS = ["person", "agent"] as const;
94
94
 
@@ -240,6 +240,16 @@ export const SECRET_OFFER_STATES = ["waiting", "taken", "left", "lapsed"] as con
240
240
 
241
241
  export type SecretOfferState = (typeof SECRET_OFFER_STATES)[number];
242
242
 
243
+ /**
244
+ * How a note on the pack stands (ADR-0178): `open`, it waits for whoever keeps the pack; `done`,
245
+ * what it asked for is in the pack, was there already, or is before a person as a proposal;
246
+ * `dropped`, nothing follows from it, or its author took it back. A note that is closed says what
247
+ * became of it.
248
+ */
249
+ export const PACK_NOTE_STATES = ["open", "done", "dropped"] as const;
250
+
251
+ export type PackNoteState = (typeof PACK_NOTE_STATES)[number];
252
+
243
253
  /**
244
254
  * How an agent account stands, in one word (ADR-0085): `running`, its runner heard from and the
245
255
  * agent at work or ready for it; `stopped`, by a supervisor, until one starts it again; `refused`,
@@ -1,20 +0,0 @@
1
- /**
2
- * A word of a line printed for a person or an agent to run, spelled so that bash and PowerShell
3
- * both take it whole as it is, expanding nothing in it: as it is where it is plain, else in
4
- * single quotes, inside which neither reads anything. A single quote has no spelling inside
5
- * those that both take (bash ends the word there; PowerShell doubles it, which bash reads as two
6
- * words joined into one), so a word that holds one is in double quotes, inside which neither
7
- * reads anything of a word without `$`, a backtick, a double quote, a backslash or `!`. Nothing
8
- * for a word that holds a single quote and one of those, which no one spelling keeps whole in
9
- * both, nor for one with a character that does not show or makes it look like another.
10
- */
11
- export declare function commandWord(word: string): string | undefined;
12
- /**
13
- * Words as one line printed for a person or an agent to run, after `command`, the command's own
14
- * words, each spelled as `commandWord` spells it; nothing where one of them has no spelling that
15
- * bash and PowerShell both take whole.
16
- */
17
- export declare function commandLine(command: string, words: readonly string[]): string | undefined;
18
- /** Why a line is not printed for a person or an agent to run, said in its place. */
19
- export declare const NO_LINE_TO_RUN = "No line is printed to run: a word of it holds a single quote with a $, a backtick, a double quote, a backslash or a !, or a character that does not show, and no one spelling keeps such a word whole in both bash and PowerShell.";
20
- //# sourceMappingURL=command-words.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"command-words.d.ts","sourceRoot":"","sources":["../../src/cli/command-words.ts"],"names":[],"mappings":"AAaA;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAW5D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAUzF;AAED,oFAAoF;AACpF,eAAO,MAAM,cAAc,uOAC2M,CAAC"}
@@ -1,51 +0,0 @@
1
- import { hasForbiddenCodePoint } from "../text.js";
2
- // The lines the commands print for a person or an agent to run, a path of a pack or a folder
3
- // among their words: spelled so that bash and PowerShell both run them as they are, since an
4
- // agent runs what it is told in whichever of the two it has.
5
- /** A word bash and PowerShell both take as it is: no character either reads as more than a letter, and no `@` first, which PowerShell reads as a variable spread. */
6
- const PLAIN_WORD = /^[\w./+:=-][\w./@+:=-]*$/;
7
- /** A single quote, as PowerShell reads one: its curly forms close a quoted word too. */
8
- const SINGLE_QUOTE = /['\u2018-\u201b]/;
9
- /** What either shell reads inside double quotes: `$`, a backtick, a double quote of any form, a backslash, `!`. */
10
- const READ_IN_DOUBLE_QUOTES = /[$`"\u201c-\u201e\\!]/;
11
- /**
12
- * A word of a line printed for a person or an agent to run, spelled so that bash and PowerShell
13
- * both take it whole as it is, expanding nothing in it: as it is where it is plain, else in
14
- * single quotes, inside which neither reads anything. A single quote has no spelling inside
15
- * those that both take (bash ends the word there; PowerShell doubles it, which bash reads as two
16
- * words joined into one), so a word that holds one is in double quotes, inside which neither
17
- * reads anything of a word without `$`, a backtick, a double quote, a backslash or `!`. Nothing
18
- * for a word that holds a single quote and one of those, which no one spelling keeps whole in
19
- * both, nor for one with a character that does not show or makes it look like another.
20
- */
21
- export function commandWord(word) {
22
- if (word.length === 0 || hasForbiddenCodePoint(word)) {
23
- return undefined;
24
- }
25
- if (PLAIN_WORD.test(word)) {
26
- return word;
27
- }
28
- if (!SINGLE_QUOTE.test(word)) {
29
- return `'${word}'`;
30
- }
31
- return READ_IN_DOUBLE_QUOTES.test(word) ? undefined : `"${word}"`;
32
- }
33
- /**
34
- * Words as one line printed for a person or an agent to run, after `command`, the command's own
35
- * words, each spelled as `commandWord` spells it; nothing where one of them has no spelling that
36
- * bash and PowerShell both take whole.
37
- */
38
- export function commandLine(command, words) {
39
- const spelled = [];
40
- for (const word of words) {
41
- const one = commandWord(word);
42
- if (one === undefined) {
43
- return undefined;
44
- }
45
- spelled.push(one);
46
- }
47
- return [command, ...spelled].join(" ");
48
- }
49
- /** Why a line is not printed for a person or an agent to run, said in its place. */
50
- export const NO_LINE_TO_RUN = "No line is printed to run: a word of it holds a single quote with a $, a backtick, a double quote, a backslash or a !, or a character that does not show, and no one spelling keeps such a word whole in both bash and PowerShell.";
51
- //# sourceMappingURL=command-words.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"command-words.js","sourceRoot":"","sources":["../../src/cli/command-words.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,6FAA6F;AAC7F,6FAA6F;AAC7F,6DAA6D;AAE7D,qKAAqK;AACrK,MAAM,UAAU,GAAG,0BAA0B,CAAC;AAC9C,wFAAwF;AACxF,MAAM,YAAY,GAAG,kBAAkB,CAAC;AACxC,mHAAmH;AACnH,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAEtD;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC;QACrD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAI,IAAI,GAAG,CAAC;IACrB,CAAC;IACD,OAAO,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC;AACpE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,KAAwB;IACnE,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC;AAED,oFAAoF;AACpF,MAAM,CAAC,MAAM,cAAc,GACzB,oOAAoO,CAAC"}
@@ -1,56 +0,0 @@
1
- import { hasForbiddenCodePoint } from "../text.js";
2
-
3
- // The lines the commands print for a person or an agent to run, a path of a pack or a folder
4
- // among their words: spelled so that bash and PowerShell both run them as they are, since an
5
- // agent runs what it is told in whichever of the two it has.
6
-
7
- /** A word bash and PowerShell both take as it is: no character either reads as more than a letter, and no `@` first, which PowerShell reads as a variable spread. */
8
- const PLAIN_WORD = /^[\w./+:=-][\w./@+:=-]*$/;
9
- /** A single quote, as PowerShell reads one: its curly forms close a quoted word too. */
10
- const SINGLE_QUOTE = /['\u2018-\u201b]/;
11
- /** What either shell reads inside double quotes: `$`, a backtick, a double quote of any form, a backslash, `!`. */
12
- const READ_IN_DOUBLE_QUOTES = /[$`"\u201c-\u201e\\!]/;
13
-
14
- /**
15
- * A word of a line printed for a person or an agent to run, spelled so that bash and PowerShell
16
- * both take it whole as it is, expanding nothing in it: as it is where it is plain, else in
17
- * single quotes, inside which neither reads anything. A single quote has no spelling inside
18
- * those that both take (bash ends the word there; PowerShell doubles it, which bash reads as two
19
- * words joined into one), so a word that holds one is in double quotes, inside which neither
20
- * reads anything of a word without `$`, a backtick, a double quote, a backslash or `!`. Nothing
21
- * for a word that holds a single quote and one of those, which no one spelling keeps whole in
22
- * both, nor for one with a character that does not show or makes it look like another.
23
- */
24
- export function commandWord(word: string): string | undefined {
25
- if (word.length === 0 || hasForbiddenCodePoint(word)) {
26
- return undefined;
27
- }
28
- if (PLAIN_WORD.test(word)) {
29
- return word;
30
- }
31
- if (!SINGLE_QUOTE.test(word)) {
32
- return `'${word}'`;
33
- }
34
- return READ_IN_DOUBLE_QUOTES.test(word) ? undefined : `"${word}"`;
35
- }
36
-
37
- /**
38
- * Words as one line printed for a person or an agent to run, after `command`, the command's own
39
- * words, each spelled as `commandWord` spells it; nothing where one of them has no spelling that
40
- * bash and PowerShell both take whole.
41
- */
42
- export function commandLine(command: string, words: readonly string[]): string | undefined {
43
- const spelled: string[] = [];
44
- for (const word of words) {
45
- const one = commandWord(word);
46
- if (one === undefined) {
47
- return undefined;
48
- }
49
- spelled.push(one);
50
- }
51
- return [command, ...spelled].join(" ");
52
- }
53
-
54
- /** Why a line is not printed for a person or an agent to run, said in its place. */
55
- export const NO_LINE_TO_RUN =
56
- "No line is printed to run: a word of it holds a single quote with a $, a backtick, a double quote, a backslash or a !, or a character that does not show, and no one spelling keeps such a word whole in both bash and PowerShell.";