@skj1724/oh-my-opencode 3.19.5 → 3.19.6
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/agents/atlas.d.ts +1 -1
- package/dist/agents/prometheus-prompt.d.ts +1 -1
- package/dist/cli/index.js +35 -2
- package/dist/config/schema.d.ts +6 -0
- package/dist/features/background-agent/manager.d.ts +3 -0
- package/dist/features/background-agent/types.d.ts +10 -0
- package/dist/features/task-toast-manager/manager.d.ts +5 -1
- package/dist/index.js +658 -405
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/windows-reserved-names.d.ts +8 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5241,6 +5241,86 @@ class PerfTracer {
|
|
|
5241
5241
|
}
|
|
5242
5242
|
var init_perf_tracer = () => {};
|
|
5243
5243
|
|
|
5244
|
+
// src/shared/windows-reserved-names.ts
|
|
5245
|
+
import { existsSync as existsSync12, readdirSync as readdirSync5 } from "fs";
|
|
5246
|
+
import { join as join14 } from "path";
|
|
5247
|
+
function scanForReservedNames(directory, maxDepth = 2) {
|
|
5248
|
+
if (!existsSync12(directory))
|
|
5249
|
+
return [];
|
|
5250
|
+
const found = [];
|
|
5251
|
+
_scan(directory, 0, maxDepth, found);
|
|
5252
|
+
return found;
|
|
5253
|
+
}
|
|
5254
|
+
function _scan(dir, depth, maxDepth, found) {
|
|
5255
|
+
if (depth > maxDepth)
|
|
5256
|
+
return;
|
|
5257
|
+
let entries;
|
|
5258
|
+
try {
|
|
5259
|
+
entries = readdirSync5(dir);
|
|
5260
|
+
} catch {
|
|
5261
|
+
return;
|
|
5262
|
+
}
|
|
5263
|
+
for (const name of entries) {
|
|
5264
|
+
const upper = name.toUpperCase();
|
|
5265
|
+
const baseName = upper.split(".")[0] ?? "";
|
|
5266
|
+
if (WIN_RESERVED_NAMES.has(upper) || WIN_RESERVED_NAMES.has(baseName)) {
|
|
5267
|
+
found.push(join14(dir, name));
|
|
5268
|
+
}
|
|
5269
|
+
const fullPath = join14(dir, name);
|
|
5270
|
+
try {
|
|
5271
|
+
const stat = existsSync12(fullPath);
|
|
5272
|
+
if (stat && depth < maxDepth) {
|
|
5273
|
+
_scan(fullPath, depth + 1, maxDepth, found);
|
|
5274
|
+
}
|
|
5275
|
+
} catch {}
|
|
5276
|
+
}
|
|
5277
|
+
}
|
|
5278
|
+
function formatReservedNamesWarning(found) {
|
|
5279
|
+
const lines = [
|
|
5280
|
+
"",
|
|
5281
|
+
"\u26A0\uFE0F WINDOWS RESERVED DEVICE NAMES DETECTED",
|
|
5282
|
+
" The following paths match Windows reserved device names (NUL, CON, AUX, etc.):",
|
|
5283
|
+
"",
|
|
5284
|
+
...found.map((p) => ` - ${p}`),
|
|
5285
|
+
"",
|
|
5286
|
+
" These will cause 'error: short read while indexing' git failures on Windows.",
|
|
5287
|
+
" This can make OpenCode's snapshot system extremely slow (30+ minutes).",
|
|
5288
|
+
"",
|
|
5289
|
+
" Fix: Rename these files/directories to avoid reserved names.",
|
|
5290
|
+
" e.g., rename 'nul' \u2192 'null-device', 'con' \u2192 'console-util'",
|
|
5291
|
+
""
|
|
5292
|
+
];
|
|
5293
|
+
return lines.join(`
|
|
5294
|
+
`);
|
|
5295
|
+
}
|
|
5296
|
+
var WIN_RESERVED_NAMES;
|
|
5297
|
+
var init_windows_reserved_names = __esm(() => {
|
|
5298
|
+
WIN_RESERVED_NAMES = new Set([
|
|
5299
|
+
"CON",
|
|
5300
|
+
"PRN",
|
|
5301
|
+
"AUX",
|
|
5302
|
+
"NUL",
|
|
5303
|
+
"COM1",
|
|
5304
|
+
"COM2",
|
|
5305
|
+
"COM3",
|
|
5306
|
+
"COM4",
|
|
5307
|
+
"COM5",
|
|
5308
|
+
"COM6",
|
|
5309
|
+
"COM7",
|
|
5310
|
+
"COM8",
|
|
5311
|
+
"COM9",
|
|
5312
|
+
"LPT1",
|
|
5313
|
+
"LPT2",
|
|
5314
|
+
"LPT3",
|
|
5315
|
+
"LPT4",
|
|
5316
|
+
"LPT5",
|
|
5317
|
+
"LPT6",
|
|
5318
|
+
"LPT7",
|
|
5319
|
+
"LPT8",
|
|
5320
|
+
"LPT9"
|
|
5321
|
+
]);
|
|
5322
|
+
});
|
|
5323
|
+
|
|
5244
5324
|
// src/shared/index.ts
|
|
5245
5325
|
var init_shared = __esm(() => {
|
|
5246
5326
|
init_frontmatter();
|
|
@@ -5270,6 +5350,7 @@ var init_shared = __esm(() => {
|
|
|
5270
5350
|
init_model_availability();
|
|
5271
5351
|
init_perf_tracer();
|
|
5272
5352
|
init_fileio_monitor();
|
|
5353
|
+
init_windows_reserved_names();
|
|
5273
5354
|
});
|
|
5274
5355
|
|
|
5275
5356
|
// node_modules/picomatch/lib/constants.js
|
|
@@ -16159,20 +16240,20 @@ function createSessionRecoveryHook(ctx, options) {
|
|
|
16159
16240
|
// src/hooks/comment-checker/cli.ts
|
|
16160
16241
|
var {spawn: spawn5 } = globalThis.Bun;
|
|
16161
16242
|
import { createRequire as createRequire2 } from "module";
|
|
16162
|
-
import { dirname, join as
|
|
16163
|
-
import { existsSync as
|
|
16243
|
+
import { dirname, join as join16 } from "path";
|
|
16244
|
+
import { existsSync as existsSync14 } from "fs";
|
|
16164
16245
|
import * as fs5 from "fs";
|
|
16165
16246
|
import { tmpdir as tmpdir4 } from "os";
|
|
16166
16247
|
|
|
16167
16248
|
// src/hooks/comment-checker/downloader.ts
|
|
16168
16249
|
init_shared();
|
|
16169
16250
|
var {spawn: spawn4 } = globalThis.Bun;
|
|
16170
|
-
import { existsSync as
|
|
16171
|
-
import { join as
|
|
16251
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync4, chmodSync, unlinkSync as unlinkSync2, appendFileSync as appendFileSync3 } from "fs";
|
|
16252
|
+
import { join as join15 } from "path";
|
|
16172
16253
|
import { homedir as homedir7, tmpdir as tmpdir3 } from "os";
|
|
16173
16254
|
import { createRequire } from "module";
|
|
16174
16255
|
var DEBUG = process.env.COMMENT_CHECKER_DEBUG === "1";
|
|
16175
|
-
var DEBUG_FILE =
|
|
16256
|
+
var DEBUG_FILE = join15(tmpdir3(), "comment-checker-debug.log");
|
|
16176
16257
|
function debugLog(...args) {
|
|
16177
16258
|
if (DEBUG) {
|
|
16178
16259
|
const msg = `[${new Date().toISOString()}] [comment-checker:downloader] ${args.map((a) => typeof a === "object" ? JSON.stringify(a, null, 2) : String(a)).join(" ")}
|
|
@@ -16191,19 +16272,19 @@ var PLATFORM_MAP = {
|
|
|
16191
16272
|
function getCacheDir() {
|
|
16192
16273
|
if (process.platform === "win32") {
|
|
16193
16274
|
const localAppData = process.env.LOCALAPPDATA || process.env.APPDATA;
|
|
16194
|
-
const base2 = localAppData ||
|
|
16195
|
-
return
|
|
16275
|
+
const base2 = localAppData || join15(homedir7(), "AppData", "Local");
|
|
16276
|
+
return join15(base2, "oh-my-opencode", "bin");
|
|
16196
16277
|
}
|
|
16197
16278
|
const xdgCache = process.env.XDG_CACHE_HOME;
|
|
16198
|
-
const base = xdgCache ||
|
|
16199
|
-
return
|
|
16279
|
+
const base = xdgCache || join15(homedir7(), ".cache");
|
|
16280
|
+
return join15(base, "oh-my-opencode", "bin");
|
|
16200
16281
|
}
|
|
16201
16282
|
function getBinaryName() {
|
|
16202
16283
|
return process.platform === "win32" ? "comment-checker.exe" : "comment-checker";
|
|
16203
16284
|
}
|
|
16204
16285
|
function getCachedBinaryPath() {
|
|
16205
|
-
const binaryPath =
|
|
16206
|
-
return
|
|
16286
|
+
const binaryPath = join15(getCacheDir(), getBinaryName());
|
|
16287
|
+
return existsSync13(binaryPath) ? binaryPath : null;
|
|
16207
16288
|
}
|
|
16208
16289
|
function getPackageVersion() {
|
|
16209
16290
|
try {
|
|
@@ -16235,8 +16316,8 @@ async function downloadCommentChecker() {
|
|
|
16235
16316
|
}
|
|
16236
16317
|
const cacheDir = getCacheDir();
|
|
16237
16318
|
const binaryName = getBinaryName();
|
|
16238
|
-
const binaryPath =
|
|
16239
|
-
if (
|
|
16319
|
+
const binaryPath = join15(cacheDir, binaryName);
|
|
16320
|
+
if (existsSync13(binaryPath)) {
|
|
16240
16321
|
debugLog("Binary already cached at:", binaryPath);
|
|
16241
16322
|
return binaryPath;
|
|
16242
16323
|
}
|
|
@@ -16247,14 +16328,14 @@ async function downloadCommentChecker() {
|
|
|
16247
16328
|
debugLog(`Downloading from: ${downloadUrl}`);
|
|
16248
16329
|
console.log(`[oh-my-opencode] Downloading comment-checker binary...`);
|
|
16249
16330
|
try {
|
|
16250
|
-
if (!
|
|
16331
|
+
if (!existsSync13(cacheDir)) {
|
|
16251
16332
|
mkdirSync4(cacheDir, { recursive: true });
|
|
16252
16333
|
}
|
|
16253
16334
|
const response = await fetch(downloadUrl, { redirect: "follow" });
|
|
16254
16335
|
if (!response.ok) {
|
|
16255
16336
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
16256
16337
|
}
|
|
16257
|
-
const archivePath =
|
|
16338
|
+
const archivePath = join15(cacheDir, assetName);
|
|
16258
16339
|
const arrayBuffer = await response.arrayBuffer();
|
|
16259
16340
|
await Bun.write(archivePath, arrayBuffer);
|
|
16260
16341
|
debugLog(`Downloaded archive to: ${archivePath}`);
|
|
@@ -16263,10 +16344,10 @@ async function downloadCommentChecker() {
|
|
|
16263
16344
|
} else {
|
|
16264
16345
|
await extractZip(archivePath, cacheDir);
|
|
16265
16346
|
}
|
|
16266
|
-
if (
|
|
16347
|
+
if (existsSync13(archivePath)) {
|
|
16267
16348
|
unlinkSync2(archivePath);
|
|
16268
16349
|
}
|
|
16269
|
-
if (process.platform !== "win32" &&
|
|
16350
|
+
if (process.platform !== "win32" && existsSync13(binaryPath)) {
|
|
16270
16351
|
chmodSync(binaryPath, 493);
|
|
16271
16352
|
}
|
|
16272
16353
|
debugLog(`Successfully downloaded binary to: ${binaryPath}`);
|
|
@@ -16290,7 +16371,7 @@ async function ensureCommentCheckerBinary() {
|
|
|
16290
16371
|
|
|
16291
16372
|
// src/hooks/comment-checker/cli.ts
|
|
16292
16373
|
var DEBUG2 = process.env.COMMENT_CHECKER_DEBUG === "1";
|
|
16293
|
-
var DEBUG_FILE2 =
|
|
16374
|
+
var DEBUG_FILE2 = join16(tmpdir4(), "comment-checker-debug.log");
|
|
16294
16375
|
function debugLog2(...args) {
|
|
16295
16376
|
if (DEBUG2) {
|
|
16296
16377
|
const msg = `[${new Date().toISOString()}] [comment-checker:cli] ${args.map((a) => typeof a === "object" ? JSON.stringify(a, null, 2) : String(a)).join(" ")}
|
|
@@ -16316,8 +16397,8 @@ function findCommentCheckerPathSync() {
|
|
|
16316
16397
|
const require2 = createRequire2(import.meta.url);
|
|
16317
16398
|
const cliPkgPath = require2.resolve("@code-yeongyu/comment-checker/package.json");
|
|
16318
16399
|
const cliDir = dirname(cliPkgPath);
|
|
16319
|
-
const binaryPath =
|
|
16320
|
-
if (
|
|
16400
|
+
const binaryPath = join16(cliDir, "bin", binaryName);
|
|
16401
|
+
if (existsSync14(binaryPath)) {
|
|
16321
16402
|
debugLog2("found binary in main package:", binaryPath);
|
|
16322
16403
|
return binaryPath;
|
|
16323
16404
|
}
|
|
@@ -16338,7 +16419,7 @@ async function getCommentCheckerPath() {
|
|
|
16338
16419
|
}
|
|
16339
16420
|
initPromise = (async () => {
|
|
16340
16421
|
const syncPath = findCommentCheckerPathSync();
|
|
16341
|
-
if (syncPath &&
|
|
16422
|
+
if (syncPath && existsSync14(syncPath)) {
|
|
16342
16423
|
resolvedCliPath = syncPath;
|
|
16343
16424
|
debugLog2("using sync-resolved path:", syncPath);
|
|
16344
16425
|
return syncPath;
|
|
@@ -16374,7 +16455,7 @@ async function runCommentChecker(input, cliPath, customPrompt) {
|
|
|
16374
16455
|
debugLog2("comment-checker binary not found");
|
|
16375
16456
|
return { hasComments: false, message: "" };
|
|
16376
16457
|
}
|
|
16377
|
-
if (!
|
|
16458
|
+
if (!existsSync14(binaryPath)) {
|
|
16378
16459
|
debugLog2("comment-checker binary does not exist:", binaryPath);
|
|
16379
16460
|
return { hasComments: false, message: "" };
|
|
16380
16461
|
}
|
|
@@ -16412,11 +16493,11 @@ async function runCommentChecker(input, cliPath, customPrompt) {
|
|
|
16412
16493
|
|
|
16413
16494
|
// src/hooks/comment-checker/index.ts
|
|
16414
16495
|
import * as fs6 from "fs";
|
|
16415
|
-
import { existsSync as
|
|
16496
|
+
import { existsSync as existsSync15 } from "fs";
|
|
16416
16497
|
import { tmpdir as tmpdir5 } from "os";
|
|
16417
|
-
import { join as
|
|
16498
|
+
import { join as join17 } from "path";
|
|
16418
16499
|
var DEBUG3 = process.env.COMMENT_CHECKER_DEBUG === "1";
|
|
16419
|
-
var DEBUG_FILE3 =
|
|
16500
|
+
var DEBUG_FILE3 = join17(tmpdir5(), "comment-checker-debug.log");
|
|
16420
16501
|
function debugLog3(...args) {
|
|
16421
16502
|
if (DEBUG3) {
|
|
16422
16503
|
const msg = `[${new Date().toISOString()}] [comment-checker:hook] ${args.map((a) => typeof a === "object" ? JSON.stringify(a, null, 2) : String(a)).join(" ")}
|
|
@@ -16496,7 +16577,7 @@ function createCommentCheckerHooks(config) {
|
|
|
16496
16577
|
}
|
|
16497
16578
|
try {
|
|
16498
16579
|
const cliPath = await cliPathPromise;
|
|
16499
|
-
if (!cliPath || !
|
|
16580
|
+
if (!cliPath || !existsSync15(cliPath)) {
|
|
16500
16581
|
debugLog3("CLI not available, skipping comment check");
|
|
16501
16582
|
return;
|
|
16502
16583
|
}
|
|
@@ -16576,33 +16657,33 @@ function createToolOutputTruncatorHook(ctx, options) {
|
|
|
16576
16657
|
};
|
|
16577
16658
|
}
|
|
16578
16659
|
// src/hooks/directory-agents-injector/index.ts
|
|
16579
|
-
import { existsSync as
|
|
16580
|
-
import { dirname as dirname2, join as
|
|
16660
|
+
import { existsSync as existsSync17, readFileSync as readFileSync9 } from "fs";
|
|
16661
|
+
import { dirname as dirname2, join as join20, resolve as resolve3 } from "path";
|
|
16581
16662
|
|
|
16582
16663
|
// src/hooks/directory-agents-injector/storage.ts
|
|
16583
16664
|
import {
|
|
16584
|
-
existsSync as
|
|
16665
|
+
existsSync as existsSync16,
|
|
16585
16666
|
mkdirSync as mkdirSync5,
|
|
16586
16667
|
readFileSync as readFileSync8,
|
|
16587
16668
|
writeFileSync as writeFileSync5,
|
|
16588
16669
|
unlinkSync as unlinkSync3
|
|
16589
16670
|
} from "fs";
|
|
16590
|
-
import { join as
|
|
16671
|
+
import { join as join19 } from "path";
|
|
16591
16672
|
|
|
16592
16673
|
// src/hooks/directory-agents-injector/constants.ts
|
|
16593
16674
|
init_data_path();
|
|
16594
|
-
import { join as
|
|
16675
|
+
import { join as join18 } from "path";
|
|
16595
16676
|
var OPENCODE_STORAGE3 = getOpenCodeStorageDir();
|
|
16596
|
-
var AGENTS_INJECTOR_STORAGE =
|
|
16677
|
+
var AGENTS_INJECTOR_STORAGE = join18(OPENCODE_STORAGE3, "directory-agents");
|
|
16597
16678
|
var AGENTS_FILENAME = "AGENTS.md";
|
|
16598
16679
|
|
|
16599
16680
|
// src/hooks/directory-agents-injector/storage.ts
|
|
16600
16681
|
function getStoragePath(sessionID) {
|
|
16601
|
-
return
|
|
16682
|
+
return join19(AGENTS_INJECTOR_STORAGE, `${sessionID}.json`);
|
|
16602
16683
|
}
|
|
16603
16684
|
function loadInjectedPaths(sessionID) {
|
|
16604
16685
|
const filePath = getStoragePath(sessionID);
|
|
16605
|
-
if (!
|
|
16686
|
+
if (!existsSync16(filePath))
|
|
16606
16687
|
return new Set;
|
|
16607
16688
|
try {
|
|
16608
16689
|
const content = readFileSync8(filePath, "utf-8");
|
|
@@ -16613,7 +16694,7 @@ function loadInjectedPaths(sessionID) {
|
|
|
16613
16694
|
}
|
|
16614
16695
|
}
|
|
16615
16696
|
function saveInjectedPaths(sessionID, paths) {
|
|
16616
|
-
if (!
|
|
16697
|
+
if (!existsSync16(AGENTS_INJECTOR_STORAGE)) {
|
|
16617
16698
|
mkdirSync5(AGENTS_INJECTOR_STORAGE, { recursive: true });
|
|
16618
16699
|
}
|
|
16619
16700
|
const data = {
|
|
@@ -16625,7 +16706,7 @@ function saveInjectedPaths(sessionID, paths) {
|
|
|
16625
16706
|
}
|
|
16626
16707
|
function clearInjectedPaths(sessionID) {
|
|
16627
16708
|
const filePath = getStoragePath(sessionID);
|
|
16628
|
-
if (
|
|
16709
|
+
if (existsSync16(filePath)) {
|
|
16629
16710
|
unlinkSync3(filePath);
|
|
16630
16711
|
}
|
|
16631
16712
|
}
|
|
@@ -16655,8 +16736,8 @@ function createDirectoryAgentsInjectorHook(ctx) {
|
|
|
16655
16736
|
while (true) {
|
|
16656
16737
|
const isRootDir = current === ctx.directory;
|
|
16657
16738
|
if (!isRootDir) {
|
|
16658
|
-
const agentsPath =
|
|
16659
|
-
if (
|
|
16739
|
+
const agentsPath = join20(current, AGENTS_FILENAME);
|
|
16740
|
+
if (existsSync17(agentsPath)) {
|
|
16660
16741
|
found.push(agentsPath);
|
|
16661
16742
|
}
|
|
16662
16743
|
}
|
|
@@ -16753,33 +16834,33 @@ ${result}${truncationNotice}`;
|
|
|
16753
16834
|
};
|
|
16754
16835
|
}
|
|
16755
16836
|
// src/hooks/directory-readme-injector/index.ts
|
|
16756
|
-
import { existsSync as
|
|
16757
|
-
import { dirname as dirname3, join as
|
|
16837
|
+
import { existsSync as existsSync19, readFileSync as readFileSync11 } from "fs";
|
|
16838
|
+
import { dirname as dirname3, join as join23, resolve as resolve4 } from "path";
|
|
16758
16839
|
|
|
16759
16840
|
// src/hooks/directory-readme-injector/storage.ts
|
|
16760
16841
|
import {
|
|
16761
|
-
existsSync as
|
|
16842
|
+
existsSync as existsSync18,
|
|
16762
16843
|
mkdirSync as mkdirSync6,
|
|
16763
16844
|
readFileSync as readFileSync10,
|
|
16764
16845
|
writeFileSync as writeFileSync6,
|
|
16765
16846
|
unlinkSync as unlinkSync4
|
|
16766
16847
|
} from "fs";
|
|
16767
|
-
import { join as
|
|
16848
|
+
import { join as join22 } from "path";
|
|
16768
16849
|
|
|
16769
16850
|
// src/hooks/directory-readme-injector/constants.ts
|
|
16770
16851
|
init_data_path();
|
|
16771
|
-
import { join as
|
|
16852
|
+
import { join as join21 } from "path";
|
|
16772
16853
|
var OPENCODE_STORAGE4 = getOpenCodeStorageDir();
|
|
16773
|
-
var README_INJECTOR_STORAGE =
|
|
16854
|
+
var README_INJECTOR_STORAGE = join21(OPENCODE_STORAGE4, "directory-readme");
|
|
16774
16855
|
var README_FILENAME = "README.md";
|
|
16775
16856
|
|
|
16776
16857
|
// src/hooks/directory-readme-injector/storage.ts
|
|
16777
16858
|
function getStoragePath2(sessionID) {
|
|
16778
|
-
return
|
|
16859
|
+
return join22(README_INJECTOR_STORAGE, `${sessionID}.json`);
|
|
16779
16860
|
}
|
|
16780
16861
|
function loadInjectedPaths2(sessionID) {
|
|
16781
16862
|
const filePath = getStoragePath2(sessionID);
|
|
16782
|
-
if (!
|
|
16863
|
+
if (!existsSync18(filePath))
|
|
16783
16864
|
return new Set;
|
|
16784
16865
|
try {
|
|
16785
16866
|
const content = readFileSync10(filePath, "utf-8");
|
|
@@ -16790,7 +16871,7 @@ function loadInjectedPaths2(sessionID) {
|
|
|
16790
16871
|
}
|
|
16791
16872
|
}
|
|
16792
16873
|
function saveInjectedPaths2(sessionID, paths) {
|
|
16793
|
-
if (!
|
|
16874
|
+
if (!existsSync18(README_INJECTOR_STORAGE)) {
|
|
16794
16875
|
mkdirSync6(README_INJECTOR_STORAGE, { recursive: true });
|
|
16795
16876
|
}
|
|
16796
16877
|
const data = {
|
|
@@ -16802,7 +16883,7 @@ function saveInjectedPaths2(sessionID, paths) {
|
|
|
16802
16883
|
}
|
|
16803
16884
|
function clearInjectedPaths2(sessionID) {
|
|
16804
16885
|
const filePath = getStoragePath2(sessionID);
|
|
16805
|
-
if (
|
|
16886
|
+
if (existsSync18(filePath)) {
|
|
16806
16887
|
unlinkSync4(filePath);
|
|
16807
16888
|
}
|
|
16808
16889
|
}
|
|
@@ -16830,8 +16911,8 @@ function createDirectoryReadmeInjectorHook(ctx) {
|
|
|
16830
16911
|
const found = [];
|
|
16831
16912
|
let current = startDir;
|
|
16832
16913
|
while (true) {
|
|
16833
|
-
const readmePath =
|
|
16834
|
-
if (
|
|
16914
|
+
const readmePath = join23(current, README_FILENAME);
|
|
16915
|
+
if (existsSync19(readmePath)) {
|
|
16835
16916
|
found.push(readmePath);
|
|
16836
16917
|
}
|
|
16837
16918
|
if (current === ctx.directory)
|
|
@@ -17141,22 +17222,22 @@ var TRUNCATE_CONFIG = {
|
|
|
17141
17222
|
|
|
17142
17223
|
// src/hooks/anthropic-context-window-limit-recovery/storage.ts
|
|
17143
17224
|
init_data_path();
|
|
17144
|
-
import { existsSync as
|
|
17145
|
-
import { join as
|
|
17225
|
+
import { existsSync as existsSync20, readdirSync as readdirSync6, readFileSync as readFileSync12, writeFileSync as writeFileSync7 } from "fs";
|
|
17226
|
+
import { join as join24 } from "path";
|
|
17146
17227
|
var OPENCODE_STORAGE5 = getOpenCodeStorageDir();
|
|
17147
|
-
var MESSAGE_STORAGE3 =
|
|
17148
|
-
var PART_STORAGE3 =
|
|
17228
|
+
var MESSAGE_STORAGE3 = join24(OPENCODE_STORAGE5, "message");
|
|
17229
|
+
var PART_STORAGE3 = join24(OPENCODE_STORAGE5, "part");
|
|
17149
17230
|
var TRUNCATION_MESSAGE = "[TOOL RESULT TRUNCATED - Context limit exceeded. Original output was too large and has been truncated to recover the session. Please re-run this tool if you need the full output.]";
|
|
17150
17231
|
function getMessageDir3(sessionID) {
|
|
17151
|
-
if (!
|
|
17232
|
+
if (!existsSync20(MESSAGE_STORAGE3))
|
|
17152
17233
|
return "";
|
|
17153
|
-
const directPath =
|
|
17154
|
-
if (
|
|
17234
|
+
const directPath = join24(MESSAGE_STORAGE3, sessionID);
|
|
17235
|
+
if (existsSync20(directPath)) {
|
|
17155
17236
|
return directPath;
|
|
17156
17237
|
}
|
|
17157
|
-
for (const dir of
|
|
17158
|
-
const sessionPath =
|
|
17159
|
-
if (
|
|
17238
|
+
for (const dir of readdirSync6(MESSAGE_STORAGE3)) {
|
|
17239
|
+
const sessionPath = join24(MESSAGE_STORAGE3, dir, sessionID);
|
|
17240
|
+
if (existsSync20(sessionPath)) {
|
|
17160
17241
|
return sessionPath;
|
|
17161
17242
|
}
|
|
17162
17243
|
}
|
|
@@ -17164,10 +17245,10 @@ function getMessageDir3(sessionID) {
|
|
|
17164
17245
|
}
|
|
17165
17246
|
function getMessageIds(sessionID) {
|
|
17166
17247
|
const messageDir = getMessageDir3(sessionID);
|
|
17167
|
-
if (!messageDir || !
|
|
17248
|
+
if (!messageDir || !existsSync20(messageDir))
|
|
17168
17249
|
return [];
|
|
17169
17250
|
const messageIds = [];
|
|
17170
|
-
for (const file of
|
|
17251
|
+
for (const file of readdirSync6(messageDir)) {
|
|
17171
17252
|
if (!file.endsWith(".json"))
|
|
17172
17253
|
continue;
|
|
17173
17254
|
const messageId = file.replace(".json", "");
|
|
@@ -17179,14 +17260,14 @@ function findToolResultsBySize(sessionID) {
|
|
|
17179
17260
|
const messageIds = getMessageIds(sessionID);
|
|
17180
17261
|
const results = [];
|
|
17181
17262
|
for (const messageID of messageIds) {
|
|
17182
|
-
const partDir =
|
|
17183
|
-
if (!
|
|
17263
|
+
const partDir = join24(PART_STORAGE3, messageID);
|
|
17264
|
+
if (!existsSync20(partDir))
|
|
17184
17265
|
continue;
|
|
17185
|
-
for (const file of
|
|
17266
|
+
for (const file of readdirSync6(partDir)) {
|
|
17186
17267
|
if (!file.endsWith(".json"))
|
|
17187
17268
|
continue;
|
|
17188
17269
|
try {
|
|
17189
|
-
const partPath =
|
|
17270
|
+
const partPath = join24(partDir, file);
|
|
17190
17271
|
const content = readFileSync12(partPath, "utf-8");
|
|
17191
17272
|
const part = JSON.parse(content);
|
|
17192
17273
|
if (part.type === "tool" && part.state?.output && !part.truncated) {
|
|
@@ -18033,8 +18114,8 @@ function createThinkModeHook() {
|
|
|
18033
18114
|
}
|
|
18034
18115
|
// src/hooks/claude-code-hooks/config.ts
|
|
18035
18116
|
init_shared();
|
|
18036
|
-
import { join as
|
|
18037
|
-
import { existsSync as
|
|
18117
|
+
import { join as join25 } from "path";
|
|
18118
|
+
import { existsSync as existsSync21 } from "fs";
|
|
18038
18119
|
function normalizeHookMatcher(raw) {
|
|
18039
18120
|
return {
|
|
18040
18121
|
matcher: raw.matcher ?? raw.pattern ?? "*",
|
|
@@ -18060,11 +18141,11 @@ function normalizeHooksConfig(raw) {
|
|
|
18060
18141
|
function getClaudeSettingsPaths(customPath) {
|
|
18061
18142
|
const claudeConfigDir = getClaudeConfigDir();
|
|
18062
18143
|
const paths = [
|
|
18063
|
-
|
|
18064
|
-
|
|
18065
|
-
|
|
18144
|
+
join25(claudeConfigDir, "settings.json"),
|
|
18145
|
+
join25(process.cwd(), ".claude", "settings.json"),
|
|
18146
|
+
join25(process.cwd(), ".claude", "settings.local.json")
|
|
18066
18147
|
];
|
|
18067
|
-
if (customPath &&
|
|
18148
|
+
if (customPath && existsSync21(customPath)) {
|
|
18068
18149
|
paths.unshift(customPath);
|
|
18069
18150
|
}
|
|
18070
18151
|
return paths;
|
|
@@ -18089,7 +18170,7 @@ async function loadClaudeHooksConfig(customSettingsPath) {
|
|
|
18089
18170
|
const paths = getClaudeSettingsPaths(customSettingsPath);
|
|
18090
18171
|
let mergedConfig = {};
|
|
18091
18172
|
for (const settingsPath of paths) {
|
|
18092
|
-
if (
|
|
18173
|
+
if (existsSync21(settingsPath)) {
|
|
18093
18174
|
try {
|
|
18094
18175
|
const content = await Bun.file(settingsPath).text();
|
|
18095
18176
|
const settings = JSON.parse(content);
|
|
@@ -18108,14 +18189,14 @@ async function loadClaudeHooksConfig(customSettingsPath) {
|
|
|
18108
18189
|
// src/hooks/claude-code-hooks/config-loader.ts
|
|
18109
18190
|
init_logger();
|
|
18110
18191
|
init_shared();
|
|
18111
|
-
import { existsSync as
|
|
18112
|
-
import { join as
|
|
18113
|
-
var USER_CONFIG_PATH =
|
|
18192
|
+
import { existsSync as existsSync22 } from "fs";
|
|
18193
|
+
import { join as join26 } from "path";
|
|
18194
|
+
var USER_CONFIG_PATH = join26(getOpenCodeConfigDir({ binary: "opencode" }), "opencode-cc-plugin.json");
|
|
18114
18195
|
function getProjectConfigPath() {
|
|
18115
|
-
return
|
|
18196
|
+
return join26(process.cwd(), ".opencode", "opencode-cc-plugin.json");
|
|
18116
18197
|
}
|
|
18117
18198
|
async function loadConfigFromPath(path4) {
|
|
18118
|
-
if (!
|
|
18199
|
+
if (!existsSync22(path4)) {
|
|
18119
18200
|
return null;
|
|
18120
18201
|
}
|
|
18121
18202
|
try {
|
|
@@ -18303,16 +18384,16 @@ init_shared();
|
|
|
18303
18384
|
// src/hooks/claude-code-hooks/transcript.ts
|
|
18304
18385
|
init_tool_name();
|
|
18305
18386
|
init_shared();
|
|
18306
|
-
import { join as
|
|
18307
|
-
import { mkdirSync as mkdirSync7, appendFileSync as appendFileSync6, existsSync as
|
|
18387
|
+
import { join as join27 } from "path";
|
|
18388
|
+
import { mkdirSync as mkdirSync7, appendFileSync as appendFileSync6, existsSync as existsSync23, writeFileSync as writeFileSync8, unlinkSync as unlinkSync5 } from "fs";
|
|
18308
18389
|
import { tmpdir as tmpdir6 } from "os";
|
|
18309
18390
|
import { randomUUID } from "crypto";
|
|
18310
|
-
var TRANSCRIPT_DIR =
|
|
18391
|
+
var TRANSCRIPT_DIR = join27(getClaudeConfigDir(), "transcripts");
|
|
18311
18392
|
function getTranscriptPath(sessionId) {
|
|
18312
|
-
return
|
|
18393
|
+
return join27(TRANSCRIPT_DIR, `${sessionId}.jsonl`);
|
|
18313
18394
|
}
|
|
18314
18395
|
function ensureTranscriptDir() {
|
|
18315
|
-
if (!
|
|
18396
|
+
if (!existsSync23(TRANSCRIPT_DIR)) {
|
|
18316
18397
|
mkdirSync7(TRANSCRIPT_DIR, { recursive: true });
|
|
18317
18398
|
}
|
|
18318
18399
|
}
|
|
@@ -18399,7 +18480,7 @@ async function buildTranscriptFromSession(client, sessionId, directory, currentT
|
|
|
18399
18480
|
}
|
|
18400
18481
|
};
|
|
18401
18482
|
entries.push(JSON.stringify(currentEntry));
|
|
18402
|
-
const tempPath =
|
|
18483
|
+
const tempPath = join27(tmpdir6(), `opencode-transcript-${sessionId}-${randomUUID()}.jsonl`);
|
|
18403
18484
|
writeFileSync8(tempPath, entries.join(`
|
|
18404
18485
|
`) + `
|
|
18405
18486
|
`);
|
|
@@ -18419,7 +18500,7 @@ async function buildTranscriptFromSession(client, sessionId, directory, currentT
|
|
|
18419
18500
|
]
|
|
18420
18501
|
}
|
|
18421
18502
|
};
|
|
18422
|
-
const tempPath =
|
|
18503
|
+
const tempPath = join27(tmpdir6(), `opencode-transcript-${sessionId}-${randomUUID()}.jsonl`);
|
|
18423
18504
|
writeFileSync8(tempPath, JSON.stringify(currentEntry) + `
|
|
18424
18505
|
`);
|
|
18425
18506
|
return tempPath;
|
|
@@ -18635,11 +18716,11 @@ ${USER_PROMPT_SUBMIT_TAG_CLOSE}`);
|
|
|
18635
18716
|
init_shared();
|
|
18636
18717
|
|
|
18637
18718
|
// src/hooks/claude-code-hooks/todo.ts
|
|
18638
|
-
import { join as
|
|
18719
|
+
import { join as join28 } from "path";
|
|
18639
18720
|
init_shared();
|
|
18640
|
-
var TODO_DIR =
|
|
18721
|
+
var TODO_DIR = join28(getClaudeConfigDir(), "todos");
|
|
18641
18722
|
function getTodoPath(sessionId) {
|
|
18642
|
-
return
|
|
18723
|
+
return join28(TODO_DIR, `${sessionId}-agent-${sessionId}.json`);
|
|
18643
18724
|
}
|
|
18644
18725
|
|
|
18645
18726
|
// src/hooks/claude-code-hooks/stop.ts
|
|
@@ -19087,18 +19168,18 @@ import { relative as relative4, resolve as resolve5 } from "path";
|
|
|
19087
19168
|
|
|
19088
19169
|
// src/hooks/rules-injector/finder.ts
|
|
19089
19170
|
import {
|
|
19090
|
-
existsSync as
|
|
19091
|
-
readdirSync as
|
|
19171
|
+
existsSync as existsSync24,
|
|
19172
|
+
readdirSync as readdirSync7,
|
|
19092
19173
|
realpathSync,
|
|
19093
19174
|
statSync as statSync2
|
|
19094
19175
|
} from "fs";
|
|
19095
|
-
import { dirname as dirname4, join as
|
|
19176
|
+
import { dirname as dirname4, join as join30, relative as relative2 } from "path";
|
|
19096
19177
|
|
|
19097
19178
|
// src/hooks/rules-injector/constants.ts
|
|
19098
19179
|
init_data_path();
|
|
19099
|
-
import { join as
|
|
19180
|
+
import { join as join29 } from "path";
|
|
19100
19181
|
var OPENCODE_STORAGE6 = getOpenCodeStorageDir();
|
|
19101
|
-
var RULES_INJECTOR_STORAGE =
|
|
19182
|
+
var RULES_INJECTOR_STORAGE = join29(OPENCODE_STORAGE6, "rules-injector");
|
|
19102
19183
|
var PROJECT_MARKERS = [
|
|
19103
19184
|
".git",
|
|
19104
19185
|
"pyproject.toml",
|
|
@@ -19139,8 +19220,8 @@ function findProjectRoot(startPath) {
|
|
|
19139
19220
|
}
|
|
19140
19221
|
while (true) {
|
|
19141
19222
|
for (const marker of PROJECT_MARKERS) {
|
|
19142
|
-
const markerPath =
|
|
19143
|
-
if (
|
|
19223
|
+
const markerPath = join30(current, marker);
|
|
19224
|
+
if (existsSync24(markerPath)) {
|
|
19144
19225
|
return current;
|
|
19145
19226
|
}
|
|
19146
19227
|
}
|
|
@@ -19152,12 +19233,12 @@ function findProjectRoot(startPath) {
|
|
|
19152
19233
|
}
|
|
19153
19234
|
}
|
|
19154
19235
|
function findRuleFilesRecursive(dir, results) {
|
|
19155
|
-
if (!
|
|
19236
|
+
if (!existsSync24(dir))
|
|
19156
19237
|
return;
|
|
19157
19238
|
try {
|
|
19158
|
-
const entries =
|
|
19239
|
+
const entries = readdirSync7(dir, { withFileTypes: true });
|
|
19159
19240
|
for (const entry of entries) {
|
|
19160
|
-
const fullPath =
|
|
19241
|
+
const fullPath = join30(dir, entry.name);
|
|
19161
19242
|
if (entry.isDirectory()) {
|
|
19162
19243
|
findRuleFilesRecursive(fullPath, results);
|
|
19163
19244
|
} else if (entry.isFile()) {
|
|
@@ -19182,7 +19263,7 @@ function findRuleFiles(projectRoot, homeDir, currentFile) {
|
|
|
19182
19263
|
let distance = 0;
|
|
19183
19264
|
while (true) {
|
|
19184
19265
|
for (const [parent, subdir] of PROJECT_RULE_SUBDIRS) {
|
|
19185
|
-
const ruleDir =
|
|
19266
|
+
const ruleDir = join30(currentDir, parent, subdir);
|
|
19186
19267
|
const files = [];
|
|
19187
19268
|
findRuleFilesRecursive(ruleDir, files);
|
|
19188
19269
|
for (const filePath of files) {
|
|
@@ -19208,8 +19289,8 @@ function findRuleFiles(projectRoot, homeDir, currentFile) {
|
|
|
19208
19289
|
}
|
|
19209
19290
|
if (projectRoot) {
|
|
19210
19291
|
for (const ruleFile of PROJECT_RULE_FILES) {
|
|
19211
|
-
const filePath =
|
|
19212
|
-
if (
|
|
19292
|
+
const filePath = join30(projectRoot, ruleFile);
|
|
19293
|
+
if (existsSync24(filePath)) {
|
|
19213
19294
|
try {
|
|
19214
19295
|
const stat = statSync2(filePath);
|
|
19215
19296
|
if (stat.isFile()) {
|
|
@@ -19229,7 +19310,7 @@ function findRuleFiles(projectRoot, homeDir, currentFile) {
|
|
|
19229
19310
|
}
|
|
19230
19311
|
}
|
|
19231
19312
|
}
|
|
19232
|
-
const userRuleDir =
|
|
19313
|
+
const userRuleDir = join30(homeDir, USER_RULE_DIR);
|
|
19233
19314
|
const userFiles = [];
|
|
19234
19315
|
findRuleFilesRecursive(userRuleDir, userFiles);
|
|
19235
19316
|
for (const filePath of userFiles) {
|
|
@@ -19418,19 +19499,19 @@ function mergeGlobs(existing, newValue) {
|
|
|
19418
19499
|
|
|
19419
19500
|
// src/hooks/rules-injector/storage.ts
|
|
19420
19501
|
import {
|
|
19421
|
-
existsSync as
|
|
19502
|
+
existsSync as existsSync25,
|
|
19422
19503
|
mkdirSync as mkdirSync8,
|
|
19423
19504
|
readFileSync as readFileSync13,
|
|
19424
19505
|
writeFileSync as writeFileSync9,
|
|
19425
19506
|
unlinkSync as unlinkSync6
|
|
19426
19507
|
} from "fs";
|
|
19427
|
-
import { join as
|
|
19508
|
+
import { join as join31 } from "path";
|
|
19428
19509
|
function getStoragePath3(sessionID) {
|
|
19429
|
-
return
|
|
19510
|
+
return join31(RULES_INJECTOR_STORAGE, `${sessionID}.json`);
|
|
19430
19511
|
}
|
|
19431
19512
|
function loadInjectedRules(sessionID) {
|
|
19432
19513
|
const filePath = getStoragePath3(sessionID);
|
|
19433
|
-
if (!
|
|
19514
|
+
if (!existsSync25(filePath))
|
|
19434
19515
|
return { contentHashes: new Set, realPaths: new Set };
|
|
19435
19516
|
try {
|
|
19436
19517
|
const content = readFileSync13(filePath, "utf-8");
|
|
@@ -19444,7 +19525,7 @@ function loadInjectedRules(sessionID) {
|
|
|
19444
19525
|
}
|
|
19445
19526
|
}
|
|
19446
19527
|
function saveInjectedRules(sessionID, data) {
|
|
19447
|
-
if (!
|
|
19528
|
+
if (!existsSync25(RULES_INJECTOR_STORAGE)) {
|
|
19448
19529
|
mkdirSync8(RULES_INJECTOR_STORAGE, { recursive: true });
|
|
19449
19530
|
}
|
|
19450
19531
|
const storageData = {
|
|
@@ -19457,7 +19538,7 @@ function saveInjectedRules(sessionID, data) {
|
|
|
19457
19538
|
}
|
|
19458
19539
|
function clearInjectedRules(sessionID) {
|
|
19459
19540
|
const filePath = getStoragePath3(sessionID);
|
|
19460
|
-
if (
|
|
19541
|
+
if (existsSync25(filePath)) {
|
|
19461
19542
|
unlinkSync6(filePath);
|
|
19462
19543
|
}
|
|
19463
19544
|
}
|
|
@@ -19613,19 +19694,19 @@ init_auto_update_checker();
|
|
|
19613
19694
|
|
|
19614
19695
|
// src/hooks/agent-usage-reminder/storage.ts
|
|
19615
19696
|
import {
|
|
19616
|
-
existsSync as
|
|
19697
|
+
existsSync as existsSync28,
|
|
19617
19698
|
mkdirSync as mkdirSync9,
|
|
19618
19699
|
readFileSync as readFileSync17,
|
|
19619
19700
|
writeFileSync as writeFileSync12,
|
|
19620
19701
|
unlinkSync as unlinkSync7
|
|
19621
19702
|
} from "fs";
|
|
19622
|
-
import { join as
|
|
19703
|
+
import { join as join36 } from "path";
|
|
19623
19704
|
|
|
19624
19705
|
// src/hooks/agent-usage-reminder/constants.ts
|
|
19625
19706
|
init_data_path();
|
|
19626
|
-
import { join as
|
|
19707
|
+
import { join as join35 } from "path";
|
|
19627
19708
|
var OPENCODE_STORAGE7 = getOpenCodeStorageDir();
|
|
19628
|
-
var AGENT_USAGE_REMINDER_STORAGE =
|
|
19709
|
+
var AGENT_USAGE_REMINDER_STORAGE = join35(OPENCODE_STORAGE7, "agent-usage-reminder");
|
|
19629
19710
|
var TARGET_TOOLS = new Set([
|
|
19630
19711
|
"grep",
|
|
19631
19712
|
"safe_grep",
|
|
@@ -19671,11 +19752,11 @@ delegate_task(agent="librarian", prompt="\u67E5\u627E Z \u7684\u6587\u6863")
|
|
|
19671
19752
|
|
|
19672
19753
|
// src/hooks/agent-usage-reminder/storage.ts
|
|
19673
19754
|
function getStoragePath4(sessionID) {
|
|
19674
|
-
return
|
|
19755
|
+
return join36(AGENT_USAGE_REMINDER_STORAGE, `${sessionID}.json`);
|
|
19675
19756
|
}
|
|
19676
19757
|
function loadAgentUsageState(sessionID) {
|
|
19677
19758
|
const filePath = getStoragePath4(sessionID);
|
|
19678
|
-
if (!
|
|
19759
|
+
if (!existsSync28(filePath))
|
|
19679
19760
|
return null;
|
|
19680
19761
|
try {
|
|
19681
19762
|
const content = readFileSync17(filePath, "utf-8");
|
|
@@ -19685,7 +19766,7 @@ function loadAgentUsageState(sessionID) {
|
|
|
19685
19766
|
}
|
|
19686
19767
|
}
|
|
19687
19768
|
function saveAgentUsageState(state2) {
|
|
19688
|
-
if (!
|
|
19769
|
+
if (!existsSync28(AGENT_USAGE_REMINDER_STORAGE)) {
|
|
19689
19770
|
mkdirSync9(AGENT_USAGE_REMINDER_STORAGE, { recursive: true });
|
|
19690
19771
|
}
|
|
19691
19772
|
const filePath = getStoragePath4(state2.sessionID);
|
|
@@ -19693,7 +19774,7 @@ function saveAgentUsageState(state2) {
|
|
|
19693
19774
|
}
|
|
19694
19775
|
function clearAgentUsageState(sessionID) {
|
|
19695
19776
|
const filePath = getStoragePath4(sessionID);
|
|
19696
|
-
if (
|
|
19777
|
+
if (existsSync28(filePath)) {
|
|
19697
19778
|
unlinkSync7(filePath);
|
|
19698
19779
|
}
|
|
19699
19780
|
}
|
|
@@ -20276,19 +20357,19 @@ function createNonInteractiveEnvHook(_ctx) {
|
|
|
20276
20357
|
}
|
|
20277
20358
|
// src/hooks/interactive-bash-session/storage.ts
|
|
20278
20359
|
import {
|
|
20279
|
-
existsSync as
|
|
20360
|
+
existsSync as existsSync29,
|
|
20280
20361
|
mkdirSync as mkdirSync10,
|
|
20281
20362
|
readFileSync as readFileSync18,
|
|
20282
20363
|
writeFileSync as writeFileSync13,
|
|
20283
20364
|
unlinkSync as unlinkSync8
|
|
20284
20365
|
} from "fs";
|
|
20285
|
-
import { join as
|
|
20366
|
+
import { join as join38 } from "path";
|
|
20286
20367
|
|
|
20287
20368
|
// src/hooks/interactive-bash-session/constants.ts
|
|
20288
20369
|
init_data_path();
|
|
20289
|
-
import { join as
|
|
20370
|
+
import { join as join37 } from "path";
|
|
20290
20371
|
var OPENCODE_STORAGE8 = getOpenCodeStorageDir();
|
|
20291
|
-
var INTERACTIVE_BASH_SESSION_STORAGE =
|
|
20372
|
+
var INTERACTIVE_BASH_SESSION_STORAGE = join37(OPENCODE_STORAGE8, "interactive-bash-session");
|
|
20292
20373
|
var OMO_SESSION_PREFIX = "omo-";
|
|
20293
20374
|
function buildSessionReminderMessage(sessions) {
|
|
20294
20375
|
if (sessions.length === 0)
|
|
@@ -20300,11 +20381,11 @@ function buildSessionReminderMessage(sessions) {
|
|
|
20300
20381
|
|
|
20301
20382
|
// src/hooks/interactive-bash-session/storage.ts
|
|
20302
20383
|
function getStoragePath5(sessionID) {
|
|
20303
|
-
return
|
|
20384
|
+
return join38(INTERACTIVE_BASH_SESSION_STORAGE, `${sessionID}.json`);
|
|
20304
20385
|
}
|
|
20305
20386
|
function loadInteractiveBashSessionState(sessionID) {
|
|
20306
20387
|
const filePath = getStoragePath5(sessionID);
|
|
20307
|
-
if (!
|
|
20388
|
+
if (!existsSync29(filePath))
|
|
20308
20389
|
return null;
|
|
20309
20390
|
try {
|
|
20310
20391
|
const content = readFileSync18(filePath, "utf-8");
|
|
@@ -20319,7 +20400,7 @@ function loadInteractiveBashSessionState(sessionID) {
|
|
|
20319
20400
|
}
|
|
20320
20401
|
}
|
|
20321
20402
|
function saveInteractiveBashSessionState(state2) {
|
|
20322
|
-
if (!
|
|
20403
|
+
if (!existsSync29(INTERACTIVE_BASH_SESSION_STORAGE)) {
|
|
20323
20404
|
mkdirSync10(INTERACTIVE_BASH_SESSION_STORAGE, { recursive: true });
|
|
20324
20405
|
}
|
|
20325
20406
|
const filePath = getStoragePath5(state2.sessionID);
|
|
@@ -20332,7 +20413,7 @@ function saveInteractiveBashSessionState(state2) {
|
|
|
20332
20413
|
}
|
|
20333
20414
|
function clearInteractiveBashSessionState(sessionID) {
|
|
20334
20415
|
const filePath = getStoragePath5(sessionID);
|
|
20335
|
-
if (
|
|
20416
|
+
if (existsSync29(filePath)) {
|
|
20336
20417
|
unlinkSync8(filePath);
|
|
20337
20418
|
}
|
|
20338
20419
|
}
|
|
@@ -20596,13 +20677,13 @@ function createThinkingBlockValidatorHook() {
|
|
|
20596
20677
|
// src/hooks/ralph-loop/index.ts
|
|
20597
20678
|
init_logger();
|
|
20598
20679
|
init_system_directive();
|
|
20599
|
-
import { existsSync as
|
|
20600
|
-
import { join as
|
|
20680
|
+
import { existsSync as existsSync31, readFileSync as readFileSync20, readdirSync as readdirSync8 } from "fs";
|
|
20681
|
+
import { join as join40 } from "path";
|
|
20601
20682
|
|
|
20602
20683
|
// src/hooks/ralph-loop/storage.ts
|
|
20603
20684
|
init_frontmatter();
|
|
20604
|
-
import { existsSync as
|
|
20605
|
-
import { dirname as dirname6, join as
|
|
20685
|
+
import { existsSync as existsSync30, readFileSync as readFileSync19, writeFileSync as writeFileSync14, unlinkSync as unlinkSync9, mkdirSync as mkdirSync11 } from "fs";
|
|
20686
|
+
import { dirname as dirname6, join as join39 } from "path";
|
|
20606
20687
|
|
|
20607
20688
|
// src/hooks/ralph-loop/constants.ts
|
|
20608
20689
|
var HOOK_NAME3 = "ralph-loop";
|
|
@@ -20612,11 +20693,11 @@ var DEFAULT_COMPLETION_PROMISE = "DONE";
|
|
|
20612
20693
|
|
|
20613
20694
|
// src/hooks/ralph-loop/storage.ts
|
|
20614
20695
|
function getStateFilePath(directory, customPath) {
|
|
20615
|
-
return customPath ?
|
|
20696
|
+
return customPath ? join39(directory, customPath) : join39(directory, DEFAULT_STATE_FILE);
|
|
20616
20697
|
}
|
|
20617
20698
|
function readState(directory, customPath) {
|
|
20618
20699
|
const filePath = getStateFilePath(directory, customPath);
|
|
20619
|
-
if (!
|
|
20700
|
+
if (!existsSync30(filePath)) {
|
|
20620
20701
|
return null;
|
|
20621
20702
|
}
|
|
20622
20703
|
try {
|
|
@@ -20654,7 +20735,7 @@ function writeState(directory, state2, customPath) {
|
|
|
20654
20735
|
const filePath = getStateFilePath(directory, customPath);
|
|
20655
20736
|
try {
|
|
20656
20737
|
const dir = dirname6(filePath);
|
|
20657
|
-
if (!
|
|
20738
|
+
if (!existsSync30(dir)) {
|
|
20658
20739
|
mkdirSync11(dir, { recursive: true });
|
|
20659
20740
|
}
|
|
20660
20741
|
const sessionIdLine = state2.session_id ? `session_id: "${state2.session_id}"
|
|
@@ -20679,7 +20760,7 @@ ${state2.prompt}
|
|
|
20679
20760
|
function clearState(directory, customPath) {
|
|
20680
20761
|
const filePath = getStateFilePath(directory, customPath);
|
|
20681
20762
|
try {
|
|
20682
|
-
if (
|
|
20763
|
+
if (existsSync30(filePath)) {
|
|
20683
20764
|
unlinkSync9(filePath);
|
|
20684
20765
|
}
|
|
20685
20766
|
return true;
|
|
@@ -20700,14 +20781,14 @@ function incrementIteration(directory, customPath) {
|
|
|
20700
20781
|
|
|
20701
20782
|
// src/hooks/ralph-loop/index.ts
|
|
20702
20783
|
function getMessageDir4(sessionID) {
|
|
20703
|
-
if (!
|
|
20784
|
+
if (!existsSync31(MESSAGE_STORAGE))
|
|
20704
20785
|
return null;
|
|
20705
|
-
const directPath =
|
|
20706
|
-
if (
|
|
20786
|
+
const directPath = join40(MESSAGE_STORAGE, sessionID);
|
|
20787
|
+
if (existsSync31(directPath))
|
|
20707
20788
|
return directPath;
|
|
20708
|
-
for (const dir of
|
|
20709
|
-
const sessionPath =
|
|
20710
|
-
if (
|
|
20789
|
+
for (const dir of readdirSync8(MESSAGE_STORAGE)) {
|
|
20790
|
+
const sessionPath = join40(MESSAGE_STORAGE, dir, sessionID);
|
|
20791
|
+
if (existsSync31(sessionPath))
|
|
20711
20792
|
return sessionPath;
|
|
20712
20793
|
}
|
|
20713
20794
|
return null;
|
|
@@ -20744,7 +20825,7 @@ function createRalphLoopHook(ctx, options) {
|
|
|
20744
20825
|
if (!transcriptPath)
|
|
20745
20826
|
return false;
|
|
20746
20827
|
try {
|
|
20747
|
-
if (!
|
|
20828
|
+
if (!existsSync31(transcriptPath))
|
|
20748
20829
|
return false;
|
|
20749
20830
|
const content = readFileSync20(transcriptPath, "utf-8");
|
|
20750
20831
|
const pattern = new RegExp(`<promise>\\s*${escapeRegex(promise)}\\s*</promise>`, "is");
|
|
@@ -21060,8 +21141,8 @@ function extractPromptText3(parts) {
|
|
|
21060
21141
|
// src/hooks/auto-slash-command/executor.ts
|
|
21061
21142
|
init_shared();
|
|
21062
21143
|
init_file_utils();
|
|
21063
|
-
import { existsSync as
|
|
21064
|
-
import { join as
|
|
21144
|
+
import { existsSync as existsSync33, readdirSync as readdirSync9, readFileSync as readFileSync23 } from "fs";
|
|
21145
|
+
import { join as join42, basename as basename2, dirname as dirname8 } from "path";
|
|
21065
21146
|
// src/features/opencode-skill-loader/loader.ts
|
|
21066
21147
|
init_js_yaml();
|
|
21067
21148
|
init_frontmatter();
|
|
@@ -21069,7 +21150,7 @@ init_file_utils();
|
|
|
21069
21150
|
init_shared();
|
|
21070
21151
|
init_opencode_config_dir();
|
|
21071
21152
|
import { promises as fs9 } from "fs";
|
|
21072
|
-
import { join as
|
|
21153
|
+
import { join as join41, basename } from "path";
|
|
21073
21154
|
function parseSkillMcpConfigFromFrontmatter(content) {
|
|
21074
21155
|
const frontmatterMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
21075
21156
|
if (!frontmatterMatch)
|
|
@@ -21085,7 +21166,7 @@ function parseSkillMcpConfigFromFrontmatter(content) {
|
|
|
21085
21166
|
return;
|
|
21086
21167
|
}
|
|
21087
21168
|
async function loadMcpJsonFromDir(skillDir) {
|
|
21088
|
-
const mcpJsonPath =
|
|
21169
|
+
const mcpJsonPath = join41(skillDir, "mcp.json");
|
|
21089
21170
|
try {
|
|
21090
21171
|
const content = await fs9.readFile(mcpJsonPath, "utf-8");
|
|
21091
21172
|
const parsed = JSON.parse(content);
|
|
@@ -21166,11 +21247,11 @@ async function loadSkillsFromDir(skillsDir, scope) {
|
|
|
21166
21247
|
for (const entry of entries) {
|
|
21167
21248
|
if (entry.name.startsWith("."))
|
|
21168
21249
|
continue;
|
|
21169
|
-
const entryPath =
|
|
21250
|
+
const entryPath = join41(skillsDir, entry.name);
|
|
21170
21251
|
if (entry.isDirectory() || entry.isSymbolicLink()) {
|
|
21171
21252
|
const resolvedPath = await resolveSymlinkAsync(entryPath);
|
|
21172
21253
|
const dirName = entry.name;
|
|
21173
|
-
const skillMdPath =
|
|
21254
|
+
const skillMdPath = join41(resolvedPath, "SKILL.md");
|
|
21174
21255
|
try {
|
|
21175
21256
|
await fs9.access(skillMdPath);
|
|
21176
21257
|
const skill = await loadSkillFromPath(skillMdPath, resolvedPath, dirName, scope);
|
|
@@ -21178,7 +21259,7 @@ async function loadSkillsFromDir(skillsDir, scope) {
|
|
|
21178
21259
|
skills.push(skill);
|
|
21179
21260
|
continue;
|
|
21180
21261
|
} catch {}
|
|
21181
|
-
const namedSkillMdPath =
|
|
21262
|
+
const namedSkillMdPath = join41(resolvedPath, `${dirName}.md`);
|
|
21182
21263
|
try {
|
|
21183
21264
|
await fs9.access(namedSkillMdPath);
|
|
21184
21265
|
const skill = await loadSkillFromPath(namedSkillMdPath, resolvedPath, dirName, scope);
|
|
@@ -21206,23 +21287,23 @@ function skillsToRecord(skills) {
|
|
|
21206
21287
|
return result;
|
|
21207
21288
|
}
|
|
21208
21289
|
async function loadUserSkills() {
|
|
21209
|
-
const userSkillsDir =
|
|
21290
|
+
const userSkillsDir = join41(getClaudeConfigDir(), "skills");
|
|
21210
21291
|
const skills = await loadSkillsFromDir(userSkillsDir, "user");
|
|
21211
21292
|
return skillsToRecord(skills);
|
|
21212
21293
|
}
|
|
21213
21294
|
async function loadProjectSkills() {
|
|
21214
|
-
const projectSkillsDir =
|
|
21295
|
+
const projectSkillsDir = join41(process.cwd(), ".claude", "skills");
|
|
21215
21296
|
const skills = await loadSkillsFromDir(projectSkillsDir, "project");
|
|
21216
21297
|
return skillsToRecord(skills);
|
|
21217
21298
|
}
|
|
21218
21299
|
async function loadOpencodeGlobalSkills() {
|
|
21219
21300
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
21220
|
-
const opencodeSkillsDir =
|
|
21301
|
+
const opencodeSkillsDir = join41(configDir, "skills");
|
|
21221
21302
|
const skills = await loadSkillsFromDir(opencodeSkillsDir, "opencode");
|
|
21222
21303
|
return skillsToRecord(skills);
|
|
21223
21304
|
}
|
|
21224
21305
|
async function loadOpencodeProjectSkills() {
|
|
21225
|
-
const opencodeProjectDir =
|
|
21306
|
+
const opencodeProjectDir = join41(process.cwd(), ".opencode", "skills");
|
|
21226
21307
|
const skills = await loadSkillsFromDir(opencodeProjectDir, "opencode-project");
|
|
21227
21308
|
return skillsToRecord(skills);
|
|
21228
21309
|
}
|
|
@@ -21251,28 +21332,29 @@ async function discoverSkills(options = {}) {
|
|
|
21251
21332
|
return [...opencodeProjectSkills, ...projectSkills, ...opencodeGlobalSkills, ...userSkills];
|
|
21252
21333
|
}
|
|
21253
21334
|
async function discoverUserClaudeSkills() {
|
|
21254
|
-
const userSkillsDir =
|
|
21335
|
+
const userSkillsDir = join41(getClaudeConfigDir(), "skills");
|
|
21255
21336
|
return loadSkillsFromDir(userSkillsDir, "user");
|
|
21256
21337
|
}
|
|
21257
21338
|
async function discoverProjectClaudeSkills() {
|
|
21258
|
-
const projectSkillsDir =
|
|
21339
|
+
const projectSkillsDir = join41(process.cwd(), ".claude", "skills");
|
|
21259
21340
|
return loadSkillsFromDir(projectSkillsDir, "project");
|
|
21260
21341
|
}
|
|
21261
21342
|
async function discoverOpencodeGlobalSkills() {
|
|
21262
21343
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
21263
|
-
const opencodeSkillsDir =
|
|
21344
|
+
const opencodeSkillsDir = join41(configDir, "skills");
|
|
21264
21345
|
return loadSkillsFromDir(opencodeSkillsDir, "opencode");
|
|
21265
21346
|
}
|
|
21266
21347
|
async function discoverOpencodeProjectSkills() {
|
|
21267
|
-
const opencodeProjectDir =
|
|
21348
|
+
const opencodeProjectDir = join41(process.cwd(), ".opencode", "skills");
|
|
21268
21349
|
return loadSkillsFromDir(opencodeProjectDir, "opencode-project");
|
|
21269
21350
|
}
|
|
21270
21351
|
// src/features/opencode-skill-loader/merger.ts
|
|
21271
21352
|
init_frontmatter();
|
|
21272
21353
|
init_deep_merge();
|
|
21273
|
-
import { readFileSync as readFileSync21, existsSync as
|
|
21354
|
+
import { readFileSync as readFileSync21, existsSync as existsSync32 } from "fs";
|
|
21274
21355
|
import { dirname as dirname7, resolve as resolve6, isAbsolute as isAbsolute2 } from "path";
|
|
21275
21356
|
import { homedir as homedir11 } from "os";
|
|
21357
|
+
import { createHash as createHash2 } from "crypto";
|
|
21276
21358
|
var SCOPE_PRIORITY = {
|
|
21277
21359
|
builtin: 1,
|
|
21278
21360
|
config: 2,
|
|
@@ -21318,7 +21400,7 @@ function resolveFilePath2(from, configDir) {
|
|
|
21318
21400
|
}
|
|
21319
21401
|
function loadSkillFromFile(filePath) {
|
|
21320
21402
|
try {
|
|
21321
|
-
if (!
|
|
21403
|
+
if (!existsSync32(filePath))
|
|
21322
21404
|
return null;
|
|
21323
21405
|
const content = readFileSync21(filePath, "utf-8");
|
|
21324
21406
|
const { data, body } = parseFrontmatter(content);
|
|
@@ -21407,13 +21489,28 @@ function mergeSkillDefinitions(base, patch) {
|
|
|
21407
21489
|
allowedTools: mergedTools ? [...new Set(mergedTools)] : undefined
|
|
21408
21490
|
};
|
|
21409
21491
|
}
|
|
21492
|
+
function contentHash(content) {
|
|
21493
|
+
return createHash2("md5").update(content).digest("hex").slice(0, 8);
|
|
21494
|
+
}
|
|
21495
|
+
function emptyDedupStats() {
|
|
21496
|
+
return { totalScanned: 0, unique: 0, skippedByScope: 0, skippedByContent: 0, byScope: {} };
|
|
21497
|
+
}
|
|
21410
21498
|
function mergeSkills(builtinSkills, config, userClaudeSkills, userOpencodeSkills, projectClaudeSkills, projectOpencodeSkills, options = {}) {
|
|
21411
21499
|
const skillMap = new Map;
|
|
21500
|
+
const contentHashes = new Map;
|
|
21501
|
+
const stats = emptyDedupStats();
|
|
21412
21502
|
for (const builtin of builtinSkills) {
|
|
21413
21503
|
const loaded = builtinToLoaded(builtin);
|
|
21414
21504
|
skillMap.set(loaded.name, loaded);
|
|
21505
|
+
stats.byScope["builtin"] = (stats.byScope["builtin"] ?? 0) + 1;
|
|
21506
|
+
stats.unique++;
|
|
21507
|
+
if (loaded.definition.template) {
|
|
21508
|
+
contentHashes.set(loaded.name, contentHash(loaded.definition.template));
|
|
21509
|
+
}
|
|
21415
21510
|
}
|
|
21511
|
+
stats.totalScanned += builtinSkills.length;
|
|
21416
21512
|
const normalizedConfig = normalizeConfig(config);
|
|
21513
|
+
let configLoaded = 0;
|
|
21417
21514
|
for (const [name, entry] of Object.entries(normalizedConfig.entries)) {
|
|
21418
21515
|
if (entry === false)
|
|
21419
21516
|
continue;
|
|
@@ -21428,9 +21525,18 @@ function mergeSkills(builtinSkills, config, userClaudeSkills, userOpencodeSkills
|
|
|
21428
21525
|
skillMap.set(name, mergeSkillDefinitions(existing, entry));
|
|
21429
21526
|
} else {
|
|
21430
21527
|
skillMap.set(name, loaded);
|
|
21528
|
+
configLoaded++;
|
|
21529
|
+
stats.unique++;
|
|
21530
|
+
if (loaded.definition.template) {
|
|
21531
|
+
contentHashes.set(name, contentHash(loaded.definition.template));
|
|
21532
|
+
}
|
|
21431
21533
|
}
|
|
21432
21534
|
}
|
|
21433
21535
|
}
|
|
21536
|
+
if (configLoaded > 0) {
|
|
21537
|
+
stats.byScope["config"] = configLoaded;
|
|
21538
|
+
stats.totalScanned += configLoaded;
|
|
21539
|
+
}
|
|
21434
21540
|
const fileSystemSkills = [
|
|
21435
21541
|
...userClaudeSkills,
|
|
21436
21542
|
...userOpencodeSkills,
|
|
@@ -21438,10 +21544,30 @@ function mergeSkills(builtinSkills, config, userClaudeSkills, userOpencodeSkills
|
|
|
21438
21544
|
...projectOpencodeSkills
|
|
21439
21545
|
];
|
|
21440
21546
|
for (const skill of fileSystemSkills) {
|
|
21547
|
+
stats.totalScanned++;
|
|
21548
|
+
stats.byScope[skill.scope] = (stats.byScope[skill.scope] ?? 0) + 1;
|
|
21441
21549
|
const existing = skillMap.get(skill.name);
|
|
21442
|
-
|
|
21443
|
-
|
|
21550
|
+
const hash = skill.definition.template ? contentHash(skill.definition.template) : undefined;
|
|
21551
|
+
if (existing) {
|
|
21552
|
+
const existingHash = contentHashes.get(skill.name);
|
|
21553
|
+
if (hash && existingHash && hash === existingHash) {
|
|
21554
|
+
stats.skippedByContent++;
|
|
21555
|
+
continue;
|
|
21556
|
+
}
|
|
21557
|
+
if (SCOPE_PRIORITY[skill.scope] <= SCOPE_PRIORITY[existing.scope]) {
|
|
21558
|
+
stats.skippedByScope++;
|
|
21559
|
+
continue;
|
|
21560
|
+
}
|
|
21561
|
+
}
|
|
21562
|
+
skillMap.set(skill.name, skill);
|
|
21563
|
+
if (hash) {
|
|
21564
|
+
contentHashes.set(skill.name, hash);
|
|
21444
21565
|
}
|
|
21566
|
+
stats.unique++;
|
|
21567
|
+
}
|
|
21568
|
+
if (stats.skippedByContent > 0 || stats.skippedByScope > 1) {
|
|
21569
|
+
const scopeSummary = Object.entries(stats.byScope).map(([scope, count]) => `${scope}:${count}`).join(", ");
|
|
21570
|
+
console.debug(`[skill-loader] Scanned ${stats.totalScanned} skills (${scopeSummary}), ` + `${stats.unique} loaded, ` + `${stats.skippedByContent} skipped (identical content), ` + `${stats.skippedByScope} skipped (lower priority scope)`);
|
|
21445
21571
|
}
|
|
21446
21572
|
for (const [name, entry] of Object.entries(normalizedConfig.entries)) {
|
|
21447
21573
|
if (entry === true)
|
|
@@ -22802,15 +22928,15 @@ async function resolveMultipleSkillsAsync(skillNames, options) {
|
|
|
22802
22928
|
}
|
|
22803
22929
|
// src/hooks/auto-slash-command/executor.ts
|
|
22804
22930
|
function discoverCommandsFromDir(commandsDir, scope) {
|
|
22805
|
-
if (!
|
|
22931
|
+
if (!existsSync33(commandsDir)) {
|
|
22806
22932
|
return [];
|
|
22807
22933
|
}
|
|
22808
|
-
const entries =
|
|
22934
|
+
const entries = readdirSync9(commandsDir, { withFileTypes: true });
|
|
22809
22935
|
const commands = [];
|
|
22810
22936
|
for (const entry of entries) {
|
|
22811
22937
|
if (!isMarkdownFile(entry))
|
|
22812
22938
|
continue;
|
|
22813
|
-
const commandPath =
|
|
22939
|
+
const commandPath = join42(commandsDir, entry.name);
|
|
22814
22940
|
const commandName = basename2(entry.name, ".md");
|
|
22815
22941
|
try {
|
|
22816
22942
|
const content = readFileSync23(commandPath, "utf-8");
|
|
@@ -22856,10 +22982,10 @@ function skillToCommandInfo(skill) {
|
|
|
22856
22982
|
}
|
|
22857
22983
|
async function discoverAllCommands(options) {
|
|
22858
22984
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
22859
|
-
const userCommandsDir =
|
|
22860
|
-
const projectCommandsDir =
|
|
22861
|
-
const opencodeGlobalDir =
|
|
22862
|
-
const opencodeProjectDir =
|
|
22985
|
+
const userCommandsDir = join42(getClaudeConfigDir(), "commands");
|
|
22986
|
+
const projectCommandsDir = join42(process.cwd(), ".claude", "commands");
|
|
22987
|
+
const opencodeGlobalDir = join42(configDir, "command");
|
|
22988
|
+
const opencodeProjectDir = join42(process.cwd(), ".opencode", "command");
|
|
22863
22989
|
const userCommands = discoverCommandsFromDir(userCommandsDir, "user");
|
|
22864
22990
|
const opencodeGlobalCommands = discoverCommandsFromDir(opencodeGlobalDir, "opencode");
|
|
22865
22991
|
const projectCommands = discoverCommandsFromDir(projectCommandsDir, "project");
|
|
@@ -23029,8 +23155,8 @@ ${EDIT_ERROR_REMINDER}`;
|
|
|
23029
23155
|
};
|
|
23030
23156
|
}
|
|
23031
23157
|
// src/hooks/prometheus-md-only/index.ts
|
|
23032
|
-
import { existsSync as
|
|
23033
|
-
import { join as
|
|
23158
|
+
import { existsSync as existsSync34, readdirSync as readdirSync10 } from "fs";
|
|
23159
|
+
import { join as join43, resolve as resolve7, relative as relative5, isAbsolute as isAbsolute3 } from "path";
|
|
23034
23160
|
|
|
23035
23161
|
// src/hooks/prometheus-md-only/constants.ts
|
|
23036
23162
|
init_system_directive();
|
|
@@ -23149,14 +23275,14 @@ function isAllowedFile(filePath, workspaceRoot) {
|
|
|
23149
23275
|
return true;
|
|
23150
23276
|
}
|
|
23151
23277
|
function getMessageDir5(sessionID) {
|
|
23152
|
-
if (!
|
|
23278
|
+
if (!existsSync34(MESSAGE_STORAGE))
|
|
23153
23279
|
return null;
|
|
23154
|
-
const directPath =
|
|
23155
|
-
if (
|
|
23280
|
+
const directPath = join43(MESSAGE_STORAGE, sessionID);
|
|
23281
|
+
if (existsSync34(directPath))
|
|
23156
23282
|
return directPath;
|
|
23157
|
-
for (const dir of
|
|
23158
|
-
const sessionPath =
|
|
23159
|
-
if (
|
|
23283
|
+
for (const dir of readdirSync10(MESSAGE_STORAGE)) {
|
|
23284
|
+
const sessionPath = join43(MESSAGE_STORAGE, dir, sessionID);
|
|
23285
|
+
if (existsSync34(sessionPath))
|
|
23160
23286
|
return sessionPath;
|
|
23161
23287
|
}
|
|
23162
23288
|
return null;
|
|
@@ -23270,14 +23396,14 @@ var NOTEPAD_DIR = "notepads";
|
|
|
23270
23396
|
var NOTEPAD_BASE_PATH = `${BOULDER_DIR}/${NOTEPAD_DIR}`;
|
|
23271
23397
|
var PROMETHEUS_PLANS_DIR = ".sisyphus/plans";
|
|
23272
23398
|
// src/features/boulder-state/storage.ts
|
|
23273
|
-
import { existsSync as
|
|
23274
|
-
import { dirname as dirname9, join as
|
|
23399
|
+
import { existsSync as existsSync35, readFileSync as readFileSync24, writeFileSync as writeFileSync15, mkdirSync as mkdirSync12, readdirSync as readdirSync11 } from "fs";
|
|
23400
|
+
import { dirname as dirname9, join as join44, basename as basename3 } from "path";
|
|
23275
23401
|
function getBoulderFilePath(directory) {
|
|
23276
|
-
return
|
|
23402
|
+
return join44(directory, BOULDER_DIR, BOULDER_FILE);
|
|
23277
23403
|
}
|
|
23278
23404
|
function readBoulderState(directory) {
|
|
23279
23405
|
const filePath = getBoulderFilePath(directory);
|
|
23280
|
-
if (!
|
|
23406
|
+
if (!existsSync35(filePath)) {
|
|
23281
23407
|
return null;
|
|
23282
23408
|
}
|
|
23283
23409
|
try {
|
|
@@ -23291,7 +23417,7 @@ function writeBoulderState(directory, state2) {
|
|
|
23291
23417
|
const filePath = getBoulderFilePath(directory);
|
|
23292
23418
|
try {
|
|
23293
23419
|
const dir = dirname9(filePath);
|
|
23294
|
-
if (!
|
|
23420
|
+
if (!existsSync35(dir)) {
|
|
23295
23421
|
mkdirSync12(dir, { recursive: true });
|
|
23296
23422
|
}
|
|
23297
23423
|
writeFileSync15(filePath, JSON.stringify(state2, null, 2), "utf-8");
|
|
@@ -23315,7 +23441,7 @@ function appendSessionId(directory, sessionId) {
|
|
|
23315
23441
|
function clearBoulderState(directory) {
|
|
23316
23442
|
const filePath = getBoulderFilePath(directory);
|
|
23317
23443
|
try {
|
|
23318
|
-
if (
|
|
23444
|
+
if (existsSync35(filePath)) {
|
|
23319
23445
|
const { unlinkSync: unlinkSync10 } = __require("fs");
|
|
23320
23446
|
unlinkSync10(filePath);
|
|
23321
23447
|
}
|
|
@@ -23325,13 +23451,13 @@ function clearBoulderState(directory) {
|
|
|
23325
23451
|
}
|
|
23326
23452
|
}
|
|
23327
23453
|
function findPrometheusPlans(directory) {
|
|
23328
|
-
const plansDir =
|
|
23329
|
-
if (!
|
|
23454
|
+
const plansDir = join44(directory, PROMETHEUS_PLANS_DIR);
|
|
23455
|
+
if (!existsSync35(plansDir)) {
|
|
23330
23456
|
return [];
|
|
23331
23457
|
}
|
|
23332
23458
|
try {
|
|
23333
|
-
const files =
|
|
23334
|
-
return files.filter((f) => f.endsWith(".md")).map((f) =>
|
|
23459
|
+
const files = readdirSync11(plansDir);
|
|
23460
|
+
return files.filter((f) => f.endsWith(".md")).map((f) => join44(plansDir, f)).sort((a, b) => {
|
|
23335
23461
|
const aStat = __require("fs").statSync(a);
|
|
23336
23462
|
const bStat = __require("fs").statSync(b);
|
|
23337
23463
|
return bStat.mtimeMs - aStat.mtimeMs;
|
|
@@ -23341,7 +23467,7 @@ function findPrometheusPlans(directory) {
|
|
|
23341
23467
|
}
|
|
23342
23468
|
}
|
|
23343
23469
|
function getPlanProgress(planPath) {
|
|
23344
|
-
if (!
|
|
23470
|
+
if (!existsSync35(planPath)) {
|
|
23345
23471
|
return { total: 0, completed: 0, isComplete: true };
|
|
23346
23472
|
}
|
|
23347
23473
|
try {
|
|
@@ -23562,8 +23688,8 @@ ${contextInfo}`;
|
|
|
23562
23688
|
}
|
|
23563
23689
|
// src/hooks/atlas/index.ts
|
|
23564
23690
|
import { execSync } from "child_process";
|
|
23565
|
-
import { existsSync as
|
|
23566
|
-
import { join as
|
|
23691
|
+
import { existsSync as existsSync36, readdirSync as readdirSync12 } from "fs";
|
|
23692
|
+
import { join as join45 } from "path";
|
|
23567
23693
|
init_logger();
|
|
23568
23694
|
init_system_directive();
|
|
23569
23695
|
var HOOK_NAME6 = "atlas";
|
|
@@ -23892,14 +24018,14 @@ function formatFileChanges(stats, notepadPath) {
|
|
|
23892
24018
|
`);
|
|
23893
24019
|
}
|
|
23894
24020
|
function getMessageDir6(sessionID) {
|
|
23895
|
-
if (!
|
|
24021
|
+
if (!existsSync36(MESSAGE_STORAGE))
|
|
23896
24022
|
return null;
|
|
23897
|
-
const directPath =
|
|
23898
|
-
if (
|
|
24023
|
+
const directPath = join45(MESSAGE_STORAGE, sessionID);
|
|
24024
|
+
if (existsSync36(directPath))
|
|
23899
24025
|
return directPath;
|
|
23900
|
-
for (const dir of
|
|
23901
|
-
const sessionPath =
|
|
23902
|
-
if (
|
|
24026
|
+
for (const dir of readdirSync12(MESSAGE_STORAGE)) {
|
|
24027
|
+
const sessionPath = join45(MESSAGE_STORAGE, dir, sessionID);
|
|
24028
|
+
if (existsSync36(sessionPath))
|
|
23903
24029
|
return sessionPath;
|
|
23904
24030
|
}
|
|
23905
24031
|
return null;
|
|
@@ -24253,7 +24379,7 @@ var DELEGATE_TASK_ERROR_PATTERNS = [
|
|
|
24253
24379
|
}
|
|
24254
24380
|
];
|
|
24255
24381
|
function detectDelegateTaskError(output) {
|
|
24256
|
-
if (!output.includes("[ERROR]") && !output.includes("Invalid arguments"))
|
|
24382
|
+
if (!output.includes("[ERROR]") && !output.includes("Invalid arguments") && !output.includes("\u53C2\u6570\u9519\u8BEF\uFF1A"))
|
|
24257
24383
|
return null;
|
|
24258
24384
|
for (const errorPattern of DELEGATE_TASK_ERROR_PATTERNS) {
|
|
24259
24385
|
if (output.includes(errorPattern.pattern)) {
|
|
@@ -24548,8 +24674,8 @@ function createFirstMessageVariantGate() {
|
|
|
24548
24674
|
}
|
|
24549
24675
|
// src/features/claude-code-mcp-loader/loader.ts
|
|
24550
24676
|
init_shared();
|
|
24551
|
-
import { existsSync as
|
|
24552
|
-
import { join as
|
|
24677
|
+
import { existsSync as existsSync37, readFileSync as readFileSync25 } from "fs";
|
|
24678
|
+
import { join as join46 } from "path";
|
|
24553
24679
|
|
|
24554
24680
|
// src/features/claude-code-mcp-loader/env-expander.ts
|
|
24555
24681
|
function expandEnvVars(value) {
|
|
@@ -24619,13 +24745,13 @@ function getMcpConfigPaths() {
|
|
|
24619
24745
|
const claudeConfigDir = getClaudeConfigDir();
|
|
24620
24746
|
const cwd2 = process.cwd();
|
|
24621
24747
|
return [
|
|
24622
|
-
{ path:
|
|
24623
|
-
{ path:
|
|
24624
|
-
{ path:
|
|
24748
|
+
{ path: join46(claudeConfigDir, ".mcp.json"), scope: "user" },
|
|
24749
|
+
{ path: join46(cwd2, ".mcp.json"), scope: "project" },
|
|
24750
|
+
{ path: join46(cwd2, ".claude", ".mcp.json"), scope: "local" }
|
|
24625
24751
|
];
|
|
24626
24752
|
}
|
|
24627
24753
|
async function loadMcpConfigFile(filePath) {
|
|
24628
|
-
if (!
|
|
24754
|
+
if (!existsSync37(filePath)) {
|
|
24629
24755
|
return null;
|
|
24630
24756
|
}
|
|
24631
24757
|
try {
|
|
@@ -24640,7 +24766,7 @@ function getSystemMcpServerNames() {
|
|
|
24640
24766
|
const names = new Set;
|
|
24641
24767
|
const paths = getMcpConfigPaths();
|
|
24642
24768
|
for (const { path: path7 } of paths) {
|
|
24643
|
-
if (!
|
|
24769
|
+
if (!existsSync37(path7))
|
|
24644
24770
|
continue;
|
|
24645
24771
|
try {
|
|
24646
24772
|
const content = readFileSync25(path7, "utf-8");
|
|
@@ -25086,11 +25212,11 @@ var EXT_TO_LANG = {
|
|
|
25086
25212
|
".gql": "graphql"
|
|
25087
25213
|
};
|
|
25088
25214
|
// src/tools/lsp/config.ts
|
|
25089
|
-
import { existsSync as
|
|
25090
|
-
import { join as
|
|
25215
|
+
import { existsSync as existsSync38, readFileSync as readFileSync26 } from "fs";
|
|
25216
|
+
import { join as join47 } from "path";
|
|
25091
25217
|
init_shared();
|
|
25092
25218
|
function loadJsonFile(path7) {
|
|
25093
|
-
if (!
|
|
25219
|
+
if (!existsSync38(path7))
|
|
25094
25220
|
return null;
|
|
25095
25221
|
try {
|
|
25096
25222
|
return JSON.parse(readFileSync26(path7, "utf-8"));
|
|
@@ -25102,9 +25228,9 @@ function getConfigPaths3() {
|
|
|
25102
25228
|
const cwd2 = process.cwd();
|
|
25103
25229
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
25104
25230
|
return {
|
|
25105
|
-
project:
|
|
25106
|
-
user:
|
|
25107
|
-
opencode:
|
|
25231
|
+
project: join47(cwd2, ".opencode", "oh-my-opencode.json"),
|
|
25232
|
+
user: join47(configDir, "oh-my-opencode.json"),
|
|
25233
|
+
opencode: join47(configDir, "opencode.json")
|
|
25108
25234
|
};
|
|
25109
25235
|
}
|
|
25110
25236
|
function loadAllConfigs() {
|
|
@@ -25217,7 +25343,7 @@ function isServerInstalled(command) {
|
|
|
25217
25343
|
return false;
|
|
25218
25344
|
const cmd = command[0];
|
|
25219
25345
|
if (cmd.includes("/") || cmd.includes("\\")) {
|
|
25220
|
-
if (
|
|
25346
|
+
if (existsSync38(cmd))
|
|
25221
25347
|
return true;
|
|
25222
25348
|
}
|
|
25223
25349
|
const isWindows2 = process.platform === "win32";
|
|
@@ -25239,23 +25365,23 @@ function isServerInstalled(command) {
|
|
|
25239
25365
|
const paths = pathEnv.split(pathSeparator);
|
|
25240
25366
|
for (const p of paths) {
|
|
25241
25367
|
for (const suffix of exts) {
|
|
25242
|
-
if (
|
|
25368
|
+
if (existsSync38(join47(p, cmd + suffix))) {
|
|
25243
25369
|
return true;
|
|
25244
25370
|
}
|
|
25245
25371
|
}
|
|
25246
25372
|
}
|
|
25247
25373
|
const cwd2 = process.cwd();
|
|
25248
25374
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
25249
|
-
const dataDir =
|
|
25375
|
+
const dataDir = join47(getDataDir(), "opencode");
|
|
25250
25376
|
const additionalBases = [
|
|
25251
|
-
|
|
25252
|
-
|
|
25253
|
-
|
|
25254
|
-
|
|
25377
|
+
join47(cwd2, "node_modules", ".bin"),
|
|
25378
|
+
join47(configDir, "bin"),
|
|
25379
|
+
join47(configDir, "node_modules", ".bin"),
|
|
25380
|
+
join47(dataDir, "bin")
|
|
25255
25381
|
];
|
|
25256
25382
|
for (const base of additionalBases) {
|
|
25257
25383
|
for (const suffix of exts) {
|
|
25258
|
-
if (
|
|
25384
|
+
if (existsSync38(join47(base, cmd + suffix))) {
|
|
25259
25385
|
return true;
|
|
25260
25386
|
}
|
|
25261
25387
|
}
|
|
@@ -25807,17 +25933,17 @@ ${msg}`);
|
|
|
25807
25933
|
// src/tools/lsp/utils.ts
|
|
25808
25934
|
import { extname as extname2, resolve as resolve9 } from "path";
|
|
25809
25935
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
25810
|
-
import { existsSync as
|
|
25936
|
+
import { existsSync as existsSync39, readFileSync as readFileSync28, writeFileSync as writeFileSync16 } from "fs";
|
|
25811
25937
|
function findWorkspaceRoot(filePath) {
|
|
25812
25938
|
let dir = resolve9(filePath);
|
|
25813
|
-
if (!
|
|
25939
|
+
if (!existsSync39(dir) || !__require("fs").statSync(dir).isDirectory()) {
|
|
25814
25940
|
dir = __require("path").dirname(dir);
|
|
25815
25941
|
}
|
|
25816
25942
|
const markers = [".git", "package.json", "pyproject.toml", "Cargo.toml", "go.mod", "pom.xml", "build.gradle"];
|
|
25817
25943
|
let prevDir = "";
|
|
25818
25944
|
while (dir !== prevDir) {
|
|
25819
25945
|
for (const marker of markers) {
|
|
25820
|
-
if (
|
|
25946
|
+
if (existsSync39(__require("path").join(dir, marker))) {
|
|
25821
25947
|
return dir;
|
|
25822
25948
|
}
|
|
25823
25949
|
}
|
|
@@ -38618,13 +38744,13 @@ var lsp_rename = tool({
|
|
|
38618
38744
|
});
|
|
38619
38745
|
// src/tools/ast-grep/constants.ts
|
|
38620
38746
|
import { createRequire as createRequire4 } from "module";
|
|
38621
|
-
import { dirname as dirname10, join as
|
|
38622
|
-
import { existsSync as
|
|
38747
|
+
import { dirname as dirname10, join as join49 } from "path";
|
|
38748
|
+
import { existsSync as existsSync41, statSync as statSync4 } from "fs";
|
|
38623
38749
|
|
|
38624
38750
|
// src/tools/ast-grep/downloader.ts
|
|
38625
38751
|
init_shared();
|
|
38626
|
-
import { existsSync as
|
|
38627
|
-
import { join as
|
|
38752
|
+
import { existsSync as existsSync40, mkdirSync as mkdirSync13, chmodSync as chmodSync2, unlinkSync as unlinkSync10 } from "fs";
|
|
38753
|
+
import { join as join48 } from "path";
|
|
38628
38754
|
import { homedir as homedir12 } from "os";
|
|
38629
38755
|
import { createRequire as createRequire3 } from "module";
|
|
38630
38756
|
var REPO2 = "ast-grep/ast-grep";
|
|
@@ -38650,19 +38776,19 @@ var PLATFORM_MAP2 = {
|
|
|
38650
38776
|
function getCacheDir3() {
|
|
38651
38777
|
if (process.platform === "win32") {
|
|
38652
38778
|
const localAppData = process.env.LOCALAPPDATA || process.env.APPDATA;
|
|
38653
|
-
const base2 = localAppData ||
|
|
38654
|
-
return
|
|
38779
|
+
const base2 = localAppData || join48(homedir12(), "AppData", "Local");
|
|
38780
|
+
return join48(base2, "oh-my-opencode", "bin");
|
|
38655
38781
|
}
|
|
38656
38782
|
const xdgCache = process.env.XDG_CACHE_HOME;
|
|
38657
|
-
const base = xdgCache ||
|
|
38658
|
-
return
|
|
38783
|
+
const base = xdgCache || join48(homedir12(), ".cache");
|
|
38784
|
+
return join48(base, "oh-my-opencode", "bin");
|
|
38659
38785
|
}
|
|
38660
38786
|
function getBinaryName3() {
|
|
38661
38787
|
return process.platform === "win32" ? "sg.exe" : "sg";
|
|
38662
38788
|
}
|
|
38663
38789
|
function getCachedBinaryPath2() {
|
|
38664
|
-
const binaryPath =
|
|
38665
|
-
return
|
|
38790
|
+
const binaryPath = join48(getCacheDir3(), getBinaryName3());
|
|
38791
|
+
return existsSync40(binaryPath) ? binaryPath : null;
|
|
38666
38792
|
}
|
|
38667
38793
|
async function downloadAstGrep(version2 = DEFAULT_VERSION) {
|
|
38668
38794
|
const platformKey = `${process.platform}-${process.arch}`;
|
|
@@ -38673,8 +38799,8 @@ async function downloadAstGrep(version2 = DEFAULT_VERSION) {
|
|
|
38673
38799
|
}
|
|
38674
38800
|
const cacheDir = getCacheDir3();
|
|
38675
38801
|
const binaryName = getBinaryName3();
|
|
38676
|
-
const binaryPath =
|
|
38677
|
-
if (
|
|
38802
|
+
const binaryPath = join48(cacheDir, binaryName);
|
|
38803
|
+
if (existsSync40(binaryPath)) {
|
|
38678
38804
|
return binaryPath;
|
|
38679
38805
|
}
|
|
38680
38806
|
const { arch, os: os6 } = platformInfo;
|
|
@@ -38682,21 +38808,21 @@ async function downloadAstGrep(version2 = DEFAULT_VERSION) {
|
|
|
38682
38808
|
const downloadUrl = `https://github.com/${REPO2}/releases/download/${version2}/${assetName}`;
|
|
38683
38809
|
console.log(`[oh-my-opencode] Downloading ast-grep binary...`);
|
|
38684
38810
|
try {
|
|
38685
|
-
if (!
|
|
38811
|
+
if (!existsSync40(cacheDir)) {
|
|
38686
38812
|
mkdirSync13(cacheDir, { recursive: true });
|
|
38687
38813
|
}
|
|
38688
38814
|
const response = await fetch(downloadUrl, { redirect: "follow" });
|
|
38689
38815
|
if (!response.ok) {
|
|
38690
38816
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
38691
38817
|
}
|
|
38692
|
-
const archivePath =
|
|
38818
|
+
const archivePath = join48(cacheDir, assetName);
|
|
38693
38819
|
const arrayBuffer = await response.arrayBuffer();
|
|
38694
38820
|
await Bun.write(archivePath, arrayBuffer);
|
|
38695
38821
|
await extractZip(archivePath, cacheDir);
|
|
38696
|
-
if (
|
|
38822
|
+
if (existsSync40(archivePath)) {
|
|
38697
38823
|
unlinkSync10(archivePath);
|
|
38698
38824
|
}
|
|
38699
|
-
if (process.platform !== "win32" &&
|
|
38825
|
+
if (process.platform !== "win32" && existsSync40(binaryPath)) {
|
|
38700
38826
|
chmodSync2(binaryPath, 493);
|
|
38701
38827
|
}
|
|
38702
38828
|
console.log(`[oh-my-opencode] ast-grep binary ready.`);
|
|
@@ -38747,8 +38873,8 @@ function findSgCliPathSync() {
|
|
|
38747
38873
|
const require2 = createRequire4(import.meta.url);
|
|
38748
38874
|
const cliPkgPath = require2.resolve("@ast-grep/cli/package.json");
|
|
38749
38875
|
const cliDir = dirname10(cliPkgPath);
|
|
38750
|
-
const sgPath =
|
|
38751
|
-
if (
|
|
38876
|
+
const sgPath = join49(cliDir, binaryName);
|
|
38877
|
+
if (existsSync41(sgPath) && isValidBinary(sgPath)) {
|
|
38752
38878
|
return sgPath;
|
|
38753
38879
|
}
|
|
38754
38880
|
} catch {}
|
|
@@ -38759,8 +38885,8 @@ function findSgCliPathSync() {
|
|
|
38759
38885
|
const pkgPath = require2.resolve(`${platformPkg}/package.json`);
|
|
38760
38886
|
const pkgDir = dirname10(pkgPath);
|
|
38761
38887
|
const astGrepName = process.platform === "win32" ? "ast-grep.exe" : "ast-grep";
|
|
38762
|
-
const binaryPath =
|
|
38763
|
-
if (
|
|
38888
|
+
const binaryPath = join49(pkgDir, astGrepName);
|
|
38889
|
+
if (existsSync41(binaryPath) && isValidBinary(binaryPath)) {
|
|
38764
38890
|
return binaryPath;
|
|
38765
38891
|
}
|
|
38766
38892
|
} catch {}
|
|
@@ -38768,7 +38894,7 @@ function findSgCliPathSync() {
|
|
|
38768
38894
|
if (process.platform === "darwin") {
|
|
38769
38895
|
const homebrewPaths = ["/opt/homebrew/bin/sg", "/usr/local/bin/sg"];
|
|
38770
38896
|
for (const path7 of homebrewPaths) {
|
|
38771
|
-
if (
|
|
38897
|
+
if (existsSync41(path7) && isValidBinary(path7)) {
|
|
38772
38898
|
return path7;
|
|
38773
38899
|
}
|
|
38774
38900
|
}
|
|
@@ -38823,11 +38949,11 @@ var DEFAULT_MAX_MATCHES = 500;
|
|
|
38823
38949
|
|
|
38824
38950
|
// src/tools/ast-grep/cli.ts
|
|
38825
38951
|
var {spawn: spawn7 } = globalThis.Bun;
|
|
38826
|
-
import { existsSync as
|
|
38952
|
+
import { existsSync as existsSync42 } from "fs";
|
|
38827
38953
|
var resolvedCliPath3 = null;
|
|
38828
38954
|
var initPromise2 = null;
|
|
38829
38955
|
async function getAstGrepPath() {
|
|
38830
|
-
if (resolvedCliPath3 !== null &&
|
|
38956
|
+
if (resolvedCliPath3 !== null && existsSync42(resolvedCliPath3)) {
|
|
38831
38957
|
return resolvedCliPath3;
|
|
38832
38958
|
}
|
|
38833
38959
|
if (initPromise2) {
|
|
@@ -38835,7 +38961,7 @@ async function getAstGrepPath() {
|
|
|
38835
38961
|
}
|
|
38836
38962
|
initPromise2 = (async () => {
|
|
38837
38963
|
const syncPath = findSgCliPathSync();
|
|
38838
|
-
if (syncPath &&
|
|
38964
|
+
if (syncPath && existsSync42(syncPath)) {
|
|
38839
38965
|
resolvedCliPath3 = syncPath;
|
|
38840
38966
|
setSgCliPath(syncPath);
|
|
38841
38967
|
return syncPath;
|
|
@@ -38869,7 +38995,7 @@ async function runSg(options) {
|
|
|
38869
38995
|
const paths = options.paths && options.paths.length > 0 ? options.paths : ["."];
|
|
38870
38996
|
args.push(...paths);
|
|
38871
38997
|
let cliPath = getSgCliPath();
|
|
38872
|
-
if (!
|
|
38998
|
+
if (!existsSync42(cliPath) && cliPath !== "sg") {
|
|
38873
38999
|
const downloadedPath = await getAstGrepPath();
|
|
38874
39000
|
if (downloadedPath) {
|
|
38875
39001
|
cliPath = downloadedPath;
|
|
@@ -39133,21 +39259,21 @@ var ast_grep_replace = tool({
|
|
|
39133
39259
|
var {spawn: spawn9 } = globalThis.Bun;
|
|
39134
39260
|
|
|
39135
39261
|
// src/tools/grep/constants.ts
|
|
39136
|
-
import { existsSync as
|
|
39137
|
-
import { join as
|
|
39262
|
+
import { existsSync as existsSync44 } from "fs";
|
|
39263
|
+
import { join as join51, dirname as dirname11 } from "path";
|
|
39138
39264
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
39139
39265
|
|
|
39140
39266
|
// src/tools/grep/downloader.ts
|
|
39141
39267
|
init_shared();
|
|
39142
|
-
import { existsSync as
|
|
39143
|
-
import { join as
|
|
39268
|
+
import { existsSync as existsSync43, mkdirSync as mkdirSync14, chmodSync as chmodSync3, unlinkSync as unlinkSync11, readdirSync as readdirSync13 } from "fs";
|
|
39269
|
+
import { join as join50 } from "path";
|
|
39144
39270
|
var {spawn: spawn8 } = globalThis.Bun;
|
|
39145
39271
|
function findFileRecursive(dir, filename) {
|
|
39146
39272
|
try {
|
|
39147
|
-
const entries =
|
|
39273
|
+
const entries = readdirSync13(dir, { withFileTypes: true, recursive: true });
|
|
39148
39274
|
for (const entry of entries) {
|
|
39149
39275
|
if (entry.isFile() && entry.name === filename) {
|
|
39150
|
-
return
|
|
39276
|
+
return join50(entry.parentPath ?? dir, entry.name);
|
|
39151
39277
|
}
|
|
39152
39278
|
}
|
|
39153
39279
|
} catch {
|
|
@@ -39168,11 +39294,11 @@ function getPlatformKey() {
|
|
|
39168
39294
|
}
|
|
39169
39295
|
function getInstallDir() {
|
|
39170
39296
|
const homeDir = process.env.HOME || process.env.USERPROFILE || ".";
|
|
39171
|
-
return
|
|
39297
|
+
return join50(homeDir, ".cache", "oh-my-opencode", "bin");
|
|
39172
39298
|
}
|
|
39173
39299
|
function getRgPath() {
|
|
39174
39300
|
const isWindows2 = process.platform === "win32";
|
|
39175
|
-
return
|
|
39301
|
+
return join50(getInstallDir(), isWindows2 ? "rg.exe" : "rg");
|
|
39176
39302
|
}
|
|
39177
39303
|
async function downloadFile(url2, destPath) {
|
|
39178
39304
|
const response = await fetch(url2);
|
|
@@ -39206,7 +39332,7 @@ async function extractZip2(archivePath, destDir) {
|
|
|
39206
39332
|
const binaryName = process.platform === "win32" ? "rg.exe" : "rg";
|
|
39207
39333
|
const foundPath = findFileRecursive(destDir, binaryName);
|
|
39208
39334
|
if (foundPath) {
|
|
39209
|
-
const destPath =
|
|
39335
|
+
const destPath = join50(destDir, binaryName);
|
|
39210
39336
|
if (foundPath !== destPath) {
|
|
39211
39337
|
const { renameSync } = await import("fs");
|
|
39212
39338
|
renameSync(foundPath, destPath);
|
|
@@ -39221,13 +39347,13 @@ async function downloadAndInstallRipgrep() {
|
|
|
39221
39347
|
}
|
|
39222
39348
|
const installDir = getInstallDir();
|
|
39223
39349
|
const rgPath = getRgPath();
|
|
39224
|
-
if (
|
|
39350
|
+
if (existsSync43(rgPath)) {
|
|
39225
39351
|
return rgPath;
|
|
39226
39352
|
}
|
|
39227
39353
|
mkdirSync14(installDir, { recursive: true });
|
|
39228
39354
|
const filename = `ripgrep-${RG_VERSION}-${config3.platform}.${config3.extension}`;
|
|
39229
39355
|
const url2 = `https://github.com/BurntSushi/ripgrep/releases/download/${RG_VERSION}/${filename}`;
|
|
39230
|
-
const archivePath =
|
|
39356
|
+
const archivePath = join50(installDir, filename);
|
|
39231
39357
|
try {
|
|
39232
39358
|
await downloadFile(url2, archivePath);
|
|
39233
39359
|
if (config3.extension === "tar.gz") {
|
|
@@ -39238,12 +39364,12 @@ async function downloadAndInstallRipgrep() {
|
|
|
39238
39364
|
if (process.platform !== "win32") {
|
|
39239
39365
|
chmodSync3(rgPath, 493);
|
|
39240
39366
|
}
|
|
39241
|
-
if (!
|
|
39367
|
+
if (!existsSync43(rgPath)) {
|
|
39242
39368
|
throw new Error("ripgrep binary not found after extraction");
|
|
39243
39369
|
}
|
|
39244
39370
|
return rgPath;
|
|
39245
39371
|
} finally {
|
|
39246
|
-
if (
|
|
39372
|
+
if (existsSync43(archivePath)) {
|
|
39247
39373
|
try {
|
|
39248
39374
|
unlinkSync11(archivePath);
|
|
39249
39375
|
} catch {}
|
|
@@ -39252,7 +39378,7 @@ async function downloadAndInstallRipgrep() {
|
|
|
39252
39378
|
}
|
|
39253
39379
|
function getInstalledRipgrepPath() {
|
|
39254
39380
|
const rgPath = getRgPath();
|
|
39255
|
-
return
|
|
39381
|
+
return existsSync43(rgPath) ? rgPath : null;
|
|
39256
39382
|
}
|
|
39257
39383
|
|
|
39258
39384
|
// src/tools/grep/constants.ts
|
|
@@ -39277,14 +39403,14 @@ function getOpenCodeBundledRg() {
|
|
|
39277
39403
|
const isWindows2 = process.platform === "win32";
|
|
39278
39404
|
const rgName = isWindows2 ? "rg.exe" : "rg";
|
|
39279
39405
|
const candidates = [
|
|
39280
|
-
|
|
39281
|
-
|
|
39282
|
-
|
|
39283
|
-
|
|
39284
|
-
|
|
39406
|
+
join51(getDataDir(), "opencode", "bin", rgName),
|
|
39407
|
+
join51(execDir, rgName),
|
|
39408
|
+
join51(execDir, "bin", rgName),
|
|
39409
|
+
join51(execDir, "..", "bin", rgName),
|
|
39410
|
+
join51(execDir, "..", "libexec", rgName)
|
|
39285
39411
|
];
|
|
39286
39412
|
for (const candidate of candidates) {
|
|
39287
|
-
if (
|
|
39413
|
+
if (existsSync44(candidate)) {
|
|
39288
39414
|
return candidate;
|
|
39289
39415
|
}
|
|
39290
39416
|
}
|
|
@@ -39746,8 +39872,8 @@ var glob = tool({
|
|
|
39746
39872
|
init_shared();
|
|
39747
39873
|
init_file_utils();
|
|
39748
39874
|
init_shared();
|
|
39749
|
-
import { existsSync as
|
|
39750
|
-
import { join as
|
|
39875
|
+
import { existsSync as existsSync45, readdirSync as readdirSync14, readFileSync as readFileSync29 } from "fs";
|
|
39876
|
+
import { join as join52, basename as basename4, dirname as dirname12 } from "path";
|
|
39751
39877
|
// src/features/builtin-commands/templates/init-deep.ts
|
|
39752
39878
|
var INIT_DEEP_TEMPLATE = `# /init-deep
|
|
39753
39879
|
|
|
@@ -40863,15 +40989,15 @@ function loadBuiltinCommands(disabledCommands) {
|
|
|
40863
40989
|
}
|
|
40864
40990
|
// src/tools/slashcommand/tools.ts
|
|
40865
40991
|
function discoverCommandsFromDir2(commandsDir, scope) {
|
|
40866
|
-
if (!
|
|
40992
|
+
if (!existsSync45(commandsDir)) {
|
|
40867
40993
|
return [];
|
|
40868
40994
|
}
|
|
40869
|
-
const entries =
|
|
40995
|
+
const entries = readdirSync14(commandsDir, { withFileTypes: true });
|
|
40870
40996
|
const commands2 = [];
|
|
40871
40997
|
for (const entry of entries) {
|
|
40872
40998
|
if (!isMarkdownFile(entry))
|
|
40873
40999
|
continue;
|
|
40874
|
-
const commandPath =
|
|
41000
|
+
const commandPath = join52(commandsDir, entry.name);
|
|
40875
41001
|
const commandName = basename4(entry.name, ".md");
|
|
40876
41002
|
try {
|
|
40877
41003
|
const content = readFileSync29(commandPath, "utf-8");
|
|
@@ -40900,10 +41026,10 @@ function discoverCommandsFromDir2(commandsDir, scope) {
|
|
|
40900
41026
|
}
|
|
40901
41027
|
function discoverCommandsSync() {
|
|
40902
41028
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
40903
|
-
const userCommandsDir =
|
|
40904
|
-
const projectCommandsDir =
|
|
40905
|
-
const opencodeGlobalDir =
|
|
40906
|
-
const opencodeProjectDir =
|
|
41029
|
+
const userCommandsDir = join52(getClaudeConfigDir(), "commands");
|
|
41030
|
+
const projectCommandsDir = join52(process.cwd(), ".claude", "commands");
|
|
41031
|
+
const opencodeGlobalDir = join52(configDir, "command");
|
|
41032
|
+
const opencodeProjectDir = join52(process.cwd(), ".opencode", "command");
|
|
40907
41033
|
const userCommands = discoverCommandsFromDir2(userCommandsDir, "user");
|
|
40908
41034
|
const opencodeGlobalCommands = discoverCommandsFromDir2(opencodeGlobalDir, "opencode");
|
|
40909
41035
|
const projectCommands = discoverCommandsFromDir2(projectCommandsDir, "project");
|
|
@@ -41080,13 +41206,13 @@ var slashcommand = createSlashcommandTool();
|
|
|
41080
41206
|
// src/tools/session-manager/constants.ts
|
|
41081
41207
|
init_data_path();
|
|
41082
41208
|
init_shared();
|
|
41083
|
-
import { join as
|
|
41209
|
+
import { join as join53 } from "path";
|
|
41084
41210
|
var OPENCODE_STORAGE9 = getOpenCodeStorageDir();
|
|
41085
|
-
var MESSAGE_STORAGE4 =
|
|
41086
|
-
var PART_STORAGE4 =
|
|
41087
|
-
var SESSION_STORAGE =
|
|
41088
|
-
var TODO_DIR2 =
|
|
41089
|
-
var TRANSCRIPT_DIR2 =
|
|
41211
|
+
var MESSAGE_STORAGE4 = join53(OPENCODE_STORAGE9, "message");
|
|
41212
|
+
var PART_STORAGE4 = join53(OPENCODE_STORAGE9, "part");
|
|
41213
|
+
var SESSION_STORAGE = join53(OPENCODE_STORAGE9, "session");
|
|
41214
|
+
var TODO_DIR2 = join53(getClaudeConfigDir(), "todos");
|
|
41215
|
+
var TRANSCRIPT_DIR2 = join53(getClaudeConfigDir(), "transcripts");
|
|
41090
41216
|
var SESSION_LIST_DESCRIPTION = `\u5217\u51FA\u6240\u6709 OpenCode session\uFF0C\u652F\u6301\u53EF\u9009\u8FC7\u6EE4\u3002
|
|
41091
41217
|
|
|
41092
41218
|
\u8FD4\u56DE\u53EF\u7528\u7684 session ID \u5217\u8868\uFF0C\u5305\u542B\u6D88\u606F\u6570\u91CF\u3001\u65E5\u671F\u8303\u56F4\u548C\u4F7F\u7528\u8FC7\u7684 agents \u7B49\u5143\u6570\u636E\u3002
|
|
@@ -41159,11 +41285,11 @@ Has Todos: Yes (12 items, 8 completed)
|
|
|
41159
41285
|
Has Transcript: Yes (234 entries)`;
|
|
41160
41286
|
|
|
41161
41287
|
// src/tools/session-manager/storage.ts
|
|
41162
|
-
import { existsSync as
|
|
41288
|
+
import { existsSync as existsSync46, readdirSync as readdirSync15 } from "fs";
|
|
41163
41289
|
import { readdir, readFile } from "fs/promises";
|
|
41164
|
-
import { join as
|
|
41290
|
+
import { join as join54 } from "path";
|
|
41165
41291
|
async function getMainSessions(options) {
|
|
41166
|
-
if (!
|
|
41292
|
+
if (!existsSync46(SESSION_STORAGE))
|
|
41167
41293
|
return [];
|
|
41168
41294
|
const sessions = [];
|
|
41169
41295
|
try {
|
|
@@ -41171,13 +41297,13 @@ async function getMainSessions(options) {
|
|
|
41171
41297
|
for (const projectDir of projectDirs) {
|
|
41172
41298
|
if (!projectDir.isDirectory())
|
|
41173
41299
|
continue;
|
|
41174
|
-
const projectPath =
|
|
41300
|
+
const projectPath = join54(SESSION_STORAGE, projectDir.name);
|
|
41175
41301
|
const sessionFiles = await readdir(projectPath);
|
|
41176
41302
|
for (const file2 of sessionFiles) {
|
|
41177
41303
|
if (!file2.endsWith(".json"))
|
|
41178
41304
|
continue;
|
|
41179
41305
|
try {
|
|
41180
|
-
const content = await readFile(
|
|
41306
|
+
const content = await readFile(join54(projectPath, file2), "utf-8");
|
|
41181
41307
|
const meta = JSON.parse(content);
|
|
41182
41308
|
if (meta.parentID)
|
|
41183
41309
|
continue;
|
|
@@ -41195,7 +41321,7 @@ async function getMainSessions(options) {
|
|
|
41195
41321
|
return sessions.sort((a, b) => b.time.updated - a.time.updated);
|
|
41196
41322
|
}
|
|
41197
41323
|
async function getAllSessions() {
|
|
41198
|
-
if (!
|
|
41324
|
+
if (!existsSync46(MESSAGE_STORAGE4))
|
|
41199
41325
|
return [];
|
|
41200
41326
|
const sessions = [];
|
|
41201
41327
|
async function scanDirectory(dir) {
|
|
@@ -41203,7 +41329,7 @@ async function getAllSessions() {
|
|
|
41203
41329
|
const entries = await readdir(dir, { withFileTypes: true });
|
|
41204
41330
|
for (const entry of entries) {
|
|
41205
41331
|
if (entry.isDirectory()) {
|
|
41206
|
-
const sessionPath =
|
|
41332
|
+
const sessionPath = join54(dir, entry.name);
|
|
41207
41333
|
const files = await readdir(sessionPath);
|
|
41208
41334
|
if (files.some((f) => f.endsWith(".json"))) {
|
|
41209
41335
|
sessions.push(entry.name);
|
|
@@ -41220,16 +41346,16 @@ async function getAllSessions() {
|
|
|
41220
41346
|
return [...new Set(sessions)];
|
|
41221
41347
|
}
|
|
41222
41348
|
function getMessageDir7(sessionID) {
|
|
41223
|
-
if (!
|
|
41349
|
+
if (!existsSync46(MESSAGE_STORAGE4))
|
|
41224
41350
|
return "";
|
|
41225
|
-
const directPath =
|
|
41226
|
-
if (
|
|
41351
|
+
const directPath = join54(MESSAGE_STORAGE4, sessionID);
|
|
41352
|
+
if (existsSync46(directPath)) {
|
|
41227
41353
|
return directPath;
|
|
41228
41354
|
}
|
|
41229
41355
|
try {
|
|
41230
|
-
for (const dir of
|
|
41231
|
-
const sessionPath =
|
|
41232
|
-
if (
|
|
41356
|
+
for (const dir of readdirSync15(MESSAGE_STORAGE4)) {
|
|
41357
|
+
const sessionPath = join54(MESSAGE_STORAGE4, dir, sessionID);
|
|
41358
|
+
if (existsSync46(sessionPath)) {
|
|
41233
41359
|
return sessionPath;
|
|
41234
41360
|
}
|
|
41235
41361
|
}
|
|
@@ -41243,7 +41369,7 @@ function sessionExists(sessionID) {
|
|
|
41243
41369
|
}
|
|
41244
41370
|
async function readSessionMessages(sessionID) {
|
|
41245
41371
|
const messageDir = getMessageDir7(sessionID);
|
|
41246
|
-
if (!messageDir || !
|
|
41372
|
+
if (!messageDir || !existsSync46(messageDir))
|
|
41247
41373
|
return [];
|
|
41248
41374
|
const messages = [];
|
|
41249
41375
|
try {
|
|
@@ -41252,7 +41378,7 @@ async function readSessionMessages(sessionID) {
|
|
|
41252
41378
|
if (!file2.endsWith(".json"))
|
|
41253
41379
|
continue;
|
|
41254
41380
|
try {
|
|
41255
|
-
const content = await readFile(
|
|
41381
|
+
const content = await readFile(join54(messageDir, file2), "utf-8");
|
|
41256
41382
|
const meta = JSON.parse(content);
|
|
41257
41383
|
const parts = await readParts2(meta.id);
|
|
41258
41384
|
messages.push({
|
|
@@ -41278,8 +41404,8 @@ async function readSessionMessages(sessionID) {
|
|
|
41278
41404
|
});
|
|
41279
41405
|
}
|
|
41280
41406
|
async function readParts2(messageID) {
|
|
41281
|
-
const partDir =
|
|
41282
|
-
if (!
|
|
41407
|
+
const partDir = join54(PART_STORAGE4, messageID);
|
|
41408
|
+
if (!existsSync46(partDir))
|
|
41283
41409
|
return [];
|
|
41284
41410
|
const parts = [];
|
|
41285
41411
|
try {
|
|
@@ -41288,7 +41414,7 @@ async function readParts2(messageID) {
|
|
|
41288
41414
|
if (!file2.endsWith(".json"))
|
|
41289
41415
|
continue;
|
|
41290
41416
|
try {
|
|
41291
|
-
const content = await readFile(
|
|
41417
|
+
const content = await readFile(join54(partDir, file2), "utf-8");
|
|
41292
41418
|
parts.push(JSON.parse(content));
|
|
41293
41419
|
} catch {
|
|
41294
41420
|
continue;
|
|
@@ -41300,14 +41426,14 @@ async function readParts2(messageID) {
|
|
|
41300
41426
|
return parts.sort((a, b) => a.id.localeCompare(b.id));
|
|
41301
41427
|
}
|
|
41302
41428
|
async function readSessionTodos(sessionID) {
|
|
41303
|
-
if (!
|
|
41429
|
+
if (!existsSync46(TODO_DIR2))
|
|
41304
41430
|
return [];
|
|
41305
41431
|
try {
|
|
41306
41432
|
const allFiles = await readdir(TODO_DIR2);
|
|
41307
41433
|
const todoFiles = allFiles.filter((f) => f.includes(sessionID) && f.endsWith(".json"));
|
|
41308
41434
|
for (const file2 of todoFiles) {
|
|
41309
41435
|
try {
|
|
41310
|
-
const content = await readFile(
|
|
41436
|
+
const content = await readFile(join54(TODO_DIR2, file2), "utf-8");
|
|
41311
41437
|
const data = JSON.parse(content);
|
|
41312
41438
|
if (Array.isArray(data)) {
|
|
41313
41439
|
return data.map((item) => ({
|
|
@@ -41327,10 +41453,10 @@ async function readSessionTodos(sessionID) {
|
|
|
41327
41453
|
return [];
|
|
41328
41454
|
}
|
|
41329
41455
|
async function readSessionTranscript(sessionID) {
|
|
41330
|
-
if (!
|
|
41456
|
+
if (!existsSync46(TRANSCRIPT_DIR2))
|
|
41331
41457
|
return 0;
|
|
41332
|
-
const transcriptFile =
|
|
41333
|
-
if (!
|
|
41458
|
+
const transcriptFile = join54(TRANSCRIPT_DIR2, `${sessionID}.jsonl`);
|
|
41459
|
+
if (!existsSync46(transcriptFile))
|
|
41334
41460
|
return 0;
|
|
41335
41461
|
try {
|
|
41336
41462
|
const content = await readFile(transcriptFile, "utf-8");
|
|
@@ -42532,19 +42658,19 @@ var CALL_OMO_AGENT_DESCRIPTION = `\u542F\u52A8 explore/librarian agent\u3002run_
|
|
|
42532
42658
|
|
|
42533
42659
|
\u4F20\u5165 \`session_id=<id>\` \u53EF\u7EE7\u7EED\u4E4B\u524D\u7684 agent\uFF0C\u4FDD\u7559\u5B8C\u6574\u4E0A\u4E0B\u6587\u3002Prompts \u5FC5\u987B\u4E3A\u4E2D\u6587\u3002\u4F7F\u7528 \`background_output\` \u83B7\u53D6\u5F02\u6B65\u7ED3\u679C\u3002`;
|
|
42534
42660
|
// src/tools/call-omo-agent/tools.ts
|
|
42535
|
-
import { existsSync as
|
|
42536
|
-
import { join as
|
|
42661
|
+
import { existsSync as existsSync47, readdirSync as readdirSync16 } from "fs";
|
|
42662
|
+
import { join as join55 } from "path";
|
|
42537
42663
|
init_shared();
|
|
42538
42664
|
init_session_cursor();
|
|
42539
42665
|
function getMessageDir8(sessionID) {
|
|
42540
|
-
if (!
|
|
42666
|
+
if (!existsSync47(MESSAGE_STORAGE))
|
|
42541
42667
|
return null;
|
|
42542
|
-
const directPath =
|
|
42543
|
-
if (
|
|
42668
|
+
const directPath = join55(MESSAGE_STORAGE, sessionID);
|
|
42669
|
+
if (existsSync47(directPath))
|
|
42544
42670
|
return directPath;
|
|
42545
|
-
for (const dir of
|
|
42546
|
-
const sessionPath =
|
|
42547
|
-
if (
|
|
42671
|
+
for (const dir of readdirSync16(MESSAGE_STORAGE)) {
|
|
42672
|
+
const sessionPath = join55(MESSAGE_STORAGE, dir, sessionID);
|
|
42673
|
+
if (existsSync47(sessionPath))
|
|
42548
42674
|
return sessionPath;
|
|
42549
42675
|
}
|
|
42550
42676
|
return null;
|
|
@@ -42953,14 +43079,17 @@ If the requested information is not found, clearly state what is missing.`;
|
|
|
42953
43079
|
}
|
|
42954
43080
|
// src/tools/delegate-task/tools.ts
|
|
42955
43081
|
init_constants2();
|
|
42956
|
-
import { existsSync as
|
|
42957
|
-
import { join as
|
|
43082
|
+
import { existsSync as existsSync48, readdirSync as readdirSync17 } from "fs";
|
|
43083
|
+
import { join as join56 } from "path";
|
|
42958
43084
|
|
|
42959
43085
|
// src/features/task-toast-manager/manager.ts
|
|
42960
43086
|
class TaskToastManager {
|
|
42961
43087
|
tasks = new Map;
|
|
42962
43088
|
client;
|
|
42963
43089
|
concurrencyManager;
|
|
43090
|
+
completionBatch = [];
|
|
43091
|
+
completionDebounceTimer;
|
|
43092
|
+
static COMPLETION_DEBOUNCE_MS = 800;
|
|
42964
43093
|
constructor(client2, concurrencyManager) {
|
|
42965
43094
|
this.client = client2;
|
|
42966
43095
|
this.concurrencyManager = concurrencyManager;
|
|
@@ -43072,13 +43201,36 @@ class TaskToastManager {
|
|
|
43072
43201
|
}).catch(() => {});
|
|
43073
43202
|
}
|
|
43074
43203
|
showCompletionToast(task) {
|
|
43204
|
+
this.removeTask(task.id);
|
|
43205
|
+
this.completionBatch.push(task);
|
|
43206
|
+
if (this.completionDebounceTimer) {
|
|
43207
|
+
clearTimeout(this.completionDebounceTimer);
|
|
43208
|
+
}
|
|
43209
|
+
this.completionDebounceTimer = setTimeout(() => {
|
|
43210
|
+
this.flushCompletionBatch();
|
|
43211
|
+
}, TaskToastManager.COMPLETION_DEBOUNCE_MS);
|
|
43212
|
+
}
|
|
43213
|
+
flushCompletionBatch() {
|
|
43075
43214
|
const tuiClient = this.client;
|
|
43076
|
-
if (!tuiClient.tui?.showToast)
|
|
43215
|
+
if (!tuiClient.tui?.showToast) {
|
|
43216
|
+
this.completionBatch = [];
|
|
43217
|
+
return;
|
|
43218
|
+
}
|
|
43219
|
+
const batch = [...this.completionBatch];
|
|
43220
|
+
this.completionBatch = [];
|
|
43221
|
+
if (batch.length === 0)
|
|
43077
43222
|
return;
|
|
43078
|
-
this.removeTask(task.id);
|
|
43079
43223
|
const remaining = this.getRunningTasks();
|
|
43080
43224
|
const queued = this.getQueuedTasks();
|
|
43081
|
-
let message
|
|
43225
|
+
let message;
|
|
43226
|
+
if (batch.length === 1) {
|
|
43227
|
+
message = `"${batch[0].description}" finished in ${batch[0].duration}`;
|
|
43228
|
+
} else {
|
|
43229
|
+
const lines = batch.map((t) => ` \u2713 "${t.description}" (${t.duration})`);
|
|
43230
|
+
message = `${batch.length} tasks completed:
|
|
43231
|
+
${lines.join(`
|
|
43232
|
+
`)}`;
|
|
43233
|
+
}
|
|
43082
43234
|
if (remaining.length > 0 || queued.length > 0) {
|
|
43083
43235
|
message += `
|
|
43084
43236
|
|
|
@@ -43086,12 +43238,13 @@ Still running: ${remaining.length} | Queued: ${queued.length}`;
|
|
|
43086
43238
|
}
|
|
43087
43239
|
tuiClient.tui.showToast({
|
|
43088
43240
|
body: {
|
|
43089
|
-
title: "Task Completed"
|
|
43241
|
+
title: batch.length === 1 ? "Task Completed" : `${batch.length} Tasks Completed`,
|
|
43090
43242
|
message,
|
|
43091
43243
|
variant: "success",
|
|
43092
|
-
duration: 5000
|
|
43244
|
+
duration: batch.length > 1 ? 7000 : 5000
|
|
43093
43245
|
}
|
|
43094
43246
|
}).catch(() => {});
|
|
43247
|
+
this.completionDebounceTimer = undefined;
|
|
43095
43248
|
}
|
|
43096
43249
|
}
|
|
43097
43250
|
var instance = null;
|
|
@@ -43113,14 +43266,14 @@ function parseModelString(model) {
|
|
|
43113
43266
|
return;
|
|
43114
43267
|
}
|
|
43115
43268
|
function getMessageDir9(sessionID) {
|
|
43116
|
-
if (!
|
|
43269
|
+
if (!existsSync48(MESSAGE_STORAGE))
|
|
43117
43270
|
return null;
|
|
43118
|
-
const directPath =
|
|
43119
|
-
if (
|
|
43271
|
+
const directPath = join56(MESSAGE_STORAGE, sessionID);
|
|
43272
|
+
if (existsSync48(directPath))
|
|
43120
43273
|
return directPath;
|
|
43121
|
-
for (const dir of
|
|
43122
|
-
const sessionPath =
|
|
43123
|
-
if (
|
|
43274
|
+
for (const dir of readdirSync17(MESSAGE_STORAGE)) {
|
|
43275
|
+
const sessionPath = join56(MESSAGE_STORAGE, dir, sessionID);
|
|
43276
|
+
if (existsSync48(sessionPath))
|
|
43124
43277
|
return sessionPath;
|
|
43125
43278
|
}
|
|
43126
43279
|
return null;
|
|
@@ -43948,12 +44101,14 @@ class PerformanceAggregator {
|
|
|
43948
44101
|
}
|
|
43949
44102
|
|
|
43950
44103
|
// src/features/background-agent/manager.ts
|
|
43951
|
-
import { existsSync as
|
|
43952
|
-
import { join as
|
|
44104
|
+
import { existsSync as existsSync49, readdirSync as readdirSync18 } from "fs";
|
|
44105
|
+
import { join as join57 } from "path";
|
|
43953
44106
|
var TASK_TTL_MS = 30 * 60 * 1000;
|
|
43954
44107
|
var MIN_STABILITY_TIME_MS = 10 * 1000;
|
|
43955
|
-
var DEFAULT_STALE_TIMEOUT_MS =
|
|
44108
|
+
var DEFAULT_STALE_TIMEOUT_MS = 120000;
|
|
43956
44109
|
var MIN_RUNTIME_BEFORE_STALE_MS = 30000;
|
|
44110
|
+
var STEP_TIMEOUT_MS = 600000;
|
|
44111
|
+
var MIN_IDLE_TIME_MS = 15000;
|
|
43957
44112
|
|
|
43958
44113
|
class BackgroundManager {
|
|
43959
44114
|
static cleanupManagers = new Set;
|
|
@@ -44006,7 +44161,11 @@ class BackgroundManager {
|
|
|
44006
44161
|
parentMessageID: input.parentMessageID,
|
|
44007
44162
|
parentModel: input.parentModel,
|
|
44008
44163
|
parentAgent: input.parentAgent,
|
|
44009
|
-
model: input.model
|
|
44164
|
+
model: input.model,
|
|
44165
|
+
maxSteps: this.config?.maxSteps,
|
|
44166
|
+
maxRuntimeMs: this.config?.maxRuntimeMs,
|
|
44167
|
+
stepTimeoutMs: this.config?.stepTimeoutMs ?? STEP_TIMEOUT_MS,
|
|
44168
|
+
stepCount: 0
|
|
44010
44169
|
};
|
|
44011
44170
|
this.tasks.set(task.id, task);
|
|
44012
44171
|
if (input.parentSessionID) {
|
|
@@ -44098,7 +44257,8 @@ class BackgroundManager {
|
|
|
44098
44257
|
task.sessionID = sessionID;
|
|
44099
44258
|
task.progress = {
|
|
44100
44259
|
toolCalls: 0,
|
|
44101
|
-
lastUpdate: new Date
|
|
44260
|
+
lastUpdate: new Date,
|
|
44261
|
+
stepStartedAt: Date.now()
|
|
44102
44262
|
};
|
|
44103
44263
|
task.concurrencyKey = concurrencyKey;
|
|
44104
44264
|
task.concurrencyGroup = concurrencyKey;
|
|
@@ -44238,7 +44398,11 @@ class BackgroundManager {
|
|
|
44238
44398
|
},
|
|
44239
44399
|
parentAgent: input.parentAgent,
|
|
44240
44400
|
concurrencyKey: input.concurrencyKey,
|
|
44241
|
-
concurrencyGroup
|
|
44401
|
+
concurrencyGroup,
|
|
44402
|
+
maxSteps: this.config?.maxSteps,
|
|
44403
|
+
maxRuntimeMs: this.config?.maxRuntimeMs,
|
|
44404
|
+
stepTimeoutMs: this.config?.stepTimeoutMs ?? STEP_TIMEOUT_MS,
|
|
44405
|
+
stepCount: 0
|
|
44242
44406
|
};
|
|
44243
44407
|
this.tasks.set(task.id, task);
|
|
44244
44408
|
subagentSessions.add(input.sessionID);
|
|
@@ -44278,12 +44442,14 @@ class BackgroundManager {
|
|
|
44278
44442
|
existingTask.parentModel = input.parentModel;
|
|
44279
44443
|
existingTask.parentAgent = input.parentAgent;
|
|
44280
44444
|
existingTask.startedAt = new Date;
|
|
44445
|
+
existingTask.stepCount = 0;
|
|
44281
44446
|
if (existingTask.progress) {
|
|
44282
44447
|
existingTask.progress.phaseTiming = undefined;
|
|
44283
44448
|
}
|
|
44284
44449
|
existingTask.progress = {
|
|
44285
44450
|
toolCalls: existingTask.progress?.toolCalls ?? 0,
|
|
44286
|
-
lastUpdate: new Date
|
|
44451
|
+
lastUpdate: new Date,
|
|
44452
|
+
stepStartedAt: Date.now()
|
|
44287
44453
|
};
|
|
44288
44454
|
this.startPolling();
|
|
44289
44455
|
if (existingTask.sessionID) {
|
|
@@ -44385,11 +44551,20 @@ class BackgroundManager {
|
|
|
44385
44551
|
const task = this.findBySession(sessionID);
|
|
44386
44552
|
if (!task || task.status !== "running")
|
|
44387
44553
|
return;
|
|
44554
|
+
task.stepCount = (task.stepCount ?? 0) + 1;
|
|
44555
|
+
if (task.progress) {
|
|
44556
|
+
task.progress.stepStartedAt = Date.now();
|
|
44557
|
+
}
|
|
44558
|
+
if (this.isStepLimitExceeded(task)) {
|
|
44559
|
+
this.tryCompleteTask(task, `step limit (${task.maxSteps} steps)`).catch((err) => {
|
|
44560
|
+
log("[background-agent] Error completing task on step limit:", err);
|
|
44561
|
+
});
|
|
44562
|
+
return;
|
|
44563
|
+
}
|
|
44388
44564
|
const startedAt = task.startedAt;
|
|
44389
44565
|
if (!startedAt)
|
|
44390
44566
|
return;
|
|
44391
44567
|
const elapsedMs = Date.now() - startedAt.getTime();
|
|
44392
|
-
const MIN_IDLE_TIME_MS = 5000;
|
|
44393
44568
|
if (elapsedMs < MIN_IDLE_TIME_MS) {
|
|
44394
44569
|
log("[background-agent] Ignoring early session.idle, elapsed:", { elapsedMs, taskId: task.id });
|
|
44395
44570
|
return;
|
|
@@ -44776,6 +44951,41 @@ ${perfSnapshot ? `| \u6392\u961F ${PerfTimer.formatDuration(new Date(0), new Dat
|
|
|
44776
44951
|
const runtime = now - startedAt.getTime();
|
|
44777
44952
|
if (runtime < MIN_RUNTIME_BEFORE_STALE_MS)
|
|
44778
44953
|
continue;
|
|
44954
|
+
if (this.isRuntimeLimitExceeded(task)) {
|
|
44955
|
+
task.status = "cancelled";
|
|
44956
|
+
task.error = `Runtime limit exceeded (${Math.round(runtime / 60000)}min)`;
|
|
44957
|
+
task.completedAt = new Date;
|
|
44958
|
+
if (task.concurrencyKey) {
|
|
44959
|
+
this.concurrencyManager.release(task.concurrencyKey);
|
|
44960
|
+
task.concurrencyKey = undefined;
|
|
44961
|
+
}
|
|
44962
|
+
this.client.session.abort({ path: { id: sessionID } }).catch(() => {});
|
|
44963
|
+
log(`[background-agent] Task ${task.id} interrupted: runtime limit`);
|
|
44964
|
+
try {
|
|
44965
|
+
await this.notifyParentSession(task);
|
|
44966
|
+
} catch (err) {
|
|
44967
|
+
log("[background-agent] Error in notifyParentSession for runtime-limit task:", { taskId: task.id, error: err });
|
|
44968
|
+
}
|
|
44969
|
+
continue;
|
|
44970
|
+
}
|
|
44971
|
+
if (this.isStepTimeoutExceeded(task)) {
|
|
44972
|
+
const stepTimeoutMs = task.stepTimeoutMs ?? STEP_TIMEOUT_MS;
|
|
44973
|
+
task.status = "cancelled";
|
|
44974
|
+
task.error = `Step timeout exceeded (single step > ${Math.round(stepTimeoutMs / 60000)}min)`;
|
|
44975
|
+
task.completedAt = new Date;
|
|
44976
|
+
if (task.concurrencyKey) {
|
|
44977
|
+
this.concurrencyManager.release(task.concurrencyKey);
|
|
44978
|
+
task.concurrencyKey = undefined;
|
|
44979
|
+
}
|
|
44980
|
+
this.client.session.abort({ path: { id: sessionID } }).catch(() => {});
|
|
44981
|
+
log(`[background-agent] Task ${task.id} interrupted: step timeout`);
|
|
44982
|
+
try {
|
|
44983
|
+
await this.notifyParentSession(task);
|
|
44984
|
+
} catch (err) {
|
|
44985
|
+
log("[background-agent] Error in notifyParentSession for step-timeout task:", { taskId: task.id, error: err });
|
|
44986
|
+
}
|
|
44987
|
+
continue;
|
|
44988
|
+
}
|
|
44779
44989
|
const timeSinceLastUpdate = now - task.progress.lastUpdate.getTime();
|
|
44780
44990
|
if (timeSinceLastUpdate <= staleTimeoutMs)
|
|
44781
44991
|
continue;
|
|
@@ -44800,6 +45010,30 @@ ${perfSnapshot ? `| \u6392\u961F ${PerfTimer.formatDuration(new Date(0), new Dat
|
|
|
44800
45010
|
}
|
|
44801
45011
|
}
|
|
44802
45012
|
}
|
|
45013
|
+
isStepLimitExceeded(task) {
|
|
45014
|
+
const maxSteps = task.maxSteps;
|
|
45015
|
+
if (!maxSteps || maxSteps <= 0)
|
|
45016
|
+
return false;
|
|
45017
|
+
return (task.stepCount ?? 0) >= maxSteps;
|
|
45018
|
+
}
|
|
45019
|
+
isRuntimeLimitExceeded(task) {
|
|
45020
|
+
const maxRuntimeMs = task.maxRuntimeMs;
|
|
45021
|
+
if (!maxRuntimeMs || maxRuntimeMs <= 0)
|
|
45022
|
+
return false;
|
|
45023
|
+
if (!task.startedAt)
|
|
45024
|
+
return false;
|
|
45025
|
+
const runtime = Date.now() - task.startedAt.getTime();
|
|
45026
|
+
return runtime >= maxRuntimeMs;
|
|
45027
|
+
}
|
|
45028
|
+
isStepTimeoutExceeded(task) {
|
|
45029
|
+
const stepTimeoutMs = task.stepTimeoutMs;
|
|
45030
|
+
if (!stepTimeoutMs || stepTimeoutMs <= 0)
|
|
45031
|
+
return false;
|
|
45032
|
+
if (!task.progress?.stepStartedAt)
|
|
45033
|
+
return false;
|
|
45034
|
+
const stepDuration = Date.now() - task.progress.stepStartedAt;
|
|
45035
|
+
return stepDuration >= stepTimeoutMs;
|
|
45036
|
+
}
|
|
44803
45037
|
async pollRunningTasks() {
|
|
44804
45038
|
const start = this.perfTracer?.isEnabled() ? performance.now() : undefined;
|
|
44805
45039
|
try {
|
|
@@ -44828,6 +45062,10 @@ ${perfSnapshot ? `| \u6392\u961F ${PerfTimer.formatDuration(new Date(0), new Dat
|
|
|
44828
45062
|
log("[background-agent] Task has incomplete todos via polling, waiting:", task.id);
|
|
44829
45063
|
continue;
|
|
44830
45064
|
}
|
|
45065
|
+
if (this.isStepLimitExceeded(task)) {
|
|
45066
|
+
await this.tryCompleteTask(task, `step limit via polling (${task.maxSteps} steps)`);
|
|
45067
|
+
continue;
|
|
45068
|
+
}
|
|
44831
45069
|
await this.tryCompleteTask(task, "polling (idle status)");
|
|
44832
45070
|
continue;
|
|
44833
45071
|
}
|
|
@@ -44900,6 +45138,10 @@ ${perfSnapshot ? `| \u6392\u961F ${PerfTimer.formatDuration(new Date(0), new Dat
|
|
|
44900
45138
|
}
|
|
44901
45139
|
if (task.status !== "running")
|
|
44902
45140
|
continue;
|
|
45141
|
+
if (this.isStepLimitExceeded(task)) {
|
|
45142
|
+
await this.tryCompleteTask(task, `step limit via stability (${task.maxSteps} steps)`);
|
|
45143
|
+
continue;
|
|
45144
|
+
}
|
|
44903
45145
|
const hasIncompleteTodos2 = await this.checkSessionTodos(sessionID);
|
|
44904
45146
|
if (!hasIncompleteTodos2) {
|
|
44905
45147
|
await this.tryCompleteTask(task, "stability detection");
|
|
@@ -44964,14 +45206,14 @@ function registerProcessSignal(signal, handler, exitAfter) {
|
|
|
44964
45206
|
return listener;
|
|
44965
45207
|
}
|
|
44966
45208
|
function getMessageDir10(sessionID) {
|
|
44967
|
-
if (!
|
|
45209
|
+
if (!existsSync49(MESSAGE_STORAGE))
|
|
44968
45210
|
return null;
|
|
44969
|
-
const directPath =
|
|
44970
|
-
if (
|
|
45211
|
+
const directPath = join57(MESSAGE_STORAGE, sessionID);
|
|
45212
|
+
if (existsSync49(directPath))
|
|
44971
45213
|
return directPath;
|
|
44972
|
-
for (const dir of
|
|
44973
|
-
const sessionPath =
|
|
44974
|
-
if (
|
|
45214
|
+
for (const dir of readdirSync18(MESSAGE_STORAGE)) {
|
|
45215
|
+
const sessionPath = join57(MESSAGE_STORAGE, dir, sessionID);
|
|
45216
|
+
if (existsSync49(sessionPath))
|
|
44975
45217
|
return sessionPath;
|
|
44976
45218
|
}
|
|
44977
45219
|
return null;
|
|
@@ -63058,7 +63300,10 @@ var BackgroundTaskConfigSchema = exports_external2.object({
|
|
|
63058
63300
|
defaultConcurrency: exports_external2.number().min(1).optional(),
|
|
63059
63301
|
providerConcurrency: exports_external2.record(exports_external2.string(), exports_external2.number().min(0)).optional(),
|
|
63060
63302
|
modelConcurrency: exports_external2.record(exports_external2.string(), exports_external2.number().min(0)).optional(),
|
|
63061
|
-
staleTimeoutMs: exports_external2.number().min(60000).optional()
|
|
63303
|
+
staleTimeoutMs: exports_external2.number().min(60000).optional(),
|
|
63304
|
+
maxSteps: exports_external2.number().min(0).optional(),
|
|
63305
|
+
maxRuntimeMs: exports_external2.number().min(0).optional(),
|
|
63306
|
+
stepTimeoutMs: exports_external2.number().min(0).optional()
|
|
63062
63307
|
});
|
|
63063
63308
|
var NotificationConfigSchema = exports_external2.object({
|
|
63064
63309
|
force_enable: exports_external2.boolean().optional()
|
|
@@ -65153,21 +65398,21 @@ TODO \u5217\u8868\uFF1A[\u8DEF\u5F84]
|
|
|
65153
65398
|
|
|
65154
65399
|
**\u5BF9\u4E8E\u63A2\u7D22\uFF08explore/librarian\uFF09**\uFF1A\u59CB\u7EC8\u540E\u53F0\u8FD0\u884C
|
|
65155
65400
|
\`\`\`typescript
|
|
65156
|
-
delegate_task(subagent_type="explore", run_in_background=true, ...)
|
|
65157
|
-
delegate_task(subagent_type="librarian", run_in_background=true, ...)
|
|
65401
|
+
delegate_task(subagent_type="explore", run_in_background=true, load_skills=[], ...)
|
|
65402
|
+
delegate_task(subagent_type="librarian", run_in_background=true, load_skills=[], ...)
|
|
65158
65403
|
\`\`\`
|
|
65159
65404
|
|
|
65160
65405
|
**\u5BF9\u4E8E\u4EFB\u52A1\u6267\u884C**\uFF1A\u7EDD\u4E0D\u7528\u540E\u53F0\u8FD0\u884C
|
|
65161
65406
|
\`\`\`typescript
|
|
65162
|
-
delegate_task(category="...", run_in_background=false, ...)
|
|
65407
|
+
delegate_task(category="...", run_in_background=false, load_skills=[], ...)
|
|
65163
65408
|
\`\`\`
|
|
65164
65409
|
|
|
65165
65410
|
**\u5E76\u884C\u4EFB\u52A1\u7EC4**\uFF1A\u5728\u4E00\u6761\u6D88\u606F\u4E2D\u591A\u6B21\u8C03\u7528
|
|
65166
65411
|
\`\`\`typescript
|
|
65167
65412
|
// \u4EFB\u52A12\u30013\u30014\u662F\u72EC\u7ACB\u7684\u2014\u2014\u4E00\u8D77\u8C03\u7528
|
|
65168
|
-
delegate_task(category="quick", prompt="\u4EFB\u52A12...")
|
|
65169
|
-
delegate_task(category="quick", prompt="\u4EFB\u52A13...")
|
|
65170
|
-
delegate_task(category="quick", prompt="\u4EFB\u52A14...")
|
|
65413
|
+
delegate_task(category="quick", prompt="\u4EFB\u52A12...", load_skills=[])
|
|
65414
|
+
delegate_task(category="quick", prompt="\u4EFB\u52A13...", load_skills=[])
|
|
65415
|
+
delegate_task(category="quick", prompt="\u4EFB\u52A14...", load_skills=[])
|
|
65171
65416
|
\`\`\`
|
|
65172
65417
|
|
|
65173
65418
|
**\u540E\u53F0\u7BA1\u7406**\uFF1A
|
|
@@ -66042,7 +66287,7 @@ init_file_utils();
|
|
|
66042
66287
|
init_shared();
|
|
66043
66288
|
init_logger();
|
|
66044
66289
|
import { promises as fs11 } from "fs";
|
|
66045
|
-
import { join as
|
|
66290
|
+
import { join as join59, basename as basename6 } from "path";
|
|
66046
66291
|
async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix = "") {
|
|
66047
66292
|
try {
|
|
66048
66293
|
await fs11.access(commandsDir);
|
|
@@ -66072,7 +66317,7 @@ async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix
|
|
|
66072
66317
|
if (entry.isDirectory()) {
|
|
66073
66318
|
if (entry.name.startsWith("."))
|
|
66074
66319
|
continue;
|
|
66075
|
-
const subDirPath =
|
|
66320
|
+
const subDirPath = join59(commandsDir, entry.name);
|
|
66076
66321
|
const subPrefix = prefix ? `${prefix}:${entry.name}` : entry.name;
|
|
66077
66322
|
const subCommands = await loadCommandsFromDir(subDirPath, scope, visited, subPrefix);
|
|
66078
66323
|
commands2.push(...subCommands);
|
|
@@ -66080,7 +66325,7 @@ async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix
|
|
|
66080
66325
|
}
|
|
66081
66326
|
if (!isMarkdownFile(entry))
|
|
66082
66327
|
continue;
|
|
66083
|
-
const commandPath =
|
|
66328
|
+
const commandPath = join59(commandsDir, entry.name);
|
|
66084
66329
|
const baseCommandName = basename6(entry.name, ".md");
|
|
66085
66330
|
const commandName = prefix ? `${prefix}:${baseCommandName}` : baseCommandName;
|
|
66086
66331
|
try {
|
|
@@ -66127,23 +66372,23 @@ function commandsToRecord(commands2) {
|
|
|
66127
66372
|
return result;
|
|
66128
66373
|
}
|
|
66129
66374
|
async function loadUserCommands() {
|
|
66130
|
-
const userCommandsDir =
|
|
66375
|
+
const userCommandsDir = join59(getClaudeConfigDir(), "commands");
|
|
66131
66376
|
const commands2 = await loadCommandsFromDir(userCommandsDir, "user");
|
|
66132
66377
|
return commandsToRecord(commands2);
|
|
66133
66378
|
}
|
|
66134
66379
|
async function loadProjectCommands() {
|
|
66135
|
-
const projectCommandsDir =
|
|
66380
|
+
const projectCommandsDir = join59(process.cwd(), ".claude", "commands");
|
|
66136
66381
|
const commands2 = await loadCommandsFromDir(projectCommandsDir, "project");
|
|
66137
66382
|
return commandsToRecord(commands2);
|
|
66138
66383
|
}
|
|
66139
66384
|
async function loadOpencodeGlobalCommands() {
|
|
66140
66385
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
66141
|
-
const opencodeCommandsDir =
|
|
66386
|
+
const opencodeCommandsDir = join59(configDir, "command");
|
|
66142
66387
|
const commands2 = await loadCommandsFromDir(opencodeCommandsDir, "opencode");
|
|
66143
66388
|
return commandsToRecord(commands2);
|
|
66144
66389
|
}
|
|
66145
66390
|
async function loadOpencodeProjectCommands() {
|
|
66146
|
-
const opencodeProjectDir =
|
|
66391
|
+
const opencodeProjectDir = join59(process.cwd(), ".opencode", "command");
|
|
66147
66392
|
const commands2 = await loadCommandsFromDir(opencodeProjectDir, "opencode-project");
|
|
66148
66393
|
return commandsToRecord(commands2);
|
|
66149
66394
|
}
|
|
@@ -66151,8 +66396,8 @@ async function loadOpencodeProjectCommands() {
|
|
|
66151
66396
|
init_frontmatter();
|
|
66152
66397
|
init_file_utils();
|
|
66153
66398
|
init_shared();
|
|
66154
|
-
import { existsSync as
|
|
66155
|
-
import { join as
|
|
66399
|
+
import { existsSync as existsSync51, readdirSync as readdirSync19, readFileSync as readFileSync31 } from "fs";
|
|
66400
|
+
import { join as join60, basename as basename7 } from "path";
|
|
66156
66401
|
function parseToolsConfig(toolsStr) {
|
|
66157
66402
|
if (!toolsStr)
|
|
66158
66403
|
return;
|
|
@@ -66166,15 +66411,15 @@ function parseToolsConfig(toolsStr) {
|
|
|
66166
66411
|
return result;
|
|
66167
66412
|
}
|
|
66168
66413
|
function loadAgentsFromDir(agentsDir, scope) {
|
|
66169
|
-
if (!
|
|
66414
|
+
if (!existsSync51(agentsDir)) {
|
|
66170
66415
|
return [];
|
|
66171
66416
|
}
|
|
66172
|
-
const entries =
|
|
66417
|
+
const entries = readdirSync19(agentsDir, { withFileTypes: true });
|
|
66173
66418
|
const agents = [];
|
|
66174
66419
|
for (const entry of entries) {
|
|
66175
66420
|
if (!isMarkdownFile(entry))
|
|
66176
66421
|
continue;
|
|
66177
|
-
const agentPath =
|
|
66422
|
+
const agentPath = join60(agentsDir, entry.name);
|
|
66178
66423
|
const agentName = basename7(entry.name, ".md");
|
|
66179
66424
|
try {
|
|
66180
66425
|
const content = readFileSync31(agentPath, "utf-8");
|
|
@@ -66204,7 +66449,7 @@ function loadAgentsFromDir(agentsDir, scope) {
|
|
|
66204
66449
|
return agents;
|
|
66205
66450
|
}
|
|
66206
66451
|
function loadUserAgents() {
|
|
66207
|
-
const userAgentsDir =
|
|
66452
|
+
const userAgentsDir = join60(getClaudeConfigDir(), "agents");
|
|
66208
66453
|
const agents = loadAgentsFromDir(userAgentsDir, "user");
|
|
66209
66454
|
const result = {};
|
|
66210
66455
|
for (const agent of agents) {
|
|
@@ -66213,7 +66458,7 @@ function loadUserAgents() {
|
|
|
66213
66458
|
return result;
|
|
66214
66459
|
}
|
|
66215
66460
|
function loadProjectAgents() {
|
|
66216
|
-
const projectAgentsDir =
|
|
66461
|
+
const projectAgentsDir = join60(process.cwd(), ".claude", "agents");
|
|
66217
66462
|
const agents = loadAgentsFromDir(projectAgentsDir, "project");
|
|
66218
66463
|
const result = {};
|
|
66219
66464
|
for (const agent of agents) {
|
|
@@ -66225,18 +66470,18 @@ function loadProjectAgents() {
|
|
|
66225
66470
|
init_frontmatter();
|
|
66226
66471
|
init_file_utils();
|
|
66227
66472
|
init_logger();
|
|
66228
|
-
import { existsSync as
|
|
66473
|
+
import { existsSync as existsSync52, readdirSync as readdirSync20, readFileSync as readFileSync32 } from "fs";
|
|
66229
66474
|
import { homedir as homedir13 } from "os";
|
|
66230
|
-
import { join as
|
|
66475
|
+
import { join as join61, basename as basename8 } from "path";
|
|
66231
66476
|
var CLAUDE_PLUGIN_ROOT_VAR = "${CLAUDE_PLUGIN_ROOT}";
|
|
66232
66477
|
function getPluginsBaseDir() {
|
|
66233
66478
|
if (process.env.CLAUDE_PLUGINS_HOME) {
|
|
66234
66479
|
return process.env.CLAUDE_PLUGINS_HOME;
|
|
66235
66480
|
}
|
|
66236
|
-
return
|
|
66481
|
+
return join61(homedir13(), ".claude", "plugins");
|
|
66237
66482
|
}
|
|
66238
66483
|
function getInstalledPluginsPath() {
|
|
66239
|
-
return
|
|
66484
|
+
return join61(getPluginsBaseDir(), "installed_plugins.json");
|
|
66240
66485
|
}
|
|
66241
66486
|
function resolvePluginPath(path8, pluginRoot) {
|
|
66242
66487
|
return path8.replace(CLAUDE_PLUGIN_ROOT_VAR, pluginRoot);
|
|
@@ -66261,7 +66506,7 @@ function resolvePluginPaths(obj, pluginRoot) {
|
|
|
66261
66506
|
}
|
|
66262
66507
|
function loadInstalledPlugins() {
|
|
66263
66508
|
const dbPath = getInstalledPluginsPath();
|
|
66264
|
-
if (!
|
|
66509
|
+
if (!existsSync52(dbPath)) {
|
|
66265
66510
|
return null;
|
|
66266
66511
|
}
|
|
66267
66512
|
try {
|
|
@@ -66276,11 +66521,11 @@ function getClaudeSettingsPath() {
|
|
|
66276
66521
|
if (process.env.CLAUDE_SETTINGS_PATH) {
|
|
66277
66522
|
return process.env.CLAUDE_SETTINGS_PATH;
|
|
66278
66523
|
}
|
|
66279
|
-
return
|
|
66524
|
+
return join61(homedir13(), ".claude", "settings.json");
|
|
66280
66525
|
}
|
|
66281
66526
|
function loadClaudeSettings() {
|
|
66282
66527
|
const settingsPath = getClaudeSettingsPath();
|
|
66283
|
-
if (!
|
|
66528
|
+
if (!existsSync52(settingsPath)) {
|
|
66284
66529
|
return null;
|
|
66285
66530
|
}
|
|
66286
66531
|
try {
|
|
@@ -66292,8 +66537,8 @@ function loadClaudeSettings() {
|
|
|
66292
66537
|
}
|
|
66293
66538
|
}
|
|
66294
66539
|
function loadPluginManifest(installPath) {
|
|
66295
|
-
const manifestPath =
|
|
66296
|
-
if (!
|
|
66540
|
+
const manifestPath = join61(installPath, ".claude-plugin", "plugin.json");
|
|
66541
|
+
if (!existsSync52(manifestPath)) {
|
|
66297
66542
|
return null;
|
|
66298
66543
|
}
|
|
66299
66544
|
try {
|
|
@@ -66344,7 +66589,7 @@ function discoverInstalledPlugins(options) {
|
|
|
66344
66589
|
continue;
|
|
66345
66590
|
}
|
|
66346
66591
|
const { installPath, scope, version: version3 } = installation;
|
|
66347
|
-
if (!
|
|
66592
|
+
if (!existsSync52(installPath)) {
|
|
66348
66593
|
errors5.push({
|
|
66349
66594
|
pluginKey,
|
|
66350
66595
|
installPath,
|
|
@@ -66362,21 +66607,21 @@ function discoverInstalledPlugins(options) {
|
|
|
66362
66607
|
pluginKey,
|
|
66363
66608
|
manifest: manifest ?? undefined
|
|
66364
66609
|
};
|
|
66365
|
-
if (
|
|
66366
|
-
loadedPlugin.commandsDir =
|
|
66610
|
+
if (existsSync52(join61(installPath, "commands"))) {
|
|
66611
|
+
loadedPlugin.commandsDir = join61(installPath, "commands");
|
|
66367
66612
|
}
|
|
66368
|
-
if (
|
|
66369
|
-
loadedPlugin.agentsDir =
|
|
66613
|
+
if (existsSync52(join61(installPath, "agents"))) {
|
|
66614
|
+
loadedPlugin.agentsDir = join61(installPath, "agents");
|
|
66370
66615
|
}
|
|
66371
|
-
if (
|
|
66372
|
-
loadedPlugin.skillsDir =
|
|
66616
|
+
if (existsSync52(join61(installPath, "skills"))) {
|
|
66617
|
+
loadedPlugin.skillsDir = join61(installPath, "skills");
|
|
66373
66618
|
}
|
|
66374
|
-
const hooksPath =
|
|
66375
|
-
if (
|
|
66619
|
+
const hooksPath = join61(installPath, "hooks", "hooks.json");
|
|
66620
|
+
if (existsSync52(hooksPath)) {
|
|
66376
66621
|
loadedPlugin.hooksPath = hooksPath;
|
|
66377
66622
|
}
|
|
66378
|
-
const mcpPath =
|
|
66379
|
-
if (
|
|
66623
|
+
const mcpPath = join61(installPath, ".mcp.json");
|
|
66624
|
+
if (existsSync52(mcpPath)) {
|
|
66380
66625
|
loadedPlugin.mcpPath = mcpPath;
|
|
66381
66626
|
}
|
|
66382
66627
|
plugins.push(loadedPlugin);
|
|
@@ -66387,13 +66632,13 @@ function discoverInstalledPlugins(options) {
|
|
|
66387
66632
|
function loadPluginCommands(plugins) {
|
|
66388
66633
|
const commands2 = {};
|
|
66389
66634
|
for (const plugin of plugins) {
|
|
66390
|
-
if (!plugin.commandsDir || !
|
|
66635
|
+
if (!plugin.commandsDir || !existsSync52(plugin.commandsDir))
|
|
66391
66636
|
continue;
|
|
66392
|
-
const entries =
|
|
66637
|
+
const entries = readdirSync20(plugin.commandsDir, { withFileTypes: true });
|
|
66393
66638
|
for (const entry of entries) {
|
|
66394
66639
|
if (!isMarkdownFile(entry))
|
|
66395
66640
|
continue;
|
|
66396
|
-
const commandPath =
|
|
66641
|
+
const commandPath = join61(plugin.commandsDir, entry.name);
|
|
66397
66642
|
const commandName = basename8(entry.name, ".md");
|
|
66398
66643
|
const namespacedName = `${plugin.name}:${commandName}`;
|
|
66399
66644
|
try {
|
|
@@ -66429,18 +66674,18 @@ $ARGUMENTS
|
|
|
66429
66674
|
function loadPluginSkillsAsCommands(plugins) {
|
|
66430
66675
|
const skills = {};
|
|
66431
66676
|
for (const plugin of plugins) {
|
|
66432
|
-
if (!plugin.skillsDir || !
|
|
66677
|
+
if (!plugin.skillsDir || !existsSync52(plugin.skillsDir))
|
|
66433
66678
|
continue;
|
|
66434
|
-
const entries =
|
|
66679
|
+
const entries = readdirSync20(plugin.skillsDir, { withFileTypes: true });
|
|
66435
66680
|
for (const entry of entries) {
|
|
66436
66681
|
if (entry.name.startsWith("."))
|
|
66437
66682
|
continue;
|
|
66438
|
-
const skillPath =
|
|
66683
|
+
const skillPath = join61(plugin.skillsDir, entry.name);
|
|
66439
66684
|
if (!entry.isDirectory() && !entry.isSymbolicLink())
|
|
66440
66685
|
continue;
|
|
66441
66686
|
const resolvedPath = resolveSymlink(skillPath);
|
|
66442
|
-
const skillMdPath =
|
|
66443
|
-
if (!
|
|
66687
|
+
const skillMdPath = join61(resolvedPath, "SKILL.md");
|
|
66688
|
+
if (!existsSync52(skillMdPath))
|
|
66444
66689
|
continue;
|
|
66445
66690
|
try {
|
|
66446
66691
|
const content = readFileSync32(skillMdPath, "utf-8");
|
|
@@ -66490,13 +66735,13 @@ function parseToolsConfig2(toolsStr) {
|
|
|
66490
66735
|
function loadPluginAgents(plugins) {
|
|
66491
66736
|
const agents = {};
|
|
66492
66737
|
for (const plugin of plugins) {
|
|
66493
|
-
if (!plugin.agentsDir || !
|
|
66738
|
+
if (!plugin.agentsDir || !existsSync52(plugin.agentsDir))
|
|
66494
66739
|
continue;
|
|
66495
|
-
const entries =
|
|
66740
|
+
const entries = readdirSync20(plugin.agentsDir, { withFileTypes: true });
|
|
66496
66741
|
for (const entry of entries) {
|
|
66497
66742
|
if (!isMarkdownFile(entry))
|
|
66498
66743
|
continue;
|
|
66499
|
-
const agentPath =
|
|
66744
|
+
const agentPath = join61(plugin.agentsDir, entry.name);
|
|
66500
66745
|
const agentName = basename8(entry.name, ".md");
|
|
66501
66746
|
const namespacedName = `${plugin.name}:${agentName}`;
|
|
66502
66747
|
try {
|
|
@@ -66526,7 +66771,7 @@ function loadPluginAgents(plugins) {
|
|
|
66526
66771
|
async function loadPluginMcpServers(plugins) {
|
|
66527
66772
|
const servers = {};
|
|
66528
66773
|
for (const plugin of plugins) {
|
|
66529
|
-
if (!plugin.mcpPath || !
|
|
66774
|
+
if (!plugin.mcpPath || !existsSync52(plugin.mcpPath))
|
|
66530
66775
|
continue;
|
|
66531
66776
|
try {
|
|
66532
66777
|
const content = await Bun.file(plugin.mcpPath).text();
|
|
@@ -66558,7 +66803,7 @@ async function loadPluginMcpServers(plugins) {
|
|
|
66558
66803
|
function loadPluginHooksConfigs(plugins) {
|
|
66559
66804
|
const configs = [];
|
|
66560
66805
|
for (const plugin of plugins) {
|
|
66561
|
-
if (!plugin.hooksPath || !
|
|
66806
|
+
if (!plugin.hooksPath || !existsSync52(plugin.hooksPath))
|
|
66562
66807
|
continue;
|
|
66563
66808
|
try {
|
|
66564
66809
|
const content = readFileSync32(plugin.hooksPath, "utf-8");
|
|
@@ -66947,8 +67192,8 @@ Prometheus\uFF1A"\u5FEB\u901F\u4FEE\u590D\u2014\u2014\u6211\u770B\u5230\u62FC\u5
|
|
|
66947
67192
|
|
|
66948
67193
|
**\u5148\u505A\u7814\u7A76\uFF1A**
|
|
66949
67194
|
\`\`\`typescript
|
|
66950
|
-
delegate_task(subagent_type="explore", prompt="\u4F7F\u7528 lsp_find_references \u6A21\u5F0F\u67E5\u627E [\u76EE\u6807] \u7684\u6240\u6709\u4F7F\u7528\u4F4D\u7F6E...", run_in_background=true)
|
|
66951
|
-
delegate_task(subagent_type="explore", prompt="\u67E5\u627E [\u53D7\u5F71\u54CD\u4EE3\u7801] \u7684\u6D4B\u8BD5\u8986\u76D6\u7387...", run_in_background=true)
|
|
67195
|
+
delegate_task(subagent_type="explore", prompt="\u4F7F\u7528 lsp_find_references \u6A21\u5F0F\u67E5\u627E [\u76EE\u6807] \u7684\u6240\u6709\u4F7F\u7528\u4F4D\u7F6E...", run_in_background=true, load_skills=[])
|
|
67196
|
+
delegate_task(subagent_type="explore", prompt="\u67E5\u627E [\u53D7\u5F71\u54CD\u4EE3\u7801] \u7684\u6D4B\u8BD5\u8986\u76D6\u7387...", run_in_background=true, load_skills=[])
|
|
66952
67197
|
\`\`\`
|
|
66953
67198
|
|
|
66954
67199
|
**\u8BBF\u8C08\u91CD\u70B9\uFF1A**
|
|
@@ -66971,9 +67216,9 @@ delegate_task(subagent_type="explore", prompt="\u67E5\u627E [\u53D7\u5F71\u54CD\
|
|
|
66971
67216
|
**\u8BBF\u8C08\u524D\u7814\u7A76\uFF08\u5F3A\u5236\u8981\u6C42\uFF09\uFF1A**
|
|
66972
67217
|
\`\`\`typescript
|
|
66973
67218
|
// \u5728\u5411\u7528\u6237\u63D0\u95EE\u4E4B\u524D\u542F\u52A8
|
|
66974
|
-
delegate_task(subagent_type="explore", prompt="\u5728\u4EE3\u7801\u5E93\u4E2D\u67E5\u627E\u7C7B\u4F3C\u5B9E\u73B0...", run_in_background=true)
|
|
66975
|
-
delegate_task(subagent_type="explore", prompt="\u67E5\u627E [\u529F\u80FD\u7C7B\u578B] \u7684\u9879\u76EE\u6A21\u5F0F...", run_in_background=true)
|
|
66976
|
-
delegate_task(subagent_type="librarian", prompt="\u67E5\u627E [\u6280\u672F] \u7684\u6700\u4F73\u5B9E\u8DF5...", run_in_background=true)
|
|
67219
|
+
delegate_task(subagent_type="explore", prompt="\u5728\u4EE3\u7801\u5E93\u4E2D\u67E5\u627E\u7C7B\u4F3C\u5B9E\u73B0...", run_in_background=true, load_skills=[])
|
|
67220
|
+
delegate_task(subagent_type="explore", prompt="\u67E5\u627E [\u529F\u80FD\u7C7B\u578B] \u7684\u9879\u76EE\u6A21\u5F0F...", run_in_background=true, load_skills=[])
|
|
67221
|
+
delegate_task(subagent_type="librarian", prompt="\u67E5\u627E [\u6280\u672F] \u7684\u6700\u4F73\u5B9E\u8DF5...", run_in_background=true, load_skills=[])
|
|
66977
67222
|
\`\`\`
|
|
66978
67223
|
|
|
66979
67224
|
**\u8BBF\u8C08\u91CD\u70B9**\uFF08\u7814\u7A76\u4E4B\u540E\uFF09\uFF1A
|
|
@@ -67012,7 +67257,7 @@ Prometheus\uFF1A"\u6211\u53D1\u73B0\u4E86\u4E00\u4E9B\u60C5\u51B5\uFF1A
|
|
|
67012
67257
|
|
|
67013
67258
|
\u8FD0\u884C\u6B64\u68C0\u67E5\uFF1A
|
|
67014
67259
|
\`\`\`typescript
|
|
67015
|
-
delegate_task(subagent_type="explore", prompt="\u67E5\u627E\u6D4B\u8BD5\u57FA\u7840\u8BBE\u65BD\uFF1Apackage.json \u4E2D\u7684\u6D4B\u8BD5\u811A\u672C\u3001\u6D4B\u8BD5\u914D\u7F6E\u6587\u4EF6\uFF08jest.config\u3001vitest.config\u3001pytest.ini \u7B49\uFF09\u3001\u73B0\u6709\u6D4B\u8BD5\u6587\u4EF6\uFF08*.test.*\u3001*.spec.*\u3001test_*\uFF09\u3002\u62A5\u544A\uFF1A1\uFF09\u662F\u5426\u5B58\u5728\u6D4B\u8BD5\u57FA\u7840\u8BBE\u65BD\uFF1F2\uFF09\u4F7F\u7528\u4EC0\u4E48\u6846\u67B6\uFF1F3\uFF09\u793A\u4F8B\u6D4B\u8BD5\u6587\u4EF6\u6A21\u5F0F\u3002", run_in_background=true)
|
|
67260
|
+
delegate_task(subagent_type="explore", prompt="\u67E5\u627E\u6D4B\u8BD5\u57FA\u7840\u8BBE\u65BD\uFF1Apackage.json \u4E2D\u7684\u6D4B\u8BD5\u811A\u672C\u3001\u6D4B\u8BD5\u914D\u7F6E\u6587\u4EF6\uFF08jest.config\u3001vitest.config\u3001pytest.ini \u7B49\uFF09\u3001\u73B0\u6709\u6D4B\u8BD5\u6587\u4EF6\uFF08*.test.*\u3001*.spec.*\u3001test_*\uFF09\u3002\u62A5\u544A\uFF1A1\uFF09\u662F\u5426\u5B58\u5728\u6D4B\u8BD5\u57FA\u7840\u8BBE\u65BD\uFF1F2\uFF09\u4F7F\u7528\u4EC0\u4E48\u6846\u67B6\uFF1F3\uFF09\u793A\u4F8B\u6D4B\u8BD5\u6587\u4EF6\u6A21\u5F0F\u3002", run_in_background=true, load_skills=[])
|
|
67016
67261
|
\`\`\`
|
|
67017
67262
|
|
|
67018
67263
|
#### \u7B2C2\u6B65\uFF1A\u8BE2\u95EE\u6D4B\u8BD5\u95EE\u9898\uFF08\u5F3A\u5236\u8981\u6C42\uFF09
|
|
@@ -67101,13 +67346,13 @@ delegate_task(subagent_type="explore", prompt="\u67E5\u627E\u6D4B\u8BD5\u57FA\u7
|
|
|
67101
67346
|
|
|
67102
67347
|
**\u5148\u505A\u7814\u7A76\uFF1A**
|
|
67103
67348
|
\`\`\`typescript
|
|
67104
|
-
delegate_task(subagent_type="explore", prompt="\u67E5\u627E\u5F53\u524D\u7CFB\u7EDF\u67B6\u6784\u548C\u6A21\u5F0F...", run_in_background=true)
|
|
67105
|
-
delegate_task(subagent_type="librarian", prompt="\u67E5\u627E [\u9886\u57DF] \u7684\u67B6\u6784\u6700\u4F73\u5B9E\u8DF5...", run_in_background=true)
|
|
67349
|
+
delegate_task(subagent_type="explore", prompt="\u67E5\u627E\u5F53\u524D\u7CFB\u7EDF\u67B6\u6784\u548C\u6A21\u5F0F...", run_in_background=true, load_skills=[])
|
|
67350
|
+
delegate_task(subagent_type="librarian", prompt="\u67E5\u627E [\u9886\u57DF] \u7684\u67B6\u6784\u6700\u4F73\u5B9E\u8DF5...", run_in_background=true, load_skills=[])
|
|
67106
67351
|
\`\`\`
|
|
67107
67352
|
|
|
67108
67353
|
**Oracle \u54A8\u8BE2**\uFF08\u5F53\u98CE\u9669\u8F83\u9AD8\u65F6\u63A8\u8350\uFF09\uFF1A
|
|
67109
67354
|
\`\`\`typescript
|
|
67110
|
-
delegate_task(subagent_type="oracle", prompt="\u9700\u8981\u67B6\u6784\u54A8\u8BE2\uFF1A[\u4E0A\u4E0B\u6587]...", run_in_background=false)
|
|
67355
|
+
delegate_task(subagent_type="oracle", prompt="\u9700\u8981\u67B6\u6784\u54A8\u8BE2\uFF1A[\u4E0A\u4E0B\u6587]...", run_in_background=false, load_skills=[])
|
|
67111
67356
|
\`\`\`
|
|
67112
67357
|
|
|
67113
67358
|
**\u8BBF\u8C08\u91CD\u70B9\uFF1A**
|
|
@@ -67124,9 +67369,9 @@ delegate_task(subagent_type="oracle", prompt="\u9700\u8981\u67B6\u6784\u54A8\u8B
|
|
|
67124
67369
|
|
|
67125
67370
|
**\u5E76\u884C\u8C03\u7814\uFF1A**
|
|
67126
67371
|
\`\`\`typescript
|
|
67127
|
-
delegate_task(subagent_type="explore", prompt="\u67E5\u627E X \u5F53\u524D\u662F\u5982\u4F55\u5904\u7406\u7684...", run_in_background=true)
|
|
67128
|
-
delegate_task(subagent_type="librarian", prompt="\u67E5\u627E Y \u7684\u5B98\u65B9\u6587\u6863...", run_in_background=true)
|
|
67129
|
-
delegate_task(subagent_type="librarian", prompt="\u67E5\u627E Z \u7684\u5F00\u6E90\u5B9E\u73B0...", run_in_background=true)
|
|
67372
|
+
delegate_task(subagent_type="explore", prompt="\u67E5\u627E X \u5F53\u524D\u662F\u5982\u4F55\u5904\u7406\u7684...", run_in_background=true, load_skills=[])
|
|
67373
|
+
delegate_task(subagent_type="librarian", prompt="\u67E5\u627E Y \u7684\u5B98\u65B9\u6587\u6863...", run_in_background=true, load_skills=[])
|
|
67374
|
+
delegate_task(subagent_type="librarian", prompt="\u67E5\u627E Z \u7684\u5F00\u6E90\u5B9E\u73B0...", run_in_background=true, load_skills=[])
|
|
67130
67375
|
\`\`\`
|
|
67131
67376
|
|
|
67132
67377
|
**\u8BBF\u8C08\u91CD\u70B9\uFF1A**
|
|
@@ -67152,17 +67397,17 @@ delegate_task(subagent_type="librarian", prompt="\u67E5\u627E Z \u7684\u5F00\u6E
|
|
|
67152
67397
|
|
|
67153
67398
|
**\u7528\u4E8E\u7406\u89E3\u4EE3\u7801\u5E93\uFF1A**
|
|
67154
67399
|
\`\`\`typescript
|
|
67155
|
-
delegate_task(subagent_type="explore", prompt="\u67E5\u627E\u4E0E [\u4E3B\u9898] \u76F8\u5173\u7684\u6240\u6709\u6587\u4EF6\u3002\u5C55\u793A\u6A21\u5F0F\u3001\u7EA6\u5B9A\u548C\u7ED3\u6784\u3002", run_in_background=true)
|
|
67400
|
+
delegate_task(subagent_type="explore", prompt="\u67E5\u627E\u4E0E [\u4E3B\u9898] \u76F8\u5173\u7684\u6240\u6709\u6587\u4EF6\u3002\u5C55\u793A\u6A21\u5F0F\u3001\u7EA6\u5B9A\u548C\u7ED3\u6784\u3002", run_in_background=true, load_skills=[])
|
|
67156
67401
|
\`\`\`
|
|
67157
67402
|
|
|
67158
67403
|
**\u7528\u4E8E\u5916\u90E8\u77E5\u8BC6\uFF1A**
|
|
67159
67404
|
\`\`\`typescript
|
|
67160
|
-
delegate_task(subagent_type="librarian", prompt="\u67E5\u627E [\u5E93] \u7684\u5B98\u65B9\u6587\u6863\u3002\u91CD\u70B9\u5173\u6CE8 [\u7279\u5B9A\u529F\u80FD] \u548C\u6700\u4F73\u5B9E\u8DF5\u3002", run_in_background=true)
|
|
67405
|
+
delegate_task(subagent_type="librarian", prompt="\u67E5\u627E [\u5E93] \u7684\u5B98\u65B9\u6587\u6863\u3002\u91CD\u70B9\u5173\u6CE8 [\u7279\u5B9A\u529F\u80FD] \u548C\u6700\u4F73\u5B9E\u8DF5\u3002", run_in_background=true, load_skills=[])
|
|
67161
67406
|
\`\`\`
|
|
67162
67407
|
|
|
67163
67408
|
**\u7528\u4E8E\u5B9E\u73B0\u793A\u4F8B\uFF1A**
|
|
67164
67409
|
\`\`\`typescript
|
|
67165
|
-
delegate_task(subagent_type="librarian", prompt="\u67E5\u627E [\u529F\u80FD] \u7684\u5F00\u6E90\u5B9E\u73B0\u3002\u5BFB\u627E\u751F\u4EA7\u8D28\u91CF\u7684\u793A\u4F8B\u3002", run_in_background=true)
|
|
67410
|
+
delegate_task(subagent_type="librarian", prompt="\u67E5\u627E [\u529F\u80FD] \u7684\u5F00\u6E90\u5B9E\u73B0\u3002\u5BFB\u627E\u751F\u4EA7\u8D28\u91CF\u7684\u793A\u4F8B\u3002", run_in_background=true, load_skills=[])
|
|
67166
67411
|
\`\`\`
|
|
67167
67412
|
|
|
67168
67413
|
## \u8BBF\u8C08\u6A21\u5F0F\u53CD\u6A21\u5F0F
|
|
@@ -67260,6 +67505,7 @@ todoWrite([
|
|
|
67260
67505
|
\`\`\`typescript
|
|
67261
67506
|
delegate_task(
|
|
67262
67507
|
subagent_type="metis",
|
|
67508
|
+
load_skills=[],
|
|
67263
67509
|
prompt=\`\u5728\u6211\u751F\u6210\u5DE5\u4F5C\u8BA1\u5212\u4E4B\u524D\uFF0C\u5BA1\u67E5\u8FD9\u6B21\u89C4\u5212\u4F1A\u8BDD\uFF1A
|
|
67264
67510
|
|
|
67265
67511
|
**\u7528\u6237\u76EE\u6807**\uFF1A{\u603B\u7ED3\u7528\u6237\u60F3\u8981\u4EC0\u4E48}
|
|
@@ -67427,7 +67673,7 @@ while (true) {
|
|
|
67427
67673
|
const result = delegate_task(
|
|
67428
67674
|
subagent_type="momus",
|
|
67429
67675
|
prompt=".sisyphus/plans/{name}.md",
|
|
67430
|
-
run_in_background=false
|
|
67676
|
+
run_in_background=false, load_skills=[]
|
|
67431
67677
|
)
|
|
67432
67678
|
|
|
67433
67679
|
if (result.verdict === "OKAY") {
|
|
@@ -68130,6 +68376,13 @@ var OhMyOpenCodePlugin = async (ctx) => {
|
|
|
68130
68376
|
log("[OhMyOpenCodePlugin] ENTRY - plugin loading", { directory: ctx.directory });
|
|
68131
68377
|
startBackgroundCheck2();
|
|
68132
68378
|
const pluginConfig = loadPluginConfig(ctx.directory, ctx);
|
|
68379
|
+
if (process.platform === "win32") {
|
|
68380
|
+
const reservedNames = scanForReservedNames(ctx.directory, 3);
|
|
68381
|
+
if (reservedNames.length > 0) {
|
|
68382
|
+
console.warn(formatReservedNamesWarning(reservedNames));
|
|
68383
|
+
log("[oh-my-opencode] Windows reserved device names detected:", reservedNames);
|
|
68384
|
+
}
|
|
68385
|
+
}
|
|
68133
68386
|
const disabledHooks = new Set(pluginConfig.disabled_hooks ?? []);
|
|
68134
68387
|
const firstMessageVariantGate = createFirstMessageVariantGate();
|
|
68135
68388
|
const isHookEnabled = (hookName) => !disabledHooks.has(hookName);
|