@cleocode/cleo 2026.4.114 → 2026.4.115

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/cli/index.js CHANGED
@@ -705,6 +705,13 @@ var init_variable_substitution = __esm({
705
705
  }
706
706
  });
707
707
 
708
+ // packages/contracts/src/operations/worktree.ts
709
+ var init_worktree = __esm({
710
+ "packages/contracts/src/operations/worktree.ts"() {
711
+ "use strict";
712
+ }
713
+ });
714
+
708
715
  // packages/contracts/src/operations/index.ts
709
716
  var init_operations = __esm({
710
717
  "packages/contracts/src/operations/index.ts"() {
@@ -725,6 +732,7 @@ var init_operations = __esm({
725
732
  init_tasks();
726
733
  init_validate();
727
734
  init_variable_substitution();
735
+ init_worktree();
728
736
  }
729
737
  });
730
738
 
@@ -735,6 +743,13 @@ var init_orchestration_hierarchy = __esm({
735
743
  }
736
744
  });
737
745
 
746
+ // packages/contracts/src/peer.ts
747
+ var init_peer = __esm({
748
+ "packages/contracts/src/peer.ts"() {
749
+ "use strict";
750
+ }
751
+ });
752
+
738
753
  // packages/contracts/src/session.ts
739
754
  var init_session2 = __esm({
740
755
  "packages/contracts/src/session.ts"() {
@@ -845,6 +860,7 @@ var init_src = __esm({
845
860
  init_operations();
846
861
  init_params();
847
862
  init_orchestration_hierarchy();
863
+ init_peer();
848
864
  init_session2();
849
865
  init_status_registry();
850
866
  init_task_evidence();
@@ -9617,13 +9633,15 @@ async function composeSpawnForTask(taskId, root, options = {}) {
9617
9633
  sessionId: options.sessionId ?? null,
9618
9634
  role: inferredRole,
9619
9635
  protocol: options.protocol,
9620
- skipAtomicityCheck: options.skipAtomicityCheck ?? false
9636
+ skipAtomicityCheck: options.skipAtomicityCheck ?? false,
9637
+ worktreePath: options.worktreePath,
9638
+ worktreeBranch: options.worktreeBranch
9621
9639
  });
9622
9640
  } finally {
9623
9641
  db.close();
9624
9642
  }
9625
9643
  }
9626
- async function orchestrateSpawn(taskId, protocolType, projectRoot, tier) {
9644
+ async function orchestrateSpawn(taskId, protocolType, projectRoot, tier, noWorktree) {
9627
9645
  if (!taskId) {
9628
9646
  return engineError("E_INVALID_INPUT", "taskId is required");
9629
9647
  }
@@ -9650,10 +9668,43 @@ async function orchestrateSpawn(taskId, protocolType, projectRoot, tier) {
9650
9668
  } catch {
9651
9669
  activeSessionId = null;
9652
9670
  }
9671
+ let sdkWorktreeResult = null;
9672
+ let worktreePath;
9673
+ let worktreeBranch;
9674
+ if (noWorktree) {
9675
+ getLogger2("engine:orchestrate").info(
9676
+ { taskId },
9677
+ "T1140 --no-worktree: worktree provisioning skipped (audit logged)"
9678
+ );
9679
+ try {
9680
+ const accessor2 = await getAccessor2(root);
9681
+ await accessor2.appendLog({
9682
+ action: "orchestrate.spawn.no-worktree",
9683
+ taskId,
9684
+ actor: "orchestrate-engine",
9685
+ details: { reason: "--no-worktree flag set by caller", taskId }
9686
+ });
9687
+ } catch {
9688
+ }
9689
+ } else {
9690
+ try {
9691
+ const { spawnWorktree } = await import("@cleocode/core/internal");
9692
+ sdkWorktreeResult = await spawnWorktree(root, { taskId });
9693
+ worktreePath = sdkWorktreeResult.path;
9694
+ worktreeBranch = sdkWorktreeResult.branch;
9695
+ } catch (wtErr) {
9696
+ getLogger2("engine:orchestrate").warn(
9697
+ { taskId, err: wtErr },
9698
+ `T1140 worktree creation failed for ${taskId} \u2014 spawning without isolation: ${wtErr instanceof Error ? wtErr.message : String(wtErr)}`
9699
+ );
9700
+ }
9701
+ }
9653
9702
  const payload = await composeSpawnForTask(taskId, root, {
9654
9703
  tier,
9655
9704
  sessionId: activeSessionId,
9656
- protocol: protocolType
9705
+ protocol: protocolType,
9706
+ worktreePath,
9707
+ worktreeBranch
9657
9708
  });
9658
9709
  if (!payload.atomicity.allowed) {
9659
9710
  return engineError(
@@ -9669,20 +9720,21 @@ async function orchestrateSpawn(taskId, protocolType, projectRoot, tier) {
9669
9720
  }
9670
9721
  );
9671
9722
  }
9672
- let worktreeResult = null;
9673
- try {
9674
- const { buildWorktreeSpawnResult, createAgentWorktree, ensureGitShimDir } = await import("@cleocode/core/internal");
9675
- const worktree = createAgentWorktree(taskId, root);
9676
- const shimDir = ensureGitShimDir(root);
9677
- worktreeResult = buildWorktreeSpawnResult(worktree, shimDir);
9678
- } catch (wtErr) {
9679
- getLogger2("engine:orchestrate").warn(
9680
- { taskId, err: wtErr },
9681
- `T1118 worktree creation failed for ${taskId} \u2014 spawning without isolation: ${wtErr instanceof Error ? wtErr.message : String(wtErr)}`
9682
- );
9683
- }
9684
- const finalPrompt = worktreeResult ? `${worktreeResult.preamble}
9685
- ${payload.prompt}` : payload.prompt;
9723
+ const finalPrompt = payload.prompt;
9724
+ const worktreeAdapterResult = sdkWorktreeResult ? {
9725
+ worktree: {
9726
+ path: sdkWorktreeResult.path,
9727
+ branch: sdkWorktreeResult.branch,
9728
+ taskId: sdkWorktreeResult.taskId,
9729
+ baseRef: sdkWorktreeResult.baseRef,
9730
+ projectHash: sdkWorktreeResult.projectHash,
9731
+ createdAt: sdkWorktreeResult.createdAt,
9732
+ locked: sdkWorktreeResult.locked
9733
+ },
9734
+ envVars: sdkWorktreeResult.envVars,
9735
+ cwd: sdkWorktreeResult.path,
9736
+ preamble: sdkWorktreeResult.preamble
9737
+ } : null;
9686
9738
  return {
9687
9739
  success: true,
9688
9740
  data: {
@@ -9694,10 +9746,10 @@ ${payload.prompt}` : payload.prompt;
9694
9746
  harnessHint: payload.harnessHint,
9695
9747
  atomicity: payload.atomicity,
9696
9748
  meta: payload.meta,
9697
- // T1118 L1+L2 — worktree binding for harness adapters.
9698
- worktree: worktreeResult?.worktree ?? null,
9699
- worktreeEnv: worktreeResult?.envVars ?? null,
9700
- worktreeCwd: worktreeResult?.cwd ?? null,
9749
+ // T1118 L1+L2 / T1140 — worktree binding for harness adapters.
9750
+ worktree: worktreeAdapterResult?.worktree ?? null,
9751
+ worktreeEnv: worktreeAdapterResult?.envVars ?? null,
9752
+ worktreeCwd: worktreeAdapterResult?.cwd ?? null,
9701
9753
  spawnContext: {
9702
9754
  taskId: payload.taskId,
9703
9755
  protocol: payload.meta.protocol,
@@ -26285,7 +26337,14 @@ var init_orchestrate2 = __esm({
26285
26337
  }
26286
26338
  const protocolType = params?.protocolType;
26287
26339
  const tier = params?.tier;
26288
- const result = await orchestrateSpawn(taskId, protocolType, projectRoot, tier);
26340
+ const noWorktree = params?.noWorktree;
26341
+ const result = await orchestrateSpawn(
26342
+ taskId,
26343
+ protocolType,
26344
+ projectRoot,
26345
+ tier,
26346
+ noWorktree
26347
+ );
26289
26348
  return wrapResult(result, "mutate", "orchestrate", operation, startTime);
26290
26349
  }
26291
26350
  case "handoff": {
@@ -50383,6 +50442,10 @@ var spawnCommand2 = defineCommand({
50383
50442
  tier: {
50384
50443
  type: "string",
50385
50444
  description: "Protocol tier: 0 (minimal), 1 (standard), 2 (full), or auto (default \u2014 inferred from role+size+labels via T892 heuristics)"
50445
+ },
50446
+ "no-worktree": {
50447
+ type: "boolean",
50448
+ description: "Skip worktree provisioning for this spawn. The opt-out is logged to the audit log (T1140)."
50386
50449
  }
50387
50450
  },
50388
50451
  async run({ args }) {
@@ -50400,7 +50463,8 @@ var spawnCommand2 = defineCommand({
50400
50463
  {
50401
50464
  taskId: args.taskId,
50402
50465
  protocolType: args.protocol,
50403
- tier
50466
+ tier,
50467
+ noWorktree: args["no-worktree"] === true
50404
50468
  },
50405
50469
  { command: "orchestrate" }
50406
50470
  );