durable-chat 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/LICENSES/mcp-sdk-MIT.txt +21 -0
- package/LICENSES/pi-MIT.txt +21 -0
- package/LICENSES/typebox-MIT.txt +23 -0
- package/LICENSES/yaml-ISC.txt +13 -0
- package/README.md +794 -2
- package/THIRD_PARTY_NOTICES.md +46 -0
- package/dist/agent-instructions.js +176 -0
- package/dist/auth.js +91 -0
- package/dist/chat.js +121 -0
- package/dist/cli.js +519 -0
- package/dist/codemode.js +23 -0
- package/dist/commands.js +227 -0
- package/dist/config-commands.js +142 -0
- package/dist/config.js +567 -0
- package/dist/context-usage.js +48 -0
- package/dist/existing-session.js +52 -0
- package/dist/faux.js +89 -0
- package/dist/forks.js +33 -0
- package/dist/format.js +144 -0
- package/dist/handoff.js +56 -0
- package/dist/harness.js +446 -0
- package/dist/images.js +64 -0
- package/dist/jobs.js +274 -0
- package/dist/mcp.js +231 -0
- package/dist/models.js +64 -0
- package/dist/reboot.js +70 -0
- package/dist/reminders.js +120 -0
- package/dist/rollback.js +72 -0
- package/dist/state.js +64 -0
- package/dist/tags.js +44 -0
- package/dist/tasks.js +466 -0
- package/dist/tool.js +205 -0
- package/dist/tui/app.js +1750 -0
- package/dist/tui/browser.js +19 -0
- package/dist/tui/composer.js +47 -0
- package/dist/tui/dialog.js +39 -0
- package/dist/tui/format.js +223 -0
- package/dist/tui/main.js +83 -0
- package/dist/tui/selection.js +161 -0
- package/dist/tui/state.js +98 -0
- package/dist/tui/transcript.js +151 -0
- package/dist/watch.js +134 -0
- package/dist/workspaces.js +106 -0
- package/package.json +57 -4
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { formatEntry, formatLive } from "./format.js";
|
|
2
|
+
import { estimateContextTokens } from "../context-usage.js";
|
|
3
|
+
const INITIAL_ENTRIES = 80;
|
|
4
|
+
const OLDER_ENTRIES = 60;
|
|
5
|
+
const MAX_ENTRIES = 1200;
|
|
6
|
+
/**
|
|
7
|
+
* One conversation's display history. The watch delivers the newest window; the
|
|
8
|
+
* class merges it with pages loaded above it, so scrolling up survives the window
|
|
9
|
+
* dropping old entries.
|
|
10
|
+
*/
|
|
11
|
+
export class Transcript {
|
|
12
|
+
conversation;
|
|
13
|
+
entries = [];
|
|
14
|
+
live;
|
|
15
|
+
inbox = 0;
|
|
16
|
+
usage;
|
|
17
|
+
contextTokens;
|
|
18
|
+
contextWindow = 0;
|
|
19
|
+
hasOlder = false;
|
|
20
|
+
loadingOlder = false;
|
|
21
|
+
context;
|
|
22
|
+
meterTimer;
|
|
23
|
+
cursor;
|
|
24
|
+
watch;
|
|
25
|
+
version = 0;
|
|
26
|
+
cache;
|
|
27
|
+
onUpdate = () => undefined;
|
|
28
|
+
constructor(conversation) {
|
|
29
|
+
this.conversation = conversation;
|
|
30
|
+
}
|
|
31
|
+
async start(context, contextWindow) {
|
|
32
|
+
this.context = context;
|
|
33
|
+
this.contextWindow = contextWindow;
|
|
34
|
+
const page = await this.conversation.entries({ order: "descending" }, INITIAL_ENTRIES, undefined, context);
|
|
35
|
+
this.entries = [...page.items].reverse();
|
|
36
|
+
this.cursor = page.next;
|
|
37
|
+
this.hasOlder = page.next !== undefined;
|
|
38
|
+
this.watch = await this.conversation.watch(context, { min: 40, max: 100 });
|
|
39
|
+
this.watch.start(async (call) => {
|
|
40
|
+
if (call.kind !== "value")
|
|
41
|
+
return;
|
|
42
|
+
this.merge(call.value);
|
|
43
|
+
this.onUpdate();
|
|
44
|
+
});
|
|
45
|
+
this.merge(this.watch.value);
|
|
46
|
+
await this.refreshMeter();
|
|
47
|
+
}
|
|
48
|
+
scheduleMeter() {
|
|
49
|
+
if (this.context === undefined)
|
|
50
|
+
return;
|
|
51
|
+
if (this.meterTimer !== undefined)
|
|
52
|
+
clearTimeout(this.meterTimer);
|
|
53
|
+
this.meterTimer = setTimeout(() => {
|
|
54
|
+
this.meterTimer = undefined;
|
|
55
|
+
void this.refreshMeter();
|
|
56
|
+
}, 200);
|
|
57
|
+
this.meterTimer.unref?.();
|
|
58
|
+
}
|
|
59
|
+
async refreshMeter() {
|
|
60
|
+
const context = this.context;
|
|
61
|
+
if (context === undefined)
|
|
62
|
+
return;
|
|
63
|
+
try {
|
|
64
|
+
const view = await this.conversation.context(context);
|
|
65
|
+
this.contextTokens = estimateContextTokens(view);
|
|
66
|
+
this.onUpdate();
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// A transient read failure leaves the previous estimate in place.
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
merge(view) {
|
|
73
|
+
const beforeLength = this.entries.length;
|
|
74
|
+
const beforeLast = this.entries.at(-1)?.id;
|
|
75
|
+
const byId = new Map();
|
|
76
|
+
for (const entry of this.entries)
|
|
77
|
+
byId.set(Number(entry.id), entry);
|
|
78
|
+
for (const entry of view.entries)
|
|
79
|
+
byId.set(Number(entry.id), entry);
|
|
80
|
+
this.entries = [...byId.values()].sort((a, b) => Number(a.id) - Number(b.id));
|
|
81
|
+
if (this.entries.length > MAX_ENTRIES)
|
|
82
|
+
this.entries = this.entries.slice(-MAX_ENTRIES);
|
|
83
|
+
const docs = view.docs;
|
|
84
|
+
this.live = docs["pi.live"];
|
|
85
|
+
const inbox = docs["pi.inbox"];
|
|
86
|
+
this.inbox = Array.isArray(inbox?.items) ? inbox.items.length : 0;
|
|
87
|
+
this.usage = docs["pi.usage"];
|
|
88
|
+
if (this.entries.length !== beforeLength || this.entries.at(-1)?.id !== beforeLast) {
|
|
89
|
+
this.touch();
|
|
90
|
+
this.scheduleMeter();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
touch() {
|
|
94
|
+
this.version++;
|
|
95
|
+
this.cache = undefined;
|
|
96
|
+
}
|
|
97
|
+
async older(context) {
|
|
98
|
+
if (this.cursor === undefined || this.loadingOlder)
|
|
99
|
+
return false;
|
|
100
|
+
this.loadingOlder = true;
|
|
101
|
+
try {
|
|
102
|
+
const page = await this.conversation.entries({ order: "descending" }, OLDER_ENTRIES, this.cursor, context);
|
|
103
|
+
const byId = new Map();
|
|
104
|
+
for (const entry of page.items)
|
|
105
|
+
byId.set(Number(entry.id), entry);
|
|
106
|
+
for (const entry of this.entries)
|
|
107
|
+
byId.set(Number(entry.id), entry);
|
|
108
|
+
this.entries = [...byId.values()].sort((a, b) => Number(a.id) - Number(b.id));
|
|
109
|
+
this.cursor = page.next;
|
|
110
|
+
this.hasOlder = page.next !== undefined;
|
|
111
|
+
this.touch();
|
|
112
|
+
this.onUpdate();
|
|
113
|
+
return page.items.length > 0;
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
this.loadingOlder = false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/** Committed transcript lines for one width. */
|
|
120
|
+
lines(width, toolsExpanded) {
|
|
121
|
+
const cached = this.cache;
|
|
122
|
+
if (cached !== undefined && cached.version === this.version && cached.width === width && cached.tools === toolsExpanded) {
|
|
123
|
+
return cached.lines;
|
|
124
|
+
}
|
|
125
|
+
const lines = [];
|
|
126
|
+
for (const entry of this.entries) {
|
|
127
|
+
const formatted = formatEntry(entry, { width, toolsExpanded });
|
|
128
|
+
if (formatted.length > 0) {
|
|
129
|
+
lines.push(...formatted, "");
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
this.cache = { version: this.version, width, tools: toolsExpanded, lines };
|
|
133
|
+
return lines;
|
|
134
|
+
}
|
|
135
|
+
liveLines(width) {
|
|
136
|
+
return formatLive(this.live, width);
|
|
137
|
+
}
|
|
138
|
+
get modelCount() {
|
|
139
|
+
const usage = this.usage;
|
|
140
|
+
if (usage === undefined)
|
|
141
|
+
return 0;
|
|
142
|
+
return Object.keys(usage.models).length;
|
|
143
|
+
}
|
|
144
|
+
async stop() {
|
|
145
|
+
if (this.meterTimer !== undefined)
|
|
146
|
+
clearTimeout(this.meterTimer);
|
|
147
|
+
this.meterTimer = undefined;
|
|
148
|
+
await this.watch?.stop();
|
|
149
|
+
this.watch = undefined;
|
|
150
|
+
}
|
|
151
|
+
}
|
package/dist/watch.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { formatLiveJobLine } from "./format.js";
|
|
2
|
+
import { scanJobs } from "./jobs.js";
|
|
3
|
+
import { JOB_KIND } from "./tasks.js";
|
|
4
|
+
function nodeLine(node) {
|
|
5
|
+
const state = node.state;
|
|
6
|
+
const detail = state.status === "waiting"
|
|
7
|
+
? ` waiting on ${state.on.join(",")}`
|
|
8
|
+
: state.status === "sleeping"
|
|
9
|
+
? ` until ${new Date(state.until).toISOString().slice(11, 19)}`
|
|
10
|
+
: "";
|
|
11
|
+
const blocked = node.blocked === undefined ? "" : ` BLOCKED(${node.blocked})`;
|
|
12
|
+
return `#${node.id} ${node.kind} ${state.status}${detail}${blocked}`;
|
|
13
|
+
}
|
|
14
|
+
function jobNodes(graph, ids) {
|
|
15
|
+
return Object.values(graph.tasks)
|
|
16
|
+
.filter((node) => node.kind === JOB_KIND && (ids === undefined || ids.has(Number(node.id))))
|
|
17
|
+
.sort((a, b) => Number(a.id) - Number(b.id));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Follow background jobs through the task graph. The graph watch is the source of
|
|
21
|
+
* completion; the interval only repaints elapsed time.
|
|
22
|
+
*/
|
|
23
|
+
export async function followJobs(runtime, options = {}) {
|
|
24
|
+
const context = runtime.context;
|
|
25
|
+
const ids = options.ids === undefined ? undefined : new Set(options.ids);
|
|
26
|
+
runtime.harness.resume();
|
|
27
|
+
const initial = await runtime.harness.inspect(context);
|
|
28
|
+
const initialJobs = initial.tasks.filter((task) => task.record.kind === JOB_KIND && (ids === undefined || ids.has(Number(task.record.id))));
|
|
29
|
+
if (initialJobs.length === 0 && options.follow !== true) {
|
|
30
|
+
process.stdout.write("No live jobs.\n");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const graph = await runtime.harness.watchTaskGraph(context);
|
|
34
|
+
const tty = process.stdout.isTTY === true;
|
|
35
|
+
const done = Promise.withResolvers();
|
|
36
|
+
let last = "";
|
|
37
|
+
let lastSignature = "<initial>";
|
|
38
|
+
let records = await scanJobs(runtime.harness, context).catch(() => []);
|
|
39
|
+
let recordsById = new Map(records.map((record) => [Number(record.id), record]));
|
|
40
|
+
let refreshing = false;
|
|
41
|
+
const paint = () => {
|
|
42
|
+
const nodes = jobNodes(graph.value, ids);
|
|
43
|
+
const lines = [];
|
|
44
|
+
if (nodes.length === 0) {
|
|
45
|
+
lines.push("No live jobs.");
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
lines.push(`Durable jobs — ${nodes.length} live`);
|
|
49
|
+
for (const node of nodes) {
|
|
50
|
+
const record = recordsById.get(Number(node.id));
|
|
51
|
+
lines.push(record === undefined ? nodeLine(node) : `${formatLiveJobLine(record, Date.now())}${node.blocked === undefined ? "" : ` BLOCKED(${node.blocked})`}`);
|
|
52
|
+
}
|
|
53
|
+
if (options.follow === true)
|
|
54
|
+
lines.push("", "Following. Ctrl-C to stop (work keeps its durable state).");
|
|
55
|
+
}
|
|
56
|
+
const text = lines.join("\n");
|
|
57
|
+
const signature = nodes.map((node) => `${node.id}:${node.state.status}:${node.blocked ?? ""}`).join("|");
|
|
58
|
+
if (tty) {
|
|
59
|
+
if (text === last)
|
|
60
|
+
return;
|
|
61
|
+
last = text;
|
|
62
|
+
process.stdout.write(`\x1b[H\x1b[2J${text}\n`);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
// Piped output: print on a status change, not on every elapsed-time repaint.
|
|
66
|
+
if (signature === lastSignature)
|
|
67
|
+
return;
|
|
68
|
+
lastSignature = signature;
|
|
69
|
+
process.stdout.write(`${text}\n`);
|
|
70
|
+
};
|
|
71
|
+
const check = (graphValue) => {
|
|
72
|
+
if (options.follow === true)
|
|
73
|
+
return;
|
|
74
|
+
const nodes = jobNodes(graphValue, ids);
|
|
75
|
+
if (nodes.length === 0) {
|
|
76
|
+
done.resolve();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (nodes.every((node) => node.blocked !== undefined)) {
|
|
80
|
+
process.stderr.write("Every remaining job is blocked; stopping the wait.\n");
|
|
81
|
+
done.resolve();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const refreshRecords = async () => {
|
|
85
|
+
if (refreshing)
|
|
86
|
+
return;
|
|
87
|
+
refreshing = true;
|
|
88
|
+
try {
|
|
89
|
+
records = await scanJobs(runtime.harness, context).catch(() => records);
|
|
90
|
+
recordsById = new Map(records.map((record) => [Number(record.id), record]));
|
|
91
|
+
paint();
|
|
92
|
+
}
|
|
93
|
+
finally {
|
|
94
|
+
refreshing = false;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
graph.start(async (call) => {
|
|
98
|
+
if (call.kind !== "value")
|
|
99
|
+
return;
|
|
100
|
+
// The graph watch reports status; a task record is fetched only when a new
|
|
101
|
+
// node appears, for its brief. No periodic store scans.
|
|
102
|
+
const missing = jobNodes(call.value, ids).some((node) => !recordsById.has(Number(node.id)));
|
|
103
|
+
if (missing)
|
|
104
|
+
await refreshRecords();
|
|
105
|
+
else
|
|
106
|
+
paint();
|
|
107
|
+
check(call.value);
|
|
108
|
+
});
|
|
109
|
+
paint();
|
|
110
|
+
check(graph.value);
|
|
111
|
+
// Keep the wait alive and repaint ages without reading the store.
|
|
112
|
+
const interval = setInterval(() => {
|
|
113
|
+
if (tty)
|
|
114
|
+
paint();
|
|
115
|
+
}, 1000);
|
|
116
|
+
const stop = () => done.resolve();
|
|
117
|
+
options.signal?.addEventListener("abort", stop, { once: true });
|
|
118
|
+
if (options.signal?.aborted === true)
|
|
119
|
+
done.resolve();
|
|
120
|
+
try {
|
|
121
|
+
await done.promise;
|
|
122
|
+
}
|
|
123
|
+
finally {
|
|
124
|
+
clearInterval(interval);
|
|
125
|
+
options.signal?.removeEventListener("abort", stop);
|
|
126
|
+
await graph.stop();
|
|
127
|
+
if (tty)
|
|
128
|
+
process.stdout.write("\n");
|
|
129
|
+
const finished = await scanJobs(runtime.harness, context).catch(() => []);
|
|
130
|
+
if (finished.length > 0) {
|
|
131
|
+
process.stdout.write(`${finished.filter((record) => record.state.status === "terminal").length} job(s) terminal, ${finished.filter((record) => record.state.status !== "terminal").length} live.\n`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { lstat, mkdir, realpath, stat } from "node:fs/promises";
|
|
4
|
+
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
5
|
+
import { promisify } from "node:util";
|
|
6
|
+
import { defineDoc } from "@earendil-works/pi-durable";
|
|
7
|
+
import { NodeExecutionEnv } from "@earendil-works/pi-durable/env/node";
|
|
8
|
+
const exec = promisify(execFile);
|
|
9
|
+
/** Conversation-scoped so the workspace assignment outlives a completed job task. */
|
|
10
|
+
export const JobWorkspaceDoc = defineDoc({
|
|
11
|
+
kind: "durable-chat.workspace", version: 1, scope: "conversation", history: "latest", fork: "initial",
|
|
12
|
+
initial: () => ({}), checkpointWhen: () => false,
|
|
13
|
+
});
|
|
14
|
+
export async function jobEnvironment(target, context, fallback) {
|
|
15
|
+
const assignment = await target.read.snapshot(JobWorkspaceDoc, target.conversationId, context);
|
|
16
|
+
if (assignment?.workspace !== undefined) {
|
|
17
|
+
if (target.cwd !== assignment.workspace.cwd)
|
|
18
|
+
throw new Error("The job cwd differs from its saved workspace assignment.");
|
|
19
|
+
await ensureWorkspace(assignment.workspace, context.abortSignal);
|
|
20
|
+
}
|
|
21
|
+
return new NodeExecutionEnv({ cwd: target.cwd ?? fallback });
|
|
22
|
+
}
|
|
23
|
+
async function git(cwd, args, signal) {
|
|
24
|
+
const result = await exec("git", ["-c", "core.hooksPath=/dev/null", "-C", cwd, ...args], {
|
|
25
|
+
encoding: "utf8", maxBuffer: 8 * 1024 * 1024, timeout: 120_000,
|
|
26
|
+
env: { ...Object.fromEntries(Object.entries(process.env).filter(([name]) => !name.startsWith("GIT_"))), GIT_OPTIONAL_LOCKS: "0" },
|
|
27
|
+
...(signal === undefined ? {} : { signal }),
|
|
28
|
+
});
|
|
29
|
+
return result.stdout.replace(/\r?\n$/, "");
|
|
30
|
+
}
|
|
31
|
+
/** Read-only planning. The durable job stores this plan before any worktree is created. */
|
|
32
|
+
export async function planWorkspace(cwd, kind, signal) {
|
|
33
|
+
const directory = await realpath(cwd);
|
|
34
|
+
if (!(await stat(directory)).isDirectory())
|
|
35
|
+
throw new Error(`Workspace is not a directory: ${cwd}`);
|
|
36
|
+
if (kind === "shared")
|
|
37
|
+
return { kind, cwd: directory };
|
|
38
|
+
const repository = await realpath(await git(directory, ["rev-parse", "--show-toplevel"], signal));
|
|
39
|
+
const baseCommit = await git(repository, ["rev-parse", "HEAD^{commit}"], signal);
|
|
40
|
+
if ((await git(repository, ["status", "--porcelain=v1", "--untracked-files=normal", "--ignore-submodules=none"], signal)).length > 0) {
|
|
41
|
+
throw new Error("Worktree forks require a clean source checkout, including untracked files. Commit the intended base or select a shared workspace.");
|
|
42
|
+
}
|
|
43
|
+
if (await git(repository, ["rev-parse", "HEAD^{commit}"], signal) !== baseCommit)
|
|
44
|
+
throw new Error("Source HEAD changed while planning the worktree; retry.");
|
|
45
|
+
const subdirectory = relative(repository, directory);
|
|
46
|
+
if (isAbsolute(subdirectory) || subdirectory === ".." || subdirectory.startsWith("../"))
|
|
47
|
+
throw new Error("The source directory is outside its Git repository.");
|
|
48
|
+
const common = await realpath(resolve(repository, await git(repository, ["rev-parse", "--git-common-dir"], signal)));
|
|
49
|
+
const token = randomUUID();
|
|
50
|
+
const path = join(common, "dchat-worktrees", token);
|
|
51
|
+
return { kind, repository, gitDirectory: common, baseCommit, path, branch: `dchat/${token}`, cwd: join(path, subdirectory) };
|
|
52
|
+
}
|
|
53
|
+
async function exists(path) {
|
|
54
|
+
try {
|
|
55
|
+
await lstat(path);
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (error.code === "ENOENT")
|
|
60
|
+
return false;
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async function registered(workspace, signal) {
|
|
65
|
+
const listing = await git(workspace.gitDirectory, ["worktree", "list", "--porcelain", "-z"], signal);
|
|
66
|
+
for (const block of listing.split("\0\0")) {
|
|
67
|
+
const fields = block.split("\0");
|
|
68
|
+
if (!fields.includes(`worktree ${workspace.path}`))
|
|
69
|
+
continue;
|
|
70
|
+
if (fields.some((field) => field === "locked" || field.startsWith("locked ")))
|
|
71
|
+
throw new Error(`The saved worktree is locked or setup is incomplete: ${workspace.path}. Inspect it before continuing.`);
|
|
72
|
+
if (!fields.includes(`branch refs/heads/${workspace.branch}`))
|
|
73
|
+
throw new Error(`Worktree branch differs from its saved job assignment: ${workspace.path}`);
|
|
74
|
+
if (fields.some((field) => field.startsWith("prunable")) || !(await exists(workspace.cwd))) {
|
|
75
|
+
throw new Error(`The saved worktree is missing or incomplete: ${workspace.path}. Restore it before continuing this job.`);
|
|
76
|
+
}
|
|
77
|
+
const root = await realpath(await git(workspace.cwd, ["rev-parse", "--show-toplevel"], signal));
|
|
78
|
+
const common = await realpath(resolve(workspace.cwd, await git(workspace.cwd, ["rev-parse", "--git-common-dir"], signal)));
|
|
79
|
+
if (root !== workspace.path || common !== workspace.gitDirectory)
|
|
80
|
+
throw new Error(`The saved job directory belongs to another repository: ${workspace.cwd}`);
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
/** Reconcile an interrupted setup without resetting, deleting, or overwriting any existing work. */
|
|
86
|
+
export async function ensureWorkspace(workspace, signal) {
|
|
87
|
+
if (workspace.kind === "shared") {
|
|
88
|
+
if (!(await stat(workspace.cwd)).isDirectory())
|
|
89
|
+
throw new Error(`Shared workspace is not a directory: ${workspace.cwd}`);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (await registered(workspace, signal))
|
|
93
|
+
return;
|
|
94
|
+
if (await exists(workspace.path))
|
|
95
|
+
throw new Error(`Refusing to overwrite an unregistered worktree directory: ${workspace.path}`);
|
|
96
|
+
const branches = await git(workspace.gitDirectory, ["for-each-ref", "--format=%(refname)", `refs/heads/${workspace.branch}`], signal);
|
|
97
|
+
if (branches.length > 0 && await git(workspace.gitDirectory, ["rev-parse", `refs/heads/${workspace.branch}`], signal) !== workspace.baseCommit) {
|
|
98
|
+
throw new Error(`Refusing to reuse a modified branch without its saved worktree: ${workspace.branch}`);
|
|
99
|
+
}
|
|
100
|
+
await mkdir(resolve(workspace.path, ".."), { recursive: true });
|
|
101
|
+
await git(workspace.gitDirectory, branches.length > 0
|
|
102
|
+
? ["worktree", "add", "--", workspace.path, workspace.branch]
|
|
103
|
+
: ["worktree", "add", "-b", workspace.branch, "--", workspace.path, workspace.baseCommit], signal);
|
|
104
|
+
if (!(await registered(workspace, signal)))
|
|
105
|
+
throw new Error(`Git did not register the assigned worktree: ${workspace.path}`);
|
|
106
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "durable-chat",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Terminal coordinator for durable pi agents with a TUI dashboard, background jobs, and configurable local inference",
|
|
5
|
+
"main": "dist/cli.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "node dist/cli.js",
|
|
8
|
+
"check": "tsc --noEmit",
|
|
9
|
+
"test": "node --test test/*.test.ts",
|
|
10
|
+
"build": "node scripts/build.mjs",
|
|
11
|
+
"prepack": "npm run build",
|
|
12
|
+
"test:package": "npm run build && node --test test/package-install.test.mjs",
|
|
13
|
+
"dev": "node src/cli.ts"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"cli",
|
|
17
|
+
"agents",
|
|
18
|
+
"terminal",
|
|
19
|
+
"durable",
|
|
20
|
+
"tui"
|
|
21
|
+
],
|
|
22
|
+
"type": "module",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@earendil-works/chord": "1.5.0",
|
|
25
|
+
"@earendil-works/pi-ai": "1.5.0",
|
|
26
|
+
"@earendil-works/pi-codemode": "1.5.0",
|
|
27
|
+
"@earendil-works/pi-durable": "1.5.0",
|
|
28
|
+
"@earendil-works/pi-mcp": "1.5.0",
|
|
29
|
+
"@earendil-works/pi-schema": "1.5.0",
|
|
30
|
+
"@earendil-works/pi-tui": "1.5.0",
|
|
31
|
+
"yaml": "2.9.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "26.6.6",
|
|
35
|
+
"typescript": "7.0.2"
|
|
36
|
+
},
|
|
37
|
+
"bin": {
|
|
38
|
+
"dchat": "./dist/cli.js",
|
|
39
|
+
"durable-chat": "./dist/cli.js"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=22.19.0"
|
|
43
|
+
},
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "git+https://github.com/thorinside/durable-chat.git"
|
|
48
|
+
},
|
|
49
|
+
"homepage": "https://github.com/thorinside/durable-chat#readme",
|
|
50
|
+
"bugs": {
|
|
51
|
+
"url": "https://github.com/thorinside/durable-chat/issues"
|
|
52
|
+
},
|
|
53
|
+
"files": [
|
|
54
|
+
"dist/",
|
|
55
|
+
"LICENSE",
|
|
56
|
+
"LICENSES/",
|
|
57
|
+
"THIRD_PARTY_NOTICES.md"
|
|
58
|
+
]
|
|
59
|
+
}
|