@cleocode/core 2026.10.23 → 2026.10.24
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/dist/build-provenance.json +2 -2
- package/dist/internal.d.ts +2 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/orchestrate/index.d.ts +2 -2
- package/dist/orchestrate/index.d.ts.map +1 -1
- package/dist/orchestrate/index.js +1 -1
- package/dist/orchestrate/index.js.map +1 -1
- package/dist/orchestrate/worktree-complete.d.ts +16 -68
- package/dist/orchestrate/worktree-complete.d.ts.map +1 -1
- package/dist/orchestrate/worktree-complete.js +71 -77
- package/dist/orchestrate/worktree-complete.js.map +1 -1
- package/dist/spawn/branch-lock.d.ts +59 -2
- package/dist/spawn/branch-lock.d.ts.map +1 -1
- package/dist/spawn/branch-lock.js +277 -128
- package/dist/spawn/branch-lock.js.map +1 -1
- package/dist/tasks/complete.d.ts +21 -11
- package/dist/tasks/complete.d.ts.map +1 -1
- package/dist/tasks/complete.js +52 -60
- package/dist/tasks/complete.js.map +1 -1
- package/dist/tasks/done-plan.d.ts +2 -0
- package/dist/tasks/done-plan.d.ts.map +1 -1
- package/dist/tasks/done-plan.js +14 -1
- package/dist/tasks/done-plan.js.map +1 -1
- package/package.json +13 -13
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
*/
|
|
41
41
|
import { existsSync, readFileSync } from 'node:fs';
|
|
42
42
|
import { join } from 'node:path';
|
|
43
|
-
import { getLogger } from '../logger.js';
|
|
44
43
|
import { completeAgentWorktreeIntegration, resolveAgentWorktreeRoot, } from '../spawn/branch-lock.js';
|
|
45
44
|
import { appendWorktreeAuditEntry, resolveWorktreeAuditActor, WORKTREE_LIFECYCLE_AUDIT_FILE, } from '../worktree/audit.js';
|
|
46
45
|
// ---------------------------------------------------------------------------
|
|
@@ -231,6 +230,57 @@ export function completeWorktreeForTask(taskId, projectRoot, opts = {}) {
|
|
|
231
230
|
: `No worktree or task branch for ${taskId} — nothing to integrate (task was not worked on a task branch).`,
|
|
232
231
|
};
|
|
233
232
|
}
|
|
233
|
+
// ---- Not provisioned by CLEO: never merged (T14053). --------------------
|
|
234
|
+
if (integration.notProvisioned) {
|
|
235
|
+
appendWorktreeAuditEntry(projectRoot, {
|
|
236
|
+
actor,
|
|
237
|
+
action: 'complete-skip',
|
|
238
|
+
target: worktreePath,
|
|
239
|
+
branch,
|
|
240
|
+
taskId,
|
|
241
|
+
reason: `'${branch}' not provisioned by CLEO — not merged (T14053)`,
|
|
242
|
+
success: true,
|
|
243
|
+
}, opts.lifecycleAuditPath);
|
|
244
|
+
return {
|
|
245
|
+
taskId,
|
|
246
|
+
outcome: 'noop',
|
|
247
|
+
integration,
|
|
248
|
+
reason: integration.hint ?? `'${branch}' was not provisioned by CLEO, so it is not merged.`,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
// ---- Main checkout would be disturbed: refused before any merge. -------
|
|
252
|
+
//
|
|
253
|
+
// T14053 — the merge checks out the default branch in the main checkout, so
|
|
254
|
+
// a checkout on another branch or with uncommitted tracked changes is left
|
|
255
|
+
// alone. Nothing was switched or merged; the worktree is preserved.
|
|
256
|
+
if (integration.rootRefused) {
|
|
257
|
+
appendWorktreeAuditEntry(projectRoot,
|
|
258
|
+
// @sync-invariant none:local-only the main checkout's git state on this machine; an audit-file row, never replicated
|
|
259
|
+
{
|
|
260
|
+
actor,
|
|
261
|
+
action: 'complete-conflict',
|
|
262
|
+
target: worktreePath,
|
|
263
|
+
branch,
|
|
264
|
+
taskId,
|
|
265
|
+
reason: 'main checkout not mergeable as-is — local merge refused (T14053)',
|
|
266
|
+
success: false,
|
|
267
|
+
error: integration.error,
|
|
268
|
+
}, opts.lifecycleAuditPath);
|
|
269
|
+
return {
|
|
270
|
+
taskId,
|
|
271
|
+
outcome: 'conflict',
|
|
272
|
+
integration,
|
|
273
|
+
reason: `Local merge refused: ${integration.error ?? 'the main checkout cannot take it'}`,
|
|
274
|
+
recovery: {
|
|
275
|
+
worktreePath,
|
|
276
|
+
branch,
|
|
277
|
+
steps: [
|
|
278
|
+
`git -C ${JSON.stringify(projectRoot)} status # needs '${integration.targetBranch}' checked out, no uncommitted changes`,
|
|
279
|
+
`cleo orchestrate worktree-complete ${taskId}`,
|
|
280
|
+
],
|
|
281
|
+
},
|
|
282
|
+
};
|
|
283
|
+
}
|
|
234
284
|
// ---- Stale target: refused before any merge, not a conflict. ------------
|
|
235
285
|
//
|
|
236
286
|
// T12773 — the local default branch is behind (or diverged from) origin,
|
|
@@ -298,12 +348,12 @@ export function completeWorktreeForTask(taskId, projectRoot, opts = {}) {
|
|
|
298
348
|
*/
|
|
299
349
|
export { WORKTREE_LIFECYCLE_AUDIT_FILE };
|
|
300
350
|
// ---------------------------------------------------------------------------
|
|
301
|
-
//
|
|
351
|
+
// Integration opt-out for cleo complete <taskId> (T9548 · T14053)
|
|
302
352
|
// ---------------------------------------------------------------------------
|
|
303
353
|
/**
|
|
304
354
|
* Environment variable that, when set to a truthy value (`'1'`, `'true'`,
|
|
305
|
-
* any non-empty string other than `'0'` / `'false'`),
|
|
306
|
-
*
|
|
355
|
+
* any non-empty string other than `'0'` / `'false'`), switches off the worktree
|
|
356
|
+
* integration `cleo complete` runs, like `--no-integrate` (T14053).
|
|
307
357
|
*
|
|
308
358
|
* Use this for manual flows where the operator wants to inspect the worktree
|
|
309
359
|
* before integration, or for CI smoke tests that exercise `cleo complete`
|
|
@@ -331,82 +381,26 @@ export function isAutoWorktreeCompleteDisabled(env = process.env) {
|
|
|
331
381
|
return true;
|
|
332
382
|
}
|
|
333
383
|
/**
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
* Behaviour:
|
|
384
|
+
* Why completion leaves the task's worktree branch alone, or `undefined` when
|
|
385
|
+
* it integrates: `--no-integrate` first, then {@link AUTO_WORKTREE_COMPLETE_ENV}.
|
|
386
|
+
* `cleo complete` and `cleo done --plan` share it, so both say the same (T14053).
|
|
338
387
|
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
* 2. **Worktree absence** — when no CLEO worktree exists for the task
|
|
343
|
-
* (under {@link resolveAgentWorktreeRoot}), the wrapper returns
|
|
344
|
-
* `outcome: 'no-worktree'` immediately. Idempotent: re-running a second
|
|
345
|
-
* time produces the same envelope. The wrapper writes NO audit row in
|
|
346
|
-
* this case — the absence of a worktree is the natural identity element
|
|
347
|
-
* for "already complete".
|
|
348
|
-
* 3. **SDK invoke** — otherwise the wrapper calls
|
|
349
|
-
* {@link completeWorktreeForTask} and maps its outcome into the
|
|
350
|
-
* diagnostic envelope. The SDK itself owns audit-row emission for every
|
|
351
|
-
* real lifecycle event (`complete`, `complete-skip`, `complete-conflict`,
|
|
352
|
-
* `complete-manual`).
|
|
353
|
-
* 4. **Never throw** — the SDK call is wrapped in `try/catch`. A throw is
|
|
354
|
-
* surfaced as `outcome: 'sdk-threw'` with the message in `reason`, so the
|
|
355
|
-
* parent `cleo complete` envelope is never derailed by an auto-merge
|
|
356
|
-
* hiccup. The task completion has already landed — the worktree integration
|
|
357
|
-
* is strictly a best-effort post-step.
|
|
388
|
+
* @param noIntegrate - Whether `--no-integrate` was passed.
|
|
389
|
+
* @param env - Environment to read (defaults to `process.env`).
|
|
390
|
+
* @returns The skip reason, or `undefined`.
|
|
358
391
|
*
|
|
359
|
-
* @
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
* @
|
|
364
|
-
* (used by tests to override audit paths + skip fetch).
|
|
365
|
-
* @returns Diagnostic envelope describing what happened.
|
|
366
|
-
*
|
|
367
|
-
* @task T9548
|
|
392
|
+
* @example
|
|
393
|
+
* ```ts
|
|
394
|
+
* integrationDisabledReason(true); // '--no-integrate was passed; …'
|
|
395
|
+
* ```
|
|
396
|
+
* @task T14053
|
|
368
397
|
*/
|
|
369
|
-
export function
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
if (isAutoWorktreeCompleteDisabled()) {
|
|
373
|
-
|
|
374
|
-
return {
|
|
375
|
-
ran: false,
|
|
376
|
-
outcome: 'env-disabled',
|
|
377
|
-
reason: `${AUTO_WORKTREE_COMPLETE_ENV} is set — auto-merge skipped`,
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
// 2. Worktree absence check.
|
|
381
|
-
const worktreeRoot = resolveAgentWorktreeRoot(projectRoot);
|
|
382
|
-
const worktreePath = join(worktreeRoot, taskId);
|
|
383
|
-
if (!existsSync(worktreePath)) {
|
|
384
|
-
log.debug({ taskId, worktreePath }, 'no CLEO worktree found for task — skipping auto-complete');
|
|
385
|
-
return {
|
|
386
|
-
ran: false,
|
|
387
|
-
outcome: 'no-worktree',
|
|
388
|
-
reason: `No CLEO worktree at ${worktreePath} — nothing to integrate`,
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
// 3. Invoke the SDK. Catch any throw so task-completion is never derailed.
|
|
392
|
-
try {
|
|
393
|
-
const integration = completeWorktreeForTask(taskId, projectRoot, opts);
|
|
394
|
-
log.info({ taskId, outcome: integration.outcome, reason: integration.reason }, 'auto-worktree-complete invoked from cleo complete');
|
|
395
|
-
return {
|
|
396
|
-
ran: true,
|
|
397
|
-
outcome: integration.outcome,
|
|
398
|
-
reason: integration.reason,
|
|
399
|
-
integration,
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
catch (err) {
|
|
403
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
404
|
-
log.warn({ taskId, err: message }, 'auto-worktree-complete SDK threw — task completion preserved');
|
|
405
|
-
return {
|
|
406
|
-
ran: false,
|
|
407
|
-
outcome: 'sdk-threw',
|
|
408
|
-
reason: `completeWorktreeForTask threw: ${message}`,
|
|
409
|
-
};
|
|
398
|
+
export function integrationDisabledReason(noIntegrate, env = process.env) {
|
|
399
|
+
if (noIntegrate)
|
|
400
|
+
return '--no-integrate was passed; the task branch and worktree are left as they are';
|
|
401
|
+
if (isAutoWorktreeCompleteDisabled(env)) {
|
|
402
|
+
return `${AUTO_WORKTREE_COMPLETE_ENV} is set; the task branch and worktree are left as they are`;
|
|
410
403
|
}
|
|
404
|
+
return undefined;
|
|
411
405
|
}
|
|
412
406
|
//# sourceMappingURL=worktree-complete.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worktree-complete.js","sourceRoot":"","sources":["../../src/orchestrate/worktree-complete.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"worktree-complete.js","sourceRoot":"","sources":["../../src/orchestrate/worktree-complete.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,gCAAgC,EAChC,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,6BAA6B,GAC9B,MAAM,sBAAsB,CAAC;AAwF9B,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E;;;;;;;;;GASG;AACH,SAAS,kBAAkB,CACzB,WAAmB,EACnB,MAAc,EACd,oBAA6B;IAE7B,MAAM,SAAS,GACb,oBAAoB,IAAI,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,4BAA4B,CAAC,CAAC;IAC5F,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;QAAE,OAAO,KAAK,CAAC;IAEzC,IAAI,GAAW,CAAC;IAChB,IAAI,CAAC;QACH,GAAG,GAAG,YAA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AC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,OAAO,EAAE,6BAA6B,EAAE,CAAC;AAEzC,8EAA8E;AAC9E,kEAAkE;AAClE,8EAA8E;AAE9E;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,gCAAgC,CAAC;AAE3E;;;;;;;;GAQG;AACH,MAAM,UAAU,8BAA8B,CAAC,MAAyB,OAAO,CAAC,GAAG;IACjF,MAAM,GAAG,GAAG,GAAG,CAAC,0BAA0B,CAAC,CAAC;IAC5C,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,EAAE;QAAE,OAAO,KAAK,CAAC;IAClD,MAAM,OAAO,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IAClC,IAAI,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IACzD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,yBAAyB,CACvC,WAAgC,EAChC,MAAyB,OAAO,CAAC,GAAG;IAEpC,IAAI,WAAW;QACb,OAAO,8EAA8E,CAAC;IACxF,IAAI,8BAA8B,CAAC,GAAG,CAAC,EAAE,CAAC;QACxC,OAAO,GAAG,0BAA0B,4DAA4D,CAAC;IACnG,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* @adr ADR-055
|
|
19
19
|
* @adr ADR-062
|
|
20
20
|
*/
|
|
21
|
-
import type { AgentWorktreeState, EvidenceAtom, FsHardenCapabilities, FsHardenState, WorktreeCleanupResult, WorktreeDisposalBlockers, WorktreeMergeResult, WorktreeSpawnResult } from '@cleocode/contracts';
|
|
21
|
+
import type { AgentWorktreeState, EvidenceAtom, FsHardenCapabilities, FsHardenState, WorktreeCleanupResult, WorktreeDisposalBlockers, WorktreeIntegrationOutcome, WorktreeIntegrationPlan, WorktreeMergeResult, WorktreeSpawnResult } from '@cleocode/contracts';
|
|
22
22
|
import { getGitRoot } from '@cleocode/worktree';
|
|
23
23
|
export { getGitRoot };
|
|
24
24
|
/**
|
|
@@ -269,6 +269,40 @@ export declare function assessUpstreamIntegration(gitRoot: string, branch: strin
|
|
|
269
269
|
remote?: string;
|
|
270
270
|
fetchTimeoutMs?: number;
|
|
271
271
|
}): UpstreamIntegrationAssessment;
|
|
272
|
+
/**
|
|
273
|
+
* Options for {@link planWorktreeIntegration} and the merge run that shares
|
|
274
|
+
* its decision (T14053).
|
|
275
|
+
*/
|
|
276
|
+
export interface WorktreeIntegrationDecisionOptions {
|
|
277
|
+
/** Override the resolved default branch. */
|
|
278
|
+
targetBranch?: string;
|
|
279
|
+
/**
|
|
280
|
+
* Set when integration is switched off (`cleo complete --no-integrate`,
|
|
281
|
+
* `CLEO_NO_AUTO_WORKTREE_COMPLETE`): the decision is `skip` with this reason.
|
|
282
|
+
*/
|
|
283
|
+
disabledReason?: string;
|
|
284
|
+
/** Skip the upstream `git fetch` (the plan never fetches). */
|
|
285
|
+
skipFetch?: boolean;
|
|
286
|
+
/** Timeout for the upstream fetch. */
|
|
287
|
+
fetchTimeoutMs?: number;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Preview what completing `taskId` does with its worktree branch, without
|
|
291
|
+
* changing git: the same decision the merge run makes, from local refs only
|
|
292
|
+
* (no fetch). Shown by `cleo done --plan` (T14053).
|
|
293
|
+
*
|
|
294
|
+
* @param taskId - The CLEO task ID.
|
|
295
|
+
* @param projectRoot - Absolute path to the project root.
|
|
296
|
+
* @param opts - Target override and the switched-off reason, if any.
|
|
297
|
+
* @returns Branch, worktree path, target branch, `merge`/`skip`/`refuse` and why.
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* ```ts
|
|
301
|
+
* planWorktreeIntegration('T123', root).action; // 'skip' for a task merged by PR
|
|
302
|
+
* ```
|
|
303
|
+
* @task T14053
|
|
304
|
+
*/
|
|
305
|
+
export declare function planWorktreeIntegration(taskId: string, projectRoot: string, opts?: Omit<WorktreeIntegrationDecisionOptions, 'skipFetch' | 'fetchTimeoutMs'>): WorktreeIntegrationPlan;
|
|
272
306
|
/**
|
|
273
307
|
* Complete a worker task's worktree via `git merge --no-ff` (ADR-062).
|
|
274
308
|
*
|
|
@@ -281,6 +315,11 @@ export declare function assessUpstreamIntegration(gitRoot: string, branch: strin
|
|
|
281
315
|
*
|
|
282
316
|
* 1. Resolve target branch via {@link getDefaultBranch} (or `opts.targetBranch`
|
|
283
317
|
* override). NEVER hardcodes "main".
|
|
318
|
+
* 1. T14053: {@link decideWorktreeIntegration} first — the same decision
|
|
319
|
+
* `cleo done --plan` shows. A branch CLEO did not provision is skipped
|
|
320
|
+
* (`notProvisioned`), never merged; a main checkout on another branch,
|
|
321
|
+
* with uncommitted tracked changes, or a linked worktree is refused
|
|
322
|
+
* (`rootRefused`) without switching or merging anything.
|
|
284
323
|
* 1a. T12773: {@link assessUpstreamIntegration} — when `task/<id>` already
|
|
285
324
|
* landed on `origin/<targetBranch>` the merge is skipped
|
|
286
325
|
* (`landedUpstream: true`); when it has no commits beyond the local
|
|
@@ -308,13 +347,16 @@ export declare function assessUpstreamIntegration(gitRoot: string, branch: strin
|
|
|
308
347
|
* @param opts.evidence - The task's evidence atoms; the prune keeps a worktree holding the only copy (T13696).
|
|
309
348
|
* @param opts.fetchTimeoutMs - Timeout for the upstream fetch (default
|
|
310
349
|
* {@link UPSTREAM_FETCH_TIMEOUT_MS}).
|
|
311
|
-
* @
|
|
350
|
+
* @param opts.disabledReason - Integration is switched off; nothing is touched (T14053).
|
|
351
|
+
* @returns Merge integration result, with the decision it acted on in `plan`.
|
|
312
352
|
*
|
|
313
353
|
* @task T1587
|
|
354
|
+
* @task T14053
|
|
314
355
|
* @adr ADR-062
|
|
315
356
|
*/
|
|
316
357
|
export declare function completeAgentWorktreeViaMerge(taskId: string, projectRoot: string, opts?: {
|
|
317
358
|
targetBranch?: string;
|
|
359
|
+
disabledReason?: string;
|
|
318
360
|
taskTitle?: string;
|
|
319
361
|
skipFetch?: boolean;
|
|
320
362
|
fetchTimeoutMs?: number;
|
|
@@ -364,6 +406,21 @@ export declare function completeAgentWorktreeIntegration(taskId: string, project
|
|
|
364
406
|
auditLogPath?: string;
|
|
365
407
|
evidence?: readonly EvidenceAtom[];
|
|
366
408
|
}): WorktreeIntegrationResult;
|
|
409
|
+
/**
|
|
410
|
+
* The single integration result for a completion envelope (T14053): what the
|
|
411
|
+
* run actually did, so it can never contradict the merge. `merge` only when a
|
|
412
|
+
* merge commit was made; a decided merge that failed reads as `refuse`.
|
|
413
|
+
*
|
|
414
|
+
* @param result - The merge run's result (its `plan` is the decision it acted on).
|
|
415
|
+
* @returns `{branch, worktreePath, targetBranch, action, reason, mergeCommit?, pushed: false}`.
|
|
416
|
+
*
|
|
417
|
+
* @example
|
|
418
|
+
* ```ts
|
|
419
|
+
* integrationOutcome(completeAgentWorktreeIntegration('T1', root)).action; // 'skip'
|
|
420
|
+
* ```
|
|
421
|
+
* @task T14053
|
|
422
|
+
*/
|
|
423
|
+
export declare function integrationOutcome(result: WorktreeMergeResult): WorktreeIntegrationOutcome;
|
|
367
424
|
/** Result of {@link ensureGitShimDir}. */
|
|
368
425
|
export interface GitShimInstall {
|
|
369
426
|
/** Directory to prepend to a worker's PATH. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branch-lock.d.ts","sourceRoot":"","sources":["../../src/spawn/branch-lock.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;GAmBG;AAiBH,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACb,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAc7B,OAAO,EAGL,UAAU,
|
|
1
|
+
{"version":3,"file":"branch-lock.d.ts","sourceRoot":"","sources":["../../src/spawn/branch-lock.ts"],"names":[],"m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