@gorlitzer-labs/seldon 0.10.0 → 0.12.0
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 +2 -20
- package/bin/seldon.js +11 -43
- package/lib/actions.mjs +15 -3
- package/lib/agents.mjs +5 -0
- package/lib/lanes.mjs +14 -0
- package/package.json +1 -1
- package/lib/entire.mjs +0 -46
package/README.md
CHANGED
|
@@ -74,28 +74,10 @@ recorded in `~/.seldon/lanes.json`. A plan item shows the lane working on it.
|
|
|
74
74
|
seldon lanes [--json] # every agent here
|
|
75
75
|
seldon lane start [dir] --task "fix the save crash" [--agent codex]
|
|
76
76
|
seldon lane stop|resume|open <name or key>
|
|
77
|
-
seldon lane
|
|
77
|
+
seldon lane rm <name or key> [--force] # a stopped lane: its worktree goes,
|
|
78
|
+
# its branch too if git sees it merged
|
|
78
79
|
```
|
|
79
80
|
|
|
80
|
-
## Why each change was made: Entire
|
|
81
|
-
|
|
82
|
-
[Entire](https://entire.com) (`entire` CLI, MIT) records the agent session behind every
|
|
83
|
-
commit: the prompt, the redacted transcript, the files touched and the tokens. It links each one
|
|
84
|
-
to its commit with an `Entire-Checkpoint` trailer, which survives rebase and squash. It works from
|
|
85
|
-
lane worktrees, Claude's and seldon's alike.
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
brew install --cask entireio/tap/entire
|
|
89
|
-
seldon setup entire [dir] [--remote origin] # turns it on for every harness installed here
|
|
90
|
-
git add .entire .claude && git commit -m "record agent sessions" # lanes get it from now on
|
|
91
|
-
seldon lane why fix-save-crash # recorded commits, then the newest explained
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
Checkpoints are pushed to `--remote` with your branches, so **a public repository makes your
|
|
95
|
-
agents' transcripts public**. Use a private remote. Redaction is best effort. With the
|
|
96
|
-
[comb gate](../../modules/comb) installed globally, use comb 0.2.4 or later: earlier versions
|
|
97
|
-
skipped Entire's pre-push from worktrees.
|
|
98
|
-
|
|
99
81
|
## Codex and opencode: let them report their state
|
|
100
82
|
|
|
101
83
|
Claude Code lists its own sessions. Codex and opencode do not, so out of the box their lanes
|
package/bin/seldon.js
CHANGED
|
@@ -10,8 +10,7 @@ import { MODULES, byId, DEPS, RAW, MONOREPO, withRequires, platformOk } from "..
|
|
|
10
10
|
import { ensureSiblingPath, loadState, resolveProject, adopt as fAdopt, staff as fStaff, attach as fAttach, hiveOf, sameDir } from "../lib/projects.mjs";
|
|
11
11
|
import { readLanes, readPlan, addToPlan, projectRoot, writeReport } from "../lib/agents.mjs";
|
|
12
12
|
import { openCommand, stopCommand, transitions, laneForItem, slugify, HARNESSES } from "../lib/lanes.mjs";
|
|
13
|
-
import {
|
|
14
|
-
import { startLane, stopLane, resumeLane, findLane } from "../lib/actions.mjs";
|
|
13
|
+
import { startLane, stopLane, resumeLane, removeLane, findLane } from "../lib/actions.mjs";
|
|
15
14
|
import { listMachines, addMachine, fetchLanes, remoteGroups, sshArgs, lastJsonLine } from "../lib/machines.mjs";
|
|
16
15
|
import { notify } from "../lib/notify.mjs";
|
|
17
16
|
import { reportFromEvent, mergeCodexHooks, removeCodexHooks, opencodePlugin } from "../lib/reports.mjs";
|
|
@@ -1439,8 +1438,6 @@ ${C.bold("seldon")} — the agent factory: your projects, and the stack that run
|
|
|
1439
1438
|
${C.dim("go takes --agent claude|codex, --model <id>, --effort <lvl>, --name <n>,")}
|
|
1440
1439
|
${C.dim(" --no-staff (do not start an agent), --no-attach (do not open the room) and")}
|
|
1441
1440
|
${C.dim(" --attach (open it even with no terminal detected — inside tmux, or from a script).")}
|
|
1442
|
-
${C.bold("seldon setup entire")} record ${C.gold("why")} each agent change was made (Entire), in this repo · --remote <name>
|
|
1443
|
-
${C.bold("seldon lane why")} <lane> a lane's recorded commits, and the prompt + transcript behind the newest
|
|
1444
1441
|
${C.bold("seldon install")} [ids…] install everything picked, or the named modules (no ids: the picker)
|
|
1445
1442
|
${C.bold("seldon uninstall")} ids… remove the named modules (global CLI / isolated venv)
|
|
1446
1443
|
${C.bold("seldon uninstall --all")} remove the whole stack (also drops ~/.seldon)
|
|
@@ -1508,56 +1505,28 @@ function laneCmd(verb, arg, flags) {
|
|
|
1508
1505
|
const r = startLane({ root, name: path.basename(root), task, harness: flags.agent || "claude" });
|
|
1509
1506
|
return r.ok ? console.log(C.green(`✓ started ${r.slug}`) + C.dim(` (${flags.agent || "claude"}) in ${root}`)) : fail(`could not start: ${r.error}`);
|
|
1510
1507
|
}
|
|
1511
|
-
if (!["stop", "resume", "open", "
|
|
1508
|
+
if (!["stop", "resume", "open", "rm"].includes(verb)) return fail('usage: seldon lane start [dir] --task "…" [--agent claude|codex|opencode] · seldon lane stop|resume|open|rm <key>');
|
|
1512
1509
|
const lane = arg && findLane(arg);
|
|
1513
1510
|
if (!lane) return fail(`no lane ${arg || ""} — see: seldon lanes`);
|
|
1514
|
-
if (verb === "why") return laneWhy(lane, fail);
|
|
1515
1511
|
if (verb === "open") {
|
|
1516
1512
|
const how = openCommand(lane);
|
|
1517
1513
|
if (how.why) return fail(`can't open ${lane.name}: ${how.why}`);
|
|
1518
1514
|
process.exitCode = spawnSync(how.bin, how.args, { stdio: "inherit", cwd: how.cwd }).status ?? 1;
|
|
1519
1515
|
return;
|
|
1520
1516
|
}
|
|
1517
|
+
if (verb === "rm") {
|
|
1518
|
+
const r = removeLane(lane, { force: !!flags.force });
|
|
1519
|
+
if (r.why) return fail(`can't remove ${lane.name}: ${r.why}`);
|
|
1520
|
+
if (!r.ok) return fail(`rm failed: ${r.error}`);
|
|
1521
|
+
return console.log(C.green(`✓ removed ${lane.name}`) + C.dim(!r.branch ? "" : r.branchDeleted ? ` (merged branch ${r.branch} deleted too)`
|
|
1522
|
+
: ` (kept branch ${r.branch}: git does not see it merged; if it was squash-merged: git branch -D ${r.branch})`));
|
|
1523
|
+
}
|
|
1521
1524
|
const r = verb === "stop" ? stopLane(lane) : resumeLane(lane);
|
|
1522
1525
|
if (r.why) return fail(`can't ${verb} ${lane.name}: ${r.why}`);
|
|
1523
1526
|
if (!r.ok) return fail(`${verb} failed: ${r.error}`);
|
|
1524
1527
|
console.log(C.green(`✓ ${verb === "stop" ? "stopped" : "resumed"} ${lane.name}`) + (r.fresh ? C.dim(" (new conversation, same task + worktree)") : ""));
|
|
1525
1528
|
}
|
|
1526
1529
|
|
|
1527
|
-
// `seldon lane why <key>` — the lane's commits that Entire recorded, then the newest one
|
|
1528
|
-
// explained: the prompt, the files and the transcript that produced it.
|
|
1529
|
-
function laneWhy(lane, fail) {
|
|
1530
|
-
if (!has("entire")) return fail("entire is not installed: brew install --cask entireio/tap/entire, then seldon setup entire");
|
|
1531
|
-
const cwd = lane.cwd;
|
|
1532
|
-
if (!cwd || !fs.existsSync(cwd)) return fail(`${lane.name}'s worktree is gone (${cwd || "unknown"})`);
|
|
1533
|
-
const git = (args) => spawnSync("git", ["-C", cwd, ...args], { encoding: "utf8" });
|
|
1534
|
-
const range = laneRange(git(["rev-parse", "--abbrev-ref", "origin/HEAD"]).stdout);
|
|
1535
|
-
const log = git(["log", range, `--format=${LOG_FORMAT}`]);
|
|
1536
|
-
if (log.status !== 0) return fail(`can't read ${lane.name}'s commits: ${log.stderr.trim()}`);
|
|
1537
|
-
const commits = parseCheckpointLog(log.stdout);
|
|
1538
|
-
if (!commits.length) { console.log(C.dim(`${lane.name}: no recorded commits in ${range} yet. Is Entire on here? seldon setup entire`)); return; }
|
|
1539
|
-
console.log(C.bold(lane.name) + C.dim(` ${commits.length} recorded commit(s), newest first`));
|
|
1540
|
-
for (const c of commits) console.log(` ${C.cyan(c.sha)} ${c.subject} ${C.dim(c.ids.join(", "))}`);
|
|
1541
|
-
console.log("");
|
|
1542
|
-
process.exitCode = spawnSync("entire", ["checkpoint", "explain", commits[0].ids[0]], { cwd, stdio: "inherit" }).status ?? 1;
|
|
1543
|
-
}
|
|
1544
|
-
|
|
1545
|
-
// `seldon setup entire [dir] [--remote <name>]` — record why each agent change was made, in
|
|
1546
|
-
// this project. Entire's own output lists the files to commit; until they are committed, lane
|
|
1547
|
-
// worktrees (which check out committed files only) do not get the agent hooks.
|
|
1548
|
-
function entireSetupCmd(dir, flags) {
|
|
1549
|
-
const fail = (msg) => { console.log(C.red(msg)); process.exitCode = 1; };
|
|
1550
|
-
if (!has("entire")) return fail("entire is not installed: brew install --cask entireio/tap/entire (or curl -fsSL https://entire.com/install.sh | bash)");
|
|
1551
|
-
const root = projectRoot(path.resolve(dir || "."));
|
|
1552
|
-
if (!root) return fail("not inside a git repository");
|
|
1553
|
-
const remote = typeof flags.remote === "string" ? flags.remote : "origin";
|
|
1554
|
-
for (const [bin, args] of enableSteps({ remote, harnesses: HARNESSES.filter((h) => has(h)) })) {
|
|
1555
|
-
if (spawnSync(bin, args, { cwd: root, stdio: "inherit" }).status !== 0) return fail(`${bin} ${args.join(" ")} failed`);
|
|
1556
|
-
}
|
|
1557
|
-
console.log("\n" + C.gold("before you push: ") + `checkpoints hold your agents' transcripts and go to ${C.bold(remote)}. If that repository is public, so are they; secret redaction is best effort.`);
|
|
1558
|
-
console.log(C.dim(" commit the files Entire listed, so every new lane worktree gets the hooks · then: seldon lane why <lane>"));
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
1530
|
// `seldon machines` — the other computers the panel shows (bifrost's realms, one list).
|
|
1562
1531
|
function machinesCmd(verb, name, target) {
|
|
1563
1532
|
if (verb === "add") {
|
|
@@ -1594,8 +1563,7 @@ function stableSeldonBin() {
|
|
|
1594
1563
|
// `seldon setup [codex|opencode] [--remove]` — install the reporter into each harness.
|
|
1595
1564
|
const CODEX_HOOKS = path.join(process.env.HOME, ".codex", "hooks.json");
|
|
1596
1565
|
const OPENCODE_PLUGIN = path.join(process.env.HOME, ".config", "opencode", "plugins", "seldon.js");
|
|
1597
|
-
function setupCmd(which, flags
|
|
1598
|
-
if (which === "entire") return entireSetupCmd(dir, flags);
|
|
1566
|
+
function setupCmd(which, flags) {
|
|
1599
1567
|
const targets = which ? [which] : ["codex", "opencode"].filter((h) => has(h) || flags.remove);
|
|
1600
1568
|
if (!targets.length) { console.log(C.dim("neither codex nor opencode is installed — Claude needs no setup")); return; }
|
|
1601
1569
|
// The `seldon` on PATH (e.g. ~/Library/pnpm/bin/seldon), not the file running now: that one
|
|
@@ -1739,7 +1707,7 @@ const ids = tokens.filter((id) => byId[id]); // only the valid module
|
|
|
1739
1707
|
if (cmd === "lanes") return lanesCmd(flags);
|
|
1740
1708
|
if (cmd === "machines") return machinesCmd(tokens[0], tokens[1], tokens[2]);
|
|
1741
1709
|
if (cmd === "lane") return laneCmd(tokens[0], tokens[1], flags);
|
|
1742
|
-
if (cmd === "setup") return setupCmd(tokens[0], flags
|
|
1710
|
+
if (cmd === "setup") return setupCmd(tokens[0], flags);
|
|
1743
1711
|
if (cmd === "panel" || cmd === "board") return panel();
|
|
1744
1712
|
if (cmd && cmd !== "install") { help(); process.exitCode = 1; return; }
|
|
1745
1713
|
if (cmd === "install") return install_picker({ dev }); // `install` with no ids
|
package/lib/actions.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
// What you can do to a lane, in one place: start, stop, resume. The panel calls these, and so
|
|
1
|
+
// What you can do to a lane, in one place: start, stop, resume, remove. The panel calls these, and so
|
|
2
2
|
// does `seldon lane …` — which is also how the panel acts on another machine (it runs
|
|
3
3
|
// `ssh <machine> seldon lane …`). One implementation, so the two can never disagree.
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
import { execFileSync } from "node:child_process";
|
|
7
7
|
import {
|
|
8
|
-
readLanes, runSteps, run, harnessBins, recordLane, markLane, SELDON_HOME,
|
|
8
|
+
readLanes, runSteps, run, harnessBins, recordLane, markLane, forgetLane, projectRoot, SELDON_HOME,
|
|
9
9
|
} from "./agents.mjs";
|
|
10
|
-
import { startCommands, resumeCommands, stopCommand, slugify, uniqueSlug, HARNESSES } from "./lanes.mjs";
|
|
10
|
+
import { startCommands, resumeCommands, stopCommand, removeCommands, slugify, uniqueSlug, HARNESSES } from "./lanes.mjs";
|
|
11
11
|
|
|
12
12
|
const branchExists = (root, ref) => {
|
|
13
13
|
try { execFileSync("git", ["-C", root, "rev-parse", "--verify", "--quiet", `refs/heads/${ref}`], { stdio: "ignore" }); return true; } catch { return false; }
|
|
@@ -45,6 +45,18 @@ export function resumeLane(lane) {
|
|
|
45
45
|
return { ...r, fresh: !!how.fresh };
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
// Worktree gone, branch deleted only if merged. Says which branch it kept, and why.
|
|
49
|
+
export function removeLane(lane, { force = false } = {}) {
|
|
50
|
+
const git = (...args) => { try { return execFileSync("git", ["-C", lane.cwd, ...args], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim(); } catch { return null; } };
|
|
51
|
+
const how = removeCommands(lane, { root: projectRoot(lane.cwd), branch: git("rev-parse", "--abbrev-ref", "HEAD"), dirty: !!git("status", "--porcelain"), force });
|
|
52
|
+
if (how.why) return { ok: false, why: how.why };
|
|
53
|
+
const r = runSteps(how.cmds);
|
|
54
|
+
if (!r.ok) return r;
|
|
55
|
+
if (lane.tmuxSession && lane.harness !== "claude") forgetLane(lane.tmuxSession);
|
|
56
|
+
const branch = how.branch?.args.at(-1) ?? null;
|
|
57
|
+
return { ok: true, branch, branchDeleted: !!how.branch && run(how.branch, { quiet: true }).ok };
|
|
58
|
+
}
|
|
59
|
+
|
|
48
60
|
export const allLanes = () => readLanes().flatMap((g) => g.lanes);
|
|
49
61
|
// By key, or by name when exactly one lane has it (keys are long; names are what you see).
|
|
50
62
|
export function findLane(ref) {
|
package/lib/agents.mjs
CHANGED
|
@@ -67,6 +67,11 @@ export function markLane(session, patch) {
|
|
|
67
67
|
writeLanes(readJson(LANES_FILE, []).map((e) => (e.session === session ? { ...e, ...patch } : e)));
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
// Removed: the lane is gone for good, so it is not listed as stopped either.
|
|
71
|
+
export function forgetLane(session) {
|
|
72
|
+
writeLanes(readJson(LANES_FILE, []).filter((e) => e.session !== session));
|
|
73
|
+
}
|
|
74
|
+
|
|
70
75
|
// tmux session -> { harness, task, startedAt }: seldon's lanes plus apiary's Codex agents.
|
|
71
76
|
export function knownSessions() {
|
|
72
77
|
const known = {};
|
package/lib/lanes.mjs
CHANGED
|
@@ -233,6 +233,20 @@ export function resumeCommands(lane, { bins = {}, env = {} } = {}) {
|
|
|
233
233
|
};
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
+
// ---- removing a finished lane ------------------------------------------------------
|
|
237
|
+
// What a done lane leaves behind is a worktree and a branch. rm takes the worktree, and the
|
|
238
|
+
// branch only when git can see it is merged (`git branch -d` refuses otherwise). A squash-merged
|
|
239
|
+
// branch looks unmerged to git, so it is kept and named, never force-deleted.
|
|
240
|
+
export function removeCommands(lane, { root, branch, dirty = false, force = false } = {}) {
|
|
241
|
+
if (!["stopped", "failed"].includes(lane.state)) return { why: `it is ${lane.state}, stop it first` };
|
|
242
|
+
if (!root || !lane.cwd || lane.cwd.replace(/\/+$/, "") === root.replace(/\/+$/, "")) return { why: "it works in the repo itself, not in a worktree of its own" };
|
|
243
|
+
if (dirty && !force) return { why: "its worktree has uncommitted changes: commit them, or --force to throw them away" };
|
|
244
|
+
return {
|
|
245
|
+
cmds: [{ bin: "git", args: ["-C", root, "worktree", "remove", ...(force ? ["--force"] : []), lane.cwd], quiet: true }],
|
|
246
|
+
branch: branch && branch !== "HEAD" ? { bin: "git", args: ["-C", root, "branch", "-d", branch], quiet: true } : null,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
|
|
236
250
|
// ---- telling the human ----------------------------------------------------------------
|
|
237
251
|
// What changed since the last look that a person should hear about: an agent that starts
|
|
238
252
|
// waiting on them, fails, or finishes. Only TRANSITIONS — a lane that stays blocked is not
|
package/package.json
CHANGED
package/lib/entire.mjs
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// Entire: why each lane's agent made each change.
|
|
2
|
-
//
|
|
3
|
-
// Entire (https://entire.com, `entire` CLI, MIT) hooks into the agent and into git. When an agent
|
|
4
|
-
// commits, it links the commit to the agent session that produced it with an
|
|
5
|
-
// `Entire-Checkpoint: <id>` trailer, and keeps the prompt, the redacted transcript, the files
|
|
6
|
-
// touched and the token count under refs/entire/checkpoints/*, pushed alongside your branches.
|
|
7
|
-
// seldon does not store any of it: it turns it on for a project and reads it back per lane.
|
|
8
|
-
//
|
|
9
|
-
// Pure, like lanes.mjs: callers run the commands and pass the output in.
|
|
10
|
-
|
|
11
|
-
export const TRAILER = "Entire-Checkpoint";
|
|
12
|
-
|
|
13
|
-
// seldon's harness names → Entire's agent names.
|
|
14
|
-
export const ENTIRE_AGENT = { claude: "claude-code", codex: "codex", opencode: "opencode" };
|
|
15
|
-
|
|
16
|
-
// One line per commit: short sha, subject, checkpoint ids (comma-separated, usually one).
|
|
17
|
-
export const LOG_FORMAT = `%h%x1f%s%x1f%(trailers:key=${TRAILER},valueonly,separator=%x2C)`;
|
|
18
|
-
|
|
19
|
-
/** Commits on a lane that carry a checkpoint, newest first: [{ sha, subject, ids }]. */
|
|
20
|
-
export function parseCheckpointLog(text) {
|
|
21
|
-
return String(text || "").split("\n").filter(Boolean).map((line) => {
|
|
22
|
-
const [sha, subject = "", ids = ""] = line.split("\x1f");
|
|
23
|
-
return { sha, subject, ids: ids.split(",").map((s) => s.trim()).filter(Boolean) };
|
|
24
|
-
}).filter((c) => c.ids.length);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* The commands that turn Entire on for a project: Claude Code first (it is the one `enable`
|
|
29
|
-
* configures), then one `agent add` per other harness installed here. Checkpoints go to
|
|
30
|
-
* `remote` only; telemetry stays off.
|
|
31
|
-
*/
|
|
32
|
-
export function enableSteps({ remote = "origin", harnesses = [] } = {}) {
|
|
33
|
-
const steps = [["entire", ["enable", "--agent", ENTIRE_AGENT.claude, "--telemetry=false", "--checkpoint-push-remote", remote]]];
|
|
34
|
-
for (const h of harnesses) if (h !== "claude" && ENTIRE_AGENT[h]) steps.push(["entire", ["agent", "add", ENTIRE_AGENT[h]]]);
|
|
35
|
-
return steps;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* The commits a lane added: everything on its HEAD that the project's default branch lacks.
|
|
40
|
-
* `defaultRef` is what `git rev-parse --abbrev-ref origin/HEAD` printed (e.g. "origin/main"),
|
|
41
|
-
* or empty when the clone has no remote HEAD.
|
|
42
|
-
*/
|
|
43
|
-
export function laneRange(defaultRef) {
|
|
44
|
-
const ref = String(defaultRef || "").trim();
|
|
45
|
-
return `${ref && ref !== "origin/HEAD" ? ref : "main"}..HEAD`;
|
|
46
|
-
}
|