opencode-swarm 7.46.0 → 7.46.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.
- package/dist/cli/index.js +289 -142
- package/dist/hooks/knowledge-events.d.ts +19 -1
- package/dist/hooks/knowledge-injector.d.ts +8 -0
- package/dist/index.js +520 -316
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -69,7 +69,7 @@ var package_default;
|
|
|
69
69
|
var init_package = __esm(() => {
|
|
70
70
|
package_default = {
|
|
71
71
|
name: "opencode-swarm",
|
|
72
|
-
version: "7.46.
|
|
72
|
+
version: "7.46.2",
|
|
73
73
|
description: "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
|
|
74
74
|
main: "dist/index.js",
|
|
75
75
|
types: "dist/index.d.ts",
|
|
@@ -59489,6 +59489,244 @@ var init_hive_promoter = __esm(() => {
|
|
|
59489
59489
|
init_utils2();
|
|
59490
59490
|
});
|
|
59491
59491
|
|
|
59492
|
+
// src/hooks/knowledge-events.ts
|
|
59493
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
59494
|
+
import { existsSync as existsSync16 } from "node:fs";
|
|
59495
|
+
import { appendFile as appendFile5, mkdir as mkdir6, readFile as readFile7, writeFile as writeFile6 } from "node:fs/promises";
|
|
59496
|
+
import * as path28 from "node:path";
|
|
59497
|
+
function resolveKnowledgeEventsPath(directory) {
|
|
59498
|
+
return path28.join(directory, ".swarm", "knowledge-events.jsonl");
|
|
59499
|
+
}
|
|
59500
|
+
function resolveLegacyApplicationLogPath(directory) {
|
|
59501
|
+
return path28.join(directory, ".swarm", "knowledge-application.jsonl");
|
|
59502
|
+
}
|
|
59503
|
+
function newTraceId() {
|
|
59504
|
+
return randomUUID4();
|
|
59505
|
+
}
|
|
59506
|
+
function newEventId() {
|
|
59507
|
+
return randomUUID4();
|
|
59508
|
+
}
|
|
59509
|
+
function withDefaults(event) {
|
|
59510
|
+
return {
|
|
59511
|
+
schema_version: KNOWLEDGE_EVENT_SCHEMA_VERSION,
|
|
59512
|
+
...event,
|
|
59513
|
+
event_id: event.event_id || newEventId(),
|
|
59514
|
+
timestamp: event.timestamp || new Date().toISOString()
|
|
59515
|
+
};
|
|
59516
|
+
}
|
|
59517
|
+
async function appendKnowledgeEvent(directory, event) {
|
|
59518
|
+
const populated = withDefaults(event);
|
|
59519
|
+
const filePath = resolveKnowledgeEventsPath(directory);
|
|
59520
|
+
const dirPath = path28.dirname(filePath);
|
|
59521
|
+
await mkdir6(dirPath, { recursive: true });
|
|
59522
|
+
let release;
|
|
59523
|
+
try {
|
|
59524
|
+
release = await import_proper_lockfile5.default.lock(dirPath, {
|
|
59525
|
+
retries: { retries: 200, minTimeout: 10, maxTimeout: 100 }
|
|
59526
|
+
});
|
|
59527
|
+
await appendFile5(filePath, `${JSON.stringify(populated)}
|
|
59528
|
+
`, "utf-8");
|
|
59529
|
+
try {
|
|
59530
|
+
const content = await readFile7(filePath, "utf-8");
|
|
59531
|
+
const lines = content.split(`
|
|
59532
|
+
`).filter((line) => line.trim().length > 0);
|
|
59533
|
+
if (lines.length > MAX_EVENT_LOG_ENTRIES) {
|
|
59534
|
+
const trimmed = lines.slice(lines.length - MAX_EVENT_LOG_ENTRIES);
|
|
59535
|
+
await writeFile6(filePath, `${trimmed.join(`
|
|
59536
|
+
`)}
|
|
59537
|
+
`, "utf-8");
|
|
59538
|
+
}
|
|
59539
|
+
} catch (err2) {
|
|
59540
|
+
warn(`[knowledge-events] local cap trim failed (non-fatal): ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
59541
|
+
}
|
|
59542
|
+
} finally {
|
|
59543
|
+
if (release)
|
|
59544
|
+
await release().catch(() => {});
|
|
59545
|
+
}
|
|
59546
|
+
return populated;
|
|
59547
|
+
}
|
|
59548
|
+
async function recordKnowledgeEvent(directory, event) {
|
|
59549
|
+
try {
|
|
59550
|
+
return await appendKnowledgeEvent(directory, event);
|
|
59551
|
+
} catch (err2) {
|
|
59552
|
+
warn(`[knowledge-events] recordKnowledgeEvent failed: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
59553
|
+
return null;
|
|
59554
|
+
}
|
|
59555
|
+
}
|
|
59556
|
+
async function readKnowledgeEvents(directory) {
|
|
59557
|
+
const filePath = resolveKnowledgeEventsPath(directory);
|
|
59558
|
+
if (!existsSync16(filePath))
|
|
59559
|
+
return [];
|
|
59560
|
+
const content = await readFile7(filePath, "utf-8");
|
|
59561
|
+
const out2 = [];
|
|
59562
|
+
for (const line of content.split(`
|
|
59563
|
+
`)) {
|
|
59564
|
+
const trimmed = line.trim();
|
|
59565
|
+
if (!trimmed)
|
|
59566
|
+
continue;
|
|
59567
|
+
try {
|
|
59568
|
+
out2.push(JSON.parse(trimmed));
|
|
59569
|
+
} catch {
|
|
59570
|
+
warn(`[knowledge-events] Skipping corrupted JSONL line in ${filePath}: ${trimmed.slice(0, 80)}`);
|
|
59571
|
+
}
|
|
59572
|
+
}
|
|
59573
|
+
return out2;
|
|
59574
|
+
}
|
|
59575
|
+
async function readLegacyApplicationRecords(directory) {
|
|
59576
|
+
const filePath = resolveLegacyApplicationLogPath(directory);
|
|
59577
|
+
if (!existsSync16(filePath))
|
|
59578
|
+
return [];
|
|
59579
|
+
const content = await readFile7(filePath, "utf-8");
|
|
59580
|
+
const out2 = [];
|
|
59581
|
+
for (const line of content.split(`
|
|
59582
|
+
`)) {
|
|
59583
|
+
const trimmed = line.trim();
|
|
59584
|
+
if (!trimmed)
|
|
59585
|
+
continue;
|
|
59586
|
+
try {
|
|
59587
|
+
out2.push(JSON.parse(trimmed));
|
|
59588
|
+
} catch {
|
|
59589
|
+
warn(`[knowledge-events] Skipping corrupted JSONL line in ${filePath}: ${trimmed.slice(0, 80)}`);
|
|
59590
|
+
}
|
|
59591
|
+
}
|
|
59592
|
+
return out2;
|
|
59593
|
+
}
|
|
59594
|
+
function emptyRollup() {
|
|
59595
|
+
return {
|
|
59596
|
+
shown_count: 0,
|
|
59597
|
+
acknowledged_count: 0,
|
|
59598
|
+
applied_explicit_count: 0,
|
|
59599
|
+
ignored_count: 0,
|
|
59600
|
+
violated_count: 0,
|
|
59601
|
+
contradicted_count: 0,
|
|
59602
|
+
succeeded_after_shown_count: 0,
|
|
59603
|
+
failed_after_shown_count: 0,
|
|
59604
|
+
partial_after_shown_count: 0
|
|
59605
|
+
};
|
|
59606
|
+
}
|
|
59607
|
+
function get(map3, id) {
|
|
59608
|
+
let r = map3.get(id);
|
|
59609
|
+
if (!r) {
|
|
59610
|
+
r = emptyRollup();
|
|
59611
|
+
map3.set(id, r);
|
|
59612
|
+
}
|
|
59613
|
+
return r;
|
|
59614
|
+
}
|
|
59615
|
+
function maxIso(current, candidate) {
|
|
59616
|
+
if (!current)
|
|
59617
|
+
return candidate;
|
|
59618
|
+
return candidate > current ? candidate : current;
|
|
59619
|
+
}
|
|
59620
|
+
function recomputeCounters(events, legacyRecords = []) {
|
|
59621
|
+
const map3 = new Map;
|
|
59622
|
+
const retrievedIds = new Set;
|
|
59623
|
+
for (const e of events) {
|
|
59624
|
+
switch (e.type) {
|
|
59625
|
+
case "retrieved": {
|
|
59626
|
+
for (const id of e.result_ids) {
|
|
59627
|
+
retrievedIds.add(id);
|
|
59628
|
+
get(map3, id).shown_count += 1;
|
|
59629
|
+
}
|
|
59630
|
+
break;
|
|
59631
|
+
}
|
|
59632
|
+
case "acknowledged": {
|
|
59633
|
+
const r = get(map3, e.knowledge_id);
|
|
59634
|
+
r.acknowledged_count += 1;
|
|
59635
|
+
r.last_acknowledged_at = maxIso(r.last_acknowledged_at, e.timestamp);
|
|
59636
|
+
break;
|
|
59637
|
+
}
|
|
59638
|
+
case "applied": {
|
|
59639
|
+
const r = get(map3, e.knowledge_id);
|
|
59640
|
+
r.applied_explicit_count += 1;
|
|
59641
|
+
r.last_applied_at = maxIso(r.last_applied_at, e.timestamp);
|
|
59642
|
+
break;
|
|
59643
|
+
}
|
|
59644
|
+
case "ignored":
|
|
59645
|
+
get(map3, e.knowledge_id).ignored_count += 1;
|
|
59646
|
+
break;
|
|
59647
|
+
case "violated":
|
|
59648
|
+
get(map3, e.knowledge_id).violated_count += 1;
|
|
59649
|
+
break;
|
|
59650
|
+
case "contradicted":
|
|
59651
|
+
get(map3, e.knowledge_id).contradicted_count += 1;
|
|
59652
|
+
break;
|
|
59653
|
+
case "outcome": {
|
|
59654
|
+
if (!e.knowledge_id)
|
|
59655
|
+
break;
|
|
59656
|
+
const r = get(map3, e.knowledge_id);
|
|
59657
|
+
if (e.outcome === "success")
|
|
59658
|
+
r.succeeded_after_shown_count += 1;
|
|
59659
|
+
else if (e.outcome === "failure")
|
|
59660
|
+
r.failed_after_shown_count += 1;
|
|
59661
|
+
else if (e.outcome === "partial")
|
|
59662
|
+
r.partial_after_shown_count += 1;
|
|
59663
|
+
break;
|
|
59664
|
+
}
|
|
59665
|
+
}
|
|
59666
|
+
}
|
|
59667
|
+
for (const rec of legacyRecords) {
|
|
59668
|
+
const r = get(map3, rec.knowledgeId);
|
|
59669
|
+
switch (rec.result) {
|
|
59670
|
+
case "shown":
|
|
59671
|
+
if (!retrievedIds.has(rec.knowledgeId))
|
|
59672
|
+
r.shown_count += 1;
|
|
59673
|
+
break;
|
|
59674
|
+
case "acknowledged":
|
|
59675
|
+
r.acknowledged_count += 1;
|
|
59676
|
+
r.last_acknowledged_at = maxIso(r.last_acknowledged_at, rec.timestamp);
|
|
59677
|
+
break;
|
|
59678
|
+
case "applied":
|
|
59679
|
+
r.applied_explicit_count += 1;
|
|
59680
|
+
r.last_applied_at = maxIso(r.last_applied_at, rec.timestamp);
|
|
59681
|
+
break;
|
|
59682
|
+
case "ignored":
|
|
59683
|
+
r.ignored_count += 1;
|
|
59684
|
+
break;
|
|
59685
|
+
case "violated":
|
|
59686
|
+
r.violated_count += 1;
|
|
59687
|
+
break;
|
|
59688
|
+
}
|
|
59689
|
+
}
|
|
59690
|
+
return map3;
|
|
59691
|
+
}
|
|
59692
|
+
async function readKnowledgeCounterRollups(directory) {
|
|
59693
|
+
try {
|
|
59694
|
+
const [events, legacyRecords] = await Promise.all([
|
|
59695
|
+
readKnowledgeEvents(directory),
|
|
59696
|
+
readLegacyApplicationRecords(directory)
|
|
59697
|
+
]);
|
|
59698
|
+
return recomputeCounters(events, legacyRecords);
|
|
59699
|
+
} catch (err2) {
|
|
59700
|
+
warn(`[knowledge-events] readKnowledgeCounterRollups failed: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
59701
|
+
return new Map;
|
|
59702
|
+
}
|
|
59703
|
+
}
|
|
59704
|
+
function effectiveRetrievalOutcomes(stored, rollup) {
|
|
59705
|
+
const base = stored ?? {
|
|
59706
|
+
applied_count: 0,
|
|
59707
|
+
succeeded_after_count: 0,
|
|
59708
|
+
failed_after_count: 0
|
|
59709
|
+
};
|
|
59710
|
+
if (!rollup)
|
|
59711
|
+
return base;
|
|
59712
|
+
return {
|
|
59713
|
+
...base,
|
|
59714
|
+
...rollup
|
|
59715
|
+
};
|
|
59716
|
+
}
|
|
59717
|
+
var import_proper_lockfile5, KNOWLEDGE_EVENT_SCHEMA_VERSION = 1, MAX_EVENT_LOG_ENTRIES = 5000, RECEIPT_EVENT_TYPES;
|
|
59718
|
+
var init_knowledge_events = __esm(() => {
|
|
59719
|
+
init_logger();
|
|
59720
|
+
import_proper_lockfile5 = __toESM(require_proper_lockfile(), 1);
|
|
59721
|
+
RECEIPT_EVENT_TYPES = new Set([
|
|
59722
|
+
"acknowledged",
|
|
59723
|
+
"applied",
|
|
59724
|
+
"ignored",
|
|
59725
|
+
"contradicted",
|
|
59726
|
+
"violated"
|
|
59727
|
+
]);
|
|
59728
|
+
});
|
|
59729
|
+
|
|
59492
59730
|
// src/hooks/knowledge-curator.ts
|
|
59493
59731
|
function pruneSeenRetroSections() {
|
|
59494
59732
|
const cutoff = Date.now() - 86400000;
|
|
@@ -59730,11 +59968,12 @@ async function curateAndStoreSwarm(lessons, projectName, phaseInfo, directory, c
|
|
|
59730
59968
|
async function runAutoPromotion(directory, config3) {
|
|
59731
59969
|
const knowledgePath = resolveSwarmKnowledgePath(directory);
|
|
59732
59970
|
const entries = await readKnowledge(knowledgePath) ?? [];
|
|
59971
|
+
const counterRollups = await readKnowledgeCounterRollups(directory);
|
|
59733
59972
|
let changed = false;
|
|
59734
59973
|
for (const entry of entries) {
|
|
59735
59974
|
if (entry.status === "promoted")
|
|
59736
59975
|
continue;
|
|
59737
|
-
if (computeOutcomeSignal(entry.retrieval_outcomes) <= OUTCOME_PROMOTION_BLOCK) {
|
|
59976
|
+
if (computeOutcomeSignal(effectiveRetrievalOutcomes(entry.retrieval_outcomes, counterRollups.get(entry.id))) <= OUTCOME_PROMOTION_BLOCK) {
|
|
59738
59977
|
continue;
|
|
59739
59978
|
}
|
|
59740
59979
|
const distinctPhases = new Set((entry.confirmed_by ?? []).map((c) => c.phase_number)).size;
|
|
@@ -59836,6 +60075,7 @@ function createKnowledgeCuratorHook(directory, config3) {
|
|
|
59836
60075
|
}
|
|
59837
60076
|
var seenRetroSections, OUTCOME_PROMOTION_BLOCK = -0.3, _internals21;
|
|
59838
60077
|
var init_knowledge_curator = __esm(() => {
|
|
60078
|
+
init_knowledge_events();
|
|
59839
60079
|
init_knowledge_store();
|
|
59840
60080
|
init_knowledge_validator();
|
|
59841
60081
|
init_utils2();
|
|
@@ -59958,11 +60198,11 @@ var init_skill_improver_llm_factory = __esm(() => {
|
|
|
59958
60198
|
});
|
|
59959
60199
|
|
|
59960
60200
|
// src/services/skill-improver-quota.ts
|
|
59961
|
-
import { existsSync as
|
|
59962
|
-
import { mkdir as
|
|
59963
|
-
import * as
|
|
60201
|
+
import { existsSync as existsSync17 } from "node:fs";
|
|
60202
|
+
import { mkdir as mkdir7, readFile as readFile8, rename as rename4, writeFile as writeFile7 } from "node:fs/promises";
|
|
60203
|
+
import * as path29 from "node:path";
|
|
59964
60204
|
async function acquireLock(dir) {
|
|
59965
|
-
const acquire =
|
|
60205
|
+
const acquire = import_proper_lockfile6.default.lock(dir, LOCK_RETRY_OPTS);
|
|
59966
60206
|
let timer;
|
|
59967
60207
|
const timeout = new Promise((_, reject) => {
|
|
59968
60208
|
timer = setTimeout(() => {
|
|
@@ -59978,7 +60218,7 @@ async function acquireLock(dir) {
|
|
|
59978
60218
|
}
|
|
59979
60219
|
}
|
|
59980
60220
|
function resolveQuotaPath(directory) {
|
|
59981
|
-
return
|
|
60221
|
+
return path29.join(directory, ".swarm", "skill-improver-quota.json");
|
|
59982
60222
|
}
|
|
59983
60223
|
function todayKey(window2, now = new Date) {
|
|
59984
60224
|
if (window2 === "utc") {
|
|
@@ -59990,10 +60230,10 @@ function todayKey(window2, now = new Date) {
|
|
|
59990
60230
|
return `${yr}-${m}-${d}`;
|
|
59991
60231
|
}
|
|
59992
60232
|
async function readState(filePath) {
|
|
59993
|
-
if (!
|
|
60233
|
+
if (!existsSync17(filePath))
|
|
59994
60234
|
return null;
|
|
59995
60235
|
try {
|
|
59996
|
-
const raw = await
|
|
60236
|
+
const raw = await readFile8(filePath, "utf-8");
|
|
59997
60237
|
const parsed = JSON.parse(raw);
|
|
59998
60238
|
if (typeof parsed.date !== "string" || typeof parsed.calls_used !== "number" || typeof parsed.max_calls !== "number" || parsed.window !== "utc" && parsed.window !== "local") {
|
|
59999
60239
|
return null;
|
|
@@ -60004,9 +60244,9 @@ async function readState(filePath) {
|
|
|
60004
60244
|
}
|
|
60005
60245
|
}
|
|
60006
60246
|
async function writeState(filePath, state) {
|
|
60007
|
-
await
|
|
60247
|
+
await mkdir7(path29.dirname(filePath), { recursive: true });
|
|
60008
60248
|
const tmp = `${filePath}.tmp-${process.pid}`;
|
|
60009
|
-
await
|
|
60249
|
+
await writeFile7(tmp, JSON.stringify(state, null, 2), "utf-8");
|
|
60010
60250
|
await rename4(tmp, filePath);
|
|
60011
60251
|
}
|
|
60012
60252
|
async function getQuotaState(directory, opts) {
|
|
@@ -60027,10 +60267,10 @@ async function getQuotaState(directory, opts) {
|
|
|
60027
60267
|
}
|
|
60028
60268
|
async function reserveQuota(directory, opts) {
|
|
60029
60269
|
const filePath = resolveQuotaPath(directory);
|
|
60030
|
-
await
|
|
60270
|
+
await mkdir7(path29.dirname(filePath), { recursive: true });
|
|
60031
60271
|
let release = null;
|
|
60032
60272
|
try {
|
|
60033
|
-
release = await acquireLock(
|
|
60273
|
+
release = await acquireLock(path29.dirname(filePath));
|
|
60034
60274
|
const state = await getQuotaState(directory, opts);
|
|
60035
60275
|
if (state.calls_used + opts.nCalls > opts.maxCalls) {
|
|
60036
60276
|
return {
|
|
@@ -60057,10 +60297,10 @@ async function reserveQuota(directory, opts) {
|
|
|
60057
60297
|
}
|
|
60058
60298
|
async function releaseQuota(directory, opts) {
|
|
60059
60299
|
const filePath = resolveQuotaPath(directory);
|
|
60060
|
-
await
|
|
60300
|
+
await mkdir7(path29.dirname(filePath), { recursive: true });
|
|
60061
60301
|
let release = null;
|
|
60062
60302
|
try {
|
|
60063
|
-
release = await acquireLock(
|
|
60303
|
+
release = await acquireLock(path29.dirname(filePath));
|
|
60064
60304
|
const state = await getQuotaState(directory, opts);
|
|
60065
60305
|
const next = {
|
|
60066
60306
|
...state,
|
|
@@ -60077,9 +60317,9 @@ async function releaseQuota(directory, opts) {
|
|
|
60077
60317
|
}
|
|
60078
60318
|
}
|
|
60079
60319
|
}
|
|
60080
|
-
var
|
|
60320
|
+
var import_proper_lockfile6, LOCK_ACQUIRE_TIMEOUT_MS = 1e4, LOCK_RETRY_OPTS;
|
|
60081
60321
|
var init_skill_improver_quota = __esm(() => {
|
|
60082
|
-
|
|
60322
|
+
import_proper_lockfile6 = __toESM(require_proper_lockfile(), 1);
|
|
60083
60323
|
LOCK_RETRY_OPTS = {
|
|
60084
60324
|
retries: {
|
|
60085
60325
|
retries: 30,
|
|
@@ -60092,22 +60332,22 @@ var init_skill_improver_quota = __esm(() => {
|
|
|
60092
60332
|
});
|
|
60093
60333
|
|
|
60094
60334
|
// src/services/skill-improver.ts
|
|
60095
|
-
import { existsSync as
|
|
60096
|
-
import { mkdir as
|
|
60097
|
-
import * as
|
|
60335
|
+
import { existsSync as existsSync18 } from "node:fs";
|
|
60336
|
+
import { mkdir as mkdir8, rename as rename5, writeFile as writeFile8 } from "node:fs/promises";
|
|
60337
|
+
import * as path30 from "node:path";
|
|
60098
60338
|
function timestampSlug(d) {
|
|
60099
60339
|
return d.toISOString().replace(/[:.]/g, "-");
|
|
60100
60340
|
}
|
|
60101
60341
|
async function atomicWrite3(p, content) {
|
|
60102
|
-
await
|
|
60342
|
+
await mkdir8(path30.dirname(p), { recursive: true });
|
|
60103
60343
|
const tmp = `${p}.tmp-${process.pid}-${Date.now()}`;
|
|
60104
|
-
await
|
|
60344
|
+
await writeFile8(tmp, content, "utf-8");
|
|
60105
60345
|
await rename5(tmp, p);
|
|
60106
60346
|
}
|
|
60107
60347
|
async function gatherInventory(directory) {
|
|
60108
60348
|
const swarm = await readKnowledge(resolveSwarmKnowledgePath(directory));
|
|
60109
60349
|
const hivePath = resolveHiveKnowledgePath();
|
|
60110
|
-
const hive =
|
|
60350
|
+
const hive = existsSync18(hivePath) ? await readKnowledge(hivePath) : [];
|
|
60111
60351
|
const archived = [...swarm, ...hive].filter((e) => e.status === "archived").length;
|
|
60112
60352
|
const skills = await listSkills(directory);
|
|
60113
60353
|
const matureCandidates = swarm.concat(hive).filter((e) => e.status !== "archived" && e.confidence >= 0.85 && !e.generated_skill_slug && (e.confirmed_by ?? []).length >= 2);
|
|
@@ -60380,8 +60620,8 @@ async function runSkillImprover(req) {
|
|
|
60380
60620
|
}
|
|
60381
60621
|
throw err2;
|
|
60382
60622
|
}
|
|
60383
|
-
const proposalDir =
|
|
60384
|
-
const proposalFile =
|
|
60623
|
+
const proposalDir = path30.join(req.directory, ".swarm", "skill-improver", "proposals");
|
|
60624
|
+
const proposalFile = path30.join(proposalDir, `${timestampSlug(now)}.md`);
|
|
60385
60625
|
const finalBody = source === "llm" ? buildLLMProposalFrame({
|
|
60386
60626
|
body: body2,
|
|
60387
60627
|
targets,
|
|
@@ -60777,7 +61017,7 @@ var init_write_retro = __esm(() => {
|
|
|
60777
61017
|
|
|
60778
61018
|
// src/commands/close.ts
|
|
60779
61019
|
import { promises as fs17 } from "node:fs";
|
|
60780
|
-
import
|
|
61020
|
+
import path31 from "node:path";
|
|
60781
61021
|
async function runAbortableSkillReview(req, timeoutMs) {
|
|
60782
61022
|
const controller = new AbortController;
|
|
60783
61023
|
let timeout;
|
|
@@ -60833,10 +61073,10 @@ function guaranteeAllPlansComplete(planData) {
|
|
|
60833
61073
|
}
|
|
60834
61074
|
async function handleCloseCommand(directory, args2, options = {}) {
|
|
60835
61075
|
const planPath = validateSwarmPath(directory, "plan.json");
|
|
60836
|
-
const swarmDir =
|
|
61076
|
+
const swarmDir = path31.join(directory, ".swarm");
|
|
60837
61077
|
let planExists = false;
|
|
60838
61078
|
let planData = {
|
|
60839
|
-
title:
|
|
61079
|
+
title: path31.basename(directory) || "Ad-hoc session",
|
|
60840
61080
|
phases: []
|
|
60841
61081
|
};
|
|
60842
61082
|
try {
|
|
@@ -60945,7 +61185,7 @@ async function handleCloseCommand(directory, args2, options = {}) {
|
|
|
60945
61185
|
warnings.push(`Session retrospective write threw: ${retroError instanceof Error ? retroError.message : String(retroError)}`);
|
|
60946
61186
|
}
|
|
60947
61187
|
}
|
|
60948
|
-
const lessonsFilePath =
|
|
61188
|
+
const lessonsFilePath = path31.join(swarmDir, "close-lessons.md");
|
|
60949
61189
|
let explicitLessons = [];
|
|
60950
61190
|
try {
|
|
60951
61191
|
const lessonsText = await fs17.readFile(lessonsFilePath, "utf-8");
|
|
@@ -60954,11 +61194,11 @@ async function handleCloseCommand(directory, args2, options = {}) {
|
|
|
60954
61194
|
} catch {}
|
|
60955
61195
|
const retroLessons = [];
|
|
60956
61196
|
try {
|
|
60957
|
-
const evidenceDir =
|
|
61197
|
+
const evidenceDir = path31.join(swarmDir, "evidence");
|
|
60958
61198
|
const evidenceEntries = await fs17.readdir(evidenceDir);
|
|
60959
61199
|
const retroDirs = evidenceEntries.filter((e) => e.startsWith("retro-")).sort((a, b) => a.localeCompare(b, undefined, { numeric: true }));
|
|
60960
61200
|
for (const retroDir of retroDirs) {
|
|
60961
|
-
const evidencePath =
|
|
61201
|
+
const evidencePath = path31.join(evidenceDir, retroDir, "evidence.json");
|
|
60962
61202
|
try {
|
|
60963
61203
|
const content = await fs17.readFile(evidencePath, "utf-8");
|
|
60964
61204
|
const parsed = JSON.parse(content);
|
|
@@ -61093,7 +61333,7 @@ async function handleCloseCommand(directory, args2, options = {}) {
|
|
|
61093
61333
|
}
|
|
61094
61334
|
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
61095
61335
|
const suffix = Math.random().toString(36).slice(2, 8);
|
|
61096
|
-
const archiveDir =
|
|
61336
|
+
const archiveDir = path31.join(swarmDir, "archive", `swarm-${timestamp}-${suffix}`);
|
|
61097
61337
|
let archiveResult = "";
|
|
61098
61338
|
let archivedFileCount = 0;
|
|
61099
61339
|
const archivedActiveStateFiles = new Set;
|
|
@@ -61101,8 +61341,8 @@ async function handleCloseCommand(directory, args2, options = {}) {
|
|
|
61101
61341
|
try {
|
|
61102
61342
|
await fs17.mkdir(archiveDir, { recursive: true });
|
|
61103
61343
|
for (const artifact of ARCHIVE_ARTIFACTS) {
|
|
61104
|
-
const srcPath =
|
|
61105
|
-
const destPath =
|
|
61344
|
+
const srcPath = path31.join(swarmDir, artifact);
|
|
61345
|
+
const destPath = path31.join(archiveDir, artifact);
|
|
61106
61346
|
try {
|
|
61107
61347
|
await fs17.copyFile(srcPath, destPath);
|
|
61108
61348
|
archivedFileCount++;
|
|
@@ -61112,22 +61352,22 @@ async function handleCloseCommand(directory, args2, options = {}) {
|
|
|
61112
61352
|
} catch {}
|
|
61113
61353
|
}
|
|
61114
61354
|
for (const dirName of ACTIVE_STATE_DIRS_TO_CLEAN) {
|
|
61115
|
-
const srcDir =
|
|
61116
|
-
const destDir =
|
|
61355
|
+
const srcDir = path31.join(swarmDir, dirName);
|
|
61356
|
+
const destDir = path31.join(archiveDir, dirName);
|
|
61117
61357
|
try {
|
|
61118
61358
|
const entries = await fs17.readdir(srcDir);
|
|
61119
61359
|
if (entries.length > 0) {
|
|
61120
61360
|
await fs17.mkdir(destDir, { recursive: true });
|
|
61121
61361
|
for (const entry of entries) {
|
|
61122
|
-
const srcEntry =
|
|
61123
|
-
const destEntry =
|
|
61362
|
+
const srcEntry = path31.join(srcDir, entry);
|
|
61363
|
+
const destEntry = path31.join(destDir, entry);
|
|
61124
61364
|
try {
|
|
61125
61365
|
const stat3 = await fs17.stat(srcEntry);
|
|
61126
61366
|
if (stat3.isDirectory()) {
|
|
61127
61367
|
await fs17.mkdir(destEntry, { recursive: true });
|
|
61128
61368
|
const subEntries = await fs17.readdir(srcEntry);
|
|
61129
61369
|
for (const sub of subEntries) {
|
|
61130
|
-
await fs17.copyFile(
|
|
61370
|
+
await fs17.copyFile(path31.join(srcEntry, sub), path31.join(destEntry, sub)).catch(() => {});
|
|
61131
61371
|
}
|
|
61132
61372
|
} else {
|
|
61133
61373
|
await fs17.copyFile(srcEntry, destEntry);
|
|
@@ -61159,7 +61399,7 @@ async function handleCloseCommand(directory, args2, options = {}) {
|
|
|
61159
61399
|
warnings.push(`Preserved ${artifact} because it was not successfully archived.`);
|
|
61160
61400
|
continue;
|
|
61161
61401
|
}
|
|
61162
|
-
const filePath =
|
|
61402
|
+
const filePath = path31.join(swarmDir, artifact);
|
|
61163
61403
|
try {
|
|
61164
61404
|
await fs17.unlink(filePath);
|
|
61165
61405
|
cleanedFiles.push(artifact);
|
|
@@ -61172,7 +61412,7 @@ async function handleCloseCommand(directory, args2, options = {}) {
|
|
|
61172
61412
|
if (!archivedActiveStateDirs.has(dirName)) {
|
|
61173
61413
|
continue;
|
|
61174
61414
|
}
|
|
61175
|
-
const dirPath =
|
|
61415
|
+
const dirPath = path31.join(swarmDir, dirName);
|
|
61176
61416
|
try {
|
|
61177
61417
|
await fs17.rm(dirPath, { recursive: true, force: true });
|
|
61178
61418
|
cleanedFiles.push(`${dirName}/`);
|
|
@@ -61183,23 +61423,23 @@ async function handleCloseCommand(directory, args2, options = {}) {
|
|
|
61183
61423
|
const configBackups = swarmFiles.filter((f) => f.startsWith("config-backup-") && f.endsWith(".json"));
|
|
61184
61424
|
for (const backup of configBackups) {
|
|
61185
61425
|
try {
|
|
61186
|
-
await fs17.unlink(
|
|
61426
|
+
await fs17.unlink(path31.join(swarmDir, backup));
|
|
61187
61427
|
configBackupsRemoved++;
|
|
61188
61428
|
} catch {}
|
|
61189
61429
|
}
|
|
61190
61430
|
const ledgerSiblings = swarmFiles.filter((f) => (f.startsWith("plan-ledger.archived-") || f.startsWith("plan-ledger.backup-")) && f.endsWith(".jsonl"));
|
|
61191
61431
|
for (const sibling of ledgerSiblings) {
|
|
61192
61432
|
try {
|
|
61193
|
-
await fs17.unlink(
|
|
61433
|
+
await fs17.unlink(path31.join(swarmDir, sibling));
|
|
61194
61434
|
} catch {}
|
|
61195
61435
|
}
|
|
61196
61436
|
} catch {}
|
|
61197
61437
|
let swarmPlanFilesRemoved = 0;
|
|
61198
61438
|
const candidates = [
|
|
61199
|
-
|
|
61200
|
-
|
|
61201
|
-
|
|
61202
|
-
|
|
61439
|
+
path31.join(directory, ".swarm", "SWARM_PLAN.json"),
|
|
61440
|
+
path31.join(directory, ".swarm", "SWARM_PLAN.md"),
|
|
61441
|
+
path31.join(directory, "SWARM_PLAN.json"),
|
|
61442
|
+
path31.join(directory, "SWARM_PLAN.md")
|
|
61203
61443
|
];
|
|
61204
61444
|
for (const candidate of candidates) {
|
|
61205
61445
|
try {
|
|
@@ -61207,12 +61447,12 @@ async function handleCloseCommand(directory, args2, options = {}) {
|
|
|
61207
61447
|
swarmPlanFilesRemoved++;
|
|
61208
61448
|
} catch (err2) {
|
|
61209
61449
|
if (err2?.code !== "ENOENT") {
|
|
61210
|
-
warnings.push(`Failed to remove ${
|
|
61450
|
+
warnings.push(`Failed to remove ${path31.basename(candidate)}: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
61211
61451
|
}
|
|
61212
61452
|
}
|
|
61213
61453
|
}
|
|
61214
61454
|
clearAllScopes(directory);
|
|
61215
|
-
const contextPath =
|
|
61455
|
+
const contextPath = path31.join(swarmDir, "context.md");
|
|
61216
61456
|
const contextContent = [
|
|
61217
61457
|
"# Context",
|
|
61218
61458
|
"",
|
|
@@ -61536,14 +61776,14 @@ var init_concurrency = __esm(() => {
|
|
|
61536
61776
|
|
|
61537
61777
|
// src/commands/config.ts
|
|
61538
61778
|
import * as os9 from "node:os";
|
|
61539
|
-
import * as
|
|
61779
|
+
import * as path32 from "node:path";
|
|
61540
61780
|
function getUserConfigDir2() {
|
|
61541
|
-
return process.env.XDG_CONFIG_HOME ||
|
|
61781
|
+
return process.env.XDG_CONFIG_HOME || path32.join(os9.homedir(), ".config");
|
|
61542
61782
|
}
|
|
61543
61783
|
async function handleConfigCommand(directory, _args) {
|
|
61544
61784
|
const config3 = loadPluginConfig(directory);
|
|
61545
|
-
const userConfigPath =
|
|
61546
|
-
const projectConfigPath =
|
|
61785
|
+
const userConfigPath = path32.join(getUserConfigDir2(), "opencode", "opencode-swarm.json");
|
|
61786
|
+
const projectConfigPath = path32.join(directory, ".opencode", "opencode-swarm.json");
|
|
61547
61787
|
const lines = [
|
|
61548
61788
|
"## Swarm Configuration",
|
|
61549
61789
|
"",
|
|
@@ -61679,9 +61919,9 @@ __export(exports_co_change_analyzer, {
|
|
|
61679
61919
|
_internals: () => _internals23
|
|
61680
61920
|
});
|
|
61681
61921
|
import * as child_process3 from "node:child_process";
|
|
61682
|
-
import { randomUUID as
|
|
61683
|
-
import { readdir as readdir2, readFile as
|
|
61684
|
-
import * as
|
|
61922
|
+
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
61923
|
+
import { readdir as readdir2, readFile as readFile9, stat as stat3 } from "node:fs/promises";
|
|
61924
|
+
import * as path33 from "node:path";
|
|
61685
61925
|
import { promisify } from "node:util";
|
|
61686
61926
|
function getExecFileAsync() {
|
|
61687
61927
|
return promisify(child_process3.execFile);
|
|
@@ -61785,7 +62025,7 @@ async function scanSourceFiles(dir) {
|
|
|
61785
62025
|
try {
|
|
61786
62026
|
const entries = await readdir2(dir, { withFileTypes: true });
|
|
61787
62027
|
for (const entry of entries) {
|
|
61788
|
-
const fullPath =
|
|
62028
|
+
const fullPath = path33.join(dir, entry.name);
|
|
61789
62029
|
if (entry.isDirectory()) {
|
|
61790
62030
|
if (skipDirs.has(entry.name)) {
|
|
61791
62031
|
continue;
|
|
@@ -61793,7 +62033,7 @@ async function scanSourceFiles(dir) {
|
|
|
61793
62033
|
const subFiles = await scanSourceFiles(fullPath);
|
|
61794
62034
|
results.push(...subFiles);
|
|
61795
62035
|
} else if (entry.isFile()) {
|
|
61796
|
-
const ext =
|
|
62036
|
+
const ext = path33.extname(entry.name);
|
|
61797
62037
|
if ([".ts", ".tsx", ".js", ".jsx", ".mjs"].includes(ext)) {
|
|
61798
62038
|
results.push(fullPath);
|
|
61799
62039
|
}
|
|
@@ -61807,7 +62047,7 @@ async function getStaticEdges(directory) {
|
|
|
61807
62047
|
const sourceFiles = await scanSourceFiles(directory);
|
|
61808
62048
|
for (const sourceFile of sourceFiles) {
|
|
61809
62049
|
try {
|
|
61810
|
-
const content = await
|
|
62050
|
+
const content = await readFile9(sourceFile, "utf-8");
|
|
61811
62051
|
const importRegex = /(?:import|require)\s*(?:\(?\s*['"`]|.*?from\s+['"`])([^'"`]+)['"`]/g;
|
|
61812
62052
|
for (let match = importRegex.exec(content);match !== null; match = importRegex.exec(content)) {
|
|
61813
62053
|
const importPath = match[1].trim();
|
|
@@ -61815,8 +62055,8 @@ async function getStaticEdges(directory) {
|
|
|
61815
62055
|
continue;
|
|
61816
62056
|
}
|
|
61817
62057
|
try {
|
|
61818
|
-
const sourceDir =
|
|
61819
|
-
const resolvedPath =
|
|
62058
|
+
const sourceDir = path33.dirname(sourceFile);
|
|
62059
|
+
const resolvedPath = path33.resolve(sourceDir, importPath);
|
|
61820
62060
|
const extensions = [
|
|
61821
62061
|
"",
|
|
61822
62062
|
".ts",
|
|
@@ -61841,8 +62081,8 @@ async function getStaticEdges(directory) {
|
|
|
61841
62081
|
if (!targetFile) {
|
|
61842
62082
|
continue;
|
|
61843
62083
|
}
|
|
61844
|
-
const relSource =
|
|
61845
|
-
const relTarget =
|
|
62084
|
+
const relSource = path33.relative(directory, sourceFile).replace(/\\/g, "/");
|
|
62085
|
+
const relTarget = path33.relative(directory, targetFile).replace(/\\/g, "/");
|
|
61846
62086
|
const [key] = relSource < relTarget ? [`${relSource}::${relTarget}`, relSource, relTarget] : [`${relTarget}::${relSource}`, relTarget, relSource];
|
|
61847
62087
|
edges.add(key);
|
|
61848
62088
|
} catch {}
|
|
@@ -61854,7 +62094,7 @@ async function getStaticEdges(directory) {
|
|
|
61854
62094
|
function isTestImplementationPair(fileA, fileB) {
|
|
61855
62095
|
const testPatterns = [".test.ts", ".test.js", ".spec.ts", ".spec.js"];
|
|
61856
62096
|
const getBaseName = (filePath) => {
|
|
61857
|
-
const base =
|
|
62097
|
+
const base = path33.basename(filePath);
|
|
61858
62098
|
for (const pattern of testPatterns) {
|
|
61859
62099
|
if (base.endsWith(pattern)) {
|
|
61860
62100
|
return base.slice(0, -pattern.length);
|
|
@@ -61864,16 +62104,16 @@ function isTestImplementationPair(fileA, fileB) {
|
|
|
61864
62104
|
};
|
|
61865
62105
|
const baseA = getBaseName(fileA);
|
|
61866
62106
|
const baseB = getBaseName(fileB);
|
|
61867
|
-
return baseA === baseB && baseA !==
|
|
62107
|
+
return baseA === baseB && baseA !== path33.basename(fileA) && baseA !== path33.basename(fileB);
|
|
61868
62108
|
}
|
|
61869
62109
|
function hasSharedPrefix(fileA, fileB) {
|
|
61870
|
-
const dirA =
|
|
61871
|
-
const dirB =
|
|
62110
|
+
const dirA = path33.dirname(fileA);
|
|
62111
|
+
const dirB = path33.dirname(fileB);
|
|
61872
62112
|
if (dirA !== dirB) {
|
|
61873
62113
|
return false;
|
|
61874
62114
|
}
|
|
61875
|
-
const baseA =
|
|
61876
|
-
const baseB =
|
|
62115
|
+
const baseA = path33.basename(fileA).replace(/\.(ts|js|tsx|jsx|mjs)$/, "");
|
|
62116
|
+
const baseB = path33.basename(fileB).replace(/\.(ts|js|tsx|jsx|mjs)$/, "");
|
|
61877
62117
|
if (baseA.startsWith(baseB) || baseB.startsWith(baseA)) {
|
|
61878
62118
|
return true;
|
|
61879
62119
|
}
|
|
@@ -61928,8 +62168,8 @@ function darkMatterToKnowledgeEntries(pairs, projectName) {
|
|
|
61928
62168
|
const entries = [];
|
|
61929
62169
|
const now = new Date().toISOString();
|
|
61930
62170
|
for (const pair of pairs.slice(0, 10)) {
|
|
61931
|
-
const baseA =
|
|
61932
|
-
const baseB =
|
|
62171
|
+
const baseA = path33.basename(pair.fileA);
|
|
62172
|
+
const baseB = path33.basename(pair.fileB);
|
|
61933
62173
|
let lesson = `Files ${pair.fileA} and ${pair.fileB} co-change with NPMI=${pair.npmi.toFixed(3)} but have no import relationship. This hidden coupling suggests a shared architectural concern — changes to one likely require changes to the other.`;
|
|
61934
62174
|
if (lesson.length > 280) {
|
|
61935
62175
|
lesson = `Files ${baseA} and ${baseB} co-change with NPMI=${pair.npmi.toFixed(3)} but have no import relationship. This hidden coupling suggests a shared architectural concern — changes to one likely require changes to the other.`;
|
|
@@ -61942,7 +62182,7 @@ function darkMatterToKnowledgeEntries(pairs, projectName) {
|
|
|
61942
62182
|
}
|
|
61943
62183
|
const confidence = Math.min(0.3 + 0.2 * Math.min(pair.coChangeCount / 10, 1), 0.5);
|
|
61944
62184
|
entries.push({
|
|
61945
|
-
id:
|
|
62185
|
+
id: randomUUID5(),
|
|
61946
62186
|
tier: "swarm",
|
|
61947
62187
|
lesson,
|
|
61948
62188
|
category: "architecture",
|
|
@@ -62031,7 +62271,7 @@ var init_co_change_analyzer = __esm(() => {
|
|
|
62031
62271
|
});
|
|
62032
62272
|
|
|
62033
62273
|
// src/commands/dark-matter.ts
|
|
62034
|
-
import
|
|
62274
|
+
import path34 from "node:path";
|
|
62035
62275
|
async function handleDarkMatterCommand(directory, args2) {
|
|
62036
62276
|
const options = {};
|
|
62037
62277
|
for (let i2 = 0;i2 < args2.length; i2++) {
|
|
@@ -62063,7 +62303,7 @@ Ensure this is a git repository with commit history.`;
|
|
|
62063
62303
|
const output = formatDarkMatterOutput(pairs);
|
|
62064
62304
|
if (pairs.length > 0) {
|
|
62065
62305
|
try {
|
|
62066
|
-
const projectName =
|
|
62306
|
+
const projectName = path34.basename(path34.resolve(directory));
|
|
62067
62307
|
const entries = darkMatterToKnowledgeEntries(pairs, projectName);
|
|
62068
62308
|
if (entries.length > 0) {
|
|
62069
62309
|
const knowledgePath = resolveSwarmKnowledgePath(directory);
|
|
@@ -62200,26 +62440,26 @@ var init_deep_dive = __esm(() => {
|
|
|
62200
62440
|
|
|
62201
62441
|
// src/config/cache-paths.ts
|
|
62202
62442
|
import * as os10 from "node:os";
|
|
62203
|
-
import * as
|
|
62443
|
+
import * as path35 from "node:path";
|
|
62204
62444
|
function getPluginConfigDir() {
|
|
62205
|
-
return
|
|
62445
|
+
return path35.join(process.env.XDG_CONFIG_HOME || path35.join(os10.homedir(), ".config"), "opencode");
|
|
62206
62446
|
}
|
|
62207
62447
|
function getPluginCachePaths() {
|
|
62208
|
-
const cacheBase = process.env.XDG_CACHE_HOME ||
|
|
62448
|
+
const cacheBase = process.env.XDG_CACHE_HOME || path35.join(os10.homedir(), ".cache");
|
|
62209
62449
|
const configDir = getPluginConfigDir();
|
|
62210
62450
|
const paths = [
|
|
62211
|
-
|
|
62212
|
-
|
|
62213
|
-
|
|
62451
|
+
path35.join(cacheBase, "opencode", "node_modules", "opencode-swarm"),
|
|
62452
|
+
path35.join(cacheBase, "opencode", "packages", "opencode-swarm@latest"),
|
|
62453
|
+
path35.join(configDir, "node_modules", "opencode-swarm")
|
|
62214
62454
|
];
|
|
62215
62455
|
if (process.platform === "darwin") {
|
|
62216
|
-
const libCaches =
|
|
62217
|
-
paths.push(
|
|
62456
|
+
const libCaches = path35.join(os10.homedir(), "Library", "Caches");
|
|
62457
|
+
paths.push(path35.join(libCaches, "opencode", "node_modules", "opencode-swarm"), path35.join(libCaches, "opencode", "packages", "opencode-swarm@latest"));
|
|
62218
62458
|
}
|
|
62219
62459
|
if (process.platform === "win32") {
|
|
62220
|
-
const localAppData = process.env.LOCALAPPDATA ||
|
|
62221
|
-
const appData = process.env.APPDATA ||
|
|
62222
|
-
paths.push(
|
|
62460
|
+
const localAppData = process.env.LOCALAPPDATA || path35.join(os10.homedir(), "AppData", "Local");
|
|
62461
|
+
const appData = process.env.APPDATA || path35.join(os10.homedir(), "AppData", "Roaming");
|
|
62462
|
+
paths.push(path35.join(localAppData, "opencode", "node_modules", "opencode-swarm"), path35.join(localAppData, "opencode", "packages", "opencode-swarm@latest"), path35.join(appData, "opencode", "node_modules", "opencode-swarm"));
|
|
62223
62463
|
}
|
|
62224
62464
|
return paths;
|
|
62225
62465
|
}
|
|
@@ -62339,81 +62579,6 @@ var init_gate_bridge = __esm(() => {
|
|
|
62339
62579
|
};
|
|
62340
62580
|
});
|
|
62341
62581
|
|
|
62342
|
-
// src/hooks/knowledge-events.ts
|
|
62343
|
-
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
62344
|
-
import { existsSync as existsSync18 } from "node:fs";
|
|
62345
|
-
import { appendFile as appendFile5, mkdir as mkdir8, readFile as readFile9 } from "node:fs/promises";
|
|
62346
|
-
import * as path35 from "node:path";
|
|
62347
|
-
function resolveKnowledgeEventsPath(directory) {
|
|
62348
|
-
return path35.join(directory, ".swarm", "knowledge-events.jsonl");
|
|
62349
|
-
}
|
|
62350
|
-
function newTraceId() {
|
|
62351
|
-
return randomUUID5();
|
|
62352
|
-
}
|
|
62353
|
-
function newEventId() {
|
|
62354
|
-
return randomUUID5();
|
|
62355
|
-
}
|
|
62356
|
-
function withDefaults(event) {
|
|
62357
|
-
return {
|
|
62358
|
-
schema_version: KNOWLEDGE_EVENT_SCHEMA_VERSION,
|
|
62359
|
-
...event,
|
|
62360
|
-
event_id: event.event_id || newEventId(),
|
|
62361
|
-
timestamp: event.timestamp || new Date().toISOString()
|
|
62362
|
-
};
|
|
62363
|
-
}
|
|
62364
|
-
async function appendKnowledgeEvent(directory, event) {
|
|
62365
|
-
const populated = withDefaults(event);
|
|
62366
|
-
const filePath = resolveKnowledgeEventsPath(directory);
|
|
62367
|
-
await mkdir8(path35.dirname(filePath), { recursive: true });
|
|
62368
|
-
await appendFile5(filePath, `${JSON.stringify(populated)}
|
|
62369
|
-
`, "utf-8");
|
|
62370
|
-
try {
|
|
62371
|
-
await enforceKnowledgeCap(filePath, MAX_EVENT_LOG_ENTRIES);
|
|
62372
|
-
} catch (err2) {
|
|
62373
|
-
warn(`[knowledge-events] enforceKnowledgeCap failed (non-fatal): ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
62374
|
-
}
|
|
62375
|
-
return populated;
|
|
62376
|
-
}
|
|
62377
|
-
async function recordKnowledgeEvent(directory, event) {
|
|
62378
|
-
try {
|
|
62379
|
-
return await appendKnowledgeEvent(directory, event);
|
|
62380
|
-
} catch (err2) {
|
|
62381
|
-
warn(`[knowledge-events] recordKnowledgeEvent failed: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
62382
|
-
return null;
|
|
62383
|
-
}
|
|
62384
|
-
}
|
|
62385
|
-
async function readKnowledgeEvents(directory) {
|
|
62386
|
-
const filePath = resolveKnowledgeEventsPath(directory);
|
|
62387
|
-
if (!existsSync18(filePath))
|
|
62388
|
-
return [];
|
|
62389
|
-
const content = await readFile9(filePath, "utf-8");
|
|
62390
|
-
const out2 = [];
|
|
62391
|
-
for (const line of content.split(`
|
|
62392
|
-
`)) {
|
|
62393
|
-
const trimmed = line.trim();
|
|
62394
|
-
if (!trimmed)
|
|
62395
|
-
continue;
|
|
62396
|
-
try {
|
|
62397
|
-
out2.push(JSON.parse(trimmed));
|
|
62398
|
-
} catch {
|
|
62399
|
-
warn(`[knowledge-events] Skipping corrupted JSONL line in ${filePath}: ${trimmed.slice(0, 80)}`);
|
|
62400
|
-
}
|
|
62401
|
-
}
|
|
62402
|
-
return out2;
|
|
62403
|
-
}
|
|
62404
|
-
var KNOWLEDGE_EVENT_SCHEMA_VERSION = 1, MAX_EVENT_LOG_ENTRIES = 5000, RECEIPT_EVENT_TYPES;
|
|
62405
|
-
var init_knowledge_events = __esm(() => {
|
|
62406
|
-
init_logger();
|
|
62407
|
-
init_knowledge_store();
|
|
62408
|
-
RECEIPT_EVENT_TYPES = new Set([
|
|
62409
|
-
"acknowledged",
|
|
62410
|
-
"applied",
|
|
62411
|
-
"ignored",
|
|
62412
|
-
"contradicted",
|
|
62413
|
-
"violated"
|
|
62414
|
-
]);
|
|
62415
|
-
});
|
|
62416
|
-
|
|
62417
62582
|
// src/services/version-check.ts
|
|
62418
62583
|
import { existsSync as existsSync19, mkdirSync as mkdirSync12, readFileSync as readFileSync8, writeFileSync as writeFileSync8 } from "node:fs";
|
|
62419
62584
|
import { homedir as homedir6 } from "node:os";
|
|
@@ -66589,7 +66754,7 @@ function withStateLock(directory, fn2) {
|
|
|
66589
66754
|
fs21.writeFileSync(lockTarget, `${JSON.stringify(seed, null, 2)}
|
|
66590
66755
|
`, "utf-8");
|
|
66591
66756
|
}
|
|
66592
|
-
release =
|
|
66757
|
+
release = lockfile7.lockSync(lockTarget, {
|
|
66593
66758
|
retries: { retries: 5, minTimeout: 5, maxTimeout: 50 },
|
|
66594
66759
|
stale: 5000
|
|
66595
66760
|
});
|
|
@@ -66889,12 +67054,12 @@ function shouldPauseForDenials(state, config3) {
|
|
|
66889
67054
|
}
|
|
66890
67055
|
return { pause: false };
|
|
66891
67056
|
}
|
|
66892
|
-
var
|
|
67057
|
+
var import_proper_lockfile7, lockfile7, STATE_FILE = "full-auto-state.json", MAX_DENIAL_HISTORY = 100, stateUnreadable = false, stateUnreadableReason = "";
|
|
66893
67058
|
var init_state2 = __esm(() => {
|
|
66894
67059
|
init_utils2();
|
|
66895
67060
|
init_logger();
|
|
66896
|
-
|
|
66897
|
-
|
|
67061
|
+
import_proper_lockfile7 = __toESM(require_proper_lockfile(), 1);
|
|
67062
|
+
lockfile7 = import_proper_lockfile7.default;
|
|
66898
67063
|
});
|
|
66899
67064
|
|
|
66900
67065
|
// src/commands/full-auto.ts
|
|
@@ -67920,7 +68085,7 @@ var KNOWLEDGE_SCHEMA_VERSION = 2;
|
|
|
67920
68085
|
// src/hooks/knowledge-migrator.ts
|
|
67921
68086
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
67922
68087
|
import { existsSync as existsSync26, readFileSync as readFileSync14 } from "node:fs";
|
|
67923
|
-
import { mkdir as mkdir9, readFile as readFile11, writeFile as
|
|
68088
|
+
import { mkdir as mkdir9, readFile as readFile11, writeFile as writeFile9 } from "node:fs/promises";
|
|
67924
68089
|
import * as path42 from "node:path";
|
|
67925
68090
|
async function migrateKnowledgeToExternal(_directory, _config) {
|
|
67926
68091
|
return {
|
|
@@ -68151,7 +68316,7 @@ async function writeSentinel(sentinelPath, migrated, dropped) {
|
|
|
68151
68316
|
migration_tool: "knowledge-migrator.ts"
|
|
68152
68317
|
};
|
|
68153
68318
|
await mkdir9(path42.dirname(sentinelPath), { recursive: true });
|
|
68154
|
-
await
|
|
68319
|
+
await writeFile9(sentinelPath, JSON.stringify(sentinel, null, 2), "utf-8");
|
|
68155
68320
|
}
|
|
68156
68321
|
var _internals29;
|
|
68157
68322
|
var init_knowledge_migrator = __esm(() => {
|
|
@@ -69233,7 +69398,7 @@ import {
|
|
|
69233
69398
|
mkdir as mkdir10,
|
|
69234
69399
|
readFile as readFile12,
|
|
69235
69400
|
rename as rename6,
|
|
69236
|
-
writeFile as
|
|
69401
|
+
writeFile as writeFile10
|
|
69237
69402
|
} from "node:fs/promises";
|
|
69238
69403
|
import * as path43 from "node:path";
|
|
69239
69404
|
|
|
@@ -69644,7 +69809,7 @@ async function writeJsonlAtomic(filePath, values) {
|
|
|
69644
69809
|
const content = values.map((value) => JSON.stringify(value)).join(`
|
|
69645
69810
|
`) + (values.length > 0 ? `
|
|
69646
69811
|
` : "");
|
|
69647
|
-
await
|
|
69812
|
+
await writeFile10(tmp, content, "utf-8");
|
|
69648
69813
|
await rename6(tmp, filePath);
|
|
69649
69814
|
}
|
|
69650
69815
|
var init_local_jsonl_provider = __esm(() => {
|
|
@@ -69739,7 +69904,7 @@ var init_prompt_block = __esm(() => {
|
|
|
69739
69904
|
|
|
69740
69905
|
// src/memory/jsonl-migration.ts
|
|
69741
69906
|
import { existsSync as existsSync28 } from "node:fs";
|
|
69742
|
-
import { copyFile, mkdir as mkdir11, readFile as readFile13, stat as stat4, writeFile as
|
|
69907
|
+
import { copyFile, mkdir as mkdir11, readFile as readFile13, stat as stat4, writeFile as writeFile11 } from "node:fs/promises";
|
|
69743
69908
|
import * as path44 from "node:path";
|
|
69744
69909
|
function resolveMemoryStorageDir(rootDirectory, config3 = {}) {
|
|
69745
69910
|
const resolved = resolveConfig(config3);
|
|
@@ -69787,14 +69952,14 @@ async function writeJsonlExport(rootDirectory, config3, memories, proposals) {
|
|
|
69787
69952
|
await mkdir11(exportDir, { recursive: true });
|
|
69788
69953
|
const memoriesPath = path44.join(exportDir, "memories.jsonl");
|
|
69789
69954
|
const proposalsPath = path44.join(exportDir, "proposals.jsonl");
|
|
69790
|
-
await
|
|
69791
|
-
await
|
|
69955
|
+
await writeFile11(memoriesPath, toJsonl(memories), "utf-8");
|
|
69956
|
+
await writeFile11(proposalsPath, toJsonl(proposals), "utf-8");
|
|
69792
69957
|
return { directory: exportDir, memoriesPath, proposalsPath };
|
|
69793
69958
|
}
|
|
69794
69959
|
async function writeMigrationReport(rootDirectory, report, config3 = {}) {
|
|
69795
69960
|
const reportPath = path44.join(resolveMemoryStorageDir(rootDirectory, config3), "migration-report.json");
|
|
69796
69961
|
await mkdir11(path44.dirname(reportPath), { recursive: true });
|
|
69797
|
-
await
|
|
69962
|
+
await writeFile11(reportPath, `${JSON.stringify(report, null, 2)}
|
|
69798
69963
|
`, "utf-8");
|
|
69799
69964
|
return reportPath;
|
|
69800
69965
|
}
|
|
@@ -82689,7 +82854,7 @@ ANTI-RATIONALIZATION: Context does not clarify. Models revert to CC training.
|
|
|
82689
82854
|
## IDENTITY
|
|
82690
82855
|
|
|
82691
82856
|
Swarm: {{SWARM_ID}}
|
|
82692
|
-
Your agents: {{AGENT_PREFIX}}explorer, {{AGENT_PREFIX}}sme, {{AGENT_PREFIX}}coder, {{AGENT_PREFIX}}reviewer, {{AGENT_PREFIX}}test_engineer, {{AGENT_PREFIX}}critic, {{AGENT_PREFIX}}critic_sounding_board, {{AGENT_PREFIX}}skill_improver, {{AGENT_PREFIX}}spec_writer, {{AGENT_PREFIX}}docs, {{AGENT_PREFIX}}designer
|
|
82857
|
+
Your agents: {{AGENT_PREFIX}}explorer, {{AGENT_PREFIX}}sme, {{AGENT_PREFIX}}coder, {{AGENT_PREFIX}}reviewer, {{AGENT_PREFIX}}test_engineer, {{AGENT_PREFIX}}critic, {{AGENT_PREFIX}}critic_sounding_board, {{AGENT_PREFIX}}critic_drift_verifier, {{AGENT_PREFIX}}critic_hallucination_verifier, {{AGENT_PREFIX}}critic_architecture_supervisor, {{AGENT_PREFIX}}skill_improver, {{AGENT_PREFIX}}spec_writer, {{AGENT_PREFIX}}docs, {{AGENT_PREFIX}}designer
|
|
82693
82858
|
|
|
82694
82859
|
## PROJECT CONTEXT
|
|
82695
82860
|
Session-start priming block. Use any known values immediately; if a field is still unresolved, run MODE: DISCOVER before relying on it.
|
|
@@ -83266,6 +83431,7 @@ Every loaded mode skill is written with active-swarm role phrases. Before follow
|
|
|
83266
83431
|
- the active swarm's critic_drift_verifier agent = @{{AGENT_PREFIX}}critic_drift_verifier
|
|
83267
83432
|
- the active swarm's critic_hallucination_verifier agent = @{{AGENT_PREFIX}}critic_hallucination_verifier
|
|
83268
83433
|
- the active swarm's critic_sounding_board agent = @{{AGENT_PREFIX}}critic_sounding_board
|
|
83434
|
+
- the active swarm's critic_architecture_supervisor agent = @{{AGENT_PREFIX}}critic_architecture_supervisor
|
|
83269
83435
|
- the active swarm's council_generalist agent = @{{AGENT_PREFIX}}council_generalist
|
|
83270
83436
|
- the active swarm's council_skeptic agent = @{{AGENT_PREFIX}}council_skeptic
|
|
83271
83437
|
- the active swarm's council_domain_expert agent = @{{AGENT_PREFIX}}council_domain_expert
|
|
@@ -83472,6 +83638,7 @@ ACTION: Load skill file:.opencode/skills/phase-wrap/SKILL.md immediately. Follow
|
|
|
83472
83638
|
HARD CONSTRAINTS:
|
|
83473
83639
|
- Complete retrospective evidence with \`write_retro\` before \`phase_complete\`.
|
|
83474
83640
|
|
|
83641
|
+
> **NOTE**: The \`critic_oversight\` agent (\`AUTONOMOUS_OVERSIGHT_PROMPT\`) is dispatched only via full-auto mode (\`src/full-auto/oversight.ts\`). It has no architect MODE dispatch path — it is **NOT** reachable from \`MODE: CRITIC-GATE\`, \`MODE: EXECUTE\`, or \`MODE: PHASE-WRAP\`. This is intentional: it serves as the sole quality gate in autonomous oversight mode.
|
|
83475
83642
|
|
|
83476
83643
|
## FILES
|
|
83477
83644
|
|
|
@@ -85704,7 +85871,7 @@ COVERAGE REPORTING:
|
|
|
85704
85871
|
`;
|
|
85705
85872
|
|
|
85706
85873
|
// src/agents/index.ts
|
|
85707
|
-
import { mkdir as mkdir13, writeFile as
|
|
85874
|
+
import { mkdir as mkdir13, writeFile as writeFile12 } from "node:fs/promises";
|
|
85708
85875
|
import * as path71 from "node:path";
|
|
85709
85876
|
function stripSwarmPrefix(agentName, swarmPrefix) {
|
|
85710
85877
|
if (!swarmPrefix || !agentName)
|
|
@@ -86120,7 +86287,7 @@ function getAgentConfigs(config3, directory, sessionId, projectContext) {
|
|
|
86120
86287
|
generatedAt: new Date().toISOString(),
|
|
86121
86288
|
agents: agentToolSnapshot
|
|
86122
86289
|
}, null, 2);
|
|
86123
|
-
mkdir13(evidenceDir, { recursive: true }).then(() =>
|
|
86290
|
+
mkdir13(evidenceDir, { recursive: true }).then(() => writeFile12(path71.join(evidenceDir, filename), snapshotData)).catch(() => {});
|
|
86124
86291
|
}
|
|
86125
86292
|
return result;
|
|
86126
86293
|
}
|
|
@@ -90659,7 +90826,7 @@ import {
|
|
|
90659
90826
|
readFile as readFile16,
|
|
90660
90827
|
realpath as realpath3,
|
|
90661
90828
|
stat as stat7,
|
|
90662
|
-
writeFile as
|
|
90829
|
+
writeFile as writeFile14
|
|
90663
90830
|
} from "node:fs/promises";
|
|
90664
90831
|
import * as path95 from "node:path";
|
|
90665
90832
|
function normalizeSeparators(filePath) {
|
|
@@ -90857,7 +91024,7 @@ async function scanDocIndex(directory) {
|
|
|
90857
91024
|
};
|
|
90858
91025
|
try {
|
|
90859
91026
|
await mkdir16(path95.dirname(manifestPath), { recursive: true });
|
|
90860
|
-
await
|
|
91027
|
+
await writeFile14(manifestPath, JSON.stringify(manifest, null, 2), "utf-8");
|
|
90861
91028
|
} catch {}
|
|
90862
91029
|
return { manifest, cached: false };
|
|
90863
91030
|
}
|
|
@@ -91071,7 +91238,7 @@ var init_doc_scan = __esm(() => {
|
|
|
91071
91238
|
|
|
91072
91239
|
// src/hooks/knowledge-reader.ts
|
|
91073
91240
|
import { existsSync as existsSync52 } from "node:fs";
|
|
91074
|
-
import { mkdir as mkdir17, readFile as readFile17, writeFile as
|
|
91241
|
+
import { mkdir as mkdir17, readFile as readFile17, writeFile as writeFile15 } from "node:fs/promises";
|
|
91075
91242
|
import * as path96 from "node:path";
|
|
91076
91243
|
function inferCategoriesFromPhase(phaseDescription) {
|
|
91077
91244
|
const lower = phaseDescription.toLowerCase();
|
|
@@ -91128,7 +91295,7 @@ async function recordLessonsShown(directory, lessonIds, currentPhase) {
|
|
|
91128
91295
|
const canonicalKey = phaseMatch ? `Phase ${phaseMatch[1]}` : currentPhase;
|
|
91129
91296
|
shownData[canonicalKey] = lessonIds;
|
|
91130
91297
|
await mkdir17(path96.dirname(shownFile), { recursive: true });
|
|
91131
|
-
await
|
|
91298
|
+
await writeFile15(shownFile, JSON.stringify(shownData, null, 2), "utf-8");
|
|
91132
91299
|
} catch {
|
|
91133
91300
|
warn("[swarm] Knowledge: failed to record shown lessons");
|
|
91134
91301
|
}
|
|
@@ -91261,7 +91428,7 @@ async function updateRetrievalOutcome(directory, phaseInfo, phaseSucceeded) {
|
|
|
91261
91428
|
const remainingIds = shownIds.filter((id) => !foundInSwarm.has(id));
|
|
91262
91429
|
if (remainingIds.length === 0) {
|
|
91263
91430
|
delete shownData[phaseInfo];
|
|
91264
|
-
await
|
|
91431
|
+
await writeFile15(shownFile, JSON.stringify(shownData, null, 2), "utf-8");
|
|
91265
91432
|
return;
|
|
91266
91433
|
}
|
|
91267
91434
|
const hivePath = resolveHiveKnowledgePath();
|
|
@@ -91282,7 +91449,7 @@ async function updateRetrievalOutcome(directory, phaseInfo, phaseSucceeded) {
|
|
|
91282
91449
|
await rewriteKnowledge(hivePath, hiveEntries);
|
|
91283
91450
|
}
|
|
91284
91451
|
delete shownData[phaseInfo];
|
|
91285
|
-
await
|
|
91452
|
+
await writeFile15(shownFile, JSON.stringify(shownData, null, 2), "utf-8");
|
|
91286
91453
|
} catch {
|
|
91287
91454
|
warn("[swarm] Knowledge: failed to update retrieval outcomes");
|
|
91288
91455
|
}
|
|
@@ -91399,6 +91566,7 @@ async function searchKnowledge(params) {
|
|
|
91399
91566
|
let candidates = await readMergedKnowledge(directory, mergeConfig, projected, {
|
|
91400
91567
|
skipScopeFilter: !applyScopeFilter
|
|
91401
91568
|
});
|
|
91569
|
+
const counterRollups = await readKnowledgeCounterRollups(directory);
|
|
91402
91570
|
candidates = candidates.filter((e) => {
|
|
91403
91571
|
if (e.status === "quarantined")
|
|
91404
91572
|
return false;
|
|
@@ -91423,15 +91591,21 @@ async function searchKnowledge(params) {
|
|
|
91423
91591
|
const metaWeight = hasQuery ? META_WEIGHT : 1;
|
|
91424
91592
|
const minConf = typeof config3.directive_min_confidence === "number" ? config3.directive_min_confidence : DIRECTIVE_BOOST_MIN_CONFIDENCE;
|
|
91425
91593
|
const scored = candidates.map((entry) => {
|
|
91594
|
+
const retrievalOutcomes = effectiveRetrievalOutcomes(entry.retrieval_outcomes, counterRollups.get(entry.id));
|
|
91426
91595
|
const textScore = queryBigrams ? jaccardBigram(queryBigrams, wordBigrams(normalize3(entryText(entry)))) : 0;
|
|
91427
91596
|
const metaScore = entry.finalScore;
|
|
91428
91597
|
const ds = context ? scoreDirectiveAgainstContext(entry, context) : { triggerHit: false, actionHit: false, agentHit: false, score: 0 };
|
|
91429
91598
|
const confBoost = context && entry.confidence >= minConf && (ds.actionHit || ds.agentHit) ? 0.25 : 0;
|
|
91430
91599
|
const generatedSkillBoost = entry.generated_skill_path && entry.status !== "archived" ? 0.05 : 0;
|
|
91431
|
-
const outcomeBoost = computeOutcomeSignal(
|
|
91600
|
+
const outcomeBoost = computeOutcomeSignal(retrievalOutcomes) * OUTCOME_RANK_WEIGHT;
|
|
91432
91601
|
const finalScore = Math.min(1, Math.max(0, textWeight * textScore + metaWeight * metaScore + ds.score + confBoost + generatedSkillBoost + outcomeBoost + (hasQuery ? statusBoost(entry.status) : 0)));
|
|
91433
91602
|
const isCritical = entry.directive_priority === "critical" && (ds.triggerHit || ds.actionHit || ds.agentHit);
|
|
91434
|
-
return {
|
|
91603
|
+
return {
|
|
91604
|
+
...entry,
|
|
91605
|
+
retrieval_outcomes: retrievalOutcomes,
|
|
91606
|
+
finalScore,
|
|
91607
|
+
__critical: isCritical
|
|
91608
|
+
};
|
|
91435
91609
|
});
|
|
91436
91610
|
scored.sort((a, b) => {
|
|
91437
91611
|
const diff = b.finalScore - a.finalScore;
|
|
@@ -91826,7 +92000,7 @@ var init_curator_drift = __esm(() => {
|
|
|
91826
92000
|
var exports_project_context = {};
|
|
91827
92001
|
__export(exports_project_context, {
|
|
91828
92002
|
buildProjectContext: () => buildProjectContext,
|
|
91829
|
-
_internals: () =>
|
|
92003
|
+
_internals: () => _internals68,
|
|
91830
92004
|
LANG_BACKEND_DETECTION_TIMEOUT_MS: () => LANG_BACKEND_DETECTION_TIMEOUT_MS
|
|
91831
92005
|
});
|
|
91832
92006
|
import * as fs117 from "node:fs";
|
|
@@ -91910,7 +92084,7 @@ function selectLintCommand(backend, directory) {
|
|
|
91910
92084
|
return null;
|
|
91911
92085
|
}
|
|
91912
92086
|
async function buildProjectContext(directory) {
|
|
91913
|
-
const backend = await
|
|
92087
|
+
const backend = await _internals68.pickBackend(directory);
|
|
91914
92088
|
if (!backend)
|
|
91915
92089
|
return null;
|
|
91916
92090
|
const ctx = emptyProjectContext();
|
|
@@ -91941,16 +92115,16 @@ async function buildProjectContext(directory) {
|
|
|
91941
92115
|
if (backend.prompts.reviewerChecklist.length > 0) {
|
|
91942
92116
|
ctx.REVIEWER_CHECKLIST = bulletList(backend.prompts.reviewerChecklist);
|
|
91943
92117
|
}
|
|
91944
|
-
const profiles =
|
|
92118
|
+
const profiles = _internals68.pickedProfiles(directory);
|
|
91945
92119
|
if (profiles.length > 1) {
|
|
91946
92120
|
ctx.PROJECT_CONTEXT_SECONDARY_LANGUAGES = profiles.slice(1).map((p) => p.id).join(", ");
|
|
91947
92121
|
}
|
|
91948
92122
|
return ctx;
|
|
91949
92123
|
}
|
|
91950
|
-
var LANG_BACKEND_DETECTION_TIMEOUT_MS = 300,
|
|
92124
|
+
var LANG_BACKEND_DETECTION_TIMEOUT_MS = 300, _internals68;
|
|
91951
92125
|
var init_project_context = __esm(() => {
|
|
91952
92126
|
init_dispatch();
|
|
91953
|
-
|
|
92127
|
+
_internals68 = {
|
|
91954
92128
|
pickBackend,
|
|
91955
92129
|
pickedProfiles
|
|
91956
92130
|
};
|
|
@@ -94544,9 +94718,9 @@ function createPhaseMonitorHook(directory, preflightManager, curatorRunner, dele
|
|
|
94544
94718
|
const initResult = await runner(directory, curatorConfig, llmDelegate);
|
|
94545
94719
|
if (initResult.briefing) {
|
|
94546
94720
|
const briefingPath = path79.join(directory, ".swarm", "curator-briefing.md");
|
|
94547
|
-
const { mkdir: mkdir14, writeFile:
|
|
94721
|
+
const { mkdir: mkdir14, writeFile: writeFile13 } = await import("node:fs/promises");
|
|
94548
94722
|
await mkdir14(path79.dirname(briefingPath), { recursive: true });
|
|
94549
|
-
await
|
|
94723
|
+
await writeFile13(briefingPath, initResult.briefing, "utf-8");
|
|
94550
94724
|
const { buildApprovedReceipt: buildApprovedReceipt2, persistReviewReceipt: persistReviewReceipt2 } = await Promise.resolve().then(() => (init_review_receipt(), exports_review_receipt));
|
|
94551
94725
|
const initReceipt = buildApprovedReceipt2({
|
|
94552
94726
|
agent: "curator",
|
|
@@ -102042,7 +102216,7 @@ import * as path101 from "node:path";
|
|
|
102042
102216
|
// src/hooks/knowledge-application.ts
|
|
102043
102217
|
init_logger();
|
|
102044
102218
|
init_knowledge_store();
|
|
102045
|
-
var
|
|
102219
|
+
var import_proper_lockfile8 = __toESM(require_proper_lockfile(), 1);
|
|
102046
102220
|
import { existsSync as existsSync56 } from "node:fs";
|
|
102047
102221
|
import { appendFile as appendFile9, mkdir as mkdir18, readFile as readFile18 } from "node:fs/promises";
|
|
102048
102222
|
import * as path100 from "node:path";
|
|
@@ -102461,10 +102635,12 @@ init_state();
|
|
|
102461
102635
|
init_logger();
|
|
102462
102636
|
init_curator_drift();
|
|
102463
102637
|
init_extractors();
|
|
102638
|
+
init_knowledge_events();
|
|
102464
102639
|
init_knowledge_store();
|
|
102465
102640
|
init_search_knowledge();
|
|
102466
102641
|
init_utils2();
|
|
102467
102642
|
var INJECTION_SENTINEL = "[[KNOWLEDGE-INJECTED]]";
|
|
102643
|
+
var defaultSearchKnowledge = searchKnowledge;
|
|
102468
102644
|
function buildKnowledgeBlock(entries, charBudget, cfg, currentProject) {
|
|
102469
102645
|
if (entries.length === 0)
|
|
102470
102646
|
return null;
|
|
@@ -102642,13 +102818,15 @@ function createKnowledgeInjectorHook(directory, config3) {
|
|
|
102642
102818
|
projectName,
|
|
102643
102819
|
currentPhase: phaseDescription
|
|
102644
102820
|
};
|
|
102645
|
-
const
|
|
102821
|
+
const searchFn = _internals48.searchKnowledge === defaultSearchKnowledge ? searchKnowledge : _internals48.searchKnowledge;
|
|
102822
|
+
const search = await searchFn({
|
|
102646
102823
|
directory,
|
|
102647
102824
|
config: config3,
|
|
102648
102825
|
context: retrievalCtx,
|
|
102649
102826
|
mode: "auto_injection",
|
|
102650
102827
|
agent: "architect",
|
|
102651
|
-
sessionId: systemMsg?.info?.sessionID
|
|
102828
|
+
sessionId: systemMsg?.info?.sessionID,
|
|
102829
|
+
emitEvent: false
|
|
102652
102830
|
});
|
|
102653
102831
|
const entries = search.results;
|
|
102654
102832
|
const filteredEntries = filterHighConfidenceKnowledge(entries);
|
|
@@ -102741,7 +102919,27 @@ ${freshPreamble}` : `<curator_briefing>${truncatedBriefing}</curator_briefing>`;
|
|
|
102741
102919
|
}
|
|
102742
102920
|
if (cachedShownIds.length > 0) {
|
|
102743
102921
|
const phaseLabel = `Phase ${currentPhase}`;
|
|
102744
|
-
|
|
102922
|
+
const scoreById = new Map(entries.map((e) => [e.id, e.finalScore]));
|
|
102923
|
+
const ranks = {};
|
|
102924
|
+
const scores = {};
|
|
102925
|
+
cachedShownIds.forEach((id, idx) => {
|
|
102926
|
+
ranks[id] = idx + 1;
|
|
102927
|
+
scores[id] = scoreById.get(id) ?? 0;
|
|
102928
|
+
});
|
|
102929
|
+
await _internals48.recordKnowledgeEvent(directory, {
|
|
102930
|
+
type: "retrieved",
|
|
102931
|
+
trace_id: search.trace_id,
|
|
102932
|
+
session_id: systemMsg?.info?.sessionID ?? "unknown",
|
|
102933
|
+
phase: retrievalCtx.currentPhase,
|
|
102934
|
+
task_id: retrievalCtx.taskId,
|
|
102935
|
+
agent: "architect",
|
|
102936
|
+
query: retrievalCtx.lastUserMessage ?? retrievalCtx.currentPhase ?? "",
|
|
102937
|
+
retrieval_mode: "auto_injection",
|
|
102938
|
+
result_ids: cachedShownIds,
|
|
102939
|
+
ranks,
|
|
102940
|
+
scores
|
|
102941
|
+
});
|
|
102942
|
+
_internals48.recordKnowledgeShown(directory, cachedShownIds, {
|
|
102745
102943
|
phase: phaseLabel,
|
|
102746
102944
|
tool: retrievalCtx.currentTool,
|
|
102747
102945
|
action: retrievalCtx.currentAction,
|
|
@@ -102751,6 +102949,11 @@ ${freshPreamble}` : `<curator_briefing>${truncatedBriefing}</curator_briefing>`;
|
|
|
102751
102949
|
}
|
|
102752
102950
|
});
|
|
102753
102951
|
}
|
|
102952
|
+
var _internals48 = {
|
|
102953
|
+
searchKnowledge,
|
|
102954
|
+
recordKnowledgeEvent,
|
|
102955
|
+
recordKnowledgeShown
|
|
102956
|
+
};
|
|
102754
102957
|
|
|
102755
102958
|
// src/index.ts
|
|
102756
102959
|
init_normalize_tool_name();
|
|
@@ -102894,7 +103097,7 @@ var TASK_DIVERSITY_WEIGHT = 0.05;
|
|
|
102894
103097
|
var CONTEXT_WEIGHT = 0.2;
|
|
102895
103098
|
var RECENCY_DECAY_MS = 30 * 24 * 60 * 60 * 1000;
|
|
102896
103099
|
var SKILL_FRONTMATTER_READ_BYTES = 16 * 1024;
|
|
102897
|
-
var
|
|
103100
|
+
var _internals49 = {
|
|
102898
103101
|
computeSkillRelevanceScore: null,
|
|
102899
103102
|
rankSkillsForContext: null,
|
|
102900
103103
|
getSkillStats: null,
|
|
@@ -103113,7 +103316,7 @@ function formatSkillIndexWithContext(skills, directory) {
|
|
|
103113
103316
|
} catch {}
|
|
103114
103317
|
if (!hasHistory) {
|
|
103115
103318
|
return skills.map((sp) => {
|
|
103116
|
-
const meta3 =
|
|
103319
|
+
const meta3 = _internals49.readSkillMetadata(sp, directory);
|
|
103117
103320
|
return ` - file:${meta3.path} - ${meta3.name}: ${meta3.description}`;
|
|
103118
103321
|
}).join(`
|
|
103119
103322
|
`);
|
|
@@ -103121,7 +103324,7 @@ function formatSkillIndexWithContext(skills, directory) {
|
|
|
103121
103324
|
const lines = [];
|
|
103122
103325
|
for (const skillPath of skills) {
|
|
103123
103326
|
const stats = getSkillStats(skillPath, directory);
|
|
103124
|
-
const meta3 =
|
|
103327
|
+
const meta3 = _internals49.readSkillMetadata(skillPath, directory);
|
|
103125
103328
|
const compliancePct = Math.round(stats.complianceRate * 100);
|
|
103126
103329
|
const topAgentNames = stats.topAgents.slice(0, 3).map((a) => a.agent).join(", ");
|
|
103127
103330
|
lines.push(` - file:${meta3.path} - ${meta3.name}: ${meta3.description} (used: ${stats.totalUsage}, compliance: ${compliancePct}%)` + (stats.topAgents.length > 0 ? ` → ${topAgentNames}` : ""));
|
|
@@ -103129,15 +103332,15 @@ function formatSkillIndexWithContext(skills, directory) {
|
|
|
103129
103332
|
return lines.join(`
|
|
103130
103333
|
`);
|
|
103131
103334
|
}
|
|
103132
|
-
|
|
103133
|
-
|
|
103134
|
-
|
|
103135
|
-
|
|
103136
|
-
|
|
103137
|
-
|
|
103138
|
-
|
|
103139
|
-
|
|
103140
|
-
|
|
103335
|
+
_internals49.computeSkillRelevanceScore = computeSkillRelevanceScore;
|
|
103336
|
+
_internals49.rankSkillsForContext = rankSkillsForContext;
|
|
103337
|
+
_internals49.getSkillStats = getSkillStats;
|
|
103338
|
+
_internals49.formatSkillIndexWithContext = formatSkillIndexWithContext;
|
|
103339
|
+
_internals49.parseSkillFrontmatter = parseSkillFrontmatter;
|
|
103340
|
+
_internals49.readSkillMetadata = readSkillMetadata;
|
|
103341
|
+
_internals49.extractSkillName = extractSkillName;
|
|
103342
|
+
_internals49.computeRecencyScore = computeRecencyScore;
|
|
103343
|
+
_internals49.computeContextMatchScore = computeContextMatchScore;
|
|
103141
103344
|
|
|
103142
103345
|
// src/hooks/skill-propagation-gate.ts
|
|
103143
103346
|
init_skill_usage_log();
|
|
@@ -103240,10 +103443,10 @@ function parseYamlValue(value) {
|
|
|
103240
103443
|
}
|
|
103241
103444
|
function loadRoutingSkills(directory, targetAgent) {
|
|
103242
103445
|
const routingPath = path105.join(directory, ".opencode", "skill-routing.yaml");
|
|
103243
|
-
if (!
|
|
103446
|
+
if (!_internals50.existsSync(routingPath))
|
|
103244
103447
|
return [];
|
|
103245
103448
|
try {
|
|
103246
|
-
const content =
|
|
103449
|
+
const content = _internals50.readFileSync(routingPath, "utf-8");
|
|
103247
103450
|
const config3 = parseSimpleYaml(content);
|
|
103248
103451
|
if (!config3?.routing)
|
|
103249
103452
|
return [];
|
|
@@ -103270,7 +103473,7 @@ var SKILL_SEARCH_ROOTS = [
|
|
|
103270
103473
|
".claude/skills"
|
|
103271
103474
|
];
|
|
103272
103475
|
var MAX_SCORING_SESSION_ENTRIES = 500;
|
|
103273
|
-
var
|
|
103476
|
+
var _internals50 = {
|
|
103274
103477
|
readdirSync: fs67.readdirSync.bind(fs67),
|
|
103275
103478
|
existsSync: fs67.existsSync.bind(fs67),
|
|
103276
103479
|
statSync: fs67.statSync.bind(fs67),
|
|
@@ -103299,11 +103502,11 @@ function discoverAvailableSkills(directory) {
|
|
|
103299
103502
|
const results = [];
|
|
103300
103503
|
for (const root of SKILL_SEARCH_ROOTS) {
|
|
103301
103504
|
const rootPath = path105.join(directory, root);
|
|
103302
|
-
if (!
|
|
103505
|
+
if (!_internals50.existsSync(rootPath))
|
|
103303
103506
|
continue;
|
|
103304
103507
|
let entries;
|
|
103305
103508
|
try {
|
|
103306
|
-
entries =
|
|
103509
|
+
entries = _internals50.readdirSync(rootPath);
|
|
103307
103510
|
} catch {
|
|
103308
103511
|
continue;
|
|
103309
103512
|
}
|
|
@@ -103311,11 +103514,11 @@ function discoverAvailableSkills(directory) {
|
|
|
103311
103514
|
if (entry.startsWith("."))
|
|
103312
103515
|
continue;
|
|
103313
103516
|
const skillDir = path105.join(rootPath, entry);
|
|
103314
|
-
if (
|
|
103517
|
+
if (_internals50.existsSync(path105.join(skillDir, "retired.marker")))
|
|
103315
103518
|
continue;
|
|
103316
103519
|
const skillFile = path105.join(skillDir, "SKILL.md");
|
|
103317
103520
|
try {
|
|
103318
|
-
if (
|
|
103521
|
+
if (_internals50.statSync(skillDir).isDirectory() && _internals50.existsSync(skillFile)) {
|
|
103319
103522
|
results.push(path105.join(root, entry, "SKILL.md").replace(/\\/g, "/"));
|
|
103320
103523
|
}
|
|
103321
103524
|
} catch (err2) {
|
|
@@ -103347,7 +103550,7 @@ function parseDelegationArgs(args2) {
|
|
|
103347
103550
|
}
|
|
103348
103551
|
if (!targetAgent)
|
|
103349
103552
|
return null;
|
|
103350
|
-
const skillsField = prompt ?
|
|
103553
|
+
const skillsField = prompt ? _internals50.extractSkillsFieldFromPrompt(prompt) : "";
|
|
103351
103554
|
return { targetAgent, skillsField };
|
|
103352
103555
|
}
|
|
103353
103556
|
function extractSkillsFieldFromPrompt(prompt) {
|
|
@@ -103388,10 +103591,10 @@ function writeWarnEvent2(directory, record3) {
|
|
|
103388
103591
|
const filePath = path105.join(directory, ".swarm", "events.jsonl");
|
|
103389
103592
|
try {
|
|
103390
103593
|
const dir = path105.dirname(filePath);
|
|
103391
|
-
if (!
|
|
103392
|
-
|
|
103594
|
+
if (!_internals50.existsSync(dir)) {
|
|
103595
|
+
_internals50.mkdirSync(dir, { recursive: true });
|
|
103393
103596
|
}
|
|
103394
|
-
|
|
103597
|
+
_internals50.appendFileSync(filePath, `${JSON.stringify(record3)}
|
|
103395
103598
|
`, "utf-8");
|
|
103396
103599
|
} catch (err2) {
|
|
103397
103600
|
warn(`[skill-propagation-gate] failed to write warning event: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
@@ -103442,19 +103645,19 @@ async function skillPropagationGateBefore(directory, input, config3) {
|
|
|
103442
103645
|
const baseAgent = stripKnownSwarmPrefix(agentRaw);
|
|
103443
103646
|
if (baseAgent !== "architect")
|
|
103444
103647
|
return { blocked: false, reason: null, recommendedSkills: undefined };
|
|
103445
|
-
const parsed =
|
|
103648
|
+
const parsed = _internals50.parseDelegationArgs(input.args);
|
|
103446
103649
|
if (!parsed)
|
|
103447
103650
|
return { blocked: false, reason: null, recommendedSkills: undefined };
|
|
103448
103651
|
const targetBase = stripKnownSwarmPrefix(parsed.targetAgent);
|
|
103449
|
-
if (!
|
|
103652
|
+
if (!_internals50.SKILL_CAPABLE_AGENTS.has(targetBase))
|
|
103450
103653
|
return { blocked: false, reason: null, recommendedSkills: undefined };
|
|
103451
103654
|
const sessionID = typeof input.sessionID === "string" ? input.sessionID : "unknown";
|
|
103452
|
-
const availableSkills =
|
|
103655
|
+
const availableSkills = _internals50.discoverAvailableSkills(directory);
|
|
103453
103656
|
const skillsValue = parsed.skillsField.trim();
|
|
103454
103657
|
if (skillsValue && skillsValue.toLowerCase() !== "none") {
|
|
103455
103658
|
const prompt = typeof input.args?.prompt === "string" ? String(input.args.prompt) : "";
|
|
103456
|
-
const taskId =
|
|
103457
|
-
const skillPaths =
|
|
103659
|
+
const taskId = _internals50.extractTaskIdFromPrompt(prompt);
|
|
103660
|
+
const skillPaths = _internals50.parseSkillPaths(skillsValue);
|
|
103458
103661
|
let coderSkillPaths = [];
|
|
103459
103662
|
if (prompt) {
|
|
103460
103663
|
for (const line of prompt.split(`
|
|
@@ -103462,7 +103665,7 @@ async function skillPropagationGateBefore(directory, input, config3) {
|
|
|
103462
103665
|
const trimmed = line.trim();
|
|
103463
103666
|
if (trimmed.startsWith("SKILLS_USED_BY_CODER:")) {
|
|
103464
103667
|
const fieldVal = trimmed.slice("SKILLS_USED_BY_CODER:".length).trim();
|
|
103465
|
-
coderSkillPaths =
|
|
103668
|
+
coderSkillPaths = _internals50.parseSkillPaths(fieldVal);
|
|
103466
103669
|
break;
|
|
103467
103670
|
}
|
|
103468
103671
|
}
|
|
@@ -103470,7 +103673,7 @@ async function skillPropagationGateBefore(directory, input, config3) {
|
|
|
103470
103673
|
const allPaths = [...new Set([...skillPaths, ...coderSkillPaths])];
|
|
103471
103674
|
for (const skillPath of allPaths) {
|
|
103472
103675
|
try {
|
|
103473
|
-
|
|
103676
|
+
_internals50.appendSkillUsageEntry(directory, {
|
|
103474
103677
|
skillPath,
|
|
103475
103678
|
agentName: targetBase,
|
|
103476
103679
|
taskID: taskId,
|
|
@@ -103487,17 +103690,17 @@ async function skillPropagationGateBefore(directory, input, config3) {
|
|
|
103487
103690
|
let scored = [];
|
|
103488
103691
|
if (skillsValue && skillsValue.toLowerCase() !== "none" && availableSkills.length > 0) {
|
|
103489
103692
|
try {
|
|
103490
|
-
const sessionEntries =
|
|
103693
|
+
const sessionEntries = _internals50.readSkillUsageEntriesTail(directory, {
|
|
103491
103694
|
sessionID
|
|
103492
103695
|
});
|
|
103493
|
-
if (sessionEntries.length >
|
|
103696
|
+
if (sessionEntries.length > _internals50.MAX_SCORING_SESSION_ENTRIES) {
|
|
103494
103697
|
scoringSkipped = true;
|
|
103495
|
-
warn(`[skill-propagation-gate] skipping scoring — session has ${sessionEntries.length} entries (limit: ${
|
|
103698
|
+
warn(`[skill-propagation-gate] skipping scoring — session has ${sessionEntries.length} entries (limit: ${_internals50.MAX_SCORING_SESSION_ENTRIES})`);
|
|
103496
103699
|
} else {
|
|
103497
103700
|
const prompt = typeof input.args?.prompt === "string" ? String(input.args.prompt) : "";
|
|
103498
103701
|
scored = availableSkills.map((skillPath) => {
|
|
103499
103702
|
const skillEntries = sessionEntries.filter((e) => e.skillPath === skillPath);
|
|
103500
|
-
const score =
|
|
103703
|
+
const score = _internals50.computeSkillRelevanceScore(skillPath, prompt, skillEntries);
|
|
103501
103704
|
return { skillPath, score, usageCount: skillEntries.length };
|
|
103502
103705
|
}).sort((a, b) => b.score - a.score || b.usageCount - a.usageCount);
|
|
103503
103706
|
if (scored.length > 0) {
|
|
@@ -103511,12 +103714,12 @@ async function skillPropagationGateBefore(directory, input, config3) {
|
|
|
103511
103714
|
}
|
|
103512
103715
|
}
|
|
103513
103716
|
try {
|
|
103514
|
-
const routingPaths =
|
|
103717
|
+
const routingPaths = _internals50.loadRoutingSkills(directory, targetBase);
|
|
103515
103718
|
if (routingPaths.length > 0) {
|
|
103516
103719
|
const existingPaths = new Set(scored.map((s) => s.skillPath));
|
|
103517
103720
|
for (const routingPath of routingPaths) {
|
|
103518
103721
|
const routedSkillDir = path105.dirname(path105.join(directory, routingPath));
|
|
103519
|
-
if (
|
|
103722
|
+
if (_internals50.existsSync(path105.join(routedSkillDir, "retired.marker")))
|
|
103520
103723
|
continue;
|
|
103521
103724
|
if (!existingPaths.has(routingPath)) {
|
|
103522
103725
|
scored.push({
|
|
@@ -103542,12 +103745,12 @@ async function skillPropagationGateBefore(directory, input, config3) {
|
|
|
103542
103745
|
} else if (typeof scored !== "undefined" && scored.length > 0) {
|
|
103543
103746
|
skillsForIndex = scored.map((r) => r.skillPath);
|
|
103544
103747
|
}
|
|
103545
|
-
const formattedIndex =
|
|
103748
|
+
const formattedIndex = _internals50.formatSkillIndexWithContext(skillsForIndex, directory);
|
|
103546
103749
|
if (formattedIndex.length > 0) {
|
|
103547
103750
|
const contextPath = path105.join(directory, ".swarm", "context.md");
|
|
103548
103751
|
let existingContent = "";
|
|
103549
|
-
if (
|
|
103550
|
-
existingContent =
|
|
103752
|
+
if (_internals50.existsSync(contextPath)) {
|
|
103753
|
+
existingContent = _internals50.readFileSync(contextPath, "utf-8");
|
|
103551
103754
|
}
|
|
103552
103755
|
const sectionHeader = "## Available Skills";
|
|
103553
103756
|
const newSection = `${sectionHeader}
|
|
@@ -103567,10 +103770,10 @@ ${newSection}`;
|
|
|
103567
103770
|
}
|
|
103568
103771
|
}
|
|
103569
103772
|
const swarmDir = path105.dirname(contextPath);
|
|
103570
|
-
if (!
|
|
103571
|
-
|
|
103773
|
+
if (!_internals50.existsSync(swarmDir)) {
|
|
103774
|
+
_internals50.mkdirSync(swarmDir, { recursive: true });
|
|
103572
103775
|
}
|
|
103573
|
-
|
|
103776
|
+
_internals50.writeFileSync(contextPath, updatedContent, "utf-8");
|
|
103574
103777
|
}
|
|
103575
103778
|
} catch (err2) {
|
|
103576
103779
|
warn(`[skill-propagation-gate] failed to write skill index to context.md: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
@@ -103596,7 +103799,7 @@ ${newSection}`;
|
|
|
103596
103799
|
});
|
|
103597
103800
|
const warningMsg = `Skill propagation warning: Delegating to ${targetBase} without SKILLS field. ` + `Available skills: ${skillNames.join(", ")}`;
|
|
103598
103801
|
try {
|
|
103599
|
-
|
|
103802
|
+
_internals50.writeWarnEvent(directory, {
|
|
103600
103803
|
type: "skill_propagation_warn",
|
|
103601
103804
|
timestamp: new Date().toISOString(),
|
|
103602
103805
|
tool: toolName,
|
|
@@ -103625,7 +103828,7 @@ async function skillPropagationTransformScan(directory, output, sessionID) {
|
|
|
103625
103828
|
let dedupKeys = new Set;
|
|
103626
103829
|
let existingEntries = [];
|
|
103627
103830
|
try {
|
|
103628
|
-
existingEntries =
|
|
103831
|
+
existingEntries = _internals50.readSkillUsageEntriesTail(directory, {
|
|
103629
103832
|
sessionID
|
|
103630
103833
|
});
|
|
103631
103834
|
dedupKeys = new Set(existingEntries.map((e, i2) => {
|
|
@@ -103657,7 +103860,7 @@ async function skillPropagationTransformScan(directory, output, sessionID) {
|
|
|
103657
103860
|
`)) {
|
|
103658
103861
|
const coderMatch = line.trim().match(CODER_SKILLS_PATTERN);
|
|
103659
103862
|
if (coderMatch) {
|
|
103660
|
-
const parsed =
|
|
103863
|
+
const parsed = _internals50.parseSkillPaths(coderMatch[1]);
|
|
103661
103864
|
skillPaths.push(...parsed);
|
|
103662
103865
|
}
|
|
103663
103866
|
}
|
|
@@ -103688,7 +103891,7 @@ async function skillPropagationTransformScan(directory, output, sessionID) {
|
|
|
103688
103891
|
if (isDuplicate(skillPath, "reviewer", resolvedTaskID))
|
|
103689
103892
|
continue;
|
|
103690
103893
|
try {
|
|
103691
|
-
|
|
103894
|
+
_internals50.appendSkillUsageEntry(directory, {
|
|
103692
103895
|
skillPath,
|
|
103693
103896
|
agentName: "reviewer",
|
|
103694
103897
|
taskID: resolvedTaskID,
|
|
@@ -103732,15 +103935,15 @@ async function skillPropagationTransformScan(directory, output, sessionID) {
|
|
|
103732
103935
|
skillsField = trimmed.slice("SKILLS:".length).trim();
|
|
103733
103936
|
}
|
|
103734
103937
|
if (currentTargetAgent && skillsField && skillsField.toLowerCase() !== "none") {
|
|
103735
|
-
const skillPaths =
|
|
103736
|
-
const taskId =
|
|
103938
|
+
const skillPaths = _internals50.parseSkillPaths(skillsField);
|
|
103939
|
+
const taskId = _internals50.extractTaskIdFromPrompt(text);
|
|
103737
103940
|
for (const skillPath of skillPaths) {
|
|
103738
103941
|
if (hadRecordingError)
|
|
103739
103942
|
break;
|
|
103740
103943
|
if (isDuplicate(skillPath, currentTargetAgent, taskId))
|
|
103741
103944
|
continue;
|
|
103742
103945
|
try {
|
|
103743
|
-
|
|
103946
|
+
_internals50.appendSkillUsageEntry(directory, {
|
|
103744
103947
|
skillPath,
|
|
103745
103948
|
agentName: currentTargetAgent,
|
|
103746
103949
|
taskID: taskId,
|
|
@@ -103760,16 +103963,16 @@ async function skillPropagationTransformScan(directory, output, sessionID) {
|
|
|
103760
103963
|
break;
|
|
103761
103964
|
}
|
|
103762
103965
|
}
|
|
103763
|
-
|
|
103764
|
-
|
|
103765
|
-
|
|
103766
|
-
|
|
103767
|
-
|
|
103768
|
-
|
|
103769
|
-
|
|
103770
|
-
|
|
103771
|
-
|
|
103772
|
-
|
|
103966
|
+
_internals50.skillPropagationGateBefore = skillPropagationGateBefore;
|
|
103967
|
+
_internals50.skillPropagationTransformScan = skillPropagationTransformScan;
|
|
103968
|
+
_internals50.writeWarnEvent = writeWarnEvent2;
|
|
103969
|
+
_internals50.discoverAvailableSkills = discoverAvailableSkills;
|
|
103970
|
+
_internals50.parseDelegationArgs = parseDelegationArgs;
|
|
103971
|
+
_internals50.parseSkillPaths = parseSkillPaths;
|
|
103972
|
+
_internals50.extractTaskIdFromPrompt = extractTaskIdFromPrompt;
|
|
103973
|
+
_internals50.extractSkillsFieldFromPrompt = extractSkillsFieldFromPrompt;
|
|
103974
|
+
_internals50.formatSkillIndexWithContext = formatSkillIndexWithContext;
|
|
103975
|
+
_internals50.loadRoutingSkills = loadRoutingSkills;
|
|
103773
103976
|
|
|
103774
103977
|
// src/index.ts
|
|
103775
103978
|
init_skill_usage_log();
|
|
@@ -107061,7 +107264,7 @@ var EVIDENCE_DIR2 = ".swarm/evidence";
|
|
|
107061
107264
|
var VALID_TASK_ID = /^\d+\.\d+(\.\d+)*$/;
|
|
107062
107265
|
var COUNCIL_GATE_NAME = "council";
|
|
107063
107266
|
var COUNCIL_AGENT_ID = "architect";
|
|
107064
|
-
var
|
|
107267
|
+
var _internals51 = {
|
|
107065
107268
|
withTaskEvidenceLock
|
|
107066
107269
|
};
|
|
107067
107270
|
var FORBIDDEN_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
@@ -107096,7 +107299,7 @@ async function writeCouncilEvidence(workingDir, synthesis) {
|
|
|
107096
107299
|
const dir = join95(workingDir, EVIDENCE_DIR2);
|
|
107097
107300
|
mkdirSync28(dir, { recursive: true });
|
|
107098
107301
|
const filePath = taskEvidencePath(workingDir, synthesis.taskId);
|
|
107099
|
-
await
|
|
107302
|
+
await _internals51.withTaskEvidenceLock(workingDir, synthesis.taskId, COUNCIL_AGENT_ID, async () => {
|
|
107100
107303
|
const existingRoot = Object.create(null);
|
|
107101
107304
|
if (existsSync63(filePath)) {
|
|
107102
107305
|
try {
|
|
@@ -110737,7 +110940,8 @@ var knowledge_receipt = createSwarmTool({
|
|
|
110737
110940
|
for (const item of newLessons) {
|
|
110738
110941
|
const raw = await knowledge_add.execute({ lesson: item.lesson, category: item.category }, ctx);
|
|
110739
110942
|
try {
|
|
110740
|
-
|
|
110943
|
+
const output = typeof raw === "string" ? raw : typeof raw === "object" && raw !== null && ("output" in raw) && typeof raw.output === "string" ? raw.output : "";
|
|
110944
|
+
newLessonResults.push(JSON.parse(output));
|
|
110741
110945
|
} catch {
|
|
110742
110946
|
newLessonResults.push({ success: false });
|
|
110743
110947
|
}
|
|
@@ -111200,7 +111404,7 @@ function listLaneEvidenceSync(directory, phase) {
|
|
|
111200
111404
|
}
|
|
111201
111405
|
return laneIds;
|
|
111202
111406
|
}
|
|
111203
|
-
var
|
|
111407
|
+
var _internals52 = {
|
|
111204
111408
|
listActiveLocks,
|
|
111205
111409
|
readPersisted: readPersisted2,
|
|
111206
111410
|
readPlanJson: defaultReadPlanJson,
|
|
@@ -111261,7 +111465,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
111261
111465
|
reason: "Lean Turbo state unreadable or missing"
|
|
111262
111466
|
};
|
|
111263
111467
|
}
|
|
111264
|
-
const persisted =
|
|
111468
|
+
const persisted = _internals52.readPersisted(directory);
|
|
111265
111469
|
if (!persisted) {
|
|
111266
111470
|
return {
|
|
111267
111471
|
ok: false,
|
|
@@ -111325,7 +111529,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
111325
111529
|
}
|
|
111326
111530
|
}
|
|
111327
111531
|
if (runState.lanes.length > 0) {
|
|
111328
|
-
const evidenceLaneIds = new Set(
|
|
111532
|
+
const evidenceLaneIds = new Set(_internals52.listLaneEvidenceSync(directory, phase));
|
|
111329
111533
|
for (const lane of runState.lanes) {
|
|
111330
111534
|
if ((lane.status === "completed" || lane.status === "failed") && !evidenceLaneIds.has(lane.laneId)) {
|
|
111331
111535
|
return {
|
|
@@ -111335,7 +111539,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
111335
111539
|
}
|
|
111336
111540
|
}
|
|
111337
111541
|
}
|
|
111338
|
-
const activeLocks =
|
|
111542
|
+
const activeLocks = _internals52.listActiveLocks(directory);
|
|
111339
111543
|
const phaseLaneIds = new Set(laneIds);
|
|
111340
111544
|
for (const lock of activeLocks) {
|
|
111341
111545
|
if (lock.laneId && phaseLaneIds.has(lock.laneId)) {
|
|
@@ -111355,7 +111559,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
111355
111559
|
}
|
|
111356
111560
|
const serialDegradedTasks = runState.degradedTasks.filter((dt) => !laneTaskIds.has(dt.taskId));
|
|
111357
111561
|
if (serialDegradedTasks.length > 0) {
|
|
111358
|
-
const plan =
|
|
111562
|
+
const plan = _internals52.readPlanJson(directory);
|
|
111359
111563
|
if (!plan) {
|
|
111360
111564
|
return {
|
|
111361
111565
|
ok: false,
|
|
@@ -111399,7 +111603,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
111399
111603
|
}
|
|
111400
111604
|
const serializedTasks = runState.serializedTasks;
|
|
111401
111605
|
if (Array.isArray(serializedTasks) && serializedTasks.length > 0) {
|
|
111402
|
-
const plan =
|
|
111606
|
+
const plan = _internals52.readPlanJson(directory);
|
|
111403
111607
|
if (!plan) {
|
|
111404
111608
|
return {
|
|
111405
111609
|
ok: false,
|
|
@@ -111458,7 +111662,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
111458
111662
|
}
|
|
111459
111663
|
let reviewerVerdict = runState.lastReviewerVerdict;
|
|
111460
111664
|
if (!reviewerVerdict) {
|
|
111461
|
-
const evidence =
|
|
111665
|
+
const evidence = _internals52.readReviewerEvidence(directory, phase);
|
|
111462
111666
|
reviewerVerdict = evidence?.verdict ?? undefined;
|
|
111463
111667
|
}
|
|
111464
111668
|
if (mergedConfig.phase_reviewer) {
|
|
@@ -111471,7 +111675,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
111471
111675
|
}
|
|
111472
111676
|
let criticVerdict = runState.lastCriticVerdict;
|
|
111473
111677
|
if (!criticVerdict) {
|
|
111474
|
-
const evidence =
|
|
111678
|
+
const evidence = _internals52.readCriticEvidence(directory, phase);
|
|
111475
111679
|
criticVerdict = evidence?.verdict ?? undefined;
|
|
111476
111680
|
}
|
|
111477
111681
|
if (mergedConfig.phase_critic) {
|
|
@@ -112449,7 +112653,7 @@ Findings: ${details.join("; ")}` : "";
|
|
|
112449
112653
|
phase_critic: leanConfig.phase_critic,
|
|
112450
112654
|
integrated_diff_required: leanConfig.integrated_diff_required
|
|
112451
112655
|
} : undefined;
|
|
112452
|
-
const leanCheck =
|
|
112656
|
+
const leanCheck = _internals52.verifyLeanTurboPhaseReady(dir, phase, sessionID, leanPhaseReadyConfig);
|
|
112453
112657
|
if (!leanCheck.ok) {
|
|
112454
112658
|
return JSON.stringify({
|
|
112455
112659
|
success: false,
|
|
@@ -114667,11 +114871,11 @@ var quality_budget = createSwarmTool({
|
|
|
114667
114871
|
}).optional().describe("Quality budget thresholds")
|
|
114668
114872
|
},
|
|
114669
114873
|
async execute(args2, directory) {
|
|
114670
|
-
const result = await
|
|
114874
|
+
const result = await _internals53.qualityBudget(args2, directory);
|
|
114671
114875
|
return JSON.stringify(result);
|
|
114672
114876
|
}
|
|
114673
114877
|
});
|
|
114674
|
-
var
|
|
114878
|
+
var _internals53 = {
|
|
114675
114879
|
qualityBudget
|
|
114676
114880
|
};
|
|
114677
114881
|
|
|
@@ -115400,7 +115604,7 @@ import * as path129 from "node:path";
|
|
|
115400
115604
|
var semgrepAvailableCache = null;
|
|
115401
115605
|
var DEFAULT_RULES_DIR = ".swarm/semgrep-rules";
|
|
115402
115606
|
var DEFAULT_TIMEOUT_MS3 = 30000;
|
|
115403
|
-
var
|
|
115607
|
+
var _internals54 = {
|
|
115404
115608
|
isSemgrepAvailable,
|
|
115405
115609
|
checkSemgrepAvailable,
|
|
115406
115610
|
resetSemgrepCache,
|
|
@@ -115425,7 +115629,7 @@ function isSemgrepAvailable() {
|
|
|
115425
115629
|
}
|
|
115426
115630
|
}
|
|
115427
115631
|
async function checkSemgrepAvailable() {
|
|
115428
|
-
return
|
|
115632
|
+
return _internals54.isSemgrepAvailable();
|
|
115429
115633
|
}
|
|
115430
115634
|
function resetSemgrepCache() {
|
|
115431
115635
|
semgrepAvailableCache = null;
|
|
@@ -115522,12 +115726,12 @@ async function runSemgrep(options) {
|
|
|
115522
115726
|
const timeoutMs = options.timeoutMs || DEFAULT_TIMEOUT_MS3;
|
|
115523
115727
|
if (files.length === 0) {
|
|
115524
115728
|
return {
|
|
115525
|
-
available:
|
|
115729
|
+
available: _internals54.isSemgrepAvailable(),
|
|
115526
115730
|
findings: [],
|
|
115527
115731
|
engine: "tier_a"
|
|
115528
115732
|
};
|
|
115529
115733
|
}
|
|
115530
|
-
if (!
|
|
115734
|
+
if (!_internals54.isSemgrepAvailable()) {
|
|
115531
115735
|
return {
|
|
115532
115736
|
available: false,
|
|
115533
115737
|
findings: [],
|
|
@@ -115686,7 +115890,7 @@ function assignOccurrenceIndices(findings, directory) {
|
|
|
115686
115890
|
}
|
|
115687
115891
|
const occIdx = countMap.get(baseKey) ?? 0;
|
|
115688
115892
|
countMap.set(baseKey, occIdx + 1);
|
|
115689
|
-
const fp =
|
|
115893
|
+
const fp = _internals55.fingerprintFinding(finding, directory, occIdx);
|
|
115690
115894
|
return {
|
|
115691
115895
|
finding,
|
|
115692
115896
|
index: occIdx,
|
|
@@ -115755,7 +115959,7 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
115755
115959
|
}
|
|
115756
115960
|
} catch {}
|
|
115757
115961
|
const scannedRelFiles = new Set(scannedFiles.map((f) => normalizeFindingPath(directory, f)));
|
|
115758
|
-
const indexed =
|
|
115962
|
+
const indexed = _internals55.assignOccurrenceIndices(findings, directory);
|
|
115759
115963
|
if (existing && !opts?.force) {
|
|
115760
115964
|
const prunedFingerprints = existing.fingerprints.filter((fp) => {
|
|
115761
115965
|
const relFile = fp.slice(0, fp.indexOf("|"));
|
|
@@ -115895,7 +116099,7 @@ function loadBaseline(directory, phase) {
|
|
|
115895
116099
|
};
|
|
115896
116100
|
}
|
|
115897
116101
|
}
|
|
115898
|
-
var
|
|
116102
|
+
var _internals55 = {
|
|
115899
116103
|
fingerprintFinding,
|
|
115900
116104
|
assignOccurrenceIndices,
|
|
115901
116105
|
captureOrMergeBaseline,
|
|
@@ -116305,11 +116509,11 @@ var sast_scan = createSwarmTool({
|
|
|
116305
116509
|
capture_baseline: safeArgs.capture_baseline,
|
|
116306
116510
|
phase: safeArgs.phase
|
|
116307
116511
|
};
|
|
116308
|
-
const result = await
|
|
116512
|
+
const result = await _internals56.sastScan(input, directory);
|
|
116309
116513
|
return JSON.stringify(result, null, 2);
|
|
116310
116514
|
}
|
|
116311
116515
|
});
|
|
116312
|
-
var
|
|
116516
|
+
var _internals56 = {
|
|
116313
116517
|
sastScan,
|
|
116314
116518
|
sast_scan
|
|
116315
116519
|
};
|
|
@@ -120232,7 +120436,7 @@ init_zod();
|
|
|
120232
120436
|
init_config();
|
|
120233
120437
|
init_schema();
|
|
120234
120438
|
init_create_tool();
|
|
120235
|
-
import { mkdir as mkdir23, rename as rename9, writeFile as
|
|
120439
|
+
import { mkdir as mkdir23, rename as rename9, writeFile as writeFile18 } from "node:fs/promises";
|
|
120236
120440
|
import * as path139 from "node:path";
|
|
120237
120441
|
var MAX_SPEC_BYTES = 256 * 1024;
|
|
120238
120442
|
var spec_write = createSwarmTool({
|
|
@@ -120294,7 +120498,7 @@ ${content}
|
|
|
120294
120498
|
}
|
|
120295
120499
|
} catch {}
|
|
120296
120500
|
}
|
|
120297
|
-
await
|
|
120501
|
+
await writeFile18(tmp, finalContent, "utf-8");
|
|
120298
120502
|
await rename9(tmp, target);
|
|
120299
120503
|
return JSON.stringify({ written: true, path: target, bytes: finalContent.length }, null, 2);
|
|
120300
120504
|
}
|
|
@@ -120726,7 +120930,7 @@ var swarm_memory_propose = createSwarmTool({
|
|
|
120726
120930
|
evidenceRefs: exports_external.array(exports_external.string().min(1).max(500)).max(20).optional().describe("Evidence refs such as files, commits, test outputs, or URLs")
|
|
120727
120931
|
},
|
|
120728
120932
|
execute: async (args2, directory, ctx) => {
|
|
120729
|
-
const { config: config3 } =
|
|
120933
|
+
const { config: config3 } = _internals57.loadPluginConfigWithMeta(directory);
|
|
120730
120934
|
if (config3.memory?.enabled !== true) {
|
|
120731
120935
|
return JSON.stringify({
|
|
120732
120936
|
success: false,
|
|
@@ -120742,7 +120946,7 @@ var swarm_memory_propose = createSwarmTool({
|
|
|
120742
120946
|
});
|
|
120743
120947
|
}
|
|
120744
120948
|
const agent = getContextAgent2(ctx);
|
|
120745
|
-
const gateway =
|
|
120949
|
+
const gateway = _internals57.createMemoryGateway({
|
|
120746
120950
|
directory,
|
|
120747
120951
|
sessionID: ctx?.sessionID,
|
|
120748
120952
|
agentRole: agent,
|
|
@@ -120767,7 +120971,7 @@ var swarm_memory_propose = createSwarmTool({
|
|
|
120767
120971
|
}
|
|
120768
120972
|
}
|
|
120769
120973
|
});
|
|
120770
|
-
var
|
|
120974
|
+
var _internals57 = {
|
|
120771
120975
|
loadPluginConfigWithMeta,
|
|
120772
120976
|
createMemoryGateway
|
|
120773
120977
|
};
|
|
@@ -120804,7 +121008,7 @@ var swarm_memory_recall = createSwarmTool({
|
|
|
120804
121008
|
maxItems: exports_external.number().int().min(1).max(20).optional().describe("Maximum memories to return")
|
|
120805
121009
|
},
|
|
120806
121010
|
execute: async (args2, directory, ctx) => {
|
|
120807
|
-
const { config: config3 } =
|
|
121011
|
+
const { config: config3 } = _internals58.loadPluginConfigWithMeta(directory);
|
|
120808
121012
|
if (config3.memory?.enabled !== true) {
|
|
120809
121013
|
return JSON.stringify({
|
|
120810
121014
|
success: false,
|
|
@@ -120820,7 +121024,7 @@ var swarm_memory_recall = createSwarmTool({
|
|
|
120820
121024
|
});
|
|
120821
121025
|
}
|
|
120822
121026
|
const agent = getContextAgent3(ctx);
|
|
120823
|
-
const gateway =
|
|
121027
|
+
const gateway = _internals58.createMemoryGateway({
|
|
120824
121028
|
directory,
|
|
120825
121029
|
sessionID: ctx?.sessionID,
|
|
120826
121030
|
agentRole: agent,
|
|
@@ -120853,7 +121057,7 @@ var RecallArgsSchema = exports_external.object({
|
|
|
120853
121057
|
kinds: exports_external.array(exports_external.enum(MEMORY_KINDS2)).optional(),
|
|
120854
121058
|
maxItems: exports_external.number().int().min(1).max(20).optional()
|
|
120855
121059
|
});
|
|
120856
|
-
var
|
|
121060
|
+
var _internals58 = {
|
|
120857
121061
|
loadPluginConfigWithMeta,
|
|
120858
121062
|
createMemoryGateway
|
|
120859
121063
|
};
|
|
@@ -122098,7 +122302,7 @@ function resolveDefaultReviewerAgent(generatedAgentNames) {
|
|
|
122098
122302
|
}
|
|
122099
122303
|
async function compileReviewPackage(directory, phase, sessionID, requireDiffSummary) {
|
|
122100
122304
|
const lanes = await listLaneEvidence(directory, phase);
|
|
122101
|
-
const persisted =
|
|
122305
|
+
const persisted = _internals59.readPersisted?.(directory) ?? null;
|
|
122102
122306
|
if (persisted) {
|
|
122103
122307
|
let matchingRunState = null;
|
|
122104
122308
|
for (const sessionState of Object.values(persisted.sessions)) {
|
|
@@ -122290,7 +122494,7 @@ Be specific and evidence-based. Do not approve a phase with unresolved degraded
|
|
|
122290
122494
|
client.session.delete({ path: { id: sessionId } }).catch(() => {});
|
|
122291
122495
|
}
|
|
122292
122496
|
}
|
|
122293
|
-
var
|
|
122497
|
+
var _internals59 = {
|
|
122294
122498
|
compileReviewPackage,
|
|
122295
122499
|
parseReviewerVerdict,
|
|
122296
122500
|
writeReviewerEvidence,
|
|
@@ -122307,28 +122511,28 @@ async function dispatchPhaseReviewer(directory, phase, sessionID, config3) {
|
|
|
122307
122511
|
};
|
|
122308
122512
|
const generatedAgentNames = swarmState.generatedAgentNames;
|
|
122309
122513
|
const agentName = mergedConfig.reviewerAgent || resolveDefaultReviewerAgent(generatedAgentNames);
|
|
122310
|
-
const pkg = await
|
|
122514
|
+
const pkg = await _internals59.compileReviewPackage(directory, phase, sessionID, mergedConfig.requireDiffSummary);
|
|
122311
122515
|
let responseText;
|
|
122312
122516
|
try {
|
|
122313
|
-
responseText = await
|
|
122517
|
+
responseText = await _internals59.dispatchReviewerAgent(directory, pkg, agentName, mergedConfig.timeoutMs);
|
|
122314
122518
|
} catch (error93) {
|
|
122315
|
-
const evidencePath2 = await
|
|
122519
|
+
const evidencePath2 = await _internals59.writeReviewerEvidence(directory, phase, "REJECTED", error93 instanceof Error ? error93.message : String(error93));
|
|
122316
122520
|
return {
|
|
122317
122521
|
verdict: "REJECTED",
|
|
122318
122522
|
reason: `Reviewer dispatch failed: ${error93 instanceof Error ? error93.message : String(error93)}`,
|
|
122319
122523
|
evidencePath: evidencePath2
|
|
122320
122524
|
};
|
|
122321
122525
|
}
|
|
122322
|
-
const parsed =
|
|
122526
|
+
const parsed = _internals59.parseReviewerVerdict(responseText);
|
|
122323
122527
|
if (!parsed) {
|
|
122324
|
-
const evidencePath2 = await
|
|
122528
|
+
const evidencePath2 = await _internals59.writeReviewerEvidence(directory, phase, "REJECTED", "Reviewer response could not be parsed");
|
|
122325
122529
|
return {
|
|
122326
122530
|
verdict: "REJECTED",
|
|
122327
122531
|
reason: "Reviewer response could not be parsed",
|
|
122328
122532
|
evidencePath: evidencePath2
|
|
122329
122533
|
};
|
|
122330
122534
|
}
|
|
122331
|
-
const evidencePath = await
|
|
122535
|
+
const evidencePath = await _internals59.writeReviewerEvidence(directory, phase, parsed.verdict, parsed.reason);
|
|
122332
122536
|
return {
|
|
122333
122537
|
verdict: parsed.verdict,
|
|
122334
122538
|
reason: parsed.reason,
|
|
@@ -122834,7 +123038,7 @@ ${fileList}
|
|
|
122834
123038
|
|
|
122835
123039
|
// src/tools/lean-turbo-run-phase.ts
|
|
122836
123040
|
init_create_tool();
|
|
122837
|
-
var
|
|
123041
|
+
var _internals60 = {
|
|
122838
123042
|
LeanTurboRunner,
|
|
122839
123043
|
loadPluginConfigWithMeta
|
|
122840
123044
|
};
|
|
@@ -122844,9 +123048,9 @@ async function executeLeanTurboRunPhase(args2) {
|
|
|
122844
123048
|
let runError = null;
|
|
122845
123049
|
let runner = null;
|
|
122846
123050
|
try {
|
|
122847
|
-
const { config: config3 } =
|
|
123051
|
+
const { config: config3 } = _internals60.loadPluginConfigWithMeta(directory);
|
|
122848
123052
|
const leanConfig = config3.turbo?.strategy === "lean" ? config3.turbo.lean : undefined;
|
|
122849
|
-
runner = new
|
|
123053
|
+
runner = new _internals60.LeanTurboRunner({
|
|
122850
123054
|
directory,
|
|
122851
123055
|
sessionID,
|
|
122852
123056
|
opencodeClient: swarmState.opencodeClient ?? null,
|
|
@@ -123200,7 +123404,7 @@ function isStaticallyEquivalent(originalCode, mutatedCode) {
|
|
|
123200
123404
|
const strippedMutated = stripCode(mutatedCode);
|
|
123201
123405
|
return strippedOriginal === strippedMutated;
|
|
123202
123406
|
}
|
|
123203
|
-
var
|
|
123407
|
+
var _internals61 = {
|
|
123204
123408
|
isStaticallyEquivalent,
|
|
123205
123409
|
checkEquivalence,
|
|
123206
123410
|
batchCheckEquivalence
|
|
@@ -123240,7 +123444,7 @@ async function batchCheckEquivalence(patches, llmJudge) {
|
|
|
123240
123444
|
const results = [];
|
|
123241
123445
|
for (const { patch, originalCode, mutatedCode } of patches) {
|
|
123242
123446
|
try {
|
|
123243
|
-
const result = await
|
|
123447
|
+
const result = await _internals61.checkEquivalence(patch, originalCode, mutatedCode, llmJudge);
|
|
123244
123448
|
results.push(result);
|
|
123245
123449
|
} catch (err3) {
|
|
123246
123450
|
results.push({
|
|
@@ -123259,7 +123463,7 @@ async function batchCheckEquivalence(patches, llmJudge) {
|
|
|
123259
123463
|
var MUTATION_TIMEOUT_MS = 30000;
|
|
123260
123464
|
var TOTAL_BUDGET_MS = 300000;
|
|
123261
123465
|
var GIT_APPLY_TIMEOUT_MS = 5000;
|
|
123262
|
-
var
|
|
123466
|
+
var _internals62 = {
|
|
123263
123467
|
executeMutation,
|
|
123264
123468
|
computeReport,
|
|
123265
123469
|
executeMutationSuite,
|
|
@@ -123291,7 +123495,7 @@ async function executeMutation(patch, testCommand, _testFiles, workingDir) {
|
|
|
123291
123495
|
};
|
|
123292
123496
|
}
|
|
123293
123497
|
try {
|
|
123294
|
-
const applyResult =
|
|
123498
|
+
const applyResult = _internals62.spawnSync("git", ["apply", "--", patchFile], {
|
|
123295
123499
|
cwd: workingDir,
|
|
123296
123500
|
timeout: GIT_APPLY_TIMEOUT_MS,
|
|
123297
123501
|
stdio: "pipe"
|
|
@@ -123320,7 +123524,7 @@ async function executeMutation(patch, testCommand, _testFiles, workingDir) {
|
|
|
123320
123524
|
}
|
|
123321
123525
|
let testPassed = false;
|
|
123322
123526
|
try {
|
|
123323
|
-
const spawnResult =
|
|
123527
|
+
const spawnResult = _internals62.spawnSync(testCommand[0], testCommand.slice(1), {
|
|
123324
123528
|
cwd: workingDir,
|
|
123325
123529
|
timeout: MUTATION_TIMEOUT_MS,
|
|
123326
123530
|
stdio: "pipe"
|
|
@@ -123353,7 +123557,7 @@ async function executeMutation(patch, testCommand, _testFiles, workingDir) {
|
|
|
123353
123557
|
} finally {
|
|
123354
123558
|
if (patchFile) {
|
|
123355
123559
|
try {
|
|
123356
|
-
const revertResult =
|
|
123560
|
+
const revertResult = _internals62.spawnSync("git", ["apply", "-R", "--", patchFile], {
|
|
123357
123561
|
cwd: workingDir,
|
|
123358
123562
|
timeout: GIT_APPLY_TIMEOUT_MS,
|
|
123359
123563
|
stdio: "pipe"
|
|
@@ -123546,7 +123750,7 @@ async function executeMutationSuite(patches, testCommand, testFiles, workingDir,
|
|
|
123546
123750
|
}
|
|
123547
123751
|
|
|
123548
123752
|
// src/mutation/gate.ts
|
|
123549
|
-
var
|
|
123753
|
+
var _internals63 = {
|
|
123550
123754
|
evaluateMutationGate,
|
|
123551
123755
|
buildTestImprovementPrompt,
|
|
123552
123756
|
buildMessage
|
|
@@ -123567,8 +123771,8 @@ function evaluateMutationGate(report, passThreshold = PASS_THRESHOLD, warnThresh
|
|
|
123567
123771
|
} else {
|
|
123568
123772
|
verdict = "fail";
|
|
123569
123773
|
}
|
|
123570
|
-
const testImprovementPrompt =
|
|
123571
|
-
const message =
|
|
123774
|
+
const testImprovementPrompt = _internals63.buildTestImprovementPrompt(report, passThreshold, verdict);
|
|
123775
|
+
const message = _internals63.buildMessage(verdict, adjustedKillRate, report.killed, report.totalMutants, report.equivalent, warnThreshold);
|
|
123572
123776
|
return {
|
|
123573
123777
|
verdict,
|
|
123574
123778
|
killRate: report.killRate,
|
|
@@ -124195,7 +124399,7 @@ import * as path152 from "node:path";
|
|
|
124195
124399
|
init_bun_compat();
|
|
124196
124400
|
import * as fs109 from "node:fs";
|
|
124197
124401
|
import * as path151 from "node:path";
|
|
124198
|
-
var
|
|
124402
|
+
var _internals64 = { bunSpawn };
|
|
124199
124403
|
var _swarmGitExcludedChecked = false;
|
|
124200
124404
|
function fileCoversSwarm(content) {
|
|
124201
124405
|
for (const rawLine of content.split(`
|
|
@@ -124228,7 +124432,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
124228
124432
|
checkIgnoreExitCode
|
|
124229
124433
|
] = await Promise.all([
|
|
124230
124434
|
(async () => {
|
|
124231
|
-
const proc =
|
|
124435
|
+
const proc = _internals64.bunSpawn(["git", "-C", directory, "rev-parse", "--show-toplevel"], GIT_SPAWN_OPTIONS);
|
|
124232
124436
|
try {
|
|
124233
124437
|
return await Promise.all([proc.exited, proc.stdout.text()]);
|
|
124234
124438
|
} finally {
|
|
@@ -124238,7 +124442,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
124238
124442
|
}
|
|
124239
124443
|
})(),
|
|
124240
124444
|
(async () => {
|
|
124241
|
-
const proc =
|
|
124445
|
+
const proc = _internals64.bunSpawn(["git", "-C", directory, "rev-parse", "--git-path", "info/exclude"], GIT_SPAWN_OPTIONS);
|
|
124242
124446
|
try {
|
|
124243
124447
|
return await Promise.all([proc.exited, proc.stdout.text()]);
|
|
124244
124448
|
} finally {
|
|
@@ -124248,7 +124452,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
124248
124452
|
}
|
|
124249
124453
|
})(),
|
|
124250
124454
|
(async () => {
|
|
124251
|
-
const proc =
|
|
124455
|
+
const proc = _internals64.bunSpawn(["git", "-C", directory, "check-ignore", "-q", ".swarm/.gitkeep"], GIT_SPAWN_OPTIONS);
|
|
124252
124456
|
try {
|
|
124253
124457
|
return await proc.exited;
|
|
124254
124458
|
} finally {
|
|
@@ -124287,7 +124491,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
124287
124491
|
}
|
|
124288
124492
|
} catch {}
|
|
124289
124493
|
}
|
|
124290
|
-
const trackedProc =
|
|
124494
|
+
const trackedProc = _internals64.bunSpawn(["git", "-C", directory, "ls-files", "--", ".swarm"], GIT_SPAWN_OPTIONS);
|
|
124291
124495
|
let trackedExitCode;
|
|
124292
124496
|
let trackedOutput;
|
|
124293
124497
|
try {
|
|
@@ -124312,7 +124516,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
124312
124516
|
}
|
|
124313
124517
|
|
|
124314
124518
|
// src/hooks/diff-scope.ts
|
|
124315
|
-
var
|
|
124519
|
+
var _internals65 = { bunSpawn };
|
|
124316
124520
|
function getDeclaredScope(taskId, directory) {
|
|
124317
124521
|
try {
|
|
124318
124522
|
const planPath = path152.join(directory, ".swarm", "plan.json");
|
|
@@ -124347,7 +124551,7 @@ var GIT_DIFF_SPAWN_OPTIONS = {
|
|
|
124347
124551
|
};
|
|
124348
124552
|
async function getChangedFiles(directory) {
|
|
124349
124553
|
try {
|
|
124350
|
-
const proc =
|
|
124554
|
+
const proc = _internals65.bunSpawn(["git", "diff", "--name-only", "HEAD~1"], {
|
|
124351
124555
|
cwd: directory,
|
|
124352
124556
|
...GIT_DIFF_SPAWN_OPTIONS
|
|
124353
124557
|
});
|
|
@@ -124364,7 +124568,7 @@ async function getChangedFiles(directory) {
|
|
|
124364
124568
|
return stdout.trim().split(`
|
|
124365
124569
|
`).map((f) => f.trim()).filter((f) => f.length > 0);
|
|
124366
124570
|
}
|
|
124367
|
-
const proc2 =
|
|
124571
|
+
const proc2 = _internals65.bunSpawn(["git", "diff", "--name-only", "HEAD"], {
|
|
124368
124572
|
cwd: directory,
|
|
124369
124573
|
...GIT_DIFF_SPAWN_OPTIONS
|
|
124370
124574
|
});
|
|
@@ -124422,7 +124626,7 @@ init_telemetry();
|
|
|
124422
124626
|
init_file_locks();
|
|
124423
124627
|
import * as fs111 from "node:fs";
|
|
124424
124628
|
import * as path153 from "node:path";
|
|
124425
|
-
var
|
|
124629
|
+
var _internals66 = {
|
|
124426
124630
|
listActiveLocks,
|
|
124427
124631
|
verifyLeanTurboTaskCompletion
|
|
124428
124632
|
};
|
|
@@ -124564,7 +124768,7 @@ function verifyLeanTurboTaskCompletion(directory, taskId, sessionID) {
|
|
|
124564
124768
|
}
|
|
124565
124769
|
};
|
|
124566
124770
|
}
|
|
124567
|
-
const activeLocks =
|
|
124771
|
+
const activeLocks = _internals66.listActiveLocks(directory);
|
|
124568
124772
|
const laneLocks = activeLocks.filter((lock) => lock.laneId === lane.laneId);
|
|
124569
124773
|
if (laneLocks.length > 0) {
|
|
124570
124774
|
return {
|
|
@@ -125493,7 +125697,7 @@ var web_search = createSwarmTool({
|
|
|
125493
125697
|
});
|
|
125494
125698
|
async function captureSearchEvidence(directory, query, results) {
|
|
125495
125699
|
try {
|
|
125496
|
-
const written = await
|
|
125700
|
+
const written = await _internals67.writeEvidenceDocuments(directory, results.map((result) => ({
|
|
125497
125701
|
sourceType: "web_search",
|
|
125498
125702
|
query,
|
|
125499
125703
|
title: result.title,
|
|
@@ -125521,7 +125725,7 @@ async function captureSearchEvidence(directory, query, results) {
|
|
|
125521
125725
|
};
|
|
125522
125726
|
}
|
|
125523
125727
|
}
|
|
125524
|
-
var
|
|
125728
|
+
var _internals67 = {
|
|
125525
125729
|
writeEvidenceDocuments
|
|
125526
125730
|
};
|
|
125527
125731
|
// src/tools/write-drift-evidence.ts
|