@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
package/init.js ADDED
@@ -0,0 +1,138 @@
1
+ // What `yak init` writes: the config a new machine's graph starts from. A
2
+ // config is the one statement of where a graph is and what reads and writes it
3
+ // (./config.ts), and a person arriving with nothing should not have to know
4
+ // which of the @yaks packages compose before their first command works.
5
+ //
6
+ // The set is the graph, its tasks and projects, the people and sessions that
7
+ // work on them and the processes a session runs in — so Claude Code or any MCP
8
+ // agent can join through hooks and `/mcp` — the person's connections to outside
9
+ // services, so `yak auth yaks.app` signs in to this graph and every command
10
+ // reaching yaks.app finds the token here, and the web canvas `yak serve`
11
+ // answers with, whose session pages read those processes, and the Spend page,
12
+ // which tallies what the models those sessions asked cost. Everything else is
13
+ // one line added to `plugins` later. Pure data: yak.ts writes it and opens the
14
+ // graph it names.
15
+ /** The plugins a new graph starts with, each a bare `@yaks/…` name the CLI
16
+ * resolves from its own release (./config.ts `located`). */ export let STARTER = [
17
+ '@yaks/kernel',
18
+ '@yaks/provenance',
19
+ '@yaks/id',
20
+ '@yaks/secrets',
21
+ '@yaks/connections',
22
+ '@yaks/alias',
23
+ '@yaks/edge',
24
+ '@yaks/doc',
25
+ '@yaks/markdown',
26
+ '@yaks/draft',
27
+ '@yaks/effects',
28
+ '@yaks/journal',
29
+ '@yaks/tools',
30
+ '@yaks/task',
31
+ '@yaks/project',
32
+ '@yaks/persona',
33
+ '@yaks/memory',
34
+ '@yaks/topic',
35
+ '@yaks/process',
36
+ '@yaks/session',
37
+ '@yaks/api',
38
+ '@yaks/mcp',
39
+ '@yaks/web',
40
+ '@yaks/browse',
41
+ '@yaks/canvas',
42
+ '@yaks/model',
43
+ '@yaks/spend'
44
+ ];
45
+ /** The config a new graph starts from, its database beside it on disk, and
46
+ * `person` the one who works in it. */ export let starter = (person)=>({
47
+ db: 'yak.db',
48
+ plugins: [
49
+ ...STARTER
50
+ ],
51
+ numbers: true,
52
+ person
53
+ });
54
+ /** `yak init --force`'s config: the starter at this release, keeping `old`'s
55
+ * graph (`db`) and person, with a line for each other value of `old` it
56
+ * replaces or drops.
57
+ *
58
+ * ```ts
59
+ * import { assertEquals } from '@std/assert'
60
+ * let old = { db: 'g.db', person: 'p', plugins: ['@yaks/kernel', '@yaks/old'], port: 9 }
61
+ * let { config, replaced } = refreshed(old)
62
+ * assertEquals([config.db, config.person], ['g.db', 'p'])
63
+ * assertEquals(replaced[0].startsWith('plugins: dropped @yaks/old; added '), true)
64
+ * assertEquals(replaced[1], 'port: dropped 9')
65
+ * ```
66
+ */ export let refreshed = (old)=>{
67
+ let config = {
68
+ ...starter(String(old.person)),
69
+ ...old.db ? {
70
+ db: old.db
71
+ } : {}
72
+ };
73
+ let fresh = config;
74
+ let replaced = Object.entries(old).flatMap(([key, was])=>{
75
+ let now = fresh[key];
76
+ if (JSON.stringify(was) == JSON.stringify(now)) return [];
77
+ if (key == 'plugins' && Array.isArray(was)) {
78
+ let named = (list)=>new Set(list.map((p)=>typeof p == 'string' ? p : JSON.stringify(p)));
79
+ let before = named(was);
80
+ let after = named(now);
81
+ let dropped = [
82
+ ...before
83
+ ].filter((p)=>!after.has(p));
84
+ let added = [
85
+ ...after
86
+ ].filter((p)=>!before.has(p));
87
+ let parts = [
88
+ dropped.length && `dropped ${dropped.join(', ')}`,
89
+ added.length && `added ${added.join(', ')}`
90
+ ].filter(Boolean);
91
+ return parts.length ? [
92
+ `plugins: ${parts.join('; ')}`
93
+ ] : [];
94
+ }
95
+ return [
96
+ now === undefined ? `${key}: dropped ${JSON.stringify(was)}` : `${key}: was ${JSON.stringify(was)}`
97
+ ];
98
+ });
99
+ return {
100
+ config,
101
+ replaced
102
+ };
103
+ };
104
+ /** The person `yak init` makes, under the name it found for them, or none. */ export let personOf = (eid, name)=>({
105
+ entity: {
106
+ eid
107
+ },
108
+ person: {},
109
+ ...name ? {
110
+ doc: {
111
+ title: name
112
+ }
113
+ } : {}
114
+ });
115
+ /** The graph's first task: confirming the name `yak init` gave the person it
116
+ * made, found rather than asked for, so the first command asks for nothing.
117
+ * It is filed to them, so any agent that connects finds it with the rest of
118
+ * their work and asks them whether the name is right, or what it is where
119
+ * none was found.
120
+ *
121
+ * ```ts
122
+ * import { assertEquals } from '@std/assert'
123
+ * assertEquals(naming('p').filed, { assignee: 'p' })
124
+ * ```
125
+ */ export let naming = (person, name)=>({
126
+ entity: {
127
+ eid: crypto.randomUUID()
128
+ },
129
+ task: {},
130
+ filed: {
131
+ assignee: person
132
+ },
133
+ doc: {
134
+ title: name ? `Confirm that ${name} is the name of the person who works in this graph` : 'Ask the person who works in this graph for their name',
135
+ body: 'The person this task is filed to is who everything typed here is ' + 'signed by. ' + (name ? `\`yak init\` named them ${name}, from git's \`user.name\` or the ` + 'login user. Ask them whether that is right; ' : '`yak init` found no name for them. Ask them for it; ') + '`yak name <their name>` writes it. Then complete this task.'
136
+ }
137
+ });
138
+ //# sourceMappingURL=init.js.map
package/init.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sources":["./init.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,gFAAgF;AAChF,4EAA4E;AAC5E,yEAAyE;AACzE,8EAA8E;AAC9E,8EAA8E;AAC9E,+EAA+E;AAC/E,kBAAkB;AAIlB;0DAC0D,GAC1D,OAAO,IAAI,UAAU;EACnB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,CAAA;AAED;qCACqC,GACrC,OAAO,IAAI,UAAU,CAAC,SAA2B,CAAC;IAChD,IAAI;IACJ,SAAS;SAAI;KAAQ;IACrB,SAAS;IACT;EACF,CAAC,EAAC;AAEF;;;;;;;;;;;;CAYC,GACD,OAAO,IAAI,YAAY,CACrB;EAEA,IAAI,SAAS;IACX,GAAG,QAAQ,OAAO,IAAI,MAAM,EAAE;IAC9B,GAAI,IAAI,EAAE,GAAG;MAAE,IAAI,IAAI,EAAE;IAAW,IAAI,CAAC,CAAC;EAC5C;EACA,IAAI,QAA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EAAC;AAEF;;;;;;;;;;CAUC,GACD,OAAO,IAAI,SAAS,CAAC,QAAgB,OAAkB,CAAC;IACtD,QAAQ;MAAE,KAAK,OAAO,UAAU;IAAG;IACnC,MAAM,CAAC;IACP,OAAO;MAAE,UAAU;IAAO;IAC1B,KAAK;MACH,OAAO,OACH,CAAC,aAAa,EAAE,KAAK,kDAAkD,CAAC,GACxE;MACJ,MAAM,sEACJ,gBACA,CAAC,OACG,CAAC,wBAAwB,EAAE,KAAK,kCAAkC,CAAC,GACnE,iDACA,sDAAsD,IAC1D;IACJ;EACF,CAAC,EAAC"}
package/init.ts ADDED
@@ -0,0 +1,139 @@
1
+ // What `yak init` writes: the config a new machine's graph starts from. A
2
+ // config is the one statement of where a graph is and what reads and writes it
3
+ // (./config.ts), and a person arriving with nothing should not have to know
4
+ // which of the @yaks packages compose before their first command works.
5
+ //
6
+ // The set is the graph, its tasks and projects, the people and sessions that
7
+ // work on them and the processes a session runs in — so Claude Code or any MCP
8
+ // agent can join through hooks and `/mcp` — the person's connections to outside
9
+ // services, so `yak auth yaks.app` signs in to this graph and every command
10
+ // reaching yaks.app finds the token here, and the web canvas `yak serve`
11
+ // answers with, whose session pages read those processes, and the Spend page,
12
+ // which tallies what the models those sessions asked cost. Everything else is
13
+ // one line added to `plugins` later. Pure data: yak.ts writes it and opens the
14
+ // graph it names.
15
+
16
+ import type { Config } from './config.ts'
17
+
18
+ /** The plugins a new graph starts with, each a bare `@yaks/…` name the CLI
19
+ * resolves from its own release (./config.ts `located`). */
20
+ export let STARTER = [
21
+ '@yaks/kernel',
22
+ '@yaks/provenance',
23
+ '@yaks/id',
24
+ '@yaks/secrets',
25
+ '@yaks/connections',
26
+ '@yaks/alias',
27
+ '@yaks/edge',
28
+ '@yaks/doc',
29
+ '@yaks/markdown',
30
+ '@yaks/draft',
31
+ '@yaks/effects',
32
+ '@yaks/journal',
33
+ '@yaks/tools',
34
+ '@yaks/task',
35
+ '@yaks/project',
36
+ '@yaks/persona',
37
+ '@yaks/memory',
38
+ '@yaks/topic',
39
+ '@yaks/process',
40
+ '@yaks/session',
41
+ '@yaks/api',
42
+ '@yaks/mcp',
43
+ '@yaks/web',
44
+ '@yaks/browse',
45
+ '@yaks/canvas',
46
+ '@yaks/model',
47
+ '@yaks/spend',
48
+ ]
49
+
50
+ /** The config a new graph starts from, its database beside it on disk, and
51
+ * `person` the one who works in it. */
52
+ export let starter = (person: string): Config => ({
53
+ db: 'yak.db',
54
+ plugins: [...STARTER],
55
+ numbers: true,
56
+ person,
57
+ })
58
+
59
+ /** `yak init --force`'s config: the starter at this release, keeping `old`'s
60
+ * graph (`db`) and person, with a line for each other value of `old` it
61
+ * replaces or drops.
62
+ *
63
+ * ```ts
64
+ * import { assertEquals } from '@std/assert'
65
+ * let old = { db: 'g.db', person: 'p', plugins: ['@yaks/kernel', '@yaks/old'], port: 9 }
66
+ * let { config, replaced } = refreshed(old)
67
+ * assertEquals([config.db, config.person], ['g.db', 'p'])
68
+ * assertEquals(replaced[0].startsWith('plugins: dropped @yaks/old; added '), true)
69
+ * assertEquals(replaced[1], 'port: dropped 9')
70
+ * ```
71
+ */
72
+ export let refreshed = (
73
+ old: Record<string, unknown>,
74
+ ): { config: Config; replaced: string[] } => {
75
+ let config = {
76
+ ...starter(String(old.person)),
77
+ ...(old.db ? { db: old.db as string } : {}),
78
+ }
79
+ let fresh = config as Record<string, unknown>
80
+ let replaced = Object.entries(old).flatMap(([key, was]) => {
81
+ let now = fresh[key]
82
+ if (JSON.stringify(was) == JSON.stringify(now)) return []
83
+ if (key == 'plugins' && Array.isArray(was)) {
84
+ let named = (list: unknown[]) =>
85
+ new Set(list.map((p) => typeof p == 'string' ? p : JSON.stringify(p)))
86
+ let before = named(was)
87
+ let after = named(now as unknown[])
88
+ let dropped = [...before].filter((p) => !after.has(p))
89
+ let added = [...after].filter((p) => !before.has(p))
90
+ let parts = [
91
+ dropped.length && `dropped ${dropped.join(', ')}`,
92
+ added.length && `added ${added.join(', ')}`,
93
+ ].filter(Boolean)
94
+ return parts.length ? [`plugins: ${parts.join('; ')}`] : []
95
+ }
96
+ return [
97
+ now === undefined
98
+ ? `${key}: dropped ${JSON.stringify(was)}`
99
+ : `${key}: was ${JSON.stringify(was)}`,
100
+ ]
101
+ })
102
+ return { config, replaced }
103
+ }
104
+
105
+ /** The person `yak init` makes, under the name it found for them, or none. */
106
+ export let personOf = (eid: string, name?: string) => ({
107
+ entity: { eid },
108
+ person: {},
109
+ ...(name ? { doc: { title: name } } : {}),
110
+ })
111
+
112
+ /** The graph's first task: confirming the name `yak init` gave the person it
113
+ * made, found rather than asked for, so the first command asks for nothing.
114
+ * It is filed to them, so any agent that connects finds it with the rest of
115
+ * their work and asks them whether the name is right, or what it is where
116
+ * none was found.
117
+ *
118
+ * ```ts
119
+ * import { assertEquals } from '@std/assert'
120
+ * assertEquals(naming('p').filed, { assignee: 'p' })
121
+ * ```
122
+ */
123
+ export let naming = (person: string, name?: string) => ({
124
+ entity: { eid: crypto.randomUUID() },
125
+ task: {},
126
+ filed: { assignee: person },
127
+ doc: {
128
+ title: name
129
+ ? `Confirm that ${name} is the name of the person who works in this graph`
130
+ : 'Ask the person who works in this graph for their name',
131
+ body: 'The person this task is filed to is who everything typed here is ' +
132
+ 'signed by. ' +
133
+ (name
134
+ ? `\`yak init\` named them ${name}, from git's \`user.name\` or the ` +
135
+ 'login user. Ask them whether that is right; '
136
+ : '`yak init` found no name for them. Ask them for it; ') +
137
+ '`yak name <their name>` writes it. Then complete this task.',
138
+ },
139
+ })
package/install.js ADDED
@@ -0,0 +1,216 @@
1
+ import * as system from "@yaks/process/system";
2
+ import * as disk from "@yaks/file/io";
3
+ import { command as launchCommand } from "@yaks/process/command";
4
+ // `deno run -A jsr:@yaks/cli/install`: puts `yak` on this machine at the
5
+ // release this module came from, so the command, every plugin a config names
6
+ // by package (./config.ts `located`) and the canvas it bundles are one set.
7
+ //
8
+ // A bare `deno install -g jsr:@yaks/cli/yak` is not that on the day a release
9
+ // publishes (./release.ts): the install takes the release before, and a `yak`
10
+ // pinned to the new one has every plugin it names refused until the day is
11
+ // out, since a global install's command keeps none of the flags it was
12
+ // installed with. What it does keep is a config, copied beside the command,
13
+ // so the config written here is the release's (./release.ts `released`).
14
+ //
15
+ // It installs the newest release a day old, whole; `--minimum-dependency-age=0`
16
+ // takes the release published today. Deno keeps the release list it fetched,
17
+ // so an update adds `--reload=jsr:@yaks/cli`, or it installs the release it
18
+ // found before.
19
+ import cli from './package.json' with {
20
+ type: 'json'
21
+ };
22
+ import { released } from "./release.js";
23
+ /** The `deno` arguments that install `yak` at `version` under `config`.
24
+ *
25
+ * ```ts
26
+ * import { assertEquals } from '@std/assert'
27
+ * assertEquals(install('1.2.3', '/tmp/c.json').at(-1), 'jsr:@yaks/cli@1.2.3/yak')
28
+ * ```
29
+ */ export let install = (version, config)=>[
30
+ 'install',
31
+ '--global',
32
+ '--allow-all',
33
+ // Deno's own lines as a first command fetches modules say nothing to whoever
34
+ // ran it; its errors print all the same.
35
+ '--quiet',
36
+ // TODO: drop once Deno honors deno.json's "no-legacy-abort" (2.9.1 does not)
37
+ '--unstable-no-legacy-abort',
38
+ '--force',
39
+ '--name',
40
+ 'yak',
41
+ '--config',
42
+ config,
43
+ `jsr:${cli.name}@${version}/yak`
44
+ ];
45
+ /** The `deno` arguments that run `yak` at `version` under `config`, with
46
+ * `args`: what the installed command runs, without installing it.
47
+ *
48
+ * ```ts
49
+ * import { assertEquals } from '@std/assert'
50
+ * assertEquals(run('1.2.3', '/tmp/c.json', ['help']).slice(-2), ['jsr:@yaks/cli@1.2.3/yak', 'help'])
51
+ * ```
52
+ */ export let run = (version, config, args)=>[
53
+ 'run',
54
+ '--allow-all',
55
+ '--config',
56
+ config,
57
+ `jsr:${cli.name}@${version}/yak`,
58
+ ...args
59
+ ];
60
+ /** A first `yak init` and `yak task list`, against a scratch graph in `dir`:
61
+ * a command imports the plugins a config names by name, which `deno install`
62
+ * never fetched, since it follows literal imports only. Run here, the wait to
63
+ * fetch and compile them is part of installing, and a person's first command
64
+ * finds them. */ export let warming = (dir)=>[
65
+ [
66
+ '--config',
67
+ `${dir}/warm/yak.json`,
68
+ 'init'
69
+ ],
70
+ [
71
+ '--config',
72
+ `${dir}/warm/yak.json`,
73
+ 'task',
74
+ 'list'
75
+ ]
76
+ ];
77
+ /** A first `yak serve` on that scratch graph, at `port`, asked for its canvas
78
+ * and stopped once it says it is ready, in the file `ready`: serving imports
79
+ * the facets of the web role, bundles the page, and, as it warms, starts its
80
+ * readers and the workers for its duty roles, none of which a command before
81
+ * it fetched, so a person's first `yak serve` would otherwise download them as
82
+ * it starts.
83
+ *
84
+ * ```ts
85
+ * import { assertEquals } from '@std/assert'
86
+ * assertEquals(serving('/tmp/i', 9).slice(-5), ['serve', '--port', '9', '--ready', '/tmp/i/ready'])
87
+ * ```
88
+ */ export let serving = (dir, port)=>[
89
+ '--config',
90
+ `${dir}/warm/yak.json`,
91
+ 'serve',
92
+ '--port',
93
+ String(port),
94
+ '--ready',
95
+ `${dir}/ready`
96
+ ];
97
+ /** What a warm-up of `yak serve` asks for once it listens, after the page at
98
+ * `/`: everything the page loads (its canvas, stylesheet, icons, manifest),
99
+ * which serve makes from the files Deno then keeps, so a first `yak serve`
100
+ * answers with them offline too.
101
+ *
102
+ * ```ts
103
+ * import { assertEquals } from '@std/assert'
104
+ * assertEquals(loads('<link href="/web/s.css" /><a href="https://x"><script src="/web/app.js">'), ['/web/s.css', '/web/app.js'])
105
+ * ```
106
+ */ export let loads = (page)=>[
107
+ ...page.matchAll(/(?:href|src)="(\/[^"]*)"/g)
108
+ ].map(([, path])=>path);
109
+ // Once `path` exists, or an error at `by`.
110
+ let appeared = async (path, by)=>{
111
+ for(;;){
112
+ try {
113
+ return void await disk.stat(path);
114
+ } catch (error) {
115
+ if (!disk.isNotFound(error)) throw error;
116
+ }
117
+ if (Date.now() > by) throw new Error(`${path} never appeared`);
118
+ await new Promise((r)=>setTimeout(r, 100));
119
+ }
120
+ };
121
+ // A port nothing listens on, from the system, released for serve to take.
122
+ let free = ()=>{
123
+ let listener = Deno.listen({
124
+ hostname: '127.0.0.1',
125
+ port: 0
126
+ });
127
+ let { port } = listener.addr;
128
+ listener.close();
129
+ return port;
130
+ };
131
+ // The answer to `url`, once something listens there and makes it, or an
132
+ // error at `by`. A page that fails is asked for again, since serve makes it
133
+ // again on the next request (./page.ts `kept`): on a cold cache the canvas's
134
+ // first make can outrun serve's limit while it downloads, and what it fetched
135
+ // stays for the next.
136
+ let answered = async (url, by)=>{
137
+ for(;;){
138
+ let failure;
139
+ try {
140
+ let res = await fetch(url);
141
+ let body = await res.text();
142
+ if (res.ok) return body;
143
+ failure = new Error(`${url} answered ${res.status}: ${body}`);
144
+ } catch (error) {
145
+ if (!(error instanceof TypeError)) throw error;
146
+ failure = error;
147
+ }
148
+ if (Date.now() > by) throw failure;
149
+ await new Promise((r)=>setTimeout(r, 100));
150
+ }
151
+ };
152
+ let deno = (args, cwd, quiet = false)=>launchCommand(system.execPath(), {
153
+ args,
154
+ cwd,
155
+ stdout: quiet ? 'null' : 'inherit',
156
+ stderr: quiet ? 'piped' : 'inherit'
157
+ }).output();
158
+ if (import.meta.main) {
159
+ let dir = await disk.makeTempDir({
160
+ prefix: 'yak-install-'
161
+ });
162
+ try {
163
+ let config = `${dir}/deno.json`;
164
+ await disk.writeTextFile(config, JSON.stringify(released));
165
+ // Run from the empty directory, since `deno install` also folds in the
166
+ // dependencies of any package.json it finds above where it runs.
167
+ let { code } = await deno(install(cli.version, config), dir);
168
+ if (code == 0) {
169
+ console.log('fetching the plugins a first command needs…');
170
+ // A warm-up is a first command: one that fails is a `yak` that does not
171
+ // run, whatever `deno install` said.
172
+ let failed;
173
+ for (let args of warming(dir)){
174
+ let warmed = await deno(run(cli.version, config, args), dir, true);
175
+ if (!warmed.success) {
176
+ console.error(new TextDecoder().decode(warmed.stderr).trim());
177
+ failed = `yak ${args.slice(2).join(' ')}`;
178
+ break;
179
+ }
180
+ }
181
+ if (!failed) {
182
+ let port = free();
183
+ let server = launchCommand(system.execPath(), {
184
+ args: run(cli.version, config, serving(dir, port)),
185
+ cwd: dir,
186
+ stdout: 'null',
187
+ stderr: 'null'
188
+ }).spawn();
189
+ try {
190
+ let by = Date.now() + 300_000;
191
+ let at = (path)=>answered(`http://127.0.0.1:${port}${path}`, by);
192
+ for (let path of loads(await at('/')))await at(path);
193
+ await appeared(`${dir}/ready`, by);
194
+ } catch (error) {
195
+ console.error(String(error));
196
+ failed = 'yak serve';
197
+ } finally{
198
+ server.kill('SIGINT');
199
+ await server.status;
200
+ }
201
+ }
202
+ if (failed) {
203
+ console.error(`yak ${cli.version} is installed but does not run: \`${failed}\` failed (above)`);
204
+ code = 1;
205
+ } else {
206
+ console.log(`yak ${cli.version} is installed. Next: yak auth yaks.app ` + 'signs you in to yaks.app, or yak init starts a graph on this machine');
207
+ }
208
+ }
209
+ system.setExitCode(code);
210
+ } finally{
211
+ await disk.remove(dir, {
212
+ recursive: true
213
+ });
214
+ }
215
+ }
216
+ //# sourceMappingURL=install.js.map
package/install.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.js","sources":["./install.ts"],"names":[],"mappings":"AAAA,YAAY,wCAA6C;AACzD,YAAY,+BAAoC;AAChD,SAAS,WAAW,aAAa,qCAA0C;AAC3E,yEAAyE;AACzE,6EAA6E;AAC7E,4EAA4E;AAC5E,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAC9E,2EAA2E;AAC3E,uEAAuE;AACvE,4EAA4E;AAC5E,yEAAyE;AACzE,EAAE;AACF,gFAAgF;AAChF,6EAA6E;AAC7E,4EAA4E;AAC5E,gBAAgB;AAEhB,OAAO,SAAS,sBAAsB;EAAE,MAAM;AAAO,EAAC;AACtD,SAAS,QAAQ,uBAAsB;AAEvC;;;;;;CAMC,GACD,OAAO,IAAI,UAAU,CAAC,SAAiB,SAA6B;IAClE;IACA;IACA;IACA,6EAA6E;IAC7E,yCAAyC;IACzC;IACA,6EAA6E;IAC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