@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/main.js ADDED
@@ -0,0 +1,534 @@
1
+ import * as system from "@yaks/process/system";
2
+ import * as disk from "@yaks/file/io";
3
+ // What the `yak` command (./yak.ts) runs. It has built-in subcommands — `help`, `work`, `restart`, `init`,
4
+ // `auth`, `apply` — and other subcommands are graph tools (local.ts),
5
+ // an MCP server's tools (platform.ts), plugin terminal controls, or an app's
6
+ // own commands (commands.ts). Either
7
+ // list costs something to gather, so run.ts asks for it only when the
8
+ // built-in subcommands did not match.
9
+ //
10
+ // `serve` is one of those tools, not one of these four: @yaks/api declares it
11
+ // and implements it, and a config that names that package as a plugin is a
12
+ // config whose graph can be served.
13
+ //
14
+ // yak app_list
15
+ // yak app_files --app recipes --path index.html --content @index.html
16
+ // yak recipes add_recipe --title 'Lemon cake' --serves 4
17
+ // cat bundles.ndjson | yak apply
18
+ //
19
+ // yak --config yak.json task list # asks its server, else opens that graph
20
+ // yak land # the same, on the checkout you are in
21
+ // yak serve --config yak.json # the same, for a tool that stays up
22
+ //
23
+ // There is no server process to start. A config file names a graph — a SQLite
24
+ // file and the plugins that read and write it — and a `yak` command asks the
25
+ // `yak serve` already running over it, which holds those plugins loaded
26
+ // (./warm.ts). Where none is running, the command opens the graph, imports
27
+ // them, runs the tool in this process and exits. SQLite in WAL mode accepts as
28
+ // many writers as there are commands running, so nothing waits on a daemon
29
+ // somebody had to start. `--host` is for a graph this machine cannot
30
+ // open as a file, and then the command talks to that machine's MCP server at
31
+ // `/mcp`; `yak serve` is the process that answers one.
32
+ //
33
+ // Reading the server's tool list at run time is why this package contains no
34
+ // list of tools: the CLI cannot drift from the MCP server an agent is talking
35
+ // to, and a tool a release adds becomes a subcommand the day it ships without
36
+ // anybody publishing this package again.
37
+ //
38
+ // Exit codes are the contract a script reads: 0 succeeded, 1 the tool or the
39
+ // server refused, 2 the command line was wrong.
40
+ import { Usage } from "./args.js";
41
+ import { bundlesIn, chunks } from "./apply.js";
42
+ import { appStray, appTools } from "./commands.js";
43
+ import { cli, helpTool } from "./run.js";
44
+ import { listed } from "./platform.js";
45
+ import { closeAccounts, personal } from "./accounts.js";
46
+ import { configPath, names, ownConfig, read } from "./config.js";
47
+ import { naming, personOf, refreshed, starter } from "./init.js";
48
+ import { command as launchCommand } from "@yaks/process/command";
49
+ import * as held from "./held.js";
50
+ import { restorable } from "./restore.js";
51
+ import { pinned } from "./release.js";
52
+ import { unitFailureCommand } from "./unit_failure.js";
53
+ import { startCommand } from "./start.js";
54
+ import { feedbackCommand } from "./feedback.js";
55
+ import { gitCredentialCommand } from "./git-credential.js";
56
+ /** The platform this command talks to when it opens no graph of its own. */ export let HOST = 'yaks.app';
57
+ let HEAD = 'yak — the tools of the graph this command runs against';
58
+ let TAIL = ` --config <path> the config file naming the graph to open: its db and
59
+ its plugins, imported in this process (default $YAK_CONFIG)
60
+ --host <host> an MCP server to call over /mcp instead, for a graph this
61
+ machine cannot open as a file (default $YAKS_HOST, else
62
+ ${HOST})
63
+ --as <account> select a saved yaks.app account by its whole address
64
+ or the part before @; list them with
65
+ \`yak connection list <owner>\` (owner id or name), and use
66
+ a yaks.app entry’s account.
67
+ On the shared box, a session defaults to checks.
68
+ Select --as admin for platform operations. Outside a
69
+ session use your own email, else the oldest connection.
70
+ A tool's own as argument is written as=<value>.
71
+ --json print the structured result instead of the text
72
+ --tui hold the answer in the terminal, scrollable, until Ctrl-C
73
+ --timing one line on stderr per response, with its Server-Timing
74
+ (or YAKS_TIMING=1)
75
+ --no-duties run no inline effects or services; serve still monitors
76
+ and restores independent workers for uncovered duty roles
77
+ --help this page, or one subcommand's own
78
+ --version the @yaks/cli release this is
79
+
80
+ An argument value written @path is read from that file, and - is read from
81
+ stdin. $YAKS_TOKEN is the bearer token when set; otherwise the selected
82
+ yaks.app connection supplies it. Sign in with \`yak auth yaks.app\`.`;
83
+ // `apply` is `graph_apply` fed from a stream. One batch is applied in one
84
+ // transaction, and a file of fifty thousand bundles is a bulk load rather than
85
+ // one transaction, so it is sent in chunks. It calls the same `graph_apply`
86
+ // every other subcommand would — the one implemented by the graph this command
87
+ // opened, or the one the MCP server it named lists — so a load goes wherever
88
+ // the rest of the session went.
89
+ let applied = async (args, c)=>{
90
+ let tool = (await c.all()).find((t)=>t.name == 'graph_apply');
91
+ if (!tool) {
92
+ throw new Usage(`${c.config ?? c.host} has no graph_apply to apply through`);
93
+ }
94
+ // A dry run is the tool's `check`: every phase runs and the transaction is
95
+ // rolled back, so the result is what would have been written.
96
+ let dry = args['dry-run'] === true;
97
+ let asked = (bundles)=>tool.run({
98
+ bundles,
99
+ ...dry ? {
100
+ check: true
101
+ } : {}
102
+ }, c);
103
+ if (args.bundles) return await asked(args.bundles);
104
+ // This is already the body: `@path` is read from that file and `-` from
105
+ // stdin for every argument value of every subcommand (args.ts `inflate`), so
106
+ // what arrives here is the bundles themselves. Given no argument at all,
107
+ // read stdin.
108
+ let body = typeof args.file == 'string' ? args.file : await c.reads.stdin();
109
+ let code = 0;
110
+ for (let bundles of chunks(bundlesIn(body))){
111
+ code = await asked(bundles) || code;
112
+ if (code) break;
113
+ }
114
+ return code;
115
+ };
116
+ // The code that lists a graph's subcommands (./subcommands.ts) and the code
117
+ // that opens one (./local.ts) are each imported by the first command that
118
+ // needs them, and by no other: the workspace runs with `lazy-dynamic-imports`
119
+ // (deno.json), because without it Deno walks every module a literal
120
+ // `import('./local.ts')` reaches as the program starts, whichever branch the
121
+ // run then takes.
122
+ let local = ()=>import("./local.js");
123
+ // Where this command's tools come from: the graph a config names, opened here,
124
+ // or the MCP server the command named.
125
+ let table = async (c, o)=>{
126
+ let commands = c.config ? await (await import("./subcommands.js")).commands(c) : await listed(c, o);
127
+ return commands.map((command)=>command.name == 'graph_apply' ? restorable(command, async (args, c)=>(await local()).restore(args, c)) : command);
128
+ };
129
+ /** What `yak` itself is, besides the tools it lists. */ export let YAK = {
130
+ name: 'yak',
131
+ about: HEAD,
132
+ version: pinned['@yaks/cli'],
133
+ notes: TAIL,
134
+ globalFlags: [
135
+ 'as',
136
+ 'json',
137
+ 'host',
138
+ 'config',
139
+ 'timing',
140
+ 'tui',
141
+ 'no-duties',
142
+ 'help',
143
+ 'version'
144
+ ],
145
+ host: HOST,
146
+ nowhere: 'not signed in to yaks.app, and no graph on this machine: ' + '`yak auth yaks.app` signs you in, or `yak init` starts a graph here',
147
+ more: table,
148
+ stray: appStray
149
+ };
150
+ // `init` is the one command that runs before there is a graph: it writes the
151
+ // config a machine's own graph starts from (./init.ts) and makes the person
152
+ // who works there, so what they type is signed as them from the first command.
153
+ // It asks for nothing: the person is named from git's `user.name`, or else the
154
+ // login user, and confirming that name is the graph's first task, filed to
155
+ // them, which any agent that connects finds and asks them about. It never
156
+ // replaces a config unless forced: one already there is somebody's graph. A
157
+ // forced one is rewritten at this release with its graph and person kept, the
158
+ // old file saved beside it.
159
+ let init = async (args, c)=>{
160
+ let path = c.config ?? system.env.get('YAK_CONFIG') ?? ownConfig();
161
+ if (!path) {
162
+ throw new Usage('no $HOME to keep a config in — name one with --config');
163
+ }
164
+ let dir = path.includes('/') ? path.slice(0, path.lastIndexOf('/')) : '.';
165
+ let graph = (db)=>db.startsWith('/') ? db : `${dir}/${db}`;
166
+ let old;
167
+ try {
168
+ old = JSON.parse(disk.readTextFileSync(path));
169
+ } catch (error) {
170
+ if (!(error instanceof disk.errors.NotFound)) throw error;
171
+ }
172
+ if (old && !args.force) {
173
+ c.note(`${path} already exists, and yak init never replaces a config. ` + 'yak init --force rewrites it for this release, keeping your graph.');
174
+ return 1;
175
+ }
176
+ // A forced init never loses the config it replaces.
177
+ let saved = old && `${path}.${new Date().toISOString().replaceAll(':', '-')}`;
178
+ if (saved) disk.copyFileSync(path, saved);
179
+ if (old?.person) {
180
+ let { config, replaced } = refreshed(old);
181
+ disk.writeTextFileSync(path, JSON.stringify(config, null, 2) + '\n');
182
+ c.out(`Rewrote ${path} for yak ${pinned['@yaks/cli']}. ` + `Your graph (${graph(config.db)}) and your person are kept.`);
183
+ for (let line of replaced)c.out(`Replaced ${line}`);
184
+ c.out(`The old config is at ${saved}.`);
185
+ return 0;
186
+ }
187
+ let person = crypto.randomUUID();
188
+ let name = await whose();
189
+ disk.mkdirSync(dir, {
190
+ recursive: true
191
+ });
192
+ try {
193
+ disk.writeTextFileSync(path, JSON.stringify(starter(person), null, 2) + '\n', {
194
+ createNew: !old
195
+ });
196
+ } catch (error) {
197
+ if (!(error instanceof disk.errors.AlreadyExists)) throw error;
198
+ c.note(`${path} already exists, and yak init never replaces a config.`);
199
+ return 1;
200
+ }
201
+ try {
202
+ let { opened } = await local();
203
+ let host = await opened(path, [
204
+ 'graph'
205
+ ], false);
206
+ await host.graph.apply([
207
+ personOf(person, name),
208
+ naming(person, name)
209
+ ]);
210
+ } catch (error) {
211
+ // A config naming a person its graph never made is worse than none: the
212
+ // next `yak init` could not replace it.
213
+ disk.removeSync(path);
214
+ throw error;
215
+ }
216
+ c.out(`Wrote ${path}. Your graph is ${graph(starter(person).db)}.`);
217
+ c.out(name ? `You are ${name}. If that is wrong, run: yak name "Your Name"` : 'No name was found for you. Run: yak name "Your Name"');
218
+ if (saved) c.out(`The old config is at ${saved}.`);
219
+ c.out('Next: yak task list, then yak serve');
220
+ return 0;
221
+ };
222
+ // The name the person at this machine already goes by: git's `user.name`,
223
+ // else the login user, else none.
224
+ let whose = async ()=>{
225
+ try {
226
+ let { code, stdout } = await launchCommand('git', {
227
+ args: [
228
+ 'config',
229
+ '--get',
230
+ 'user.name'
231
+ ],
232
+ stdout: 'piped',
233
+ stderr: 'null'
234
+ }).output();
235
+ let name = new TextDecoder().decode(stdout).trim();
236
+ if (code == 0 && name) return name;
237
+ } catch {
238
+ // no git on this machine
239
+ }
240
+ return system.env.get('USER') || system.env.get('USERNAME') || undefined;
241
+ };
242
+ // `name` renames the person who works in this machine's graph: their
243
+ // `doc.title`, which is how what they type is signed.
244
+ let rename = async (args, c)=>{
245
+ let path = configPath(c.config);
246
+ if (!path) {
247
+ throw new Usage('no graph on this machine yet: `yak init` starts one');
248
+ }
249
+ let name = String(args.name ?? '').trim();
250
+ if (!name) throw new Usage('yak name <your name>');
251
+ let eid = read(path).person;
252
+ if (!eid) throw new Usage(`${path} names no person`);
253
+ let { opened } = await local();
254
+ let host = await opened(path, [
255
+ 'graph'
256
+ ], false);
257
+ await host.graph.apply([
258
+ {
259
+ entity: {
260
+ eid
261
+ },
262
+ doc: {
263
+ title: name
264
+ }
265
+ }
266
+ ]);
267
+ c.out(`you are ${name}`);
268
+ return 0;
269
+ };
270
+ /** The command's built-in subcommands, which shadow a tool of the same name
271
+ * from either list. */ export let own = [
272
+ {
273
+ name: 'ui',
274
+ description: "Open @yaks/ui's style guide in this terminal: every part " + 'in every variant, as /ui shows it in a browser, in each theme.',
275
+ inputSchema: {
276
+ type: 'object',
277
+ additionalProperties: false,
278
+ properties: {}
279
+ },
280
+ // What it runs is imported when it runs: every command line lists this one.
281
+ run: async ()=>{
282
+ let { open } = await import("@yaks/tui/guide");
283
+ await open();
284
+ return 0;
285
+ }
286
+ },
287
+ unitFailureCommand,
288
+ {
289
+ name: 'unit_handoff',
290
+ noun: 'unit',
291
+ verb: 'handoff',
292
+ description: 'Keep a systemd role served while its last ready unit drains',
293
+ offered: (c)=>names(c.config, 'processes'),
294
+ positional: [
295
+ 'unit'
296
+ ],
297
+ inputSchema: {
298
+ type: 'object',
299
+ additionalProperties: false,
300
+ required: [
301
+ 'unit'
302
+ ],
303
+ properties: {
304
+ unit: {
305
+ type: 'string',
306
+ description: 'the unit about to stop (%n)'
307
+ }
308
+ }
309
+ },
310
+ run: async (args, c)=>{
311
+ let runtimeDir = system.env.get('XDG_RUNTIME_DIR');
312
+ if (!runtimeDir) {
313
+ throw new Usage('yak unit handoff needs $XDG_RUNTIME_DIR');
314
+ }
315
+ let { beforeStop } = await import("./restart.js");
316
+ let said = await beforeStop(String(args.unit), {
317
+ runtimeDir
318
+ });
319
+ if (said) c.out(said);
320
+ return 0;
321
+ }
322
+ },
323
+ startCommand,
324
+ feedbackCommand,
325
+ gitCredentialCommand,
326
+ {
327
+ name: 'mcp',
328
+ description: 'Connect a local MCP client over stdio, expanding its own @files',
329
+ inputSchema: {
330
+ type: 'object',
331
+ additionalProperties: false
332
+ },
333
+ readOnly: true,
334
+ run: async (_, c)=>{
335
+ let [{ bridge, stdio }, { createInterface }, { Readable }] = await Promise.all([
336
+ import("./mcp.js"),
337
+ import('node:readline'),
338
+ import('node:stream')
339
+ ]);
340
+ await stdio(createInterface({
341
+ input: Readable.from(system.stdin.readable)
342
+ }), c.out, bridge(c.ask, c.reads.file));
343
+ return 0;
344
+ }
345
+ },
346
+ helpTool(YAK),
347
+ {
348
+ name: 'version',
349
+ description: 'the @yaks/cli release this is',
350
+ inputSchema: {
351
+ type: 'object',
352
+ additionalProperties: false
353
+ },
354
+ readOnly: true,
355
+ run: (_, c)=>(c.out(YAK.version), 0)
356
+ },
357
+ {
358
+ name: 'work',
359
+ description: 'Run the effects pool and plugin services without the web',
360
+ offered: (c)=>names(c.config, 'processes'),
361
+ inputSchema: {
362
+ type: 'object',
363
+ properties: {
364
+ ready: {
365
+ type: 'string',
366
+ description: 'Readiness file'
367
+ },
368
+ process: {
369
+ type: 'string',
370
+ description: 'Configured process unit name'
371
+ },
372
+ tethered: {
373
+ type: 'boolean',
374
+ description: 'Exit when stdin closes: the requesting process ended'
375
+ },
376
+ roles: {
377
+ type: 'string',
378
+ description: 'Only these comma-separated duties'
379
+ }
380
+ }
381
+ },
382
+ run: async (args, c)=>{
383
+ let path = c.config ?? ownConfig();
384
+ if (!path) throw new Usage('yak work needs --config');
385
+ let ready = typeof args.ready == 'string' ? args.ready : undefined;
386
+ let roles = typeof args.roles == 'string' ? args.roles.split(',') : undefined;
387
+ await (await local()).work(path, ready, roles, args.tethered === true, typeof args.process == 'string' ? args.process : undefined);
388
+ return 0;
389
+ }
390
+ },
391
+ {
392
+ name: 'restart',
393
+ description: "Queue a ready-first handover of the box's workers and webs in the background",
394
+ offered: (c)=>names(c.config, 'processes'),
395
+ inputSchema: {
396
+ type: 'object',
397
+ properties: {
398
+ handover: {
399
+ type: 'boolean',
400
+ description: 'Run the supervised handover'
401
+ },
402
+ replace: {
403
+ type: 'array',
404
+ items: {
405
+ type: 'string'
406
+ },
407
+ description: 'Units to hand over even when they run this code. Accepts full names like yak-web or shorthand like web.'
408
+ }
409
+ }
410
+ },
411
+ run: async (args, c)=>{
412
+ let runtimeDir = system.env.get('XDG_RUNTIME_DIR');
413
+ if (!runtimeDir) throw new Usage('yak restart needs $XDG_RUNTIME_DIR');
414
+ let { restart, queue } = await import("./restart.js");
415
+ let path = configPath(c.config);
416
+ let replace = Array.isArray(args.replace) ? args.replace.map(String) : [];
417
+ if (!args.handover) {
418
+ c.out(await queue(runtimeDir, {
419
+ config: path,
420
+ replace
421
+ }));
422
+ return 0;
423
+ }
424
+ c.out(await restart({
425
+ runtimeDir,
426
+ processes: path ? read(path).processes : undefined,
427
+ replace
428
+ }));
429
+ return 0;
430
+ }
431
+ },
432
+ {
433
+ name: 'init',
434
+ description: "start this machine's own graph: write its config and make you its person",
435
+ offered: (c)=>!c.config,
436
+ inputSchema: {
437
+ type: 'object',
438
+ additionalProperties: false,
439
+ properties: {
440
+ force: {
441
+ type: 'boolean',
442
+ description: 'rewrite an existing config for this release, keeping its graph and person'
443
+ }
444
+ }
445
+ },
446
+ run: init
447
+ },
448
+ {
449
+ name: 'name',
450
+ description: "rename yourself, the person who works in this machine's graph",
451
+ offered: (c)=>!!configPath(c.config),
452
+ inputSchema: {
453
+ type: 'object',
454
+ additionalProperties: false,
455
+ required: [
456
+ 'name'
457
+ ],
458
+ properties: {
459
+ name: {
460
+ type: 'string',
461
+ description: 'your name, as the graph knows you'
462
+ }
463
+ }
464
+ },
465
+ positional: [
466
+ 'name'
467
+ ],
468
+ run: rename
469
+ },
470
+ {
471
+ name: 'apply',
472
+ description: 'apply bundles read as NDJSON, in transactions of 50; --dry-run ' + 'reports what would be written and writes none of it',
473
+ inputSchema: {
474
+ type: 'object',
475
+ additionalProperties: false,
476
+ properties: {
477
+ file: {
478
+ type: 'string',
479
+ description: '@file, or - for stdin'
480
+ },
481
+ bundles: {
482
+ type: 'array',
483
+ description: 'one batch of bundles, inline'
484
+ },
485
+ 'dry-run': {
486
+ type: 'boolean',
487
+ description: 'report what would be written, and write none of it'
488
+ }
489
+ }
490
+ },
491
+ positional: [
492
+ 'file'
493
+ ],
494
+ destructive: true,
495
+ run: applied
496
+ }
497
+ ];
498
+ /** What a plain install carries, in precedence order. The apps' commands come
499
+ * after this command's built-ins and before the graph's tools, because one of
500
+ * those tools is `command` itself: the graph's version takes the app's
501
+ * arguments as a JSON object, and the one here takes them the way a person
502
+ * types them. */ export let TOOLS = [
503
+ ...own,
504
+ ...appTools
505
+ ];
506
+ /** One command line, from argv to an exit code, printing any refusal on the
507
+ * way. A program with subcommands of its own passes them in, and they shadow
508
+ * everything here. Whatever graph the command opened is closed when it is
509
+ * done, and the exit code it returns is what its `process` row records as its
510
+ * ending. */ export let main = async (argv, extra = [])=>{
511
+ let code = 1;
512
+ try {
513
+ let { configPath } = await import("./config.js");
514
+ if (argv.includes('auth') && !configPath() && !argv.some((a)=>a == '--config' || a.startsWith('--config='))) {
515
+ let path = await personal();
516
+ argv = [
517
+ '--config',
518
+ path,
519
+ ...argv
520
+ ];
521
+ }
522
+ return code = await cli([
523
+ ...extra,
524
+ ...TOOLS
525
+ ], {
526
+ ...YAK,
527
+ argv
528
+ });
529
+ } finally{
530
+ await held.close(code);
531
+ await closeAccounts();
532
+ }
533
+ };
534
+ //# sourceMappingURL=main.js.map
package/main.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sources":["./main.ts"],"names":[],"mappings":"AAAA,YAAY,wCAA6C;AACzD,YAAY,+BAAoC;AAChD,2GAA2G;AAC3G,sEAAsE;AACtE,6EAA6E;AAC7E,qCAAqC;AACrC,sEAAsE;AACtE,sCAAsC;AACtC,EAAE;AACF,8EAA8E;AAC9E,2EAA2E;AAC3E,oCAAoC;AACpC,EAAE;AACF,iBAAiB;AACjB,wEAAwE;AACxE,2DAA2D;AAC3D,mCAAmC;AACnC,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,2EAA2E;AAC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