@skillcdn/console 0.5.0 → 0.5.1

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 (345) hide show
  1. package/README.md +68 -11
  2. package/SKILLCDN.md +3 -3
  3. package/dist/agent-page.d.ts.map +1 -1
  4. package/dist/agent-page.js +3 -2
  5. package/dist/agent-page.js.map +1 -1
  6. package/dist/api.d.ts +7 -6
  7. package/dist/api.d.ts.map +1 -1
  8. package/dist/api.js +6 -5
  9. package/dist/api.js.map +1 -1
  10. package/dist/charts.d.ts +103 -0
  11. package/dist/charts.d.ts.map +1 -0
  12. package/dist/charts.js +182 -0
  13. package/dist/charts.js.map +1 -0
  14. package/dist/cli/cli.d.ts +26 -2
  15. package/dist/cli/cli.d.ts.map +1 -1
  16. package/dist/cli/cli.js +1304 -383
  17. package/dist/cli/cli.js.map +1 -1
  18. package/dist/cli/command-words.d.ts +20 -0
  19. package/dist/cli/command-words.d.ts.map +1 -0
  20. package/dist/cli/command-words.js +51 -0
  21. package/dist/cli/command-words.js.map +1 -0
  22. package/dist/cli/credentials.d.ts +54 -5
  23. package/dist/cli/credentials.d.ts.map +1 -1
  24. package/dist/cli/credentials.js +126 -20
  25. package/dist/cli/credentials.js.map +1 -1
  26. package/dist/cli/directory.d.ts +19 -4
  27. package/dist/cli/directory.d.ts.map +1 -1
  28. package/dist/cli/directory.js +16 -8
  29. package/dist/cli/directory.js.map +1 -1
  30. package/dist/cli/format.d.ts +65 -8
  31. package/dist/cli/format.d.ts.map +1 -1
  32. package/dist/cli/format.js +242 -37
  33. package/dist/cli/format.js.map +1 -1
  34. package/dist/cli/help.d.ts +13 -4
  35. package/dist/cli/help.d.ts.map +1 -1
  36. package/dist/cli/help.js +92 -54
  37. package/dist/cli/help.js.map +1 -1
  38. package/dist/cli/main.js +76 -2
  39. package/dist/cli/main.js.map +1 -1
  40. package/dist/cli/pack.d.ts +69 -60
  41. package/dist/cli/pack.d.ts.map +1 -1
  42. package/dist/cli/pack.js +241 -270
  43. package/dist/cli/pack.js.map +1 -1
  44. package/dist/cli/plugin-check.d.ts +42 -0
  45. package/dist/cli/plugin-check.d.ts.map +1 -1
  46. package/dist/cli/plugin-check.js +221 -36
  47. package/dist/cli/plugin-check.js.map +1 -1
  48. package/dist/cli/plugin-cli.d.ts +6 -1
  49. package/dist/cli/plugin-cli.d.ts.map +1 -1
  50. package/dist/cli/plugin-cli.js +21 -4
  51. package/dist/cli/plugin-cli.js.map +1 -1
  52. package/dist/cli/plugin-main.js +1 -0
  53. package/dist/cli/plugin-main.js.map +1 -1
  54. package/dist/cli/serve.d.ts +33 -1
  55. package/dist/cli/serve.d.ts.map +1 -1
  56. package/dist/cli/serve.js +252 -3
  57. package/dist/cli/serve.js.map +1 -1
  58. package/dist/client.d.ts +48 -9
  59. package/dist/client.d.ts.map +1 -1
  60. package/dist/client.js +72 -80
  61. package/dist/client.js.map +1 -1
  62. package/dist/components/agent-page.d.ts +64 -1
  63. package/dist/components/agent-page.d.ts.map +1 -1
  64. package/dist/components/agent-page.js +244 -96
  65. package/dist/components/agent-page.js.map +1 -1
  66. package/dist/components/charts.d.ts +157 -0
  67. package/dist/components/charts.d.ts.map +1 -0
  68. package/dist/components/charts.js +182 -0
  69. package/dist/components/charts.js.map +1 -0
  70. package/dist/components/desk-records.d.ts +102 -0
  71. package/dist/components/desk-records.d.ts.map +1 -0
  72. package/dist/components/desk-records.js +221 -0
  73. package/dist/components/desk-records.js.map +1 -0
  74. package/dist/components/desk.d.ts +85 -0
  75. package/dist/components/desk.d.ts.map +1 -0
  76. package/dist/components/desk.js +135 -0
  77. package/dist/components/desk.js.map +1 -0
  78. package/dist/components/event-feed.d.ts.map +1 -1
  79. package/dist/components/event-feed.js +4 -1
  80. package/dist/components/event-feed.js.map +1 -1
  81. package/dist/components/home.d.ts.map +1 -1
  82. package/dist/components/home.js +4 -2
  83. package/dist/components/home.js.map +1 -1
  84. package/dist/components/plugin-settings.d.ts.map +1 -1
  85. package/dist/components/plugin-settings.js +54 -3
  86. package/dist/components/plugin-settings.js.map +1 -1
  87. package/dist/components/projects.d.ts.map +1 -1
  88. package/dist/components/projects.js +27 -7
  89. package/dist/components/projects.js.map +1 -1
  90. package/dist/components/rules.d.ts +8 -10
  91. package/dist/components/rules.d.ts.map +1 -1
  92. package/dist/components/rules.js +35 -13
  93. package/dist/components/rules.js.map +1 -1
  94. package/dist/components/setup.d.ts +9 -3
  95. package/dist/components/setup.d.ts.map +1 -1
  96. package/dist/components/setup.js +10 -4
  97. package/dist/components/setup.js.map +1 -1
  98. package/dist/console.css +677 -7
  99. package/dist/console.d.ts +5 -0
  100. package/dist/console.d.ts.map +1 -1
  101. package/dist/console.js +14 -8
  102. package/dist/console.js.map +1 -1
  103. package/dist/data.d.ts.map +1 -1
  104. package/dist/data.js +32 -33
  105. package/dist/data.js.map +1 -1
  106. package/dist/desk-page.d.ts +38 -0
  107. package/dist/desk-page.d.ts.map +1 -0
  108. package/dist/desk-page.js +184 -0
  109. package/dist/desk-page.js.map +1 -0
  110. package/dist/desk-records-page.d.ts +18 -0
  111. package/dist/desk-records-page.d.ts.map +1 -0
  112. package/dist/desk-records-page.js +130 -0
  113. package/dist/desk-records-page.js.map +1 -0
  114. package/dist/desk-records.d.ts +247 -0
  115. package/dist/desk-records.d.ts.map +1 -0
  116. package/dist/desk-records.js +543 -0
  117. package/dist/desk-records.js.map +1 -0
  118. package/dist/desk.d.ts +122 -0
  119. package/dist/desk.d.ts.map +1 -0
  120. package/dist/desk.js +211 -0
  121. package/dist/desk.js.map +1 -0
  122. package/dist/feed-stream.d.ts +39 -0
  123. package/dist/feed-stream.d.ts.map +1 -0
  124. package/dist/feed-stream.js +117 -0
  125. package/dist/feed-stream.js.map +1 -0
  126. package/dist/home-tiles.d.ts +10 -3
  127. package/dist/home-tiles.d.ts.map +1 -1
  128. package/dist/home-tiles.js +54 -31
  129. package/dist/home-tiles.js.map +1 -1
  130. package/dist/i18n/en.d.ts +180 -5
  131. package/dist/i18n/en.d.ts.map +1 -1
  132. package/dist/i18n/en.js +184 -7
  133. package/dist/i18n/en.js.map +1 -1
  134. package/dist/i18n/ko.d.ts.map +1 -1
  135. package/dist/i18n/ko.js +169 -6
  136. package/dist/i18n/ko.js.map +1 -1
  137. package/dist/index.d.ts +8 -0
  138. package/dist/index.d.ts.map +1 -1
  139. package/dist/index.js +8 -0
  140. package/dist/index.js.map +1 -1
  141. package/dist/limits.d.ts +11 -0
  142. package/dist/limits.d.ts.map +1 -1
  143. package/dist/limits.js +11 -0
  144. package/dist/limits.js.map +1 -1
  145. package/dist/onboarding.d.ts +6 -0
  146. package/dist/onboarding.d.ts.map +1 -1
  147. package/dist/onboarding.js +3 -3
  148. package/dist/onboarding.js.map +1 -1
  149. package/dist/plugin/context.d.ts +42 -11
  150. package/dist/plugin/context.d.ts.map +1 -1
  151. package/dist/plugin/limits.d.ts +2 -0
  152. package/dist/plugin/limits.d.ts.map +1 -1
  153. package/dist/plugin/limits.js +2 -0
  154. package/dist/plugin/limits.js.map +1 -1
  155. package/dist/plugin/manifest.d.ts +13 -0
  156. package/dist/plugin/manifest.d.ts.map +1 -1
  157. package/dist/plugin/manifest.js +30 -3
  158. package/dist/plugin/manifest.js.map +1 -1
  159. package/dist/plugin/rest-schemas.d.ts +55 -0
  160. package/dist/plugin/rest-schemas.d.ts.map +1 -1
  161. package/dist/plugin/rest-schemas.js +37 -0
  162. package/dist/plugin/rest-schemas.js.map +1 -1
  163. package/dist/plugin/sandbox.d.ts.map +1 -1
  164. package/dist/plugin/sandbox.js +4 -1
  165. package/dist/plugin/sandbox.js.map +1 -1
  166. package/dist/plugin/testing.d.ts +6 -2
  167. package/dist/plugin/testing.d.ts.map +1 -1
  168. package/dist/plugin/testing.js +52 -10
  169. package/dist/plugin/testing.js.map +1 -1
  170. package/dist/plugin.d.ts +1 -1
  171. package/dist/plugin.d.ts.map +1 -1
  172. package/dist/plugin.js +1 -1
  173. package/dist/plugin.js.map +1 -1
  174. package/dist/records.d.ts +283 -0
  175. package/dist/records.d.ts.map +1 -0
  176. package/dist/records.js +543 -0
  177. package/dist/records.js.map +1 -0
  178. package/dist/routes.d.ts +3 -1
  179. package/dist/routes.d.ts.map +1 -1
  180. package/dist/routes.js +3 -1
  181. package/dist/routes.js.map +1 -1
  182. package/dist/rules.d.ts +30 -11
  183. package/dist/rules.d.ts.map +1 -1
  184. package/dist/rules.js +98 -45
  185. package/dist/rules.js.map +1 -1
  186. package/dist/runner/acp.d.ts +1 -1
  187. package/dist/runner/acp.d.ts.map +1 -1
  188. package/dist/runner/acp.js +31 -20
  189. package/dist/runner/acp.js.map +1 -1
  190. package/dist/runner/claude.d.ts +1 -1
  191. package/dist/runner/claude.d.ts.map +1 -1
  192. package/dist/runner/claude.js +85 -15
  193. package/dist/runner/claude.js.map +1 -1
  194. package/dist/runner/codex.d.ts +1 -1
  195. package/dist/runner/codex.d.ts.map +1 -1
  196. package/dist/runner/codex.js +19 -16
  197. package/dist/runner/codex.js.map +1 -1
  198. package/dist/runner/desk.d.ts +43 -2
  199. package/dist/runner/desk.d.ts.map +1 -1
  200. package/dist/runner/desk.js +166 -10
  201. package/dist/runner/desk.js.map +1 -1
  202. package/dist/runner/process.d.ts.map +1 -1
  203. package/dist/runner/process.js +11 -4
  204. package/dist/runner/process.js.map +1 -1
  205. package/dist/runner/redact.d.ts +39 -4
  206. package/dist/runner/redact.d.ts.map +1 -1
  207. package/dist/runner/redact.js +81 -5
  208. package/dist/runner/redact.js.map +1 -1
  209. package/dist/runner/runner.d.ts +15 -1
  210. package/dist/runner/runner.d.ts.map +1 -1
  211. package/dist/runner/runner.js +231 -33
  212. package/dist/runner/runner.js.map +1 -1
  213. package/dist/runner/task-scheduler.d.ts +20 -0
  214. package/dist/runner/task-scheduler.d.ts.map +1 -1
  215. package/dist/runner/task-scheduler.js +34 -4
  216. package/dist/runner/task-scheduler.js.map +1 -1
  217. package/dist/runner/types.d.ts +36 -1
  218. package/dist/runner/types.d.ts.map +1 -1
  219. package/dist/runner/types.js +17 -0
  220. package/dist/runner/types.js.map +1 -1
  221. package/dist/runner.d.ts +6 -6
  222. package/dist/runner.d.ts.map +1 -1
  223. package/dist/runner.js +5 -5
  224. package/dist/runner.js.map +1 -1
  225. package/dist/schemas.d.ts +509 -5
  226. package/dist/schemas.d.ts.map +1 -1
  227. package/dist/schemas.js +76 -16
  228. package/dist/schemas.js.map +1 -1
  229. package/dist/services.d.ts +22 -5
  230. package/dist/services.d.ts.map +1 -1
  231. package/dist/services.js +35 -15
  232. package/dist/services.js.map +1 -1
  233. package/dist/setup-guide.d.ts +3 -1
  234. package/dist/setup-guide.d.ts.map +1 -1
  235. package/dist/setup-guide.js +7 -4
  236. package/dist/setup-guide.js.map +1 -1
  237. package/dist/vocabulary.d.ts +14 -3
  238. package/dist/vocabulary.d.ts.map +1 -1
  239. package/dist/vocabulary.js +13 -3
  240. package/dist/vocabulary.js.map +1 -1
  241. package/docs/specs/cli.md +64 -38
  242. package/docs/specs/plugins.md +27 -20
  243. package/docs/specs/records.md +113 -0
  244. package/docs/specs/rest.md +20 -13
  245. package/docs/specs/runner.md +23 -17
  246. package/package.json +7 -2
  247. package/skills/building-a-console/SKILL.md +4 -4
  248. package/skills/building-a-plugin/SKILL.md +6 -6
  249. package/skills/deploying-a-console/SKILL.md +4 -4
  250. package/skills/deploying-a-console/references/resources.md +41 -4
  251. package/skills/deploying-a-console/references/running-it-again.md +3 -2
  252. package/skills/keeping-a-desk/SKILL.md +133 -0
  253. package/skills/keeping-a-desk/collections.md +96 -0
  254. package/skills/planning-the-board/SKILL.md +14 -18
  255. package/skills/planning-the-board/references/a-task.md +2 -2
  256. package/skills/planning-the-board/references/project-rules.md +13 -14
  257. package/skills/planning-the-board/references/setting-up.md +15 -13
  258. package/skills/running-an-agent/SKILL.md +10 -9
  259. package/skills/working-the-board/SKILL.md +62 -44
  260. package/skills/working-the-board/references/terms.md +9 -5
  261. package/skills/working-the-board/references/the-pack.md +12 -10
  262. package/skills/working-the-board/references/the-sentence.md +2 -2
  263. package/src/agent-page.tsx +3 -1
  264. package/src/api.ts +77 -2
  265. package/src/charts.ts +250 -0
  266. package/src/cli/cli.ts +1698 -476
  267. package/src/cli/command-words.ts +56 -0
  268. package/src/cli/credentials.ts +181 -20
  269. package/src/cli/directory.ts +28 -10
  270. package/src/cli/format.ts +301 -46
  271. package/src/cli/help.ts +102 -54
  272. package/src/cli/main.ts +72 -2
  273. package/src/cli/pack.ts +333 -372
  274. package/src/cli/plugin-check.ts +275 -34
  275. package/src/cli/plugin-cli.ts +28 -4
  276. package/src/cli/plugin-main.ts +1 -0
  277. package/src/cli/serve.ts +295 -2
  278. package/src/client.ts +192 -177
  279. package/src/components/agent-page.tsx +489 -243
  280. package/src/components/charts.tsx +680 -0
  281. package/src/components/desk-records.tsx +724 -0
  282. package/src/components/desk.tsx +471 -0
  283. package/src/components/event-feed.tsx +5 -1
  284. package/src/components/home.tsx +12 -0
  285. package/src/components/plugin-settings.tsx +171 -12
  286. package/src/components/projects.tsx +29 -12
  287. package/src/components/rules.tsx +94 -34
  288. package/src/components/setup.tsx +18 -3
  289. package/src/console.tsx +17 -9
  290. package/src/data.ts +37 -34
  291. package/src/desk-page.tsx +332 -0
  292. package/src/desk-records-page.tsx +256 -0
  293. package/src/desk-records.ts +808 -0
  294. package/src/desk.ts +329 -0
  295. package/src/feed-stream.ts +144 -0
  296. package/src/home-tiles.ts +55 -35
  297. package/src/i18n/en.ts +196 -9
  298. package/src/i18n/ko.ts +178 -8
  299. package/src/index.ts +118 -0
  300. package/src/limits.ts +11 -0
  301. package/src/onboarding.ts +12 -4
  302. package/src/plugin/context.ts +55 -12
  303. package/src/plugin/limits.ts +2 -0
  304. package/src/plugin/manifest.ts +38 -2
  305. package/src/plugin/rest-schemas.ts +41 -0
  306. package/src/plugin/sandbox.ts +4 -1
  307. package/src/plugin/testing.ts +63 -12
  308. package/src/plugin.ts +2 -0
  309. package/src/records.ts +702 -0
  310. package/src/routes.ts +3 -1
  311. package/src/rules.ts +108 -47
  312. package/src/runner/acp.ts +47 -29
  313. package/src/runner/claude.ts +113 -23
  314. package/src/runner/codex.ts +35 -25
  315. package/src/runner/desk.ts +198 -12
  316. package/src/runner/process.ts +11 -4
  317. package/src/runner/redact.ts +92 -6
  318. package/src/runner/runner.ts +275 -34
  319. package/src/runner/task-scheduler.ts +36 -4
  320. package/src/runner/types.ts +47 -1
  321. package/src/runner.ts +27 -2
  322. package/src/schemas.ts +83 -15
  323. package/src/services.ts +49 -14
  324. package/src/setup-guide.ts +6 -2
  325. package/src/styles/README.md +11 -1
  326. package/src/styles/console.css +9 -0
  327. package/src/styles/pages/desk.css +126 -0
  328. package/src/styles/pages/documents.css +5 -0
  329. package/src/styles/parts/bars.css +80 -0
  330. package/src/styles/parts/chart.css +173 -0
  331. package/src/styles/parts/figures.css +65 -0
  332. package/src/styles/parts/legend.css +48 -0
  333. package/src/styles/parts/series.css +32 -0
  334. package/src/styles/parts/share.css +25 -0
  335. package/src/styles/parts/spark.css +23 -0
  336. package/src/styles/parts/stat.css +69 -0
  337. package/src/styles/tokens.css +13 -7
  338. package/src/vocabulary.ts +16 -3
  339. package/template/desk-web/README.md +8 -0
  340. package/template/desk-web/index.html +13 -0
  341. package/template/desk-web/package.json +25 -0
  342. package/template/desk-web/src/main.tsx +24 -0
  343. package/template/desk-web/src/page.tsx +51 -0
  344. package/template/desk-web/tsconfig.json +16 -0
  345. package/template/desk-web/vite.config.ts +15 -0
@@ -0,0 +1,56 @@
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.";
@@ -34,10 +34,37 @@ export interface Login {
34
34
  readonly timeZone?: string | undefined;
35
35
  }
36
36
 
37
+ /**
38
+ * A connection begun and not yet approved (ADR-0129): what a later `login` needs to go on
39
+ * waiting for it, kept for the few minutes its code lasts where the call that began it ended
40
+ * before a person approved. Its secret is good for nothing until a person signed in at the
41
+ * console approves the code, and is kept as a token is: here, and never printed.
42
+ */
43
+ export interface PendingConnection {
44
+ /** The origin of the console the connection was begun at. */
45
+ readonly url: string;
46
+ /** What the command claims the token with, once a person approved. */
47
+ readonly secret: string;
48
+ /** The code the person checks on the page, to say again. */
49
+ readonly code: string;
50
+ /** The page the person opens to approve. */
51
+ readonly page: string;
52
+ /** When the code runs out, as the console said it. */
53
+ readonly expiresAt: string;
54
+ /** How many seconds the console asked for between two claims. */
55
+ readonly interval: number;
56
+ /** Whether the command asked to be the account itself (ADR-0084). */
57
+ readonly self?: boolean | undefined;
58
+ /** Whether the login is to be the default console here. */
59
+ readonly default?: boolean | undefined;
60
+ }
61
+
37
62
  /** Everything the command keeps: the logins, and the console a directory that names none works at. */
38
63
  export interface Credentials {
39
64
  readonly default: string | undefined;
40
65
  readonly logins: readonly Login[];
66
+ /** The connections begun and waiting for a person, one a console at most (ADR-0129); left out when none is. */
67
+ readonly pending?: readonly PendingConnection[] | undefined;
41
68
  }
42
69
 
43
70
  export const EMPTY_CREDENTIALS: Credentials = { default: undefined, logins: [] };
@@ -60,14 +87,16 @@ export interface CredentialStore {
60
87
  }
61
88
 
62
89
  export class CredentialsError extends Error {
63
- readonly code: "credentials.malformed" | "credentials.too_large";
90
+ readonly code: "credentials.malformed" | "credentials.too_large" | "credentials.unfit";
64
91
  readonly path: string;
65
92
 
66
93
  constructor(code: CredentialsError["code"], path: string) {
67
94
  super(
68
95
  code === "credentials.too_large"
69
96
  ? `The credentials file ${path} is larger than the command reads.`
70
- : `The credentials file ${path} could not be read as one.`,
97
+ : code === "credentials.unfit"
98
+ ? "What was to be kept is not what the command reads back, so nothing was written."
99
+ : `The credentials file ${path} could not be read as one.`,
71
100
  );
72
101
  this.name = "CredentialsError";
73
102
  this.code = code;
@@ -84,10 +113,23 @@ const loginSchema = z.object({
84
113
  self: z.optional(z.boolean()),
85
114
  timeZone: z.optional(z.string().check(z.minLength(1), z.maxLength(64))),
86
115
  });
116
+ const pendingSchema = z.object({
117
+ url: z.string().check(z.minLength(1), z.maxLength(2048)),
118
+ secret: z.string().check(z.minLength(1), z.maxLength(1024)),
119
+ code: z.string().check(z.minLength(1), z.maxLength(64)),
120
+ page: z.string().check(z.minLength(1), z.maxLength(2048)),
121
+ expiresAt: z.string().check(z.minLength(1), z.maxLength(40)),
122
+ interval: z.number().check(z.gte(1), z.lte(600)),
123
+ self: z.optional(z.boolean()),
124
+ default: z.optional(z.boolean()),
125
+ });
87
126
  const fileSchema = z.object({
88
127
  version: z.literal(2),
89
128
  default: z.optional(z.string().check(z.minLength(1), z.maxLength(2048))),
90
129
  logins: z.array(loginSchema).check(z.maxLength(MAX_LOGINS)),
130
+ // Left out by a command from before ADR-0129, which reads the file without it and writes it
131
+ // back without it: a connection that waited is begun again.
132
+ pending: z.optional(z.array(pendingSchema).check(z.maxLength(MAX_LOGINS))),
91
133
  });
92
134
  /** The file as the command kept it before 2026-10: one console, one token. */
93
135
  const firstFileSchema = z.object({
@@ -95,6 +137,51 @@ const firstFileSchema = z.object({
95
137
  token: z.string().check(z.minLength(1)),
96
138
  });
97
139
 
140
+ /** The file as it is written: what `save` writes, and `load` reads back with `fileSchema`. */
141
+ function fileOf(credentials: Credentials) {
142
+ return {
143
+ version: 2,
144
+ default: credentials.default,
145
+ logins: credentials.logins.map((login) => ({
146
+ url: login.url,
147
+ account: login.account,
148
+ token: login.token,
149
+ agent: login.agent,
150
+ since: login.since,
151
+ // What a login is read back with: whether the command is the account itself, and the
152
+ // zone the workspace keeps its times in.
153
+ ...(login.self === true ? { self: true } : {}),
154
+ ...(login.timeZone === undefined ? {} : { timeZone: login.timeZone }),
155
+ })),
156
+ // The connections that wait for a person (ADR-0129), each with its secret, in this file
157
+ // and under its mode as a token is.
158
+ ...(credentials.pending === undefined || credentials.pending.length === 0
159
+ ? {}
160
+ : {
161
+ pending: credentials.pending.map((waiting) => ({
162
+ url: waiting.url,
163
+ secret: waiting.secret,
164
+ code: waiting.code,
165
+ page: waiting.page,
166
+ expiresAt: waiting.expiresAt,
167
+ interval: waiting.interval,
168
+ ...(waiting.self === true ? { self: true } : {}),
169
+ ...(waiting.default === true ? { default: true } : {}),
170
+ })),
171
+ }),
172
+ };
173
+ }
174
+
175
+ /**
176
+ * Whether what is to be kept reads back as the file's own shape. What a console answers comes
177
+ * to rest here, a code, a token, a name, and anything at an address may answer to nobody: a
178
+ * file written beyond its own bounds is one the command stops on from then on, at every
179
+ * console. So it is asked before anything is written, and what does not fit is not kept.
180
+ */
181
+ export function fitsFile(credentials: Credentials): boolean {
182
+ return fileSchema.safeParse(fileOf(credentials)).success;
183
+ }
184
+
98
185
  /** What a file says, in the current shape; one in the first shape reads as one login, the default. Nothing for anything else. */
99
186
  export function parseCredentials(json: unknown): Credentials | undefined {
100
187
  const current = fileSchema.safeParse(json);
@@ -110,6 +197,20 @@ export function parseCredentials(json: unknown): Credentials | undefined {
110
197
  ...(login.self === true ? { self: true } : {}),
111
198
  ...(login.timeZone === undefined ? {} : { timeZone: login.timeZone }),
112
199
  })),
200
+ ...(current.data.pending === undefined || current.data.pending.length === 0
201
+ ? {}
202
+ : {
203
+ pending: current.data.pending.map((waiting) => ({
204
+ url: waiting.url,
205
+ secret: waiting.secret,
206
+ code: waiting.code,
207
+ page: waiting.page,
208
+ expiresAt: waiting.expiresAt,
209
+ interval: waiting.interval,
210
+ ...(waiting.self === true ? { self: true } : {}),
211
+ ...(waiting.default === true ? { default: true } : {}),
212
+ })),
213
+ }),
113
214
  };
114
215
  }
115
216
  const first = firstFileSchema.safeParse(json);
@@ -142,11 +243,13 @@ export function consolesOf(credentials: Credentials): readonly string[] {
142
243
 
143
244
  /**
144
245
  * With a login kept: in place of the one at the same console for the same account, else added.
145
- * The first login kept is the default console, and one kept as the default is.
246
+ * The first login kept is the default console, and one kept as the default is. The connections
247
+ * that wait are carried while their codes last at `now`.
146
248
  */
147
249
  export function withLogin(
148
250
  credentials: Credentials,
149
251
  login: Login,
252
+ now: number,
150
253
  options: { readonly default?: boolean | undefined } = {},
151
254
  ): Credentials {
152
255
  const rest = credentials.logins.filter(
@@ -156,14 +259,81 @@ export function withLogin(
156
259
  return {
157
260
  default: options.default === true ? login.url : (credentials.default ?? first),
158
261
  logins: [...rest, login],
262
+ ...carried(credentials.pending, now),
159
263
  };
160
264
  }
161
265
 
266
+ /**
267
+ * The connections that wait, as a field of what is kept anew: those whose codes still last, so
268
+ * that a secret rests here no longer than its code once anything is kept again (ADR-0129), and
269
+ * the field left out when none does.
270
+ */
271
+ function carried(
272
+ pending: readonly PendingConnection[] | undefined,
273
+ now: number,
274
+ ): {
275
+ readonly pending?: readonly PendingConnection[];
276
+ } {
277
+ const lasting = (pending ?? []).filter((waiting) => lasts(waiting, now));
278
+ return lasting.length === 0 ? {} : { pending: lasting };
279
+ }
280
+
281
+ /** Whether a connection's code still lasts at a moment; one whose end does not read as a moment does not. */
282
+ export function lasts(pending: PendingConnection, now: number): boolean {
283
+ const end = Date.parse(pending.expiresAt);
284
+ return Number.isFinite(end) && end > now;
285
+ }
286
+
287
+ /** The connection that waits at a console, whether or not its code still lasts. */
288
+ export function pendingAt(
289
+ credentials: Credentials | undefined,
290
+ url: string,
291
+ ): PendingConnection | undefined {
292
+ return credentials?.pending?.find((waiting) => waiting.url === url);
293
+ }
294
+
295
+ /**
296
+ * With a connection that waits: in place of the one at the same console, and without any whose
297
+ * code ran out, so that a secret rests here no longer than its code lasts once anything is kept
298
+ * again (ADR-0129).
299
+ */
300
+ export function withPending(
301
+ credentials: Credentials,
302
+ pending: PendingConnection,
303
+ now: number,
304
+ ): Credentials {
305
+ const rest = (credentials.pending ?? []).filter(
306
+ (waiting) => waiting.url !== pending.url && lasts(waiting, now),
307
+ );
308
+ return {
309
+ default: credentials.default,
310
+ logins: credentials.logins,
311
+ pending: [...rest, pending],
312
+ };
313
+ }
314
+
315
+ /** Without the connection that waits at a console, and without any whose code ran out. */
316
+ export function withoutPending(credentials: Credentials, url: string, now: number): Credentials {
317
+ const rest = (credentials.pending ?? []).filter((waiting) => waiting.url !== url);
318
+ return { default: credentials.default, logins: credentials.logins, ...carried(rest, now) };
319
+ }
320
+
321
+ /** Whether nothing is kept: no login, and no connection that waits. */
322
+ export function keepsNothing(credentials: Credentials): boolean {
323
+ return credentials.logins.length === 0 && (credentials.pending ?? []).length === 0;
324
+ }
325
+
162
326
  /**
163
327
  * Without the login at a console, for one account or for every account there. The default
164
- * stays while a login at it remains; else it moves to the one console left, or to none.
328
+ * stays while a login at it remains; else it moves to the one console left, or to none. The
329
+ * connections that wait are carried while their codes last at `now`.
165
330
  */
166
- export function withoutLogin(credentials: Credentials, url: string, account?: string): Credentials {
331
+ export function withoutLogin(
332
+ credentials: Credentials,
333
+ url: string,
334
+ now: number,
335
+ account?: string,
336
+ ): Credentials {
167
337
  const logins = credentials.logins.filter(
168
338
  (kept) => !(kept.url === url && (account === undefined || kept.account === account)),
169
339
  );
@@ -176,6 +346,7 @@ export function withoutLogin(credentials: Credentials, url: string, account?: st
176
346
  ? credentials.default
177
347
  : fallback,
178
348
  logins,
349
+ ...carried(credentials.pending, now),
179
350
  };
180
351
  }
181
352
 
@@ -316,22 +487,12 @@ export function createFileStore(directory: string): CredentialStore {
316
487
  return parsed;
317
488
  },
318
489
  async save(credentials) {
490
+ // Never written in a shape `load` refuses: the file would stop every command after this.
491
+ if (!fitsFile(credentials)) {
492
+ throw new CredentialsError("credentials.unfit", path);
493
+ }
319
494
  await mkdir(directory, { recursive: true, mode: 0o700 });
320
- const file = {
321
- version: 2,
322
- default: credentials.default,
323
- logins: credentials.logins.map((login) => ({
324
- url: login.url,
325
- account: login.account,
326
- token: login.token,
327
- agent: login.agent,
328
- since: login.since,
329
- // What a login is read back with: whether the command is the account itself, and the
330
- // zone the workspace keeps its times in.
331
- ...(login.self === true ? { self: true } : {}),
332
- ...(login.timeZone === undefined ? {} : { timeZone: login.timeZone }),
333
- })),
334
- };
495
+ const file = fileOf(credentials);
335
496
  // Written beside the file and moved over it in one step, so that a command that stops
336
497
  // half-way leaves the file as it was, whole.
337
498
  const draft = `${path}.${process.pid}.tmp`;
@@ -6,11 +6,12 @@ import * as z from "zod/mini";
6
6
  // it or in a directory above it, as `.nvmrc` and its kind are found. Written by `console use`,
7
7
  // and meant to be committed in a private repository, so that everyone who works in the
8
8
  // checkout, and every agent they run in it, is in the same project without saying so; left out
9
- // of a public one, since it may name the organization's console. It names the project, and
10
- // where the checkout is bound to a console other than the default login, that console and the
11
- // account there (ADR-0027). Never a token, a code or anything secret: the token for the console
12
- // it names is looked up in the credentials the command keeps, and a key this file does not
13
- // know is dropped on reading.
9
+ // of a public one, since it names the organization's console. It names the project and the
10
+ // console, every time `console use` writes it (ADR-0112): a file with the project alone, as it
11
+ // was written before, follows the default login of whichever machine reads it, which is
12
+ // another console's on the next. The account there only where one was asked for (ADR-0027).
13
+ // Never a token, a code or anything secret: the token for the console it names is looked up in
14
+ // the credentials the command keeps, and a key this file does not know is dropped on reading.
14
15
 
15
16
  /** The file's name, in the working directory or one above it. */
16
17
  export const DIRECTORY_FILE = ".skillcdn-console.json";
@@ -19,10 +20,16 @@ export const DIRECTORY_FILE = ".skillcdn-console.json";
19
20
  * The sentence a checkout's agreement carries to send the agents working there to the console:
20
21
  * the one the skill working-the-board keeps (references/the-sentence.md) and this repository's
21
22
  * own agreement carries. `console use` prints it, since nothing tells an agent to look until the
22
- * checkout says so, as `skillcdn use` prints the sentence for a pack.
23
+ * checkout says so, as `skillcdn use` prints the sentence for a pack. It says to run
24
+ * `console whoami` before the first step, where it once stated the two conditions alone: a
25
+ * condition nobody tested is passed over, and an agent in a checkout bound to a project its
26
+ * console did not have began the work with no task. The command changes nothing on the board,
27
+ * and is refused where the binding is wrong (ADR-0112), which is what stops the work. It ends
28
+ * on what `whoami` answers, which names the rules and the skill to read: it once ended on the
29
+ * command's help, and an agent that had the skill read the whole help as a third thing.
23
30
  */
24
31
  export const THE_SENTENCE =
25
- "**Bound to a console?** When `.skillcdn-console.json` is in this checkout, or `console whoami` names a project, work the task through that SkillCDN console (`console help` says how).";
32
+ "**Bound to a console?** Before the first step, run `console whoami`: when it names a project, or `.skillcdn-console.json` is in this checkout, work the task through that SkillCDN console (its answer says how).";
26
33
 
27
34
  /** How large the file may be before it is not read: a few names, never more. */
28
35
  const MAX_FILE_CHARS = 16 * 1024;
@@ -30,15 +37,25 @@ const MAX_FILE_CHARS = 16 * 1024;
30
37
  export interface DirectorySettings {
31
38
  /** The key of the project the directory's work belongs to. */
32
39
  readonly project: string;
33
- /** The origin of the console the directory is bound to; the default login when left out. */
40
+ /** The origin of the console the directory is bound to; the default login when left out, as a file from before ADR-0112 leaves it. */
34
41
  readonly url?: string | undefined;
35
42
  /** The account at that console, where several are signed in to it. */
36
43
  readonly account?: string | undefined;
37
44
  }
38
45
 
46
+ /** What a directory says, with where it was said: the working directory, or one above it. */
47
+ export interface DirectoryFound extends DirectorySettings {
48
+ /**
49
+ * The directory whose file said so, for `console whoami` to name (ADR-0112): a checkout that
50
+ * works in the wrong project is mended where the key came from, and a file of a folder above
51
+ * the checkout is the one nobody looks for. Left out by a store that keeps no files.
52
+ */
53
+ readonly directory?: string | undefined;
54
+ }
55
+
39
56
  export interface DirectoryStore {
40
57
  /** The settings of the working directory, or of the nearest directory above it that has them. */
41
- load(): Promise<DirectorySettings | undefined>;
58
+ load(): Promise<DirectoryFound | undefined>;
42
59
  /** Writes the settings into the working directory and answers where. */
43
60
  save(settings: DirectorySettings): Promise<string>;
44
61
  }
@@ -78,7 +95,8 @@ export function createDirectoryStore(cwd: string): DirectoryStore {
78
95
  return undefined;
79
96
  }
80
97
  try {
81
- return parseDirectorySettings(JSON.parse(content));
98
+ const settings = parseDirectorySettings(JSON.parse(content));
99
+ return settings === undefined ? undefined : { ...settings, directory };
82
100
  } catch {
83
101
  return undefined;
84
102
  }