opencode-swarm 7.164.0 → 7.164.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 (103) hide show
  1. package/.opencode/skills/codebase-review-swarm/SKILL.md +4 -0
  2. package/.opencode/skills/commit-pr/SKILL.md +4 -1
  3. package/.opencode/skills/critic-gate/SKILL.md +4 -0
  4. package/.opencode/skills/deep-dive/SKILL.md +4 -0
  5. package/.opencode/skills/engineering-conventions/SKILL.md +2 -0
  6. package/.opencode/skills/execute/SKILL.md +4 -0
  7. package/.opencode/skills/phase-wrap/SKILL.md +4 -0
  8. package/.opencode/skills/plan/SKILL.md +4 -0
  9. package/.opencode/skills/running-tests/SKILL.md +4 -0
  10. package/.opencode/skills/swarm-pr-review/SKILL.md +4 -0
  11. package/.opencode/skills/swarm-pr-review/references/prompt-templates.md +2 -0
  12. package/.opencode/skills/writing-tests/SKILL.md +4 -0
  13. package/dist/agents/critic.d.ts +6 -6
  14. package/dist/cli/{coder-settlement-84je6bza.js → coder-settlement-kv1x94w6.js} +12 -13
  15. package/dist/cli/{config-doctor-vfze38e1.js → config-doctor-8d7ydxck.js} +3 -3
  16. package/dist/cli/{core-q5hv8e2w.js → core-7jjgxczp.js} +2 -2
  17. package/dist/cli/{curation-policy-a2zty4br.js → curation-policy-7pnmnfct.js} +6 -7
  18. package/dist/cli/{curator-4pckmmyf.js → curator-5nyth2rj.js} +35 -38
  19. package/dist/cli/{curator-drift-wy7ejcvw.js → curator-drift-ykrdf08r.js} +4 -5
  20. package/dist/cli/curator-llm-factory-d415s169.js +66 -0
  21. package/dist/cli/{evidence-summary-service-b15yes21.js → evidence-summary-service-aebn7nb9.js} +16 -17
  22. package/dist/cli/{gate-evidence-70h0w4tb.js → gate-evidence-es59pysy.js} +8 -9
  23. package/dist/cli/guardrail-explain-mn2x7w2y.js +67 -0
  24. package/dist/cli/{guardrail-log-7rxbd20p.js → guardrail-log-fd3c5rks.js} +8 -9
  25. package/dist/cli/{guardrail-reset-3b4gs357.js → guardrail-reset-r49rvptv.js} +35 -38
  26. package/dist/cli/{hive-promoter-s80g1gwb.js → hive-promoter-qp2kjhhp.js} +35 -38
  27. package/dist/cli/{index-93sepnc9.js → index-0145kpjr.js} +2 -2
  28. package/dist/cli/{index-v3a9rmyh.js → index-1r6p1wpa.js} +4 -4
  29. package/dist/cli/{index-c4pynht5.js → index-2xj34nkh.js} +1 -1
  30. package/dist/cli/{index-g64154pd.js → index-34exj2e3.js} +2 -2
  31. package/dist/cli/{index-td6n935w.js → index-3704v4e6.js} +2 -2
  32. package/dist/cli/{index-ynqp3jb6.js → index-5d7bzpfn.js} +1 -1
  33. package/dist/cli/{index-hyq20s2v.js → index-6vtm4rd0.js} +12 -12
  34. package/dist/cli/{index-4afh2cz7.js → index-92q98ry8.js} +7 -7
  35. package/dist/cli/{index-wdtckfnf.js → index-ac39znep.js} +2 -2
  36. package/dist/cli/{index-4jersar8.js → index-axtnc0xf.js} +5 -5
  37. package/dist/cli/{index-e3hwzcjv.js → index-b85jnfp4.js} +2 -2
  38. package/dist/cli/{index-bm73pych.js → index-br7q79t2.js} +7 -7
  39. package/dist/cli/{index-1b1h770t.js → index-bzd67m2j.js} +3 -3
  40. package/dist/cli/{index-ma8w6pfp.js → index-c8k4cs94.js} +5 -5
  41. package/dist/cli/{index-t90gjc0k.js → index-cm4r8gh2.js} +1 -1
  42. package/dist/cli/{index-3b762978.js → index-f9nfknjg.js} +182 -37
  43. package/dist/cli/{index-t9rhtvy9.js → index-fyt5byhd.js} +3 -3
  44. package/dist/cli/{index-zbpcpsk0.js → index-gz5rn6w6.js} +9 -9
  45. package/dist/cli/{index-7r9vpkwa.js → index-h9wnkr2e.js} +5 -5
  46. package/dist/cli/{index-1hpjwz3s.js → index-hcn69kp0.js} +1 -1
  47. package/dist/cli/{index-12f1tsn2.js → index-hnwg5gt6.js} +655 -16
  48. package/dist/cli/{index-qkk2skff.js → index-jw9wbwdh.js} +37 -40
  49. package/dist/cli/{index-pvgcex0d.js → index-kwd09y5a.js} +4 -4
  50. package/dist/cli/{index-9xd073d4.js → index-m1nrd3yd.js} +9 -2
  51. package/dist/cli/{index-c69jbpex.js → index-pcnhh2vt.js} +2 -2
  52. package/dist/cli/{index-gxd8fwyt.js → index-q3xn3m3g.js} +4 -4
  53. package/dist/cli/{index-fckfgptr.js → index-qbr05tbw.js} +2 -2
  54. package/dist/cli/{index-9sy65e94.js → index-qmeewt3g.js} +32 -34
  55. package/dist/cli/{index-tb1k8jya.js → index-sb4eanpv.js} +1 -1
  56. package/dist/cli/{index-dtn0pne5.js → index-v56mhyhs.js} +1 -1
  57. package/dist/cli/{index-2s4s9n82.js → index-w5jpjaqe.js} +2 -2
  58. package/dist/cli/{index-1z4jzwja.js → index-w8qt2612.js} +3 -3
  59. package/dist/cli/{index-nhxaa9j5.js → index-xm6c1tnf.js} +1 -1
  60. package/dist/cli/{index-0515j0cz.js → index-y2f5s2cf.js} +1 -1
  61. package/dist/cli/{index-36nt17m8.js → index-yep24wn4.js} +1 -1
  62. package/dist/cli/{index-xk0kc1py.js → index-yjftcanv.js} +7767 -2575
  63. package/dist/cli/{index-t5t82jy8.js → index-yqhwrjw9.js} +5 -5
  64. package/dist/cli/{index-nzrhw31r.js → index-zgeqwbhw.js} +2 -2
  65. package/dist/cli/{index-70bfj3v1.js → index-zs1jrsta.js} +2 -2
  66. package/dist/cli/index.js +35 -38
  67. package/dist/cli/{knowledge-escalator-sttdnwf8.js → knowledge-escalator-439jajb3.js} +14 -15
  68. package/dist/cli/{knowledge-events-4h88stj7.js → knowledge-events-wz3h98kk.js} +12 -13
  69. package/dist/cli/{knowledge-link-yykmxdyw.js → knowledge-link-2gh1cnk3.js} +5 -6
  70. package/dist/cli/{knowledge-store-j832fxpx.js → knowledge-store-y1cwe80n.js} +6 -7
  71. package/dist/cli/{knowledge-validator-edbg761g.js → knowledge-validator-bk2qfqe2.js} +8 -9
  72. package/dist/cli/{model-preflight-c3mc8njg.js → model-preflight-pmnbfzjv.js} +1 -1
  73. package/dist/cli/{pending-delegations-sphntrs0.js → pending-delegations-kh4mkvzb.js} +6 -8
  74. package/dist/cli/{pr-subscriptions-1a4gcnzv.js → pr-subscriptions-sdv0n59c.js} +6 -7
  75. package/dist/cli/pr-workflow-gate-a9vj11e5.js +221 -0
  76. package/dist/cli/{runner-d294h1by.js → runner-m95v9d47.js} +6 -7
  77. package/dist/cli/{scan-cursor-5frvp7nb.js → scan-cursor-pjek24k7.js} +7 -8
  78. package/dist/cli/{schema-9xkt5hvd.js → schema-674qw3aj.js} +2 -2
  79. package/dist/cli/{scope-persistence-gk55h3sp.js → scope-persistence-sq331eqh.js} +10 -11
  80. package/dist/cli/{skill-generator-sxxf7jbb.js → skill-generator-pcw7c50r.js} +16 -17
  81. package/dist/cli/{telemetry-q51s6tyt.js → telemetry-c4j18da8.js} +1 -1
  82. package/dist/cli/{worktree-collision-ownership-7kj2ryt1.js → worktree-collision-ownership-vnj31rgc.js} +7 -9
  83. package/dist/cli/{worktree-isolation-67fs6rz9.js → worktree-isolation-tje6p4zt.js} +35 -38
  84. package/dist/hooks/delegate-ack-collector.d.ts +5 -0
  85. package/dist/hooks/delegation-gate.d.ts +14 -2
  86. package/dist/hooks/plan-task-id-context.d.ts +24 -0
  87. package/dist/hooks/pr-workflow-gate.d.ts +14 -8
  88. package/dist/hooks/pr-workflow-response-gate.d.ts +9 -12
  89. package/dist/hooks/skill-injection.d.ts +7 -3
  90. package/dist/hooks/skill-propagation-gate.d.ts +1 -1
  91. package/dist/hooks/task-id-resolver.d.ts +46 -0
  92. package/dist/index.js +118 -92
  93. package/dist/pr-review/authorization.d.ts +18 -12
  94. package/dist/tools/authorize-pr-review-reentry.d.ts +12 -8
  95. package/dist/tools/tool-metadata.d.ts +1 -1
  96. package/opencode-swarm.schema.json +4 -1
  97. package/package.json +1 -1
  98. package/dist/cli/authorization-vstrh7ra.js +0 -23
  99. package/dist/cli/curator-llm-factory-msbj3hpn.js +0 -69
  100. package/dist/cli/guardrail-explain-kksdy032.js +0 -70
  101. package/dist/cli/index-ed5ykebp.js +0 -151
  102. package/dist/cli/index-mmngnxev.js +0 -883
  103. package/dist/cli/index-w7ekntej.js +0 -643
@@ -5,7 +5,7 @@ import {
5
5
  } from "./index-3f7hqtgg.js";
6
6
  import {
7
7
  removeWorktreeProvisioningOwner
8
- } from "./index-fckfgptr.js";
8
+ } from "./index-qbr05tbw.js";
9
9
  import {
10
10
  SOURCE_WORKTREE_GONE_STAGE,
11
11
  getTaskWorkflowSnapshot,
@@ -13,19 +13,19 @@ import {
13
13
  reconcileLandedMerge,
14
14
  withTaskEvidenceTransaction,
15
15
  writeWorkflowWalFile
16
- } from "./index-7r9vpkwa.js";
16
+ } from "./index-h9wnkr2e.js";
17
17
  import {
18
18
  canonicalRootKeyFresh
19
19
  } from "./index-ddszzne4.js";
20
20
  import {
21
21
  appendCoreEventSync
22
- } from "./index-93sepnc9.js";
22
+ } from "./index-0145kpjr.js";
23
23
  import {
24
24
  isPathWithinDeclaredScope
25
25
  } from "./index-556ja8an.js";
26
26
  import {
27
27
  validateSwarmPath
28
- } from "./index-dtn0pne5.js";
28
+ } from "./index-v56mhyhs.js";
29
29
  import {
30
30
  init_git_executable,
31
31
  resolveGitExecutable
@@ -36,7 +36,7 @@ import {
36
36
  } from "./index-4rhhvd1a.js";
37
37
  import {
38
38
  tryAcquireLock
39
- } from "./index-36nt17m8.js";
39
+ } from "./index-yep24wn4.js";
40
40
  import {
41
41
  criticalWarn,
42
42
  init_logger
@@ -478,7 +478,7 @@ async function cleanupRecoveredWorktree(directory, descriptor) {
478
478
  awaitingMergeByCallID,
479
479
  cleanupStandardWorktreeForCallId,
480
480
  standardWorktreeByCallID
481
- } = await import("./worktree-isolation-67fs6rz9.js");
481
+ } = await import("./worktree-isolation-tje6p4zt.js");
482
482
  standardWorktreeByCallID.delete(descriptor.callID);
483
483
  if (hasResidue)
484
484
  awaitingMergeByCallID.set(descriptor.callID, {
@@ -602,7 +602,7 @@ async function recoverCoderSettlement(directory, taskId) {
602
602
  awaitingMergeByCallID,
603
603
  finishStandardWorktreeDispatch,
604
604
  standardWorktreeByCallID
605
- } = await import("./worktree-isolation-67fs6rz9.js");
605
+ } = await import("./worktree-isolation-tje6p4zt.js");
606
606
  const descriptor = wal.worktree;
607
607
  const reconstructedDispatch = {
608
608
  callID: descriptor.callID,
@@ -1,12 +1,12 @@
1
1
  // @bun
2
2
  import {
3
3
  atomicWriteSwarmFile
4
- } from "./index-3b762978.js";
4
+ } from "./index-f9nfknjg.js";
5
5
  import {
6
6
  pseudonymousRef,
7
7
  resolveLineageSalt,
8
8
  telemetry
9
- } from "./index-1b1h770t.js";
9
+ } from "./index-bzd67m2j.js";
10
10
 
11
11
  // src/health/learning-health.ts
12
12
  import { promises as fs } from "fs";
@@ -2,23 +2,23 @@
2
2
  import {
3
3
  computePlanStructureHash,
4
4
  derivePlanId
5
- } from "./index-1z4jzwja.js";
5
+ } from "./index-w8qt2612.js";
6
6
  import {
7
7
  appendCoreEventSync
8
- } from "./index-93sepnc9.js";
8
+ } from "./index-0145kpjr.js";
9
9
  import {
10
10
  unsafePathTextReason
11
11
  } from "./index-556ja8an.js";
12
12
  import {
13
13
  PlanSchema
14
- } from "./index-nhxaa9j5.js";
14
+ } from "./index-xm6c1tnf.js";
15
15
  import {
16
16
  assertProjectRoot
17
- } from "./index-36nt17m8.js";
17
+ } from "./index-yep24wn4.js";
18
18
  import {
19
19
  atomicWriteSwarmFile,
20
20
  atomicWriteSwarmFileSync
21
- } from "./index-3b762978.js";
21
+ } from "./index-f9nfknjg.js";
22
22
  import {
23
23
  require_proper_lockfile
24
24
  } from "./index-7g4c7s5r.js";
@@ -2,14 +2,14 @@
2
2
  import {
3
3
  readKnowledge,
4
4
  transactKnowledge
5
- } from "./index-bm73pych.js";
5
+ } from "./index-br7q79t2.js";
6
6
  import {
7
7
  init_git_executable,
8
8
  resolveGitExecutableAsync
9
9
  } from "./index-9e6fdz2h.js";
10
10
  import {
11
11
  resolveKnowledgeStoreDir
12
- } from "./index-ynqp3jb6.js";
12
+ } from "./index-5d7bzpfn.js";
13
13
  import {
14
14
  init_knowledge_types,
15
15
  isActiveStatus
@@ -6,17 +6,17 @@ import {
6
6
  } from "./index-ae75rja9.js";
7
7
  import {
8
8
  resolveKnowledgeStoreDir
9
- } from "./index-ynqp3jb6.js";
9
+ } from "./index-5d7bzpfn.js";
10
10
  import {
11
11
  atomicWriteFile
12
- } from "./index-70bfj3v1.js";
12
+ } from "./index-zs1jrsta.js";
13
13
  import {
14
14
  init_knowledge_types,
15
15
  isActiveStatus
16
16
  } from "./index-bk5tah7q.js";
17
17
  import {
18
18
  readCachedParsedFile
19
- } from "./index-ed5ykebp.js";
19
+ } from "./index-f9nfknjg.js";
20
20
  import {
21
21
  require_proper_lockfile
22
22
  } from "./index-7g4c7s5r.js";
@@ -713,7 +713,7 @@ async function applyConfidenceFloorAction(directory, touched, options) {
713
713
  const {
714
714
  readAuthoritativeKnowledgeCounterRollups,
715
715
  effectiveRetrievalOutcomes
716
- } = await import("./knowledge-events-4h88stj7.js");
716
+ } = await import("./knowledge-events-wz3h98kk.js");
717
717
  const rollups = await readAuthoritativeKnowledgeCounterRollups(directory);
718
718
  const flagIds = new Set;
719
719
  for (const e of atFloor) {
@@ -780,11 +780,11 @@ async function applyConfidenceFloorAction(directory, touched, options) {
780
780
  });
781
781
  }
782
782
  if (action === "quarantine" && toQuarantine.length > 0) {
783
- const { quarantineEntry } = await import("./knowledge-validator-edbg761g.js");
784
- const { KnowledgeConfigSchema } = await import("./schema-9xkt5hvd.js");
783
+ const { quarantineEntry } = await import("./knowledge-validator-bk2qfqe2.js");
784
+ const { KnowledgeConfigSchema } = await import("./schema-674qw3aj.js");
785
785
  let config;
786
786
  try {
787
- const { loadPluginConfigWithMeta } = await import("./index-v3a9rmyh.js");
787
+ const { loadPluginConfigWithMeta } = await import("./index-1r6p1wpa.js");
788
788
  const { config: loadedConfig } = loadPluginConfigWithMeta(directory);
789
789
  config = KnowledgeConfigSchema.parse(loadedConfig.knowledge ?? {});
790
790
  } catch {
@@ -217,7 +217,7 @@ var CATALOG_SOURCE = [
217
217
  category: "delegation",
218
218
  severity: "info",
219
219
  privacyClass: "pseudonymous",
220
- producer: "src/index.ts:638",
220
+ producer: "src/index.ts:642",
221
221
  consumers: CONSUMER_COST_CORRECTION,
222
222
  retentionOwnerIssue: ISSUE_COST_RETENTION,
223
223
  requiredWorkflowIds: REQUIRE_SESSION_AND_TASK,
@@ -230,7 +230,7 @@ var CATALOG_SOURCE = [
230
230
  category: "delegation",
231
231
  severity: "info",
232
232
  privacyClass: "pseudonymous",
233
- producer: "src/index.ts:1563",
233
+ producer: "src/index.ts:1567",
234
234
  consumers: NO_CONSUMERS,
235
235
  futureOwnerIssue: ISSUE_SINK,
236
236
  retentionOwnerIssue: ISSUE_COST_RETENTION,
@@ -244,7 +244,7 @@ var CATALOG_SOURCE = [
244
244
  category: "delegation",
245
245
  severity: "notice",
246
246
  privacyClass: "pseudonymous",
247
- producer: "src/index.ts:1583",
247
+ producer: "src/index.ts:1587",
248
248
  consumers: CONSUMER_COST_JOIN,
249
249
  retentionOwnerIssue: ISSUE_COST_RETENTION,
250
250
  requiredWorkflowIds: REQUIRE_SESSION,
@@ -1,19 +1,19 @@
1
1
  // @bun
2
2
  import {
3
3
  validateSwarmPath
4
- } from "./index-dtn0pne5.js";
4
+ } from "./index-v56mhyhs.js";
5
5
  import {
6
6
  observeStoreHealth
7
- } from "./index-wdtckfnf.js";
7
+ } from "./index-ac39znep.js";
8
8
  import {
9
9
  withEvidenceLock
10
- } from "./index-36nt17m8.js";
10
+ } from "./index-yep24wn4.js";
11
11
  import {
12
12
  atomicWriteSwarmFileSync
13
- } from "./index-3b762978.js";
13
+ } from "./index-f9nfknjg.js";
14
14
  import {
15
15
  telemetry
16
- } from "./index-1b1h770t.js";
16
+ } from "./index-bzd67m2j.js";
17
17
  import {
18
18
  exports_external,
19
19
  init_zod
@@ -4,7 +4,7 @@ import {
4
4
  readShellAuditTail,
5
5
  redactPath,
6
6
  redactShellCommand
7
- } from "./index-9sy65e94.js";
7
+ } from "./index-qmeewt3g.js";
8
8
 
9
9
  // src/services/guardrail-log-service.ts
10
10
  var BLOCK_TYPES = new Set([
@@ -1,12 +1,157 @@
1
1
  // @bun
2
- import {
3
- invalidateCachedArtifact
4
- } from "./index-ed5ykebp.js";
2
+ // src/utils/swarm-artifact-cache.ts
3
+ import * as fsSync from "fs";
4
+ import * as fs from "fs/promises";
5
+ import * as path from "path";
6
+ var MAX_CACHE_ENTRIES = 128;
7
+ var textCache = new Map;
8
+ var parsedCache = new Map;
9
+ var stats = {
10
+ textReadCount: 0,
11
+ textCacheHitCount: 0,
12
+ textCacheMissCount: 0,
13
+ parsedReadCount: 0,
14
+ parseCount: 0,
15
+ parsedCacheHitCount: 0,
16
+ parsedCacheMissCount: 0,
17
+ statFailureCount: 0,
18
+ evictionCount: 0,
19
+ textEvictionCount: 0,
20
+ parsedEvictionCount: 0,
21
+ cloneFallbackCount: 0,
22
+ textEntryCount: 0,
23
+ parsedEntryCount: 0
24
+ };
25
+ function sameStamp(a, b) {
26
+ return a.mtimeMs === b.mtimeMs && a.ctimeMs === b.ctimeMs && a.size === b.size;
27
+ }
28
+ var _internals = {
29
+ stat: fs.stat,
30
+ statSync: fsSync.statSync
31
+ };
32
+ async function getStamp(filePath) {
33
+ try {
34
+ const stat2 = await _internals.stat(filePath);
35
+ if (!stat2.isFile())
36
+ return null;
37
+ return { mtimeMs: stat2.mtimeMs, ctimeMs: stat2.ctimeMs, size: stat2.size };
38
+ } catch {
39
+ stats.statFailureCount++;
40
+ return null;
41
+ }
42
+ }
43
+ function canStoreRead(before, after) {
44
+ return after !== null && sameStamp(before, after);
45
+ }
46
+ function setBounded(cache, key, value, cacheKind) {
47
+ cache.set(key, value);
48
+ while (cache.size > MAX_CACHE_ENTRIES) {
49
+ const oldest = cache.keys().next().value;
50
+ if (oldest === undefined)
51
+ break;
52
+ cache.delete(oldest);
53
+ stats.evictionCount++;
54
+ if (cacheKind === "text") {
55
+ stats.textEvictionCount++;
56
+ } else {
57
+ stats.parsedEvictionCount++;
58
+ }
59
+ }
60
+ stats.textEntryCount = textCache.size;
61
+ stats.parsedEntryCount = parsedCache.size;
62
+ }
63
+ function cloneCachedValue(value) {
64
+ if (value === null || typeof value !== "object")
65
+ return value;
66
+ if (typeof structuredClone === "function") {
67
+ return structuredClone(value);
68
+ }
69
+ stats.cloneFallbackCount++;
70
+ return JSON.parse(JSON.stringify(value));
71
+ }
72
+ async function readCachedTextFile(filePath, directRead) {
73
+ const cacheKey = path.resolve(filePath);
74
+ const stamp = await getStamp(cacheKey);
75
+ if (!stamp) {
76
+ stats.textReadCount++;
77
+ return directRead();
78
+ }
79
+ const cached = textCache.get(cacheKey);
80
+ if (cached && sameStamp(cached, stamp)) {
81
+ stats.textCacheHitCount++;
82
+ return cached.value;
83
+ }
84
+ stats.textCacheMissCount++;
85
+ stats.textReadCount++;
86
+ const value = await directRead();
87
+ const afterReadStamp = await getStamp(cacheKey);
88
+ if (value !== null && canStoreRead(stamp, afterReadStamp)) {
89
+ setBounded(textCache, cacheKey, { ...afterReadStamp, value }, "text");
90
+ }
91
+ return value;
92
+ }
93
+ async function readCachedParsedFile(filePath, namespace, readText, parse) {
94
+ const resolvedPath = path.resolve(filePath);
95
+ const cacheKey = `${resolvedPath}\x00${namespace}`;
96
+ const stamp = await getStamp(resolvedPath);
97
+ if (!stamp) {
98
+ stats.parsedReadCount++;
99
+ const content2 = await readText();
100
+ if (content2 === null)
101
+ return null;
102
+ stats.parseCount++;
103
+ return parse(content2);
104
+ }
105
+ const cached = parsedCache.get(cacheKey);
106
+ if (cached && sameStamp(cached, stamp)) {
107
+ stats.parsedCacheHitCount++;
108
+ return cloneCachedValue(cached.value);
109
+ }
110
+ stats.parsedCacheMissCount++;
111
+ stats.parsedReadCount++;
112
+ const content = await readText();
113
+ if (content === null)
114
+ return null;
115
+ stats.parseCount++;
116
+ const value = parse(content);
117
+ const afterReadStamp = await getStamp(resolvedPath);
118
+ if (canStoreRead(stamp, afterReadStamp)) {
119
+ setBounded(parsedCache, cacheKey, { ...afterReadStamp, value }, "parsed");
120
+ }
121
+ return cloneCachedValue(value);
122
+ }
123
+ function invalidateCachedArtifact(filePath) {
124
+ const resolvedPath = path.resolve(filePath);
125
+ textCache.delete(resolvedPath);
126
+ const prefix = `${resolvedPath}\x00`;
127
+ for (const key of parsedCache.keys()) {
128
+ if (key.startsWith(prefix))
129
+ parsedCache.delete(key);
130
+ }
131
+ }
132
+ function resetSwarmArtifactCache() {
133
+ textCache.clear();
134
+ parsedCache.clear();
135
+ stats.textReadCount = 0;
136
+ stats.textCacheHitCount = 0;
137
+ stats.textCacheMissCount = 0;
138
+ stats.parsedReadCount = 0;
139
+ stats.parseCount = 0;
140
+ stats.parsedCacheHitCount = 0;
141
+ stats.parsedCacheMissCount = 0;
142
+ stats.statFailureCount = 0;
143
+ stats.evictionCount = 0;
144
+ stats.textEvictionCount = 0;
145
+ stats.parsedEvictionCount = 0;
146
+ stats.cloneFallbackCount = 0;
147
+ stats.textEntryCount = 0;
148
+ stats.parsedEntryCount = 0;
149
+ }
5
150
 
6
151
  // src/utils/atomic-write.ts
7
152
  import { randomBytes } from "crypto";
8
- import * as fs from "fs";
9
- import * as path from "path";
153
+ import * as fs2 from "fs";
154
+ import * as path2 from "path";
10
155
  var UUID_RE = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
11
156
  var SWARM_TEMP_GRAMMARS = [
12
157
  {
@@ -364,7 +509,7 @@ var WRITER_CLASSIFICATION = Object.freeze({
364
509
  "src/worktree/core.ts": "reader-only"
365
510
  });
366
511
  function assertWellFormedTargetPath(targetPath) {
367
- if (!path.isAbsolute(targetPath)) {
512
+ if (!path2.isAbsolute(targetPath)) {
368
513
  throw new Error(`atomic-write target must be absolute: ${targetPath}`);
369
514
  }
370
515
  if (/[\0-\x1f\x7f]/.test(targetPath)) {
@@ -381,15 +526,15 @@ function assertWellFormedTargetPath(targetPath) {
381
526
  }
382
527
  }
383
528
  function lstatNotSymlink(p, what) {
384
- const st = fs.lstatSync(p);
529
+ const st = fs2.lstatSync(p);
385
530
  if (st.isSymbolicLink()) {
386
531
  throw new Error(`${what} is a symlink/reparse point: ${p}`);
387
532
  }
388
533
  }
389
534
  function assertSwarmContainedTarget(targetPath) {
390
535
  assertWellFormedTargetPath(targetPath);
391
- const resolved = path.normalize(path.resolve(targetPath));
392
- const segments = resolved.split(path.sep);
536
+ const resolved = path2.normalize(path2.resolve(targetPath));
537
+ const segments = resolved.split(path2.sep);
393
538
  let swarmIdx = -1;
394
539
  for (let i = segments.length - 2;i >= 1; i--) {
395
540
  if (segments[i] === ".swarm") {
@@ -400,9 +545,9 @@ function assertSwarmContainedTarget(targetPath) {
400
545
  if (swarmIdx === -1) {
401
546
  throw new Error(`atomic-write target is not under a project .swarm root: ${targetPath}`);
402
547
  }
403
- const swarmRoot = segments.slice(0, swarmIdx + 1).join(path.sep);
548
+ const swarmRoot = segments.slice(0, swarmIdx + 1).join(path2.sep);
404
549
  try {
405
- const st = fs.lstatSync(swarmRoot);
550
+ const st = fs2.lstatSync(swarmRoot);
406
551
  if (!st.isDirectory() || st.isSymbolicLink()) {
407
552
  throw new Error(`.swarm root is not a real directory (symlink/reparse or non-dir): ${swarmRoot}`);
408
553
  }
@@ -410,28 +555,28 @@ function assertSwarmContainedTarget(targetPath) {
410
555
  if (err?.code !== "ENOENT")
411
556
  throw err;
412
557
  }
413
- const rel = path.relative(swarmRoot, resolved);
414
- if (!rel || rel.startsWith("..") || path.isAbsolute(rel)) {
558
+ const rel = path2.relative(swarmRoot, resolved);
559
+ if (!rel || rel.startsWith("..") || path2.isAbsolute(rel)) {
415
560
  throw new Error(`atomic-write target escapes .swarm root: ${targetPath}`);
416
561
  }
417
562
  let probe = swarmRoot;
418
- for (const seg of rel.split(path.sep)) {
419
- probe = path.join(probe, seg);
420
- if (!fs.existsSync(probe))
563
+ for (const seg of rel.split(path2.sep)) {
564
+ probe = path2.join(probe, seg);
565
+ if (!fs2.existsSync(probe))
421
566
  break;
422
567
  lstatNotSymlink(probe, "path segment under .swarm");
423
568
  }
424
- return { projectRoot: path.dirname(swarmRoot), swarmRoot };
569
+ return { projectRoot: path2.dirname(swarmRoot), swarmRoot };
425
570
  }
426
571
  var MAX_ATOMIC_WRITE_BYTES = 256 * 1024 * 1024;
427
572
  var RENAME_RETRY_DELAYS_MS = [10, 25, 50, 100, 200];
428
573
  var RETRYABLE_RENAME_CODES = new Set(["EPERM", "EBUSY", "EACCES", "EEXIST"]);
429
- var _internals = {
574
+ var _internals2 = {
430
575
  randomSuffix: () => randomBytes(16).toString("hex"),
431
- writeSync: (fd, buffer, offset, length) => fs.writeSync(fd, buffer, offset, length),
432
- renameSync: (from, to) => fs.renameSync(from, to),
433
- unlinkSync: (p) => fs.unlinkSync(p),
434
- fsyncSync: (fd) => fs.fsyncSync(fd)
576
+ writeSync: (fd, buffer, offset, length) => fs2.writeSync(fd, buffer, offset, length),
577
+ renameSync: (from, to) => fs2.renameSync(from, to),
578
+ unlinkSync: (p) => fs2.unlinkSync(p),
579
+ fsyncSync: (fd) => fs2.fsyncSync(fd)
435
580
  };
436
581
  function toBuffer(content) {
437
582
  if (typeof content === "string")
@@ -450,7 +595,7 @@ function renameWithRetry(tempPath, targetPath) {
450
595
  let lastError;
451
596
  for (let attempt = 0;attempt <= RENAME_RETRY_DELAYS_MS.length; attempt++) {
452
597
  try {
453
- _internals.renameSync(tempPath, targetPath);
598
+ _internals2.renameSync(tempPath, targetPath);
454
599
  return;
455
600
  } catch (err) {
456
601
  lastError = err;
@@ -470,55 +615,55 @@ function writeAtomicSync(targetPath, content, options) {
470
615
  } else {
471
616
  assertWellFormedTargetPath(targetPath);
472
617
  }
473
- const resolvedTarget = path.resolve(targetPath);
618
+ const resolvedTarget = path2.resolve(targetPath);
474
619
  const buffer = toBuffer(content);
475
620
  const maxBytes = options?.maxBytes ?? MAX_ATOMIC_WRITE_BYTES;
476
621
  if (buffer.byteLength > maxBytes) {
477
622
  throw new Error(`atomic write exceeds ${maxBytes} byte bound: ${buffer.byteLength}`);
478
623
  }
479
- const tempPath = `${resolvedTarget}.${_internals.randomSuffix()}.tmp`;
480
- fs.mkdirSync(path.dirname(tempPath), { recursive: true });
624
+ const tempPath = `${resolvedTarget}.${_internals2.randomSuffix()}.tmp`;
625
+ fs2.mkdirSync(path2.dirname(tempPath), { recursive: true });
481
626
  try {
482
- const fd = fs.openSync(tempPath, "wx", options?.mode);
627
+ const fd = fs2.openSync(tempPath, "wx", options?.mode);
483
628
  try {
484
629
  let written = 0;
485
630
  while (written < buffer.byteLength) {
486
- written += _internals.writeSync(fd, buffer, written, buffer.byteLength - written);
631
+ written += _internals2.writeSync(fd, buffer, written, buffer.byteLength - written);
487
632
  }
488
633
  if (options?.skipFsync !== true) {
489
634
  try {
490
- _internals.fsyncSync(fd);
635
+ _internals2.fsyncSync(fd);
491
636
  } catch {}
492
637
  }
493
638
  } finally {
494
- fs.closeSync(fd);
639
+ fs2.closeSync(fd);
495
640
  }
496
641
  renameWithRetry(tempPath, resolvedTarget);
497
642
  } finally {
498
643
  try {
499
- _internals.unlinkSync(tempPath);
644
+ _internals2.unlinkSync(tempPath);
500
645
  } catch {}
501
646
  }
502
647
  try {
503
- const dirFd = fs.openSync(path.dirname(resolvedTarget), "r");
648
+ const dirFd = fs2.openSync(path2.dirname(resolvedTarget), "r");
504
649
  try {
505
- fs.fsyncSync(dirFd);
650
+ fs2.fsyncSync(dirFd);
506
651
  } finally {
507
- fs.closeSync(dirFd);
652
+ fs2.closeSync(dirFd);
508
653
  }
509
654
  } catch {}
510
655
  invalidateCachedArtifact(resolvedTarget);
511
656
  }
512
657
  async function atomicWriteSwarmFile(targetPath, content, options) {
513
- await new Promise((resolve2) => setImmediate(resolve2));
658
+ await new Promise((resolve3) => setImmediate(resolve3));
514
659
  writeAtomicSync(targetPath, content, options);
515
660
  }
516
661
  function atomicWriteSwarmFileSync(targetPath, content, options) {
517
662
  writeAtomicSync(targetPath, content, options);
518
663
  }
519
664
  async function atomicWriteFileAnyRoot(targetPath, content, options) {
520
- await new Promise((resolve2) => setImmediate(resolve2));
665
+ await new Promise((resolve3) => setImmediate(resolve3));
521
666
  writeAtomicSync(targetPath, content, { ...options, contained: false });
522
667
  }
523
668
 
524
- export { matchTempGrammar, parseTargetBasename, atomicWriteSwarmFile, atomicWriteSwarmFileSync, atomicWriteFileAnyRoot };
669
+ export { readCachedTextFile, readCachedParsedFile, invalidateCachedArtifact, resetSwarmArtifactCache, matchTempGrammar, parseTargetBasename, atomicWriteSwarmFile, atomicWriteSwarmFileSync, atomicWriteFileAnyRoot };
@@ -2,14 +2,14 @@
2
2
  import {
3
3
  init_loader,
4
4
  loadPluginConfigWithMeta
5
- } from "./index-nhxaa9j5.js";
5
+ } from "./index-xm6c1tnf.js";
6
6
  import {
7
7
  init_schema
8
- } from "./index-td6n935w.js";
8
+ } from "./index-3704v4e6.js";
9
9
  import {
10
10
  DEFAULT_WORKTREE_ISOLATION_CONFIG,
11
11
  init_constants
12
- } from "./index-9xd073d4.js";
12
+ } from "./index-m1nrd3yd.js";
13
13
 
14
14
  // src/config/index.ts
15
15
  init_constants();
@@ -1,32 +1,32 @@
1
1
  // @bun
2
2
  import {
3
3
  validateSwarmPath
4
- } from "./index-dtn0pne5.js";
4
+ } from "./index-v56mhyhs.js";
5
5
  import {
6
6
  loadPluginConfigWithMeta
7
- } from "./index-nhxaa9j5.js";
7
+ } from "./index-xm6c1tnf.js";
8
8
  import {
9
9
  KnowledgeConfigSchema,
10
10
  init_schema
11
- } from "./index-td6n935w.js";
11
+ } from "./index-3704v4e6.js";
12
12
  import {
13
13
  observeReceiptTransition
14
- } from "./index-wdtckfnf.js";
14
+ } from "./index-ac39znep.js";
15
15
  import {
16
16
  resolveHiveEventsPath
17
17
  } from "./index-ae75rja9.js";
18
18
  import {
19
19
  resolveKnowledgeStoreDir
20
- } from "./index-ynqp3jb6.js";
20
+ } from "./index-5d7bzpfn.js";
21
21
  import {
22
22
  atomicWriteFile
23
- } from "./index-70bfj3v1.js";
23
+ } from "./index-zs1jrsta.js";
24
24
  import {
25
25
  assertProjectRoot
26
- } from "./index-36nt17m8.js";
26
+ } from "./index-yep24wn4.js";
27
27
  import {
28
28
  emit
29
- } from "./index-1b1h770t.js";
29
+ } from "./index-bzd67m2j.js";
30
30
  import {
31
31
  require_proper_lockfile
32
32
  } from "./index-7g4c7s5r.js";
@@ -2810,7 +2810,7 @@ async function applyKnowledgeVerdictFeedback(directory, options) {
2810
2810
  }
2811
2811
  let bumps = 0;
2812
2812
  if (deltas.length > 0) {
2813
- const { bumpKnowledgeConfidenceBatch } = await import("./knowledge-store-j832fxpx.js");
2813
+ const { bumpKnowledgeConfidenceBatch } = await import("./knowledge-store-y1cwe80n.js");
2814
2814
  bumps = await bumpKnowledgeConfidenceBatch(directory, deltas, options?.floorOptions);
2815
2815
  }
2816
2816
  return {
@@ -2,14 +2,14 @@
2
2
  import {
3
3
  autoCommitDirty,
4
4
  cleanUntrackedFiles
5
- } from "./index-nzrhw31r.js";
5
+ } from "./index-zgeqwbhw.js";
6
6
  import {
7
7
  isPathWithinDeclaredScope,
8
8
  unsafePathTextReason
9
9
  } from "./index-556ja8an.js";
10
10
  import {
11
11
  validateSwarmPath
12
- } from "./index-dtn0pne5.js";
12
+ } from "./index-v56mhyhs.js";
13
13
  import {
14
14
  bunSpawn,
15
15
  classifySpawnFailure
@@ -26,13 +26,13 @@ import {
26
26
  atomicWriteFile,
27
27
  taskEvidencePath,
28
28
  withTaskEvidenceLock
29
- } from "./index-70bfj3v1.js";
29
+ } from "./index-zs1jrsta.js";
30
30
  import {
31
31
  assertProjectRoot
32
- } from "./index-36nt17m8.js";
32
+ } from "./index-yep24wn4.js";
33
33
  import {
34
34
  telemetry
35
- } from "./index-1b1h770t.js";
35
+ } from "./index-bzd67m2j.js";
36
36
  import {
37
37
  exports_external,
38
38
  init_zod
@@ -11,7 +11,7 @@ import {
11
11
  } from "./index-4rhhvd1a.js";
12
12
  import {
13
13
  atomicWriteSwarmFileSync
14
- } from "./index-3b762978.js";
14
+ } from "./index-f9nfknjg.js";
15
15
 
16
16
  // src/sdd/effective-spec.ts
17
17
  import { createHash } from "crypto";