opencode-swarm 7.163.1 → 7.164.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli/{coder-settlement-f1gtvcy8.js → coder-settlement-w4qk90kh.js} +12 -13
- package/dist/cli/{config-doctor-0fnqzqz1.js → config-doctor-r81bp1nd.js} +3 -3
- package/dist/cli/{core-w81fk5sc.js → core-xfw4s9b9.js} +2 -2
- package/dist/cli/{curation-policy-j12j2gvc.js → curation-policy-2h37sd6p.js} +6 -7
- package/dist/cli/{curator-as495r18.js → curator-7zy6bdmw.js} +36 -39
- package/dist/cli/{curator-drift-g6w4ga1q.js → curator-drift-ykrdf08r.js} +105 -38
- package/dist/cli/curator-llm-factory-7gjvm4ds.js +66 -0
- package/dist/cli/{evidence-summary-service-51dxfcn5.js → evidence-summary-service-519ny6b1.js} +17 -18
- package/dist/cli/{gate-evidence-nb1e8hz0.js → gate-evidence-a7st3vbc.js} +8 -9
- package/dist/cli/guardrail-explain-ewcm37em.js +67 -0
- package/dist/cli/{guardrail-log-2kwntcqw.js → guardrail-log-kp51by1v.js} +8 -9
- package/dist/cli/{guardrail-reset-mrxrc56j.js → guardrail-reset-reyfwtwn.js} +36 -39
- package/dist/cli/hive-promoter-zf2vf5sw.js +81 -0
- package/dist/cli/{index-4p0wyz5p.js → index-1af3rb5n.js} +9 -9
- package/dist/cli/{index-2zgjcmmc.js → index-1b1h770t.js} +3 -3
- package/dist/cli/{index-0tervb1m.js → index-2ee2g27m.js} +7795 -2724
- package/dist/cli/{index-x2f1f011.js → index-2s40e3b0.js} +4 -3
- package/dist/cli/{index-9xd073d4.js → index-2yd732fd.js} +7 -1
- package/dist/cli/{index-9crtmnqg.js → index-36nt17m8.js} +1 -1
- package/dist/cli/{index-d3azve4r.js → index-5084szce.js} +122 -300
- package/dist/cli/{index-d9gdwh34.js → index-5bza8nxz.js} +2 -2
- package/dist/cli/{index-xyhmt813.js → index-6097tx05.js} +1 -1
- package/dist/cli/{index-5056zmpt.js → index-644t46hr.js} +1 -1
- package/dist/cli/{index-2v06a1yh.js → index-6ay5zp1v.js} +5 -5
- package/dist/cli/{index-n2mhyect.js → index-6kd3jnaf.js} +1 -1
- package/dist/cli/{index-n67vx5zw.js → index-6t35714n.js} +2 -2
- package/dist/cli/{index-tnpf9wwv.js → index-862c0xhc.js} +1 -1
- package/dist/cli/{index-2n1ym7jb.js → index-b98r3pyv.js} +5 -5
- package/dist/cli/{index-8ada7ag7.js → index-dhzsvmx6.js} +2 -2
- package/dist/cli/{index-n985274d.js → index-e630pvvw.js} +4 -4
- package/dist/cli/{index-3b762978.js → index-f9nfknjg.js} +182 -37
- package/dist/cli/{index-m1fvbah1.js → index-fwfhbs27.js} +2 -2
- package/dist/cli/{index-t34daffb.js → index-h2f21caa.js} +2 -2
- package/dist/cli/{index-9ss2m4rs.js → index-hcn69kp0.js} +410 -1
- package/dist/cli/{index-g3znh2yd.js → index-hzaw10zh.js} +7 -7
- package/dist/cli/{index-cqgpvx2d.js → index-j0ajeary.js} +2 -2
- package/dist/cli/{index-f923njwh.js → index-jczbtx2x.js} +7 -7
- package/dist/cli/{index-hm239n1p.js → index-k8j7m0e2.js} +1 -1
- package/dist/cli/{index-zjme8atd.js → index-n1wcq816.js} +5 -5
- package/dist/cli/{index-66073kej.js → index-pmmfhzsp.js} +3 -3
- package/dist/cli/{index-fckfgptr.js → index-qbr05tbw.js} +2 -2
- package/dist/cli/{index-r56f3f81.js → index-r5jn0ah5.js} +2 -2
- package/dist/cli/{index-dtn0pne5.js → index-v56mhyhs.js} +1 -1
- package/dist/cli/{index-etvq73mp.js → index-vc3zmtxb.js} +38 -41
- package/dist/cli/{index-kvra3nv1.js → index-vdgw2k4c.js} +3 -3
- package/dist/cli/{index-0103w5pf.js → index-vkckf2ch.js} +2 -2
- package/dist/cli/{index-swgy9xvk.js → index-vrxx0ea4.js} +4 -4
- package/dist/cli/{index-08y8pccg.js → index-wnf1ej2q.js} +4 -4
- package/dist/cli/{index-qynqyfgj.js → index-wv4b01ex.js} +32 -34
- package/dist/cli/{index-7n9jznv0.js → index-x2qmpkth.js} +5 -5
- package/dist/cli/index-y2f5s2cf.js +403 -0
- package/dist/cli/{index-ma52g2pq.js → index-yc415pzf.js} +655 -16
- package/dist/cli/{index-n249fbw7.js → index-zaab1wz9.js} +5 -0
- package/dist/cli/index.js +36 -39
- package/dist/cli/{knowledge-escalator-fq7dm2g4.js → knowledge-escalator-wwkbsgvw.js} +14 -15
- package/dist/cli/{knowledge-events-3zanyfkr.js → knowledge-events-vmmgwfmc.js} +12 -13
- package/dist/cli/{knowledge-link-vmdj5e5d.js → knowledge-link-bvra01zv.js} +5 -6
- package/dist/cli/{knowledge-store-vhehnw52.js → knowledge-store-6wbagbqm.js} +6 -7
- package/dist/cli/{knowledge-validator-0tt0pe6b.js → knowledge-validator-q1z4fmeg.js} +8 -9
- package/dist/cli/{model-preflight-c3mc8njg.js → model-preflight-1ecjbg73.js} +1 -1
- package/dist/cli/{pending-delegations-b92pecbj.js → pending-delegations-cq5g4rr4.js} +6 -8
- package/dist/cli/{pr-subscriptions-2mkdt0ak.js → pr-subscriptions-m0z5wxkb.js} +6 -7
- package/dist/cli/pr-workflow-gate-0zvp0qs9.js +221 -0
- package/dist/cli/{runner-3gw2njnx.js → runner-s55g5233.js} +6 -7
- package/dist/cli/{scan-cursor-1c8a3b0m.js → scan-cursor-z6zepy3r.js} +7 -8
- package/dist/cli/{schema-c554j5c8.js → schema-skf0ckh4.js} +2 -2
- package/dist/cli/{scope-persistence-vtbcszvv.js → scope-persistence-f6davq7x.js} +10 -11
- package/dist/cli/{skill-generator-0es21fck.js → skill-generator-wqbazppk.js} +16 -17
- package/dist/cli/{sqlite-loader-c92413n7.js → sqlite-loader-8zefc142.js} +1 -1
- package/dist/cli/{telemetry-x4zggfd7.js → telemetry-q51s6tyt.js} +1 -1
- package/dist/cli/{worktree-collision-ownership-043dg8gg.js → worktree-collision-ownership-c0030qbm.js} +7 -9
- package/dist/cli/{worktree-isolation-hk42yxw7.js → worktree-isolation-09qq8066.js} +36 -39
- package/dist/db/canonical-project.d.ts +31 -0
- package/dist/db/db-errors.d.ts +24 -0
- package/dist/db/driver-parity.d.ts +31 -0
- package/dist/db/durability.d.ts +40 -0
- package/dist/db/group-commit-writer.d.ts +117 -0
- package/dist/db/health.d.ts +35 -0
- package/dist/db/insight-candidate-store.d.ts +61 -0
- package/dist/db/legacy-import.d.ts +77 -0
- package/dist/db/phase-report-store.d.ts +45 -0
- package/dist/db/project-db.d.ts +35 -8
- package/dist/db/qa-gate-profile.d.ts +2 -0
- package/dist/hooks/curator-drift.d.ts +9 -5
- package/dist/hooks/curator-types.d.ts +1 -0
- package/dist/hooks/delegation-gate.d.ts +1 -0
- package/dist/hooks/knowledge-curator.d.ts +5 -3
- package/dist/hooks/micro-reflector.d.ts +12 -7
- package/dist/hooks/pr-workflow-gate.d.ts +14 -8
- package/dist/hooks/pr-workflow-response-gate.d.ts +9 -12
- package/dist/index.js +627 -574
- package/dist/memory/schema.d.ts +4 -4
- package/dist/pr-review/authorization.d.ts +18 -12
- package/dist/prm/index.d.ts +3 -1
- package/dist/tools/authorize-pr-review-reentry.d.ts +12 -8
- package/package.json +3 -2
- package/dist/cli/authorization-vstrh7ra.js +0 -23
- package/dist/cli/curator-llm-factory-v8vwz20c.js +0 -69
- package/dist/cli/guardrail-explain-z2qb6v67.js +0 -70
- package/dist/cli/hive-promoter-c62x2ncb.js +0 -84
- package/dist/cli/index-c8s9a3zh.js +0 -73
- package/dist/cli/index-ed5ykebp.js +0 -151
- package/dist/cli/index-mmngnxev.js +0 -883
- package/dist/cli/index-w7ekntej.js +0 -643
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
resolveSwarmKnowledgePath,
|
|
7
7
|
transactKnowledge,
|
|
8
8
|
wordBigrams
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-jczbtx2x.js";
|
|
10
10
|
import {
|
|
11
11
|
queryHistoricalOutcomes,
|
|
12
12
|
readKnowledgeEvents,
|
|
13
13
|
recordKnowledgeEvent
|
|
14
|
-
} from "./index-
|
|
14
|
+
} from "./index-1af3rb5n.js";
|
|
15
15
|
import {
|
|
16
16
|
init_knowledge_types,
|
|
17
17
|
isActiveStatus
|
|
@@ -224,11 +224,11 @@ async function maybeQuarantineOnContradiction(directory, entryId, threshold, win
|
|
|
224
224
|
alreadyInactive: true
|
|
225
225
|
};
|
|
226
226
|
}
|
|
227
|
-
const { quarantineEntry } = await import("./knowledge-validator-
|
|
227
|
+
const { quarantineEntry } = await import("./knowledge-validator-q1z4fmeg.js");
|
|
228
228
|
let policyConfig;
|
|
229
229
|
try {
|
|
230
|
-
const { KnowledgeConfigSchema } = await import("./schema-
|
|
231
|
-
const { loadPluginConfigWithMeta } = await import("./index-
|
|
230
|
+
const { KnowledgeConfigSchema } = await import("./schema-skf0ckh4.js");
|
|
231
|
+
const { loadPluginConfigWithMeta } = await import("./index-vrxx0ea4.js");
|
|
232
232
|
const { config: loadedConfig } = loadPluginConfigWithMeta(directory);
|
|
233
233
|
policyConfig = KnowledgeConfigSchema.parse(loadedConfig.knowledge ?? {});
|
|
234
234
|
} catch {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
withEvidenceLock
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-36nt17m8.js";
|
|
5
5
|
import {
|
|
6
6
|
atomicWriteFileAnyRoot
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-f9nfknjg.js";
|
|
8
8
|
|
|
9
9
|
// src/evidence/task-file.ts
|
|
10
10
|
import * as path from "path";
|
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
import {
|
|
3
3
|
computePlanStructureHash,
|
|
4
4
|
derivePlanId
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-vdgw2k4c.js";
|
|
6
6
|
import {
|
|
7
7
|
appendCoreEventSync
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-dhzsvmx6.js";
|
|
9
9
|
import {
|
|
10
10
|
unsafePathTextReason
|
|
11
11
|
} from "./index-556ja8an.js";
|
|
12
12
|
import {
|
|
13
13
|
PlanSchema
|
|
14
|
-
} from "./index-
|
|
14
|
+
} from "./index-862c0xhc.js";
|
|
15
15
|
import {
|
|
16
16
|
assertProjectRoot
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-36nt17m8.js";
|
|
18
18
|
import {
|
|
19
19
|
atomicWriteSwarmFile,
|
|
20
20
|
atomicWriteSwarmFileSync
|
|
21
|
-
} from "./index-
|
|
21
|
+
} from "./index-f9nfknjg.js";
|
|
22
22
|
import {
|
|
23
23
|
require_proper_lockfile
|
|
24
24
|
} from "./index-7g4c7s5r.js";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
ALLOWED_SKILL_PATH_PREFIXES,
|
|
4
4
|
validateSkillPath
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-wnf1ej2q.js";
|
|
6
6
|
import {
|
|
7
7
|
withTimeoutSignal
|
|
8
8
|
} from "./index-q7sjgr1y.js";
|
|
@@ -12,11 +12,11 @@ import {
|
|
|
12
12
|
resolveHiveKnowledgePath,
|
|
13
13
|
resolveSwarmKnowledgePath,
|
|
14
14
|
transactKnowledge
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-jczbtx2x.js";
|
|
16
16
|
import {
|
|
17
17
|
effectiveRetrievalOutcomes,
|
|
18
18
|
readAuthoritativeKnowledgeCounterRollups
|
|
19
|
-
} from "./index-
|
|
19
|
+
} from "./index-1af3rb5n.js";
|
|
20
20
|
import {
|
|
21
21
|
advisoryWarn,
|
|
22
22
|
init_warning_buffer
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
import {
|
|
29
29
|
atomicWriteFileAnyRoot,
|
|
30
30
|
atomicWriteSwarmFile
|
|
31
|
-
} from "./index-
|
|
31
|
+
} from "./index-f9nfknjg.js";
|
|
32
32
|
import {
|
|
33
33
|
init_logger,
|
|
34
34
|
log,
|
|
@@ -1,12 +1,157 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
9
|
-
import * as
|
|
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 (!
|
|
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 =
|
|
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 =
|
|
392
|
-
const segments = resolved.split(
|
|
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(
|
|
548
|
+
const swarmRoot = segments.slice(0, swarmIdx + 1).join(path2.sep);
|
|
404
549
|
try {
|
|
405
|
-
const st =
|
|
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 =
|
|
414
|
-
if (!rel || rel.startsWith("..") ||
|
|
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(
|
|
419
|
-
probe =
|
|
420
|
-
if (!
|
|
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:
|
|
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
|
|
574
|
+
var _internals2 = {
|
|
430
575
|
randomSuffix: () => randomBytes(16).toString("hex"),
|
|
431
|
-
writeSync: (fd, buffer, offset, length) =>
|
|
432
|
-
renameSync: (from, to) =>
|
|
433
|
-
unlinkSync: (p) =>
|
|
434
|
-
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
|
-
|
|
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 =
|
|
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}.${
|
|
480
|
-
|
|
624
|
+
const tempPath = `${resolvedTarget}.${_internals2.randomSuffix()}.tmp`;
|
|
625
|
+
fs2.mkdirSync(path2.dirname(tempPath), { recursive: true });
|
|
481
626
|
try {
|
|
482
|
-
const fd =
|
|
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 +=
|
|
631
|
+
written += _internals2.writeSync(fd, buffer, written, buffer.byteLength - written);
|
|
487
632
|
}
|
|
488
633
|
if (options?.skipFsync !== true) {
|
|
489
634
|
try {
|
|
490
|
-
|
|
635
|
+
_internals2.fsyncSync(fd);
|
|
491
636
|
} catch {}
|
|
492
637
|
}
|
|
493
638
|
} finally {
|
|
494
|
-
|
|
639
|
+
fs2.closeSync(fd);
|
|
495
640
|
}
|
|
496
641
|
renameWithRetry(tempPath, resolvedTarget);
|
|
497
642
|
} finally {
|
|
498
643
|
try {
|
|
499
|
-
|
|
644
|
+
_internals2.unlinkSync(tempPath);
|
|
500
645
|
} catch {}
|
|
501
646
|
}
|
|
502
647
|
try {
|
|
503
|
-
const dirFd =
|
|
648
|
+
const dirFd = fs2.openSync(path2.dirname(resolvedTarget), "r");
|
|
504
649
|
try {
|
|
505
|
-
|
|
650
|
+
fs2.fsyncSync(dirFd);
|
|
506
651
|
} finally {
|
|
507
|
-
|
|
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((
|
|
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((
|
|
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 };
|
|
@@ -14,14 +14,14 @@ import {
|
|
|
14
14
|
detectWindowsWrites,
|
|
15
15
|
getSharedClassifierGuardrailBlock,
|
|
16
16
|
resolveWriteTargets
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-2ee2g27m.js";
|
|
18
18
|
import {
|
|
19
19
|
checkFileAuthority,
|
|
20
20
|
classifyFile,
|
|
21
21
|
isInDeclaredScope,
|
|
22
22
|
redactPath,
|
|
23
23
|
redactShellCommand
|
|
24
|
-
} from "./index-
|
|
24
|
+
} from "./index-wv4b01ex.js";
|
|
25
25
|
|
|
26
26
|
// src/services/guardrail-explain-service.ts
|
|
27
27
|
import path from "path";
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
import {
|
|
3
3
|
readKnowledge,
|
|
4
4
|
transactKnowledge
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-jczbtx2x.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-
|
|
12
|
+
} from "./index-6kd3jnaf.js";
|
|
13
13
|
import {
|
|
14
14
|
init_knowledge_types,
|
|
15
15
|
isActiveStatus
|