@yaks/cli 0.0.0-stage → 0.2.36

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 (331) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +1059 -2
  3. package/_dist/account-forward.d.ts +12 -0
  4. package/_dist/account-forward.d.ts.map +1 -0
  5. package/_dist/accounts.d.ts +23 -0
  6. package/_dist/accounts.d.ts.map +1 -0
  7. package/_dist/answer.d.ts +88 -0
  8. package/_dist/answer.d.ts.map +1 -0
  9. package/_dist/apply.d.ts +17 -0
  10. package/_dist/apply.d.ts.map +1 -0
  11. package/_dist/args.d.ts +86 -0
  12. package/_dist/args.d.ts.map +1 -0
  13. package/_dist/commands.d.ts +15 -0
  14. package/_dist/commands.d.ts.map +1 -0
  15. package/_dist/complete.d.ts +15 -0
  16. package/_dist/complete.d.ts.map +1 -0
  17. package/_dist/config.d.ts +37 -0
  18. package/_dist/config.d.ts.map +1 -0
  19. package/_dist/dependencies.d.ts +6 -0
  20. package/_dist/dependencies.d.ts.map +1 -0
  21. package/_dist/facets.d.ts +71 -0
  22. package/_dist/facets.d.ts.map +1 -0
  23. package/_dist/grammar.d.ts +5 -0
  24. package/_dist/grammar.d.ts.map +1 -0
  25. package/_dist/host.d.ts +164 -0
  26. package/_dist/host.d.ts.map +1 -0
  27. package/_dist/install.d.ts +43 -0
  28. package/_dist/install.d.ts.map +1 -0
  29. package/_dist/main.d.ts +16 -0
  30. package/_dist/main.d.ts.map +1 -0
  31. package/_dist/memo.d.ts +60 -0
  32. package/_dist/memo.d.ts.map +1 -0
  33. package/_dist/mod.d.ts +46 -0
  34. package/_dist/mod.d.ts.map +1 -0
  35. package/_dist/page.d.ts +73 -0
  36. package/_dist/page.d.ts.map +1 -0
  37. package/_dist/platform.d.ts +27 -0
  38. package/_dist/platform.d.ts.map +1 -0
  39. package/_dist/reader.d.ts +10 -0
  40. package/_dist/reader.d.ts.map +1 -0
  41. package/_dist/release.d.ts +48 -0
  42. package/_dist/release.d.ts.map +1 -0
  43. package/_dist/remote.d.ts +13 -0
  44. package/_dist/remote.d.ts.map +1 -0
  45. package/_dist/reported.d.ts +11 -0
  46. package/_dist/reported.d.ts.map +1 -0
  47. package/_dist/roles.d.ts +2 -0
  48. package/_dist/roles.d.ts.map +1 -0
  49. package/_dist/roster.d.ts +41 -0
  50. package/_dist/roster.d.ts.map +1 -0
  51. package/_dist/rpc.d.ts +29 -0
  52. package/_dist/rpc.d.ts.map +1 -0
  53. package/_dist/run.d.ts +164 -0
  54. package/_dist/run.d.ts.map +1 -0
  55. package/_dist/runtime.d.ts +4 -0
  56. package/_dist/runtime.d.ts.map +1 -0
  57. package/_dist/searching.d.ts +7 -0
  58. package/_dist/searching.d.ts.map +1 -0
  59. package/_dist/show.d.ts +22 -0
  60. package/_dist/show.d.ts.map +1 -0
  61. package/_dist/store.d.ts +25 -0
  62. package/_dist/store.d.ts.map +1 -0
  63. package/_dist/terminal.d.ts +17 -0
  64. package/_dist/terminal.d.ts.map +1 -0
  65. package/_dist/tool.d.ts +55 -0
  66. package/_dist/tool.d.ts.map +1 -0
  67. package/_dist/tty.d.ts +3 -0
  68. package/_dist/tty.d.ts.map +1 -0
  69. package/_dist/vault.d.ts +9 -0
  70. package/_dist/vault.d.ts.map +1 -0
  71. package/_dist/words.d.ts +11 -0
  72. package/_dist/words.d.ts.map +1 -0
  73. package/_dist/yak.d.ts +10 -0
  74. package/_dist/yak.d.ts.map +1 -0
  75. package/account-forward.js +40 -0
  76. package/account-forward.js.map +1 -0
  77. package/account-forward.ts +50 -0
  78. package/accounts.js +162 -0
  79. package/accounts.js.map +1 -0
  80. package/accounts.ts +228 -0
  81. package/answer.js +394 -0
  82. package/answer.js.map +1 -0
  83. package/answer.ts +569 -0
  84. package/apply.js +49 -0
  85. package/apply.js.map +1 -0
  86. package/apply.ts +54 -0
  87. package/args.js +420 -0
  88. package/args.js.map +1 -0
  89. package/args.ts +494 -0
  90. package/code.js +209 -0
  91. package/code.js.map +1 -0
  92. package/code.ts +227 -0
  93. package/commands.js +131 -0
  94. package/commands.js.map +1 -0
  95. package/commands.ts +142 -0
  96. package/complete.js +104 -0
  97. package/complete.js.map +1 -0
  98. package/complete.ts +152 -0
  99. package/config.js +125 -0
  100. package/config.js.map +1 -0
  101. package/config.ts +180 -0
  102. package/declarations.js +67 -0
  103. package/declarations.js.map +1 -0
  104. package/declarations.ts +84 -0
  105. package/deno.json +1 -0
  106. package/dependencies.js +126 -0
  107. package/dependencies.js.map +1 -0
  108. package/dependencies.ts +141 -0
  109. package/derive.js +102 -0
  110. package/derive.js.map +1 -0
  111. package/derive.ts +125 -0
  112. package/drain.js +83 -0
  113. package/drain.js.map +1 -0
  114. package/drain.ts +115 -0
  115. package/duties.ts +17 -0
  116. package/exports.json +1486 -0
  117. package/external.js +373 -0
  118. package/external.js.map +1 -0
  119. package/external.ts +435 -0
  120. package/facets.js +214 -0
  121. package/facets.js.map +1 -0
  122. package/facets.ts +232 -0
  123. package/feedback.js +54 -0
  124. package/feedback.js.map +1 -0
  125. package/feedback.ts +57 -0
  126. package/files.js +84 -0
  127. package/files.js.map +1 -0
  128. package/files.ts +112 -0
  129. package/get_starts.js +31 -0
  130. package/get_starts.js.map +1 -0
  131. package/get_starts.ts +34 -0
  132. package/git-credential.js +79 -0
  133. package/git-credential.js.map +1 -0
  134. package/git-credential.ts +77 -0
  135. package/grammar.js +4 -0
  136. package/grammar.js.map +1 -0
  137. package/grammar.ts +5 -0
  138. package/held.js +51 -0
  139. package/held.js.map +1 -0
  140. package/held.ts +66 -0
  141. package/host.js +1174 -0
  142. package/host.js.map +1 -0
  143. package/host.ts +1343 -0
  144. package/init.js +138 -0
  145. package/init.js.map +1 -0
  146. package/init.ts +139 -0
  147. package/install.js +216 -0
  148. package/install.js.map +1 -0
  149. package/install.ts +223 -0
  150. package/lifetime.js +56 -0
  151. package/lifetime.js.map +1 -0
  152. package/lifetime.ts +66 -0
  153. package/local-page.ts +114 -0
  154. package/local.js +417 -0
  155. package/local.js.map +1 -0
  156. package/local.ts +537 -0
  157. package/lockfile.js +20 -0
  158. package/lockfile.js.map +1 -0
  159. package/lockfile.ts +32 -0
  160. package/machines.js +33 -0
  161. package/machines.js.map +1 -0
  162. package/machines.ts +51 -0
  163. package/made/4f855610bdabcd736100d34e4e467ea5.json +1 -0
  164. package/main.js +534 -0
  165. package/main.js.map +1 -0
  166. package/main.ts +547 -0
  167. package/mcp.js +108 -0
  168. package/mcp.js.map +1 -0
  169. package/mcp.ts +113 -0
  170. package/member.js +103 -0
  171. package/member.js.map +1 -0
  172. package/member.ts +133 -0
  173. package/memo.js +503 -0
  174. package/memo.js.map +1 -0
  175. package/memo.ts +634 -0
  176. package/mod.js +46 -0
  177. package/mod.js.map +1 -0
  178. package/mod.ts +99 -0
  179. package/operations.js +53 -0
  180. package/operations.js.map +1 -0
  181. package/operations.ts +68 -0
  182. package/package.json +115 -4
  183. package/page.js +211 -0
  184. package/page.js.map +1 -0
  185. package/page.ts +308 -0
  186. package/parser.js +45 -0
  187. package/parser.js.map +1 -0
  188. package/parser.ts +77 -0
  189. package/people-search.js +112 -0
  190. package/people-search.js.map +1 -0
  191. package/people-search.ts +162 -0
  192. package/platform.js +184 -0
  193. package/platform.js.map +1 -0
  194. package/platform.ts +224 -0
  195. package/platform_effects.js +5 -0
  196. package/platform_effects.js.map +1 -0
  197. package/platform_effects.ts +13 -0
  198. package/prepare.js +40 -0
  199. package/prepare.js.map +1 -0
  200. package/prepare.ts +46 -0
  201. package/read_activity.js +54 -0
  202. package/read_activity.js.map +1 -0
  203. package/read_activity.ts +61 -0
  204. package/read_thread.js +387 -0
  205. package/read_thread.js.map +1 -0
  206. package/read_thread.ts +506 -0
  207. package/read_worker.ts +164 -0
  208. package/reader.js +48 -0
  209. package/reader.js.map +1 -0
  210. package/reader.ts +57 -0
  211. package/release.js +82 -0
  212. package/release.js.map +1 -0
  213. package/release.json +127 -0
  214. package/release.ts +98 -0
  215. package/remote-page.ts +70 -0
  216. package/remote.js +96 -0
  217. package/remote.js.map +1 -0
  218. package/remote.ts +153 -0
  219. package/report.js +83 -0
  220. package/report.js.map +1 -0
  221. package/report.ts +101 -0
  222. package/reported.js +32 -0
  223. package/reported.js.map +1 -0
  224. package/reported.ts +38 -0
  225. package/restart.js +349 -0
  226. package/restart.js.map +1 -0
  227. package/restart.ts +478 -0
  228. package/restore.js +32 -0
  229. package/restore.js.map +1 -0
  230. package/restore.ts +38 -0
  231. package/roles.js +32 -0
  232. package/roles.js.map +1 -0
  233. package/roles.ts +49 -0
  234. package/roster.js +65 -0
  235. package/roster.js.map +1 -0
  236. package/roster.ts +84 -0
  237. package/rpc.js +113 -0
  238. package/rpc.js.map +1 -0
  239. package/rpc.ts +159 -0
  240. package/run.js +533 -0
  241. package/run.js.map +1 -0
  242. package/run.ts +741 -0
  243. package/runtime.js +381 -0
  244. package/runtime.js.map +1 -0
  245. package/runtime.ts +433 -0
  246. package/sandboxes.js +26 -0
  247. package/sandboxes.js.map +1 -0
  248. package/sandboxes.ts +30 -0
  249. package/searching.js +33 -0
  250. package/searching.js.map +1 -0
  251. package/searching.ts +50 -0
  252. package/show.js +109 -0
  253. package/show.js.map +1 -0
  254. package/show.ts +144 -0
  255. package/shown.js +13 -0
  256. package/shown.js.map +1 -0
  257. package/shown.ts +44 -0
  258. package/stall.js +90 -0
  259. package/stall.js.map +1 -0
  260. package/stall.ts +156 -0
  261. package/stall_profile.js +113 -0
  262. package/stall_profile.js.map +1 -0
  263. package/stall_profile.ts +142 -0
  264. package/stall_wait.js +183 -0
  265. package/stall_wait.js.map +1 -0
  266. package/stall_wait.ts +249 -0
  267. package/stall_wait_worker.ts +11 -0
  268. package/start.js +349 -0
  269. package/start.js.map +1 -0
  270. package/start.ts +343 -0
  271. package/starvation.js +147 -0
  272. package/starvation.js.map +1 -0
  273. package/starvation.ts +224 -0
  274. package/store.js +118 -0
  275. package/store.js.map +1 -0
  276. package/store.ts +193 -0
  277. package/subcommands.js +62 -0
  278. package/subcommands.js.map +1 -0
  279. package/subcommands.ts +77 -0
  280. package/terminal.js +93 -0
  281. package/terminal.js.map +1 -0
  282. package/terminal.ts +128 -0
  283. package/text.js +20 -0
  284. package/text.js.map +1 -0
  285. package/text.ts +37 -0
  286. package/tool.js +76 -0
  287. package/tool.js.map +1 -0
  288. package/tool.ts +157 -0
  289. package/trace_control.js +231 -0
  290. package/trace_control.js.map +1 -0
  291. package/trace_control.ts +233 -0
  292. package/traces.js +138 -0
  293. package/traces.js.map +1 -0
  294. package/traces.ts +160 -0
  295. package/tracker.js +22 -0
  296. package/tracker.js.map +1 -0
  297. package/tracker.ts +27 -0
  298. package/tty.js +82 -0
  299. package/tty.js.map +1 -0
  300. package/tty.ts +142 -0
  301. package/unit_failure.js +178 -0
  302. package/unit_failure.js.map +1 -0
  303. package/unit_failure.ts +191 -0
  304. package/upkeep_thread.js +32 -0
  305. package/upkeep_thread.js.map +1 -0
  306. package/upkeep_thread.ts +35 -0
  307. package/upkeep_worker.ts +27 -0
  308. package/vault.js +186 -0
  309. package/vault.js.map +1 -0
  310. package/vault.ts +220 -0
  311. package/vocab-ids.js +63 -0
  312. package/vocab-ids.js.map +1 -0
  313. package/vocab-ids.ts +62 -0
  314. package/vocab.json +35 -0
  315. package/warm.js +138 -0
  316. package/warm.js.map +1 -0
  317. package/warm.ts +171 -0
  318. package/watch_revision.js +25 -0
  319. package/watch_revision.js.map +1 -0
  320. package/watch_revision.ts +30 -0
  321. package/words.js +29 -0
  322. package/words.js.map +1 -0
  323. package/words.ts +41 -0
  324. package/workspaces.js +40 -0
  325. package/workspaces.js.map +1 -0
  326. package/workspaces.ts +58 -0
  327. package/yak-unit-failure.conf +6 -0
  328. package/yak-unit-handoff.conf +2 -0
  329. package/yak.js +123 -0
  330. package/yak.js.map +1 -0
  331. package/yak.ts +136 -0
@@ -0,0 +1,79 @@
1
+ import { accountToken } from "./accounts.js";
2
+ import { saidBy } from "./roster.js";
3
+ import { doorUrl, rpc } from "./rpc.js";
4
+ let spaceOf = (input)=>{
5
+ let fields = new Map(input.trimEnd().split(/\r?\n/).map((row)=>{
6
+ let at = row.indexOf('=');
7
+ return [
8
+ row.slice(0, at),
9
+ row.slice(at + 1)
10
+ ];
11
+ }));
12
+ let path = fields.get('path')?.replace(/^\//, '') ?? '';
13
+ if (fields.get('protocol') != 'https' || !/^(?:[a-z0-9-]+)?\.git$/.test(path)) {
14
+ return;
15
+ }
16
+ return /^([a-z0-9][a-z0-9-]*)\.yaks\.app$/.exec(fields.get('host') ?? '')?.[1];
17
+ };
18
+ let grantOf = (text)=>/^yaks_[A-Za-z0-9_.=-]+$/.test(text);
19
+ /** Git receives a space grant through its credential protocol. */ export let gitCredential = async (input, token, connect)=>{
20
+ let space = spaceOf(input);
21
+ if (!space) return;
22
+ let credential = await token();
23
+ if (!credential) return;
24
+ if (!grantOf(credential)) {
25
+ let result = await connect(credential)('tools/call', {
26
+ name: 'grant',
27
+ arguments: {
28
+ space,
29
+ hours: 1 / 12
30
+ }
31
+ });
32
+ if (result.isError) return;
33
+ credential = /^yak login (\S+)/.exec(saidBy(result).text)?.[1] ?? '';
34
+ }
35
+ if (grantOf(credential)) return `username=yak\npassword=${credential}\n`;
36
+ };
37
+ export let gitCredentialCommand = {
38
+ name: 'git_credential',
39
+ noun: 'git',
40
+ verb: 'credential',
41
+ description: 'Supply a yaks.app credential to Git',
42
+ positional: [
43
+ 'operation'
44
+ ],
45
+ inputSchema: {
46
+ type: 'object',
47
+ properties: {
48
+ operation: {
49
+ type: 'string',
50
+ enum: [
51
+ 'get',
52
+ 'store',
53
+ 'erase'
54
+ ]
55
+ }
56
+ },
57
+ required: [
58
+ 'operation'
59
+ ]
60
+ },
61
+ run: async ({ operation }, ctx)=>{
62
+ let input = await ctx.reads.stdin();
63
+ if (operation != 'get' || !spaceOf(input)) return 0;
64
+ let credential = await gitCredential(input, ()=>accountToken('yaks.app', ctx.state, {
65
+ config: ctx.config,
66
+ as: ctx.as,
67
+ agent: !!ctx.via
68
+ }), (token)=>rpc({
69
+ url: doorUrl('yaks.app'),
70
+ token
71
+ })).catch(()=>undefined);
72
+ if (credential) ctx.out(credential);
73
+ else {
74
+ ctx.note('yak: no Git credential available. Sign in with yak auth yaks.app.');
75
+ }
76
+ return 0;
77
+ }
78
+ };
79
+ //# sourceMappingURL=git-credential.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-credential.js","sources":["./git-credential.ts"],"names":[],"mappings":"AAAA,SAAS,YAAY,wBAAuB;AAC5C,SAAS,MAAM,sBAAqB;AACpC,SAAS,OAAO,EAAY,GAAG,mBAAkB;AAGjD,IAAI,UAAU,CAAC;EACb,IAAI,SAAS,IAAI,IACf,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;IAClC,IAAI,KAAK,IAAI,OAAO,CAAC;IACrB,OAAO;MAAC,IAAI,KAAK,CAAC,GAAG;MAAK,IAAI,KAAK,CAAC,KAAK;KAAG;EAC9C;EAEF,IAAI,OAAO,OAAO,GAAG,CAAC,SAAS,QAAQ,OAAO,OAAO;EACrD,IACE,OAAO,GAAG,CAAC,eAAe,WAAW,CAAC,yBAAyB,IAAI,CAAC,OACpE;IACA;EACF;EACA,OAAO,oCAAoC,IAAI,CAAC,OAAO,GAAG,CAAC,WAAW,KAAK,CAAC,EAAE;AAChF;AAEA,IAAI,UAAU,CAAC,OAAiB,0BAA0B,IAAI,CAAC;AAE/D,gEAAgE,GAChE,OAAO,IAAI,gBAAgB,OACzB,OACA,OACA;EAEA,IAAI,QAAQ,QAAQ;EACpB,IAAI,CAAC,OAAO;EACZ,IAAI,aAAa,MAAM;EACvB,IAAI,CAAC,YAAY;EACjB,IAAI,CAAC,QAAQ,aAAa;IACxB,IAAI,SAAS,MAAM,QAAQ,YAAY,cAAc;MACnD,MAAM;MACN,WAAW;QAAE;QAAO,OAAO,IAAI;MAAG;IACpC;IACA,IAAI,OAAO,OAAO,EAAE;IACpB,aAAa,mBAAmB,IAAI,CAAC,OAAO,QAAQ,IAAI,GAAG,CAAC,EAAE,IAAI;EACpE;EACA,IAAI,QAAQ,aAAa,OAAO,CAAC,uBAAuB,EAAE,WAAW,EAAE,CAAC;AAC1E,EAAC;AAED,OAAO,IAAI,uBAAgC;EACzC,MAAM;EACN,MAAM;EACN,MAAM;EACN,aAAa;EACb,YAAY;IAAC;GAAY;EACzB,aAAa;IACX,MAAM;IACN,YAAY;MACV,WAAW;QAAE,MAAM;QAAU,MAAM;UAAC;UAAO;UAAS;SAAQ;MAAC;IAC/D;IACA,UAAU;MAAC;KAAY;EACzB;EACA,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE;IACzB,IAAI,QAAQ,MAAM,IAAI,KAAK,CAAC,KAAK;IACjC,IAAI,aAAa,SAAS,CAAC,QAAQ,QAAQ,OAAO;IAClD,IAAI,aAAa,MAAM,cACrB,OACA,IACE,aAAa,YAAY,IAAI,KAAK,EAAE;QAClC,QAAQ,IAAI,MAAM;QAClB,IAAI,IAAI,EAAE;QACV,OAAO,CAAC,CAAC,IAAI,GAAG;MAClB,IACF,CAAC,QAAU,IAAI;QAAE,KAAK,QAAQ;QAAa;MAAM,IACjD,KAAK,CAAC,IAAM;IACd,IAAI,YAAY,IAAI,GAAG,CAAC;SACnB;MAAC,IAAI,IAAI,CACV;IACD;IACH,OAAO;EACT;AACF,EAAC"}
@@ -0,0 +1,77 @@
1
+ import { accountToken } from './accounts.js'
2
+ import { saidBy } from './roster.js'
3
+ import { doorUrl, type Rpc, rpc } from './rpc.js'
4
+ import type { Command } from './run.ts'
5
+
6
+ let spaceOf = (input: string) => {
7
+ let fields = new Map(
8
+ input.trimEnd().split(/\r?\n/).map((row) => {
9
+ let at = row.indexOf('=')
10
+ return [row.slice(0, at), row.slice(at + 1)]
11
+ }),
12
+ )
13
+ let path = fields.get('path')?.replace(/^\//, '') ?? ''
14
+ if (
15
+ fields.get('protocol') != 'https' || !/^(?:[a-z0-9-]+)?\.git$/.test(path)
16
+ ) {
17
+ return
18
+ }
19
+ return /^([a-z0-9][a-z0-9-]*)\.yaks\.app$/.exec(fields.get('host') ?? '')?.[1]
20
+ }
21
+
22
+ let grantOf = (text: string) => /^yaks_[A-Za-z0-9_.=-]+$/.test(text)
23
+
24
+ /** Git receives a space grant through its credential protocol. */
25
+ export let gitCredential = async (
26
+ input: string,
27
+ token: () => Promise<string | null>,
28
+ connect: (token: string) => Rpc,
29
+ ): Promise<string | undefined> => {
30
+ let space = spaceOf(input)
31
+ if (!space) return
32
+ let credential = await token()
33
+ if (!credential) return
34
+ if (!grantOf(credential)) {
35
+ let result = await connect(credential)('tools/call', {
36
+ name: 'grant',
37
+ arguments: { space, hours: 1 / 12 },
38
+ })
39
+ if (result.isError) return
40
+ credential = /^yak login (\S+)/.exec(saidBy(result).text)?.[1] ?? ''
41
+ }
42
+ if (grantOf(credential)) return `username=yak\npassword=${credential}\n`
43
+ }
44
+
45
+ export let gitCredentialCommand: Command = {
46
+ name: 'git_credential',
47
+ noun: 'git',
48
+ verb: 'credential',
49
+ description: 'Supply a yaks.app credential to Git',
50
+ positional: ['operation'],
51
+ inputSchema: {
52
+ type: 'object',
53
+ properties: {
54
+ operation: { type: 'string', enum: ['get', 'store', 'erase'] },
55
+ },
56
+ required: ['operation'],
57
+ },
58
+ run: async ({ operation }, ctx) => {
59
+ let input = await ctx.reads.stdin()
60
+ if (operation != 'get' || !spaceOf(input)) return 0
61
+ let credential = await gitCredential(
62
+ input,
63
+ () =>
64
+ accountToken('yaks.app', ctx.state, {
65
+ config: ctx.config,
66
+ as: ctx.as,
67
+ agent: !!ctx.via,
68
+ }),
69
+ (token) => rpc({ url: doorUrl('yaks.app'), token }),
70
+ ).catch(() => undefined)
71
+ if (credential) ctx.out(credential)
72
+ else {ctx.note(
73
+ 'yak: no Git credential available. Sign in with yak auth yaks.app.',
74
+ )}
75
+ return 0
76
+ },
77
+ }
package/grammar.js ADDED
@@ -0,0 +1,4 @@
1
+ /** Browser-safe command grammar, completion and help text, with no runtime IO. */ export * from "./args.js";
2
+ export { complete, quoted } from "./complete.js";
3
+ export { toolHelp, toolLines } from "./show.js";
4
+ //# sourceMappingURL=grammar.js.map
package/grammar.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grammar.js","sources":["./grammar.ts"],"names":[],"mappings":"AAAA,gFAAgF,GAChF,0BAAyB;AACzB,SAAS,QAAQ,EAAe,MAAM,wBAAuB;AAE7D,SAAS,QAAQ,EAAE,SAAS,oBAAmB"}
package/grammar.ts ADDED
@@ -0,0 +1,5 @@
1
+ /** Browser-safe command grammar, completion and help text, with no runtime IO. */
2
+ export * from './args.js'
3
+ export { complete, type Lookup, quoted } from './complete.js'
4
+ export { type Prop, type Schema } from './tool.js'
5
+ export { toolHelp, toolLines } from './show.js'
package/held.js ADDED
@@ -0,0 +1,51 @@
1
+ // The graphs this process holds open, however each was opened (./local.ts),
2
+ // and how they end: what a command does with them when it is done or
3
+ // interrupted (./yak.ts), whether or not it opened any. A module of its own,
4
+ // so a command that opens nothing never loads the code that opens a graph.
5
+ /** One graph per config path and set of roles, for the life of the process:
6
+ * every call a command makes goes through the same assembled graph, and
7
+ * opening the file twice for the same roles would mean two writers in one
8
+ * process for no reason. */ export let hosts = new Map();
9
+ /** The duty threads those graphs started, for a close that cannot wait on
10
+ * them. */ export let asides = new Set();
11
+ /** Work a closing graph stopped but cannot wait on, let settle before the
12
+ * process ends: a page body still being made (./page.ts), which a host that
13
+ * stops cancels, and whose compiler would otherwise outlive the process. */ export let settling = new Set();
14
+ // How long a close lets stopped work settle: a make that ignores its abort
15
+ // never keeps the process from ending.
16
+ let grace = 5_000;
17
+ /** Ask every graph this process opened to wind down (host.ts `stop`): it
18
+ * takes no new request, effect or step, and the command in flight finishes
19
+ * what it started and returns on its own. False when it opened none, and
20
+ * there is nothing to wait for. */ export let stop = ()=>{
21
+ for (let host of hosts.values())host.then((h)=>h.stop(), ()=>{});
22
+ return hosts.size > 0;
23
+ };
24
+ /** Stop waiting on what is winding down: every duty thread this process
25
+ * started is ended where it stands (@yaks/threads `end`), so a close waiting on
26
+ * one goes on to its last write. What a second interrupt does before it
27
+ * closes (./yak.ts). */ export let cut = ()=>asides.forEach((a)=>a.end());
28
+ /** Close every graph this process opened, stamping how the command ended on
29
+ * the `process` row each of them holds. */ export let close = (code)=>// One close at a time: an interrupt's (./yak.ts) and the command's own
30
+ // ending can arrive together, and the second waits on the first.
31
+ closing ??= (async ()=>{
32
+ // Awaited, because the last batch is a write: a command that closed the
33
+ // file without waiting would leave its own row saying it is still running.
34
+ // A graph that failed to open has nothing to close, and the command said
35
+ // why.
36
+ for (let host of hosts.values()){
37
+ await (await host.catch(()=>undefined))?.close(code);
38
+ }
39
+ hosts.clear();
40
+ asides.clear();
41
+ let timer;
42
+ await Promise.race([
43
+ Promise.allSettled([
44
+ ...settling
45
+ ]),
46
+ new Promise((done)=>timer = setTimeout(done, grace))
47
+ ]);
48
+ clearTimeout(timer);
49
+ })().finally(()=>closing = undefined);
50
+ let closing;
51
+ //# sourceMappingURL=held.js.map
package/held.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"held.js","sources":["./held.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,qEAAqE;AACrE,6EAA6E;AAC7E,2EAA2E;AAK3E;;;0BAG0B,GAC1B,OAAO,IAAI,QAAQ,IAAI,MAA8B;AAErD;SACS,GACT,OAAO,IAAI,SAAS,IAAI,MAAoB;AAE5C;;0EAE0E,GAC1E,OAAO,IAAI,WAAW,IAAI,MAAuB;AAEjD,2EAA2E;AAC3E,uCAAuC;AACvC,IAAI,QAAQ;AAEZ;;;iCAGiC,GACjC,OAAO,IAAI,OAAO;EAChB,KAAK,IAAI,QAAQ,MAAM,MAAM,GAAI,KAAK,IAAI,CAAC,CAAC,IAAM,EAAE,IAAI,IAAI,KAAO;EACnE,OAAO,MAAM,IAAI,GAAG;AACtB,EAAC;AAED;;;sBAGsB,GACtB,OAAO,IAAI,MAAM,IAAY,OAAO,OAAO,CAAC,CAAC,IAAM,EAAE,GAAG,IAAG;AAE3D;yCACyC,GACzC,OAAO,IAAI,QAAQ,CAAC,OAClB,uEAAuE;EACvE,iEAAiE;EACjE,YAAY,CAAC;IACX,wEAAwE;IACxE,2EAA2E;IAC3E,yEAAyE;IACzE,OAAO;IACP,KAAK,IAAI,QAAQ,MAAM,MAAM,GAAI;MAC/B,MAAM,CAAC,MAAM,KAAK,KAAK,CAAC,IAAM,UAAU,GAAG,MAAM;IACnD;IACA,MAAM,KAAK;IACX,OAAO,KAAK;IACZ,IAAI;IACJ,MAAM,QAAQ,IAAI,CAAC;MACjB,QAAQ,UAAU,CAAC;WAAI;OAAS;MAChC,IAAI,QAAQ,CAAC,OAAS,QAAQ,WAAW,MAAM;KAChD;IACD,aAAa;EACf,CAAC,IAAI,OAAO,CAAC,IAAM,UAAU,WAAU;AAEzC,IAAI"}
package/held.ts ADDED
@@ -0,0 +1,66 @@
1
+ // The graphs this process holds open, however each was opened (./local.ts),
2
+ // and how they end: what a command does with them when it is done or
3
+ // interrupted (./yak.ts), whether or not it opened any. A module of its own,
4
+ // so a command that opens nothing never loads the code that opens a graph.
5
+
6
+ import type { Aside } from 'jsr:@yaks/threads@0.2.36'
7
+ import type { Served } from './host.ts'
8
+
9
+ /** One graph per config path and set of roles, for the life of the process:
10
+ * every call a command makes goes through the same assembled graph, and
11
+ * opening the file twice for the same roles would mean two writers in one
12
+ * process for no reason. */
13
+ export let hosts = new Map<string, Promise<Served>>()
14
+
15
+ /** The duty threads those graphs started, for a close that cannot wait on
16
+ * them. */
17
+ export let asides = new Set<Aside<string>>()
18
+
19
+ /** Work a closing graph stopped but cannot wait on, let settle before the
20
+ * process ends: a page body still being made (./page.ts), which a host that
21
+ * stops cancels, and whose compiler would otherwise outlive the process. */
22
+ export let settling = new Set<Promise<unknown>>()
23
+
24
+ // How long a close lets stopped work settle: a make that ignores its abort
25
+ // never keeps the process from ending.
26
+ let grace = 5_000
27
+
28
+ /** Ask every graph this process opened to wind down (host.ts `stop`): it
29
+ * takes no new request, effect or step, and the command in flight finishes
30
+ * what it started and returns on its own. False when it opened none, and
31
+ * there is nothing to wait for. */
32
+ export let stop = (): boolean => {
33
+ for (let host of hosts.values()) host.then((h) => h.stop(), () => {})
34
+ return hosts.size > 0
35
+ }
36
+
37
+ /** Stop waiting on what is winding down: every duty thread this process
38
+ * started is ended where it stands (@yaks/threads `end`), so a close waiting on
39
+ * one goes on to its last write. What a second interrupt does before it
40
+ * closes (./yak.ts). */
41
+ export let cut = (): void => asides.forEach((a) => a.end())
42
+
43
+ /** Close every graph this process opened, stamping how the command ended on
44
+ * the `process` row each of them holds. */
45
+ export let close = (code?: number): Promise<void> =>
46
+ // One close at a time: an interrupt's (./yak.ts) and the command's own
47
+ // ending can arrive together, and the second waits on the first.
48
+ closing ??= (async () => {
49
+ // Awaited, because the last batch is a write: a command that closed the
50
+ // file without waiting would leave its own row saying it is still running.
51
+ // A graph that failed to open has nothing to close, and the command said
52
+ // why.
53
+ for (let host of hosts.values()) {
54
+ await (await host.catch(() => undefined))?.close(code)
55
+ }
56
+ hosts.clear()
57
+ asides.clear()
58
+ let timer: ReturnType<typeof setTimeout> | undefined
59
+ await Promise.race([
60
+ Promise.allSettled([...settling]),
61
+ new Promise((done) => timer = setTimeout(done, grace)),
62
+ ])
63
+ clearTimeout(timer)
64
+ })().finally(() => closing = undefined)
65
+
66
+ let closing: Promise<void> | undefined