@stringsync/splates 0.0.46 → 0.0.51
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/README.md +55 -10
- package/flags.d.ts +4 -4
- package/hook.d.ts +3 -0
- package/index.js +924 -451
- package/infra.d.ts +3 -0
- package/lane.d.ts +1 -1
- package/notes.d.ts +4 -0
- package/package.json +3 -3
- package/queue.d.ts +1 -1
- package/server.d.ts +7 -0
- package/setup.d.ts +2 -0
- package/task.d.ts +3 -0
- package/waiting.d.ts +3 -0
- package/coordinator.d.ts +0 -3
- package/main.d.ts +0 -6
- package/todo.d.ts +0 -3
package/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
|
-
//
|
|
5
|
-
import { basename as basename2 } from "
|
|
4
|
+
// index.ts
|
|
5
|
+
import { basename as basename2 } from "path";
|
|
6
6
|
import {
|
|
7
7
|
LEGACY,
|
|
8
8
|
legacyWarnings,
|
|
@@ -12,49 +12,49 @@ import { assets } from "@stringsync/splates-server/server";
|
|
|
12
12
|
import { NodeFs } from "webappwiz/system";
|
|
13
13
|
|
|
14
14
|
// splates.ts
|
|
15
|
-
import { DEFAULT_PORT } from "@stringsync/splates-server";
|
|
16
15
|
import { agents } from "@stringsync/splates-server/agents";
|
|
17
16
|
import { attach } from "@stringsync/splates-server/artifacts";
|
|
18
|
-
import { commaList as
|
|
19
|
-
import {
|
|
17
|
+
import { commaList as commaList6 } from "@stringsync/splates-server/comma-list";
|
|
18
|
+
import { refuseGroomer as refuseGroomer4 } from "@stringsync/splates-server/conversations";
|
|
19
|
+
import { exits, fail as fail9 } from "@stringsync/splates-server/exit";
|
|
20
20
|
import { DEFAULT_COUNT, log as showLog } from "@stringsync/splates-server/log";
|
|
21
21
|
import { merge } from "@stringsync/splates-server/merge";
|
|
22
22
|
import { portsLs } from "@stringsync/splates-server/ports";
|
|
23
23
|
import { forget, init } from "@stringsync/splates-server/projects";
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
MIGRATING,
|
|
26
|
+
MIGRATION_LIMIT,
|
|
27
|
+
migrateRecords,
|
|
28
|
+
repository as repository9
|
|
29
|
+
} from "@stringsync/splates-server/records";
|
|
25
30
|
import {
|
|
26
31
|
newest,
|
|
32
|
+
recordsFirst,
|
|
27
33
|
rosterOf as rosterOf2,
|
|
28
34
|
runHeavy,
|
|
29
35
|
seeded as seeded2,
|
|
30
|
-
serveDev,
|
|
31
36
|
update
|
|
32
37
|
} from "@stringsync/splates-server/server";
|
|
33
|
-
import {
|
|
38
|
+
import { addFactTasks } from "@stringsync/splates-server/stats";
|
|
34
39
|
import {
|
|
35
40
|
add,
|
|
36
41
|
checkpoint,
|
|
37
42
|
claim,
|
|
38
43
|
DEFAULT_TIMEOUT as DEFAULT_TIMEOUT3,
|
|
39
|
-
escalate,
|
|
40
44
|
follow,
|
|
41
|
-
handoff,
|
|
42
45
|
list,
|
|
43
46
|
path,
|
|
44
47
|
REMOVE_REASONS,
|
|
45
48
|
recordRetry,
|
|
46
49
|
remove,
|
|
47
|
-
reportToCaller,
|
|
48
50
|
serveProject,
|
|
49
51
|
show,
|
|
50
|
-
tell,
|
|
51
52
|
untilAfter as untilAfter3,
|
|
52
53
|
wait
|
|
53
54
|
} from "@stringsync/splates-server/tasks";
|
|
54
|
-
import {
|
|
55
|
-
import { cli as cli12 } from "webappwiz/cmd";
|
|
55
|
+
import { cli as cli15 } from "webappwiz/cmd";
|
|
56
56
|
import { Duration as Duration3 } from "webappwiz/time";
|
|
57
|
-
import { z as
|
|
57
|
+
import { z as z16 } from "zod";
|
|
58
58
|
|
|
59
59
|
// artifact.ts
|
|
60
60
|
import { basename, resolve } from "node:path";
|
|
@@ -71,6 +71,7 @@ import { cli } from "webappwiz/cmd";
|
|
|
71
71
|
import { z as z2 } from "zod";
|
|
72
72
|
|
|
73
73
|
// flags.ts
|
|
74
|
+
import { BACKLOG_LANE } from "@stringsync/splates-server/board";
|
|
74
75
|
import { commaList } from "@stringsync/splates-server/comma-list";
|
|
75
76
|
import { SYSTEM_STORES } from "@stringsync/splates-server/creds";
|
|
76
77
|
import { fail } from "@stringsync/splates-server/exit";
|
|
@@ -82,6 +83,7 @@ import {
|
|
|
82
83
|
} from "@stringsync/splates-server/models";
|
|
83
84
|
import { SLOT_POOL } from "@stringsync/splates-server/ports";
|
|
84
85
|
import { rosterOf, seeded } from "@stringsync/splates-server/server";
|
|
86
|
+
import { FsStorage } from "@stringsync/splates-server/storage";
|
|
85
87
|
import { SavedTunnel } from "@stringsync/splates-server/tunnel";
|
|
86
88
|
import { z } from "zod";
|
|
87
89
|
var position = z.coerce.number().int().positive().optional();
|
|
@@ -112,17 +114,14 @@ async function effortIn(deps, agent, effort, data = {}) {
|
|
|
112
114
|
return { effort: pickEffort(offered, agent, effort, data) };
|
|
113
115
|
}
|
|
114
116
|
function offeredOf({ ps, fs }) {
|
|
115
|
-
return new Offered(
|
|
117
|
+
return new Offered(new FsStorage(splatesHome(ps), fs).document("offered.json"));
|
|
116
118
|
}
|
|
117
119
|
function slotTunnelsOf({
|
|
118
120
|
ps,
|
|
119
121
|
fs,
|
|
120
122
|
secrets = SYSTEM_STORES
|
|
121
123
|
}) {
|
|
122
|
-
return SLOT_POOL.map(({ word }) => new
|
|
123
|
-
fs,
|
|
124
|
-
store: secrets.device
|
|
125
|
-
}));
|
|
124
|
+
return SLOT_POOL.map(({ word }) => SavedTunnel.in(new FsStorage(`${splatesHome(ps)}/slots/${word}`, fs), secrets.device));
|
|
126
125
|
}
|
|
127
126
|
function laneIn(raw) {
|
|
128
127
|
const value = raw.trim();
|
|
@@ -135,19 +134,22 @@ function laneIn(raw) {
|
|
|
135
134
|
if (value === "none") {
|
|
136
135
|
return null;
|
|
137
136
|
}
|
|
137
|
+
if (value === "backlog") {
|
|
138
|
+
return BACKLOG_LANE;
|
|
139
|
+
}
|
|
138
140
|
const id = Number(value);
|
|
139
|
-
if (!Number.isInteger(id) || id
|
|
141
|
+
if (!Number.isInteger(id) || id < 0) {
|
|
140
142
|
fail("usage", `'${value}' is not a lane: pass its number, new or none`, {
|
|
141
143
|
lane: value
|
|
142
144
|
});
|
|
143
145
|
}
|
|
144
146
|
return id;
|
|
145
147
|
}
|
|
146
|
-
function
|
|
148
|
+
function taskIds(raw) {
|
|
147
149
|
return commaList(raw).map((value) => {
|
|
148
150
|
const id = Number(value);
|
|
149
151
|
if (!Number.isInteger(id) || id <= 0) {
|
|
150
|
-
fail("usage", `'${value}' is not a
|
|
152
|
+
fail("usage", `'${value}' is not a task number`, { number: value });
|
|
151
153
|
}
|
|
152
154
|
return id;
|
|
153
155
|
});
|
|
@@ -162,7 +164,7 @@ async function here({
|
|
|
162
164
|
}
|
|
163
165
|
|
|
164
166
|
// artifact.ts
|
|
165
|
-
var splatesArtifact = cli("artifact").description("files your conversation made as its outputs, such as a screenshot, a recording or an HTML page: kept by name for the life of the conversation, whatever task it was made in, and listed on the `splates server` page beside its thread. A file that shows a question
|
|
167
|
+
var splatesArtifact = cli("artifact").description("files your conversation made as its outputs, such as a screenshot, a recording or an HTML page: kept by name for the life of the conversation, whatever task it was made in, and listed on the `splates server` page beside its thread. A file that shows a question or a demo step is no artifact: `splates attach` it. The conversation is $SPLATES_CONVERSATION, or --conversation <id> from an agent outside `splates server`");
|
|
166
168
|
var conversation = [
|
|
167
169
|
"conversation",
|
|
168
170
|
z2.string(),
|
|
@@ -232,6 +234,7 @@ splatesBudget.command("show").description("show each limit: what made workers sp
|
|
|
232
234
|
dev: opts.dev,
|
|
233
235
|
json: opts.json,
|
|
234
236
|
log: ctx.log,
|
|
237
|
+
fs: ctx.fs,
|
|
235
238
|
ps: ctx.ps,
|
|
236
239
|
send: ctx.fetch
|
|
237
240
|
}));
|
|
@@ -243,6 +246,7 @@ splatesBudget.command("set").description("set a limit, in dollars (dollars an ho
|
|
|
243
246
|
dev: opts.dev,
|
|
244
247
|
json: opts.json,
|
|
245
248
|
log: ctx.log,
|
|
249
|
+
fs: ctx.fs,
|
|
246
250
|
ps: ctx.ps,
|
|
247
251
|
send: ctx.fetch
|
|
248
252
|
}));
|
|
@@ -256,6 +260,7 @@ splatesBudget.command("raise").description("add dollars to a limit for a while,
|
|
|
256
260
|
dev: opts.dev,
|
|
257
261
|
json: opts.json,
|
|
258
262
|
log: ctx.log,
|
|
263
|
+
fs: ctx.fs,
|
|
259
264
|
ps: ctx.ps,
|
|
260
265
|
send: ctx.fetch
|
|
261
266
|
}));
|
|
@@ -264,91 +269,56 @@ splatesBudget.command("end").description("end a raise now, by the number `show`
|
|
|
264
269
|
dev: opts.dev,
|
|
265
270
|
json: opts.json,
|
|
266
271
|
log: ctx.log,
|
|
272
|
+
fs: ctx.fs,
|
|
267
273
|
ps: ctx.ps,
|
|
268
274
|
send: ctx.fetch
|
|
269
275
|
}));
|
|
270
276
|
|
|
271
|
-
// coordinator.ts
|
|
272
|
-
import {
|
|
273
|
-
CoordinatorBox
|
|
274
|
-
} from "@stringsync/splates-server/coordinator";
|
|
275
|
-
import { RUNNING } from "@stringsync/splates-server/server";
|
|
276
|
-
import { cli as cli3 } from "webappwiz/cmd";
|
|
277
|
-
import { z as z4 } from "zod";
|
|
278
|
-
var splatesCoordinator = cli3("coordinator").description("the always-on box in your own Hetzner Cloud account that `splates server` moves onto, made through Pulumi with the token and state the Cloud workers setup readied: a CPX21 in Ashburn with Hetzner's daily backups, reached by SSH alone");
|
|
279
|
-
splatesCoordinator.command("up").description("make the coordinator's box, or bring it to its program, with splates of this release installed for the user splates and an SSH key splates makes under ~/.splates/coordinator; run again, it changes only what is not so already. The box serves nothing until the coordinator moves onto it").option("json", z4.boolean(), { default: false, description: "emit JSON" }).action(async (opts, ctx) => {
|
|
280
|
-
ctx.log.info("making the coordinator's box; its first boot takes minutes");
|
|
281
|
-
print(ctx, await box(ctx).up(), opts.json);
|
|
282
|
-
});
|
|
283
|
-
splatesCoordinator.command("status").description("print the coordinator's box as its Pulumi stack has it").option("json", z4.boolean(), { default: false, description: "emit JSON" }).action(async (opts, ctx) => {
|
|
284
|
-
const standing = await box(ctx).status();
|
|
285
|
-
if (standing === null) {
|
|
286
|
-
ctx.log.info(opts.json ? "null" : "no coordinator's box: `splates coordinator up` makes one");
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
print(ctx, standing, opts.json);
|
|
290
|
-
});
|
|
291
|
-
splatesCoordinator.command("remove").description("destroy the coordinator's box and its backups, lifting the protection that keeps it from deletion first, and forget its stack; its SSH key stays. Anything only on the box is lost").action(async (_opts, ctx) => {
|
|
292
|
-
await box(ctx).remove();
|
|
293
|
-
ctx.log.info("removed the coordinator's box");
|
|
294
|
-
});
|
|
295
|
-
function box(ctx) {
|
|
296
|
-
return new CoordinatorBox({ version: RUNNING, ps: ctx.ps, fs: ctx.fs });
|
|
297
|
-
}
|
|
298
|
-
function print(ctx, standing, json) {
|
|
299
|
-
if (json) {
|
|
300
|
-
ctx.log.info(JSON.stringify(standing));
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
ctx.log.info([
|
|
304
|
-
`address: ${standing.ipv4}`,
|
|
305
|
-
`server: ${standing.serverId} (${standing.serverType} in ${standing.location})`,
|
|
306
|
-
`ssh: ssh -i ${standing.key} root@${standing.ipv4}`
|
|
307
|
-
].join(`
|
|
308
|
-
`));
|
|
309
|
-
}
|
|
310
|
-
|
|
311
277
|
// creds.ts
|
|
312
|
-
import { DEFAULT_TIMEOUT } from "@stringsync/splates-server/creds";
|
|
278
|
+
import { DEFAULT_TIMEOUT, PROVIDERS } from "@stringsync/splates-server/creds";
|
|
313
279
|
import { fail as fail3 } from "@stringsync/splates-server/exit";
|
|
314
280
|
import { repository as repository2 } from "@stringsync/splates-server/records";
|
|
315
281
|
import { untilAfter } from "@stringsync/splates-server/tasks";
|
|
316
|
-
import { cli as
|
|
282
|
+
import { cli as cli3 } from "webappwiz/cmd";
|
|
317
283
|
import { color } from "webappwiz/log";
|
|
318
284
|
import { Duration } from "webappwiz/time";
|
|
319
|
-
import { z as
|
|
320
|
-
var splatesCreds =
|
|
321
|
-
splatesCreds.command("request").use(repository2({ needs: "own" })).description("ask a person for a cred, saying why it is needed and what it will be used for, with markdown instructions for getting it; returns at once, and does nothing when the store already keeps it unless --replace; run from a worktree, it records the task asking").arg("name",
|
|
285
|
+
import { z as z4 } from "zod";
|
|
286
|
+
var splatesCreds = cli3("creds").description("creds an agent needs a person for, such as an API token: request one saying what it is for, with instructions for getting it, which the Creds page of `splates server` shows for the person to paste, then wait for it; the value goes into the system's store (the macOS Keychain, Windows Credential Manager, a Linux secret service), never to the agent, and code reads it through webappwiz/creds");
|
|
287
|
+
splatesCreds.command("request").use(repository2({ needs: "own" })).description("ask a person for a cred, saying why it is needed and what it will be used for, with markdown instructions for getting it; returns at once, and does nothing when the store already keeps it unless --replace; run from a worktree, it records the task asking").arg("name", z4.string(), {
|
|
322
288
|
description: "what it is kept as, an environment variable's name"
|
|
323
|
-
}).option("purpose",
|
|
289
|
+
}).option("purpose", z4.string(), {
|
|
324
290
|
default: "",
|
|
325
291
|
description: "why it is needed and what it will be used for, in a sentence the person reads before getting it"
|
|
326
|
-
}).option("instructions",
|
|
292
|
+
}).option("instructions", z4.string(), {
|
|
327
293
|
default: "",
|
|
328
294
|
description: "how to get it, in markdown: where to go, what to pick, what to paste"
|
|
329
|
-
}).option("device",
|
|
295
|
+
}).option("device", z4.boolean(), {
|
|
330
296
|
default: false,
|
|
331
297
|
description: "keep it for every project on this device, as for a person's own account, rather than this project alone"
|
|
332
|
-
}).option("
|
|
298
|
+
}).option("provider", z4.optional(z4.enum(PROVIDERS)), {
|
|
299
|
+
description: "who keeps it: `system`, the machine's own store, or `ssm`, AWS Parameter Store, where that is offered"
|
|
300
|
+
}).option("replace", z4.boolean(), {
|
|
333
301
|
default: false,
|
|
334
302
|
description: "ask again although one is kept, since the kept one does not work; --purpose and --instructions left off are those of the last request"
|
|
335
303
|
}).action(async (opts, ctx) => {
|
|
336
304
|
const scope = opts.device ? "device" : "project";
|
|
305
|
+
const provider = opts.provider ?? "system";
|
|
337
306
|
const request = await ctx.journal.record("creds request", null, async () => ctx.creds.request(opts.name, {
|
|
338
307
|
scope,
|
|
308
|
+
provider,
|
|
339
309
|
purpose: opts.purpose,
|
|
340
310
|
instructions: opts.instructions,
|
|
341
311
|
task: await here(ctx),
|
|
342
312
|
replace: opts.replace
|
|
343
313
|
}), (asked) => ({ name: opts.name, asked: asked !== null }));
|
|
344
314
|
if (request === null) {
|
|
345
|
-
ctx.log.info(`${color.green("kept")} ${opts.name} in ${ctx.creds.label(scope)}: nothing to ask`);
|
|
315
|
+
ctx.log.info(`${color.green("kept")} ${opts.name} in ${ctx.creds.label(scope, provider)}: nothing to ask`);
|
|
346
316
|
return;
|
|
347
317
|
}
|
|
348
318
|
ctx.log.info(`${color.yellow("requested")} ${opts.name} ${color.dim(request.purpose)}`);
|
|
349
319
|
ctx.log.error(`It shows on the Creds page of \`splates server\`. \`splates creds wait ${opts.name}\` until it is saved.`);
|
|
350
320
|
});
|
|
351
|
-
splatesCreds.command("wait").use(repository2({ needs: "own" })).description("block until a person saves the cred requested, or dismisses the request (`dismissed`); gives up with `timeout` rather than waiting forever").arg("name",
|
|
321
|
+
splatesCreds.command("wait").use(repository2({ needs: "own" })).description("block until a person saves the cred requested, or dismisses the request (`dismissed`); gives up with `timeout` rather than waiting forever").arg("name", z4.string(), { description: "the cred requested" }).option("timeout-secs", z4.coerce.number(), {
|
|
352
322
|
default: DEFAULT_TIMEOUT.secs,
|
|
353
323
|
description: "how long to wait before giving up"
|
|
354
324
|
}).action(async (opts, ctx) => {
|
|
@@ -361,7 +331,7 @@ splatesCreds.command("wait").use(repository2({ needs: "own" })).description("blo
|
|
|
361
331
|
});
|
|
362
332
|
ctx.log.info(`${color.green("saved")} ${opts.name}`);
|
|
363
333
|
});
|
|
364
|
-
splatesCreds.command("list").use(repository2({ needs: "read" })).description("the creds requested and still open, with what each is for, and every cred the project's store and the device's keep, by name; never a value").option("json",
|
|
334
|
+
splatesCreds.command("list").use(repository2({ needs: "read" })).description("the creds requested and still open, with what each is for, and every cred the project's store and the device's keep, by name; never a value").option("json", z4.boolean(), { default: false, description: "emit JSON" }).action(async (opts, ctx) => {
|
|
365
335
|
const open = (await ctx.creds.requests()).filter((each) => each.status === "open");
|
|
366
336
|
const kept = await ctx.creds.kept();
|
|
367
337
|
if (opts.json) {
|
|
@@ -375,15 +345,202 @@ splatesCreds.command("list").use(repository2({ needs: "read" })).description("th
|
|
|
375
345
|
}
|
|
376
346
|
}
|
|
377
347
|
for (const each of kept) {
|
|
378
|
-
ctx.log.info(`${color.green("kept")} ${each.name} ${color.dim(each.scope)}${each.savedBy === null ? "" : color.dim(` saved by ${each.savedBy}`)}`);
|
|
348
|
+
ctx.log.info(`${color.green("kept")} ${each.name} ${color.dim(`${each.provider} ${each.scope}`)}${each.savedBy === null ? "" : color.dim(` saved by ${each.savedBy}`)}`);
|
|
379
349
|
}
|
|
380
350
|
if (open.length === 0 && kept.length === 0) {
|
|
381
351
|
ctx.log.info(color.dim("no creds requested or kept"));
|
|
382
352
|
}
|
|
383
353
|
});
|
|
384
354
|
|
|
355
|
+
// hook.ts
|
|
356
|
+
import { commaList as commaList3 } from "@stringsync/splates-server/comma-list";
|
|
357
|
+
import { fail as fail4 } from "@stringsync/splates-server/exit";
|
|
358
|
+
import {
|
|
359
|
+
HookStore,
|
|
360
|
+
hookAdd,
|
|
361
|
+
hookAudit,
|
|
362
|
+
hookEdit,
|
|
363
|
+
hookGroomer,
|
|
364
|
+
hookList,
|
|
365
|
+
hookPause,
|
|
366
|
+
hookRemove,
|
|
367
|
+
lanesNamed,
|
|
368
|
+
stagesNamed,
|
|
369
|
+
TASK_EVENTS
|
|
370
|
+
} from "@stringsync/splates-server/hooks";
|
|
371
|
+
import { repository as repository3 } from "@stringsync/splates-server/records";
|
|
372
|
+
import { cli as cli4 } from "webappwiz/cmd";
|
|
373
|
+
import { z as z5 } from "zod";
|
|
374
|
+
var splatesHook = cli4("hook").description(`automations: what runs on a task event (${TASK_EVENTS.join(", ")}), as \`splates server\` sees the journal take it, or on a schedule it keeps: an agent told of it; or a shell command. Kept for you in this project's .git/splates, never checked in, since an agent hook spends your tokens; splates.config.ts's \`on\` holds the shell commands a project checks in. None set, nothing runs. The page's Automations tab lists them with when each last ran and for what task`);
|
|
375
|
+
splatesHook.command("list").use(repository3({ needs: "read" })).description("every automation set here, by number, with its trigger").option("json", z5.boolean(), { default: false, description: "emit JSON" }).action((opts, ctx) => hookList({ hooks: storeOf(ctx), log: ctx.log }, { json: opts.json }));
|
|
376
|
+
splatesHook.command("add").use(repository3({ needs: "tasks" })).description("run something on a task event, or on a schedule with `--every` or `--cron` in place of the event: `--agent <a> --prompt <words>` starts that agent in the main tree, told the event as `[SPLATES EVENT <event> #N]`, or a schedule as `[SPLATES SCHEDULE <number>]`, then your words; `--run <command>` runs it via `sh -c` in the main tree, with $SPLATES_EVENT (`schedule` for one), $SPLATES_TASKS and $SPLATES_TASK set. A schedule that came due while `splates server` was down runs once as it starts").arg("event", z5.string().optional(), {
|
|
377
|
+
description: "the task event, as task.created; none for a schedule"
|
|
378
|
+
}).option("stage", z5.string(), {
|
|
379
|
+
default: "",
|
|
380
|
+
description: "only for tasks in these stages, comma separated: backlog, ready, queued, running"
|
|
381
|
+
}).option("lane", z5.string(), {
|
|
382
|
+
default: "",
|
|
383
|
+
description: "only for tasks in these lanes, by number, comma separated"
|
|
384
|
+
}).option("every", z5.string(), {
|
|
385
|
+
default: "",
|
|
386
|
+
description: "run every so often, as 30m, 2h or 1d"
|
|
387
|
+
}).option("cron", z5.string(), {
|
|
388
|
+
default: "",
|
|
389
|
+
description: `run on a five-field cron line, in this machine's time, as "0 9 * * 1-5"`
|
|
390
|
+
}).option("agent", z5.string(), {
|
|
391
|
+
default: "",
|
|
392
|
+
description: "the agent to run, as `splates agents` names it"
|
|
393
|
+
}).option("model", z5.string(), {
|
|
394
|
+
default: "",
|
|
395
|
+
description: "its model (default: the agent's own)"
|
|
396
|
+
}).option("effort", z5.string(), {
|
|
397
|
+
default: "",
|
|
398
|
+
description: "its thinking level (default: the agent's own)"
|
|
399
|
+
}).option("prompt", z5.string(), {
|
|
400
|
+
default: "",
|
|
401
|
+
description: "what the agent is told after the event"
|
|
402
|
+
}).option("run", z5.string(), {
|
|
403
|
+
default: "",
|
|
404
|
+
description: "a shell command to run"
|
|
405
|
+
}).action(async (opts, ctx) => {
|
|
406
|
+
const pick = await assigneeIn(ctx, opts.agent, opts.model, opts.effort);
|
|
407
|
+
let hook;
|
|
408
|
+
if (opts.run !== "") {
|
|
409
|
+
if (pick != null || opts.prompt !== "") {
|
|
410
|
+
fail4("usage", "--run goes alone: a shell command runs no agent", {});
|
|
411
|
+
}
|
|
412
|
+
hook = { kind: "run", command: opts.run };
|
|
413
|
+
} else if (pick == null) {
|
|
414
|
+
fail4("usage", "say what runs: --agent with --prompt, or --run", {});
|
|
415
|
+
} else if (opts.prompt === "") {
|
|
416
|
+
fail4("usage", "an agent hook needs --prompt: what to tell it", {});
|
|
417
|
+
} else {
|
|
418
|
+
hook = { kind: "agent", prompt: opts.prompt, ...pick };
|
|
419
|
+
}
|
|
420
|
+
await hookAdd({ hooks: storeOf(ctx), log: ctx.log }, triggerOf(opts), hook);
|
|
421
|
+
});
|
|
422
|
+
splatesHook.command("edit").use(repository3({ needs: "tasks" })).description("change one of your automations, by its number in `splates hook list`, keeping its number, its pause and its last runs. Each flag changes only what it names, as `splates hook add` takes it: `--event`, `--every` or `--cron` sets what sets it off anew, `--stage` or `--lane` alone narrows its event again (`any` for no narrowing), `--prompt` or `--agent` changes what an agent is told or which agent, and `--run` makes it a shell command. The groomer changes through `splates hook groomer`").arg("id", z5.string(), { description: "its number in `splates hook list`" }).option("event", z5.string(), {
|
|
423
|
+
default: "",
|
|
424
|
+
description: "a task event to run on, as task.created, in place of what sets it off now"
|
|
425
|
+
}).option("stage", z5.string(), {
|
|
426
|
+
default: "",
|
|
427
|
+
description: "only for tasks in these stages, comma separated, or `any`: backlog, ready, queued, running"
|
|
428
|
+
}).option("lane", z5.string(), {
|
|
429
|
+
default: "",
|
|
430
|
+
description: "only for tasks in these lanes, by number, comma separated, or `any`"
|
|
431
|
+
}).option("every", z5.string(), {
|
|
432
|
+
default: "",
|
|
433
|
+
description: "run every so often, as 30m, 2h or 1d"
|
|
434
|
+
}).option("cron", z5.string(), {
|
|
435
|
+
default: "",
|
|
436
|
+
description: `run on a five-field cron line, in this machine's time, as "0 9 * * 1-5"`
|
|
437
|
+
}).option("agent", z5.string(), {
|
|
438
|
+
default: "",
|
|
439
|
+
description: "the agent to run, as `splates agents` names it"
|
|
440
|
+
}).option("model", z5.string(), {
|
|
441
|
+
default: "",
|
|
442
|
+
description: "its model, with --agent (default: the agent's own)"
|
|
443
|
+
}).option("effort", z5.string(), {
|
|
444
|
+
default: "",
|
|
445
|
+
description: "its thinking level, with --agent (default: the agent's own)"
|
|
446
|
+
}).option("prompt", z5.string(), {
|
|
447
|
+
default: "",
|
|
448
|
+
description: "what the agent is told after the event"
|
|
449
|
+
}).option("run", z5.string(), {
|
|
450
|
+
default: "",
|
|
451
|
+
description: "a shell command to run in place of an agent"
|
|
452
|
+
}).action(async (opts, ctx) => {
|
|
453
|
+
const { id, agent, model, effort, ...change } = opts;
|
|
454
|
+
const pick = await assigneeIn(ctx, agent, model, effort);
|
|
455
|
+
if (pick === null) {
|
|
456
|
+
fail4("usage", "an agent automation needs an agent: name one, or --run", {});
|
|
457
|
+
}
|
|
458
|
+
await hookEdit({ hooks: storeOf(ctx), log: ctx.log }, id, {
|
|
459
|
+
...change,
|
|
460
|
+
...pick === undefined ? {} : { pick }
|
|
461
|
+
});
|
|
462
|
+
});
|
|
463
|
+
splatesHook.command("remove").use(repository3({ needs: "tasks" })).description("take away an automation, by its number in `splates hook list`, or every one on an event").arg("id", z5.string(), {
|
|
464
|
+
description: "its number, or a task event, as task.created"
|
|
465
|
+
}).action((opts, ctx) => hookRemove({ hooks: storeOf(ctx), log: ctx.log }, opts.id));
|
|
466
|
+
splatesHook.command("pause").use(repository3({ needs: "tasks" })).description("stop an automation running, keeping it to resume").arg("id", z5.string(), { description: "its number in `splates hook list`" }).action((opts, ctx) => hookPause({ hooks: storeOf(ctx), log: ctx.log }, opts.id, true));
|
|
467
|
+
splatesHook.command("resume").use(repository3({ needs: "tasks" })).description("let a paused automation run again").arg("id", z5.string(), { description: "its number in `splates hook list`" }).action((opts, ctx) => hookPause({ hooks: storeOf(ctx), log: ctx.log }, opts.id, false));
|
|
468
|
+
splatesHook.command("groomer").use(repository3({ needs: "tasks" })).description("turn on the project's groomer, built-in automation `groomer`, or set the agent it runs as, as the Automations page does: on each task deferred to the backlog, and the backlog as `splates server` starts, a conversation of its own per run, archived as the run ends, organizes each task in order and marks it ready, never doing it. `--off` turns it off, retiring its conversations").option("agent", z5.string(), {
|
|
469
|
+
default: "",
|
|
470
|
+
description: "the agent it runs as, as `splates agents` names it"
|
|
471
|
+
}).option("model", z5.string(), {
|
|
472
|
+
default: "",
|
|
473
|
+
description: "its model (default: the agent's own)"
|
|
474
|
+
}).option("effort", z5.string(), {
|
|
475
|
+
default: "",
|
|
476
|
+
description: "its thinking level (default: the agent's own)"
|
|
477
|
+
}).option("off", z5.boolean(), {
|
|
478
|
+
default: false,
|
|
479
|
+
description: "turn it off"
|
|
480
|
+
}).action(async (opts, ctx) => {
|
|
481
|
+
const pick = await assigneeIn(ctx, opts.agent, opts.model, opts.effort);
|
|
482
|
+
if (opts.off === (pick != null)) {
|
|
483
|
+
fail4("usage", "say how it runs with --agent, or turn it off with --off", {});
|
|
484
|
+
}
|
|
485
|
+
await hookGroomer({ hooks: storeOf(ctx), log: ctx.log }, pick ?? null);
|
|
486
|
+
});
|
|
487
|
+
splatesHook.command("audit").use(repository3({ needs: "tasks" })).description("turn on the notes audit, built-in automation `notes-audit`, or set the agent it runs as and its schedule, as the Automations page does: on each run, an agent in the main tree reads each project note no open task names by its path, checks it against the code and the other notes, and defers a task for each one gone stale or contradicting another, never fixing one itself. Off by default, since each run reads code for every note on your tokens; it runs every 7d until you set `--every` or `--cron`. `--off` turns it off").option("agent", z5.string(), {
|
|
488
|
+
default: "",
|
|
489
|
+
description: "the agent it runs as, as `splates agents` names it"
|
|
490
|
+
}).option("model", z5.string(), {
|
|
491
|
+
default: "",
|
|
492
|
+
description: "its model (default: the agent's own)"
|
|
493
|
+
}).option("effort", z5.string(), {
|
|
494
|
+
default: "",
|
|
495
|
+
description: "its thinking level (default: the agent's own)"
|
|
496
|
+
}).option("every", z5.string(), {
|
|
497
|
+
default: "",
|
|
498
|
+
description: "run every so often, as 1d (default: as it was, or 7d)"
|
|
499
|
+
}).option("cron", z5.string(), {
|
|
500
|
+
default: "",
|
|
501
|
+
description: `run on a five-field cron line, in this machine's time, as "0 9 * * 1"`
|
|
502
|
+
}).option("off", z5.boolean(), {
|
|
503
|
+
default: false,
|
|
504
|
+
description: "turn it off"
|
|
505
|
+
}).action(async (opts, ctx) => {
|
|
506
|
+
const pick = await assigneeIn(ctx, opts.agent, opts.model, opts.effort);
|
|
507
|
+
if (opts.off === (pick != null)) {
|
|
508
|
+
fail4("usage", "say how it runs with --agent, or turn it off with --off", {});
|
|
509
|
+
}
|
|
510
|
+
await hookAudit({ hooks: storeOf(ctx), log: ctx.log }, pick ?? null, {
|
|
511
|
+
every: opts.every,
|
|
512
|
+
cron: opts.cron
|
|
513
|
+
});
|
|
514
|
+
});
|
|
515
|
+
function triggerOf(opts) {
|
|
516
|
+
const given = [opts.event, opts.every, opts.cron].filter((each) => each !== undefined && each !== "");
|
|
517
|
+
if (given.length !== 1) {
|
|
518
|
+
fail4("usage", "say what sets it off: a task event, --every or --cron, one of them", {});
|
|
519
|
+
}
|
|
520
|
+
if (opts.event === undefined || opts.event === "") {
|
|
521
|
+
if (opts.stage !== "" || opts.lane !== "") {
|
|
522
|
+
fail4("usage", "--stage and --lane narrow a task event, not a schedule", {});
|
|
523
|
+
}
|
|
524
|
+
return opts.every !== "" ? { every: opts.every } : { cron: opts.cron };
|
|
525
|
+
}
|
|
526
|
+
const filter = {};
|
|
527
|
+
if (opts.stage !== "") {
|
|
528
|
+
filter.stages = stagesNamed(commaList3(opts.stage));
|
|
529
|
+
}
|
|
530
|
+
if (opts.lane !== "") {
|
|
531
|
+
filter.lanes = lanesNamed(opts.lane);
|
|
532
|
+
}
|
|
533
|
+
const event = opts.event;
|
|
534
|
+
return Object.keys(filter).length === 0 ? { event } : { event, filter };
|
|
535
|
+
}
|
|
536
|
+
function storeOf(ctx) {
|
|
537
|
+
return new HookStore(ctx.storage);
|
|
538
|
+
}
|
|
539
|
+
|
|
385
540
|
// lane.ts
|
|
386
541
|
import {
|
|
542
|
+
APPROVAL,
|
|
543
|
+
BACKLOG_LANE as BACKLOG_LANE2,
|
|
387
544
|
laneAdd,
|
|
388
545
|
laneList,
|
|
389
546
|
laneRemove,
|
|
@@ -392,22 +549,27 @@ import {
|
|
|
392
549
|
laneUpdated,
|
|
393
550
|
recordLaneRemove
|
|
394
551
|
} from "@stringsync/splates-server/board";
|
|
552
|
+
import { refuseGroomer } from "@stringsync/splates-server/conversations";
|
|
395
553
|
import { UNTRIAGED } from "@stringsync/splates-server/plans";
|
|
396
|
-
import {
|
|
554
|
+
import { refuseAgentQueue } from "@stringsync/splates-server/queue";
|
|
555
|
+
import { repository as repository4 } from "@stringsync/splates-server/records";
|
|
397
556
|
import { cli as cli5 } from "webappwiz/cmd";
|
|
398
557
|
import { z as z6 } from "zod";
|
|
399
|
-
var
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
splatesLane.command("
|
|
406
|
-
|
|
558
|
+
var laneNumber = z6.union([
|
|
559
|
+
z6.literal("backlog").transform(() => BACKLOG_LANE2),
|
|
560
|
+
z6.coerce.number().int().nonnegative()
|
|
561
|
+
]);
|
|
562
|
+
var splatesLane = cli5("lane").description("lanes: named groups of tasks, for you to see related work together on the board; queue one whole with `splates lane queue`. Backlog (lane 0) is permanent and holds unmatched deferred work. Untriaged is groomed into lanes and cannot be queued whole");
|
|
563
|
+
splatesLane.command("list").use(repository4({ needs: "read" })).description("every lane: its name, its queued tasks in order, the started tasks on it, its next task, and what blocks that in other lanes").option("json", z6.boolean(), { default: false, description: "emit JSON" }).action((opts, ctx) => laneList(ctx, { json: opts.json }));
|
|
564
|
+
splatesLane.command("show").use(repository4({ needs: "read" })).description("one lane step by step, and what its agent does next: start the next task, or wait for the one blocking it in another lane to land first; `untriaged` lists the tasks in no lane, to place in lanes").arg("lane", z6.union([z6.literal(UNTRIAGED).transform(() => null), laneNumber], {
|
|
565
|
+
error: "pass a lane's number, backlog, or untriaged"
|
|
566
|
+
}), { description: "lane number, `backlog`, or `untriaged`" }).option("json", z6.boolean(), { default: false, description: "emit JSON" }).action((opts, ctx) => laneShow(ctx, opts.lane, { json: opts.json }));
|
|
567
|
+
splatesLane.command("add").use(repository4({ needs: "tasks" })).description("start an empty lane, after the others").arg("name", z6.string(), {
|
|
568
|
+
description: "what its tasks are for, like `Licensing`"
|
|
407
569
|
}).action(async (opts, ctx) => {
|
|
408
570
|
await ctx.journal.record("lane add", null, () => laneAdd(ctx, opts.name), (lane) => ({ lane: lane.id, name: lane.name }));
|
|
409
571
|
});
|
|
410
|
-
splatesLane.command("update").use(
|
|
572
|
+
splatesLane.command("update").use(repository4({ needs: "tasks" })).description("rename a lane, or move it among the others").arg("lane", laneNumber, {
|
|
411
573
|
description: "lane number"
|
|
412
574
|
}).option("name", z6.string().optional(), {
|
|
413
575
|
description: "what it is called from now on"
|
|
@@ -417,9 +579,46 @@ splatesLane.command("update").use(repository3({ needs: "tasks" })).description("
|
|
|
417
579
|
const change = { name: opts.name, position: opts.position };
|
|
418
580
|
await ctx.journal.record("lane update", null, () => laneUpdate(ctx, opts.lane, change), (record) => laneUpdated(opts.lane, record, change));
|
|
419
581
|
});
|
|
420
|
-
splatesLane.command("
|
|
582
|
+
splatesLane.command("queue").use(repository4({ needs: "tasks" })).description("queue a lane whole: each of its tasks is queued as soon as nothing blocks it, now and as tasks land, until the lane is empty; a task you take out with `splates queue remove` stays out until you queue it again. Untriaged cannot be queued whole").arg("lane", laneNumber, {
|
|
583
|
+
description: "lane number"
|
|
584
|
+
}).action(async (opts, ctx) => {
|
|
585
|
+
refuseAgentQueue(ctx.service, "lane queue");
|
|
586
|
+
await refuseGroomer(ctx.service, "lane queue");
|
|
587
|
+
const change = { queued: true };
|
|
588
|
+
await ctx.journal.record("lane update", null, () => laneUpdate(ctx, opts.lane, change), (record) => laneUpdated(opts.lane, record, change));
|
|
589
|
+
});
|
|
590
|
+
splatesLane.command("approve").use(repository4({ needs: "tasks" })).description("let a queued lane queue more tasks on its own: it stops when its budget is spent, which starts at its tasks then plus 5, and this adds 10 to what is left; refused from an agent").arg("lane", laneNumber, {
|
|
421
591
|
description: "lane number"
|
|
422
|
-
}).action((opts, ctx) =>
|
|
592
|
+
}).action(async (opts, ctx) => {
|
|
593
|
+
refuseAgentQueue(ctx.service, "lane approve");
|
|
594
|
+
const change = { approve: APPROVAL };
|
|
595
|
+
await ctx.journal.record("lane update", null, () => laneUpdate(ctx, opts.lane, change), (record) => laneUpdated(opts.lane, record, change));
|
|
596
|
+
});
|
|
597
|
+
splatesLane.command("unqueue").use(repository4({ needs: "tasks" })).description("stop queueing a lane whole, taking out of the queue each of its tasks that has yet to start; those under way go on").arg("lane", laneNumber, {
|
|
598
|
+
description: "lane number"
|
|
599
|
+
}).action(async (opts, ctx) => {
|
|
600
|
+
refuseAgentQueue(ctx.service, "lane unqueue");
|
|
601
|
+
const change = { queued: false };
|
|
602
|
+
await ctx.journal.record("lane update", null, () => laneUpdate(ctx, opts.lane, change), (record) => laneUpdated(opts.lane, record, change));
|
|
603
|
+
});
|
|
604
|
+
splatesLane.command("remove").use(repository4({ needs: "tasks" })).description("remove a lane and its tasks, kept to restore; a lane whose last task merges goes on its own; refused from an agent, which asks with a permission card").arg("lane", laneNumber, {
|
|
605
|
+
description: "lane number"
|
|
606
|
+
}).action((opts, ctx) => {
|
|
607
|
+
refuseAgentQueue(ctx.service, "lane remove");
|
|
608
|
+
return recordLaneRemove(ctx.journal, ctx.tasks, opts.lane, () => laneRemove(ctx, opts.lane));
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
// notes.ts
|
|
612
|
+
import { loadConfig } from "@stringsync/splates-server/config";
|
|
613
|
+
import { Notes } from "@stringsync/splates-server/notes";
|
|
614
|
+
async function notes(ctx) {
|
|
615
|
+
const root = ctx.project === undefined ? (await ctx.git.run(ctx.ps.cwd(), "rev-parse", "--show-toplevel")).stdout.trim() : ctx.git.root;
|
|
616
|
+
const config = await loadConfig(root, { fs: ctx.fs, git: ctx.git });
|
|
617
|
+
const found = await new Notes(ctx.fs).list(root, config);
|
|
618
|
+
for (const note of found) {
|
|
619
|
+
ctx.log.info(note.description);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
423
622
|
|
|
424
623
|
// projects.ts
|
|
425
624
|
import {
|
|
@@ -427,48 +626,265 @@ import {
|
|
|
427
626
|
listReaches,
|
|
428
627
|
REACHES
|
|
429
628
|
} from "@stringsync/splates-server/projects";
|
|
430
|
-
import { repository as
|
|
629
|
+
import { repository as repository5 } from "@stringsync/splates-server/records";
|
|
431
630
|
import { cli as cli6 } from "webappwiz/cmd";
|
|
432
631
|
import { z as z7 } from "zod";
|
|
433
|
-
var splatesProjects = cli6("projects").description("the other splates projects on this machine, and what agents of each may do in the others through splates: `read` their tasks
|
|
434
|
-
splatesProjects.command("list").use(
|
|
435
|
-
splatesProjects.command("grant").use(
|
|
436
|
-
description: "read,
|
|
632
|
+
var splatesProjects = cli6("projects").description("the other splates projects on this machine, and what agents of each may do in the others through splates: `read` their tasks and lanes; add tasks to their untriaged lane with `queue`, as every project may until granted otherwise; or run their queue, lanes and hooks with `tasks`. Any repo command runs on another project as `splates --project <slug> <command>`, refused where it needs more than that project granted").fallback("list");
|
|
633
|
+
splatesProjects.command("list").use(repository5({ needs: "read" })).description("print each other project: its slug, its root, what it may do here, and what this one may do there").option("json", z7.boolean(), { default: false, description: "emit JSON" }).action((opts, ctx) => listReaches(ctx, { json: opts.json }));
|
|
634
|
+
splatesProjects.command("grant").use(repository5({ needs: "own" })).description("let agents of another project do as much as `read`, `queue` or `tasks` here, each including those before it; the user's call, so an agent runs it only when the user asks it to").arg("project", z7.string(), { description: "the other project's slug" }).arg("reach", z7.enum(REACHES), {
|
|
635
|
+
description: "read, queue or tasks"
|
|
437
636
|
}).action((opts, ctx) => grantReach(ctx, opts.project, opts.reach));
|
|
438
637
|
|
|
439
638
|
// queue.ts
|
|
440
|
-
import {
|
|
639
|
+
import { tasksNamed } from "@stringsync/splates-server/board";
|
|
640
|
+
import { refuseGroomer as refuseGroomer2 } from "@stringsync/splates-server/conversations";
|
|
641
|
+
import {
|
|
642
|
+
queueAdd,
|
|
643
|
+
queueList,
|
|
644
|
+
queueMove,
|
|
645
|
+
queueRemove,
|
|
646
|
+
refuseAgentQueue as refuseAgentQueue2
|
|
647
|
+
} from "@stringsync/splates-server/queue";
|
|
648
|
+
import { repository as repository6 } from "@stringsync/splates-server/records";
|
|
441
649
|
import { cli as cli7 } from "webappwiz/cmd";
|
|
442
650
|
import { z as z8 } from "zod";
|
|
443
|
-
var
|
|
651
|
+
var splatesQueue = cli7("queue").description("the queue: the tasks a worker of `splates server` starts as soon as it has a slot free, each after every task it is blocked by, otherwise in the order you set. Only you queue a task, from the backlog or groomed, and an agent asks you to with a queue card; one that names no model runs on the roster's first agent");
|
|
652
|
+
splatesQueue.command("list").use(repository6({ needs: "read" })).description("the queue in the order workers start it, with each task's model and what it waits on: the open tasks it is blocked by, or those removed without merging").option("json", z8.boolean(), { default: false, description: "emit JSON" }).action((opts, ctx) => queueList(ctx, { json: opts.json }));
|
|
653
|
+
splatesQueue.command("add").use(repository6({ needs: "tasks" })).description("queue tasks for a worker to start once nothing they are blocked by is open; refused for one already under way").rest("ids", z8.coerce.number().int().positive(), {
|
|
654
|
+
description: "task numbers"
|
|
655
|
+
}).action(async (opts, ctx) => {
|
|
656
|
+
refuseAgentQueue2(ctx.service, "queue add");
|
|
657
|
+
await refuseGroomer2(ctx.service, "queue add");
|
|
658
|
+
await ctx.journal.record("queue add", await here(ctx), () => queueAdd(ctx, opts.ids), (queued) => ({ tasks: tasksNamed(queued) }));
|
|
659
|
+
});
|
|
660
|
+
splatesQueue.command("remove").use(repository6({ needs: "tasks" })).description("take tasks out of the queue, back to ready when they name a model, else the backlog; the tasks stay").rest("ids", z8.coerce.number().int().positive(), {
|
|
661
|
+
description: "task numbers"
|
|
662
|
+
}).action(async (opts, ctx) => {
|
|
663
|
+
refuseAgentQueue2(ctx.service, "queue remove");
|
|
664
|
+
await ctx.journal.record("queue remove", await here(ctx), () => queueRemove(ctx, opts.ids), (removed) => ({ tasks: tasksNamed(removed) }));
|
|
665
|
+
});
|
|
666
|
+
splatesQueue.command("move").use(repository6({ needs: "tasks" })).description("move a queued task to another place in the queue, from 1 for the next to start; what it is blocked by still goes first. Then lists the queue").arg("id", z8.coerce.number().int().positive(), { description: "task number" }).arg("position", z8.coerce.number().int().positive(), {
|
|
667
|
+
description: "where in the queue to put it, from 1"
|
|
668
|
+
}).action(async (opts, ctx) => {
|
|
669
|
+
refuseAgentQueue2(ctx.service, "queue move");
|
|
670
|
+
return queueMove(ctx, opts.id, opts.position);
|
|
671
|
+
});
|
|
672
|
+
|
|
673
|
+
// server.ts
|
|
674
|
+
import {
|
|
675
|
+
BoxShell,
|
|
676
|
+
CoordinatorBox as CoordinatorBox2,
|
|
677
|
+
deployKey,
|
|
678
|
+
machineMove,
|
|
679
|
+
neededCreds
|
|
680
|
+
} from "@stringsync/splates-server/coordinator";
|
|
681
|
+
import { SYSTEM_STORES as SYSTEM_STORES2 } from "@stringsync/splates-server/creds";
|
|
682
|
+
import { fail as fail6 } from "@stringsync/splates-server/exit";
|
|
683
|
+
import {
|
|
684
|
+
DEFAULT_PORT,
|
|
685
|
+
RUNNING,
|
|
686
|
+
serveDev
|
|
687
|
+
} from "@stringsync/splates-server/server";
|
|
688
|
+
import { coordinatorMoved } from "@stringsync/splates-server/setup";
|
|
689
|
+
import { LOCAL_SLOTS } from "@stringsync/splates-server/workers";
|
|
690
|
+
import { cli as cli9 } from "webappwiz/cmd";
|
|
691
|
+
import { z as z10 } from "zod";
|
|
692
|
+
|
|
693
|
+
// infra.ts
|
|
694
|
+
import { resolve as resolve2 } from "node:path";
|
|
695
|
+
import { commaList as commaList4 } from "@stringsync/splates-server/comma-list";
|
|
696
|
+
import {
|
|
697
|
+
CoordinatorBox,
|
|
698
|
+
writeInfraConfig
|
|
699
|
+
} from "@stringsync/splates-server/coordinator";
|
|
700
|
+
import { fail as fail5 } from "@stringsync/splates-server/exit";
|
|
701
|
+
import { infraInit } from "@stringsync/splates-server/infra/init";
|
|
702
|
+
import { cli as cli8 } from "webappwiz/cmd";
|
|
703
|
+
import { z as z9 } from "zod";
|
|
704
|
+
var splatesInfra = cli8("infra").description("the Pulumi project that makes everything the server's box needs in AWS, Cloudflare and GitHub, which `splates server deploy` then installs splates on");
|
|
705
|
+
splatesInfra.command("init").description("write a Pulumi project in <dir>, its program a dozen lines using the components of @stringsync/splates-server/infra, and the stack's config from the flags; run again, it writes only what is not so already and keeps values you changed. It prints each id and secret left to set with `pulumi config set`. It records the directory in ~/.splates/coordinator/infra.json, where `splates server deploy` finds the stack. Then `bun add @stringsync/splates-server @pulumi/pulumi @pulumi/aws @pulumi/awsx @pulumi/cloudflare @pulumi/github @pulumi/tls @pulumi/random` there and `pulumi up`").arg("dir", z9.string(), { description: "where the Pulumi project goes" }).option("stack", z9.string(), { default: "prod", description: "the stack" }).option("host", z9.string(), {
|
|
706
|
+
description: "the public host name, as in splates.example.com"
|
|
707
|
+
}).option("email", z9.string(), {
|
|
708
|
+
description: "the email address Access lets in"
|
|
709
|
+
}).option("region", z9.string(), {
|
|
710
|
+
default: "us-east-1",
|
|
711
|
+
description: "the AWS region"
|
|
712
|
+
}).option("projects", z9.string(), {
|
|
444
713
|
default: "",
|
|
445
|
-
description: "
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
ps: ctx.ps,
|
|
466
|
-
|
|
467
|
-
|
|
714
|
+
description: "comma-separated slug=owner/repo, each a project the box pushes trunk of"
|
|
715
|
+
}).action(async (opts, ctx) => {
|
|
716
|
+
const projects = commaList4(opts.projects).map((entry) => {
|
|
717
|
+
const [slug, repository] = entry.split("=");
|
|
718
|
+
if (!slug || !repository?.includes("/")) {
|
|
719
|
+
fail5("usage", `--projects wants slug=owner/repo, not ${entry}`, {
|
|
720
|
+
entry
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
return { slug, repository };
|
|
724
|
+
});
|
|
725
|
+
const { written, todo } = await infraInit({
|
|
726
|
+
dir: opts.dir,
|
|
727
|
+
stack: opts.stack,
|
|
728
|
+
host: opts.host,
|
|
729
|
+
email: opts.email,
|
|
730
|
+
region: opts.region,
|
|
731
|
+
projects,
|
|
732
|
+
fs: ctx.fs
|
|
733
|
+
});
|
|
734
|
+
await writeInfraConfig(ctx.fs, new CoordinatorBox({ ps: ctx.ps, fs: ctx.fs }).home, { dir: resolve2(opts.dir), stack: opts.stack });
|
|
735
|
+
ctx.log.info(written.length === 0 ? "already so: nothing written" : `wrote ${written.join(", ")}`);
|
|
736
|
+
for (const command of todo) {
|
|
737
|
+
ctx.log.info(`still to run in ${opts.dir}: ${command}`);
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
|
|
741
|
+
// server.ts
|
|
742
|
+
var splatesServer = cli9("server").description("the splates server: run it on this machine, or deploy it to an always-on box in your own AWS account, which the Pulumi project `splates server infra init` writes makes, reached by SSH alone").fallback("run");
|
|
743
|
+
splatesServer.command("run").description("serve every splates project on this machine as a web page, from wherever it is run: the page picks the project it shows, adds one by its path, running `splates init` there, and shows its queued and started tasks, where queued tasks can be added, updated, reordered or removed; it brings each project's records forward as it opens it. A server that crashes starts again after 2s, then 4s, 8s and 16s, and is left down after five crashes in a row that each came within a minute of its start").option("port", z10.coerce.number(), {
|
|
744
|
+
default: DEFAULT_PORT,
|
|
745
|
+
description: "port to listen on, or the next open one above it"
|
|
746
|
+
}).option("allow-hosts", z10.string(), {
|
|
747
|
+
default: "",
|
|
748
|
+
description: "comma-separated host names the page may also be reached by, like a tunnel's; put Cloudflare Access in front of them with --access-team and --access-aud"
|
|
749
|
+
}).option("access-team", z10.string(), {
|
|
750
|
+
default: "",
|
|
751
|
+
description: "the Cloudflare Access team in front of --allow-hosts, as in <team>.cloudflareaccess.com; with --access-aud, those hosts answer only to a verified Access token, and may then use conversations and terminals"
|
|
752
|
+
}).option("access-aud", z10.string(), {
|
|
753
|
+
default: "",
|
|
754
|
+
description: "the AUD tag of that Access application"
|
|
755
|
+
}).option("tunnel", z10.string(), {
|
|
756
|
+
default: "",
|
|
757
|
+
description: "the public host name of a tunnel to run, with cloudflared or the tunnel provider named by splates.config.ts in the repository it is run in, if any, which is allowed as a host too; refused without --access-team and --access-aud, so a tunnel never exposes the page unauthenticated. With none of the tunnel and Access flags, the tunnel `splates tunnel setup` saved runs, if any"
|
|
758
|
+
}).option("tunnel-name", z10.string(), {
|
|
759
|
+
default: "",
|
|
760
|
+
description: "the named tunnel cloudflared runs for --tunnel, by default the one its own config names; not with a tunnel provider of splates.config.ts"
|
|
761
|
+
}).option("ports-host", z10.string(), {
|
|
762
|
+
default: "",
|
|
763
|
+
description: "the wildcard base host to serve task ports under, saved for this machine so a bare `splates server` serves it too: each port a task's processes listen on opens at https://<task>-<port>.<base>, to whoever Cloudflare Access lets in, and is refused without Access; routing *.<base> here, its DNS and TLS, are yours. `none` forgets it, leaving each task port forwarded to a port on this machine's loopback alone"
|
|
764
|
+
}).option("worker-slots", z10.coerce.number().int().min(1), {
|
|
765
|
+
default: LOCAL_SLOTS,
|
|
766
|
+
description: "how many agents that other agents started (with `splates add --agent`, or a lane's orchestrator handing out tasks) this machine's worker runs at once; past them, each new or resumed one waits in the queue, first come, first served, which `splates worker queue` shows and reorders. An agent you start runs at once on any worker up, taking no slot. Read as the server starts its worker, which a restart from the page leaves running"
|
|
767
|
+
}).option("keepalive", z10.boolean(), {
|
|
768
|
+
default: false,
|
|
769
|
+
description: "keep a machine left to serve awake while the server runs: on macOS with `caffeinate`, on power or idle, though closing a laptop's lid still sleeps it; on Linux with a systemd-inhibit lock on sleep and idle, which the server serves on without, saying so, where systemd is missing or refuses it. Refused on other platforms"
|
|
770
|
+
}).option("slot", z10.boolean(), {
|
|
771
|
+
default: false,
|
|
772
|
+
description: "serve this checkout's splates at https://<word>.<zone>, a slot of its own on the zone `splates tunnel setup` uses, behind the same Access policy, so several run side by side and a phone opens each by name: a task's worktree keeps its word, as fox, until the task merges or is removed, which stops its server; run again, it stops the tree's last server first. Refused in a splates repository's main tree, which every agent shares. A slot keeps its own projects in ~/.splates/slots/<word>, apart from yours, starting with a throwaway project there; not with the tunnel and Access flags"
|
|
773
|
+
}).action((opts, ctx) => serveDev(ctx, opts));
|
|
774
|
+
splatesServer.mount("infra", splatesInfra);
|
|
775
|
+
splatesServer.command("deploy").description("deploy the server to the box its Pulumi stack made (`splates server infra init`, then `pulumi up`), over SSH, with splates of this release installed for the user splates. The SSH key and the host key come from the stack and the instance's console. It checks what the deploy needs, brings the box's splates to this release, and exits `blocked`, naming each, until the box's Parameter Store holds the creds the stack should have put there; then gives each project a clone there with its deploy key from Parameter Store. Then it asks every agent of this machine's `splates server` to checkpoint and stops it, carries the server's records (no creds: the box reads its own through its instance role) to the box, starts `splates server` there for good under systemd, and joins this machine to it as a worker, kept up by a LaunchAgent, where each task carries on in its worktree here. This machine's records go aside, kept, and its `splates` reaches the box from then on. Run again once the server runs on the box, it brings the box's splates to this release and restarts it there").option("dry-run", z10.boolean(), {
|
|
776
|
+
default: false,
|
|
777
|
+
description: "stop once the box is ready, before this machine's server stops or anything here changes; once the server runs on the box, change nothing"
|
|
778
|
+
}).option("dev", z10.string(), {
|
|
779
|
+
default: `http://localhost:${DEFAULT_PORT}`,
|
|
780
|
+
description: "this machine's `splates server`, which the deploy stops"
|
|
781
|
+
}).action(async (opts, ctx) => {
|
|
782
|
+
const moved = await machineMove({
|
|
783
|
+
ps: ctx.ps,
|
|
784
|
+
fs: ctx.fs,
|
|
785
|
+
log: ctx.log,
|
|
786
|
+
version: RUNNING,
|
|
787
|
+
dev: opts.dev,
|
|
788
|
+
stores: ctx.secrets ?? SYSTEM_STORES2,
|
|
789
|
+
...ctx.fetch === undefined ? {} : { fetch: ctx.fetch }
|
|
790
|
+
}).run({ dryRun: opts["dry-run"] });
|
|
791
|
+
if (moved.status === "blocked") {
|
|
792
|
+
fail6("blocked", [
|
|
793
|
+
"The box's Parameter Store lacks these. Set each (the Pulumi stack makes them: `pulumi up`), then deploy again:",
|
|
794
|
+
...moved.needs.map((name) => ` ${name}`)
|
|
795
|
+
].join(`
|
|
796
|
+
`), { needs: moved.needs });
|
|
797
|
+
}
|
|
798
|
+
if (moved.status === "deployed") {
|
|
799
|
+
ctx.log.info(`the server runs on the box at ${moved.ipv4}: deploy again without --dry-run to bring it to ${moved.version}`);
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
if (moved.status === "updated") {
|
|
803
|
+
ctx.log.info(`the server on the box at ${moved.ipv4} runs ${moved.version} now`);
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
if (moved.status === "ready") {
|
|
807
|
+
ctx.log.info(`the box is ready to serve ${moved.projects.join(", ")} through ${moved.host}: deploy again without --dry-run`);
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
ctx.log.info([
|
|
811
|
+
`the server runs on the box: https://${moved.host}`,
|
|
812
|
+
`this machine is its worker ${ctx.ps.hostname}, kept up by ${moved.worker}`,
|
|
813
|
+
`its own records are kept aside in ${moved.aside} and each project's .git/splates.moved`
|
|
814
|
+
].join(`
|
|
815
|
+
`));
|
|
816
|
+
});
|
|
817
|
+
splatesServer.command("status").description("print where the server runs, here or deployed to its box, and the box as its cloud has it").option("json", z10.boolean(), { default: false, description: "emit JSON" }).action(async (opts, ctx) => {
|
|
818
|
+
const deployed = await coordinatorMoved({
|
|
819
|
+
fs: ctx.fs,
|
|
820
|
+
ps: ctx.ps,
|
|
821
|
+
home: box(ctx).home
|
|
822
|
+
});
|
|
823
|
+
const standing = await box(ctx).status();
|
|
824
|
+
if (opts.json) {
|
|
825
|
+
ctx.log.info(JSON.stringify({ deployed, box: standing }));
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
ctx.log.info([
|
|
829
|
+
`runs: ${deployed ? "on the box" : "on this machine"}`,
|
|
830
|
+
...standing === null ? [
|
|
831
|
+
"box: none: `splates server infra init` writes the Pulumi project, `pulumi up` there makes it"
|
|
832
|
+
] : [
|
|
833
|
+
`address: ${standing.ipv4}`,
|
|
834
|
+
`instance: ${standing.instanceId} (role ${standing.roleName})`,
|
|
835
|
+
`host: ${standing.host}`,
|
|
836
|
+
"ssh: splates server ssh"
|
|
837
|
+
]
|
|
838
|
+
].join(`
|
|
839
|
+
`));
|
|
840
|
+
});
|
|
841
|
+
splatesServer.command("ssh").description("open a root shell on the box over SSH, with the key its Pulumi stack made, or run the command given there").rest("command", z10.string(), {
|
|
842
|
+
description: "what to run on the box; by default a shell"
|
|
843
|
+
}).passThroughOptions().action(async (opts, ctx) => {
|
|
844
|
+
const standing = await box(ctx).status();
|
|
845
|
+
if (standing === null) {
|
|
846
|
+
fail6("not_found", "no box: `splates server infra init` writes the Pulumi project, `pulumi up` there makes it");
|
|
847
|
+
}
|
|
848
|
+
const { exitCode } = await ctx.ps.spawn(shell(ctx, standing).login(opts.command));
|
|
849
|
+
ctx.ps.exit(exitCode);
|
|
850
|
+
});
|
|
851
|
+
splatesServer.command("destroy").description("say how to destroy the box: its Pulumi stack made it, so the stack unmakes it").action(async (_opts, ctx) => {
|
|
852
|
+
const infra = await box(ctx).infra();
|
|
853
|
+
fail6("usage", infra === null ? "no infra project here: run `pulumi destroy` in the one `splates server infra init` wrote" : `run \`pulumi destroy\` in ${infra.dir}, after lifting the termination protection (\`disableApiTermination\`) on the instance. Anything only on the box is lost`);
|
|
854
|
+
});
|
|
855
|
+
splatesServer.command("needs").description("kept for `splates server deploy`, which runs it on the box: print the name of each cred this box's store lacks of those the server needs, one per line").rest("roots", z10.string(), {
|
|
856
|
+
description: "each project's clone on this machine"
|
|
857
|
+
}).action(async (opts, ctx) => {
|
|
858
|
+
const missing = await neededCreds(ctx.secrets ?? SYSTEM_STORES2, opts.roots);
|
|
859
|
+
for (const name of missing) {
|
|
860
|
+
ctx.log.info(name);
|
|
861
|
+
}
|
|
862
|
+
});
|
|
863
|
+
splatesServer.command("deploy-key").description("kept for `splates server deploy`, which runs it on the box: print the deploy key of the project whose clone is <root>").arg("root", z10.string(), {
|
|
864
|
+
description: "the project's clone on this machine"
|
|
865
|
+
}).action(async (opts, ctx) => {
|
|
866
|
+
const key = await deployKey(ctx.secrets ?? SYSTEM_STORES2, opts.root);
|
|
867
|
+
if (key === undefined) {
|
|
868
|
+
fail6("not_found", `no deploy key kept for ${opts.root}`);
|
|
869
|
+
}
|
|
870
|
+
ctx.log.info(key);
|
|
871
|
+
});
|
|
872
|
+
function box(ctx) {
|
|
873
|
+
return new CoordinatorBox2({ ps: ctx.ps, fs: ctx.fs });
|
|
874
|
+
}
|
|
875
|
+
function shell(ctx, standing) {
|
|
876
|
+
return new BoxShell({
|
|
877
|
+
ps: ctx.ps,
|
|
878
|
+
ipv4: standing.ipv4,
|
|
879
|
+
key: standing.key,
|
|
880
|
+
knownHosts: `${box(ctx).home}/coordinator/known_hosts`
|
|
881
|
+
});
|
|
882
|
+
}
|
|
468
883
|
|
|
469
884
|
// setup.ts
|
|
470
885
|
import { dirname } from "node:path";
|
|
471
|
-
import { SYSTEM_STORES as
|
|
886
|
+
import { SYSTEM_STORES as SYSTEM_STORES3 } from "@stringsync/splates-server/creds";
|
|
887
|
+
import { fail as fail7 } from "@stringsync/splates-server/exit";
|
|
472
888
|
import { splatesHome as splatesHome2 } from "@stringsync/splates-server/models";
|
|
473
889
|
import { Projects } from "@stringsync/splates-server/projects";
|
|
474
890
|
import {
|
|
@@ -483,8 +899,28 @@ import {
|
|
|
483
899
|
} from "@stringsync/splates-server/workers";
|
|
484
900
|
import { color as color2 } from "webappwiz/log";
|
|
485
901
|
async function setup(deps, opts) {
|
|
902
|
+
if (opts.step === "" && (opts.skip || opts.unskip || opts.undo)) {
|
|
903
|
+
fail7("usage", "--skip and --unskip name a step, --undo an area", {});
|
|
904
|
+
}
|
|
905
|
+
if (opts.undo && (opts.skip || opts.unskip)) {
|
|
906
|
+
fail7("usage", "--undo names an area, not a step to skip", {
|
|
907
|
+
area: opts.step
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
if (opts.skip && opts.unskip) {
|
|
911
|
+
fail7("usage", "--skip or --unskip, not both", { step: opts.step });
|
|
912
|
+
}
|
|
486
913
|
const machine = await setupOf(deps);
|
|
487
914
|
const { log } = deps;
|
|
915
|
+
if (opts.undo) {
|
|
916
|
+
const plan = await machine.undoPlan(opts.step);
|
|
917
|
+
if (opts.json) {
|
|
918
|
+
log.info(JSON.stringify(plan, null, 2));
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
printUndo(log, plan);
|
|
922
|
+
return;
|
|
923
|
+
}
|
|
488
924
|
if (opts.step !== "") {
|
|
489
925
|
machine.step(opts.step);
|
|
490
926
|
if (opts.skip) {
|
|
@@ -510,7 +946,7 @@ async function setup(deps, opts) {
|
|
|
510
946
|
printStep(log, step);
|
|
511
947
|
}
|
|
512
948
|
async function setupOf(deps) {
|
|
513
|
-
const { fs, ps, secrets =
|
|
949
|
+
const { fs, ps, secrets = SYSTEM_STORES3, fetch } = deps;
|
|
514
950
|
const root = deps.project === undefined ? await repoRoot(ps) : (await Projects.ofMachine(deps).named(deps.project)).root;
|
|
515
951
|
return new Setup({
|
|
516
952
|
fs,
|
|
@@ -581,13 +1017,37 @@ function printStep(log, step) {
|
|
|
581
1017
|
log.info(`${color2.red("problem:")} ${step.problem}`);
|
|
582
1018
|
}
|
|
583
1019
|
}
|
|
1020
|
+
function printUndo(log, plan) {
|
|
1021
|
+
log.info(`${color2.bold(`Undo ${plan.title}`)} ${color2.dim(plan.area)}`);
|
|
1022
|
+
if (plan.refused !== null) {
|
|
1023
|
+
log.info(`${color2.red("refused:")} ${plan.refused}`);
|
|
1024
|
+
return;
|
|
1025
|
+
}
|
|
1026
|
+
for (const step of plan.steps) {
|
|
1027
|
+
const started = step.done ? "" : ` ${color2.yellow("started")}`;
|
|
1028
|
+
log.info(` ${step.title} ${color2.dim(step.id)}${started}`);
|
|
1029
|
+
for (const line of step.removes) {
|
|
1030
|
+
log.info(` removes ${line}`);
|
|
1031
|
+
}
|
|
1032
|
+
for (const line of step.leaves) {
|
|
1033
|
+
log.info(` leaves ${line}`);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
for (const cred of plan.creds) {
|
|
1037
|
+
log.info(cred.keptFor === null ? ` forgets ${cred.name}` : ` keeps ${cred.name} ${color2.dim(`${cred.keptFor} still uses it`)}`);
|
|
1038
|
+
}
|
|
1039
|
+
if (plan.confirm !== null) {
|
|
1040
|
+
log.info(` the page asks for ${plan.confirm} to be typed`);
|
|
1041
|
+
}
|
|
1042
|
+
log.info(color2.dim("the Setup page's Undo does it, after the user confirms"));
|
|
1043
|
+
}
|
|
584
1044
|
|
|
585
1045
|
// slots.ts
|
|
586
1046
|
import { Slots } from "@stringsync/splates-server/ports";
|
|
587
|
-
import { cli as
|
|
588
|
-
import { z as
|
|
589
|
-
var splatesSlots =
|
|
590
|
-
splatesSlots.command("list").description("print each claimed word, the tree holding it, its server's pid while one runs, and whether it is orphaned: its tree gone, or a splates repository's main tree, which every agent shares").option("json",
|
|
1047
|
+
import { cli as cli10 } from "webappwiz/cmd";
|
|
1048
|
+
import { z as z11 } from "zod";
|
|
1049
|
+
var splatesSlots = cli10("slots").description("the words `splates server --slot` hands out on this machine, each held by the tree that claimed it: a task's worktree holds its word until the task merges or is removed, which stops its server and gives the word back");
|
|
1050
|
+
splatesSlots.command("list").description("print each claimed word, the tree holding it, its server's pid while one runs, and whether it is orphaned: its tree gone, or a splates repository's main tree, which every agent shares").option("json", z11.boolean(), { default: false, description: "emit JSON" }).action(async (opts, ctx) => {
|
|
591
1051
|
const held = await Slots.ofMachine(ctx).status();
|
|
592
1052
|
if (opts.json) {
|
|
593
1053
|
ctx.log.info(JSON.stringify(held.map(({ slot, tree, pid, orphaned }) => ({
|
|
@@ -619,178 +1079,210 @@ function heldLine({ slot, tree, pid, orphaned }) {
|
|
|
619
1079
|
return `${slot.word} ${slot.emoji} ${tree} ${server}${orphaned ? " orphaned: `splates slots prune` frees it" : ""}`;
|
|
620
1080
|
}
|
|
621
1081
|
|
|
622
|
-
//
|
|
1082
|
+
// task.ts
|
|
623
1083
|
import {
|
|
624
1084
|
addedFacts,
|
|
625
1085
|
recordUpdate,
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
todoTake,
|
|
633
|
-
todoUpdate
|
|
1086
|
+
taskAdd,
|
|
1087
|
+
taskList,
|
|
1088
|
+
taskRemove,
|
|
1089
|
+
taskShow,
|
|
1090
|
+
tasksNamed as tasksNamed2,
|
|
1091
|
+
taskUpdate
|
|
634
1092
|
} from "@stringsync/splates-server/board";
|
|
635
|
-
import { commaList as
|
|
636
|
-
import {
|
|
637
|
-
import {
|
|
1093
|
+
import { commaList as commaList5 } from "@stringsync/splates-server/comma-list";
|
|
1094
|
+
import { refuseGroomer as refuseGroomer3 } from "@stringsync/splates-server/conversations";
|
|
1095
|
+
import { fail as fail8 } from "@stringsync/splates-server/exit";
|
|
1096
|
+
import { repository as repository7 } from "@stringsync/splates-server/records";
|
|
638
1097
|
import {
|
|
639
1098
|
DEFAULT_TIMEOUT as DEFAULT_TIMEOUT2,
|
|
640
|
-
|
|
1099
|
+
taskWait,
|
|
641
1100
|
untilAfter as untilAfter2
|
|
642
1101
|
} from "@stringsync/splates-server/tasks";
|
|
643
|
-
import { cli as
|
|
1102
|
+
import { cli as cli11 } from "webappwiz/cmd";
|
|
644
1103
|
import { Duration as Duration2 } from "webappwiz/time";
|
|
645
|
-
import { z as
|
|
646
|
-
var
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
}).option("position", position, {
|
|
651
|
-
description: "where it goes in the list, 1 at the top, pushing those from there down (default: the bottom)"
|
|
652
|
-
}).option("file", z10.string(), {
|
|
653
|
-
default: "",
|
|
654
|
-
description: "files to attach, comma separated: copied under .git/splates/todos/<id>/"
|
|
655
|
-
}).option("blocked-by", z10.string(), {
|
|
656
|
-
default: "",
|
|
657
|
-
description: "ids of the todos blocking it, comma separated: each has to merge before this one starts"
|
|
658
|
-
}).option("lane", z10.string(), {
|
|
659
|
-
default: "",
|
|
660
|
-
description: "the lane it goes in, at the bottom: a lane's number, or `new` for one of its own (default: none, untriaged)"
|
|
661
|
-
}).option("agent", z10.string(), {
|
|
662
|
-
default: "",
|
|
663
|
-
description: "the agent on the roster (`splates agents`) that should work it, which Start on the `splates server` board offers first"
|
|
664
|
-
}).option("model", z10.string(), {
|
|
665
|
-
default: "",
|
|
666
|
-
description: "with --agent: the model, by its id or name on the roster"
|
|
667
|
-
}).option("effort", z10.string(), {
|
|
668
|
-
default: "",
|
|
669
|
-
description: "with --agent: the thinking level, one the agent offers (default: the agent's own)"
|
|
670
|
-
}).action(async (opts, ctx) => {
|
|
671
|
-
if (ctx.elsewhere !== null && opts.lane !== "") {
|
|
672
|
-
fail4("not_granted", "a todo from another project goes in its untriaged lane, for whoever orchestrates it there to place: leave --lane off", { subject: opts.subject });
|
|
1104
|
+
import { z as z12 } from "zod";
|
|
1105
|
+
var splatesTask = cli11("task").description("the numbered tasks: defer work for later instead of growing the task you are in, and `splates add <slug> --task <n>` starts one; `merge` recommends the next one when a task lands. The person puts tasks in `splates queue`, for workers to start");
|
|
1106
|
+
async function projectFrom(ctx) {
|
|
1107
|
+
if (ctx.elsewhere === null) {
|
|
1108
|
+
return;
|
|
673
1109
|
}
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
})
|
|
690
|
-
|
|
1110
|
+
return (await ctx.projects.list()).find((each) => each.root === ctx.git.root)?.slug;
|
|
1111
|
+
}
|
|
1112
|
+
function adding(name, description, ready) {
|
|
1113
|
+
splatesTask.command(name).use(repository7({ needs: "queue" })).description(description).arg("subject", z12.string(), {
|
|
1114
|
+
description: "what is left to do, in a line"
|
|
1115
|
+
}).arg("text", z12.string(), {
|
|
1116
|
+
default: "",
|
|
1117
|
+
description: "whatever more there is to say about it, in markdown"
|
|
1118
|
+
}).option("slug", z12.string(), {
|
|
1119
|
+
description: "a short name for the task that takes it (lowercase-with-dashes), naming its branch, worktree and conversation: a few words for what it changes, not the subject cut short"
|
|
1120
|
+
}).option("position", position, {
|
|
1121
|
+
description: "where it goes in the list, 1 at the top, pushing those from there down (default: the bottom)"
|
|
1122
|
+
}).option("file", z12.string(), {
|
|
1123
|
+
default: "",
|
|
1124
|
+
description: "files to attach, comma separated: copied under .git/splates/tasks/<n>/"
|
|
1125
|
+
}).option("blocked-by", z12.string(), {
|
|
1126
|
+
default: "",
|
|
1127
|
+
description: "numbers of the tasks blocking it, comma separated: each has to merge before this one starts"
|
|
1128
|
+
}).option("lane", z12.string(), {
|
|
1129
|
+
default: "",
|
|
1130
|
+
description: "the lane it goes in, at the bottom: a lane's number, `backlog` for the permanent catch-all, or `new` for one of its own (default: none, untriaged)"
|
|
1131
|
+
}).option("agent", z12.string(), {
|
|
1132
|
+
default: "",
|
|
1133
|
+
description: "the agent on the roster (`splates agents`) that should work it, which Start on the `splates server` board offers first"
|
|
1134
|
+
}).option("model", z12.string(), {
|
|
1135
|
+
default: "",
|
|
1136
|
+
description: "with --agent: the model, by its id or name on the roster"
|
|
1137
|
+
}).option("effort", z12.string(), {
|
|
1138
|
+
default: "",
|
|
1139
|
+
description: "with --agent: the thinking level, one the agent offers (default: the agent's own)"
|
|
1140
|
+
}).action(async (opts, ctx) => {
|
|
1141
|
+
if (ctx.elsewhere !== null && opts.lane !== "") {
|
|
1142
|
+
fail8("not_granted", "a task from another project goes in its untriaged lane, for whoever orchestrates it there to place: leave --lane off", { subject: opts.subject });
|
|
1143
|
+
}
|
|
1144
|
+
const from = await here(ctx);
|
|
1145
|
+
const assignee = await assigneeIn(ctx, opts.agent, opts.model, opts.effort);
|
|
1146
|
+
const origin = ctx.elsewhere === null ? undefined : {
|
|
1147
|
+
project: ctx.elsewhere,
|
|
1148
|
+
task: ctx.project === undefined ? null : ctx.service.taskFor(await ctx.git.currentBranch(ctx.ps.cwd()))
|
|
1149
|
+
};
|
|
1150
|
+
const project = await projectFrom(ctx);
|
|
1151
|
+
await ctx.journal.record("task add", from, () => taskAdd(ctx, opts.subject, from, {
|
|
1152
|
+
slug: opts.slug,
|
|
1153
|
+
text: opts.text,
|
|
1154
|
+
position: opts.position,
|
|
1155
|
+
files: commaList5(opts.file),
|
|
1156
|
+
blockedBy: taskIds(opts["blocked-by"]),
|
|
1157
|
+
lane: laneIn(opts.lane) ?? null,
|
|
1158
|
+
assignee,
|
|
1159
|
+
origin,
|
|
1160
|
+
ready,
|
|
1161
|
+
project
|
|
1162
|
+
}), addedFacts);
|
|
1163
|
+
});
|
|
1164
|
+
}
|
|
1165
|
+
adding("add", "queue a task to do later and move on, groomed, so it goes in ready: you checked no task already asks it, and linked what blocks it; run from a worktree, it records the task it came up in", true);
|
|
1166
|
+
adding("defer", "queue a task as it is, rough, in the backlog for whoever grooms it: to check for one that already asks it, link what blocks it, and mark it ready; run from a worktree, it records the task it came up in", false);
|
|
1167
|
+
splatesTask.command("list").use(repository7({ needs: "read" })).description("every queued task, top of the list first, with the task it came from and the started one that took it up").option("json", z12.boolean(), { default: false, description: "emit JSON" }).option("open", z12.boolean(), {
|
|
691
1168
|
default: false,
|
|
692
|
-
description: "only
|
|
693
|
-
}).option("ready",
|
|
1169
|
+
description: "only tasks no started one has taken up: the ones free to pick up"
|
|
1170
|
+
}).option("ready", z12.boolean(), {
|
|
694
1171
|
default: false,
|
|
695
|
-
description: "only
|
|
696
|
-
}).action((opts, ctx) =>
|
|
1172
|
+
description: "only tasks free to start now: none has taken them, and nothing blocking them is still open"
|
|
1173
|
+
}).action(async (opts, ctx) => taskList(ctx, {
|
|
697
1174
|
json: opts.json,
|
|
698
1175
|
open: opts.open,
|
|
699
|
-
ready: opts.ready
|
|
1176
|
+
ready: opts.ready,
|
|
1177
|
+
project: await projectFrom(ctx)
|
|
700
1178
|
}));
|
|
701
|
-
|
|
702
|
-
|
|
1179
|
+
splatesTask.command("show").use(repository7({ needs: "read" })).description("one task in full: where it stands, its files, and its detail").arg("id", z12.coerce.number().int().positive(), { description: "task number" }).option("json", z12.boolean(), { default: false, description: "emit JSON" }).action(async (opts, ctx) => taskShow(ctx, opts.id, {
|
|
1180
|
+
json: opts.json,
|
|
1181
|
+
project: await projectFrom(ctx),
|
|
1182
|
+
others: (await ctx.projects.list()).filter((project) => project.root !== ctx.git.root).map((project) => project.slug)
|
|
1183
|
+
}));
|
|
1184
|
+
splatesTask.command("update").use(repository7({ needs: "tasks" })).description("say what a queued task is in other words, move it up or down the list, or attach and drop files; it keeps its number").arg("id", z12.coerce.number().int().positive(), { description: "task number" }).arg("text", z12.string(), {
|
|
703
1185
|
default: "",
|
|
704
1186
|
description: "whatever more there is to say about it, in markdown; leave out to keep the detail"
|
|
705
|
-
}).option("subject",
|
|
1187
|
+
}).option("subject", z12.string(), {
|
|
706
1188
|
default: "",
|
|
707
1189
|
description: "what is left to do, in a line; leave out to keep it"
|
|
1190
|
+
}).option("slug", z12.string(), {
|
|
1191
|
+
default: "",
|
|
1192
|
+
description: "a new name for the task that takes it (lowercase-with-dashes); leave out to keep it"
|
|
708
1193
|
}).option("position", position, {
|
|
709
1194
|
description: "where to move it in the list, 1 at the top; the others close up around it"
|
|
710
|
-
}).option("file",
|
|
1195
|
+
}).option("file", z12.string(), {
|
|
711
1196
|
default: "",
|
|
712
1197
|
description: "files to attach, comma separated"
|
|
713
|
-
}).option("remove-file",
|
|
1198
|
+
}).option("remove-file", z12.string(), {
|
|
714
1199
|
default: "",
|
|
715
1200
|
description: "attached files to drop, comma separated, by path or stored name"
|
|
716
|
-
}).option("blocked-by",
|
|
1201
|
+
}).option("blocked-by", z12.string(), {
|
|
717
1202
|
default: "",
|
|
718
|
-
description: "
|
|
719
|
-
}).option("remove-blocked-by",
|
|
1203
|
+
description: "numbers of more tasks blocking it, comma separated: each has to merge before this one starts; refused when that makes a loop"
|
|
1204
|
+
}).option("remove-blocked-by", z12.string(), {
|
|
720
1205
|
default: "",
|
|
721
|
-
description: "
|
|
722
|
-
}).option("lane",
|
|
1206
|
+
description: "numbers of tasks no longer blocking it, comma separated"
|
|
1207
|
+
}).option("lane", z12.string(), {
|
|
723
1208
|
default: "",
|
|
724
|
-
description: "move it to a lane, at the bottom: a lane's number, `new` for one of its own, or `none`
|
|
725
|
-
}).option("agent",
|
|
1209
|
+
description: "move it to a lane, at the bottom: a lane's number, `backlog` for the permanent catch-all, `new` for one of its own, or `none` for untriaged"
|
|
1210
|
+
}).option("agent", z12.string(), {
|
|
726
1211
|
default: "",
|
|
727
1212
|
description: "the agent on the roster (`splates agents`) that should work it, which Start on the `splates server` board offers first, or `none`"
|
|
728
|
-
}).option("model",
|
|
1213
|
+
}).option("model", z12.string(), {
|
|
729
1214
|
default: "",
|
|
730
1215
|
description: "with --agent: the model, by its id or name on the roster"
|
|
731
|
-
}).option("effort",
|
|
1216
|
+
}).option("effort", z12.string(), {
|
|
732
1217
|
default: "",
|
|
733
1218
|
description: "with --agent: the thinking level, one the agent offers (default: the agent's own)"
|
|
1219
|
+
}).option("ready", z12.boolean(), {
|
|
1220
|
+
default: false,
|
|
1221
|
+
description: "mark it groomed, moving it from the backlog to ready: no task already asks it, and what blocks it is linked"
|
|
1222
|
+
}).option("manual", z12.boolean(), {
|
|
1223
|
+
default: false,
|
|
1224
|
+
description: "queue it by hand only: a queued lane passes over it, and it starts once you `splates queue add` it"
|
|
1225
|
+
}).option("auto", z12.boolean(), {
|
|
1226
|
+
default: false,
|
|
1227
|
+
description: "let a queued lane queue it again, undoing --manual"
|
|
734
1228
|
}).action(async (opts, ctx) => {
|
|
1229
|
+
if (opts.manual && opts.auto) {
|
|
1230
|
+
fail8("usage", "pass --manual or --auto, not both", { number: opts.id });
|
|
1231
|
+
}
|
|
1232
|
+
await refuseGroomer3(ctx.service, "task update", await ctx.tasks.find(opts.id));
|
|
735
1233
|
const assignee = await assigneeIn(ctx, opts.agent, opts.model, opts.effort);
|
|
736
|
-
await recordUpdate(ctx.journal, ctx.
|
|
1234
|
+
await recordUpdate(ctx.journal, ctx.tasks, opts.id, () => taskUpdate(ctx, opts.id, {
|
|
737
1235
|
subject: opts.subject,
|
|
1236
|
+
slug: opts.slug,
|
|
738
1237
|
text: opts.text,
|
|
739
1238
|
position: opts.position,
|
|
740
|
-
files:
|
|
741
|
-
removeFiles:
|
|
742
|
-
blockedBy:
|
|
743
|
-
removeBlockedBy:
|
|
1239
|
+
files: commaList5(opts.file),
|
|
1240
|
+
removeFiles: commaList5(opts["remove-file"]),
|
|
1241
|
+
blockedBy: taskIds(opts["blocked-by"]),
|
|
1242
|
+
removeBlockedBy: taskIds(opts["remove-blocked-by"]),
|
|
744
1243
|
lane: laneIn(opts.lane),
|
|
745
|
-
assignee
|
|
1244
|
+
assignee,
|
|
1245
|
+
ready: opts.ready,
|
|
1246
|
+
manual: opts.manual ? true : opts.auto ? false : undefined
|
|
746
1247
|
}));
|
|
747
1248
|
});
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
const task = await here(ctx);
|
|
752
|
-
await ctx.journal.record("todo take", task, () => todoTake(ctx, opts.ids, task), (taken) => ({ todos: todosNamed(taken) }));
|
|
753
|
-
});
|
|
754
|
-
splatesTodo.command("release").use(repository5({ needs: "own" })).description("put taken todos back on the list, as when a task lands without finishing them: `splates todo update` the leftover first; from a worktree, only its own task's").rest("ids", z10.coerce.number().int().positive(), {
|
|
755
|
-
description: "todo ids"
|
|
756
|
-
}).action(async (opts, ctx) => {
|
|
757
|
-
const task = await here(ctx);
|
|
758
|
-
await ctx.journal.record("todo release", task, () => todoRelease(ctx, opts.ids, task), (released) => ({ todos: todosNamed(released) }));
|
|
1249
|
+
splatesTask.command("remove").use(repository7({ needs: "tasks" })).description("drop a queued task that was done some other way or no longer applies").arg("id", z12.coerce.number().int().positive(), { description: "task number" }).action(async (opts, ctx) => {
|
|
1250
|
+
await refuseGroomer3(ctx.service, "task remove", await ctx.tasks.find(opts.id));
|
|
1251
|
+
await ctx.journal.record("task remove", null, () => taskRemove(ctx, opts.id), (removed) => ({ tasks: tasksNamed2([removed]) }));
|
|
759
1252
|
});
|
|
760
|
-
|
|
761
|
-
splatesTodo.command("wait").use(repository5({ needs: "read" })).description("block until a todo leaves the list, which it does when the task that took it merges: for a todo blocked by one another lane is on; ends early when that task is escalated, and gives up with `timeout`").arg("id", z10.coerce.number().int().positive(), { description: "todo id" }).option("timeout-secs", z10.coerce.number(), {
|
|
1253
|
+
splatesTask.command("wait").use(repository7({ needs: "read" })).description("block until a task leaves the queue, which it does when the task that took it merges: for a task blocked by one another lane is on; ends early when that task waits on a person to answer its questions, and gives up with `timeout`").arg("id", z12.coerce.number().int().positive(), { description: "task number" }).option("timeout-secs", z12.coerce.number(), {
|
|
762
1254
|
default: DEFAULT_TIMEOUT2.secs,
|
|
763
1255
|
description: "how long to wait before giving up"
|
|
764
1256
|
}).action(async (opts, ctx) => {
|
|
765
1257
|
const timeout = Duration2.secs(opts["timeout-secs"]);
|
|
766
|
-
const
|
|
767
|
-
await ctx.journal.waiting("
|
|
768
|
-
|
|
769
|
-
subject:
|
|
1258
|
+
const task = (await ctx.tasks.all()).find((each) => each.id === opts.id);
|
|
1259
|
+
await ctx.journal.waiting("task wait", null, {
|
|
1260
|
+
number: opts.id,
|
|
1261
|
+
subject: task?.subject ?? null,
|
|
770
1262
|
until: untilAfter2(timeout)
|
|
771
|
-
}, () =>
|
|
1263
|
+
}, () => taskWait(ctx, opts.id, { timeout }));
|
|
772
1264
|
});
|
|
773
1265
|
|
|
774
1266
|
// tunnel.ts
|
|
775
|
-
import { repository as
|
|
1267
|
+
import { repository as repository8 } from "@stringsync/splates-server/records";
|
|
776
1268
|
import { savedTunnelOf } from "@stringsync/splates-server/server";
|
|
777
1269
|
import {
|
|
778
1270
|
API_TOKEN,
|
|
779
1271
|
tunnelRemove,
|
|
780
1272
|
tunnelSetup
|
|
781
1273
|
} from "@stringsync/splates-server/tunnel";
|
|
782
|
-
import { cli as
|
|
783
|
-
import { z as
|
|
784
|
-
var splatesTunnel =
|
|
785
|
-
splatesTunnel.command("setup").use(
|
|
1274
|
+
import { cli as cli12 } from "webappwiz/cmd";
|
|
1275
|
+
import { z as z13 } from "zod";
|
|
1276
|
+
var splatesTunnel = cli12("tunnel").description("reach `splates server` from elsewhere: a Cloudflare tunnel with Cloudflare Access in front, set up once per machine");
|
|
1277
|
+
splatesTunnel.command("setup").use(repository8({ needs: "own" })).description(`make a Cloudflare tunnel to \`splates server\`, the DNS record routing <host> to it, and an Access application letting in only --email, through the API with the token kept as the cred ${API_TOKEN}, then save them for this machine, so a bare \`splates server\` comes up tunneled; run again, it changes only what is not so already. Without that token it requests it on the Creds page of \`splates server\`, with how to make it, and exits \`requested\`: \`splates creds wait ${API_TOKEN}\`, then run it again`).arg("host", z13.string(), {
|
|
786
1278
|
description: "the public host name, in a zone of the account, as in splates.example.com"
|
|
787
|
-
}).option("email",
|
|
1279
|
+
}).option("email", z13.string(), {
|
|
788
1280
|
default: "",
|
|
789
1281
|
description: "comma-separated email addresses Access lets in"
|
|
790
|
-
}).option("name",
|
|
1282
|
+
}).option("name", z13.string(), {
|
|
791
1283
|
default: "splates",
|
|
792
1284
|
description: "what the tunnel, the Access application and its policy are called"
|
|
793
|
-
}).option("team",
|
|
1285
|
+
}).option("team", z13.string(), {
|
|
794
1286
|
default: "",
|
|
795
1287
|
description: "the Zero Trust team to make, as in <team>.cloudflareaccess.com, when the account has none yet"
|
|
796
1288
|
}).action(async (opts, ctx) => ctx.journal.record("tunnel setup", null, async () => tunnelSetup({
|
|
@@ -801,7 +1293,7 @@ splatesTunnel.command("setup").use(repository6({ needs: "own" })).description(`m
|
|
|
801
1293
|
log: ctx.log,
|
|
802
1294
|
fetch: ctx.fetch
|
|
803
1295
|
})));
|
|
804
|
-
splatesTunnel.command("status").description("print the tunnel `splates tunnel setup` saved for this machine, which a bare `splates server` runs, and whether its token is in the system's secret store").option("json",
|
|
1296
|
+
splatesTunnel.command("status").description("print the tunnel `splates tunnel setup` saved for this machine, which a bare `splates server` runs, and whether its token is in the system's secret store").option("json", z13.boolean(), { default: false, description: "emit JSON" }).action(async (opts, ctx) => {
|
|
805
1297
|
const saved = savedTunnelOf(ctx);
|
|
806
1298
|
const record = await saved.read();
|
|
807
1299
|
const token = record === null ? false : await saved.token() !== undefined;
|
|
@@ -822,7 +1314,7 @@ splatesTunnel.command("status").description("print the tunnel `splates tunnel se
|
|
|
822
1314
|
].join(`
|
|
823
1315
|
`));
|
|
824
1316
|
});
|
|
825
|
-
splatesTunnel.command("remove").use(
|
|
1317
|
+
splatesTunnel.command("remove").use(repository8({ needs: "own" })).description(`delete what \`splates tunnel setup\` and \`splates server --slot\` made in Cloudflare by what they saved: each tunnel, the DNS record routing to it, the Access applications and their policy, then forget the saved files and the tunnels' tokens; the API token kept as ${API_TOKEN} stays. Run again after a failure, it finishes what is left`).action(async (_opts, ctx) => ctx.journal.record("tunnel remove", null, async () => tunnelRemove({
|
|
826
1318
|
saved: savedTunnelOf(ctx),
|
|
827
1319
|
slots: slotTunnelsOf(ctx),
|
|
828
1320
|
creds: ctx.creds,
|
|
@@ -833,65 +1325,111 @@ splatesTunnel.command("remove").use(repository6({ needs: "own" })).description(`
|
|
|
833
1325
|
})));
|
|
834
1326
|
|
|
835
1327
|
// worker.ts
|
|
1328
|
+
import { splatesHome as splatesHome3 } from "@stringsync/splates-server/models";
|
|
836
1329
|
import {
|
|
837
1330
|
addWorker,
|
|
838
1331
|
drainWorker,
|
|
1332
|
+
FileLogger,
|
|
839
1333
|
listWorkers,
|
|
840
1334
|
removeWorker,
|
|
841
1335
|
setWorkerSlots,
|
|
1336
|
+
WORKER_JOIN,
|
|
842
1337
|
wakeWorker,
|
|
843
1338
|
workerJoin,
|
|
844
1339
|
workerRecipe,
|
|
845
1340
|
workerRun
|
|
846
1341
|
} from "@stringsync/splates-server/workers";
|
|
847
|
-
import { cli as
|
|
848
|
-
import {
|
|
849
|
-
|
|
850
|
-
|
|
1342
|
+
import { cli as cli14 } from "webappwiz/cmd";
|
|
1343
|
+
import { CompositeLogger } from "webappwiz/log";
|
|
1344
|
+
import { z as z15 } from "zod";
|
|
1345
|
+
|
|
1346
|
+
// waiting.ts
|
|
1347
|
+
import { listQueue, moveQueued } from "@stringsync/splates-server/workers";
|
|
1348
|
+
import { cli as cli13 } from "webappwiz/cmd";
|
|
1349
|
+
import { z as z14 } from "zod";
|
|
1350
|
+
var DEV2 = {
|
|
851
1351
|
default: "",
|
|
852
|
-
description: "the
|
|
853
|
-
}
|
|
1352
|
+
description: "the `splates server` to ask, a URL such as http://localhost:4310; by default the one an agent runs under, from SPLATES_DEV"
|
|
1353
|
+
};
|
|
1354
|
+
var splatesWaiting = cli13("queue").description("the agents waiting for a slot on a worker of the running `splates server`: each one another agent started (with `splates add --agent`, or a lane's orchestrator handing out tasks), started or resumed while every worker it can run on is full, waits here, first come, first served, and starts once a slot frees, as when an agent left idle 30 minutes stops; none is ever failed for waiting. An agent you start waits only while no worker it can run on is up, as with this machine's own removed or none on the platform its project requires");
|
|
1355
|
+
splatesWaiting.command("list").description("list the agents waiting for a slot, first in line first: position, project, task, conversation, how long each has waited and why (no free slot, no worker up, or a platform no worker runs, as `needs macOS`)").option("dev", z14.string(), DEV2).option("json", z14.boolean(), { default: false, description: "emit JSON" }).action((opts, ctx) => listQueue({
|
|
1356
|
+
dev: opts.dev,
|
|
1357
|
+
json: opts.json,
|
|
1358
|
+
log: ctx.log,
|
|
1359
|
+
fs: ctx.fs,
|
|
1360
|
+
ps: ctx.ps,
|
|
1361
|
+
send: ctx.fetch
|
|
1362
|
+
}));
|
|
1363
|
+
splatesWaiting.command("move").description("move an agent waiting for a slot to another place in line, from 1 for the next to start, then list the queue").arg("which", z14.string(), {
|
|
1364
|
+
description: "the task it works, or its conversation's id"
|
|
1365
|
+
}).arg("position", z14.coerce.number().int(), {
|
|
1366
|
+
description: "where in line to put it, from 1"
|
|
1367
|
+
}).option("dev", z14.string(), DEV2).option("json", z14.boolean(), { default: false, description: "emit JSON" }).action((opts, ctx) => moveQueued({
|
|
1368
|
+
which: opts.which,
|
|
1369
|
+
position: opts.position,
|
|
1370
|
+
dev: opts.dev,
|
|
1371
|
+
json: opts.json,
|
|
1372
|
+
log: ctx.log,
|
|
1373
|
+
fs: ctx.fs,
|
|
1374
|
+
ps: ctx.ps,
|
|
1375
|
+
send: ctx.fetch
|
|
1376
|
+
}));
|
|
1377
|
+
|
|
1378
|
+
// worker.ts
|
|
1379
|
+
var splatesWorker = cli14("worker").description("the machines that run tasks for `splates server`: each dials out to it and runs what it is given, agents, terminals and the git and process reads around them, on its own machine");
|
|
1380
|
+
splatesWorker.command("run").description("run a worker on this machine until stopped: it dials `splates server`, by default the one on this machine through a socket in ~/.splates only you may open, and dials again whenever the link drops, while what it runs carries on; it stops reading a process's output while the server is away too long, so nothing is lost. Once its agents have moved off it, a server on another build has it restart on that build, through `bunx @stringsync/splates@<build>`, as it does when it refuses this worker for another protocol; one that says no build has it exit `outdated`").option("server", z15.string(), {
|
|
1381
|
+
default: "",
|
|
1382
|
+
description: "the `splates server` to dial: its URL, whose /api/workers it opens, or unix:<path>; by default this machine's"
|
|
1383
|
+
}).option("coordinator", z15.string(), {
|
|
1384
|
+
default: "",
|
|
1385
|
+
description: "the old name for --server, still read for workers installed before it, and passed to a build older than it"
|
|
1386
|
+
}).option("slots", z15.coerce.number().int().min(0), {
|
|
854
1387
|
default: 0,
|
|
855
1388
|
description: "how many tasks this worker takes at once; by default one for each core and 4 GB of memory it has, whichever is fewer, as a VM such as WSL2 sees them"
|
|
856
|
-
}).option("id",
|
|
1389
|
+
}).option("id", z15.string(), {
|
|
857
1390
|
default: "",
|
|
858
|
-
description: "what the
|
|
859
|
-
}).option("join",
|
|
1391
|
+
description: "what the server knows this worker by, kept across restarts so it picks up where it was; by default the id it joined as, kept beside its key, else the machine's host name"
|
|
1392
|
+
}).option("join", z15.string(), {
|
|
860
1393
|
default: "",
|
|
861
|
-
description: "a join token from `splates worker add` on the
|
|
862
|
-
}).option("ephemeral",
|
|
1394
|
+
description: "a join token from `splates worker add` on the server, spent to join it before dialing; the key it answers is kept in this machine's system store, or read from SPLATES_WORKER_KEY on one without"
|
|
1395
|
+
}).option("ephemeral", z15.boolean(), {
|
|
863
1396
|
default: false,
|
|
864
1397
|
description: "keep the key --join answers in memory alone, for a machine destroyed rather than restarted, as one a worker provider makes"
|
|
865
|
-
}).option("key-file",
|
|
1398
|
+
}).option("key-file", z15.boolean(), {
|
|
866
1399
|
default: false,
|
|
867
1400
|
description: "keep the key --join answers in ~/.splates/worker.env, which only this user may read, rather than the system store, for a machine whose store is locked or missing at boot, as WSL's is with no one signed in; read it from there on each run after"
|
|
868
|
-
}).option("quiet",
|
|
1401
|
+
}).option("quiet", z15.boolean(), {
|
|
869
1402
|
default: false,
|
|
870
|
-
description: "say only what went wrong, not each time it joins or loses its
|
|
1403
|
+
description: "say only what went wrong, not each time it joins or loses its server, as the worker `splates server` starts beside itself does; all of it still goes to worker.log in ~/.splates, the one before it kept as worker.log.1"
|
|
871
1404
|
}).action((opts, ctx) => workerRun({
|
|
872
|
-
coordinator: opts.coordinator,
|
|
1405
|
+
coordinator: opts.server || opts.coordinator,
|
|
873
1406
|
slots: opts.slots,
|
|
874
1407
|
id: opts.id,
|
|
875
|
-
join: opts.join,
|
|
1408
|
+
join: opts.join || ctx.ps.env(WORKER_JOIN) || "",
|
|
876
1409
|
ephemeral: opts.ephemeral,
|
|
877
1410
|
keyFile: opts["key-file"],
|
|
878
|
-
log: opts.quiet ?
|
|
1411
|
+
log: opts.quiet ? quietLog(ctx) : ctx.log,
|
|
879
1412
|
ps: ctx.ps,
|
|
880
1413
|
fs: ctx.fs
|
|
881
1414
|
}));
|
|
882
|
-
splatesWorker.command("join").description("spend a join token from `splates worker add` and keep the key it answers, as `splates worker run --join` does, then exit, for an installer that leaves running the worker to a service").option("
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
1415
|
+
splatesWorker.command("join").description("spend a join token from `splates worker add` and keep the key it answers, as `splates worker run --join` does, then exit, for an installer that leaves running the worker to a service").option("server", z15.string(), {
|
|
1416
|
+
default: "",
|
|
1417
|
+
description: "the `splates server` to join: its URL"
|
|
1418
|
+
}).option("coordinator", z15.string(), {
|
|
1419
|
+
default: "",
|
|
1420
|
+
description: "the old name for --server"
|
|
1421
|
+
}).option("join", z15.string(), {
|
|
1422
|
+
default: "",
|
|
1423
|
+
description: "the join token `splates worker add` printed there; by default read from SPLATES_WORKER_JOIN, which keeps it out of the process list other users of the machine can read"
|
|
1424
|
+
}).option("id", z15.string(), {
|
|
1425
|
+
default: "",
|
|
1426
|
+
description: "what the server knows this worker by, kept beside its key so a change of host name leaves it the same; by default the machine's host name"
|
|
1427
|
+
}).option("key-file", z15.boolean(), {
|
|
890
1428
|
default: false,
|
|
891
1429
|
description: "keep the key in ~/.splates/worker.env, which only this user may read, rather than the system store, for `splates worker run --key-file` to read"
|
|
892
1430
|
}).action((opts, ctx) => workerJoin({
|
|
893
|
-
coordinator: opts.coordinator,
|
|
894
|
-
join: opts.join,
|
|
1431
|
+
coordinator: opts.server || opts.coordinator,
|
|
1432
|
+
join: opts.join || ctx.ps.env(WORKER_JOIN) || "",
|
|
895
1433
|
id: opts.id,
|
|
896
1434
|
keyFile: opts["key-file"],
|
|
897
1435
|
log: ctx.log,
|
|
@@ -899,13 +1437,14 @@ splatesWorker.command("join").description("spend a join token from `splates work
|
|
|
899
1437
|
fs: ctx.fs
|
|
900
1438
|
}));
|
|
901
1439
|
splatesWorker.command("recipe").description("print the shell script, run as root on a fresh Debian or Ubuntu machine, that installs what a Linux worker needs: bun, git, the shared browser and this build of splates, for the user `splates`. It is what a provider's snapshot is built from, and what the Windows installer runs in WSL").action((_opts, ctx) => workerRecipe({ log: ctx.log }));
|
|
902
|
-
splatesWorker.command("list").description("list the workers the running `splates server` has: kind (local over its socket, registered otherwise), platform, build, protocol, slots used and total, health with when it was last heard, tasks and $/hour, then any it refused for speaking another protocol").option("dev",
|
|
1440
|
+
splatesWorker.command("list").description("list the workers the running `splates server` has: kind (local over its socket, registered otherwise), platform, build, protocol, slots used and total, health with when it was last heard, tasks and $/hour, then any it refused for speaking another protocol").option("dev", z15.string(), {
|
|
903
1441
|
default: "",
|
|
904
1442
|
description: "the `splates server` to ask, a URL such as http://localhost:4310; by default the one an agent runs under, from SPLATES_DEV"
|
|
905
|
-
}).option("json",
|
|
1443
|
+
}).option("json", z15.boolean(), { default: false, description: "emit JSON" }).action((opts, ctx) => listWorkers({
|
|
906
1444
|
dev: opts.dev,
|
|
907
1445
|
json: opts.json,
|
|
908
1446
|
log: ctx.log,
|
|
1447
|
+
fs: ctx.fs,
|
|
909
1448
|
ps: ctx.ps,
|
|
910
1449
|
send: ctx.fetch
|
|
911
1450
|
}));
|
|
@@ -913,71 +1452,84 @@ var dev = {
|
|
|
913
1452
|
default: "",
|
|
914
1453
|
description: "the `splates server` to ask, a URL such as http://localhost:4310; by default the one an agent runs under, from SPLATES_DEV"
|
|
915
1454
|
};
|
|
916
|
-
splatesWorker.command("add").description("add a worker to the running `splates server`: prints a join token, single use and good for 15 minutes, for `splates worker run --join <token>` on the machine to join, which gets a key of its own that `splates worker remove` revokes; with --local N, makes this machine's own worker run N agents at once and take new ones again, adding it back if it was removed; with --provider, has the `workerProvider` in splates.config.ts make one, booted from the snapshot splates builds for it, which joins on its own and whose machine `splates worker remove` destroys").option("local",
|
|
1455
|
+
splatesWorker.command("add").description("add a worker to the running `splates server`: prints a join token, single use and good for 15 minutes, for `splates worker run --join <token>` on the machine to join, which gets a key of its own that `splates worker remove` revokes; with --local N, makes this machine's own worker run N agents at once and take new ones again, adding it back if it was removed; with --provider, has the `workerProvider` in splates.config.ts make one, booted from the snapshot splates builds for it, which joins on its own and whose machine `splates worker remove` destroys").option("local", z15.coerce.number().int().min(0), {
|
|
917
1456
|
default: 0,
|
|
918
1457
|
description: "this machine's own worker, with this many slots"
|
|
919
|
-
}).option("provider",
|
|
1458
|
+
}).option("provider", z15.boolean(), {
|
|
920
1459
|
default: false,
|
|
921
1460
|
description: "have the server's worker provider make the worker, of its cheapest type unless --type says"
|
|
922
|
-
}).option("type",
|
|
1461
|
+
}).option("type", z15.string(), {
|
|
923
1462
|
default: "",
|
|
924
1463
|
description: "the worker provider's type to make, as it names it; implies --provider"
|
|
925
|
-
}).option("dev",
|
|
1464
|
+
}).option("dev", z15.string(), dev).action((opts, ctx) => addWorker({
|
|
926
1465
|
local: opts.local,
|
|
927
1466
|
provider: opts.provider,
|
|
928
1467
|
type: opts.type,
|
|
929
1468
|
dev: opts.dev,
|
|
930
1469
|
log: ctx.log,
|
|
1470
|
+
fs: ctx.fs,
|
|
931
1471
|
ps: ctx.ps,
|
|
932
1472
|
send: ctx.fetch
|
|
933
1473
|
}));
|
|
934
|
-
splatesWorker.command("drain").description("take no new agents on a worker, letting those on it run to their end, but for one asking you something in a task, which saves its task and lets its slot go, its question kept for you to answer and carry it on elsewhere; --undo takes new ones again").arg("id",
|
|
1474
|
+
splatesWorker.command("drain").description("take no new agents on a worker, letting those on it run to their end, but for one asking you something in a task, which saves its task and lets its slot go, its question kept for you to answer and carry it on elsewhere; --undo takes new ones again").arg("id", z15.string(), {
|
|
935
1475
|
description: "the worker, as `splates worker list` names it"
|
|
936
|
-
}).option("undo",
|
|
1476
|
+
}).option("undo", z15.boolean(), {
|
|
937
1477
|
default: false,
|
|
938
1478
|
description: "take new agents again"
|
|
939
|
-
}).option("dev",
|
|
1479
|
+
}).option("dev", z15.string(), dev).action((opts, ctx) => drainWorker({
|
|
940
1480
|
id: opts.id,
|
|
941
1481
|
undo: opts.undo,
|
|
942
1482
|
dev: opts.dev,
|
|
943
1483
|
log: ctx.log,
|
|
1484
|
+
fs: ctx.fs,
|
|
944
1485
|
ps: ctx.ps,
|
|
945
1486
|
send: ctx.fetch
|
|
946
1487
|
}));
|
|
947
|
-
splatesWorker.command("wake").description("wake a worker asleep at home, a Windows PC that joined in WSL2: a worker awake on its network sends the Wake-on-LAN packet. Placement wakes one by itself when agents queue, before making a worker").arg("id",
|
|
1488
|
+
splatesWorker.command("wake").description("wake a worker asleep at home, a Windows PC that joined in WSL2: a worker awake on its network sends the Wake-on-LAN packet. Placement wakes one by itself when agents queue, before making a worker").arg("id", z15.string(), {
|
|
948
1489
|
description: "the worker, as `splates worker list` names it"
|
|
949
|
-
}).option("dev",
|
|
1490
|
+
}).option("dev", z15.string(), dev).action((opts, ctx) => wakeWorker({
|
|
950
1491
|
id: opts.id,
|
|
951
1492
|
dev: opts.dev,
|
|
952
1493
|
log: ctx.log,
|
|
1494
|
+
fs: ctx.fs,
|
|
953
1495
|
ps: ctx.ps,
|
|
954
1496
|
send: ctx.fetch
|
|
955
1497
|
}));
|
|
956
|
-
splatesWorker.command("slots").description("set how many agents a worker runs at once, from now on, over what it started with").arg("id",
|
|
1498
|
+
splatesWorker.command("slots").description("set how many agents a worker runs at once, from now on, over what it started with").arg("id", z15.string(), {
|
|
957
1499
|
description: "the worker, as `splates worker list` names it"
|
|
958
|
-
}).arg("slots",
|
|
1500
|
+
}).arg("slots", z15.coerce.number().int().min(1), {
|
|
959
1501
|
description: "how many at once"
|
|
960
|
-
}).option("dev",
|
|
1502
|
+
}).option("dev", z15.string(), dev).action((opts, ctx) => setWorkerSlots({
|
|
961
1503
|
id: opts.id,
|
|
962
1504
|
slots: opts.slots,
|
|
963
1505
|
dev: opts.dev,
|
|
964
1506
|
log: ctx.log,
|
|
1507
|
+
fs: ctx.fs,
|
|
965
1508
|
ps: ctx.ps,
|
|
966
1509
|
send: ctx.fetch
|
|
967
1510
|
}));
|
|
968
|
-
splatesWorker.command("remove").description("remove a worker, revoking its key: one with agents on it drains and is removed once they end; --force ends them now, frees their slots, and places each again on another worker, to carry on its task from the checkpoint it last pushed. This machine's own worker, `local`, stops taking agents, its agents running to their end, and leaves this machine only coordinating until `splates worker add --local <slots>`; it takes no --force").arg("id",
|
|
1511
|
+
splatesWorker.command("remove").description("remove a worker, revoking its key: one with agents on it drains and is removed once they end; --force ends them now, frees their slots, and places each again on another worker, to carry on its task from the checkpoint it last pushed. This machine's own worker, `local`, stops taking agents, its agents running to their end, and leaves this machine only coordinating until `splates worker add --local <slots>`; it takes no --force").arg("id", z15.string(), {
|
|
969
1512
|
description: "the worker, as `splates worker list` names it"
|
|
970
|
-
}).option("force",
|
|
1513
|
+
}).option("force", z15.boolean(), {
|
|
971
1514
|
default: false,
|
|
972
1515
|
description: "end the agents on it now rather than wait for them"
|
|
973
|
-
}).option("dev",
|
|
1516
|
+
}).option("dev", z15.string(), dev).action((opts, ctx) => removeWorker({
|
|
974
1517
|
id: opts.id,
|
|
975
1518
|
force: opts.force,
|
|
976
1519
|
dev: opts.dev,
|
|
977
1520
|
log: ctx.log,
|
|
1521
|
+
fs: ctx.fs,
|
|
978
1522
|
ps: ctx.ps,
|
|
979
1523
|
send: ctx.fetch
|
|
980
1524
|
}));
|
|
1525
|
+
splatesWorker.mount("queue", splatesWaiting);
|
|
1526
|
+
function quietLog(ctx) {
|
|
1527
|
+
const file = new FileLogger(ctx.fs, `${splatesHome3(ctx.ps)}/worker.log`);
|
|
1528
|
+
return new CompositeLogger([
|
|
1529
|
+
{ info: () => {}, error: (...said) => ctx.log.error(...said) },
|
|
1530
|
+
file
|
|
1531
|
+
]);
|
|
1532
|
+
}
|
|
981
1533
|
|
|
982
1534
|
// splates.ts
|
|
983
1535
|
function projectArgs(argv) {
|
|
@@ -993,9 +1545,16 @@ function projectArgs(argv) {
|
|
|
993
1545
|
}
|
|
994
1546
|
return { argv };
|
|
995
1547
|
}
|
|
996
|
-
var splates =
|
|
997
|
-
splates.command("
|
|
998
|
-
splates.command("
|
|
1548
|
+
var splates = cli15("splates").use(exits());
|
|
1549
|
+
splates.command("notes").use(repository9({ needs: "read" })).description("print each project note's frontmatter description, one per line; notesDir in splates.config.ts defaults to notes; an absent directory prints nothing").action((_opts, ctx) => notes(ctx));
|
|
1550
|
+
splates.command("init").use(repository9({ creates: true, needs: "own" })).description("make this repository a splates project: set up its records under .git/splates when it has none, install the splates skill of this release with `bunx skills add`, and register it in ~/.splates/projects.json, so `splates server` serves it beside every other; run again, it changes only what is not so already").action((_opts, ctx) => init(ctx));
|
|
1551
|
+
splates.command("migrate").description(`move this repository's records under .git/splates to this splates's format, as \`splates server\` does as it starts: backed up first, the steps run with ${MIGRATION_LIMIT.human()} to finish, and the backup put back if one fails or runs over, with why kept in .git/splates-migration.json; it tries again past a failure kept there, which the server and every other command leave alone. Run it only while no older \`splates server\` serves the repository, which would refuse the records once moved; \`splates update\` restarts one first`).action(async (_opts, ctx) => {
|
|
1552
|
+
const format = await migrateRecords(ctx);
|
|
1553
|
+
if (ctx.ps.env(MIGRATING) === undefined) {
|
|
1554
|
+
ctx.log.info(`splates's records are in format ${format}`);
|
|
1555
|
+
}
|
|
1556
|
+
});
|
|
1557
|
+
splates.command("update").use(recordsFirst()).use(repository9({ needs: "own" })).description("bring this repository up to the newest splates on npm: run `update` on that release when it is newer than this one, which moves the records under .git/splates to its format, as `splates migrate` does, unless an older `splates server` serves the repository, which it asks to restart onto that release once its agents have checkpointed, migrating them as it starts; then installs its splates skill with `bunx skills add` over the copy there, leaving one that links to your own; commit what changed").action(async (_opts, ctx) => {
|
|
999
1558
|
const code = await update({
|
|
1000
1559
|
root: ctx.git.root,
|
|
1001
1560
|
fs: ctx.fs,
|
|
@@ -1007,7 +1566,7 @@ splates.command("update").use(repository7({ needs: "own" })).description("bring
|
|
|
1007
1566
|
ctx.ps.exit(code);
|
|
1008
1567
|
}
|
|
1009
1568
|
});
|
|
1010
|
-
splates.command("heavy").description("run a heavy command (a full test run, an install) in one of this machine's heavy-job slots, waiting for one to come free first, so agents testing at once queue rather than run out of memory; `SPLATES_HEAVY_JOBS` sets how many run at once, 2 by default").rest("command",
|
|
1569
|
+
splates.command("heavy").description("run a heavy command (a full test run, an install) in one of this machine's heavy-job slots, waiting for one to come free first, so agents testing at once queue rather than run out of memory; `SPLATES_HEAVY_JOBS` sets how many run at once, 2 by default").rest("command", z16.string(), {
|
|
1011
1570
|
description: "the command and its arguments, after `--`"
|
|
1012
1571
|
}).action(async (opts, ctx) => {
|
|
1013
1572
|
const code = await runHeavy(ctx, opts.command);
|
|
@@ -1015,61 +1574,66 @@ splates.command("heavy").description("run a heavy command (a full test run, an i
|
|
|
1015
1574
|
ctx.ps.exit(code);
|
|
1016
1575
|
}
|
|
1017
1576
|
});
|
|
1018
|
-
splates.command("forget").use(
|
|
1019
|
-
splates.command("add").use(
|
|
1577
|
+
splates.command("forget").use(repository9({ needs: "own" })).description("take this repository off ~/.splates/projects.json, so `splates server` no longer offers it; its records stay, and `splates init` brings it back").action((_opts, ctx) => forget(ctx));
|
|
1578
|
+
splates.command("add").use(repository9({ needs: "tasks" })).description("start a task: a new one, or with --task one from the queue; create branch task/<slug>, a worktree at ../<repo>-splates.noindex/<slug> and a state record").arg("slug", z16.string(), {
|
|
1579
|
+
description: "the task's name, for its branch and worktree (lowercase-with-dashes)"
|
|
1580
|
+
}).option("base", z16.string(), {
|
|
1020
1581
|
default: "",
|
|
1021
1582
|
description: "branch this task starts from and merges onto (default: trunk); `task/<other>` stacks this task on that one and lands the work in its worktree"
|
|
1022
|
-
}).option("
|
|
1583
|
+
}).option("task", z16.string(), {
|
|
1023
1584
|
default: "",
|
|
1024
|
-
description: "
|
|
1025
|
-
}).option("goal",
|
|
1585
|
+
description: "start this queued task by number: its words become the plan's Goal, merging removes it, and removing this task puts it back where it was"
|
|
1586
|
+
}).option("goal", z16.string(), {
|
|
1026
1587
|
default: "",
|
|
1027
|
-
description: "one or two lines on what done means, written under `## Goal` in the task's SPLATES.md; required unless --
|
|
1028
|
-
}).option("agent",
|
|
1588
|
+
description: "one or two lines on what done means, written under `## Goal` in the task's SPLATES.md; required unless --task seeds the Goal"
|
|
1589
|
+
}).option("agent", z16.string(), {
|
|
1029
1590
|
default: "",
|
|
1030
|
-
description: "
|
|
1031
|
-
}).option("model",
|
|
1591
|
+
description: "how `splates server`'s queue hands the task to an agent on the roster (`splates agents`), which it starts in the worktree; refused from an agent, which starts no agents and queues work with `splates task add` instead"
|
|
1592
|
+
}).option("model", z16.string(), {
|
|
1032
1593
|
default: "",
|
|
1033
1594
|
description: "with --agent: the model it works on, by its id or name on the roster (default: the agent's own)"
|
|
1034
|
-
}).option("effort",
|
|
1595
|
+
}).option("effort", z16.string(), {
|
|
1035
1596
|
default: "",
|
|
1036
1597
|
description: "with --agent: the thinking level it works at, one the agent offers (default: the agent's own)"
|
|
1037
|
-
}).option("prompt",
|
|
1598
|
+
}).option("prompt", z16.string(), {
|
|
1038
1599
|
default: "",
|
|
1039
|
-
description: "with --agent: what to tell the agent beyond claiming the task
|
|
1040
|
-
}).option("
|
|
1041
|
-
default:
|
|
1042
|
-
description: "with --agent:
|
|
1600
|
+
description: "with --agent: what to tell the agent beyond claiming the task"
|
|
1601
|
+
}).option("held", z16.string(), {
|
|
1602
|
+
default: "",
|
|
1603
|
+
description: "with --agent: the conversation `splates server`'s queue held for the queued task, which takes the task rather than a new one"
|
|
1043
1604
|
}).action(async (opts, ctx) => {
|
|
1044
|
-
|
|
1045
|
-
|
|
1605
|
+
await refuseGroomer4(ctx.service, "add");
|
|
1606
|
+
if (opts.agent === "" && (opts.model !== "" || opts.effort !== "" || opts.prompt !== "" || opts.held !== "")) {
|
|
1607
|
+
fail9("usage", "--model, --effort, --prompt and --held go with --agent", {
|
|
1608
|
+
task: opts.slug
|
|
1609
|
+
});
|
|
1046
1610
|
}
|
|
1047
|
-
if (opts.goal.trim() === "" && opts.
|
|
1048
|
-
|
|
1611
|
+
if (opts.goal.trim() === "" && opts.task === "") {
|
|
1612
|
+
fail9("usage", `say what done means: \`splates add ${opts.slug} --goal "<one or two lines>"\`, or start queued tasks with --task`, { task: opts.slug });
|
|
1049
1613
|
}
|
|
1050
1614
|
const dispatch = opts.agent === "" ? undefined : {
|
|
1051
1615
|
agent: opts.agent,
|
|
1052
1616
|
...opts.model === "" ? {} : { model: opts.model },
|
|
1053
1617
|
...await effortIn(ctx, opts.agent, opts.effort, {
|
|
1054
|
-
task: opts.
|
|
1618
|
+
task: opts.slug
|
|
1055
1619
|
}),
|
|
1056
|
-
...opts.prompt === "" ? {} : { prompt: opts.prompt }
|
|
1620
|
+
...opts.prompt === "" ? {} : { prompt: opts.prompt },
|
|
1621
|
+
...opts.held === "" ? {} : { held: opts.held }
|
|
1057
1622
|
};
|
|
1058
1623
|
const agents = dispatch === undefined ? [] : await seeded2(rosterOf2(ctx));
|
|
1059
|
-
const all = await ctx.
|
|
1060
|
-
const subjects =
|
|
1061
|
-
await ctx.journal.record("add", opts.
|
|
1624
|
+
const all = await ctx.tasks.all();
|
|
1625
|
+
const subjects = taskIds(opts.task).flatMap((id) => all.find((each) => each.id === id)?.subject ?? []);
|
|
1626
|
+
await ctx.journal.record("add", opts.slug, () => add(ctx, opts.slug, {
|
|
1062
1627
|
base: opts.base || undefined,
|
|
1063
|
-
|
|
1628
|
+
tasks: taskIds(opts.task),
|
|
1064
1629
|
goal: opts.goal.trim() || undefined,
|
|
1065
1630
|
dispatch,
|
|
1066
1631
|
agents,
|
|
1067
1632
|
away: ctx.elsewhere !== null,
|
|
1068
|
-
|
|
1069
|
-
onTree: dispatch === undefined ? () => follow(ctx, opts.task, { base: opts.base || undefined }) : undefined
|
|
1633
|
+
onTree: dispatch === undefined ? () => follow(ctx, opts.slug, { base: opts.base || undefined }) : undefined
|
|
1070
1634
|
}), {
|
|
1071
1635
|
base: opts.base || ctx.config.trunk,
|
|
1072
|
-
|
|
1636
|
+
tasks: taskIds(opts.task),
|
|
1073
1637
|
goal: opts.goal.trim() || null,
|
|
1074
1638
|
subjects,
|
|
1075
1639
|
agent: dispatch?.agent ?? null,
|
|
@@ -1079,204 +1643,113 @@ splates.command("add").use(repository7({ needs: "tasks" })).description("start a
|
|
|
1079
1643
|
await serveProject(ctx);
|
|
1080
1644
|
}
|
|
1081
1645
|
});
|
|
1082
|
-
splates.command("claim").use(
|
|
1646
|
+
splates.command("claim").use(repository9({ needs: "own" })).description("resume an existing task: take ownership of its worktree and print its path, status and any half-finished rebase; refuses while another agent holds the lease, but takes a stale one silently, so `splates show` first if the tree may not be abandoned").arg("task", z16.string(), { description: "task name" }).action(async (opts, ctx) => {
|
|
1083
1647
|
await ctx.journal.record("claim", opts.task, () => claim(ctx, opts.task), (claimed) => claimed);
|
|
1084
1648
|
await follow(ctx, opts.task);
|
|
1085
1649
|
});
|
|
1086
|
-
splates.command("merge").use(
|
|
1650
|
+
splates.command("merge").use(repository9({ needs: "own" })).description("land this worktree's branch on its base (trunk unless created with --base): rebase onto it, run tests on the rebased code, fast-forward it in whichever worktree has it checked out, then discard the worktree, branch and record (linear history, never a merge commit, no flag to skip tests); requires committed work, refusing a dirty worktree").option("message", z16.string(), {
|
|
1651
|
+
default: "",
|
|
1652
|
+
description: "squash the task's commits into one with this message before landing, saying what the base gains in at least 5 characters"
|
|
1653
|
+
}).action(async (opts, ctx) => {
|
|
1654
|
+
await refuseGroomer4(ctx.service, "merge");
|
|
1087
1655
|
const task = await here(ctx);
|
|
1088
|
-
const landing = task === null ? null : await ctx.service.find(task);
|
|
1089
1656
|
const facts = {};
|
|
1090
|
-
await ctx.journal.record("merge", task, () => merge(ctx, ctx.ps.cwd(), facts), facts);
|
|
1657
|
+
await ctx.journal.record("merge", task, () => merge(ctx, ctx.ps.cwd(), facts, { message: opts.message }), facts);
|
|
1091
1658
|
if (task !== null) {
|
|
1092
|
-
await
|
|
1659
|
+
await addFactTasks(ctx, task).catch((error) => ctx.log.error(`could not queue tasks for what the merge found: ${error}`));
|
|
1093
1660
|
await follow(ctx, null, { from: task });
|
|
1094
1661
|
}
|
|
1095
|
-
if (landing !== null) {
|
|
1096
|
-
await reportToCaller(ctx, landing);
|
|
1097
|
-
}
|
|
1098
1662
|
});
|
|
1099
|
-
splates.command("remove").use(
|
|
1663
|
+
splates.command("remove").use(repository9({ needs: "tasks" })).description("discard a task: worktree, branch and state file; cheap and encouraged, since redoing a task against current trunk often beats a hard rebase").arg("task", z16.string(), { description: "task name" }).option("force", z16.boolean(), {
|
|
1100
1664
|
default: false,
|
|
1101
1665
|
description: "discard even when another agent holds the lease"
|
|
1102
|
-
}).option("reason",
|
|
1103
|
-
description: "why, for the Stats page: nothing (nothing to change), moot (no longer needed), superseded (done some other way), redo (better redone against current trunk)"
|
|
1666
|
+
}).option("reason", z16.optional(z16.enum(REMOVE_REASONS)), {
|
|
1667
|
+
description: "why, for the Stats page: nothing (nothing to change), moot (no longer needed), superseded (done some other way), redo (better redone against current trunk), blocked (set aside until what it waits on lands, so back on the list)"
|
|
1104
1668
|
}).action(async (opts, ctx) => {
|
|
1105
|
-
const removing = await ctx.service.find(opts.task);
|
|
1106
1669
|
await ctx.journal.record("remove", opts.task, () => remove(ctx, opts.task, { force: opts.force, reason: opts.reason }), ({ released }) => ({ why: opts.reason ?? null, released }));
|
|
1107
1670
|
await follow(ctx, null, { from: opts.task });
|
|
1108
|
-
await reportToCaller(ctx, removing);
|
|
1109
1671
|
});
|
|
1110
|
-
splates.command("list").use(
|
|
1672
|
+
splates.command("list").use(repository9({ needs: "read" })).description("list every started task: its number, name, status, lease (held: an agent is on it now; stale: gone quiet, normal for a task mid-edit; none), commits ahead of trunk, age; `splates task list` lists the queue").option("json", z16.boolean(), { default: false, description: "emit JSON" }).option("files", z16.boolean(), {
|
|
1111
1673
|
default: false,
|
|
1112
1674
|
description: "add each task's Goal and changed files (committed or not), to check for overlap before starting"
|
|
1113
1675
|
}).action((opts, ctx) => list(ctx, { json: opts.json, files: opts.files }));
|
|
1114
|
-
splates.command("show").use(
|
|
1115
|
-
splates.command("wait").use(
|
|
1676
|
+
splates.command("show").use(repository9({ needs: "read" })).description("read one task without touching it: everything `list` shows for it, plus the SPLATES.md its agent left at the worktree root; takes no lease, so it cannot knock that agent off its own tree; for a task no longer live, the newest finished one of that name: how it ended, its base, the commit it landed as, its conversation and the SPLATES.md it ended on").arg("task", z16.string(), { description: "task name" }).option("json", z16.boolean(), { default: false, description: "emit JSON" }).action((opts, ctx) => show(ctx, opts.task, { json: opts.json }));
|
|
1677
|
+
splates.command("wait").use(repository9({ needs: "read" })).description("block until a task stops moving: waiting on a person to answer its questions, or gone (merged or removed), or broken; takes no lease, and gives up with `timeout` rather than waiting forever").arg("task", z16.string(), { description: "task name" }).option("timeout-secs", z16.coerce.number(), {
|
|
1116
1678
|
default: DEFAULT_TIMEOUT3.secs,
|
|
1117
1679
|
description: "how long to wait before giving up"
|
|
1118
1680
|
}).action((opts, ctx) => {
|
|
1119
1681
|
const timeout = Duration3.secs(opts["timeout-secs"]);
|
|
1120
1682
|
return ctx.journal.waiting("wait", opts.task, { until: untilAfter3(timeout) }, () => wait(ctx, opts.task, { timeout }));
|
|
1121
1683
|
});
|
|
1122
|
-
splates.command("log").use(
|
|
1684
|
+
splates.command("log").use(repository9({ needs: "read" })).description("show what has been done here recently: one line per add, claim, merge, remove, retry, queued task and more, with how it ended; outlives the tasks themselves").option("count", z16.coerce.number(), {
|
|
1123
1685
|
default: DEFAULT_COUNT,
|
|
1124
1686
|
description: "how many entries to show"
|
|
1125
|
-
}).option("json",
|
|
1126
|
-
splates.
|
|
1127
|
-
|
|
1128
|
-
description: "port to listen on, or the next open one above it"
|
|
1129
|
-
}).option("allow-hosts", z13.string(), {
|
|
1130
|
-
default: "",
|
|
1131
|
-
description: "comma-separated host names the page may also be reached by, like a tunnel's; put Cloudflare Access in front of them with --access-team and --access-aud"
|
|
1132
|
-
}).option("access-team", z13.string(), {
|
|
1133
|
-
default: "",
|
|
1134
|
-
description: "the Cloudflare Access team in front of --allow-hosts, as in <team>.cloudflareaccess.com; with --access-aud, those hosts answer only to a verified Access token, and may then use conversations and terminals"
|
|
1135
|
-
}).option("access-aud", z13.string(), {
|
|
1136
|
-
default: "",
|
|
1137
|
-
description: "the AUD tag of that Access application"
|
|
1138
|
-
}).option("tunnel", z13.string(), {
|
|
1139
|
-
default: "",
|
|
1140
|
-
description: "the public host name of a tunnel to run, with cloudflared or the tunnel provider named by splates.config.ts in the repository it is run in, if any, which is allowed as a host too; refused without --access-team and --access-aud, so a tunnel never exposes the page unauthenticated. With none of the tunnel and Access flags, the tunnel `splates tunnel setup` saved runs, if any"
|
|
1141
|
-
}).option("tunnel-name", z13.string(), {
|
|
1142
|
-
default: "",
|
|
1143
|
-
description: "the named tunnel cloudflared runs for --tunnel, by default the one its own config names; not with a tunnel provider of splates.config.ts"
|
|
1144
|
-
}).option("ports-host", z13.string(), {
|
|
1145
|
-
default: "",
|
|
1146
|
-
description: "the wildcard base host to serve task ports under, saved for this machine so a bare `splates server` serves it too: each port a task's processes listen on opens at https://<task>-<port>.<base>, to whoever Cloudflare Access lets in, and is refused without Access; routing *.<base> here, its DNS and TLS, are yours. `none` forgets it, leaving each task port forwarded to a port on this machine's loopback alone"
|
|
1147
|
-
}).option("worker-slots", z13.coerce.number().int().min(1), {
|
|
1148
|
-
default: LOCAL_SLOTS,
|
|
1149
|
-
description: "how many agents that other agents started (with `splates add --agent`, or a lane's orchestrator handing out todos) this machine's worker runs at once; past them, each new or resumed one waits in the queue, first come, first served, which `splates queue` shows and reorders. An agent you start runs at once on any worker up, taking no slot. Read as the server starts its worker, which a restart from the page leaves running"
|
|
1150
|
-
}).option("slot", z13.boolean(), {
|
|
1151
|
-
default: false,
|
|
1152
|
-
description: "serve this checkout's splates at https://<word>.<zone>, a slot of its own on the zone `splates tunnel setup` uses, behind the same Access policy, so several run side by side and a phone opens each by name: a task's worktree keeps its word, as fox, until the task merges or is removed, which stops its server; run again, it stops the tree's last server first. Refused in a splates repository's main tree, which every agent shares. A slot keeps its own projects in ~/.splates/slots/<word>, apart from yours, starting with a throwaway project there; not with the tunnel and Access flags"
|
|
1153
|
-
}).action((opts, ctx) => serveDev(ctx, opts));
|
|
1154
|
-
splates.command("ports").description("list the ports tasks serve, found by the running `splates server` as an editor finds ports to forward: each port a process in a task's worktree, or under its agent, listens on, with its link through the ports host `splates server --ports-host` saved, behind Cloudflare Access, and its link on this machine; give the user both").arg("task", z13.string(), {
|
|
1687
|
+
}).option("json", z16.boolean(), { default: false, description: "emit JSON" }).action((opts, ctx) => showLog(ctx, { count: opts.count, json: opts.json }));
|
|
1688
|
+
splates.mount("server", splatesServer);
|
|
1689
|
+
splates.command("ports").description("list the ports tasks serve, found by the running `splates server` as an editor finds ports to forward: each port a process in a task's worktree, or under its agent, listens on, with its link through the ports host `splates server --ports-host` saved, behind Cloudflare Access, and its link on this machine, which on a worker whose server runs elsewhere only that worker's own ports have; give the user both").arg("task", z16.string(), {
|
|
1155
1690
|
default: "",
|
|
1156
1691
|
description: "only this task's ports; every task's by default"
|
|
1157
|
-
}).option("dev",
|
|
1692
|
+
}).option("dev", z16.string(), {
|
|
1158
1693
|
default: "",
|
|
1159
|
-
description: "the `splates server` to ask, a URL such as http://localhost:4310; by default the one an agent runs under, from SPLATES_DEV, else this machine's on its default port"
|
|
1160
|
-
}).option("json",
|
|
1694
|
+
description: "the `splates server` to ask, a URL such as http://localhost:4310; by default the one an agent runs under, from SPLATES_DEV, else the coordinator this machine's worker relays to, else this machine's on its default port"
|
|
1695
|
+
}).option("json", z16.boolean(), { default: false, description: "emit JSON" }).action((opts, ctx) => portsLs({
|
|
1161
1696
|
task: opts.task,
|
|
1162
1697
|
dev: opts.dev,
|
|
1163
1698
|
json: opts.json,
|
|
1164
1699
|
log: ctx.log,
|
|
1700
|
+
fs: ctx.fs,
|
|
1165
1701
|
ps: ctx.ps,
|
|
1166
1702
|
send: ctx.fetch
|
|
1167
1703
|
}));
|
|
1168
|
-
splates.command("agents").description("print the roster of agents splates can start, kept for every project in ~/.splates/agents.json: each agent's launch command and models, with what each model is good at and what it costs, and the thinking levels `--effort` takes, as the agent offered them when last started, for choosing whom to delegate to; writes the defaults (Claude, Codex) there first when there is none, and `splates server` starts conversations with those it lists").option("json",
|
|
1704
|
+
splates.command("agents").description("print the roster of agents splates can start, kept for every project in ~/.splates/agents.json: each agent's launch command and models, with what each model is good at and what it costs, and the thinking levels `--effort` takes, as the agent offered them when last started, for choosing whom to delegate to; writes the defaults (Claude, Codex) there first when there is none, and `splates server` starts conversations with those it lists").option("json", z16.boolean(), { default: false, description: "emit JSON" }).action(async (opts, ctx) => agents({
|
|
1169
1705
|
roster: rosterOf2(ctx),
|
|
1170
1706
|
offered: await offeredOf(ctx).all(),
|
|
1171
1707
|
log: ctx.log
|
|
1172
1708
|
}, { json: opts.json }));
|
|
1173
|
-
splates.command("setup").description("set splates up on this machine, one step at a time: with no step, each area's steps, checked from real state, and the one to do next; with a step, why it matters, the one thing the user does and what the agent does. Skips are kept in ~/.splates/setup.json, so a skipped step stops asking").arg("step",
|
|
1709
|
+
splates.command("setup").description("set splates up on this machine, one step at a time: with no step, each area's steps, checked from real state, and the one to do next; with a step, why it matters, the one thing the user does and what the agent does. Skips are kept in ~/.splates/setup.json, so a skipped step stops asking").arg("step", z16.string(), {
|
|
1174
1710
|
default: "",
|
|
1175
1711
|
description: "a step's id; omit for every area's progress"
|
|
1176
|
-
}).option("json",
|
|
1712
|
+
}).option("json", z16.boolean(), { default: false, description: "emit JSON" }).option("skip", z16.boolean(), {
|
|
1177
1713
|
default: false,
|
|
1178
1714
|
description: "with a step: stop asking for it"
|
|
1179
|
-
}).option("unskip",
|
|
1715
|
+
}).option("unskip", z16.boolean(), {
|
|
1180
1716
|
default: false,
|
|
1181
1717
|
description: "with a step: ask for it again"
|
|
1182
|
-
}).
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
fail5("usage", "--skip or --unskip, not both", { step: opts.step });
|
|
1188
|
-
}
|
|
1189
|
-
await setup(ctx, opts);
|
|
1190
|
-
});
|
|
1191
|
-
splates.command("path").use(repository7({ needs: "read" })).description("print a task's worktree path, or the main tree with no task; names another agent's tree without taking its lease").arg("task", z13.string(), {
|
|
1718
|
+
}).option("undo", z16.boolean(), {
|
|
1719
|
+
default: false,
|
|
1720
|
+
description: "with an area's id in place of a step: print what undoing it would remove, the creds it forgets and keeps, and what only the user can remove; the Setup page's Undo does it, after the user confirms"
|
|
1721
|
+
}).action((opts, ctx) => setup(ctx, opts));
|
|
1722
|
+
splates.command("path").use(repository9({ needs: "read" })).description("print a task's worktree path, or the main tree with no task; names another agent's tree without taking its lease").arg("task", z16.string(), {
|
|
1192
1723
|
default: "",
|
|
1193
1724
|
description: "task name; omit for the main tree"
|
|
1194
1725
|
}).action((opts, ctx) => path(ctx, opts.task || undefined));
|
|
1195
|
-
splates.command("checkpoint").use(
|
|
1726
|
+
splates.command("checkpoint").use(repository9({ needs: "own" })).description("save this task to the central remote (`remote` in splates.config.ts) before a stop: commit what is uncommitted as a `WIP: checkpoint` commit, to squash before merging, and push the branch as `splates/<task>`, so a worker that dies loses nothing; with no remote configured, leaves the tree as it is").action(async (_opts, ctx) => {
|
|
1196
1727
|
await checkpoint(ctx, ctx.ps.cwd());
|
|
1197
1728
|
});
|
|
1198
|
-
splates.command("
|
|
1199
|
-
description: "why this needs a human; with --review, what to look at before approving"
|
|
1200
|
-
}).option("task", z13.string(), {
|
|
1201
|
-
default: "",
|
|
1202
|
-
description: "task name, when run outside its worktree"
|
|
1203
|
-
}).option("review", z13.boolean(), {
|
|
1204
|
-
default: false,
|
|
1205
|
-
description: "ask a person to approve merging, the reason saying what to look at, approved in chat; refused until the task is ready to merge, with every question under ## Blocked and step under ## Next checked"
|
|
1206
|
-
}).action(async (opts, ctx) => {
|
|
1207
|
-
const task = opts.task || await here(ctx);
|
|
1208
|
-
await ctx.journal.record("escalate", task, () => escalate(ctx, opts.reason, ctx.ps.cwd(), {
|
|
1209
|
-
task: opts.task || undefined,
|
|
1210
|
-
review: opts.review
|
|
1211
|
-
}), (facts) => facts);
|
|
1212
|
-
if (task !== null) {
|
|
1213
|
-
await reportToCaller(ctx, await ctx.service.find(task));
|
|
1214
|
-
}
|
|
1215
|
-
});
|
|
1216
|
-
splates.command("tell").use(repository7({ needs: "tasks" })).description("say something in the conversation of the agent a task was handed to with `splates add --agent` or `splates handoff --relay`, as the user would: how an orchestrator wakes an agent that sits idle, stops it for a change of plans, or passes on what its lane taught it, and how a relaying agent passes on the user's answers; only the conversation that handed the task out may").arg("task", z13.string(), { description: "task name" }).arg("text", z13.string(), { description: "what to say, as markdown" }).option("stop", z13.boolean(), {
|
|
1217
|
-
default: false,
|
|
1218
|
-
description: "stop the turn the agent is running first, as the user's Stop does, then say text: for a change of plans"
|
|
1219
|
-
}).action((opts, ctx) => ctx.journal.record("tell", opts.task, () => tell(ctx, opts.task, opts.text, { stop: opts.stop }), (to) => ({ to })));
|
|
1220
|
-
splates.command("handoff").use(repository7({ needs: "own" })).description("hand the task you are at work on to another agent on the roster (`splates agents`), which `splates server` starts in its worktree, told `[SPLATES HANDOFF <task>]` to claim it and carry on from its SPLATES.md; it answers to the user as you did, or with --relay to you, and this conversation leaves the task, though a lane's orchestrator that started you goes on hearing of it; refused to an agent that answers to another conversation, and for a task another conversation is at work on").arg("task", z13.string(), { description: "task name" }).option("agent", z13.string(), {
|
|
1221
|
-
description: "the agent on the roster to hand it to"
|
|
1222
|
-
}).option("model", z13.string(), {
|
|
1223
|
-
default: "",
|
|
1224
|
-
description: "the model it works on, by its id or name on the roster (default: the agent's own)"
|
|
1225
|
-
}).option("effort", z13.string(), {
|
|
1226
|
-
default: "",
|
|
1227
|
-
description: "the thinking level it works at, one the agent offers (default: the agent's own)"
|
|
1228
|
-
}).option("prompt", z13.string(), {
|
|
1229
|
-
default: "",
|
|
1230
|
-
description: "what to tell the agent beyond taking the task over, such as why it is handed on"
|
|
1231
|
-
}).option("relay", z13.boolean(), {
|
|
1232
|
-
default: false,
|
|
1233
|
-
description: "for work you judged another model fits better: the agent answers to you rather than the user, reporting back with `[SPLATES REPORT <task>]` and told what the user says with `splates tell`; needs `splates server`"
|
|
1234
|
-
}).action(async (opts, ctx) => {
|
|
1235
|
-
const agents = await seeded2(rosterOf2(ctx));
|
|
1236
|
-
const effort = await effortIn(ctx, opts.agent, opts.effort, {
|
|
1237
|
-
task: opts.task
|
|
1238
|
-
});
|
|
1239
|
-
await ctx.journal.record("handoff", opts.task, () => handoff(ctx, opts.task, {
|
|
1240
|
-
agent: opts.agent,
|
|
1241
|
-
...opts.model === "" ? {} : { model: opts.model },
|
|
1242
|
-
...effort,
|
|
1243
|
-
...opts.prompt === "" ? {} : { prompt: opts.prompt }
|
|
1244
|
-
}, agents, { relay: opts.relay }), (picked) => ({
|
|
1245
|
-
agent: picked.agent,
|
|
1246
|
-
model: picked.model ?? null,
|
|
1247
|
-
relay: opts.relay
|
|
1248
|
-
}));
|
|
1249
|
-
await follow(ctx, null, { from: opts.task });
|
|
1250
|
-
});
|
|
1251
|
-
splates.command("attach").use(repository7({ needs: "own" })).description("store screenshots and recordings for this task's questions to show: prints the path each was stored at, under .git/splates, which the `splates server` page shows inline; from a conversation (its $SPLATES_CONVERSATION, or --conversation) they stay with it past the task, otherwise they go when the task merges or is removed, and a task holds at most attachmentCapacity bytes; with no files, lists what it holds. A file the user will come back for on its own is an artifact instead (`splates artifact add`)").arg("files", z13.string(), {
|
|
1729
|
+
splates.command("attach").use(repository9({ needs: "own" })).description("store screenshots and recordings for this task's questions to show: prints the path each was stored at, under .git/splates, which the `splates server` page shows inline; from a conversation (its $SPLATES_CONVERSATION, or --conversation) they stay with it past the task, otherwise they go when the task merges or is removed; those the task's final SPLATES.md shows are copied to keep with its finished record. A task holds at most attachmentCapacity bytes; with no files, lists what it holds. A file the user will come back for on its own is an artifact instead (`splates artifact add`)").arg("files", z16.string(), {
|
|
1252
1730
|
default: "",
|
|
1253
1731
|
description: "files to store, comma separated"
|
|
1254
|
-
}).option("task",
|
|
1732
|
+
}).option("task", z16.string(), {
|
|
1255
1733
|
default: "",
|
|
1256
1734
|
description: "task name, when run outside its worktree"
|
|
1257
|
-
}).option("remove",
|
|
1735
|
+
}).option("remove", z16.string(), {
|
|
1258
1736
|
default: "",
|
|
1259
1737
|
description: "files it holds to drop first, comma separated, by path or stored name"
|
|
1260
|
-
}).option("conversation",
|
|
1738
|
+
}).option("conversation", z16.string(), {
|
|
1261
1739
|
default: "",
|
|
1262
1740
|
description: "conversation to keep the files with, when $SPLATES_CONVERSATION is not set"
|
|
1263
|
-
}).action(async (opts, ctx) => ctx.journal.record("attach", opts.task || await here(ctx), () => attach(ctx,
|
|
1741
|
+
}).action(async (opts, ctx) => ctx.journal.record("attach", opts.task || await here(ctx), () => attach(ctx, commaList6(opts.files), ctx.ps.cwd(), {
|
|
1264
1742
|
task: opts.task || undefined,
|
|
1265
|
-
remove:
|
|
1743
|
+
remove: commaList6(opts.remove),
|
|
1266
1744
|
conversation: opts.conversation || undefined
|
|
1267
|
-
}), (stored) => ({ stored, removed:
|
|
1268
|
-
splates.command("retry").use(
|
|
1269
|
-
splates.mount("artifact", splatesArtifact).mount("
|
|
1270
|
-
|
|
1271
|
-
// main.ts
|
|
1272
|
-
async function main() {
|
|
1273
|
-
if (basename2(process.argv[1] ?? "") === LEGACY) {
|
|
1274
|
-
legacyWarnings.once(LEGACY, "splates");
|
|
1275
|
-
}
|
|
1276
|
-
const ps = systemPs();
|
|
1277
|
-
const { project, argv } = projectArgs(ps.args);
|
|
1278
|
-
await splates.run({ fs: new NodeFs, ps, assets, project }, argv);
|
|
1279
|
-
}
|
|
1745
|
+
}), (stored) => ({ stored, removed: commaList6(opts.remove) })));
|
|
1746
|
+
splates.command("retry").use(repository9({ needs: "own" })).description("give a task that spent its merge attempts another mergeRetryCount of them; the way out of `budget_exhausted` that is not remove and redo, for a person to run once they have seen the tree").arg("task", z16.string(), { description: "task name" }).action((opts, ctx) => recordRetry(ctx, opts.task));
|
|
1747
|
+
splates.mount("artifact", splatesArtifact).mount("task", splatesTask).mount("lane", splatesLane).mount("projects", splatesProjects).mount("creds", splatesCreds).mount("tunnel", splatesTunnel).mount("slots", splatesSlots).mount("worker", splatesWorker).mount("queue", splatesQueue).mount("hook", splatesHook).mount("budget", splatesBudget);
|
|
1280
1748
|
|
|
1281
1749
|
// index.ts
|
|
1282
|
-
|
|
1750
|
+
if (basename2(process.argv[1] ?? "") === LEGACY) {
|
|
1751
|
+
legacyWarnings.once(LEGACY, "splates");
|
|
1752
|
+
}
|
|
1753
|
+
var ps = systemPs();
|
|
1754
|
+
var { project, argv } = projectArgs(ps.args);
|
|
1755
|
+
await splates.run({ fs: new NodeFs, ps, assets, project }, argv);
|