@skillcdn/console 0.5.0 → 0.5.2

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 (490) hide show
  1. package/README.md +87 -12
  2. package/SKILLCDN.md +3 -3
  3. package/dist/agent-page.d.ts.map +1 -1
  4. package/dist/agent-page.js +7 -6
  5. package/dist/agent-page.js.map +1 -1
  6. package/dist/api.d.ts +9 -7
  7. package/dist/api.d.ts.map +1 -1
  8. package/dist/api.js +8 -6
  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 +58 -2
  15. package/dist/cli/cli.d.ts.map +1 -1
  16. package/dist/cli/cli.js +1742 -472
  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 +70 -9
  31. package/dist/cli/format.d.ts.map +1 -1
  32. package/dist/cli/format.js +267 -40
  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 +101 -58
  37. package/dist/cli/help.js.map +1 -1
  38. package/dist/cli/machine-check.d.ts +36 -0
  39. package/dist/cli/machine-check.d.ts.map +1 -0
  40. package/dist/cli/machine-check.js +151 -0
  41. package/dist/cli/machine-check.js.map +1 -0
  42. package/dist/cli/main.js +76 -2
  43. package/dist/cli/main.js.map +1 -1
  44. package/dist/cli/pack.d.ts +69 -60
  45. package/dist/cli/pack.d.ts.map +1 -1
  46. package/dist/cli/pack.js +241 -270
  47. package/dist/cli/pack.js.map +1 -1
  48. package/dist/cli/plugin-check.d.ts +42 -0
  49. package/dist/cli/plugin-check.d.ts.map +1 -1
  50. package/dist/cli/plugin-check.js +221 -36
  51. package/dist/cli/plugin-check.js.map +1 -1
  52. package/dist/cli/plugin-cli.d.ts +6 -1
  53. package/dist/cli/plugin-cli.d.ts.map +1 -1
  54. package/dist/cli/plugin-cli.js +21 -4
  55. package/dist/cli/plugin-cli.js.map +1 -1
  56. package/dist/cli/plugin-main.js +1 -0
  57. package/dist/cli/plugin-main.js.map +1 -1
  58. package/dist/cli/runner-host.d.ts +7 -0
  59. package/dist/cli/runner-host.d.ts.map +1 -1
  60. package/dist/cli/runner-host.js +2 -0
  61. package/dist/cli/runner-host.js.map +1 -1
  62. package/dist/cli/secret-notes.d.ts +8 -0
  63. package/dist/cli/secret-notes.d.ts.map +1 -0
  64. package/dist/cli/secret-notes.js +48 -0
  65. package/dist/cli/secret-notes.js.map +1 -0
  66. package/dist/cli/serve.d.ts +33 -1
  67. package/dist/cli/serve.d.ts.map +1 -1
  68. package/dist/cli/serve.js +252 -3
  69. package/dist/cli/serve.js.map +1 -1
  70. package/dist/client.d.ts +54 -9
  71. package/dist/client.d.ts.map +1 -1
  72. package/dist/client.js +77 -80
  73. package/dist/client.js.map +1 -1
  74. package/dist/components/agent-page.d.ts +164 -8
  75. package/dist/components/agent-page.d.ts.map +1 -1
  76. package/dist/components/agent-page.js +588 -151
  77. package/dist/components/agent-page.js.map +1 -1
  78. package/dist/components/agents.d.ts.map +1 -1
  79. package/dist/components/agents.js +1 -1
  80. package/dist/components/agents.js.map +1 -1
  81. package/dist/components/board.d.ts.map +1 -1
  82. package/dist/components/board.js +3 -2
  83. package/dist/components/board.js.map +1 -1
  84. package/dist/components/categories.js +1 -1
  85. package/dist/components/categories.js.map +1 -1
  86. package/dist/components/charts.d.ts +157 -0
  87. package/dist/components/charts.d.ts.map +1 -0
  88. package/dist/components/charts.js +182 -0
  89. package/dist/components/charts.js.map +1 -0
  90. package/dist/components/decision-list.d.ts.map +1 -1
  91. package/dist/components/decision-list.js +1 -1
  92. package/dist/components/decision-list.js.map +1 -1
  93. package/dist/components/desk-records.d.ts +102 -0
  94. package/dist/components/desk-records.d.ts.map +1 -0
  95. package/dist/components/desk-records.js +221 -0
  96. package/dist/components/desk-records.js.map +1 -0
  97. package/dist/components/desk.d.ts +85 -0
  98. package/dist/components/desk.d.ts.map +1 -0
  99. package/dist/components/desk.js +135 -0
  100. package/dist/components/desk.js.map +1 -0
  101. package/dist/components/event-feed.d.ts.map +1 -1
  102. package/dist/components/event-feed.js +7 -3
  103. package/dist/components/event-feed.js.map +1 -1
  104. package/dist/components/goals.d.ts +2 -0
  105. package/dist/components/goals.d.ts.map +1 -1
  106. package/dist/components/goals.js +1 -1
  107. package/dist/components/goals.js.map +1 -1
  108. package/dist/components/home.d.ts.map +1 -1
  109. package/dist/components/home.js +14 -6
  110. package/dist/components/home.js.map +1 -1
  111. package/dist/components/icon.d.ts +31 -0
  112. package/dist/components/icon.d.ts.map +1 -0
  113. package/dist/components/icon.js +169 -0
  114. package/dist/components/icon.js.map +1 -0
  115. package/dist/components/markdown.d.ts +6 -0
  116. package/dist/components/markdown.d.ts.map +1 -1
  117. package/dist/components/markdown.js +10 -2
  118. package/dist/components/markdown.js.map +1 -1
  119. package/dist/components/people.js +1 -1
  120. package/dist/components/people.js.map +1 -1
  121. package/dist/components/plugin-frame.d.ts.map +1 -1
  122. package/dist/components/plugin-frame.js +7 -0
  123. package/dist/components/plugin-frame.js.map +1 -1
  124. package/dist/components/plugin-settings.d.ts.map +1 -1
  125. package/dist/components/plugin-settings.js +54 -3
  126. package/dist/components/plugin-settings.js.map +1 -1
  127. package/dist/components/projects.d.ts +17 -4
  128. package/dist/components/projects.d.ts.map +1 -1
  129. package/dist/components/projects.js +51 -12
  130. package/dist/components/projects.js.map +1 -1
  131. package/dist/components/rules.d.ts +8 -10
  132. package/dist/components/rules.d.ts.map +1 -1
  133. package/dist/components/rules.js +35 -13
  134. package/dist/components/rules.js.map +1 -1
  135. package/dist/components/sessions.d.ts.map +1 -1
  136. package/dist/components/sessions.js +3 -2
  137. package/dist/components/sessions.js.map +1 -1
  138. package/dist/components/setup.d.ts +9 -3
  139. package/dist/components/setup.d.ts.map +1 -1
  140. package/dist/components/setup.js +12 -6
  141. package/dist/components/setup.js.map +1 -1
  142. package/dist/components/shell.d.ts.map +1 -1
  143. package/dist/components/shell.js +3 -2
  144. package/dist/components/shell.js.map +1 -1
  145. package/dist/components/tokens.js +1 -1
  146. package/dist/components/tokens.js.map +1 -1
  147. package/dist/components/ui.d.ts +5 -2
  148. package/dist/components/ui.d.ts.map +1 -1
  149. package/dist/components/ui.js +10 -7
  150. package/dist/components/ui.js.map +1 -1
  151. package/dist/connect-page.js +1 -1
  152. package/dist/connect-page.js.map +1 -1
  153. package/dist/console.css +1172 -106
  154. package/dist/console.d.ts +5 -0
  155. package/dist/console.d.ts.map +1 -1
  156. package/dist/console.js +52 -39
  157. package/dist/console.js.map +1 -1
  158. package/dist/data.d.ts.map +1 -1
  159. package/dist/data.js +32 -33
  160. package/dist/data.js.map +1 -1
  161. package/dist/desk-page.d.ts +38 -0
  162. package/dist/desk-page.d.ts.map +1 -0
  163. package/dist/desk-page.js +184 -0
  164. package/dist/desk-page.js.map +1 -0
  165. package/dist/desk-records-page.d.ts +18 -0
  166. package/dist/desk-records-page.d.ts.map +1 -0
  167. package/dist/desk-records-page.js +130 -0
  168. package/dist/desk-records-page.js.map +1 -0
  169. package/dist/desk-records.d.ts +247 -0
  170. package/dist/desk-records.d.ts.map +1 -0
  171. package/dist/desk-records.js +543 -0
  172. package/dist/desk-records.js.map +1 -0
  173. package/dist/desk.d.ts +122 -0
  174. package/dist/desk.d.ts.map +1 -0
  175. package/dist/desk.js +211 -0
  176. package/dist/desk.js.map +1 -0
  177. package/dist/feed-stream.d.ts +39 -0
  178. package/dist/feed-stream.d.ts.map +1 -0
  179. package/dist/feed-stream.js +117 -0
  180. package/dist/feed-stream.js.map +1 -0
  181. package/dist/home-tiles.d.ts +19 -3
  182. package/dist/home-tiles.d.ts.map +1 -1
  183. package/dist/home-tiles.js +147 -42
  184. package/dist/home-tiles.js.map +1 -1
  185. package/dist/i18n/en.d.ts +228 -6
  186. package/dist/i18n/en.d.ts.map +1 -1
  187. package/dist/i18n/en.js +309 -9
  188. package/dist/i18n/en.js.map +1 -1
  189. package/dist/i18n/ko.d.ts.map +1 -1
  190. package/dist/i18n/ko.js +366 -85
  191. package/dist/i18n/ko.js.map +1 -1
  192. package/dist/i18n/particles.d.ts +7 -0
  193. package/dist/i18n/particles.d.ts.map +1 -0
  194. package/dist/i18n/particles.js +72 -0
  195. package/dist/i18n/particles.js.map +1 -0
  196. package/dist/icons/glyphs.d.ts +605 -0
  197. package/dist/icons/glyphs.d.ts.map +1 -0
  198. package/dist/icons/glyphs.js +104 -0
  199. package/dist/icons/glyphs.js.map +1 -0
  200. package/dist/icons/index.d.ts +59 -0
  201. package/dist/icons/index.d.ts.map +1 -0
  202. package/dist/icons/index.js +157 -0
  203. package/dist/icons/index.js.map +1 -0
  204. package/dist/index.d.ts +9 -0
  205. package/dist/index.d.ts.map +1 -1
  206. package/dist/index.js +9 -0
  207. package/dist/index.js.map +1 -1
  208. package/dist/limits.d.ts +20 -0
  209. package/dist/limits.d.ts.map +1 -1
  210. package/dist/limits.js +20 -0
  211. package/dist/limits.js.map +1 -1
  212. package/dist/marks.d.ts +9 -0
  213. package/dist/marks.d.ts.map +1 -1
  214. package/dist/marks.js +9 -0
  215. package/dist/marks.js.map +1 -1
  216. package/dist/onboarding.d.ts +6 -0
  217. package/dist/onboarding.d.ts.map +1 -1
  218. package/dist/onboarding.js +5 -5
  219. package/dist/onboarding.js.map +1 -1
  220. package/dist/plugin/context.d.ts +42 -11
  221. package/dist/plugin/context.d.ts.map +1 -1
  222. package/dist/plugin/limits.d.ts +2 -0
  223. package/dist/plugin/limits.d.ts.map +1 -1
  224. package/dist/plugin/limits.js +2 -0
  225. package/dist/plugin/limits.js.map +1 -1
  226. package/dist/plugin/manifest.d.ts +13 -0
  227. package/dist/plugin/manifest.d.ts.map +1 -1
  228. package/dist/plugin/manifest.js +30 -3
  229. package/dist/plugin/manifest.js.map +1 -1
  230. package/dist/plugin/rest-schemas.d.ts +55 -0
  231. package/dist/plugin/rest-schemas.d.ts.map +1 -1
  232. package/dist/plugin/rest-schemas.js +37 -0
  233. package/dist/plugin/rest-schemas.js.map +1 -1
  234. package/dist/plugin/sandbox.d.ts.map +1 -1
  235. package/dist/plugin/sandbox.js +4 -1
  236. package/dist/plugin/sandbox.js.map +1 -1
  237. package/dist/plugin/testing.d.ts +6 -2
  238. package/dist/plugin/testing.d.ts.map +1 -1
  239. package/dist/plugin/testing.js +52 -10
  240. package/dist/plugin/testing.js.map +1 -1
  241. package/dist/plugin/web.d.ts +3 -0
  242. package/dist/plugin/web.d.ts.map +1 -1
  243. package/dist/plugin/web.js +5 -1
  244. package/dist/plugin/web.js.map +1 -1
  245. package/dist/plugin.d.ts +1 -1
  246. package/dist/plugin.d.ts.map +1 -1
  247. package/dist/plugin.js +1 -1
  248. package/dist/plugin.js.map +1 -1
  249. package/dist/records.d.ts +283 -0
  250. package/dist/records.d.ts.map +1 -0
  251. package/dist/records.js +543 -0
  252. package/dist/records.js.map +1 -0
  253. package/dist/routes.d.ts +3 -1
  254. package/dist/routes.d.ts.map +1 -1
  255. package/dist/routes.js +3 -1
  256. package/dist/routes.js.map +1 -1
  257. package/dist/rules.d.ts +30 -11
  258. package/dist/rules.d.ts.map +1 -1
  259. package/dist/rules.js +98 -45
  260. package/dist/rules.js.map +1 -1
  261. package/dist/runner/acp.d.ts +1 -1
  262. package/dist/runner/acp.d.ts.map +1 -1
  263. package/dist/runner/acp.js +32 -21
  264. package/dist/runner/acp.js.map +1 -1
  265. package/dist/runner/awake.d.ts +35 -0
  266. package/dist/runner/awake.d.ts.map +1 -0
  267. package/dist/runner/awake.js +95 -0
  268. package/dist/runner/awake.js.map +1 -0
  269. package/dist/runner/claude.d.ts +1 -1
  270. package/dist/runner/claude.d.ts.map +1 -1
  271. package/dist/runner/claude.js +100 -18
  272. package/dist/runner/claude.js.map +1 -1
  273. package/dist/runner/codex.d.ts +1 -1
  274. package/dist/runner/codex.d.ts.map +1 -1
  275. package/dist/runner/codex.js +20 -17
  276. package/dist/runner/codex.js.map +1 -1
  277. package/dist/runner/config.d.ts +5 -0
  278. package/dist/runner/config.d.ts.map +1 -1
  279. package/dist/runner/config.js +9 -0
  280. package/dist/runner/config.js.map +1 -1
  281. package/dist/runner/desk.d.ts +43 -2
  282. package/dist/runner/desk.d.ts.map +1 -1
  283. package/dist/runner/desk.js +168 -13
  284. package/dist/runner/desk.js.map +1 -1
  285. package/dist/runner/process.d.ts.map +1 -1
  286. package/dist/runner/process.js +11 -4
  287. package/dist/runner/process.js.map +1 -1
  288. package/dist/runner/redact.d.ts +39 -4
  289. package/dist/runner/redact.d.ts.map +1 -1
  290. package/dist/runner/redact.js +81 -5
  291. package/dist/runner/redact.js.map +1 -1
  292. package/dist/runner/runner.d.ts +28 -3
  293. package/dist/runner/runner.d.ts.map +1 -1
  294. package/dist/runner/runner.js +371 -54
  295. package/dist/runner/runner.js.map +1 -1
  296. package/dist/runner/slack.d.ts.map +1 -1
  297. package/dist/runner/slack.js +10 -4
  298. package/dist/runner/slack.js.map +1 -1
  299. package/dist/runner/task-scheduler.d.ts +20 -0
  300. package/dist/runner/task-scheduler.d.ts.map +1 -1
  301. package/dist/runner/task-scheduler.js +34 -4
  302. package/dist/runner/task-scheduler.js.map +1 -1
  303. package/dist/runner/types.d.ts +51 -1
  304. package/dist/runner/types.d.ts.map +1 -1
  305. package/dist/runner/types.js +26 -0
  306. package/dist/runner/types.js.map +1 -1
  307. package/dist/runner.d.ts +6 -6
  308. package/dist/runner.d.ts.map +1 -1
  309. package/dist/runner.js +5 -5
  310. package/dist/runner.js.map +1 -1
  311. package/dist/schemas.d.ts +603 -6
  312. package/dist/schemas.d.ts.map +1 -1
  313. package/dist/schemas.js +156 -20
  314. package/dist/schemas.js.map +1 -1
  315. package/dist/services.d.ts +22 -5
  316. package/dist/services.d.ts.map +1 -1
  317. package/dist/services.js +41 -17
  318. package/dist/services.js.map +1 -1
  319. package/dist/setup-guide.d.ts +17 -4
  320. package/dist/setup-guide.d.ts.map +1 -1
  321. package/dist/setup-guide.js +48 -41
  322. package/dist/setup-guide.js.map +1 -1
  323. package/dist/tokens.d.ts.map +1 -1
  324. package/dist/tokens.js +5 -1
  325. package/dist/tokens.js.map +1 -1
  326. package/dist/vocabulary.d.ts +21 -3
  327. package/dist/vocabulary.d.ts.map +1 -1
  328. package/dist/vocabulary.js +19 -3
  329. package/dist/vocabulary.js.map +1 -1
  330. package/docs/specs/cli.md +73 -44
  331. package/docs/specs/plugins.md +40 -22
  332. package/docs/specs/records.md +113 -0
  333. package/docs/specs/rest.md +30 -21
  334. package/docs/specs/runner.md +46 -22
  335. package/package.json +11 -2
  336. package/skills/building-a-console/SKILL.md +4 -4
  337. package/skills/building-a-plugin/SKILL.md +6 -6
  338. package/skills/deploying-a-console/SKILL.md +4 -4
  339. package/skills/deploying-a-console/references/resources.md +41 -4
  340. package/skills/deploying-a-console/references/running-it-again.md +3 -2
  341. package/skills/keeping-a-desk/SKILL.md +133 -0
  342. package/skills/keeping-a-desk/collections.md +96 -0
  343. package/skills/planning-the-board/SKILL.md +14 -18
  344. package/skills/planning-the-board/references/a-task.md +2 -2
  345. package/skills/planning-the-board/references/project-rules.md +13 -14
  346. package/skills/planning-the-board/references/setting-up.md +15 -13
  347. package/skills/running-an-agent/SKILL.md +47 -56
  348. package/skills/working-the-board/SKILL.md +63 -44
  349. package/skills/working-the-board/references/terms.md +9 -5
  350. package/skills/working-the-board/references/the-pack.md +12 -10
  351. package/skills/working-the-board/references/the-sentence.md +2 -2
  352. package/src/agent-page.tsx +16 -2
  353. package/src/api.ts +109 -3
  354. package/src/charts.ts +250 -0
  355. package/src/cli/cli.ts +2226 -580
  356. package/src/cli/command-words.ts +56 -0
  357. package/src/cli/credentials.ts +181 -20
  358. package/src/cli/directory.ts +28 -10
  359. package/src/cli/format.ts +332 -49
  360. package/src/cli/help.ts +113 -57
  361. package/src/cli/machine-check.ts +223 -0
  362. package/src/cli/main.ts +72 -2
  363. package/src/cli/pack.ts +333 -372
  364. package/src/cli/plugin-check.ts +275 -34
  365. package/src/cli/plugin-cli.ts +28 -4
  366. package/src/cli/plugin-main.ts +1 -0
  367. package/src/cli/runner-host.ts +8 -0
  368. package/src/cli/secret-notes.ts +63 -0
  369. package/src/cli/serve.ts +295 -2
  370. package/src/client.ts +215 -177
  371. package/src/components/agent-page.tsx +1044 -281
  372. package/src/components/agents.tsx +9 -5
  373. package/src/components/board.tsx +3 -15
  374. package/src/components/categories.tsx +2 -2
  375. package/src/components/charts.tsx +680 -0
  376. package/src/components/decision-list.tsx +11 -7
  377. package/src/components/desk-records.tsx +724 -0
  378. package/src/components/desk.tsx +471 -0
  379. package/src/components/event-feed.tsx +12 -3
  380. package/src/components/goals.tsx +33 -25
  381. package/src/components/home.tsx +42 -6
  382. package/src/components/icon.tsx +337 -0
  383. package/src/components/markdown.tsx +22 -2
  384. package/src/components/people.tsx +1 -1
  385. package/src/components/plugin-frame.tsx +7 -0
  386. package/src/components/plugin-settings.tsx +171 -12
  387. package/src/components/projects.tsx +68 -17
  388. package/src/components/rules.tsx +94 -34
  389. package/src/components/sessions.tsx +2 -13
  390. package/src/components/setup.tsx +20 -5
  391. package/src/components/shell.tsx +3 -20
  392. package/src/components/tokens.tsx +1 -1
  393. package/src/components/ui.tsx +16 -8
  394. package/src/connect-page.tsx +1 -1
  395. package/src/console.tsx +104 -62
  396. package/src/data.ts +37 -34
  397. package/src/desk-page.tsx +332 -0
  398. package/src/desk-records-page.tsx +256 -0
  399. package/src/desk-records.ts +808 -0
  400. package/src/desk.ts +329 -0
  401. package/src/feed-stream.ts +144 -0
  402. package/src/home-tiles.ts +170 -46
  403. package/src/i18n/en.ts +323 -11
  404. package/src/i18n/ko.ts +378 -87
  405. package/src/i18n/particles.ts +79 -0
  406. package/src/icons/glyphs.ts +112 -0
  407. package/src/icons/index.ts +195 -0
  408. package/src/index.ts +125 -0
  409. package/src/limits.ts +20 -0
  410. package/src/marks.ts +12 -0
  411. package/src/onboarding.ts +14 -6
  412. package/src/plugin/context.ts +55 -12
  413. package/src/plugin/limits.ts +2 -0
  414. package/src/plugin/manifest.ts +38 -2
  415. package/src/plugin/rest-schemas.ts +41 -0
  416. package/src/plugin/sandbox.ts +4 -1
  417. package/src/plugin/testing.ts +63 -12
  418. package/src/plugin/web.ts +9 -2
  419. package/src/plugin.ts +2 -0
  420. package/src/records.ts +702 -0
  421. package/src/routes.ts +3 -1
  422. package/src/rules.ts +108 -47
  423. package/src/runner/acp.ts +49 -30
  424. package/src/runner/awake.ts +135 -0
  425. package/src/runner/claude.ts +131 -26
  426. package/src/runner/codex.ts +37 -26
  427. package/src/runner/config.ts +9 -0
  428. package/src/runner/desk.ts +200 -15
  429. package/src/runner/process.ts +11 -4
  430. package/src/runner/redact.ts +92 -6
  431. package/src/runner/runner.ts +457 -56
  432. package/src/runner/slack.ts +10 -4
  433. package/src/runner/task-scheduler.ts +36 -4
  434. package/src/runner/types.ts +67 -1
  435. package/src/runner.ts +27 -2
  436. package/src/schemas.ts +177 -18
  437. package/src/services.ts +55 -16
  438. package/src/setup-guide.ts +49 -40
  439. package/src/styles/README.md +16 -5
  440. package/src/styles/base.css +17 -0
  441. package/src/styles/console.css +10 -0
  442. package/src/styles/drawn-by-pages.json +1 -1
  443. package/src/styles/pages/agents.css +103 -1
  444. package/src/styles/pages/board.css +0 -10
  445. package/src/styles/pages/calendar.css +1 -1
  446. package/src/styles/pages/connect.css +0 -10
  447. package/src/styles/pages/decisions.css +3 -1
  448. package/src/styles/pages/desk.css +126 -0
  449. package/src/styles/pages/documents.css +5 -0
  450. package/src/styles/pages/feed.css +5 -2
  451. package/src/styles/pages/home.css +5 -0
  452. package/src/styles/pages/roadmap.css +2 -2
  453. package/src/styles/pages/settings.css +11 -0
  454. package/src/styles/pages/task.css +0 -20
  455. package/src/styles/pages/thread.css +1 -1
  456. package/src/styles/parts/bars.css +80 -0
  457. package/src/styles/parts/calendar.css +1 -1
  458. package/src/styles/parts/callout.css +1 -0
  459. package/src/styles/parts/chart.css +173 -0
  460. package/src/styles/parts/detail.css +22 -0
  461. package/src/styles/parts/empty.css +2 -0
  462. package/src/styles/parts/eyebrow.css +1 -1
  463. package/src/styles/parts/facts.css +1 -1
  464. package/src/styles/parts/figures.css +65 -0
  465. package/src/styles/parts/form.css +2 -1
  466. package/src/styles/parts/icon.css +191 -0
  467. package/src/styles/parts/input.css +14 -4
  468. package/src/styles/parts/legend.css +48 -0
  469. package/src/styles/parts/mark.css +36 -0
  470. package/src/styles/parts/menu.css +1 -7
  471. package/src/styles/parts/page.css +1 -1
  472. package/src/styles/parts/panel.css +10 -0
  473. package/src/styles/parts/person.css +5 -2
  474. package/src/styles/parts/progress.css +5 -2
  475. package/src/styles/parts/rows.css +1 -0
  476. package/src/styles/parts/series.css +32 -0
  477. package/src/styles/parts/settings.css +5 -0
  478. package/src/styles/parts/share.css +25 -0
  479. package/src/styles/parts/spark.css +23 -0
  480. package/src/styles/parts/stat.css +69 -0
  481. package/src/styles/tokens.css +31 -10
  482. package/src/tokens.ts +5 -1
  483. package/src/vocabulary.ts +25 -3
  484. package/template/desk-web/README.md +8 -0
  485. package/template/desk-web/index.html +13 -0
  486. package/template/desk-web/package.json +25 -0
  487. package/template/desk-web/src/main.tsx +24 -0
  488. package/template/desk-web/src/page.tsx +51 -0
  489. package/template/desk-web/tsconfig.json +16 -0
  490. package/template/desk-web/vite.config.ts +15 -0
package/src/cli/pack.ts CHANGED
@@ -1,68 +1,70 @@
1
1
  import {
2
- type BrowseResult,
3
- browseBody,
4
- browseResultOf,
5
- catalogStateOf,
6
- type DirectoryResult,
7
- directoryBody,
8
- directoryResultOf,
9
- type FileResult,
10
- type FindItem,
11
- type FindResult,
12
- fileBody,
13
- fileResultOf,
14
- findResultOf,
15
- joinSkillPages,
16
- type MountSummary,
17
- mountSummaryOf,
2
+ type BrowseQuery,
3
+ type CodePage,
4
+ type DataQuery,
5
+ type FileQuery,
6
+ type FindQuery,
7
+ type Pack,
8
+ PackError,
9
+ type RowsPage,
10
+ } from "@skillcdn/cli";
11
+ import {
12
+ isReadmePath,
18
13
  parseAddress,
19
14
  parseRepoPath,
20
15
  parseSkillUri,
21
16
  type RestBrowse,
22
17
  type RestFile,
18
+ type RestFind,
23
19
  type RestMount,
24
- type RestSkill,
25
- renderBrowseResult,
26
- renderDirectoryResult,
27
- renderFileResult,
28
- renderFindResult,
29
- renderInstructions,
30
- renderSkillResult,
31
- rowsCsv,
32
- type SkillResult,
33
- skillOutcome,
34
- skillResultOf,
20
+ type RestSkill as RestSkillPage,
35
21
  type ToolWords,
36
22
  } from "@skillcdn/core";
37
- import type {
38
- RestSkillBrowse,
39
- RestSkillCode,
40
- RestSkillFile,
41
- RestSkillFind,
42
- RestSkillLoad,
43
- RestSkillRows,
44
- RestSkills,
45
- } from "../schemas.js";
23
+ import type { PackClient } from "../client.js";
24
+ import type { RestSkills } from "../schemas.js";
46
25
  import type { SkillsStatus } from "../vocabulary.js";
26
+ import { commandLine, NO_LINE_TO_RUN } from "./command-words.js";
27
+
28
+ // The pack of the project, as the command prints it (ADR-0028, ADR-0031, ADR-0124): the console
29
+ // answers what the pack's REST API answered, in the shapes of @skillcdn/core, and the command
30
+ // hands those answers, as a pack, to the reads the skillcdn command itself prints with
31
+ // (`readPack` of @skillcdn/cli), naming the reads as its own commands. So an agent reads here
32
+ // what it would read over MCP, or with the skillcdn command, and a change of that command's text
33
+ // comes with its next version. What is here is the console's own: the pack made of the console's
34
+ // answers, the lines around a listing, and the words of a pack the console could not read,
35
+ // which is a project's or the organization's and whose token is the console's to hold.
36
+
37
+ /** How the results name the four reads of a pack read with `skills` and `skill`, so that an agent is told the command and not a tool. */
38
+ export const packWords = (skills: string, skill: string): ToolWords => ({
39
+ browse: `${skills} <folder>`,
40
+ search: `${skills} --search`,
41
+ load: skill,
42
+ read: `${skill} --file`,
43
+ });
44
+
45
+ /** The words of the project's pack, and the organization's: `console skills` and `console skill`. */
46
+ export const CONSOLE_WORDS: ToolWords = packWords("console skills", "console skill");
47
47
 
48
- // The pack of the project, as the command prints it (ADR-0028, ADR-0031): the console answers
49
- // what the pack's REST API answered, in the shapes of @skillcdn/core, and the command renders
50
- // it with the functions a deployment's own tools render for a model, naming the reads as its
51
- // own commands, so that an agent reads here what it would read over MCP, or with the skillcdn
52
- // command. The pages a read came in are joined first: a skill, a folder and a file arrive whole.
48
+ export const NO_ADDRESS = "No skills address: neither this project nor the console names one.";
53
49
 
54
- /** How the results name the four reads, so that an agent is told the command and not a tool. */
55
- export const CONSOLE_WORDS: ToolWords = {
56
- browse: "console skills <folder>",
57
- search: "console skills --search",
58
- load: "console skill",
59
- read: "console skill --file",
60
- };
50
+ /**
51
+ * Whose pack a read is of, for the words of a read that did not happen: a project's, or the
52
+ * organization's, which is what a command reads where no project is named (ADR-0113).
53
+ */
54
+ export type PackOwner = "project" | "organization";
61
55
 
62
- /** Where the reads of a pack are rendered at: what the listing said the address serves. */
63
- export type PackSummary = MountSummary;
56
+ const NO_ORGANIZATION_ADDRESS =
57
+ "No skills address: the console names none for the organization's skills, and no project is named here.";
64
58
 
65
- export const NO_ADDRESS = "No skills address: neither this project nor the console names one.";
59
+ const noAddress = (owner: PackOwner): string =>
60
+ owner === "organization" ? NO_ORGANIZATION_ADDRESS : NO_ADDRESS;
61
+
62
+ /**
63
+ * What a read of the organization's pack begins with: whose pack it is, since the command
64
+ * would otherwise read as if a project had been named, and how a project's own is read.
65
+ */
66
+ export const ORGANIZATION_PACK_LINE =
67
+ "The organization's pack, since no project is named here: --project <key>, or a directory bound with console use <key>, reads a project's own.";
66
68
 
67
69
  /** The words of a read that did not happen, by status, with what to do about it. */
68
70
  const SKILLS_WORDS: Readonly<Record<Exclude<SkillsStatus, "none" | "ready">, string>> = {
@@ -76,20 +78,63 @@ const SKILLS_WORDS: Readonly<Record<Exclude<SkillsStatus, "none" | "ready">, str
76
78
  unavailable: "The pack could not be reached; ask again later.",
77
79
  };
78
80
 
79
- type Envelope = Pick<RestSkills, "address" | "source" | "page" | "status" | "refusal">;
81
+ /** The same, where the pack is the organization's: the token is the workspace's, an administrator's to set. */
82
+ const ORGANIZATION_WORDS: Readonly<Record<"not_found" | "token_invalid", string>> = {
83
+ not_found:
84
+ "Nothing is served to the console at this address or path: it is not there, or the organization's pack is private and the workspace holds no SkillCDN token for it (console workspace pack-token --connect, for an administrator).",
85
+ token_invalid:
86
+ "The SkillCDN token the workspace holds no longer works at the deployment: an administrator sets a new one (console workspace pack-token --connect).",
87
+ };
88
+
89
+ /** What every answer of the console about a pack says first: where it is, and how the read went. */
90
+ export type PackEnvelope = Pick<RestSkills, "address" | "source" | "page" | "status" | "refusal">;
91
+
92
+ /** One answer of the console to a read of a pack: the envelope, and the pack's own answer in it. */
93
+ export type PackAnswer = PackEnvelope & { readonly read: unknown };
80
94
 
81
95
  /** The first line of an answer about the pack: what was read, where the pack is, and how it went. */
82
- function head(what: string, answer: Envelope): string {
96
+ function head(what: string, answer: PackEnvelope): string {
83
97
  const where =
84
98
  answer.source === null ? "read from the console's machine" : `served by ${answer.source}`;
85
99
  return `${what} at ${answer.address}, ${where}: ${answer.status}`;
86
100
  }
87
101
 
88
- /** A read that did not happen: the head, the words of its status, and the pack's own refusal when it gave one. */
89
- function refused(what: string, answer: Envelope): string {
102
+ /**
103
+ * Whether a refusal is the pack's answer to one read: a path with nothing at it, a read asked
104
+ * wrong, a file it will not carry, in the pack's own code and words. The pack answered, so no
105
+ * token is what is missing, and saying so would send an agent to mend a pack that is served.
106
+ * Every other refusal is of the pack as a whole: nothing is served to the console at the
107
+ * address, the token is no good there, the index is not there to read, or it was not reached.
108
+ */
109
+ const ofOneRead = (answer: PackEnvelope): boolean =>
110
+ answer.refusal !== null &&
111
+ (answer.status === "not_found" || answer.status === "failed") &&
112
+ !/^(mount|auth|index)\./.test(answer.refusal.code);
113
+
114
+ /**
115
+ * A read the console could not make, of the pack as a whole, as the command says it on standard
116
+ * error: that no address is named; or where the pack is and how it stands, the words of that
117
+ * standing with whose token is missing, and the pack's own refusal when it gave one. `what` is
118
+ * the read in a word: `skills`, `folder`, `search`, `skill`, `file`, `tables`, `code blocks`.
119
+ */
120
+ export function refusalWords(
121
+ what: string,
122
+ answer: PackEnvelope,
123
+ owner: PackOwner = "project",
124
+ ): string {
125
+ if (answer.status === "none" || answer.address === null) {
126
+ return noAddress(owner);
127
+ }
90
128
  const lines = [head(what, answer)];
91
- if (answer.status !== "none" && answer.status !== "ready") {
92
- lines.push(SKILLS_WORDS[answer.status]);
129
+ if (answer.status === "ready") {
130
+ lines.push("Nothing was read.");
131
+ } else {
132
+ lines.push(
133
+ owner === "organization" &&
134
+ (answer.status === "not_found" || answer.status === "token_invalid")
135
+ ? ORGANIZATION_WORDS[answer.status]
136
+ : SKILLS_WORDS[answer.status],
137
+ );
93
138
  }
94
139
  if (answer.refusal !== null) {
95
140
  lines.push(answer.refusal.message);
@@ -97,97 +142,269 @@ function refused(what: string, answer: Envelope): string {
97
142
  return lines.join("\n");
98
143
  }
99
144
 
100
- /** What the listing said the address serves, for the reads to be rendered at; nothing when it did not answer. */
101
- export function summaryOf(listing: RestSkills): PackSummary | undefined {
102
- return listing.mount === null ? undefined : mountSummaryOf(listing.mount);
145
+ /**
146
+ * A read of the pack as a whole that the console could not make: thrown by the pack made of the
147
+ * console's answers, for the command to say in the console's words ({@link refusalWords}). A
148
+ * refusal of one read, in the pack's own code and words, is a `PackError` instead, as the
149
+ * skillcdn command's own pack throws one.
150
+ */
151
+ export class PackRefusal extends Error {
152
+ /** The read in a word, as the first line of the refusal names it. */
153
+ readonly what: string;
154
+ /** What the console answered. */
155
+ readonly answer: PackAnswer;
156
+
157
+ constructor(what: string, answer: PackAnswer) {
158
+ super(`${what}: ${answer.status}`);
159
+ this.name = "PackRefusal";
160
+ this.what = what;
161
+ this.answer = answer;
162
+ }
103
163
  }
104
164
 
105
- /** Every skill and document the address serves, as one listing: what `search_repo` without words answers. */
106
- function listingOf(mount: RestMount, summary: PackSummary): FindResult | undefined {
107
- if (mount.index.status !== "ready") {
108
- return undefined;
109
- }
165
+ type Ready<T> = Extract<T, { readonly status: "ready" }>;
166
+
167
+ /**
168
+ * Every skill and document the address serves, as a search without words answers them, made
169
+ * from what the pack says of itself in the one answer the console already has (ADR-0118, point
170
+ * 5): the console's API takes no search without words, and a listing asked page by page through
171
+ * a console that may be far would be several requests for the answer one gives. A folder's
172
+ * README is marked as its overview by the rule @skillcdn/core exports.
173
+ */
174
+ function listingOf(mount: RestMount): Ready<RestFind> {
110
175
  const { index } = mount;
111
- const items: FindItem[] = [];
176
+ if (index.status !== "ready") {
177
+ throw new PackError(503, `index.${index.status}`, "The pack is not ready to read.");
178
+ }
179
+ const items: Ready<RestFind>["items"] = [];
112
180
  for (const skill of index.skills) {
113
- const directory = parseRepoPath(skill.directory);
114
- if (!directory.ok) {
115
- continue;
116
- }
117
- const path = parseRepoPath(
118
- skill.path ?? (skill.directory === "" ? "SKILL.md" : `${skill.directory}/SKILL.md`),
119
- );
120
181
  items.push({
121
182
  kind: "skill",
122
- ...(path.ok ? { path: path.value } : {}),
183
+ path: skill.path ?? (skill.directory === "" ? "SKILL.md" : `${skill.directory}/SKILL.md`),
123
184
  name: skill.name,
124
- directory: directory.value,
185
+ directory: skill.directory,
125
186
  description: skill.description,
187
+ translations: skill.translations,
126
188
  files: [],
127
189
  moreFiles: 0,
128
- // For people, and not rendered for a model.
129
- translations: {},
130
190
  });
131
191
  }
132
192
  for (const document of index.documents) {
133
193
  const path = parseRepoPath(document.path);
134
- if (path.ok) {
135
- items.push({
136
- kind: "document",
137
- path: path.value,
138
- title: document.title ?? undefined,
139
- summary: document.summary ?? undefined,
140
- skillDirectory: undefined,
141
- });
142
- }
194
+ items.push({
195
+ kind: "document",
196
+ path: document.path,
197
+ title: document.title,
198
+ summary: document.summary,
199
+ skillDirectory: null,
200
+ ...(path.ok && isReadmePath(path.value) ? { overview: true } : {}),
201
+ });
143
202
  }
144
- const state = catalogStateOf(mount);
145
203
  return {
146
- mount: summary,
147
- query: undefined,
204
+ status: "ready",
205
+ query: null,
206
+ commit: mount.commit,
148
207
  items,
208
+ diagnostics: index.diagnostics,
149
209
  // The counts stand in the instructions above; without totals here, nothing suggests a cursor.
150
- totals: undefined,
151
- diagnostics: state.status === "ready" ? state.catalog.diagnostics : [],
210
+ totals: null,
211
+ nextCursor: null,
152
212
  };
153
213
  }
154
214
 
155
215
  /**
156
- * The pack: where it is and how it answered; what a client is told on connect, as the
157
- * deployment tells one; every skill and document; where a person connects an agent of its own;
158
- * and where the console's own skills are on this machine.
216
+ * A document's outline with the reads of its tables and its code blocks named as commands
217
+ * (ADR-0100): where the console said an address of its own for one, the command that reads it,
218
+ * `command` being the one the pack is read with, so that an agent is told what to run. Where the
219
+ * path has no spelling both shells take whole, what to run is said in words, with why.
159
220
  */
160
- export function formatSkills(skills: RestSkills, ownSkills?: string): string {
221
+ function withDataCommands(read: Ready<RestBrowse>, command: string): Ready<RestBrowse> {
222
+ const outline = read.outline;
223
+ if (outline?.data === undefined) {
224
+ return read;
225
+ }
226
+ const line = (flag: string): string =>
227
+ commandLine(command, [flag, outline.path]) ??
228
+ `${command} ${flag} with this file's path, quoted for your shell. ${NO_LINE_TO_RUN}`;
229
+ return {
230
+ ...read,
231
+ outline: {
232
+ ...outline,
233
+ data: {
234
+ ...(outline.data.rows === undefined ? {} : { rows: line("--rows") }),
235
+ ...(outline.data.code === undefined ? {} : { code: line("--code") }),
236
+ },
237
+ },
238
+ };
239
+ }
240
+
241
+ /**
242
+ * How many pages of a skill, of tables or of code blocks one command follows before it stops:
243
+ * far above what a pack holds, and the end of a read that would otherwise go round a console
244
+ * that names the same cursor again.
245
+ */
246
+ const MAX_PAGES = 64;
247
+
248
+ /** A pack made of the console's answers, which says what the console answered last. */
249
+ export interface ConsolePack extends Pack {
250
+ /** The console's answer to the last read made of the pack: what `--json` prints around the pack's own answer, and what a refusal is said from. */
251
+ answered(): PackAnswer | undefined;
252
+ }
253
+
254
+ /**
255
+ * The pack `reader` reads, as the reads of the skillcdn command take one (ADR-0124): each read
256
+ * asked of the console, and the pack's own answer taken out of the console's. `listing` is the
257
+ * console's answer about the pack as a whole, which the command asks first; nothing is made of
258
+ * one that does not answer a pack, and the command says that as it stands. `url` is the console's
259
+ * origin, where a pack with no deployment of its own is read. With `dataCommand`, the outline of
260
+ * a document names the commands that read its tables and its code blocks, `dataCommand` being
261
+ * the one the pack is read with; without it, the console's addresses stay, as `--json` has them.
262
+ */
263
+ export function consolePack(
264
+ reader: PackClient,
265
+ listing: RestSkills,
266
+ options: { readonly url: string; readonly dataCommand?: string | undefined },
267
+ ): ConsolePack | undefined {
268
+ const { mount } = listing;
269
+ const address = listing.address === null ? undefined : parseAddress(listing.address);
270
+ if (listing.status !== "ready" || mount === null || address === undefined || !address.ok) {
271
+ return undefined;
272
+ }
273
+ let last: PackAnswer | undefined;
274
+ let pages = 0;
275
+ /** One more page of a read the command joins, within what one command follows. */
276
+ const another = (what: string, path: string | undefined): void => {
277
+ pages += 1;
278
+ if (pages > MAX_PAGES) {
279
+ throw new PackError(
280
+ 0,
281
+ "invalid_response",
282
+ `The ${what} under ${path ?? "the pack"} are more than the command reads at once (${MAX_PAGES} pages): name a folder or a file under it.`,
283
+ );
284
+ }
285
+ };
286
+ /** The pack's own answer in the console's: a refusal of the one read as the pack's, any other as the console's. */
287
+ const taken = <R>(what: string, answer: PackEnvelope & { readonly read: R | null }): R => {
288
+ last = answer;
289
+ if (answer.status === "ready" && answer.read !== null) {
290
+ return answer.read;
291
+ }
292
+ if (answer.refusal !== null && ofOneRead(answer)) {
293
+ throw new PackError(
294
+ answer.status === "failed" ? 415 : 404,
295
+ answer.refusal.code,
296
+ answer.refusal.message,
297
+ {
298
+ directories: answer.refusal.directories,
299
+ sourceUrl: answer.refusal.sourceUrl ?? undefined,
300
+ },
301
+ );
302
+ }
303
+ throw new PackRefusal(what, answer);
304
+ };
305
+ /** The same, of a read the pack answers with its own standing: ready, or the console says how it stands. */
306
+ const ready = <R extends { readonly status: string }>(
307
+ what: string,
308
+ answer: PackEnvelope & { readonly read: R | null },
309
+ ): Ready<R> => {
310
+ const read = taken(what, answer);
311
+ if (read.status !== "ready") {
312
+ throw new PackRefusal(what, answer);
313
+ }
314
+ return read as Ready<R>;
315
+ };
316
+ return {
317
+ address: address.value,
318
+ source: { kind: "deployment", url: listing.source ?? options.url },
319
+ answered: () => last,
320
+ mount: async () => mount,
321
+ browse: async (query: BrowseQuery): Promise<RestBrowse> => {
322
+ const read = ready("folder", await reader.skillBrowse(query));
323
+ return options.dataCommand === undefined ? read : withDataCommands(read, options.dataCommand);
324
+ },
325
+ find: async (query: FindQuery): Promise<RestFind> =>
326
+ query.query === undefined
327
+ ? listingOf(mount)
328
+ : ready(
329
+ "search",
330
+ await reader.skillFind(query.query, {
331
+ path: query.path,
332
+ cursor: query.cursor,
333
+ limit: query.limit,
334
+ }),
335
+ ),
336
+ skill: async (path: string, cursor?: string): Promise<RestSkillPage> => {
337
+ pages += 1;
338
+ if (pages > MAX_PAGES) {
339
+ throw new PackError(
340
+ 0,
341
+ "invalid_response",
342
+ "The pack answers more pages of a skill than one read takes.",
343
+ );
344
+ }
345
+ return ready("skill", await reader.skill(path, cursor));
346
+ },
347
+ file: async (query: FileQuery): Promise<RestFile> =>
348
+ taken(
349
+ "file",
350
+ await reader.skillFile(query.path, { offset: query.offset, limit: query.limit }),
351
+ ),
352
+ rows: async (query: DataQuery): Promise<RowsPage> => {
353
+ another("tables", query.path);
354
+ return ready("tables", await reader.skillRows(query));
355
+ },
356
+ code: async (query: DataQuery): Promise<CodePage> => {
357
+ another("code blocks", query.path);
358
+ return ready("code blocks", await reader.skillCode(query));
359
+ },
360
+ };
361
+ }
362
+
363
+ /**
364
+ * The listing of a pack as the command prints it. Where the pack answered, `text` is what the
365
+ * skillcdn command prints for it, what a client is told on connect and then every skill and
366
+ * document, between the lines of the console's own: where the pack is and how it answered,
367
+ * where a person connects an agent of their own, and where the console's own skills are on this
368
+ * machine. Where it did not, why, with that last line still.
369
+ */
370
+ export function formatSkills(
371
+ skills: RestSkills,
372
+ text: string | undefined,
373
+ ownSkills?: string,
374
+ owner: PackOwner = "project",
375
+ words: ToolWords = CONSOLE_WORDS,
376
+ ): string {
161
377
  const own =
162
378
  ownSkills === undefined
163
379
  ? []
164
- : ["", `The console's own skills, for working the board: ${ownSkills}`];
165
- if (skills.status === "none" || skills.address === null) {
166
- return [NO_ADDRESS, ...own].join("\n");
167
- }
168
- const summary = summaryOf(skills);
169
- if (skills.status !== "ready" || skills.mount === null || summary === undefined) {
170
- return [refused("skills", skills), ...own].join("\n");
171
- }
172
- const lines = [
173
- head("skills", skills),
174
- "",
175
- renderInstructions(catalogStateOf(skills.mount), CONSOLE_WORDS),
176
- ];
177
- const listing = listingOf(skills.mount, summary);
178
- if (listing !== undefined) {
179
- lines.push("", renderFindResult(listing, CONSOLE_WORDS));
380
+ : ["", `The console's own skills, for working the board and keeping a desk: ${ownSkills}`];
381
+ if (text === undefined || skills.status !== "ready") {
382
+ return [refusalWords("skills", skills, owner), ...own].join("\n");
180
383
  }
384
+ const lines = [head("skills", skills), "", text];
181
385
  if (skills.page !== null) {
182
386
  lines.push(
183
387
  "",
184
- `A host with a SkillCDN connection of its own loads a skill by its URI, which a person makes at ${skills.page}; through the console, ${CONSOLE_WORDS.load} takes the URI too. --json adds the page of each skill, for a person.`,
388
+ `A host with a SkillCDN connection of its own loads a skill by its URI, which a person makes at ${skills.page}; through the console, ${words.load} takes the URI too. --json adds the page of each skill, for a person.`,
185
389
  );
186
390
  }
187
391
  lines.push(...own);
188
392
  return lines.join("\n");
189
393
  }
190
394
 
395
+ /**
396
+ * The `SKILL.md` a path names: the path itself where it names one, else the one in the folder
397
+ * it names, since a skill is its folder and a listing cut short shows the folder alone; the
398
+ * root's own for the dot, as the root is everywhere.
399
+ */
400
+ function skillFileOf(given: string): string {
401
+ const path = given.replace(/\/+$/, "");
402
+ if (path === "" || path === ".") {
403
+ return "SKILL.md";
404
+ }
405
+ return path === "SKILL.md" || path.endsWith("/SKILL.md") ? path : `${path}/SKILL.md`;
406
+ }
407
+
191
408
  /**
192
409
  * A skill's path as given, or taken out of the URI the listing names it by
193
410
  * (`skill://<host>/<owner>/<name>/<path>`); a URI of another pack would read this pack's skill
@@ -203,7 +420,7 @@ export function skillPathIn(
203
420
  ? {
204
421
  error: `Not a skill's URI the console knows: ${given}. Say the path of its SKILL.md from the repository's root, or the URI console skills lists.`,
205
422
  }
206
- : { path: given };
423
+ : { path: skillFileOf(given) };
207
424
  }
208
425
  const pack = packAddress === null ? undefined : parseAddress(packAddress);
209
426
  if (
@@ -219,262 +436,6 @@ export function skillPathIn(
219
436
  return { path: uri.path };
220
437
  }
221
438
 
222
- /** The pages of a skill, as the console answered them, as the one skill they were cut from. */
223
- export function joinSkill(
224
- pages: readonly RestSkillLoad[],
225
- summary: PackSummary,
226
- ): SkillResult | undefined {
227
- return joinSkillPages(
228
- pages.flatMap((page) =>
229
- page.read?.status === "ready" ? (skillResultOf(page.read, summary) ?? []) : [],
230
- ),
231
- );
232
- }
233
-
234
- /** The skill whole, as the REST API answers one, for `--json`. */
235
- export function bodyOfSkill(skill: SkillResult): RestSkill {
236
- const outcome = skillOutcome({ status: "ready", lookup: { kind: "found", skill } });
237
- if ("failure" in outcome) {
238
- throw new Error("a skill that was found has a body");
239
- }
240
- return outcome.body;
241
- }
242
-
243
- /** One skill as `load_skill` lays it out for a model: the rules, the body, the included files, its files and references. */
244
- export function formatSkillLoad(loaded: RestSkillLoad, whole: SkillResult | undefined): string {
245
- if (loaded.status === "none" || loaded.address === null) {
246
- return NO_ADDRESS;
247
- }
248
- if (loaded.status !== "ready") {
249
- return refused("skill", loaded);
250
- }
251
- if (whole === undefined) {
252
- return `${head("skill", loaded)}\nNothing was read.`;
253
- }
254
- return renderSkillResult(whole, CONSOLE_WORDS);
255
- }
256
-
257
- /** The pages of a folder, as the console answered them, as the one listing they were cut from. */
258
- export function joinFolder(
259
- pages: readonly RestSkillBrowse[],
260
- summary: PackSummary,
261
- ): BrowseResult | undefined {
262
- const results = pages.flatMap((page) =>
263
- page.read?.status === "ready" ? (browseResultOf(page.read, summary) ?? []) : [],
264
- );
265
- const first = results[0];
266
- const last = results[results.length - 1];
267
- if (first === undefined || last === undefined) {
268
- return undefined;
269
- }
270
- // A file's path answers its outline (SkillCDN 0.4), its headings paged as a folder's entries are.
271
- const outline =
272
- first.outline === undefined
273
- ? undefined
274
- : {
275
- ...first.outline,
276
- headings: results.flatMap((result) => result.outline?.headings ?? []),
277
- };
278
- return {
279
- ...first,
280
- mount: last.mount,
281
- entries: results.flatMap((result) => result.entries),
282
- nextCursor: last.nextCursor,
283
- ...(outline === undefined ? {} : { outline }),
284
- };
285
- }
286
-
287
- /** A folder whole, as the REST API answers one page, for `--json`. */
288
- export const bodyOfFolder = (result: BrowseResult): RestBrowse =>
289
- browseBody({ status: "ready", result });
290
-
291
- /** A path as a word of a command line: as it is, or quoted where a shell would split it. */
292
- const pathWord = (path: string): string =>
293
- /^[\w./@+-]+$/.test(path) ? path : JSON.stringify(path);
294
-
295
- /**
296
- * A document's outline with the reads of its tables and its code blocks named as commands
297
- * (ADR-0100): where the console said an address of its own for one, the command that reads it,
298
- * `command` being the one the pack is read with, so that an agent is told what to run.
299
- */
300
- function withDataCommands(whole: BrowseResult, command: string): BrowseResult {
301
- const outline = whole.outline;
302
- if (outline?.data === undefined) {
303
- return whole;
304
- }
305
- const path = pathWord(outline.path);
306
- return {
307
- ...whole,
308
- outline: {
309
- ...outline,
310
- data: {
311
- ...(outline.data.rows === undefined ? {} : { rows: `${command} --rows ${path}` }),
312
- ...(outline.data.code === undefined ? {} : { code: `${command} --code ${path}` }),
313
- },
314
- },
315
- };
316
- }
317
-
318
- /** What a folder holds, as `browse_repo` lays it out for a model; `command` is the one the pack is read with. */
319
- export function formatSkillBrowse(
320
- browsed: RestSkillBrowse,
321
- whole: BrowseResult | undefined,
322
- command = "console skills",
323
- ): string {
324
- if (browsed.status === "none" || browsed.address === null) {
325
- return NO_ADDRESS;
326
- }
327
- if (browsed.status !== "ready") {
328
- return refused("folder", browsed);
329
- }
330
- if (whole === undefined) {
331
- return `${head("folder", browsed)}\nNothing was read.`;
332
- }
333
- return renderBrowseResult(withDataCommands(whole, command), CONSOLE_WORDS);
334
- }
335
-
336
- type ReadyRows = Extract<NonNullable<RestSkillRows["read"]>, { readonly status: "ready" }>;
337
- type ReadyCode = Extract<NonNullable<RestSkillCode["read"]>, { readonly status: "ready" }>;
338
-
339
- /** The pages of a read of tables, as the console answered them, as the one answer they were cut from: every table in reading order. */
340
- export function joinRows(pages: readonly RestSkillRows[]): ReadyRows | undefined {
341
- const reads = pages.flatMap((page) => (page.read?.status === "ready" ? [page.read] : []));
342
- const first = reads[0];
343
- const last = reads[reads.length - 1];
344
- if (first === undefined || last === undefined) {
345
- return undefined;
346
- }
347
- return {
348
- ...first,
349
- tables: reads.flatMap((read) => read.tables),
350
- rowCount: reads.reduce((sum, read) => sum + read.rowCount, 0),
351
- nextCursor: last.nextCursor,
352
- };
353
- }
354
-
355
- /** The pages of a read of code blocks, as the one answer they were cut from: every block in reading order. */
356
- export function joinCode(pages: readonly RestSkillCode[]): ReadyCode | undefined {
357
- const reads = pages.flatMap((page) => (page.read?.status === "ready" ? [page.read] : []));
358
- const first = reads[0];
359
- const last = reads[reads.length - 1];
360
- if (first === undefined || last === undefined) {
361
- return undefined;
362
- }
363
- return {
364
- ...first,
365
- blocks: reads.flatMap((read) => read.blocks),
366
- nextCursor: last.nextCursor,
367
- };
368
- }
369
-
370
- /** Why a read of tables or of code blocks did not happen, for the command to fail with; nothing when it did. */
371
- export function dataRefusal(
372
- what: "tables" | "code blocks",
373
- read: RestSkillRows | RestSkillCode,
374
- ): string | undefined {
375
- if (read.status === "none" || read.address === null) {
376
- return NO_ADDRESS;
377
- }
378
- return read.status === "ready" ? undefined : refused(what, read);
379
- }
380
-
381
- /** How many files the tables, or the blocks, stand in. */
382
- const filesOf = (items: readonly { readonly path: string }[]): number =>
383
- new Set(items.map((item) => item.path)).size;
384
-
385
- const counted = (count: number, one: string, many = `${one}s`): string =>
386
- `${count} ${count === 1 ? one : many}`;
387
-
388
- /** The tables as one CSV: a header of `path`, `heading` and every column name, then a line per row (`rowsCsv` of `@skillcdn/core`). */
389
- export const csvOfRows = (whole: ReadyRows): string => rowsCsv(whole.tables);
390
-
391
- /** What a read of tables held, in a line. */
392
- export const describeRows = (whole: ReadyRows): string =>
393
- `${counted(whole.rowCount, "row")} of ${counted(whole.tables.length, "table")} in ${counted(filesOf(whole.tables), "file")}`;
394
-
395
- /**
396
- * The code blocks as written, each under a line that names its file, the section it stands in
397
- * and what it says it is written in, a blank line between two.
398
- */
399
- export function textOfCode(whole: ReadyCode): string {
400
- return whole.blocks
401
- .map((block) => {
402
- const where = [block.path, ...block.heading].join(" > ");
403
- const language = block.language === "" ? "" : ` [${block.language}]`;
404
- return `--- ${where}${language}\n${block.text}${block.text.endsWith("\n") ? "" : "\n"}`;
405
- })
406
- .join("\n");
407
- }
408
-
409
- /** What a read of code blocks held, in a line. */
410
- export const describeCode = (whole: ReadyCode): string =>
411
- `${counted(whole.blocks.length, "code block")} in ${counted(filesOf(whole.blocks), "file")}`;
412
-
413
- /** What words found, as `search_repo` lays it out for a model, one page of it. */
414
- export function formatSkillFind(found: RestSkillFind, summary: PackSummary | undefined): string {
415
- if (found.status === "none" || found.address === null) {
416
- return NO_ADDRESS;
417
- }
418
- if (found.status !== "ready" || found.read?.status !== "ready" || summary === undefined) {
419
- return refused("search", found);
420
- }
421
- return renderFindResult(findResultOf(found.read, summary), CONSOLE_WORDS);
422
- }
423
-
424
- /**
425
- * The pages of a file, as the console answered them, as the file whole; or the folder the path
426
- * named. With `requested`, the one page is a section read as asked (`--offset`, `--limit`): the
427
- * result carries the length asked for, so that the renderer says where the file continues rather
428
- * than asking for the rest.
429
- */
430
- export function joinFile(
431
- pages: readonly RestSkillFile[],
432
- summary: PackSummary,
433
- requested?: number,
434
- ): FileResult | DirectoryResult | undefined {
435
- const reads = pages.flatMap((page) => (page.read === null ? [] : [page.read]));
436
- const first = reads[0];
437
- if (first === undefined) {
438
- return undefined;
439
- }
440
- if (first.kind === "directory") {
441
- return directoryResultOf(first, summary);
442
- }
443
- const files = reads.flatMap((read) =>
444
- read.kind === "file" ? (fileResultOf(read, summary) ?? []) : [],
445
- );
446
- const opening = files[0];
447
- const closing = files[files.length - 1];
448
- if (opening === undefined || closing === undefined) {
449
- return undefined;
450
- }
451
- return {
452
- ...opening,
453
- mount: closing.mount,
454
- content: files.map((file) => file.content).join(""),
455
- nextOffset: closing.nextOffset,
456
- totalLength: closing.totalLength,
457
- ...(requested === undefined ? {} : { requestedLength: requested }),
458
- };
459
- }
460
-
461
- /** A file whole, or a folder, as the REST API answers it, for `--json`. */
462
- export const bodyOfFile = (result: FileResult | DirectoryResult): RestFile =>
463
- "entries" in result ? directoryBody(result) : fileBody(result);
464
-
465
- /** A file as `read_repo_file` lays it out for a model, whole; or what the folder holds. */
466
- export function formatSkillFile(
467
- read: RestSkillFile,
468
- whole: FileResult | DirectoryResult | undefined,
469
- ): string {
470
- if (read.status === "none" || read.address === null) {
471
- return NO_ADDRESS;
472
- }
473
- if (read.status !== "ready") {
474
- return refused("file", read);
475
- }
476
- if (whole === undefined) {
477
- return `${head("file", read)}\nNothing was read.`;
478
- }
479
- return "entries" in whole ? renderDirectoryResult(whole) : renderFileResult(whole, CONSOLE_WORDS);
480
- }
439
+ /** Whether a read of data held nothing, by what the read says it holds: no table, or no code block. */
440
+ export const holdsNothing = (holds: string | undefined): boolean =>
441
+ holds !== undefined && /(^| )0 (tables|code blocks)$/.test(holds);