@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
package/src/cli/format.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { createHash } from "node:crypto";
1
2
  import { argUsage } from "../plugin/args.js";
2
3
  import type {
3
4
  RestAgent,
@@ -9,6 +10,8 @@ import type {
9
10
  RestDocument,
10
11
  RestDocumentSummary,
11
12
  RestDocuments,
13
+ RestEvent,
14
+ RestEvents,
12
15
  RestGoal,
13
16
  RestListing,
14
17
  RestMember,
@@ -19,6 +22,7 @@ import type {
19
22
  RestPluginDetail,
20
23
  RestPluginGrant,
21
24
  RestPluginInvocation,
25
+ RestPluginJob,
22
26
  RestPluginOperation,
23
27
  RestPluginRecord,
24
28
  RestPluginRecordPage,
@@ -31,14 +35,17 @@ import type {
31
35
  RestRules,
32
36
  RestRulesPlugin,
33
37
  RestRun,
38
+ RestRunBrief,
34
39
  RestSignal,
35
40
  RestTask,
41
+ RestTaskBrief,
36
42
  RestTeam,
37
43
  RestVersion,
38
44
  RestVersionSummary,
39
45
  RestWork,
40
46
  RestWorkspace,
41
47
  } from "../schemas.js";
48
+ import { reportCountOf } from "../schemas.js";
42
49
 
43
50
  // What the command prints: one line per thing in a list, a few lines for one thing in full.
44
51
  // Plain text, for an agent to read and a person to skim; ids are given, since the commands take
@@ -159,7 +166,16 @@ export function formatAgentLine(agent: RestAgent): string {
159
166
  const standing = [
160
167
  `signs in as ${person.login}`,
161
168
  ...(manager === null ? [] : [`reports to ${calledOf(manager)}`]),
162
- ...(person.invited === true ? ["not signed in yet"] : []),
169
+ ...(person.invited === true
170
+ ? [
171
+ // At a git host, whether the host said which account the login is (ADR-0126).
172
+ agent.firstSignIn === undefined
173
+ ? "not signed in yet"
174
+ : agent.firstSignIn === "account"
175
+ ? "not signed in yet, its account confirmed at the host"
176
+ : "not signed in yet, its account not confirmed",
177
+ ]
178
+ : []),
163
179
  ...(person.status === "active" ? [] : ["deactivated"]),
164
180
  ].join(", ");
165
181
  return `@${person.handle ?? person.login} ${called.join(", ")} (${standing})`;
@@ -318,7 +334,7 @@ export const calledOf = (person: Pick<RestPerson, "login" | "handle">): string =
318
334
  /** The members at work on a task as a line calls them, in the order they came to it. */
319
335
  const logins = (people: readonly RestPerson[]): string => people.map(calledOf).join(", ");
320
336
 
321
- export function formatTaskLine(task: RestTask): string {
337
+ export function formatTaskLine(task: RestTaskBrief): string {
322
338
  const notes = [`owner ${calledOf(task.owner)}`];
323
339
  if (task.workers.length > 0) {
324
340
  notes.push(`workers ${logins(task.workers)}`);
@@ -365,13 +381,16 @@ function scheduleLines(task: RestTask): string[] {
365
381
  export function formatTask(
366
382
  task: RestTask,
367
383
  decisions?: readonly RestDecision[],
368
- runs?: readonly RestRun[],
384
+ runs?: readonly RestRunBrief[],
369
385
  comments?: readonly RestComment[],
386
+ /** The address of the task's page at the console, where the command knows it: what a person is given to open. */
387
+ page?: string,
370
388
  ): string {
371
389
  const lines = [
372
390
  `#${task.number} ${task.title}`,
373
391
  `state: ${task.state} priority: ${task.priority} owner: ${calledOf(task.owner)} workers: ${task.workers.length === 0 ? "nobody" : logins(task.workers)}`,
374
392
  `id: ${task.id}${task.parentId === null ? "" : ` part of: ${task.parentId}`}`,
393
+ ...(page === undefined ? [] : [pageLine(page)]),
375
394
  ...(task.agent == null ? [] : [`written through: ${task.agent}`]),
376
395
  ...scheduleLines(task),
377
396
  ];
@@ -426,8 +445,10 @@ export function formatComment(comment: RestComment): string {
426
445
  return lines.join("\n");
427
446
  }
428
447
 
429
- export function formatRunLine(run: RestRun): string {
430
- const notes = [plural(run.reports.length, "report"), plural(run.artifacts.length, "artifact")];
448
+ export function formatRunLine(run: RestRunBrief): string {
449
+ // A run of a listing comes without its reports, counted (`?brief=true`); a run read whole,
450
+ // or from a console from before the brief form, with them.
451
+ const notes = [plural(reportCountOf(run), "report"), plural(run.artifacts.length, "artifact")];
431
452
  if (run.waitingFor !== null) {
432
453
  notes.push(`waiting for decision ${run.waitingFor}`);
433
454
  }
@@ -473,45 +494,174 @@ export function formatArtifact(
473
494
  return artifact.label === null ? what : `${artifact.label}: ${what}`;
474
495
  }
475
496
 
476
- /** One half of the rules: where it comes from, and the text as it stands. */
477
- function formatRulesHalf(where: "the workspace" | "this project", rules: RestRules): string {
478
- const page = rules.page;
479
- const facts =
480
- page === null
481
- ? undefined
482
- : `v${page.version}, by ${writer(page.updatedBy, page.agent)}; ${moment(page.updatedAt)}`;
483
- if (rules.source === "none" || rules.body === null) {
484
- return `Rules of ${where}: none of its own; the workspace's hold.`;
485
- }
497
+ /** When a part of the rules was written and by whom, where a page says; nothing for the console's own. */
498
+ function rulesFacts(page: RestRules["page"]): string {
499
+ return page === null
500
+ ? ""
501
+ : ` (v${page.version}, by ${writer(page.updatedBy, page.agent)}; ${moment(page.updatedAt)})`;
502
+ }
503
+
504
+ /** A part of the rules that has a text: what it is, who wrote it where someone did, and the text as it stands. */
505
+ const formatRulesPart = (head: string, page: RestRules["page"], body: string): string =>
506
+ `${head}${rulesFacts(page)}:\n\n${body.trimEnd()}`;
507
+
508
+ /**
509
+ * The workspace's rules as a console of before the parts answers them (ADR-0120): whole, the
510
+ * console's own until an administrator writes the organization's in their place, which is
511
+ * what holds on such a console. No command is named for writing them: this one writes what an
512
+ * organization adds, and refuses to on a console that would keep it as the whole.
513
+ */
514
+ function formatRulesWhole(rules: RestRules): string {
486
515
  const head =
487
516
  rules.source === "reference"
488
- ? `Rules of ${where}: the console's own, until an administrator writes the organization's (console rules write --workspace).`
489
- : `Rules of ${where} (${facts ?? "written"}):`;
490
- return `${head}\n\n${rules.body.trimEnd()}`;
517
+ ? "Rules of the workspace: the console's own, until an administrator writes the organization's."
518
+ : `Rules of the workspace${rulesFacts(rules.page) || " (written)"}:`;
519
+ return `${head}\n\n${(rules.body ?? "").trimEnd()}`;
520
+ }
521
+
522
+ /**
523
+ * The parts of the rules as they are printed for whoever reads them (ADR-0120): what the
524
+ * project adds where the command works in one and it adds something, the plugins' lines in the
525
+ * language they are read in, what the organization adds where it adds something, and the
526
+ * console's rules, which always hold.
527
+ */
528
+ function rulesParts(rules: RestProjectRules | RestRules, language: string | null | undefined) {
529
+ const named = "workspace" in rules;
530
+ const workspace = named ? rules.workspace : rules;
531
+ const project = named && rules.project.source !== "none" ? rules.project : undefined;
532
+ const count = rules.plugins?.length ?? 0;
533
+ const added = workspace.added ?? null;
534
+ return {
535
+ /** Whether the command works in a project: its rules were asked for, whether it adds any or not. */
536
+ named,
537
+ workspace,
538
+ /** What the project adds, where it adds something. */
539
+ own: project !== undefined && project.body !== null ? project : undefined,
540
+ plugins:
541
+ rules.plugins === undefined || count === 0
542
+ ? undefined
543
+ : formatRulesPlugins(rules.plugins, language),
544
+ pluginCount: count,
545
+ /** What the organization adds, where it adds something and the console says the parts. */
546
+ added: workspace.own === undefined || added === null ? undefined : added,
547
+ /** The console's rules by themselves; nothing from a console of before, which answers the whole. */
548
+ console: workspace.own,
549
+ };
550
+ }
551
+
552
+ /**
553
+ * The mark of the rules (ADR-0119): the first eight hex characters of a SHA-256 over what they
554
+ * say to whoever reads them: the workspace's text whole, which is the console's rules with
555
+ * what the organization adds (ADR-0120), what the project adds, and the plugins' lines, in the
556
+ * language they are read in. A session that was shown the rules holds their mark, and a later
557
+ * take of that session leaves out the rules the mark stands for; nothing but having been shown
558
+ * them gives it. When they were written and by whom is no part of it: the same rules have the
559
+ * same mark, and a project that adds nothing has the workspace's.
560
+ */
561
+ export function rulesMark(
562
+ rules: RestProjectRules | RestRules,
563
+ language?: string | null | undefined,
564
+ ): string {
565
+ const parts = rulesParts(rules, language);
566
+ return createHash("sha256")
567
+ .update(
568
+ JSON.stringify([
569
+ (parts.workspace.body ?? "").trimEnd(),
570
+ parts.own === undefined ? null : (parts.own.body ?? "").trimEnd(),
571
+ parts.plugins ?? null,
572
+ ]),
573
+ )
574
+ .digest("hex")
575
+ .slice(0, 8);
491
576
  }
492
577
 
578
+ /** How long a text of the rules is, as its first line says it. */
579
+ const charactersOf = (text: string | null): string => `${(text ?? "").trimEnd().length} characters`;
580
+
493
581
  /**
494
- * The rules that hold: the workspace's, and what the project adds when the command works in one;
495
- * then the plugins the console names after them, a line each, where there are any.
582
+ * The rules that hold, under a first line that says what follows (ADR-0119): the mark, which
583
+ * parts there are and how long each is, and how a later take of the session leaves them out.
584
+ * What differs stands first and what always holds last (ADR-0120): what the project adds with
585
+ * the plugins' lines, then what the organization adds, then the console's rules. An agent that
586
+ * had read the long part once cut every later print at its head, and never saw what stood
587
+ * after it; and where they differ it is the earlier part that holds. Who adds nothing is said
588
+ * in a clause of the line, and has no part.
496
589
  */
497
590
  export function formatRules(
498
591
  rules: RestProjectRules | RestRules,
499
592
  language?: string | null | undefined,
500
593
  ): string {
501
- const parts =
502
- "workspace" in rules
503
- ? [
504
- formatRulesHalf("the workspace", rules.workspace),
505
- "",
506
- formatRulesHalf("this project", rules.project),
507
- ]
508
- : [formatRulesHalf("the workspace", rules)];
509
- if (rules.plugins !== undefined && rules.plugins.length > 0) {
510
- parts.push("", formatRulesPlugins(rules.plugins, language));
511
- }
512
- return parts.join("\n");
594
+ const parts = rulesParts(rules, language);
595
+ const mark = rulesMark(rules, language);
596
+ // A console of before answers the workspace's rules whole: they are the last part then.
597
+ const whole = parts.console === undefined;
598
+ const last = whole
599
+ ? `the workspace's (${charactersOf(parts.workspace.body)})`
600
+ : `the console's (${charactersOf(parts.console ?? null)})`;
601
+ const lastFollows = whole
602
+ ? `the workspace's follow (${charactersOf(parts.workspace.body)})`
603
+ : `the console's follow (${charactersOf(parts.console ?? null)})`;
604
+ const plugins = `${parts.pluginCount} plugin${parts.pluginCount === 1 ? "" : "s"}`;
605
+ const HOLDS = "the earlier holding where they differ";
606
+ /** The organization's part and the last, after whatever stood before them. */
607
+ const rest = (first: boolean): string =>
608
+ parts.added === undefined
609
+ ? last
610
+ : `the organization's${first ? " additions first" : ""} (${charactersOf(parts.added.body)}), then ${last}`;
611
+ let follows: string;
612
+ if (parts.own !== undefined) {
613
+ follows = `this project's additions first (${charactersOf(parts.own.body)})${parts.plugins === undefined ? "" : ` with its ${plugins}`}, then ${rest(false)}, ${HOLDS}${whole || parts.added !== undefined ? "" : "; the organization adds nothing"}.`;
614
+ } else {
615
+ const nobody = parts.added === undefined && !whole;
616
+ const lead = parts.named
617
+ ? nobody
618
+ ? "this project and the organization add nothing; "
619
+ : "this project adds nothing; "
620
+ : nobody
621
+ ? "the organization adds nothing; "
622
+ : "";
623
+ const theirs = parts.named ? `its ${plugins}` : `the ${plugins} you may use`;
624
+ const body =
625
+ parts.plugins !== undefined
626
+ ? `${theirs} first, then ${parts.added === undefined ? last : `the organization's additions (${charactersOf(parts.added.body)}), then ${last}, ${HOLDS}`}`
627
+ : parts.added === undefined
628
+ ? parts.named || nobody
629
+ ? lastFollows
630
+ : last
631
+ : `${rest(true)}, ${HOLDS}`;
632
+ follows = `${lead}${body}${parts.named ? "." : "; no project is named here, and a project's additions stand before them where it has some."}`;
633
+ }
634
+ // The mark ends the line bare, so that it is copied as it is.
635
+ const later = parts.named
636
+ ? ` A later take in this session leaves them out: console take <number> --rules ${mark}`
637
+ : "";
638
+ return [
639
+ `Rules ${mark}: ${follows}${later}`,
640
+ ...(parts.own === undefined
641
+ ? []
642
+ : ["", formatRulesPart("What this project adds", parts.own.page, parts.own.body ?? "")]),
643
+ ...(parts.plugins === undefined ? [] : ["", parts.plugins]),
644
+ ...(parts.added === undefined
645
+ ? []
646
+ : ["", formatRulesPart("What this organization adds", parts.added.page, parts.added.body)]),
647
+ "",
648
+ parts.console === undefined
649
+ ? formatRulesWhole(parts.workspace)
650
+ : formatRulesPart("The console's rules, which always hold", null, parts.console),
651
+ ].join("\n");
513
652
  }
514
653
 
654
+ /** What a take says, before the task, where it was told the mark the rules have (ADR-0119): they are left out. */
655
+ export const formatRulesLeftOut = (mark: string): string =>
656
+ `Rules ${mark}: left out, since they stand as this session read them. console rules prints them.`;
657
+
658
+ /**
659
+ * What a take says, before the task, where it was told a mark the rules do not have (ADR-0119):
660
+ * the rules then follow the task whole, as they do without a mark.
661
+ */
662
+ export const formatRulesChanged = (given: string): string =>
663
+ `The rules are not the ones marked ${given}: they changed since, or that mark is of another project's. They follow whole after the task, under the mark they have now.`;
664
+
515
665
  /** How far a goal is, from its tasks: the done, the at work, and the rest, in one phrase. */
516
666
  function progressOf(goal: RestGoal): string {
517
667
  const counts = goal.taskCounts;
@@ -532,7 +682,7 @@ export function formatGoalLine(goal: RestGoal): string {
532
682
  }
533
683
 
534
684
  /** One goal in full; with the tasks that work towards it, when given. */
535
- export function formatGoal(goal: RestGoal, tasks?: readonly RestTask[]): string {
685
+ export function formatGoal(goal: RestGoal, tasks?: readonly RestTaskBrief[]): string {
536
686
  const lines = [
537
687
  `goal ${goal.id}: ${goal.title}`,
538
688
  `state: ${goal.state} category: ${goal.category?.key ?? "none"} starts: ${goal.startsOn ?? "none"} due: ${goal.dueOn ?? "none"} set by: ${calledOf(goal.createdBy)}${through(goal.agent)}`,
@@ -607,9 +757,13 @@ const addressed = (decision: RestDecision): string =>
607
757
  ? ""
608
758
  : `, for ${deciderLogins(decision)}`;
609
759
 
760
+ /**
761
+ * One decision in a line, with when it was asked: a decision that waits holds a run, and whoever
762
+ * is told what is on their plate is told since when each one waits.
763
+ */
610
764
  export function formatDecisionLine(decision: RestDecision): string {
611
765
  const state = decision.answer === null ? "waiting" : `answered ${decision.answer.option}`;
612
- return `${decision.id} ${state} ${decision.question} (asked by ${asker(decision)}${addressed(decision)})`;
766
+ return `${decision.id} ${state} ${decision.question} (asked by ${asker(decision)}${addressed(decision)}, at ${moment(decision.createdAt)})`;
613
767
  }
614
768
 
615
769
  /** The options, one a line; the person's own answer, when they wrote one, is the last and says so. */
@@ -630,7 +784,7 @@ export function formatAnswer(decision: RestDecision): string {
630
784
  }
631
785
  const chosen = decision.options.find((option) => option.id === answer.option);
632
786
  const lines = [
633
- `Answered: ${answer.option}) ${chosen?.label ?? answer.option}${chosen?.own === true ? ", in their own words" : ""}, by ${calledOf(answer.by)}${through(answer.agent)} at ${answer.at}`,
787
+ `Answered: ${answer.option}) ${chosen?.label ?? answer.option}${chosen?.own === true ? ", in their own words" : ""}, by ${calledOf(answer.by)}${through(answer.agent)} at ${moment(answer.at)}`,
634
788
  ];
635
789
  if (answer.note !== null && answer.note.length > 0) {
636
790
  lines.push(`Note: ${answer.note}`);
@@ -638,6 +792,13 @@ export function formatAnswer(decision: RestDecision): string {
638
792
  return lines.join("\n");
639
793
  }
640
794
 
795
+ /**
796
+ * The address of a task's or a decision's page, on a line of its own: what an agent gives a
797
+ * person to open, in place of the console's front page, or of a number a git host would take
798
+ * for an issue of its own.
799
+ */
800
+ export const pageLine = (page: string): string => `page: ${page}`;
801
+
641
802
  /**
642
803
  * One decision in full. A decision reached at its own address (ADR-0068), outside the project the
643
804
  * command works in, names its files with the command that reads them there, by the decision too:
@@ -645,7 +806,11 @@ export function formatAnswer(decision: RestDecision): string {
645
806
  */
646
807
  export function formatDecision(
647
808
  decision: RestDecision,
648
- options: { readonly atItsAddress?: boolean } = {},
809
+ options: {
810
+ readonly atItsAddress?: boolean;
811
+ /** The address of the decision's page at the console, where the command knows it. */
812
+ readonly page?: string | undefined;
813
+ } = {},
649
814
  ): string {
650
815
  const reads = (fileId: string): string =>
651
816
  options.atItsAddress === true
@@ -653,7 +818,8 @@ export function formatDecision(
653
818
  : `console file ${fileId}`;
654
819
  const lines = [
655
820
  `decision ${decision.id}: ${decision.question}`,
656
- `asked by ${asker(decision)}${addressed(decision)}${decision.taskNumber === null ? "" : `, about task #${decision.taskNumber}`}`,
821
+ `asked by ${asker(decision)}${addressed(decision)}${decision.taskNumber === null ? "" : `, about task #${decision.taskNumber}`}, at ${moment(decision.createdAt)}`,
822
+ ...(options.page === undefined ? [] : [pageLine(options.page)]),
657
823
  ];
658
824
  if (decision.body.trim().length > 0) {
659
825
  lines.push("", decision.body.trimEnd());
@@ -675,7 +841,7 @@ export function formatDecision(
675
841
  if (decision.outcomeBy != null && decision.outcomeAt != null) {
676
842
  lines.push(
677
843
  indent(
678
- `written by ${calledOf(decision.outcomeBy)}${through(decision.outcomeAgent)} at ${decision.outcomeAt}`,
844
+ `written by ${calledOf(decision.outcomeBy)}${through(decision.outcomeAgent)} at ${moment(decision.outcomeAt)}`,
679
845
  ),
680
846
  );
681
847
  }
@@ -916,21 +1082,40 @@ export function formatPluginHelp(detail: RestPluginDetail, name: string | undefi
916
1082
  return parts.join("\n");
917
1083
  }
918
1084
 
919
- /** A setting in a line: its key and type, what it holds or whether it is set, and its name. */
1085
+ /** When a secret was set, from where where it was sealed from an answer, and when it expires: never what it holds. */
1086
+ function secretStanding(standing: {
1087
+ readonly setAt: string | null;
1088
+ readonly source?: string | null | undefined;
1089
+ readonly expiresAt?: string | null | undefined;
1090
+ }): string {
1091
+ return `set${standing.setAt === null ? "" : ` ${moment(standing.setAt)}`}${
1092
+ standing.source === null || standing.source === undefined || standing.source === "administrator"
1093
+ ? ""
1094
+ : ` from ${standing.source}`
1095
+ }${standing.expiresAt === null || standing.expiresAt === undefined ? "" : `, expires ${moment(standing.expiresAt)}`}`;
1096
+ }
1097
+
1098
+ /**
1099
+ * A setting in a line: its key and type, what it holds or whether it is set, and its name; for a
1100
+ * secret kept per key (ADR-0111), how many keys of how many, and a line under it for each key.
1101
+ */
920
1102
  export function formatPluginSettingLine(
921
1103
  setting: RestPluginSetting,
922
1104
  language: string | null | undefined,
923
1105
  ): string {
1106
+ const keys = setting.keys ?? null;
1107
+ if (setting.type === "secret" && keys !== null) {
1108
+ const max = setting.keyed?.max;
1109
+ const count = `${keys.length}${max === undefined ? "" : ` of ${max}`} ${keys.length === 1 && max === undefined ? "key" : "keys"}`;
1110
+ return [
1111
+ ` ${setting.key} (secret, per key): ${count} ${localized(setting.name, language)}`,
1112
+ ...keys.map((kept) => ` ${kept.key}: ${secretStanding(kept)}`),
1113
+ ].join("\n");
1114
+ }
924
1115
  const holds =
925
1116
  setting.type === "secret"
926
1117
  ? setting.set
927
- ? `set${setting.setAt === null ? "" : ` ${moment(setting.setAt)}`}${
928
- setting.source === null ||
929
- setting.source === undefined ||
930
- setting.source === "administrator"
931
- ? ""
932
- : ` from ${setting.source}`
933
- }${setting.expiresAt === null || setting.expiresAt === undefined ? "" : `, expires ${moment(setting.expiresAt)}`}`
1118
+ ? secretStanding(setting)
934
1119
  : "not set"
935
1120
  : setting.set
936
1121
  ? setting.value === null
@@ -964,6 +1149,68 @@ export function formatTeamLine(team: RestTeam, loginOf: ReadonlyMap<string, stri
964
1149
  return `${team.key} ${team.name} ${count}${logins.length === 0 ? "" : `: ${logins.join(", ")}`}`;
965
1150
  }
966
1151
 
1152
+ /**
1153
+ * A job of a plugin in a line (ADR-0128): its name and how often it runs, how its last run went
1154
+ * and since when it has failed where it keeps failing, and when it runs next.
1155
+ */
1156
+ export function formatPluginJobLine(job: RestPluginJob): string {
1157
+ const schedule = `every ${job.every}${job.at === null ? "" : ` at ${job.at}`}`;
1158
+ const last =
1159
+ job.lastRunAt === null || job.lastOutcome === null
1160
+ ? "has not run yet"
1161
+ : `last run ${moment(job.lastRunAt)}: ${job.lastOutcome}${
1162
+ job.lastOutcome === "failed" && job.failedSince !== null
1163
+ ? `, failing since ${moment(job.failedSince)}`
1164
+ : ""
1165
+ }`;
1166
+ return ` ${job.name} ${schedule} ${last} next: ${job.nextAt === null ? "not scheduled" : moment(job.nextAt)}`;
1167
+ }
1168
+
1169
+ /** What an event of a plugin says, after its kind: what failed, which command and how it ended, else what it carries. */
1170
+ function pluginEventSays(event: RestEvent): string {
1171
+ const data = event.data;
1172
+ if (event.kind === "plugin.failed") {
1173
+ return data.problem ?? "";
1174
+ }
1175
+ if (event.kind === "plugin.command") {
1176
+ return `${data.command ?? "?"} ${data.outcome ?? "?"}${data.code === undefined ? "" : ` (${data.code})`}${
1177
+ data.durationMs === undefined ? "" : `, ${data.durationMs} ms`
1178
+ }`;
1179
+ }
1180
+ const carried = JSON.stringify(data);
1181
+ return carried === "{}" ? "" : carried.length > 300 ? `${carried.slice(0, 300)}...` : carried;
1182
+ }
1183
+
1184
+ /** One event of a plugin in a line: its number, when, its kind, who did it and through what, and what it says. */
1185
+ export function formatPluginEventLine(event: RestEvent): string {
1186
+ const who =
1187
+ event.actor === null
1188
+ ? "the console"
1189
+ : `${calledOf(event.actor)}${event.agent === null ? "" : ` as ${event.agent}`}`;
1190
+ const says = pluginEventSays(event);
1191
+ return `#${event.id} ${moment(event.createdAt)} ${event.kind} ${who}${says === "" ? "" : ` ${says}`}`;
1192
+ }
1193
+
1194
+ /**
1195
+ * A page of a plugin's events, newest first (ADR-0128), of one kind where one was asked for:
1196
+ * what `console plugin <key> events` prints, with how to read on. The console answers what the
1197
+ * caller may read and says nothing of the rest, so an empty page is said as that, and never as
1198
+ * a plugin that has no events.
1199
+ */
1200
+ export function formatPluginEvents(
1201
+ key: string,
1202
+ page: RestEvents,
1203
+ asked: { readonly kind: string | undefined; readonly limit: number; readonly offset: number },
1204
+ ): string {
1205
+ if (page.items.length === 0) {
1206
+ const none = `No ${asked.kind === undefined ? "" : `${asked.kind} `}event of ${key} that you may read${
1207
+ asked.offset > 0 ? ", that far back" : ""
1208
+ }.`;
1209
+ return `${none}${formatMore(page.more, asked.limit, asked.offset)}`;
1210
+ }
1211
+ return `${page.items.map(formatPluginEventLine).join("\n")}${formatMore(page.more, asked.limit, asked.offset)}`;
1212
+ }
1213
+
967
1214
  /** One plugin in full: what it is, how it stands, what one may run, its skills and its settings. */
968
1215
  export function formatPlugin(
969
1216
  detail: RestPluginDetail,
@@ -1014,6 +1261,14 @@ export function formatPlugin(
1014
1261
  `Skills: console plugin ${detail.key} skills lists them; console plugin ${detail.key} skill <path> reads one. Read the one that fits before the first command.`,
1015
1262
  );
1016
1263
  }
1264
+ // A console before 0.5.1 names no jobs: nothing is printed of them then, not an empty block.
1265
+ if (detail.jobs !== undefined && detail.jobs.length > 0) {
1266
+ lines.push(
1267
+ "",
1268
+ `Jobs (what went wrong in one: console plugin ${detail.key} events --kind plugin.failed):`,
1269
+ ...detail.jobs.map(formatPluginJobLine),
1270
+ );
1271
+ }
1017
1272
  if (detail.settings.length > 0) {
1018
1273
  lines.push(
1019
1274
  "",