@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
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { accountToken } from "./accounts.js";
|
|
2
|
+
import { saidBy } from "./roster.js";
|
|
3
|
+
import { doorUrl, rpc } from "./rpc.js";
|
|
4
|
+
let spaceOf = (input)=>{
|
|
5
|
+
let fields = new Map(input.trimEnd().split(/\r?\n/).map((row)=>{
|
|
6
|
+
let at = row.indexOf('=');
|
|
7
|
+
return [
|
|
8
|
+
row.slice(0, at),
|
|
9
|
+
row.slice(at + 1)
|
|
10
|
+
];
|
|
11
|
+
}));
|
|
12
|
+
let path = fields.get('path')?.replace(/^\//, '') ?? '';
|
|
13
|
+
if (fields.get('protocol') != 'https' || !/^(?:[a-z0-9-]+)?\.git$/.test(path)) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
return /^([a-z0-9][a-z0-9-]*)\.yaks\.app$/.exec(fields.get('host') ?? '')?.[1];
|
|
17
|
+
};
|
|
18
|
+
let grantOf = (text)=>/^yaks_[A-Za-z0-9_.=-]+$/.test(text);
|
|
19
|
+
/** Git receives a space grant through its credential protocol. */ export let gitCredential = async (input, token, connect)=>{
|
|
20
|
+
let space = spaceOf(input);
|
|
21
|
+
if (!space) return;
|
|
22
|
+
let credential = await token();
|
|
23
|
+
if (!credential) return;
|
|
24
|
+
if (!grantOf(credential)) {
|
|
25
|
+
let result = await connect(credential)('tools/call', {
|
|
26
|
+
name: 'grant',
|
|
27
|
+
arguments: {
|
|
28
|
+
space,
|
|
29
|
+
hours: 1 / 12
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
if (result.isError) return;
|
|
33
|
+
credential = /^yak login (\S+)/.exec(saidBy(result).text)?.[1] ?? '';
|
|
34
|
+
}
|
|
35
|
+
if (grantOf(credential)) return `username=yak\npassword=${credential}\n`;
|
|
36
|
+
};
|
|
37
|
+
export let gitCredentialCommand = {
|
|
38
|
+
name: 'git_credential',
|
|
39
|
+
noun: 'git',
|
|
40
|
+
verb: 'credential',
|
|
41
|
+
description: 'Supply a yaks.app credential to Git',
|
|
42
|
+
positional: [
|
|
43
|
+
'operation'
|
|
44
|
+
],
|
|
45
|
+
inputSchema: {
|
|
46
|
+
type: 'object',
|
|
47
|
+
properties: {
|
|
48
|
+
operation: {
|
|
49
|
+
type: 'string',
|
|
50
|
+
enum: [
|
|
51
|
+
'get',
|
|
52
|
+
'store',
|
|
53
|
+
'erase'
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
required: [
|
|
58
|
+
'operation'
|
|
59
|
+
]
|
|
60
|
+
},
|
|
61
|
+
run: async ({ operation }, ctx)=>{
|
|
62
|
+
let input = await ctx.reads.stdin();
|
|
63
|
+
if (operation != 'get' || !spaceOf(input)) return 0;
|
|
64
|
+
let credential = await gitCredential(input, ()=>accountToken('yaks.app', ctx.state, {
|
|
65
|
+
config: ctx.config,
|
|
66
|
+
as: ctx.as,
|
|
67
|
+
agent: !!ctx.via
|
|
68
|
+
}), (token)=>rpc({
|
|
69
|
+
url: doorUrl('yaks.app'),
|
|
70
|
+
token
|
|
71
|
+
})).catch(()=>undefined);
|
|
72
|
+
if (credential) ctx.out(credential);
|
|
73
|
+
else {
|
|
74
|
+
ctx.note('yak: no Git credential available. Sign in with yak auth yaks.app.');
|
|
75
|
+
}
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=git-credential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-credential.js","sources":["./git-credential.ts"],"names":[],"mappings":"AAAA,SAAS,YAAY,wBAAuB;AAC5C,SAAS,MAAM,sBAAqB;AACpC,SAAS,OAAO,EAAY,GAAG,mBAAkB;AAGjD,IAAI,UAAU,CAAC;EACb,IAAI,SAAS,IAAI,IACf,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;IAClC,IAAI,KAAK,IAAI,OAAO,CAAC;IACrB,OAAO;MAAC,IAAI,KAAK,CAAC,GAAG;MAAK,IAAI,KAAK,CAAC,KAAK;KAAG;EAC9C;EAEF,IAAI,OAAO,OAAO,GAAG,CAAC,SAAS,QAAQ,OAAO,OAAO;EACrD,IACE,OAAO,GAAG,CAAC,eAAe,WAAW,CAAC,yBAAyB,IAAI,CAAC,OACpE;IACA;EACF;EACA,OAAO,oCAAoC,IAAI,CAAC,OAAO,GAAG,CAAC,WAAW,KAAK,CAAC,EAAE;AAChF;AAEA,IAAI,UAAU,CAAC,OAAiB,0BAA0B,IAAI,CAAC;AAE/D,gEAAgE,GAChE,OAAO,IAAI,gBAAgB,OACzB,OACA,OACA;EAEA,IAAI,QAAQ,QAAQ;EACpB,IAAI,CAAC,OAAO;EACZ,IAAI,aAAa,MAAM;EACvB,IAAI,CAAC,YAAY;EACjB,IAAI,CAAC,QAAQ,aAAa;IACxB,IAAI,SAAS,MAAM,QAAQ,YAAY,cAAc;MACnD,MAAM;MACN,WAAW;QAAE;QAAO,OAAO,IAAI;MAAG;IACpC;IACA,IAAI,OAAO,OAAO,EAAE;IACpB,aAAa,mBAAmB,IAAI,CAAC,OAAO,QAAQ,IAAI,GAAG,CAAC,EAAE,IAAI;EACpE;EACA,IAAI,QAAQ,aAAa,OAAO,CAAC,uBAAuB,EAAE,WAAW,EAAE,CAAC;AAC1E,EAAC;AAED,OAAO,IAAI,uBAAgC;EACzC,MAAM;EACN,MAAM;EACN,MAAM;EACN,aAAa;EACb,YAAY;IAAC;GAAY;EACzB,aAAa;IACX,MAAM;IACN,YAAY;MACV,WAAW;QAAE,MAAM;QAAU,MAAM;UAAC;UAAO;UAAS;SAAQ;MAAC;IAC/D;IACA,UAAU;MAAC;KAAY;EACzB;EACA,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE;IACzB,IAAI,QAAQ,MAAM,IAAI,KAAK,CAAC,KAAK;IACjC,IAAI,aAAa,SAAS,CAAC,QAAQ,QAAQ,OAAO;IAClD,IAAI,aAAa,MAAM,cACrB,OACA,IACE,aAAa,YAAY,IAAI,KAAK,EAAE;QAClC,QAAQ,IAAI,MAAM;QAClB,IAAI,IAAI,EAAE;QACV,OAAO,CAAC,CAAC,IAAI,GAAG;MAClB,IACF,CAAC,QAAU,IAAI;QAAE,KAAK,QAAQ;QAAa;MAAM,IACjD,KAAK,CAAC,IAAM;IACd,IAAI,YAAY,IAAI,GAAG,CAAC;SACnB;MAAC,IAAI,IAAI,CACV;IACD;IACH,OAAO;EACT;AACF,EAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { accountToken } from './accounts.js'
|
|
2
|
+
import { saidBy } from './roster.js'
|
|
3
|
+
import { doorUrl, type Rpc, rpc } from './rpc.js'
|
|
4
|
+
import type { Command } from './run.ts'
|
|
5
|
+
|
|
6
|
+
let spaceOf = (input: string) => {
|
|
7
|
+
let fields = new Map(
|
|
8
|
+
input.trimEnd().split(/\r?\n/).map((row) => {
|
|
9
|
+
let at = row.indexOf('=')
|
|
10
|
+
return [row.slice(0, at), row.slice(at + 1)]
|
|
11
|
+
}),
|
|
12
|
+
)
|
|
13
|
+
let path = fields.get('path')?.replace(/^\//, '') ?? ''
|
|
14
|
+
if (
|
|
15
|
+
fields.get('protocol') != 'https' || !/^(?:[a-z0-9-]+)?\.git$/.test(path)
|
|
16
|
+
) {
|
|
17
|
+
return
|
|
18
|
+
}
|
|
19
|
+
return /^([a-z0-9][a-z0-9-]*)\.yaks\.app$/.exec(fields.get('host') ?? '')?.[1]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let grantOf = (text: string) => /^yaks_[A-Za-z0-9_.=-]+$/.test(text)
|
|
23
|
+
|
|
24
|
+
/** Git receives a space grant through its credential protocol. */
|
|
25
|
+
export let gitCredential = async (
|
|
26
|
+
input: string,
|
|
27
|
+
token: () => Promise<string | null>,
|
|
28
|
+
connect: (token: string) => Rpc,
|
|
29
|
+
): Promise<string | undefined> => {
|
|
30
|
+
let space = spaceOf(input)
|
|
31
|
+
if (!space) return
|
|
32
|
+
let credential = await token()
|
|
33
|
+
if (!credential) return
|
|
34
|
+
if (!grantOf(credential)) {
|
|
35
|
+
let result = await connect(credential)('tools/call', {
|
|
36
|
+
name: 'grant',
|
|
37
|
+
arguments: { space, hours: 1 / 12 },
|
|
38
|
+
})
|
|
39
|
+
if (result.isError) return
|
|
40
|
+
credential = /^yak login (\S+)/.exec(saidBy(result).text)?.[1] ?? ''
|
|
41
|
+
}
|
|
42
|
+
if (grantOf(credential)) return `username=yak\npassword=${credential}\n`
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export let gitCredentialCommand: Command = {
|
|
46
|
+
name: 'git_credential',
|
|
47
|
+
noun: 'git',
|
|
48
|
+
verb: 'credential',
|
|
49
|
+
description: 'Supply a yaks.app credential to Git',
|
|
50
|
+
positional: ['operation'],
|
|
51
|
+
inputSchema: {
|
|
52
|
+
type: 'object',
|
|
53
|
+
properties: {
|
|
54
|
+
operation: { type: 'string', enum: ['get', 'store', 'erase'] },
|
|
55
|
+
},
|
|
56
|
+
required: ['operation'],
|
|
57
|
+
},
|
|
58
|
+
run: async ({ operation }, ctx) => {
|
|
59
|
+
let input = await ctx.reads.stdin()
|
|
60
|
+
if (operation != 'get' || !spaceOf(input)) return 0
|
|
61
|
+
let credential = await gitCredential(
|
|
62
|
+
input,
|
|
63
|
+
() =>
|
|
64
|
+
accountToken('yaks.app', ctx.state, {
|
|
65
|
+
config: ctx.config,
|
|
66
|
+
as: ctx.as,
|
|
67
|
+
agent: !!ctx.via,
|
|
68
|
+
}),
|
|
69
|
+
(token) => rpc({ url: doorUrl('yaks.app'), token }),
|
|
70
|
+
).catch(() => undefined)
|
|
71
|
+
if (credential) ctx.out(credential)
|
|
72
|
+
else {ctx.note(
|
|
73
|
+
'yak: no Git credential available. Sign in with yak auth yaks.app.',
|
|
74
|
+
)}
|
|
75
|
+
return 0
|
|
76
|
+
},
|
|
77
|
+
}
|
package/grammar.js
ADDED
package/grammar.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grammar.js","sources":["./grammar.ts"],"names":[],"mappings":"AAAA,gFAAgF,GAChF,0BAAyB;AACzB,SAAS,QAAQ,EAAe,MAAM,wBAAuB;AAE7D,SAAS,QAAQ,EAAE,SAAS,oBAAmB"}
|
package/grammar.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Browser-safe command grammar, completion and help text, with no runtime IO. */
|
|
2
|
+
export * from './args.js'
|
|
3
|
+
export { complete, type Lookup, quoted } from './complete.js'
|
|
4
|
+
export { type Prop, type Schema } from './tool.js'
|
|
5
|
+
export { toolHelp, toolLines } from './show.js'
|
package/held.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// The graphs this process holds open, however each was opened (./local.ts),
|
|
2
|
+
// and how they end: what a command does with them when it is done or
|
|
3
|
+
// interrupted (./yak.ts), whether or not it opened any. A module of its own,
|
|
4
|
+
// so a command that opens nothing never loads the code that opens a graph.
|
|
5
|
+
/** One graph per config path and set of roles, for the life of the process:
|
|
6
|
+
* every call a command makes goes through the same assembled graph, and
|
|
7
|
+
* opening the file twice for the same roles would mean two writers in one
|
|
8
|
+
* process for no reason. */ export let hosts = new Map();
|
|
9
|
+
/** The duty threads those graphs started, for a close that cannot wait on
|
|
10
|
+
* them. */ export let asides = new Set();
|
|
11
|
+
/** Work a closing graph stopped but cannot wait on, let settle before the
|
|
12
|
+
* process ends: a page body still being made (./page.ts), which a host that
|
|
13
|
+
* stops cancels, and whose compiler would otherwise outlive the process. */ export let settling = new Set();
|
|
14
|
+
// How long a close lets stopped work settle: a make that ignores its abort
|
|
15
|
+
// never keeps the process from ending.
|
|
16
|
+
let grace = 5_000;
|
|
17
|
+
/** Ask every graph this process opened to wind down (host.ts `stop`): it
|
|
18
|
+
* takes no new request, effect or step, and the command in flight finishes
|
|
19
|
+
* what it started and returns on its own. False when it opened none, and
|
|
20
|
+
* there is nothing to wait for. */ export let stop = ()=>{
|
|
21
|
+
for (let host of hosts.values())host.then((h)=>h.stop(), ()=>{});
|
|
22
|
+
return hosts.size > 0;
|
|
23
|
+
};
|
|
24
|
+
/** Stop waiting on what is winding down: every duty thread this process
|
|
25
|
+
* started is ended where it stands (@yaks/threads `end`), so a close waiting on
|
|
26
|
+
* one goes on to its last write. What a second interrupt does before it
|
|
27
|
+
* closes (./yak.ts). */ export let cut = ()=>asides.forEach((a)=>a.end());
|
|
28
|
+
/** Close every graph this process opened, stamping how the command ended on
|
|
29
|
+
* the `process` row each of them holds. */ export let close = (code)=>// One close at a time: an interrupt's (./yak.ts) and the command's own
|
|
30
|
+
// ending can arrive together, and the second waits on the first.
|
|
31
|
+
closing ??= (async ()=>{
|
|
32
|
+
// Awaited, because the last batch is a write: a command that closed the
|
|
33
|
+
// file without waiting would leave its own row saying it is still running.
|
|
34
|
+
// A graph that failed to open has nothing to close, and the command said
|
|
35
|
+
// why.
|
|
36
|
+
for (let host of hosts.values()){
|
|
37
|
+
await (await host.catch(()=>undefined))?.close(code);
|
|
38
|
+
}
|
|
39
|
+
hosts.clear();
|
|
40
|
+
asides.clear();
|
|
41
|
+
let timer;
|
|
42
|
+
await Promise.race([
|
|
43
|
+
Promise.allSettled([
|
|
44
|
+
...settling
|
|
45
|
+
]),
|
|
46
|
+
new Promise((done)=>timer = setTimeout(done, grace))
|
|
47
|
+
]);
|
|
48
|
+
clearTimeout(timer);
|
|
49
|
+
})().finally(()=>closing = undefined);
|
|
50
|
+
let closing;
|
|
51
|
+
//# sourceMappingURL=held.js.map
|
package/held.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"held.js","sources":["./held.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,qEAAqE;AACrE,6EAA6E;AAC7E,2EAA2E;AAK3E;;;0BAG0B,GAC1B,OAAO,IAAI,QAAQ,IAAI,MAA8B;AAErD;SACS,GACT,OAAO,IAAI,SAAS,IAAI,MAAoB;AAE5C;;0EAE0E,GAC1E,OAAO,IAAI,WAAW,IAAI,MAAuB;AAEjD,2EAA2E;AAC3E,uCAAuC;AACvC,IAAI,QAAQ;AAEZ;;;iCAGiC,GACjC,OAAO,IAAI,OAAO;EAChB,KAAK,IAAI,QAAQ,MAAM,MAAM,GAAI,KAAK,IAAI,CAAC,CAAC,IAAM,EAAE,IAAI,IAAI,KAAO;EACnE,OAAO,MAAM,IAAI,GAAG;AACtB,EAAC;AAED;;;sBAGsB,GACtB,OAAO,IAAI,MAAM,IAAY,OAAO,OAAO,CAAC,CAAC,IAAM,EAAE,GAAG,IAAG;AAE3D;yCACyC,GACzC,OAAO,IAAI,QAAQ,CAAC,OAClB,uEAAuE;EACvE,iEAAiE;EACjE,YAAY,CAAC;IACX,wEAAwE;IACxE,2EAA2E;IAC3E,yEAAyE;IACzE,OAAO;IACP,KAAK,IAAI,QAAQ,MAAM,MAAM,GAAI;MAC/B,MAAM,CAAC,MAAM,KAAK,KAAK,CAAC,IAAM,UAAU,GAAG,MAAM;IACnD;IACA,MAAM,KAAK;IACX,OAAO,KAAK;IACZ,IAAI;IACJ,MAAM,QAAQ,IAAI,CAAC;MACjB,QAAQ,UAAU,CAAC;WAAI;OAAS;MAChC,IAAI,QAAQ,CAAC,OAAS,QAAQ,WAAW,MAAM;KAChD;IACD,aAAa;EACf,CAAC,IAAI,OAAO,CAAC,IAAM,UAAU,WAAU;AAEzC,IAAI"}
|
package/held.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// The graphs this process holds open, however each was opened (./local.ts),
|
|
2
|
+
// and how they end: what a command does with them when it is done or
|
|
3
|
+
// interrupted (./yak.ts), whether or not it opened any. A module of its own,
|
|
4
|
+
// so a command that opens nothing never loads the code that opens a graph.
|
|
5
|
+
|
|
6
|
+
import type { Aside } from 'jsr:@yaks/threads@0.2.36'
|
|
7
|
+
import type { Served } from './host.ts'
|
|
8
|
+
|
|
9
|
+
/** One graph per config path and set of roles, for the life of the process:
|
|
10
|
+
* every call a command makes goes through the same assembled graph, and
|
|
11
|
+
* opening the file twice for the same roles would mean two writers in one
|
|
12
|
+
* process for no reason. */
|
|
13
|
+
export let hosts = new Map<string, Promise<Served>>()
|
|
14
|
+
|
|
15
|
+
/** The duty threads those graphs started, for a close that cannot wait on
|
|
16
|
+
* them. */
|
|
17
|
+
export let asides = new Set<Aside<string>>()
|
|
18
|
+
|
|
19
|
+
/** Work a closing graph stopped but cannot wait on, let settle before the
|
|
20
|
+
* process ends: a page body still being made (./page.ts), which a host that
|
|
21
|
+
* stops cancels, and whose compiler would otherwise outlive the process. */
|
|
22
|
+
export let settling = new Set<Promise<unknown>>()
|
|
23
|
+
|
|
24
|
+
// How long a close lets stopped work settle: a make that ignores its abort
|
|
25
|
+
// never keeps the process from ending.
|
|
26
|
+
let grace = 5_000
|
|
27
|
+
|
|
28
|
+
/** Ask every graph this process opened to wind down (host.ts `stop`): it
|
|
29
|
+
* takes no new request, effect or step, and the command in flight finishes
|
|
30
|
+
* what it started and returns on its own. False when it opened none, and
|
|
31
|
+
* there is nothing to wait for. */
|
|
32
|
+
export let stop = (): boolean => {
|
|
33
|
+
for (let host of hosts.values()) host.then((h) => h.stop(), () => {})
|
|
34
|
+
return hosts.size > 0
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Stop waiting on what is winding down: every duty thread this process
|
|
38
|
+
* started is ended where it stands (@yaks/threads `end`), so a close waiting on
|
|
39
|
+
* one goes on to its last write. What a second interrupt does before it
|
|
40
|
+
* closes (./yak.ts). */
|
|
41
|
+
export let cut = (): void => asides.forEach((a) => a.end())
|
|
42
|
+
|
|
43
|
+
/** Close every graph this process opened, stamping how the command ended on
|
|
44
|
+
* the `process` row each of them holds. */
|
|
45
|
+
export let close = (code?: number): Promise<void> =>
|
|
46
|
+
// One close at a time: an interrupt's (./yak.ts) and the command's own
|
|
47
|
+
// ending can arrive together, and the second waits on the first.
|
|
48
|
+
closing ??= (async () => {
|
|
49
|
+
// Awaited, because the last batch is a write: a command that closed the
|
|
50
|
+
// file without waiting would leave its own row saying it is still running.
|
|
51
|
+
// A graph that failed to open has nothing to close, and the command said
|
|
52
|
+
// why.
|
|
53
|
+
for (let host of hosts.values()) {
|
|
54
|
+
await (await host.catch(() => undefined))?.close(code)
|
|
55
|
+
}
|
|
56
|
+
hosts.clear()
|
|
57
|
+
asides.clear()
|
|
58
|
+
let timer: ReturnType<typeof setTimeout> | undefined
|
|
59
|
+
await Promise.race([
|
|
60
|
+
Promise.allSettled([...settling]),
|
|
61
|
+
new Promise((done) => timer = setTimeout(done, grace)),
|
|
62
|
+
])
|
|
63
|
+
clearTimeout(timer)
|
|
64
|
+
})().finally(() => closing = undefined)
|
|
65
|
+
|
|
66
|
+
let closing: Promise<void> | undefined
|