opencode-swarm 7.121.3 → 7.121.4
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/{curator-ed91r7rw.js → curator-3azybqrw.js} +1 -1
- package/dist/cli/{curator-llm-factory-q9veqj3h.js → curator-llm-factory-6rafny5e.js} +1 -1
- package/dist/cli/{guardrail-explain-0vcaa7hj.js → guardrail-explain-d1m747g5.js} +2 -2
- package/dist/cli/{hive-promoter-dg6fk563.js → hive-promoter-4xnj3fdk.js} +1 -1
- package/dist/cli/{index-g9eg7z93.js → index-2k6z335c.js} +2 -2
- package/dist/cli/{index-qad0m9bz.js → index-982hhpcm.js} +1 -1
- package/dist/cli/{index-fs2q8jyf.js → index-q0fv0xec.js} +576 -476
- package/dist/cli/index.js +1 -1
- package/dist/db/index.d.ts +4 -0
- package/dist/db/sqlite-loader.d.ts +78 -0
- package/dist/index.js +245 -245
- package/package.json +3 -2
|
@@ -279,16 +279,123 @@ import { createHash } from "crypto";
|
|
|
279
279
|
|
|
280
280
|
// src/db/project-db.ts
|
|
281
281
|
import { existsSync, mkdirSync } from "fs";
|
|
282
|
-
import { createRequire } from "module";
|
|
283
282
|
import { join, resolve } from "path";
|
|
283
|
+
|
|
284
|
+
// src/db/sqlite-loader.ts
|
|
285
|
+
import { createRequire } from "module";
|
|
286
|
+
function createNodeDatabaseCtor(DatabaseSyncCtor) {
|
|
287
|
+
|
|
288
|
+
class NodeSqliteDatabase {
|
|
289
|
+
raw;
|
|
290
|
+
stmts = new Map;
|
|
291
|
+
savepointCounter = 0;
|
|
292
|
+
constructor(filename) {
|
|
293
|
+
this.raw = new DatabaseSyncCtor(filename, { allowExtension: true });
|
|
294
|
+
}
|
|
295
|
+
statement(sql) {
|
|
296
|
+
let stmt = this.stmts.get(sql);
|
|
297
|
+
if (!stmt) {
|
|
298
|
+
stmt = this.raw.prepare(sql);
|
|
299
|
+
this.stmts.set(sql, stmt);
|
|
300
|
+
}
|
|
301
|
+
return stmt;
|
|
302
|
+
}
|
|
303
|
+
run(sql, ...rest) {
|
|
304
|
+
if (rest.length === 0) {
|
|
305
|
+
this.raw.exec(sql);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
const params = rest.length === 1 && Array.isArray(rest[0]) ? rest[0] : rest;
|
|
309
|
+
return this.statement(sql).run(...params);
|
|
310
|
+
}
|
|
311
|
+
query(sql) {
|
|
312
|
+
const stmt = this.statement(sql);
|
|
313
|
+
return {
|
|
314
|
+
get: (...params) => stmt.get(...params),
|
|
315
|
+
all: (...params) => stmt.all(...params),
|
|
316
|
+
iterate: (...params) => stmt.iterate(...params)
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
get inTransaction() {
|
|
320
|
+
return this.raw.isTransaction;
|
|
321
|
+
}
|
|
322
|
+
transaction(fn) {
|
|
323
|
+
return (...args) => {
|
|
324
|
+
if (this.raw.isTransaction) {
|
|
325
|
+
const sp = `swarm_sp_${this.savepointCounter++}`;
|
|
326
|
+
this.raw.exec(`SAVEPOINT ${sp}`);
|
|
327
|
+
try {
|
|
328
|
+
const result = fn(...args);
|
|
329
|
+
this.raw.exec(`RELEASE ${sp}`);
|
|
330
|
+
return result;
|
|
331
|
+
} catch (err) {
|
|
332
|
+
try {
|
|
333
|
+
this.raw.exec(`ROLLBACK TO ${sp}`);
|
|
334
|
+
this.raw.exec(`RELEASE ${sp}`);
|
|
335
|
+
} catch {}
|
|
336
|
+
throw err;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
this.raw.exec("BEGIN");
|
|
340
|
+
try {
|
|
341
|
+
const result = fn(...args);
|
|
342
|
+
this.raw.exec("COMMIT");
|
|
343
|
+
return result;
|
|
344
|
+
} catch (err) {
|
|
345
|
+
try {
|
|
346
|
+
this.raw.exec("ROLLBACK");
|
|
347
|
+
} catch {}
|
|
348
|
+
throw err;
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
loadExtension(path) {
|
|
353
|
+
this.raw.enableLoadExtension(true);
|
|
354
|
+
try {
|
|
355
|
+
this.raw.loadExtension(path);
|
|
356
|
+
} finally {
|
|
357
|
+
this.raw.enableLoadExtension(false);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
close() {
|
|
361
|
+
this.stmts.clear();
|
|
362
|
+
this.raw.close();
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return NodeSqliteDatabase;
|
|
366
|
+
}
|
|
284
367
|
var _DatabaseCtor = null;
|
|
368
|
+
var _internals4 = {
|
|
369
|
+
requireModule(id) {
|
|
370
|
+
return createRequire(import.meta.url)(id);
|
|
371
|
+
},
|
|
372
|
+
reset() {
|
|
373
|
+
_DatabaseCtor = null;
|
|
374
|
+
}
|
|
375
|
+
};
|
|
285
376
|
function loadDatabaseCtor() {
|
|
286
377
|
if (_DatabaseCtor)
|
|
287
378
|
return _DatabaseCtor;
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
379
|
+
let bunError;
|
|
380
|
+
try {
|
|
381
|
+
const mod = _internals4.requireModule("bun:sqlite");
|
|
382
|
+
_DatabaseCtor = mod.Database;
|
|
383
|
+
return _DatabaseCtor;
|
|
384
|
+
} catch (err) {
|
|
385
|
+
bunError = err;
|
|
386
|
+
}
|
|
387
|
+
try {
|
|
388
|
+
const mod = _internals4.requireModule("node:sqlite");
|
|
389
|
+
_DatabaseCtor = createNodeDatabaseCtor(mod.DatabaseSync);
|
|
390
|
+
return _DatabaseCtor;
|
|
391
|
+
} catch (nodeError) {
|
|
392
|
+
const bunMsg = bunError instanceof Error ? bunError.message : String(bunError);
|
|
393
|
+
const nodeMsg = nodeError instanceof Error ? nodeError.message : String(nodeError);
|
|
394
|
+
throw new Error("opencode-swarm: no SQLite driver available. This build needs Bun " + "(bun:sqlite) or Node.js 22.13+ (node:sqlite). " + `bun:sqlite: ${bunMsg}; node:sqlite: ${nodeMsg}`);
|
|
395
|
+
}
|
|
291
396
|
}
|
|
397
|
+
|
|
398
|
+
// src/db/project-db.ts
|
|
292
399
|
var MIGRATIONS = [
|
|
293
400
|
{
|
|
294
401
|
version: 1,
|
|
@@ -371,7 +478,7 @@ function getProjectDb(directory) {
|
|
|
371
478
|
}
|
|
372
479
|
|
|
373
480
|
// src/db/qa-gate-profile.ts
|
|
374
|
-
var
|
|
481
|
+
var _internals5 = {
|
|
375
482
|
getProfile,
|
|
376
483
|
getOrCreateProfile,
|
|
377
484
|
setGates,
|
|
@@ -447,7 +554,7 @@ function hasAnyProfileWithEnabledGate(directory, gate) {
|
|
|
447
554
|
return false;
|
|
448
555
|
}
|
|
449
556
|
function getOrCreateProfile(directory, planId, projectType) {
|
|
450
|
-
const existing =
|
|
557
|
+
const existing = _internals5.getProfile(directory, planId);
|
|
451
558
|
if (existing)
|
|
452
559
|
return existing;
|
|
453
560
|
const db = getProjectDb(directory);
|
|
@@ -463,14 +570,14 @@ function getOrCreateProfile(directory, planId, projectType) {
|
|
|
463
570
|
throw err;
|
|
464
571
|
}
|
|
465
572
|
}
|
|
466
|
-
const after =
|
|
573
|
+
const after = _internals5.getProfile(directory, planId);
|
|
467
574
|
if (!after) {
|
|
468
575
|
throw new Error(`Failed to create or load QA gate profile for plan_id=${planId}`);
|
|
469
576
|
}
|
|
470
577
|
return after;
|
|
471
578
|
}
|
|
472
579
|
function setGates(directory, planId, gates) {
|
|
473
|
-
const current =
|
|
580
|
+
const current = _internals5.getProfile(directory, planId);
|
|
474
581
|
if (!current) {
|
|
475
582
|
throw new Error(`No QA gate profile found for plan_id=${planId} \u2014 call getOrCreateProfile first`);
|
|
476
583
|
}
|
|
@@ -494,7 +601,7 @@ function setGates(directory, planId, gates) {
|
|
|
494
601
|
JSON.stringify(merged),
|
|
495
602
|
planId
|
|
496
603
|
]);
|
|
497
|
-
const updated =
|
|
604
|
+
const updated = _internals5.getProfile(directory, planId);
|
|
498
605
|
if (!updated) {
|
|
499
606
|
throw new Error(`Failed to re-read QA gate profile after update for plan_id=${planId}`);
|
|
500
607
|
}
|
|
@@ -524,7 +631,7 @@ init_logger();
|
|
|
524
631
|
init_executor();
|
|
525
632
|
init_logger();
|
|
526
633
|
// src/worktree/merge.ts
|
|
527
|
-
var
|
|
634
|
+
var _internals6 = {
|
|
528
635
|
bunSpawn,
|
|
529
636
|
platform: process.platform,
|
|
530
637
|
sleep: (ms) => new Promise((resolve2) => setTimeout(resolve2, ms)),
|
|
@@ -534,7 +641,7 @@ var _internals5 = {
|
|
|
534
641
|
};
|
|
535
642
|
var MERGE_TIMEOUT_MS = 30000;
|
|
536
643
|
async function runGit(args, cwd, timeoutMs = MERGE_TIMEOUT_MS) {
|
|
537
|
-
const proc =
|
|
644
|
+
const proc = _internals6.bunSpawn(["git", ...args], {
|
|
538
645
|
cwd,
|
|
539
646
|
timeout: timeoutMs,
|
|
540
647
|
stdin: "ignore",
|
|
@@ -2419,7 +2526,7 @@ class EmbeddingVersionMismatchError extends Error {
|
|
|
2419
2526
|
}
|
|
2420
2527
|
|
|
2421
2528
|
// src/memory/embeddings/local-provider.ts
|
|
2422
|
-
var
|
|
2529
|
+
var _internals8 = {
|
|
2423
2530
|
resolveEmbeddingCacheDir() {
|
|
2424
2531
|
let base;
|
|
2425
2532
|
if (process.platform === "win32") {
|
|
@@ -2440,7 +2547,7 @@ var _internals7 = {
|
|
|
2440
2547
|
}
|
|
2441
2548
|
};
|
|
2442
2549
|
function resolveEmbeddingCacheDir() {
|
|
2443
|
-
return
|
|
2550
|
+
return _internals8.resolveEmbeddingCacheDir();
|
|
2444
2551
|
}
|
|
2445
2552
|
|
|
2446
2553
|
class LocalEmbeddingProvider {
|
|
@@ -2858,14 +2965,6 @@ function toJsonl(values) {
|
|
|
2858
2965
|
}
|
|
2859
2966
|
|
|
2860
2967
|
// src/memory/sqlite-provider.ts
|
|
2861
|
-
var _DatabaseCtor2 = null;
|
|
2862
|
-
function loadDatabaseCtor2() {
|
|
2863
|
-
if (_DatabaseCtor2)
|
|
2864
|
-
return _DatabaseCtor2;
|
|
2865
|
-
const req = createRequire4(import.meta.url);
|
|
2866
|
-
_DatabaseCtor2 = req("bun:sqlite").Database;
|
|
2867
|
-
return _DatabaseCtor2;
|
|
2868
|
-
}
|
|
2869
2968
|
var RECALL_CANDIDATE_LIMIT = 1000;
|
|
2870
2969
|
var FTS_SCHEMA_MIGRATION_NAME = "create_memory_fts5_shadow_index";
|
|
2871
2970
|
var FTS_TABLE_NAME = "memory_items_fts";
|
|
@@ -3110,7 +3209,7 @@ class SQLiteMemoryProvider {
|
|
|
3110
3209
|
async doInitialize() {
|
|
3111
3210
|
const dbPath = this.databasePath();
|
|
3112
3211
|
mkdirSync4(path5.dirname(dbPath), { recursive: true });
|
|
3113
|
-
const Db =
|
|
3212
|
+
const Db = loadDatabaseCtor();
|
|
3114
3213
|
this.db = new Db(dbPath);
|
|
3115
3214
|
try {
|
|
3116
3215
|
this.db.run("PRAGMA journal_mode = WAL;");
|
|
@@ -3778,7 +3877,7 @@ class SQLiteMemoryProvider {
|
|
|
3778
3877
|
}
|
|
3779
3878
|
}
|
|
3780
3879
|
getStoredModelVersion() {
|
|
3781
|
-
const row = this.requireDb().query(`SELECT value FROM embedding_config WHERE key =
|
|
3880
|
+
const row = this.requireDb().query(`SELECT value FROM embedding_config WHERE key = ? LIMIT 1`).get("model_version");
|
|
3782
3881
|
return row?.value ?? null;
|
|
3783
3882
|
}
|
|
3784
3883
|
async selectDenseCandidates(request, queryEmbedding) {
|
|
@@ -3850,7 +3949,7 @@ class SQLiteMemoryProvider {
|
|
|
3850
3949
|
}
|
|
3851
3950
|
backfillScopeKeys() {
|
|
3852
3951
|
const db = this.requireDb();
|
|
3853
|
-
const metaRow = db.query("SELECT value FROM _meta WHERE key =
|
|
3952
|
+
const metaRow = db.query("SELECT value FROM _meta WHERE key = ?").get("scope_key_backfilled");
|
|
3854
3953
|
if (metaRow?.value === "1")
|
|
3855
3954
|
return;
|
|
3856
3955
|
const rows = db.query("SELECT id, record_json, scope_key FROM memory_items").all();
|
|
@@ -3875,7 +3974,7 @@ class SQLiteMemoryProvider {
|
|
|
3875
3974
|
}
|
|
3876
3975
|
backfillRecallRunIds() {
|
|
3877
3976
|
const db = this.requireDb();
|
|
3878
|
-
const metaRow = db.query("SELECT value FROM _meta WHERE key =
|
|
3977
|
+
const metaRow = db.query("SELECT value FROM _meta WHERE key = ?").get("recall_run_id_backfilled");
|
|
3879
3978
|
if (metaRow?.value === "1")
|
|
3880
3979
|
return;
|
|
3881
3980
|
const rows = db.query("SELECT id, usage_json FROM memory_recall_usage WHERE run_id IS NULL").all();
|
|
@@ -5033,7 +5132,7 @@ async function handleAnalyzeCommand(_directory, args) {
|
|
|
5033
5132
|
}
|
|
5034
5133
|
|
|
5035
5134
|
// src/commands/archive.ts
|
|
5036
|
-
var
|
|
5135
|
+
var _internals9 = {
|
|
5037
5136
|
now: () => new Date
|
|
5038
5137
|
};
|
|
5039
5138
|
function artifactLabel(artifact) {
|
|
@@ -5047,7 +5146,7 @@ async function handleArchiveCommand(directory, args) {
|
|
|
5047
5146
|
const report = await archiveEvidence(directory, maxAgeDays, maxBundles, {
|
|
5048
5147
|
report: true,
|
|
5049
5148
|
dryRun,
|
|
5050
|
-
now:
|
|
5149
|
+
now: _internals9.now()
|
|
5051
5150
|
});
|
|
5052
5151
|
const evaluationSelected = report.evaluation.selected.map(artifactLabel);
|
|
5053
5152
|
const evaluationArchived = report.evaluation.archived.map(artifactLabel);
|
|
@@ -6618,7 +6717,7 @@ var IPV4_PRIVATE_192 = /^192\.168\./;
|
|
|
6618
6717
|
var IPV4_ZERO_NETWORK = /^0\./;
|
|
6619
6718
|
var IPV6_LINK_LOCAL = /^fe80:/i;
|
|
6620
6719
|
var IPV6_UNIQUE_LOCAL = /^f[cd][0-9a-f]{2}:/i;
|
|
6621
|
-
var
|
|
6720
|
+
var _internals10 = {
|
|
6622
6721
|
spawnSync: (cmd, args, options) => {
|
|
6623
6722
|
const mergedEnv = mergeEnvForChild(options?.env, options?.envOverrides);
|
|
6624
6723
|
return child_process2.spawnSync(cmd, args, {
|
|
@@ -6736,7 +6835,7 @@ function validateAndSanitizeGithubUrl(rawUrl, resource) {
|
|
|
6736
6835
|
}
|
|
6737
6836
|
function detectGitRemote(cwd, laneEnv) {
|
|
6738
6837
|
try {
|
|
6739
|
-
const result =
|
|
6838
|
+
const result = _internals10.spawnSync("git", ["remote", "get-url", "origin"], {
|
|
6740
6839
|
encoding: "utf-8",
|
|
6741
6840
|
stdio: ["ignore", "pipe", "pipe"],
|
|
6742
6841
|
timeout: 5000,
|
|
@@ -6998,7 +7097,7 @@ function timeoutKillSignal(platform) {
|
|
|
6998
7097
|
}
|
|
6999
7098
|
function killProcess(proc) {
|
|
7000
7099
|
try {
|
|
7001
|
-
proc?.kill(timeoutKillSignal(
|
|
7100
|
+
proc?.kill(timeoutKillSignal(_internals11.platform()));
|
|
7002
7101
|
} catch {}
|
|
7003
7102
|
}
|
|
7004
7103
|
async function runExternalTool(options) {
|
|
@@ -7030,7 +7129,7 @@ async function runExternalTool(options) {
|
|
|
7030
7129
|
let exitSettled = false;
|
|
7031
7130
|
let settledExitCode = null;
|
|
7032
7131
|
try {
|
|
7033
|
-
proc =
|
|
7132
|
+
proc = _internals11.bunSpawn([options.executable, ...options.args], {
|
|
7034
7133
|
cwd: options.cwd,
|
|
7035
7134
|
env: options.env,
|
|
7036
7135
|
stdin: "ignore",
|
|
@@ -7129,7 +7228,7 @@ async function runExternalTool(options) {
|
|
|
7129
7228
|
}
|
|
7130
7229
|
}
|
|
7131
7230
|
}
|
|
7132
|
-
var
|
|
7231
|
+
var _internals11 = {
|
|
7133
7232
|
bunSpawn,
|
|
7134
7233
|
platform: () => process.platform
|
|
7135
7234
|
};
|
|
@@ -7139,7 +7238,7 @@ init_logger();
|
|
|
7139
7238
|
var GIT_TIMEOUT_MS2 = 30000;
|
|
7140
7239
|
var VALIDATION_TIMEOUT_MS = 5 * 60 * 1000;
|
|
7141
7240
|
var OUTPUT_LIMIT_BYTES = 12000;
|
|
7142
|
-
var
|
|
7241
|
+
var _internals12 = {
|
|
7143
7242
|
runExternalTool,
|
|
7144
7243
|
getDefaultBaseBranch,
|
|
7145
7244
|
platform: process.platform,
|
|
@@ -7150,7 +7249,7 @@ var _internals11 = {
|
|
|
7150
7249
|
}
|
|
7151
7250
|
};
|
|
7152
7251
|
async function runGit2(args, cwd, timeoutMs = GIT_TIMEOUT_MS2) {
|
|
7153
|
-
const result = await
|
|
7252
|
+
const result = await _internals12.runExternalTool({
|
|
7154
7253
|
executable: "git",
|
|
7155
7254
|
args,
|
|
7156
7255
|
cwd,
|
|
@@ -7168,7 +7267,7 @@ async function runGit2(args, cwd, timeoutMs = GIT_TIMEOUT_MS2) {
|
|
|
7168
7267
|
}
|
|
7169
7268
|
async function runValidationCommand(cmd, cwd, timeoutMs = VALIDATION_TIMEOUT_MS) {
|
|
7170
7269
|
const [executable, ...args] = cmd;
|
|
7171
|
-
const result = await
|
|
7270
|
+
const result = await _internals12.runExternalTool({
|
|
7172
7271
|
executable,
|
|
7173
7272
|
args,
|
|
7174
7273
|
cwd,
|
|
@@ -7196,7 +7295,7 @@ async function getCurrentBranchOrRef(directory) {
|
|
|
7196
7295
|
return hashResult.stdout.trim();
|
|
7197
7296
|
}
|
|
7198
7297
|
async function setupWorktree(projectRoot, prRef, baseBranch, onWorktreeCreated) {
|
|
7199
|
-
const worktreeBase = path13.join(
|
|
7298
|
+
const worktreeBase = path13.join(_internals12.osTmpdir(), "swarm-ci-simulate");
|
|
7200
7299
|
const worktreeName = `pr-${Date.now()}-${Math.floor(Math.random() * 1e6)}`;
|
|
7201
7300
|
const worktreePath = path13.join(worktreeBase, worktreeName);
|
|
7202
7301
|
await fsPromises2.mkdir(worktreeBase, { recursive: true });
|
|
@@ -7214,8 +7313,8 @@ async function setupWorktree(projectRoot, prRef, baseBranch, onWorktreeCreated)
|
|
|
7214
7313
|
async function cleanupWorktree(worktreePath, projectRoot) {
|
|
7215
7314
|
const removeResult = await runGit2(["worktree", "remove", "--force", worktreePath], projectRoot);
|
|
7216
7315
|
try {
|
|
7217
|
-
if (
|
|
7218
|
-
|
|
7316
|
+
if (_internals12.fs.existsSync(worktreePath)) {
|
|
7317
|
+
_internals12.fs.rmSync(worktreePath, { recursive: true, force: true });
|
|
7219
7318
|
}
|
|
7220
7319
|
} catch {}
|
|
7221
7320
|
if (removeResult.exitCode !== 0) {
|
|
@@ -7297,7 +7396,7 @@ async function handleCiSimulateCommand(directory, args) {
|
|
|
7297
7396
|
steps: []
|
|
7298
7397
|
};
|
|
7299
7398
|
try {
|
|
7300
|
-
const baseBranch =
|
|
7399
|
+
const baseBranch = _internals12.getDefaultBaseBranch(directory);
|
|
7301
7400
|
if (!isSafeGitRef(baseBranch)) {
|
|
7302
7401
|
throw new Error("Detected default branch is not a safe git reference.");
|
|
7303
7402
|
}
|
|
@@ -8085,7 +8184,7 @@ async function reviseSkill(params) {
|
|
|
8085
8184
|
}
|
|
8086
8185
|
if (!params.delegate) {
|
|
8087
8186
|
try {
|
|
8088
|
-
const revised =
|
|
8187
|
+
const revised = _internals13.buildDeterministicRevision(params.currentContent, params.currentVersion, params.violationContexts);
|
|
8089
8188
|
const validation = await validateRevisionCandidate(params, revised, "skill_reviser:deterministic");
|
|
8090
8189
|
if (!validation.passed) {
|
|
8091
8190
|
return {
|
|
@@ -8212,7 +8311,7 @@ async function reviseSkill(params) {
|
|
|
8212
8311
|
};
|
|
8213
8312
|
}
|
|
8214
8313
|
}
|
|
8215
|
-
var
|
|
8314
|
+
var _internals13 = {
|
|
8216
8315
|
reviseSkill,
|
|
8217
8316
|
getSkillVersion,
|
|
8218
8317
|
buildDeterministicRevision,
|
|
@@ -8296,7 +8395,7 @@ function resolveLogPath(directory) {
|
|
|
8296
8395
|
function normalizeComplianceVerdict(verdict) {
|
|
8297
8396
|
return verdict === "violation" ? "violated" : verdict;
|
|
8298
8397
|
}
|
|
8299
|
-
var
|
|
8398
|
+
var _internals14 = {
|
|
8300
8399
|
generateId: () => crypto2.randomUUID(),
|
|
8301
8400
|
appendFileSync: fs6.appendFileSync.bind(fs6),
|
|
8302
8401
|
readFileSync: fs6.readFileSync.bind(fs6),
|
|
@@ -8366,9 +8465,9 @@ function parseFeedbackMarker(raw) {
|
|
|
8366
8465
|
function readFeedbackAppliedEntryIds(directory) {
|
|
8367
8466
|
const resolved = resolveLogPath(directory);
|
|
8368
8467
|
const processed = new Set;
|
|
8369
|
-
if (!
|
|
8468
|
+
if (!_internals14.existsSync(resolved))
|
|
8370
8469
|
return processed;
|
|
8371
|
-
const raw =
|
|
8470
|
+
const raw = _internals14.readFileSync(resolved, "utf-8");
|
|
8372
8471
|
for (const line of raw.split(`
|
|
8373
8472
|
`)) {
|
|
8374
8473
|
const trimmed = line.trim();
|
|
@@ -8389,15 +8488,15 @@ function appendFeedbackAppliedMarker(directory, processedEntryIds) {
|
|
|
8389
8488
|
return;
|
|
8390
8489
|
const resolved = resolveLogPath(directory);
|
|
8391
8490
|
const dir = path16.dirname(resolved);
|
|
8392
|
-
if (!
|
|
8393
|
-
|
|
8491
|
+
if (!_internals14.existsSync(dir)) {
|
|
8492
|
+
_internals14.mkdirSync(dir, { recursive: true });
|
|
8394
8493
|
}
|
|
8395
8494
|
const marker = {
|
|
8396
8495
|
type: "feedback_applied",
|
|
8397
8496
|
timestamp: new Date().toISOString(),
|
|
8398
8497
|
processedEntryIds: [...new Set(processedEntryIds)]
|
|
8399
8498
|
};
|
|
8400
|
-
|
|
8499
|
+
_internals14.appendFileSync(resolved, `${JSON.stringify(marker)}
|
|
8401
8500
|
`, "utf-8");
|
|
8402
8501
|
}
|
|
8403
8502
|
function appendSkillUsageEntry(directory, entry) {
|
|
@@ -8434,11 +8533,11 @@ function appendSkillUsageEntry(directory, entry) {
|
|
|
8434
8533
|
}
|
|
8435
8534
|
const resolved = validateSwarmPath(directory, "skill-usage.jsonl");
|
|
8436
8535
|
const dir = path16.dirname(resolved);
|
|
8437
|
-
if (!
|
|
8438
|
-
|
|
8536
|
+
if (!_internals14.existsSync(dir)) {
|
|
8537
|
+
_internals14.mkdirSync(dir, { recursive: true });
|
|
8439
8538
|
}
|
|
8440
8539
|
const fullEntry = {
|
|
8441
|
-
id:
|
|
8540
|
+
id: _internals14.generateId(),
|
|
8442
8541
|
skillPath,
|
|
8443
8542
|
agentName,
|
|
8444
8543
|
taskID,
|
|
@@ -8448,21 +8547,21 @@ function appendSkillUsageEntry(directory, entry) {
|
|
|
8448
8547
|
...reviewerNotes !== undefined && { reviewerNotes },
|
|
8449
8548
|
...skillVersion !== undefined && { skillVersion }
|
|
8450
8549
|
};
|
|
8451
|
-
|
|
8550
|
+
_internals14.appendFileSync(resolved, `${JSON.stringify(fullEntry)}
|
|
8452
8551
|
`, "utf-8");
|
|
8453
8552
|
try {
|
|
8454
|
-
const stat2 =
|
|
8553
|
+
const stat2 = _internals14.statSync(resolved);
|
|
8455
8554
|
if (stat2.size > SKILL_USAGE_LOG_ROTATE_BYTES) {
|
|
8456
|
-
|
|
8555
|
+
_internals14.pruneSkillUsageLog(directory, SKILL_USAGE_LOG_MAX_ENTRIES_PER_SKILL);
|
|
8457
8556
|
}
|
|
8458
8557
|
} catch {}
|
|
8459
8558
|
}
|
|
8460
8559
|
function readSkillUsageEntries(directory, options) {
|
|
8461
8560
|
const resolved = resolveLogPath(directory);
|
|
8462
|
-
if (!
|
|
8561
|
+
if (!_internals14.existsSync(resolved)) {
|
|
8463
8562
|
return [];
|
|
8464
8563
|
}
|
|
8465
|
-
const raw =
|
|
8564
|
+
const raw = _internals14.readFileSync(resolved, "utf-8");
|
|
8466
8565
|
const entries = [];
|
|
8467
8566
|
for (const line of raw.split(`
|
|
8468
8567
|
`)) {
|
|
@@ -8505,20 +8604,20 @@ var SKILL_USAGE_LOG_ROTATE_BYTES = 1024 * 1024;
|
|
|
8505
8604
|
var SKILL_USAGE_LOG_MAX_ENTRIES_PER_SKILL = 500;
|
|
8506
8605
|
function readSkillUsageEntriesTail(directory, filters, maxBytes = TAIL_BYTES_DEFAULT) {
|
|
8507
8606
|
const logPath = resolveLogPath(directory);
|
|
8508
|
-
if (!
|
|
8607
|
+
if (!_internals14.existsSync(logPath))
|
|
8509
8608
|
return [];
|
|
8510
8609
|
try {
|
|
8511
8610
|
const normalizedMaxBytes = Number.isFinite(maxBytes) ? maxBytes : TAIL_BYTES_DEFAULT;
|
|
8512
8611
|
const boundedMaxBytes = Math.min(Math.max(1, normalizedMaxBytes), MAX_TAIL_BYTES);
|
|
8513
|
-
const stat2 =
|
|
8612
|
+
const stat2 = _internals14.statSync(logPath);
|
|
8514
8613
|
const start = Math.max(0, stat2.size - boundedMaxBytes);
|
|
8515
|
-
const fd =
|
|
8614
|
+
const fd = _internals14.openSync(logPath, "r");
|
|
8516
8615
|
try {
|
|
8517
8616
|
const readLen = stat2.size - start;
|
|
8518
8617
|
if (readLen === 0)
|
|
8519
8618
|
return [];
|
|
8520
8619
|
const buf = Buffer.alloc(readLen);
|
|
8521
|
-
|
|
8620
|
+
_internals14.readSync(fd, buf, 0, buf.length, start);
|
|
8522
8621
|
const content = buf.toString("utf-8");
|
|
8523
8622
|
let usable;
|
|
8524
8623
|
if (start > 0) {
|
|
@@ -8545,7 +8644,7 @@ function readSkillUsageEntriesTail(directory, filters, maxBytes = TAIL_BYTES_DEF
|
|
|
8545
8644
|
}
|
|
8546
8645
|
return entries;
|
|
8547
8646
|
} finally {
|
|
8548
|
-
|
|
8647
|
+
_internals14.closeSync(fd);
|
|
8549
8648
|
}
|
|
8550
8649
|
} catch {
|
|
8551
8650
|
return [];
|
|
@@ -8582,10 +8681,10 @@ function computeComplianceByVersion(entries, skillPath) {
|
|
|
8582
8681
|
}
|
|
8583
8682
|
function pruneSkillUsageLog(directory, maxEntriesPerSkill = 500) {
|
|
8584
8683
|
const resolved = resolveLogPath(directory);
|
|
8585
|
-
if (!
|
|
8684
|
+
if (!_internals14.existsSync(resolved)) {
|
|
8586
8685
|
return { pruned: 0, remaining: 0 };
|
|
8587
8686
|
}
|
|
8588
|
-
const raw =
|
|
8687
|
+
const raw = _internals14.readFileSync(resolved, "utf-8");
|
|
8589
8688
|
const lines = raw.split(`
|
|
8590
8689
|
`);
|
|
8591
8690
|
const entries = [];
|
|
@@ -8615,13 +8714,13 @@ function pruneSkillUsageLog(directory, maxEntriesPerSkill = 500) {
|
|
|
8615
8714
|
`).concat(preservedMarkers.length > 0 ? `
|
|
8616
8715
|
` : "");
|
|
8617
8716
|
try {
|
|
8618
|
-
|
|
8619
|
-
|
|
8717
|
+
_internals14.writeFileSync(tmpPath2, content2, "utf-8");
|
|
8718
|
+
_internals14.renameSync(tmpPath2, resolved);
|
|
8620
8719
|
} catch (writeErr) {
|
|
8621
8720
|
const msg = writeErr instanceof Error ? writeErr.message : String(writeErr);
|
|
8622
8721
|
try {
|
|
8623
|
-
if (
|
|
8624
|
-
|
|
8722
|
+
if (_internals14.existsSync(tmpPath2)) {
|
|
8723
|
+
_internals14.writeFileSync(tmpPath2, "", "utf-8");
|
|
8625
8724
|
}
|
|
8626
8725
|
} catch {}
|
|
8627
8726
|
return { pruned: 0, remaining: 0, error: msg };
|
|
@@ -8660,13 +8759,13 @@ function pruneSkillUsageLog(directory, maxEntriesPerSkill = 500) {
|
|
|
8660
8759
|
`).concat(`
|
|
8661
8760
|
`);
|
|
8662
8761
|
try {
|
|
8663
|
-
|
|
8664
|
-
|
|
8762
|
+
_internals14.writeFileSync(tmpPath, content, "utf-8");
|
|
8763
|
+
_internals14.renameSync(tmpPath, resolved);
|
|
8665
8764
|
} catch (writeErr) {
|
|
8666
8765
|
const msg = writeErr instanceof Error ? writeErr.message : String(writeErr);
|
|
8667
8766
|
try {
|
|
8668
|
-
if (
|
|
8669
|
-
|
|
8767
|
+
if (_internals14.existsSync(tmpPath)) {
|
|
8768
|
+
_internals14.writeFileSync(tmpPath, "", "utf-8");
|
|
8670
8769
|
}
|
|
8671
8770
|
} catch {}
|
|
8672
8771
|
return { pruned: 0, remaining: entries.length, error: msg };
|
|
@@ -8688,10 +8787,10 @@ async function resolveSourceKnowledgeIds(directory, skillPath) {
|
|
|
8688
8787
|
if (!isContained) {
|
|
8689
8788
|
return [];
|
|
8690
8789
|
}
|
|
8691
|
-
if (!
|
|
8790
|
+
if (!_internals14.existsSync(absolute)) {
|
|
8692
8791
|
return [];
|
|
8693
8792
|
}
|
|
8694
|
-
const content =
|
|
8793
|
+
const content = _internals14.readFileSync(absolute, "utf-8");
|
|
8695
8794
|
return parseGeneratedFromKnowledge(content);
|
|
8696
8795
|
} catch (err) {
|
|
8697
8796
|
log("[skill-usage-log] resolveSourceKnowledgeIds failed (fail-open):", err instanceof Error ? err.message : String(err));
|
|
@@ -8799,7 +8898,7 @@ var DEFAULT_CURATOR_LLM_TIMEOUT_MS = 300000;
|
|
|
8799
8898
|
var MAX_CURATOR_PHASE_DIGESTS = 50;
|
|
8800
8899
|
var MAX_CURATOR_COMPLIANCE_OBSERVATIONS = 200;
|
|
8801
8900
|
var MAX_CURATOR_RECOMMENDATIONS = 200;
|
|
8802
|
-
var
|
|
8901
|
+
var _internals15 = {
|
|
8803
8902
|
parseKnowledgeRecommendations,
|
|
8804
8903
|
parseKnowledgeRecommendationsWithDiagnostics,
|
|
8805
8904
|
readCuratorSummary,
|
|
@@ -8905,9 +9004,9 @@ ${digest.summary}`).join(`
|
|
|
8905
9004
|
async function autoRetireSkills(directory, _curatorKnowledgePath, excludeSlugs) {
|
|
8906
9005
|
const observations = [];
|
|
8907
9006
|
try {
|
|
8908
|
-
const skillListResult = await
|
|
8909
|
-
const usageEntries =
|
|
8910
|
-
const allArchivedIds = await
|
|
9007
|
+
const skillListResult = await _internals15.listSkills(directory);
|
|
9008
|
+
const usageEntries = _internals15.readSkillUsageEntries(directory);
|
|
9009
|
+
const allArchivedIds = await _internals15.getArchivedKnowledgeIds(directory);
|
|
8911
9010
|
for (const active of skillListResult.active) {
|
|
8912
9011
|
if (excludeSlugs?.has(active.slug))
|
|
8913
9012
|
continue;
|
|
@@ -8929,7 +9028,7 @@ async function autoRetireSkills(directory, _curatorKnowledgePath, excludeSlugs)
|
|
|
8929
9028
|
const violationRate = skillUsage.length > 0 ? violations / skillUsage.length : 0;
|
|
8930
9029
|
if (violationRate > 0.3) {
|
|
8931
9030
|
const reason = `auto-retire: violation rate ${(violationRate * 100).toFixed(0)}% exceeds 30% threshold`;
|
|
8932
|
-
await
|
|
9031
|
+
await _internals15.retireSkill(directory, active.slug, reason);
|
|
8933
9032
|
observations.push(`Skill '${active.slug}' auto-retired: ${reason}`);
|
|
8934
9033
|
warn(`[curator] ${observations[observations.length - 1]}`);
|
|
8935
9034
|
continue;
|
|
@@ -8937,15 +9036,15 @@ async function autoRetireSkills(directory, _curatorKnowledgePath, excludeSlugs)
|
|
|
8937
9036
|
let archivedSourceMatched = false;
|
|
8938
9037
|
if (allArchivedIds.size > 0) {
|
|
8939
9038
|
try {
|
|
8940
|
-
const content = await
|
|
8941
|
-
const sourceIds =
|
|
9039
|
+
const content = await _internals15.readFileAsync(active.path, "utf-8");
|
|
9040
|
+
const sourceIds = _internals15.parseDraftFrontmatter(content)?.sourceKnowledgeIds ?? [];
|
|
8942
9041
|
archivedSourceMatched = sourceIds.some((id) => allArchivedIds.has(id));
|
|
8943
9042
|
} catch {
|
|
8944
9043
|
archivedSourceMatched = false;
|
|
8945
9044
|
}
|
|
8946
9045
|
}
|
|
8947
9046
|
if (archivedSourceMatched) {
|
|
8948
|
-
const result = await
|
|
9047
|
+
const result = await _internals15.retireOrMarkStale(directory, path17.dirname(active.path), allArchivedIds);
|
|
8949
9048
|
if (result.action === "retire") {
|
|
8950
9049
|
observations.push(`Skill '${active.slug}' auto-retired: all source knowledge entries archived`);
|
|
8951
9050
|
warn(`[curator] ${observations[observations.length - 1]}`);
|
|
@@ -9213,7 +9312,7 @@ async function transactCuratorSummary(directory, mutate) {
|
|
|
9213
9312
|
const resolvedPath = validateSwarmPath(directory, "curator-summary.json");
|
|
9214
9313
|
let invoked = false;
|
|
9215
9314
|
let mutationResult;
|
|
9216
|
-
await
|
|
9315
|
+
await _internals15.transactFile(resolvedPath, _internals15.readCuratorSummaryState, _internals15.writeCuratorSummaryState, (state) => {
|
|
9217
9316
|
invoked = true;
|
|
9218
9317
|
const mutation = mutate(state.summary);
|
|
9219
9318
|
mutationResult = mutation.result;
|
|
@@ -9362,8 +9461,8 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
|
|
|
9362
9461
|
const observations = [];
|
|
9363
9462
|
const timestamp = new Date().toISOString();
|
|
9364
9463
|
for (const agent of requiredAgents) {
|
|
9365
|
-
const normalizedAgent =
|
|
9366
|
-
const isDispatched = agentsDispatched.some((a) =>
|
|
9464
|
+
const normalizedAgent = _internals15.normalizeAgentName(agent);
|
|
9465
|
+
const isDispatched = agentsDispatched.some((a) => _internals15.normalizeAgentName(a) === normalizedAgent);
|
|
9367
9466
|
if (!isDispatched) {
|
|
9368
9467
|
observations.push({
|
|
9369
9468
|
phase,
|
|
@@ -9382,7 +9481,7 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
|
|
|
9382
9481
|
if (e.type === "agent.delegation") {
|
|
9383
9482
|
const agent = e.agent;
|
|
9384
9483
|
if (agent && typeof agent === "string") {
|
|
9385
|
-
const normalized =
|
|
9484
|
+
const normalized = _internals15.normalizeAgentName(agent);
|
|
9386
9485
|
if (normalized === "coder") {
|
|
9387
9486
|
coderDelegations.push({ event: e, index: i });
|
|
9388
9487
|
} else if (normalized === "reviewer") {
|
|
@@ -9439,7 +9538,7 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
|
|
|
9439
9538
|
if (e.type === "agent.delegation" && e.agent) {
|
|
9440
9539
|
const agent = e.agent;
|
|
9441
9540
|
if (agent && typeof agent === "string") {
|
|
9442
|
-
const normalized =
|
|
9541
|
+
const normalized = _internals15.normalizeAgentName(agent);
|
|
9443
9542
|
if (normalized === "sme") {
|
|
9444
9543
|
smeDelegations.push({ event: e, index: i });
|
|
9445
9544
|
}
|
|
@@ -9463,7 +9562,7 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
|
|
|
9463
9562
|
}
|
|
9464
9563
|
async function runCuratorInit(directory, config, llmDelegate) {
|
|
9465
9564
|
try {
|
|
9466
|
-
const priorSummary = await
|
|
9565
|
+
const priorSummary = await _internals15.readCuratorSummary(directory);
|
|
9467
9566
|
const knowledgePath = resolveSwarmKnowledgePath(directory);
|
|
9468
9567
|
const allEntries = await readKnowledge(knowledgePath);
|
|
9469
9568
|
const highConfidenceEntries = allEntries.filter((e) => typeof e.confidence === "number" && e.confidence >= config.min_knowledge_confidence);
|
|
@@ -9504,7 +9603,7 @@ async function runCuratorInit(directory, config, llmDelegate) {
|
|
|
9504
9603
|
const maxContextChars = config.max_summary_tokens * 2;
|
|
9505
9604
|
briefingParts.push(contextMd.slice(0, maxContextChars));
|
|
9506
9605
|
}
|
|
9507
|
-
const latestPostMortemDigest =
|
|
9606
|
+
const latestPostMortemDigest = _internals15.readLatestPostMortemDigest(directory);
|
|
9508
9607
|
if (latestPostMortemDigest) {
|
|
9509
9608
|
briefingParts.push(`
|
|
9510
9609
|
## Latest Post-Mortem`);
|
|
@@ -9591,7 +9690,7 @@ Could not load prior session context.`,
|
|
|
9591
9690
|
}
|
|
9592
9691
|
async function runCuratorPhase(directory, phase, agentsDispatched, config, knowledgeConfig, llmDelegate) {
|
|
9593
9692
|
try {
|
|
9594
|
-
const priorSummary = await
|
|
9693
|
+
const priorSummary = await _internals15.readCuratorSummary(directory);
|
|
9595
9694
|
if (priorSummary?.phase_digests.some((d) => d.phase === phase)) {
|
|
9596
9695
|
const existingDigest = priorSummary.phase_digests.find((d) => d.phase === phase);
|
|
9597
9696
|
return {
|
|
@@ -9604,10 +9703,10 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
|
|
|
9604
9703
|
};
|
|
9605
9704
|
}
|
|
9606
9705
|
const eventsJsonlContent = await readSwarmFileAsync(directory, "events.jsonl");
|
|
9607
|
-
const phaseEvents = eventsJsonlContent ?
|
|
9706
|
+
const phaseEvents = eventsJsonlContent ? _internals15.filterPhaseEvents(eventsJsonlContent, phase) : [];
|
|
9608
9707
|
const contextMd = await readSwarmFileAsync(directory, "context.md");
|
|
9609
9708
|
const requiredAgents = ["reviewer", "test_engineer"];
|
|
9610
|
-
const complianceObservations =
|
|
9709
|
+
const complianceObservations = _internals15.checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, phase);
|
|
9611
9710
|
const plan = await loadPlanJsonOnly(directory);
|
|
9612
9711
|
const phaseData = plan?.phases.find((p) => p.id === phase);
|
|
9613
9712
|
const tasksCompleted = phaseData ? phaseData.tasks.filter((t) => t.status === "completed").length : 0;
|
|
@@ -9631,7 +9730,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
|
|
|
9631
9730
|
timestamp: new Date().toISOString(),
|
|
9632
9731
|
summary: `Phase ${phase} completed. ${tasksCompleted}/${tasksTotal} tasks completed. ${complianceObservations.length} compliance observations.`,
|
|
9633
9732
|
agents_used: [
|
|
9634
|
-
...new Set(agentsDispatched.map((a) =>
|
|
9733
|
+
...new Set(agentsDispatched.map((a) => _internals15.normalizeAgentName(a)))
|
|
9635
9734
|
],
|
|
9636
9735
|
tasks_completed: tasksCompleted,
|
|
9637
9736
|
tasks_total: tasksTotal,
|
|
@@ -9683,7 +9782,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
|
|
|
9683
9782
|
clearTimeout(timer);
|
|
9684
9783
|
}
|
|
9685
9784
|
if (llmOutput?.trim()) {
|
|
9686
|
-
const parsed =
|
|
9785
|
+
const parsed = _internals15.parseKnowledgeRecommendationsWithDiagnostics(llmOutput);
|
|
9687
9786
|
for (const diagnostic of parsed.diagnostics) {
|
|
9688
9787
|
warn("[curator] skipped malformed recommendation line", {
|
|
9689
9788
|
phase,
|
|
@@ -9728,7 +9827,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
|
|
|
9728
9827
|
}
|
|
9729
9828
|
const sessionId = `session-${Date.now()}`;
|
|
9730
9829
|
const now = new Date().toISOString();
|
|
9731
|
-
const summaryUpdated = await
|
|
9830
|
+
const summaryUpdated = await _internals15.mergeCuratorPhaseSummary(directory, {
|
|
9732
9831
|
phase,
|
|
9733
9832
|
phaseDigest,
|
|
9734
9833
|
complianceObservations,
|
|
@@ -9777,8 +9876,8 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
|
|
|
9777
9876
|
}
|
|
9778
9877
|
const revisedSlugs = new Set;
|
|
9779
9878
|
try {
|
|
9780
|
-
const skillListResult = await
|
|
9781
|
-
const usageEntries =
|
|
9879
|
+
const skillListResult = await _internals15.listSkills(directory);
|
|
9880
|
+
const usageEntries = _internals15.readSkillUsageEntries(directory);
|
|
9782
9881
|
let revisionCallsThisPhase = 0;
|
|
9783
9882
|
for (const active of skillListResult.active) {
|
|
9784
9883
|
if (revisionCallsThisPhase >= MAX_REVISION_CALLS_PER_PHASE)
|
|
@@ -9802,8 +9901,8 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
|
|
|
9802
9901
|
const violations = skillUsage.filter((e) => e.complianceVerdict === "violated").length;
|
|
9803
9902
|
const violationRate = violations / skillUsage.length;
|
|
9804
9903
|
if (violationRate > REVISION_VIOLATION_THRESHOLD && violationRate <= 0.3) {
|
|
9805
|
-
const content = await
|
|
9806
|
-
const fm =
|
|
9904
|
+
const content = await _internals15.readFileAsync(active.path, "utf-8");
|
|
9905
|
+
const fm = _internals15.parseDraftFrontmatter(content);
|
|
9807
9906
|
if (fm && fm.skillOrigin === "promoted_external")
|
|
9808
9907
|
continue;
|
|
9809
9908
|
const currentVersion = fm?.version ?? 1;
|
|
@@ -9814,7 +9913,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
|
|
|
9814
9913
|
reviewerNotes: e.reviewerNotes,
|
|
9815
9914
|
timestamp: e.timestamp
|
|
9816
9915
|
}));
|
|
9817
|
-
const result2 = await
|
|
9916
|
+
const result2 = await _internals15.reviseSkill({
|
|
9818
9917
|
directory,
|
|
9819
9918
|
slug: active.slug,
|
|
9820
9919
|
skillPath: active.path,
|
|
@@ -9833,7 +9932,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
|
|
|
9833
9932
|
} catch (revisionErr) {
|
|
9834
9933
|
warn(`[curator] skill revision check failed: ${revisionErr instanceof Error ? revisionErr.message : String(revisionErr)}`);
|
|
9835
9934
|
}
|
|
9836
|
-
const autoRetireObservations = await
|
|
9935
|
+
const autoRetireObservations = await _internals15.autoRetireSkills(directory, curatorKnowledgePath, revisedSlugs);
|
|
9837
9936
|
if (autoRetireObservations.length > 0) {
|
|
9838
9937
|
const retireNote = ` [${autoRetireObservations.length} skill(s) auto-retired]`;
|
|
9839
9938
|
phaseDigest.summary += retireNote;
|
|
@@ -9928,7 +10027,7 @@ async function applyCuratorKnowledgeUpdates(directory, recommendations, knowledg
|
|
|
9928
10027
|
const knowledgePath = resolveSwarmKnowledgePath(directory);
|
|
9929
10028
|
const authorizedRevisions = new Map;
|
|
9930
10029
|
if (validRecommendations.length > 0) {
|
|
9931
|
-
const preSnapshot = await
|
|
10030
|
+
const preSnapshot = await _internals15.readKnowledge(knowledgePath);
|
|
9932
10031
|
const authorizedRecs = [];
|
|
9933
10032
|
for (const rec of validRecommendations) {
|
|
9934
10033
|
if (rec.action !== "archive" && rec.action !== "rewrite") {
|
|
@@ -10461,18 +10560,18 @@ async function executePostMortemActions(directory, parsed, options, generation)
|
|
|
10461
10560
|
proposals_rejected: 0,
|
|
10462
10561
|
proposals_skipped: 0
|
|
10463
10562
|
};
|
|
10464
|
-
const knowledgeConfig = options.knowledgeConfig ?? await
|
|
10563
|
+
const knowledgeConfig = options.knowledgeConfig ?? await _internals16.loadDefaultKnowledgeConfig(directory);
|
|
10465
10564
|
if (parsed.recommendations.length > 0) {
|
|
10466
10565
|
try {
|
|
10467
|
-
const knowledgeResult = await
|
|
10566
|
+
const knowledgeResult = await _internals16.applyCuratorKnowledgeUpdates(directory, parsed.recommendations, knowledgeConfig, generation);
|
|
10468
10567
|
result.knowledge_applied = knowledgeResult.applied;
|
|
10469
10568
|
result.knowledge_skipped = knowledgeResult.skipped;
|
|
10470
10569
|
} catch (err) {
|
|
10471
10570
|
warnings.push(`Post-mortem knowledge actions failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
10472
10571
|
}
|
|
10473
10572
|
try {
|
|
10474
|
-
const entries = await
|
|
10475
|
-
const hiveResult = await
|
|
10573
|
+
const entries = await _internals16.readSwarmKnowledge(directory);
|
|
10574
|
+
const hiveResult = await _internals16.checkHivePromotions(entries, knowledgeConfig, directory);
|
|
10476
10575
|
result.hive_promotions = hiveResult.new_promotions;
|
|
10477
10576
|
result.hive_encounters_incremented = hiveResult.encounters_incremented;
|
|
10478
10577
|
result.hive_advancements = hiveResult.advancements;
|
|
@@ -10482,7 +10581,7 @@ async function executePostMortemActions(directory, parsed, options, generation)
|
|
|
10482
10581
|
}
|
|
10483
10582
|
if (parsed.queueTriage.length > 0) {
|
|
10484
10583
|
try {
|
|
10485
|
-
const proposalResult = await
|
|
10584
|
+
const proposalResult = await _internals16.applyProposalTriage(directory, parsed.queueTriage);
|
|
10486
10585
|
result.proposals_approved = proposalResult.approved.length;
|
|
10487
10586
|
result.proposals_rejected = proposalResult.rejected.length;
|
|
10488
10587
|
result.proposals_skipped = proposalResult.skipped.length;
|
|
@@ -10495,7 +10594,7 @@ async function executePostMortemActions(directory, parsed, options, generation)
|
|
|
10495
10594
|
async function verifyPostMortemKnowledgeActions(directory, recommendations) {
|
|
10496
10595
|
if (recommendations.length === 0)
|
|
10497
10596
|
return [];
|
|
10498
|
-
const entries = await
|
|
10597
|
+
const entries = await _internals16.readSwarmKnowledge(directory);
|
|
10499
10598
|
const activeEntries = entries.filter((entry) => isActiveStatus(entry.status));
|
|
10500
10599
|
const exactIds = new Set(activeEntries.map((entry) => entry.id));
|
|
10501
10600
|
const prefixMatches = new Map;
|
|
@@ -10596,7 +10695,7 @@ async function repairPostMortemActions(llmOutput, diagnostics, options) {
|
|
|
10596
10695
|
].join(`
|
|
10597
10696
|
`);
|
|
10598
10697
|
const repaired = await options.llmDelegate("", repairPrompt, ac.signal);
|
|
10599
|
-
const parsed =
|
|
10698
|
+
const parsed = _internals16.parsePostMortemActions(repaired);
|
|
10600
10699
|
if (parsed.diagnostics.length === 0) {
|
|
10601
10700
|
return parsed;
|
|
10602
10701
|
}
|
|
@@ -10649,7 +10748,7 @@ function collectRetrospectives(directory) {
|
|
|
10649
10748
|
}
|
|
10650
10749
|
async function collectDriftReports(directory) {
|
|
10651
10750
|
try {
|
|
10652
|
-
const reports = await
|
|
10751
|
+
const reports = await _internals16.readPriorDriftReports(directory);
|
|
10653
10752
|
return reports.slice(-MAX_DRIFT_REPORTS).map((report) => JSON.stringify(report, null, 2));
|
|
10654
10753
|
} catch {
|
|
10655
10754
|
return [];
|
|
@@ -10872,7 +10971,7 @@ async function runCuratorPostMortem(directory, options = {}) {
|
|
|
10872
10971
|
warnings
|
|
10873
10972
|
};
|
|
10874
10973
|
}
|
|
10875
|
-
const lock = await
|
|
10974
|
+
const lock = await _internals16.acquirePostMortemLock(directory, effectivePlanId);
|
|
10876
10975
|
if (!lock.acquired) {
|
|
10877
10976
|
return {
|
|
10878
10977
|
success: false,
|
|
@@ -10953,20 +11052,20 @@ async function runCuratorPostMortem(directory, options = {}) {
|
|
|
10953
11052
|
} finally {
|
|
10954
11053
|
clearTimeout(timer);
|
|
10955
11054
|
}
|
|
10956
|
-
let parsedActions =
|
|
11055
|
+
let parsedActions = _internals16.parsePostMortemActions(llmOutput);
|
|
10957
11056
|
if (parsedActions.diagnostics.length > 0) {
|
|
10958
11057
|
warnings.push(`Post-mortem structured action parse diagnostics: ${parsedActions.diagnostics.join("; ")}`);
|
|
10959
|
-
const repaired = await
|
|
11058
|
+
const repaired = await _internals16.repairPostMortemActions(llmOutput, parsedActions.diagnostics, options);
|
|
10960
11059
|
if (repaired) {
|
|
10961
11060
|
parsedActions = repaired;
|
|
10962
11061
|
warnings.push("Post-mortem structured actions repaired by LLM.");
|
|
10963
11062
|
}
|
|
10964
11063
|
}
|
|
10965
11064
|
llmSummary = parsedActions.summary;
|
|
10966
|
-
const executed = await
|
|
11065
|
+
const executed = await _internals16.executePostMortemActions(directory, parsedActions, options, scanCursor.generation);
|
|
10967
11066
|
actionResult = executed.result;
|
|
10968
11067
|
warnings.push(...executed.warnings);
|
|
10969
|
-
const knowledgeVerification = await
|
|
11068
|
+
const knowledgeVerification = await _internals16.verifyPostMortemKnowledgeActions(directory, parsedActions.recommendations);
|
|
10970
11069
|
for (const item of knowledgeVerification) {
|
|
10971
11070
|
if (item.status === "not_found" || item.status === "ambiguous_prefix" || item.status === "missing_entry_id") {
|
|
10972
11071
|
warnings.push(`Post-mortem knowledge action ${item.action} for '${item.input_entry_id ?? "new"}' ${item.status}: ${item.reason}`);
|
|
@@ -11005,10 +11104,10 @@ ${actionSummary}`;
|
|
|
11005
11104
|
} catch (err) {
|
|
11006
11105
|
const msg = err instanceof Error ? err.message : String(err);
|
|
11007
11106
|
warnings.push(`LLM delegate failed, falling back to data-only report: ${msg}`);
|
|
11008
|
-
reportContent =
|
|
11107
|
+
reportContent = _internals16.buildDataOnlyReport(effectivePlanId, planSummary, knowledgeSummary, curatorDigest, proposals, unactionable, retrospectives, driftReports, { scope, sessionID: options.sessionID, planLoaded });
|
|
11009
11108
|
}
|
|
11010
11109
|
} else {
|
|
11011
|
-
reportContent =
|
|
11110
|
+
reportContent = _internals16.buildDataOnlyReport(effectivePlanId, planSummary, knowledgeSummary, curatorDigest, proposals, unactionable, retrospectives, driftReports, { scope, sessionID: options.sessionID, planLoaded });
|
|
11012
11111
|
}
|
|
11013
11112
|
try {
|
|
11014
11113
|
const { mkdirSync: mkdirSync8 } = await import("fs");
|
|
@@ -11049,7 +11148,7 @@ ${actionSummary}`;
|
|
|
11049
11148
|
}
|
|
11050
11149
|
}
|
|
11051
11150
|
}
|
|
11052
|
-
var
|
|
11151
|
+
var _internals16 = {
|
|
11053
11152
|
acquirePostMortemLock,
|
|
11054
11153
|
collectKnowledgeSummary,
|
|
11055
11154
|
collectRetrospectives,
|
|
@@ -11076,11 +11175,11 @@ var _internals15 = {
|
|
|
11076
11175
|
}
|
|
11077
11176
|
},
|
|
11078
11177
|
applyCuratorKnowledgeUpdates: async (directory, recommendations, knowledgeConfig, generation) => {
|
|
11079
|
-
const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-
|
|
11178
|
+
const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-3azybqrw.js");
|
|
11080
11179
|
return applyCuratorKnowledgeUpdates2(directory, recommendations, knowledgeConfig, generation);
|
|
11081
11180
|
},
|
|
11082
11181
|
checkHivePromotions: async (entries, knowledgeConfig, directory) => {
|
|
11083
|
-
const { checkHivePromotions } = await import("./hive-promoter-
|
|
11182
|
+
const { checkHivePromotions } = await import("./hive-promoter-4xnj3fdk.js");
|
|
11084
11183
|
return checkHivePromotions(entries, knowledgeConfig, directory);
|
|
11085
11184
|
},
|
|
11086
11185
|
applyProposalTriage: async (directory, triage) => {
|
|
@@ -11228,10 +11327,10 @@ var HIVE_LOCK_RETRIES = {
|
|
|
11228
11327
|
retries: { retries: 5, minTimeout: 100, maxTimeout: 500 }
|
|
11229
11328
|
};
|
|
11230
11329
|
async function transactHiveStore(mutate) {
|
|
11231
|
-
const dataDir =
|
|
11232
|
-
const hivePath =
|
|
11233
|
-
const rejectedPath =
|
|
11234
|
-
const eventsPath =
|
|
11330
|
+
const dataDir = _internals17.resolveHiveDataDir();
|
|
11331
|
+
const hivePath = _internals17.resolveHiveKnowledgePath();
|
|
11332
|
+
const rejectedPath = _internals17.resolveHiveRejectedPath();
|
|
11333
|
+
const eventsPath = _internals17.resolveHiveEventsPath();
|
|
11235
11334
|
const diagnostics = [];
|
|
11236
11335
|
try {
|
|
11237
11336
|
await mkdir6(dataDir, { recursive: true });
|
|
@@ -11242,7 +11341,7 @@ async function transactHiveStore(mutate) {
|
|
|
11242
11341
|
let release = null;
|
|
11243
11342
|
try {
|
|
11244
11343
|
try {
|
|
11245
|
-
release = await
|
|
11344
|
+
release = await _internals17.lockfile.lock(dataDir, {
|
|
11246
11345
|
...HIVE_LOCK_RETRIES,
|
|
11247
11346
|
stale: HIVE_LOCK_STALE_MS
|
|
11248
11347
|
});
|
|
@@ -11250,7 +11349,7 @@ async function transactHiveStore(mutate) {
|
|
|
11250
11349
|
diagnostics.push(`hive lock acquire failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
11251
11350
|
return { committed: false, return: undefined, diagnostics };
|
|
11252
11351
|
}
|
|
11253
|
-
const entries = await
|
|
11352
|
+
const entries = await _internals17.readKnowledge(hivePath);
|
|
11254
11353
|
const outcome = await mutate({ entries });
|
|
11255
11354
|
if (outcome.kind === "noop") {
|
|
11256
11355
|
return { committed: false, return: outcome.return, diagnostics };
|
|
@@ -11271,12 +11370,12 @@ async function transactHiveStore(mutate) {
|
|
|
11271
11370
|
return { committed: false, return: undefined, diagnostics };
|
|
11272
11371
|
}
|
|
11273
11372
|
if (typeof outcome.maxEntries === "number" && committedEntries.length > outcome.maxEntries) {
|
|
11274
|
-
committedEntries =
|
|
11373
|
+
committedEntries = _internals17.selectKnowledgeCapSurvivors(committedEntries, outcome.maxEntries);
|
|
11275
11374
|
}
|
|
11276
11375
|
const content = committedEntries.map((e) => JSON.stringify(e)).join(`
|
|
11277
11376
|
`) + (committedEntries.length > 0 ? `
|
|
11278
11377
|
` : "");
|
|
11279
|
-
await
|
|
11378
|
+
await _internals17.atomicWriteFile(hivePath, content);
|
|
11280
11379
|
if (outcome.rejects && outcome.rejects.length > 0) {
|
|
11281
11380
|
const rejectBlock = `${outcome.rejects.map((r) => JSON.stringify(r)).join(`
|
|
11282
11381
|
`)}
|
|
@@ -11318,7 +11417,7 @@ async function trimHiveEventsUnderLock(eventsPath) {
|
|
|
11318
11417
|
`)}
|
|
11319
11418
|
`);
|
|
11320
11419
|
}
|
|
11321
|
-
var
|
|
11420
|
+
var _internals17 = {
|
|
11322
11421
|
lockfile: import_proper_lockfile2.default,
|
|
11323
11422
|
readKnowledge,
|
|
11324
11423
|
atomicWriteFile,
|
|
@@ -11437,8 +11536,8 @@ async function checkHivePromotions(swarmEntries, config, directory) {
|
|
|
11437
11536
|
if (config.hive_enabled === false) {
|
|
11438
11537
|
return empty;
|
|
11439
11538
|
}
|
|
11440
|
-
const sourceCohort = await
|
|
11441
|
-
const evidence = await
|
|
11539
|
+
const sourceCohort = await _internals18.resolveCohortId(directory);
|
|
11540
|
+
const evidence = await _internals18.loadPromotionEvidence(swarmEntries);
|
|
11442
11541
|
const diagnostics = [];
|
|
11443
11542
|
const activeSwarm = swarmEntries.filter((e) => isActiveStatus(e.status));
|
|
11444
11543
|
const activeSwarmBigrams = activeSwarm.map((e) => typeof e.lesson === "string" ? wordBigrams(e.lesson) : new Set);
|
|
@@ -11458,7 +11557,7 @@ async function checkHivePromotions(swarmEntries, config, directory) {
|
|
|
11458
11557
|
diagnostics.push(`skip promote '${swarmEntry.lesson.slice(0, 40)}\u2026': ${decision.reason}`);
|
|
11459
11558
|
continue;
|
|
11460
11559
|
}
|
|
11461
|
-
const validationResult =
|
|
11560
|
+
const validationResult = _internals18.validateLesson(swarmEntry.lesson, [], {
|
|
11462
11561
|
category: swarmEntry.category,
|
|
11463
11562
|
scope: swarmEntry.scope,
|
|
11464
11563
|
confidence: swarmEntry.confidence
|
|
@@ -11480,7 +11579,7 @@ async function checkHivePromotions(swarmEntries, config, directory) {
|
|
|
11480
11579
|
});
|
|
11481
11580
|
}
|
|
11482
11581
|
const hiveDir = resolveHiveDataDir();
|
|
11483
|
-
const result = await
|
|
11582
|
+
const result = await _internals18.transactHiveStore(async (ctx) => {
|
|
11484
11583
|
let newPromotions = 0;
|
|
11485
11584
|
let encounters = 0;
|
|
11486
11585
|
let advancements = 0;
|
|
@@ -11706,7 +11805,7 @@ async function authorizeAndRecordHiveMerge(args) {
|
|
|
11706
11805
|
let authorized = true;
|
|
11707
11806
|
let basis = "config-skipped-unlinked";
|
|
11708
11807
|
try {
|
|
11709
|
-
const decision = await
|
|
11808
|
+
const decision = await _internals18.authorizeCuration({
|
|
11710
11809
|
directory: hiveDir,
|
|
11711
11810
|
action: "merge",
|
|
11712
11811
|
entryId: survivingEntry.id,
|
|
@@ -11736,7 +11835,7 @@ async function authorizeAndRecordHiveMerge(args) {
|
|
|
11736
11835
|
authorizationBasis: basis
|
|
11737
11836
|
});
|
|
11738
11837
|
}
|
|
11739
|
-
var
|
|
11838
|
+
var _internals18 = {
|
|
11740
11839
|
readSwarmEntries: (directory) => readKnowledge(resolveSwarmKnowledgePath(directory)),
|
|
11741
11840
|
checkHivePromotions,
|
|
11742
11841
|
readCuratorSummary,
|
|
@@ -11750,15 +11849,15 @@ var _internals17 = {
|
|
|
11750
11849
|
};
|
|
11751
11850
|
function createHivePromoterHook(directory, config) {
|
|
11752
11851
|
const hook = async (_input, _output) => {
|
|
11753
|
-
const swarmEntries = await
|
|
11754
|
-
const promotionSummary = await
|
|
11755
|
-
const curatorSummary = await
|
|
11852
|
+
const swarmEntries = await _internals18.readSwarmEntries(directory);
|
|
11853
|
+
const promotionSummary = await _internals18.checkHivePromotions(swarmEntries, config, directory);
|
|
11854
|
+
const curatorSummary = await _internals18.readCuratorSummary(directory);
|
|
11756
11855
|
if (!curatorSummary)
|
|
11757
11856
|
return;
|
|
11758
11857
|
const hasActivity = promotionSummary.new_promotions > 0 || promotionSummary.encounters_incremented > 0 || promotionSummary.advancements > 0;
|
|
11759
11858
|
if (!hasActivity)
|
|
11760
11859
|
return;
|
|
11761
|
-
await
|
|
11860
|
+
await _internals18.appendCuratorRecommendation(directory, {
|
|
11762
11861
|
action: "promote",
|
|
11763
11862
|
lesson: `Hive promotion: ${promotionSummary.new_promotions} new, ${promotionSummary.encounters_incremented} encounters, ${promotionSummary.advancements} advancements, ${promotionSummary.total_hive_entries} total entries`,
|
|
11764
11863
|
reason: JSON.stringify({
|
|
@@ -11774,16 +11873,16 @@ function createHivePromoterHook(directory, config) {
|
|
|
11774
11873
|
}
|
|
11775
11874
|
async function promoteToHive(directory, lesson, category, options, config) {
|
|
11776
11875
|
const trimmedLesson = lesson.trim();
|
|
11777
|
-
const sourceCohort = await
|
|
11778
|
-
const policyConfig = config ??
|
|
11779
|
-
const result = await
|
|
11876
|
+
const sourceCohort = await _internals18.resolveCohortId(directory);
|
|
11877
|
+
const policyConfig = config ?? _internals18.loadDefaultKnowledgeConfig();
|
|
11878
|
+
const result = await _internals18.transactHiveStore(async (ctx) => {
|
|
11780
11879
|
if (findNearDuplicate(trimmedLesson, ctx.entries, policyConfig.dedup_threshold)) {
|
|
11781
11880
|
return {
|
|
11782
11881
|
kind: "noop",
|
|
11783
11882
|
return: `Lesson already exists in hive (near-duplicate).`
|
|
11784
11883
|
};
|
|
11785
11884
|
}
|
|
11786
|
-
const validationResult =
|
|
11885
|
+
const validationResult = _internals18.validateLesson(trimmedLesson, ctx.entries.map((e) => e.lesson), {
|
|
11787
11886
|
category: category || "process",
|
|
11788
11887
|
scope: "global",
|
|
11789
11888
|
confidence: 1
|
|
@@ -11892,16 +11991,16 @@ async function promoteFromSwarm(directory, lessonId, options, config) {
|
|
|
11892
11991
|
if (!swarmEntry) {
|
|
11893
11992
|
throw new Error(`Lesson ${lessonId} not found in .swarm/knowledge.jsonl`);
|
|
11894
11993
|
}
|
|
11895
|
-
const sourceCohort = await
|
|
11896
|
-
const policyConfig = config ??
|
|
11897
|
-
const result = await
|
|
11994
|
+
const sourceCohort = await _internals18.resolveCohortId(directory);
|
|
11995
|
+
const policyConfig = config ?? _internals18.loadDefaultKnowledgeConfig();
|
|
11996
|
+
const result = await _internals18.transactHiveStore(async (ctx) => {
|
|
11898
11997
|
if (findNearDuplicate(swarmEntry.lesson, ctx.entries, policyConfig.dedup_threshold)) {
|
|
11899
11998
|
return {
|
|
11900
11999
|
kind: "noop",
|
|
11901
12000
|
return: `Lesson already exists in hive (near-duplicate).`
|
|
11902
12001
|
};
|
|
11903
12002
|
}
|
|
11904
|
-
const validationResult =
|
|
12003
|
+
const validationResult = _internals18.validateLesson(swarmEntry.lesson, ctx.entries.map((e) => e.lesson), {
|
|
11905
12004
|
category: swarmEntry.category,
|
|
11906
12005
|
scope: swarmEntry.scope,
|
|
11907
12006
|
confidence: swarmEntry.confidence
|
|
@@ -12233,7 +12332,7 @@ var SKILL_AUDIENCE_RUNNER_PATTERN = /^runner:(opencode|claude|codex)$/;
|
|
|
12233
12332
|
var WORKFLOW_BOOST_MIN_CONTEXT = 0.05;
|
|
12234
12333
|
var RECENCY_DECAY_MS = 30 * 24 * 60 * 60 * 1000;
|
|
12235
12334
|
var SKILL_FRONTMATTER_READ_BYTES = 16 * 1024;
|
|
12236
|
-
var
|
|
12335
|
+
var _internals19 = {
|
|
12237
12336
|
computeSkillRelevanceScore: null,
|
|
12238
12337
|
rankSkillsForContext: null,
|
|
12239
12338
|
getSkillStats: null,
|
|
@@ -12600,7 +12699,7 @@ function rankSkillsForContext(skills, taskContext, directory) {
|
|
|
12600
12699
|
const results = [];
|
|
12601
12700
|
for (const skillPath of skills) {
|
|
12602
12701
|
const skillEntries = allEntries.filter((e) => e.skillPath === skillPath);
|
|
12603
|
-
const metadata =
|
|
12702
|
+
const metadata = _internals19.readSkillMetadata(skillPath, directory);
|
|
12604
12703
|
const score = computeSkillRelevanceScore(skillPath, taskContext, skillEntries, metadata);
|
|
12605
12704
|
const entriesWithVerdict = skillEntries.filter((e) => e.complianceVerdict !== undefined && e.complianceVerdict !== "not_checked");
|
|
12606
12705
|
const compliantCount = entriesWithVerdict.filter((e) => e.complianceVerdict === "compliant").length;
|
|
@@ -12659,7 +12758,7 @@ function formatSkillIndexWithContext(skills, directory, metadataBySkillPath) {
|
|
|
12659
12758
|
} catch {}
|
|
12660
12759
|
if (!hasHistory) {
|
|
12661
12760
|
return skills.map((sp) => {
|
|
12662
|
-
const meta = metadataBySkillPath?.get(sp) ??
|
|
12761
|
+
const meta = metadataBySkillPath?.get(sp) ?? _internals19.readSkillMetadata(sp, directory);
|
|
12663
12762
|
return ` - file:${meta.path} - ${meta.name}: ${meta.description}`;
|
|
12664
12763
|
}).join(`
|
|
12665
12764
|
`);
|
|
@@ -12667,7 +12766,7 @@ function formatSkillIndexWithContext(skills, directory, metadataBySkillPath) {
|
|
|
12667
12766
|
const lines = [];
|
|
12668
12767
|
for (const skillPath of skills) {
|
|
12669
12768
|
const stats = getSkillStats(skillPath, directory);
|
|
12670
|
-
const meta = metadataBySkillPath?.get(skillPath) ??
|
|
12769
|
+
const meta = metadataBySkillPath?.get(skillPath) ?? _internals19.readSkillMetadata(skillPath, directory);
|
|
12671
12770
|
const compliancePct = Math.round(stats.complianceRate * 100);
|
|
12672
12771
|
const topAgentNames = stats.topAgents.slice(0, 3).map((a) => a.agent).join(", ");
|
|
12673
12772
|
lines.push(` - file:${meta.path} - ${meta.name}: ${meta.description} (used: ${stats.totalUsage}, compliance: ${compliancePct}%)` + (stats.topAgents.length > 0 ? ` \u2192 ${topAgentNames}` : ""));
|
|
@@ -12675,16 +12774,16 @@ function formatSkillIndexWithContext(skills, directory, metadataBySkillPath) {
|
|
|
12675
12774
|
return lines.join(`
|
|
12676
12775
|
`);
|
|
12677
12776
|
}
|
|
12678
|
-
|
|
12679
|
-
|
|
12680
|
-
|
|
12681
|
-
|
|
12682
|
-
|
|
12683
|
-
|
|
12684
|
-
|
|
12685
|
-
|
|
12686
|
-
|
|
12687
|
-
|
|
12777
|
+
_internals19.computeSkillRelevanceScore = computeSkillRelevanceScore;
|
|
12778
|
+
_internals19.rankSkillsForContext = rankSkillsForContext;
|
|
12779
|
+
_internals19.getSkillStats = getSkillStats;
|
|
12780
|
+
_internals19.formatSkillIndexWithContext = formatSkillIndexWithContext;
|
|
12781
|
+
_internals19.parseSkillFrontmatter = parseSkillFrontmatter;
|
|
12782
|
+
_internals19.readSkillMetadata = readSkillMetadata;
|
|
12783
|
+
_internals19.extractSkillName = extractSkillName;
|
|
12784
|
+
_internals19.computeRecencyScore = computeRecencyScore;
|
|
12785
|
+
_internals19.computeContextMatchScore = computeContextMatchScore;
|
|
12786
|
+
_internals19.computeTriggerMatchBoost = computeTriggerMatchBoost;
|
|
12688
12787
|
|
|
12689
12788
|
// src/hooks/skill-propagation-gate.ts
|
|
12690
12789
|
function parseSimpleYaml(content) {
|
|
@@ -12786,10 +12885,10 @@ function parseYamlValue(value) {
|
|
|
12786
12885
|
}
|
|
12787
12886
|
function loadRoutingSkills(directory, targetAgent) {
|
|
12788
12887
|
const routingPath = path23.join(directory, ".opencode", "skill-routing.yaml");
|
|
12789
|
-
if (!
|
|
12888
|
+
if (!_internals20.existsSync(routingPath))
|
|
12790
12889
|
return [];
|
|
12791
12890
|
try {
|
|
12792
|
-
const content =
|
|
12891
|
+
const content = _internals20.readFileSync(routingPath, "utf-8");
|
|
12793
12892
|
const config = parseSimpleYaml(content);
|
|
12794
12893
|
if (!config?.routing)
|
|
12795
12894
|
return [];
|
|
@@ -12816,7 +12915,7 @@ var SKILL_SEARCH_ROOTS = [
|
|
|
12816
12915
|
".claude/skills"
|
|
12817
12916
|
];
|
|
12818
12917
|
var MAX_SCORING_SESSION_ENTRIES = 500;
|
|
12819
|
-
var
|
|
12918
|
+
var _internals20 = {
|
|
12820
12919
|
readdirSync: fs9.readdirSync.bind(fs9),
|
|
12821
12920
|
existsSync: fs9.existsSync.bind(fs9),
|
|
12822
12921
|
statSync: fs9.statSync.bind(fs9),
|
|
@@ -12849,11 +12948,11 @@ function discoverAvailableSkills(directory) {
|
|
|
12849
12948
|
const results = [];
|
|
12850
12949
|
for (const root of SKILL_SEARCH_ROOTS) {
|
|
12851
12950
|
const rootPath = path23.join(directory, root);
|
|
12852
|
-
if (!
|
|
12951
|
+
if (!_internals20.existsSync(rootPath))
|
|
12853
12952
|
continue;
|
|
12854
12953
|
let entries;
|
|
12855
12954
|
try {
|
|
12856
|
-
entries =
|
|
12955
|
+
entries = _internals20.readdirSync(rootPath);
|
|
12857
12956
|
} catch {
|
|
12858
12957
|
continue;
|
|
12859
12958
|
}
|
|
@@ -12861,11 +12960,11 @@ function discoverAvailableSkills(directory) {
|
|
|
12861
12960
|
if (entry.startsWith("."))
|
|
12862
12961
|
continue;
|
|
12863
12962
|
const skillDir = path23.join(rootPath, entry);
|
|
12864
|
-
if (
|
|
12963
|
+
if (_internals20.existsSync(path23.join(skillDir, "retired.marker")) || _internals20.existsSync(path23.join(skillDir, "stale.marker")))
|
|
12865
12964
|
continue;
|
|
12866
12965
|
const skillFile = path23.join(skillDir, "SKILL.md");
|
|
12867
12966
|
try {
|
|
12868
|
-
if (
|
|
12967
|
+
if (_internals20.statSync(skillDir).isDirectory() && _internals20.existsSync(skillFile)) {
|
|
12869
12968
|
results.push(path23.join(root, entry, "SKILL.md").replace(/\\/g, "/"));
|
|
12870
12969
|
}
|
|
12871
12970
|
} catch (err) {
|
|
@@ -12897,7 +12996,7 @@ function parseDelegationArgs(args) {
|
|
|
12897
12996
|
}
|
|
12898
12997
|
if (!targetAgent)
|
|
12899
12998
|
return null;
|
|
12900
|
-
const skillsField = prompt ?
|
|
12999
|
+
const skillsField = prompt ? _internals20.extractSkillsFieldFromPrompt(prompt) : "";
|
|
12901
13000
|
return { targetAgent, skillsField };
|
|
12902
13001
|
}
|
|
12903
13002
|
function extractSkillsFieldFromPrompt(prompt) {
|
|
@@ -12938,10 +13037,10 @@ function writeWarnEvent(directory, record) {
|
|
|
12938
13037
|
const filePath = path23.join(directory, ".swarm", "events.jsonl");
|
|
12939
13038
|
try {
|
|
12940
13039
|
const dir = path23.dirname(filePath);
|
|
12941
|
-
if (!
|
|
12942
|
-
|
|
13040
|
+
if (!_internals20.existsSync(dir)) {
|
|
13041
|
+
_internals20.mkdirSync(dir, { recursive: true });
|
|
12943
13042
|
}
|
|
12944
|
-
|
|
13043
|
+
_internals20.appendFileSync(filePath, `${JSON.stringify(record)}
|
|
12945
13044
|
`, "utf-8");
|
|
12946
13045
|
} catch (err) {
|
|
12947
13046
|
warn(`[skill-propagation-gate] failed to write warning event: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -12996,7 +13095,7 @@ function validateSkillReference(directory, reference, context, options) {
|
|
|
12996
13095
|
};
|
|
12997
13096
|
}
|
|
12998
13097
|
try {
|
|
12999
|
-
const root =
|
|
13098
|
+
const root = _internals20.realpathSync(directory);
|
|
13000
13099
|
const lexicalPath = path23.resolve(root, withoutPrefix);
|
|
13001
13100
|
if (!isWithinRoot(root, lexicalPath)) {
|
|
13002
13101
|
return {
|
|
@@ -13004,10 +13103,10 @@ function validateSkillReference(directory, reference, context, options) {
|
|
|
13004
13103
|
reason: "skill path resolves outside the project"
|
|
13005
13104
|
};
|
|
13006
13105
|
}
|
|
13007
|
-
if (!
|
|
13106
|
+
if (!_internals20.existsSync(lexicalPath) || !_internals20.statSync(lexicalPath).isFile()) {
|
|
13008
13107
|
return { valid: false, reason: "skill file does not exist" };
|
|
13009
13108
|
}
|
|
13010
|
-
const realPath =
|
|
13109
|
+
const realPath = _internals20.realpathSync(lexicalPath);
|
|
13011
13110
|
if (!isWithinRoot(root, realPath)) {
|
|
13012
13111
|
return {
|
|
13013
13112
|
valid: false,
|
|
@@ -13016,7 +13115,7 @@ function validateSkillReference(directory, reference, context, options) {
|
|
|
13016
13115
|
}
|
|
13017
13116
|
const normalizedPath = withoutPrefix.replace(/^\.\//, "");
|
|
13018
13117
|
const validatedMetadataPath = path23.relative(root, realPath).replace(/\\/g, "/");
|
|
13019
|
-
const metadata =
|
|
13118
|
+
const metadata = _internals20.readSkillMetadata(validatedMetadataPath, root);
|
|
13020
13119
|
if (metadata.frontmatterStatus !== "valid" && metadata.frontmatterStatus !== "absent") {
|
|
13021
13120
|
return {
|
|
13022
13121
|
valid: false,
|
|
@@ -13048,18 +13147,18 @@ async function validateExplicitSkillReferencesBefore(directory, input, config) {
|
|
|
13048
13147
|
if (!agentRaw || stripKnownSwarmPrefix(agentRaw) !== "architect") {
|
|
13049
13148
|
return { blocked: false, reason: null };
|
|
13050
13149
|
}
|
|
13051
|
-
const parsed =
|
|
13150
|
+
const parsed = _internals20.parseDelegationArgs(input.args);
|
|
13052
13151
|
if (!parsed)
|
|
13053
13152
|
return { blocked: false, reason: null };
|
|
13054
13153
|
const targetBase = stripKnownSwarmPrefix(parsed.targetAgent);
|
|
13055
|
-
if (!
|
|
13154
|
+
if (!_internals20.SKILL_CAPABLE_AGENTS.has(targetBase)) {
|
|
13056
13155
|
return { blocked: false, reason: null };
|
|
13057
13156
|
}
|
|
13058
13157
|
const skillsValue = parsed.skillsField.trim();
|
|
13059
13158
|
if (!skillsValue || skillsValue.toLowerCase() === "none") {
|
|
13060
13159
|
return { blocked: false, reason: null };
|
|
13061
13160
|
}
|
|
13062
|
-
const fileReferences =
|
|
13161
|
+
const fileReferences = _internals20.extractFileSkillReferences(skillsValue);
|
|
13063
13162
|
if (fileReferences.length === 0) {
|
|
13064
13163
|
return { blocked: false, reason: null, validatedSkillPaths: [] };
|
|
13065
13164
|
}
|
|
@@ -13072,7 +13171,7 @@ async function validateExplicitSkillReferencesBefore(directory, input, config) {
|
|
|
13072
13171
|
const context = resolveSkillAudienceContext(config);
|
|
13073
13172
|
const validatedSkillPaths = [];
|
|
13074
13173
|
for (const reference of fileReferences) {
|
|
13075
|
-
const result =
|
|
13174
|
+
const result = _internals20.validateSkillReference(directory, reference, context, {
|
|
13076
13175
|
enforceAudience: true
|
|
13077
13176
|
});
|
|
13078
13177
|
if (!result.valid) {
|
|
@@ -13117,18 +13216,18 @@ async function skillPropagationGateBefore(directory, input, config) {
|
|
|
13117
13216
|
const baseAgent = stripKnownSwarmPrefix(agentRaw);
|
|
13118
13217
|
if (baseAgent !== "architect")
|
|
13119
13218
|
return { blocked: false, reason: null, recommendedSkills: undefined };
|
|
13120
|
-
const parsed =
|
|
13219
|
+
const parsed = _internals20.parseDelegationArgs(input.args);
|
|
13121
13220
|
if (!parsed)
|
|
13122
13221
|
return { blocked: false, reason: null, recommendedSkills: undefined };
|
|
13123
13222
|
const targetBase = stripKnownSwarmPrefix(parsed.targetAgent);
|
|
13124
|
-
if (!
|
|
13223
|
+
if (!_internals20.SKILL_CAPABLE_AGENTS.has(targetBase))
|
|
13125
13224
|
return { blocked: false, reason: null, recommendedSkills: undefined };
|
|
13126
13225
|
const sessionID = typeof input.sessionID === "string" ? input.sessionID : "unknown";
|
|
13127
13226
|
const audienceContext = resolveSkillAudienceContext(config);
|
|
13128
13227
|
const availableSkills = [];
|
|
13129
13228
|
const metadataBySkillPath = new Map;
|
|
13130
|
-
for (const skillPath of
|
|
13131
|
-
const validation =
|
|
13229
|
+
for (const skillPath of _internals20.discoverAvailableSkills(directory)) {
|
|
13230
|
+
const validation = _internals20.validateSkillReference(directory, skillPath, audienceContext, { enforceAudience: true, requireFilePrefix: false });
|
|
13132
13231
|
if (!validation.valid || !validation.skillPath)
|
|
13133
13232
|
continue;
|
|
13134
13233
|
availableSkills.push(validation.skillPath);
|
|
@@ -13139,7 +13238,7 @@ async function skillPropagationGateBefore(directory, input, config) {
|
|
|
13139
13238
|
const skillsValue = parsed.skillsField.trim();
|
|
13140
13239
|
if (skillsValue && skillsValue.toLowerCase() !== "none") {
|
|
13141
13240
|
const prompt = typeof input.args?.prompt === "string" ? String(input.args.prompt) : "";
|
|
13142
|
-
const taskId =
|
|
13241
|
+
const taskId = _internals20.extractTaskIdFromPrompt(prompt);
|
|
13143
13242
|
const skillPaths = explicitIntegrity.validatedSkillPaths ?? [];
|
|
13144
13243
|
let coderSkillPaths = [];
|
|
13145
13244
|
if (prompt) {
|
|
@@ -13148,19 +13247,19 @@ async function skillPropagationGateBefore(directory, input, config) {
|
|
|
13148
13247
|
const trimmed = line.trim();
|
|
13149
13248
|
if (trimmed.startsWith("SKILLS_USED_BY_CODER:")) {
|
|
13150
13249
|
const fieldVal = trimmed.slice("SKILLS_USED_BY_CODER:".length).trim();
|
|
13151
|
-
coderSkillPaths =
|
|
13250
|
+
coderSkillPaths = _internals20.parseSkillPaths(fieldVal);
|
|
13152
13251
|
break;
|
|
13153
13252
|
}
|
|
13154
13253
|
}
|
|
13155
13254
|
}
|
|
13156
13255
|
const safeCoderSkillPaths = coderSkillPaths.flatMap((skillPath) => {
|
|
13157
|
-
const validation =
|
|
13256
|
+
const validation = _internals20.validateSkillReference(directory, skillPath, audienceContext, { enforceAudience: false });
|
|
13158
13257
|
return validation.valid && validation.skillPath ? [validation.skillPath] : [];
|
|
13159
13258
|
});
|
|
13160
13259
|
const allPaths = [...new Set([...skillPaths, ...safeCoderSkillPaths])];
|
|
13161
13260
|
for (const skillPath of allPaths) {
|
|
13162
13261
|
try {
|
|
13163
|
-
|
|
13262
|
+
_internals20.appendSkillUsageEntry(directory, {
|
|
13164
13263
|
skillPath,
|
|
13165
13264
|
agentName: targetBase,
|
|
13166
13265
|
taskID: taskId,
|
|
@@ -13177,18 +13276,18 @@ async function skillPropagationGateBefore(directory, input, config) {
|
|
|
13177
13276
|
let scored = [];
|
|
13178
13277
|
if (skillsValue.toLowerCase() !== "none" && availableSkills.length > 0) {
|
|
13179
13278
|
try {
|
|
13180
|
-
const sessionEntries =
|
|
13279
|
+
const sessionEntries = _internals20.readSkillUsageEntriesTail(directory, {
|
|
13181
13280
|
sessionID
|
|
13182
13281
|
});
|
|
13183
|
-
if (sessionEntries.length >
|
|
13282
|
+
if (sessionEntries.length > _internals20.MAX_SCORING_SESSION_ENTRIES) {
|
|
13184
13283
|
scoringSkipped = true;
|
|
13185
|
-
warn(`[skill-propagation-gate] skipping scoring \u2014 tail window has ${sessionEntries.length} session entries (limit: ${
|
|
13284
|
+
warn(`[skill-propagation-gate] skipping scoring \u2014 tail window has ${sessionEntries.length} session entries (limit: ${_internals20.MAX_SCORING_SESSION_ENTRIES})`);
|
|
13186
13285
|
} else {
|
|
13187
13286
|
const prompt = typeof input.args?.prompt === "string" ? String(input.args.prompt) : "";
|
|
13188
13287
|
scored = availableSkills.map((skillPath) => {
|
|
13189
13288
|
const skillEntries = sessionEntries.filter((e) => e.skillPath === skillPath);
|
|
13190
|
-
const metadata = metadataBySkillPath.get(skillPath) ??
|
|
13191
|
-
const score =
|
|
13289
|
+
const metadata = metadataBySkillPath.get(skillPath) ?? _internals20.readSkillMetadata(skillPath, directory);
|
|
13290
|
+
const score = _internals20.computeSkillRelevanceScore(skillPath, prompt, skillEntries, metadata);
|
|
13192
13291
|
return { skillPath, score, usageCount: skillEntries.length };
|
|
13193
13292
|
}).sort((a, b) => b.score - a.score || b.usageCount - a.usageCount);
|
|
13194
13293
|
if (scored.length > 0) {
|
|
@@ -13202,11 +13301,11 @@ async function skillPropagationGateBefore(directory, input, config) {
|
|
|
13202
13301
|
}
|
|
13203
13302
|
}
|
|
13204
13303
|
try {
|
|
13205
|
-
const routingPaths =
|
|
13304
|
+
const routingPaths = _internals20.loadRoutingSkills(directory, targetBase);
|
|
13206
13305
|
if (routingPaths.length > 0) {
|
|
13207
13306
|
const existingPaths = new Set(scored.map((s) => s.skillPath));
|
|
13208
13307
|
for (const routingPath of routingPaths) {
|
|
13209
|
-
const validation =
|
|
13308
|
+
const validation = _internals20.validateSkillReference(directory, routingPath, audienceContext, { enforceAudience: true, requireFilePrefix: false });
|
|
13210
13309
|
if (!validation.valid || !validation.skillPath)
|
|
13211
13310
|
continue;
|
|
13212
13311
|
const eligibleRoutingPath = validation.skillPath;
|
|
@@ -13214,7 +13313,7 @@ async function skillPropagationGateBefore(directory, input, config) {
|
|
|
13214
13313
|
metadataBySkillPath.set(eligibleRoutingPath, validation.metadata);
|
|
13215
13314
|
}
|
|
13216
13315
|
const routedSkillDir = path23.dirname(path23.join(directory, eligibleRoutingPath));
|
|
13217
|
-
if (
|
|
13316
|
+
if (_internals20.existsSync(path23.join(routedSkillDir, "retired.marker")) || _internals20.existsSync(path23.join(routedSkillDir, "stale.marker")))
|
|
13218
13317
|
continue;
|
|
13219
13318
|
if (!existingPaths.has(eligibleRoutingPath)) {
|
|
13220
13319
|
scored.push({
|
|
@@ -13240,12 +13339,12 @@ async function skillPropagationGateBefore(directory, input, config) {
|
|
|
13240
13339
|
} else if (typeof scored !== "undefined" && scored.length > 0) {
|
|
13241
13340
|
skillsForIndex = scored.map((r) => r.skillPath);
|
|
13242
13341
|
}
|
|
13243
|
-
const formattedIndex =
|
|
13342
|
+
const formattedIndex = _internals20.formatSkillIndexWithContext(skillsForIndex, directory, metadataBySkillPath);
|
|
13244
13343
|
if (formattedIndex.length > 0) {
|
|
13245
13344
|
const contextPath = path23.join(directory, ".swarm", "context.md");
|
|
13246
13345
|
let existingContent = "";
|
|
13247
|
-
if (
|
|
13248
|
-
existingContent =
|
|
13346
|
+
if (_internals20.existsSync(contextPath)) {
|
|
13347
|
+
existingContent = _internals20.readFileSync(contextPath, "utf-8");
|
|
13249
13348
|
}
|
|
13250
13349
|
const sectionHeader = "## Available Skills";
|
|
13251
13350
|
const newSection = `${sectionHeader}
|
|
@@ -13265,10 +13364,10 @@ ${newSection}`;
|
|
|
13265
13364
|
}
|
|
13266
13365
|
}
|
|
13267
13366
|
const swarmDir = path23.dirname(contextPath);
|
|
13268
|
-
if (!
|
|
13269
|
-
|
|
13367
|
+
if (!_internals20.existsSync(swarmDir)) {
|
|
13368
|
+
_internals20.mkdirSync(swarmDir, { recursive: true });
|
|
13270
13369
|
}
|
|
13271
|
-
|
|
13370
|
+
_internals20.writeFileSync(contextPath, updatedContent, "utf-8");
|
|
13272
13371
|
}
|
|
13273
13372
|
} catch (err) {
|
|
13274
13373
|
warn(`[skill-propagation-gate] failed to write skill index to context.md: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -13294,7 +13393,7 @@ ${newSection}`;
|
|
|
13294
13393
|
});
|
|
13295
13394
|
const warningMsg = `Skill propagation warning: Delegating to ${targetBase} without SKILLS field. ` + `Available skills: ${skillNames.join(", ")}`;
|
|
13296
13395
|
try {
|
|
13297
|
-
|
|
13396
|
+
_internals20.writeWarnEvent(directory, {
|
|
13298
13397
|
type: "skill_propagation_warn",
|
|
13299
13398
|
timestamp: new Date().toISOString(),
|
|
13300
13399
|
tool: toolName,
|
|
@@ -13326,17 +13425,17 @@ async function skillPropagationTransformScan(directory, output, sessionID, confi
|
|
|
13326
13425
|
const validatedProvenancePaths = (fieldValue) => {
|
|
13327
13426
|
if (remainingProvenanceValidationBudget <= 0)
|
|
13328
13427
|
return [];
|
|
13329
|
-
const references =
|
|
13428
|
+
const references = _internals20.parseSkillPaths(fieldValue).slice(0, remainingProvenanceValidationBudget);
|
|
13330
13429
|
remainingProvenanceValidationBudget -= references.length;
|
|
13331
13430
|
return references.flatMap((reference) => {
|
|
13332
|
-
const validation =
|
|
13431
|
+
const validation = _internals20.validateSkillReference(directory, reference, audienceContext, { enforceAudience: true });
|
|
13333
13432
|
return validation.valid && validation.skillPath ? [validation.skillPath] : [];
|
|
13334
13433
|
});
|
|
13335
13434
|
};
|
|
13336
13435
|
let dedupKeys = new Set;
|
|
13337
13436
|
let existingEntries = [];
|
|
13338
13437
|
try {
|
|
13339
|
-
existingEntries =
|
|
13438
|
+
existingEntries = _internals20.readSkillUsageEntriesTail(directory, {
|
|
13340
13439
|
sessionID
|
|
13341
13440
|
});
|
|
13342
13441
|
dedupKeys = new Set(existingEntries.map((e, i) => {
|
|
@@ -13407,7 +13506,7 @@ async function skillPropagationTransformScan(directory, output, sessionID, confi
|
|
|
13407
13506
|
if (isDuplicate(skillPath, "reviewer", resolvedTaskID))
|
|
13408
13507
|
continue;
|
|
13409
13508
|
try {
|
|
13410
|
-
|
|
13509
|
+
_internals20.appendSkillUsageEntry(directory, {
|
|
13411
13510
|
skillPath,
|
|
13412
13511
|
agentName: "reviewer",
|
|
13413
13512
|
taskID: resolvedTaskID,
|
|
@@ -13452,14 +13551,14 @@ async function skillPropagationTransformScan(directory, output, sessionID, confi
|
|
|
13452
13551
|
}
|
|
13453
13552
|
if (currentTargetAgent && skillsField && skillsField.toLowerCase() !== "none") {
|
|
13454
13553
|
const skillPaths = validatedProvenancePaths(skillsField);
|
|
13455
|
-
const taskId =
|
|
13554
|
+
const taskId = _internals20.extractTaskIdFromPrompt(text);
|
|
13456
13555
|
for (const skillPath of skillPaths) {
|
|
13457
13556
|
if (hadRecordingError)
|
|
13458
13557
|
break;
|
|
13459
13558
|
if (isDuplicate(skillPath, currentTargetAgent, taskId))
|
|
13460
13559
|
continue;
|
|
13461
13560
|
try {
|
|
13462
|
-
|
|
13561
|
+
_internals20.appendSkillUsageEntry(directory, {
|
|
13463
13562
|
skillPath,
|
|
13464
13563
|
agentName: currentTargetAgent,
|
|
13465
13564
|
taskID: taskId,
|
|
@@ -13479,18 +13578,18 @@ async function skillPropagationTransformScan(directory, output, sessionID, confi
|
|
|
13479
13578
|
break;
|
|
13480
13579
|
}
|
|
13481
13580
|
}
|
|
13482
|
-
|
|
13483
|
-
|
|
13484
|
-
|
|
13485
|
-
|
|
13486
|
-
|
|
13487
|
-
|
|
13488
|
-
|
|
13489
|
-
|
|
13490
|
-
|
|
13491
|
-
|
|
13492
|
-
|
|
13493
|
-
|
|
13581
|
+
_internals20.skillPropagationGateBefore = skillPropagationGateBefore;
|
|
13582
|
+
_internals20.skillPropagationTransformScan = skillPropagationTransformScan;
|
|
13583
|
+
_internals20.writeWarnEvent = writeWarnEvent;
|
|
13584
|
+
_internals20.discoverAvailableSkills = discoverAvailableSkills;
|
|
13585
|
+
_internals20.parseDelegationArgs = parseDelegationArgs;
|
|
13586
|
+
_internals20.parseSkillPaths = parseSkillPaths;
|
|
13587
|
+
_internals20.extractFileSkillReferences = extractFileSkillReferences;
|
|
13588
|
+
_internals20.validateSkillReference = validateSkillReference;
|
|
13589
|
+
_internals20.extractTaskIdFromPrompt = extractTaskIdFromPrompt;
|
|
13590
|
+
_internals20.extractSkillsFieldFromPrompt = extractSkillsFieldFromPrompt;
|
|
13591
|
+
_internals20.formatSkillIndexWithContext = formatSkillIndexWithContext;
|
|
13592
|
+
_internals20.loadRoutingSkills = loadRoutingSkills;
|
|
13494
13593
|
|
|
13495
13594
|
// src/hooks/micro-reflector.ts
|
|
13496
13595
|
var REFLECT_OUTCOMES = new Set([
|
|
@@ -13567,7 +13666,7 @@ async function loadConfigForPolicyCurator(directory) {
|
|
|
13567
13666
|
async function canonicalExistingPath(candidate) {
|
|
13568
13667
|
let resolved = path25.resolve(candidate);
|
|
13569
13668
|
try {
|
|
13570
|
-
resolved = await
|
|
13669
|
+
resolved = await _internals21.realpath(resolved);
|
|
13571
13670
|
} catch {}
|
|
13572
13671
|
return resolved;
|
|
13573
13672
|
}
|
|
@@ -14362,9 +14461,9 @@ async function curateAndStoreSwarm(lessons, projectName, phaseInfo, directory, c
|
|
|
14362
14461
|
} catch {}
|
|
14363
14462
|
}
|
|
14364
14463
|
if (!options?.skipAutoPromotion) {
|
|
14365
|
-
await
|
|
14464
|
+
await _internals21.runAutoPromotion(directory, config);
|
|
14366
14465
|
if (phaseInfo.phase_number > 0) {
|
|
14367
|
-
await
|
|
14466
|
+
await _internals21.runAutoDemotion(directory, config, phaseInfo.phase_number);
|
|
14368
14467
|
}
|
|
14369
14468
|
}
|
|
14370
14469
|
return { stored, reinforced, skipped, rejected, quarantined };
|
|
@@ -14479,7 +14578,7 @@ function createKnowledgeCuratorHook(directory, config, options = {}) {
|
|
|
14479
14578
|
}
|
|
14480
14579
|
inFlightEvidenceEntries.add(evidenceKey);
|
|
14481
14580
|
try {
|
|
14482
|
-
await
|
|
14581
|
+
await _internals21.curateAndStoreSwarm(batch.lessons, batch.projectName, { phase_number: batch.phaseNumber }, directory, config, {
|
|
14483
14582
|
llmDelegate: options.llmDelegateFactory?.(trigger.sessionID),
|
|
14484
14583
|
enrichmentQuota: options.enrichmentQuota
|
|
14485
14584
|
});
|
|
@@ -14511,14 +14610,14 @@ function createKnowledgeCuratorHook(directory, config, options = {}) {
|
|
|
14511
14610
|
const projectName = projectNameMatch ? projectNameMatch[1].trim() : "unknown";
|
|
14512
14611
|
const phaseMatch = /^Phase:\s*(\d+)/m.exec(planContent);
|
|
14513
14612
|
const phaseNumber = phaseMatch ? parseInt(phaseMatch[1], 10) : 1;
|
|
14514
|
-
await
|
|
14613
|
+
await _internals21.curateAndStoreSwarm(normalLessons, projectName, { phase_number: phaseNumber }, directory, config, {
|
|
14515
14614
|
llmDelegate: options.llmDelegateFactory?.(trigger.sessionID),
|
|
14516
14615
|
enrichmentQuota: options.enrichmentQuota
|
|
14517
14616
|
});
|
|
14518
14617
|
};
|
|
14519
14618
|
return safeHook(handler);
|
|
14520
14619
|
}
|
|
14521
|
-
var
|
|
14620
|
+
var _internals21 = {
|
|
14522
14621
|
isWriteToEvidenceFile,
|
|
14523
14622
|
curateAndStoreSwarm,
|
|
14524
14623
|
runAutoPromotion,
|
|
@@ -14557,7 +14656,7 @@ async function runFinalizeRewardSweep(args) {
|
|
|
14557
14656
|
return result;
|
|
14558
14657
|
}
|
|
14559
14658
|
const timestamp = args.timestamp ?? new Date().toISOString();
|
|
14560
|
-
const provider =
|
|
14659
|
+
const provider = _internals22.createConfiguredMemoryProvider(directory, memoryConfig);
|
|
14561
14660
|
try {
|
|
14562
14661
|
result.swept = true;
|
|
14563
14662
|
for (const taskId of taskIds) {
|
|
@@ -14577,7 +14676,7 @@ async function runFinalizeRewardSweep(args) {
|
|
|
14577
14676
|
}
|
|
14578
14677
|
let taskRewarded = 0;
|
|
14579
14678
|
for (const runId of runIds) {
|
|
14580
|
-
const { memoriesRewarded } = await
|
|
14679
|
+
const { memoriesRewarded } = await _internals22.applyCouncilReward(provider, {
|
|
14581
14680
|
runId,
|
|
14582
14681
|
unitId: taskId,
|
|
14583
14682
|
reward: FINALIZE_NEGATIVE_TERMINAL_REWARD,
|
|
@@ -14603,7 +14702,7 @@ async function runFinalizeRewardSweep(args) {
|
|
|
14603
14702
|
}
|
|
14604
14703
|
return result;
|
|
14605
14704
|
}
|
|
14606
|
-
var
|
|
14705
|
+
var _internals22 = {
|
|
14607
14706
|
createConfiguredMemoryProvider,
|
|
14608
14707
|
applyCouncilReward
|
|
14609
14708
|
};
|
|
@@ -15630,7 +15729,7 @@ async function reconcileStaleActiveSkills(directory, options = {}) {
|
|
|
15630
15729
|
continue;
|
|
15631
15730
|
}
|
|
15632
15731
|
try {
|
|
15633
|
-
const regen = await
|
|
15732
|
+
const regen = await _internals23.regenerateSkill(directory, skill.slug, {
|
|
15634
15733
|
evaluate: false
|
|
15635
15734
|
});
|
|
15636
15735
|
if (regen.regenerated) {
|
|
@@ -15880,7 +15979,7 @@ async function runSkillImprover(req) {
|
|
|
15880
15979
|
autoApply
|
|
15881
15980
|
};
|
|
15882
15981
|
}
|
|
15883
|
-
var
|
|
15982
|
+
var _internals23 = {
|
|
15884
15983
|
runSkillImprover,
|
|
15885
15984
|
buildDeterministicProposal,
|
|
15886
15985
|
buildLLMProposalFrame,
|
|
@@ -16283,13 +16382,13 @@ var write_retro = createSwarmTool({
|
|
|
16283
16382
|
task_id: args.task_id !== undefined ? String(args.task_id) : undefined,
|
|
16284
16383
|
metadata: args.metadata
|
|
16285
16384
|
};
|
|
16286
|
-
return await
|
|
16385
|
+
return await _internals24.executeWriteRetro(writeRetroArgs, directory);
|
|
16287
16386
|
} catch {
|
|
16288
16387
|
return JSON.stringify({ success: false, phase: rawPhase, message: "Invalid arguments" }, null, 2);
|
|
16289
16388
|
}
|
|
16290
16389
|
}
|
|
16291
16390
|
});
|
|
16292
|
-
var
|
|
16391
|
+
var _internals24 = {
|
|
16293
16392
|
executeWriteRetro,
|
|
16294
16393
|
write_retro
|
|
16295
16394
|
};
|
|
@@ -16595,8 +16694,8 @@ async function runFinalizeStage(ctx) {
|
|
|
16595
16694
|
];
|
|
16596
16695
|
ctx.curationSucceeded = false;
|
|
16597
16696
|
try {
|
|
16598
|
-
ctx.curationResult = await
|
|
16599
|
-
llmDelegate:
|
|
16697
|
+
ctx.curationResult = await _internals25.curateAndStoreSwarm(ctx.allLessons, ctx.projectName, { phase_number: 0 }, ctx.directory, ctx.config, {
|
|
16698
|
+
llmDelegate: _internals25.createCuratorLLMDelegate(ctx.directory, "phase", ctx.options.sessionID),
|
|
16600
16699
|
enrichmentQuota: {
|
|
16601
16700
|
maxCalls: ctx.config.enrichment.max_calls_per_day,
|
|
16602
16701
|
window: ctx.config.enrichment.quota_window
|
|
@@ -16615,7 +16714,7 @@ async function runFinalizeStage(ctx) {
|
|
|
16615
16714
|
if (ctx.config.hive_enabled === false) {} else {
|
|
16616
16715
|
try {
|
|
16617
16716
|
const entries = await readKnowledge(resolveSwarmKnowledgePath(ctx.directory));
|
|
16618
|
-
const result = await
|
|
16717
|
+
const result = await _internals25.checkHivePromotions(entries, ctx.config, ctx.directory);
|
|
16619
16718
|
ctx.hivePromoted = result.new_promotions;
|
|
16620
16719
|
} catch (hiveErr) {
|
|
16621
16720
|
const msg = hiveErr instanceof Error ? hiveErr.message : String(hiveErr);
|
|
@@ -16636,7 +16735,7 @@ async function runFinalizeStage(ctx) {
|
|
|
16636
16735
|
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.` : "";
|
|
16637
16736
|
if (ctx.runSkillReview) {
|
|
16638
16737
|
try {
|
|
16639
|
-
const { config: loadedConfig } =
|
|
16738
|
+
const { config: loadedConfig } = _internals25.loadPluginConfigWithMeta(ctx.directory);
|
|
16640
16739
|
const skillImproverConfig = SkillImproverConfigSchema.parse(loadedConfig.skill_improver ?? {});
|
|
16641
16740
|
const skillReviewResult = await runAbortableSkillReview({
|
|
16642
16741
|
directory: ctx.directory,
|
|
@@ -16699,7 +16798,7 @@ async function runFinalizeStage(ctx) {
|
|
|
16699
16798
|
}
|
|
16700
16799
|
if (!ctx.planAlreadyDone || ctx.guaranteeResult.closedPhaseIds.length > 0 || ctx.guaranteeResult.closedTaskIds.length > 0) {
|
|
16701
16800
|
try {
|
|
16702
|
-
await
|
|
16801
|
+
await _internals25.closePlanTerminalState(ctx.directory, ctx.planData, {
|
|
16703
16802
|
closedPhaseIds: ctx.guaranteeResult.closedPhaseIds,
|
|
16704
16803
|
closedTaskIds: ctx.guaranteeResult.closedTaskIds,
|
|
16705
16804
|
originalStatuses: ctx.originalStatuses
|
|
@@ -16716,11 +16815,11 @@ async function runFinalizeStage(ctx) {
|
|
|
16716
16815
|
}
|
|
16717
16816
|
try {
|
|
16718
16817
|
const { CuratorConfigSchema: CCS } = await import("./schema-vwxpsk6j.js");
|
|
16719
|
-
const { config: pmLoadedConfig } =
|
|
16818
|
+
const { config: pmLoadedConfig } = _internals25.loadPluginConfigWithMeta(ctx.directory);
|
|
16720
16819
|
const curatorCfg = CCS.parse(pmLoadedConfig.curator ?? {});
|
|
16721
16820
|
if (curatorCfg.enabled && curatorCfg.postmortem_enabled) {
|
|
16722
|
-
const pmResult = await
|
|
16723
|
-
llmDelegate:
|
|
16821
|
+
const pmResult = await _internals25.runCuratorPostMortem(ctx.directory, {
|
|
16822
|
+
llmDelegate: _internals25.createCuratorLLMDelegate(ctx.directory, "postmortem", ctx.options.sessionID),
|
|
16724
16823
|
scope: "project",
|
|
16725
16824
|
sessionID: ctx.options.sessionID
|
|
16726
16825
|
});
|
|
@@ -16746,7 +16845,7 @@ async function copySqliteSafe(srcPath, destPath, laneEnv) {
|
|
|
16746
16845
|
}
|
|
16747
16846
|
let checkpointVerified = false;
|
|
16748
16847
|
try {
|
|
16749
|
-
const result =
|
|
16848
|
+
const result = _internals25.spawnSync("sqlite3", [srcPath, "PRAGMA wal_checkpoint(TRUNCATE);"], {
|
|
16750
16849
|
cwd: path31.dirname(srcPath),
|
|
16751
16850
|
encoding: "utf-8",
|
|
16752
16851
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -16913,7 +17012,7 @@ async function runArchiveEvidenceRetention(ctx) {
|
|
|
16913
17012
|
let maxAgeDays = 30;
|
|
16914
17013
|
let maxBundles = 10;
|
|
16915
17014
|
try {
|
|
16916
|
-
const { config: evidenceLoadedConfig } =
|
|
17015
|
+
const { config: evidenceLoadedConfig } = _internals25.loadPluginConfigWithMeta(ctx.directory);
|
|
16917
17016
|
const evidenceCfg = evidenceLoadedConfig.evidence ?? {};
|
|
16918
17017
|
if (typeof evidenceCfg.max_age_days === "number") {
|
|
16919
17018
|
maxAgeDays = evidenceCfg.max_age_days;
|
|
@@ -16923,7 +17022,7 @@ async function runArchiveEvidenceRetention(ctx) {
|
|
|
16923
17022
|
}
|
|
16924
17023
|
} catch {}
|
|
16925
17024
|
try {
|
|
16926
|
-
await
|
|
17025
|
+
await _internals25.archiveEvidence(ctx.directory, maxAgeDays, maxBundles);
|
|
16927
17026
|
} catch (error2) {
|
|
16928
17027
|
const msg = error2 instanceof Error ? error2.message : String(error2);
|
|
16929
17028
|
ctx.warnings.push(`Evidence retention archive failed: ${msg}`);
|
|
@@ -17126,9 +17225,9 @@ async function runAlignStage(ctx) {
|
|
|
17126
17225
|
const pruneBranches = ctx.args.includes("--prune-branches");
|
|
17127
17226
|
let gitAlignResult = "";
|
|
17128
17227
|
const prunedBranches = [];
|
|
17129
|
-
const gitStatus =
|
|
17228
|
+
const gitStatus = _internals25.getGitRepositoryStatus(ctx.directory);
|
|
17130
17229
|
if (gitStatus.isRepo) {
|
|
17131
|
-
const aggressiveResult = await
|
|
17230
|
+
const aggressiveResult = await _internals25.resetToMainAfterMerge(ctx.directory, {
|
|
17132
17231
|
pruneBranches
|
|
17133
17232
|
});
|
|
17134
17233
|
if (aggressiveResult.success) {
|
|
@@ -17140,7 +17239,7 @@ async function runAlignStage(ctx) {
|
|
|
17140
17239
|
ctx.warnings.push("Uncommitted changes were discarded during git alignment");
|
|
17141
17240
|
}
|
|
17142
17241
|
} else {
|
|
17143
|
-
const alignResult = await
|
|
17242
|
+
const alignResult = await _internals25.resetToRemoteBranch(ctx.directory, {
|
|
17144
17243
|
pruneBranches
|
|
17145
17244
|
});
|
|
17146
17245
|
gitAlignResult = alignResult.message;
|
|
@@ -17176,7 +17275,7 @@ async function runFinalizeDryRun(directory, swarmDir, planData, planExists) {
|
|
|
17176
17275
|
const wouldArchiveDirs = ACTIVE_STATE_DIRS_TO_CLEAN.filter(existsInSwarm);
|
|
17177
17276
|
const wouldRemoveTerminal = TERMINAL_STATE_FILES.filter(existsInSwarm);
|
|
17178
17277
|
const wouldCleanFiles = ACTIVE_STATE_TO_CLEAN.filter((f) => existsInSwarm(f) && !TERMINAL_STATE_FILES.includes(f));
|
|
17179
|
-
const gitStatus =
|
|
17278
|
+
const gitStatus = _internals25.getGitRepositoryStatus(directory);
|
|
17180
17279
|
const gitNote = gitStatus.isRepo ? "would align the working tree to main/remote (git reset), pruning merged branches only with --prune-branches" : "would skip git alignment (not a git repository / git unavailable)";
|
|
17181
17280
|
const lines = [
|
|
17182
17281
|
"## /swarm finalize \u2014 DRY RUN (no changes made)",
|
|
@@ -17248,12 +17347,12 @@ async function handleCloseCommand(directory, args, options = {}) {
|
|
|
17248
17347
|
}
|
|
17249
17348
|
}
|
|
17250
17349
|
if (args.includes("--dry-run")) {
|
|
17251
|
-
return
|
|
17350
|
+
return _internals25.runFinalizeDryRun(directory, swarmDir, planData, planExists);
|
|
17252
17351
|
}
|
|
17253
17352
|
let finalizeLock = {
|
|
17254
17353
|
acquired: false
|
|
17255
17354
|
};
|
|
17256
|
-
finalizeLock = await
|
|
17355
|
+
finalizeLock = await _internals25.acquireFinalizeLock(directory);
|
|
17257
17356
|
if (!finalizeLock.acquired) {
|
|
17258
17357
|
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.`;
|
|
17259
17358
|
}
|
|
@@ -17284,7 +17383,7 @@ This project was already finalized in a previous /swarm close run. The plan has
|
|
|
17284
17383
|
if (planExists) {
|
|
17285
17384
|
planAlreadyDone = phases.length > 0 && phases.every((p) => p.status === "complete" || p.status === "completed" || p.status === "blocked" || p.status === "closed");
|
|
17286
17385
|
}
|
|
17287
|
-
const { config: loadedConfig } =
|
|
17386
|
+
const { config: loadedConfig } = _internals25.loadPluginConfigWithMeta(directory);
|
|
17288
17387
|
const config = KnowledgeConfigSchema.parse(loadedConfig.knowledge ?? {});
|
|
17289
17388
|
const ctx = {
|
|
17290
17389
|
directory,
|
|
@@ -17328,7 +17427,7 @@ This project was already finalized in a previous /swarm close run. The plan has
|
|
|
17328
17427
|
args
|
|
17329
17428
|
};
|
|
17330
17429
|
await runFinalizeStage(ctx);
|
|
17331
|
-
await
|
|
17430
|
+
await _internals25.runFinalizeRewardSweep({
|
|
17332
17431
|
directory,
|
|
17333
17432
|
closedTaskIds: ctx.guaranteeResult.closedTaskIds,
|
|
17334
17433
|
memoryConfig: loadedConfig.memory
|
|
@@ -17410,9 +17509,9 @@ This project was already finalized in a previous /swarm close run. The plan has
|
|
|
17410
17509
|
try {
|
|
17411
17510
|
const sessionIdsToEnd = [...swarmState.agentSessions.keys()];
|
|
17412
17511
|
for (const sessionId of sessionIdsToEnd) {
|
|
17413
|
-
|
|
17512
|
+
_internals25.endAgentSession(sessionId);
|
|
17414
17513
|
}
|
|
17415
|
-
|
|
17514
|
+
_internals25.resetSwarmStatePreservingSingletons();
|
|
17416
17515
|
} catch (teardownError) {
|
|
17417
17516
|
const msg = teardownError instanceof Error ? teardownError.message : String(teardownError);
|
|
17418
17517
|
ctx.warnings.push(`Session teardown encountered an error after finalization completed (state may not be fully reset): ${msg}`);
|
|
@@ -17486,7 +17585,7 @@ async function acquireFinalizeLock(directory) {
|
|
|
17486
17585
|
}
|
|
17487
17586
|
return { acquired: false };
|
|
17488
17587
|
}
|
|
17489
|
-
var
|
|
17588
|
+
var _internals25 = {
|
|
17490
17589
|
ACTIVE_STATE_DIRS_TO_CLEAN,
|
|
17491
17590
|
countSessionKnowledgeEntries,
|
|
17492
17591
|
CLOSE_SKILL_REVIEW_TIMEOUT_MS,
|
|
@@ -18314,9 +18413,9 @@ async function detectDarkMatter(directory, options) {
|
|
|
18314
18413
|
} catch {
|
|
18315
18414
|
return [];
|
|
18316
18415
|
}
|
|
18317
|
-
const commitMap = await
|
|
18318
|
-
const matrix =
|
|
18319
|
-
const staticEdges = await
|
|
18416
|
+
const commitMap = await _internals26.parseGitLog(directory, maxCommitsToAnalyze);
|
|
18417
|
+
const matrix = _internals26.buildCoChangeMatrix(commitMap, maxFilesPerCommit);
|
|
18418
|
+
const staticEdges = await _internals26.getStaticEdges(directory);
|
|
18320
18419
|
const results = [];
|
|
18321
18420
|
for (const entry of matrix.values()) {
|
|
18322
18421
|
const key = `${entry.fileA}::${entry.fileB}`;
|
|
@@ -18432,11 +18531,11 @@ var co_change_analyzer = createSwarmTool({
|
|
|
18432
18531
|
npmiThreshold,
|
|
18433
18532
|
maxCommitsToAnalyze
|
|
18434
18533
|
};
|
|
18435
|
-
const pairs = await
|
|
18436
|
-
return
|
|
18534
|
+
const pairs = await _internals26.detectDarkMatter(directory, options);
|
|
18535
|
+
return _internals26.formatDarkMatterOutput(pairs);
|
|
18437
18536
|
}
|
|
18438
18537
|
});
|
|
18439
|
-
var
|
|
18538
|
+
var _internals26 = {
|
|
18440
18539
|
parseGitLog,
|
|
18441
18540
|
buildCoChangeMatrix,
|
|
18442
18541
|
getStaticEdges,
|
|
@@ -18453,7 +18552,7 @@ var DEFAULT_MAX_COMMITS = 500;
|
|
|
18453
18552
|
var cache = new Map;
|
|
18454
18553
|
async function readGitHead(directory) {
|
|
18455
18554
|
try {
|
|
18456
|
-
const { stdout } = await
|
|
18555
|
+
const { stdout } = await _internals27.execFile("git", ["rev-parse", "HEAD"], {
|
|
18457
18556
|
cwd: directory,
|
|
18458
18557
|
timeout: GIT_HEAD_TIMEOUT_MS
|
|
18459
18558
|
});
|
|
@@ -18479,9 +18578,9 @@ async function getCoChangeData(directory, options) {
|
|
|
18479
18578
|
let entries;
|
|
18480
18579
|
let commitsObserved;
|
|
18481
18580
|
try {
|
|
18482
|
-
const commitMap = await
|
|
18581
|
+
const commitMap = await _internals27.parseGitLog(directory, maxCommits);
|
|
18483
18582
|
commitsObserved = commitMap.size;
|
|
18484
|
-
const matrix =
|
|
18583
|
+
const matrix = _internals27.buildCoChangeMatrix(commitMap);
|
|
18485
18584
|
entries = Array.from(matrix.values());
|
|
18486
18585
|
} catch {
|
|
18487
18586
|
return { pairs: [], commitsObserved: 0 };
|
|
@@ -18505,10 +18604,10 @@ async function getCoChangePairs(directory, options) {
|
|
|
18505
18604
|
const data = await getCoChangeData(directory, options);
|
|
18506
18605
|
return data.pairs;
|
|
18507
18606
|
}
|
|
18508
|
-
var
|
|
18607
|
+
var _internals27 = {
|
|
18509
18608
|
execFile: execFileAsync,
|
|
18510
|
-
parseGitLog:
|
|
18511
|
-
buildCoChangeMatrix:
|
|
18609
|
+
parseGitLog: _internals26.parseGitLog,
|
|
18610
|
+
buildCoChangeMatrix: _internals26.buildCoChangeMatrix
|
|
18512
18611
|
};
|
|
18513
18612
|
|
|
18514
18613
|
// src/turbo/epic/cochange-conflict.ts
|
|
@@ -18790,7 +18889,7 @@ async function handleCouplingCommand(directory, args) {
|
|
|
18790
18889
|
|
|
18791
18890
|
Usage: /swarm coupling [--phase <n>] [--threshold <-1..1>] [--min-co-changes <n>] [--format markdown|json] [--persist]`;
|
|
18792
18891
|
}
|
|
18793
|
-
const plan = await
|
|
18892
|
+
const plan = await _internals28.loadPlanJsonOnly(directory);
|
|
18794
18893
|
if (plan === null) {
|
|
18795
18894
|
return "No plan found at `.swarm/plan.json`. Run `/swarm plan` to create one before measuring coupling.";
|
|
18796
18895
|
}
|
|
@@ -18814,7 +18913,7 @@ Usage: /swarm coupling [--phase <n>] [--threshold <-1..1>] [--min-co-changes <n>
|
|
|
18814
18913
|
const scope = scopeFiles ?? task.files_touched ?? [];
|
|
18815
18914
|
return { id: task.id, scope };
|
|
18816
18915
|
});
|
|
18817
|
-
const cochangePairs = await
|
|
18916
|
+
const cochangePairs = await _internals28.getCoChangePairs(directory);
|
|
18818
18917
|
const report = computeCouplingReport(tasks, cochangePairs, {
|
|
18819
18918
|
npmi: parsed.threshold,
|
|
18820
18919
|
minCoChanges: parsed.minCoChanges
|
|
@@ -18853,13 +18952,13 @@ _Warning: failed to persist report (${persistStatus.error})._`;
|
|
|
18853
18952
|
}
|
|
18854
18953
|
return `${formatCouplingReportMarkdown(report)}${persistTrailer}`;
|
|
18855
18954
|
}
|
|
18856
|
-
var
|
|
18955
|
+
var _internals28 = {
|
|
18857
18956
|
loadPlanJsonOnly,
|
|
18858
18957
|
getCoChangePairs
|
|
18859
18958
|
};
|
|
18860
18959
|
|
|
18861
18960
|
// src/commands/curate.ts
|
|
18862
|
-
var
|
|
18961
|
+
var _internals29 = {
|
|
18863
18962
|
checkHivePromotions,
|
|
18864
18963
|
readKnowledge,
|
|
18865
18964
|
resolveSwarmKnowledgePath,
|
|
@@ -18867,8 +18966,8 @@ var _internals28 = {
|
|
|
18867
18966
|
loadCuratorDeps: async () => {
|
|
18868
18967
|
const [{ CuratorConfigSchema }, curator, { createCuratorLLMDelegate: createCuratorLLMDelegate2 }] = await Promise.all([
|
|
18869
18968
|
import("./schema-vwxpsk6j.js"),
|
|
18870
|
-
import("./curator-
|
|
18871
|
-
import("./curator-llm-factory-
|
|
18969
|
+
import("./curator-3azybqrw.js"),
|
|
18970
|
+
import("./curator-llm-factory-6rafny5e.js")
|
|
18872
18971
|
]);
|
|
18873
18972
|
return { CuratorConfigSchema, curator, createCuratorLLMDelegate: createCuratorLLMDelegate2 };
|
|
18874
18973
|
}
|
|
@@ -18876,15 +18975,15 @@ var _internals28 = {
|
|
|
18876
18975
|
async function handleCurateCommand(directory, _args, options) {
|
|
18877
18976
|
try {
|
|
18878
18977
|
const config = KnowledgeConfigSchema.parse({});
|
|
18879
|
-
const swarmPath =
|
|
18880
|
-
const swarmEntries = await
|
|
18881
|
-
const summary = await
|
|
18978
|
+
const swarmPath = _internals29.resolveSwarmKnowledgePath(directory);
|
|
18979
|
+
const swarmEntries = await _internals29.readKnowledge(swarmPath) ?? [];
|
|
18980
|
+
const summary = await _internals29.checkHivePromotions(swarmEntries, config, directory);
|
|
18882
18981
|
if (options?.sessionID) {
|
|
18883
18982
|
let onDemandPhase = 1;
|
|
18884
18983
|
try {
|
|
18885
|
-
const { CuratorConfigSchema, curator, createCuratorLLMDelegate: createCuratorLLMDelegate2 } = await
|
|
18984
|
+
const { CuratorConfigSchema, curator, createCuratorLLMDelegate: createCuratorLLMDelegate2 } = await _internals29.loadCuratorDeps();
|
|
18886
18985
|
const curatorConfig = CuratorConfigSchema.parse({});
|
|
18887
|
-
const priorSummary = await
|
|
18986
|
+
const priorSummary = await _internals29.readSwarmFileAsync(directory, "curator-summary.json");
|
|
18888
18987
|
if (priorSummary) {
|
|
18889
18988
|
try {
|
|
18890
18989
|
const parsed = JSON.parse(priorSummary);
|
|
@@ -18895,7 +18994,7 @@ async function handleCurateCommand(directory, _args, options) {
|
|
|
18895
18994
|
}
|
|
18896
18995
|
let planPhaseCount = Infinity;
|
|
18897
18996
|
try {
|
|
18898
|
-
const planRaw = await
|
|
18997
|
+
const planRaw = await _internals29.readSwarmFileAsync(directory, "plan.json");
|
|
18899
18998
|
if (planRaw) {
|
|
18900
18999
|
const plan = JSON.parse(planRaw);
|
|
18901
19000
|
if (Array.isArray(plan.phases))
|
|
@@ -18914,8 +19013,8 @@ async function handleCurateCommand(directory, _args, options) {
|
|
|
18914
19013
|
summary.knowledge_skipped = applied.skipped;
|
|
18915
19014
|
summary.curator_phase = onDemandPhase;
|
|
18916
19015
|
try {
|
|
18917
|
-
const updatedEntries = await
|
|
18918
|
-
const postUpdateHive = await
|
|
19016
|
+
const updatedEntries = await _internals29.readKnowledge(swarmPath) ?? [];
|
|
19017
|
+
const postUpdateHive = await _internals29.checkHivePromotions(updatedEntries, config, directory);
|
|
18919
19018
|
summary.new_promotions += postUpdateHive.new_promotions;
|
|
18920
19019
|
summary.encounters_incremented += postUpdateHive.encounters_incremented;
|
|
18921
19020
|
summary.advancements += postUpdateHive.advancements;
|
|
@@ -18981,7 +19080,7 @@ async function handleDarkMatterCommand(directory, args) {
|
|
|
18981
19080
|
}
|
|
18982
19081
|
let pairs;
|
|
18983
19082
|
try {
|
|
18984
|
-
pairs = await
|
|
19083
|
+
pairs = await _internals26.detectDarkMatter(directory, options);
|
|
18985
19084
|
} catch (err) {
|
|
18986
19085
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
18987
19086
|
return `## Dark Matter Analysis Failed
|
|
@@ -19245,7 +19344,7 @@ ${USAGE5}`;
|
|
|
19245
19344
|
|
|
19246
19345
|
// src/commands/design-docs.ts
|
|
19247
19346
|
var MAX_DESC_LEN = 2000;
|
|
19248
|
-
var
|
|
19347
|
+
var _internals30 = { loadPluginConfigWithMeta };
|
|
19249
19348
|
var USAGE6 = `Usage: /swarm design-docs <description> [--out <dir>] [--lang <name>] [--update]
|
|
19250
19349
|
|
|
19251
19350
|
Generate or sync language-agnostic design docs for the project under build:
|
|
@@ -19341,7 +19440,7 @@ async function handleDesignDocsCommand(directory, args) {
|
|
|
19341
19440
|
${USAGE6}`;
|
|
19342
19441
|
}
|
|
19343
19442
|
try {
|
|
19344
|
-
const { config } =
|
|
19443
|
+
const { config } = _internals30.loadPluginConfigWithMeta(directory);
|
|
19345
19444
|
if (config.design_docs?.enabled !== true) {
|
|
19346
19445
|
return "Error: design docs are disabled. Set `design_docs.enabled: true` in " + `opencode-swarm.json to enable the docs_design agent and this command.
|
|
19347
19446
|
|
|
@@ -19366,7 +19465,7 @@ import { fileURLToPath } from "url";
|
|
|
19366
19465
|
// package.json
|
|
19367
19466
|
var package_default = {
|
|
19368
19467
|
name: "opencode-swarm",
|
|
19369
|
-
version: "7.121.
|
|
19468
|
+
version: "7.121.4",
|
|
19370
19469
|
description: "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
|
|
19371
19470
|
main: "dist/index.js",
|
|
19372
19471
|
types: "dist/index.d.ts",
|
|
@@ -19466,7 +19565,8 @@ var package_default = {
|
|
|
19466
19565
|
"package:smoke": "node scripts/package-smoke.mjs",
|
|
19467
19566
|
prepare: "bun run build",
|
|
19468
19567
|
"repro:704": "node scripts/repro-704.mjs",
|
|
19469
|
-
"repro:1144": "bun scripts/repro-1144.mjs"
|
|
19568
|
+
"repro:1144": "bun scripts/repro-1144.mjs",
|
|
19569
|
+
"repro:1873": "bun build scripts/repro-1873-entry.ts --outdir dist-build-test/repro-1873 --target node --format esm && node scripts/repro-1873.mjs"
|
|
19470
19570
|
},
|
|
19471
19571
|
dependencies: {
|
|
19472
19572
|
"@opencode-ai/plugin": "^1.1.53",
|
|
@@ -19987,7 +20087,7 @@ function resolveCachePackageRoot(cachePath) {
|
|
|
19987
20087
|
const nestedPackageRoot = path38.join(cachePath, "node_modules", "opencode-swarm");
|
|
19988
20088
|
return existsSync22(nestedPackageRoot) ? nestedPackageRoot : cachePath;
|
|
19989
20089
|
}
|
|
19990
|
-
var
|
|
20090
|
+
var _internals31 = {
|
|
19991
20091
|
detectSandboxCapability: () => sandboxCapabilityProbe.detect(),
|
|
19992
20092
|
getSandboxExecutor: getExecutor
|
|
19993
20093
|
};
|
|
@@ -20571,9 +20671,9 @@ async function checkCurator(directory) {
|
|
|
20571
20671
|
}
|
|
20572
20672
|
async function getSandboxStatus() {
|
|
20573
20673
|
try {
|
|
20574
|
-
const capability = await
|
|
20674
|
+
const capability = await _internals31.detectSandboxCapability();
|
|
20575
20675
|
const mechanism = capability.mechanism ?? "none";
|
|
20576
|
-
const executor = await
|
|
20676
|
+
const executor = await _internals31.getSandboxExecutor();
|
|
20577
20677
|
const hasExecutor = executor !== null;
|
|
20578
20678
|
if (hasExecutor) {
|
|
20579
20679
|
const executorStrength = executor?.strength;
|
|
@@ -21325,7 +21425,7 @@ function readPromotionEvidence(directory) {
|
|
|
21325
21425
|
}
|
|
21326
21426
|
|
|
21327
21427
|
// src/commands/epic.ts
|
|
21328
|
-
var
|
|
21428
|
+
var _internals32 = {
|
|
21329
21429
|
loadPluginConfigWithMeta,
|
|
21330
21430
|
loadPlanJsonOnly,
|
|
21331
21431
|
getCoChangeData,
|
|
@@ -21347,7 +21447,7 @@ async function handleEpicCommand(directory, args, sessionID) {
|
|
|
21347
21447
|
if (!sessionID || sessionID.trim() === "") {
|
|
21348
21448
|
return "Error: No active session context. Epic Mode requires an active session. Use /swarm epic from within an OpenCode session.";
|
|
21349
21449
|
}
|
|
21350
|
-
const session =
|
|
21450
|
+
const session = _internals32.ensureAgentSession(sessionID, undefined, directory);
|
|
21351
21451
|
const arg0 = args[0]?.toLowerCase();
|
|
21352
21452
|
switch (arg0) {
|
|
21353
21453
|
case "status":
|
|
@@ -21374,7 +21474,7 @@ Usage:
|
|
|
21374
21474
|
}
|
|
21375
21475
|
function enableAndAck(directory, sessionID, session) {
|
|
21376
21476
|
try {
|
|
21377
|
-
|
|
21477
|
+
_internals32.enableEpicMode(directory, sessionID);
|
|
21378
21478
|
} catch (err) {
|
|
21379
21479
|
return `Error enabling Epic Mode: ${err instanceof Error ? err.message : String(err)}`;
|
|
21380
21480
|
}
|
|
@@ -21390,7 +21490,7 @@ function enableAndAck(directory, sessionID, session) {
|
|
|
21390
21490
|
}
|
|
21391
21491
|
function disableAndAck(directory, sessionID, session) {
|
|
21392
21492
|
try {
|
|
21393
|
-
|
|
21493
|
+
_internals32.disableEpicMode(directory, sessionID);
|
|
21394
21494
|
} catch (err) {
|
|
21395
21495
|
return `Error disabling Epic Mode: ${err instanceof Error ? err.message : String(err)}`;
|
|
21396
21496
|
}
|
|
@@ -21399,12 +21499,12 @@ function disableAndAck(directory, sessionID, session) {
|
|
|
21399
21499
|
}
|
|
21400
21500
|
function renderStatus(directory, sessionID) {
|
|
21401
21501
|
const lines = ["## Epic Mode \u2014 Status", ""];
|
|
21402
|
-
if (
|
|
21502
|
+
if (_internals32.isStateUnreadable(directory)) {
|
|
21403
21503
|
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.");
|
|
21404
21504
|
return lines.join(`
|
|
21405
21505
|
`);
|
|
21406
21506
|
}
|
|
21407
|
-
const state =
|
|
21507
|
+
const state = _internals32.loadEpicSessionState(directory, sessionID);
|
|
21408
21508
|
if (!state) {
|
|
21409
21509
|
lines.push("Epic Mode has not been toggled for this session.");
|
|
21410
21510
|
return lines.join(`
|
|
@@ -21456,7 +21556,7 @@ function formatGreenfieldDetail(input) {
|
|
|
21456
21556
|
function renderLast(directory) {
|
|
21457
21557
|
let records;
|
|
21458
21558
|
try {
|
|
21459
|
-
records =
|
|
21559
|
+
records = _internals32.readPromotionEvidence(directory);
|
|
21460
21560
|
} catch (err) {
|
|
21461
21561
|
return `Error reading epic-promotions.jsonl: ${err instanceof Error ? err.message : String(err)}`;
|
|
21462
21562
|
}
|
|
@@ -21511,7 +21611,7 @@ function renderLast(directory) {
|
|
|
21511
21611
|
`);
|
|
21512
21612
|
}
|
|
21513
21613
|
function renderCalibration(directory) {
|
|
21514
|
-
if (
|
|
21614
|
+
if (_internals32.isCalibrationStateUnreadable(directory)) {
|
|
21515
21615
|
return [
|
|
21516
21616
|
"## Epic Mode \u2014 Calibration",
|
|
21517
21617
|
"",
|
|
@@ -21523,11 +21623,11 @@ function renderCalibration(directory) {
|
|
|
21523
21623
|
}
|
|
21524
21624
|
let state;
|
|
21525
21625
|
try {
|
|
21526
|
-
state =
|
|
21626
|
+
state = _internals32.loadCalibrationState(directory);
|
|
21527
21627
|
} catch (err) {
|
|
21528
21628
|
return `Error reading calibration state: ${err instanceof Error ? err.message : String(err)}`;
|
|
21529
21629
|
}
|
|
21530
|
-
const { config } =
|
|
21630
|
+
const { config } = _internals32.loadPluginConfigWithMeta(directory);
|
|
21531
21631
|
const staticThreshold = config.turbo?.epic?.mode?.activation_threshold ?? 0.3;
|
|
21532
21632
|
const calibrationCfg = config.turbo?.epic?.calibration;
|
|
21533
21633
|
const loosenWindow = calibrationCfg?.loosen_window ?? 10;
|
|
@@ -21575,7 +21675,7 @@ function renderCalibration(directory) {
|
|
|
21575
21675
|
lines.push("");
|
|
21576
21676
|
let recentDivergent = [];
|
|
21577
21677
|
try {
|
|
21578
|
-
const all =
|
|
21678
|
+
const all = _internals32.readDivergenceHistory(directory, { limit: 50 });
|
|
21579
21679
|
recentDivergent = all.filter((r) => !r.isClean).slice(-5);
|
|
21580
21680
|
} catch {}
|
|
21581
21681
|
lines.push("### Recent divergent tasks (tightened the threshold)");
|
|
@@ -21592,11 +21692,11 @@ function renderCalibration(directory) {
|
|
|
21592
21692
|
`);
|
|
21593
21693
|
}
|
|
21594
21694
|
async function renderDecide(directory) {
|
|
21595
|
-
const plan = await
|
|
21695
|
+
const plan = await _internals32.loadPlanJsonOnly(directory);
|
|
21596
21696
|
if (!plan) {
|
|
21597
21697
|
return "No plan found at `.swarm/plan.json`. Run `/swarm plan` first.";
|
|
21598
21698
|
}
|
|
21599
|
-
const { config } =
|
|
21699
|
+
const { config } = _internals32.loadPluginConfigWithMeta(directory);
|
|
21600
21700
|
const modeCfg = config.turbo?.epic?.mode;
|
|
21601
21701
|
const cochangeCfg = config.turbo?.epic?.cochange;
|
|
21602
21702
|
const activationThreshold = modeCfg?.activation_threshold ?? 0.3;
|
|
@@ -21606,20 +21706,20 @@ async function renderDecide(directory) {
|
|
|
21606
21706
|
const tasks = [];
|
|
21607
21707
|
for (const phase of plan.phases) {
|
|
21608
21708
|
for (const task of phase.tasks) {
|
|
21609
|
-
const scopeFiles =
|
|
21709
|
+
const scopeFiles = _internals32.readTaskScopes(directory, task.id);
|
|
21610
21710
|
const scope = scopeFiles ?? task.files_touched ?? [];
|
|
21611
21711
|
tasks.push({ id: task.id, scope });
|
|
21612
21712
|
}
|
|
21613
21713
|
}
|
|
21614
|
-
const { pairs, commitsObserved } = await
|
|
21714
|
+
const { pairs, commitsObserved } = await _internals32.getCoChangeData(directory);
|
|
21615
21715
|
const isGitProject = (() => {
|
|
21616
21716
|
try {
|
|
21617
|
-
return
|
|
21717
|
+
return _internals32.isGitRepo(directory);
|
|
21618
21718
|
} catch {
|
|
21619
21719
|
return false;
|
|
21620
21720
|
}
|
|
21621
21721
|
})();
|
|
21622
|
-
const verdict =
|
|
21722
|
+
const verdict = _internals32.decideEpicActivation(tasks, pairs, commitsObserved, {
|
|
21623
21723
|
activationThreshold,
|
|
21624
21724
|
minCommitsForSignal,
|
|
21625
21725
|
cochangeNpmiThreshold,
|
|
@@ -21663,7 +21763,7 @@ function formatVerdict(verdict) {
|
|
|
21663
21763
|
}
|
|
21664
21764
|
|
|
21665
21765
|
// src/services/evidence-service.ts
|
|
21666
|
-
var
|
|
21766
|
+
var _internals33 = {
|
|
21667
21767
|
loadEvidence,
|
|
21668
21768
|
listEvidenceTaskIds
|
|
21669
21769
|
};
|
|
@@ -21708,7 +21808,7 @@ function getVerdictEmoji(verdict) {
|
|
|
21708
21808
|
return getVerdictIcon(verdict);
|
|
21709
21809
|
}
|
|
21710
21810
|
async function getTaskEvidenceData(directory, taskId) {
|
|
21711
|
-
const result = await
|
|
21811
|
+
const result = await _internals33.loadEvidence(directory, taskId);
|
|
21712
21812
|
if (result.status !== "found") {
|
|
21713
21813
|
return {
|
|
21714
21814
|
hasEvidence: false,
|
|
@@ -21731,13 +21831,13 @@ async function getTaskEvidenceData(directory, taskId) {
|
|
|
21731
21831
|
};
|
|
21732
21832
|
}
|
|
21733
21833
|
async function getEvidenceListData(directory) {
|
|
21734
|
-
const taskIds = await
|
|
21834
|
+
const taskIds = await _internals33.listEvidenceTaskIds(directory);
|
|
21735
21835
|
if (taskIds.length === 0) {
|
|
21736
21836
|
return { hasEvidence: false, tasks: [] };
|
|
21737
21837
|
}
|
|
21738
21838
|
const tasks = [];
|
|
21739
21839
|
for (const taskId of taskIds) {
|
|
21740
|
-
const result = await
|
|
21840
|
+
const result = await _internals33.loadEvidence(directory, taskId);
|
|
21741
21841
|
if (result.status === "found") {
|
|
21742
21842
|
tasks.push({
|
|
21743
21843
|
taskId,
|
|
@@ -22632,7 +22732,7 @@ function isStaticallyEquivalent(originalCode, mutatedCode) {
|
|
|
22632
22732
|
const strippedMutated = stripCode(mutatedCode);
|
|
22633
22733
|
return strippedOriginal === strippedMutated;
|
|
22634
22734
|
}
|
|
22635
|
-
var
|
|
22735
|
+
var _internals34 = {
|
|
22636
22736
|
isStaticallyEquivalent,
|
|
22637
22737
|
checkEquivalence,
|
|
22638
22738
|
batchCheckEquivalence
|
|
@@ -22672,7 +22772,7 @@ async function batchCheckEquivalence(patches, llmJudge) {
|
|
|
22672
22772
|
const results = [];
|
|
22673
22773
|
for (const { patch, originalCode, mutatedCode } of patches) {
|
|
22674
22774
|
try {
|
|
22675
|
-
const result = await
|
|
22775
|
+
const result = await _internals34.checkEquivalence(patch, originalCode, mutatedCode, llmJudge);
|
|
22676
22776
|
results.push(result);
|
|
22677
22777
|
} catch (err) {
|
|
22678
22778
|
results.push({
|
|
@@ -22746,10 +22846,10 @@ function isMissingExecutableFailure(message) {
|
|
|
22746
22846
|
return /\bENOENT\b/i.test(message) || /\bexecutable\b[^\r\n]*\bnot found\b/i.test(message) || /\bnot found in (?:the )?\$?PATH\b/i.test(message);
|
|
22747
22847
|
}
|
|
22748
22848
|
var runMutationCommand = async (args) => {
|
|
22749
|
-
const resolvedExecutable =
|
|
22849
|
+
const resolvedExecutable = _internals35.resolveExecutableFromPath([
|
|
22750
22850
|
args.executable
|
|
22751
22851
|
]);
|
|
22752
|
-
const result = await
|
|
22852
|
+
const result = await _internals35.runExternalTool({
|
|
22753
22853
|
executable: resolvedExecutable ?? args.executable,
|
|
22754
22854
|
args: args.args,
|
|
22755
22855
|
cwd: args.cwd,
|
|
@@ -22768,7 +22868,7 @@ var runMutationCommand = async (args) => {
|
|
|
22768
22868
|
};
|
|
22769
22869
|
var runLegacyTestSeam = async (args) => {
|
|
22770
22870
|
try {
|
|
22771
|
-
const result =
|
|
22871
|
+
const result = _internals35.spawnSync(args.executable, args.args, {
|
|
22772
22872
|
cwd: args.cwd,
|
|
22773
22873
|
timeout: args.timeoutMs,
|
|
22774
22874
|
stdio: "pipe"
|
|
@@ -22802,11 +22902,11 @@ var runLegacyTestSeam = async (args) => {
|
|
|
22802
22902
|
function selectRunner(options) {
|
|
22803
22903
|
if (options.runner)
|
|
22804
22904
|
return options.runner;
|
|
22805
|
-
if (
|
|
22905
|
+
if (_internals35.spawnSync !== defaultLegacySpawnSync)
|
|
22806
22906
|
return runLegacyTestSeam;
|
|
22807
|
-
return
|
|
22907
|
+
return _internals35.runCommand;
|
|
22808
22908
|
}
|
|
22809
|
-
var
|
|
22909
|
+
var _internals35 = {
|
|
22810
22910
|
executeMutation,
|
|
22811
22911
|
computeReport,
|
|
22812
22912
|
executeMutationSuite,
|
|
@@ -24047,11 +24147,11 @@ var quality_budget = createSwarmTool({
|
|
|
24047
24147
|
}).optional().describe("Quality budget thresholds")
|
|
24048
24148
|
},
|
|
24049
24149
|
async execute(args, directory) {
|
|
24050
|
-
const result = await
|
|
24150
|
+
const result = await _internals36.qualityBudget(args, directory);
|
|
24051
24151
|
return JSON.stringify(result);
|
|
24052
24152
|
}
|
|
24053
24153
|
});
|
|
24054
|
-
var
|
|
24154
|
+
var _internals36 = {
|
|
24055
24155
|
qualityBudget
|
|
24056
24156
|
};
|
|
24057
24157
|
|
|
@@ -24919,7 +25019,7 @@ var DEFAULT_RULES_DIR = ".swarm/semgrep-rules";
|
|
|
24919
25019
|
var DEFAULT_TIMEOUT_MS = 30000;
|
|
24920
25020
|
var MAX_OUTPUT_BYTES = 10 * 1024 * 1024;
|
|
24921
25021
|
var KILL_GRACE_MS = 2000;
|
|
24922
|
-
var
|
|
25022
|
+
var _internals37 = {
|
|
24923
25023
|
isSemgrepAvailable,
|
|
24924
25024
|
checkSemgrepAvailable,
|
|
24925
25025
|
resetSemgrepCache,
|
|
@@ -24945,7 +25045,7 @@ function isSemgrepAvailable() {
|
|
|
24945
25045
|
}
|
|
24946
25046
|
}
|
|
24947
25047
|
async function checkSemgrepAvailable() {
|
|
24948
|
-
return
|
|
25048
|
+
return _internals37.isSemgrepAvailable();
|
|
24949
25049
|
}
|
|
24950
25050
|
function resetSemgrepCache() {
|
|
24951
25051
|
semgrepAvailableCache = null;
|
|
@@ -25132,12 +25232,12 @@ async function runSemgrep(options) {
|
|
|
25132
25232
|
const timeoutMs = options.timeoutMs || DEFAULT_TIMEOUT_MS;
|
|
25133
25233
|
if (files.length === 0) {
|
|
25134
25234
|
return {
|
|
25135
|
-
available:
|
|
25235
|
+
available: _internals37.isSemgrepAvailable(),
|
|
25136
25236
|
findings: [],
|
|
25137
25237
|
engine: "tier_a"
|
|
25138
25238
|
};
|
|
25139
25239
|
}
|
|
25140
|
-
if (!
|
|
25240
|
+
if (!_internals37.isSemgrepAvailable()) {
|
|
25141
25241
|
return {
|
|
25142
25242
|
available: false,
|
|
25143
25243
|
findings: [],
|
|
@@ -25299,7 +25399,7 @@ function assignOccurrenceIndices(findings, directory) {
|
|
|
25299
25399
|
}
|
|
25300
25400
|
const occIdx = countMap.get(baseKey) ?? 0;
|
|
25301
25401
|
countMap.set(baseKey, occIdx + 1);
|
|
25302
|
-
const fp =
|
|
25402
|
+
const fp = _internals38.fingerprintFinding(finding, directory, occIdx);
|
|
25303
25403
|
return {
|
|
25304
25404
|
finding,
|
|
25305
25405
|
index: occIdx,
|
|
@@ -25368,7 +25468,7 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
25368
25468
|
}
|
|
25369
25469
|
} catch {}
|
|
25370
25470
|
const scannedRelFiles = new Set(scannedFiles.map((f) => normalizeFindingPath(directory, f)));
|
|
25371
|
-
const indexed =
|
|
25471
|
+
const indexed = _internals38.assignOccurrenceIndices(findings, directory);
|
|
25372
25472
|
if (existing && !opts?.force) {
|
|
25373
25473
|
const prunedFingerprints = existing.fingerprints.filter((fp) => {
|
|
25374
25474
|
const relFile = fp.slice(0, fp.indexOf("|"));
|
|
@@ -25508,7 +25608,7 @@ function loadBaseline(directory, phase) {
|
|
|
25508
25608
|
};
|
|
25509
25609
|
}
|
|
25510
25610
|
}
|
|
25511
|
-
var
|
|
25611
|
+
var _internals38 = {
|
|
25512
25612
|
fingerprintFinding,
|
|
25513
25613
|
assignOccurrenceIndices,
|
|
25514
25614
|
captureOrMergeBaseline,
|
|
@@ -25622,7 +25722,7 @@ async function sastScan(input, directory, config) {
|
|
|
25622
25722
|
let filesScanned = 0;
|
|
25623
25723
|
let _filesSkipped = 0;
|
|
25624
25724
|
const scannedFilePaths = [];
|
|
25625
|
-
const semgrepAvailable = !offline_only &&
|
|
25725
|
+
const semgrepAvailable = !offline_only && _internals39.isSemgrepAvailable();
|
|
25626
25726
|
const engine = semgrepAvailable ? "tier_a+tier_b" : "tier_a";
|
|
25627
25727
|
const filesByLanguage = new Map;
|
|
25628
25728
|
for (const filePath of changed_files) {
|
|
@@ -25685,13 +25785,13 @@ async function sastScan(input, directory, config) {
|
|
|
25685
25785
|
let semgrepResult;
|
|
25686
25786
|
if (bucketKey.startsWith("auto:")) {
|
|
25687
25787
|
const lang = bucketKey.slice("auto:".length);
|
|
25688
|
-
semgrepResult = await
|
|
25788
|
+
semgrepResult = await _internals39.runSemgrep({
|
|
25689
25789
|
files: bucketFiles,
|
|
25690
25790
|
lang,
|
|
25691
25791
|
useAutoConfig: true
|
|
25692
25792
|
});
|
|
25693
25793
|
} else {
|
|
25694
|
-
semgrepResult = await
|
|
25794
|
+
semgrepResult = await _internals39.runSemgrep({
|
|
25695
25795
|
files: bucketFiles
|
|
25696
25796
|
});
|
|
25697
25797
|
}
|
|
@@ -25933,11 +26033,11 @@ var sast_scan = createSwarmTool({
|
|
|
25933
26033
|
capture_baseline: safeArgs.capture_baseline,
|
|
25934
26034
|
phase: safeArgs.phase
|
|
25935
26035
|
};
|
|
25936
|
-
const result = await
|
|
26036
|
+
const result = await _internals39.sastScan(input, directory);
|
|
25937
26037
|
return JSON.stringify(result, null, 2);
|
|
25938
26038
|
}
|
|
25939
26039
|
});
|
|
25940
|
-
var
|
|
26040
|
+
var _internals39 = {
|
|
25941
26041
|
sastScan,
|
|
25942
26042
|
sast_scan,
|
|
25943
26043
|
isSemgrepAvailable: () => isSemgrepAvailable(),
|
|
@@ -25969,10 +26069,10 @@ class DisposableWorktreeCleanupError extends Error {
|
|
|
25969
26069
|
}
|
|
25970
26070
|
}
|
|
25971
26071
|
async function git(projectRoot, args, abortSignal) {
|
|
25972
|
-
const executable =
|
|
26072
|
+
const executable = _internals40.resolveExecutableFromPath(["git"]);
|
|
25973
26073
|
if (!executable)
|
|
25974
26074
|
throw new Error("git executable not found");
|
|
25975
|
-
const result = await
|
|
26075
|
+
const result = await _internals40.runExternalTool({
|
|
25976
26076
|
executable,
|
|
25977
26077
|
args: ["-C", projectRoot, ...args],
|
|
25978
26078
|
cwd: projectRoot,
|
|
@@ -26008,7 +26108,7 @@ async function createDisposableWorktree(projectRoot, baseRef, abortSignal) {
|
|
|
26008
26108
|
if (!/^[A-Fa-f0-9]{40,64}$/.test(baseRef)) {
|
|
26009
26109
|
throw new Error("Evaluation baseRef must be a full commit hash");
|
|
26010
26110
|
}
|
|
26011
|
-
const parent = path49.join(
|
|
26111
|
+
const parent = path49.join(_internals40.tmpdir(), WORKTREE_PARENT);
|
|
26012
26112
|
fs22.mkdirSync(parent, { recursive: true });
|
|
26013
26113
|
const canonicalParent = fs22.realpathSync(parent);
|
|
26014
26114
|
const worktreePath = path49.join(canonicalParent, crypto4.randomUUID());
|
|
@@ -26017,7 +26117,7 @@ async function createDisposableWorktree(projectRoot, baseRef, abortSignal) {
|
|
|
26017
26117
|
}
|
|
26018
26118
|
async function removeDisposableWorktree(projectRoot, worktreePath) {
|
|
26019
26119
|
const canonicalRoot = fs22.realpathSync(projectRoot);
|
|
26020
|
-
const expectedParent = fs22.realpathSync(path49.join(
|
|
26120
|
+
const expectedParent = fs22.realpathSync(path49.join(_internals40.tmpdir(), WORKTREE_PARENT));
|
|
26021
26121
|
const resolved = path49.resolve(worktreePath);
|
|
26022
26122
|
const relative7 = path49.relative(expectedParent, resolved);
|
|
26023
26123
|
if (!relative7 || relative7 === ".." || relative7.startsWith(`..${path49.sep}`) || path49.isAbsolute(relative7)) {
|
|
@@ -26030,7 +26130,7 @@ async function removeDisposableWorktree(projectRoot, worktreePath) {
|
|
|
26030
26130
|
cleanupErrors.push(`git-remove: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
26031
26131
|
}
|
|
26032
26132
|
try {
|
|
26033
|
-
|
|
26133
|
+
_internals40.rmSync(resolved, { recursive: true, force: true });
|
|
26034
26134
|
} catch (error2) {
|
|
26035
26135
|
cleanupErrors.push(`filesystem-remove: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
26036
26136
|
}
|
|
@@ -26039,7 +26139,7 @@ async function removeDisposableWorktree(projectRoot, worktreePath) {
|
|
|
26039
26139
|
} catch (error2) {
|
|
26040
26140
|
cleanupErrors.push(`git-prune: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
26041
26141
|
}
|
|
26042
|
-
const pathPresent =
|
|
26142
|
+
const pathPresent = _internals40.existsSync(resolved);
|
|
26043
26143
|
let registrationPresent;
|
|
26044
26144
|
try {
|
|
26045
26145
|
const listed = await git(canonicalRoot, [
|
|
@@ -26061,7 +26161,7 @@ function normalizeWorktreePath(value) {
|
|
|
26061
26161
|
const resolved = path49.resolve(value);
|
|
26062
26162
|
return process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
26063
26163
|
}
|
|
26064
|
-
var
|
|
26164
|
+
var _internals40 = {
|
|
26065
26165
|
runExternalTool,
|
|
26066
26166
|
resolveExecutableFromPath,
|
|
26067
26167
|
tmpdir: os7.tmpdir,
|
|
@@ -26895,7 +26995,7 @@ function extractCurrentPhaseFromPlan(plan) {
|
|
|
26895
26995
|
if (!plan) {
|
|
26896
26996
|
return { currentPhase: null, currentTask: null, incompleteTasks: [] };
|
|
26897
26997
|
}
|
|
26898
|
-
if (!
|
|
26998
|
+
if (!_internals41.validatePlanPhases(plan)) {
|
|
26899
26999
|
return { currentPhase: null, currentTask: null, incompleteTasks: [] };
|
|
26900
27000
|
}
|
|
26901
27001
|
let currentPhase = null;
|
|
@@ -27037,9 +27137,9 @@ function extractPhaseMetrics(content) {
|
|
|
27037
27137
|
async function getHandoffData(directory) {
|
|
27038
27138
|
const now = new Date().toISOString();
|
|
27039
27139
|
const sessionContent = await readSwarmFileAsync(directory, "session/state.json");
|
|
27040
|
-
const sessionState =
|
|
27140
|
+
const sessionState = _internals41.parseSessionState(sessionContent);
|
|
27041
27141
|
const plan = await loadPlanJsonOnly(directory);
|
|
27042
|
-
const planInfo =
|
|
27142
|
+
const planInfo = _internals41.extractCurrentPhaseFromPlan(plan);
|
|
27043
27143
|
if (!plan) {
|
|
27044
27144
|
const planMdContent = await readSwarmFileAsync(directory, "plan.md");
|
|
27045
27145
|
if (planMdContent) {
|
|
@@ -27058,8 +27158,8 @@ async function getHandoffData(directory) {
|
|
|
27058
27158
|
}
|
|
27059
27159
|
}
|
|
27060
27160
|
const contextContent = await readSwarmFileAsync(directory, "context.md");
|
|
27061
|
-
const recentDecisions =
|
|
27062
|
-
const rawPhaseMetrics =
|
|
27161
|
+
const recentDecisions = _internals41.extractDecisions(contextContent);
|
|
27162
|
+
const rawPhaseMetrics = _internals41.extractPhaseMetrics(contextContent);
|
|
27063
27163
|
const phaseMetrics = sanitizeString(rawPhaseMetrics, 1000);
|
|
27064
27164
|
let delegationState = null;
|
|
27065
27165
|
if (sessionState?.delegationState) {
|
|
@@ -27223,7 +27323,7 @@ ${lines.join(`
|
|
|
27223
27323
|
`)}
|
|
27224
27324
|
\`\`\``;
|
|
27225
27325
|
}
|
|
27226
|
-
var
|
|
27326
|
+
var _internals41 = {
|
|
27227
27327
|
getHandoffData,
|
|
27228
27328
|
formatHandoffMarkdown,
|
|
27229
27329
|
formatContinuationPrompt,
|
|
@@ -27372,15 +27472,15 @@ async function writeSnapshot(directory, state) {
|
|
|
27372
27472
|
}
|
|
27373
27473
|
function createSnapshotWriterHook(directory) {
|
|
27374
27474
|
return (_input, _output) => {
|
|
27375
|
-
_writeInFlight = _writeInFlight.then(() =>
|
|
27475
|
+
_writeInFlight = _writeInFlight.then(() => _internals42.writeSnapshot(directory, swarmState), () => _internals42.writeSnapshot(directory, swarmState));
|
|
27376
27476
|
return _writeInFlight;
|
|
27377
27477
|
};
|
|
27378
27478
|
}
|
|
27379
27479
|
async function flushPendingSnapshot(directory) {
|
|
27380
|
-
_writeInFlight = _writeInFlight.then(() =>
|
|
27480
|
+
_writeInFlight = _writeInFlight.then(() => _internals42.writeSnapshot(directory, swarmState), () => _internals42.writeSnapshot(directory, swarmState));
|
|
27381
27481
|
await _writeInFlight;
|
|
27382
27482
|
}
|
|
27383
|
-
var
|
|
27483
|
+
var _internals42 = {
|
|
27384
27484
|
writeSnapshot,
|
|
27385
27485
|
createSnapshotWriterHook,
|
|
27386
27486
|
flushPendingSnapshot
|
|
@@ -27665,7 +27765,7 @@ function parseIssueRef(input, directory) {
|
|
|
27665
27765
|
}
|
|
27666
27766
|
return null;
|
|
27667
27767
|
}
|
|
27668
|
-
var
|
|
27768
|
+
var _internals43 = {
|
|
27669
27769
|
writeFileSync: fs24.writeFileSync,
|
|
27670
27770
|
mkdirSync: fs24.mkdirSync,
|
|
27671
27771
|
renameSync: fs24.renameSync,
|
|
@@ -27676,18 +27776,18 @@ var _internals42 = {
|
|
|
27676
27776
|
function atomicWriteFileSync(dir, filename, content) {
|
|
27677
27777
|
const tmpPath = path53.join(dir, `.tmp-${filename}-${Date.now()}-${process.pid}`);
|
|
27678
27778
|
const finalPath = path53.join(dir, filename);
|
|
27679
|
-
|
|
27779
|
+
_internals43.writeFileSync(tmpPath, content, "utf-8");
|
|
27680
27780
|
try {
|
|
27681
|
-
|
|
27781
|
+
_internals43.renameSync(tmpPath, finalPath);
|
|
27682
27782
|
} catch {
|
|
27683
27783
|
try {
|
|
27684
|
-
|
|
27784
|
+
_internals43.unlinkSync(finalPath);
|
|
27685
27785
|
} catch {}
|
|
27686
27786
|
try {
|
|
27687
|
-
|
|
27787
|
+
_internals43.renameSync(tmpPath, finalPath);
|
|
27688
27788
|
} catch (retryErr) {
|
|
27689
27789
|
try {
|
|
27690
|
-
|
|
27790
|
+
_internals43.unlinkSync(tmpPath);
|
|
27691
27791
|
} catch {}
|
|
27692
27792
|
throw retryErr;
|
|
27693
27793
|
}
|
|
@@ -27740,10 +27840,10 @@ ${USAGE7}`;
|
|
|
27740
27840
|
};
|
|
27741
27841
|
let oldTraceState = null;
|
|
27742
27842
|
try {
|
|
27743
|
-
oldTraceState =
|
|
27843
|
+
oldTraceState = _internals43.readFileSync(path53.join(swarmDir, "issue-trace-state.json"), "utf-8");
|
|
27744
27844
|
} catch {}
|
|
27745
27845
|
try {
|
|
27746
|
-
|
|
27846
|
+
_internals43.mkdirSync(swarmDir, { recursive: true });
|
|
27747
27847
|
atomicWriteFileSync(swarmDir, "issue-trace-state.json", JSON.stringify(traceState, null, 2));
|
|
27748
27848
|
atomicWriteFileSync(swarmDir, "issue-reference.json", JSON.stringify(issueReference, null, 2));
|
|
27749
27849
|
} catch (e) {
|
|
@@ -27753,11 +27853,11 @@ ${USAGE7}`;
|
|
|
27753
27853
|
} catch {}
|
|
27754
27854
|
} else {
|
|
27755
27855
|
try {
|
|
27756
|
-
|
|
27856
|
+
_internals43.unlinkSync(path53.join(swarmDir, "issue-trace-state.json"));
|
|
27757
27857
|
} catch {}
|
|
27758
27858
|
}
|
|
27759
27859
|
try {
|
|
27760
|
-
|
|
27860
|
+
_internals43.unlinkSync(path53.join(swarmDir, "issue-reference.json"));
|
|
27761
27861
|
} catch {}
|
|
27762
27862
|
const errMsg = e instanceof Error ? e.message : String(e);
|
|
27763
27863
|
return `Error: Failed to persist issue reference durably: ${errMsg}
|
|
@@ -27788,7 +27888,7 @@ import * as path54 from "path";
|
|
|
27788
27888
|
async function migrateKnowledgeToExternal(_directory, _config) {
|
|
27789
27889
|
const externalSentinelPath = path54.join(_directory, ".swarm", ".knowledge-external-migrated");
|
|
27790
27890
|
const contextPath = path54.join(_directory, ".swarm", "context.md");
|
|
27791
|
-
if (
|
|
27891
|
+
if (_internals44.existsSync(externalSentinelPath)) {
|
|
27792
27892
|
return {
|
|
27793
27893
|
migrated: false,
|
|
27794
27894
|
entriesMigrated: 0,
|
|
@@ -27797,7 +27897,7 @@ async function migrateKnowledgeToExternal(_directory, _config) {
|
|
|
27797
27897
|
skippedReason: "external-sentinel-exists"
|
|
27798
27898
|
};
|
|
27799
27899
|
}
|
|
27800
|
-
if (!
|
|
27900
|
+
if (!_internals44.existsSync(contextPath)) {
|
|
27801
27901
|
return {
|
|
27802
27902
|
migrated: false,
|
|
27803
27903
|
entriesMigrated: 0,
|
|
@@ -27806,7 +27906,7 @@ async function migrateKnowledgeToExternal(_directory, _config) {
|
|
|
27806
27906
|
skippedReason: "no-context-file"
|
|
27807
27907
|
};
|
|
27808
27908
|
}
|
|
27809
|
-
const contextContent = await
|
|
27909
|
+
const contextContent = await _internals44.readFile(contextPath, "utf-8");
|
|
27810
27910
|
if (contextContent.trim().length === 0) {
|
|
27811
27911
|
return {
|
|
27812
27912
|
migrated: false,
|
|
@@ -27824,7 +27924,7 @@ async function migrateKnowledgeToExternal(_directory, _config) {
|
|
|
27824
27924
|
entriesCount++;
|
|
27825
27925
|
}
|
|
27826
27926
|
}
|
|
27827
|
-
await
|
|
27927
|
+
await _internals44.writeSentinel(externalSentinelPath, entriesCount, entriesCount);
|
|
27828
27928
|
return {
|
|
27829
27929
|
migrated: true,
|
|
27830
27930
|
entriesMigrated: entriesCount,
|
|
@@ -27832,7 +27932,7 @@ async function migrateKnowledgeToExternal(_directory, _config) {
|
|
|
27832
27932
|
entriesTotal: entriesCount
|
|
27833
27933
|
};
|
|
27834
27934
|
}
|
|
27835
|
-
var
|
|
27935
|
+
var _internals44 = {
|
|
27836
27936
|
appendKnowledge,
|
|
27837
27937
|
migrateContextToKnowledge,
|
|
27838
27938
|
migrateKnowledgeToExternal,
|
|
@@ -27883,9 +27983,9 @@ async function migrateContextToKnowledge(directory, config) {
|
|
|
27883
27983
|
skippedReason: "empty-context"
|
|
27884
27984
|
};
|
|
27885
27985
|
}
|
|
27886
|
-
const rawEntries =
|
|
27986
|
+
const rawEntries = _internals44.parseContextMd(contextContent);
|
|
27887
27987
|
if (rawEntries.length === 0) {
|
|
27888
|
-
await
|
|
27988
|
+
await _internals44.writeSentinel(sentinelPath, 0, 0);
|
|
27889
27989
|
return {
|
|
27890
27990
|
migrated: true,
|
|
27891
27991
|
entriesMigrated: 0,
|
|
@@ -27896,10 +27996,10 @@ async function migrateContextToKnowledge(directory, config) {
|
|
|
27896
27996
|
const existing = await readKnowledge(knowledgePath);
|
|
27897
27997
|
let migrated = 0;
|
|
27898
27998
|
let dropped = 0;
|
|
27899
|
-
const projectName =
|
|
27999
|
+
const projectName = _internals44.inferProjectName(directory);
|
|
27900
28000
|
for (const raw of rawEntries) {
|
|
27901
28001
|
if (config.validation_enabled !== false) {
|
|
27902
|
-
const category = raw.categoryHint ??
|
|
28002
|
+
const category = raw.categoryHint ?? _internals44.inferCategoryFromText(raw.text);
|
|
27903
28003
|
const result = validateLesson(raw.text, existing.map((e) => e.lesson), {
|
|
27904
28004
|
category,
|
|
27905
28005
|
scope: "global",
|
|
@@ -27919,8 +28019,8 @@ async function migrateContextToKnowledge(directory, config) {
|
|
|
27919
28019
|
const entry = {
|
|
27920
28020
|
id: randomUUID7(),
|
|
27921
28021
|
tier: "swarm",
|
|
27922
|
-
lesson:
|
|
27923
|
-
category: raw.categoryHint ??
|
|
28022
|
+
lesson: _internals44.truncateLesson(raw.text),
|
|
28023
|
+
category: raw.categoryHint ?? _internals44.inferCategoryFromText(raw.text),
|
|
27924
28024
|
tags: [...inferredTags, `migration:${raw.sourceSection}`],
|
|
27925
28025
|
scope: "global",
|
|
27926
28026
|
confidence: 0.3,
|
|
@@ -27943,7 +28043,7 @@ async function migrateContextToKnowledge(directory, config) {
|
|
|
27943
28043
|
if (migrated > 0) {
|
|
27944
28044
|
await rewriteKnowledge(knowledgePath, existing);
|
|
27945
28045
|
}
|
|
27946
|
-
await
|
|
28046
|
+
await _internals44.writeSentinel(sentinelPath, migrated, dropped);
|
|
27947
28047
|
log(`[knowledge-migrator] Migrated ${migrated} entries, dropped ${dropped}`);
|
|
27948
28048
|
return {
|
|
27949
28049
|
migrated: true,
|
|
@@ -27953,7 +28053,7 @@ async function migrateContextToKnowledge(directory, config) {
|
|
|
27953
28053
|
};
|
|
27954
28054
|
}
|
|
27955
28055
|
async function migrateHiveKnowledgeLegacy(config) {
|
|
27956
|
-
const legacyHivePath =
|
|
28056
|
+
const legacyHivePath = _internals44.resolveLegacyHiveKnowledgePath();
|
|
27957
28057
|
const canonicalHivePath = resolveHiveKnowledgePath2();
|
|
27958
28058
|
const sentinelPath = path54.join(path54.dirname(canonicalHivePath), ".hive-knowledge-migrated");
|
|
27959
28059
|
if (existsSync32(sentinelPath)) {
|
|
@@ -27976,7 +28076,7 @@ async function migrateHiveKnowledgeLegacy(config) {
|
|
|
27976
28076
|
}
|
|
27977
28077
|
const legacyEntries = await readKnowledge(legacyHivePath);
|
|
27978
28078
|
if (legacyEntries.length === 0) {
|
|
27979
|
-
await
|
|
28079
|
+
await _internals44.writeSentinel(sentinelPath, 0, 0);
|
|
27980
28080
|
return {
|
|
27981
28081
|
migrated: true,
|
|
27982
28082
|
entriesMigrated: 0,
|
|
@@ -28024,7 +28124,7 @@ async function migrateHiveKnowledgeLegacy(config) {
|
|
|
28024
28124
|
const newHiveEntry = {
|
|
28025
28125
|
id: resolvedId,
|
|
28026
28126
|
tier: "hive",
|
|
28027
|
-
lesson:
|
|
28127
|
+
lesson: _internals44.truncateLesson(lesson),
|
|
28028
28128
|
category,
|
|
28029
28129
|
tags: ["migration:legacy-hive"],
|
|
28030
28130
|
scope: scopeTag,
|
|
@@ -28043,7 +28143,7 @@ async function migrateHiveKnowledgeLegacy(config) {
|
|
|
28043
28143
|
encounter_score: 1
|
|
28044
28144
|
};
|
|
28045
28145
|
try {
|
|
28046
|
-
await
|
|
28146
|
+
await _internals44.appendKnowledge(canonicalHivePath, newHiveEntry);
|
|
28047
28147
|
existingHiveEntries.push(newHiveEntry);
|
|
28048
28148
|
migrated++;
|
|
28049
28149
|
} catch (appendError) {
|
|
@@ -28059,7 +28159,7 @@ async function migrateHiveKnowledgeLegacy(config) {
|
|
|
28059
28159
|
dropped++;
|
|
28060
28160
|
}
|
|
28061
28161
|
}
|
|
28062
|
-
await
|
|
28162
|
+
await _internals44.writeSentinel(sentinelPath, migrated, dropped);
|
|
28063
28163
|
log(`[knowledge-migrator] Migrated ${migrated} legacy hive entries, dropped ${dropped}`);
|
|
28064
28164
|
return {
|
|
28065
28165
|
migrated: true,
|
|
@@ -28070,7 +28170,7 @@ async function migrateHiveKnowledgeLegacy(config) {
|
|
|
28070
28170
|
};
|
|
28071
28171
|
}
|
|
28072
28172
|
function parseContextMd(content) {
|
|
28073
|
-
const sections =
|
|
28173
|
+
const sections = _internals44.splitIntoSections(content);
|
|
28074
28174
|
const entries = [];
|
|
28075
28175
|
const seen = new Set;
|
|
28076
28176
|
const sectionPatterns = [
|
|
@@ -28086,7 +28186,7 @@ function parseContextMd(content) {
|
|
|
28086
28186
|
const match = sectionPatterns.find((sp) => sp.pattern.test(section.heading));
|
|
28087
28187
|
if (!match)
|
|
28088
28188
|
continue;
|
|
28089
|
-
const bullets =
|
|
28189
|
+
const bullets = _internals44.extractBullets(section.body);
|
|
28090
28190
|
for (const bullet of bullets) {
|
|
28091
28191
|
if (bullet.length < 15)
|
|
28092
28192
|
continue;
|
|
@@ -28095,9 +28195,9 @@ function parseContextMd(content) {
|
|
|
28095
28195
|
continue;
|
|
28096
28196
|
seen.add(normalized);
|
|
28097
28197
|
entries.push({
|
|
28098
|
-
text:
|
|
28198
|
+
text: _internals44.truncateLesson(bullet),
|
|
28099
28199
|
sourceSection: match.sourceSection,
|
|
28100
|
-
categoryHint:
|
|
28200
|
+
categoryHint: _internals44.inferCategoryFromText(bullet)
|
|
28101
28201
|
});
|
|
28102
28202
|
}
|
|
28103
28203
|
}
|
|
@@ -28187,8 +28287,8 @@ async function writeSentinel(sentinelPath, migrated, dropped) {
|
|
|
28187
28287
|
schema_version: 1,
|
|
28188
28288
|
migration_tool: "knowledge-migrator.ts"
|
|
28189
28289
|
};
|
|
28190
|
-
await
|
|
28191
|
-
await
|
|
28290
|
+
await _internals44.mkdir(path54.dirname(sentinelPath), { recursive: true });
|
|
28291
|
+
await _internals44.writeFile(sentinelPath, JSON.stringify(sentinel, null, 2), "utf-8");
|
|
28192
28292
|
}
|
|
28193
28293
|
function resolveLegacyHiveKnowledgePath() {
|
|
28194
28294
|
const platform = process.platform;
|
|
@@ -28600,7 +28700,7 @@ function timeoutMessage(timeoutMs) {
|
|
|
28600
28700
|
async function computeWithTimeout(directory, currentPhase, timeoutMs) {
|
|
28601
28701
|
const controller = new AbortController;
|
|
28602
28702
|
let timeout;
|
|
28603
|
-
const metricsPromise =
|
|
28703
|
+
const metricsPromise = _internals45.computeLearningMetrics(directory, {
|
|
28604
28704
|
currentPhase,
|
|
28605
28705
|
signal: controller.signal
|
|
28606
28706
|
});
|
|
@@ -28657,7 +28757,7 @@ ${JSON.stringify({
|
|
|
28657
28757
|
return `Error computing learning metrics: ${message}. Run /swarm diagnose to check .swarm/ health.`;
|
|
28658
28758
|
}
|
|
28659
28759
|
}
|
|
28660
|
-
var
|
|
28760
|
+
var _internals45 = {
|
|
28661
28761
|
computeLearningMetrics
|
|
28662
28762
|
};
|
|
28663
28763
|
|
|
@@ -29279,7 +29379,7 @@ async function readLatestLoopState(directory) {
|
|
|
29279
29379
|
return null;
|
|
29280
29380
|
}
|
|
29281
29381
|
}
|
|
29282
|
-
var
|
|
29382
|
+
var _internals46 = {
|
|
29283
29383
|
readLatestLoopState
|
|
29284
29384
|
};
|
|
29285
29385
|
var USAGE8 = `Usage: /swarm loop <objective> [--max-cycles 1..5] [--autonomy checkpoint|auto] [--depth standard|exhaustive] [--resume]
|
|
@@ -29392,7 +29492,7 @@ ${USAGE8}`;
|
|
|
29392
29492
|
}
|
|
29393
29493
|
let autonomy = parsed.autonomy;
|
|
29394
29494
|
if (parsed.resume && !parsed.autonomyExplicit) {
|
|
29395
|
-
const state = await
|
|
29495
|
+
const state = await _internals46.readLatestLoopState(_directory);
|
|
29396
29496
|
if (state?.autonomy && AUTONOMY_LEVELS.has(state.autonomy)) {
|
|
29397
29497
|
autonomy = state.autonomy;
|
|
29398
29498
|
}
|
|
@@ -30328,15 +30428,15 @@ function truncate(value, maxLength) {
|
|
|
30328
30428
|
}
|
|
30329
30429
|
|
|
30330
30430
|
// src/services/plan-service.ts
|
|
30331
|
-
var
|
|
30431
|
+
var _internals47 = {
|
|
30332
30432
|
loadPlanJsonOnly,
|
|
30333
30433
|
derivePlanMarkdown,
|
|
30334
30434
|
readSwarmFileAsync
|
|
30335
30435
|
};
|
|
30336
30436
|
async function getPlanData(directory, phaseArg) {
|
|
30337
|
-
const plan = await
|
|
30437
|
+
const plan = await _internals47.loadPlanJsonOnly(directory);
|
|
30338
30438
|
if (plan) {
|
|
30339
|
-
const fullMarkdown =
|
|
30439
|
+
const fullMarkdown = _internals47.derivePlanMarkdown(plan);
|
|
30340
30440
|
if (phaseArg === undefined || phaseArg === null || phaseArg === "") {
|
|
30341
30441
|
return {
|
|
30342
30442
|
hasPlan: true,
|
|
@@ -30379,7 +30479,7 @@ async function getPlanData(directory, phaseArg) {
|
|
|
30379
30479
|
isLegacy: false
|
|
30380
30480
|
};
|
|
30381
30481
|
}
|
|
30382
|
-
const planContent = await
|
|
30482
|
+
const planContent = await _internals47.readSwarmFileAsync(directory, "plan.md");
|
|
30383
30483
|
if (!planContent) {
|
|
30384
30484
|
return {
|
|
30385
30485
|
hasPlan: false,
|
|
@@ -30476,7 +30576,7 @@ async function handlePlanCommand(directory, args) {
|
|
|
30476
30576
|
return formatPlanMarkdown(planData);
|
|
30477
30577
|
}
|
|
30478
30578
|
// src/commands/post-mortem.ts
|
|
30479
|
-
var
|
|
30579
|
+
var _internals48 = {
|
|
30480
30580
|
createCuratorLLMDelegate,
|
|
30481
30581
|
runCuratorPostMortem
|
|
30482
30582
|
};
|
|
@@ -30524,10 +30624,10 @@ async function handlePostMortemCommand(directory, args, options) {
|
|
|
30524
30624
|
};
|
|
30525
30625
|
if (options?.sessionID) {
|
|
30526
30626
|
try {
|
|
30527
|
-
pmOptions.llmDelegate =
|
|
30627
|
+
pmOptions.llmDelegate = _internals48.createCuratorLLMDelegate(directory, "postmortem", options.sessionID);
|
|
30528
30628
|
} catch {}
|
|
30529
30629
|
}
|
|
30530
|
-
const result = await
|
|
30630
|
+
const result = await _internals48.runCuratorPostMortem(directory, pmOptions);
|
|
30531
30631
|
const lines = [];
|
|
30532
30632
|
if (result.success) {
|
|
30533
30633
|
lines.push("## Post-Mortem Report Generated");
|
|
@@ -30684,7 +30784,7 @@ function formatMergeGroupStatus(status, conclusion, htmlUrl) {
|
|
|
30684
30784
|
}
|
|
30685
30785
|
return parts.join(" ");
|
|
30686
30786
|
}
|
|
30687
|
-
var
|
|
30787
|
+
var _internals49 = {
|
|
30688
30788
|
formatRelativeTime,
|
|
30689
30789
|
formatMergeGroupStatus,
|
|
30690
30790
|
listActive,
|
|
@@ -30692,7 +30792,7 @@ var _internals48 = {
|
|
|
30692
30792
|
parseMergeGroupRuns
|
|
30693
30793
|
};
|
|
30694
30794
|
async function handlePrMonitorStatusCommand(directory, _args, sessionID, source) {
|
|
30695
|
-
const allActive = await
|
|
30795
|
+
const allActive = await _internals49.listActive(directory);
|
|
30696
30796
|
const allSessions = source === "cli";
|
|
30697
30797
|
const subs = allSessions ? allActive : allActive.filter((record) => record.sessionID === sessionID);
|
|
30698
30798
|
if (subs.length === 0) {
|
|
@@ -30708,7 +30808,7 @@ async function handlePrMonitorStatusCommand(directory, _args, sessionID, source)
|
|
|
30708
30808
|
const index = i + 1;
|
|
30709
30809
|
lines.push(` ${index}. ${sub.repoFullName}#${sub.prNumber}`);
|
|
30710
30810
|
lines.push(` URL: ${sub.prUrl}`);
|
|
30711
|
-
const mergeGroupRuns = await
|
|
30811
|
+
const mergeGroupRuns = await _internals49.listMergeGroupRuns(directory, sub.repoFullName, sub.prNumber);
|
|
30712
30812
|
if (mergeGroupRuns.runs.length > 0) {
|
|
30713
30813
|
lines.push(" Merge-group runs:");
|
|
30714
30814
|
for (const run of mergeGroupRuns.runs) {
|
|
@@ -30848,7 +30948,7 @@ async function handlePrSubscribeCommand(directory, args, sessionID) {
|
|
|
30848
30948
|
const repoFullName = `${prInfo.owner}/${prInfo.repo}`;
|
|
30849
30949
|
const prUrl = `https://github.com/${prInfo.owner}/${prInfo.repo}/pull/${prInfo.number}`;
|
|
30850
30950
|
try {
|
|
30851
|
-
const config =
|
|
30951
|
+
const config = _internals50.loadPluginConfig(directory);
|
|
30852
30952
|
const prMonitorConfig = config.pr_monitor;
|
|
30853
30953
|
if (!prMonitorConfig?.enabled) {
|
|
30854
30954
|
return [
|
|
@@ -30858,7 +30958,7 @@ async function handlePrSubscribeCommand(directory, args, sessionID) {
|
|
|
30858
30958
|
].join(`
|
|
30859
30959
|
`);
|
|
30860
30960
|
}
|
|
30861
|
-
await
|
|
30961
|
+
await _internals50.subscribe(directory, {
|
|
30862
30962
|
sessionID,
|
|
30863
30963
|
prNumber: prInfo.number,
|
|
30864
30964
|
repoFullName,
|
|
@@ -30886,7 +30986,7 @@ async function handlePrSubscribeCommand(directory, args, sessionID) {
|
|
|
30886
30986
|
`);
|
|
30887
30987
|
}
|
|
30888
30988
|
}
|
|
30889
|
-
var
|
|
30989
|
+
var _internals50 = {
|
|
30890
30990
|
loadPluginConfig,
|
|
30891
30991
|
subscribe
|
|
30892
30992
|
};
|
|
@@ -30909,9 +31009,9 @@ async function handlePrUnsubscribeCommand(directory, args, sessionID) {
|
|
|
30909
31009
|
`);
|
|
30910
31010
|
}
|
|
30911
31011
|
const refToken = rest[0];
|
|
30912
|
-
const prInfo =
|
|
31012
|
+
const prInfo = _internals51.parsePrRef(refToken, directory);
|
|
30913
31013
|
if (!prInfo) {
|
|
30914
|
-
if (
|
|
31014
|
+
if (_internals51.looksLikePrRef(refToken)) {
|
|
30915
31015
|
return [
|
|
30916
31016
|
`Error: Could not resolve PR reference from "${refToken}".`,
|
|
30917
31017
|
"",
|
|
@@ -30932,8 +31032,8 @@ async function handlePrUnsubscribeCommand(directory, args, sessionID) {
|
|
|
30932
31032
|
const repoFullName = `${prInfo.owner}/${prInfo.repo}`;
|
|
30933
31033
|
const prUrl = `https://github.com/${prInfo.owner}/${prInfo.repo}/pull/${prInfo.number}`;
|
|
30934
31034
|
try {
|
|
30935
|
-
const correlationId =
|
|
30936
|
-
const result = await
|
|
31035
|
+
const correlationId = _internals51.buildCorrelationId(sessionID, repoFullName, prInfo.number);
|
|
31036
|
+
const result = await _internals51.unsubscribe(directory, correlationId);
|
|
30937
31037
|
if (!result) {
|
|
30938
31038
|
return [
|
|
30939
31039
|
`Not subscribed to ${prUrl}`,
|
|
@@ -30960,7 +31060,7 @@ async function handlePrUnsubscribeCommand(directory, args, sessionID) {
|
|
|
30960
31060
|
`);
|
|
30961
31061
|
}
|
|
30962
31062
|
}
|
|
30963
|
-
var
|
|
31063
|
+
var _internals51 = {
|
|
30964
31064
|
unsubscribe,
|
|
30965
31065
|
buildCorrelationId,
|
|
30966
31066
|
parsePrRef,
|
|
@@ -31442,15 +31542,15 @@ var lint = createSwarmTool({
|
|
|
31442
31542
|
}
|
|
31443
31543
|
const { mode } = args;
|
|
31444
31544
|
const cwd = directory;
|
|
31445
|
-
const linter = await
|
|
31545
|
+
const linter = await _internals52.detectAvailableLinter(directory);
|
|
31446
31546
|
if (linter) {
|
|
31447
|
-
const result = await
|
|
31547
|
+
const result = await _internals52.runLint(linter, mode, directory);
|
|
31448
31548
|
return JSON.stringify(result, null, 2);
|
|
31449
31549
|
}
|
|
31450
|
-
const additionalLinter =
|
|
31550
|
+
const additionalLinter = _internals52.detectAdditionalLinter(cwd);
|
|
31451
31551
|
if (additionalLinter) {
|
|
31452
31552
|
warn(`[lint] Using ${additionalLinter} linter for this project`);
|
|
31453
|
-
const result = await
|
|
31553
|
+
const result = await _internals52.runAdditionalLint(additionalLinter, mode, cwd);
|
|
31454
31554
|
return JSON.stringify(result, null, 2);
|
|
31455
31555
|
}
|
|
31456
31556
|
const errorResult = {
|
|
@@ -31464,7 +31564,7 @@ For Rust: rustup component add clippy`
|
|
|
31464
31564
|
return JSON.stringify(errorResult, null, 2);
|
|
31465
31565
|
}
|
|
31466
31566
|
});
|
|
31467
|
-
var
|
|
31567
|
+
var _internals52 = {
|
|
31468
31568
|
detectAvailableLinter,
|
|
31469
31569
|
runLint,
|
|
31470
31570
|
detectAdditionalLinter,
|
|
@@ -32152,7 +32252,7 @@ var secretscan = createSwarmTool({
|
|
|
32152
32252
|
});
|
|
32153
32253
|
async function runSecretscan(directory) {
|
|
32154
32254
|
try {
|
|
32155
|
-
const result = await
|
|
32255
|
+
const result = await _internals53.secretscan.execute({ directory }, {});
|
|
32156
32256
|
const jsonStr = typeof result === "string" ? result : result.output;
|
|
32157
32257
|
return JSON.parse(jsonStr);
|
|
32158
32258
|
} catch (e) {
|
|
@@ -32224,7 +32324,7 @@ async function runSecretscanOnFiles(files, directory) {
|
|
|
32224
32324
|
};
|
|
32225
32325
|
}
|
|
32226
32326
|
}
|
|
32227
|
-
var
|
|
32327
|
+
var _internals53 = {
|
|
32228
32328
|
secretscan,
|
|
32229
32329
|
runSecretscan,
|
|
32230
32330
|
runSecretscanOnFiles,
|
|
@@ -32500,7 +32600,7 @@ async function buildImpactMapInternal(cwd) {
|
|
|
32500
32600
|
}
|
|
32501
32601
|
return impactMap;
|
|
32502
32602
|
}
|
|
32503
|
-
var
|
|
32603
|
+
var _internals54 = {
|
|
32504
32604
|
validateProjectRoot,
|
|
32505
32605
|
normalizePath: normalizePath2,
|
|
32506
32606
|
isCacheStale,
|
|
@@ -32515,8 +32615,8 @@ var _internals53 = {
|
|
|
32515
32615
|
_clearGoModuleCache
|
|
32516
32616
|
};
|
|
32517
32617
|
async function buildImpactMap(cwd) {
|
|
32518
|
-
const impactMap = await
|
|
32519
|
-
await
|
|
32618
|
+
const impactMap = await _internals54.buildImpactMapInternal(cwd);
|
|
32619
|
+
await _internals54.saveImpactMap(cwd, impactMap);
|
|
32520
32620
|
return impactMap;
|
|
32521
32621
|
}
|
|
32522
32622
|
async function loadImpactMap(cwd, options) {
|
|
@@ -32530,7 +32630,7 @@ async function loadImpactMap(cwd, options) {
|
|
|
32530
32630
|
const hasValidValues = Object.values(map).every((v) => Array.isArray(v) && v.every((item) => typeof item === "string"));
|
|
32531
32631
|
if (hasValidValues) {
|
|
32532
32632
|
const generatedAt = new Date(data.generatedAt).getTime();
|
|
32533
|
-
if (!
|
|
32633
|
+
if (!_internals54.isCacheStale(map, generatedAt)) {
|
|
32534
32634
|
return map;
|
|
32535
32635
|
}
|
|
32536
32636
|
if (options?.skipRebuild) {
|
|
@@ -32550,13 +32650,13 @@ async function loadImpactMap(cwd, options) {
|
|
|
32550
32650
|
if (options?.skipRebuild) {
|
|
32551
32651
|
return {};
|
|
32552
32652
|
}
|
|
32553
|
-
return
|
|
32653
|
+
return _internals54.buildImpactMap(cwd);
|
|
32554
32654
|
}
|
|
32555
32655
|
async function saveImpactMap(cwd, impactMap) {
|
|
32556
32656
|
if (!path62.isAbsolute(cwd)) {
|
|
32557
32657
|
throw new Error(`saveImpactMap requires an absolute project root path, got: "${cwd}"`);
|
|
32558
32658
|
}
|
|
32559
|
-
|
|
32659
|
+
_internals54.validateProjectRoot(cwd);
|
|
32560
32660
|
const cacheDir2 = path62.join(cwd, ".swarm", "cache");
|
|
32561
32661
|
const cachePath = path62.join(cacheDir2, "impact-map.json");
|
|
32562
32662
|
if (!fs28.existsSync(cacheDir2)) {
|
|
@@ -32580,7 +32680,7 @@ async function analyzeImpact(changedFiles, cwd, budget) {
|
|
|
32580
32680
|
};
|
|
32581
32681
|
}
|
|
32582
32682
|
const validFiles = changedFiles.filter((f) => typeof f === "string" && f.length > 0 && !f.includes("\x00"));
|
|
32583
|
-
const impactMap = await
|
|
32683
|
+
const impactMap = await _internals54.loadImpactMap(cwd);
|
|
32584
32684
|
const impactedTestsSet = new Set;
|
|
32585
32685
|
const untestedFiles = [];
|
|
32586
32686
|
let visitedCount = 0;
|
|
@@ -32857,7 +32957,7 @@ function batchAppendTestRuns(records, workingDir) {
|
|
|
32857
32957
|
}
|
|
32858
32958
|
const historyPath = getHistoryPath(workingDir);
|
|
32859
32959
|
const historyDir = path63.dirname(historyPath);
|
|
32860
|
-
|
|
32960
|
+
_internals55.validateProjectRoot(workingDir);
|
|
32861
32961
|
if (!fs29.existsSync(historyDir)) {
|
|
32862
32962
|
fs29.mkdirSync(historyDir, { recursive: true });
|
|
32863
32963
|
}
|
|
@@ -32980,7 +33080,7 @@ function getAllHistory(workingDir) {
|
|
|
32980
33080
|
records.sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
|
|
32981
33081
|
return records;
|
|
32982
33082
|
}
|
|
32983
|
-
var
|
|
33083
|
+
var _internals55 = {
|
|
32984
33084
|
validateProjectRoot
|
|
32985
33085
|
};
|
|
32986
33086
|
|
|
@@ -34957,9 +35057,9 @@ function getVersionFileVersion(dir) {
|
|
|
34957
35057
|
async function runVersionCheck(dir, _timeoutMs) {
|
|
34958
35058
|
const startTime = Date.now();
|
|
34959
35059
|
try {
|
|
34960
|
-
const packageVersion =
|
|
34961
|
-
const changelogVersion =
|
|
34962
|
-
const versionFileVersion =
|
|
35060
|
+
const packageVersion = _internals56.getPackageVersion(dir);
|
|
35061
|
+
const changelogVersion = _internals56.getChangelogVersion(dir);
|
|
35062
|
+
const versionFileVersion = _internals56.getVersionFileVersion(dir);
|
|
34963
35063
|
const versions = [];
|
|
34964
35064
|
if (packageVersion)
|
|
34965
35065
|
versions.push(`package.json: ${packageVersion}`);
|
|
@@ -35323,7 +35423,7 @@ async function runPreflight(dir, phase, config) {
|
|
|
35323
35423
|
const reportId = `preflight-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
35324
35424
|
let validatedDir;
|
|
35325
35425
|
try {
|
|
35326
|
-
validatedDir =
|
|
35426
|
+
validatedDir = _internals56.validateDirectoryPath(dir);
|
|
35327
35427
|
} catch (error2) {
|
|
35328
35428
|
return {
|
|
35329
35429
|
id: reportId,
|
|
@@ -35343,7 +35443,7 @@ async function runPreflight(dir, phase, config) {
|
|
|
35343
35443
|
}
|
|
35344
35444
|
let validatedTimeout;
|
|
35345
35445
|
try {
|
|
35346
|
-
validatedTimeout =
|
|
35446
|
+
validatedTimeout = _internals56.validateTimeout(config?.checkTimeoutMs, DEFAULT_CONFIG.checkTimeoutMs);
|
|
35347
35447
|
} catch (error2) {
|
|
35348
35448
|
return {
|
|
35349
35449
|
id: reportId,
|
|
@@ -35384,12 +35484,12 @@ async function runPreflight(dir, phase, config) {
|
|
|
35384
35484
|
});
|
|
35385
35485
|
const checks = [];
|
|
35386
35486
|
log("[Preflight] Running lint check...");
|
|
35387
|
-
const lintResult = await
|
|
35487
|
+
const lintResult = await _internals56.runLintCheck(validatedDir, cfg.linter, cfg.checkTimeoutMs);
|
|
35388
35488
|
checks.push(lintResult);
|
|
35389
35489
|
log(`[Preflight] Lint check: ${lintResult.status} ${lintResult.message}`);
|
|
35390
35490
|
if (!cfg.skipTests) {
|
|
35391
35491
|
log("[Preflight] Running tests check...");
|
|
35392
|
-
const testsResult = await
|
|
35492
|
+
const testsResult = await _internals56.runTestsCheck(validatedDir, cfg.testScope, cfg.checkTimeoutMs);
|
|
35393
35493
|
checks.push(testsResult);
|
|
35394
35494
|
log(`[Preflight] Tests check: ${testsResult.status} ${testsResult.message}`);
|
|
35395
35495
|
} else {
|
|
@@ -35401,7 +35501,7 @@ async function runPreflight(dir, phase, config) {
|
|
|
35401
35501
|
}
|
|
35402
35502
|
if (!cfg.skipSecrets) {
|
|
35403
35503
|
log("[Preflight] Running secrets check...");
|
|
35404
|
-
const secretsResult = await
|
|
35504
|
+
const secretsResult = await _internals56.runSecretsCheck(validatedDir, cfg.checkTimeoutMs);
|
|
35405
35505
|
checks.push(secretsResult);
|
|
35406
35506
|
log(`[Preflight] Secrets check: ${secretsResult.status} ${secretsResult.message}`);
|
|
35407
35507
|
} else {
|
|
@@ -35413,7 +35513,7 @@ async function runPreflight(dir, phase, config) {
|
|
|
35413
35513
|
}
|
|
35414
35514
|
if (!cfg.skipEvidence) {
|
|
35415
35515
|
log("[Preflight] Running evidence check...");
|
|
35416
|
-
const evidenceResult = await
|
|
35516
|
+
const evidenceResult = await _internals56.runEvidenceCheck(validatedDir);
|
|
35417
35517
|
checks.push(evidenceResult);
|
|
35418
35518
|
log(`[Preflight] Evidence check: ${evidenceResult.status} ${evidenceResult.message}`);
|
|
35419
35519
|
} else {
|
|
@@ -35424,12 +35524,12 @@ async function runPreflight(dir, phase, config) {
|
|
|
35424
35524
|
});
|
|
35425
35525
|
}
|
|
35426
35526
|
log("[Preflight] Running requirement coverage check...");
|
|
35427
|
-
const reqCoverageResult = await
|
|
35527
|
+
const reqCoverageResult = await _internals56.runRequirementCoverageCheck(validatedDir, phase);
|
|
35428
35528
|
checks.push(reqCoverageResult);
|
|
35429
35529
|
log(`[Preflight] Requirement coverage check: ${reqCoverageResult.status} ${reqCoverageResult.message}`);
|
|
35430
35530
|
if (!cfg.skipVersion) {
|
|
35431
35531
|
log("[Preflight] Running version check...");
|
|
35432
|
-
const versionResult = await
|
|
35532
|
+
const versionResult = await _internals56.runVersionCheck(validatedDir, cfg.checkTimeoutMs);
|
|
35433
35533
|
checks.push(versionResult);
|
|
35434
35534
|
log(`[Preflight] Version check: ${versionResult.status} ${versionResult.message}`);
|
|
35435
35535
|
} else {
|
|
@@ -35492,10 +35592,10 @@ function formatPreflightMarkdown(report) {
|
|
|
35492
35592
|
async function handlePreflightCommand(directory, _args) {
|
|
35493
35593
|
const plan = await loadPlan(directory);
|
|
35494
35594
|
const phase = plan?.current_phase ?? 1;
|
|
35495
|
-
const report = await
|
|
35496
|
-
return
|
|
35595
|
+
const report = await _internals56.runPreflight(directory, phase);
|
|
35596
|
+
return _internals56.formatPreflightMarkdown(report);
|
|
35497
35597
|
}
|
|
35498
|
-
var
|
|
35598
|
+
var _internals56 = {
|
|
35499
35599
|
runPreflight,
|
|
35500
35600
|
formatPreflightMarkdown,
|
|
35501
35601
|
handlePreflightCommand,
|
|
@@ -36466,7 +36566,7 @@ function pruneOldResetBackups(backupsRoot, warnings) {
|
|
|
36466
36566
|
}
|
|
36467
36567
|
|
|
36468
36568
|
// src/commands/reset.ts
|
|
36469
|
-
var
|
|
36569
|
+
var _internals57 = {
|
|
36470
36570
|
backupSwarmStateBeforeReset
|
|
36471
36571
|
};
|
|
36472
36572
|
async function handleResetCommand(directory, args) {
|
|
@@ -36500,7 +36600,7 @@ async function handleResetCommand(directory, args) {
|
|
|
36500
36600
|
];
|
|
36501
36601
|
const results = [];
|
|
36502
36602
|
try {
|
|
36503
|
-
const backup =
|
|
36603
|
+
const backup = _internals57.backupSwarmStateBeforeReset(directory, "reset", [
|
|
36504
36604
|
...filesToReset,
|
|
36505
36605
|
"summaries"
|
|
36506
36606
|
]);
|
|
@@ -37122,7 +37222,7 @@ async function recordReplayEntry(artifactPath, sessionID, entry) {
|
|
|
37122
37222
|
}
|
|
37123
37223
|
|
|
37124
37224
|
// src/prm/index.ts
|
|
37125
|
-
var
|
|
37225
|
+
var _internals58 = {
|
|
37126
37226
|
getAgentSession,
|
|
37127
37227
|
readTrajectory,
|
|
37128
37228
|
getInMemoryTrajectory,
|
|
@@ -37145,12 +37245,12 @@ function resetPrmSessionState(session, sessionId) {
|
|
|
37145
37245
|
session.prmTrajectoryStep = 0;
|
|
37146
37246
|
session.replayArtifactPath = null;
|
|
37147
37247
|
if (sessionId) {
|
|
37148
|
-
|
|
37248
|
+
_internals58.clearTrajectoryCache(sessionId);
|
|
37149
37249
|
}
|
|
37150
37250
|
}
|
|
37151
37251
|
|
|
37152
37252
|
// src/commands/reset-session.ts
|
|
37153
|
-
var
|
|
37253
|
+
var _internals59 = {
|
|
37154
37254
|
cleanupOrphanedBranches,
|
|
37155
37255
|
backupSwarmStateBeforeReset
|
|
37156
37256
|
};
|
|
@@ -37162,7 +37262,7 @@ function errorMessage(err) {
|
|
|
37162
37262
|
async function handleResetSessionCommand(directory, _args) {
|
|
37163
37263
|
const results = [];
|
|
37164
37264
|
try {
|
|
37165
|
-
const backup =
|
|
37265
|
+
const backup = _internals59.backupSwarmStateBeforeReset(directory, "reset-session", ["session"]);
|
|
37166
37266
|
if (backup.backupDir && backup.copied.length > 0) {
|
|
37167
37267
|
const rel = path71.relative(directory, backup.backupDir);
|
|
37168
37268
|
results.push(`\uD83D\uDCE6 Backed up session state to ${rel}/ (restore by copying files back into .swarm/session/)`);
|
|
@@ -37229,7 +37329,7 @@ async function handleResetSessionCommand(directory, _args) {
|
|
|
37229
37329
|
results.push(`\u26A0\uFE0F Failed to remove .swarm-worktrees/: ${errorMessage(err)}`);
|
|
37230
37330
|
}
|
|
37231
37331
|
try {
|
|
37232
|
-
const branchResult = await
|
|
37332
|
+
const branchResult = await _internals59.cleanupOrphanedBranches(directory, []);
|
|
37233
37333
|
if (branchResult.removed.length > 0) {
|
|
37234
37334
|
results.push(`\u2705 Removed ${branchResult.removed.length} orphan swarm-lane branch(es)`);
|
|
37235
37335
|
}
|
|
@@ -37567,7 +37667,7 @@ async function handleRollbackCommand(directory, args) {
|
|
|
37567
37667
|
// src/commands/sdd.ts
|
|
37568
37668
|
import * as fs39 from "fs";
|
|
37569
37669
|
import * as path74 from "path";
|
|
37570
|
-
var
|
|
37670
|
+
var _internals60 = {
|
|
37571
37671
|
writeProjectedSpecSync
|
|
37572
37672
|
};
|
|
37573
37673
|
var SWARM_SPEC_REL = path74.join(".swarm", "spec.md");
|
|
@@ -37963,7 +38063,7 @@ ${USAGE10}`;
|
|
|
37963
38063
|
|
|
37964
38064
|
${USAGE10}`;
|
|
37965
38065
|
}
|
|
37966
|
-
const result2 =
|
|
38066
|
+
const result2 = _internals60.writeProjectedSpecSync(directory, {
|
|
37967
38067
|
source: "speckit",
|
|
37968
38068
|
feature: resolution.feature,
|
|
37969
38069
|
dryRun: parsed.dryRun,
|
|
@@ -38021,7 +38121,7 @@ ${formatList(result2.projection.warnings)}` : ""
|
|
|
38021
38121
|
].join(`
|
|
38022
38122
|
`);
|
|
38023
38123
|
}
|
|
38024
|
-
const result =
|
|
38124
|
+
const result = _internals60.writeProjectedSpecSync(directory, {
|
|
38025
38125
|
changeId: parsed.changeId,
|
|
38026
38126
|
dryRun: parsed.dryRun,
|
|
38027
38127
|
overwrite: parsed.overwrite
|
|
@@ -38102,7 +38202,7 @@ async function handleSimulateCommand(directory, args) {
|
|
|
38102
38202
|
}
|
|
38103
38203
|
let darkMatterPairs;
|
|
38104
38204
|
try {
|
|
38105
|
-
darkMatterPairs = await
|
|
38205
|
+
darkMatterPairs = await _internals26.detectDarkMatter(directory, options);
|
|
38106
38206
|
} catch (err) {
|
|
38107
38207
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
38108
38208
|
return `## Simulate Report
|
|
@@ -38408,7 +38508,7 @@ var DEFAULT_CONTEXT_BUDGET_CONFIG = {
|
|
|
38408
38508
|
};
|
|
38409
38509
|
|
|
38410
38510
|
// src/services/status-service.ts
|
|
38411
|
-
var
|
|
38511
|
+
var _internals61 = {
|
|
38412
38512
|
loadLeanTurboRunState,
|
|
38413
38513
|
hasActiveLeanTurbo,
|
|
38414
38514
|
hasActiveFullAuto,
|
|
@@ -38529,11 +38629,11 @@ async function getStatusData(directory, agents) {
|
|
|
38529
38629
|
} catch {
|
|
38530
38630
|
status.cohort = { linked: false };
|
|
38531
38631
|
}
|
|
38532
|
-
status.fullAutoActive =
|
|
38632
|
+
status.fullAutoActive = _internals61.hasActiveFullAuto();
|
|
38533
38633
|
if (status.fullAutoActive) {
|
|
38534
|
-
const sid =
|
|
38634
|
+
const sid = _internals61.getActiveFullAutoSessionID();
|
|
38535
38635
|
if (sid) {
|
|
38536
|
-
const runState =
|
|
38636
|
+
const runState = _internals61.loadFullAutoRunState(directory, sid);
|
|
38537
38637
|
if (runState?.lastEscalation) {
|
|
38538
38638
|
status.fullAutoEscalation = {
|
|
38539
38639
|
reason: runState.lastEscalation.reason,
|
|
@@ -38548,7 +38648,7 @@ async function getStatusData(directory, agents) {
|
|
|
38548
38648
|
}
|
|
38549
38649
|
function enrichWithLeanTurbo(status, directory) {
|
|
38550
38650
|
const turboMode = hasActiveTurboMode();
|
|
38551
|
-
const leanActive =
|
|
38651
|
+
const leanActive = _internals61.hasActiveLeanTurbo();
|
|
38552
38652
|
let turboStrategy = "off";
|
|
38553
38653
|
if (leanActive) {
|
|
38554
38654
|
turboStrategy = "lean";
|
|
@@ -38567,7 +38667,7 @@ function enrichWithLeanTurbo(status, directory) {
|
|
|
38567
38667
|
}
|
|
38568
38668
|
}
|
|
38569
38669
|
if (leanSessionID) {
|
|
38570
|
-
const runState =
|
|
38670
|
+
const runState = _internals61.loadLeanTurboRunState(directory, leanSessionID);
|
|
38571
38671
|
if (runState) {
|
|
38572
38672
|
status.leanTurboPhase = runState.phase;
|
|
38573
38673
|
status.leanMaxParallelCoders = runState.maxParallelCoders;
|
|
@@ -38774,7 +38874,7 @@ No active swarm plan found. Nothing to sync.`;
|
|
|
38774
38874
|
|
|
38775
38875
|
// src/commands/turbo.ts
|
|
38776
38876
|
init_logger();
|
|
38777
|
-
var
|
|
38877
|
+
var _internals62 = {
|
|
38778
38878
|
loadPluginConfigWithMeta
|
|
38779
38879
|
};
|
|
38780
38880
|
async function handleTurboCommand(directory, args, sessionID) {
|
|
@@ -38834,7 +38934,7 @@ async function handleTurboCommand(directory, args, sessionID) {
|
|
|
38834
38934
|
if (arg0 === "on") {
|
|
38835
38935
|
let strategy = "standard";
|
|
38836
38936
|
try {
|
|
38837
|
-
const { config } =
|
|
38937
|
+
const { config } = _internals62.loadPluginConfigWithMeta(directory);
|
|
38838
38938
|
if (config.turbo?.strategy === "lean") {
|
|
38839
38939
|
strategy = "lean";
|
|
38840
38940
|
}
|
|
@@ -38931,7 +39031,7 @@ function enableLeanTurbo(session, directory, sessionID) {
|
|
|
38931
39031
|
let maxParallelCoders = 4;
|
|
38932
39032
|
let conflictPolicy = "serialize";
|
|
38933
39033
|
try {
|
|
38934
|
-
const { config } =
|
|
39034
|
+
const { config } = _internals62.loadPluginConfigWithMeta(directory);
|
|
38935
39035
|
const leanConfig = config.turbo?.lean;
|
|
38936
39036
|
if (leanConfig) {
|
|
38937
39037
|
maxParallelCoders = leanConfig.max_parallel_coders ?? 4;
|
|
@@ -39136,7 +39236,7 @@ function findSimilarCommands(query) {
|
|
|
39136
39236
|
}
|
|
39137
39237
|
const scored = VALID_COMMANDS.map((cmd) => {
|
|
39138
39238
|
const cmdLower = cmd.toLowerCase();
|
|
39139
|
-
const fullScore =
|
|
39239
|
+
const fullScore = _internals63.levenshteinDistance(q, cmdLower);
|
|
39140
39240
|
let tokenScore = Infinity;
|
|
39141
39241
|
if (cmd.includes(" ") || cmd.includes("-")) {
|
|
39142
39242
|
const qTokens = q.split(/[\s-]+/);
|
|
@@ -39149,7 +39249,7 @@ function findSimilarCommands(query) {
|
|
|
39149
39249
|
for (const ct of cmdTokens) {
|
|
39150
39250
|
if (ct.length === 0)
|
|
39151
39251
|
continue;
|
|
39152
|
-
const dist =
|
|
39252
|
+
const dist = _internals63.levenshteinDistance(qt, ct);
|
|
39153
39253
|
if (dist < minDist)
|
|
39154
39254
|
minDist = dist;
|
|
39155
39255
|
}
|
|
@@ -39159,7 +39259,7 @@ function findSimilarCommands(query) {
|
|
|
39159
39259
|
}
|
|
39160
39260
|
const dashStrippedQ = q.replace(/-/g, "");
|
|
39161
39261
|
const dashStrippedCmd = cmdLower.replace(/-/g, "");
|
|
39162
|
-
const dashScore =
|
|
39262
|
+
const dashScore = _internals63.levenshteinDistance(dashStrippedQ, dashStrippedCmd);
|
|
39163
39263
|
const score = Math.min(fullScore, tokenScore, dashScore);
|
|
39164
39264
|
return { cmd, score };
|
|
39165
39265
|
});
|
|
@@ -39194,16 +39294,16 @@ function buildDetailedHelp(commandName, entry) {
|
|
|
39194
39294
|
async function handleHelpCommand(ctx) {
|
|
39195
39295
|
const targetCommand = ctx.args.join(" ");
|
|
39196
39296
|
if (!targetCommand) {
|
|
39197
|
-
const { buildHelpText } = await import("./index-
|
|
39297
|
+
const { buildHelpText } = await import("./index-2k6z335c.js");
|
|
39198
39298
|
return buildHelpText();
|
|
39199
39299
|
}
|
|
39200
39300
|
const tokens = targetCommand.split(/\s+/);
|
|
39201
|
-
const resolved =
|
|
39301
|
+
const resolved = _internals63.resolveCommand(tokens);
|
|
39202
39302
|
if (resolved) {
|
|
39203
|
-
return
|
|
39303
|
+
return _internals63.buildDetailedHelp(resolved.key, resolved.entry);
|
|
39204
39304
|
}
|
|
39205
|
-
const similar =
|
|
39206
|
-
const { buildHelpText: fullHelp } = await import("./index-
|
|
39305
|
+
const similar = _internals63.findSimilarCommands(targetCommand);
|
|
39306
|
+
const { buildHelpText: fullHelp } = await import("./index-2k6z335c.js");
|
|
39207
39307
|
if (similar.length > 0) {
|
|
39208
39308
|
return `Command '/swarm ${targetCommand}' not found.
|
|
39209
39309
|
|
|
@@ -39267,7 +39367,7 @@ var COMMAND_REGISTRY = {
|
|
|
39267
39367
|
toolNoArgs: true
|
|
39268
39368
|
},
|
|
39269
39369
|
help: {
|
|
39270
|
-
handler: (ctx) =>
|
|
39370
|
+
handler: (ctx) => _internals63.handleHelpCommand(ctx),
|
|
39271
39371
|
description: "Show help for swarm commands",
|
|
39272
39372
|
category: "core",
|
|
39273
39373
|
args: "[command]",
|
|
@@ -39336,7 +39436,7 @@ var COMMAND_REGISTRY = {
|
|
|
39336
39436
|
},
|
|
39337
39437
|
"guardrail explain": {
|
|
39338
39438
|
handler: async (ctx) => {
|
|
39339
|
-
const { handleGuardrailExplain } = await import("./guardrail-explain-
|
|
39439
|
+
const { handleGuardrailExplain } = await import("./guardrail-explain-d1m747g5.js");
|
|
39340
39440
|
return handleGuardrailExplain(ctx.directory, ctx.args);
|
|
39341
39441
|
},
|
|
39342
39442
|
description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
|
|
@@ -39346,7 +39446,7 @@ var COMMAND_REGISTRY = {
|
|
|
39346
39446
|
},
|
|
39347
39447
|
"guardrail-explain": {
|
|
39348
39448
|
handler: async (ctx) => {
|
|
39349
|
-
const { handleGuardrailExplain } = await import("./guardrail-explain-
|
|
39449
|
+
const { handleGuardrailExplain } = await import("./guardrail-explain-d1m747g5.js");
|
|
39350
39450
|
return handleGuardrailExplain(ctx.directory, ctx.args);
|
|
39351
39451
|
},
|
|
39352
39452
|
description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
|
|
@@ -40207,7 +40307,7 @@ function validateToolPolicy() {
|
|
|
40207
40307
|
}
|
|
40208
40308
|
return { valid: warnings.length === 0, warnings };
|
|
40209
40309
|
}
|
|
40210
|
-
var
|
|
40310
|
+
var _internals63 = {
|
|
40211
40311
|
handleHelpCommand,
|
|
40212
40312
|
validateAliases,
|
|
40213
40313
|
validateToolPolicy,
|
|
@@ -40217,16 +40317,16 @@ var _internals62 = {
|
|
|
40217
40317
|
findSimilarCommands,
|
|
40218
40318
|
buildDetailedHelp
|
|
40219
40319
|
};
|
|
40220
|
-
var validation =
|
|
40320
|
+
var validation = _internals63.validateAliases();
|
|
40221
40321
|
if (!validation.valid) {
|
|
40222
40322
|
throw new Error(`COMMAND_REGISTRY alias validation failed:
|
|
40223
40323
|
${validation.errors.join(`
|
|
40224
40324
|
`)}`);
|
|
40225
40325
|
}
|
|
40226
|
-
|
|
40326
|
+
_internals63.emitValidationWarnings("COMMAND_REGISTRY alias warnings", validation.warnings);
|
|
40227
40327
|
try {
|
|
40228
|
-
const toolPolicyValidation =
|
|
40229
|
-
|
|
40328
|
+
const toolPolicyValidation = _internals63.validateToolPolicy();
|
|
40329
|
+
_internals63.emitValidationWarnings("COMMAND_REGISTRY toolPolicy warnings", toolPolicyValidation.warnings);
|
|
40230
40330
|
} catch (e) {
|
|
40231
40331
|
warn(`COMMAND_REGISTRY toolPolicy validation failed (non-fatal): ${e.message}`);
|
|
40232
40332
|
}
|
|
@@ -42946,7 +43046,7 @@ function formatCommandNotFound(tokens) {
|
|
|
42946
43046
|
const attemptedCommand = tokens[0] || "";
|
|
42947
43047
|
const MAX_DISPLAY = 100;
|
|
42948
43048
|
const displayCommand = attemptedCommand.length > MAX_DISPLAY ? `${attemptedCommand.slice(0, MAX_DISPLAY)}...` : attemptedCommand;
|
|
42949
|
-
const similar =
|
|
43049
|
+
const similar = _internals63.findSimilarCommands(attemptedCommand);
|
|
42950
43050
|
const header = `Command \`/swarm ${displayCommand}\` not found.`;
|
|
42951
43051
|
const suggestions = similar.length > 0 ? `Did you mean:
|
|
42952
43052
|
${similar.map((cmd) => ` - /swarm ${cmd}`).join(`
|
|
@@ -44906,10 +45006,10 @@ function startAgentSession(sessionId, agentName, staleDurationMs = STALE_SESSION
|
|
|
44906
45006
|
}
|
|
44907
45007
|
telemetry.sessionStarted(sessionId, agentName);
|
|
44908
45008
|
swarmState.activeAgent.set(sessionId, agentName);
|
|
44909
|
-
|
|
45009
|
+
_internals66.applyRehydrationCache(sessionState);
|
|
44910
45010
|
if (directory) {
|
|
44911
45011
|
let rehydrationPromise;
|
|
44912
|
-
rehydrationPromise =
|
|
45012
|
+
rehydrationPromise = _internals66.rehydrateSessionFromDisk(directory, sessionState).then(async () => {
|
|
44913
45013
|
try {
|
|
44914
45014
|
sessionState.prSubscriptions = await rehydratePrSubscriptions(sessionId, directory);
|
|
44915
45015
|
} catch (err) {
|
|
@@ -45090,7 +45190,7 @@ function ensureAgentSession(sessionId, agentName, directory) {
|
|
|
45090
45190
|
maybeSweepStaleSessions();
|
|
45091
45191
|
return session;
|
|
45092
45192
|
}
|
|
45093
|
-
|
|
45193
|
+
_internals66.startAgentSession(sessionId, agentName ?? "unknown", 7200000, directory);
|
|
45094
45194
|
session = swarmState.agentSessions.get(sessionId);
|
|
45095
45195
|
if (!session) {
|
|
45096
45196
|
throw new Error(`Failed to create guardrail session for ${sessionId}`);
|
|
@@ -45378,8 +45478,8 @@ function applyRehydrationCache(session) {
|
|
|
45378
45478
|
}
|
|
45379
45479
|
}
|
|
45380
45480
|
async function rehydrateSessionFromDisk(directory, session) {
|
|
45381
|
-
await
|
|
45382
|
-
|
|
45481
|
+
await _internals66.buildRehydrationCache(directory);
|
|
45482
|
+
_internals66.applyRehydrationCache(session);
|
|
45383
45483
|
}
|
|
45384
45484
|
function hasActiveTurboMode(sessionID) {
|
|
45385
45485
|
if (sessionID) {
|
|
@@ -45467,7 +45567,7 @@ async function rehydratePrSubscriptions(sessionID, directory) {
|
|
|
45467
45567
|
}
|
|
45468
45568
|
return map;
|
|
45469
45569
|
}
|
|
45470
|
-
var
|
|
45570
|
+
var _internals66 = {
|
|
45471
45571
|
swarmState,
|
|
45472
45572
|
resetSwarmState,
|
|
45473
45573
|
ensureAgentSession,
|
|
@@ -45606,4 +45706,4 @@ function createCuratorLLMDelegate(directory, mode = "init", sessionId) {
|
|
|
45606
45706
|
};
|
|
45607
45707
|
}
|
|
45608
45708
|
|
|
45609
|
-
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, handleCiSimulateCommand, handleClarifyCommand, createCuratorLLMDelegate,
|
|
45709
|
+
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, handleCiSimulateCommand, handleClarifyCommand, createCuratorLLMDelegate, _internals15 as _internals, normalizeRecommendationEntryIdToken, parseKnowledgeRecommendations, parseKnowledgeRecommendationsWithDiagnostics, parseStructuredCuratorBlocks, readCuratorSummary, writeCuratorSummary, appendCuratorRecommendation, mergeCuratorPhaseSummary, filterPhaseEvents, checkPhaseCompliance, runCuratorInit, runCuratorPhase, applyCuratorKnowledgeUpdates, isHiveEligible, countDistinctProjects, checkHivePromotions, _internals18 as _internals1, createHivePromoterHook, promoteToHive, promoteFromSwarm, handleCloseCommand, handleCodebaseReviewCommand, handleConcurrencyCommand, handleConfigCommand, handleConsolidateCommand, handleCostsCommand, handleCouncilCommand, handleCurateCommand, handleDarkMatterCommand, handleDeepDiveCommand, handleDeepResearchCommand, getPluginConfigDir, getPluginCachePaths, getPluginLockFilePaths, handleDiagnoseCommand, handleDoctorCommand, handleEvidenceCommand, handleEvidenceSummaryCommand, handleExportCommand, handleFullAutoCommand, handleGateAuditCommand, handleGateStatsCommand, handleHandoffCommand, handleHistoryCommand, handleKnowledgeQuarantineCommand, handleKnowledgeRestoreCommand, handleKnowledgeMigrateCommand, handleKnowledgeListCommand, handleKnowledgeUnactionableCommand, handleKnowledgeRetryHardeningCommand, handleLearningCommand, handleLinkCommand, handleMemoryCommand, handleMemoryStatusCommand, handleMemoryValueLogCommand, handleMemoryMigrateCommand, handleMemoryImportCommand, handleMemoryExportCommand, handlePlanCommand, handlePreflightCommand, handlePromoteCommand, handleQaGatesCommand, handleResetCommand, handleResetSessionCommand, handleRetrieveCommand, handleRollbackCommand, handleSddStatusCommand, handleSddValidateCommand, handleSddProjectCommand, handleSddCommand, handleSimulateCommand, handleSpecifyCommand, handleStatusCommand, handleSyncPlanCommand, handleTurboCommand, handleUnlinkCommand, handleWriteRetroCommand, handleHelpCommand, COMMAND_REGISTRY, VALID_COMMANDS, _internals63 as _internals2, resolveCommand };
|