opencode-swarm 7.87.2 → 7.87.3
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/{guardrail-explain-9fngqx80.js → guardrail-explain-2q9myk7c.js} +3 -3
- package/dist/cli/{index-s8bj492g.js → index-32axfg6h.js} +23 -7
- package/dist/cli/{index-f41fa3f0.js → index-amwa268r.js} +1 -1
- package/dist/cli/{index-6qkwgdsg.js → index-kz1bmebr.js} +241 -164
- package/dist/cli/{index-gjdq4na6.js → index-r3f47swm.js} +3 -3
- package/dist/cli/index.js +2 -2
- package/dist/cli/{skill-generator-3pvpk4y2.js → skill-generator-kz4q8e49.js} +3 -1
- package/dist/hooks/knowledge-reader.d.ts +2 -0
- package/dist/hooks/knowledge-types.d.ts +3 -0
- package/dist/index.js +626 -554
- package/dist/services/skill-generator.d.ts +10 -0
- package/dist/services/skill-improver.d.ts +25 -1
- package/package.json +1 -1
|
@@ -11,14 +11,16 @@ import {
|
|
|
11
11
|
quarantineEntry,
|
|
12
12
|
readKnowledgeCounterRollups,
|
|
13
13
|
readKnowledgeEvents,
|
|
14
|
+
regenerateSkill,
|
|
14
15
|
resolveKnowledgeEventsPath,
|
|
15
16
|
resolveUnactionablePath,
|
|
16
17
|
restoreEntry,
|
|
18
|
+
retireSkill,
|
|
17
19
|
selectCandidateEntries,
|
|
18
20
|
validateActionability,
|
|
19
21
|
validateActionableFields,
|
|
20
22
|
validateLesson
|
|
21
|
-
} from "./index-
|
|
23
|
+
} from "./index-32axfg6h.js";
|
|
22
24
|
import {
|
|
23
25
|
appendKnowledge,
|
|
24
26
|
appendRejectedLesson,
|
|
@@ -897,7 +899,7 @@ var init_executor = __esm(() => {
|
|
|
897
899
|
// package.json
|
|
898
900
|
var package_default = {
|
|
899
901
|
name: "opencode-swarm",
|
|
900
|
-
version: "7.87.
|
|
902
|
+
version: "7.87.3",
|
|
901
903
|
description: "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
|
|
902
904
|
main: "dist/index.js",
|
|
903
905
|
types: "dist/index.d.ts",
|
|
@@ -9929,6 +9931,9 @@ ${userInput}` : userInput;
|
|
|
9929
9931
|
};
|
|
9930
9932
|
}
|
|
9931
9933
|
|
|
9934
|
+
// src/services/skill-improver.ts
|
|
9935
|
+
init_logger();
|
|
9936
|
+
|
|
9932
9937
|
// src/services/trajectory-cluster.ts
|
|
9933
9938
|
import { mkdir as mkdir6, writeFile as writeFile6 } from "fs/promises";
|
|
9934
9939
|
import * as path22 from "path";
|
|
@@ -10357,7 +10362,14 @@ async function gatherInventory(directory) {
|
|
|
10357
10362
|
continue;
|
|
10358
10363
|
}
|
|
10359
10364
|
const fm = parseDraftFrontmatter(content);
|
|
10360
|
-
if (!fm)
|
|
10365
|
+
if (!fm) {
|
|
10366
|
+
staleActiveSkills.push({
|
|
10367
|
+
slug: skill.slug,
|
|
10368
|
+
reasons: ["unparseable_frontmatter"]
|
|
10369
|
+
});
|
|
10370
|
+
continue;
|
|
10371
|
+
}
|
|
10372
|
+
if (fm.skillOrigin === "shim")
|
|
10361
10373
|
continue;
|
|
10362
10374
|
metadataReadable += 1;
|
|
10363
10375
|
const reasons = [];
|
|
@@ -10505,6 +10517,59 @@ function buildLLMProposalFrame(args) {
|
|
|
10505
10517
|
return lines.join(`
|
|
10506
10518
|
`);
|
|
10507
10519
|
}
|
|
10520
|
+
async function reconcileStaleActiveSkills(directory, options = {}) {
|
|
10521
|
+
const result = {
|
|
10522
|
+
regenerated: [],
|
|
10523
|
+
retired: [],
|
|
10524
|
+
skipped: [],
|
|
10525
|
+
checked: 0
|
|
10526
|
+
};
|
|
10527
|
+
let skills;
|
|
10528
|
+
try {
|
|
10529
|
+
skills = await listSkills(directory);
|
|
10530
|
+
} catch {
|
|
10531
|
+
return result;
|
|
10532
|
+
}
|
|
10533
|
+
for (const skill of skills.active) {
|
|
10534
|
+
let content;
|
|
10535
|
+
try {
|
|
10536
|
+
content = await readFile7(skill.path, "utf-8");
|
|
10537
|
+
} catch {
|
|
10538
|
+
continue;
|
|
10539
|
+
}
|
|
10540
|
+
const fm = parseDraftFrontmatter(content);
|
|
10541
|
+
if (fm?.skillOrigin === "shim") {
|
|
10542
|
+
result.skipped.push(skill.slug);
|
|
10543
|
+
continue;
|
|
10544
|
+
}
|
|
10545
|
+
const stale = !fm || fm.sourceKnowledgeIds.length === 0 || !fm.generatedAt;
|
|
10546
|
+
if (!stale)
|
|
10547
|
+
continue;
|
|
10548
|
+
result.checked += 1;
|
|
10549
|
+
if (options.dryRun) {
|
|
10550
|
+
result.retired.push(skill.slug);
|
|
10551
|
+
continue;
|
|
10552
|
+
}
|
|
10553
|
+
try {
|
|
10554
|
+
const regen = await _internals18.regenerateSkill(directory, skill.slug, {
|
|
10555
|
+
evaluate: false
|
|
10556
|
+
});
|
|
10557
|
+
if (regen.regenerated) {
|
|
10558
|
+
result.regenerated.push(skill.slug);
|
|
10559
|
+
} else if (regen.retired) {
|
|
10560
|
+
result.retired.push(skill.slug);
|
|
10561
|
+
} else {
|
|
10562
|
+
const retire = await retireSkill(directory, skill.slug, "stale_no_source_knowledge");
|
|
10563
|
+
if (retire.retired)
|
|
10564
|
+
result.retired.push(skill.slug);
|
|
10565
|
+
}
|
|
10566
|
+
} catch (err) {
|
|
10567
|
+
warn(`[skill-improver] reconcileStaleActiveSkills: failed to reconcile '${skill.slug}': ${err instanceof Error ? err.message : String(err)}`);
|
|
10568
|
+
result.skipped.push(skill.slug);
|
|
10569
|
+
}
|
|
10570
|
+
}
|
|
10571
|
+
return result;
|
|
10572
|
+
}
|
|
10508
10573
|
async function runSkillImprover(req) {
|
|
10509
10574
|
const cfg = req.config;
|
|
10510
10575
|
const now = req.now ?? new Date;
|
|
@@ -10711,6 +10776,7 @@ async function runSkillImprover(req) {
|
|
|
10711
10776
|
motifs: successMotifResult.motifs,
|
|
10712
10777
|
proposalsWritten: successMotifResult.proposalsWritten.length
|
|
10713
10778
|
};
|
|
10779
|
+
const staleSkillReconciliation = await reconcileStaleActiveSkills(req.directory, { dryRun: writeMode !== "draft_skills" });
|
|
10714
10780
|
let autoApply;
|
|
10715
10781
|
if (req.allowAutoApply !== false && delegate && req.sessionId && hasActiveFullAuto(req.sessionId)) {
|
|
10716
10782
|
try {
|
|
@@ -10731,9 +10797,20 @@ async function runSkillImprover(req) {
|
|
|
10731
10797
|
unactionableHardening,
|
|
10732
10798
|
macroMotifs,
|
|
10733
10799
|
successMotifs,
|
|
10800
|
+
staleSkillReconciliation,
|
|
10734
10801
|
autoApply
|
|
10735
10802
|
};
|
|
10736
10803
|
}
|
|
10804
|
+
var _internals18 = {
|
|
10805
|
+
runSkillImprover,
|
|
10806
|
+
buildDeterministicProposal,
|
|
10807
|
+
buildLLMProposalFrame,
|
|
10808
|
+
buildSystemPrompt,
|
|
10809
|
+
buildUserPrompt,
|
|
10810
|
+
gatherInventory,
|
|
10811
|
+
reconcileStaleActiveSkills,
|
|
10812
|
+
regenerateSkill
|
|
10813
|
+
};
|
|
10737
10814
|
|
|
10738
10815
|
// src/tools/write-retro.ts
|
|
10739
10816
|
async function executeWriteRetro(args, directory) {
|
|
@@ -11077,13 +11154,13 @@ var write_retro = createSwarmTool({
|
|
|
11077
11154
|
task_id: args.task_id !== undefined ? String(args.task_id) : undefined,
|
|
11078
11155
|
metadata: args.metadata
|
|
11079
11156
|
};
|
|
11080
|
-
return await
|
|
11157
|
+
return await _internals19.executeWriteRetro(writeRetroArgs, directory);
|
|
11081
11158
|
} catch {
|
|
11082
11159
|
return JSON.stringify({ success: false, phase: rawPhase, message: "Invalid arguments" }, null, 2);
|
|
11083
11160
|
}
|
|
11084
11161
|
}
|
|
11085
11162
|
});
|
|
11086
|
-
var
|
|
11163
|
+
var _internals19 = {
|
|
11087
11164
|
executeWriteRetro,
|
|
11088
11165
|
write_retro
|
|
11089
11166
|
};
|
|
@@ -11354,8 +11431,8 @@ async function runFinalizeStage(ctx) {
|
|
|
11354
11431
|
];
|
|
11355
11432
|
ctx.curationSucceeded = false;
|
|
11356
11433
|
try {
|
|
11357
|
-
ctx.curationResult = await
|
|
11358
|
-
llmDelegate:
|
|
11434
|
+
ctx.curationResult = await _internals20.curateAndStoreSwarm(ctx.allLessons, ctx.projectName, { phase_number: 0 }, ctx.directory, ctx.config, {
|
|
11435
|
+
llmDelegate: _internals20.createCuratorLLMDelegate(ctx.directory, "phase", ctx.options.sessionID),
|
|
11359
11436
|
enrichmentQuota: {
|
|
11360
11437
|
maxCalls: ctx.config.enrichment.max_calls_per_day,
|
|
11361
11438
|
window: ctx.config.enrichment.quota_window
|
|
@@ -11374,7 +11451,7 @@ async function runFinalizeStage(ctx) {
|
|
|
11374
11451
|
if (ctx.config.hive_enabled === false) {} else {
|
|
11375
11452
|
try {
|
|
11376
11453
|
const entries = await readKnowledge(resolveSwarmKnowledgePath(ctx.directory));
|
|
11377
|
-
const result = await
|
|
11454
|
+
const result = await _internals20.checkHivePromotions(entries, ctx.config);
|
|
11378
11455
|
ctx.hivePromoted = result.new_promotions;
|
|
11379
11456
|
} catch (hiveErr) {
|
|
11380
11457
|
const msg = hiveErr instanceof Error ? hiveErr.message : String(hiveErr);
|
|
@@ -11395,7 +11472,7 @@ async function runFinalizeStage(ctx) {
|
|
|
11395
11472
|
ctx.knowledgeSkillHint = ctx.sessionKnowledgeCreated > 0 ? `${ctx.sessionKnowledgeCreated} knowledge entries created this session. Consider running skill_improve or skill_generate to compile mature entries into skills.` : "";
|
|
11396
11473
|
if (ctx.runSkillReview) {
|
|
11397
11474
|
try {
|
|
11398
|
-
const { config: loadedConfig } =
|
|
11475
|
+
const { config: loadedConfig } = _internals20.loadPluginConfigWithMeta(ctx.directory);
|
|
11399
11476
|
const skillImproverConfig = SkillImproverConfigSchema.parse(loadedConfig.skill_improver ?? {});
|
|
11400
11477
|
const skillReviewResult = await runAbortableSkillReview({
|
|
11401
11478
|
directory: ctx.directory,
|
|
@@ -11446,7 +11523,7 @@ async function runFinalizeStage(ctx) {
|
|
|
11446
11523
|
}
|
|
11447
11524
|
if (!ctx.planAlreadyDone || ctx.guaranteeResult.closedPhaseIds.length > 0 || ctx.guaranteeResult.closedTaskIds.length > 0) {
|
|
11448
11525
|
try {
|
|
11449
|
-
await
|
|
11526
|
+
await _internals20.closePlanTerminalState(ctx.directory, ctx.planData, {
|
|
11450
11527
|
closedPhaseIds: ctx.guaranteeResult.closedPhaseIds,
|
|
11451
11528
|
closedTaskIds: ctx.guaranteeResult.closedTaskIds,
|
|
11452
11529
|
originalStatuses: ctx.originalStatuses
|
|
@@ -11463,11 +11540,11 @@ async function runFinalizeStage(ctx) {
|
|
|
11463
11540
|
}
|
|
11464
11541
|
try {
|
|
11465
11542
|
const { CuratorConfigSchema: CCS } = await import("./schema-84146tvk.js");
|
|
11466
|
-
const { config: pmLoadedConfig } =
|
|
11543
|
+
const { config: pmLoadedConfig } = _internals20.loadPluginConfigWithMeta(ctx.directory);
|
|
11467
11544
|
const curatorCfg = CCS.parse(pmLoadedConfig.curator ?? {});
|
|
11468
11545
|
if (curatorCfg.enabled && curatorCfg.postmortem_enabled) {
|
|
11469
|
-
const pmResult = await
|
|
11470
|
-
llmDelegate:
|
|
11546
|
+
const pmResult = await _internals20.runCuratorPostMortem(ctx.directory, {
|
|
11547
|
+
llmDelegate: _internals20.createCuratorLLMDelegate(ctx.directory, "postmortem", ctx.options.sessionID)
|
|
11471
11548
|
});
|
|
11472
11549
|
if (pmResult.success && pmResult.summary) {
|
|
11473
11550
|
ctx.postMortemSummary = pmResult.summary;
|
|
@@ -11637,7 +11714,7 @@ async function runArchiveEvidenceRetention(ctx) {
|
|
|
11637
11714
|
let maxAgeDays = 30;
|
|
11638
11715
|
let maxBundles = 10;
|
|
11639
11716
|
try {
|
|
11640
|
-
const { config: evidenceLoadedConfig } =
|
|
11717
|
+
const { config: evidenceLoadedConfig } = _internals20.loadPluginConfigWithMeta(ctx.directory);
|
|
11641
11718
|
const evidenceCfg = evidenceLoadedConfig.evidence ?? {};
|
|
11642
11719
|
if (typeof evidenceCfg.max_age_days === "number") {
|
|
11643
11720
|
maxAgeDays = evidenceCfg.max_age_days;
|
|
@@ -11647,7 +11724,7 @@ async function runArchiveEvidenceRetention(ctx) {
|
|
|
11647
11724
|
}
|
|
11648
11725
|
} catch {}
|
|
11649
11726
|
try {
|
|
11650
|
-
await
|
|
11727
|
+
await _internals20.archiveEvidence(ctx.directory, maxAgeDays, maxBundles);
|
|
11651
11728
|
} catch (error2) {
|
|
11652
11729
|
const msg = error2 instanceof Error ? error2.message : String(error2);
|
|
11653
11730
|
ctx.warnings.push(`Evidence retention archive failed: ${msg}`);
|
|
@@ -11802,9 +11879,9 @@ async function runAlignStage(ctx) {
|
|
|
11802
11879
|
const pruneBranches = ctx.args.includes("--prune-branches");
|
|
11803
11880
|
let gitAlignResult = "";
|
|
11804
11881
|
const prunedBranches = [];
|
|
11805
|
-
const gitStatus =
|
|
11882
|
+
const gitStatus = _internals20.getGitRepositoryStatus(ctx.directory);
|
|
11806
11883
|
if (gitStatus.isRepo) {
|
|
11807
|
-
const aggressiveResult = await
|
|
11884
|
+
const aggressiveResult = await _internals20.resetToMainAfterMerge(ctx.directory, {
|
|
11808
11885
|
pruneBranches
|
|
11809
11886
|
});
|
|
11810
11887
|
if (aggressiveResult.success) {
|
|
@@ -11816,7 +11893,7 @@ async function runAlignStage(ctx) {
|
|
|
11816
11893
|
ctx.warnings.push("Uncommitted changes were discarded during git alignment");
|
|
11817
11894
|
}
|
|
11818
11895
|
} else {
|
|
11819
|
-
const alignResult = await
|
|
11896
|
+
const alignResult = await _internals20.resetToRemoteBranch(ctx.directory, {
|
|
11820
11897
|
pruneBranches
|
|
11821
11898
|
});
|
|
11822
11899
|
gitAlignResult = alignResult.message;
|
|
@@ -11876,7 +11953,7 @@ async function handleCloseCommand(directory, args, options = {}) {
|
|
|
11876
11953
|
let finalizeLock = {
|
|
11877
11954
|
acquired: false
|
|
11878
11955
|
};
|
|
11879
|
-
finalizeLock = await
|
|
11956
|
+
finalizeLock = await _internals20.acquireFinalizeLock(directory);
|
|
11880
11957
|
if (!finalizeLock.acquired) {
|
|
11881
11958
|
return `\u274C Another /swarm finalize is already running for this project. If you are certain no other run is active, wait for the lock to expire or remove the stale lock and retry.`;
|
|
11882
11959
|
}
|
|
@@ -11907,7 +11984,7 @@ This project was already finalized in a previous /swarm close run. The plan has
|
|
|
11907
11984
|
if (planExists) {
|
|
11908
11985
|
planAlreadyDone = phases.length > 0 && phases.every((p) => p.status === "complete" || p.status === "completed" || p.status === "blocked" || p.status === "closed");
|
|
11909
11986
|
}
|
|
11910
|
-
const { config: loadedConfig } =
|
|
11987
|
+
const { config: loadedConfig } = _internals20.loadPluginConfigWithMeta(directory);
|
|
11911
11988
|
const config = KnowledgeConfigSchema.parse(loadedConfig.knowledge ?? {});
|
|
11912
11989
|
const ctx = {
|
|
11913
11990
|
directory,
|
|
@@ -12018,7 +12095,7 @@ This project was already finalized in a previous /swarm close run. The plan has
|
|
|
12018
12095
|
ctx.warnings.push(`Failed to write close-summary.md: ${msg}`);
|
|
12019
12096
|
console.warn("[close-command] Failed to write close-summary.md:", error2);
|
|
12020
12097
|
}
|
|
12021
|
-
|
|
12098
|
+
_internals20.resetSwarmStatePreservingSingletons();
|
|
12022
12099
|
const retroWarnings = ctx.warnings.filter((w) => w.includes("Retrospective write") || w.includes("retrospective write") || w.includes("Session retrospective"));
|
|
12023
12100
|
const otherWarnings = ctx.warnings.filter((w) => !w.includes("Retrospective write") && !w.includes("retrospective write") && !w.includes("Session retrospective"));
|
|
12024
12101
|
let warningMsg = "";
|
|
@@ -12073,7 +12150,7 @@ async function acquireFinalizeLock(directory) {
|
|
|
12073
12150
|
}
|
|
12074
12151
|
return { acquired: false };
|
|
12075
12152
|
}
|
|
12076
|
-
var
|
|
12153
|
+
var _internals20 = {
|
|
12077
12154
|
ACTIVE_STATE_DIRS_TO_CLEAN,
|
|
12078
12155
|
countSessionKnowledgeEntries,
|
|
12079
12156
|
CLOSE_SKILL_REVIEW_TIMEOUT_MS,
|
|
@@ -12861,9 +12938,9 @@ async function detectDarkMatter(directory, options) {
|
|
|
12861
12938
|
} catch {
|
|
12862
12939
|
return [];
|
|
12863
12940
|
}
|
|
12864
|
-
const commitMap = await
|
|
12865
|
-
const matrix =
|
|
12866
|
-
const staticEdges = await
|
|
12941
|
+
const commitMap = await _internals21.parseGitLog(directory, maxCommitsToAnalyze);
|
|
12942
|
+
const matrix = _internals21.buildCoChangeMatrix(commitMap, maxFilesPerCommit);
|
|
12943
|
+
const staticEdges = await _internals21.getStaticEdges(directory);
|
|
12867
12944
|
const results = [];
|
|
12868
12945
|
for (const entry of matrix.values()) {
|
|
12869
12946
|
const key = `${entry.fileA}::${entry.fileB}`;
|
|
@@ -12979,11 +13056,11 @@ var co_change_analyzer = createSwarmTool({
|
|
|
12979
13056
|
npmiThreshold,
|
|
12980
13057
|
maxCommitsToAnalyze
|
|
12981
13058
|
};
|
|
12982
|
-
const pairs = await
|
|
12983
|
-
return
|
|
13059
|
+
const pairs = await _internals21.detectDarkMatter(directory, options);
|
|
13060
|
+
return _internals21.formatDarkMatterOutput(pairs);
|
|
12984
13061
|
}
|
|
12985
13062
|
});
|
|
12986
|
-
var
|
|
13063
|
+
var _internals21 = {
|
|
12987
13064
|
parseGitLog,
|
|
12988
13065
|
buildCoChangeMatrix,
|
|
12989
13066
|
getStaticEdges,
|
|
@@ -13000,7 +13077,7 @@ var DEFAULT_MAX_COMMITS = 500;
|
|
|
13000
13077
|
var cache = new Map;
|
|
13001
13078
|
async function readGitHead(directory) {
|
|
13002
13079
|
try {
|
|
13003
|
-
const { stdout } = await
|
|
13080
|
+
const { stdout } = await _internals22.execFile("git", ["rev-parse", "HEAD"], {
|
|
13004
13081
|
cwd: directory,
|
|
13005
13082
|
timeout: GIT_HEAD_TIMEOUT_MS
|
|
13006
13083
|
});
|
|
@@ -13026,9 +13103,9 @@ async function getCoChangeData(directory, options) {
|
|
|
13026
13103
|
let entries;
|
|
13027
13104
|
let commitsObserved;
|
|
13028
13105
|
try {
|
|
13029
|
-
const commitMap = await
|
|
13106
|
+
const commitMap = await _internals22.parseGitLog(directory, maxCommits);
|
|
13030
13107
|
commitsObserved = commitMap.size;
|
|
13031
|
-
const matrix =
|
|
13108
|
+
const matrix = _internals22.buildCoChangeMatrix(commitMap);
|
|
13032
13109
|
entries = Array.from(matrix.values());
|
|
13033
13110
|
} catch {
|
|
13034
13111
|
return { pairs: [], commitsObserved: 0 };
|
|
@@ -13052,10 +13129,10 @@ async function getCoChangePairs(directory, options) {
|
|
|
13052
13129
|
const data = await getCoChangeData(directory, options);
|
|
13053
13130
|
return data.pairs;
|
|
13054
13131
|
}
|
|
13055
|
-
var
|
|
13132
|
+
var _internals22 = {
|
|
13056
13133
|
execFile: execFileAsync,
|
|
13057
|
-
parseGitLog:
|
|
13058
|
-
buildCoChangeMatrix:
|
|
13134
|
+
parseGitLog: _internals21.parseGitLog,
|
|
13135
|
+
buildCoChangeMatrix: _internals21.buildCoChangeMatrix
|
|
13059
13136
|
};
|
|
13060
13137
|
|
|
13061
13138
|
// src/turbo/epic/cochange-conflict.ts
|
|
@@ -13337,7 +13414,7 @@ async function handleCouplingCommand(directory, args) {
|
|
|
13337
13414
|
|
|
13338
13415
|
Usage: /swarm coupling [--phase <n>] [--threshold <-1..1>] [--min-co-changes <n>] [--format markdown|json] [--persist]`;
|
|
13339
13416
|
}
|
|
13340
|
-
const plan = await
|
|
13417
|
+
const plan = await _internals23.loadPlanJsonOnly(directory);
|
|
13341
13418
|
if (plan === null) {
|
|
13342
13419
|
return "No plan found at `.swarm/plan.json`. Run `/swarm plan` to create one before measuring coupling.";
|
|
13343
13420
|
}
|
|
@@ -13361,7 +13438,7 @@ Usage: /swarm coupling [--phase <n>] [--threshold <-1..1>] [--min-co-changes <n>
|
|
|
13361
13438
|
const scope = scopeFiles ?? task.files_touched ?? [];
|
|
13362
13439
|
return { id: task.id, scope };
|
|
13363
13440
|
});
|
|
13364
|
-
const cochangePairs = await
|
|
13441
|
+
const cochangePairs = await _internals23.getCoChangePairs(directory);
|
|
13365
13442
|
const report = computeCouplingReport(tasks, cochangePairs, {
|
|
13366
13443
|
npmi: parsed.threshold,
|
|
13367
13444
|
minCoChanges: parsed.minCoChanges
|
|
@@ -13400,7 +13477,7 @@ _Warning: failed to persist report (${persistStatus.error})._`;
|
|
|
13400
13477
|
}
|
|
13401
13478
|
return `${formatCouplingReportMarkdown(report)}${persistTrailer}`;
|
|
13402
13479
|
}
|
|
13403
|
-
var
|
|
13480
|
+
var _internals23 = {
|
|
13404
13481
|
loadPlanJsonOnly,
|
|
13405
13482
|
getCoChangePairs
|
|
13406
13483
|
};
|
|
@@ -13454,7 +13531,7 @@ async function handleDarkMatterCommand(directory, args) {
|
|
|
13454
13531
|
}
|
|
13455
13532
|
let pairs;
|
|
13456
13533
|
try {
|
|
13457
|
-
pairs = await
|
|
13534
|
+
pairs = await _internals21.detectDarkMatter(directory, options);
|
|
13458
13535
|
} catch (err) {
|
|
13459
13536
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
13460
13537
|
return `## Dark Matter Analysis Failed
|
|
@@ -14142,7 +14219,7 @@ async function checkKnowledgeHealth(directory) {
|
|
|
14142
14219
|
// src/services/diagnose-service.ts
|
|
14143
14220
|
var { version: version2 } = package_default;
|
|
14144
14221
|
var sandboxCapabilityProbe = new SandboxCapabilityProbe;
|
|
14145
|
-
var
|
|
14222
|
+
var _internals24 = {
|
|
14146
14223
|
detectSandboxCapability: () => sandboxCapabilityProbe.detect(),
|
|
14147
14224
|
getSandboxExecutor: getExecutor
|
|
14148
14225
|
};
|
|
@@ -14726,9 +14803,9 @@ async function checkCurator(directory) {
|
|
|
14726
14803
|
}
|
|
14727
14804
|
async function getSandboxStatus() {
|
|
14728
14805
|
try {
|
|
14729
|
-
const capability = await
|
|
14806
|
+
const capability = await _internals24.detectSandboxCapability();
|
|
14730
14807
|
const mechanism = capability.mechanism ?? "none";
|
|
14731
|
-
const executor = await
|
|
14808
|
+
const executor = await _internals24.getSandboxExecutor();
|
|
14732
14809
|
const hasExecutor = executor !== null;
|
|
14733
14810
|
if (hasExecutor) {
|
|
14734
14811
|
return {
|
|
@@ -15464,7 +15541,7 @@ function readPromotionEvidence(directory) {
|
|
|
15464
15541
|
}
|
|
15465
15542
|
|
|
15466
15543
|
// src/commands/epic.ts
|
|
15467
|
-
var
|
|
15544
|
+
var _internals25 = {
|
|
15468
15545
|
loadPluginConfigWithMeta,
|
|
15469
15546
|
loadPlanJsonOnly,
|
|
15470
15547
|
getCoChangeData,
|
|
@@ -15486,7 +15563,7 @@ async function handleEpicCommand(directory, args, sessionID) {
|
|
|
15486
15563
|
if (!sessionID || sessionID.trim() === "") {
|
|
15487
15564
|
return "Error: No active session context. Epic Mode requires an active session. Use /swarm epic from within an OpenCode session.";
|
|
15488
15565
|
}
|
|
15489
|
-
const session =
|
|
15566
|
+
const session = _internals25.ensureAgentSession(sessionID, undefined, directory);
|
|
15490
15567
|
const arg0 = args[0]?.toLowerCase();
|
|
15491
15568
|
switch (arg0) {
|
|
15492
15569
|
case "status":
|
|
@@ -15513,7 +15590,7 @@ Usage:
|
|
|
15513
15590
|
}
|
|
15514
15591
|
function enableAndAck(directory, sessionID, session) {
|
|
15515
15592
|
try {
|
|
15516
|
-
|
|
15593
|
+
_internals25.enableEpicMode(directory, sessionID);
|
|
15517
15594
|
} catch (err) {
|
|
15518
15595
|
return `Error enabling Epic Mode: ${err instanceof Error ? err.message : String(err)}`;
|
|
15519
15596
|
}
|
|
@@ -15529,7 +15606,7 @@ function enableAndAck(directory, sessionID, session) {
|
|
|
15529
15606
|
}
|
|
15530
15607
|
function disableAndAck(directory, sessionID, session) {
|
|
15531
15608
|
try {
|
|
15532
|
-
|
|
15609
|
+
_internals25.disableEpicMode(directory, sessionID);
|
|
15533
15610
|
} catch (err) {
|
|
15534
15611
|
return `Error disabling Epic Mode: ${err instanceof Error ? err.message : String(err)}`;
|
|
15535
15612
|
}
|
|
@@ -15538,12 +15615,12 @@ function disableAndAck(directory, sessionID, session) {
|
|
|
15538
15615
|
}
|
|
15539
15616
|
function renderStatus(directory, sessionID) {
|
|
15540
15617
|
const lines = ["## Epic Mode \u2014 Status", ""];
|
|
15541
|
-
if (
|
|
15618
|
+
if (_internals25.isStateUnreadable(directory)) {
|
|
15542
15619
|
lines.push("**Epic Mode state is unreadable** (`.swarm/epic-state.json` is corrupt or has an unexpected shape). Status cannot be reported until the file is repaired or removed. The fail-closed marker means `epic_decide_phase` will refuse to compute a verdict in this state.");
|
|
15543
15620
|
return lines.join(`
|
|
15544
15621
|
`);
|
|
15545
15622
|
}
|
|
15546
|
-
const state =
|
|
15623
|
+
const state = _internals25.loadEpicSessionState(directory, sessionID);
|
|
15547
15624
|
if (!state) {
|
|
15548
15625
|
lines.push("Epic Mode has not been toggled for this session.");
|
|
15549
15626
|
return lines.join(`
|
|
@@ -15595,7 +15672,7 @@ function formatGreenfieldDetail(input) {
|
|
|
15595
15672
|
function renderLast(directory) {
|
|
15596
15673
|
let records;
|
|
15597
15674
|
try {
|
|
15598
|
-
records =
|
|
15675
|
+
records = _internals25.readPromotionEvidence(directory);
|
|
15599
15676
|
} catch (err) {
|
|
15600
15677
|
return `Error reading epic-promotions.jsonl: ${err instanceof Error ? err.message : String(err)}`;
|
|
15601
15678
|
}
|
|
@@ -15650,7 +15727,7 @@ function renderLast(directory) {
|
|
|
15650
15727
|
`);
|
|
15651
15728
|
}
|
|
15652
15729
|
function renderCalibration(directory) {
|
|
15653
|
-
if (
|
|
15730
|
+
if (_internals25.isCalibrationStateUnreadable(directory)) {
|
|
15654
15731
|
return [
|
|
15655
15732
|
"## Epic Mode \u2014 Calibration",
|
|
15656
15733
|
"",
|
|
@@ -15662,11 +15739,11 @@ function renderCalibration(directory) {
|
|
|
15662
15739
|
}
|
|
15663
15740
|
let state;
|
|
15664
15741
|
try {
|
|
15665
|
-
state =
|
|
15742
|
+
state = _internals25.loadCalibrationState(directory);
|
|
15666
15743
|
} catch (err) {
|
|
15667
15744
|
return `Error reading calibration state: ${err instanceof Error ? err.message : String(err)}`;
|
|
15668
15745
|
}
|
|
15669
|
-
const { config } =
|
|
15746
|
+
const { config } = _internals25.loadPluginConfigWithMeta(directory);
|
|
15670
15747
|
const staticThreshold = config.turbo?.epic?.mode?.activation_threshold ?? 0.3;
|
|
15671
15748
|
const calibrationCfg = config.turbo?.epic?.calibration;
|
|
15672
15749
|
const loosenWindow = calibrationCfg?.loosen_window ?? 10;
|
|
@@ -15714,7 +15791,7 @@ function renderCalibration(directory) {
|
|
|
15714
15791
|
lines.push("");
|
|
15715
15792
|
let recentDivergent = [];
|
|
15716
15793
|
try {
|
|
15717
|
-
const all =
|
|
15794
|
+
const all = _internals25.readDivergenceHistory(directory, { limit: 50 });
|
|
15718
15795
|
recentDivergent = all.filter((r) => !r.isClean).slice(-5);
|
|
15719
15796
|
} catch {}
|
|
15720
15797
|
lines.push("### Recent divergent tasks (tightened the threshold)");
|
|
@@ -15731,11 +15808,11 @@ function renderCalibration(directory) {
|
|
|
15731
15808
|
`);
|
|
15732
15809
|
}
|
|
15733
15810
|
async function renderDecide(directory) {
|
|
15734
|
-
const plan = await
|
|
15811
|
+
const plan = await _internals25.loadPlanJsonOnly(directory);
|
|
15735
15812
|
if (!plan) {
|
|
15736
15813
|
return "No plan found at `.swarm/plan.json`. Run `/swarm plan` first.";
|
|
15737
15814
|
}
|
|
15738
|
-
const { config } =
|
|
15815
|
+
const { config } = _internals25.loadPluginConfigWithMeta(directory);
|
|
15739
15816
|
const modeCfg = config.turbo?.epic?.mode;
|
|
15740
15817
|
const cochangeCfg = config.turbo?.epic?.cochange;
|
|
15741
15818
|
const activationThreshold = modeCfg?.activation_threshold ?? 0.3;
|
|
@@ -15745,20 +15822,20 @@ async function renderDecide(directory) {
|
|
|
15745
15822
|
const tasks = [];
|
|
15746
15823
|
for (const phase of plan.phases) {
|
|
15747
15824
|
for (const task of phase.tasks) {
|
|
15748
|
-
const scopeFiles =
|
|
15825
|
+
const scopeFiles = _internals25.readTaskScopes(directory, task.id);
|
|
15749
15826
|
const scope = scopeFiles ?? task.files_touched ?? [];
|
|
15750
15827
|
tasks.push({ id: task.id, scope });
|
|
15751
15828
|
}
|
|
15752
15829
|
}
|
|
15753
|
-
const { pairs, commitsObserved } = await
|
|
15830
|
+
const { pairs, commitsObserved } = await _internals25.getCoChangeData(directory);
|
|
15754
15831
|
const isGitProject = (() => {
|
|
15755
15832
|
try {
|
|
15756
|
-
return
|
|
15833
|
+
return _internals25.isGitRepo(directory);
|
|
15757
15834
|
} catch {
|
|
15758
15835
|
return false;
|
|
15759
15836
|
}
|
|
15760
15837
|
})();
|
|
15761
|
-
const verdict =
|
|
15838
|
+
const verdict = _internals25.decideEpicActivation(tasks, pairs, commitsObserved, {
|
|
15762
15839
|
activationThreshold,
|
|
15763
15840
|
minCommitsForSignal,
|
|
15764
15841
|
cochangeNpmiThreshold,
|
|
@@ -15802,7 +15879,7 @@ function formatVerdict(verdict) {
|
|
|
15802
15879
|
}
|
|
15803
15880
|
|
|
15804
15881
|
// src/services/evidence-service.ts
|
|
15805
|
-
var
|
|
15882
|
+
var _internals26 = {
|
|
15806
15883
|
loadEvidence,
|
|
15807
15884
|
listEvidenceTaskIds
|
|
15808
15885
|
};
|
|
@@ -15847,7 +15924,7 @@ function getVerdictEmoji(verdict) {
|
|
|
15847
15924
|
return getVerdictIcon(verdict);
|
|
15848
15925
|
}
|
|
15849
15926
|
async function getTaskEvidenceData(directory, taskId) {
|
|
15850
|
-
const result = await
|
|
15927
|
+
const result = await _internals26.loadEvidence(directory, taskId);
|
|
15851
15928
|
if (result.status !== "found") {
|
|
15852
15929
|
return {
|
|
15853
15930
|
hasEvidence: false,
|
|
@@ -15870,13 +15947,13 @@ async function getTaskEvidenceData(directory, taskId) {
|
|
|
15870
15947
|
};
|
|
15871
15948
|
}
|
|
15872
15949
|
async function getEvidenceListData(directory) {
|
|
15873
|
-
const taskIds = await
|
|
15950
|
+
const taskIds = await _internals26.listEvidenceTaskIds(directory);
|
|
15874
15951
|
if (taskIds.length === 0) {
|
|
15875
15952
|
return { hasEvidence: false, tasks: [] };
|
|
15876
15953
|
}
|
|
15877
15954
|
const tasks = [];
|
|
15878
15955
|
for (const taskId of taskIds) {
|
|
15879
|
-
const result = await
|
|
15956
|
+
const result = await _internals26.loadEvidence(directory, taskId);
|
|
15880
15957
|
if (result.status === "found") {
|
|
15881
15958
|
tasks.push({
|
|
15882
15959
|
taskId,
|
|
@@ -16498,7 +16575,7 @@ function extractCurrentPhaseFromPlan2(plan) {
|
|
|
16498
16575
|
if (!plan) {
|
|
16499
16576
|
return { currentPhase: null, currentTask: null, incompleteTasks: [] };
|
|
16500
16577
|
}
|
|
16501
|
-
if (!
|
|
16578
|
+
if (!_internals27.validatePlanPhases(plan)) {
|
|
16502
16579
|
return { currentPhase: null, currentTask: null, incompleteTasks: [] };
|
|
16503
16580
|
}
|
|
16504
16581
|
let currentPhase = null;
|
|
@@ -16640,9 +16717,9 @@ function extractPhaseMetrics(content) {
|
|
|
16640
16717
|
async function getHandoffData(directory) {
|
|
16641
16718
|
const now = new Date().toISOString();
|
|
16642
16719
|
const sessionContent = await readSwarmFileAsync(directory, "session/state.json");
|
|
16643
|
-
const sessionState =
|
|
16720
|
+
const sessionState = _internals27.parseSessionState(sessionContent);
|
|
16644
16721
|
const plan = await loadPlanJsonOnly(directory);
|
|
16645
|
-
const planInfo =
|
|
16722
|
+
const planInfo = _internals27.extractCurrentPhaseFromPlan(plan);
|
|
16646
16723
|
if (!plan) {
|
|
16647
16724
|
const planMdContent = await readSwarmFileAsync(directory, "plan.md");
|
|
16648
16725
|
if (planMdContent) {
|
|
@@ -16661,8 +16738,8 @@ async function getHandoffData(directory) {
|
|
|
16661
16738
|
}
|
|
16662
16739
|
}
|
|
16663
16740
|
const contextContent = await readSwarmFileAsync(directory, "context.md");
|
|
16664
|
-
const recentDecisions =
|
|
16665
|
-
const rawPhaseMetrics =
|
|
16741
|
+
const recentDecisions = _internals27.extractDecisions(contextContent);
|
|
16742
|
+
const rawPhaseMetrics = _internals27.extractPhaseMetrics(contextContent);
|
|
16666
16743
|
const phaseMetrics = sanitizeString(rawPhaseMetrics, 1000);
|
|
16667
16744
|
let delegationState = null;
|
|
16668
16745
|
if (sessionState?.delegationState) {
|
|
@@ -16826,7 +16903,7 @@ ${lines.join(`
|
|
|
16826
16903
|
`)}
|
|
16827
16904
|
\`\`\``;
|
|
16828
16905
|
}
|
|
16829
|
-
var
|
|
16906
|
+
var _internals27 = {
|
|
16830
16907
|
getHandoffData,
|
|
16831
16908
|
formatHandoffMarkdown,
|
|
16832
16909
|
formatContinuationPrompt,
|
|
@@ -16969,15 +17046,15 @@ async function writeSnapshot(directory, state) {
|
|
|
16969
17046
|
}
|
|
16970
17047
|
function createSnapshotWriterHook(directory) {
|
|
16971
17048
|
return (_input, _output) => {
|
|
16972
|
-
_writeInFlight = _writeInFlight.then(() =>
|
|
17049
|
+
_writeInFlight = _writeInFlight.then(() => _internals28.writeSnapshot(directory, swarmState), () => _internals28.writeSnapshot(directory, swarmState));
|
|
16973
17050
|
return _writeInFlight;
|
|
16974
17051
|
};
|
|
16975
17052
|
}
|
|
16976
17053
|
async function flushPendingSnapshot(directory) {
|
|
16977
|
-
_writeInFlight = _writeInFlight.then(() =>
|
|
17054
|
+
_writeInFlight = _writeInFlight.then(() => _internals28.writeSnapshot(directory, swarmState), () => _internals28.writeSnapshot(directory, swarmState));
|
|
16978
17055
|
await _writeInFlight;
|
|
16979
17056
|
}
|
|
16980
|
-
var
|
|
17057
|
+
var _internals28 = {
|
|
16981
17058
|
writeSnapshot,
|
|
16982
17059
|
createSnapshotWriterHook,
|
|
16983
17060
|
flushPendingSnapshot
|
|
@@ -17177,7 +17254,7 @@ var IPV4_PRIVATE_192 = /^192\.168\./;
|
|
|
17177
17254
|
var IPV4_ZERO_NETWORK = /^0\./;
|
|
17178
17255
|
var IPV6_LINK_LOCAL = /^fe80:/i;
|
|
17179
17256
|
var IPV6_UNIQUE_LOCAL = /^f[cd][0-9a-f]{2}:/i;
|
|
17180
|
-
var
|
|
17257
|
+
var _internals29 = { spawnSync: spawnSync6 };
|
|
17181
17258
|
function sanitizeUrl(raw) {
|
|
17182
17259
|
let urlStr = raw.trim();
|
|
17183
17260
|
urlStr = urlStr.replace(/\[\s*MODE\s*:[^\]]*\]/gi, "");
|
|
@@ -17287,7 +17364,7 @@ function validateAndSanitizeGithubUrl(rawUrl, resource) {
|
|
|
17287
17364
|
}
|
|
17288
17365
|
function detectGitRemote(cwd) {
|
|
17289
17366
|
try {
|
|
17290
|
-
const result =
|
|
17367
|
+
const result = _internals29.spawnSync("git", ["remote", "get-url", "origin"], {
|
|
17291
17368
|
encoding: "utf-8",
|
|
17292
17369
|
stdio: ["ignore", "pipe", "pipe"],
|
|
17293
17370
|
timeout: 5000,
|
|
@@ -17474,7 +17551,7 @@ async function migrateKnowledgeToExternal(_directory, _config) {
|
|
|
17474
17551
|
skippedReason: "no-context-file"
|
|
17475
17552
|
};
|
|
17476
17553
|
}
|
|
17477
|
-
var
|
|
17554
|
+
var _internals30 = {
|
|
17478
17555
|
appendKnowledge,
|
|
17479
17556
|
migrateContextToKnowledge,
|
|
17480
17557
|
migrateKnowledgeToExternal,
|
|
@@ -17520,9 +17597,9 @@ async function migrateContextToKnowledge(directory, config) {
|
|
|
17520
17597
|
skippedReason: "empty-context"
|
|
17521
17598
|
};
|
|
17522
17599
|
}
|
|
17523
|
-
const rawEntries =
|
|
17600
|
+
const rawEntries = _internals30.parseContextMd(contextContent);
|
|
17524
17601
|
if (rawEntries.length === 0) {
|
|
17525
|
-
await
|
|
17602
|
+
await _internals30.writeSentinel(sentinelPath, 0, 0);
|
|
17526
17603
|
return {
|
|
17527
17604
|
migrated: true,
|
|
17528
17605
|
entriesMigrated: 0,
|
|
@@ -17533,10 +17610,10 @@ async function migrateContextToKnowledge(directory, config) {
|
|
|
17533
17610
|
const existing = await readKnowledge(knowledgePath);
|
|
17534
17611
|
let migrated = 0;
|
|
17535
17612
|
let dropped = 0;
|
|
17536
|
-
const projectName =
|
|
17613
|
+
const projectName = _internals30.inferProjectName(directory);
|
|
17537
17614
|
for (const raw of rawEntries) {
|
|
17538
17615
|
if (config.validation_enabled !== false) {
|
|
17539
|
-
const category = raw.categoryHint ??
|
|
17616
|
+
const category = raw.categoryHint ?? _internals30.inferCategoryFromText(raw.text);
|
|
17540
17617
|
const result = validateLesson(raw.text, existing.map((e) => e.lesson), {
|
|
17541
17618
|
category,
|
|
17542
17619
|
scope: "global",
|
|
@@ -17556,8 +17633,8 @@ async function migrateContextToKnowledge(directory, config) {
|
|
|
17556
17633
|
const entry = {
|
|
17557
17634
|
id: randomUUID4(),
|
|
17558
17635
|
tier: "swarm",
|
|
17559
|
-
lesson:
|
|
17560
|
-
category: raw.categoryHint ??
|
|
17636
|
+
lesson: _internals30.truncateLesson(raw.text),
|
|
17637
|
+
category: raw.categoryHint ?? _internals30.inferCategoryFromText(raw.text),
|
|
17561
17638
|
tags: [...inferredTags, `migration:${raw.sourceSection}`],
|
|
17562
17639
|
scope: "global",
|
|
17563
17640
|
confidence: 0.3,
|
|
@@ -17580,7 +17657,7 @@ async function migrateContextToKnowledge(directory, config) {
|
|
|
17580
17657
|
if (migrated > 0) {
|
|
17581
17658
|
await rewriteKnowledge(knowledgePath, existing);
|
|
17582
17659
|
}
|
|
17583
|
-
await
|
|
17660
|
+
await _internals30.writeSentinel(sentinelPath, migrated, dropped);
|
|
17584
17661
|
log(`[knowledge-migrator] Migrated ${migrated} entries, dropped ${dropped}`);
|
|
17585
17662
|
return {
|
|
17586
17663
|
migrated: true,
|
|
@@ -17590,7 +17667,7 @@ async function migrateContextToKnowledge(directory, config) {
|
|
|
17590
17667
|
};
|
|
17591
17668
|
}
|
|
17592
17669
|
async function migrateHiveKnowledgeLegacy(config) {
|
|
17593
|
-
const legacyHivePath =
|
|
17670
|
+
const legacyHivePath = _internals30.resolveLegacyHiveKnowledgePath();
|
|
17594
17671
|
const canonicalHivePath = resolveHiveKnowledgePath();
|
|
17595
17672
|
const sentinelPath = path37.join(path37.dirname(canonicalHivePath), ".hive-knowledge-migrated");
|
|
17596
17673
|
if (existsSync22(sentinelPath)) {
|
|
@@ -17613,7 +17690,7 @@ async function migrateHiveKnowledgeLegacy(config) {
|
|
|
17613
17690
|
}
|
|
17614
17691
|
const legacyEntries = await readKnowledge(legacyHivePath);
|
|
17615
17692
|
if (legacyEntries.length === 0) {
|
|
17616
|
-
await
|
|
17693
|
+
await _internals30.writeSentinel(sentinelPath, 0, 0);
|
|
17617
17694
|
return {
|
|
17618
17695
|
migrated: true,
|
|
17619
17696
|
entriesMigrated: 0,
|
|
@@ -17661,7 +17738,7 @@ async function migrateHiveKnowledgeLegacy(config) {
|
|
|
17661
17738
|
const newHiveEntry = {
|
|
17662
17739
|
id: resolvedId,
|
|
17663
17740
|
tier: "hive",
|
|
17664
|
-
lesson:
|
|
17741
|
+
lesson: _internals30.truncateLesson(lesson),
|
|
17665
17742
|
category,
|
|
17666
17743
|
tags: ["migration:legacy-hive"],
|
|
17667
17744
|
scope: scopeTag,
|
|
@@ -17680,7 +17757,7 @@ async function migrateHiveKnowledgeLegacy(config) {
|
|
|
17680
17757
|
encounter_score: 1
|
|
17681
17758
|
};
|
|
17682
17759
|
try {
|
|
17683
|
-
await
|
|
17760
|
+
await _internals30.appendKnowledge(canonicalHivePath, newHiveEntry);
|
|
17684
17761
|
existingHiveEntries.push(newHiveEntry);
|
|
17685
17762
|
migrated++;
|
|
17686
17763
|
} catch (appendError) {
|
|
@@ -17696,7 +17773,7 @@ async function migrateHiveKnowledgeLegacy(config) {
|
|
|
17696
17773
|
dropped++;
|
|
17697
17774
|
}
|
|
17698
17775
|
}
|
|
17699
|
-
await
|
|
17776
|
+
await _internals30.writeSentinel(sentinelPath, migrated, dropped);
|
|
17700
17777
|
log(`[knowledge-migrator] Migrated ${migrated} legacy hive entries, dropped ${dropped}`);
|
|
17701
17778
|
return {
|
|
17702
17779
|
migrated: true,
|
|
@@ -17707,7 +17784,7 @@ async function migrateHiveKnowledgeLegacy(config) {
|
|
|
17707
17784
|
};
|
|
17708
17785
|
}
|
|
17709
17786
|
function parseContextMd(content) {
|
|
17710
|
-
const sections =
|
|
17787
|
+
const sections = _internals30.splitIntoSections(content);
|
|
17711
17788
|
const entries = [];
|
|
17712
17789
|
const seen = new Set;
|
|
17713
17790
|
const sectionPatterns = [
|
|
@@ -17723,7 +17800,7 @@ function parseContextMd(content) {
|
|
|
17723
17800
|
const match = sectionPatterns.find((sp) => sp.pattern.test(section.heading));
|
|
17724
17801
|
if (!match)
|
|
17725
17802
|
continue;
|
|
17726
|
-
const bullets =
|
|
17803
|
+
const bullets = _internals30.extractBullets(section.body);
|
|
17727
17804
|
for (const bullet of bullets) {
|
|
17728
17805
|
if (bullet.length < 15)
|
|
17729
17806
|
continue;
|
|
@@ -17732,9 +17809,9 @@ function parseContextMd(content) {
|
|
|
17732
17809
|
continue;
|
|
17733
17810
|
seen.add(normalized);
|
|
17734
17811
|
entries.push({
|
|
17735
|
-
text:
|
|
17812
|
+
text: _internals30.truncateLesson(bullet),
|
|
17736
17813
|
sourceSection: match.sourceSection,
|
|
17737
|
-
categoryHint:
|
|
17814
|
+
categoryHint: _internals30.inferCategoryFromText(bullet)
|
|
17738
17815
|
});
|
|
17739
17816
|
}
|
|
17740
17817
|
}
|
|
@@ -18081,7 +18158,7 @@ function timeoutMessage(timeoutMs) {
|
|
|
18081
18158
|
async function computeWithTimeout(directory, currentPhase, timeoutMs) {
|
|
18082
18159
|
const controller = new AbortController;
|
|
18083
18160
|
let timeout;
|
|
18084
|
-
const metricsPromise =
|
|
18161
|
+
const metricsPromise = _internals31.computeLearningMetrics(directory, {
|
|
18085
18162
|
currentPhase,
|
|
18086
18163
|
signal: controller.signal
|
|
18087
18164
|
});
|
|
@@ -18138,7 +18215,7 @@ ${JSON.stringify({
|
|
|
18138
18215
|
return `Error computing learning metrics: ${message}. Run /swarm diagnose to check .swarm/ health.`;
|
|
18139
18216
|
}
|
|
18140
18217
|
}
|
|
18141
|
-
var
|
|
18218
|
+
var _internals31 = {
|
|
18142
18219
|
computeLearningMetrics
|
|
18143
18220
|
};
|
|
18144
18221
|
|
|
@@ -21601,15 +21678,15 @@ function truncate(value, maxLength) {
|
|
|
21601
21678
|
}
|
|
21602
21679
|
|
|
21603
21680
|
// src/services/plan-service.ts
|
|
21604
|
-
var
|
|
21681
|
+
var _internals32 = {
|
|
21605
21682
|
loadPlanJsonOnly,
|
|
21606
21683
|
derivePlanMarkdown,
|
|
21607
21684
|
readSwarmFileAsync
|
|
21608
21685
|
};
|
|
21609
21686
|
async function getPlanData(directory, phaseArg) {
|
|
21610
|
-
const plan = await
|
|
21687
|
+
const plan = await _internals32.loadPlanJsonOnly(directory);
|
|
21611
21688
|
if (plan) {
|
|
21612
|
-
const fullMarkdown =
|
|
21689
|
+
const fullMarkdown = _internals32.derivePlanMarkdown(plan);
|
|
21613
21690
|
if (phaseArg === undefined || phaseArg === null || phaseArg === "") {
|
|
21614
21691
|
return {
|
|
21615
21692
|
hasPlan: true,
|
|
@@ -21652,7 +21729,7 @@ async function getPlanData(directory, phaseArg) {
|
|
|
21652
21729
|
isLegacy: false
|
|
21653
21730
|
};
|
|
21654
21731
|
}
|
|
21655
|
-
const planContent = await
|
|
21732
|
+
const planContent = await _internals32.readSwarmFileAsync(directory, "plan.md");
|
|
21656
21733
|
if (!planContent) {
|
|
21657
21734
|
return {
|
|
21658
21735
|
hasPlan: false,
|
|
@@ -21749,7 +21826,7 @@ async function handlePlanCommand(directory, args) {
|
|
|
21749
21826
|
return formatPlanMarkdown(planData);
|
|
21750
21827
|
}
|
|
21751
21828
|
// src/commands/post-mortem.ts
|
|
21752
|
-
var
|
|
21829
|
+
var _internals33 = {
|
|
21753
21830
|
createCuratorLLMDelegate,
|
|
21754
21831
|
runCuratorPostMortem
|
|
21755
21832
|
};
|
|
@@ -21761,10 +21838,10 @@ async function handlePostMortemCommand(directory, args, options) {
|
|
|
21761
21838
|
};
|
|
21762
21839
|
if (options?.sessionID) {
|
|
21763
21840
|
try {
|
|
21764
|
-
pmOptions.llmDelegate =
|
|
21841
|
+
pmOptions.llmDelegate = _internals33.createCuratorLLMDelegate(directory, "postmortem", options.sessionID);
|
|
21765
21842
|
} catch {}
|
|
21766
21843
|
}
|
|
21767
|
-
const result = await
|
|
21844
|
+
const result = await _internals33.runCuratorPostMortem(directory, pmOptions);
|
|
21768
21845
|
const lines = [];
|
|
21769
21846
|
if (result.success) {
|
|
21770
21847
|
lines.push("## Post-Mortem Report Generated");
|
|
@@ -21919,12 +21996,12 @@ function formatRelativeTime(epochMs) {
|
|
|
21919
21996
|
const diffDays = Math.floor(diffHours / 24);
|
|
21920
21997
|
return `${diffDays} day${diffDays === 1 ? "" : "s"} ago`;
|
|
21921
21998
|
}
|
|
21922
|
-
var
|
|
21999
|
+
var _internals34 = {
|
|
21923
22000
|
formatRelativeTime,
|
|
21924
22001
|
listActive
|
|
21925
22002
|
};
|
|
21926
22003
|
async function handlePrMonitorStatusCommand(directory, _args, sessionID) {
|
|
21927
|
-
const allActive = await
|
|
22004
|
+
const allActive = await _internals34.listActive(directory);
|
|
21928
22005
|
const sessionSubs = allActive.filter((record) => record.sessionID === sessionID);
|
|
21929
22006
|
if (sessionSubs.length === 0) {
|
|
21930
22007
|
return "No active PR subscriptions for this session.";
|
|
@@ -22049,7 +22126,7 @@ async function handlePrSubscribeCommand(directory, args, sessionID) {
|
|
|
22049
22126
|
const repoFullName = `${prInfo.owner}/${prInfo.repo}`;
|
|
22050
22127
|
const prUrl = `https://github.com/${prInfo.owner}/${prInfo.repo}/pull/${prInfo.number}`;
|
|
22051
22128
|
try {
|
|
22052
|
-
const config =
|
|
22129
|
+
const config = _internals35.loadPluginConfig(directory);
|
|
22053
22130
|
const prMonitorConfig = config.pr_monitor;
|
|
22054
22131
|
if (!prMonitorConfig?.enabled) {
|
|
22055
22132
|
return [
|
|
@@ -22059,7 +22136,7 @@ async function handlePrSubscribeCommand(directory, args, sessionID) {
|
|
|
22059
22136
|
].join(`
|
|
22060
22137
|
`);
|
|
22061
22138
|
}
|
|
22062
|
-
await
|
|
22139
|
+
await _internals35.subscribe(directory, {
|
|
22063
22140
|
sessionID,
|
|
22064
22141
|
prNumber: prInfo.number,
|
|
22065
22142
|
repoFullName,
|
|
@@ -22083,7 +22160,7 @@ async function handlePrSubscribeCommand(directory, args, sessionID) {
|
|
|
22083
22160
|
`);
|
|
22084
22161
|
}
|
|
22085
22162
|
}
|
|
22086
|
-
var
|
|
22163
|
+
var _internals35 = {
|
|
22087
22164
|
loadPluginConfig,
|
|
22088
22165
|
subscribe
|
|
22089
22166
|
};
|
|
@@ -22106,9 +22183,9 @@ async function handlePrUnsubscribeCommand(directory, args, sessionID) {
|
|
|
22106
22183
|
`);
|
|
22107
22184
|
}
|
|
22108
22185
|
const refToken = rest[0];
|
|
22109
|
-
const prInfo =
|
|
22186
|
+
const prInfo = _internals36.parsePrRef(refToken, directory);
|
|
22110
22187
|
if (!prInfo) {
|
|
22111
|
-
if (
|
|
22188
|
+
if (_internals36.looksLikePrRef(refToken)) {
|
|
22112
22189
|
return [
|
|
22113
22190
|
`Error: Could not resolve PR reference from "${refToken}".`,
|
|
22114
22191
|
"",
|
|
@@ -22129,8 +22206,8 @@ async function handlePrUnsubscribeCommand(directory, args, sessionID) {
|
|
|
22129
22206
|
const repoFullName = `${prInfo.owner}/${prInfo.repo}`;
|
|
22130
22207
|
const prUrl = `https://github.com/${prInfo.owner}/${prInfo.repo}/pull/${prInfo.number}`;
|
|
22131
22208
|
try {
|
|
22132
|
-
const correlationId =
|
|
22133
|
-
const result = await
|
|
22209
|
+
const correlationId = _internals36.buildCorrelationId(sessionID, repoFullName, prInfo.number);
|
|
22210
|
+
const result = await _internals36.unsubscribe(directory, correlationId);
|
|
22134
22211
|
if (!result) {
|
|
22135
22212
|
return [
|
|
22136
22213
|
`Not subscribed to ${prUrl}`,
|
|
@@ -22157,7 +22234,7 @@ async function handlePrUnsubscribeCommand(directory, args, sessionID) {
|
|
|
22157
22234
|
`);
|
|
22158
22235
|
}
|
|
22159
22236
|
}
|
|
22160
|
-
var
|
|
22237
|
+
var _internals36 = {
|
|
22161
22238
|
unsubscribe,
|
|
22162
22239
|
buildCorrelationId,
|
|
22163
22240
|
parsePrRef,
|
|
@@ -22591,15 +22668,15 @@ var lint = createSwarmTool({
|
|
|
22591
22668
|
}
|
|
22592
22669
|
const { mode } = args;
|
|
22593
22670
|
const cwd = directory;
|
|
22594
|
-
const linter = await
|
|
22671
|
+
const linter = await _internals37.detectAvailableLinter(directory);
|
|
22595
22672
|
if (linter) {
|
|
22596
|
-
const result = await
|
|
22673
|
+
const result = await _internals37.runLint(linter, mode, directory);
|
|
22597
22674
|
return JSON.stringify(result, null, 2);
|
|
22598
22675
|
}
|
|
22599
|
-
const additionalLinter =
|
|
22676
|
+
const additionalLinter = _internals37.detectAdditionalLinter(cwd);
|
|
22600
22677
|
if (additionalLinter) {
|
|
22601
22678
|
warn(`[lint] Using ${additionalLinter} linter for this project`);
|
|
22602
|
-
const result = await
|
|
22679
|
+
const result = await _internals37.runAdditionalLint(additionalLinter, mode, cwd);
|
|
22603
22680
|
return JSON.stringify(result, null, 2);
|
|
22604
22681
|
}
|
|
22605
22682
|
const errorResult = {
|
|
@@ -22613,7 +22690,7 @@ For Rust: rustup component add clippy`
|
|
|
22613
22690
|
return JSON.stringify(errorResult, null, 2);
|
|
22614
22691
|
}
|
|
22615
22692
|
});
|
|
22616
|
-
var
|
|
22693
|
+
var _internals37 = {
|
|
22617
22694
|
detectAvailableLinter,
|
|
22618
22695
|
runLint,
|
|
22619
22696
|
detectAdditionalLinter,
|
|
@@ -23301,7 +23378,7 @@ var secretscan = createSwarmTool({
|
|
|
23301
23378
|
});
|
|
23302
23379
|
async function runSecretscan(directory) {
|
|
23303
23380
|
try {
|
|
23304
|
-
const result = await
|
|
23381
|
+
const result = await _internals38.secretscan.execute({ directory }, {});
|
|
23305
23382
|
const jsonStr = typeof result === "string" ? result : result.output;
|
|
23306
23383
|
return JSON.parse(jsonStr);
|
|
23307
23384
|
} catch (e) {
|
|
@@ -23316,7 +23393,7 @@ async function runSecretscan(directory) {
|
|
|
23316
23393
|
return errorResult;
|
|
23317
23394
|
}
|
|
23318
23395
|
}
|
|
23319
|
-
var
|
|
23396
|
+
var _internals38 = {
|
|
23320
23397
|
secretscan,
|
|
23321
23398
|
runSecretscan
|
|
23322
23399
|
};
|
|
@@ -23589,7 +23666,7 @@ async function buildImpactMapInternal(cwd) {
|
|
|
23589
23666
|
}
|
|
23590
23667
|
return impactMap;
|
|
23591
23668
|
}
|
|
23592
|
-
var
|
|
23669
|
+
var _internals39 = {
|
|
23593
23670
|
validateProjectRoot,
|
|
23594
23671
|
normalizePath: normalizePath2,
|
|
23595
23672
|
isCacheStale,
|
|
@@ -23604,8 +23681,8 @@ var _internals38 = {
|
|
|
23604
23681
|
_clearGoModuleCache
|
|
23605
23682
|
};
|
|
23606
23683
|
async function buildImpactMap(cwd) {
|
|
23607
|
-
const impactMap = await
|
|
23608
|
-
await
|
|
23684
|
+
const impactMap = await _internals39.buildImpactMapInternal(cwd);
|
|
23685
|
+
await _internals39.saveImpactMap(cwd, impactMap);
|
|
23609
23686
|
return impactMap;
|
|
23610
23687
|
}
|
|
23611
23688
|
async function loadImpactMap(cwd, options) {
|
|
@@ -23619,7 +23696,7 @@ async function loadImpactMap(cwd, options) {
|
|
|
23619
23696
|
const hasValidValues = Object.values(map).every((v) => Array.isArray(v) && v.every((item) => typeof item === "string"));
|
|
23620
23697
|
if (hasValidValues) {
|
|
23621
23698
|
const generatedAt = new Date(data.generatedAt).getTime();
|
|
23622
|
-
if (!
|
|
23699
|
+
if (!_internals39.isCacheStale(map, generatedAt)) {
|
|
23623
23700
|
return map;
|
|
23624
23701
|
}
|
|
23625
23702
|
if (options?.skipRebuild) {
|
|
@@ -23639,13 +23716,13 @@ async function loadImpactMap(cwd, options) {
|
|
|
23639
23716
|
if (options?.skipRebuild) {
|
|
23640
23717
|
return {};
|
|
23641
23718
|
}
|
|
23642
|
-
return
|
|
23719
|
+
return _internals39.buildImpactMap(cwd);
|
|
23643
23720
|
}
|
|
23644
23721
|
async function saveImpactMap(cwd, impactMap) {
|
|
23645
23722
|
if (!path45.isAbsolute(cwd)) {
|
|
23646
23723
|
throw new Error(`saveImpactMap requires an absolute project root path, got: "${cwd}"`);
|
|
23647
23724
|
}
|
|
23648
|
-
|
|
23725
|
+
_internals39.validateProjectRoot(cwd);
|
|
23649
23726
|
const cacheDir2 = path45.join(cwd, ".swarm", "cache");
|
|
23650
23727
|
const cachePath = path45.join(cacheDir2, "impact-map.json");
|
|
23651
23728
|
if (!fs20.existsSync(cacheDir2)) {
|
|
@@ -23669,7 +23746,7 @@ async function analyzeImpact(changedFiles, cwd, budget) {
|
|
|
23669
23746
|
};
|
|
23670
23747
|
}
|
|
23671
23748
|
const validFiles = changedFiles.filter((f) => typeof f === "string" && f.length > 0 && !f.includes("\x00"));
|
|
23672
|
-
const impactMap = await
|
|
23749
|
+
const impactMap = await _internals39.loadImpactMap(cwd);
|
|
23673
23750
|
const impactedTestsSet = new Set;
|
|
23674
23751
|
const untestedFiles = [];
|
|
23675
23752
|
let visitedCount = 0;
|
|
@@ -24134,7 +24211,7 @@ function batchAppendTestRuns(records, workingDir) {
|
|
|
24134
24211
|
}
|
|
24135
24212
|
const historyPath = getHistoryPath(workingDir);
|
|
24136
24213
|
const historyDir = path46.dirname(historyPath);
|
|
24137
|
-
|
|
24214
|
+
_internals40.validateProjectRoot(workingDir);
|
|
24138
24215
|
if (!fs21.existsSync(historyDir)) {
|
|
24139
24216
|
fs21.mkdirSync(historyDir, { recursive: true });
|
|
24140
24217
|
}
|
|
@@ -24257,7 +24334,7 @@ function getAllHistory(workingDir) {
|
|
|
24257
24334
|
records.sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
|
|
24258
24335
|
return records;
|
|
24259
24336
|
}
|
|
24260
|
-
var
|
|
24337
|
+
var _internals40 = {
|
|
24261
24338
|
validateProjectRoot
|
|
24262
24339
|
};
|
|
24263
24340
|
|
|
@@ -26170,9 +26247,9 @@ function getVersionFileVersion(dir) {
|
|
|
26170
26247
|
async function runVersionCheck(dir, _timeoutMs) {
|
|
26171
26248
|
const startTime = Date.now();
|
|
26172
26249
|
try {
|
|
26173
|
-
const packageVersion =
|
|
26174
|
-
const changelogVersion =
|
|
26175
|
-
const versionFileVersion =
|
|
26250
|
+
const packageVersion = _internals41.getPackageVersion(dir);
|
|
26251
|
+
const changelogVersion = _internals41.getChangelogVersion(dir);
|
|
26252
|
+
const versionFileVersion = _internals41.getVersionFileVersion(dir);
|
|
26176
26253
|
const versions = [];
|
|
26177
26254
|
if (packageVersion)
|
|
26178
26255
|
versions.push(`package.json: ${packageVersion}`);
|
|
@@ -26536,7 +26613,7 @@ async function runPreflight(dir, phase, config) {
|
|
|
26536
26613
|
const reportId = `preflight-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
26537
26614
|
let validatedDir;
|
|
26538
26615
|
try {
|
|
26539
|
-
validatedDir =
|
|
26616
|
+
validatedDir = _internals41.validateDirectoryPath(dir);
|
|
26540
26617
|
} catch (error2) {
|
|
26541
26618
|
return {
|
|
26542
26619
|
id: reportId,
|
|
@@ -26556,7 +26633,7 @@ async function runPreflight(dir, phase, config) {
|
|
|
26556
26633
|
}
|
|
26557
26634
|
let validatedTimeout;
|
|
26558
26635
|
try {
|
|
26559
|
-
validatedTimeout =
|
|
26636
|
+
validatedTimeout = _internals41.validateTimeout(config?.checkTimeoutMs, DEFAULT_CONFIG.checkTimeoutMs);
|
|
26560
26637
|
} catch (error2) {
|
|
26561
26638
|
return {
|
|
26562
26639
|
id: reportId,
|
|
@@ -26597,12 +26674,12 @@ async function runPreflight(dir, phase, config) {
|
|
|
26597
26674
|
});
|
|
26598
26675
|
const checks = [];
|
|
26599
26676
|
log("[Preflight] Running lint check...");
|
|
26600
|
-
const lintResult = await
|
|
26677
|
+
const lintResult = await _internals41.runLintCheck(validatedDir, cfg.linter, cfg.checkTimeoutMs);
|
|
26601
26678
|
checks.push(lintResult);
|
|
26602
26679
|
log(`[Preflight] Lint check: ${lintResult.status} ${lintResult.message}`);
|
|
26603
26680
|
if (!cfg.skipTests) {
|
|
26604
26681
|
log("[Preflight] Running tests check...");
|
|
26605
|
-
const testsResult = await
|
|
26682
|
+
const testsResult = await _internals41.runTestsCheck(validatedDir, cfg.testScope, cfg.checkTimeoutMs);
|
|
26606
26683
|
checks.push(testsResult);
|
|
26607
26684
|
log(`[Preflight] Tests check: ${testsResult.status} ${testsResult.message}`);
|
|
26608
26685
|
} else {
|
|
@@ -26614,7 +26691,7 @@ async function runPreflight(dir, phase, config) {
|
|
|
26614
26691
|
}
|
|
26615
26692
|
if (!cfg.skipSecrets) {
|
|
26616
26693
|
log("[Preflight] Running secrets check...");
|
|
26617
|
-
const secretsResult = await
|
|
26694
|
+
const secretsResult = await _internals41.runSecretsCheck(validatedDir, cfg.checkTimeoutMs);
|
|
26618
26695
|
checks.push(secretsResult);
|
|
26619
26696
|
log(`[Preflight] Secrets check: ${secretsResult.status} ${secretsResult.message}`);
|
|
26620
26697
|
} else {
|
|
@@ -26626,7 +26703,7 @@ async function runPreflight(dir, phase, config) {
|
|
|
26626
26703
|
}
|
|
26627
26704
|
if (!cfg.skipEvidence) {
|
|
26628
26705
|
log("[Preflight] Running evidence check...");
|
|
26629
|
-
const evidenceResult = await
|
|
26706
|
+
const evidenceResult = await _internals41.runEvidenceCheck(validatedDir);
|
|
26630
26707
|
checks.push(evidenceResult);
|
|
26631
26708
|
log(`[Preflight] Evidence check: ${evidenceResult.status} ${evidenceResult.message}`);
|
|
26632
26709
|
} else {
|
|
@@ -26637,12 +26714,12 @@ async function runPreflight(dir, phase, config) {
|
|
|
26637
26714
|
});
|
|
26638
26715
|
}
|
|
26639
26716
|
log("[Preflight] Running requirement coverage check...");
|
|
26640
|
-
const reqCoverageResult = await
|
|
26717
|
+
const reqCoverageResult = await _internals41.runRequirementCoverageCheck(validatedDir, phase);
|
|
26641
26718
|
checks.push(reqCoverageResult);
|
|
26642
26719
|
log(`[Preflight] Requirement coverage check: ${reqCoverageResult.status} ${reqCoverageResult.message}`);
|
|
26643
26720
|
if (!cfg.skipVersion) {
|
|
26644
26721
|
log("[Preflight] Running version check...");
|
|
26645
|
-
const versionResult = await
|
|
26722
|
+
const versionResult = await _internals41.runVersionCheck(validatedDir, cfg.checkTimeoutMs);
|
|
26646
26723
|
checks.push(versionResult);
|
|
26647
26724
|
log(`[Preflight] Version check: ${versionResult.status} ${versionResult.message}`);
|
|
26648
26725
|
} else {
|
|
@@ -26705,10 +26782,10 @@ function formatPreflightMarkdown(report) {
|
|
|
26705
26782
|
async function handlePreflightCommand(directory, _args) {
|
|
26706
26783
|
const plan = await loadPlan(directory);
|
|
26707
26784
|
const phase = plan?.current_phase ?? 1;
|
|
26708
|
-
const report = await
|
|
26709
|
-
return
|
|
26785
|
+
const report = await _internals41.runPreflight(directory, phase);
|
|
26786
|
+
return _internals41.formatPreflightMarkdown(report);
|
|
26710
26787
|
}
|
|
26711
|
-
var
|
|
26788
|
+
var _internals41 = {
|
|
26712
26789
|
runPreflight,
|
|
26713
26790
|
formatPreflightMarkdown,
|
|
26714
26791
|
handlePreflightCommand,
|
|
@@ -28111,7 +28188,7 @@ async function recordReplayEntry(artifactPath, sessionID, entry) {
|
|
|
28111
28188
|
}
|
|
28112
28189
|
|
|
28113
28190
|
// src/prm/index.ts
|
|
28114
|
-
var
|
|
28191
|
+
var _internals42 = {
|
|
28115
28192
|
getAgentSession,
|
|
28116
28193
|
readTrajectory,
|
|
28117
28194
|
getInMemoryTrajectory,
|
|
@@ -28134,7 +28211,7 @@ function resetPrmSessionState(session, sessionId) {
|
|
|
28134
28211
|
session.prmTrajectoryStep = 0;
|
|
28135
28212
|
session.replayArtifactPath = null;
|
|
28136
28213
|
if (sessionId) {
|
|
28137
|
-
|
|
28214
|
+
_internals42.clearTrajectoryCache(sessionId);
|
|
28138
28215
|
}
|
|
28139
28216
|
}
|
|
28140
28217
|
|
|
@@ -28611,7 +28688,7 @@ async function handleSimulateCommand(directory, args) {
|
|
|
28611
28688
|
}
|
|
28612
28689
|
let darkMatterPairs;
|
|
28613
28690
|
try {
|
|
28614
|
-
darkMatterPairs = await
|
|
28691
|
+
darkMatterPairs = await _internals21.detectDarkMatter(directory, options);
|
|
28615
28692
|
} catch (err) {
|
|
28616
28693
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
28617
28694
|
return `## Simulate Report
|
|
@@ -28876,7 +28953,7 @@ var DEFAULT_CONTEXT_BUDGET_CONFIG = {
|
|
|
28876
28953
|
};
|
|
28877
28954
|
|
|
28878
28955
|
// src/services/status-service.ts
|
|
28879
|
-
var
|
|
28956
|
+
var _internals43 = {
|
|
28880
28957
|
loadLeanTurboRunState,
|
|
28881
28958
|
hasActiveLeanTurbo,
|
|
28882
28959
|
hasActiveFullAuto
|
|
@@ -28981,7 +29058,7 @@ async function getStatusData(directory, agents) {
|
|
|
28981
29058
|
}
|
|
28982
29059
|
function enrichWithLeanTurbo(status, directory) {
|
|
28983
29060
|
const turboMode = hasActiveTurboMode();
|
|
28984
|
-
const leanActive =
|
|
29061
|
+
const leanActive = _internals43.hasActiveLeanTurbo();
|
|
28985
29062
|
let turboStrategy = "off";
|
|
28986
29063
|
if (leanActive) {
|
|
28987
29064
|
turboStrategy = "lean";
|
|
@@ -29000,7 +29077,7 @@ function enrichWithLeanTurbo(status, directory) {
|
|
|
29000
29077
|
}
|
|
29001
29078
|
}
|
|
29002
29079
|
if (leanSessionID) {
|
|
29003
|
-
const runState =
|
|
29080
|
+
const runState = _internals43.loadLeanTurboRunState(directory, leanSessionID);
|
|
29004
29081
|
if (runState) {
|
|
29005
29082
|
status.leanTurboPhase = runState.phase;
|
|
29006
29083
|
status.leanMaxParallelCoders = runState.maxParallelCoders;
|
|
@@ -29032,7 +29109,7 @@ function enrichWithLeanTurbo(status, directory) {
|
|
|
29032
29109
|
}
|
|
29033
29110
|
}
|
|
29034
29111
|
}
|
|
29035
|
-
status.fullAutoActive =
|
|
29112
|
+
status.fullAutoActive = _internals43.hasActiveFullAuto();
|
|
29036
29113
|
return status;
|
|
29037
29114
|
}
|
|
29038
29115
|
function formatStatusMarkdown(status) {
|
|
@@ -29186,7 +29263,7 @@ No active swarm plan found. Nothing to sync.`;
|
|
|
29186
29263
|
|
|
29187
29264
|
// src/commands/turbo.ts
|
|
29188
29265
|
init_logger();
|
|
29189
|
-
var
|
|
29266
|
+
var _internals44 = {
|
|
29190
29267
|
loadPluginConfigWithMeta
|
|
29191
29268
|
};
|
|
29192
29269
|
async function handleTurboCommand(directory, args, sessionID) {
|
|
@@ -29246,7 +29323,7 @@ async function handleTurboCommand(directory, args, sessionID) {
|
|
|
29246
29323
|
if (arg0 === "on") {
|
|
29247
29324
|
let strategy = "standard";
|
|
29248
29325
|
try {
|
|
29249
|
-
const { config } =
|
|
29326
|
+
const { config } = _internals44.loadPluginConfigWithMeta(directory);
|
|
29250
29327
|
if (config.turbo?.strategy === "lean") {
|
|
29251
29328
|
strategy = "lean";
|
|
29252
29329
|
}
|
|
@@ -29343,7 +29420,7 @@ function enableLeanTurbo(session, directory, sessionID) {
|
|
|
29343
29420
|
let maxParallelCoders = 4;
|
|
29344
29421
|
let conflictPolicy = "serialize";
|
|
29345
29422
|
try {
|
|
29346
|
-
const { config } =
|
|
29423
|
+
const { config } = _internals44.loadPluginConfigWithMeta(directory);
|
|
29347
29424
|
const leanConfig = config.turbo?.lean;
|
|
29348
29425
|
if (leanConfig) {
|
|
29349
29426
|
maxParallelCoders = leanConfig.max_parallel_coders ?? 4;
|
|
@@ -29499,7 +29576,7 @@ function findSimilarCommands(query) {
|
|
|
29499
29576
|
}
|
|
29500
29577
|
const scored = VALID_COMMANDS.map((cmd) => {
|
|
29501
29578
|
const cmdLower = cmd.toLowerCase();
|
|
29502
|
-
const fullScore =
|
|
29579
|
+
const fullScore = _internals45.levenshteinDistance(q, cmdLower);
|
|
29503
29580
|
let tokenScore = Infinity;
|
|
29504
29581
|
if (cmd.includes(" ") || cmd.includes("-")) {
|
|
29505
29582
|
const qTokens = q.split(/[\s-]+/);
|
|
@@ -29512,7 +29589,7 @@ function findSimilarCommands(query) {
|
|
|
29512
29589
|
for (const ct of cmdTokens) {
|
|
29513
29590
|
if (ct.length === 0)
|
|
29514
29591
|
continue;
|
|
29515
|
-
const dist =
|
|
29592
|
+
const dist = _internals45.levenshteinDistance(qt, ct);
|
|
29516
29593
|
if (dist < minDist)
|
|
29517
29594
|
minDist = dist;
|
|
29518
29595
|
}
|
|
@@ -29522,7 +29599,7 @@ function findSimilarCommands(query) {
|
|
|
29522
29599
|
}
|
|
29523
29600
|
const dashStrippedQ = q.replace(/-/g, "");
|
|
29524
29601
|
const dashStrippedCmd = cmdLower.replace(/-/g, "");
|
|
29525
|
-
const dashScore =
|
|
29602
|
+
const dashScore = _internals45.levenshteinDistance(dashStrippedQ, dashStrippedCmd);
|
|
29526
29603
|
const score = Math.min(fullScore, tokenScore, dashScore);
|
|
29527
29604
|
return { cmd, score };
|
|
29528
29605
|
});
|
|
@@ -29550,16 +29627,16 @@ function buildDetailedHelp(commandName, entry) {
|
|
|
29550
29627
|
async function handleHelpCommand(ctx) {
|
|
29551
29628
|
const targetCommand = ctx.args.join(" ");
|
|
29552
29629
|
if (!targetCommand) {
|
|
29553
|
-
const { buildHelpText } = await import("./index-
|
|
29630
|
+
const { buildHelpText } = await import("./index-r3f47swm.js");
|
|
29554
29631
|
return buildHelpText();
|
|
29555
29632
|
}
|
|
29556
29633
|
const tokens = targetCommand.split(/\s+/);
|
|
29557
|
-
const resolved =
|
|
29634
|
+
const resolved = _internals45.resolveCommand(tokens);
|
|
29558
29635
|
if (resolved) {
|
|
29559
|
-
return
|
|
29636
|
+
return _internals45.buildDetailedHelp(resolved.key, resolved.entry);
|
|
29560
29637
|
}
|
|
29561
|
-
const similar =
|
|
29562
|
-
const { buildHelpText: fullHelp } = await import("./index-
|
|
29638
|
+
const similar = _internals45.findSimilarCommands(targetCommand);
|
|
29639
|
+
const { buildHelpText: fullHelp } = await import("./index-r3f47swm.js");
|
|
29563
29640
|
if (similar.length > 0) {
|
|
29564
29641
|
return `Command '/swarm ${targetCommand}' not found.
|
|
29565
29642
|
|
|
@@ -29623,7 +29700,7 @@ var COMMAND_REGISTRY = {
|
|
|
29623
29700
|
toolNoArgs: true
|
|
29624
29701
|
},
|
|
29625
29702
|
help: {
|
|
29626
|
-
handler: (ctx) =>
|
|
29703
|
+
handler: (ctx) => _internals45.handleHelpCommand(ctx),
|
|
29627
29704
|
description: "Show help for swarm commands",
|
|
29628
29705
|
category: "core",
|
|
29629
29706
|
args: "[command]",
|
|
@@ -29692,7 +29769,7 @@ var COMMAND_REGISTRY = {
|
|
|
29692
29769
|
},
|
|
29693
29770
|
"guardrail explain": {
|
|
29694
29771
|
handler: async (ctx) => {
|
|
29695
|
-
const { handleGuardrailExplain } = await import("./guardrail-explain-
|
|
29772
|
+
const { handleGuardrailExplain } = await import("./guardrail-explain-2q9myk7c.js");
|
|
29696
29773
|
return handleGuardrailExplain(ctx.directory, ctx.args);
|
|
29697
29774
|
},
|
|
29698
29775
|
description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
|
|
@@ -30473,7 +30550,7 @@ function validateToolPolicy() {
|
|
|
30473
30550
|
}
|
|
30474
30551
|
return { valid: warnings.length === 0, warnings };
|
|
30475
30552
|
}
|
|
30476
|
-
var
|
|
30553
|
+
var _internals45 = {
|
|
30477
30554
|
handleHelpCommand,
|
|
30478
30555
|
validateAliases,
|
|
30479
30556
|
validateToolPolicy,
|
|
@@ -30482,7 +30559,7 @@ var _internals44 = {
|
|
|
30482
30559
|
findSimilarCommands,
|
|
30483
30560
|
buildDetailedHelp
|
|
30484
30561
|
};
|
|
30485
|
-
var validation =
|
|
30562
|
+
var validation = _internals45.validateAliases();
|
|
30486
30563
|
if (!validation.valid) {
|
|
30487
30564
|
throw new Error(`COMMAND_REGISTRY alias validation failed:
|
|
30488
30565
|
${validation.errors.join(`
|
|
@@ -30494,7 +30571,7 @@ ${validation.warnings.join(`
|
|
|
30494
30571
|
`)}`);
|
|
30495
30572
|
}
|
|
30496
30573
|
try {
|
|
30497
|
-
const toolPolicyValidation =
|
|
30574
|
+
const toolPolicyValidation = _internals45.validateToolPolicy();
|
|
30498
30575
|
if (toolPolicyValidation.warnings.length > 0) {
|
|
30499
30576
|
console.warn(`COMMAND_REGISTRY toolPolicy warnings:
|
|
30500
30577
|
${toolPolicyValidation.warnings.join(`
|
|
@@ -30558,7 +30635,7 @@ function formatCommandNotFound(tokens) {
|
|
|
30558
30635
|
const attemptedCommand = tokens[0] || "";
|
|
30559
30636
|
const MAX_DISPLAY = 100;
|
|
30560
30637
|
const displayCommand = attemptedCommand.length > MAX_DISPLAY ? `${attemptedCommand.slice(0, MAX_DISPLAY)}...` : attemptedCommand;
|
|
30561
|
-
const similar =
|
|
30638
|
+
const similar = _internals45.findSimilarCommands(attemptedCommand);
|
|
30562
30639
|
const header = `Command \`/swarm ${displayCommand}\` not found.`;
|
|
30563
30640
|
const suggestions = similar.length > 0 ? `Did you mean:
|
|
30564
30641
|
${similar.map((cmd) => ` - /swarm ${cmd}`).join(`
|
|
@@ -30615,4 +30692,4 @@ ${text}`;
|
|
|
30615
30692
|
};
|
|
30616
30693
|
}
|
|
30617
30694
|
|
|
30618
|
-
export { package_default, handleAcknowledgeSpecDriftCommand, handleAgentsCommand, handleAnalyzeCommand, handleArchiveCommand, DC_SAFE_TARGETS, dcNormalizeCommand, dcUnwrapWrappers, dcSplitSegments, dcValidateTargets, dcCheckJunctionCreation, dcExtractWindowsCmdTargets, dcExtractPowerShellTargets, normalizeSwarmCommandInput, canonicalCommandKey, formatCommandNotFound, executeSwarmCommand, SWARM_COMMAND_TOOL_COMMANDS, SWARM_COMMAND_TOOL_ALLOWLIST, HUMAN_ONLY_SWARM_COMMANDS, classifySwarmCommandToolUse, classifySwarmCommandChatFallbackUse, detectPosixWrites, detectWindowsWrites, resolveWriteTargets, handleAutoProceedCommand, handleBenchmarkCommand, handleBrainstormCommand, handleCheckpointCommand, handleClarifyCommand, handleCloseCommand, handleCodebaseReviewCommand, handleConcurrencyCommand, handleConfigCommand, handleConsolidateCommand, handleCouncilCommand, handleCurateCommand, handleDarkMatterCommand, handleDeepDiveCommand, handleDeepResearchCommand, getPluginConfigDir, getPluginCachePaths, getPluginLockFilePaths, handleDiagnoseCommand, handleDoctorCommand, handleEvidenceCommand, handleEvidenceSummaryCommand, handleExportCommand, handleFullAutoCommand, handleHandoffCommand, handleHistoryCommand, handleKnowledgeQuarantineCommand, handleKnowledgeRestoreCommand, handleKnowledgeMigrateCommand, handleKnowledgeListCommand, handleKnowledgeUnactionableCommand, handleKnowledgeRetryHardeningCommand, handleLearningCommand, handleMemoryCommand, handleMemoryStatusCommand, handleMemoryMigrateCommand, handleMemoryImportCommand, handleMemoryExportCommand, handlePlanCommand, handlePreflightCommand, handlePromoteCommand, handleQaGatesCommand, handleResetCommand, handleResetSessionCommand, handleRetrieveCommand, handleRollbackCommand, handleSddStatusCommand, handleSddValidateCommand, handleSddProjectCommand, handleSddCommand, handleSimulateCommand, handleSpecifyCommand, handleStatusCommand, handleSyncPlanCommand, handleTurboCommand, handleWriteRetroCommand, handleHelpCommand, COMMAND_REGISTRY, VALID_COMMANDS,
|
|
30695
|
+
export { package_default, handleAcknowledgeSpecDriftCommand, handleAgentsCommand, handleAnalyzeCommand, handleArchiveCommand, DC_SAFE_TARGETS, dcNormalizeCommand, dcUnwrapWrappers, dcSplitSegments, dcValidateTargets, dcCheckJunctionCreation, dcExtractWindowsCmdTargets, dcExtractPowerShellTargets, normalizeSwarmCommandInput, canonicalCommandKey, formatCommandNotFound, executeSwarmCommand, SWARM_COMMAND_TOOL_COMMANDS, SWARM_COMMAND_TOOL_ALLOWLIST, HUMAN_ONLY_SWARM_COMMANDS, classifySwarmCommandToolUse, classifySwarmCommandChatFallbackUse, detectPosixWrites, detectWindowsWrites, resolveWriteTargets, handleAutoProceedCommand, handleBenchmarkCommand, handleBrainstormCommand, handleCheckpointCommand, handleClarifyCommand, handleCloseCommand, handleCodebaseReviewCommand, handleConcurrencyCommand, handleConfigCommand, handleConsolidateCommand, handleCouncilCommand, handleCurateCommand, handleDarkMatterCommand, handleDeepDiveCommand, handleDeepResearchCommand, getPluginConfigDir, getPluginCachePaths, getPluginLockFilePaths, handleDiagnoseCommand, handleDoctorCommand, handleEvidenceCommand, handleEvidenceSummaryCommand, handleExportCommand, handleFullAutoCommand, handleHandoffCommand, handleHistoryCommand, handleKnowledgeQuarantineCommand, handleKnowledgeRestoreCommand, handleKnowledgeMigrateCommand, handleKnowledgeListCommand, handleKnowledgeUnactionableCommand, handleKnowledgeRetryHardeningCommand, handleLearningCommand, handleMemoryCommand, handleMemoryStatusCommand, handleMemoryMigrateCommand, handleMemoryImportCommand, handleMemoryExportCommand, handlePlanCommand, handlePreflightCommand, handlePromoteCommand, handleQaGatesCommand, handleResetCommand, handleResetSessionCommand, handleRetrieveCommand, handleRollbackCommand, handleSddStatusCommand, handleSddValidateCommand, handleSddProjectCommand, handleSddCommand, handleSimulateCommand, handleSpecifyCommand, handleStatusCommand, handleSyncPlanCommand, handleTurboCommand, handleWriteRetroCommand, handleHelpCommand, COMMAND_REGISTRY, VALID_COMMANDS, _internals45 as _internals, resolveCommand };
|