opencode-swarm 7.199.0 → 7.199.2

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.
Files changed (86) hide show
  1. package/.opencode/skills/swarm-pr-feedback/SKILL.md +9 -9
  2. package/binaries/win32-arm64/swarm-sandbox-runner.exe +0 -0
  3. package/binaries/win32-x64/swarm-sandbox-runner.exe +0 -0
  4. package/dist/agents/architect.d.ts +1 -1
  5. package/dist/background/workspace-snapshot.d.ts +51 -0
  6. package/dist/cli/{auto-checkpoint-1wf9n5yj.js → auto-checkpoint-0ajspw7n.js} +6 -6
  7. package/dist/cli/{checkpoint-gw6f4ghv.js → checkpoint-1dsrg3ft.js} +10 -10
  8. package/dist/cli/{coder-settlement-qy77s1x6.js → coder-settlement-189074m3.js} +6 -6
  9. package/dist/cli/{config-doctor-2tcp28sc.js → config-doctor-20pd12nw.js} +9 -9
  10. package/dist/cli/{core-pz87qafz.js → core-5bqceeft.js} +2 -2
  11. package/dist/cli/{curator-fvnptcnw.js → curator-b3zn9w9q.js} +29 -29
  12. package/dist/cli/{curator-drift-c1x7jdxj.js → curator-drift-ka477rrz.js} +6 -6
  13. package/dist/cli/{curator-llm-factory-cg1p6ysr.js → curator-llm-factory-nbprwszt.js} +29 -29
  14. package/dist/cli/{doctor-knowledge-receipt-phase-id-xwyb5sf8.js → doctor-knowledge-receipt-phase-id-nrk52ak6.js} +5 -5
  15. package/dist/cli/{evidence-summary-service-47cptvea.js → evidence-summary-service-qrr8zjhj.js} +11 -11
  16. package/dist/cli/{gate-evidence-77bzfckz.js → gate-evidence-cbs5xh1n.js} +3 -3
  17. package/dist/cli/{guardrail-explain-0ap0a51w.js → guardrail-explain-6xd6r3f5.js} +30 -30
  18. package/dist/cli/{guardrail-log-xw37f7ws.js → guardrail-log-qn1sqjs9.js} +6 -5
  19. package/dist/cli/{guardrail-reset-3fq8xdjf.js → guardrail-reset-ha3w0nby.js} +29 -29
  20. package/dist/cli/{hive-promoter-bmdgnmnf.js → hive-promoter-2dnv2xrg.js} +29 -29
  21. package/dist/cli/{index-vbm2ykr9.js → index-46sgm9rd.js} +1 -1
  22. package/dist/cli/{index-gds6c8qt.js → index-4py6w3hy.js} +4 -4
  23. package/dist/cli/{index-3x07b03s.js → index-5mbpybdm.js} +2 -2
  24. package/dist/cli/{index-ckcdheqx.js → index-5v0wkcd9.js} +2 -2
  25. package/dist/cli/{index-e5ecn73v.js → index-67ad9qbe.js} +1 -1
  26. package/dist/cli/{index-pqrepne6.js → index-7d3ft7by.js} +1 -1
  27. package/dist/cli/{index-mefad009.js → index-9qc7d3q2.js} +15 -11
  28. package/dist/cli/{index-ye9bze9s.js → index-bz5h9ttt.js} +5 -5
  29. package/dist/cli/{index-bjzxbxpw.js → index-c2eqtpk1.js} +2 -2
  30. package/dist/cli/{index-2f9tsejp.js → index-cpdcscwt.js} +2 -2
  31. package/dist/cli/{index-26h8fb7t.js → index-djtqb6b7.js} +2 -2
  32. package/dist/cli/{index-jccs3fgn.js → index-dyp5807d.js} +13 -1
  33. package/dist/cli/{index-1fwm8vqr.js → index-eyt9ryhd.js} +4 -4
  34. package/dist/cli/{index-a5xzwxdq.js → index-gfdz460m.js} +1 -1
  35. package/dist/cli/{index-awt5dpam.js → index-h349p91m.js} +32 -1
  36. package/dist/cli/{index-42dtc5nd.js → index-hfsyvkn0.js} +4 -4
  37. package/dist/cli/{index-3gwh8c9d.js → index-hj76n215.js} +1 -1
  38. package/dist/cli/{index-9ztsfved.js → index-hz2609qt.js} +117 -2
  39. package/dist/cli/{index-b5k6etf9.js → index-jrdepg4w.js} +2 -2
  40. package/dist/cli/{index-vh87e91s.js → index-km9tjdgw.js} +3 -3
  41. package/dist/cli/{index-kxaxf3en.js → index-kwh4b9cm.js} +246 -19
  42. package/dist/cli/{index-tnrq0pg8.js → index-mb3y5cgy.js} +6 -6
  43. package/dist/cli/{index-71g0ps66.js → index-mbygjbj8.js} +4 -4
  44. package/dist/cli/{index-kjhsssaq.js → index-qksw8p51.js} +29 -29
  45. package/dist/cli/{index-y9ckbta5.js → index-r9s68beh.js} +1 -1
  46. package/dist/cli/{index-79b9re6h.js → index-skg220qc.js} +441 -120
  47. package/dist/cli/{index-mzsj4kkv.js → index-t6gsqe10.js} +2 -2
  48. package/dist/cli/{index-qdwccqv5.js → index-vd6s2mxq.js} +1 -1
  49. package/dist/cli/{index-r52wrpb7.js → index-ve0ncsnc.js} +1 -1
  50. package/dist/cli/{index-jjsjjefm.js → index-wz8zc7w3.js} +6 -6
  51. package/dist/cli/{index-zd15v0gr.js → index-xapmt05a.js} +3 -3
  52. package/dist/cli/{index-hqrkr9ag.js → index-xfzkq1k4.js} +5 -5
  53. package/dist/cli/{index-zg5gnn3m.js → index-y4kjbf12.js} +1 -1
  54. package/dist/cli/{index-4hnxtssf.js → index-zvjrymp9.js} +31 -31
  55. package/dist/cli/index.js +30 -30
  56. package/dist/cli/{knowledge-escalator-w7b32ak4.js → knowledge-escalator-k1mssp9r.js} +8 -8
  57. package/dist/cli/{knowledge-events-y0kb9wbe.js → knowledge-events-f7c0z8rb.js} +6 -6
  58. package/dist/cli/{knowledge-store-knrqgmyk.js → knowledge-store-50vj5db0.js} +1 -1
  59. package/dist/cli/{knowledge-validator-zg7d9z8p.js → knowledge-validator-afxk6dvk.js} +2 -2
  60. package/dist/cli/{mcp-3k1t9q6h.js → mcp-j0grf8gt.js} +1 -1
  61. package/dist/cli/{model-preflight-k92fnbq8.js → model-preflight-ks9j40t5.js} +29 -29
  62. package/dist/cli/{pending-delegations-ape3hrm0.js → pending-delegations-e42yvvj0.js} +2 -2
  63. package/dist/cli/{pr-subscriptions-cn13b19x.js → pr-subscriptions-e92eg4ts.js} +1 -1
  64. package/dist/cli/{pr-workflow-gate-74j5mcxh.js → pr-workflow-gate-zqwde6r6.js} +29 -29
  65. package/dist/cli/{runner-qe3fkzx5.js → runner-7sd43gan.js} +1 -1
  66. package/dist/cli/{scan-cursor-4xxfc42h.js → scan-cursor-yehnf9jt.js} +2 -2
  67. package/dist/cli/{schema-qv9bvhyz.js → schema-jw861rj0.js} +2 -2
  68. package/dist/cli/{scope-persistence-fmva1cv0.js → scope-persistence-p778xbbq.js} +7 -7
  69. package/dist/cli/{server-s5ac6ydk.js → server-nkhvbbc5.js} +102 -40
  70. package/dist/cli/{skill-generator-19ckpm74.js → skill-generator-dd1w9p3t.js} +9 -9
  71. package/dist/cli/{snapshot-coordination-init-7c0s65jw.js → snapshot-coordination-init-11qb0jbs.js} +29 -29
  72. package/dist/cli/{speckit-checkoff-9b2zj8hd.js → speckit-checkoff-d92ej93g.js} +4 -4
  73. package/dist/cli/{workspace-snapshot-vhvrkbbb.js → workspace-snapshot-4zfj5wnd.js} +13 -1
  74. package/dist/cli/{worktree-collision-ownership-3r669yvh.js → worktree-collision-ownership-81wpkagz.js} +2 -2
  75. package/dist/cli/{worktree-isolation-5dydsr8c.js → worktree-isolation-zw3ydg49.js} +29 -29
  76. package/dist/config/skill-contract-digest.d.ts +8 -0
  77. package/dist/hooks/guardrails/file-authority.d.ts +17 -0
  78. package/dist/hooks/pr-workflow-gate.d.ts +32 -23
  79. package/dist/host/v2/events.d.ts +19 -1
  80. package/dist/host/v2/hooks.d.ts +25 -0
  81. package/dist/index.js +131 -128
  82. package/dist/tools/index.d.ts +1 -0
  83. package/dist/tools/manifest.d.ts +1 -0
  84. package/dist/tools/prepare-pr-feedback-commit-message.d.ts +30 -0
  85. package/dist/tools/tool-metadata.d.ts +4 -4
  86. package/package.json +1 -1
@@ -685,6 +685,37 @@ function selfHealAuthorityKeys(directory, keys) {
685
685
  mergeAuthorityKeys(directory, state, keys);
686
686
  } catch {}
687
687
  }
688
+ function getCoderRetryEscalationActions(directory, taskId, retryEpoch) {
689
+ const actions = new Set;
690
+ const prefix = `retry|${taskId}|${retryEpoch}|`;
691
+ const state = loadAuthorityIndex(directory);
692
+ if (state.kind === "corrupt") {
693
+ throw new Error("CORE_EVENT_AUTHORITY_INDEX_UNREADABLE");
694
+ }
695
+ const heal = [];
696
+ if (state.kind === "ok") {
697
+ for (const key of Object.keys(state.index.entries)) {
698
+ if (key.startsWith(prefix)) {
699
+ const action = key.slice(prefix.length);
700
+ if (RETRY_ACTIONS.has(action)) {
701
+ actions.add(action);
702
+ }
703
+ }
704
+ }
705
+ }
706
+ for (const event of scanWindowFor(directory, (e) => e.type === AUTHORITY_RETRY && e.taskId === taskId && e.retryEpoch === retryEpoch && typeof e.action === "string" && RETRY_ACTIONS.has(e.action))) {
707
+ const action = event.action;
708
+ if (!actions.has(action)) {
709
+ actions.add(action);
710
+ const key = authorityKeyFor(event);
711
+ if (key)
712
+ heal.push(key);
713
+ }
714
+ }
715
+ if (heal.length > 0)
716
+ selfHealAuthorityKeys(directory, heal);
717
+ return actions;
718
+ }
688
719
  function hasAuthorityEvent(directory, key, predicate) {
689
720
  const state = loadAuthorityIndex(directory);
690
721
  if (state.kind === "corrupt") {
@@ -904,4 +935,4 @@ function emitHealth(directory, payload, preloadedAuthorityState) {
904
935
  _internals.emitHealth(directory, payload, preloadedAuthorityState);
905
936
  }
906
937
 
907
- export { readCoreEvents, getCoreEventCoverage, CORE_EVENT_LOCKED, appendCoreEventSync, appendCoreEventsSync, hasSpecDriftAuditEvent, hasTaskRepairAuditEvent, finalizeCoreEventsForClose };
938
+ export { readCoreEvents, getCoreEventCoverage, CORE_EVENT_LOCKED, appendCoreEventSync, appendCoreEventsSync, getCoderRetryEscalationActions, hasSpecDriftAuditEvent, hasTaskRepairAuditEvent, finalizeCoreEventsForClose };
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  loadPlanJsonOnly
4
- } from "./index-tnrq0pg8.js";
4
+ } from "./index-mb3y5cgy.js";
5
5
  import {
6
6
  isCanonicalPathWithinRoot
7
7
  } from "./index-6b295cas.js";
@@ -14,7 +14,7 @@ import {
14
14
  legacyEpicIssuePath,
15
15
  migrateLegacyEpicConfig,
16
16
  resolveEpicConfig
17
- } from "./index-qdwccqv5.js";
17
+ } from "./index-vd6s2mxq.js";
18
18
  import {
19
19
  FALLBACK_MODELS_MAX,
20
20
  GATE_CONFIG_KNOWN_SECTION_KEYS,
@@ -25,13 +25,13 @@ import {
25
25
  init_schema,
26
26
  retiredEpicKeyReplacement,
27
27
  stripKnownSwarmPrefix
28
- } from "./index-3x07b03s.js";
28
+ } from "./index-5mbpybdm.js";
29
29
  import {
30
30
  ALL_AGENT_NAMES,
31
31
  TOOL_NAME_SET,
32
32
  init_constants,
33
33
  init_tool_metadata
34
- } from "./index-hqrkr9ag.js";
34
+ } from "./index-xfzkq1k4.js";
35
35
  import {
36
36
  log
37
37
  } from "./index-zgwm4ryv.js";
@@ -4745,7 +4745,7 @@ async function reconcileLegacyCoderSettlements(directory, maxRecords, onReconcil
4745
4745
  const candidates = readDelegations(directory).filter((record) => record.normalizedAgent === "coder" && Boolean(record.legacyCoderSettlementTransfer) && Boolean(record.terminalResult)).slice(0, maxRecords);
4746
4746
  if (candidates.length === 0)
4747
4747
  return 0;
4748
- const { transferCoderSettlementToBackground } = await import("./coder-settlement-qy77s1x6.js");
4748
+ const { transferCoderSettlementToBackground } = await import("./coder-settlement-189074m3.js");
4749
4749
  let transferred = 0;
4750
4750
  for (const record of candidates) {
4751
4751
  try {
@@ -201,8 +201,9 @@ async function runGitAsyncDetailed(directory, args, timeoutMs) {
201
201
  } catch {}
202
202
  }
203
203
  }
204
+ var gitSnapshotRelativePathPattern = /^(?:\.\/|\.?(?=[A-Za-z0-9]))(?:\.?[A-Za-z0-9][A-Za-z0-9._-]*\/)*\.?[A-Za-z0-9][A-Za-z0-9._-]*$/;
204
205
  function readGitTextAtRevision(directory, revision, relativePath) {
205
- if (!isSafeGitRevisionToken(revision) || !/^\.?(?:[A-Za-z0-9][A-Za-z0-9._-]*\/)*[A-Za-z0-9][A-Za-z0-9._-]*$/.test(relativePath) || relativePath.split("/").includes("..")) {
206
+ if (!isSafeGitRevisionToken(revision) || !gitSnapshotRelativePathPattern.test(relativePath) || relativePath.split("/").includes("..")) {
206
207
  return null;
207
208
  }
208
209
  const result = _internals.spawnSync(_internals.resolveGitExecutable(), ["-C", directory, "show", `${revision}:${relativePath}`], {
@@ -533,6 +534,120 @@ async function resolveIsWorkingTreeCleanAsync(directory) {
533
534
  ]);
534
535
  return status === null ? null : status.length === 0;
535
536
  }
537
+ async function resolveWorkingTreeDirtyPathsAsync(directory) {
538
+ const status = await runGitAsync(directory, [
539
+ "status",
540
+ "--porcelain=v1",
541
+ "-z",
542
+ "--untracked-files=all"
543
+ ]);
544
+ if (status === null)
545
+ return null;
546
+ const paths = [];
547
+ let skipNextRecord = false;
548
+ for (const entry of status.split("\x00")) {
549
+ if (entry.length === 0)
550
+ continue;
551
+ if (skipNextRecord) {
552
+ skipNextRecord = false;
553
+ continue;
554
+ }
555
+ if (entry.length < 4)
556
+ continue;
557
+ const statusCode = entry.slice(0, 2);
558
+ if (statusCode.startsWith("R") || statusCode.startsWith("C")) {
559
+ skipNextRecord = true;
560
+ }
561
+ const rawPath = entry.slice(3);
562
+ if (rawPath.length === 0)
563
+ continue;
564
+ paths.push(rawPath);
565
+ }
566
+ return paths;
567
+ }
568
+ async function resolvePrWorkflowChangedPathSetAsync(directory, baseHeadSha) {
569
+ if (!/^[0-9a-f]{40}$/i.test(baseHeadSha))
570
+ return null;
571
+ const diff = await runGitAsync(directory, [
572
+ "diff",
573
+ "--no-ext-diff",
574
+ "--name-only",
575
+ "-z",
576
+ baseHeadSha
577
+ ]);
578
+ if (diff === null)
579
+ return null;
580
+ const status = await runGitAsync(directory, [
581
+ "status",
582
+ "--porcelain=v1",
583
+ "-z",
584
+ "--untracked-files=all"
585
+ ]);
586
+ if (status === null)
587
+ return null;
588
+ const set = new Set;
589
+ const normalize = (value) => value.replace(/\\/g, "/").replace(/^\.\//, "");
590
+ for (const name of diff.split("\x00")) {
591
+ if (name.length > 0)
592
+ set.add(normalize(name));
593
+ }
594
+ let skipNextRecord = false;
595
+ for (const entry of status.split("\x00")) {
596
+ if (entry.length === 0)
597
+ continue;
598
+ if (skipNextRecord) {
599
+ skipNextRecord = false;
600
+ continue;
601
+ }
602
+ if (entry.length < 4 || entry[2] !== " ")
603
+ continue;
604
+ const statusCode = entry.slice(0, 2);
605
+ if (statusCode.includes("R") || statusCode.includes("C")) {
606
+ skipNextRecord = true;
607
+ }
608
+ const rawPath = entry.slice(3);
609
+ if (rawPath.length === 0)
610
+ continue;
611
+ set.add(normalize(rawPath));
612
+ }
613
+ return set;
614
+ }
615
+ async function resolveRepoTopLevelAsync(directory) {
616
+ const toplevel = await runGitAsync(directory, [
617
+ "rev-parse",
618
+ "--show-toplevel"
619
+ ]);
620
+ if (toplevel === null || toplevel.length === 0)
621
+ return null;
622
+ return toplevel;
623
+ }
624
+ async function resolveLocalRefHeadAsync(directory, ref) {
625
+ if (!/^[A-Za-z0-9._/-]+$/.test(ref))
626
+ return null;
627
+ const sha = await runGitAsync(directory, [
628
+ "rev-parse",
629
+ "--verify",
630
+ `${ref}^{commit}`
631
+ ]);
632
+ return sha && /^[0-9a-f]{40}$/i.test(sha) ? sha.toLowerCase() : null;
633
+ }
634
+ async function resolveIsAncestorAsync(directory, ancestor, descendant) {
635
+ if (!/^[0-9a-f]{40}$/i.test(ancestor) || !/^[0-9a-f]{40}$/i.test(descendant))
636
+ return false;
637
+ const out = await runGitAsyncDetailed(directory, ["merge-base", "--is-ancestor", ancestor, descendant], _internals.gitTimeoutMs);
638
+ if (!out.ok) {
639
+ if (out.reason === "git-failed")
640
+ return false;
641
+ return null;
642
+ }
643
+ return true;
644
+ }
645
+ async function fastForwardToRefAsync(directory, ref) {
646
+ if (!/^[A-Za-z0-9._/-]+$/.test(ref))
647
+ return false;
648
+ const out = await runGitAsync(directory, ["merge", "--ff-only", "--", ref], 15000);
649
+ return out !== null;
650
+ }
536
651
  function resolveCommitCountSince(directory, baseHeadSha, currentHeadSha) {
537
652
  if (!isSafeGitRevisionToken(baseHeadSha) || !isSafeGitRevisionToken(currentHeadSha))
538
653
  return null;
@@ -1322,4 +1437,4 @@ var _internals = {
1322
1437
  readChangedFileSync: (filePath) => fs.readFileSync(filePath)
1323
1438
  };
1324
1439
 
1325
- export { readGitTextAtRevision, resolveCurrentGitHead, resolveCurrentGitHeadAsync, resolveExactMergeBase, resolveExactMergeBaseAsync, resolvePrReviewDiffStats, resolvePrReviewDiffStatsAsync, resolveCurrentUpstreamRemoteRef, resolveCurrentUpstreamPushTarget, resolveCurrentUpstreamPushTargetAsync, resolveCurrentLocalHeadRefAsync, resolveExactRemoteBranchHead, resolveExactRemoteBranchHeadAsync, redactRemoteUrlIdentity, resolveRemoteUrlIdentity, resolveRemoteUrlIdentityAsync, resolveGitControlStateDigest, resolveGitControlStateDigestAsync, resolveIsWorkingTreeClean, resolveIsWorkingTreeCleanAsync, resolveCommitCountSince, resolveCommitCountSinceAsync, resolveIsExactSingleChildCommit, resolveIsExactSingleChildCommitAsync, resolveRemoteRefsContainingHead, resolveRemoteRefsContainingHeadAsync, resolvePrFeedbackTrackingCandidatesAsync, switchPrFeedbackTrackingCandidateAsync, resolvePrWorkflowRevisionDigestDetailed, resolvePrWorkflowRevisionDigest, resolvePrWorkflowRevisionDigestDetailedAsync, resolvePrWorkflowRevisionDigestAsync, parsePorcelainPaths, isSwarmRuntimePath, parsePorcelainV2Snapshot, captureWorkspaceSnapshot, captureWorkspaceSnapshotAsync, shouldSkipSnapshot, changedFilesSinceSnapshot, changedFilesSinceSnapshotAsync, committedFilesBetween, workspaceSnapshotMatches, compareWorkspaceSnapshot, compareWorkspaceSnapshots, digest, _internals };
1440
+ export { readGitTextAtRevision, resolveCurrentGitHead, resolveCurrentGitHeadAsync, resolveExactMergeBase, resolveExactMergeBaseAsync, resolvePrReviewDiffStats, resolvePrReviewDiffStatsAsync, resolveCurrentUpstreamRemoteRef, resolveCurrentUpstreamPushTarget, resolveCurrentUpstreamPushTargetAsync, resolveCurrentLocalHeadRefAsync, resolveExactRemoteBranchHead, resolveExactRemoteBranchHeadAsync, redactRemoteUrlIdentity, resolveRemoteUrlIdentity, resolveRemoteUrlIdentityAsync, resolveGitControlStateDigest, resolveGitControlStateDigestAsync, resolveIsWorkingTreeClean, resolveIsWorkingTreeCleanAsync, resolveWorkingTreeDirtyPathsAsync, resolvePrWorkflowChangedPathSetAsync, resolveRepoTopLevelAsync, resolveLocalRefHeadAsync, resolveIsAncestorAsync, fastForwardToRefAsync, resolveCommitCountSince, resolveCommitCountSinceAsync, resolveIsExactSingleChildCommit, resolveIsExactSingleChildCommitAsync, resolveRemoteRefsContainingHead, resolveRemoteRefsContainingHeadAsync, resolvePrFeedbackTrackingCandidatesAsync, switchPrFeedbackTrackingCandidateAsync, resolvePrWorkflowRevisionDigestDetailed, resolvePrWorkflowRevisionDigest, resolvePrWorkflowRevisionDigestDetailedAsync, resolvePrWorkflowRevisionDigestAsync, parsePorcelainPaths, isSwarmRuntimePath, parsePorcelainV2Snapshot, captureWorkspaceSnapshot, captureWorkspaceSnapshotAsync, shouldSkipSnapshot, changedFilesSinceSnapshot, changedFilesSinceSnapshotAsync, committedFilesBetween, workspaceSnapshotMatches, compareWorkspaceSnapshot, compareWorkspaceSnapshots, digest, _internals };
@@ -1,10 +1,10 @@
1
1
  // @bun
2
2
  import {
3
3
  computePlanStructureHash
4
- } from "./index-26h8fb7t.js";
4
+ } from "./index-djtqb6b7.js";
5
5
  import {
6
6
  appendCoreEventSync
7
- } from "./index-awt5dpam.js";
7
+ } from "./index-h349p91m.js";
8
8
  import {
9
9
  deleteCoordinationState,
10
10
  importCoordinationOnce,
@@ -2,14 +2,14 @@
2
2
  import {
3
3
  init_loader,
4
4
  loadPluginConfigWithMeta
5
- } from "./index-qdwccqv5.js";
5
+ } from "./index-vd6s2mxq.js";
6
6
  import {
7
7
  init_schema
8
- } from "./index-3x07b03s.js";
8
+ } from "./index-5mbpybdm.js";
9
9
  import {
10
10
  DEFAULT_WORKTREE_ISOLATION_CONFIG,
11
11
  init_constants
12
- } from "./index-hqrkr9ag.js";
12
+ } from "./index-xfzkq1k4.js";
13
13
 
14
14
  // src/config/index.ts
15
15
  init_constants();
@@ -5,13 +5,17 @@ import {
5
5
  import {
6
6
  telemetry
7
7
  } from "./index-6dtt0brw.js";
8
+ import {
9
+ init_git_executable,
10
+ resolveGitExecutable
11
+ } from "./index-zxdawwc7.js";
8
12
  import {
9
13
  init_schema,
10
14
  stripKnownSwarmPrefix
11
- } from "./index-3x07b03s.js";
15
+ } from "./index-5mbpybdm.js";
12
16
  import {
13
17
  init_constants
14
- } from "./index-hqrkr9ag.js";
18
+ } from "./index-xfzkq1k4.js";
15
19
  import {
16
20
  getPathFlavor,
17
21
  init_path_identity,
@@ -1806,6 +1810,7 @@ function stableCanonicalStringify(value) {
1806
1810
  }
1807
1811
 
1808
1812
  // src/hooks/guardrails/file-authority.ts
1813
+ import { execFileSync } from "child_process";
1809
1814
  import * as fsSync from "fs";
1810
1815
  var import_picomatch = __toESM(require_picomatch2(), 1);
1811
1816
  import * as path2 from "path";
@@ -2148,12 +2153,166 @@ function protectedRoots(projectRoot, additional = []) {
2148
2153
  var HASH_INPUT_CAP_BYTES = 64 * 1024;
2149
2154
 
2150
2155
  // src/hooks/guardrails/file-authority.ts
2156
+ init_git_executable();
2151
2157
  var pathNormalizationCache = new QuickLRU({
2152
2158
  maxSize: 500
2153
2159
  });
2154
2160
  var globMatcherCache = new QuickLRU({
2155
2161
  maxSize: 200
2156
2162
  });
2163
+ var GIT_WORKTREE_CACHE_MAX_AGE_MS = 60000;
2164
+ var gitWorktreeCache = new QuickLRU({
2165
+ maxSize: 50,
2166
+ maxAge: GIT_WORKTREE_CACHE_MAX_AGE_MS
2167
+ });
2168
+ function gitEnvWithoutRepoRedirectors() {
2169
+ const env = { ...process.env };
2170
+ delete env.GIT_DIR;
2171
+ delete env.GIT_WORK_TREE;
2172
+ delete env.GIT_INDEX_FILE;
2173
+ delete env.GIT_COMMON_DIR;
2174
+ return env;
2175
+ }
2176
+ function parseWorktreeListPorcelain(output) {
2177
+ const records = [];
2178
+ for (const line of output.split(`
2179
+ `)) {
2180
+ if (line.startsWith("worktree ")) {
2181
+ const wtPath = line.slice("worktree ".length).trim();
2182
+ if (wtPath) {
2183
+ records.push({ path: wtPath, attributes: new Set });
2184
+ }
2185
+ continue;
2186
+ }
2187
+ const record = records[records.length - 1];
2188
+ if (!record)
2189
+ continue;
2190
+ const separator = line.indexOf(" ");
2191
+ const attribute = separator === -1 ? line : line.slice(0, separator);
2192
+ if (attribute)
2193
+ record.attributes.add(attribute);
2194
+ }
2195
+ return records;
2196
+ }
2197
+ function canonicalizeWindowsPathNative(p) {
2198
+ if (process.platform !== "win32")
2199
+ return p;
2200
+ try {
2201
+ const native = fsSync.realpathSync.native(p);
2202
+ return native.startsWith(String.fromCharCode(92, 92, 63, 92)) ? native.slice(4) : native;
2203
+ } catch {
2204
+ return;
2205
+ }
2206
+ }
2207
+ function canonicalizeWindowsPathTailTolerant(p) {
2208
+ if (process.platform !== "win32")
2209
+ return p;
2210
+ const tail = [];
2211
+ let probe = p;
2212
+ for (;; ) {
2213
+ const native = canonicalizeWindowsPathNative(probe);
2214
+ if (native !== undefined) {
2215
+ return tail.length === 0 ? native : path2.join(native, ...tail.reverse());
2216
+ }
2217
+ const parent = path2.dirname(probe);
2218
+ if (parent === probe)
2219
+ return p;
2220
+ tail.push(path2.basename(probe));
2221
+ probe = parent;
2222
+ }
2223
+ }
2224
+ function isValidWorktreeRecord(repoRootRecord, record) {
2225
+ if (record === repoRootRecord) {
2226
+ try {
2227
+ return fsSync.statSync(path2.join(record.path, ".git")).isDirectory();
2228
+ } catch {
2229
+ return false;
2230
+ }
2231
+ }
2232
+ if (record.attributes.has("bare"))
2233
+ return false;
2234
+ const dotGitPath = path2.join(record.path, ".git");
2235
+ let dotGitStat;
2236
+ try {
2237
+ dotGitStat = fsSync.lstatSync(dotGitPath);
2238
+ } catch {
2239
+ return false;
2240
+ }
2241
+ if (!dotGitStat.isFile())
2242
+ return false;
2243
+ let gitDirLine;
2244
+ try {
2245
+ gitDirLine = fsSync.readFileSync(dotGitPath, "utf8").trim();
2246
+ } catch {
2247
+ return false;
2248
+ }
2249
+ if (!gitDirLine.startsWith("gitdir:"))
2250
+ return false;
2251
+ const gitDirRef = gitDirLine.slice("gitdir:".length).trim();
2252
+ if (!gitDirRef)
2253
+ return false;
2254
+ const gitDirPath = path2.isAbsolute(gitDirRef) ? gitDirRef : path2.resolve(record.path, gitDirRef);
2255
+ let registrationGitdirFile;
2256
+ try {
2257
+ registrationGitdirFile = fsSync.realpathSync(path2.join(gitDirPath, "gitdir"));
2258
+ } catch {
2259
+ return false;
2260
+ }
2261
+ if (repoRootRecord) {
2262
+ let worktreesRoot;
2263
+ try {
2264
+ worktreesRoot = path2.join(fsSync.realpathSync(path2.join(repoRootRecord.path, ".git")), "worktrees");
2265
+ } catch {
2266
+ return false;
2267
+ }
2268
+ if (!isPathIdentityWithin(registrationGitdirFile, worktreesRoot)) {
2269
+ return false;
2270
+ }
2271
+ }
2272
+ let backReference;
2273
+ try {
2274
+ backReference = fsSync.readFileSync(registrationGitdirFile, "utf8").trim();
2275
+ } catch {
2276
+ return false;
2277
+ }
2278
+ try {
2279
+ return pathIdentitiesEqual(fsSync.realpathSync(dotGitPath), fsSync.realpathSync(backReference));
2280
+ } catch {
2281
+ return false;
2282
+ }
2283
+ }
2284
+ function getLinkedGitWorktrees(dir) {
2285
+ const cached = gitWorktreeCache.get(dir);
2286
+ if (cached !== undefined) {
2287
+ return cached;
2288
+ }
2289
+ const worktrees = [];
2290
+ try {
2291
+ const output = execFileSync(resolveGitExecutable(), ["worktree", "list", "--porcelain"], {
2292
+ cwd: dir,
2293
+ encoding: "utf8",
2294
+ stdio: ["ignore", "pipe", "ignore"],
2295
+ timeout: 1500,
2296
+ maxBuffer: 4 * 1024 * 1024,
2297
+ windowsHide: true,
2298
+ env: gitEnvWithoutRepoRedirectors()
2299
+ });
2300
+ const records = parseWorktreeListPorcelain(output);
2301
+ const repoRootRecord = records[0];
2302
+ for (const record of records) {
2303
+ if (!isValidWorktreeRecord(repoRootRecord, record)) {
2304
+ continue;
2305
+ }
2306
+ const native = canonicalizeWindowsPathNative(record.path);
2307
+ if (native === undefined) {
2308
+ continue;
2309
+ }
2310
+ worktrees.push(native);
2311
+ }
2312
+ } catch {}
2313
+ gitWorktreeCache.set(dir, worktrees);
2314
+ return worktrees;
2315
+ }
2157
2316
  function normalizePathWithCache(filePath, cwd) {
2158
2317
  const cacheKey = `${cwd}:${filePath}`;
2159
2318
  const cached = pathNormalizationCache.get(cacheKey);
@@ -2468,21 +2627,89 @@ function checkFileAuthorityWithRules(agentName, filePath, cwd, effectiveRules, o
2468
2627
  resolvedTarget = path2.resolve(dir, filePath);
2469
2628
  normalizedPath = path2.relative(dir, resolvedTarget).replace(/\\/g, "/");
2470
2629
  }
2630
+ let effectiveDir = dir;
2631
+ const nativeTarget2 = canonicalizeWindowsPathTailTolerant(resolvedTarget);
2632
+ const matchWorktreeRoot = () => {
2633
+ const worktrees = getLinkedGitWorktrees(dir);
2634
+ let best;
2635
+ for (const wt of worktrees) {
2636
+ const relToWt = path2.relative(wt, nativeTarget2).replace(/\\/g, "/");
2637
+ if (relToWt !== ".." && !relToWt.startsWith("../") && !isOnDifferentFilesystemRoot(nativeTarget2, wt)) {
2638
+ if (!best || wt.length > best.wt.length) {
2639
+ best = { wt, rel: relToWt };
2640
+ }
2641
+ }
2642
+ }
2643
+ if (best) {
2644
+ effectiveDir = best.wt;
2645
+ normalizedPath = best.rel;
2646
+ }
2647
+ return best?.wt;
2648
+ };
2649
+ const findPlantedLinkBelow = (root) => {
2650
+ const ancestors = [];
2651
+ let current = nativeTarget2;
2652
+ while (true) {
2653
+ const rel = path2.relative(root, current);
2654
+ if (rel === "" || rel === ".." || rel.startsWith(`..${path2.sep}`) || path2.isAbsolute(rel))
2655
+ break;
2656
+ ancestors.push(current);
2657
+ const parent = path2.dirname(current);
2658
+ if (parent === current)
2659
+ break;
2660
+ current = parent;
2661
+ }
2662
+ for (const ancestor of ancestors) {
2663
+ try {
2664
+ if (fsSync.lstatSync(ancestor).isSymbolicLink())
2665
+ return ancestor;
2666
+ } catch (err) {
2667
+ const code = err.code;
2668
+ if (code === "ENOENT")
2669
+ continue;
2670
+ return ancestor;
2671
+ }
2672
+ }
2673
+ return null;
2674
+ };
2471
2675
  if (isOnDifferentFilesystemRoot(resolvedTarget, dir)) {
2472
- return denyAuthority(agentName, normalizedPath, {
2473
- code: "AUTHORITY_ROOT_ESCAPE",
2474
- layer: "containment",
2475
- rule: "same-filesystem-root",
2476
- detail: "target is on a different drive or filesystem root"
2477
- });
2478
- }
2479
- if (normalizedPath === ".." || normalizedPath.startsWith("../")) {
2480
- return denyAuthority(agentName, normalizedPath, {
2481
- code: "AUTHORITY_ROOT_ESCAPE",
2482
- layer: "containment",
2483
- rule: "workspace-containment",
2484
- detail: "target resolves outside the working directory"
2485
- });
2676
+ const matchedWorktree = matchWorktreeRoot();
2677
+ if (!matchedWorktree) {
2678
+ return denyAuthority(agentName, normalizedPath, {
2679
+ code: "AUTHORITY_ROOT_ESCAPE",
2680
+ layer: "containment",
2681
+ rule: "same-filesystem-root",
2682
+ detail: "target is on a different drive or filesystem root"
2683
+ });
2684
+ }
2685
+ const plantedLink = findPlantedLinkBelow(matchedWorktree);
2686
+ if (plantedLink) {
2687
+ return denyAuthority(agentName, normalizedPath, {
2688
+ code: "AUTHORITY_ROOT_ESCAPE",
2689
+ layer: "containment",
2690
+ rule: "workspace-containment",
2691
+ detail: `re-rooted target crosses symlink/junction "${plantedLink}" inside the matched worktree`
2692
+ });
2693
+ }
2694
+ } else if (normalizedPath === ".." || normalizedPath.startsWith("../")) {
2695
+ const matchedWorktree = matchWorktreeRoot();
2696
+ if (!matchedWorktree) {
2697
+ return denyAuthority(agentName, normalizedPath, {
2698
+ code: "AUTHORITY_ROOT_ESCAPE",
2699
+ layer: "containment",
2700
+ rule: "workspace-containment",
2701
+ detail: "target resolves outside the working directory"
2702
+ });
2703
+ }
2704
+ const plantedLink = findPlantedLinkBelow(matchedWorktree);
2705
+ if (plantedLink) {
2706
+ return denyAuthority(agentName, normalizedPath, {
2707
+ code: "AUTHORITY_ROOT_ESCAPE",
2708
+ layer: "containment",
2709
+ rule: "workspace-containment",
2710
+ detail: `re-rooted target crosses symlink/junction "${plantedLink}" inside the matched worktree`
2711
+ });
2712
+ }
2486
2713
  }
2487
2714
  const classifiedRules = effectiveRules[normalizedAgent] ?? effectiveRules[strippedAgent];
2488
2715
  const unclassifiedWhileDisabled = !classifiedRules && options.authorityEnabled === false && normalizedAgent !== "unknown";
@@ -2496,10 +2723,10 @@ function checkFileAuthorityWithRules(agentName, filePath, cwd, effectiveRules, o
2496
2723
  });
2497
2724
  }
2498
2725
  const flavor = getPathFlavor();
2499
- const matchesPathPrefix = (candidate, prefix) => isPathIdentityWithin(path2.resolve(dir, candidate), path2.resolve(dir, prefix), flavor);
2726
+ const matchesPathPrefix = (candidate, prefix) => isPathIdentityWithin(path2.resolve(effectiveDir, candidate), path2.resolve(effectiveDir, prefix), flavor);
2500
2727
  const matchesGlob = (glob) => getGlobMatcher(glob)(normalizedPath);
2501
2728
  for (const prefix of options.universalDenyPrefixes ?? []) {
2502
- if (matchesAuthorityDenyPrefix(normalizedPath, prefix, dir, flavor)) {
2729
+ if (matchesAuthorityDenyPrefix(normalizedPath, prefix, effectiveDir, flavor)) {
2503
2730
  return denyAuthority(agentName, normalizedPath, {
2504
2731
  code: "AUTHORITY_UNIVERSAL_DENY",
2505
2732
  layer: "universal-deny",
@@ -2563,7 +2790,7 @@ function checkFileAuthorityWithRules(agentName, filePath, cwd, effectiveRules, o
2563
2790
  detail: "agent role is read-only"
2564
2791
  });
2565
2792
  }
2566
- const pathIsInDeclaredScope = isCoderAgent && options.declaredScope != null && options.declaredScope.length > 0 && isPathWithinDeclaredScope(normalizedPath, options.declaredScope, dir);
2793
+ const pathIsInDeclaredScope = isCoderAgent && options.declaredScope != null && options.declaredScope.length > 0 && isPathWithinDeclaredScope(normalizedPath, options.declaredScope, effectiveDir);
2567
2794
  if (pathIsInDeclaredScope) {
2568
2795
  return {
2569
2796
  allowed: true,
@@ -4,7 +4,7 @@ import {
4
4
  } from "./index-6b295cas.js";
5
5
  import {
6
6
  readEffectiveSpecSync
7
- } from "./index-zd15v0gr.js";
7
+ } from "./index-xapmt05a.js";
8
8
  import {
9
9
  _internals,
10
10
  clearWorktreeMergeStatus,
@@ -43,10 +43,10 @@ import {
43
43
  replayFromLedgerWithStatus,
44
44
  takeSnapshotEvent,
45
45
  takeSnapshotWithRetry
46
- } from "./index-26h8fb7t.js";
46
+ } from "./index-djtqb6b7.js";
47
47
  import {
48
48
  appendCoreEventSync
49
- } from "./index-awt5dpam.js";
49
+ } from "./index-h349p91m.js";
50
50
  import {
51
51
  deleteCoordinationStateWithinTransaction,
52
52
  getCoordinationStateRaw,
@@ -93,7 +93,7 @@ import {
93
93
  init_loader,
94
94
  isEpicModeConfigEnabled,
95
95
  loadPluginConfigWithMeta
96
- } from "./index-qdwccqv5.js";
96
+ } from "./index-vd6s2mxq.js";
97
97
  import {
98
98
  exports_external,
99
99
  init_zod
@@ -2664,7 +2664,7 @@ ${markdown}`;
2664
2664
  }
2665
2665
  }
2666
2666
  async function defaultMaybeSaveAutoCheckpoint(directory, plan) {
2667
- const { maybeSaveAutoCheckpoint } = await import("./auto-checkpoint-1wf9n5yj.js");
2667
+ const { maybeSaveAutoCheckpoint } = await import("./auto-checkpoint-0ajspw7n.js");
2668
2668
  return maybeSaveAutoCheckpoint(directory, plan);
2669
2669
  }
2670
2670
  async function updateTaskStatus(directory, taskId, status, options) {
@@ -2740,7 +2740,7 @@ async function updateTaskStatus(directory, taskId, status, options) {
2740
2740
  if (status === "completed") {
2741
2741
  try {
2742
2742
  const completedTask = updatedPlan.phases.flatMap((phase) => phase.tasks).find((candidate) => candidate.id === taskId);
2743
- const { maybePropagateSpeckitCheckoff } = await import("./speckit-checkoff-9b2zj8hd.js");
2743
+ const { maybePropagateSpeckitCheckoff } = await import("./speckit-checkoff-d92ej93g.js");
2744
2744
  await maybePropagateSpeckitCheckoff(directory, {
2745
2745
  taskId,
2746
2746
  frRefs: completedTask?.fr_refs ?? [],
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  _internals,
4
4
  resolveWorktreeIsolationConfig
5
- } from "./index-vh87e91s.js";
5
+ } from "./index-km9tjdgw.js";
6
6
  import {
7
7
  ApprovalEvidenceSchema,
8
8
  BaseEvidenceSchema,
@@ -46,7 +46,7 @@ import {
46
46
  loadPluginConfigWithMeta,
47
47
  loadPluginConfigWithMetaAsync,
48
48
  resetConfigAdvisoryDedup
49
- } from "./index-qdwccqv5.js";
49
+ } from "./index-vd6s2mxq.js";
50
50
  import"./index-zxdawwc7.js";
51
51
  import {
52
52
  AUTO_REVIEW_V8_BURN_IN_DECISION,
@@ -72,7 +72,7 @@ import {
72
72
  TurboConfigSchema,
73
73
  WorktreeIsolationConfigSchema,
74
74
  resolveAutoReviewConfig
75
- } from "./index-3x07b03s.js";
75
+ } from "./index-5mbpybdm.js";
76
76
  import {
77
77
  ALL_AGENT_NAMES,
78
78
  ALL_SUBAGENT_NAMES,
@@ -82,7 +82,7 @@ import {
82
82
  QA_AGENTS,
83
83
  isQAAgent,
84
84
  isSubagent
85
- } from "./index-hqrkr9ag.js";
85
+ } from "./index-xfzkq1k4.js";
86
86
  import"./index-bk5tah7q.js";
87
87
  import"./index-gknz3bv1.js";
88
88
  import"./index-zpsr8rpc.js";