@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.
- package/LICENSE +202 -0
- package/README.md +1059 -2
- package/_dist/account-forward.d.ts +12 -0
- package/_dist/account-forward.d.ts.map +1 -0
- package/_dist/accounts.d.ts +23 -0
- package/_dist/accounts.d.ts.map +1 -0
- package/_dist/answer.d.ts +88 -0
- package/_dist/answer.d.ts.map +1 -0
- package/_dist/apply.d.ts +17 -0
- package/_dist/apply.d.ts.map +1 -0
- package/_dist/args.d.ts +86 -0
- package/_dist/args.d.ts.map +1 -0
- package/_dist/commands.d.ts +15 -0
- package/_dist/commands.d.ts.map +1 -0
- package/_dist/complete.d.ts +15 -0
- package/_dist/complete.d.ts.map +1 -0
- package/_dist/config.d.ts +37 -0
- package/_dist/config.d.ts.map +1 -0
- package/_dist/dependencies.d.ts +6 -0
- package/_dist/dependencies.d.ts.map +1 -0
- package/_dist/facets.d.ts +71 -0
- package/_dist/facets.d.ts.map +1 -0
- package/_dist/grammar.d.ts +5 -0
- package/_dist/grammar.d.ts.map +1 -0
- package/_dist/host.d.ts +164 -0
- package/_dist/host.d.ts.map +1 -0
- package/_dist/install.d.ts +43 -0
- package/_dist/install.d.ts.map +1 -0
- package/_dist/main.d.ts +16 -0
- package/_dist/main.d.ts.map +1 -0
- package/_dist/memo.d.ts +60 -0
- package/_dist/memo.d.ts.map +1 -0
- package/_dist/mod.d.ts +46 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/page.d.ts +73 -0
- package/_dist/page.d.ts.map +1 -0
- package/_dist/platform.d.ts +27 -0
- package/_dist/platform.d.ts.map +1 -0
- package/_dist/reader.d.ts +10 -0
- package/_dist/reader.d.ts.map +1 -0
- package/_dist/release.d.ts +48 -0
- package/_dist/release.d.ts.map +1 -0
- package/_dist/remote.d.ts +13 -0
- package/_dist/remote.d.ts.map +1 -0
- package/_dist/reported.d.ts +11 -0
- package/_dist/reported.d.ts.map +1 -0
- package/_dist/roles.d.ts +2 -0
- package/_dist/roles.d.ts.map +1 -0
- package/_dist/roster.d.ts +41 -0
- package/_dist/roster.d.ts.map +1 -0
- package/_dist/rpc.d.ts +29 -0
- package/_dist/rpc.d.ts.map +1 -0
- package/_dist/run.d.ts +164 -0
- package/_dist/run.d.ts.map +1 -0
- package/_dist/runtime.d.ts +4 -0
- package/_dist/runtime.d.ts.map +1 -0
- package/_dist/searching.d.ts +7 -0
- package/_dist/searching.d.ts.map +1 -0
- package/_dist/show.d.ts +22 -0
- package/_dist/show.d.ts.map +1 -0
- package/_dist/store.d.ts +25 -0
- package/_dist/store.d.ts.map +1 -0
- package/_dist/terminal.d.ts +17 -0
- package/_dist/terminal.d.ts.map +1 -0
- package/_dist/tool.d.ts +55 -0
- package/_dist/tool.d.ts.map +1 -0
- package/_dist/tty.d.ts +3 -0
- package/_dist/tty.d.ts.map +1 -0
- package/_dist/vault.d.ts +9 -0
- package/_dist/vault.d.ts.map +1 -0
- package/_dist/words.d.ts +11 -0
- package/_dist/words.d.ts.map +1 -0
- package/_dist/yak.d.ts +10 -0
- package/_dist/yak.d.ts.map +1 -0
- package/account-forward.js +40 -0
- package/account-forward.js.map +1 -0
- package/account-forward.ts +50 -0
- package/accounts.js +162 -0
- package/accounts.js.map +1 -0
- package/accounts.ts +228 -0
- package/answer.js +394 -0
- package/answer.js.map +1 -0
- package/answer.ts +569 -0
- package/apply.js +49 -0
- package/apply.js.map +1 -0
- package/apply.ts +54 -0
- package/args.js +420 -0
- package/args.js.map +1 -0
- package/args.ts +494 -0
- package/code.js +209 -0
- package/code.js.map +1 -0
- package/code.ts +227 -0
- package/commands.js +131 -0
- package/commands.js.map +1 -0
- package/commands.ts +142 -0
- package/complete.js +104 -0
- package/complete.js.map +1 -0
- package/complete.ts +152 -0
- package/config.js +125 -0
- package/config.js.map +1 -0
- package/config.ts +180 -0
- package/declarations.js +67 -0
- package/declarations.js.map +1 -0
- package/declarations.ts +84 -0
- package/deno.json +1 -0
- package/dependencies.js +126 -0
- package/dependencies.js.map +1 -0
- package/dependencies.ts +141 -0
- package/derive.js +102 -0
- package/derive.js.map +1 -0
- package/derive.ts +125 -0
- package/drain.js +83 -0
- package/drain.js.map +1 -0
- package/drain.ts +115 -0
- package/duties.ts +17 -0
- package/exports.json +1486 -0
- package/external.js +373 -0
- package/external.js.map +1 -0
- package/external.ts +435 -0
- package/facets.js +214 -0
- package/facets.js.map +1 -0
- package/facets.ts +232 -0
- package/feedback.js +54 -0
- package/feedback.js.map +1 -0
- package/feedback.ts +57 -0
- package/files.js +84 -0
- package/files.js.map +1 -0
- package/files.ts +112 -0
- package/get_starts.js +31 -0
- package/get_starts.js.map +1 -0
- package/get_starts.ts +34 -0
- package/git-credential.js +79 -0
- package/git-credential.js.map +1 -0
- package/git-credential.ts +77 -0
- package/grammar.js +4 -0
- package/grammar.js.map +1 -0
- package/grammar.ts +5 -0
- package/held.js +51 -0
- package/held.js.map +1 -0
- package/held.ts +66 -0
- package/host.js +1174 -0
- package/host.js.map +1 -0
- package/host.ts +1343 -0
- package/init.js +138 -0
- package/init.js.map +1 -0
- package/init.ts +139 -0
- package/install.js +216 -0
- package/install.js.map +1 -0
- package/install.ts +223 -0
- package/lifetime.js +56 -0
- package/lifetime.js.map +1 -0
- package/lifetime.ts +66 -0
- package/local-page.ts +114 -0
- package/local.js +417 -0
- package/local.js.map +1 -0
- package/local.ts +537 -0
- package/lockfile.js +20 -0
- package/lockfile.js.map +1 -0
- package/lockfile.ts +32 -0
- package/machines.js +33 -0
- package/machines.js.map +1 -0
- package/machines.ts +51 -0
- package/made/4f855610bdabcd736100d34e4e467ea5.json +1 -0
- package/main.js +534 -0
- package/main.js.map +1 -0
- package/main.ts +547 -0
- package/mcp.js +108 -0
- package/mcp.js.map +1 -0
- package/mcp.ts +113 -0
- package/member.js +103 -0
- package/member.js.map +1 -0
- package/member.ts +133 -0
- package/memo.js +503 -0
- package/memo.js.map +1 -0
- package/memo.ts +634 -0
- package/mod.js +46 -0
- package/mod.js.map +1 -0
- package/mod.ts +99 -0
- package/operations.js +53 -0
- package/operations.js.map +1 -0
- package/operations.ts +68 -0
- package/package.json +115 -4
- package/page.js +211 -0
- package/page.js.map +1 -0
- package/page.ts +308 -0
- package/parser.js +45 -0
- package/parser.js.map +1 -0
- package/parser.ts +77 -0
- package/people-search.js +112 -0
- package/people-search.js.map +1 -0
- package/people-search.ts +162 -0
- package/platform.js +184 -0
- package/platform.js.map +1 -0
- package/platform.ts +224 -0
- package/platform_effects.js +5 -0
- package/platform_effects.js.map +1 -0
- package/platform_effects.ts +13 -0
- package/prepare.js +40 -0
- package/prepare.js.map +1 -0
- package/prepare.ts +46 -0
- package/read_activity.js +54 -0
- package/read_activity.js.map +1 -0
- package/read_activity.ts +61 -0
- package/read_thread.js +387 -0
- package/read_thread.js.map +1 -0
- package/read_thread.ts +506 -0
- package/read_worker.ts +164 -0
- package/reader.js +48 -0
- package/reader.js.map +1 -0
- package/reader.ts +57 -0
- package/release.js +82 -0
- package/release.js.map +1 -0
- package/release.json +127 -0
- package/release.ts +98 -0
- package/remote-page.ts +70 -0
- package/remote.js +96 -0
- package/remote.js.map +1 -0
- package/remote.ts +153 -0
- package/report.js +83 -0
- package/report.js.map +1 -0
- package/report.ts +101 -0
- package/reported.js +32 -0
- package/reported.js.map +1 -0
- package/reported.ts +38 -0
- package/restart.js +349 -0
- package/restart.js.map +1 -0
- package/restart.ts +478 -0
- package/restore.js +32 -0
- package/restore.js.map +1 -0
- package/restore.ts +38 -0
- package/roles.js +32 -0
- package/roles.js.map +1 -0
- package/roles.ts +49 -0
- package/roster.js +65 -0
- package/roster.js.map +1 -0
- package/roster.ts +84 -0
- package/rpc.js +113 -0
- package/rpc.js.map +1 -0
- package/rpc.ts +159 -0
- package/run.js +533 -0
- package/run.js.map +1 -0
- package/run.ts +741 -0
- package/runtime.js +381 -0
- package/runtime.js.map +1 -0
- package/runtime.ts +433 -0
- package/sandboxes.js +26 -0
- package/sandboxes.js.map +1 -0
- package/sandboxes.ts +30 -0
- package/searching.js +33 -0
- package/searching.js.map +1 -0
- package/searching.ts +50 -0
- package/show.js +109 -0
- package/show.js.map +1 -0
- package/show.ts +144 -0
- package/shown.js +13 -0
- package/shown.js.map +1 -0
- package/shown.ts +44 -0
- package/stall.js +90 -0
- package/stall.js.map +1 -0
- package/stall.ts +156 -0
- package/stall_profile.js +113 -0
- package/stall_profile.js.map +1 -0
- package/stall_profile.ts +142 -0
- package/stall_wait.js +183 -0
- package/stall_wait.js.map +1 -0
- package/stall_wait.ts +249 -0
- package/stall_wait_worker.ts +11 -0
- package/start.js +349 -0
- package/start.js.map +1 -0
- package/start.ts +343 -0
- package/starvation.js +147 -0
- package/starvation.js.map +1 -0
- package/starvation.ts +224 -0
- package/store.js +118 -0
- package/store.js.map +1 -0
- package/store.ts +193 -0
- package/subcommands.js +62 -0
- package/subcommands.js.map +1 -0
- package/subcommands.ts +77 -0
- package/terminal.js +93 -0
- package/terminal.js.map +1 -0
- package/terminal.ts +128 -0
- package/text.js +20 -0
- package/text.js.map +1 -0
- package/text.ts +37 -0
- package/tool.js +76 -0
- package/tool.js.map +1 -0
- package/tool.ts +157 -0
- package/trace_control.js +231 -0
- package/trace_control.js.map +1 -0
- package/trace_control.ts +233 -0
- package/traces.js +138 -0
- package/traces.js.map +1 -0
- package/traces.ts +160 -0
- package/tracker.js +22 -0
- package/tracker.js.map +1 -0
- package/tracker.ts +27 -0
- package/tty.js +82 -0
- package/tty.js.map +1 -0
- package/tty.ts +142 -0
- package/unit_failure.js +178 -0
- package/unit_failure.js.map +1 -0
- package/unit_failure.ts +191 -0
- package/upkeep_thread.js +32 -0
- package/upkeep_thread.js.map +1 -0
- package/upkeep_thread.ts +35 -0
- package/upkeep_worker.ts +27 -0
- package/vault.js +186 -0
- package/vault.js.map +1 -0
- package/vault.ts +220 -0
- package/vocab-ids.js +63 -0
- package/vocab-ids.js.map +1 -0
- package/vocab-ids.ts +62 -0
- package/vocab.json +35 -0
- package/warm.js +138 -0
- package/warm.js.map +1 -0
- package/warm.ts +171 -0
- package/watch_revision.js +25 -0
- package/watch_revision.js.map +1 -0
- package/watch_revision.ts +30 -0
- package/words.js +29 -0
- package/words.js.map +1 -0
- package/words.ts +41 -0
- package/workspaces.js +40 -0
- package/workspaces.js.map +1 -0
- package/workspaces.ts +58 -0
- package/yak-unit-failure.conf +6 -0
- package/yak-unit-handoff.conf +2 -0
- package/yak.js +123 -0
- package/yak.js.map +1 -0
- package/yak.ts +136 -0
package/warm.ts
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// A graph tool, asked of the `yak serve` already running over the graph a
|
|
2
|
+
// command's config names. That server holds the whole read path loaded and
|
|
3
|
+
// warm, and answers in milliseconds what a command opening the graph itself
|
|
4
|
+
// spends half a second importing (./local.ts). Its `/mcp` is the door every
|
|
5
|
+
// agent's MCP tools already use, so a command and an MCP call run the same
|
|
6
|
+
// tool through the same runner. An answer printed to no terminal, and not as
|
|
7
|
+
// `--json`, is the text the server's own views draw (@yaks/api/address
|
|
8
|
+
// `TEXT`), which is what a command that opened the graph prints there
|
|
9
|
+
// (./local.ts `tool`, the host's `text`), so this process loads no views. One
|
|
10
|
+
// for a terminal is drawn here, with this config's own vocabulary and views,
|
|
11
|
+
// as a command that opened the graph draws it (./terminal.ts `shown`): the
|
|
12
|
+
// server's own account of its words is never needed, so no cached copy of it
|
|
13
|
+
// can be stale.
|
|
14
|
+
//
|
|
15
|
+
// Nothing has to be running: a command no server answers opens the graph
|
|
16
|
+
// itself, as it always could. The server is found at the address its config
|
|
17
|
+
// says it listens on (@yaks/api/address), and every request names the graph
|
|
18
|
+
// file it means. Only a server serving that file says it back, so an answer
|
|
19
|
+
// from one listening there for another graph (a copy's config naming the same
|
|
20
|
+
// port), or from one too old to say, is not taken for this graph's.
|
|
21
|
+
//
|
|
22
|
+
// A command runs here only where the server can run it exactly as this
|
|
23
|
+
// process would:
|
|
24
|
+
//
|
|
25
|
+
// - its tool declares no role beyond the graph (`serve` listens; a tool
|
|
26
|
+
// naming a plugin's role runs in that role's process);
|
|
27
|
+
// - it is not held in this terminal (`--tui`);
|
|
28
|
+
// - it reads, or it speaks for a session: the server signs a session's writes
|
|
29
|
+
// as that session (`x-via`, local.ts `signer`), and a line typed at a
|
|
30
|
+
// keyboard with none, which this process signs as the config's person,
|
|
31
|
+
// writes from here.
|
|
32
|
+
//
|
|
33
|
+
// Only a call the server never began is run again here: no server, one
|
|
34
|
+
// serving another graph, or one whose code predates the tool (an unknown
|
|
35
|
+
// tool). Once a call is under way, what the server says is the answer, and a
|
|
36
|
+
// connection lost during it is an error, never a second run.
|
|
37
|
+
|
|
38
|
+
import type { Bundle } from 'jsr:@yaks/graph@0.2.36'
|
|
39
|
+
import { ailing } from '@yaks/tools/check'
|
|
40
|
+
import { DB, served, TEXT } from '@yaks/api/address'
|
|
41
|
+
import { type Config, pluginViews, used } from './config.js'
|
|
42
|
+
import type { Declared } from './words.js'
|
|
43
|
+
import { doorUrl, Refused, type Rpc, rpc } from './rpc.js'
|
|
44
|
+
import type { Ctx } from './run.ts'
|
|
45
|
+
import { type Result, saidBy } from './roster.js'
|
|
46
|
+
|
|
47
|
+
// JSON-RPC's invalid params, which an MCP server answers an unknown tool with
|
|
48
|
+
// before running anything.
|
|
49
|
+
let UNKNOWN = -32602
|
|
50
|
+
|
|
51
|
+
/** Whether the server for `config` may run `declared` for this line. */
|
|
52
|
+
export let warmable = (
|
|
53
|
+
c: Pick<Ctx, 'tui' | 'via'>,
|
|
54
|
+
config: Pick<Config, 'db'>,
|
|
55
|
+
declared: Pick<Declared, 'roles' | 'readOnly'>,
|
|
56
|
+
): boolean =>
|
|
57
|
+
!!config.db && config.db != ':memory:' && !c.tui &&
|
|
58
|
+
!declared.roles?.some((role) => role != 'graph') &&
|
|
59
|
+
(!!declared.readOnly || !!c.via)
|
|
60
|
+
|
|
61
|
+
/** `declared`, run by the server serving `config`'s graph and printed:
|
|
62
|
+
* the exit code, or undefined where no such server began it. */
|
|
63
|
+
export let warm = async (
|
|
64
|
+
c: Ctx,
|
|
65
|
+
config: Config,
|
|
66
|
+
declared: Declared,
|
|
67
|
+
args: Record<string, unknown>,
|
|
68
|
+
fetch?: (request: Request) => Response | Promise<Response>,
|
|
69
|
+
): Promise<number | undefined> => {
|
|
70
|
+
if (!warmable(c, config, declared)) return
|
|
71
|
+
let host = served(config)
|
|
72
|
+
let go = fetch ?? ((request: Request) => globalThis.fetch(request))
|
|
73
|
+
// The response to the request last sent, once one came: whether it said
|
|
74
|
+
// this graph's file back is whether this graph's server answered.
|
|
75
|
+
let last: Response | undefined
|
|
76
|
+
let ours = () => last?.headers.get(DB) == config.db
|
|
77
|
+
let ask = rpc({
|
|
78
|
+
url: doorUrl(host),
|
|
79
|
+
via: c.via,
|
|
80
|
+
headers: {
|
|
81
|
+
[DB]: config.db!,
|
|
82
|
+
...c.json || c.tty ? {} : { [TEXT]: 'drawn' },
|
|
83
|
+
},
|
|
84
|
+
fetch: async (request) => {
|
|
85
|
+
last = undefined
|
|
86
|
+
return last = await go(request)
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
// A ping runs nothing, so whatever becomes of it, nothing has run yet.
|
|
90
|
+
try {
|
|
91
|
+
await ask('ping')
|
|
92
|
+
} catch {
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
if (!ours()) return
|
|
96
|
+
let said: Result
|
|
97
|
+
try {
|
|
98
|
+
said = await ask('tools/call', {
|
|
99
|
+
name: declared.name,
|
|
100
|
+
arguments: args,
|
|
101
|
+
}) as Result
|
|
102
|
+
} catch (error) {
|
|
103
|
+
if (last && !ours()) return
|
|
104
|
+
if (error instanceof Refused && error.code == UNKNOWN) return
|
|
105
|
+
throw error
|
|
106
|
+
}
|
|
107
|
+
if (last?.headers.has(TEXT)) {
|
|
108
|
+
let { text } = saidBy(said)
|
|
109
|
+
if (text) c.out(text)
|
|
110
|
+
return exit(declared, said)
|
|
111
|
+
}
|
|
112
|
+
return await printed(c, config, declared, said, ask)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// The bundles a reply answers with, which every tool whose answer is entities
|
|
116
|
+
// sends under `structuredContent.result` (@yaks/mcp `answerSchema`).
|
|
117
|
+
let bundles = (said: Result): Bundle[] | undefined => {
|
|
118
|
+
let result = (said.structuredContent as { result?: unknown } | undefined)
|
|
119
|
+
?.result
|
|
120
|
+
return Array.isArray(result) ? result : undefined
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// The exit code ./local.ts `tool` would have returned: 1 for a refusal or a
|
|
124
|
+
// check whose own answer fails.
|
|
125
|
+
let exit = (declared: Declared, said: Result): number =>
|
|
126
|
+
said.isError || ailing(declared, bundles(said) ?? []) ? 1 : 0
|
|
127
|
+
|
|
128
|
+
// A reply printed as the command would have printed the answer had it run the
|
|
129
|
+
// tool itself (./local.ts `tool`): `--json` as the data, entities through the
|
|
130
|
+
// views, a refusal's exit code 1. A reply with no entities is its text.
|
|
131
|
+
let printed = async (
|
|
132
|
+
c: Ctx,
|
|
133
|
+
config: Config,
|
|
134
|
+
declared: Declared,
|
|
135
|
+
said: Result,
|
|
136
|
+
ask: Rpc,
|
|
137
|
+
): Promise<number> => {
|
|
138
|
+
let code = exit(declared, said)
|
|
139
|
+
let answer = bundles(said)
|
|
140
|
+
if (c.json && said.structuredContent !== undefined) {
|
|
141
|
+
c.out(JSON.stringify(said.structuredContent, null, 2))
|
|
142
|
+
return code
|
|
143
|
+
}
|
|
144
|
+
if (!answer) {
|
|
145
|
+
let { text } = saidBy(said)
|
|
146
|
+
if (text) (code ? c.note : c.out)(text)
|
|
147
|
+
return code
|
|
148
|
+
}
|
|
149
|
+
let plugins = (config.plugins ?? []).map(used)
|
|
150
|
+
let [{ vocab }, { registry }, { shown }] = await Promise.all([
|
|
151
|
+
import('./words.js').then(({ words }) => words(config)),
|
|
152
|
+
import('./answer.js'),
|
|
153
|
+
import('./shown.js'),
|
|
154
|
+
])
|
|
155
|
+
let asked = (name: string, args: Record<string, unknown>) =>
|
|
156
|
+
ask('tools/call', { name, arguments: args })
|
|
157
|
+
.then((r) => bundles(r as Result) ?? [], () => [])
|
|
158
|
+
await shown(
|
|
159
|
+
c,
|
|
160
|
+
plugins,
|
|
161
|
+
await registry(plugins, pluginViews),
|
|
162
|
+
vocab,
|
|
163
|
+
answer,
|
|
164
|
+
{
|
|
165
|
+
lookup: (ids) => asked('graph_show', { ids }),
|
|
166
|
+
query: (q) => asked('graph_query', { q }),
|
|
167
|
+
},
|
|
168
|
+
declared,
|
|
169
|
+
)
|
|
170
|
+
return code
|
|
171
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Wake an effect pool from committed revisions read beside its main thread.
|
|
2
|
+
// Only one read is outstanding; a slow database cannot queue polling work.
|
|
3
|
+
import { system } from "@yaks/fp";
|
|
4
|
+
export let watchRevision = (read, changed, report, clock = system)=>{
|
|
5
|
+
let stopped = false, first = true, prior;
|
|
6
|
+
let cancel = ()=>{};
|
|
7
|
+
let look = async ()=>{
|
|
8
|
+
try {
|
|
9
|
+
let next = await read();
|
|
10
|
+
if (stopped) return;
|
|
11
|
+
if (!first && next !== prior) changed();
|
|
12
|
+
first = false;
|
|
13
|
+
prior = next;
|
|
14
|
+
cancel = clock.after(50, ()=>void look());
|
|
15
|
+
} catch (error) {
|
|
16
|
+
if (!stopped) report(error);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
void look();
|
|
20
|
+
return ()=>{
|
|
21
|
+
stopped = true;
|
|
22
|
+
cancel();
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=watch_revision.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch_revision.js","sources":["./watch_revision.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,2EAA2E;AAC3E,SAAqB,MAAM,wBAA6B;AAExD,OAAO,IAAI,gBAAgB,CACzB,MACA,SACA,QACA,QAAe,MAAM;EAErB,IAAI,UAAU,OAAO,QAAQ,MAAM;EACnC,IAAI,SAAS,KAAO;EACpB,IAAI,OAAO;IACT,IAAI;MACF,IAAI,OAAO,MAAM;MACjB,IAAI,SAAS;MACb,IAAI,CAAC,SAAS,SAAS,OAAO;MAC9B,QAAQ;MACR,QAAQ;MACR,SAAS,MAAM,KAAK,CAAC,IAAI,IAAM,KAAK;IACtC,EAAE,OAAO,OAAO;MACd,IAAI,CAAC,SAAS,OAAO;IACvB;EACF;EACA,KAAK;EACL,OAAO;IACL,UAAU;IACV;EACF;AACF,EAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Wake an effect pool from committed revisions read beside its main thread.
|
|
2
|
+
// Only one read is outstanding; a slow database cannot queue polling work.
|
|
3
|
+
import { type Clock, system } from '@yaks/fp'
|
|
4
|
+
|
|
5
|
+
export let watchRevision = (
|
|
6
|
+
read: () => unknown | Promise<unknown>,
|
|
7
|
+
changed: () => void,
|
|
8
|
+
report: (error: unknown) => void,
|
|
9
|
+
clock: Clock = system,
|
|
10
|
+
): () => void => {
|
|
11
|
+
let stopped = false, first = true, prior: unknown
|
|
12
|
+
let cancel = () => {}
|
|
13
|
+
let look = async () => {
|
|
14
|
+
try {
|
|
15
|
+
let next = await read()
|
|
16
|
+
if (stopped) return
|
|
17
|
+
if (!first && next !== prior) changed()
|
|
18
|
+
first = false
|
|
19
|
+
prior = next
|
|
20
|
+
cancel = clock.after(50, () => void look())
|
|
21
|
+
} catch (error) {
|
|
22
|
+
if (!stopped) report(error)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
void look()
|
|
26
|
+
return () => {
|
|
27
|
+
stopped = true
|
|
28
|
+
cancel()
|
|
29
|
+
}
|
|
30
|
+
}
|
package/words.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// What a config's plugins declare, read without opening anything: each one's
|
|
2
|
+
// `./vocab`, the vocabulary those documents load into, and the tools they
|
|
3
|
+
// declare. A command line lists its subcommands from these words
|
|
4
|
+
// (./subcommands.ts), and a graph is built over them (./host.ts `compose`).
|
|
5
|
+
// This module imports none of what opens a graph — no database, rule or
|
|
6
|
+
// effect — so a usage page, a help page or a mistyped word costs a command
|
|
7
|
+
// the plugins' declarations and nothing more.
|
|
8
|
+
import { given, subpath, subpaths, used } from "./config.js";
|
|
9
|
+
import { chosen, facetsOf } from "@yaks/host/config";
|
|
10
|
+
import { taking, wordsOf } from "@yaks/host/words";
|
|
11
|
+
export { wordsOf } from "@yaks/host/words";
|
|
12
|
+
/** The box's loader, including its terminal commands. */ export let facet = Object.assign((plugin, name)=>subpath(plugin, name), {
|
|
13
|
+
together: subpaths
|
|
14
|
+
});
|
|
15
|
+
/** The words a config's plugins declare: each one's `./vocab`, and nothing
|
|
16
|
+
* else — no database opened, no rule or tool imported. */ export let words = async (config, load = facet)=>{
|
|
17
|
+
let plugins = (config.plugins ?? []).map((plug)=>[
|
|
18
|
+
used(plug),
|
|
19
|
+
given(plug),
|
|
20
|
+
chosen(plug),
|
|
21
|
+
facetsOf(plug)
|
|
22
|
+
]);
|
|
23
|
+
await load.together?.(plugins.filter(([, , , facets])=>facets === undefined || facets.includes('vocab')).map(([p])=>[
|
|
24
|
+
p,
|
|
25
|
+
'vocab'
|
|
26
|
+
]));
|
|
27
|
+
return wordsOf(await taking(plugins, 'vocab', load));
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=words.js.map
|
package/words.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"words.js","sources":["./words.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,0EAA0E;AAC1E,iEAAiE;AACjE,4EAA4E;AAC5E,wEAAwE;AACxE,2EAA2E;AAC3E,8CAA8C;AAE9C,SAAsB,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,sBAAqB;AACzE,SAAS,MAAM,EAAmB,QAAQ,iCAAsC;AAEhF,SAAS,MAAM,EAAc,OAAO,gCAAqC;AAEzE,SAAoC,OAAO,gCAAqC;AAEhF,uDAAuD,GACvD,OAAO,IAAI,QAAiC,OAAO,MAAM,CACvD,CAA+C,QAAgB,OAC7D,QAAyC,QAAQ,OACnD;EAAE,UAAU;AAAS,GACtB;AAED;wDACwD,GACxD,OAAO,IAAI,QAAQ,OACjB,QACA,OAAa,KAAK;EAElB,IAAI,UAAU,CAAC,OAAO,OAAO,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,OAAqB;MAC7D,KAAK;MACL,MAAM;MACN,OAAO;MACP,SAAS;KACV;EACD,MAAM,KAAK,QAAQ,GACjB,QAAQ,MAAM,CAAC,CAAC,OAAO,OAAO,GAC5B,WAAW,aAAa,OAAO,QAAQ,CAAC,UACxC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAK;MAAC;MAAG;KAAQ;EAE7B,OAAO,QAAQ,MAAM,OAAO,SAAS,SAAS;AAChD,EAAC"}
|
package/words.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// What a config's plugins declare, read without opening anything: each one's
|
|
2
|
+
// `./vocab`, the vocabulary those documents load into, and the tools they
|
|
3
|
+
// declare. A command line lists its subcommands from these words
|
|
4
|
+
// (./subcommands.ts), and a graph is built over them (./host.ts `compose`).
|
|
5
|
+
// This module imports none of what opens a graph — no database, rule or
|
|
6
|
+
// effect — so a usage page, a help page or a mistyped word costs a command
|
|
7
|
+
// the plugins' declarations and nothing more.
|
|
8
|
+
|
|
9
|
+
import { type Config, given, subpath, subpaths, used } from './config.js'
|
|
10
|
+
import { chosen, type Configured, facetsOf } from '@yaks/host/config'
|
|
11
|
+
import type { Facets, Load } from 'jsr:@yaks/host@0.2.36'
|
|
12
|
+
import { taking, type Words, wordsOf } from '@yaks/host/words'
|
|
13
|
+
import type { CliFacet } from './host.ts'
|
|
14
|
+
export { type Declared, type Words, wordsOf } from '@yaks/host/words'
|
|
15
|
+
|
|
16
|
+
/** The box's loader, including its terminal commands. */
|
|
17
|
+
export let facet: Load<{ cli: CliFacet }> = Object.assign(
|
|
18
|
+
<F extends keyof (Facets & { cli: CliFacet })>(plugin: string, name: F) =>
|
|
19
|
+
subpath<(Facets & { cli: CliFacet })[F]>(plugin, name),
|
|
20
|
+
{ together: subpaths },
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
/** The words a config's plugins declare: each one's `./vocab`, and nothing
|
|
24
|
+
* else — no database opened, no rule or tool imported. */
|
|
25
|
+
export let words = async (
|
|
26
|
+
config: Config,
|
|
27
|
+
load: Load = facet,
|
|
28
|
+
): Promise<Words> => {
|
|
29
|
+
let plugins = (config.plugins ?? []).map((plug): Configured => [
|
|
30
|
+
used(plug),
|
|
31
|
+
given(plug),
|
|
32
|
+
chosen(plug),
|
|
33
|
+
facetsOf(plug),
|
|
34
|
+
])
|
|
35
|
+
await load.together?.(
|
|
36
|
+
plugins.filter(([, , , facets]) =>
|
|
37
|
+
facets === undefined || facets.includes('vocab')
|
|
38
|
+
).map(([p]) => [p, 'vocab'] as const),
|
|
39
|
+
)
|
|
40
|
+
return wordsOf(await taking(plugins, 'vocab', load))
|
|
41
|
+
}
|
package/workspaces.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as system from "@yaks/process/system";
|
|
2
|
+
import { importing } from "@yaks/fp/imports";
|
|
3
|
+
import { localConnector, sshConnector } from "@yaks/machine/connectors";
|
|
4
|
+
import { workspaces } from "@yaks/machine/workspaces";
|
|
5
|
+
import { resolveOptions } from "@yaks/sandbox/configuration";
|
|
6
|
+
import { sandboxConnect } from "@yaks/sandbox/lifecycle";
|
|
7
|
+
export let workspaceCapabilities = (host, config)=>{
|
|
8
|
+
// This CLI already has the local computer's OS doors. Availability does not
|
|
9
|
+
// select a workspace, and remote/unknown placements still never go local.
|
|
10
|
+
let configured = config.workspaces ?? {
|
|
11
|
+
connectors: {},
|
|
12
|
+
receipts: config.db && config.db != ':memory:' ? (config.db.slice(0, config.db.lastIndexOf('/')) || '.') + '/workspace-receipts' : (system.env.get('TMPDIR') ?? '/tmp') + '/yak-workspace-receipts-' + system.uid()
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
connect: async (id)=>{
|
|
16
|
+
let connectors = {
|
|
17
|
+
local: localConnector()
|
|
18
|
+
};
|
|
19
|
+
for (let [name, source] of Object.entries(configured.connectors)){
|
|
20
|
+
if (source.use == '@yaks/machine/local') {
|
|
21
|
+
connectors[name] = localConnector();
|
|
22
|
+
} else if (source.use == '@yaks/machine/ssh') {
|
|
23
|
+
connectors[name] = sshConnector(source.with);
|
|
24
|
+
} else {
|
|
25
|
+
let loaded = await importing(import.meta.resolve(source.use));
|
|
26
|
+
if (typeof loaded.connector != 'function') {
|
|
27
|
+
throw new Error('Connector module must export connector: ' + source.use);
|
|
28
|
+
}
|
|
29
|
+
connectors[name] = await loaded.connector(source.with ?? {});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return await workspaces(host.graph, {
|
|
33
|
+
connectors,
|
|
34
|
+
receipts: configured.receipts,
|
|
35
|
+
sandbox: async (id)=>(await sandboxConnect(host.graph, (await resolveOptions(host, config.sandboxes)).providers, id)).workspace
|
|
36
|
+
}).connect(id);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=workspaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspaces.js","sources":["./workspaces.ts"],"names":[],"mappings":"AAAA,YAAY,wCAA6C;AACzD,SAAS,SAAS,gCAAqC;AAIvD,SAAS,cAAc,EAAE,YAAY,wCAA6C;AAClF,SAAS,UAAU,wCAA6C;AAEhE,SAAS,cAAc,2CAAgD;AACvE,SAAS,cAAc,uCAA4C;AAEnE,OAAO,IAAI,wBAAwB,CACjC,MACA;EAEA,4EAA4E;EAC5E,0EAA0E;EAC1E,IAAI,aAAa,OAAO,UAAU,IAAI;IACpC,YAAY,CAAC;IACb,UAAU,OAAO,EAAE,IAAI,OAAO,EAAE,IAAI,aAChC,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,EAAE,CAAC,WAAW,CAAC,SAAS,GAAG,IACtD,wBACA,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,aAAa,MAAM,IAAI,6BACvC,OAAO,GAAG;EAChB;EACA,OAAO;IACL,SAAS,OAAO;MACd,IAAI,aAAgD;QAClD,OAAO;MACT;MACA,KAAK,IAAI,CAAC,MAAM,OAAO,IAAI,OAAO,OAAO,CAAC,WAAW,UAAU,EAAG;QAChE,IAAI,OAAO,GAAG,IAAI,uBAAuB;UACvC,UAAU,CAAC,KAAK,GAAG;QACrB,OAAO,IAAI,OAAO,GAAG,IAAI,qBAAqB;UAC5C,UAAU,CAAC,KAAK,GAAG,aAAa,OAAO,IAAI;QAC7C,OAAO;UACL,IAAI,SAAS,MAAM,UAAU,YAAY,OAAO,CAAC,OAAO,GAAG;UAC3D,IAAI,OAAO,OAAO,SAAS,IAAI,YAAY;YACzC,MAAM,IAAI,MACR,6CAA6C,OAAO,GAAG;UAE3D;UACA,UAAU,CAAC,KAAK,GAAG,MAAM,OAAO,SAAS,CAAC,OAAO,IAAI,IAAI,CAAC;QAC5D;MACF;MACA,OAAO,MAAM,WAAW,KAAK,KAAK,EAAE;QAClC;QACA,UAAU,WAAW,QAAQ;QAC7B,SAAS,OAAO,KACd,CAAC,MAAM,eACL,KAAK,KAAK,EACV,CAAC,MAAM,eAAe,MAAM,OAAO,SAAS,CAAC,EAAE,SAAS,EACxD,GACD,EAAE,SAAS;MAChB,GAAG,OAAO,CAAC;IACb;EACF;AACF,EAAC"}
|
package/workspaces.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as system from '@yaks/process/system'
|
|
2
|
+
import { importing } from '@yaks/fp/imports'
|
|
3
|
+
// Bind explicitly configured computer transports to existing workspace records.
|
|
4
|
+
// No connector is enabled by the graph server's own launch directory.
|
|
5
|
+
import type { Config, Host } from 'jsr:@yaks/host@0.2.36'
|
|
6
|
+
import { localConnector, sshConnector } from '@yaks/machine/connectors'
|
|
7
|
+
import { workspaces } from '@yaks/machine/workspaces'
|
|
8
|
+
import type { ComputerConnector } from 'jsr:@yaks/machine@0.2.36'
|
|
9
|
+
import { resolveOptions } from '@yaks/sandbox/configuration'
|
|
10
|
+
import { sandboxConnect } from '@yaks/sandbox/lifecycle'
|
|
11
|
+
|
|
12
|
+
export let workspaceCapabilities = (
|
|
13
|
+
host: Pick<Host, 'graph'>,
|
|
14
|
+
config: Config,
|
|
15
|
+
): Host['workspaces'] => {
|
|
16
|
+
// This CLI already has the local computer's OS doors. Availability does not
|
|
17
|
+
// select a workspace, and remote/unknown placements still never go local.
|
|
18
|
+
let configured = config.workspaces ?? {
|
|
19
|
+
connectors: {},
|
|
20
|
+
receipts: config.db && config.db != ':memory:'
|
|
21
|
+
? (config.db.slice(0, config.db.lastIndexOf('/')) || '.') +
|
|
22
|
+
'/workspace-receipts'
|
|
23
|
+
: (system.env.get('TMPDIR') ?? '/tmp') + '/yak-workspace-receipts-' +
|
|
24
|
+
system.uid(),
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
connect: async (id) => {
|
|
28
|
+
let connectors: Record<string, ComputerConnector> = {
|
|
29
|
+
local: localConnector(),
|
|
30
|
+
}
|
|
31
|
+
for (let [name, source] of Object.entries(configured.connectors)) {
|
|
32
|
+
if (source.use == '@yaks/machine/local') {
|
|
33
|
+
connectors[name] = localConnector()
|
|
34
|
+
} else if (source.use == '@yaks/machine/ssh') {
|
|
35
|
+
connectors[name] = sshConnector(source.with)
|
|
36
|
+
} else {
|
|
37
|
+
let loaded = await importing(import.meta.resolve(source.use))
|
|
38
|
+
if (typeof loaded.connector != 'function') {
|
|
39
|
+
throw new Error(
|
|
40
|
+
'Connector module must export connector: ' + source.use,
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
connectors[name] = await loaded.connector(source.with ?? {})
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return await workspaces(host.graph, {
|
|
47
|
+
connectors,
|
|
48
|
+
receipts: configured.receipts,
|
|
49
|
+
sandbox: async (id) =>
|
|
50
|
+
(await sandboxConnect(
|
|
51
|
+
host.graph,
|
|
52
|
+
(await resolveOptions(host, config.sandboxes)).providers,
|
|
53
|
+
id,
|
|
54
|
+
)).workspace,
|
|
55
|
+
}).connect(id)
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Install as <unit-template>.service.d/tracker.conf for yak web/worker units.
|
|
2
|
+
# ExecStopPost runs even when the main process was killed or timed out. It
|
|
3
|
+
# runs after the template's own ExecStopPost lines, and systemd skips it when
|
|
4
|
+
# one of those fails, so each of them carries `-` (ExecStopPost=-/usr/bin/rm …).
|
|
5
|
+
[Service]
|
|
6
|
+
ExecStopPost=%h/.deno/bin/yak unit failure %n --config %h/.yak/yak.json
|
package/yak.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// The `yak` command: ./main.ts is what it runs, and this module is where it
|
|
2
|
+
// starts.
|
|
3
|
+
//
|
|
4
|
+
// A checkout changes under a running command: a landing rewrites main's
|
|
5
|
+
// checkout file by file, and Deno reads a module when something first imports
|
|
6
|
+
// it. A command loading from the checkout as it moved would join modules of
|
|
7
|
+
// two commits, one importing a name the other has yet to export. So a command
|
|
8
|
+
// started from a checkout loads only the land lock (@yaks/git/hold, whose one
|
|
9
|
+
// import is @yaks/file/io, which imports Node's alone), waits out a landing,
|
|
10
|
+
// loads the launcher and reads the checkout under that lock, held shared
|
|
11
|
+
// (`yak serve` first mints the vocabulary's missing ids into it), and
|
|
12
|
+
// runs, in this process, the copy of this module in a snapshot of it
|
|
13
|
+
// (./runtime.ts `launch`), a tree nothing rewrites while a process runs from
|
|
14
|
+
// it. A release from JSR, an install without `.git`, and the snapshot itself
|
|
15
|
+
// never change, and run here.
|
|
16
|
+
//
|
|
17
|
+
// yak task list # the command, from its checkout's snapshot
|
|
18
|
+
// yak serve --config yak.json
|
|
19
|
+
import { hold } from "@yaks/git/hold";
|
|
20
|
+
import { readFile, stat } from 'node:fs/promises';
|
|
21
|
+
import { resolve } from 'node:path';
|
|
22
|
+
import { fileURLToPath } from 'node:url';
|
|
23
|
+
/** The Git directory every worktree of the checkout at `root` shares, read as
|
|
24
|
+
* Git reads it: `.git` is that directory, or a file naming the worktree's
|
|
25
|
+
* own, whose `commondir` names the shared one. Undefined when `root` is no
|
|
26
|
+
* Git checkout. */ export let common = async (root)=>{
|
|
27
|
+
let dot = resolve(root, '.git');
|
|
28
|
+
let found = await stat(dot).catch(()=>undefined);
|
|
29
|
+
if (!found?.isFile()) return found && dot;
|
|
30
|
+
let own = resolve(root, (await readFile(dot, 'utf8')).slice(8).trim());
|
|
31
|
+
let shared = await readFile(`${own}/commondir`, 'utf8').catch(()=>'.');
|
|
32
|
+
return resolve(own, shared.trim());
|
|
33
|
+
};
|
|
34
|
+
/** Wait until no landing writes the checkout at `root`, and keep the next
|
|
35
|
+
* from writing it until the returned release. Undefined when `root` is no Git
|
|
36
|
+
* checkout. */ export let steady = async (root)=>{
|
|
37
|
+
let dir = await common(root);
|
|
38
|
+
return dir ? hold(dir, false) : undefined;
|
|
39
|
+
};
|
|
40
|
+
// The command, from argv to its exit.
|
|
41
|
+
//
|
|
42
|
+
// An interrupt winds the command down rather than cutting it off
|
|
43
|
+
// (@yaks/process/wind). The command holds the process open: the first
|
|
44
|
+
// interrupt stops every graph it opened (./held.ts `stop`), so `yak serve`
|
|
45
|
+
// takes no new request, no new effect and no new step, and the command
|
|
46
|
+
// finishes what it started and closes the way it always does, for as long as
|
|
47
|
+
// that takes. A command with nothing open has nothing to finish, and ends at
|
|
48
|
+
// once. A second interrupt ends its duty threads where they stand (./held.ts
|
|
49
|
+
// `cut`), closes with the interrupt's code, and exits.
|
|
50
|
+
export let start = async (argv)=>{
|
|
51
|
+
let root = new URL('../../', import.meta.url);
|
|
52
|
+
let pinned = Deno.env.get('YAK_RUNTIME_ROOT') == root.href.replace(/\/$/, '');
|
|
53
|
+
let release = root.protocol == 'file:' && !pinned ? await steady(fileURLToPath(root)) : undefined;
|
|
54
|
+
if (release) {
|
|
55
|
+
// `yak serve` mints a `$id` for each word its checkout's vocab.json files
|
|
56
|
+
// lack (./vocab-ids.ts), with no landing under way, before the snapshot
|
|
57
|
+
// takes the checkout. A failure leaves the words held by their labels.
|
|
58
|
+
if (argv[0] == 'serve') {
|
|
59
|
+
await import("./vocab-ids.js").then(({ mintIds })=>mintIds(root)).catch((error)=>console.error('yak serve: vocab ids:', error));
|
|
60
|
+
}
|
|
61
|
+
let { launch } = await import("./runtime.js").catch((error)=>{
|
|
62
|
+
release();
|
|
63
|
+
throw error;
|
|
64
|
+
});
|
|
65
|
+
return launch(argv, release);
|
|
66
|
+
}
|
|
67
|
+
let [system, { listen, wind }, { inspector }] = await Promise.all([
|
|
68
|
+
import("@yaks/process/system"),
|
|
69
|
+
import("@yaks/process/wind"),
|
|
70
|
+
import("./runtime.js")
|
|
71
|
+
]);
|
|
72
|
+
listen();
|
|
73
|
+
let port = system.env.get('YAK_WORK_INSPECT');
|
|
74
|
+
if (port && argv.includes('work')) {
|
|
75
|
+
let { open } = await import('node:inspector');
|
|
76
|
+
open(inspector(port), '127.0.0.1');
|
|
77
|
+
}
|
|
78
|
+
// A supervised process keeps what it runs beside its ready file, for the
|
|
79
|
+
// next restart to compare (./code.ts).
|
|
80
|
+
let ready = flag(argv, 'ready');
|
|
81
|
+
let forget = async ()=>{};
|
|
82
|
+
if (ready) {
|
|
83
|
+
let { codeFile, record } = await import("./code.js");
|
|
84
|
+
forget = record(codeFile(ready), flag(argv, 'config')).stop;
|
|
85
|
+
}
|
|
86
|
+
// Resolve the repository's default from the same frozen tree as the CLI.
|
|
87
|
+
// Children inherit it, and a new launcher can select its own tree's pin.
|
|
88
|
+
if (pinned && !Deno.env.has('DENO_SQLITE_PATH')) {
|
|
89
|
+
let { importing } = await import("@yaks/fp/imports");
|
|
90
|
+
let { library } = await importing(new URL('bin/sqlite.ts', root).href);
|
|
91
|
+
Deno.env.set('YAK_SQLITE_PATH', await library());
|
|
92
|
+
}
|
|
93
|
+
let [{ closeAccounts }, held, { main }] = await Promise.all([
|
|
94
|
+
import("./accounts.js"),
|
|
95
|
+
import("./held.js"),
|
|
96
|
+
import("./main.js")
|
|
97
|
+
]);
|
|
98
|
+
let ran = main(argv);
|
|
99
|
+
wind.hold({
|
|
100
|
+
drain: ()=>held.stop() ? ran : undefined,
|
|
101
|
+
force: ()=>held.cut()
|
|
102
|
+
});
|
|
103
|
+
wind.done.then(async (code)=>{
|
|
104
|
+
await held.close(code);
|
|
105
|
+
await closeAccounts();
|
|
106
|
+
await forget();
|
|
107
|
+
system.exit(code);
|
|
108
|
+
});
|
|
109
|
+
ran.then(async (code)=>{
|
|
110
|
+
await forget();
|
|
111
|
+
system.exit(code);
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
/// flag(['work', '--ready', '/r/a.ready'], 'ready') -> '/r/a.ready'
|
|
115
|
+
/// flag(['serve', '--config=yak.json'], 'config') -> 'yak.json'
|
|
116
|
+
/// flag(['serve'], 'ready') -> undefined
|
|
117
|
+
/** The value a command line gives `--name`. */ export let flag = (argv, name)=>{
|
|
118
|
+
let at = argv.indexOf(`--${name}`);
|
|
119
|
+
if (at >= 0) return argv[at + 1];
|
|
120
|
+
return argv.find((a)=>a.startsWith(`--${name}=`))?.slice(name.length + 3);
|
|
121
|
+
};
|
|
122
|
+
if (import.meta.main) start(Deno.args);
|
|
123
|
+
//# sourceMappingURL=yak.js.map
|
package/yak.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yak.js","sources":["./yak.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,UAAU;AACV,EAAE;AACF,wEAAwE;AACxE,8EAA8E;AAC9E,4EAA4E;AAC5E,8EAA8E;AAC9E,8EAA8E;AAC9E,6EAA6E;AAC7E,yEAAyE;AACzE,sEAAsE;AACtE,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