kith-coord 0.1.9 → 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.
@@ -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
- if (started) return;
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
- const 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 });
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 const 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 });\n});\nprocess.send?.({ ready: true });\n"],"mappings":";;;AAEA,OAAO,QAAQ;AACf,SAAS,aAAa;AAEtB,IAAI,UAAU;AACd,QAAQ,GAAG,cAAc,MAAM;AAC7B,MAAI;AAAE,YAAQ,KAAK,CAAC,QAAQ,KAAK,SAAS;AAAA,EAAG,QAAQ;AAAE,YAAQ,KAAK,CAAC;AAAA,EAAG;AAC1E,CAAC;AACD,QAAQ,KAAK,WAAW,CAAC,YAA0G;AACjI,MAAI,QAAS;AACb,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,QAAM,QAAQ,MAAM,QAAQ,QAAQ,OAAO,IACvC,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,EACrJ,CAAC;AACH,CAAC;AACD,QAAQ,OAAO,EAAE,OAAO,KAAK,CAAC;","names":[]}
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
- interface SpawnedWorktree {
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): boolean;
158
- listWorktrees(): Array<{
159
- path: string;
160
- head: string;
161
- branch: string | null;
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 {
@@ -1119,6 +1258,7 @@ declare class KithEngine {
1119
1258
  mutexWaiters: Record<string, node_sqlite.SQLOutputValue>[];
1120
1259
  commandGuards: Record<string, node_sqlite.SQLOutputValue>[];
1121
1260
  workspaces: WorkspaceObservation[];
1261
+ worktreeRegistrations: WorktreeRegistration[];
1122
1262
  };
1123
1263
  previewIntegration(agentId: string): {
1124
1264
  ok: boolean;
@@ -1147,6 +1287,8 @@ declare class KithEngine {
1147
1287
  };
1148
1288
  beginWork(params: Parameters<IntentAndTaskEngine['declareIntent']>[0] & {
1149
1289
  isolateWorktree?: boolean;
1290
+ adoptWorktree?: boolean;
1291
+ worktreePath?: string;
1150
1292
  }): {
1151
1293
  worktree: SpawnedWorktree | null;
1152
1294
  workflowMode: "worktrees" | "main";
@@ -1169,6 +1311,8 @@ declare class KithEngine {
1169
1311
  claimNextTask(params: {
1170
1312
  agentId: string;
1171
1313
  isolateWorktree?: boolean;
1314
+ adoptWorktree?: boolean;
1315
+ worktreePath?: string;
1172
1316
  }): {
1173
1317
  worktree: SpawnedWorktree | null;
1174
1318
  workflowMode: "worktrees" | "main";
@@ -1194,6 +1338,8 @@ declare class KithEngine {
1194
1338
  claimNextTaskWhenAvailable(params: {
1195
1339
  agentId: string;
1196
1340
  isolateWorktree?: boolean;
1341
+ adoptWorktree?: boolean;
1342
+ worktreePath?: string;
1197
1343
  waitTimeoutMs: number;
1198
1344
  signal?: AbortSignal;
1199
1345
  }): Promise<{
@@ -1262,19 +1408,28 @@ declare class KithEngine {
1262
1408
  waitTimeoutMs?: number;
1263
1409
  }): {
1264
1410
  ok: boolean;
1265
- mergeResult: SpeculativeMergeResult;
1411
+ mergeResult: null;
1266
1412
  error: string;
1267
1413
  completedTasks?: undefined;
1414
+ notes?: undefined;
1268
1415
  } | {
1269
1416
  ok: boolean;
1417
+ completedTasks: TaskRecord[];
1270
1418
  mergeResult: null;
1419
+ notes: string[];
1420
+ error?: undefined;
1421
+ } | {
1422
+ ok: boolean;
1423
+ mergeResult: SpeculativeMergeResult;
1271
1424
  error: string;
1272
1425
  completedTasks?: undefined;
1426
+ notes?: undefined;
1273
1427
  } | {
1274
1428
  ok: boolean;
1275
1429
  completedTasks: TaskRecord[];
1276
1430
  mergeResult: SpeculativeMergeResult | null;
1277
1431
  error?: undefined;
1432
+ notes?: undefined;
1278
1433
  };
1279
1434
  close(): void;
1280
1435
  }
@@ -1342,12 +1497,14 @@ declare function readCoordinationState(directory?: string, options?: {
1342
1497
  handoffs: HandoffRecord[];
1343
1498
  workflowMode: WorkflowMode;
1344
1499
  workflowModeConfigured: boolean;
1500
+ worktreeRegistrations: WorktreeRegistration[];
1345
1501
  } | {
1346
1502
  state: "ready";
1347
1503
  schemaVersion: number;
1348
1504
  handoffs: HandoffRecord[];
1349
1505
  workflowMode: "worktrees" | "main";
1350
1506
  workflowModeConfigured: boolean;
1507
+ worktreeRegistrations: WorktreeRegistration[];
1351
1508
  fencingEpoch: number;
1352
1509
  agents: AgentRecord[];
1353
1510
  tasks: {
@@ -1407,6 +1564,7 @@ declare function readCoordinationState(directory?: string, options?: {
1407
1564
  commandGuards: Record<string, unknown>[];
1408
1565
  mergeQueue: Record<string, unknown>[];
1409
1566
  recentAgentFiles: Record<string, string[]>;
1567
+ worktreeRegistrations: WorktreeRegistration[];
1410
1568
  truncated: boolean;
1411
1569
  protocolVersion: string;
1412
1570
  observedAt: number;
@@ -1482,6 +1640,7 @@ declare function recoveryReport(directory?: string): {
1482
1640
  handoffs: HandoffRecord[];
1483
1641
  workflowMode: WorkflowMode;
1484
1642
  workflowModeConfigured: boolean;
1643
+ worktreeRegistrations: WorktreeRegistration[];
1485
1644
  } | {
1486
1645
  retainedWorktrees: {
1487
1646
  path: string;
@@ -1503,6 +1662,7 @@ declare function recoveryReport(directory?: string): {
1503
1662
  handoffs: HandoffRecord[];
1504
1663
  workflowMode: "worktrees" | "main";
1505
1664
  workflowModeConfigured: boolean;
1665
+ worktreeRegistrations: WorktreeRegistration[];
1506
1666
  fencingEpoch: number;
1507
1667
  agents: AgentRecord[];
1508
1668
  tasks: {
@@ -1577,6 +1737,7 @@ declare function recoveryReport(directory?: string): {
1577
1737
  commandGuards: Record<string, unknown>[];
1578
1738
  mergeQueue: Record<string, unknown>[];
1579
1739
  recentAgentFiles: Record<string, string[]>;
1740
+ worktreeRegistrations: WorktreeRegistration[];
1580
1741
  truncated: boolean;
1581
1742
  protocolVersion: string;
1582
1743
  observedAt: number;
@@ -1604,7 +1765,7 @@ interface GcOptions {
1604
1765
  interface GcPreservedItem {
1605
1766
  path: string;
1606
1767
  branch: string | null;
1607
- reason: 'active-session' | 'open-handoff' | 'dirty' | 'unmerged';
1768
+ reason: 'active-session' | 'open-handoff' | 'dirty' | 'unmerged' | 'adopted';
1608
1769
  }
1609
1770
  interface GcReport {
1610
1771
  ok: boolean;
@@ -1630,7 +1791,7 @@ interface GcReport {
1630
1791
  declare function resyncStaleIndexEntries(repoRoot: string): number;
1631
1792
  declare function gcCoordination(directory?: string, options?: GcOptions): GcReport;
1632
1793
 
1633
- declare const KITH_VERSION = "0.1.9";
1794
+ declare const KITH_VERSION = "0.2.0";
1634
1795
  declare const KITH_PROTOCOL_VERSION = "1.6.0";
1635
1796
 
1636
- 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, refUpdateResyncRoots, 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 };