opencode-swarm 7.140.4 → 7.140.6

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 (100) hide show
  1. package/.opencode/skills/plan/SKILL.md +40 -12
  2. package/.opencode/skills/swarm-pr-review/SKILL.md +2 -4
  3. package/.opencode/skills/swarm-pr-review/references/lane-output-recoverability.md +54 -0
  4. package/dist/agents/architect.d.ts +2 -1
  5. package/dist/background/candidate-contract.d.ts +1 -1
  6. package/dist/background/pending-delegations.d.ts +5 -0
  7. package/dist/background/pr-review-trigger-contract.d.ts +36 -0
  8. package/dist/cli/{config-doctor-qqe6172n.js → config-doctor-y5qeh18c.js} +3 -3
  9. package/dist/cli/{core-52k057mf.js → core-pwd9604e.js} +2 -2
  10. package/dist/cli/{curation-policy-9291bdat.js → curation-policy-avvb56x2.js} +6 -6
  11. package/dist/cli/curator-llm-factory-96pnc23w.js +61 -0
  12. package/dist/cli/{curator-04xqq68e.js → curator-q1nchgpg.js} +36 -36
  13. package/dist/cli/{evidence-summary-service-em58myd7.js → evidence-summary-service-18142mr3.js} +14 -11
  14. package/dist/cli/gate-evidence-smn2wqft.js +51 -0
  15. package/dist/cli/guardrail-explain-kyd89z8z.js +62 -0
  16. package/dist/cli/{guardrail-log-vb5zkegf.js → guardrail-log-cahp1ews.js} +4 -4
  17. package/dist/cli/{hive-promoter-z09khawt.js → hive-promoter-vcbcvcsh.js} +36 -36
  18. package/dist/cli/{index-ysa38bnr.js → index-1p72dtym.js} +3 -3
  19. package/dist/cli/{index-s8g7jh1k.js → index-2778hhh7.js} +2 -2
  20. package/dist/cli/{index-v3xhc7kg.js → index-4s7xgzbm.js} +1 -1
  21. package/dist/cli/{index-wk8s1m7b.js → index-4zxrkk1h.js} +217 -15
  22. package/dist/cli/{index-hz0refz4.js → index-56rqw2hs.js} +70 -29
  23. package/dist/cli/{index-djbhe0yh.js → index-5qd5vt2d.js} +38 -38
  24. package/dist/cli/{index-35qep0v7.js → index-912qz4y0.js} +88 -88
  25. package/dist/cli/{index-2rb3x0fk.js → index-92n3d5ky.js} +7 -7
  26. package/dist/cli/{index-ryq97w1x.js → index-bjqpdr83.js} +4 -4
  27. package/dist/cli/{index-c5kr20nz.js → index-c432knmy.js} +1 -1
  28. package/dist/cli/{index-v3x7j9ey.js → index-dtqjxfw9.js} +2 -2
  29. package/dist/cli/{index-hfwzxh3j.js → index-e58e3v0v.js} +12 -10
  30. package/dist/cli/{index-bfhwtdsw.js → index-epvhf50h.js} +3 -3
  31. package/dist/cli/{index-vrmkg8fm.js → index-fejfzy2j.js} +9 -9
  32. package/dist/cli/{index-mpytsq6k.js → index-h01wb18g.js} +2 -2
  33. package/dist/cli/{index-hxvkfx6t.js → index-jqsfsqbx.js} +15 -2
  34. package/dist/cli/{index-bn17ycxn.js → index-m9xrdjn0.js} +1 -1
  35. package/dist/cli/{index-a1fjhx4w.js → index-nakkgkkt.js} +37922 -35984
  36. package/dist/cli/index-p04qrwck.js +43 -0
  37. package/dist/cli/{index-arza4m4j.js → index-p2ty3eee.js} +2 -2
  38. package/dist/cli/{index-4hp8nvwb.js → index-p8kk34am.js} +3 -3
  39. package/dist/cli/{index-1kyex7z2.js → index-qwm6vdyv.js} +32 -1
  40. package/dist/cli/{index-dtam929z.js → index-qy1nq52t.js} +1 -1
  41. package/dist/cli/{index-rrb6cz2f.js → index-s1v0wza5.js} +6 -2
  42. package/dist/cli/{index-w4etfamq.js → index-t5pytnca.js} +2 -2
  43. package/dist/cli/{index-tj04dj06.js → index-thp186x0.js} +2 -2
  44. package/dist/cli/index-tjqzr3jc.js +623 -0
  45. package/dist/cli/{index-mrpfd1jx.js → index-vh05t3w5.js} +1 -1
  46. package/dist/cli/{index-7begd9aq.js → index-y9q9f6ms.js} +4 -4
  47. package/dist/cli/{index-v1an91bq.js → index-z0z9pe7b.js} +5 -5
  48. package/dist/cli/{index-hfjvepk2.js → index-z3s0a44b.js} +3 -3
  49. package/dist/cli/{index-pp5m7xga.js → index-zd4qhnr7.js} +70 -34
  50. package/dist/cli/{index-b8zgtz81.js → index-zsrtt42s.js} +34 -1
  51. package/dist/cli/index.js +35 -35
  52. package/dist/cli/{knowledge-escalator-gdjnwszd.js → knowledge-escalator-gj58za4g.js} +12 -12
  53. package/dist/cli/{knowledge-events-581x4q7n.js → knowledge-events-3m5jnnv6.js} +10 -10
  54. package/dist/cli/{knowledge-link-axx45d1h.js → knowledge-link-m9p80f4r.js} +5 -5
  55. package/dist/cli/{knowledge-store-ttg33482.js → knowledge-store-0vy8wbzd.js} +6 -6
  56. package/dist/cli/{knowledge-validator-8kywqt8b.js → knowledge-validator-mvcs8wf6.js} +8 -8
  57. package/dist/cli/{pending-delegations-btwqsvz4.js → pending-delegations-cxx9tezp.js} +4 -4
  58. package/dist/cli/{pr-subscriptions-83y1cdwv.js → pr-subscriptions-2sfnb599.js} +4 -4
  59. package/dist/cli/{runner-fh3r41nw.js → runner-mky3vvht.js} +6 -6
  60. package/dist/cli/{scan-cursor-j8ytdpam.js → scan-cursor-wznc7p7p.js} +7 -7
  61. package/dist/cli/{schema-6xfqtpvn.js → schema-k596bhds.js} +2 -2
  62. package/dist/cli/{scope-persistence-8c72jrgp.js → scope-persistence-0ny5fn07.js} +10 -5
  63. package/dist/cli/{skill-generator-n8vm1yhn.js → skill-generator-vrks0jjj.js} +14 -14
  64. package/dist/cli/{telemetry-fb44gpba.js → telemetry-0x6kszvk.js} +1 -1
  65. package/dist/cli/{worktree-collision-ownership-f28r473k.js → worktree-collision-ownership-wm5pse49.js} +8 -8
  66. package/dist/cli/worktree-isolation-zgk7314k.js +102 -0
  67. package/dist/cli/worktree-provisioning-owner-sjh7te1h.js +22 -0
  68. package/dist/commands/acknowledge-spec-drift.d.ts +4 -5
  69. package/dist/config/evidence-schema.d.ts +3 -3
  70. package/dist/config/index.d.ts +2 -2
  71. package/dist/config/plan-schema.d.ts +8 -0
  72. package/dist/config/schema.d.ts +2 -2
  73. package/dist/council/council-evidence-writer.d.ts +1 -1
  74. package/dist/gate-evidence.d.ts +117 -4
  75. package/dist/hooks/delegation-gate.d.ts +21 -0
  76. package/dist/hooks/pr-workflow-gate.d.ts +20 -0
  77. package/dist/index.js +775 -748
  78. package/dist/plan/ledger.d.ts +55 -0
  79. package/dist/plan/manager.d.ts +9 -0
  80. package/dist/plan/planning-profile.d.ts +27 -0
  81. package/dist/services/spec-drift-recovery.d.ts +84 -0
  82. package/dist/session/snapshot-writer.d.ts +3 -1
  83. package/dist/state.d.ts +19 -17
  84. package/dist/summaries/schema.d.ts +2 -2
  85. package/dist/tools/convene-council.d.ts +6 -6
  86. package/dist/tools/save-plan.d.ts +8 -0
  87. package/dist/tools/submit-phase-council-verdicts.d.ts +6 -6
  88. package/dist/tools/tool-metadata.d.ts +28 -28
  89. package/dist/tools/update-task-status.d.ts +13 -0
  90. package/dist/tools/write-final-council-evidence.d.ts +6 -6
  91. package/dist/types/events.d.ts +29 -1
  92. package/dist/workflow/coder-settlement.d.ts +62 -0
  93. package/dist/workflow/task-repair.d.ts +30 -0
  94. package/dist/workflow/task-terminal.d.ts +52 -0
  95. package/package.json +1 -1
  96. package/dist/cli/curator-llm-factory-cfm8fhdw.js +0 -61
  97. package/dist/cli/gate-evidence-ezxfkb22.js +0 -32
  98. package/dist/cli/guardrail-explain-pn1bcgfz.js +0 -62
  99. package/dist/cli/index-d181x9zr.js +0 -71
  100. package/dist/cli/index-dtyeabmj.js +0 -239
@@ -1,12 +1,12 @@
1
1
  // @bun
2
+ import {
3
+ loadDatabaseCtor
4
+ } from "./index-134d35c1.js";
2
5
  import {
3
6
  EvaluationRunV1Schema,
4
7
  GateAuditResultV1Schema,
5
8
  getProtectedEvaluationRunIds
6
- } from "./index-w4etfamq.js";
7
- import {
8
- loadDatabaseCtor
9
- } from "./index-134d35c1.js";
9
+ } from "./index-t5pytnca.js";
10
10
  import {
11
11
  readEffectiveSpecSync
12
12
  } from "./index-9ss2m4rs.js";
@@ -21,21 +21,24 @@ import {
21
21
  initLedger,
22
22
  ledgerExists,
23
23
  loadLastApprovedPlan,
24
+ normalizeExecutionProfileForHash,
24
25
  readLedgerEvents,
26
+ readLedgerEventsWithIntegrity,
27
+ replaceTruncatedLedgerWithRecoveryRoot,
25
28
  replayFromLedger,
26
29
  replayFromLedgerWithStatus,
27
30
  takeSnapshotEvent,
28
31
  takeSnapshotWithRetry
29
- } from "./index-wk8s1m7b.js";
32
+ } from "./index-4zxrkk1h.js";
30
33
  import {
31
34
  getWorktreeMergeFailure
32
- } from "./index-b8zgtz81.js";
35
+ } from "./index-zsrtt42s.js";
33
36
  import {
34
37
  isValidTaskId,
35
38
  readTaskEvidence,
36
39
  readTaskEvidenceRaw,
37
40
  sanitizeTaskId
38
- } from "./index-dtyeabmj.js";
41
+ } from "./index-tjqzr3jc.js";
39
42
  import {
40
43
  _internals,
41
44
  buildDefaultPolicy,
@@ -47,15 +50,15 @@ import {
47
50
  readSwarmFileAsync,
48
51
  validateSwarmPath
49
52
  } from "./index-k46me75h.js";
50
- import {
51
- invalidateCachedArtifact,
52
- readCachedParsedFile
53
- } from "./index-ed5ykebp.js";
54
53
  import {
55
54
  assertProjectRoot,
56
55
  tryAcquireLock,
57
56
  withEvidenceLock
58
- } from "./index-35qep0v7.js";
57
+ } from "./index-912qz4y0.js";
58
+ import {
59
+ invalidateCachedArtifact,
60
+ readCachedParsedFile
61
+ } from "./index-ed5ykebp.js";
59
62
  import {
60
63
  bunHash,
61
64
  bunWrite,
@@ -68,7 +71,7 @@ import {
68
71
  } from "./index-gprxjmm7.js";
69
72
  import {
70
73
  PlanSchema
71
- } from "./index-d181x9zr.js";
74
+ } from "./index-zd4qhnr7.js";
72
75
  import {
73
76
  criticalWarn,
74
77
  error,
@@ -77,7 +80,7 @@ import {
77
80
  } from "./index-zgwm4ryv.js";
78
81
  import {
79
82
  emit
80
- } from "./index-bfhwtdsw.js";
83
+ } from "./index-epvhf50h.js";
81
84
  import {
82
85
  ZodError,
83
86
  init_zod
@@ -993,8 +996,8 @@ import * as path8 from "path";
993
996
  import { createHash } from "crypto";
994
997
 
995
998
  // src/db/project-db.ts
996
- import { existsSync, mkdirSync } from "fs";
997
- import { join, resolve } from "path";
999
+ import { existsSync, mkdirSync as mkdirSync2 } from "fs";
1000
+ import { join as join3, resolve } from "path";
998
1001
  var MIGRATIONS = [
999
1002
  {
1000
1003
  version: 1,
@@ -1148,7 +1151,7 @@ function runProjectMigrations(db) {
1148
1151
  }
1149
1152
  }
1150
1153
  function projectDbPath(directory) {
1151
- return join(resolve(directory), ".swarm", "swarm.db");
1154
+ return join3(resolve(directory), ".swarm", "swarm.db");
1152
1155
  }
1153
1156
  function projectDbExists(directory) {
1154
1157
  return existsSync(projectDbPath(directory));
@@ -1158,10 +1161,10 @@ function getProjectDb(directory) {
1158
1161
  const existing = _projectDbs.get(key);
1159
1162
  if (existing)
1160
1163
  return existing;
1161
- const swarmDir = join(key, ".swarm");
1162
- mkdirSync(swarmDir, { recursive: true });
1164
+ const swarmDir = join3(key, ".swarm");
1165
+ mkdirSync2(swarmDir, { recursive: true });
1163
1166
  const Db = loadDatabaseCtor();
1164
- const db = new Db(join(swarmDir, "swarm.db"));
1167
+ const db = new Db(join3(swarmDir, "swarm.db"));
1165
1168
  db.run("PRAGMA journal_mode = WAL;");
1166
1169
  db.run("PRAGMA synchronous = NORMAL;");
1167
1170
  db.run("PRAGMA busy_timeout = 5000;");
@@ -2957,14 +2960,7 @@ function computePlanContentHash(plan) {
2957
2960
  swarm: plan.swarm,
2958
2961
  current_phase: plan.current_phase,
2959
2962
  migration_status: plan.migration_status,
2960
- execution_profile: plan.execution_profile ? {
2961
- parallelization_enabled: plan.execution_profile.parallelization_enabled,
2962
- max_concurrent_tasks: plan.execution_profile.max_concurrent_tasks,
2963
- council_parallel: plan.execution_profile.council_parallel,
2964
- locked: plan.execution_profile.locked,
2965
- auto_proceed: plan.execution_profile.auto_proceed,
2966
- commit_after_each_completed_task: plan.execution_profile.commit_after_each_completed_task === true ? true : undefined
2967
- } : undefined,
2963
+ execution_profile: normalizeExecutionProfileForHash(plan.execution_profile),
2968
2964
  phases: plan.phases.map((phase) => ({
2969
2965
  id: phase.id,
2970
2966
  name: phase.name,
@@ -3314,6 +3310,10 @@ async function savePlan(directory, plan, options) {
3314
3310
  }
3315
3311
  }
3316
3312
  const validated = PlanSchema.parse(plan);
3313
+ const requestedForStaleProjectionReconcile = options?.staleProjectionReconcile !== undefined ? PlanSchema.parse(plan) : null;
3314
+ if (requestedForStaleProjectionReconcile) {
3315
+ derivePhaseStatusesInPlace(requestedForStaleProjectionReconcile);
3316
+ }
3317
3317
  if (options?.preserveCompletedStatuses !== false) {
3318
3318
  try {
3319
3319
  const currentPlan2 = await _internals9.loadPlanJsonOnly(directory);
@@ -3425,6 +3425,43 @@ async function savePlan(directory, plan, options) {
3425
3425
  } catch {}
3426
3426
  }
3427
3427
  }
3428
+ if (options?.staleProjectionReconcile) {
3429
+ if (!currentPlan) {
3430
+ throw new Error("RECONCILE_LEDGER_PROJECTION_MISMATCH: no current plan.json projection exists.");
3431
+ }
3432
+ const comparableCurrent = PlanSchema.parse(currentPlan);
3433
+ derivePhaseStatusesInPlace(comparableCurrent);
3434
+ if (JSON.stringify(comparableCurrent) !== JSON.stringify(requestedForStaleProjectionReconcile)) {
3435
+ throw new Error("RECONCILE_LEDGER_PROJECTION_MISMATCH: manager rejected content that is not the exact unchanged plan.json projection.");
3436
+ }
3437
+ const events = await readLedgerEvents(directory);
3438
+ const tail = events[events.length - 1];
3439
+ const expected = options.staleProjectionReconcile;
3440
+ if (!tail || tail.seq !== expected.expectedSeq || tail.plan_hash_after !== expected.expectedLedgerHash || events[0]?.plan_id !== planId) {
3441
+ throw new PlanConcurrentModificationError("RECONCILE_LEDGER_PROJECTION_STALE: the ledger identity or tail changed before the recovery snapshot could be appended.");
3442
+ }
3443
+ try {
3444
+ const integrity = await readLedgerEventsWithIntegrity(directory);
3445
+ if (integrity.truncated) {
3446
+ await replaceTruncatedLedgerWithRecoveryRoot(directory, validated, {
3447
+ seq: expected.expectedSeq,
3448
+ ledgerHash: expected.expectedLedgerHash
3449
+ });
3450
+ } else {
3451
+ await takeSnapshotEvent(directory, validated, {
3452
+ planHashAfter: computePlanHash(validated),
3453
+ source: "save_plan_stale_projection_reconcile",
3454
+ expectedSeq: expected.expectedSeq,
3455
+ expectedLedgerHash: expected.expectedLedgerHash
3456
+ });
3457
+ }
3458
+ } catch (error2) {
3459
+ if (error2 instanceof LedgerStaleWriterError) {
3460
+ throw new PlanConcurrentModificationError(`RECONCILE_LEDGER_PROJECTION_STALE: ${error2.message}`);
3461
+ }
3462
+ throw error2;
3463
+ }
3464
+ }
3428
3465
  const currentHash = computeCurrentPlanHash(directory);
3429
3466
  const hashAfter = computePlanHash(validated);
3430
3467
  if (currentPlan) {
@@ -3837,6 +3874,10 @@ Phase: ${currentPhase} [${phaseStatus}] | Updated: ${now}
3837
3874
  `;
3838
3875
  markdown += `- Commit After Each Completed Task: ${profile.commit_after_each_completed_task ? "yes" : "no"}
3839
3876
  `;
3877
+ if (profile.planning_profile) {
3878
+ markdown += `- Planning Profile: ${profile.planning_profile}
3879
+ `;
3880
+ }
3840
3881
  }
3841
3882
  const sortedPhases = [...plan.phases].sort((a, b) => a.id - b.id);
3842
3883
  for (const phase of sortedPhases) {
@@ -4967,4 +5008,4 @@ function mergeDurableGateEntriesFromEvidence(taskId, entries, evidence) {
4967
5008
  return merged;
4968
5009
  }
4969
5010
 
4970
- export { projectDbExists, getProjectDb, closeProjectDb, buildTaskCompletionDescriptor, ensureTaskCheckpointReceipt, updateTaskCheckpointReceipt, getExecutor, init_executor, MAX_TRANSIENT_RETRIES, isTransientSpawnError, transientBackoff, getGitRepositoryStatus, isGitRepo, getDefaultBaseBranch, detectDefaultRemoteBranch, resetToRemoteBranch, resetToMainAfterMerge, containsPathTraversal, containsControlChars, isStateUnreadable, loadEpicSessionState, isEpicModeActive, enableEpicMode, disableEpicMode, normalizePath, pathsConflict, isGlobalFile, isProtectedPath, readTaskScopes, computeSpecHash, loadPlanJsonOnly, loadPlan, savePlan, closePlanTerminalState, derivePlanMarkdown, isValidEvidenceType, sanitizeTaskId2 as sanitizeTaskId, validateProjectRoot, saveEvidence, loadEvidence, listEvidenceTaskIds, checkRequirementCoverage, archiveEvidence, readDurableGateEvidence, getDurableGateEvidenceStatus, getDurableGateEvidenceStatusForTask, mergeDurableGateEntriesFromEvidence };
5011
+ export { projectDbExists, getProjectDb, closeProjectDb, buildTaskCompletionDescriptor, ensureTaskCheckpointReceipt, updateTaskCheckpointReceipt, isValidEnvKey, getExecutor, init_executor, MAX_TRANSIENT_RETRIES, isTransientSpawnError, transientBackoff, getGitRepositoryStatus, isGitRepo, getDefaultBaseBranch, detectDefaultRemoteBranch, resetToRemoteBranch, resetToMainAfterMerge, containsPathTraversal, containsControlChars, isStateUnreadable, loadEpicSessionState, isEpicModeActive, enableEpicMode, disableEpicMode, normalizePath, pathsConflict, isGlobalFile, isProtectedPath, readTaskScopes, loadPlanJsonOnly, loadPlan, savePlan, closePlanTerminalState, derivePlanMarkdown, isValidEvidenceType, sanitizeTaskId2 as sanitizeTaskId, validateProjectRoot, saveEvidence, loadEvidence, listEvidenceTaskIds, checkRequirementCoverage, archiveEvidence, readDurableGateEvidence, getDurableGateEvidenceStatus, getDurableGateEvidenceStatusForTask, mergeDurableGateEntriesFromEvidence };
@@ -1,16 +1,16 @@
1
1
  // @bun
2
2
  import {
3
3
  handleGuardrailExplain
4
- } from "./index-s8g7jh1k.js";
4
+ } from "./index-2778hhh7.js";
5
5
  import {
6
6
  handleGuardrailLog
7
- } from "./index-v3xhc7kg.js";
7
+ } from "./index-4s7xgzbm.js";
8
8
  import {
9
9
  COMMAND_REGISTRY,
10
10
  SWARM_COMMAND_TOOL_ALLOWLIST,
11
11
  SWARM_COMMAND_TOOL_COMMANDS,
12
12
  VALID_COMMANDS,
13
- _internals2 as _internals,
13
+ _internals3 as _internals,
14
14
  canonicalCommandKey,
15
15
  classifySwarmCommandChatFallbackUse,
16
16
  classifySwarmCommandToolUse,
@@ -84,66 +84,66 @@ import {
84
84
  handleWriteRetroCommand,
85
85
  normalizeSwarmCommandInput,
86
86
  resolveCommand
87
- } from "./index-a1fjhx4w.js";
88
- import"./index-41hkt36g.js";
89
- import"./index-c5kr20nz.js";
90
- import"./index-ysa38bnr.js";
91
- import"./index-arza4m4j.js";
92
- import"./index-hz0refz4.js";
93
- import"./index-w4etfamq.js";
94
- import"./index-y8552snf.js";
87
+ } from "./index-nakkgkkt.js";
95
88
  import"./index-4905hd2m.js";
96
- import"./index-134d35c1.js";
97
- import"./index-hfjvepk2.js";
98
- import"./index-v1an91bq.js";
99
- import"./index-mpytsq6k.js";
100
- import"./index-v2xrer41.js";
89
+ import"./index-41hkt36g.js";
90
+ import"./index-c432knmy.js";
91
+ import"./index-1p72dtym.js";
101
92
  import"./index-c8s9a3zh.js";
93
+ import"./index-p2ty3eee.js";
94
+ import"./index-56rqw2hs.js";
95
+ import"./index-134d35c1.js";
96
+ import"./index-t5pytnca.js";
97
+ import"./index-y8552snf.js";
102
98
  import"./index-9ss2m4rs.js";
103
- import"./index-bn17ycxn.js";
104
- import"./index-ryq97w1x.js";
105
- import"./index-556ja8an.js";
106
- import"./index-wk8s1m7b.js";
107
- import"./index-1kyex7z2.js";
108
- import"./index-b8zgtz81.js";
109
- import"./index-v3x7j9ey.js";
110
- import"./index-rrb6cz2f.js";
111
99
  import"./index-74hpm6sh.js";
112
- import"./index-dtyeabmj.js";
100
+ import"./index-z3s0a44b.js";
101
+ import"./index-z0z9pe7b.js";
102
+ import"./index-h01wb18g.js";
103
+ import"./index-v2xrer41.js";
104
+ import"./index-m9xrdjn0.js";
105
+ import"./index-bjqpdr83.js";
106
+ import"./index-556ja8an.js";
107
+ import"./index-4zxrkk1h.js";
108
+ import"./index-zsrtt42s.js";
109
+ import"./index-dtqjxfw9.js";
110
+ import"./index-qwm6vdyv.js";
111
+ import"./index-tjqzr3jc.js";
112
+ import"./index-s1v0wza5.js";
113
113
  import"./index-8fwhhayc.js";
114
114
  import"./index-q1exe2b3.js";
115
- import"./index-2rb3x0fk.js";
115
+ import"./index-92n3d5ky.js";
116
116
  import"./index-k46me75h.js";
117
117
  import"./index-ee3x66a5.js";
118
- import"./index-7begd9aq.js";
119
- import"./index-dtam929z.js";
118
+ import"./index-y9q9f6ms.js";
119
+ import"./index-qy1nq52t.js";
120
120
  import"./index-rtry5xyf.js";
121
- import"./index-vrmkg8fm.js";
121
+ import"./index-fejfzy2j.js";
122
122
  import"./index-ae75rja9.js";
123
- import"./index-mrpfd1jx.js";
124
- import"./index-4hp8nvwb.js";
125
- import"./index-ed5ykebp.js";
126
- import"./index-35qep0v7.js";
123
+ import"./index-vh05t3w5.js";
124
+ import"./index-p8kk34am.js";
125
+ import"./index-912qz4y0.js";
127
126
  import"./index-7g4c7s5r.js";
127
+ import"./index-ed5ykebp.js";
128
128
  import"./index-4nt52yr9.js";
129
- import"./index-pp5m7xga.js";
129
+ import"./index-p04qrwck.js";
130
130
  import"./index-gprxjmm7.js";
131
131
  import"./index-n832052r.js";
132
- import"./index-d181x9zr.js";
132
+ import"./index-zd4qhnr7.js";
133
133
  import"./index-4rhhvd1a.js";
134
134
  import"./index-zgwm4ryv.js";
135
135
  import {
136
136
  init_schema,
137
137
  stripKnownSwarmPrefix
138
- } from "./index-tj04dj06.js";
138
+ } from "./index-thp186x0.js";
139
139
  import {
140
140
  AGENT_TOOL_MAP,
141
141
  ORCHESTRATOR_NAME,
142
142
  init_constants
143
- } from "./index-hxvkfx6t.js";
143
+ } from "./index-jqsfsqbx.js";
144
144
  import"./index-zjygnfay.js";
145
145
  import"./index-bk5tah7q.js";
146
- import"./index-bfhwtdsw.js";
146
+ import"./index-epvhf50h.js";
147
147
  import"./index-bpmtbmy9.js";
148
148
  import"./index-a76rekgs.js";
149
149
 
@@ -8,16 +8,89 @@ import {
8
8
  } from "./index-zgwm4ryv.js";
9
9
  import {
10
10
  emit
11
- } from "./index-bfhwtdsw.js";
11
+ } from "./index-epvhf50h.js";
12
12
  import {
13
13
  __toESM
14
14
  } from "./index-a76rekgs.js";
15
15
 
16
+ // src/parallel/file-locks.ts
17
+ var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
18
+ import * as crypto from "crypto";
19
+ import * as fs from "fs";
20
+ import * as path from "path";
21
+ var LOCKS_DIR = ".swarm/locks";
22
+ var LOCK_TIMEOUT_MS = 5 * 60 * 1000;
23
+ var _internals = {
24
+ tryAcquireLock,
25
+ writeFile: fs.promises.writeFile
26
+ };
27
+ function getLockFilePath(directory, filePath) {
28
+ const normalized = path.resolve(directory, filePath);
29
+ const baseDir = path.resolve(directory) + path.sep;
30
+ const pathOk = process.platform === "win32" ? normalized.toLowerCase().startsWith(baseDir.toLowerCase()) : normalized.startsWith(baseDir);
31
+ if (!pathOk) {
32
+ throw new Error("Invalid file path: path traversal not allowed");
33
+ }
34
+ const pathForHash = process.platform === "win32" ? normalized.toLowerCase() : normalized;
35
+ const hash = crypto.createHash("sha256").update(pathForHash).digest("hex");
36
+ const lockPath = path.join(directory, LOCKS_DIR, `${hash}.lock`);
37
+ const legacyPaths = [pathForHash];
38
+ if (process.platform === "win32" && normalized !== pathForHash) {
39
+ legacyPaths.push(normalized);
40
+ }
41
+ for (const legacyPath of legacyPaths) {
42
+ const oldHash = Buffer.from(legacyPath).toString("base64").replace(/[/+=]/g, "_");
43
+ const oldLockPath = path.join(directory, LOCKS_DIR, `${oldHash}.lock`);
44
+ if (fs.existsSync(oldLockPath)) {
45
+ return oldLockPath;
46
+ }
47
+ }
48
+ return lockPath;
49
+ }
50
+ async function tryAcquireLock(directory, filePath, agent, taskId) {
51
+ const lockPath = getLockFilePath(directory, filePath);
52
+ const locksDir = path.dirname(lockPath);
53
+ if (!fs.existsSync(locksDir)) {
54
+ fs.mkdirSync(locksDir, { recursive: true });
55
+ }
56
+ if (!fs.existsSync(lockPath)) {
57
+ fs.writeFileSync(lockPath, "", "utf-8");
58
+ }
59
+ let release;
60
+ try {
61
+ release = await import_proper_lockfile.default.lock(lockPath, {
62
+ stale: LOCK_TIMEOUT_MS,
63
+ retries: {
64
+ retries: 5,
65
+ minTimeout: 10,
66
+ maxTimeout: 500,
67
+ factor: 2
68
+ },
69
+ realpath: false
70
+ });
71
+ } catch (err) {
72
+ const code = err.code;
73
+ if (code === "ELOCKED" || code === "EEXIST") {
74
+ return { acquired: false };
75
+ }
76
+ throw err;
77
+ }
78
+ const lock = {
79
+ filePath,
80
+ agent,
81
+ taskId,
82
+ timestamp: new Date().toISOString(),
83
+ expiresAt: Date.now() + LOCK_TIMEOUT_MS,
84
+ _release: release
85
+ };
86
+ return { acquired: true, lock };
87
+ }
88
+
16
89
  // src/utils/project-boundary.ts
17
90
  init_logger();
18
- import * as fs from "fs";
91
+ import * as fs2 from "fs";
19
92
  import * as os from "os";
20
- import * as path from "path";
93
+ import * as path2 from "path";
21
94
  var MAX_PROJECT_ROOT_DEPTH = 20;
22
95
  var PROJECT_ROOT_INDICATORS = [
23
96
  "package.json",
@@ -40,14 +113,14 @@ var PROJECT_BOUNDARY_MARKERS = [
40
113
  { name: ".opencode", accepts: (stat) => stat.isDirectory() }
41
114
  ];
42
115
  function isAbsoluteDirectoryInput(value) {
43
- return typeof value === "string" && value.trim().length > 0 && path.isAbsolute(value);
116
+ return typeof value === "string" && value.trim().length > 0 && path2.isAbsolute(value);
44
117
  }
45
118
  function hasExplicitProjectBoundary(directory) {
46
119
  if (!isAbsoluteDirectoryInput(directory))
47
120
  return false;
48
121
  for (const marker of PROJECT_BOUNDARY_MARKERS) {
49
122
  try {
50
- const stat = _internals.lstatSync(path.join(directory, marker.name));
123
+ const stat = _internals2.lstatSync(path2.join(directory, marker.name));
51
124
  if (!stat.isSymbolicLink() && marker.accepts(stat))
52
125
  return true;
53
126
  } catch {}
@@ -58,8 +131,8 @@ function isStrictPathDescendant(candidate, root) {
58
131
  if (!isAbsoluteDirectoryInput(candidate) || !isAbsoluteDirectoryInput(root)) {
59
132
  return false;
60
133
  }
61
- const relative2 = path.relative(root, candidate);
62
- return relative2 !== "" && relative2 !== ".." && !relative2.startsWith(`..${path.sep}`) && !path.isAbsolute(relative2);
134
+ const relative2 = path2.relative(root, candidate);
135
+ return relative2 !== "" && relative2 !== ".." && !relative2.startsWith(`..${path2.sep}`) && !path2.isAbsolute(relative2);
63
136
  }
64
137
  function isMissingPathError(error) {
65
138
  const code = error?.code;
@@ -70,8 +143,8 @@ function isWeakConfigContainerRoot(directory, dependencies) {
70
143
  const resolved = dependencies.realpathSync(directory);
71
144
  return resolved === dependencies.realpathSync(os.tmpdir()) || resolved === dependencies.realpathSync(os.homedir());
72
145
  } catch {
73
- const resolved = path.resolve(directory);
74
- return resolved === path.resolve(os.tmpdir()) || resolved === path.resolve(os.homedir());
146
+ const resolved = path2.resolve(directory);
147
+ return resolved === path2.resolve(os.tmpdir()) || resolved === path2.resolve(os.homedir());
75
148
  }
76
149
  }
77
150
  function projectIndicatorState(directory, dependencies, options = {}) {
@@ -80,7 +153,7 @@ function projectIndicatorState(directory, dependencies, options = {}) {
80
153
  if (!allowConfigOnly && indicator === ".opencode")
81
154
  continue;
82
155
  try {
83
- const indicatorStat = dependencies.statSync(path.join(directory, indicator));
156
+ const indicatorStat = dependencies.statSync(path2.join(directory, indicator));
84
157
  if (indicatorStat.isFile() || indicatorStat.isDirectory())
85
158
  return "present";
86
159
  } catch (error) {
@@ -90,7 +163,7 @@ function projectIndicatorState(directory, dependencies, options = {}) {
90
163
  }
91
164
  return "absent";
92
165
  }
93
- function assertProjectRoot(directory, dependencies = fs, artifactLabel = "runtime state") {
166
+ function assertProjectRoot(directory, dependencies = fs2, artifactLabel = "runtime state") {
94
167
  let resolved;
95
168
  try {
96
169
  resolved = dependencies.realpathSync(directory);
@@ -108,14 +181,14 @@ function assertProjectRoot(directory, dependencies = fs, artifactLabel = "runtim
108
181
  throw new Error(`Cannot verify project root for "${resolved}" \u2014 ancestor search exceeded ${MAX_PROJECT_ROOT_DEPTH} levels`);
109
182
  }
110
183
  depth++;
111
- const parent = path.dirname(current);
184
+ const parent = path2.dirname(current);
112
185
  if (parent === current)
113
186
  break;
114
- if (path.dirname(parent) === parent) {
187
+ if (path2.dirname(parent) === parent) {
115
188
  current = parent;
116
189
  continue;
117
190
  }
118
- const parentSwarm = path.join(parent, ".swarm");
191
+ const parentSwarm = path2.join(parent, ".swarm");
119
192
  let parentSwarmStat;
120
193
  try {
121
194
  parentSwarmStat = dependencies.statSync(parentSwarm);
@@ -143,82 +216,9 @@ function assertProjectRoot(directory, dependencies = fs, artifactLabel = "runtim
143
216
  current = parent;
144
217
  }
145
218
  }
146
- var _internals = {
147
- lstatSync: fs.lstatSync
148
- };
149
-
150
- // src/parallel/file-locks.ts
151
- var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
152
- import * as crypto from "crypto";
153
- import * as fs2 from "fs";
154
- import * as path2 from "path";
155
- var LOCKS_DIR = ".swarm/locks";
156
- var LOCK_TIMEOUT_MS = 5 * 60 * 1000;
157
219
  var _internals2 = {
158
- tryAcquireLock,
159
- writeFile: fs2.promises.writeFile
220
+ lstatSync: fs2.lstatSync
160
221
  };
161
- function getLockFilePath(directory, filePath) {
162
- const normalized = path2.resolve(directory, filePath);
163
- const baseDir = path2.resolve(directory) + path2.sep;
164
- const pathOk = process.platform === "win32" ? normalized.toLowerCase().startsWith(baseDir.toLowerCase()) : normalized.startsWith(baseDir);
165
- if (!pathOk) {
166
- throw new Error("Invalid file path: path traversal not allowed");
167
- }
168
- const pathForHash = process.platform === "win32" ? normalized.toLowerCase() : normalized;
169
- const hash = crypto.createHash("sha256").update(pathForHash).digest("hex");
170
- const lockPath = path2.join(directory, LOCKS_DIR, `${hash}.lock`);
171
- const legacyPaths = [pathForHash];
172
- if (process.platform === "win32" && normalized !== pathForHash) {
173
- legacyPaths.push(normalized);
174
- }
175
- for (const legacyPath of legacyPaths) {
176
- const oldHash = Buffer.from(legacyPath).toString("base64").replace(/[/+=]/g, "_");
177
- const oldLockPath = path2.join(directory, LOCKS_DIR, `${oldHash}.lock`);
178
- if (fs2.existsSync(oldLockPath)) {
179
- return oldLockPath;
180
- }
181
- }
182
- return lockPath;
183
- }
184
- async function tryAcquireLock(directory, filePath, agent, taskId) {
185
- const lockPath = getLockFilePath(directory, filePath);
186
- const locksDir = path2.dirname(lockPath);
187
- if (!fs2.existsSync(locksDir)) {
188
- fs2.mkdirSync(locksDir, { recursive: true });
189
- }
190
- if (!fs2.existsSync(lockPath)) {
191
- fs2.writeFileSync(lockPath, "", "utf-8");
192
- }
193
- let release;
194
- try {
195
- release = await import_proper_lockfile.default.lock(lockPath, {
196
- stale: LOCK_TIMEOUT_MS,
197
- retries: {
198
- retries: 5,
199
- minTimeout: 10,
200
- maxTimeout: 500,
201
- factor: 2
202
- },
203
- realpath: false
204
- });
205
- } catch (err) {
206
- const code = err.code;
207
- if (code === "ELOCKED" || code === "EEXIST") {
208
- return { acquired: false };
209
- }
210
- throw err;
211
- }
212
- const lock = {
213
- filePath,
214
- agent,
215
- taskId,
216
- timestamp: new Date().toISOString(),
217
- expiresAt: Date.now() + LOCK_TIMEOUT_MS,
218
- _release: release
219
- };
220
- return { acquired: true, lock };
221
- }
222
222
 
223
223
  // src/evidence/lock.ts
224
224
  class EvidenceLockTimeoutError extends Error {
@@ -7,19 +7,19 @@ import {
7
7
  } from "./index-ae75rja9.js";
8
8
  import {
9
9
  resolveKnowledgeStoreDir
10
- } from "./index-mrpfd1jx.js";
10
+ } from "./index-vh05t3w5.js";
11
11
  import {
12
12
  atomicWriteFile
13
- } from "./index-4hp8nvwb.js";
13
+ } from "./index-p8kk34am.js";
14
14
  import {
15
15
  assertProjectRoot
16
- } from "./index-35qep0v7.js";
16
+ } from "./index-912qz4y0.js";
17
17
  import {
18
18
  require_proper_lockfile
19
19
  } from "./index-7g4c7s5r.js";
20
20
  import {
21
21
  loadPluginConfigWithMeta
22
- } from "./index-pp5m7xga.js";
22
+ } from "./index-zd4qhnr7.js";
23
23
  import {
24
24
  init_logger,
25
25
  warn
@@ -27,10 +27,10 @@ import {
27
27
  import {
28
28
  KnowledgeConfigSchema,
29
29
  init_schema
30
- } from "./index-tj04dj06.js";
30
+ } from "./index-thp186x0.js";
31
31
  import {
32
32
  emit
33
- } from "./index-bfhwtdsw.js";
33
+ } from "./index-epvhf50h.js";
34
34
  import {
35
35
  __require,
36
36
  __toESM
@@ -2514,7 +2514,7 @@ async function applyKnowledgeVerdictFeedback(directory, options) {
2514
2514
  }
2515
2515
  let bumps = 0;
2516
2516
  if (deltas.length > 0) {
2517
- const { bumpKnowledgeConfidenceBatch } = await import("./knowledge-store-ttg33482.js");
2517
+ const { bumpKnowledgeConfidenceBatch } = await import("./knowledge-store-0vy8wbzd.js");
2518
2518
  bumps = await bumpKnowledgeConfidenceBatch(directory, deltas, options?.floorOptions);
2519
2519
  }
2520
2520
  return {
@@ -5,10 +5,10 @@ import {
5
5
  import {
6
6
  computePlanStructureHash,
7
7
  derivePlanId
8
- } from "./index-wk8s1m7b.js";
8
+ } from "./index-4zxrkk1h.js";
9
9
  import {
10
10
  assertProjectRoot
11
- } from "./index-35qep0v7.js";
11
+ } from "./index-912qz4y0.js";
12
12
  import {
13
13
  require_proper_lockfile
14
14
  } from "./index-7g4c7s5r.js";
@@ -17,7 +17,7 @@ import {
17
17
  } from "./index-4nt52yr9.js";
18
18
  import {
19
19
  PlanSchema
20
- } from "./index-d181x9zr.js";
20
+ } from "./index-zd4qhnr7.js";
21
21
  import {
22
22
  __toESM
23
23
  } from "./index-a76rekgs.js";
@@ -773,12 +773,12 @@ function isDispatchCorrelated(binding) {
773
773
  return binding.activation === "active" && typeof binding.dispatchCallId === "string" && binding.dispatchCallId.length > 0 && binding.ownerMessageId === binding.dispatchCallId && typeof binding.parentOwnerSessionId === "string" && binding.parentOwnerSessionId.length > 0 && binding.ownerSessionId !== binding.parentOwnerSessionId && binding.parentCallId === binding.dispatchCallId;
774
774
  }
775
775
  function clearScopeBindingFromDisk(input) {
776
+ const localRetirement = installScopeBindingRetirementIntent(input.binding);
776
777
  try {
777
778
  assertProjectRoot(input.directory);
778
779
  } catch (error) {
779
780
  return persistenceFailure(`Scope retirement project-root validation failed: ${error instanceof Error ? error.message : "unknown validation error"}`);
780
781
  }
781
- const localRetirement = installScopeBindingRetirementIntent(input.binding);
782
782
  let release;
783
783
  try {
784
784
  const resolvedWorkspace = fs2.realpathSync(input.directory);
@@ -9,7 +9,7 @@ import {
9
9
  readEvaluationRun,
10
10
  saveEvaluationRun,
11
11
  saveTaskSetSnapshot
12
- } from "./index-w4etfamq.js";
12
+ } from "./index-t5pytnca.js";
13
13
  import {
14
14
  canonicalHash,
15
15
  computeCandidateInputContentHash,
@@ -12,7 +12,7 @@ import {
12
12
  import {
13
13
  SWARM_WORKTREE_DIR_NAME,
14
14
  init_constants
15
- } from "./index-hxvkfx6t.js";
15
+ } from "./index-jqsfsqbx.js";
16
16
  import {
17
17
  __require
18
18
  } from "./index-a76rekgs.js";
@@ -86,7 +86,7 @@ var _internals = {
86
86
  symlinkSync: fs.symlinkSync
87
87
  },
88
88
  writeScopeToDisk: async (directory, taskId, files) => {
89
- const { writeScopeToDisk: realWrite } = await import("./scope-persistence-8c72jrgp.js");
89
+ const { writeScopeToDisk: realWrite } = await import("./scope-persistence-0ny5fn07.js");
90
90
  return realWrite(directory, taskId, files);
91
91
  },
92
92
  writeLaneProfileToDisk: async (_worktreePath, _laneIndex, _envOverrides) => {