@reinamaccredy/maestro 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +16 -2
- package/dist/index.js +387 -346
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/platform-detection.d.ts +42 -0
- package/package.json +12 -2
- package/postinstall.mjs +97 -4
package/dist/index.js
CHANGED
|
@@ -4746,6 +4746,43 @@ var init_agent_tool_restrictions = __esm(() => {
|
|
|
4746
4746
|
};
|
|
4747
4747
|
});
|
|
4748
4748
|
|
|
4749
|
+
// src/shared/platform-detection.ts
|
|
4750
|
+
import { existsSync as existsSync10 } from "fs";
|
|
4751
|
+
import { join as join13 } from "path";
|
|
4752
|
+
function detectPlatform2(ctx) {
|
|
4753
|
+
if (ctx?.client && typeof ctx.client === "object") {
|
|
4754
|
+
return "opencode";
|
|
4755
|
+
}
|
|
4756
|
+
if (process.env.CLAUDE_CODE === "1" || process.env.CLAUDE_CODE === "true") {
|
|
4757
|
+
return "claude-code";
|
|
4758
|
+
}
|
|
4759
|
+
if (process.env.AMP_CODE === "1" || process.env.AMP_CODE === "true") {
|
|
4760
|
+
return "amp";
|
|
4761
|
+
}
|
|
4762
|
+
if (process.env.CODEX_CLI === "1" || process.env.CODEX_CLI === "true") {
|
|
4763
|
+
return "codex";
|
|
4764
|
+
}
|
|
4765
|
+
const cwd = ctx?.directory ?? process.cwd();
|
|
4766
|
+
if (existsSync10(join13(cwd, ".claude")))
|
|
4767
|
+
return "claude-code";
|
|
4768
|
+
if (existsSync10(join13(cwd, ".agents")))
|
|
4769
|
+
return "amp";
|
|
4770
|
+
if (existsSync10(join13(cwd, ".codex")))
|
|
4771
|
+
return "codex";
|
|
4772
|
+
return "unknown";
|
|
4773
|
+
}
|
|
4774
|
+
function shouldSkipAgent(agentName) {
|
|
4775
|
+
const platform2 = detectPlatform2();
|
|
4776
|
+
if (platform2 === "amp") {
|
|
4777
|
+
if (agentName === "Virtuoso" || agentName === "oracle")
|
|
4778
|
+
return true;
|
|
4779
|
+
if (agentName === "Archivist" || agentName === "librarian")
|
|
4780
|
+
return true;
|
|
4781
|
+
}
|
|
4782
|
+
return false;
|
|
4783
|
+
}
|
|
4784
|
+
var init_platform_detection = () => {};
|
|
4785
|
+
|
|
4749
4786
|
// src/shared/index.ts
|
|
4750
4787
|
var init_shared = __esm(() => {
|
|
4751
4788
|
init_frontmatter();
|
|
@@ -4770,6 +4807,7 @@ var init_shared = __esm(() => {
|
|
|
4770
4807
|
init_session_cursor();
|
|
4771
4808
|
init_system_directive();
|
|
4772
4809
|
init_agent_tool_restrictions();
|
|
4810
|
+
init_platform_detection();
|
|
4773
4811
|
});
|
|
4774
4812
|
|
|
4775
4813
|
// node_modules/picomatch/lib/constants.js
|
|
@@ -15446,20 +15484,20 @@ function createSessionRecoveryHook(ctx, options) {
|
|
|
15446
15484
|
// src/hooks/comment-checker/cli.ts
|
|
15447
15485
|
var {spawn: spawn5 } = globalThis.Bun;
|
|
15448
15486
|
import { createRequire as createRequire2 } from "module";
|
|
15449
|
-
import { dirname, join as
|
|
15450
|
-
import { existsSync as
|
|
15487
|
+
import { dirname, join as join15 } from "path";
|
|
15488
|
+
import { existsSync as existsSync12 } from "fs";
|
|
15451
15489
|
import * as fs6 from "fs";
|
|
15452
15490
|
import { tmpdir as tmpdir3 } from "os";
|
|
15453
15491
|
|
|
15454
15492
|
// src/hooks/comment-checker/downloader.ts
|
|
15455
15493
|
init_shared();
|
|
15456
15494
|
var {spawn: spawn4 } = globalThis.Bun;
|
|
15457
|
-
import { existsSync as
|
|
15458
|
-
import { join as
|
|
15495
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync3, chmodSync, unlinkSync as unlinkSync2, appendFileSync as appendFileSync2 } from "fs";
|
|
15496
|
+
import { join as join14 } from "path";
|
|
15459
15497
|
import { homedir as homedir7, tmpdir as tmpdir2 } from "os";
|
|
15460
15498
|
import { createRequire } from "module";
|
|
15461
15499
|
var DEBUG = process.env.COMMENT_CHECKER_DEBUG === "1";
|
|
15462
|
-
var DEBUG_FILE =
|
|
15500
|
+
var DEBUG_FILE = join14(tmpdir2(), "comment-checker-debug.log");
|
|
15463
15501
|
function debugLog(...args) {
|
|
15464
15502
|
if (DEBUG) {
|
|
15465
15503
|
const msg = `[${new Date().toISOString()}] [comment-checker:downloader] ${args.map((a) => typeof a === "object" ? JSON.stringify(a, null, 2) : String(a)).join(" ")}
|
|
@@ -15478,19 +15516,19 @@ var PLATFORM_MAP = {
|
|
|
15478
15516
|
function getCacheDir() {
|
|
15479
15517
|
if (process.platform === "win32") {
|
|
15480
15518
|
const localAppData = process.env.LOCALAPPDATA || process.env.APPDATA;
|
|
15481
|
-
const base2 = localAppData ||
|
|
15482
|
-
return
|
|
15519
|
+
const base2 = localAppData || join14(homedir7(), "AppData", "Local");
|
|
15520
|
+
return join14(base2, "oh-my-opencode", "bin");
|
|
15483
15521
|
}
|
|
15484
15522
|
const xdgCache = process.env.XDG_CACHE_HOME;
|
|
15485
|
-
const base = xdgCache ||
|
|
15486
|
-
return
|
|
15523
|
+
const base = xdgCache || join14(homedir7(), ".cache");
|
|
15524
|
+
return join14(base, "oh-my-opencode", "bin");
|
|
15487
15525
|
}
|
|
15488
15526
|
function getBinaryName() {
|
|
15489
15527
|
return process.platform === "win32" ? "comment-checker.exe" : "comment-checker";
|
|
15490
15528
|
}
|
|
15491
15529
|
function getCachedBinaryPath() {
|
|
15492
|
-
const binaryPath =
|
|
15493
|
-
return
|
|
15530
|
+
const binaryPath = join14(getCacheDir(), getBinaryName());
|
|
15531
|
+
return existsSync11(binaryPath) ? binaryPath : null;
|
|
15494
15532
|
}
|
|
15495
15533
|
function getPackageVersion() {
|
|
15496
15534
|
try {
|
|
@@ -15522,8 +15560,8 @@ async function downloadCommentChecker() {
|
|
|
15522
15560
|
}
|
|
15523
15561
|
const cacheDir = getCacheDir();
|
|
15524
15562
|
const binaryName = getBinaryName();
|
|
15525
|
-
const binaryPath =
|
|
15526
|
-
if (
|
|
15563
|
+
const binaryPath = join14(cacheDir, binaryName);
|
|
15564
|
+
if (existsSync11(binaryPath)) {
|
|
15527
15565
|
debugLog("Binary already cached at:", binaryPath);
|
|
15528
15566
|
return binaryPath;
|
|
15529
15567
|
}
|
|
@@ -15534,14 +15572,14 @@ async function downloadCommentChecker() {
|
|
|
15534
15572
|
debugLog(`Downloading from: ${downloadUrl}`);
|
|
15535
15573
|
console.log(`[oh-my-opencode] Downloading comment-checker binary...`);
|
|
15536
15574
|
try {
|
|
15537
|
-
if (!
|
|
15575
|
+
if (!existsSync11(cacheDir)) {
|
|
15538
15576
|
mkdirSync3(cacheDir, { recursive: true });
|
|
15539
15577
|
}
|
|
15540
15578
|
const response = await fetch(downloadUrl, { redirect: "follow" });
|
|
15541
15579
|
if (!response.ok) {
|
|
15542
15580
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
15543
15581
|
}
|
|
15544
|
-
const archivePath =
|
|
15582
|
+
const archivePath = join14(cacheDir, assetName);
|
|
15545
15583
|
const arrayBuffer = await response.arrayBuffer();
|
|
15546
15584
|
await Bun.write(archivePath, arrayBuffer);
|
|
15547
15585
|
debugLog(`Downloaded archive to: ${archivePath}`);
|
|
@@ -15550,10 +15588,10 @@ async function downloadCommentChecker() {
|
|
|
15550
15588
|
} else {
|
|
15551
15589
|
await extractZip(archivePath, cacheDir);
|
|
15552
15590
|
}
|
|
15553
|
-
if (
|
|
15591
|
+
if (existsSync11(archivePath)) {
|
|
15554
15592
|
unlinkSync2(archivePath);
|
|
15555
15593
|
}
|
|
15556
|
-
if (process.platform !== "win32" &&
|
|
15594
|
+
if (process.platform !== "win32" && existsSync11(binaryPath)) {
|
|
15557
15595
|
chmodSync(binaryPath, 493);
|
|
15558
15596
|
}
|
|
15559
15597
|
debugLog(`Successfully downloaded binary to: ${binaryPath}`);
|
|
@@ -15577,7 +15615,7 @@ async function ensureCommentCheckerBinary() {
|
|
|
15577
15615
|
|
|
15578
15616
|
// src/hooks/comment-checker/cli.ts
|
|
15579
15617
|
var DEBUG2 = process.env.COMMENT_CHECKER_DEBUG === "1";
|
|
15580
|
-
var DEBUG_FILE2 =
|
|
15618
|
+
var DEBUG_FILE2 = join15(tmpdir3(), "comment-checker-debug.log");
|
|
15581
15619
|
function debugLog2(...args) {
|
|
15582
15620
|
if (DEBUG2) {
|
|
15583
15621
|
const msg = `[${new Date().toISOString()}] [comment-checker:cli] ${args.map((a) => typeof a === "object" ? JSON.stringify(a, null, 2) : String(a)).join(" ")}
|
|
@@ -15603,8 +15641,8 @@ function findCommentCheckerPathSync() {
|
|
|
15603
15641
|
const require2 = createRequire2(import.meta.url);
|
|
15604
15642
|
const cliPkgPath = require2.resolve("@code-yeongyu/comment-checker/package.json");
|
|
15605
15643
|
const cliDir = dirname(cliPkgPath);
|
|
15606
|
-
const binaryPath =
|
|
15607
|
-
if (
|
|
15644
|
+
const binaryPath = join15(cliDir, "bin", binaryName);
|
|
15645
|
+
if (existsSync12(binaryPath)) {
|
|
15608
15646
|
debugLog2("found binary in main package:", binaryPath);
|
|
15609
15647
|
return binaryPath;
|
|
15610
15648
|
}
|
|
@@ -15625,7 +15663,7 @@ async function getCommentCheckerPath() {
|
|
|
15625
15663
|
}
|
|
15626
15664
|
initPromise = (async () => {
|
|
15627
15665
|
const syncPath = findCommentCheckerPathSync();
|
|
15628
|
-
if (syncPath &&
|
|
15666
|
+
if (syncPath && existsSync12(syncPath)) {
|
|
15629
15667
|
resolvedCliPath = syncPath;
|
|
15630
15668
|
debugLog2("using sync-resolved path:", syncPath);
|
|
15631
15669
|
return syncPath;
|
|
@@ -15661,7 +15699,7 @@ async function runCommentChecker(input, cliPath, customPrompt) {
|
|
|
15661
15699
|
debugLog2("comment-checker binary not found");
|
|
15662
15700
|
return { hasComments: false, message: "" };
|
|
15663
15701
|
}
|
|
15664
|
-
if (!
|
|
15702
|
+
if (!existsSync12(binaryPath)) {
|
|
15665
15703
|
debugLog2("comment-checker binary does not exist:", binaryPath);
|
|
15666
15704
|
return { hasComments: false, message: "" };
|
|
15667
15705
|
}
|
|
@@ -15699,11 +15737,11 @@ async function runCommentChecker(input, cliPath, customPrompt) {
|
|
|
15699
15737
|
|
|
15700
15738
|
// src/hooks/comment-checker/index.ts
|
|
15701
15739
|
import * as fs7 from "fs";
|
|
15702
|
-
import { existsSync as
|
|
15740
|
+
import { existsSync as existsSync13 } from "fs";
|
|
15703
15741
|
import { tmpdir as tmpdir4 } from "os";
|
|
15704
|
-
import { join as
|
|
15742
|
+
import { join as join16 } from "path";
|
|
15705
15743
|
var DEBUG3 = process.env.COMMENT_CHECKER_DEBUG === "1";
|
|
15706
|
-
var DEBUG_FILE3 =
|
|
15744
|
+
var DEBUG_FILE3 = join16(tmpdir4(), "comment-checker-debug.log");
|
|
15707
15745
|
function debugLog3(...args) {
|
|
15708
15746
|
if (DEBUG3) {
|
|
15709
15747
|
const msg = `[${new Date().toISOString()}] [comment-checker:hook] ${args.map((a) => typeof a === "object" ? JSON.stringify(a, null, 2) : String(a)).join(" ")}
|
|
@@ -15783,7 +15821,7 @@ function createCommentCheckerHooks(config) {
|
|
|
15783
15821
|
}
|
|
15784
15822
|
try {
|
|
15785
15823
|
const cliPath = await cliPathPromise;
|
|
15786
|
-
if (!cliPath || !
|
|
15824
|
+
if (!cliPath || !existsSync13(cliPath)) {
|
|
15787
15825
|
debugLog3("CLI not available, skipping comment check");
|
|
15788
15826
|
return;
|
|
15789
15827
|
}
|
|
@@ -15863,33 +15901,33 @@ function createToolOutputTruncatorHook(ctx, options) {
|
|
|
15863
15901
|
};
|
|
15864
15902
|
}
|
|
15865
15903
|
// src/hooks/directory-agents-injector/index.ts
|
|
15866
|
-
import { existsSync as
|
|
15867
|
-
import { dirname as dirname2, join as
|
|
15904
|
+
import { existsSync as existsSync15, readFileSync as readFileSync7 } from "fs";
|
|
15905
|
+
import { dirname as dirname2, join as join19, resolve as resolve3 } from "path";
|
|
15868
15906
|
|
|
15869
15907
|
// src/hooks/directory-agents-injector/storage.ts
|
|
15870
15908
|
import {
|
|
15871
|
-
existsSync as
|
|
15909
|
+
existsSync as existsSync14,
|
|
15872
15910
|
mkdirSync as mkdirSync4,
|
|
15873
15911
|
readFileSync as readFileSync6,
|
|
15874
15912
|
writeFileSync as writeFileSync4,
|
|
15875
15913
|
unlinkSync as unlinkSync3
|
|
15876
15914
|
} from "fs";
|
|
15877
|
-
import { join as
|
|
15915
|
+
import { join as join18 } from "path";
|
|
15878
15916
|
|
|
15879
15917
|
// src/hooks/directory-agents-injector/constants.ts
|
|
15880
15918
|
init_data_path();
|
|
15881
|
-
import { join as
|
|
15919
|
+
import { join as join17 } from "path";
|
|
15882
15920
|
var OPENCODE_STORAGE3 = getOpenCodeStorageDir();
|
|
15883
|
-
var AGENTS_INJECTOR_STORAGE =
|
|
15921
|
+
var AGENTS_INJECTOR_STORAGE = join17(OPENCODE_STORAGE3, "directory-agents");
|
|
15884
15922
|
var AGENTS_FILENAME = "AGENTS.md";
|
|
15885
15923
|
|
|
15886
15924
|
// src/hooks/directory-agents-injector/storage.ts
|
|
15887
15925
|
function getStoragePath(sessionID) {
|
|
15888
|
-
return
|
|
15926
|
+
return join18(AGENTS_INJECTOR_STORAGE, `${sessionID}.json`);
|
|
15889
15927
|
}
|
|
15890
15928
|
function loadInjectedPaths(sessionID) {
|
|
15891
15929
|
const filePath = getStoragePath(sessionID);
|
|
15892
|
-
if (!
|
|
15930
|
+
if (!existsSync14(filePath))
|
|
15893
15931
|
return new Set;
|
|
15894
15932
|
try {
|
|
15895
15933
|
const content = readFileSync6(filePath, "utf-8");
|
|
@@ -15900,7 +15938,7 @@ function loadInjectedPaths(sessionID) {
|
|
|
15900
15938
|
}
|
|
15901
15939
|
}
|
|
15902
15940
|
function saveInjectedPaths(sessionID, paths) {
|
|
15903
|
-
if (!
|
|
15941
|
+
if (!existsSync14(AGENTS_INJECTOR_STORAGE)) {
|
|
15904
15942
|
mkdirSync4(AGENTS_INJECTOR_STORAGE, { recursive: true });
|
|
15905
15943
|
}
|
|
15906
15944
|
const data = {
|
|
@@ -15912,7 +15950,7 @@ function saveInjectedPaths(sessionID, paths) {
|
|
|
15912
15950
|
}
|
|
15913
15951
|
function clearInjectedPaths(sessionID) {
|
|
15914
15952
|
const filePath = getStoragePath(sessionID);
|
|
15915
|
-
if (
|
|
15953
|
+
if (existsSync14(filePath)) {
|
|
15916
15954
|
unlinkSync3(filePath);
|
|
15917
15955
|
}
|
|
15918
15956
|
}
|
|
@@ -15942,8 +15980,8 @@ function createDirectoryAgentsInjectorHook(ctx) {
|
|
|
15942
15980
|
while (true) {
|
|
15943
15981
|
const isRootDir = current === ctx.directory;
|
|
15944
15982
|
if (!isRootDir) {
|
|
15945
|
-
const agentsPath =
|
|
15946
|
-
if (
|
|
15983
|
+
const agentsPath = join19(current, AGENTS_FILENAME);
|
|
15984
|
+
if (existsSync15(agentsPath)) {
|
|
15947
15985
|
found.push(agentsPath);
|
|
15948
15986
|
}
|
|
15949
15987
|
}
|
|
@@ -16040,33 +16078,33 @@ ${result}${truncationNotice}`;
|
|
|
16040
16078
|
};
|
|
16041
16079
|
}
|
|
16042
16080
|
// src/hooks/directory-readme-injector/index.ts
|
|
16043
|
-
import { existsSync as
|
|
16044
|
-
import { dirname as dirname3, join as
|
|
16081
|
+
import { existsSync as existsSync17, readFileSync as readFileSync9 } from "fs";
|
|
16082
|
+
import { dirname as dirname3, join as join22, resolve as resolve4 } from "path";
|
|
16045
16083
|
|
|
16046
16084
|
// src/hooks/directory-readme-injector/storage.ts
|
|
16047
16085
|
import {
|
|
16048
|
-
existsSync as
|
|
16086
|
+
existsSync as existsSync16,
|
|
16049
16087
|
mkdirSync as mkdirSync5,
|
|
16050
16088
|
readFileSync as readFileSync8,
|
|
16051
16089
|
writeFileSync as writeFileSync5,
|
|
16052
16090
|
unlinkSync as unlinkSync4
|
|
16053
16091
|
} from "fs";
|
|
16054
|
-
import { join as
|
|
16092
|
+
import { join as join21 } from "path";
|
|
16055
16093
|
|
|
16056
16094
|
// src/hooks/directory-readme-injector/constants.ts
|
|
16057
16095
|
init_data_path();
|
|
16058
|
-
import { join as
|
|
16096
|
+
import { join as join20 } from "path";
|
|
16059
16097
|
var OPENCODE_STORAGE4 = getOpenCodeStorageDir();
|
|
16060
|
-
var README_INJECTOR_STORAGE =
|
|
16098
|
+
var README_INJECTOR_STORAGE = join20(OPENCODE_STORAGE4, "directory-readme");
|
|
16061
16099
|
var README_FILENAME = "README.md";
|
|
16062
16100
|
|
|
16063
16101
|
// src/hooks/directory-readme-injector/storage.ts
|
|
16064
16102
|
function getStoragePath2(sessionID) {
|
|
16065
|
-
return
|
|
16103
|
+
return join21(README_INJECTOR_STORAGE, `${sessionID}.json`);
|
|
16066
16104
|
}
|
|
16067
16105
|
function loadInjectedPaths2(sessionID) {
|
|
16068
16106
|
const filePath = getStoragePath2(sessionID);
|
|
16069
|
-
if (!
|
|
16107
|
+
if (!existsSync16(filePath))
|
|
16070
16108
|
return new Set;
|
|
16071
16109
|
try {
|
|
16072
16110
|
const content = readFileSync8(filePath, "utf-8");
|
|
@@ -16077,7 +16115,7 @@ function loadInjectedPaths2(sessionID) {
|
|
|
16077
16115
|
}
|
|
16078
16116
|
}
|
|
16079
16117
|
function saveInjectedPaths2(sessionID, paths) {
|
|
16080
|
-
if (!
|
|
16118
|
+
if (!existsSync16(README_INJECTOR_STORAGE)) {
|
|
16081
16119
|
mkdirSync5(README_INJECTOR_STORAGE, { recursive: true });
|
|
16082
16120
|
}
|
|
16083
16121
|
const data = {
|
|
@@ -16089,7 +16127,7 @@ function saveInjectedPaths2(sessionID, paths) {
|
|
|
16089
16127
|
}
|
|
16090
16128
|
function clearInjectedPaths2(sessionID) {
|
|
16091
16129
|
const filePath = getStoragePath2(sessionID);
|
|
16092
|
-
if (
|
|
16130
|
+
if (existsSync16(filePath)) {
|
|
16093
16131
|
unlinkSync4(filePath);
|
|
16094
16132
|
}
|
|
16095
16133
|
}
|
|
@@ -16117,8 +16155,8 @@ function createDirectoryReadmeInjectorHook(ctx) {
|
|
|
16117
16155
|
const found = [];
|
|
16118
16156
|
let current = startDir;
|
|
16119
16157
|
while (true) {
|
|
16120
|
-
const readmePath =
|
|
16121
|
-
if (
|
|
16158
|
+
const readmePath = join22(current, README_FILENAME);
|
|
16159
|
+
if (existsSync17(readmePath)) {
|
|
16122
16160
|
found.push(readmePath);
|
|
16123
16161
|
}
|
|
16124
16162
|
if (current === ctx.directory)
|
|
@@ -16428,22 +16466,22 @@ var TRUNCATE_CONFIG = {
|
|
|
16428
16466
|
|
|
16429
16467
|
// src/hooks/anthropic-context-window-limit-recovery/storage.ts
|
|
16430
16468
|
init_data_path();
|
|
16431
|
-
import { existsSync as
|
|
16432
|
-
import { join as
|
|
16469
|
+
import { existsSync as existsSync18, readdirSync as readdirSync4, readFileSync as readFileSync10, writeFileSync as writeFileSync6 } from "fs";
|
|
16470
|
+
import { join as join23 } from "path";
|
|
16433
16471
|
var OPENCODE_STORAGE5 = getOpenCodeStorageDir();
|
|
16434
|
-
var MESSAGE_STORAGE3 =
|
|
16435
|
-
var PART_STORAGE3 =
|
|
16472
|
+
var MESSAGE_STORAGE3 = join23(OPENCODE_STORAGE5, "message");
|
|
16473
|
+
var PART_STORAGE3 = join23(OPENCODE_STORAGE5, "part");
|
|
16436
16474
|
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.]";
|
|
16437
16475
|
function getMessageDir3(sessionID) {
|
|
16438
|
-
if (!
|
|
16476
|
+
if (!existsSync18(MESSAGE_STORAGE3))
|
|
16439
16477
|
return "";
|
|
16440
|
-
const directPath =
|
|
16441
|
-
if (
|
|
16478
|
+
const directPath = join23(MESSAGE_STORAGE3, sessionID);
|
|
16479
|
+
if (existsSync18(directPath)) {
|
|
16442
16480
|
return directPath;
|
|
16443
16481
|
}
|
|
16444
16482
|
for (const dir of readdirSync4(MESSAGE_STORAGE3)) {
|
|
16445
|
-
const sessionPath =
|
|
16446
|
-
if (
|
|
16483
|
+
const sessionPath = join23(MESSAGE_STORAGE3, dir, sessionID);
|
|
16484
|
+
if (existsSync18(sessionPath)) {
|
|
16447
16485
|
return sessionPath;
|
|
16448
16486
|
}
|
|
16449
16487
|
}
|
|
@@ -16451,7 +16489,7 @@ function getMessageDir3(sessionID) {
|
|
|
16451
16489
|
}
|
|
16452
16490
|
function getMessageIds(sessionID) {
|
|
16453
16491
|
const messageDir = getMessageDir3(sessionID);
|
|
16454
|
-
if (!messageDir || !
|
|
16492
|
+
if (!messageDir || !existsSync18(messageDir))
|
|
16455
16493
|
return [];
|
|
16456
16494
|
const messageIds = [];
|
|
16457
16495
|
for (const file of readdirSync4(messageDir)) {
|
|
@@ -16466,14 +16504,14 @@ function findToolResultsBySize(sessionID) {
|
|
|
16466
16504
|
const messageIds = getMessageIds(sessionID);
|
|
16467
16505
|
const results = [];
|
|
16468
16506
|
for (const messageID of messageIds) {
|
|
16469
|
-
const partDir =
|
|
16470
|
-
if (!
|
|
16507
|
+
const partDir = join23(PART_STORAGE3, messageID);
|
|
16508
|
+
if (!existsSync18(partDir))
|
|
16471
16509
|
continue;
|
|
16472
16510
|
for (const file of readdirSync4(partDir)) {
|
|
16473
16511
|
if (!file.endsWith(".json"))
|
|
16474
16512
|
continue;
|
|
16475
16513
|
try {
|
|
16476
|
-
const partPath =
|
|
16514
|
+
const partPath = join23(partDir, file);
|
|
16477
16515
|
const content = readFileSync10(partPath, "utf-8");
|
|
16478
16516
|
const part = JSON.parse(content);
|
|
16479
16517
|
if (part.type === "tool" && part.state?.output && !part.truncated) {
|
|
@@ -17305,8 +17343,8 @@ function createThinkModeHook() {
|
|
|
17305
17343
|
}
|
|
17306
17344
|
// src/hooks/claude-code-hooks/config.ts
|
|
17307
17345
|
init_shared();
|
|
17308
|
-
import { join as
|
|
17309
|
-
import { existsSync as
|
|
17346
|
+
import { join as join24 } from "path";
|
|
17347
|
+
import { existsSync as existsSync19 } from "fs";
|
|
17310
17348
|
function normalizeHookMatcher(raw) {
|
|
17311
17349
|
return {
|
|
17312
17350
|
matcher: raw.matcher ?? raw.pattern ?? "*",
|
|
@@ -17332,11 +17370,11 @@ function normalizeHooksConfig(raw) {
|
|
|
17332
17370
|
function getClaudeSettingsPaths(customPath) {
|
|
17333
17371
|
const claudeConfigDir = getClaudeConfigDir();
|
|
17334
17372
|
const paths = [
|
|
17335
|
-
|
|
17336
|
-
|
|
17337
|
-
|
|
17373
|
+
join24(claudeConfigDir, "settings.json"),
|
|
17374
|
+
join24(process.cwd(), ".claude", "settings.json"),
|
|
17375
|
+
join24(process.cwd(), ".claude", "settings.local.json")
|
|
17338
17376
|
];
|
|
17339
|
-
if (customPath &&
|
|
17377
|
+
if (customPath && existsSync19(customPath)) {
|
|
17340
17378
|
paths.unshift(customPath);
|
|
17341
17379
|
}
|
|
17342
17380
|
return paths;
|
|
@@ -17361,7 +17399,7 @@ async function loadClaudeHooksConfig(customSettingsPath) {
|
|
|
17361
17399
|
const paths = getClaudeSettingsPaths(customSettingsPath);
|
|
17362
17400
|
let mergedConfig = {};
|
|
17363
17401
|
for (const settingsPath of paths) {
|
|
17364
|
-
if (
|
|
17402
|
+
if (existsSync19(settingsPath)) {
|
|
17365
17403
|
try {
|
|
17366
17404
|
const content = await Bun.file(settingsPath).text();
|
|
17367
17405
|
const settings = JSON.parse(content);
|
|
@@ -17379,15 +17417,15 @@ async function loadClaudeHooksConfig(customSettingsPath) {
|
|
|
17379
17417
|
|
|
17380
17418
|
// src/hooks/claude-code-hooks/config-loader.ts
|
|
17381
17419
|
init_logger();
|
|
17382
|
-
import { existsSync as
|
|
17420
|
+
import { existsSync as existsSync20 } from "fs";
|
|
17383
17421
|
import { homedir as homedir8 } from "os";
|
|
17384
|
-
import { join as
|
|
17385
|
-
var USER_CONFIG_PATH =
|
|
17422
|
+
import { join as join25 } from "path";
|
|
17423
|
+
var USER_CONFIG_PATH = join25(homedir8(), ".config", "opencode", "opencode-cc-plugin.json");
|
|
17386
17424
|
function getProjectConfigPath() {
|
|
17387
|
-
return
|
|
17425
|
+
return join25(process.cwd(), ".opencode", "opencode-cc-plugin.json");
|
|
17388
17426
|
}
|
|
17389
17427
|
async function loadConfigFromPath(path5) {
|
|
17390
|
-
if (!
|
|
17428
|
+
if (!existsSync20(path5)) {
|
|
17391
17429
|
return null;
|
|
17392
17430
|
}
|
|
17393
17431
|
try {
|
|
@@ -17575,16 +17613,16 @@ init_shared();
|
|
|
17575
17613
|
// src/hooks/claude-code-hooks/transcript.ts
|
|
17576
17614
|
init_tool_name();
|
|
17577
17615
|
init_shared();
|
|
17578
|
-
import { join as
|
|
17579
|
-
import { mkdirSync as mkdirSync6, appendFileSync as appendFileSync5, existsSync as
|
|
17616
|
+
import { join as join26 } from "path";
|
|
17617
|
+
import { mkdirSync as mkdirSync6, appendFileSync as appendFileSync5, existsSync as existsSync21, writeFileSync as writeFileSync7, unlinkSync as unlinkSync5 } from "fs";
|
|
17580
17618
|
import { tmpdir as tmpdir5 } from "os";
|
|
17581
17619
|
import { randomUUID } from "crypto";
|
|
17582
|
-
var TRANSCRIPT_DIR =
|
|
17620
|
+
var TRANSCRIPT_DIR = join26(getClaudeConfigDir(), "transcripts");
|
|
17583
17621
|
function getTranscriptPath(sessionId) {
|
|
17584
|
-
return
|
|
17622
|
+
return join26(TRANSCRIPT_DIR, `${sessionId}.jsonl`);
|
|
17585
17623
|
}
|
|
17586
17624
|
function ensureTranscriptDir() {
|
|
17587
|
-
if (!
|
|
17625
|
+
if (!existsSync21(TRANSCRIPT_DIR)) {
|
|
17588
17626
|
mkdirSync6(TRANSCRIPT_DIR, { recursive: true });
|
|
17589
17627
|
}
|
|
17590
17628
|
}
|
|
@@ -17671,7 +17709,7 @@ async function buildTranscriptFromSession(client, sessionId, directory, currentT
|
|
|
17671
17709
|
}
|
|
17672
17710
|
};
|
|
17673
17711
|
entries.push(JSON.stringify(currentEntry));
|
|
17674
|
-
const tempPath =
|
|
17712
|
+
const tempPath = join26(tmpdir5(), `opencode-transcript-${sessionId}-${randomUUID()}.jsonl`);
|
|
17675
17713
|
writeFileSync7(tempPath, entries.join(`
|
|
17676
17714
|
`) + `
|
|
17677
17715
|
`);
|
|
@@ -17691,7 +17729,7 @@ async function buildTranscriptFromSession(client, sessionId, directory, currentT
|
|
|
17691
17729
|
]
|
|
17692
17730
|
}
|
|
17693
17731
|
};
|
|
17694
|
-
const tempPath =
|
|
17732
|
+
const tempPath = join26(tmpdir5(), `opencode-transcript-${sessionId}-${randomUUID()}.jsonl`);
|
|
17695
17733
|
writeFileSync7(tempPath, JSON.stringify(currentEntry) + `
|
|
17696
17734
|
`);
|
|
17697
17735
|
return tempPath;
|
|
@@ -17907,11 +17945,11 @@ ${USER_PROMPT_SUBMIT_TAG_CLOSE}`);
|
|
|
17907
17945
|
init_shared();
|
|
17908
17946
|
|
|
17909
17947
|
// src/hooks/claude-code-hooks/todo.ts
|
|
17910
|
-
import { join as
|
|
17948
|
+
import { join as join27 } from "path";
|
|
17911
17949
|
init_shared();
|
|
17912
|
-
var TODO_DIR =
|
|
17950
|
+
var TODO_DIR = join27(getClaudeConfigDir(), "todos");
|
|
17913
17951
|
function getTodoPath(sessionId) {
|
|
17914
|
-
return
|
|
17952
|
+
return join27(TODO_DIR, `${sessionId}-agent-${sessionId}.json`);
|
|
17915
17953
|
}
|
|
17916
17954
|
|
|
17917
17955
|
// src/hooks/claude-code-hooks/stop.ts
|
|
@@ -18359,18 +18397,18 @@ import { relative as relative3, resolve as resolve5 } from "path";
|
|
|
18359
18397
|
|
|
18360
18398
|
// src/hooks/rules-injector/finder.ts
|
|
18361
18399
|
import {
|
|
18362
|
-
existsSync as
|
|
18400
|
+
existsSync as existsSync22,
|
|
18363
18401
|
readdirSync as readdirSync5,
|
|
18364
18402
|
realpathSync,
|
|
18365
18403
|
statSync as statSync2
|
|
18366
18404
|
} from "fs";
|
|
18367
|
-
import { dirname as dirname4, join as
|
|
18405
|
+
import { dirname as dirname4, join as join29, relative } from "path";
|
|
18368
18406
|
|
|
18369
18407
|
// src/hooks/rules-injector/constants.ts
|
|
18370
18408
|
init_data_path();
|
|
18371
|
-
import { join as
|
|
18409
|
+
import { join as join28 } from "path";
|
|
18372
18410
|
var OPENCODE_STORAGE6 = getOpenCodeStorageDir();
|
|
18373
|
-
var RULES_INJECTOR_STORAGE =
|
|
18411
|
+
var RULES_INJECTOR_STORAGE = join28(OPENCODE_STORAGE6, "rules-injector");
|
|
18374
18412
|
var PROJECT_MARKERS = [
|
|
18375
18413
|
".git",
|
|
18376
18414
|
"pyproject.toml",
|
|
@@ -18411,8 +18449,8 @@ function findProjectRoot(startPath) {
|
|
|
18411
18449
|
}
|
|
18412
18450
|
while (true) {
|
|
18413
18451
|
for (const marker of PROJECT_MARKERS) {
|
|
18414
|
-
const markerPath =
|
|
18415
|
-
if (
|
|
18452
|
+
const markerPath = join29(current, marker);
|
|
18453
|
+
if (existsSync22(markerPath)) {
|
|
18416
18454
|
return current;
|
|
18417
18455
|
}
|
|
18418
18456
|
}
|
|
@@ -18424,12 +18462,12 @@ function findProjectRoot(startPath) {
|
|
|
18424
18462
|
}
|
|
18425
18463
|
}
|
|
18426
18464
|
function findRuleFilesRecursive(dir, results) {
|
|
18427
|
-
if (!
|
|
18465
|
+
if (!existsSync22(dir))
|
|
18428
18466
|
return;
|
|
18429
18467
|
try {
|
|
18430
18468
|
const entries = readdirSync5(dir, { withFileTypes: true });
|
|
18431
18469
|
for (const entry of entries) {
|
|
18432
|
-
const fullPath =
|
|
18470
|
+
const fullPath = join29(dir, entry.name);
|
|
18433
18471
|
if (entry.isDirectory()) {
|
|
18434
18472
|
findRuleFilesRecursive(fullPath, results);
|
|
18435
18473
|
} else if (entry.isFile()) {
|
|
@@ -18454,7 +18492,7 @@ function findRuleFiles(projectRoot, homeDir, currentFile) {
|
|
|
18454
18492
|
let distance = 0;
|
|
18455
18493
|
while (true) {
|
|
18456
18494
|
for (const [parent, subdir] of PROJECT_RULE_SUBDIRS) {
|
|
18457
|
-
const ruleDir =
|
|
18495
|
+
const ruleDir = join29(currentDir, parent, subdir);
|
|
18458
18496
|
const files = [];
|
|
18459
18497
|
findRuleFilesRecursive(ruleDir, files);
|
|
18460
18498
|
for (const filePath of files) {
|
|
@@ -18480,8 +18518,8 @@ function findRuleFiles(projectRoot, homeDir, currentFile) {
|
|
|
18480
18518
|
}
|
|
18481
18519
|
if (projectRoot) {
|
|
18482
18520
|
for (const ruleFile of PROJECT_RULE_FILES) {
|
|
18483
|
-
const filePath =
|
|
18484
|
-
if (
|
|
18521
|
+
const filePath = join29(projectRoot, ruleFile);
|
|
18522
|
+
if (existsSync22(filePath)) {
|
|
18485
18523
|
try {
|
|
18486
18524
|
const stat = statSync2(filePath);
|
|
18487
18525
|
if (stat.isFile()) {
|
|
@@ -18501,7 +18539,7 @@ function findRuleFiles(projectRoot, homeDir, currentFile) {
|
|
|
18501
18539
|
}
|
|
18502
18540
|
}
|
|
18503
18541
|
}
|
|
18504
|
-
const userRuleDir =
|
|
18542
|
+
const userRuleDir = join29(homeDir, USER_RULE_DIR);
|
|
18505
18543
|
const userFiles = [];
|
|
18506
18544
|
findRuleFilesRecursive(userRuleDir, userFiles);
|
|
18507
18545
|
for (const filePath of userFiles) {
|
|
@@ -18690,19 +18728,19 @@ function mergeGlobs(existing, newValue) {
|
|
|
18690
18728
|
|
|
18691
18729
|
// src/hooks/rules-injector/storage.ts
|
|
18692
18730
|
import {
|
|
18693
|
-
existsSync as
|
|
18731
|
+
existsSync as existsSync23,
|
|
18694
18732
|
mkdirSync as mkdirSync7,
|
|
18695
18733
|
readFileSync as readFileSync11,
|
|
18696
18734
|
writeFileSync as writeFileSync8,
|
|
18697
18735
|
unlinkSync as unlinkSync6
|
|
18698
18736
|
} from "fs";
|
|
18699
|
-
import { join as
|
|
18737
|
+
import { join as join30 } from "path";
|
|
18700
18738
|
function getStoragePath3(sessionID) {
|
|
18701
|
-
return
|
|
18739
|
+
return join30(RULES_INJECTOR_STORAGE, `${sessionID}.json`);
|
|
18702
18740
|
}
|
|
18703
18741
|
function loadInjectedRules(sessionID) {
|
|
18704
18742
|
const filePath = getStoragePath3(sessionID);
|
|
18705
|
-
if (!
|
|
18743
|
+
if (!existsSync23(filePath))
|
|
18706
18744
|
return { contentHashes: new Set, realPaths: new Set };
|
|
18707
18745
|
try {
|
|
18708
18746
|
const content = readFileSync11(filePath, "utf-8");
|
|
@@ -18716,7 +18754,7 @@ function loadInjectedRules(sessionID) {
|
|
|
18716
18754
|
}
|
|
18717
18755
|
}
|
|
18718
18756
|
function saveInjectedRules(sessionID, data) {
|
|
18719
|
-
if (!
|
|
18757
|
+
if (!existsSync23(RULES_INJECTOR_STORAGE)) {
|
|
18720
18758
|
mkdirSync7(RULES_INJECTOR_STORAGE, { recursive: true });
|
|
18721
18759
|
}
|
|
18722
18760
|
const storageData = {
|
|
@@ -18729,7 +18767,7 @@ function saveInjectedRules(sessionID, data) {
|
|
|
18729
18767
|
}
|
|
18730
18768
|
function clearInjectedRules(sessionID) {
|
|
18731
18769
|
const filePath = getStoragePath3(sessionID);
|
|
18732
|
-
if (
|
|
18770
|
+
if (existsSync23(filePath)) {
|
|
18733
18771
|
unlinkSync6(filePath);
|
|
18734
18772
|
}
|
|
18735
18773
|
}
|
|
@@ -18885,19 +18923,19 @@ init_auto_update_checker();
|
|
|
18885
18923
|
|
|
18886
18924
|
// src/hooks/agent-usage-reminder/storage.ts
|
|
18887
18925
|
import {
|
|
18888
|
-
existsSync as
|
|
18926
|
+
existsSync as existsSync27,
|
|
18889
18927
|
mkdirSync as mkdirSync8,
|
|
18890
18928
|
readFileSync as readFileSync15,
|
|
18891
18929
|
writeFileSync as writeFileSync11,
|
|
18892
18930
|
unlinkSync as unlinkSync7
|
|
18893
18931
|
} from "fs";
|
|
18894
|
-
import { join as
|
|
18932
|
+
import { join as join35 } from "path";
|
|
18895
18933
|
|
|
18896
18934
|
// src/hooks/agent-usage-reminder/constants.ts
|
|
18897
18935
|
init_data_path();
|
|
18898
|
-
import { join as
|
|
18936
|
+
import { join as join34 } from "path";
|
|
18899
18937
|
var OPENCODE_STORAGE7 = getOpenCodeStorageDir();
|
|
18900
|
-
var AGENT_USAGE_REMINDER_STORAGE =
|
|
18938
|
+
var AGENT_USAGE_REMINDER_STORAGE = join34(OPENCODE_STORAGE7, "agent-usage-reminder");
|
|
18901
18939
|
var TARGET_TOOLS = new Set([
|
|
18902
18940
|
"grep",
|
|
18903
18941
|
"safe_grep",
|
|
@@ -18943,11 +18981,11 @@ ALWAYS prefer: Multiple parallel delegate_task calls > Direct tool calls
|
|
|
18943
18981
|
|
|
18944
18982
|
// src/hooks/agent-usage-reminder/storage.ts
|
|
18945
18983
|
function getStoragePath4(sessionID) {
|
|
18946
|
-
return
|
|
18984
|
+
return join35(AGENT_USAGE_REMINDER_STORAGE, `${sessionID}.json`);
|
|
18947
18985
|
}
|
|
18948
18986
|
function loadAgentUsageState(sessionID) {
|
|
18949
18987
|
const filePath = getStoragePath4(sessionID);
|
|
18950
|
-
if (!
|
|
18988
|
+
if (!existsSync27(filePath))
|
|
18951
18989
|
return null;
|
|
18952
18990
|
try {
|
|
18953
18991
|
const content = readFileSync15(filePath, "utf-8");
|
|
@@ -18957,7 +18995,7 @@ function loadAgentUsageState(sessionID) {
|
|
|
18957
18995
|
}
|
|
18958
18996
|
}
|
|
18959
18997
|
function saveAgentUsageState(state2) {
|
|
18960
|
-
if (!
|
|
18998
|
+
if (!existsSync27(AGENT_USAGE_REMINDER_STORAGE)) {
|
|
18961
18999
|
mkdirSync8(AGENT_USAGE_REMINDER_STORAGE, { recursive: true });
|
|
18962
19000
|
}
|
|
18963
19001
|
const filePath = getStoragePath4(state2.sessionID);
|
|
@@ -18965,7 +19003,7 @@ function saveAgentUsageState(state2) {
|
|
|
18965
19003
|
}
|
|
18966
19004
|
function clearAgentUsageState(sessionID) {
|
|
18967
19005
|
const filePath = getStoragePath4(sessionID);
|
|
18968
|
-
if (
|
|
19006
|
+
if (existsSync27(filePath)) {
|
|
18969
19007
|
unlinkSync7(filePath);
|
|
18970
19008
|
}
|
|
18971
19009
|
}
|
|
@@ -19449,19 +19487,19 @@ function createNonInteractiveEnvHook(_ctx) {
|
|
|
19449
19487
|
}
|
|
19450
19488
|
// src/hooks/interactive-bash-session/storage.ts
|
|
19451
19489
|
import {
|
|
19452
|
-
existsSync as
|
|
19490
|
+
existsSync as existsSync28,
|
|
19453
19491
|
mkdirSync as mkdirSync9,
|
|
19454
19492
|
readFileSync as readFileSync16,
|
|
19455
19493
|
writeFileSync as writeFileSync12,
|
|
19456
19494
|
unlinkSync as unlinkSync8
|
|
19457
19495
|
} from "fs";
|
|
19458
|
-
import { join as
|
|
19496
|
+
import { join as join37 } from "path";
|
|
19459
19497
|
|
|
19460
19498
|
// src/hooks/interactive-bash-session/constants.ts
|
|
19461
19499
|
init_data_path();
|
|
19462
|
-
import { join as
|
|
19500
|
+
import { join as join36 } from "path";
|
|
19463
19501
|
var OPENCODE_STORAGE8 = getOpenCodeStorageDir();
|
|
19464
|
-
var INTERACTIVE_BASH_SESSION_STORAGE =
|
|
19502
|
+
var INTERACTIVE_BASH_SESSION_STORAGE = join36(OPENCODE_STORAGE8, "interactive-bash-session");
|
|
19465
19503
|
var OMO_SESSION_PREFIX = "omo-";
|
|
19466
19504
|
function buildSessionReminderMessage(sessions) {
|
|
19467
19505
|
if (sessions.length === 0)
|
|
@@ -19473,11 +19511,11 @@ function buildSessionReminderMessage(sessions) {
|
|
|
19473
19511
|
|
|
19474
19512
|
// src/hooks/interactive-bash-session/storage.ts
|
|
19475
19513
|
function getStoragePath5(sessionID) {
|
|
19476
|
-
return
|
|
19514
|
+
return join37(INTERACTIVE_BASH_SESSION_STORAGE, `${sessionID}.json`);
|
|
19477
19515
|
}
|
|
19478
19516
|
function loadInteractiveBashSessionState(sessionID) {
|
|
19479
19517
|
const filePath = getStoragePath5(sessionID);
|
|
19480
|
-
if (!
|
|
19518
|
+
if (!existsSync28(filePath))
|
|
19481
19519
|
return null;
|
|
19482
19520
|
try {
|
|
19483
19521
|
const content = readFileSync16(filePath, "utf-8");
|
|
@@ -19492,7 +19530,7 @@ function loadInteractiveBashSessionState(sessionID) {
|
|
|
19492
19530
|
}
|
|
19493
19531
|
}
|
|
19494
19532
|
function saveInteractiveBashSessionState(state2) {
|
|
19495
|
-
if (!
|
|
19533
|
+
if (!existsSync28(INTERACTIVE_BASH_SESSION_STORAGE)) {
|
|
19496
19534
|
mkdirSync9(INTERACTIVE_BASH_SESSION_STORAGE, { recursive: true });
|
|
19497
19535
|
}
|
|
19498
19536
|
const filePath = getStoragePath5(state2.sessionID);
|
|
@@ -19505,7 +19543,7 @@ function saveInteractiveBashSessionState(state2) {
|
|
|
19505
19543
|
}
|
|
19506
19544
|
function clearInteractiveBashSessionState(sessionID) {
|
|
19507
19545
|
const filePath = getStoragePath5(sessionID);
|
|
19508
|
-
if (
|
|
19546
|
+
if (existsSync28(filePath)) {
|
|
19509
19547
|
unlinkSync8(filePath);
|
|
19510
19548
|
}
|
|
19511
19549
|
}
|
|
@@ -19838,13 +19876,13 @@ function createThinkingBlockValidatorHook() {
|
|
|
19838
19876
|
// src/hooks/ralph-loop/index.ts
|
|
19839
19877
|
init_logger();
|
|
19840
19878
|
init_system_directive();
|
|
19841
|
-
import { existsSync as
|
|
19842
|
-
import { join as
|
|
19879
|
+
import { existsSync as existsSync30, readFileSync as readFileSync18, readdirSync as readdirSync6 } from "fs";
|
|
19880
|
+
import { join as join39 } from "path";
|
|
19843
19881
|
|
|
19844
19882
|
// src/hooks/ralph-loop/storage.ts
|
|
19845
19883
|
init_frontmatter();
|
|
19846
|
-
import { existsSync as
|
|
19847
|
-
import { dirname as dirname6, join as
|
|
19884
|
+
import { existsSync as existsSync29, readFileSync as readFileSync17, writeFileSync as writeFileSync13, unlinkSync as unlinkSync9, mkdirSync as mkdirSync10 } from "fs";
|
|
19885
|
+
import { dirname as dirname6, join as join38 } from "path";
|
|
19848
19886
|
|
|
19849
19887
|
// src/hooks/ralph-loop/constants.ts
|
|
19850
19888
|
var HOOK_NAME3 = "ralph-loop";
|
|
@@ -19854,11 +19892,11 @@ var DEFAULT_COMPLETION_PROMISE = "DONE";
|
|
|
19854
19892
|
|
|
19855
19893
|
// src/hooks/ralph-loop/storage.ts
|
|
19856
19894
|
function getStateFilePath(directory, customPath) {
|
|
19857
|
-
return customPath ?
|
|
19895
|
+
return customPath ? join38(directory, customPath) : join38(directory, DEFAULT_STATE_FILE);
|
|
19858
19896
|
}
|
|
19859
19897
|
function readState(directory, customPath) {
|
|
19860
19898
|
const filePath = getStateFilePath(directory, customPath);
|
|
19861
|
-
if (!
|
|
19899
|
+
if (!existsSync29(filePath)) {
|
|
19862
19900
|
return null;
|
|
19863
19901
|
}
|
|
19864
19902
|
try {
|
|
@@ -19895,7 +19933,7 @@ function writeState(directory, state2, customPath) {
|
|
|
19895
19933
|
const filePath = getStateFilePath(directory, customPath);
|
|
19896
19934
|
try {
|
|
19897
19935
|
const dir = dirname6(filePath);
|
|
19898
|
-
if (!
|
|
19936
|
+
if (!existsSync29(dir)) {
|
|
19899
19937
|
mkdirSync10(dir, { recursive: true });
|
|
19900
19938
|
}
|
|
19901
19939
|
const sessionIdLine = state2.session_id ? `session_id: "${state2.session_id}"
|
|
@@ -19918,7 +19956,7 @@ ${state2.prompt}
|
|
|
19918
19956
|
function clearState(directory, customPath) {
|
|
19919
19957
|
const filePath = getStateFilePath(directory, customPath);
|
|
19920
19958
|
try {
|
|
19921
|
-
if (
|
|
19959
|
+
if (existsSync29(filePath)) {
|
|
19922
19960
|
unlinkSync9(filePath);
|
|
19923
19961
|
}
|
|
19924
19962
|
return true;
|
|
@@ -19939,14 +19977,14 @@ function incrementIteration(directory, customPath) {
|
|
|
19939
19977
|
|
|
19940
19978
|
// src/hooks/ralph-loop/index.ts
|
|
19941
19979
|
function getMessageDir4(sessionID) {
|
|
19942
|
-
if (!
|
|
19980
|
+
if (!existsSync30(MESSAGE_STORAGE))
|
|
19943
19981
|
return null;
|
|
19944
|
-
const directPath =
|
|
19945
|
-
if (
|
|
19982
|
+
const directPath = join39(MESSAGE_STORAGE, sessionID);
|
|
19983
|
+
if (existsSync30(directPath))
|
|
19946
19984
|
return directPath;
|
|
19947
19985
|
for (const dir of readdirSync6(MESSAGE_STORAGE)) {
|
|
19948
|
-
const sessionPath =
|
|
19949
|
-
if (
|
|
19986
|
+
const sessionPath = join39(MESSAGE_STORAGE, dir, sessionID);
|
|
19987
|
+
if (existsSync30(sessionPath))
|
|
19950
19988
|
return sessionPath;
|
|
19951
19989
|
}
|
|
19952
19990
|
return null;
|
|
@@ -19983,7 +20021,7 @@ function createRalphLoopHook(ctx, options) {
|
|
|
19983
20021
|
if (!transcriptPath)
|
|
19984
20022
|
return false;
|
|
19985
20023
|
try {
|
|
19986
|
-
if (!
|
|
20024
|
+
if (!existsSync30(transcriptPath))
|
|
19987
20025
|
return false;
|
|
19988
20026
|
const content = readFileSync18(transcriptPath, "utf-8");
|
|
19989
20027
|
const pattern = new RegExp(`<promise>\\s*${escapeRegex(promise)}\\s*</promise>`, "is");
|
|
@@ -20281,8 +20319,8 @@ function extractPromptText3(parts) {
|
|
|
20281
20319
|
// src/hooks/auto-slash-command/executor.ts
|
|
20282
20320
|
init_shared();
|
|
20283
20321
|
init_file_utils();
|
|
20284
|
-
import { existsSync as
|
|
20285
|
-
import { join as
|
|
20322
|
+
import { existsSync as existsSync32, readdirSync as readdirSync7, readFileSync as readFileSync21 } from "fs";
|
|
20323
|
+
import { join as join41, basename as basename2, dirname as dirname8 } from "path";
|
|
20286
20324
|
import { homedir as homedir14 } from "os";
|
|
20287
20325
|
// src/features/opencode-skill-loader/loader.ts
|
|
20288
20326
|
init_js_yaml();
|
|
@@ -20290,7 +20328,7 @@ init_frontmatter();
|
|
|
20290
20328
|
init_file_utils();
|
|
20291
20329
|
init_shared();
|
|
20292
20330
|
import { promises as fs11 } from "fs";
|
|
20293
|
-
import { join as
|
|
20331
|
+
import { join as join40, basename } from "path";
|
|
20294
20332
|
import { homedir as homedir12 } from "os";
|
|
20295
20333
|
function parseSkillMcpConfigFromFrontmatter(content) {
|
|
20296
20334
|
const frontmatterMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
@@ -20307,7 +20345,7 @@ function parseSkillMcpConfigFromFrontmatter(content) {
|
|
|
20307
20345
|
return;
|
|
20308
20346
|
}
|
|
20309
20347
|
async function loadMcpJsonFromDir(skillDir) {
|
|
20310
|
-
const mcpJsonPath =
|
|
20348
|
+
const mcpJsonPath = join40(skillDir, "mcp.json");
|
|
20311
20349
|
try {
|
|
20312
20350
|
const content = await fs11.readFile(mcpJsonPath, "utf-8");
|
|
20313
20351
|
const parsed = JSON.parse(content);
|
|
@@ -20388,11 +20426,11 @@ async function loadSkillsFromDir(skillsDir, scope) {
|
|
|
20388
20426
|
for (const entry of entries) {
|
|
20389
20427
|
if (entry.name.startsWith("."))
|
|
20390
20428
|
continue;
|
|
20391
|
-
const entryPath =
|
|
20429
|
+
const entryPath = join40(skillsDir, entry.name);
|
|
20392
20430
|
if (entry.isDirectory() || entry.isSymbolicLink()) {
|
|
20393
20431
|
const resolvedPath = await resolveSymlinkAsync(entryPath);
|
|
20394
20432
|
const dirName = entry.name;
|
|
20395
|
-
const skillMdPath =
|
|
20433
|
+
const skillMdPath = join40(resolvedPath, "SKILL.md");
|
|
20396
20434
|
try {
|
|
20397
20435
|
await fs11.access(skillMdPath);
|
|
20398
20436
|
const skill = await loadSkillFromPath(skillMdPath, resolvedPath, dirName, scope);
|
|
@@ -20400,7 +20438,7 @@ async function loadSkillsFromDir(skillsDir, scope) {
|
|
|
20400
20438
|
skills.push(skill);
|
|
20401
20439
|
continue;
|
|
20402
20440
|
} catch {}
|
|
20403
|
-
const namedSkillMdPath =
|
|
20441
|
+
const namedSkillMdPath = join40(resolvedPath, `${dirName}.md`);
|
|
20404
20442
|
try {
|
|
20405
20443
|
await fs11.access(namedSkillMdPath);
|
|
20406
20444
|
const skill = await loadSkillFromPath(namedSkillMdPath, resolvedPath, dirName, scope);
|
|
@@ -20428,22 +20466,22 @@ function skillsToRecord(skills) {
|
|
|
20428
20466
|
return result;
|
|
20429
20467
|
}
|
|
20430
20468
|
async function loadUserSkills() {
|
|
20431
|
-
const userSkillsDir =
|
|
20469
|
+
const userSkillsDir = join40(getClaudeConfigDir(), "skills");
|
|
20432
20470
|
const skills = await loadSkillsFromDir(userSkillsDir, "user");
|
|
20433
20471
|
return skillsToRecord(skills);
|
|
20434
20472
|
}
|
|
20435
20473
|
async function loadProjectSkills() {
|
|
20436
|
-
const projectSkillsDir =
|
|
20474
|
+
const projectSkillsDir = join40(process.cwd(), ".claude", "skills");
|
|
20437
20475
|
const skills = await loadSkillsFromDir(projectSkillsDir, "project");
|
|
20438
20476
|
return skillsToRecord(skills);
|
|
20439
20477
|
}
|
|
20440
20478
|
async function loadOpencodeGlobalSkills() {
|
|
20441
|
-
const opencodeSkillsDir =
|
|
20479
|
+
const opencodeSkillsDir = join40(homedir12(), ".config", "opencode", "skill");
|
|
20442
20480
|
const skills = await loadSkillsFromDir(opencodeSkillsDir, "opencode");
|
|
20443
20481
|
return skillsToRecord(skills);
|
|
20444
20482
|
}
|
|
20445
20483
|
async function loadOpencodeProjectSkills() {
|
|
20446
|
-
const opencodeProjectDir =
|
|
20484
|
+
const opencodeProjectDir = join40(process.cwd(), ".opencode", "skill");
|
|
20447
20485
|
const skills = await loadSkillsFromDir(opencodeProjectDir, "opencode-project");
|
|
20448
20486
|
return skillsToRecord(skills);
|
|
20449
20487
|
}
|
|
@@ -20472,25 +20510,25 @@ async function discoverSkills(options = {}) {
|
|
|
20472
20510
|
return [...opencodeProjectSkills, ...projectSkills, ...opencodeGlobalSkills, ...userSkills];
|
|
20473
20511
|
}
|
|
20474
20512
|
async function discoverUserClaudeSkills() {
|
|
20475
|
-
const userSkillsDir =
|
|
20513
|
+
const userSkillsDir = join40(getClaudeConfigDir(), "skills");
|
|
20476
20514
|
return loadSkillsFromDir(userSkillsDir, "user");
|
|
20477
20515
|
}
|
|
20478
20516
|
async function discoverProjectClaudeSkills() {
|
|
20479
|
-
const projectSkillsDir =
|
|
20517
|
+
const projectSkillsDir = join40(process.cwd(), ".claude", "skills");
|
|
20480
20518
|
return loadSkillsFromDir(projectSkillsDir, "project");
|
|
20481
20519
|
}
|
|
20482
20520
|
async function discoverOpencodeGlobalSkills() {
|
|
20483
|
-
const opencodeSkillsDir =
|
|
20521
|
+
const opencodeSkillsDir = join40(homedir12(), ".config", "opencode", "skill");
|
|
20484
20522
|
return loadSkillsFromDir(opencodeSkillsDir, "opencode");
|
|
20485
20523
|
}
|
|
20486
20524
|
async function discoverOpencodeProjectSkills() {
|
|
20487
|
-
const opencodeProjectDir =
|
|
20525
|
+
const opencodeProjectDir = join40(process.cwd(), ".opencode", "skill");
|
|
20488
20526
|
return loadSkillsFromDir(opencodeProjectDir, "opencode-project");
|
|
20489
20527
|
}
|
|
20490
20528
|
// src/features/opencode-skill-loader/merger.ts
|
|
20491
20529
|
init_frontmatter();
|
|
20492
20530
|
init_deep_merge();
|
|
20493
|
-
import { readFileSync as readFileSync19, existsSync as
|
|
20531
|
+
import { readFileSync as readFileSync19, existsSync as existsSync31 } from "fs";
|
|
20494
20532
|
import { dirname as dirname7, resolve as resolve6, isAbsolute as isAbsolute2 } from "path";
|
|
20495
20533
|
import { homedir as homedir13 } from "os";
|
|
20496
20534
|
var SCOPE_PRIORITY = {
|
|
@@ -20538,7 +20576,7 @@ function resolveFilePath2(from, configDir) {
|
|
|
20538
20576
|
}
|
|
20539
20577
|
function loadSkillFromFile(filePath) {
|
|
20540
20578
|
try {
|
|
20541
|
-
if (!
|
|
20579
|
+
if (!existsSync31(filePath))
|
|
20542
20580
|
return null;
|
|
20543
20581
|
const content = readFileSync19(filePath, "utf-8");
|
|
20544
20582
|
const { data, body } = parseFrontmatter(content);
|
|
@@ -22239,7 +22277,7 @@ async function resolveMultipleSkillsAsync(skillNames, options) {
|
|
|
22239
22277
|
}
|
|
22240
22278
|
// src/hooks/auto-slash-command/executor.ts
|
|
22241
22279
|
function discoverCommandsFromDir(commandsDir, scope) {
|
|
22242
|
-
if (!
|
|
22280
|
+
if (!existsSync32(commandsDir)) {
|
|
22243
22281
|
return [];
|
|
22244
22282
|
}
|
|
22245
22283
|
const entries = readdirSync7(commandsDir, { withFileTypes: true });
|
|
@@ -22247,7 +22285,7 @@ function discoverCommandsFromDir(commandsDir, scope) {
|
|
|
22247
22285
|
for (const entry of entries) {
|
|
22248
22286
|
if (!isMarkdownFile(entry))
|
|
22249
22287
|
continue;
|
|
22250
|
-
const commandPath =
|
|
22288
|
+
const commandPath = join41(commandsDir, entry.name);
|
|
22251
22289
|
const commandName = basename2(entry.name, ".md");
|
|
22252
22290
|
try {
|
|
22253
22291
|
const content = readFileSync21(commandPath, "utf-8");
|
|
@@ -22292,10 +22330,10 @@ function skillToCommandInfo(skill) {
|
|
|
22292
22330
|
};
|
|
22293
22331
|
}
|
|
22294
22332
|
async function discoverAllCommands(options) {
|
|
22295
|
-
const userCommandsDir =
|
|
22296
|
-
const projectCommandsDir =
|
|
22297
|
-
const opencodeGlobalDir =
|
|
22298
|
-
const opencodeProjectDir =
|
|
22333
|
+
const userCommandsDir = join41(getClaudeConfigDir(), "commands");
|
|
22334
|
+
const projectCommandsDir = join41(process.cwd(), ".claude", "commands");
|
|
22335
|
+
const opencodeGlobalDir = join41(homedir14(), ".config", "opencode", "command");
|
|
22336
|
+
const opencodeProjectDir = join41(process.cwd(), ".opencode", "command");
|
|
22299
22337
|
const userCommands = discoverCommandsFromDir(userCommandsDir, "user");
|
|
22300
22338
|
const opencodeGlobalCommands = discoverCommandsFromDir(opencodeGlobalDir, "opencode");
|
|
22301
22339
|
const projectCommands = discoverCommandsFromDir(projectCommandsDir, "project");
|
|
@@ -22472,8 +22510,8 @@ ${EDIT_ERROR_REMINDER}`;
|
|
|
22472
22510
|
};
|
|
22473
22511
|
}
|
|
22474
22512
|
// src/hooks/composer-md-only/index.ts
|
|
22475
|
-
import { existsSync as
|
|
22476
|
-
import { join as
|
|
22513
|
+
import { existsSync as existsSync33, readdirSync as readdirSync8 } from "fs";
|
|
22514
|
+
import { join as join42, resolve as resolve7, relative as relative4, isAbsolute as isAbsolute3 } from "path";
|
|
22477
22515
|
|
|
22478
22516
|
// src/hooks/composer-md-only/constants.ts
|
|
22479
22517
|
init_system_directive();
|
|
@@ -22521,14 +22559,14 @@ function isAllowedFile(filePath, workspaceRoot) {
|
|
|
22521
22559
|
return true;
|
|
22522
22560
|
}
|
|
22523
22561
|
function getMessageDir5(sessionID) {
|
|
22524
|
-
if (!
|
|
22562
|
+
if (!existsSync33(MESSAGE_STORAGE))
|
|
22525
22563
|
return null;
|
|
22526
|
-
const directPath =
|
|
22527
|
-
if (
|
|
22564
|
+
const directPath = join42(MESSAGE_STORAGE, sessionID);
|
|
22565
|
+
if (existsSync33(directPath))
|
|
22528
22566
|
return directPath;
|
|
22529
22567
|
for (const dir of readdirSync8(MESSAGE_STORAGE)) {
|
|
22530
|
-
const sessionPath =
|
|
22531
|
-
if (
|
|
22568
|
+
const sessionPath = join42(MESSAGE_STORAGE, dir, sessionID);
|
|
22569
|
+
if (existsSync33(sessionPath))
|
|
22532
22570
|
return sessionPath;
|
|
22533
22571
|
}
|
|
22534
22572
|
return null;
|
|
@@ -22632,14 +22670,14 @@ var NOTEPAD_DIR = "notepads";
|
|
|
22632
22670
|
var NOTEPAD_BASE_PATH = `${BOULDER_DIR}/${NOTEPAD_DIR}`;
|
|
22633
22671
|
var COMPOSER_PLANS_DIR = ".maestro/plans";
|
|
22634
22672
|
// src/features/boulder-state/storage.ts
|
|
22635
|
-
import { existsSync as
|
|
22636
|
-
import { dirname as dirname9, join as
|
|
22673
|
+
import { existsSync as existsSync34, readFileSync as readFileSync22, writeFileSync as writeFileSync14, mkdirSync as mkdirSync11, readdirSync as readdirSync9 } from "fs";
|
|
22674
|
+
import { dirname as dirname9, join as join43, basename as basename3 } from "path";
|
|
22637
22675
|
function getBoulderFilePath(directory) {
|
|
22638
|
-
return
|
|
22676
|
+
return join43(directory, BOULDER_DIR, BOULDER_FILE);
|
|
22639
22677
|
}
|
|
22640
22678
|
function readBoulderState(directory) {
|
|
22641
22679
|
const filePath = getBoulderFilePath(directory);
|
|
22642
|
-
if (!
|
|
22680
|
+
if (!existsSync34(filePath)) {
|
|
22643
22681
|
return null;
|
|
22644
22682
|
}
|
|
22645
22683
|
try {
|
|
@@ -22653,7 +22691,7 @@ function writeBoulderState(directory, state2) {
|
|
|
22653
22691
|
const filePath = getBoulderFilePath(directory);
|
|
22654
22692
|
try {
|
|
22655
22693
|
const dir = dirname9(filePath);
|
|
22656
|
-
if (!
|
|
22694
|
+
if (!existsSync34(dir)) {
|
|
22657
22695
|
mkdirSync11(dir, { recursive: true });
|
|
22658
22696
|
}
|
|
22659
22697
|
writeFileSync14(filePath, JSON.stringify(state2, null, 2), "utf-8");
|
|
@@ -22677,7 +22715,7 @@ function appendSessionId(directory, sessionId) {
|
|
|
22677
22715
|
function clearBoulderState(directory) {
|
|
22678
22716
|
const filePath = getBoulderFilePath(directory);
|
|
22679
22717
|
try {
|
|
22680
|
-
if (
|
|
22718
|
+
if (existsSync34(filePath)) {
|
|
22681
22719
|
const { unlinkSync: unlinkSync10 } = __require("fs");
|
|
22682
22720
|
unlinkSync10(filePath);
|
|
22683
22721
|
}
|
|
@@ -22687,13 +22725,13 @@ function clearBoulderState(directory) {
|
|
|
22687
22725
|
}
|
|
22688
22726
|
}
|
|
22689
22727
|
function findComposerPlans(directory) {
|
|
22690
|
-
const plansDir =
|
|
22691
|
-
if (!
|
|
22728
|
+
const plansDir = join43(directory, COMPOSER_PLANS_DIR);
|
|
22729
|
+
if (!existsSync34(plansDir)) {
|
|
22692
22730
|
return [];
|
|
22693
22731
|
}
|
|
22694
22732
|
try {
|
|
22695
22733
|
const files = readdirSync9(plansDir);
|
|
22696
|
-
return files.filter((f) => f.endsWith(".md")).map((f) =>
|
|
22734
|
+
return files.filter((f) => f.endsWith(".md")).map((f) => join43(plansDir, f)).sort((a, b) => {
|
|
22697
22735
|
const aStat = __require("fs").statSync(a);
|
|
22698
22736
|
const bStat = __require("fs").statSync(b);
|
|
22699
22737
|
return bStat.mtimeMs - aStat.mtimeMs;
|
|
@@ -22703,7 +22741,7 @@ function findComposerPlans(directory) {
|
|
|
22703
22741
|
}
|
|
22704
22742
|
}
|
|
22705
22743
|
function getPlanProgress(planPath) {
|
|
22706
|
-
if (!
|
|
22744
|
+
if (!existsSync34(planPath)) {
|
|
22707
22745
|
return { total: 0, completed: 0, isComplete: true };
|
|
22708
22746
|
}
|
|
22709
22747
|
try {
|
|
@@ -22924,8 +22962,8 @@ ${contextInfo}`;
|
|
|
22924
22962
|
}
|
|
22925
22963
|
// src/hooks/maestro-orchestrator/index.ts
|
|
22926
22964
|
import { execSync } from "child_process";
|
|
22927
|
-
import { existsSync as
|
|
22928
|
-
import { join as
|
|
22965
|
+
import { existsSync as existsSync35, readdirSync as readdirSync10 } from "fs";
|
|
22966
|
+
import { join as join44 } from "path";
|
|
22929
22967
|
init_logger();
|
|
22930
22968
|
init_system_directive();
|
|
22931
22969
|
var HOOK_NAME6 = "maestro-orchestrator";
|
|
@@ -23252,14 +23290,14 @@ No file changes detected.
|
|
|
23252
23290
|
`);
|
|
23253
23291
|
}
|
|
23254
23292
|
function getMessageDir6(sessionID) {
|
|
23255
|
-
if (!
|
|
23293
|
+
if (!existsSync35(MESSAGE_STORAGE))
|
|
23256
23294
|
return null;
|
|
23257
|
-
const directPath =
|
|
23258
|
-
if (
|
|
23295
|
+
const directPath = join44(MESSAGE_STORAGE, sessionID);
|
|
23296
|
+
if (existsSync35(directPath))
|
|
23259
23297
|
return directPath;
|
|
23260
23298
|
for (const dir of readdirSync10(MESSAGE_STORAGE)) {
|
|
23261
|
-
const sessionPath =
|
|
23262
|
-
if (
|
|
23299
|
+
const sessionPath = join44(MESSAGE_STORAGE, dir, sessionID);
|
|
23300
|
+
if (existsSync35(sessionPath))
|
|
23263
23301
|
return sessionPath;
|
|
23264
23302
|
}
|
|
23265
23303
|
return null;
|
|
@@ -23846,8 +23884,8 @@ function createFirstMessageVariantGate() {
|
|
|
23846
23884
|
}
|
|
23847
23885
|
// src/features/claude-code-mcp-loader/loader.ts
|
|
23848
23886
|
init_shared();
|
|
23849
|
-
import { existsSync as
|
|
23850
|
-
import { join as
|
|
23887
|
+
import { existsSync as existsSync36, readFileSync as readFileSync23 } from "fs";
|
|
23888
|
+
import { join as join45 } from "path";
|
|
23851
23889
|
|
|
23852
23890
|
// src/features/claude-code-mcp-loader/env-expander.ts
|
|
23853
23891
|
function expandEnvVars(value) {
|
|
@@ -23917,13 +23955,13 @@ function getMcpConfigPaths() {
|
|
|
23917
23955
|
const claudeConfigDir = getClaudeConfigDir();
|
|
23918
23956
|
const cwd = process.cwd();
|
|
23919
23957
|
return [
|
|
23920
|
-
{ path:
|
|
23921
|
-
{ path:
|
|
23922
|
-
{ path:
|
|
23958
|
+
{ path: join45(claudeConfigDir, ".mcp.json"), scope: "user" },
|
|
23959
|
+
{ path: join45(cwd, ".mcp.json"), scope: "project" },
|
|
23960
|
+
{ path: join45(cwd, ".claude", ".mcp.json"), scope: "local" }
|
|
23923
23961
|
];
|
|
23924
23962
|
}
|
|
23925
23963
|
async function loadMcpConfigFile(filePath) {
|
|
23926
|
-
if (!
|
|
23964
|
+
if (!existsSync36(filePath)) {
|
|
23927
23965
|
return null;
|
|
23928
23966
|
}
|
|
23929
23967
|
try {
|
|
@@ -23938,7 +23976,7 @@ function getSystemMcpServerNames() {
|
|
|
23938
23976
|
const names = new Set;
|
|
23939
23977
|
const paths = getMcpConfigPaths();
|
|
23940
23978
|
for (const { path: path8 } of paths) {
|
|
23941
|
-
if (!
|
|
23979
|
+
if (!existsSync36(path8))
|
|
23942
23980
|
continue;
|
|
23943
23981
|
try {
|
|
23944
23982
|
const content = readFileSync23(path8, "utf-8");
|
|
@@ -24378,11 +24416,11 @@ var EXT_TO_LANG = {
|
|
|
24378
24416
|
".gql": "graphql"
|
|
24379
24417
|
};
|
|
24380
24418
|
// src/tools/lsp/config.ts
|
|
24381
|
-
import { existsSync as
|
|
24382
|
-
import { join as
|
|
24419
|
+
import { existsSync as existsSync37, readFileSync as readFileSync24 } from "fs";
|
|
24420
|
+
import { join as join46 } from "path";
|
|
24383
24421
|
import { homedir as homedir15 } from "os";
|
|
24384
24422
|
function loadJsonFile(path8) {
|
|
24385
|
-
if (!
|
|
24423
|
+
if (!existsSync37(path8))
|
|
24386
24424
|
return null;
|
|
24387
24425
|
try {
|
|
24388
24426
|
return JSON.parse(readFileSync24(path8, "utf-8"));
|
|
@@ -24393,9 +24431,9 @@ function loadJsonFile(path8) {
|
|
|
24393
24431
|
function getConfigPaths3() {
|
|
24394
24432
|
const cwd = process.cwd();
|
|
24395
24433
|
return {
|
|
24396
|
-
project:
|
|
24397
|
-
user:
|
|
24398
|
-
opencode:
|
|
24434
|
+
project: join46(cwd, ".opencode", "oh-my-opencode.json"),
|
|
24435
|
+
user: join46(homedir15(), ".config", "opencode", "oh-my-opencode.json"),
|
|
24436
|
+
opencode: join46(homedir15(), ".config", "opencode", "opencode.json")
|
|
24399
24437
|
};
|
|
24400
24438
|
}
|
|
24401
24439
|
function loadAllConfigs() {
|
|
@@ -24508,7 +24546,7 @@ function isServerInstalled(command) {
|
|
|
24508
24546
|
return false;
|
|
24509
24547
|
const cmd = command[0];
|
|
24510
24548
|
if (cmd.includes("/") || cmd.includes("\\")) {
|
|
24511
|
-
if (
|
|
24549
|
+
if (existsSync37(cmd))
|
|
24512
24550
|
return true;
|
|
24513
24551
|
}
|
|
24514
24552
|
const isWindows2 = process.platform === "win32";
|
|
@@ -24530,20 +24568,20 @@ function isServerInstalled(command) {
|
|
|
24530
24568
|
const paths = pathEnv.split(pathSeparator);
|
|
24531
24569
|
for (const p of paths) {
|
|
24532
24570
|
for (const suffix of exts) {
|
|
24533
|
-
if (
|
|
24571
|
+
if (existsSync37(join46(p, cmd + suffix))) {
|
|
24534
24572
|
return true;
|
|
24535
24573
|
}
|
|
24536
24574
|
}
|
|
24537
24575
|
}
|
|
24538
24576
|
const cwd = process.cwd();
|
|
24539
24577
|
const additionalBases = [
|
|
24540
|
-
|
|
24541
|
-
|
|
24542
|
-
|
|
24578
|
+
join46(cwd, "node_modules", ".bin"),
|
|
24579
|
+
join46(homedir15(), ".config", "opencode", "bin"),
|
|
24580
|
+
join46(homedir15(), ".config", "opencode", "node_modules", ".bin")
|
|
24543
24581
|
];
|
|
24544
24582
|
for (const base of additionalBases) {
|
|
24545
24583
|
for (const suffix of exts) {
|
|
24546
|
-
if (
|
|
24584
|
+
if (existsSync37(join46(base, cmd + suffix))) {
|
|
24547
24585
|
return true;
|
|
24548
24586
|
}
|
|
24549
24587
|
}
|
|
@@ -25095,17 +25133,17 @@ ${msg}`);
|
|
|
25095
25133
|
// src/tools/lsp/utils.ts
|
|
25096
25134
|
import { extname as extname2, resolve as resolve9 } from "path";
|
|
25097
25135
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
25098
|
-
import { existsSync as
|
|
25136
|
+
import { existsSync as existsSync38, readFileSync as readFileSync26, writeFileSync as writeFileSync15 } from "fs";
|
|
25099
25137
|
function findWorkspaceRoot(filePath) {
|
|
25100
25138
|
let dir = resolve9(filePath);
|
|
25101
|
-
if (!
|
|
25139
|
+
if (!existsSync38(dir) || !__require("fs").statSync(dir).isDirectory()) {
|
|
25102
25140
|
dir = __require("path").dirname(dir);
|
|
25103
25141
|
}
|
|
25104
25142
|
const markers = [".git", "package.json", "pyproject.toml", "Cargo.toml", "go.mod", "pom.xml", "build.gradle"];
|
|
25105
25143
|
let prevDir = "";
|
|
25106
25144
|
while (dir !== prevDir) {
|
|
25107
25145
|
for (const marker of markers) {
|
|
25108
|
-
if (
|
|
25146
|
+
if (existsSync38(__require("path").join(dir, marker))) {
|
|
25109
25147
|
return dir;
|
|
25110
25148
|
}
|
|
25111
25149
|
}
|
|
@@ -37906,13 +37944,13 @@ var lsp_rename = tool({
|
|
|
37906
37944
|
});
|
|
37907
37945
|
// src/tools/ast-grep/constants.ts
|
|
37908
37946
|
import { createRequire as createRequire4 } from "module";
|
|
37909
|
-
import { dirname as dirname10, join as
|
|
37910
|
-
import { existsSync as
|
|
37947
|
+
import { dirname as dirname10, join as join48 } from "path";
|
|
37948
|
+
import { existsSync as existsSync40, statSync as statSync4 } from "fs";
|
|
37911
37949
|
|
|
37912
37950
|
// src/tools/ast-grep/downloader.ts
|
|
37913
37951
|
init_shared();
|
|
37914
|
-
import { existsSync as
|
|
37915
|
-
import { join as
|
|
37952
|
+
import { existsSync as existsSync39, mkdirSync as mkdirSync12, chmodSync as chmodSync2, unlinkSync as unlinkSync10 } from "fs";
|
|
37953
|
+
import { join as join47 } from "path";
|
|
37916
37954
|
import { homedir as homedir16 } from "os";
|
|
37917
37955
|
import { createRequire as createRequire3 } from "module";
|
|
37918
37956
|
var REPO2 = "ast-grep/ast-grep";
|
|
@@ -37938,19 +37976,19 @@ var PLATFORM_MAP2 = {
|
|
|
37938
37976
|
function getCacheDir3() {
|
|
37939
37977
|
if (process.platform === "win32") {
|
|
37940
37978
|
const localAppData = process.env.LOCALAPPDATA || process.env.APPDATA;
|
|
37941
|
-
const base2 = localAppData ||
|
|
37942
|
-
return
|
|
37979
|
+
const base2 = localAppData || join47(homedir16(), "AppData", "Local");
|
|
37980
|
+
return join47(base2, "oh-my-opencode", "bin");
|
|
37943
37981
|
}
|
|
37944
37982
|
const xdgCache = process.env.XDG_CACHE_HOME;
|
|
37945
|
-
const base = xdgCache ||
|
|
37946
|
-
return
|
|
37983
|
+
const base = xdgCache || join47(homedir16(), ".cache");
|
|
37984
|
+
return join47(base, "oh-my-opencode", "bin");
|
|
37947
37985
|
}
|
|
37948
37986
|
function getBinaryName3() {
|
|
37949
37987
|
return process.platform === "win32" ? "sg.exe" : "sg";
|
|
37950
37988
|
}
|
|
37951
37989
|
function getCachedBinaryPath2() {
|
|
37952
|
-
const binaryPath =
|
|
37953
|
-
return
|
|
37990
|
+
const binaryPath = join47(getCacheDir3(), getBinaryName3());
|
|
37991
|
+
return existsSync39(binaryPath) ? binaryPath : null;
|
|
37954
37992
|
}
|
|
37955
37993
|
async function downloadAstGrep(version2 = DEFAULT_VERSION) {
|
|
37956
37994
|
const platformKey = `${process.platform}-${process.arch}`;
|
|
@@ -37961,8 +37999,8 @@ async function downloadAstGrep(version2 = DEFAULT_VERSION) {
|
|
|
37961
37999
|
}
|
|
37962
38000
|
const cacheDir = getCacheDir3();
|
|
37963
38001
|
const binaryName = getBinaryName3();
|
|
37964
|
-
const binaryPath =
|
|
37965
|
-
if (
|
|
38002
|
+
const binaryPath = join47(cacheDir, binaryName);
|
|
38003
|
+
if (existsSync39(binaryPath)) {
|
|
37966
38004
|
return binaryPath;
|
|
37967
38005
|
}
|
|
37968
38006
|
const { arch, os: os7 } = platformInfo;
|
|
@@ -37970,21 +38008,21 @@ async function downloadAstGrep(version2 = DEFAULT_VERSION) {
|
|
|
37970
38008
|
const downloadUrl = `https://github.com/${REPO2}/releases/download/${version2}/${assetName}`;
|
|
37971
38009
|
console.log(`[oh-my-opencode] Downloading ast-grep binary...`);
|
|
37972
38010
|
try {
|
|
37973
|
-
if (!
|
|
38011
|
+
if (!existsSync39(cacheDir)) {
|
|
37974
38012
|
mkdirSync12(cacheDir, { recursive: true });
|
|
37975
38013
|
}
|
|
37976
38014
|
const response = await fetch(downloadUrl, { redirect: "follow" });
|
|
37977
38015
|
if (!response.ok) {
|
|
37978
38016
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
37979
38017
|
}
|
|
37980
|
-
const archivePath =
|
|
38018
|
+
const archivePath = join47(cacheDir, assetName);
|
|
37981
38019
|
const arrayBuffer = await response.arrayBuffer();
|
|
37982
38020
|
await Bun.write(archivePath, arrayBuffer);
|
|
37983
38021
|
await extractZip(archivePath, cacheDir);
|
|
37984
|
-
if (
|
|
38022
|
+
if (existsSync39(archivePath)) {
|
|
37985
38023
|
unlinkSync10(archivePath);
|
|
37986
38024
|
}
|
|
37987
|
-
if (process.platform !== "win32" &&
|
|
38025
|
+
if (process.platform !== "win32" && existsSync39(binaryPath)) {
|
|
37988
38026
|
chmodSync2(binaryPath, 493);
|
|
37989
38027
|
}
|
|
37990
38028
|
console.log(`[oh-my-opencode] ast-grep binary ready.`);
|
|
@@ -38035,8 +38073,8 @@ function findSgCliPathSync() {
|
|
|
38035
38073
|
const require2 = createRequire4(import.meta.url);
|
|
38036
38074
|
const cliPkgPath = require2.resolve("@ast-grep/cli/package.json");
|
|
38037
38075
|
const cliDir = dirname10(cliPkgPath);
|
|
38038
|
-
const sgPath =
|
|
38039
|
-
if (
|
|
38076
|
+
const sgPath = join48(cliDir, binaryName);
|
|
38077
|
+
if (existsSync40(sgPath) && isValidBinary(sgPath)) {
|
|
38040
38078
|
return sgPath;
|
|
38041
38079
|
}
|
|
38042
38080
|
} catch {}
|
|
@@ -38047,8 +38085,8 @@ function findSgCliPathSync() {
|
|
|
38047
38085
|
const pkgPath = require2.resolve(`${platformPkg}/package.json`);
|
|
38048
38086
|
const pkgDir = dirname10(pkgPath);
|
|
38049
38087
|
const astGrepName = process.platform === "win32" ? "ast-grep.exe" : "ast-grep";
|
|
38050
|
-
const binaryPath =
|
|
38051
|
-
if (
|
|
38088
|
+
const binaryPath = join48(pkgDir, astGrepName);
|
|
38089
|
+
if (existsSync40(binaryPath) && isValidBinary(binaryPath)) {
|
|
38052
38090
|
return binaryPath;
|
|
38053
38091
|
}
|
|
38054
38092
|
} catch {}
|
|
@@ -38056,7 +38094,7 @@ function findSgCliPathSync() {
|
|
|
38056
38094
|
if (process.platform === "darwin") {
|
|
38057
38095
|
const homebrewPaths = ["/opt/homebrew/bin/sg", "/usr/local/bin/sg"];
|
|
38058
38096
|
for (const path8 of homebrewPaths) {
|
|
38059
|
-
if (
|
|
38097
|
+
if (existsSync40(path8) && isValidBinary(path8)) {
|
|
38060
38098
|
return path8;
|
|
38061
38099
|
}
|
|
38062
38100
|
}
|
|
@@ -38111,11 +38149,11 @@ var DEFAULT_MAX_MATCHES = 500;
|
|
|
38111
38149
|
|
|
38112
38150
|
// src/tools/ast-grep/cli.ts
|
|
38113
38151
|
var {spawn: spawn7 } = globalThis.Bun;
|
|
38114
|
-
import { existsSync as
|
|
38152
|
+
import { existsSync as existsSync41 } from "fs";
|
|
38115
38153
|
var resolvedCliPath3 = null;
|
|
38116
38154
|
var initPromise2 = null;
|
|
38117
38155
|
async function getAstGrepPath() {
|
|
38118
|
-
if (resolvedCliPath3 !== null &&
|
|
38156
|
+
if (resolvedCliPath3 !== null && existsSync41(resolvedCliPath3)) {
|
|
38119
38157
|
return resolvedCliPath3;
|
|
38120
38158
|
}
|
|
38121
38159
|
if (initPromise2) {
|
|
@@ -38123,7 +38161,7 @@ async function getAstGrepPath() {
|
|
|
38123
38161
|
}
|
|
38124
38162
|
initPromise2 = (async () => {
|
|
38125
38163
|
const syncPath = findSgCliPathSync();
|
|
38126
|
-
if (syncPath &&
|
|
38164
|
+
if (syncPath && existsSync41(syncPath)) {
|
|
38127
38165
|
resolvedCliPath3 = syncPath;
|
|
38128
38166
|
setSgCliPath(syncPath);
|
|
38129
38167
|
return syncPath;
|
|
@@ -38157,7 +38195,7 @@ async function runSg(options) {
|
|
|
38157
38195
|
const paths = options.paths && options.paths.length > 0 ? options.paths : ["."];
|
|
38158
38196
|
args.push(...paths);
|
|
38159
38197
|
let cliPath = getSgCliPath();
|
|
38160
|
-
if (!
|
|
38198
|
+
if (!existsSync41(cliPath) && cliPath !== "sg") {
|
|
38161
38199
|
const downloadedPath = await getAstGrepPath();
|
|
38162
38200
|
if (downloadedPath) {
|
|
38163
38201
|
cliPath = downloadedPath;
|
|
@@ -38421,21 +38459,21 @@ var ast_grep_replace = tool({
|
|
|
38421
38459
|
var {spawn: spawn9 } = globalThis.Bun;
|
|
38422
38460
|
|
|
38423
38461
|
// src/tools/grep/constants.ts
|
|
38424
|
-
import { existsSync as
|
|
38425
|
-
import { join as
|
|
38462
|
+
import { existsSync as existsSync43 } from "fs";
|
|
38463
|
+
import { join as join50, dirname as dirname11 } from "path";
|
|
38426
38464
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
38427
38465
|
|
|
38428
38466
|
// src/tools/grep/downloader.ts
|
|
38429
38467
|
init_shared();
|
|
38430
|
-
import { existsSync as
|
|
38431
|
-
import { join as
|
|
38468
|
+
import { existsSync as existsSync42, mkdirSync as mkdirSync13, chmodSync as chmodSync3, unlinkSync as unlinkSync11, readdirSync as readdirSync11 } from "fs";
|
|
38469
|
+
import { join as join49 } from "path";
|
|
38432
38470
|
var {spawn: spawn8 } = globalThis.Bun;
|
|
38433
38471
|
function findFileRecursive(dir, filename) {
|
|
38434
38472
|
try {
|
|
38435
38473
|
const entries = readdirSync11(dir, { withFileTypes: true, recursive: true });
|
|
38436
38474
|
for (const entry of entries) {
|
|
38437
38475
|
if (entry.isFile() && entry.name === filename) {
|
|
38438
|
-
return
|
|
38476
|
+
return join49(entry.parentPath ?? dir, entry.name);
|
|
38439
38477
|
}
|
|
38440
38478
|
}
|
|
38441
38479
|
} catch {
|
|
@@ -38456,11 +38494,11 @@ function getPlatformKey() {
|
|
|
38456
38494
|
}
|
|
38457
38495
|
function getInstallDir() {
|
|
38458
38496
|
const homeDir = process.env.HOME || process.env.USERPROFILE || ".";
|
|
38459
|
-
return
|
|
38497
|
+
return join49(homeDir, ".cache", "oh-my-opencode", "bin");
|
|
38460
38498
|
}
|
|
38461
38499
|
function getRgPath() {
|
|
38462
38500
|
const isWindows2 = process.platform === "win32";
|
|
38463
|
-
return
|
|
38501
|
+
return join49(getInstallDir(), isWindows2 ? "rg.exe" : "rg");
|
|
38464
38502
|
}
|
|
38465
38503
|
async function downloadFile(url2, destPath) {
|
|
38466
38504
|
const response = await fetch(url2);
|
|
@@ -38494,7 +38532,7 @@ async function extractZip2(archivePath, destDir) {
|
|
|
38494
38532
|
const binaryName = process.platform === "win32" ? "rg.exe" : "rg";
|
|
38495
38533
|
const foundPath = findFileRecursive(destDir, binaryName);
|
|
38496
38534
|
if (foundPath) {
|
|
38497
|
-
const destPath =
|
|
38535
|
+
const destPath = join49(destDir, binaryName);
|
|
38498
38536
|
if (foundPath !== destPath) {
|
|
38499
38537
|
const { renameSync } = await import("fs");
|
|
38500
38538
|
renameSync(foundPath, destPath);
|
|
@@ -38509,13 +38547,13 @@ async function downloadAndInstallRipgrep() {
|
|
|
38509
38547
|
}
|
|
38510
38548
|
const installDir = getInstallDir();
|
|
38511
38549
|
const rgPath = getRgPath();
|
|
38512
|
-
if (
|
|
38550
|
+
if (existsSync42(rgPath)) {
|
|
38513
38551
|
return rgPath;
|
|
38514
38552
|
}
|
|
38515
38553
|
mkdirSync13(installDir, { recursive: true });
|
|
38516
38554
|
const filename = `ripgrep-${RG_VERSION}-${config3.platform}.${config3.extension}`;
|
|
38517
38555
|
const url2 = `https://github.com/BurntSushi/ripgrep/releases/download/${RG_VERSION}/${filename}`;
|
|
38518
|
-
const archivePath =
|
|
38556
|
+
const archivePath = join49(installDir, filename);
|
|
38519
38557
|
try {
|
|
38520
38558
|
await downloadFile(url2, archivePath);
|
|
38521
38559
|
if (config3.extension === "tar.gz") {
|
|
@@ -38526,12 +38564,12 @@ async function downloadAndInstallRipgrep() {
|
|
|
38526
38564
|
if (process.platform !== "win32") {
|
|
38527
38565
|
chmodSync3(rgPath, 493);
|
|
38528
38566
|
}
|
|
38529
|
-
if (!
|
|
38567
|
+
if (!existsSync42(rgPath)) {
|
|
38530
38568
|
throw new Error("ripgrep binary not found after extraction");
|
|
38531
38569
|
}
|
|
38532
38570
|
return rgPath;
|
|
38533
38571
|
} finally {
|
|
38534
|
-
if (
|
|
38572
|
+
if (existsSync42(archivePath)) {
|
|
38535
38573
|
try {
|
|
38536
38574
|
unlinkSync11(archivePath);
|
|
38537
38575
|
} catch {}
|
|
@@ -38540,7 +38578,7 @@ async function downloadAndInstallRipgrep() {
|
|
|
38540
38578
|
}
|
|
38541
38579
|
function getInstalledRipgrepPath() {
|
|
38542
38580
|
const rgPath = getRgPath();
|
|
38543
|
-
return
|
|
38581
|
+
return existsSync42(rgPath) ? rgPath : null;
|
|
38544
38582
|
}
|
|
38545
38583
|
|
|
38546
38584
|
// src/tools/grep/constants.ts
|
|
@@ -38565,14 +38603,14 @@ function getOpenCodeBundledRg() {
|
|
|
38565
38603
|
const isWindows2 = process.platform === "win32";
|
|
38566
38604
|
const rgName = isWindows2 ? "rg.exe" : "rg";
|
|
38567
38605
|
const candidates = [
|
|
38568
|
-
|
|
38569
|
-
|
|
38570
|
-
|
|
38571
|
-
|
|
38572
|
-
|
|
38606
|
+
join50(getDataDir(), "opencode", "bin", rgName),
|
|
38607
|
+
join50(execDir, rgName),
|
|
38608
|
+
join50(execDir, "bin", rgName),
|
|
38609
|
+
join50(execDir, "..", "bin", rgName),
|
|
38610
|
+
join50(execDir, "..", "libexec", rgName)
|
|
38573
38611
|
];
|
|
38574
38612
|
for (const candidate of candidates) {
|
|
38575
|
-
if (
|
|
38613
|
+
if (existsSync43(candidate)) {
|
|
38576
38614
|
return candidate;
|
|
38577
38615
|
}
|
|
38578
38616
|
}
|
|
@@ -39034,10 +39072,10 @@ var glob = tool({
|
|
|
39034
39072
|
init_shared();
|
|
39035
39073
|
init_file_utils();
|
|
39036
39074
|
init_shared();
|
|
39037
|
-
import { existsSync as
|
|
39038
|
-
import { join as
|
|
39075
|
+
import { existsSync as existsSync44, readdirSync as readdirSync12, readFileSync as readFileSync27 } from "fs";
|
|
39076
|
+
import { join as join51, basename as basename4, dirname as dirname12 } from "path";
|
|
39039
39077
|
function discoverCommandsFromDir2(commandsDir, scope) {
|
|
39040
|
-
if (!
|
|
39078
|
+
if (!existsSync44(commandsDir)) {
|
|
39041
39079
|
return [];
|
|
39042
39080
|
}
|
|
39043
39081
|
const entries = readdirSync12(commandsDir, { withFileTypes: true });
|
|
@@ -39045,7 +39083,7 @@ function discoverCommandsFromDir2(commandsDir, scope) {
|
|
|
39045
39083
|
for (const entry of entries) {
|
|
39046
39084
|
if (!isMarkdownFile(entry))
|
|
39047
39085
|
continue;
|
|
39048
|
-
const commandPath =
|
|
39086
|
+
const commandPath = join51(commandsDir, entry.name);
|
|
39049
39087
|
const commandName = basename4(entry.name, ".md");
|
|
39050
39088
|
try {
|
|
39051
39089
|
const content = readFileSync27(commandPath, "utf-8");
|
|
@@ -39074,10 +39112,10 @@ function discoverCommandsFromDir2(commandsDir, scope) {
|
|
|
39074
39112
|
}
|
|
39075
39113
|
function discoverCommandsSync() {
|
|
39076
39114
|
const { homedir: homedir17 } = __require("os");
|
|
39077
|
-
const userCommandsDir =
|
|
39078
|
-
const projectCommandsDir =
|
|
39079
|
-
const opencodeGlobalDir =
|
|
39080
|
-
const opencodeProjectDir =
|
|
39115
|
+
const userCommandsDir = join51(getClaudeConfigDir(), "commands");
|
|
39116
|
+
const projectCommandsDir = join51(process.cwd(), ".claude", "commands");
|
|
39117
|
+
const opencodeGlobalDir = join51(homedir17(), ".config", "opencode", "command");
|
|
39118
|
+
const opencodeProjectDir = join51(process.cwd(), ".opencode", "command");
|
|
39081
39119
|
const userCommands = discoverCommandsFromDir2(userCommandsDir, "user");
|
|
39082
39120
|
const opencodeGlobalCommands = discoverCommandsFromDir2(opencodeGlobalDir, "opencode");
|
|
39083
39121
|
const projectCommands = discoverCommandsFromDir2(projectCommandsDir, "project");
|
|
@@ -39240,13 +39278,13 @@ var slashcommand = createSlashcommandTool();
|
|
|
39240
39278
|
// src/tools/session-manager/constants.ts
|
|
39241
39279
|
init_data_path();
|
|
39242
39280
|
init_shared();
|
|
39243
|
-
import { join as
|
|
39281
|
+
import { join as join52 } from "path";
|
|
39244
39282
|
var OPENCODE_STORAGE9 = getOpenCodeStorageDir();
|
|
39245
|
-
var MESSAGE_STORAGE4 =
|
|
39246
|
-
var PART_STORAGE4 =
|
|
39247
|
-
var SESSION_STORAGE =
|
|
39248
|
-
var TODO_DIR2 =
|
|
39249
|
-
var TRANSCRIPT_DIR2 =
|
|
39283
|
+
var MESSAGE_STORAGE4 = join52(OPENCODE_STORAGE9, "message");
|
|
39284
|
+
var PART_STORAGE4 = join52(OPENCODE_STORAGE9, "part");
|
|
39285
|
+
var SESSION_STORAGE = join52(OPENCODE_STORAGE9, "session");
|
|
39286
|
+
var TODO_DIR2 = join52(getClaudeConfigDir(), "todos");
|
|
39287
|
+
var TRANSCRIPT_DIR2 = join52(getClaudeConfigDir(), "transcripts");
|
|
39250
39288
|
var SESSION_LIST_DESCRIPTION = `List all OpenCode sessions with optional filtering.
|
|
39251
39289
|
|
|
39252
39290
|
Returns a list of available session IDs with metadata including message count, date range, and agents used.
|
|
@@ -39319,11 +39357,11 @@ Has Todos: Yes (12 items, 8 completed)
|
|
|
39319
39357
|
Has Transcript: Yes (234 entries)`;
|
|
39320
39358
|
|
|
39321
39359
|
// src/tools/session-manager/storage.ts
|
|
39322
|
-
import { existsSync as
|
|
39360
|
+
import { existsSync as existsSync45, readdirSync as readdirSync13 } from "fs";
|
|
39323
39361
|
import { readdir, readFile } from "fs/promises";
|
|
39324
|
-
import { join as
|
|
39362
|
+
import { join as join53 } from "path";
|
|
39325
39363
|
async function getMainSessions(options) {
|
|
39326
|
-
if (!
|
|
39364
|
+
if (!existsSync45(SESSION_STORAGE))
|
|
39327
39365
|
return [];
|
|
39328
39366
|
const sessions = [];
|
|
39329
39367
|
try {
|
|
@@ -39331,13 +39369,13 @@ async function getMainSessions(options) {
|
|
|
39331
39369
|
for (const projectDir of projectDirs) {
|
|
39332
39370
|
if (!projectDir.isDirectory())
|
|
39333
39371
|
continue;
|
|
39334
|
-
const projectPath =
|
|
39372
|
+
const projectPath = join53(SESSION_STORAGE, projectDir.name);
|
|
39335
39373
|
const sessionFiles = await readdir(projectPath);
|
|
39336
39374
|
for (const file2 of sessionFiles) {
|
|
39337
39375
|
if (!file2.endsWith(".json"))
|
|
39338
39376
|
continue;
|
|
39339
39377
|
try {
|
|
39340
|
-
const content = await readFile(
|
|
39378
|
+
const content = await readFile(join53(projectPath, file2), "utf-8");
|
|
39341
39379
|
const meta = JSON.parse(content);
|
|
39342
39380
|
if (meta.parentID)
|
|
39343
39381
|
continue;
|
|
@@ -39355,7 +39393,7 @@ async function getMainSessions(options) {
|
|
|
39355
39393
|
return sessions.sort((a, b) => b.time.updated - a.time.updated);
|
|
39356
39394
|
}
|
|
39357
39395
|
async function getAllSessions() {
|
|
39358
|
-
if (!
|
|
39396
|
+
if (!existsSync45(MESSAGE_STORAGE4))
|
|
39359
39397
|
return [];
|
|
39360
39398
|
const sessions = [];
|
|
39361
39399
|
async function scanDirectory(dir) {
|
|
@@ -39363,7 +39401,7 @@ async function getAllSessions() {
|
|
|
39363
39401
|
const entries = await readdir(dir, { withFileTypes: true });
|
|
39364
39402
|
for (const entry of entries) {
|
|
39365
39403
|
if (entry.isDirectory()) {
|
|
39366
|
-
const sessionPath =
|
|
39404
|
+
const sessionPath = join53(dir, entry.name);
|
|
39367
39405
|
const files = await readdir(sessionPath);
|
|
39368
39406
|
if (files.some((f) => f.endsWith(".json"))) {
|
|
39369
39407
|
sessions.push(entry.name);
|
|
@@ -39380,16 +39418,16 @@ async function getAllSessions() {
|
|
|
39380
39418
|
return [...new Set(sessions)];
|
|
39381
39419
|
}
|
|
39382
39420
|
function getMessageDir7(sessionID) {
|
|
39383
|
-
if (!
|
|
39421
|
+
if (!existsSync45(MESSAGE_STORAGE4))
|
|
39384
39422
|
return "";
|
|
39385
|
-
const directPath =
|
|
39386
|
-
if (
|
|
39423
|
+
const directPath = join53(MESSAGE_STORAGE4, sessionID);
|
|
39424
|
+
if (existsSync45(directPath)) {
|
|
39387
39425
|
return directPath;
|
|
39388
39426
|
}
|
|
39389
39427
|
try {
|
|
39390
39428
|
for (const dir of readdirSync13(MESSAGE_STORAGE4)) {
|
|
39391
|
-
const sessionPath =
|
|
39392
|
-
if (
|
|
39429
|
+
const sessionPath = join53(MESSAGE_STORAGE4, dir, sessionID);
|
|
39430
|
+
if (existsSync45(sessionPath)) {
|
|
39393
39431
|
return sessionPath;
|
|
39394
39432
|
}
|
|
39395
39433
|
}
|
|
@@ -39403,7 +39441,7 @@ function sessionExists(sessionID) {
|
|
|
39403
39441
|
}
|
|
39404
39442
|
async function readSessionMessages(sessionID) {
|
|
39405
39443
|
const messageDir = getMessageDir7(sessionID);
|
|
39406
|
-
if (!messageDir || !
|
|
39444
|
+
if (!messageDir || !existsSync45(messageDir))
|
|
39407
39445
|
return [];
|
|
39408
39446
|
const messages = [];
|
|
39409
39447
|
try {
|
|
@@ -39412,7 +39450,7 @@ async function readSessionMessages(sessionID) {
|
|
|
39412
39450
|
if (!file2.endsWith(".json"))
|
|
39413
39451
|
continue;
|
|
39414
39452
|
try {
|
|
39415
|
-
const content = await readFile(
|
|
39453
|
+
const content = await readFile(join53(messageDir, file2), "utf-8");
|
|
39416
39454
|
const meta = JSON.parse(content);
|
|
39417
39455
|
const parts = await readParts2(meta.id);
|
|
39418
39456
|
messages.push({
|
|
@@ -39438,8 +39476,8 @@ async function readSessionMessages(sessionID) {
|
|
|
39438
39476
|
});
|
|
39439
39477
|
}
|
|
39440
39478
|
async function readParts2(messageID) {
|
|
39441
|
-
const partDir =
|
|
39442
|
-
if (!
|
|
39479
|
+
const partDir = join53(PART_STORAGE4, messageID);
|
|
39480
|
+
if (!existsSync45(partDir))
|
|
39443
39481
|
return [];
|
|
39444
39482
|
const parts = [];
|
|
39445
39483
|
try {
|
|
@@ -39448,7 +39486,7 @@ async function readParts2(messageID) {
|
|
|
39448
39486
|
if (!file2.endsWith(".json"))
|
|
39449
39487
|
continue;
|
|
39450
39488
|
try {
|
|
39451
|
-
const content = await readFile(
|
|
39489
|
+
const content = await readFile(join53(partDir, file2), "utf-8");
|
|
39452
39490
|
parts.push(JSON.parse(content));
|
|
39453
39491
|
} catch {
|
|
39454
39492
|
continue;
|
|
@@ -39460,14 +39498,14 @@ async function readParts2(messageID) {
|
|
|
39460
39498
|
return parts.sort((a, b) => a.id.localeCompare(b.id));
|
|
39461
39499
|
}
|
|
39462
39500
|
async function readSessionTodos(sessionID) {
|
|
39463
|
-
if (!
|
|
39501
|
+
if (!existsSync45(TODO_DIR2))
|
|
39464
39502
|
return [];
|
|
39465
39503
|
try {
|
|
39466
39504
|
const allFiles = await readdir(TODO_DIR2);
|
|
39467
39505
|
const todoFiles = allFiles.filter((f) => f.includes(sessionID) && f.endsWith(".json"));
|
|
39468
39506
|
for (const file2 of todoFiles) {
|
|
39469
39507
|
try {
|
|
39470
|
-
const content = await readFile(
|
|
39508
|
+
const content = await readFile(join53(TODO_DIR2, file2), "utf-8");
|
|
39471
39509
|
const data = JSON.parse(content);
|
|
39472
39510
|
if (Array.isArray(data)) {
|
|
39473
39511
|
return data.map((item) => ({
|
|
@@ -39487,10 +39525,10 @@ async function readSessionTodos(sessionID) {
|
|
|
39487
39525
|
return [];
|
|
39488
39526
|
}
|
|
39489
39527
|
async function readSessionTranscript(sessionID) {
|
|
39490
|
-
if (!
|
|
39528
|
+
if (!existsSync45(TRANSCRIPT_DIR2))
|
|
39491
39529
|
return 0;
|
|
39492
|
-
const transcriptFile =
|
|
39493
|
-
if (!
|
|
39530
|
+
const transcriptFile = join53(TRANSCRIPT_DIR2, `${sessionID}.jsonl`);
|
|
39531
|
+
if (!existsSync45(transcriptFile))
|
|
39494
39532
|
return 0;
|
|
39495
39533
|
try {
|
|
39496
39534
|
const content = await readFile(transcriptFile, "utf-8");
|
|
@@ -40579,19 +40617,19 @@ Available: {agents}
|
|
|
40579
40617
|
|
|
40580
40618
|
Pass \`resume=session_id\` to continue previous agent with full context. Prompts MUST be in English. Use \`background_output\` for async results.`;
|
|
40581
40619
|
// src/tools/call-omo-agent/tools.ts
|
|
40582
|
-
import { existsSync as
|
|
40583
|
-
import { join as
|
|
40620
|
+
import { existsSync as existsSync46, readdirSync as readdirSync14 } from "fs";
|
|
40621
|
+
import { join as join54 } from "path";
|
|
40584
40622
|
init_shared();
|
|
40585
40623
|
init_session_cursor();
|
|
40586
40624
|
function getMessageDir8(sessionID) {
|
|
40587
|
-
if (!
|
|
40625
|
+
if (!existsSync46(MESSAGE_STORAGE))
|
|
40588
40626
|
return null;
|
|
40589
|
-
const directPath =
|
|
40590
|
-
if (
|
|
40627
|
+
const directPath = join54(MESSAGE_STORAGE, sessionID);
|
|
40628
|
+
if (existsSync46(directPath))
|
|
40591
40629
|
return directPath;
|
|
40592
40630
|
for (const dir of readdirSync14(MESSAGE_STORAGE)) {
|
|
40593
|
-
const sessionPath =
|
|
40594
|
-
if (
|
|
40631
|
+
const sessionPath = join54(MESSAGE_STORAGE, dir, sessionID);
|
|
40632
|
+
if (existsSync46(sessionPath))
|
|
40595
40633
|
return sessionPath;
|
|
40596
40634
|
}
|
|
40597
40635
|
return null;
|
|
@@ -40998,8 +41036,8 @@ If the requested information is not found, clearly state what is missing.`;
|
|
|
40998
41036
|
}
|
|
40999
41037
|
// src/tools/delegate-task/tools.ts
|
|
41000
41038
|
init_constants2();
|
|
41001
|
-
import { existsSync as
|
|
41002
|
-
import { join as
|
|
41039
|
+
import { existsSync as existsSync47, readdirSync as readdirSync15 } from "fs";
|
|
41040
|
+
import { join as join55 } from "path";
|
|
41003
41041
|
|
|
41004
41042
|
// src/features/task-toast-manager/manager.ts
|
|
41005
41043
|
class TaskToastManager {
|
|
@@ -41162,14 +41200,14 @@ function parseModelString(model) {
|
|
|
41162
41200
|
return;
|
|
41163
41201
|
}
|
|
41164
41202
|
function getMessageDir9(sessionID) {
|
|
41165
|
-
if (!
|
|
41203
|
+
if (!existsSync47(MESSAGE_STORAGE))
|
|
41166
41204
|
return null;
|
|
41167
|
-
const directPath =
|
|
41168
|
-
if (
|
|
41205
|
+
const directPath = join55(MESSAGE_STORAGE, sessionID);
|
|
41206
|
+
if (existsSync47(directPath))
|
|
41169
41207
|
return directPath;
|
|
41170
41208
|
for (const dir of readdirSync15(MESSAGE_STORAGE)) {
|
|
41171
|
-
const sessionPath =
|
|
41172
|
-
if (
|
|
41209
|
+
const sessionPath = join55(MESSAGE_STORAGE, dir, sessionID);
|
|
41210
|
+
if (existsSync47(sessionPath))
|
|
41173
41211
|
return sessionPath;
|
|
41174
41212
|
}
|
|
41175
41213
|
return null;
|
|
@@ -41886,8 +41924,8 @@ class ConcurrencyManager {
|
|
|
41886
41924
|
}
|
|
41887
41925
|
|
|
41888
41926
|
// src/features/background-agent/manager.ts
|
|
41889
|
-
import { existsSync as
|
|
41890
|
-
import { join as
|
|
41927
|
+
import { existsSync as existsSync48, readdirSync as readdirSync16 } from "fs";
|
|
41928
|
+
import { join as join56 } from "path";
|
|
41891
41929
|
var TASK_TTL_MS = 30 * 60 * 1000;
|
|
41892
41930
|
var MIN_STABILITY_TIME_MS = 10 * 1000;
|
|
41893
41931
|
|
|
@@ -42700,14 +42738,14 @@ function registerProcessSignal(signal, handler, exitAfter) {
|
|
|
42700
42738
|
return listener;
|
|
42701
42739
|
}
|
|
42702
42740
|
function getMessageDir10(sessionID) {
|
|
42703
|
-
if (!
|
|
42741
|
+
if (!existsSync48(MESSAGE_STORAGE))
|
|
42704
42742
|
return null;
|
|
42705
|
-
const directPath =
|
|
42706
|
-
if (
|
|
42743
|
+
const directPath = join56(MESSAGE_STORAGE, sessionID);
|
|
42744
|
+
if (existsSync48(directPath))
|
|
42707
42745
|
return directPath;
|
|
42708
42746
|
for (const dir of readdirSync16(MESSAGE_STORAGE)) {
|
|
42709
|
-
const sessionPath =
|
|
42710
|
-
if (
|
|
42747
|
+
const sessionPath = join56(MESSAGE_STORAGE, dir, sessionID);
|
|
42748
|
+
if (existsSync48(sessionPath))
|
|
42711
42749
|
return sessionPath;
|
|
42712
42750
|
}
|
|
42713
42751
|
return null;
|
|
@@ -64695,6 +64733,7 @@ var criticAgent = createCriticAgent();
|
|
|
64695
64733
|
// src/agents/utils.ts
|
|
64696
64734
|
init_shared();
|
|
64697
64735
|
init_constants2();
|
|
64736
|
+
init_platform_detection();
|
|
64698
64737
|
var agentSources = {
|
|
64699
64738
|
Maestro: createMaestroAgent,
|
|
64700
64739
|
Virtuoso: createVirtuosoAgent,
|
|
@@ -64787,6 +64826,8 @@ function createBuiltinAgents(disabledAgents = [], agentOverrides = {}, directory
|
|
|
64787
64826
|
continue;
|
|
64788
64827
|
if (disabledAgents.includes(agentName))
|
|
64789
64828
|
continue;
|
|
64829
|
+
if (shouldSkipAgent(agentName))
|
|
64830
|
+
continue;
|
|
64790
64831
|
const override = agentOverrides[agentName];
|
|
64791
64832
|
const model = override?.model;
|
|
64792
64833
|
let config4 = buildAgent(source, model, mergedCategories, gitMasterConfig);
|
|
@@ -64952,7 +64993,7 @@ init_file_utils();
|
|
|
64952
64993
|
init_shared();
|
|
64953
64994
|
init_logger();
|
|
64954
64995
|
import { promises as fs13 } from "fs";
|
|
64955
|
-
import { join as
|
|
64996
|
+
import { join as join58, basename as basename6 } from "path";
|
|
64956
64997
|
import { homedir as homedir17 } from "os";
|
|
64957
64998
|
async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix = "") {
|
|
64958
64999
|
try {
|
|
@@ -64983,7 +65024,7 @@ async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix
|
|
|
64983
65024
|
if (entry.isDirectory()) {
|
|
64984
65025
|
if (entry.name.startsWith("."))
|
|
64985
65026
|
continue;
|
|
64986
|
-
const subDirPath =
|
|
65027
|
+
const subDirPath = join58(commandsDir, entry.name);
|
|
64987
65028
|
const subPrefix = prefix ? `${prefix}:${entry.name}` : entry.name;
|
|
64988
65029
|
const subCommands = await loadCommandsFromDir(subDirPath, scope, visited, subPrefix);
|
|
64989
65030
|
commands.push(...subCommands);
|
|
@@ -64991,7 +65032,7 @@ async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix
|
|
|
64991
65032
|
}
|
|
64992
65033
|
if (!isMarkdownFile(entry))
|
|
64993
65034
|
continue;
|
|
64994
|
-
const commandPath =
|
|
65035
|
+
const commandPath = join58(commandsDir, entry.name);
|
|
64995
65036
|
const baseCommandName = basename6(entry.name, ".md");
|
|
64996
65037
|
const commandName = prefix ? `${prefix}:${baseCommandName}` : baseCommandName;
|
|
64997
65038
|
try {
|
|
@@ -65038,22 +65079,22 @@ function commandsToRecord(commands) {
|
|
|
65038
65079
|
return result;
|
|
65039
65080
|
}
|
|
65040
65081
|
async function loadUserCommands() {
|
|
65041
|
-
const userCommandsDir =
|
|
65082
|
+
const userCommandsDir = join58(getClaudeConfigDir(), "commands");
|
|
65042
65083
|
const commands = await loadCommandsFromDir(userCommandsDir, "user");
|
|
65043
65084
|
return commandsToRecord(commands);
|
|
65044
65085
|
}
|
|
65045
65086
|
async function loadProjectCommands() {
|
|
65046
|
-
const projectCommandsDir =
|
|
65087
|
+
const projectCommandsDir = join58(process.cwd(), ".claude", "commands");
|
|
65047
65088
|
const commands = await loadCommandsFromDir(projectCommandsDir, "project");
|
|
65048
65089
|
return commandsToRecord(commands);
|
|
65049
65090
|
}
|
|
65050
65091
|
async function loadOpencodeGlobalCommands() {
|
|
65051
|
-
const opencodeCommandsDir =
|
|
65092
|
+
const opencodeCommandsDir = join58(homedir17(), ".config", "opencode", "command");
|
|
65052
65093
|
const commands = await loadCommandsFromDir(opencodeCommandsDir, "opencode");
|
|
65053
65094
|
return commandsToRecord(commands);
|
|
65054
65095
|
}
|
|
65055
65096
|
async function loadOpencodeProjectCommands() {
|
|
65056
|
-
const opencodeProjectDir =
|
|
65097
|
+
const opencodeProjectDir = join58(process.cwd(), ".opencode", "command");
|
|
65057
65098
|
const commands = await loadCommandsFromDir(opencodeProjectDir, "opencode-project");
|
|
65058
65099
|
return commandsToRecord(commands);
|
|
65059
65100
|
}
|
|
@@ -66163,8 +66204,8 @@ function loadBuiltinCommands(disabledCommands) {
|
|
|
66163
66204
|
init_frontmatter();
|
|
66164
66205
|
init_file_utils();
|
|
66165
66206
|
init_shared();
|
|
66166
|
-
import { existsSync as
|
|
66167
|
-
import { join as
|
|
66207
|
+
import { existsSync as existsSync50, readdirSync as readdirSync17, readFileSync as readFileSync29 } from "fs";
|
|
66208
|
+
import { join as join59, basename as basename7 } from "path";
|
|
66168
66209
|
function parseToolsConfig(toolsStr) {
|
|
66169
66210
|
if (!toolsStr)
|
|
66170
66211
|
return;
|
|
@@ -66178,7 +66219,7 @@ function parseToolsConfig(toolsStr) {
|
|
|
66178
66219
|
return result;
|
|
66179
66220
|
}
|
|
66180
66221
|
function loadAgentsFromDir(agentsDir, scope) {
|
|
66181
|
-
if (!
|
|
66222
|
+
if (!existsSync50(agentsDir)) {
|
|
66182
66223
|
return [];
|
|
66183
66224
|
}
|
|
66184
66225
|
const entries = readdirSync17(agentsDir, { withFileTypes: true });
|
|
@@ -66186,7 +66227,7 @@ function loadAgentsFromDir(agentsDir, scope) {
|
|
|
66186
66227
|
for (const entry of entries) {
|
|
66187
66228
|
if (!isMarkdownFile(entry))
|
|
66188
66229
|
continue;
|
|
66189
|
-
const agentPath =
|
|
66230
|
+
const agentPath = join59(agentsDir, entry.name);
|
|
66190
66231
|
const agentName = basename7(entry.name, ".md");
|
|
66191
66232
|
try {
|
|
66192
66233
|
const content = readFileSync29(agentPath, "utf-8");
|
|
@@ -66216,7 +66257,7 @@ function loadAgentsFromDir(agentsDir, scope) {
|
|
|
66216
66257
|
return agents;
|
|
66217
66258
|
}
|
|
66218
66259
|
function loadUserAgents() {
|
|
66219
|
-
const userAgentsDir =
|
|
66260
|
+
const userAgentsDir = join59(getClaudeConfigDir(), "agents");
|
|
66220
66261
|
const agents = loadAgentsFromDir(userAgentsDir, "user");
|
|
66221
66262
|
const result = {};
|
|
66222
66263
|
for (const agent of agents) {
|
|
@@ -66225,7 +66266,7 @@ function loadUserAgents() {
|
|
|
66225
66266
|
return result;
|
|
66226
66267
|
}
|
|
66227
66268
|
function loadProjectAgents() {
|
|
66228
|
-
const projectAgentsDir =
|
|
66269
|
+
const projectAgentsDir = join59(process.cwd(), ".claude", "agents");
|
|
66229
66270
|
const agents = loadAgentsFromDir(projectAgentsDir, "project");
|
|
66230
66271
|
const result = {};
|
|
66231
66272
|
for (const agent of agents) {
|
|
@@ -66237,18 +66278,18 @@ function loadProjectAgents() {
|
|
|
66237
66278
|
init_frontmatter();
|
|
66238
66279
|
init_file_utils();
|
|
66239
66280
|
init_logger();
|
|
66240
|
-
import { existsSync as
|
|
66281
|
+
import { existsSync as existsSync51, readdirSync as readdirSync18, readFileSync as readFileSync30 } from "fs";
|
|
66241
66282
|
import { homedir as homedir18 } from "os";
|
|
66242
|
-
import { join as
|
|
66283
|
+
import { join as join60, basename as basename8 } from "path";
|
|
66243
66284
|
var CLAUDE_PLUGIN_ROOT_VAR = "${CLAUDE_PLUGIN_ROOT}";
|
|
66244
66285
|
function getPluginsBaseDir() {
|
|
66245
66286
|
if (process.env.CLAUDE_PLUGINS_HOME) {
|
|
66246
66287
|
return process.env.CLAUDE_PLUGINS_HOME;
|
|
66247
66288
|
}
|
|
66248
|
-
return
|
|
66289
|
+
return join60(homedir18(), ".claude", "plugins");
|
|
66249
66290
|
}
|
|
66250
66291
|
function getInstalledPluginsPath() {
|
|
66251
|
-
return
|
|
66292
|
+
return join60(getPluginsBaseDir(), "installed_plugins.json");
|
|
66252
66293
|
}
|
|
66253
66294
|
function resolvePluginPath(path9, pluginRoot) {
|
|
66254
66295
|
return path9.replace(CLAUDE_PLUGIN_ROOT_VAR, pluginRoot);
|
|
@@ -66273,7 +66314,7 @@ function resolvePluginPaths(obj, pluginRoot) {
|
|
|
66273
66314
|
}
|
|
66274
66315
|
function loadInstalledPlugins() {
|
|
66275
66316
|
const dbPath = getInstalledPluginsPath();
|
|
66276
|
-
if (!
|
|
66317
|
+
if (!existsSync51(dbPath)) {
|
|
66277
66318
|
return null;
|
|
66278
66319
|
}
|
|
66279
66320
|
try {
|
|
@@ -66288,11 +66329,11 @@ function getClaudeSettingsPath() {
|
|
|
66288
66329
|
if (process.env.CLAUDE_SETTINGS_PATH) {
|
|
66289
66330
|
return process.env.CLAUDE_SETTINGS_PATH;
|
|
66290
66331
|
}
|
|
66291
|
-
return
|
|
66332
|
+
return join60(homedir18(), ".claude", "settings.json");
|
|
66292
66333
|
}
|
|
66293
66334
|
function loadClaudeSettings() {
|
|
66294
66335
|
const settingsPath = getClaudeSettingsPath();
|
|
66295
|
-
if (!
|
|
66336
|
+
if (!existsSync51(settingsPath)) {
|
|
66296
66337
|
return null;
|
|
66297
66338
|
}
|
|
66298
66339
|
try {
|
|
@@ -66304,8 +66345,8 @@ function loadClaudeSettings() {
|
|
|
66304
66345
|
}
|
|
66305
66346
|
}
|
|
66306
66347
|
function loadPluginManifest(installPath) {
|
|
66307
|
-
const manifestPath =
|
|
66308
|
-
if (!
|
|
66348
|
+
const manifestPath = join60(installPath, ".claude-plugin", "plugin.json");
|
|
66349
|
+
if (!existsSync51(manifestPath)) {
|
|
66309
66350
|
return null;
|
|
66310
66351
|
}
|
|
66311
66352
|
try {
|
|
@@ -66356,7 +66397,7 @@ function discoverInstalledPlugins(options) {
|
|
|
66356
66397
|
continue;
|
|
66357
66398
|
}
|
|
66358
66399
|
const { installPath, scope, version: version3 } = installation;
|
|
66359
|
-
if (!
|
|
66400
|
+
if (!existsSync51(installPath)) {
|
|
66360
66401
|
errors5.push({
|
|
66361
66402
|
pluginKey,
|
|
66362
66403
|
installPath,
|
|
@@ -66374,21 +66415,21 @@ function discoverInstalledPlugins(options) {
|
|
|
66374
66415
|
pluginKey,
|
|
66375
66416
|
manifest: manifest ?? undefined
|
|
66376
66417
|
};
|
|
66377
|
-
if (
|
|
66378
|
-
loadedPlugin.commandsDir =
|
|
66418
|
+
if (existsSync51(join60(installPath, "commands"))) {
|
|
66419
|
+
loadedPlugin.commandsDir = join60(installPath, "commands");
|
|
66379
66420
|
}
|
|
66380
|
-
if (
|
|
66381
|
-
loadedPlugin.agentsDir =
|
|
66421
|
+
if (existsSync51(join60(installPath, "agents"))) {
|
|
66422
|
+
loadedPlugin.agentsDir = join60(installPath, "agents");
|
|
66382
66423
|
}
|
|
66383
|
-
if (
|
|
66384
|
-
loadedPlugin.skillsDir =
|
|
66424
|
+
if (existsSync51(join60(installPath, "skills"))) {
|
|
66425
|
+
loadedPlugin.skillsDir = join60(installPath, "skills");
|
|
66385
66426
|
}
|
|
66386
|
-
const hooksPath =
|
|
66387
|
-
if (
|
|
66427
|
+
const hooksPath = join60(installPath, "hooks", "hooks.json");
|
|
66428
|
+
if (existsSync51(hooksPath)) {
|
|
66388
66429
|
loadedPlugin.hooksPath = hooksPath;
|
|
66389
66430
|
}
|
|
66390
|
-
const mcpPath =
|
|
66391
|
-
if (
|
|
66431
|
+
const mcpPath = join60(installPath, ".mcp.json");
|
|
66432
|
+
if (existsSync51(mcpPath)) {
|
|
66392
66433
|
loadedPlugin.mcpPath = mcpPath;
|
|
66393
66434
|
}
|
|
66394
66435
|
plugins.push(loadedPlugin);
|
|
@@ -66399,13 +66440,13 @@ function discoverInstalledPlugins(options) {
|
|
|
66399
66440
|
function loadPluginCommands(plugins) {
|
|
66400
66441
|
const commands2 = {};
|
|
66401
66442
|
for (const plugin of plugins) {
|
|
66402
|
-
if (!plugin.commandsDir || !
|
|
66443
|
+
if (!plugin.commandsDir || !existsSync51(plugin.commandsDir))
|
|
66403
66444
|
continue;
|
|
66404
66445
|
const entries = readdirSync18(plugin.commandsDir, { withFileTypes: true });
|
|
66405
66446
|
for (const entry of entries) {
|
|
66406
66447
|
if (!isMarkdownFile(entry))
|
|
66407
66448
|
continue;
|
|
66408
|
-
const commandPath =
|
|
66449
|
+
const commandPath = join60(plugin.commandsDir, entry.name);
|
|
66409
66450
|
const commandName = basename8(entry.name, ".md");
|
|
66410
66451
|
const namespacedName = `${plugin.name}:${commandName}`;
|
|
66411
66452
|
try {
|
|
@@ -66441,18 +66482,18 @@ $ARGUMENTS
|
|
|
66441
66482
|
function loadPluginSkillsAsCommands(plugins) {
|
|
66442
66483
|
const skills = {};
|
|
66443
66484
|
for (const plugin of plugins) {
|
|
66444
|
-
if (!plugin.skillsDir || !
|
|
66485
|
+
if (!plugin.skillsDir || !existsSync51(plugin.skillsDir))
|
|
66445
66486
|
continue;
|
|
66446
66487
|
const entries = readdirSync18(plugin.skillsDir, { withFileTypes: true });
|
|
66447
66488
|
for (const entry of entries) {
|
|
66448
66489
|
if (entry.name.startsWith("."))
|
|
66449
66490
|
continue;
|
|
66450
|
-
const skillPath =
|
|
66491
|
+
const skillPath = join60(plugin.skillsDir, entry.name);
|
|
66451
66492
|
if (!entry.isDirectory() && !entry.isSymbolicLink())
|
|
66452
66493
|
continue;
|
|
66453
66494
|
const resolvedPath = resolveSymlink(skillPath);
|
|
66454
|
-
const skillMdPath =
|
|
66455
|
-
if (!
|
|
66495
|
+
const skillMdPath = join60(resolvedPath, "SKILL.md");
|
|
66496
|
+
if (!existsSync51(skillMdPath))
|
|
66456
66497
|
continue;
|
|
66457
66498
|
try {
|
|
66458
66499
|
const content = readFileSync30(skillMdPath, "utf-8");
|
|
@@ -66502,13 +66543,13 @@ function parseToolsConfig2(toolsStr) {
|
|
|
66502
66543
|
function loadPluginAgents(plugins) {
|
|
66503
66544
|
const agents = {};
|
|
66504
66545
|
for (const plugin of plugins) {
|
|
66505
|
-
if (!plugin.agentsDir || !
|
|
66546
|
+
if (!plugin.agentsDir || !existsSync51(plugin.agentsDir))
|
|
66506
66547
|
continue;
|
|
66507
66548
|
const entries = readdirSync18(plugin.agentsDir, { withFileTypes: true });
|
|
66508
66549
|
for (const entry of entries) {
|
|
66509
66550
|
if (!isMarkdownFile(entry))
|
|
66510
66551
|
continue;
|
|
66511
|
-
const agentPath =
|
|
66552
|
+
const agentPath = join60(plugin.agentsDir, entry.name);
|
|
66512
66553
|
const agentName = basename8(entry.name, ".md");
|
|
66513
66554
|
const namespacedName = `${plugin.name}:${agentName}`;
|
|
66514
66555
|
try {
|
|
@@ -66538,7 +66579,7 @@ function loadPluginAgents(plugins) {
|
|
|
66538
66579
|
async function loadPluginMcpServers(plugins) {
|
|
66539
66580
|
const servers = {};
|
|
66540
66581
|
for (const plugin of plugins) {
|
|
66541
|
-
if (!plugin.mcpPath || !
|
|
66582
|
+
if (!plugin.mcpPath || !existsSync51(plugin.mcpPath))
|
|
66542
66583
|
continue;
|
|
66543
66584
|
try {
|
|
66544
66585
|
const content = await Bun.file(plugin.mcpPath).text();
|
|
@@ -66570,7 +66611,7 @@ async function loadPluginMcpServers(plugins) {
|
|
|
66570
66611
|
function loadPluginHooksConfigs(plugins) {
|
|
66571
66612
|
const configs = [];
|
|
66572
66613
|
for (const plugin of plugins) {
|
|
66573
|
-
if (!plugin.hooksPath || !
|
|
66614
|
+
if (!plugin.hooksPath || !existsSync51(plugin.hooksPath))
|
|
66574
66615
|
continue;
|
|
66575
66616
|
try {
|
|
66576
66617
|
const content = readFileSync30(plugin.hooksPath, "utf-8");
|