oh-my-opencode 3.17.2 → 3.17.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +474 -373
- package/dist/config/schema/agent-definitions.d.ts +3 -0
- package/dist/config/schema/oh-my-opencode-config.d.ts +1 -0
- package/dist/features/claude-code-agent-loader/agent-definitions-loader.d.ts +3 -0
- package/dist/features/claude-code-agent-loader/index.d.ts +3 -0
- package/dist/features/claude-code-agent-loader/json-agent-loader.d.ts +2 -0
- package/dist/features/claude-code-agent-loader/loader.d.ts +2 -0
- package/dist/features/claude-code-agent-loader/opencode-config-agents-reader.d.ts +2 -0
- package/dist/features/claude-code-agent-loader/types.d.ts +9 -1
- package/dist/hooks/keyword-detector/ultrawork/default.d.ts +1 -1
- package/dist/hooks/keyword-detector/ultrawork/gemini.d.ts +1 -1
- package/dist/hooks/keyword-detector/ultrawork/gpt.d.ts +1 -1
- package/dist/hooks/keyword-detector/ultrawork/planner.d.ts +1 -1
- package/dist/index.js +876 -561
- package/dist/oh-my-opencode.schema.json +7 -0
- package/dist/shared/agent-tool-restrictions.d.ts +0 -5
- package/dist/shared/index.d.ts +2 -0
- package/dist/shared/parse-tools-config.d.ts +6 -0
- package/dist/shared/resolve-agent-definition-paths.d.ts +1 -0
- package/dist/tools/call-omo-agent/agent-resolver.d.ts +17 -0
- package/dist/tools/call-omo-agent/constants.d.ts +1 -1
- package/package.json +12 -12
package/dist/cli/index.js
CHANGED
|
@@ -4915,6 +4915,42 @@ var init_command_executor = __esm(() => {
|
|
|
4915
4915
|
});
|
|
4916
4916
|
|
|
4917
4917
|
// src/shared/contains-path.ts
|
|
4918
|
+
import { existsSync, realpathSync } from "fs";
|
|
4919
|
+
import { basename, dirname, isAbsolute, join, normalize, relative, resolve } from "path";
|
|
4920
|
+
function findNearestExistingAncestor(resolvedPath) {
|
|
4921
|
+
let candidatePath = resolvedPath;
|
|
4922
|
+
while (!existsSync(candidatePath)) {
|
|
4923
|
+
const parentPath = dirname(candidatePath);
|
|
4924
|
+
if (parentPath === candidatePath) {
|
|
4925
|
+
return candidatePath;
|
|
4926
|
+
}
|
|
4927
|
+
candidatePath = parentPath;
|
|
4928
|
+
}
|
|
4929
|
+
return candidatePath;
|
|
4930
|
+
}
|
|
4931
|
+
function toCanonicalPath(pathToNormalize) {
|
|
4932
|
+
const resolvedPath = resolve(pathToNormalize);
|
|
4933
|
+
if (existsSync(resolvedPath)) {
|
|
4934
|
+
try {
|
|
4935
|
+
return normalize(realpathSync.native(resolvedPath));
|
|
4936
|
+
} catch {
|
|
4937
|
+
return normalize(resolvedPath);
|
|
4938
|
+
}
|
|
4939
|
+
}
|
|
4940
|
+
const nearestExistingAncestor = findNearestExistingAncestor(resolvedPath);
|
|
4941
|
+
const canonicalAncestor = existsSync(nearestExistingAncestor) ? realpathSync.native(nearestExistingAncestor) : nearestExistingAncestor;
|
|
4942
|
+
const relativePathFromAncestor = relative(nearestExistingAncestor, resolvedPath);
|
|
4943
|
+
return normalize(join(canonicalAncestor, relativePathFromAncestor || basename(resolvedPath)));
|
|
4944
|
+
}
|
|
4945
|
+
function containsPath(rootPath, candidatePath) {
|
|
4946
|
+
const canonicalRootPath = toCanonicalPath(rootPath);
|
|
4947
|
+
const canonicalCandidatePath = toCanonicalPath(candidatePath);
|
|
4948
|
+
const relativePath = relative(canonicalRootPath, canonicalCandidatePath);
|
|
4949
|
+
return relativePath === "" || !relativePath.startsWith("..") && !isAbsolute(relativePath);
|
|
4950
|
+
}
|
|
4951
|
+
function isWithinProject(candidatePath, projectRoot) {
|
|
4952
|
+
return containsPath(projectRoot, candidatePath);
|
|
4953
|
+
}
|
|
4918
4954
|
var init_contains_path = () => {};
|
|
4919
4955
|
|
|
4920
4956
|
// src/shared/plugin-identity.ts
|
|
@@ -5018,13 +5054,13 @@ var init_pattern_matcher = __esm(() => {
|
|
|
5018
5054
|
regexCache = new Map;
|
|
5019
5055
|
});
|
|
5020
5056
|
// src/shared/file-utils.ts
|
|
5021
|
-
import { lstatSync, realpathSync } from "fs";
|
|
5057
|
+
import { lstatSync, realpathSync as realpathSync2 } from "fs";
|
|
5022
5058
|
function normalizeDarwinRealpath(filePath) {
|
|
5023
5059
|
return filePath.startsWith("/private/var/") ? filePath.slice("/private".length) : filePath;
|
|
5024
5060
|
}
|
|
5025
5061
|
function resolveSymlink(filePath) {
|
|
5026
5062
|
try {
|
|
5027
|
-
return normalizeDarwinRealpath(
|
|
5063
|
+
return normalizeDarwinRealpath(realpathSync2(filePath));
|
|
5028
5064
|
} catch {
|
|
5029
5065
|
return filePath;
|
|
5030
5066
|
}
|
|
@@ -5982,8 +6018,8 @@ var init_main = __esm(() => {
|
|
|
5982
6018
|
});
|
|
5983
6019
|
|
|
5984
6020
|
// src/shared/jsonc-parser.ts
|
|
5985
|
-
import { existsSync, readFileSync } from "fs";
|
|
5986
|
-
import { join as
|
|
6021
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
6022
|
+
import { join as join4 } from "path";
|
|
5987
6023
|
function stripBom(content) {
|
|
5988
6024
|
return content.charCodeAt(0) === 65279 ? content.slice(1) : content;
|
|
5989
6025
|
}
|
|
@@ -6003,17 +6039,17 @@ function parseJsonc(content) {
|
|
|
6003
6039
|
function detectConfigFile(basePath) {
|
|
6004
6040
|
const jsoncPath = `${basePath}.jsonc`;
|
|
6005
6041
|
const jsonPath = `${basePath}.json`;
|
|
6006
|
-
if (
|
|
6042
|
+
if (existsSync2(jsoncPath)) {
|
|
6007
6043
|
return { format: "jsonc", path: jsoncPath };
|
|
6008
6044
|
}
|
|
6009
|
-
if (
|
|
6045
|
+
if (existsSync2(jsonPath)) {
|
|
6010
6046
|
return { format: "json", path: jsonPath };
|
|
6011
6047
|
}
|
|
6012
6048
|
return { format: "none", path: jsonPath };
|
|
6013
6049
|
}
|
|
6014
6050
|
function detectPluginConfigFile(dir) {
|
|
6015
|
-
const canonicalResult = detectConfigFile(
|
|
6016
|
-
const legacyResult = detectConfigFile(
|
|
6051
|
+
const canonicalResult = detectConfigFile(join4(dir, CONFIG_BASENAME));
|
|
6052
|
+
const legacyResult = detectConfigFile(join4(dir, LEGACY_CONFIG_BASENAME));
|
|
6017
6053
|
if (canonicalResult.format !== "none") {
|
|
6018
6054
|
return {
|
|
6019
6055
|
...canonicalResult,
|
|
@@ -6023,7 +6059,7 @@ function detectPluginConfigFile(dir) {
|
|
|
6023
6059
|
if (legacyResult.format !== "none") {
|
|
6024
6060
|
return legacyResult;
|
|
6025
6061
|
}
|
|
6026
|
-
return { format: "none", path:
|
|
6062
|
+
return { format: "none", path: join4(dir, `${CONFIG_BASENAME}.json`) };
|
|
6027
6063
|
}
|
|
6028
6064
|
var init_jsonc_parser = __esm(() => {
|
|
6029
6065
|
init_main();
|
|
@@ -6335,20 +6371,28 @@ function migrateConfigFile(configPath, rawConfig) {
|
|
|
6335
6371
|
}
|
|
6336
6372
|
}
|
|
6337
6373
|
if (needsWrite) {
|
|
6374
|
+
let finalConfig = JSON.parse(JSON.stringify(copy));
|
|
6375
|
+
const newContent = JSON.stringify(finalConfig, null, 2) + `
|
|
6376
|
+
`;
|
|
6377
|
+
let existingContent;
|
|
6378
|
+
try {
|
|
6379
|
+
existingContent = fs3.readFileSync(configPath, "utf-8");
|
|
6380
|
+
} catch {}
|
|
6381
|
+
const contentChanged = existingContent !== newContent;
|
|
6338
6382
|
const timestamp2 = new Date().toISOString().replace(/[:.]/g, "-");
|
|
6339
6383
|
const backupPath = `${configPath}.bak.${timestamp2}`;
|
|
6340
6384
|
let backupSucceeded = false;
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6385
|
+
if (contentChanged) {
|
|
6386
|
+
try {
|
|
6387
|
+
fs3.copyFileSync(configPath, backupPath);
|
|
6388
|
+
backupSucceeded = true;
|
|
6389
|
+
} catch {
|
|
6390
|
+
backupSucceeded = false;
|
|
6391
|
+
}
|
|
6346
6392
|
}
|
|
6347
6393
|
let writeSucceeded = false;
|
|
6348
|
-
let finalConfig = JSON.parse(JSON.stringify(copy));
|
|
6349
6394
|
try {
|
|
6350
|
-
writeFileAtomically(configPath,
|
|
6351
|
-
`);
|
|
6395
|
+
writeFileAtomically(configPath, newContent);
|
|
6352
6396
|
writeSucceeded = true;
|
|
6353
6397
|
} catch (err) {
|
|
6354
6398
|
log(`Failed to write migrated config to ${configPath}:`, err);
|
|
@@ -6400,9 +6444,9 @@ var init_migration = __esm(() => {
|
|
|
6400
6444
|
});
|
|
6401
6445
|
|
|
6402
6446
|
// src/shared/opencode-config-dir.ts
|
|
6403
|
-
import { existsSync as
|
|
6447
|
+
import { existsSync as existsSync4, realpathSync as realpathSync3 } from "fs";
|
|
6404
6448
|
import { homedir as homedir2 } from "os";
|
|
6405
|
-
import { join as
|
|
6449
|
+
import { join as join5, resolve as resolve2, win32 } from "path";
|
|
6406
6450
|
function isDevBuild(version) {
|
|
6407
6451
|
if (!version)
|
|
6408
6452
|
return false;
|
|
@@ -6412,24 +6456,24 @@ function getTauriConfigDir(identifier) {
|
|
|
6412
6456
|
const platform = process.platform;
|
|
6413
6457
|
switch (platform) {
|
|
6414
6458
|
case "darwin":
|
|
6415
|
-
return
|
|
6459
|
+
return join5(homedir2(), "Library", "Application Support", identifier);
|
|
6416
6460
|
case "win32": {
|
|
6417
|
-
const appData = process.env.APPDATA ||
|
|
6461
|
+
const appData = process.env.APPDATA || join5(homedir2(), "AppData", "Roaming");
|
|
6418
6462
|
return win32.join(appData, identifier);
|
|
6419
6463
|
}
|
|
6420
6464
|
case "linux":
|
|
6421
6465
|
default: {
|
|
6422
|
-
const xdgConfig = process.env.XDG_CONFIG_HOME ||
|
|
6423
|
-
return
|
|
6466
|
+
const xdgConfig = process.env.XDG_CONFIG_HOME || join5(homedir2(), ".config");
|
|
6467
|
+
return join5(xdgConfig, identifier);
|
|
6424
6468
|
}
|
|
6425
6469
|
}
|
|
6426
6470
|
}
|
|
6427
6471
|
function resolveConfigPath(pathValue) {
|
|
6428
|
-
const resolvedPath =
|
|
6429
|
-
if (!
|
|
6472
|
+
const resolvedPath = resolve2(pathValue);
|
|
6473
|
+
if (!existsSync4(resolvedPath))
|
|
6430
6474
|
return resolvedPath;
|
|
6431
6475
|
try {
|
|
6432
|
-
return
|
|
6476
|
+
return realpathSync3(resolvedPath);
|
|
6433
6477
|
} catch {
|
|
6434
6478
|
return resolvedPath;
|
|
6435
6479
|
}
|
|
@@ -6439,8 +6483,8 @@ function getCliConfigDir() {
|
|
|
6439
6483
|
if (envConfigDir) {
|
|
6440
6484
|
return resolveConfigPath(envConfigDir);
|
|
6441
6485
|
}
|
|
6442
|
-
const xdgConfig = process.env.XDG_CONFIG_HOME ||
|
|
6443
|
-
return resolveConfigPath(
|
|
6486
|
+
const xdgConfig = process.env.XDG_CONFIG_HOME || join5(homedir2(), ".config");
|
|
6487
|
+
return resolveConfigPath(join5(xdgConfig, "opencode"));
|
|
6444
6488
|
}
|
|
6445
6489
|
function getOpenCodeConfigDir(options) {
|
|
6446
6490
|
const { binary: binary2, version, checkExisting = true } = options;
|
|
@@ -6452,9 +6496,9 @@ function getOpenCodeConfigDir(options) {
|
|
|
6452
6496
|
const tauriDir = process.platform === "win32" ? win32.isAbsolute(tauriDirBase) ? win32.normalize(tauriDirBase) : win32.resolve(tauriDirBase) : resolveConfigPath(tauriDirBase);
|
|
6453
6497
|
if (checkExisting) {
|
|
6454
6498
|
const legacyDir = getCliConfigDir();
|
|
6455
|
-
const legacyConfig =
|
|
6456
|
-
const legacyConfigC =
|
|
6457
|
-
if (
|
|
6499
|
+
const legacyConfig = join5(legacyDir, "opencode.json");
|
|
6500
|
+
const legacyConfigC = join5(legacyDir, "opencode.jsonc");
|
|
6501
|
+
if (existsSync4(legacyConfig) || existsSync4(legacyConfigC)) {
|
|
6458
6502
|
return legacyDir;
|
|
6459
6503
|
}
|
|
6460
6504
|
}
|
|
@@ -6464,10 +6508,10 @@ function getOpenCodeConfigPaths(options) {
|
|
|
6464
6508
|
const configDir = getOpenCodeConfigDir(options);
|
|
6465
6509
|
return {
|
|
6466
6510
|
configDir,
|
|
6467
|
-
configJson:
|
|
6468
|
-
configJsonc:
|
|
6469
|
-
packageJson:
|
|
6470
|
-
omoConfig:
|
|
6511
|
+
configJson: join5(configDir, "opencode.json"),
|
|
6512
|
+
configJsonc: join5(configDir, "opencode.jsonc"),
|
|
6513
|
+
packageJson: join5(configDir, "package.json"),
|
|
6514
|
+
omoConfig: join5(configDir, `${CONFIG_BASENAME}.json`)
|
|
6471
6515
|
};
|
|
6472
6516
|
}
|
|
6473
6517
|
var TAURI_APP_IDENTIFIER = "ai.opencode.desktop", TAURI_APP_IDENTIFIER_DEV = "ai.opencode.desktop.dev";
|
|
@@ -6475,6 +6519,25 @@ var init_opencode_config_dir = __esm(() => {
|
|
|
6475
6519
|
init_plugin_identity();
|
|
6476
6520
|
});
|
|
6477
6521
|
|
|
6522
|
+
// src/shared/resolve-agent-definition-paths.ts
|
|
6523
|
+
import { homedir as homedir3 } from "os";
|
|
6524
|
+
import { isAbsolute as isAbsolute2, resolve as resolve3 } from "path";
|
|
6525
|
+
function resolveAgentDefinitionPaths(paths, baseDir, containmentDir) {
|
|
6526
|
+
return paths.flatMap((p) => {
|
|
6527
|
+
const expanded = p.startsWith("~/") ? p.replace(/^~\//, `${homedir3()}/`) : p;
|
|
6528
|
+
const resolved = isAbsolute2(expanded) ? expanded : resolve3(baseDir, expanded);
|
|
6529
|
+
if (containmentDir !== null && !isWithinProject(resolved, containmentDir)) {
|
|
6530
|
+
log(`agent_definitions path rejected (outside project boundary): ${p} -> ${resolved}`);
|
|
6531
|
+
return [];
|
|
6532
|
+
}
|
|
6533
|
+
return [resolved];
|
|
6534
|
+
});
|
|
6535
|
+
}
|
|
6536
|
+
var init_resolve_agent_definition_paths = __esm(() => {
|
|
6537
|
+
init_contains_path();
|
|
6538
|
+
init_logger();
|
|
6539
|
+
});
|
|
6540
|
+
|
|
6478
6541
|
// src/shared/opencode-version.ts
|
|
6479
6542
|
import { execSync } from "child_process";
|
|
6480
6543
|
function parseVersion(version) {
|
|
@@ -6526,8 +6589,8 @@ var init_opencode_version = __esm(() => {
|
|
|
6526
6589
|
});
|
|
6527
6590
|
|
|
6528
6591
|
// src/shared/opencode-storage-detection.ts
|
|
6529
|
-
import { existsSync as
|
|
6530
|
-
import { join as
|
|
6592
|
+
import { existsSync as existsSync5 } from "fs";
|
|
6593
|
+
import { join as join6 } from "path";
|
|
6531
6594
|
function isSqliteBackend() {
|
|
6532
6595
|
if (cachedResult === true)
|
|
6533
6596
|
return true;
|
|
@@ -6535,8 +6598,8 @@ function isSqliteBackend() {
|
|
|
6535
6598
|
return false;
|
|
6536
6599
|
const check = () => {
|
|
6537
6600
|
const versionOk = isOpenCodeVersionAtLeast(OPENCODE_SQLITE_VERSION);
|
|
6538
|
-
const dbPath =
|
|
6539
|
-
return versionOk &&
|
|
6601
|
+
const dbPath = join6(getDataDir(), "opencode", "opencode.db");
|
|
6602
|
+
return versionOk && existsSync5(dbPath);
|
|
6540
6603
|
};
|
|
6541
6604
|
if (cachedResult === FALSE_PENDING_RETRY) {
|
|
6542
6605
|
const result2 = check();
|
|
@@ -6608,17 +6671,94 @@ var init_zip_extractor = __esm(() => {
|
|
|
6608
6671
|
});
|
|
6609
6672
|
|
|
6610
6673
|
// src/shared/binary-downloader.ts
|
|
6611
|
-
import { chmodSync, existsSync as
|
|
6674
|
+
import { chmodSync, existsSync as existsSync6, mkdirSync as mkdirSync3, unlinkSync as unlinkSync2 } from "fs";
|
|
6612
6675
|
import * as path4 from "path";
|
|
6613
6676
|
function getCachedBinaryPath(cacheDir, binaryName) {
|
|
6614
6677
|
const binaryPath = path4.join(cacheDir, binaryName);
|
|
6615
|
-
return
|
|
6678
|
+
return existsSync6(binaryPath) ? binaryPath : null;
|
|
6616
6679
|
}
|
|
6617
6680
|
var init_binary_downloader = __esm(() => {
|
|
6618
6681
|
init_archive_entry_validator();
|
|
6619
6682
|
init_zip_extractor();
|
|
6620
6683
|
});
|
|
6621
6684
|
|
|
6685
|
+
// src/shared/agent-display-names.ts
|
|
6686
|
+
function stripInvisibleAgentCharacters(agentName) {
|
|
6687
|
+
return agentName.replace(INVISIBLE_AGENT_CHARACTERS_REGEX, "");
|
|
6688
|
+
}
|
|
6689
|
+
function stripAgentListSortPrefix(agentName) {
|
|
6690
|
+
return stripInvisibleAgentCharacters(agentName);
|
|
6691
|
+
}
|
|
6692
|
+
function getAgentRuntimeName(configKey) {
|
|
6693
|
+
const displayName = getAgentDisplayName(configKey);
|
|
6694
|
+
const prefix = AGENT_LIST_SORT_PREFIXES[configKey.toLowerCase()];
|
|
6695
|
+
return prefix ? `${prefix}${displayName}` : displayName;
|
|
6696
|
+
}
|
|
6697
|
+
function getAgentDisplayName(configKey) {
|
|
6698
|
+
const exactMatch = AGENT_DISPLAY_NAMES[configKey];
|
|
6699
|
+
if (exactMatch !== undefined)
|
|
6700
|
+
return exactMatch;
|
|
6701
|
+
const lowerKey = configKey.toLowerCase();
|
|
6702
|
+
for (const [k, v] of Object.entries(AGENT_DISPLAY_NAMES)) {
|
|
6703
|
+
if (k.toLowerCase() === lowerKey)
|
|
6704
|
+
return v;
|
|
6705
|
+
}
|
|
6706
|
+
return configKey;
|
|
6707
|
+
}
|
|
6708
|
+
function resolveKnownAgentConfigKey(agentName) {
|
|
6709
|
+
const lower = stripAgentListSortPrefix(agentName).trim().toLowerCase();
|
|
6710
|
+
const reversed = REVERSE_DISPLAY_NAMES[lower];
|
|
6711
|
+
if (reversed !== undefined)
|
|
6712
|
+
return reversed;
|
|
6713
|
+
const legacy = LEGACY_DISPLAY_NAMES[lower];
|
|
6714
|
+
if (legacy !== undefined)
|
|
6715
|
+
return legacy;
|
|
6716
|
+
if (AGENT_DISPLAY_NAMES[lower] !== undefined)
|
|
6717
|
+
return lower;
|
|
6718
|
+
return;
|
|
6719
|
+
}
|
|
6720
|
+
function getAgentConfigKey(agentName) {
|
|
6721
|
+
const lower = stripAgentListSortPrefix(agentName).trim().toLowerCase();
|
|
6722
|
+
return resolveKnownAgentConfigKey(agentName) ?? lower;
|
|
6723
|
+
}
|
|
6724
|
+
var AGENT_DISPLAY_NAMES, AGENT_LIST_SORT_PREFIXES, INVISIBLE_AGENT_CHARACTERS_REGEX, REVERSE_DISPLAY_NAMES, LEGACY_DISPLAY_NAMES;
|
|
6725
|
+
var init_agent_display_names = __esm(() => {
|
|
6726
|
+
AGENT_DISPLAY_NAMES = {
|
|
6727
|
+
sisyphus: "Sisyphus - Ultraworker",
|
|
6728
|
+
hephaestus: "Hephaestus - Deep Agent",
|
|
6729
|
+
prometheus: "Prometheus - Plan Builder",
|
|
6730
|
+
atlas: "Atlas - Plan Executor",
|
|
6731
|
+
"sisyphus-junior": "Sisyphus-Junior",
|
|
6732
|
+
metis: "Metis - Plan Consultant",
|
|
6733
|
+
momus: "Momus - Plan Critic",
|
|
6734
|
+
athena: "Athena - Council",
|
|
6735
|
+
"athena-junior": "Athena-Junior - Council",
|
|
6736
|
+
oracle: "oracle",
|
|
6737
|
+
librarian: "librarian",
|
|
6738
|
+
explore: "explore",
|
|
6739
|
+
"multimodal-looker": "multimodal-looker",
|
|
6740
|
+
"council-member": "council-member"
|
|
6741
|
+
};
|
|
6742
|
+
AGENT_LIST_SORT_PREFIXES = {
|
|
6743
|
+
sisyphus: "\u200B",
|
|
6744
|
+
hephaestus: "\u200B\u200B",
|
|
6745
|
+
prometheus: "\u200B\u200B\u200B",
|
|
6746
|
+
atlas: "\u200B\u200B\u200B\u200B"
|
|
6747
|
+
};
|
|
6748
|
+
INVISIBLE_AGENT_CHARACTERS_REGEX = /[\u200B\u200C\u200D\uFEFF]/g;
|
|
6749
|
+
REVERSE_DISPLAY_NAMES = Object.fromEntries(Object.entries(AGENT_DISPLAY_NAMES).map(([key, displayName]) => [displayName.toLowerCase(), key]));
|
|
6750
|
+
LEGACY_DISPLAY_NAMES = {
|
|
6751
|
+
"sisyphus (ultraworker)": "sisyphus",
|
|
6752
|
+
"hephaestus (deep agent)": "hephaestus",
|
|
6753
|
+
"prometheus (plan builder)": "prometheus",
|
|
6754
|
+
"atlas (plan executor)": "atlas",
|
|
6755
|
+
"metis (plan consultant)": "metis",
|
|
6756
|
+
"momus (plan critic)": "momus",
|
|
6757
|
+
"athena (council)": "athena",
|
|
6758
|
+
"athena-junior (council)": "athena-junior"
|
|
6759
|
+
};
|
|
6760
|
+
});
|
|
6761
|
+
|
|
6622
6762
|
// src/shared/model-requirements.ts
|
|
6623
6763
|
var AGENT_MODEL_REQUIREMENTS, CATEGORY_MODEL_REQUIREMENTS;
|
|
6624
6764
|
var init_model_requirements = __esm(() => {
|
|
@@ -6945,6 +7085,7 @@ var init_model_requirements = __esm(() => {
|
|
|
6945
7085
|
|
|
6946
7086
|
// src/shared/agent-variant.ts
|
|
6947
7087
|
var init_agent_variant = __esm(() => {
|
|
7088
|
+
init_agent_display_names();
|
|
6948
7089
|
init_model_requirements();
|
|
6949
7090
|
});
|
|
6950
7091
|
|
|
@@ -6963,6 +7104,9 @@ function detectShellType() {
|
|
|
6963
7104
|
}
|
|
6964
7105
|
return "unix";
|
|
6965
7106
|
}
|
|
7107
|
+
if (process.env.MSYSTEM) {
|
|
7108
|
+
return "unix";
|
|
7109
|
+
}
|
|
6966
7110
|
if (process.env.PSModulePath) {
|
|
6967
7111
|
return "powershell";
|
|
6968
7112
|
}
|
|
@@ -6973,7 +7117,9 @@ function detectShellType() {
|
|
|
6973
7117
|
var init_system_directive = () => {};
|
|
6974
7118
|
|
|
6975
7119
|
// src/shared/agent-tool-restrictions.ts
|
|
6976
|
-
var init_agent_tool_restrictions = () => {
|
|
7120
|
+
var init_agent_tool_restrictions = __esm(() => {
|
|
7121
|
+
init_agent_display_names();
|
|
7122
|
+
});
|
|
6977
7123
|
|
|
6978
7124
|
// src/shared/model-normalization.ts
|
|
6979
7125
|
function normalizeModelID(modelID) {
|
|
@@ -6981,19 +7127,19 @@ function normalizeModelID(modelID) {
|
|
|
6981
7127
|
}
|
|
6982
7128
|
|
|
6983
7129
|
// src/shared/json-file-cache-store.ts
|
|
6984
|
-
import { existsSync as
|
|
6985
|
-
import { join as
|
|
7130
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "fs";
|
|
7131
|
+
import { join as join8 } from "path";
|
|
6986
7132
|
function toLogLabel(cacheLabel) {
|
|
6987
7133
|
return cacheLabel.toLowerCase();
|
|
6988
7134
|
}
|
|
6989
7135
|
function createJsonFileCacheStore(options) {
|
|
6990
7136
|
let memoryValue;
|
|
6991
7137
|
function getCacheFilePath() {
|
|
6992
|
-
return
|
|
7138
|
+
return join8(options.getCacheDir(), options.filename);
|
|
6993
7139
|
}
|
|
6994
7140
|
function ensureCacheDir() {
|
|
6995
7141
|
const cacheDir = options.getCacheDir();
|
|
6996
|
-
if (!
|
|
7142
|
+
if (!existsSync7(cacheDir)) {
|
|
6997
7143
|
mkdirSync4(cacheDir, { recursive: true });
|
|
6998
7144
|
}
|
|
6999
7145
|
}
|
|
@@ -7002,13 +7148,13 @@ function createJsonFileCacheStore(options) {
|
|
|
7002
7148
|
return memoryValue;
|
|
7003
7149
|
}
|
|
7004
7150
|
const cacheFile = getCacheFilePath();
|
|
7005
|
-
if (!
|
|
7151
|
+
if (!existsSync7(cacheFile)) {
|
|
7006
7152
|
memoryValue = null;
|
|
7007
7153
|
log(`[${options.logPrefix}] ${options.cacheLabel} file not found`, { cacheFile });
|
|
7008
7154
|
return null;
|
|
7009
7155
|
}
|
|
7010
7156
|
try {
|
|
7011
|
-
const content =
|
|
7157
|
+
const content = readFileSync4(cacheFile, "utf-8");
|
|
7012
7158
|
const value = JSON.parse(content);
|
|
7013
7159
|
memoryValue = value;
|
|
7014
7160
|
log(`[${options.logPrefix}] Read ${toLogLabel(options.cacheLabel)}`, options.describe(value));
|
|
@@ -7022,7 +7168,7 @@ function createJsonFileCacheStore(options) {
|
|
|
7022
7168
|
}
|
|
7023
7169
|
}
|
|
7024
7170
|
function has() {
|
|
7025
|
-
return
|
|
7171
|
+
return existsSync7(getCacheFilePath());
|
|
7026
7172
|
}
|
|
7027
7173
|
function write(value) {
|
|
7028
7174
|
ensureCacheDir();
|
|
@@ -7191,14 +7337,14 @@ var init_connected_providers_cache = __esm(() => {
|
|
|
7191
7337
|
});
|
|
7192
7338
|
|
|
7193
7339
|
// src/shared/model-availability.ts
|
|
7194
|
-
import { existsSync as
|
|
7195
|
-
import { join as
|
|
7340
|
+
import { existsSync as existsSync8, readFileSync as readFileSync5 } from "fs";
|
|
7341
|
+
import { join as join9 } from "path";
|
|
7196
7342
|
function isModelCacheAvailable() {
|
|
7197
7343
|
if (hasProviderModelsCache()) {
|
|
7198
7344
|
return true;
|
|
7199
7345
|
}
|
|
7200
|
-
const cacheFile =
|
|
7201
|
-
return
|
|
7346
|
+
const cacheFile = join9(getOpenCodeCacheDir(), "models.json");
|
|
7347
|
+
return existsSync8(cacheFile);
|
|
7202
7348
|
}
|
|
7203
7349
|
var init_model_availability = __esm(() => {
|
|
7204
7350
|
init_logger();
|
|
@@ -48487,19 +48633,19 @@ var init_constants = __esm(() => {
|
|
|
48487
48633
|
});
|
|
48488
48634
|
|
|
48489
48635
|
// src/shared/opencode-storage-paths.ts
|
|
48490
|
-
import { join as
|
|
48636
|
+
import { join as join10 } from "path";
|
|
48491
48637
|
var OPENCODE_STORAGE, MESSAGE_STORAGE, PART_STORAGE, SESSION_STORAGE;
|
|
48492
48638
|
var init_opencode_storage_paths = __esm(() => {
|
|
48493
48639
|
init_data_path();
|
|
48494
48640
|
OPENCODE_STORAGE = getOpenCodeStorageDir();
|
|
48495
|
-
MESSAGE_STORAGE =
|
|
48496
|
-
PART_STORAGE =
|
|
48497
|
-
SESSION_STORAGE =
|
|
48641
|
+
MESSAGE_STORAGE = join10(OPENCODE_STORAGE, "message");
|
|
48642
|
+
PART_STORAGE = join10(OPENCODE_STORAGE, "part");
|
|
48643
|
+
SESSION_STORAGE = join10(OPENCODE_STORAGE, "session");
|
|
48498
48644
|
});
|
|
48499
48645
|
|
|
48500
48646
|
// src/shared/compaction-marker.ts
|
|
48501
|
-
import { existsSync as
|
|
48502
|
-
import { join as
|
|
48647
|
+
import { existsSync as existsSync9, readdirSync, readFileSync as readFileSync6 } from "fs";
|
|
48648
|
+
import { join as join11 } from "path";
|
|
48503
48649
|
function isCompactionPart(part) {
|
|
48504
48650
|
return typeof part === "object" && part !== null && part.type === "compaction";
|
|
48505
48651
|
}
|
|
@@ -48513,20 +48659,20 @@ function isCompactionMessage(message) {
|
|
|
48513
48659
|
return isCompactionAgent(message.info?.agent ?? message.agent) || hasCompactionPart(message.parts);
|
|
48514
48660
|
}
|
|
48515
48661
|
function getCompactionPartStorageDir(messageID) {
|
|
48516
|
-
return
|
|
48662
|
+
return join11(PART_STORAGE, messageID);
|
|
48517
48663
|
}
|
|
48518
48664
|
function hasCompactionPartInStorage(messageID) {
|
|
48519
48665
|
if (!messageID) {
|
|
48520
48666
|
return false;
|
|
48521
48667
|
}
|
|
48522
48668
|
const partDir = getCompactionPartStorageDir(messageID);
|
|
48523
|
-
if (!
|
|
48669
|
+
if (!existsSync9(partDir)) {
|
|
48524
48670
|
return false;
|
|
48525
48671
|
}
|
|
48526
48672
|
try {
|
|
48527
48673
|
return readdirSync(partDir).filter((fileName) => fileName.endsWith(".json")).some((fileName) => {
|
|
48528
48674
|
try {
|
|
48529
|
-
const content =
|
|
48675
|
+
const content = readFileSync6(join11(partDir, fileName), "utf-8");
|
|
48530
48676
|
return isCompactionPart(JSON.parse(content));
|
|
48531
48677
|
} catch {
|
|
48532
48678
|
return false;
|
|
@@ -48559,23 +48705,23 @@ var init_hook_message_injector = __esm(() => {
|
|
|
48559
48705
|
});
|
|
48560
48706
|
|
|
48561
48707
|
// src/shared/opencode-message-dir.ts
|
|
48562
|
-
import { existsSync as
|
|
48563
|
-
import { join as
|
|
48708
|
+
import { existsSync as existsSync10, readdirSync as readdirSync2 } from "fs";
|
|
48709
|
+
import { join as join12 } from "path";
|
|
48564
48710
|
function getMessageDir(sessionID) {
|
|
48565
48711
|
if (!sessionID.startsWith("ses_"))
|
|
48566
48712
|
return null;
|
|
48567
48713
|
if (/[/\\]|\.\./.test(sessionID))
|
|
48568
48714
|
return null;
|
|
48569
|
-
if (!
|
|
48715
|
+
if (!existsSync10(MESSAGE_STORAGE))
|
|
48570
48716
|
return null;
|
|
48571
|
-
const directPath =
|
|
48572
|
-
if (
|
|
48717
|
+
const directPath = join12(MESSAGE_STORAGE, sessionID);
|
|
48718
|
+
if (existsSync10(directPath)) {
|
|
48573
48719
|
return directPath;
|
|
48574
48720
|
}
|
|
48575
48721
|
try {
|
|
48576
48722
|
for (const dir of readdirSync2(MESSAGE_STORAGE)) {
|
|
48577
|
-
const sessionPath =
|
|
48578
|
-
if (
|
|
48723
|
+
const sessionPath = join12(MESSAGE_STORAGE, dir, sessionID);
|
|
48724
|
+
if (existsSync10(sessionPath)) {
|
|
48579
48725
|
return sessionPath;
|
|
48580
48726
|
}
|
|
48581
48727
|
}
|
|
@@ -48590,72 +48736,6 @@ var init_opencode_message_dir = __esm(() => {
|
|
|
48590
48736
|
init_logger();
|
|
48591
48737
|
});
|
|
48592
48738
|
|
|
48593
|
-
// src/shared/agent-display-names.ts
|
|
48594
|
-
function stripInvisibleAgentCharacters(agentName) {
|
|
48595
|
-
return agentName.replace(INVISIBLE_AGENT_CHARACTERS_REGEX, "");
|
|
48596
|
-
}
|
|
48597
|
-
function stripAgentListSortPrefix(agentName) {
|
|
48598
|
-
return stripInvisibleAgentCharacters(agentName);
|
|
48599
|
-
}
|
|
48600
|
-
function getAgentDisplayName(configKey) {
|
|
48601
|
-
const exactMatch = AGENT_DISPLAY_NAMES[configKey];
|
|
48602
|
-
if (exactMatch !== undefined)
|
|
48603
|
-
return exactMatch;
|
|
48604
|
-
const lowerKey = configKey.toLowerCase();
|
|
48605
|
-
for (const [k, v] of Object.entries(AGENT_DISPLAY_NAMES)) {
|
|
48606
|
-
if (k.toLowerCase() === lowerKey)
|
|
48607
|
-
return v;
|
|
48608
|
-
}
|
|
48609
|
-
return configKey;
|
|
48610
|
-
}
|
|
48611
|
-
function resolveKnownAgentConfigKey(agentName) {
|
|
48612
|
-
const lower = stripAgentListSortPrefix(agentName).trim().toLowerCase();
|
|
48613
|
-
const reversed = REVERSE_DISPLAY_NAMES[lower];
|
|
48614
|
-
if (reversed !== undefined)
|
|
48615
|
-
return reversed;
|
|
48616
|
-
const legacy = LEGACY_DISPLAY_NAMES[lower];
|
|
48617
|
-
if (legacy !== undefined)
|
|
48618
|
-
return legacy;
|
|
48619
|
-
if (AGENT_DISPLAY_NAMES[lower] !== undefined)
|
|
48620
|
-
return lower;
|
|
48621
|
-
return;
|
|
48622
|
-
}
|
|
48623
|
-
function getAgentConfigKey(agentName) {
|
|
48624
|
-
const lower = stripAgentListSortPrefix(agentName).trim().toLowerCase();
|
|
48625
|
-
return resolveKnownAgentConfigKey(agentName) ?? lower;
|
|
48626
|
-
}
|
|
48627
|
-
var AGENT_DISPLAY_NAMES, INVISIBLE_AGENT_CHARACTERS_REGEX, REVERSE_DISPLAY_NAMES, LEGACY_DISPLAY_NAMES;
|
|
48628
|
-
var init_agent_display_names = __esm(() => {
|
|
48629
|
-
AGENT_DISPLAY_NAMES = {
|
|
48630
|
-
sisyphus: "Sisyphus - Ultraworker",
|
|
48631
|
-
hephaestus: "Hephaestus - Deep Agent",
|
|
48632
|
-
prometheus: "Prometheus - Plan Builder",
|
|
48633
|
-
atlas: "Atlas - Plan Executor",
|
|
48634
|
-
"sisyphus-junior": "Sisyphus-Junior",
|
|
48635
|
-
metis: "Metis - Plan Consultant",
|
|
48636
|
-
momus: "Momus - Plan Critic",
|
|
48637
|
-
athena: "Athena - Council",
|
|
48638
|
-
"athena-junior": "Athena-Junior - Council",
|
|
48639
|
-
oracle: "oracle",
|
|
48640
|
-
librarian: "librarian",
|
|
48641
|
-
explore: "explore",
|
|
48642
|
-
"multimodal-looker": "multimodal-looker",
|
|
48643
|
-
"council-member": "council-member"
|
|
48644
|
-
};
|
|
48645
|
-
INVISIBLE_AGENT_CHARACTERS_REGEX = /[\u200B\u200C\u200D\uFEFF]/g;
|
|
48646
|
-
REVERSE_DISPLAY_NAMES = Object.fromEntries(Object.entries(AGENT_DISPLAY_NAMES).map(([key, displayName]) => [displayName.toLowerCase(), key]));
|
|
48647
|
-
LEGACY_DISPLAY_NAMES = {
|
|
48648
|
-
"sisyphus (ultraworker)": "sisyphus",
|
|
48649
|
-
"hephaestus (deep agent)": "hephaestus",
|
|
48650
|
-
"prometheus (plan builder)": "prometheus",
|
|
48651
|
-
"atlas (plan executor)": "atlas",
|
|
48652
|
-
"metis (plan consultant)": "metis",
|
|
48653
|
-
"momus (plan critic)": "momus",
|
|
48654
|
-
"athena (council)": "athena",
|
|
48655
|
-
"athena-junior (council)": "athena-junior"
|
|
48656
|
-
};
|
|
48657
|
-
});
|
|
48658
|
-
|
|
48659
48739
|
// src/shared/session-utils.ts
|
|
48660
48740
|
var init_session_utils = __esm(() => {
|
|
48661
48741
|
init_hook_message_injector();
|
|
@@ -48992,6 +49072,7 @@ var init_shared = __esm(() => {
|
|
|
48992
49072
|
init_jsonc_parser();
|
|
48993
49073
|
init_migration();
|
|
48994
49074
|
init_opencode_config_dir();
|
|
49075
|
+
init_resolve_agent_definition_paths();
|
|
48995
49076
|
init_opencode_version();
|
|
48996
49077
|
init_opencode_storage_detection();
|
|
48997
49078
|
init_external_plugin_detector();
|
|
@@ -49110,17 +49191,17 @@ var init_plugin_name_with_version = __esm(() => {
|
|
|
49110
49191
|
});
|
|
49111
49192
|
|
|
49112
49193
|
// src/cli/config-manager/backup-config.ts
|
|
49113
|
-
import { copyFileSync as copyFileSync2, existsSync as
|
|
49114
|
-
import { dirname as
|
|
49194
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync11, mkdirSync as mkdirSync5 } from "fs";
|
|
49195
|
+
import { dirname as dirname3 } from "path";
|
|
49115
49196
|
function backupConfigFile(configPath) {
|
|
49116
|
-
if (!
|
|
49197
|
+
if (!existsSync11(configPath)) {
|
|
49117
49198
|
return { success: true };
|
|
49118
49199
|
}
|
|
49119
49200
|
const timestamp2 = new Date().toISOString().replace(/[:.]/g, "-");
|
|
49120
49201
|
const backupPath = `${configPath}.backup-${timestamp2}`;
|
|
49121
49202
|
try {
|
|
49122
|
-
const dir =
|
|
49123
|
-
if (!
|
|
49203
|
+
const dir = dirname3(backupPath);
|
|
49204
|
+
if (!existsSync11(dir)) {
|
|
49124
49205
|
mkdirSync5(dir, { recursive: true });
|
|
49125
49206
|
}
|
|
49126
49207
|
copyFileSync2(configPath, backupPath);
|
|
@@ -49135,10 +49216,10 @@ function backupConfigFile(configPath) {
|
|
|
49135
49216
|
var init_backup_config = () => {};
|
|
49136
49217
|
|
|
49137
49218
|
// src/cli/config-manager/ensure-config-directory-exists.ts
|
|
49138
|
-
import { existsSync as
|
|
49219
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync6 } from "fs";
|
|
49139
49220
|
function ensureConfigDirectoryExists() {
|
|
49140
49221
|
const configDir = getConfigDir();
|
|
49141
|
-
if (!
|
|
49222
|
+
if (!existsSync12(configDir)) {
|
|
49142
49223
|
mkdirSync6(configDir, { recursive: true });
|
|
49143
49224
|
}
|
|
49144
49225
|
}
|
|
@@ -49176,14 +49257,14 @@ function formatErrorWithSuggestion(err, context) {
|
|
|
49176
49257
|
}
|
|
49177
49258
|
|
|
49178
49259
|
// src/cli/config-manager/opencode-config-format.ts
|
|
49179
|
-
import { existsSync as
|
|
49260
|
+
import { existsSync as existsSync13 } from "fs";
|
|
49180
49261
|
function detectConfigFormat() {
|
|
49181
49262
|
const configJsonc = getConfigJsonc();
|
|
49182
49263
|
const configJson = getConfigJson();
|
|
49183
|
-
if (
|
|
49264
|
+
if (existsSync13(configJsonc)) {
|
|
49184
49265
|
return { format: "jsonc", path: configJsonc };
|
|
49185
49266
|
}
|
|
49186
|
-
if (
|
|
49267
|
+
if (existsSync13(configJson)) {
|
|
49187
49268
|
return { format: "json", path: configJson };
|
|
49188
49269
|
}
|
|
49189
49270
|
return { format: "none", path: configJson };
|
|
@@ -49193,7 +49274,7 @@ var init_opencode_config_format = __esm(() => {
|
|
|
49193
49274
|
});
|
|
49194
49275
|
|
|
49195
49276
|
// src/cli/config-manager/parse-opencode-config-file.ts
|
|
49196
|
-
import { readFileSync as
|
|
49277
|
+
import { readFileSync as readFileSync7, statSync } from "fs";
|
|
49197
49278
|
function isEmptyOrWhitespace(content) {
|
|
49198
49279
|
return content.trim().length === 0;
|
|
49199
49280
|
}
|
|
@@ -49203,7 +49284,7 @@ function parseOpenCodeConfigFileWithError(path5) {
|
|
|
49203
49284
|
if (stat.size === 0) {
|
|
49204
49285
|
return { config: null, error: `Config file is empty: ${path5}. Delete it or add valid JSON content.` };
|
|
49205
49286
|
}
|
|
49206
|
-
const content =
|
|
49287
|
+
const content = readFileSync7(path5, "utf-8");
|
|
49207
49288
|
if (isEmptyOrWhitespace(content)) {
|
|
49208
49289
|
return { config: null, error: `Config file contains only whitespace: ${path5}. Delete it or add valid JSON content.` };
|
|
49209
49290
|
}
|
|
@@ -49309,7 +49390,7 @@ function extractVersionFromPluginEntry(entry) {
|
|
|
49309
49390
|
}
|
|
49310
49391
|
|
|
49311
49392
|
// src/cli/config-manager/add-plugin-to-opencode-config.ts
|
|
49312
|
-
import { readFileSync as
|
|
49393
|
+
import { readFileSync as readFileSync8, writeFileSync as writeFileSync3 } from "fs";
|
|
49313
49394
|
async function addPluginToOpenCodeConfig(currentVersion) {
|
|
49314
49395
|
try {
|
|
49315
49396
|
ensureConfigDirectoryExists();
|
|
@@ -49366,7 +49447,7 @@ async function addPluginToOpenCodeConfig(currentVersion) {
|
|
|
49366
49447
|
normalizedPlugins.push(pluginEntry);
|
|
49367
49448
|
config.plugin = normalizedPlugins;
|
|
49368
49449
|
if (format2 === "jsonc") {
|
|
49369
|
-
const content =
|
|
49450
|
+
const content = readFileSync8(path5, "utf-8");
|
|
49370
49451
|
const pluginArrayRegex = /((?:"plugin"|plugin)\s*:\s*)\[([\s\S]*?)\]/;
|
|
49371
49452
|
const match = content.match(pluginArrayRegex);
|
|
49372
49453
|
if (match) {
|
|
@@ -49722,12 +49803,12 @@ var init_generate_omo_config = __esm(() => {
|
|
|
49722
49803
|
});
|
|
49723
49804
|
|
|
49724
49805
|
// src/shared/migrate-legacy-config-file.ts
|
|
49725
|
-
import { existsSync as
|
|
49726
|
-
import { join as
|
|
49806
|
+
import { existsSync as existsSync14, readFileSync as readFileSync9, renameSync as renameSync2, rmSync } from "fs";
|
|
49807
|
+
import { join as join13, dirname as dirname4, basename as basename2 } from "path";
|
|
49727
49808
|
function buildCanonicalPath(legacyPath) {
|
|
49728
|
-
const dir =
|
|
49729
|
-
const ext =
|
|
49730
|
-
return
|
|
49809
|
+
const dir = dirname4(legacyPath);
|
|
49810
|
+
const ext = basename2(legacyPath).includes(".jsonc") ? ".jsonc" : ".json";
|
|
49811
|
+
return join13(dir, `${CONFIG_BASENAME}${ext}`);
|
|
49731
49812
|
}
|
|
49732
49813
|
function archiveLegacyConfigFile(legacyPath) {
|
|
49733
49814
|
const backupPath = `${legacyPath}.bak`;
|
|
@@ -49759,15 +49840,15 @@ function archiveLegacyConfigFile(legacyPath) {
|
|
|
49759
49840
|
}
|
|
49760
49841
|
}
|
|
49761
49842
|
function migrateLegacyConfigFile(legacyPath) {
|
|
49762
|
-
if (!
|
|
49843
|
+
if (!existsSync14(legacyPath))
|
|
49763
49844
|
return false;
|
|
49764
|
-
if (!
|
|
49845
|
+
if (!basename2(legacyPath).startsWith(LEGACY_CONFIG_BASENAME))
|
|
49765
49846
|
return false;
|
|
49766
49847
|
const canonicalPath = buildCanonicalPath(legacyPath);
|
|
49767
|
-
if (
|
|
49848
|
+
if (existsSync14(canonicalPath))
|
|
49768
49849
|
return false;
|
|
49769
49850
|
try {
|
|
49770
|
-
const content =
|
|
49851
|
+
const content = readFileSync9(legacyPath, "utf-8");
|
|
49771
49852
|
writeFileAtomically(canonicalPath, content);
|
|
49772
49853
|
const archivedLegacyConfig = archiveLegacyConfigFile(legacyPath);
|
|
49773
49854
|
log("[migrateLegacyConfigFile] Migrated legacy config to canonical path", {
|
|
@@ -49805,8 +49886,8 @@ function deepMergeRecord(target, source) {
|
|
|
49805
49886
|
}
|
|
49806
49887
|
|
|
49807
49888
|
// src/cli/config-manager/write-omo-config.ts
|
|
49808
|
-
import { existsSync as
|
|
49809
|
-
import { basename as
|
|
49889
|
+
import { existsSync as existsSync15, readFileSync as readFileSync10, statSync as statSync2, writeFileSync as writeFileSync4 } from "fs";
|
|
49890
|
+
import { basename as basename3, dirname as dirname5, extname, join as join14 } from "path";
|
|
49810
49891
|
function isEmptyOrWhitespace2(content) {
|
|
49811
49892
|
return content.trim().length === 0;
|
|
49812
49893
|
}
|
|
@@ -49821,12 +49902,12 @@ function writeOmoConfig(installConfig) {
|
|
|
49821
49902
|
};
|
|
49822
49903
|
}
|
|
49823
49904
|
const detectedConfigPath = getOmoConfigPath();
|
|
49824
|
-
const canonicalConfigPath =
|
|
49825
|
-
const shouldMigrateLegacyPath =
|
|
49826
|
-
const omoConfigPath = shouldMigrateLegacyPath ? migrateLegacyConfigFile(detectedConfigPath) ||
|
|
49905
|
+
const canonicalConfigPath = join14(dirname5(detectedConfigPath), `${CONFIG_BASENAME}${extname(detectedConfigPath) || ".json"}`);
|
|
49906
|
+
const shouldMigrateLegacyPath = basename3(detectedConfigPath).startsWith(LEGACY_CONFIG_BASENAME);
|
|
49907
|
+
const omoConfigPath = shouldMigrateLegacyPath ? migrateLegacyConfigFile(detectedConfigPath) || existsSync15(canonicalConfigPath) ? canonicalConfigPath : detectedConfigPath : detectedConfigPath;
|
|
49827
49908
|
try {
|
|
49828
49909
|
const newConfig = generateOmoConfig(installConfig);
|
|
49829
|
-
if (
|
|
49910
|
+
if (existsSync15(omoConfigPath)) {
|
|
49830
49911
|
const backupResult = backupConfigFile(omoConfigPath);
|
|
49831
49912
|
if (!backupResult.success) {
|
|
49832
49913
|
return {
|
|
@@ -49837,7 +49918,7 @@ function writeOmoConfig(installConfig) {
|
|
|
49837
49918
|
}
|
|
49838
49919
|
try {
|
|
49839
49920
|
const stat = statSync2(omoConfigPath);
|
|
49840
|
-
const content =
|
|
49921
|
+
const content = readFileSync10(omoConfigPath, "utf-8");
|
|
49841
49922
|
if (stat.size === 0 || isEmptyOrWhitespace2(content)) {
|
|
49842
49923
|
writeFileSync4(omoConfigPath, JSON.stringify(newConfig, null, 2) + `
|
|
49843
49924
|
`);
|
|
@@ -49896,8 +49977,8 @@ function toReadableStream(stream) {
|
|
|
49896
49977
|
function wrapNodeProcess(proc) {
|
|
49897
49978
|
let resolveExited;
|
|
49898
49979
|
let exitCode = null;
|
|
49899
|
-
const exited = new Promise((
|
|
49900
|
-
resolveExited =
|
|
49980
|
+
const exited = new Promise((resolve4) => {
|
|
49981
|
+
resolveExited = resolve4;
|
|
49901
49982
|
});
|
|
49902
49983
|
proc.on("exit", (code) => {
|
|
49903
49984
|
exitCode = code ?? 1;
|
|
@@ -49980,10 +50061,10 @@ var init_opencode_binary = __esm(() => {
|
|
|
49980
50061
|
});
|
|
49981
50062
|
|
|
49982
50063
|
// src/cli/config-manager/detect-current-config.ts
|
|
49983
|
-
import { existsSync as
|
|
50064
|
+
import { existsSync as existsSync16, readFileSync as readFileSync11 } from "fs";
|
|
49984
50065
|
function detectProvidersFromOmoConfig() {
|
|
49985
50066
|
const omoConfigPath = getOmoConfigPath();
|
|
49986
|
-
if (!
|
|
50067
|
+
if (!existsSync16(omoConfigPath)) {
|
|
49987
50068
|
return {
|
|
49988
50069
|
hasOpenAI: true,
|
|
49989
50070
|
hasOpencodeZen: true,
|
|
@@ -49994,7 +50075,7 @@ function detectProvidersFromOmoConfig() {
|
|
|
49994
50075
|
};
|
|
49995
50076
|
}
|
|
49996
50077
|
try {
|
|
49997
|
-
const content =
|
|
50078
|
+
const content = readFileSync11(omoConfigPath, "utf-8");
|
|
49998
50079
|
const omoConfig = parseJsonc(content);
|
|
49999
50080
|
if (!omoConfig || typeof omoConfig !== "object") {
|
|
50000
50081
|
return {
|
|
@@ -50083,10 +50164,10 @@ var init_detect_current_config = __esm(() => {
|
|
|
50083
50164
|
});
|
|
50084
50165
|
|
|
50085
50166
|
// src/cli/config-manager/bun-install.ts
|
|
50086
|
-
import { existsSync as
|
|
50087
|
-
import { join as
|
|
50167
|
+
import { existsSync as existsSync17 } from "fs";
|
|
50168
|
+
import { join as join15 } from "path";
|
|
50088
50169
|
function getDefaultWorkspaceDir() {
|
|
50089
|
-
return
|
|
50170
|
+
return join15(getOpenCodeCacheDir(), "packages");
|
|
50090
50171
|
}
|
|
50091
50172
|
function readProcessOutput(stream) {
|
|
50092
50173
|
if (!stream) {
|
|
@@ -50112,7 +50193,7 @@ async function runBunInstallWithDetails(options) {
|
|
|
50112
50193
|
const outputMode = options?.outputMode ?? "pipe";
|
|
50113
50194
|
const cacheDir = options?.workspaceDir ?? getDefaultWorkspaceDir();
|
|
50114
50195
|
const packageJsonPath = `${cacheDir}/package.json`;
|
|
50115
|
-
if (!
|
|
50196
|
+
if (!existsSync17(packageJsonPath)) {
|
|
50116
50197
|
return {
|
|
50117
50198
|
success: false,
|
|
50118
50199
|
error: `Workspace not initialized: ${packageJsonPath} not found. OpenCode should create this on first run.`
|
|
@@ -50126,8 +50207,8 @@ async function runBunInstallWithDetails(options) {
|
|
|
50126
50207
|
});
|
|
50127
50208
|
const outputPromise = Promise.all([readProcessOutput(proc.stdout), readProcessOutput(proc.stderr)]).then(([stdout, stderr]) => ({ stdout, stderr }));
|
|
50128
50209
|
let timeoutId;
|
|
50129
|
-
const timeoutPromise = new Promise((
|
|
50130
|
-
timeoutId = setTimeout(() =>
|
|
50210
|
+
const timeoutPromise = new Promise((resolve4) => {
|
|
50211
|
+
timeoutId = setTimeout(() => resolve4("timeout"), BUN_INSTALL_TIMEOUT_MS);
|
|
50131
50212
|
});
|
|
50132
50213
|
const exitPromise = proc.exited.then(() => "completed");
|
|
50133
50214
|
const result = await Promise.race([exitPromise, timeoutPromise]);
|
|
@@ -50338,12 +50419,12 @@ var require_isexe = __commonJS((exports2, module) => {
|
|
|
50338
50419
|
if (typeof Promise !== "function") {
|
|
50339
50420
|
throw new TypeError("callback not provided");
|
|
50340
50421
|
}
|
|
50341
|
-
return new Promise(function(
|
|
50422
|
+
return new Promise(function(resolve4, reject) {
|
|
50342
50423
|
isexe(path6, options || {}, function(er, is) {
|
|
50343
50424
|
if (er) {
|
|
50344
50425
|
reject(er);
|
|
50345
50426
|
} else {
|
|
50346
|
-
|
|
50427
|
+
resolve4(is);
|
|
50347
50428
|
}
|
|
50348
50429
|
});
|
|
50349
50430
|
});
|
|
@@ -50405,27 +50486,27 @@ var require_which = __commonJS((exports2, module) => {
|
|
|
50405
50486
|
opt = {};
|
|
50406
50487
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
50407
50488
|
const found = [];
|
|
50408
|
-
const step = (i2) => new Promise((
|
|
50489
|
+
const step = (i2) => new Promise((resolve4, reject) => {
|
|
50409
50490
|
if (i2 === pathEnv.length)
|
|
50410
|
-
return opt.all && found.length ?
|
|
50491
|
+
return opt.all && found.length ? resolve4(found) : reject(getNotFoundError(cmd));
|
|
50411
50492
|
const ppRaw = pathEnv[i2];
|
|
50412
50493
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
50413
50494
|
const pCmd = path6.join(pathPart, cmd);
|
|
50414
50495
|
const p2 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
50415
|
-
|
|
50496
|
+
resolve4(subStep(p2, i2, 0));
|
|
50416
50497
|
});
|
|
50417
|
-
const subStep = (p2, i2, ii) => new Promise((
|
|
50498
|
+
const subStep = (p2, i2, ii) => new Promise((resolve4, reject) => {
|
|
50418
50499
|
if (ii === pathExt.length)
|
|
50419
|
-
return
|
|
50500
|
+
return resolve4(step(i2 + 1));
|
|
50420
50501
|
const ext = pathExt[ii];
|
|
50421
50502
|
isexe(p2 + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
50422
50503
|
if (!er && is) {
|
|
50423
50504
|
if (opt.all)
|
|
50424
50505
|
found.push(p2 + ext);
|
|
50425
50506
|
else
|
|
50426
|
-
return
|
|
50507
|
+
return resolve4(p2 + ext);
|
|
50427
50508
|
}
|
|
50428
|
-
return
|
|
50509
|
+
return resolve4(subStep(p2, i2, ii + 1));
|
|
50429
50510
|
});
|
|
50430
50511
|
});
|
|
50431
50512
|
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
@@ -51278,8 +51359,8 @@ var init_update_toasts = __esm(() => {
|
|
|
51278
51359
|
});
|
|
51279
51360
|
|
|
51280
51361
|
// src/hooks/auto-update-checker/hook/background-update-check.ts
|
|
51281
|
-
import { existsSync as
|
|
51282
|
-
import { join as
|
|
51362
|
+
import { existsSync as existsSync29 } from "fs";
|
|
51363
|
+
import { join as join28 } from "path";
|
|
51283
51364
|
function getCacheWorkspaceDir(deps) {
|
|
51284
51365
|
return deps.join(deps.getOpenCodeCacheDir(), "packages");
|
|
51285
51366
|
}
|
|
@@ -51397,8 +51478,8 @@ var init_background_update_check = __esm(() => {
|
|
|
51397
51478
|
init_checker();
|
|
51398
51479
|
init_update_toasts();
|
|
51399
51480
|
defaultDeps = {
|
|
51400
|
-
existsSync:
|
|
51401
|
-
join:
|
|
51481
|
+
existsSync: existsSync29,
|
|
51482
|
+
join: join28,
|
|
51402
51483
|
runBunInstallWithDetails,
|
|
51403
51484
|
log,
|
|
51404
51485
|
getOpenCodeCacheDir,
|
|
@@ -51551,7 +51632,7 @@ async function showSpinnerToast(ctx, version3, message) {
|
|
|
51551
51632
|
duration: frameInterval + 50
|
|
51552
51633
|
}
|
|
51553
51634
|
}).catch(() => {});
|
|
51554
|
-
await new Promise((
|
|
51635
|
+
await new Promise((resolve4) => setTimeout(resolve4, frameInterval));
|
|
51555
51636
|
}
|
|
51556
51637
|
}
|
|
51557
51638
|
var SISYPHUS_SPINNER;
|
|
@@ -51691,7 +51772,7 @@ var {
|
|
|
51691
51772
|
// package.json
|
|
51692
51773
|
var package_default = {
|
|
51693
51774
|
name: "oh-my-opencode",
|
|
51694
|
-
version: "3.17.
|
|
51775
|
+
version: "3.17.3",
|
|
51695
51776
|
description: "The Best AI Agent Harness - Batteries-Included OpenCode Plugin with Multi-Model Orchestration, Parallel Background Agents, and Crafted LSP/AST Tools",
|
|
51696
51777
|
main: "./dist/index.js",
|
|
51697
51778
|
types: "dist/index.d.ts",
|
|
@@ -51770,17 +51851,17 @@ var package_default = {
|
|
|
51770
51851
|
typescript: "^5.7.3"
|
|
51771
51852
|
},
|
|
51772
51853
|
optionalDependencies: {
|
|
51773
|
-
"oh-my-opencode-darwin-arm64": "3.17.
|
|
51774
|
-
"oh-my-opencode-darwin-x64": "3.17.
|
|
51775
|
-
"oh-my-opencode-darwin-x64-baseline": "3.17.
|
|
51776
|
-
"oh-my-opencode-linux-arm64": "3.17.
|
|
51777
|
-
"oh-my-opencode-linux-arm64-musl": "3.17.
|
|
51778
|
-
"oh-my-opencode-linux-x64": "3.17.
|
|
51779
|
-
"oh-my-opencode-linux-x64-baseline": "3.17.
|
|
51780
|
-
"oh-my-opencode-linux-x64-musl": "3.17.
|
|
51781
|
-
"oh-my-opencode-linux-x64-musl-baseline": "3.17.
|
|
51782
|
-
"oh-my-opencode-windows-x64": "3.17.
|
|
51783
|
-
"oh-my-opencode-windows-x64-baseline": "3.17.
|
|
51854
|
+
"oh-my-opencode-darwin-arm64": "3.17.3",
|
|
51855
|
+
"oh-my-opencode-darwin-x64": "3.17.3",
|
|
51856
|
+
"oh-my-opencode-darwin-x64-baseline": "3.17.3",
|
|
51857
|
+
"oh-my-opencode-linux-arm64": "3.17.3",
|
|
51858
|
+
"oh-my-opencode-linux-arm64-musl": "3.17.3",
|
|
51859
|
+
"oh-my-opencode-linux-x64": "3.17.3",
|
|
51860
|
+
"oh-my-opencode-linux-x64-baseline": "3.17.3",
|
|
51861
|
+
"oh-my-opencode-linux-x64-musl": "3.17.3",
|
|
51862
|
+
"oh-my-opencode-linux-x64-musl-baseline": "3.17.3",
|
|
51863
|
+
"oh-my-opencode-windows-x64": "3.17.3",
|
|
51864
|
+
"oh-my-opencode-windows-x64-baseline": "3.17.3"
|
|
51784
51865
|
},
|
|
51785
51866
|
overrides: {},
|
|
51786
51867
|
trustedDependencies: [
|
|
@@ -52001,7 +52082,7 @@ import os3 from "os";
|
|
|
52001
52082
|
import { createHash } from "crypto";
|
|
52002
52083
|
|
|
52003
52084
|
// node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
|
|
52004
|
-
import { dirname as
|
|
52085
|
+
import { dirname as dirname6, posix, sep } from "path";
|
|
52005
52086
|
function createModulerModifier() {
|
|
52006
52087
|
const getModuleFromFileName = createGetModuleFromFilename();
|
|
52007
52088
|
return async (frames) => {
|
|
@@ -52010,7 +52091,7 @@ function createModulerModifier() {
|
|
|
52010
52091
|
return frames;
|
|
52011
52092
|
};
|
|
52012
52093
|
}
|
|
52013
|
-
function createGetModuleFromFilename(basePath = process.argv[1] ?
|
|
52094
|
+
function createGetModuleFromFilename(basePath = process.argv[1] ? dirname6(process.argv[1]) : process.cwd(), isWindows = sep === "\\") {
|
|
52014
52095
|
const normalizedBase = isWindows ? normalizeWindowsPath(basePath) : basePath;
|
|
52015
52096
|
return (filename) => {
|
|
52016
52097
|
if (!filename)
|
|
@@ -54349,14 +54430,14 @@ async function addSourceContext(frames) {
|
|
|
54349
54430
|
return frames;
|
|
54350
54431
|
}
|
|
54351
54432
|
function getContextLinesFromFile(path5, ranges, output) {
|
|
54352
|
-
return new Promise((
|
|
54433
|
+
return new Promise((resolve4) => {
|
|
54353
54434
|
const stream = createReadStream(path5);
|
|
54354
54435
|
const lineReaded = createInterface({
|
|
54355
54436
|
input: stream
|
|
54356
54437
|
});
|
|
54357
54438
|
function destroyStreamAndResolve() {
|
|
54358
54439
|
stream.destroy();
|
|
54359
|
-
|
|
54440
|
+
resolve4();
|
|
54360
54441
|
}
|
|
54361
54442
|
let lineNumber = 0;
|
|
54362
54443
|
let currentRangeIndex = 0;
|
|
@@ -55596,9 +55677,9 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
55596
55677
|
if (this.disabled || this.optedOut)
|
|
55597
55678
|
return;
|
|
55598
55679
|
if (!this._waitUntilCycle) {
|
|
55599
|
-
let
|
|
55680
|
+
let resolve4;
|
|
55600
55681
|
const promise = new Promise((r) => {
|
|
55601
|
-
|
|
55682
|
+
resolve4 = r;
|
|
55602
55683
|
});
|
|
55603
55684
|
try {
|
|
55604
55685
|
waitUntil(promise);
|
|
@@ -55606,7 +55687,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
55606
55687
|
return;
|
|
55607
55688
|
}
|
|
55608
55689
|
this._waitUntilCycle = {
|
|
55609
|
-
resolve:
|
|
55690
|
+
resolve: resolve4,
|
|
55610
55691
|
startedAt: Date.now(),
|
|
55611
55692
|
timer: undefined
|
|
55612
55693
|
};
|
|
@@ -55632,11 +55713,11 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
55632
55713
|
return cycle?.resolve;
|
|
55633
55714
|
}
|
|
55634
55715
|
async resolveWaitUntilFlush() {
|
|
55635
|
-
const
|
|
55716
|
+
const resolve4 = this._consumeWaitUntilCycle();
|
|
55636
55717
|
try {
|
|
55637
55718
|
await super.flush();
|
|
55638
55719
|
} catch {} finally {
|
|
55639
|
-
|
|
55720
|
+
resolve4?.();
|
|
55640
55721
|
}
|
|
55641
55722
|
}
|
|
55642
55723
|
getPersistedProperty(key) {
|
|
@@ -55736,15 +55817,15 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
55736
55817
|
return true;
|
|
55737
55818
|
if (this.featureFlagsPoller === undefined)
|
|
55738
55819
|
return false;
|
|
55739
|
-
return new Promise((
|
|
55820
|
+
return new Promise((resolve4) => {
|
|
55740
55821
|
const timeout = setTimeout(() => {
|
|
55741
55822
|
cleanup();
|
|
55742
|
-
|
|
55823
|
+
resolve4(false);
|
|
55743
55824
|
}, timeoutMs);
|
|
55744
55825
|
const cleanup = this._events.on("localEvaluationFlagsLoaded", (count) => {
|
|
55745
55826
|
clearTimeout(timeout);
|
|
55746
55827
|
cleanup();
|
|
55747
|
-
|
|
55828
|
+
resolve4(count > 0);
|
|
55748
55829
|
});
|
|
55749
55830
|
});
|
|
55750
55831
|
}
|
|
@@ -56088,13 +56169,13 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
56088
56169
|
this.context?.enter(data, options);
|
|
56089
56170
|
}
|
|
56090
56171
|
async _shutdown(shutdownTimeoutMs) {
|
|
56091
|
-
const
|
|
56172
|
+
const resolve4 = this._consumeWaitUntilCycle();
|
|
56092
56173
|
await this.featureFlagsPoller?.stopPoller(shutdownTimeoutMs);
|
|
56093
56174
|
this.errorTracking.shutdown();
|
|
56094
56175
|
try {
|
|
56095
56176
|
return await super._shutdown(shutdownTimeoutMs);
|
|
56096
56177
|
} finally {
|
|
56097
|
-
|
|
56178
|
+
resolve4?.();
|
|
56098
56179
|
}
|
|
56099
56180
|
}
|
|
56100
56181
|
async _requestRemoteConfigPayload(flagKey) {
|
|
@@ -56448,11 +56529,11 @@ init_data_path();
|
|
|
56448
56529
|
init_logger();
|
|
56449
56530
|
init_plugin_identity();
|
|
56450
56531
|
init_write_file_atomically();
|
|
56451
|
-
import { existsSync as
|
|
56452
|
-
import { join as
|
|
56532
|
+
import { existsSync as existsSync18, mkdirSync as mkdirSync7, readFileSync as readFileSync12 } from "fs";
|
|
56533
|
+
import { join as join16 } from "path";
|
|
56453
56534
|
var POSTHOG_ACTIVITY_STATE_FILE = "posthog-activity.json";
|
|
56454
56535
|
function getPostHogActivityStateFilePath() {
|
|
56455
|
-
return
|
|
56536
|
+
return join16(getDataDir(), CACHE_DIR_NAME, POSTHOG_ACTIVITY_STATE_FILE);
|
|
56456
56537
|
}
|
|
56457
56538
|
function getUtcDayString(date) {
|
|
56458
56539
|
return date.toISOString().slice(0, 10);
|
|
@@ -56465,11 +56546,11 @@ function isPostHogActivityState(value) {
|
|
|
56465
56546
|
}
|
|
56466
56547
|
function readPostHogActivityState() {
|
|
56467
56548
|
const stateFilePath = getPostHogActivityStateFilePath();
|
|
56468
|
-
if (!
|
|
56549
|
+
if (!existsSync18(stateFilePath)) {
|
|
56469
56550
|
return {};
|
|
56470
56551
|
}
|
|
56471
56552
|
try {
|
|
56472
|
-
const content =
|
|
56553
|
+
const content = readFileSync12(stateFilePath, "utf-8");
|
|
56473
56554
|
const parsed = JSON.parse(content);
|
|
56474
56555
|
if (!isPostHogActivityState(parsed)) {
|
|
56475
56556
|
return {};
|
|
@@ -56486,7 +56567,7 @@ function readPostHogActivityState() {
|
|
|
56486
56567
|
function writePostHogActivityState(nextState) {
|
|
56487
56568
|
const stateFilePath = getPostHogActivityStateFilePath();
|
|
56488
56569
|
try {
|
|
56489
|
-
mkdirSync7(
|
|
56570
|
+
mkdirSync7(join16(getDataDir(), CACHE_DIR_NAME), { recursive: true });
|
|
56490
56571
|
writeFileAtomically(stateFilePath, `${JSON.stringify(nextState, null, 2)}
|
|
56491
56572
|
`);
|
|
56492
56573
|
} catch (error) {
|
|
@@ -56638,7 +56719,7 @@ function getPostHogDistinctId() {
|
|
|
56638
56719
|
}
|
|
56639
56720
|
function createCliPostHog() {
|
|
56640
56721
|
return createPostHogClient("cli", {
|
|
56641
|
-
enableExceptionAutocapture:
|
|
56722
|
+
enableExceptionAutocapture: false,
|
|
56642
56723
|
flushAt: 1,
|
|
56643
56724
|
flushInterval: 0
|
|
56644
56725
|
});
|
|
@@ -72148,6 +72229,10 @@ var NotificationConfigSchema = exports_external.object({
|
|
|
72148
72229
|
var McpNameSchema = exports_external.enum(["websearch", "context7", "grep_app"]);
|
|
72149
72230
|
var AnyMcpNameSchema = exports_external.string().min(1);
|
|
72150
72231
|
|
|
72232
|
+
// src/config/schema/agent-definitions.ts
|
|
72233
|
+
var AgentDefinitionPathSchema = exports_external.string().min(1);
|
|
72234
|
+
var AgentDefinitionsConfigSchema = exports_external.array(AgentDefinitionPathSchema).optional();
|
|
72235
|
+
|
|
72151
72236
|
// src/config/schema/openclaw.ts
|
|
72152
72237
|
var OpenClawGatewaySchema = exports_external.object({
|
|
72153
72238
|
type: exports_external.enum(["http", "command"]).default("http"),
|
|
@@ -72289,6 +72374,7 @@ var OhMyOpenCodeConfigSchema = exports_external.object({
|
|
|
72289
72374
|
$schema: exports_external.string().optional(),
|
|
72290
72375
|
new_task_system_enabled: exports_external.boolean().optional(),
|
|
72291
72376
|
default_run_agent: exports_external.string().optional(),
|
|
72377
|
+
agent_definitions: AgentDefinitionsConfigSchema,
|
|
72292
72378
|
disabled_mcps: exports_external.array(AnyMcpNameSchema).optional(),
|
|
72293
72379
|
disabled_agents: exports_external.array(exports_external.string()).optional(),
|
|
72294
72380
|
disabled_skills: exports_external.array(BuiltinSkillNameSchema).optional(),
|
|
@@ -72352,7 +72438,8 @@ var PARTIAL_STRING_ARRAY_KEYS = new Set([
|
|
|
72352
72438
|
"disabled_hooks",
|
|
72353
72439
|
"disabled_commands",
|
|
72354
72440
|
"disabled_tools",
|
|
72355
|
-
"mcp_env_allowlist"
|
|
72441
|
+
"mcp_env_allowlist",
|
|
72442
|
+
"agent_definitions"
|
|
72356
72443
|
]);
|
|
72357
72444
|
function parseConfigPartially(rawConfig) {
|
|
72358
72445
|
const fullResult = OhMyOpenCodeConfigSchema.safeParse(rawConfig);
|
|
@@ -72424,6 +72511,12 @@ function mergeConfigs(base, override) {
|
|
|
72424
72511
|
...override,
|
|
72425
72512
|
agents: deepMerge(base.agents, override.agents),
|
|
72426
72513
|
categories: deepMerge(base.categories, override.categories),
|
|
72514
|
+
agent_definitions: [
|
|
72515
|
+
...new Set([
|
|
72516
|
+
...base.agent_definitions ?? [],
|
|
72517
|
+
...override.agent_definitions ?? []
|
|
72518
|
+
])
|
|
72519
|
+
],
|
|
72427
72520
|
disabled_agents: [
|
|
72428
72521
|
...new Set([
|
|
72429
72522
|
...base.disabled_agents ?? [],
|
|
@@ -72504,10 +72597,16 @@ function loadPluginConfig(directory, ctx) {
|
|
|
72504
72597
|
}
|
|
72505
72598
|
const userConfig = loadConfigFromPath(userConfigPath, ctx);
|
|
72506
72599
|
const userGitMasterOverrides = loadExplicitGitMasterOverrides(userConfigPath);
|
|
72600
|
+
if (userConfig?.agent_definitions) {
|
|
72601
|
+
userConfig.agent_definitions = resolveAgentDefinitionPaths(userConfig.agent_definitions, configDir, null);
|
|
72602
|
+
}
|
|
72507
72603
|
let config2 = userConfig ?? OhMyOpenCodeConfigSchema.parse({});
|
|
72508
72604
|
const defaultGitMaster = OhMyOpenCodeConfigSchema.parse({}).git_master;
|
|
72509
72605
|
const projectConfig = loadConfigFromPath(projectConfigPath, ctx);
|
|
72510
72606
|
const projectGitMasterOverrides = loadExplicitGitMasterOverrides(projectConfigPath);
|
|
72607
|
+
if (projectConfig?.agent_definitions) {
|
|
72608
|
+
projectConfig.agent_definitions = resolveAgentDefinitionPaths(projectConfig.agent_definitions, projectBasePath, directory);
|
|
72609
|
+
}
|
|
72511
72610
|
if (projectConfig) {
|
|
72512
72611
|
config2 = mergeConfigs(config2, projectConfig);
|
|
72513
72612
|
}
|
|
@@ -72537,7 +72636,7 @@ function loadPluginConfig(directory, ctx) {
|
|
|
72537
72636
|
// node_modules/@opencode-ai/sdk/dist/gen/core/serverSentEvents.gen.js
|
|
72538
72637
|
var createSseClient = ({ onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url: url2, ...options }) => {
|
|
72539
72638
|
let lastEventId;
|
|
72540
|
-
const sleep = sseSleepFn ?? ((ms) => new Promise((
|
|
72639
|
+
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve4) => setTimeout(resolve4, ms)));
|
|
72541
72640
|
const createStream = async function* () {
|
|
72542
72641
|
let retryDelay = sseDefaultRetryDelay ?? 3000;
|
|
72543
72642
|
let attempt = 0;
|
|
@@ -73972,7 +74071,7 @@ async function createOpencodeServer(options) {
|
|
|
73972
74071
|
}
|
|
73973
74072
|
});
|
|
73974
74073
|
let clear = () => {};
|
|
73975
|
-
const url2 = await new Promise((
|
|
74074
|
+
const url2 = await new Promise((resolve4, reject) => {
|
|
73976
74075
|
const id = setTimeout(() => {
|
|
73977
74076
|
clear();
|
|
73978
74077
|
stop(proc);
|
|
@@ -73998,7 +74097,7 @@ async function createOpencodeServer(options) {
|
|
|
73998
74097
|
}
|
|
73999
74098
|
clearTimeout(id);
|
|
74000
74099
|
resolved = true;
|
|
74001
|
-
|
|
74100
|
+
resolve4(match[1]);
|
|
74002
74101
|
return;
|
|
74003
74102
|
}
|
|
74004
74103
|
}
|
|
@@ -74052,7 +74151,7 @@ var import_picocolors10 = __toESM(require_picocolors(), 1);
|
|
|
74052
74151
|
|
|
74053
74152
|
// src/cli/run/opencode-binary-resolver.ts
|
|
74054
74153
|
init_spawn_with_windows_hide();
|
|
74055
|
-
import { delimiter, dirname as
|
|
74154
|
+
import { delimiter, dirname as dirname8, join as join18 } from "path";
|
|
74056
74155
|
var OPENCODE_COMMANDS = ["opencode", "opencode-desktop"];
|
|
74057
74156
|
var WINDOWS_SUFFIXES = ["", ".exe", ".cmd", ".bat", ".ps1"];
|
|
74058
74157
|
function getCommandCandidates(platform) {
|
|
@@ -74075,7 +74174,7 @@ function collectCandidateBinaryPaths(pathEnv, which = Bun.which, platform = proc
|
|
|
74075
74174
|
}
|
|
74076
74175
|
for (const entry of (pathEnv ?? "").split(delimiter).filter(Boolean)) {
|
|
74077
74176
|
for (const command of commandCandidates) {
|
|
74078
|
-
addCandidate(
|
|
74177
|
+
addCandidate(join18(entry, command));
|
|
74079
74178
|
}
|
|
74080
74179
|
}
|
|
74081
74180
|
return candidates;
|
|
@@ -74102,7 +74201,7 @@ async function findWorkingOpencodeBinary(pathEnv = process.env.PATH, probe = can
|
|
|
74102
74201
|
return null;
|
|
74103
74202
|
}
|
|
74104
74203
|
function buildPathWithBinaryFirst(pathEnv, binaryPath) {
|
|
74105
|
-
const preferredDir =
|
|
74204
|
+
const preferredDir = dirname8(binaryPath);
|
|
74106
74205
|
const existing = (pathEnv ?? "").split(delimiter).filter((entry) => entry.length > 0 && entry !== preferredDir);
|
|
74107
74206
|
return [preferredDir, ...existing].join(delimiter);
|
|
74108
74207
|
}
|
|
@@ -74240,7 +74339,7 @@ async function resolveSession(options) {
|
|
|
74240
74339
|
if (attempt < SESSION_CREATE_MAX_RETRIES) {
|
|
74241
74340
|
const delay = SESSION_CREATE_RETRY_DELAY_MS * attempt;
|
|
74242
74341
|
console.log(import_picocolors11.default.dim(` Retrying in ${delay}ms...`));
|
|
74243
|
-
await new Promise((
|
|
74342
|
+
await new Promise((resolve4) => setTimeout(resolve4, delay));
|
|
74244
74343
|
}
|
|
74245
74344
|
continue;
|
|
74246
74345
|
}
|
|
@@ -74251,7 +74350,7 @@ async function resolveSession(options) {
|
|
|
74251
74350
|
if (attempt < SESSION_CREATE_MAX_RETRIES) {
|
|
74252
74351
|
const delay = SESSION_CREATE_RETRY_DELAY_MS * attempt;
|
|
74253
74352
|
console.log(import_picocolors11.default.dim(` Retrying in ${delay}ms...`));
|
|
74254
|
-
await new Promise((
|
|
74353
|
+
await new Promise((resolve4) => setTimeout(resolve4, delay));
|
|
74255
74354
|
}
|
|
74256
74355
|
}
|
|
74257
74356
|
throw new Error("Failed to create session after all retries");
|
|
@@ -74380,10 +74479,11 @@ var normalizeAgentName = (agent) => {
|
|
|
74380
74479
|
return;
|
|
74381
74480
|
const configKey = getAgentConfigKey(trimmed);
|
|
74382
74481
|
const displayName = getAgentDisplayName(configKey);
|
|
74482
|
+
const runtimeName = getAgentRuntimeName(configKey);
|
|
74383
74483
|
const isKnownAgent = displayName !== configKey;
|
|
74384
74484
|
return {
|
|
74385
74485
|
configKey,
|
|
74386
|
-
resolvedName: isKnownAgent ?
|
|
74486
|
+
resolvedName: isKnownAgent ? runtimeName : trimmed
|
|
74387
74487
|
};
|
|
74388
74488
|
};
|
|
74389
74489
|
var isAgentDisabled = (agentConfigKey, config2) => {
|
|
@@ -74407,18 +74507,19 @@ var resolveRunAgent = (options, pluginConfig, env = process.env) => {
|
|
|
74407
74507
|
const configAgent = normalizeAgentName(pluginConfig.default_run_agent);
|
|
74408
74508
|
const resolved = cliAgent ?? envAgent ?? configAgent ?? {
|
|
74409
74509
|
configKey: DEFAULT_AGENT,
|
|
74410
|
-
resolvedName:
|
|
74510
|
+
resolvedName: getAgentRuntimeName(DEFAULT_AGENT)
|
|
74411
74511
|
};
|
|
74412
74512
|
if (isAgentDisabled(resolved.configKey, pluginConfig)) {
|
|
74413
74513
|
const fallback = pickFallbackAgent(pluginConfig);
|
|
74414
|
-
const
|
|
74514
|
+
const fallbackDisplayName = getAgentDisplayName(fallback);
|
|
74515
|
+
const fallbackRuntimeName = getAgentRuntimeName(fallback);
|
|
74415
74516
|
const fallbackDisabled = isAgentDisabled(fallback, pluginConfig);
|
|
74416
74517
|
if (fallbackDisabled) {
|
|
74417
|
-
console.log(import_picocolors12.default.yellow(`Requested agent "${resolved.resolvedName}" is disabled and no enabled core agent was found. Proceeding with "${
|
|
74418
|
-
return
|
|
74518
|
+
console.log(import_picocolors12.default.yellow(`Requested agent "${resolved.resolvedName}" is disabled and no enabled core agent was found. Proceeding with "${fallbackDisplayName}".`));
|
|
74519
|
+
return fallbackRuntimeName;
|
|
74419
74520
|
}
|
|
74420
|
-
console.log(import_picocolors12.default.yellow(`Requested agent "${resolved.resolvedName}" is disabled. Falling back to "${
|
|
74421
|
-
return
|
|
74521
|
+
console.log(import_picocolors12.default.yellow(`Requested agent "${resolved.resolvedName}" is disabled. Falling back to "${fallbackDisplayName}".`));
|
|
74522
|
+
return fallbackRuntimeName;
|
|
74422
74523
|
}
|
|
74423
74524
|
return resolved.resolvedName;
|
|
74424
74525
|
};
|
|
@@ -74460,19 +74561,19 @@ var BOULDER_STATE_PATH = `${BOULDER_DIR}/${BOULDER_FILE}`;
|
|
|
74460
74561
|
var NOTEPAD_DIR = "notepads";
|
|
74461
74562
|
var NOTEPAD_BASE_PATH = `${BOULDER_DIR}/${NOTEPAD_DIR}`;
|
|
74462
74563
|
// src/features/boulder-state/storage.ts
|
|
74463
|
-
import { existsSync as
|
|
74464
|
-
import { dirname as
|
|
74564
|
+
import { existsSync as existsSync20, readFileSync as readFileSync14, writeFileSync as writeFileSync5, mkdirSync as mkdirSync8, readdirSync as readdirSync3 } from "fs";
|
|
74565
|
+
import { dirname as dirname9, join as join19, basename as basename5 } from "path";
|
|
74465
74566
|
var RESERVED_KEYS = new Set(["__proto__", "prototype", "constructor"]);
|
|
74466
74567
|
function getBoulderFilePath(directory) {
|
|
74467
|
-
return
|
|
74568
|
+
return join19(directory, BOULDER_DIR, BOULDER_FILE);
|
|
74468
74569
|
}
|
|
74469
74570
|
function readBoulderState(directory) {
|
|
74470
74571
|
const filePath = getBoulderFilePath(directory);
|
|
74471
|
-
if (!
|
|
74572
|
+
if (!existsSync20(filePath)) {
|
|
74472
74573
|
return null;
|
|
74473
74574
|
}
|
|
74474
74575
|
try {
|
|
74475
|
-
const content =
|
|
74576
|
+
const content = readFileSync14(filePath, "utf-8");
|
|
74476
74577
|
const parsed = JSON.parse(content);
|
|
74477
74578
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
74478
74579
|
return null;
|
|
@@ -74505,11 +74606,11 @@ var CHECKED_CHECKBOX_PATTERN = /^(\s*)[-*]\s*\[[xX]\]\s*(.+)$/;
|
|
|
74505
74606
|
var TODO_TASK_PATTERN = /^\d+\.\s+/;
|
|
74506
74607
|
var FINAL_WAVE_TASK_PATTERN = /^F\d+\.\s+/i;
|
|
74507
74608
|
function getPlanProgress(planPath) {
|
|
74508
|
-
if (!
|
|
74609
|
+
if (!existsSync20(planPath)) {
|
|
74509
74610
|
return { total: 0, completed: 0, isComplete: true };
|
|
74510
74611
|
}
|
|
74511
74612
|
try {
|
|
74512
|
-
const content =
|
|
74613
|
+
const content = readFileSync14(planPath, "utf-8");
|
|
74513
74614
|
const lines = content.split(/\r?\n/);
|
|
74514
74615
|
const hasStructuredSections = lines.some((line) => TODO_HEADING_PATTERN.test(line) || FINAL_VERIFICATION_HEADING_PATTERN.test(line));
|
|
74515
74616
|
if (hasStructuredSections) {
|
|
@@ -74581,17 +74682,17 @@ function getSessionAgent(sessionID) {
|
|
|
74581
74682
|
// src/features/run-continuation-state/constants.ts
|
|
74582
74683
|
var CONTINUATION_MARKER_DIR = ".sisyphus/run-continuation";
|
|
74583
74684
|
// src/features/run-continuation-state/storage.ts
|
|
74584
|
-
import { existsSync as
|
|
74585
|
-
import { join as
|
|
74685
|
+
import { existsSync as existsSync21, mkdirSync as mkdirSync9, readFileSync as readFileSync15, rmSync as rmSync2, writeFileSync as writeFileSync6 } from "fs";
|
|
74686
|
+
import { join as join20 } from "path";
|
|
74586
74687
|
function getMarkerPath(directory, sessionID) {
|
|
74587
|
-
return
|
|
74688
|
+
return join20(directory, CONTINUATION_MARKER_DIR, `${sessionID}.json`);
|
|
74588
74689
|
}
|
|
74589
74690
|
function readContinuationMarker(directory, sessionID) {
|
|
74590
74691
|
const markerPath = getMarkerPath(directory, sessionID);
|
|
74591
|
-
if (!
|
|
74692
|
+
if (!existsSync21(markerPath))
|
|
74592
74693
|
return null;
|
|
74593
74694
|
try {
|
|
74594
|
-
const raw =
|
|
74695
|
+
const raw = readFileSync15(markerPath, "utf-8");
|
|
74595
74696
|
const parsed = JSON.parse(raw);
|
|
74596
74697
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
74597
74698
|
return null;
|
|
@@ -74652,8 +74753,8 @@ async function isSessionInBoulderLineage(input) {
|
|
|
74652
74753
|
// src/hooks/atlas/session-last-agent.ts
|
|
74653
74754
|
init_shared();
|
|
74654
74755
|
init_compaction_marker();
|
|
74655
|
-
import { readFileSync as
|
|
74656
|
-
import { join as
|
|
74756
|
+
import { readFileSync as readFileSync16, readdirSync as readdirSync4 } from "fs";
|
|
74757
|
+
import { join as join21 } from "path";
|
|
74657
74758
|
var defaultSessionLastAgentDeps = {
|
|
74658
74759
|
getMessageDir,
|
|
74659
74760
|
isSqliteBackend,
|
|
@@ -74701,7 +74802,7 @@ async function getLastAgentFromSession(sessionID, client3, deps = {}) {
|
|
|
74701
74802
|
try {
|
|
74702
74803
|
const messages = readdirSync4(messageDir).filter((fileName) => fileName.endsWith(".json")).map((fileName) => {
|
|
74703
74804
|
try {
|
|
74704
|
-
const content =
|
|
74805
|
+
const content = readFileSync16(join21(messageDir, fileName), "utf-8");
|
|
74705
74806
|
const parsed = JSON.parse(content);
|
|
74706
74807
|
return {
|
|
74707
74808
|
fileName,
|
|
@@ -74734,8 +74835,8 @@ init_agent_display_names();
|
|
|
74734
74835
|
|
|
74735
74836
|
// src/hooks/ralph-loop/storage.ts
|
|
74736
74837
|
init_frontmatter();
|
|
74737
|
-
import { existsSync as
|
|
74738
|
-
import { dirname as
|
|
74838
|
+
import { existsSync as existsSync22, readFileSync as readFileSync17, writeFileSync as writeFileSync7, unlinkSync as unlinkSync3, mkdirSync as mkdirSync10 } from "fs";
|
|
74839
|
+
import { dirname as dirname10, join as join22 } from "path";
|
|
74739
74840
|
|
|
74740
74841
|
// src/hooks/ralph-loop/constants.ts
|
|
74741
74842
|
var DEFAULT_STATE_FILE = ".sisyphus/ralph-loop.local.md";
|
|
@@ -74744,15 +74845,15 @@ var DEFAULT_COMPLETION_PROMISE = "DONE";
|
|
|
74744
74845
|
|
|
74745
74846
|
// src/hooks/ralph-loop/storage.ts
|
|
74746
74847
|
function getStateFilePath(directory, customPath) {
|
|
74747
|
-
return customPath ?
|
|
74848
|
+
return customPath ? join22(directory, customPath) : join22(directory, DEFAULT_STATE_FILE);
|
|
74748
74849
|
}
|
|
74749
74850
|
function readState(directory, customPath) {
|
|
74750
74851
|
const filePath = getStateFilePath(directory, customPath);
|
|
74751
|
-
if (!
|
|
74852
|
+
if (!existsSync22(filePath)) {
|
|
74752
74853
|
return null;
|
|
74753
74854
|
}
|
|
74754
74855
|
try {
|
|
74755
|
-
const content =
|
|
74856
|
+
const content = readFileSync17(filePath, "utf-8");
|
|
74756
74857
|
const { data, body } = parseFrontmatter(content);
|
|
74757
74858
|
const active = data.active;
|
|
74758
74859
|
const iteration = data.iteration;
|
|
@@ -74961,7 +75062,7 @@ async function pollForCompletion(ctx, eventState, abortController, options = {})
|
|
|
74961
75062
|
let secondaryTimeoutChecked = false;
|
|
74962
75063
|
const pollStartTimestamp = Date.now();
|
|
74963
75064
|
while (!abortController.signal.aborted) {
|
|
74964
|
-
await new Promise((
|
|
75065
|
+
await new Promise((resolve4) => setTimeout(resolve4, pollIntervalMs));
|
|
74965
75066
|
if (abortController.signal.aborted) {
|
|
74966
75067
|
return 130;
|
|
74967
75068
|
}
|
|
@@ -75192,7 +75293,7 @@ var EVENT_PROCESSOR_SHUTDOWN_TIMEOUT_MS = 2000;
|
|
|
75192
75293
|
async function waitForEventProcessorShutdown(eventProcessor, timeoutMs = EVENT_PROCESSOR_SHUTDOWN_TIMEOUT_MS) {
|
|
75193
75294
|
const completed = await Promise.race([
|
|
75194
75295
|
eventProcessor.then(() => true),
|
|
75195
|
-
new Promise((
|
|
75296
|
+
new Promise((resolve4) => setTimeout(() => resolve4(false), timeoutMs))
|
|
75196
75297
|
]);
|
|
75197
75298
|
}
|
|
75198
75299
|
async function run(options) {
|
|
@@ -75520,12 +75621,12 @@ async function getLocalVersion(options = {}) {
|
|
|
75520
75621
|
}
|
|
75521
75622
|
}
|
|
75522
75623
|
// src/cli/doctor/checks/system.ts
|
|
75523
|
-
import { existsSync as
|
|
75624
|
+
import { existsSync as existsSync33, readFileSync as readFileSync27 } from "fs";
|
|
75524
75625
|
|
|
75525
75626
|
// src/cli/doctor/checks/system-binary.ts
|
|
75526
|
-
import { existsSync as
|
|
75527
|
-
import { homedir as
|
|
75528
|
-
import { join as
|
|
75627
|
+
import { existsSync as existsSync30 } from "fs";
|
|
75628
|
+
import { homedir as homedir6 } from "os";
|
|
75629
|
+
import { join as join29 } from "path";
|
|
75529
75630
|
|
|
75530
75631
|
// src/cli/doctor/spawn-with-timeout.ts
|
|
75531
75632
|
init_spawn_with_windows_hide();
|
|
@@ -75538,8 +75639,8 @@ async function spawnWithTimeout(command, options, timeoutMs = DEFAULT_SPAWN_TIME
|
|
|
75538
75639
|
return { stdout: "", stderr: "", exitCode: 1, timedOut: false };
|
|
75539
75640
|
}
|
|
75540
75641
|
let timer;
|
|
75541
|
-
const timeoutPromise = new Promise((
|
|
75542
|
-
timer = setTimeout(() =>
|
|
75642
|
+
const timeoutPromise = new Promise((resolve4) => {
|
|
75643
|
+
timer = setTimeout(() => resolve4("timeout"), timeoutMs);
|
|
75543
75644
|
});
|
|
75544
75645
|
const processPromise = (async () => {
|
|
75545
75646
|
await proc.exited;
|
|
@@ -75559,22 +75660,22 @@ async function spawnWithTimeout(command, options, timeoutMs = DEFAULT_SPAWN_TIME
|
|
|
75559
75660
|
|
|
75560
75661
|
// src/cli/doctor/checks/system-binary.ts
|
|
75561
75662
|
function getDesktopAppPaths(platform) {
|
|
75562
|
-
const home =
|
|
75663
|
+
const home = homedir6();
|
|
75563
75664
|
switch (platform) {
|
|
75564
75665
|
case "darwin":
|
|
75565
75666
|
return [
|
|
75566
75667
|
"/Applications/OpenCode.app/Contents/MacOS/OpenCode",
|
|
75567
|
-
|
|
75668
|
+
join29(home, "Applications", "OpenCode.app", "Contents", "MacOS", "OpenCode")
|
|
75568
75669
|
];
|
|
75569
75670
|
case "win32": {
|
|
75570
75671
|
const programFiles = process.env.ProgramFiles;
|
|
75571
75672
|
const localAppData = process.env.LOCALAPPDATA;
|
|
75572
75673
|
const paths = [];
|
|
75573
75674
|
if (programFiles) {
|
|
75574
|
-
paths.push(
|
|
75675
|
+
paths.push(join29(programFiles, "OpenCode", "OpenCode.exe"));
|
|
75575
75676
|
}
|
|
75576
75677
|
if (localAppData) {
|
|
75577
|
-
paths.push(
|
|
75678
|
+
paths.push(join29(localAppData, "OpenCode", "OpenCode.exe"));
|
|
75578
75679
|
}
|
|
75579
75680
|
return paths;
|
|
75580
75681
|
}
|
|
@@ -75582,8 +75683,8 @@ function getDesktopAppPaths(platform) {
|
|
|
75582
75683
|
return [
|
|
75583
75684
|
"/usr/bin/opencode",
|
|
75584
75685
|
"/usr/lib/opencode/opencode",
|
|
75585
|
-
|
|
75586
|
-
|
|
75686
|
+
join29(home, "Applications", "opencode-desktop-linux-x86_64.AppImage"),
|
|
75687
|
+
join29(home, "Applications", "opencode-desktop-linux-aarch64.AppImage")
|
|
75587
75688
|
];
|
|
75588
75689
|
default:
|
|
75589
75690
|
return [];
|
|
@@ -75595,7 +75696,7 @@ function buildVersionCommand(binaryPath, platform) {
|
|
|
75595
75696
|
}
|
|
75596
75697
|
return [binaryPath, "--version"];
|
|
75597
75698
|
}
|
|
75598
|
-
function findDesktopBinary(platform = process.platform, checkExists =
|
|
75699
|
+
function findDesktopBinary(platform = process.platform, checkExists = existsSync30) {
|
|
75599
75700
|
for (const desktopPath of getDesktopAppPaths(platform)) {
|
|
75600
75701
|
if (checkExists(desktopPath)) {
|
|
75601
75702
|
return { binary: "opencode", path: desktopPath };
|
|
@@ -75641,12 +75742,12 @@ function compareVersions3(current, minimum) {
|
|
|
75641
75742
|
|
|
75642
75743
|
// src/cli/doctor/checks/system-plugin.ts
|
|
75643
75744
|
init_shared();
|
|
75644
|
-
import { existsSync as
|
|
75745
|
+
import { existsSync as existsSync31, readFileSync as readFileSync25 } from "fs";
|
|
75645
75746
|
function detectConfigPath() {
|
|
75646
75747
|
const paths = getOpenCodeConfigPaths({ binary: "opencode", version: null });
|
|
75647
|
-
if (
|
|
75748
|
+
if (existsSync31(paths.configJsonc))
|
|
75648
75749
|
return paths.configJsonc;
|
|
75649
|
-
if (
|
|
75750
|
+
if (existsSync31(paths.configJson))
|
|
75650
75751
|
return paths.configJson;
|
|
75651
75752
|
return null;
|
|
75652
75753
|
}
|
|
@@ -75692,7 +75793,7 @@ function getPluginInfo() {
|
|
|
75692
75793
|
};
|
|
75693
75794
|
}
|
|
75694
75795
|
try {
|
|
75695
|
-
const content =
|
|
75796
|
+
const content = readFileSync25(configPath, "utf-8");
|
|
75696
75797
|
const parsedConfig = parseJsonc(content);
|
|
75697
75798
|
const pluginEntry = findPluginEntry2(parsedConfig.plugin ?? []);
|
|
75698
75799
|
if (!pluginEntry) {
|
|
@@ -75730,37 +75831,37 @@ function getPluginInfo() {
|
|
|
75730
75831
|
init_file_utils();
|
|
75731
75832
|
init_checker();
|
|
75732
75833
|
init_auto_update_checker();
|
|
75733
|
-
import { existsSync as
|
|
75734
|
-
import { homedir as
|
|
75735
|
-
import { join as
|
|
75834
|
+
import { existsSync as existsSync32, readFileSync as readFileSync26 } from "fs";
|
|
75835
|
+
import { homedir as homedir7 } from "os";
|
|
75836
|
+
import { join as join30 } from "path";
|
|
75736
75837
|
init_shared();
|
|
75737
75838
|
function getPlatformDefaultCacheDir(platform = process.platform) {
|
|
75738
75839
|
if (platform === "darwin")
|
|
75739
|
-
return
|
|
75840
|
+
return join30(homedir7(), "Library", "Caches");
|
|
75740
75841
|
if (platform === "win32")
|
|
75741
|
-
return process.env.LOCALAPPDATA ??
|
|
75742
|
-
return
|
|
75842
|
+
return process.env.LOCALAPPDATA ?? join30(homedir7(), "AppData", "Local");
|
|
75843
|
+
return join30(homedir7(), ".cache");
|
|
75743
75844
|
}
|
|
75744
75845
|
function resolveOpenCodeCacheDir() {
|
|
75745
75846
|
const xdgCacheHome = process.env.XDG_CACHE_HOME;
|
|
75746
75847
|
if (xdgCacheHome)
|
|
75747
|
-
return
|
|
75848
|
+
return join30(xdgCacheHome, "opencode");
|
|
75748
75849
|
const fromShared = getOpenCodeCacheDir();
|
|
75749
|
-
const platformDefault =
|
|
75750
|
-
if (
|
|
75850
|
+
const platformDefault = join30(getPlatformDefaultCacheDir(), "opencode");
|
|
75851
|
+
if (existsSync32(fromShared) || !existsSync32(platformDefault))
|
|
75751
75852
|
return fromShared;
|
|
75752
75853
|
return platformDefault;
|
|
75753
75854
|
}
|
|
75754
75855
|
function resolveExistingDir(dirPath) {
|
|
75755
|
-
if (!
|
|
75856
|
+
if (!existsSync32(dirPath))
|
|
75756
75857
|
return dirPath;
|
|
75757
75858
|
return resolveSymlink(dirPath);
|
|
75758
75859
|
}
|
|
75759
75860
|
function readPackageJson(filePath) {
|
|
75760
|
-
if (!
|
|
75861
|
+
if (!existsSync32(filePath))
|
|
75761
75862
|
return null;
|
|
75762
75863
|
try {
|
|
75763
|
-
const content =
|
|
75864
|
+
const content = readFileSync26(filePath, "utf-8");
|
|
75764
75865
|
return parseJsonc(content);
|
|
75765
75866
|
} catch {
|
|
75766
75867
|
return null;
|
|
@@ -75775,11 +75876,11 @@ function normalizeVersion(value) {
|
|
|
75775
75876
|
function createPackageCandidates(rootDir) {
|
|
75776
75877
|
return ACCEPTED_PACKAGE_NAMES.map((packageName) => ({
|
|
75777
75878
|
packageName,
|
|
75778
|
-
installedPackagePath:
|
|
75879
|
+
installedPackagePath: join30(rootDir, "node_modules", packageName, "package.json")
|
|
75779
75880
|
}));
|
|
75780
75881
|
}
|
|
75781
75882
|
function selectInstalledPackage(candidate) {
|
|
75782
|
-
return candidate.packageCandidates.find((packageCandidate) =>
|
|
75883
|
+
return candidate.packageCandidates.find((packageCandidate) => existsSync32(packageCandidate.installedPackagePath)) ?? candidate.packageCandidates[0];
|
|
75783
75884
|
}
|
|
75784
75885
|
function getExpectedVersion(cachePackage, packageName) {
|
|
75785
75886
|
return normalizeVersion(cachePackage?.dependencies?.[packageName]) ?? normalizeVersion(cachePackage?.dependencies?.[PACKAGE_NAME]);
|
|
@@ -75791,16 +75892,16 @@ function getLoadedPluginVersion() {
|
|
|
75791
75892
|
const candidates = [
|
|
75792
75893
|
{
|
|
75793
75894
|
cacheDir: configDir,
|
|
75794
|
-
cachePackagePath:
|
|
75895
|
+
cachePackagePath: join30(configDir, "package.json"),
|
|
75795
75896
|
packageCandidates: createPackageCandidates(configDir)
|
|
75796
75897
|
},
|
|
75797
75898
|
{
|
|
75798
75899
|
cacheDir,
|
|
75799
|
-
cachePackagePath:
|
|
75900
|
+
cachePackagePath: join30(cacheDir, "package.json"),
|
|
75800
75901
|
packageCandidates: createPackageCandidates(cacheDir)
|
|
75801
75902
|
}
|
|
75802
75903
|
];
|
|
75803
|
-
const selectedCandidate = candidates.find((candidate) => candidate.packageCandidates.some((packageCandidate) =>
|
|
75904
|
+
const selectedCandidate = candidates.find((candidate) => candidate.packageCandidates.some((packageCandidate) => existsSync32(packageCandidate.installedPackagePath))) ?? candidates[0];
|
|
75804
75905
|
const { cacheDir: selectedDir, cachePackagePath } = selectedCandidate;
|
|
75805
75906
|
const selectedPackage = selectInstalledPackage(selectedCandidate);
|
|
75806
75907
|
const installedPackagePath = selectedPackage.installedPackagePath;
|
|
@@ -75839,10 +75940,10 @@ var defaultDeps3 = {
|
|
|
75839
75940
|
function isConfigValid(configPath) {
|
|
75840
75941
|
if (!configPath)
|
|
75841
75942
|
return true;
|
|
75842
|
-
if (!
|
|
75943
|
+
if (!existsSync33(configPath))
|
|
75843
75944
|
return false;
|
|
75844
75945
|
try {
|
|
75845
|
-
parseJsonc(
|
|
75946
|
+
parseJsonc(readFileSync27(configPath, "utf-8"));
|
|
75846
75947
|
return true;
|
|
75847
75948
|
} catch {
|
|
75848
75949
|
return false;
|
|
@@ -75964,32 +76065,32 @@ async function checkSystem(deps = defaultDeps3) {
|
|
|
75964
76065
|
}
|
|
75965
76066
|
|
|
75966
76067
|
// src/cli/doctor/checks/config.ts
|
|
75967
|
-
import { readFileSync as
|
|
75968
|
-
import { join as
|
|
76068
|
+
import { readFileSync as readFileSync30 } from "fs";
|
|
76069
|
+
import { join as join34 } from "path";
|
|
75969
76070
|
init_shared();
|
|
75970
76071
|
|
|
75971
76072
|
// src/cli/doctor/checks/model-resolution-cache.ts
|
|
75972
76073
|
init_shared();
|
|
75973
|
-
import { existsSync as
|
|
75974
|
-
import { homedir as
|
|
75975
|
-
import { join as
|
|
76074
|
+
import { existsSync as existsSync34, readFileSync as readFileSync28 } from "fs";
|
|
76075
|
+
import { homedir as homedir8 } from "os";
|
|
76076
|
+
import { join as join31 } from "path";
|
|
75976
76077
|
function getUserConfigDir2() {
|
|
75977
76078
|
const xdgConfig = process.env.XDG_CONFIG_HOME;
|
|
75978
76079
|
if (xdgConfig)
|
|
75979
|
-
return
|
|
75980
|
-
return
|
|
76080
|
+
return join31(xdgConfig, "opencode");
|
|
76081
|
+
return join31(homedir8(), ".config", "opencode");
|
|
75981
76082
|
}
|
|
75982
76083
|
function loadCustomProviderNames() {
|
|
75983
76084
|
const configDir = getUserConfigDir2();
|
|
75984
76085
|
const candidatePaths = [
|
|
75985
|
-
|
|
75986
|
-
|
|
76086
|
+
join31(configDir, "opencode.json"),
|
|
76087
|
+
join31(configDir, "opencode.jsonc")
|
|
75987
76088
|
];
|
|
75988
76089
|
for (const configPath of candidatePaths) {
|
|
75989
|
-
if (!
|
|
76090
|
+
if (!existsSync34(configPath))
|
|
75990
76091
|
continue;
|
|
75991
76092
|
try {
|
|
75992
|
-
const content =
|
|
76093
|
+
const content = readFileSync28(configPath, "utf-8");
|
|
75993
76094
|
const data = parseJsonc(content);
|
|
75994
76095
|
if (data?.provider && typeof data.provider === "object") {
|
|
75995
76096
|
return Object.keys(data.provider);
|
|
@@ -75999,16 +76100,16 @@ function loadCustomProviderNames() {
|
|
|
75999
76100
|
return [];
|
|
76000
76101
|
}
|
|
76001
76102
|
function loadAvailableModelsFromCache() {
|
|
76002
|
-
const cacheFile =
|
|
76103
|
+
const cacheFile = join31(getOpenCodeCacheDir(), "models.json");
|
|
76003
76104
|
const customProviders = loadCustomProviderNames();
|
|
76004
|
-
if (!
|
|
76105
|
+
if (!existsSync34(cacheFile)) {
|
|
76005
76106
|
if (customProviders.length > 0) {
|
|
76006
76107
|
return { providers: customProviders, modelCount: 0, cacheExists: true };
|
|
76007
76108
|
}
|
|
76008
76109
|
return { providers: [], modelCount: 0, cacheExists: false };
|
|
76009
76110
|
}
|
|
76010
76111
|
try {
|
|
76011
|
-
const content =
|
|
76112
|
+
const content = readFileSync28(cacheFile, "utf-8");
|
|
76012
76113
|
const data = parseJsonc(content);
|
|
76013
76114
|
const cacheProviders = Object.keys(data);
|
|
76014
76115
|
let modelCount = 0;
|
|
@@ -76031,14 +76132,14 @@ init_model_capabilities();
|
|
|
76031
76132
|
|
|
76032
76133
|
// src/cli/doctor/checks/model-resolution-config.ts
|
|
76033
76134
|
init_shared();
|
|
76034
|
-
import { readFileSync as
|
|
76035
|
-
import { join as
|
|
76036
|
-
var PROJECT_CONFIG_DIR =
|
|
76135
|
+
import { readFileSync as readFileSync29 } from "fs";
|
|
76136
|
+
import { join as join32 } from "path";
|
|
76137
|
+
var PROJECT_CONFIG_DIR = join32(process.cwd(), ".opencode");
|
|
76037
76138
|
function loadOmoConfig() {
|
|
76038
76139
|
const projectDetected = detectPluginConfigFile(PROJECT_CONFIG_DIR);
|
|
76039
76140
|
if (projectDetected.format !== "none") {
|
|
76040
76141
|
try {
|
|
76041
|
-
const content =
|
|
76142
|
+
const content = readFileSync29(projectDetected.path, "utf-8");
|
|
76042
76143
|
return parseJsonc(content);
|
|
76043
76144
|
} catch {
|
|
76044
76145
|
return null;
|
|
@@ -76048,7 +76149,7 @@ function loadOmoConfig() {
|
|
|
76048
76149
|
const userDetected = detectPluginConfigFile(userConfigDir);
|
|
76049
76150
|
if (userDetected.format !== "none") {
|
|
76050
76151
|
try {
|
|
76051
|
-
const content =
|
|
76152
|
+
const content = readFileSync29(userDetected.path, "utf-8");
|
|
76052
76153
|
return parseJsonc(content);
|
|
76053
76154
|
} catch {
|
|
76054
76155
|
return null;
|
|
@@ -76059,7 +76160,7 @@ function loadOmoConfig() {
|
|
|
76059
76160
|
|
|
76060
76161
|
// src/cli/doctor/checks/model-resolution-details.ts
|
|
76061
76162
|
init_shared();
|
|
76062
|
-
import { join as
|
|
76163
|
+
import { join as join33 } from "path";
|
|
76063
76164
|
|
|
76064
76165
|
// src/cli/doctor/checks/model-resolution-variant.ts
|
|
76065
76166
|
function formatModelWithVariant(model, variant) {
|
|
@@ -76101,7 +76202,7 @@ function formatCapabilityResolutionLabel(mode) {
|
|
|
76101
76202
|
}
|
|
76102
76203
|
function buildModelResolutionDetails(options) {
|
|
76103
76204
|
const details = [];
|
|
76104
|
-
const cacheFile =
|
|
76205
|
+
const cacheFile = join33(getOpenCodeCacheDir(), "models.json");
|
|
76105
76206
|
details.push("\u2550\u2550\u2550 Available Models (from cache) \u2550\u2550\u2550");
|
|
76106
76207
|
details.push("");
|
|
76107
76208
|
if (options.available.cacheExists) {
|
|
@@ -76256,7 +76357,7 @@ async function checkModels() {
|
|
|
76256
76357
|
}
|
|
76257
76358
|
|
|
76258
76359
|
// src/cli/doctor/checks/config.ts
|
|
76259
|
-
var PROJECT_CONFIG_DIR2 =
|
|
76360
|
+
var PROJECT_CONFIG_DIR2 = join34(process.cwd(), ".opencode");
|
|
76260
76361
|
function findConfigPath() {
|
|
76261
76362
|
const projectConfig = detectPluginConfigFile(PROJECT_CONFIG_DIR2);
|
|
76262
76363
|
if (projectConfig.format !== "none")
|
|
@@ -76273,7 +76374,7 @@ function validateConfig() {
|
|
|
76273
76374
|
return { exists: false, path: null, valid: true, config: null, errors: [] };
|
|
76274
76375
|
}
|
|
76275
76376
|
try {
|
|
76276
|
-
const content =
|
|
76377
|
+
const content = readFileSync30(configPath, "utf-8");
|
|
76277
76378
|
const rawConfig = parseJsonc(content);
|
|
76278
76379
|
const schemaResult = OhMyOpenCodeConfigSchema.safeParse(rawConfig);
|
|
76279
76380
|
if (!schemaResult.success) {
|
|
@@ -76376,27 +76477,27 @@ async function checkConfig() {
|
|
|
76376
76477
|
}
|
|
76377
76478
|
|
|
76378
76479
|
// src/cli/doctor/checks/dependencies.ts
|
|
76379
|
-
import { existsSync as
|
|
76480
|
+
import { existsSync as existsSync35 } from "fs";
|
|
76380
76481
|
import { createRequire } from "module";
|
|
76381
|
-
import { dirname as
|
|
76482
|
+
import { dirname as dirname14, join as join36 } from "path";
|
|
76382
76483
|
|
|
76383
76484
|
// src/hooks/comment-checker/downloader.ts
|
|
76384
|
-
import { join as
|
|
76385
|
-
import { homedir as
|
|
76485
|
+
import { join as join35 } from "path";
|
|
76486
|
+
import { homedir as homedir9, tmpdir as tmpdir3 } from "os";
|
|
76386
76487
|
init_binary_downloader();
|
|
76387
76488
|
init_logger();
|
|
76388
76489
|
init_plugin_identity();
|
|
76389
76490
|
var DEBUG = process.env.COMMENT_CHECKER_DEBUG === "1";
|
|
76390
|
-
var DEBUG_FILE =
|
|
76491
|
+
var DEBUG_FILE = join35(tmpdir3(), "comment-checker-debug.log");
|
|
76391
76492
|
function getCacheDir2() {
|
|
76392
76493
|
if (process.platform === "win32") {
|
|
76393
76494
|
const localAppData = process.env.LOCALAPPDATA || process.env.APPDATA;
|
|
76394
|
-
const base2 = localAppData ||
|
|
76395
|
-
return
|
|
76495
|
+
const base2 = localAppData || join35(homedir9(), "AppData", "Local");
|
|
76496
|
+
return join35(base2, CACHE_DIR_NAME, "bin");
|
|
76396
76497
|
}
|
|
76397
76498
|
const xdgCache = process.env.XDG_CACHE_HOME;
|
|
76398
|
-
const base = xdgCache ||
|
|
76399
|
-
return
|
|
76499
|
+
const base = xdgCache || join35(homedir9(), ".cache");
|
|
76500
|
+
return join35(base, CACHE_DIR_NAME, "bin");
|
|
76400
76501
|
}
|
|
76401
76502
|
function getBinaryName() {
|
|
76402
76503
|
return process.platform === "win32" ? "comment-checker.exe" : "comment-checker";
|
|
@@ -76460,15 +76561,15 @@ async function checkAstGrepNapi() {
|
|
|
76460
76561
|
path: null
|
|
76461
76562
|
};
|
|
76462
76563
|
} catch {
|
|
76463
|
-
const { existsSync:
|
|
76464
|
-
const { join:
|
|
76465
|
-
const { homedir:
|
|
76564
|
+
const { existsSync: existsSync36 } = await import("fs");
|
|
76565
|
+
const { join: join37 } = await import("path");
|
|
76566
|
+
const { homedir: homedir10 } = await import("os");
|
|
76466
76567
|
const pathsToCheck = [
|
|
76467
|
-
|
|
76468
|
-
|
|
76568
|
+
join37(homedir10(), ".config", "opencode", "node_modules", "@ast-grep", "napi"),
|
|
76569
|
+
join37(process.cwd(), "node_modules", "@ast-grep", "napi")
|
|
76469
76570
|
];
|
|
76470
76571
|
for (const napiPath of pathsToCheck) {
|
|
76471
|
-
if (
|
|
76572
|
+
if (existsSync36(napiPath)) {
|
|
76472
76573
|
return {
|
|
76473
76574
|
name: "AST-Grep NAPI",
|
|
76474
76575
|
required: false,
|
|
@@ -76493,8 +76594,8 @@ function findCommentCheckerPackageBinary() {
|
|
|
76493
76594
|
try {
|
|
76494
76595
|
const require2 = createRequire(import.meta.url);
|
|
76495
76596
|
const pkgPath = require2.resolve("@code-yeongyu/comment-checker/package.json");
|
|
76496
|
-
const binaryPath =
|
|
76497
|
-
if (
|
|
76597
|
+
const binaryPath = join36(dirname14(pkgPath), "bin", binaryName);
|
|
76598
|
+
if (existsSync35(binaryPath))
|
|
76498
76599
|
return binaryPath;
|
|
76499
76600
|
} catch {}
|
|
76500
76601
|
return null;
|
|
@@ -76655,15 +76756,15 @@ var BUILTIN_SERVERS = {
|
|
|
76655
76756
|
"kotlin-ls": { command: ["kotlin-lsp"], extensions: [".kt", ".kts"] }
|
|
76656
76757
|
};
|
|
76657
76758
|
// src/tools/lsp/server-config-loader.ts
|
|
76658
|
-
import { existsSync as
|
|
76659
|
-
import { join as
|
|
76759
|
+
import { existsSync as existsSync36, readFileSync as readFileSync31 } from "fs";
|
|
76760
|
+
import { join as join37 } from "path";
|
|
76660
76761
|
init_shared();
|
|
76661
76762
|
init_jsonc_parser();
|
|
76662
76763
|
function loadJsonFile(path12) {
|
|
76663
|
-
if (!
|
|
76764
|
+
if (!existsSync36(path12))
|
|
76664
76765
|
return null;
|
|
76665
76766
|
try {
|
|
76666
|
-
return parseJsonc(
|
|
76767
|
+
return parseJsonc(readFileSync31(path12, "utf-8"));
|
|
76667
76768
|
} catch {
|
|
76668
76769
|
return null;
|
|
76669
76770
|
}
|
|
@@ -76672,9 +76773,9 @@ function getConfigPaths2() {
|
|
|
76672
76773
|
const cwd = process.cwd();
|
|
76673
76774
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
76674
76775
|
return {
|
|
76675
|
-
project: detectPluginConfigFile(
|
|
76776
|
+
project: detectPluginConfigFile(join37(cwd, ".opencode")).path,
|
|
76676
76777
|
user: detectPluginConfigFile(configDir).path,
|
|
76677
|
-
opencode: detectConfigFile(
|
|
76778
|
+
opencode: detectConfigFile(join37(configDir, "opencode")).path
|
|
76678
76779
|
};
|
|
76679
76780
|
}
|
|
76680
76781
|
function loadAllConfigs() {
|
|
@@ -76743,21 +76844,21 @@ function getMergedServers() {
|
|
|
76743
76844
|
}
|
|
76744
76845
|
|
|
76745
76846
|
// src/tools/lsp/server-installation.ts
|
|
76746
|
-
import { existsSync as
|
|
76747
|
-
import { delimiter as delimiter2, join as
|
|
76847
|
+
import { existsSync as existsSync37 } from "fs";
|
|
76848
|
+
import { delimiter as delimiter2, join as join39 } from "path";
|
|
76748
76849
|
|
|
76749
76850
|
// src/tools/lsp/server-path-bases.ts
|
|
76750
76851
|
init_shared();
|
|
76751
|
-
import { join as
|
|
76852
|
+
import { join as join38 } from "path";
|
|
76752
76853
|
function getLspServerAdditionalPathBases(workingDirectory) {
|
|
76753
76854
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
76754
|
-
const dataDir =
|
|
76855
|
+
const dataDir = join38(getDataDir(), "opencode");
|
|
76755
76856
|
return [
|
|
76756
|
-
|
|
76757
|
-
|
|
76758
|
-
|
|
76759
|
-
|
|
76760
|
-
|
|
76857
|
+
join38(workingDirectory, "node_modules", ".bin"),
|
|
76858
|
+
join38(configDir, "bin"),
|
|
76859
|
+
join38(configDir, "node_modules", ".bin"),
|
|
76860
|
+
join38(dataDir, "bin"),
|
|
76861
|
+
join38(dataDir, "bin", "node_modules", ".bin")
|
|
76761
76862
|
];
|
|
76762
76863
|
}
|
|
76763
76864
|
|
|
@@ -76767,7 +76868,7 @@ function isServerInstalled(command) {
|
|
|
76767
76868
|
return false;
|
|
76768
76869
|
const cmd = command[0];
|
|
76769
76870
|
if (cmd.includes("/") || cmd.includes("\\")) {
|
|
76770
|
-
if (
|
|
76871
|
+
if (existsSync37(cmd))
|
|
76771
76872
|
return true;
|
|
76772
76873
|
}
|
|
76773
76874
|
const isWindows = process.platform === "win32";
|
|
@@ -76788,14 +76889,14 @@ function isServerInstalled(command) {
|
|
|
76788
76889
|
const paths = pathEnv.split(delimiter2);
|
|
76789
76890
|
for (const p2 of paths) {
|
|
76790
76891
|
for (const suffix of exts) {
|
|
76791
|
-
if (
|
|
76892
|
+
if (existsSync37(join39(p2, cmd + suffix))) {
|
|
76792
76893
|
return true;
|
|
76793
76894
|
}
|
|
76794
76895
|
}
|
|
76795
76896
|
}
|
|
76796
76897
|
for (const base of getLspServerAdditionalPathBases(process.cwd())) {
|
|
76797
76898
|
for (const suffix of exts) {
|
|
76798
|
-
if (
|
|
76899
|
+
if (existsSync37(join39(base, cmd + suffix))) {
|
|
76799
76900
|
return true;
|
|
76800
76901
|
}
|
|
76801
76902
|
}
|
|
@@ -76857,24 +76958,24 @@ function getInstalledLspServers() {
|
|
|
76857
76958
|
|
|
76858
76959
|
// src/cli/doctor/checks/tools-mcp.ts
|
|
76859
76960
|
init_shared();
|
|
76860
|
-
import { existsSync as
|
|
76861
|
-
import { homedir as
|
|
76862
|
-
import { join as
|
|
76961
|
+
import { existsSync as existsSync38, readFileSync as readFileSync32 } from "fs";
|
|
76962
|
+
import { homedir as homedir10 } from "os";
|
|
76963
|
+
import { join as join40 } from "path";
|
|
76863
76964
|
var BUILTIN_MCP_SERVERS = ["context7", "grep_app"];
|
|
76864
76965
|
function getMcpConfigPaths() {
|
|
76865
76966
|
return [
|
|
76866
|
-
|
|
76867
|
-
|
|
76868
|
-
|
|
76967
|
+
join40(homedir10(), ".claude", ".mcp.json"),
|
|
76968
|
+
join40(process.cwd(), ".mcp.json"),
|
|
76969
|
+
join40(process.cwd(), ".claude", ".mcp.json")
|
|
76869
76970
|
];
|
|
76870
76971
|
}
|
|
76871
76972
|
function loadUserMcpConfig() {
|
|
76872
76973
|
const servers = {};
|
|
76873
76974
|
for (const configPath of getMcpConfigPaths()) {
|
|
76874
|
-
if (!
|
|
76975
|
+
if (!existsSync38(configPath))
|
|
76875
76976
|
continue;
|
|
76876
76977
|
try {
|
|
76877
|
-
const content =
|
|
76978
|
+
const content = readFileSync32(configPath, "utf-8");
|
|
76878
76979
|
const config2 = parseJsonc(content);
|
|
76879
76980
|
if (config2.mcpServers) {
|
|
76880
76981
|
Object.assign(servers, config2.mcpServers);
|
|
@@ -77372,11 +77473,11 @@ async function refreshModelCapabilities(options, deps = {}) {
|
|
|
77372
77473
|
|
|
77373
77474
|
// src/features/mcp-oauth/storage.ts
|
|
77374
77475
|
init_shared();
|
|
77375
|
-
import { chmodSync as chmodSync2, existsSync as
|
|
77376
|
-
import { dirname as
|
|
77476
|
+
import { chmodSync as chmodSync2, existsSync as existsSync39, mkdirSync as mkdirSync12, readFileSync as readFileSync33, renameSync as renameSync4, unlinkSync as unlinkSync6, writeFileSync as writeFileSync10 } from "fs";
|
|
77477
|
+
import { dirname as dirname15, join as join41 } from "path";
|
|
77377
77478
|
var STORAGE_FILE_NAME = "mcp-oauth.json";
|
|
77378
77479
|
function getMcpOauthStoragePath() {
|
|
77379
|
-
return
|
|
77480
|
+
return join41(getOpenCodeConfigDir({ binary: "opencode" }), STORAGE_FILE_NAME);
|
|
77380
77481
|
}
|
|
77381
77482
|
function normalizeHost(serverHost) {
|
|
77382
77483
|
let host = serverHost.trim();
|
|
@@ -77413,11 +77514,11 @@ function buildKey(serverHost, resource) {
|
|
|
77413
77514
|
}
|
|
77414
77515
|
function readStore() {
|
|
77415
77516
|
const filePath = getMcpOauthStoragePath();
|
|
77416
|
-
if (!
|
|
77517
|
+
if (!existsSync39(filePath)) {
|
|
77417
77518
|
return null;
|
|
77418
77519
|
}
|
|
77419
77520
|
try {
|
|
77420
|
-
const content =
|
|
77521
|
+
const content = readFileSync33(filePath, "utf-8");
|
|
77421
77522
|
return JSON.parse(content);
|
|
77422
77523
|
} catch {
|
|
77423
77524
|
return null;
|
|
@@ -77426,8 +77527,8 @@ function readStore() {
|
|
|
77426
77527
|
function writeStore(store2) {
|
|
77427
77528
|
const filePath = getMcpOauthStoragePath();
|
|
77428
77529
|
try {
|
|
77429
|
-
const dir =
|
|
77430
|
-
if (!
|
|
77530
|
+
const dir = dirname15(filePath);
|
|
77531
|
+
if (!existsSync39(dir)) {
|
|
77431
77532
|
mkdirSync12(dir, { recursive: true });
|
|
77432
77533
|
}
|
|
77433
77534
|
const tempPath = `${filePath}.tmp.${Date.now()}`;
|
|
@@ -77464,7 +77565,7 @@ function deleteToken(serverHost, resource) {
|
|
|
77464
77565
|
if (Object.keys(store2).length === 0) {
|
|
77465
77566
|
try {
|
|
77466
77567
|
const filePath = getMcpOauthStoragePath();
|
|
77467
|
-
if (
|
|
77568
|
+
if (existsSync39(filePath)) {
|
|
77468
77569
|
unlinkSync6(filePath);
|
|
77469
77570
|
}
|
|
77470
77571
|
return true;
|
|
@@ -77684,7 +77785,7 @@ function buildAuthorizationUrl(authorizationEndpoint, options) {
|
|
|
77684
77785
|
}
|
|
77685
77786
|
var CALLBACK_TIMEOUT_MS = 5 * 60 * 1000;
|
|
77686
77787
|
function startCallbackServer(port) {
|
|
77687
|
-
return new Promise((
|
|
77788
|
+
return new Promise((resolve4, reject) => {
|
|
77688
77789
|
let timeoutId;
|
|
77689
77790
|
const server2 = createServer((request, response) => {
|
|
77690
77791
|
clearTimeout(timeoutId);
|
|
@@ -77710,7 +77811,7 @@ function startCallbackServer(port) {
|
|
|
77710
77811
|
response.writeHead(200, { "content-type": "text/html" });
|
|
77711
77812
|
response.end("<html><body><h1>Authorization successful. You can close this tab.</h1></body></html>");
|
|
77712
77813
|
server2.close();
|
|
77713
|
-
|
|
77814
|
+
resolve4({ code, state: state2 });
|
|
77714
77815
|
});
|
|
77715
77816
|
timeoutId = setTimeout(() => {
|
|
77716
77817
|
server2.close();
|