kith-coord 0.1.8 → 0.2.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/CHANGELOG.md +17 -0
- package/CONTRIBUTING.md +7 -1
- package/README.md +81 -142
- package/assets/demo/claim.jq +5 -0
- package/assets/demo/claims.gif +0 -0
- package/assets/demo/claims.tape +59 -0
- package/assets/demo/prepare.sh +63 -0
- package/bin/kith-menubar +0 -0
- package/dist/cli/index.js +4257 -941
- package/dist/cli/index.js.map +1 -1
- package/dist/command-worker.js +31 -2
- package/dist/command-worker.js.map +1 -1
- package/dist/index.d.ts +216 -11
- package/dist/index.js +3015 -461
- package/dist/index.js.map +1 -1
- package/docs/architecture.md +5 -2
- package/docs/install.md +183 -0
- package/docs/integrations.md +8 -4
- package/docs/protocol/tools.v1.json +53 -0
- package/docs/protocol.md +13 -2
- package/docs/reliability.md +1 -1
- package/docs/roadmap.md +2 -0
- package/docs/sessions-and-mutexes.md +29 -3
- package/docs/usage.md +45 -0
- package/package.json +35 -25
- package/server.json +3 -3
package/dist/command-worker.js
CHANGED
|
@@ -4,6 +4,26 @@ import { createRequire as __kithRequire } from 'node:module'; const require = __
|
|
|
4
4
|
import os from "os";
|
|
5
5
|
import { spawn } from "child_process";
|
|
6
6
|
var started = false;
|
|
7
|
+
var shuttingDown = false;
|
|
8
|
+
var child;
|
|
9
|
+
var hello;
|
|
10
|
+
process.on("SIGHUP", () => {
|
|
11
|
+
});
|
|
12
|
+
function shutdown() {
|
|
13
|
+
if (shuttingDown) return;
|
|
14
|
+
shuttingDown = true;
|
|
15
|
+
if (hello) clearInterval(hello);
|
|
16
|
+
if (!child || child.exitCode !== null || child.signalCode !== null) {
|
|
17
|
+
if (!started) process.exit(1);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
child.kill("SIGKILL");
|
|
22
|
+
} catch {
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
process.on("SIGTERM", shutdown);
|
|
26
|
+
process.on("SIGINT", shutdown);
|
|
7
27
|
process.on("disconnect", () => {
|
|
8
28
|
try {
|
|
9
29
|
process.kill(-process.pid, "SIGKILL");
|
|
@@ -11,12 +31,20 @@ process.on("disconnect", () => {
|
|
|
11
31
|
process.exit(1);
|
|
12
32
|
}
|
|
13
33
|
});
|
|
34
|
+
hello = setInterval(() => {
|
|
35
|
+
if (started || !process.connected) {
|
|
36
|
+
clearInterval(hello);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
process.send?.({ ready: true });
|
|
40
|
+
}, 50);
|
|
14
41
|
process.once("message", (message) => {
|
|
15
|
-
|
|
42
|
+
clearInterval(hello);
|
|
43
|
+
if (started || shuttingDown) return;
|
|
16
44
|
started = true;
|
|
17
45
|
let finished = false;
|
|
18
46
|
const env = { ...process.env, ...message.env, ...message.mutexName === "package-install" ? { KITH_PACKAGE_INSTALL_GUARDED: "1" } : {} };
|
|
19
|
-
|
|
47
|
+
child = Array.isArray(message.command) ? spawn(message.command[0], message.command.slice(1), { cwd: message.cwd, env, stdio: ["ignore", "inherit", "inherit"] }) : spawn(message.command, { cwd: message.cwd, env, stdio: ["ignore", "inherit", "inherit"], shell: true });
|
|
20
48
|
child.once("error", (err) => {
|
|
21
49
|
if (finished) return;
|
|
22
50
|
finished = true;
|
|
@@ -26,6 +54,7 @@ process.once("message", (message) => {
|
|
|
26
54
|
if (finished) return;
|
|
27
55
|
finished = true;
|
|
28
56
|
if (process.connected) process.send?.({ exitCode: code ?? (signal ? 128 + (os.constants.signals[signal] ?? 1) : 1), signal }, () => process.exit(0));
|
|
57
|
+
else process.exit(code === 0 ? 0 : 1);
|
|
29
58
|
});
|
|
30
59
|
});
|
|
31
60
|
process.send?.({ ready: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/command-worker.ts"],"sourcesContent":["// A detached process-group leader. The command cannot start until its supervisor\n// has durably recorded this group and sent the start message over private IPC.\nimport os from 'node:os';\nimport { spawn } from 'node:child_process';\n\nlet started = false;\nprocess.on('disconnect', () => {\n try { process.kill(-process.pid, 'SIGKILL'); } catch { process.exit(1); }\n});\nprocess.once('message', (message: { command: string | string[]; cwd: string; mutexName: string; env?: Record<string, string> }) => {\n if (started) return;\n started = true;\n let finished = false;\n const env = { ...process.env, ...message.env, ...(message.mutexName === 'package-install' ? { KITH_PACKAGE_INSTALL_GUARDED: '1' } : {}) };\n
|
|
1
|
+
{"version":3,"sources":["../src/core/command-worker.ts"],"sourcesContent":["// A detached process-group leader. The command cannot start until its supervisor\n// has durably recorded this group and sent the start message over private IPC.\nimport os from 'node:os';\nimport { spawn, type ChildProcess } from 'node:child_process';\n\nlet started = false;\nlet shuttingDown = false;\nlet child: ChildProcess | undefined;\nlet hello: ReturnType<typeof setInterval> | undefined;\n\n// Detaching into a new session can deliver SIGHUP on macOS. The supervisor\n// stops this process with SIGTERM or by closing IPC, not with a hangup.\nprocess.on('SIGHUP', () => {});\n\nfunction shutdown(): void {\n if (shuttingDown) return;\n shuttingDown = true;\n if (hello) clearInterval(hello);\n if (!child || child.exitCode !== null || child.signalCode !== null) {\n if (!started) process.exit(1);\n return;\n }\n // Kill the direct child, not this process group. SIGKILL of the group would\n // kill us before we can reap, and macOS then reports the child as alive\n // until launchd collects the zombie. A failed kill means the child has\n // already exited; its close handler reaps it and exits this process.\n try { child.kill('SIGKILL'); } catch { /* already gone */ }\n}\n\nprocess.on('SIGTERM', shutdown);\nprocess.on('SIGINT', shutdown);\nprocess.on('disconnect', () => {\n try { process.kill(-process.pid, 'SIGKILL'); } catch { process.exit(1); }\n});\n\n// Repeat ready until the parent sends the command. A single IPC message can be\n// dropped when its length header is split across reads (Node 22.13) or when it\n// arrives before the parent is listening.\nhello = setInterval(() => {\n if (started || !process.connected) { clearInterval(hello); return; }\n process.send?.({ ready: true });\n}, 50);\n\nprocess.once('message', (message: { command: string | string[]; cwd: string; mutexName: string; env?: Record<string, string> }) => {\n clearInterval(hello);\n if (started || shuttingDown) return;\n started = true;\n let finished = false;\n const env = { ...process.env, ...message.env, ...(message.mutexName === 'package-install' ? { KITH_PACKAGE_INSTALL_GUARDED: '1' } : {}) };\n child = Array.isArray(message.command)\n ? spawn(message.command[0], message.command.slice(1), { cwd: message.cwd, env, stdio: ['ignore', 'inherit', 'inherit'] })\n : spawn(message.command, { cwd: message.cwd, env, stdio: ['ignore', 'inherit', 'inherit'], shell: true });\n child.once('error', (err) => {\n if (finished) return;\n finished = true;\n process.send?.({ error: err.message }, () => process.exit(1));\n });\n child.once('close', (code, signal) => {\n if (finished) return;\n finished = true;\n if (process.connected) process.send?.({ exitCode: code ?? (signal ? 128 + (os.constants.signals[signal] ?? 1) : 1), signal }, () => process.exit(0));\n else process.exit(code === 0 ? 0 : 1);\n });\n});\nprocess.send?.({ ready: true });\n"],"mappings":";;;AAEA,OAAO,QAAQ;AACf,SAAS,aAAgC;AAEzC,IAAI,UAAU;AACd,IAAI,eAAe;AACnB,IAAI;AACJ,IAAI;AAIJ,QAAQ,GAAG,UAAU,MAAM;AAAC,CAAC;AAE7B,SAAS,WAAiB;AACxB,MAAI,aAAc;AAClB,iBAAe;AACf,MAAI,MAAO,eAAc,KAAK;AAC9B,MAAI,CAAC,SAAS,MAAM,aAAa,QAAQ,MAAM,eAAe,MAAM;AAClE,QAAI,CAAC,QAAS,SAAQ,KAAK,CAAC;AAC5B;AAAA,EACF;AAKA,MAAI;AAAE,UAAM,KAAK,SAAS;AAAA,EAAG,QAAQ;AAAA,EAAqB;AAC5D;AAEA,QAAQ,GAAG,WAAW,QAAQ;AAC9B,QAAQ,GAAG,UAAU,QAAQ;AAC7B,QAAQ,GAAG,cAAc,MAAM;AAC7B,MAAI;AAAE,YAAQ,KAAK,CAAC,QAAQ,KAAK,SAAS;AAAA,EAAG,QAAQ;AAAE,YAAQ,KAAK,CAAC;AAAA,EAAG;AAC1E,CAAC;AAKD,QAAQ,YAAY,MAAM;AACxB,MAAI,WAAW,CAAC,QAAQ,WAAW;AAAE,kBAAc,KAAK;AAAG;AAAA,EAAQ;AACnE,UAAQ,OAAO,EAAE,OAAO,KAAK,CAAC;AAChC,GAAG,EAAE;AAEL,QAAQ,KAAK,WAAW,CAAC,YAA0G;AACjI,gBAAc,KAAK;AACnB,MAAI,WAAW,aAAc;AAC7B,YAAU;AACV,MAAI,WAAW;AACf,QAAM,MAAM,EAAE,GAAG,QAAQ,KAAK,GAAG,QAAQ,KAAK,GAAI,QAAQ,cAAc,oBAAoB,EAAE,8BAA8B,IAAI,IAAI,CAAC,EAAG;AACxI,UAAQ,MAAM,QAAQ,QAAQ,OAAO,IACjC,MAAM,QAAQ,QAAQ,CAAC,GAAG,QAAQ,QAAQ,MAAM,CAAC,GAAG,EAAE,KAAK,QAAQ,KAAK,KAAK,OAAO,CAAC,UAAU,WAAW,SAAS,EAAE,CAAC,IACtH,MAAM,QAAQ,SAAS,EAAE,KAAK,QAAQ,KAAK,KAAK,OAAO,CAAC,UAAU,WAAW,SAAS,GAAG,OAAO,KAAK,CAAC;AAC1G,QAAM,KAAK,SAAS,CAAC,QAAQ;AAC3B,QAAI,SAAU;AACd,eAAW;AACX,YAAQ,OAAO,EAAE,OAAO,IAAI,QAAQ,GAAG,MAAM,QAAQ,KAAK,CAAC,CAAC;AAAA,EAC9D,CAAC;AACD,QAAM,KAAK,SAAS,CAAC,MAAM,WAAW;AACpC,QAAI,SAAU;AACd,eAAW;AACX,QAAI,QAAQ,UAAW,SAAQ,OAAO,EAAE,UAAU,SAAS,SAAS,OAAO,GAAG,UAAU,QAAQ,MAAM,KAAK,KAAK,IAAI,OAAO,GAAG,MAAM,QAAQ,KAAK,CAAC,CAAC;AAAA,QAC9I,SAAQ,KAAK,SAAS,IAAI,IAAI,CAAC;AAAA,EACtC,CAAC;AACH,CAAC;AACD,QAAQ,OAAO,EAAE,OAAO,KAAK,CAAC;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -81,11 +81,23 @@ declare class FencingAndAgentManager {
|
|
|
81
81
|
private readonly capabilities;
|
|
82
82
|
private static ownWindowsStart;
|
|
83
83
|
private static inspectionFailure;
|
|
84
|
+
/** Confirmed start times. Heartbeats must not spawn `ps` on every 100ms tick: on macOS that blocks the event loop longer than a short mutex lease and the lease is lost before the command starts. */
|
|
85
|
+
private static confirmedStarts;
|
|
86
|
+
private static rechecking;
|
|
84
87
|
constructor(coordDb: CoordDatabase);
|
|
85
88
|
static validateLease(duration: number): number;
|
|
86
89
|
/** A real kernel process identity; tests must not supply liveness sentinels. */
|
|
87
90
|
static getProcessStartTime(pid: number): string | null;
|
|
91
|
+
/**
|
|
92
|
+
* Resolve a start time without blocking lease renewal. A just-forked pid can be
|
|
93
|
+
* invisible to `ps` for a moment, and a single timed-out `ps` must not abort the command.
|
|
94
|
+
*/
|
|
95
|
+
static waitForProcessStartTime(pid: number, budgetMs: number, aborted?: () => boolean): Promise<string | null>;
|
|
88
96
|
static isProcessAlive(pid: number, expectedStartTime: string): boolean;
|
|
97
|
+
private static rememberStart;
|
|
98
|
+
/** Refresh identity in the background so a slow `ps` cannot stall mutex renewal. */
|
|
99
|
+
private static scheduleStartRecheck;
|
|
100
|
+
private static readDarwinStartTime;
|
|
89
101
|
registerAgent(params: {
|
|
90
102
|
id: string;
|
|
91
103
|
name?: string;
|
|
@@ -130,13 +142,121 @@ declare class FencingAndAgentManager {
|
|
|
130
142
|
private hash;
|
|
131
143
|
}
|
|
132
144
|
|
|
133
|
-
|
|
145
|
+
type WorktreeProvenance = 'created' | 'adopted';
|
|
146
|
+
type WorktreeSource = 'kith' | 'claude-code' | 'external';
|
|
147
|
+
interface ListedWorktree {
|
|
148
|
+
path: string;
|
|
149
|
+
head: string;
|
|
150
|
+
branch: string | null;
|
|
151
|
+
detached: boolean;
|
|
152
|
+
locked: boolean;
|
|
153
|
+
lockReason: string | null;
|
|
154
|
+
}
|
|
155
|
+
interface WorktreeRegistration {
|
|
156
|
+
agentId: string;
|
|
157
|
+
worktreePath: string;
|
|
158
|
+
provenance: WorktreeProvenance;
|
|
159
|
+
source: WorktreeSource;
|
|
160
|
+
branch: string | null;
|
|
161
|
+
head: string | null;
|
|
162
|
+
detached: boolean;
|
|
163
|
+
dirty: boolean;
|
|
164
|
+
branchCheckedOutElsewhere: boolean;
|
|
165
|
+
registeredAt: number;
|
|
166
|
+
}
|
|
167
|
+
/** A workspace binding stored for the agent. `branch` is null when HEAD is detached. */
|
|
168
|
+
interface WorktreeBinding {
|
|
169
|
+
agentId: string;
|
|
170
|
+
worktreePath: string;
|
|
171
|
+
branch: string | null;
|
|
172
|
+
hydrationMethod: 'apfs-cow' | 'reflink-cow' | 'copy' | 'none';
|
|
173
|
+
hydratedDirs: string[];
|
|
174
|
+
durationMs: number;
|
|
175
|
+
provenance: WorktreeProvenance;
|
|
176
|
+
source: WorktreeSource;
|
|
177
|
+
detached: boolean;
|
|
178
|
+
dirty: boolean;
|
|
179
|
+
branchCheckedOutElsewhere: boolean;
|
|
180
|
+
alreadyRegistered: boolean;
|
|
181
|
+
notes: string[];
|
|
182
|
+
}
|
|
183
|
+
interface LiveAdoption {
|
|
184
|
+
worktreePath: string;
|
|
185
|
+
branch: string | null;
|
|
186
|
+
detached: boolean;
|
|
187
|
+
dirty: boolean;
|
|
188
|
+
branchCheckedOutElsewhere: boolean;
|
|
189
|
+
source: WorktreeSource;
|
|
190
|
+
provenance: 'adopted';
|
|
191
|
+
/** Set when integration must not run. The worktree is left unchanged. */
|
|
192
|
+
integrationError: string | null;
|
|
193
|
+
/** Set when `kith commit` must not move a branch another checkout is using. */
|
|
194
|
+
commitError: string | null;
|
|
195
|
+
}
|
|
196
|
+
declare function detachedIntegrationError(): string;
|
|
197
|
+
declare function branchElsewhereError(branch: string): string;
|
|
198
|
+
declare function parseWorktreePorcelain(output: string): ListedWorktree[];
|
|
199
|
+
declare function listGitWorktrees(repoRoot: string): ListedWorktree[];
|
|
200
|
+
declare function branchIsCheckedOutElsewhere(entries: ListedWorktree[], worktreePath: string, branch: string | null): boolean;
|
|
201
|
+
declare function kithWorktreesRoot(coord: CoordDatabase): string;
|
|
202
|
+
declare function isKithOwnedWorktree(coord: CoordDatabase, worktreePath: string): boolean;
|
|
203
|
+
/** The non-linked checkout of the repository that contains `start`. */
|
|
204
|
+
declare function primaryCheckoutOf(start: string): string;
|
|
205
|
+
declare function registrationFromRow(row: {
|
|
206
|
+
agent_id: string;
|
|
207
|
+
worktree_path: string;
|
|
208
|
+
provenance: string;
|
|
209
|
+
source: string;
|
|
210
|
+
branch: string | null;
|
|
211
|
+
head: string | null;
|
|
212
|
+
detached: number | boolean;
|
|
213
|
+
dirty: number | boolean;
|
|
214
|
+
branch_elsewhere: number | boolean;
|
|
215
|
+
registered_at: number;
|
|
216
|
+
}): WorktreeRegistration;
|
|
217
|
+
declare function readRegistration(coord: CoordDatabase, agentId: string): WorktreeRegistration | null;
|
|
218
|
+
declare function listRegistrations(coord: CoordDatabase): WorktreeRegistration[];
|
|
219
|
+
declare function clearRegistration(coord: CoordDatabase, agentId: string): void;
|
|
220
|
+
declare function adoptWorktree(coord: CoordDatabase, fencing: FencingAndAgentManager, params: {
|
|
221
|
+
agentId: string;
|
|
222
|
+
path?: string;
|
|
223
|
+
explicit: boolean;
|
|
224
|
+
}): WorktreeBinding;
|
|
225
|
+
declare function recordCreatedWorktree(coord: CoordDatabase, fencing: FencingAndAgentManager, params: {
|
|
134
226
|
agentId: string;
|
|
135
227
|
worktreePath: string;
|
|
136
228
|
branch: string;
|
|
229
|
+
head: string | null;
|
|
230
|
+
}): void;
|
|
231
|
+
/** Fill provenance for a checkout the session already recorded, without switching worktrees. */
|
|
232
|
+
declare function syncRegistration(coord: CoordDatabase, fencing: FencingAndAgentManager, agentId: string): WorktreeRegistration | null;
|
|
233
|
+
/**
|
|
234
|
+
* Adopt when the hook cwd is exactly one linked worktree of this repository and the session
|
|
235
|
+
* does not already own a different checkout. Anything else is left alone.
|
|
236
|
+
*/
|
|
237
|
+
declare function adoptIfUnambiguous(coord: CoordDatabase, fencing: FencingAndAgentManager, params: {
|
|
238
|
+
agentId: string;
|
|
239
|
+
cwd: string;
|
|
240
|
+
}): WorktreeBinding | null;
|
|
241
|
+
declare function liveAdoption(coord: CoordDatabase, fencing: FencingAndAgentManager, agent: AgentRecord | null | undefined): LiveAdoption | null;
|
|
242
|
+
/** Move an adopted or created workspace from one agent onto another, leaving the directory in place. */
|
|
243
|
+
declare function transferWorktreeRegistration(coord: CoordDatabase, fromId: string, toId: string): boolean;
|
|
244
|
+
declare function forgetWorktree(coord: CoordDatabase, fencing: FencingAndAgentManager, agentId: string): boolean;
|
|
245
|
+
|
|
246
|
+
interface SpawnedWorktree {
|
|
247
|
+
agentId: string;
|
|
248
|
+
worktreePath: string;
|
|
249
|
+
branch: string | null;
|
|
137
250
|
hydrationMethod: 'apfs-cow' | 'reflink-cow' | 'copy' | 'none';
|
|
138
251
|
hydratedDirs: string[];
|
|
139
252
|
durationMs: number;
|
|
253
|
+
provenance?: WorktreeBinding['provenance'];
|
|
254
|
+
source?: WorktreeBinding['source'];
|
|
255
|
+
detached?: boolean;
|
|
256
|
+
dirty?: boolean;
|
|
257
|
+
branchCheckedOutElsewhere?: boolean;
|
|
258
|
+
alreadyRegistered?: boolean;
|
|
259
|
+
notes?: string[];
|
|
140
260
|
}
|
|
141
261
|
declare class CoWWorktreeManager {
|
|
142
262
|
private readonly coordDb;
|
|
@@ -154,12 +274,31 @@ declare class CoWWorktreeManager {
|
|
|
154
274
|
baseRef?: string;
|
|
155
275
|
}): SpawnedWorktree;
|
|
156
276
|
private cloneDirectoryCoW;
|
|
157
|
-
removeWorktree(agentId: string
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
277
|
+
removeWorktree(agentId: string, options?: {
|
|
278
|
+
deleteAdopted?: boolean;
|
|
279
|
+
}): boolean;
|
|
280
|
+
private removeCheckout;
|
|
281
|
+
private clearAgentWorktree;
|
|
282
|
+
listWorktrees(): ListedWorktree[];
|
|
283
|
+
registrationFor(agentId: string): WorktreeRegistration | null;
|
|
284
|
+
listRegistrations(): WorktreeRegistration[];
|
|
285
|
+
adoptWorktree(params: {
|
|
286
|
+
agentId: string;
|
|
287
|
+
path?: string;
|
|
288
|
+
explicit?: boolean;
|
|
289
|
+
}): WorktreeBinding;
|
|
290
|
+
adoptIfUnambiguous(params: {
|
|
291
|
+
agentId: string;
|
|
292
|
+
cwd: string;
|
|
293
|
+
}): WorktreeBinding | null;
|
|
294
|
+
syncRegistration(agentId: string): WorktreeRegistration | null;
|
|
295
|
+
liveAdoption(agent: {
|
|
296
|
+
id: string;
|
|
297
|
+
worktree_path?: string | null;
|
|
298
|
+
branch?: string | null;
|
|
299
|
+
status?: string;
|
|
300
|
+
} | null | undefined): LiveAdoption | null;
|
|
301
|
+
forgetWorktree(agentId: string): boolean;
|
|
163
302
|
}
|
|
164
303
|
|
|
165
304
|
interface WorktreeChange {
|
|
@@ -558,6 +697,30 @@ declare class ShadowGitEngine {
|
|
|
558
697
|
probePairConflict(agentA: string, commitA: string, agentB: string, commitB: string): DirtyMergeProbeResult;
|
|
559
698
|
/** Remove orphaned shadow Git index files left behind by dead or completed sessions. */
|
|
560
699
|
pruneStaleShadowIndexes(dryRun?: boolean): number;
|
|
700
|
+
/** Counts from the most recent {@link pruneFalseConflicts} call. Tests assert the probe budget. */
|
|
701
|
+
lastConflictHygiene: {
|
|
702
|
+
mergeFileProbes: number;
|
|
703
|
+
headReads: number;
|
|
704
|
+
removed: number;
|
|
705
|
+
probeDir: string | null;
|
|
706
|
+
};
|
|
707
|
+
/**
|
|
708
|
+
* Drop stored conflicts that are no longer real. 0.1.8 already refuses to record a side equal
|
|
709
|
+
* to HEAD, or two identical sides, while probing. Rows written before that commit, or before
|
|
710
|
+
* HEAD moved, stay until something reads them. `git merge-file` runs only for triples not
|
|
711
|
+
* already settled, at most `maxMergeProbes` per call, and the decision is cached by HEAD sha
|
|
712
|
+
* plus conflict id so a later status read does not spawn those processes again. Probe files
|
|
713
|
+
* live in the system temp directory and are removed before this returns.
|
|
714
|
+
*/
|
|
715
|
+
pruneFalseConflicts(maxMergeProbes?: number): number;
|
|
716
|
+
private blobsAtCommit;
|
|
717
|
+
/** `conflict` is a real overlap. `error` is not cached, so a later read can retry the probe. */
|
|
718
|
+
private blobsMergeCleanly;
|
|
719
|
+
/** Prefer the system temp dir. If that lives inside this checkout, step outside it. */
|
|
720
|
+
private mergeProbeParent;
|
|
721
|
+
private hygieneCachePath;
|
|
722
|
+
private readHygieneCache;
|
|
723
|
+
private writeHygieneCache;
|
|
561
724
|
listConflicts(): ConflictRecord[];
|
|
562
725
|
}
|
|
563
726
|
|
|
@@ -583,6 +746,12 @@ interface BashGuardPostReport {
|
|
|
583
746
|
authorizedModifiedFiles: string[];
|
|
584
747
|
quarantinedViolations: QuarantineRecord[];
|
|
585
748
|
}
|
|
749
|
+
/**
|
|
750
|
+
* Checkouts whose index should be resynced after a command that ran `git update-ref`.
|
|
751
|
+
* Each directory is the worktree root of a classified `update-ref` (after `git -C` and `cd`).
|
|
752
|
+
* Unparsed commands and stdin batches yield nothing, so the post-hook does not reset an unrelated index.
|
|
753
|
+
*/
|
|
754
|
+
declare function refUpdateResyncRoots(command: string, startDir: string): string[];
|
|
586
755
|
/**
|
|
587
756
|
* True when a shell command is purely observational (e.g. `ls`, `tail`, `git status`, `stack.mjs status`)
|
|
588
757
|
* and contains no file-redirection or write primitives.
|
|
@@ -611,7 +780,21 @@ declare class BashMerkleGuard {
|
|
|
611
780
|
}): {
|
|
612
781
|
safe: boolean;
|
|
613
782
|
reason?: string;
|
|
783
|
+
deferred?: boolean;
|
|
784
|
+
};
|
|
785
|
+
/**
|
|
786
|
+
* Post-hook half of a deferred shared-checkout update-ref. Literal SHAs are decided in
|
|
787
|
+
* checkCommandSafety; shell variables are checked against the commit that landed.
|
|
788
|
+
*/
|
|
789
|
+
settleDeferredRefUpdate(params: {
|
|
790
|
+
agentId: string;
|
|
791
|
+
command: string;
|
|
792
|
+
}): {
|
|
793
|
+
warnings: string[];
|
|
794
|
+
reverted: boolean;
|
|
614
795
|
};
|
|
796
|
+
private refHost;
|
|
797
|
+
private recordedTasks;
|
|
615
798
|
private getSnapshotFilePath;
|
|
616
799
|
/**
|
|
617
800
|
* Captures a Merkle snapshot of workspace files before a Bash tool execution.
|
|
@@ -1075,6 +1258,7 @@ declare class KithEngine {
|
|
|
1075
1258
|
mutexWaiters: Record<string, node_sqlite.SQLOutputValue>[];
|
|
1076
1259
|
commandGuards: Record<string, node_sqlite.SQLOutputValue>[];
|
|
1077
1260
|
workspaces: WorkspaceObservation[];
|
|
1261
|
+
worktreeRegistrations: WorktreeRegistration[];
|
|
1078
1262
|
};
|
|
1079
1263
|
previewIntegration(agentId: string): {
|
|
1080
1264
|
ok: boolean;
|
|
@@ -1103,6 +1287,8 @@ declare class KithEngine {
|
|
|
1103
1287
|
};
|
|
1104
1288
|
beginWork(params: Parameters<IntentAndTaskEngine['declareIntent']>[0] & {
|
|
1105
1289
|
isolateWorktree?: boolean;
|
|
1290
|
+
adoptWorktree?: boolean;
|
|
1291
|
+
worktreePath?: string;
|
|
1106
1292
|
}): {
|
|
1107
1293
|
worktree: SpawnedWorktree | null;
|
|
1108
1294
|
workflowMode: "worktrees" | "main";
|
|
@@ -1125,6 +1311,8 @@ declare class KithEngine {
|
|
|
1125
1311
|
claimNextTask(params: {
|
|
1126
1312
|
agentId: string;
|
|
1127
1313
|
isolateWorktree?: boolean;
|
|
1314
|
+
adoptWorktree?: boolean;
|
|
1315
|
+
worktreePath?: string;
|
|
1128
1316
|
}): {
|
|
1129
1317
|
worktree: SpawnedWorktree | null;
|
|
1130
1318
|
workflowMode: "worktrees" | "main";
|
|
@@ -1150,6 +1338,8 @@ declare class KithEngine {
|
|
|
1150
1338
|
claimNextTaskWhenAvailable(params: {
|
|
1151
1339
|
agentId: string;
|
|
1152
1340
|
isolateWorktree?: boolean;
|
|
1341
|
+
adoptWorktree?: boolean;
|
|
1342
|
+
worktreePath?: string;
|
|
1153
1343
|
waitTimeoutMs: number;
|
|
1154
1344
|
signal?: AbortSignal;
|
|
1155
1345
|
}): Promise<{
|
|
@@ -1218,19 +1408,28 @@ declare class KithEngine {
|
|
|
1218
1408
|
waitTimeoutMs?: number;
|
|
1219
1409
|
}): {
|
|
1220
1410
|
ok: boolean;
|
|
1221
|
-
mergeResult:
|
|
1411
|
+
mergeResult: null;
|
|
1222
1412
|
error: string;
|
|
1223
1413
|
completedTasks?: undefined;
|
|
1414
|
+
notes?: undefined;
|
|
1224
1415
|
} | {
|
|
1225
1416
|
ok: boolean;
|
|
1417
|
+
completedTasks: TaskRecord[];
|
|
1226
1418
|
mergeResult: null;
|
|
1419
|
+
notes: string[];
|
|
1420
|
+
error?: undefined;
|
|
1421
|
+
} | {
|
|
1422
|
+
ok: boolean;
|
|
1423
|
+
mergeResult: SpeculativeMergeResult;
|
|
1227
1424
|
error: string;
|
|
1228
1425
|
completedTasks?: undefined;
|
|
1426
|
+
notes?: undefined;
|
|
1229
1427
|
} | {
|
|
1230
1428
|
ok: boolean;
|
|
1231
1429
|
completedTasks: TaskRecord[];
|
|
1232
1430
|
mergeResult: SpeculativeMergeResult | null;
|
|
1233
1431
|
error?: undefined;
|
|
1432
|
+
notes?: undefined;
|
|
1234
1433
|
};
|
|
1235
1434
|
close(): void;
|
|
1236
1435
|
}
|
|
@@ -1298,12 +1497,14 @@ declare function readCoordinationState(directory?: string, options?: {
|
|
|
1298
1497
|
handoffs: HandoffRecord[];
|
|
1299
1498
|
workflowMode: WorkflowMode;
|
|
1300
1499
|
workflowModeConfigured: boolean;
|
|
1500
|
+
worktreeRegistrations: WorktreeRegistration[];
|
|
1301
1501
|
} | {
|
|
1302
1502
|
state: "ready";
|
|
1303
1503
|
schemaVersion: number;
|
|
1304
1504
|
handoffs: HandoffRecord[];
|
|
1305
1505
|
workflowMode: "worktrees" | "main";
|
|
1306
1506
|
workflowModeConfigured: boolean;
|
|
1507
|
+
worktreeRegistrations: WorktreeRegistration[];
|
|
1307
1508
|
fencingEpoch: number;
|
|
1308
1509
|
agents: AgentRecord[];
|
|
1309
1510
|
tasks: {
|
|
@@ -1363,6 +1564,7 @@ declare function readCoordinationState(directory?: string, options?: {
|
|
|
1363
1564
|
commandGuards: Record<string, unknown>[];
|
|
1364
1565
|
mergeQueue: Record<string, unknown>[];
|
|
1365
1566
|
recentAgentFiles: Record<string, string[]>;
|
|
1567
|
+
worktreeRegistrations: WorktreeRegistration[];
|
|
1366
1568
|
truncated: boolean;
|
|
1367
1569
|
protocolVersion: string;
|
|
1368
1570
|
observedAt: number;
|
|
@@ -1438,6 +1640,7 @@ declare function recoveryReport(directory?: string): {
|
|
|
1438
1640
|
handoffs: HandoffRecord[];
|
|
1439
1641
|
workflowMode: WorkflowMode;
|
|
1440
1642
|
workflowModeConfigured: boolean;
|
|
1643
|
+
worktreeRegistrations: WorktreeRegistration[];
|
|
1441
1644
|
} | {
|
|
1442
1645
|
retainedWorktrees: {
|
|
1443
1646
|
path: string;
|
|
@@ -1459,6 +1662,7 @@ declare function recoveryReport(directory?: string): {
|
|
|
1459
1662
|
handoffs: HandoffRecord[];
|
|
1460
1663
|
workflowMode: "worktrees" | "main";
|
|
1461
1664
|
workflowModeConfigured: boolean;
|
|
1665
|
+
worktreeRegistrations: WorktreeRegistration[];
|
|
1462
1666
|
fencingEpoch: number;
|
|
1463
1667
|
agents: AgentRecord[];
|
|
1464
1668
|
tasks: {
|
|
@@ -1533,6 +1737,7 @@ declare function recoveryReport(directory?: string): {
|
|
|
1533
1737
|
commandGuards: Record<string, unknown>[];
|
|
1534
1738
|
mergeQueue: Record<string, unknown>[];
|
|
1535
1739
|
recentAgentFiles: Record<string, string[]>;
|
|
1740
|
+
worktreeRegistrations: WorktreeRegistration[];
|
|
1536
1741
|
truncated: boolean;
|
|
1537
1742
|
protocolVersion: string;
|
|
1538
1743
|
observedAt: number;
|
|
@@ -1560,7 +1765,7 @@ interface GcOptions {
|
|
|
1560
1765
|
interface GcPreservedItem {
|
|
1561
1766
|
path: string;
|
|
1562
1767
|
branch: string | null;
|
|
1563
|
-
reason: 'active-session' | 'open-handoff' | 'dirty' | 'unmerged';
|
|
1768
|
+
reason: 'active-session' | 'open-handoff' | 'dirty' | 'unmerged' | 'adopted';
|
|
1564
1769
|
}
|
|
1565
1770
|
interface GcReport {
|
|
1566
1771
|
ok: boolean;
|
|
@@ -1586,7 +1791,7 @@ interface GcReport {
|
|
|
1586
1791
|
declare function resyncStaleIndexEntries(repoRoot: string): number;
|
|
1587
1792
|
declare function gcCoordination(directory?: string, options?: GcOptions): GcReport;
|
|
1588
1793
|
|
|
1589
|
-
declare const KITH_VERSION = "0.
|
|
1794
|
+
declare const KITH_VERSION = "0.2.0";
|
|
1590
1795
|
declare const KITH_PROTOCOL_VERSION = "1.6.0";
|
|
1591
1796
|
|
|
1592
|
-
export { type AcquireLockResult, type AgentRecord, type AgentUnreadDelta, AstAnalyzer, type BashGuardPostReport, BashMerkleGuard, type BlastRadiusAlert, CoWWorktreeManager, type CommitParams, type CommitResult, type ConflictRecord, type ContractRecord, CoordDatabase, type CoordEvent, type DeclareIntentResult, DependencyAndContractEngine, type DirtyMergeProbeResult, type ExtractedImport, type ExtractedSymbol, FencingAndAgentManager, type FileAstAnalysis, type FileModificationReport, type FileSnapshotEntry, type GcOptions, type GcPreservedItem, type GcReport, IntentAndTaskEngine, KITH_PROTOCOL_VERSION, KITH_VERSION, KithEngine, type LinkedWorkspaceContract, type LockConflict, LockEngine, type LockRecord, type MergeTrainEntry, type PostFileEditHookResult, type QuarantineRecord, type RepositoryLayout, ResourceBroker, type ResourceRecord, SessionOwnershipError, type SessionRegistration, ShadowGitEngine, type SpawnedWorktree, type SpeculativeMergeResult, SpeculativeMergeTrain, StaleFencingTokenError, type SupervisedCommandOptions, type SwarmPrompts, type SymbolKind, type TaskRecord, type WorkspaceContractReport, type WorkspaceObservation, type WorktreeChange, buildSwarmPrompts, caseSensitivePaths, commandTargetsFileForWrite, commitScopedFiles, discoverChildRepositories, discoverRepository, extractRecentAgentFiles, gcCoordination, inspectWorkspaceContracts, isReadOnlyShellCommand, isWithin, observeWorkspaces, physicalPath, previewIntegration, readBrief, readCoordinationState, recoveryReport, repositoryFile, resyncStaleIndexEntries, runVerificationCommand, sqliteDatabase, verifyCrossRepoImportsForFile, worktreeChanges };
|
|
1797
|
+
export { type AcquireLockResult, type AgentRecord, type AgentUnreadDelta, AstAnalyzer, type BashGuardPostReport, BashMerkleGuard, type BlastRadiusAlert, CoWWorktreeManager, type CommitParams, type CommitResult, type ConflictRecord, type ContractRecord, CoordDatabase, type CoordEvent, type DeclareIntentResult, DependencyAndContractEngine, type DirtyMergeProbeResult, type ExtractedImport, type ExtractedSymbol, FencingAndAgentManager, type FileAstAnalysis, type FileModificationReport, type FileSnapshotEntry, type GcOptions, type GcPreservedItem, type GcReport, IntentAndTaskEngine, KITH_PROTOCOL_VERSION, KITH_VERSION, KithEngine, type LinkedWorkspaceContract, type ListedWorktree, type LiveAdoption, type LockConflict, LockEngine, type LockRecord, type MergeTrainEntry, type PostFileEditHookResult, type QuarantineRecord, type RepositoryLayout, ResourceBroker, type ResourceRecord, SessionOwnershipError, type SessionRegistration, ShadowGitEngine, type SpawnedWorktree, type SpeculativeMergeResult, SpeculativeMergeTrain, StaleFencingTokenError, type SupervisedCommandOptions, type SwarmPrompts, type SymbolKind, type TaskRecord, type WorkspaceContractReport, type WorkspaceObservation, type WorktreeBinding, type WorktreeChange, type WorktreeProvenance, type WorktreeRegistration, type WorktreeSource, adoptIfUnambiguous, adoptWorktree, branchElsewhereError, branchIsCheckedOutElsewhere, buildSwarmPrompts, caseSensitivePaths, clearRegistration, commandTargetsFileForWrite, commitScopedFiles, detachedIntegrationError, discoverChildRepositories, discoverRepository, extractRecentAgentFiles, forgetWorktree, gcCoordination, inspectWorkspaceContracts, isKithOwnedWorktree, isReadOnlyShellCommand, isWithin, kithWorktreesRoot, listGitWorktrees, listRegistrations, liveAdoption, observeWorkspaces, parseWorktreePorcelain, physicalPath, previewIntegration, primaryCheckoutOf, readBrief, readCoordinationState, readRegistration, recordCreatedWorktree, recoveryReport, refUpdateResyncRoots, registrationFromRow, repositoryFile, resyncStaleIndexEntries, runVerificationCommand, sqliteDatabase, syncRegistration, transferWorktreeRegistration, verifyCrossRepoImportsForFile, worktreeChanges };
|