@hiai-gg/hiai-opencode 0.1.2 → 0.1.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/.env.example +14 -3
- package/AGENTS.md +111 -8
- package/ARCHITECTURE.md +6 -6
- package/README.md +145 -25
- package/assets/mcp/mempalace.mjs +47 -4
- package/assets/mcp/playwright.mjs +76 -0
- package/dist/config/defaults.d.ts +3 -0
- package/dist/config/platform-schema.d.ts +2 -0
- package/dist/index.js +220 -175
- package/dist/mcp/registry.d.ts +14 -0
- package/dist/mcp/types.d.ts +6 -0
- package/hiai-opencode.json +2 -2
- package/package.json +1 -1
- package/src/config/defaults.ts +5 -62
- package/src/config/loader.ts +4 -1
- package/src/config/platform-schema.ts +1 -0
- package/src/index.ts +1 -0
- package/src/mcp/index.ts +0 -33
- package/src/mcp/omo-mcp-index.ts +0 -5
- package/src/mcp/registry.ts +132 -0
- package/src/mcp/types.ts +11 -1
package/dist/index.js
CHANGED
|
@@ -114171,7 +114171,17 @@ var NotificationConfigSchema = exports_external.object({
|
|
|
114171
114171
|
force_enable: exports_external.boolean().optional()
|
|
114172
114172
|
});
|
|
114173
114173
|
// src/mcp/types.ts
|
|
114174
|
-
var McpNameSchema = exports_external.enum([
|
|
114174
|
+
var McpNameSchema = exports_external.enum([
|
|
114175
|
+
"playwright",
|
|
114176
|
+
"stitch",
|
|
114177
|
+
"sequential-thinking",
|
|
114178
|
+
"firecrawl",
|
|
114179
|
+
"rag",
|
|
114180
|
+
"context7",
|
|
114181
|
+
"mempalace",
|
|
114182
|
+
"websearch",
|
|
114183
|
+
"grep_app"
|
|
114184
|
+
]);
|
|
114175
114185
|
var AnyMcpNameSchema = exports_external.string().min(1);
|
|
114176
114186
|
|
|
114177
114187
|
// src/config/schema/ralph-loop.ts
|
|
@@ -120434,7 +120444,7 @@ import * as path6 from "path";
|
|
|
120434
120444
|
|
|
120435
120445
|
// src/config/loader.ts
|
|
120436
120446
|
import { existsSync as existsSync56, readFileSync as readFileSync42 } from "fs";
|
|
120437
|
-
import { join as
|
|
120447
|
+
import { join as join67 } from "path";
|
|
120438
120448
|
|
|
120439
120449
|
// src/config/platform-schema.ts
|
|
120440
120450
|
var AgentConfigSchema = exports_external.object({
|
|
@@ -120471,6 +120481,7 @@ var McpServerConfigSchema = exports_external.object({
|
|
|
120471
120481
|
enabled: exports_external.boolean().default(true),
|
|
120472
120482
|
type: exports_external.enum(["remote", "local"]).optional(),
|
|
120473
120483
|
url: exports_external.string().optional(),
|
|
120484
|
+
headers: exports_external.record(exports_external.string(), exports_external.string()).optional(),
|
|
120474
120485
|
command: exports_external.array(exports_external.string()).optional(),
|
|
120475
120486
|
timeout: exports_external.number().optional(),
|
|
120476
120487
|
environment: exports_external.record(exports_external.string(), exports_external.string()).optional()
|
|
@@ -120605,9 +120616,6 @@ var HiaiOpencodeConfigSchema = exports_external.object({
|
|
|
120605
120616
|
ollama: OllamaConfigSchema.optional()
|
|
120606
120617
|
});
|
|
120607
120618
|
|
|
120608
|
-
// src/config/defaults.ts
|
|
120609
|
-
import { join as join65 } from "path";
|
|
120610
|
-
|
|
120611
120619
|
// src/config/models.ts
|
|
120612
120620
|
var MODEL_PRESETS = {
|
|
120613
120621
|
fast: "openrouter/google/gemini-2.0-flash",
|
|
@@ -120621,19 +120629,111 @@ var MODEL_PRESETS = {
|
|
|
120621
120629
|
writing: "openrouter/kimi/kimi-latest"
|
|
120622
120630
|
};
|
|
120623
120631
|
|
|
120624
|
-
// src/
|
|
120632
|
+
// src/mcp/registry.ts
|
|
120633
|
+
import { join as join65 } from "path";
|
|
120625
120634
|
function resolveAssetScript(...segments) {
|
|
120626
120635
|
return join65(import.meta.dirname, "..", "assets", ...segments);
|
|
120627
120636
|
}
|
|
120628
120637
|
function createNpmPackageCommand(pkg, ...args) {
|
|
120629
120638
|
return ["node", resolveAssetScript("runtime", "npm-package-runner.mjs"), pkg, ...args];
|
|
120630
120639
|
}
|
|
120631
|
-
|
|
120632
|
-
|
|
120633
|
-
|
|
120640
|
+
var HIAI_MCP_REGISTRY = {
|
|
120641
|
+
playwright: {
|
|
120642
|
+
name: "playwright",
|
|
120643
|
+
enabledByDefault: true,
|
|
120644
|
+
install: "npm",
|
|
120645
|
+
optionalEnv: ["HIAI_PLAYWRIGHT_INSTALL_BROWSERS"],
|
|
120646
|
+
config: {
|
|
120647
|
+
enabled: true,
|
|
120648
|
+
command: ["node", resolveAssetScript("mcp", "playwright.mjs")],
|
|
120649
|
+
timeout: 600000
|
|
120650
|
+
}
|
|
120651
|
+
},
|
|
120652
|
+
stitch: {
|
|
120653
|
+
name: "stitch",
|
|
120654
|
+
enabledByDefault: true,
|
|
120655
|
+
install: "remote",
|
|
120656
|
+
requiredEnv: ["STITCH_AI_API_KEY"],
|
|
120657
|
+
config: {
|
|
120658
|
+
enabled: true,
|
|
120659
|
+
type: "remote",
|
|
120660
|
+
url: "https://stitch.googleapis.com/mcp",
|
|
120661
|
+
headers: { "X-Goog-Api-Key": "{env:STITCH_AI_API_KEY}" },
|
|
120662
|
+
timeout: 600000
|
|
120663
|
+
}
|
|
120664
|
+
},
|
|
120665
|
+
"sequential-thinking": {
|
|
120666
|
+
name: "sequential-thinking",
|
|
120667
|
+
enabledByDefault: true,
|
|
120668
|
+
install: "npm",
|
|
120669
|
+
config: {
|
|
120670
|
+
enabled: true,
|
|
120671
|
+
command: createNpmPackageCommand("@modelcontextprotocol/server-sequential-thinking"),
|
|
120672
|
+
timeout: 600000
|
|
120673
|
+
}
|
|
120674
|
+
},
|
|
120675
|
+
firecrawl: {
|
|
120676
|
+
name: "firecrawl",
|
|
120677
|
+
enabledByDefault: true,
|
|
120678
|
+
install: "npm",
|
|
120679
|
+
requiredEnv: ["FIRECRAWL_API_KEY"],
|
|
120680
|
+
config: {
|
|
120681
|
+
enabled: true,
|
|
120682
|
+
command: createNpmPackageCommand("firecrawl-mcp"),
|
|
120683
|
+
timeout: 600000,
|
|
120684
|
+
environment: { FIRECRAWL_API_KEY: "{env:FIRECRAWL_API_KEY}" }
|
|
120685
|
+
}
|
|
120686
|
+
},
|
|
120687
|
+
rag: {
|
|
120688
|
+
name: "rag",
|
|
120689
|
+
enabledByDefault: true,
|
|
120690
|
+
install: "user-service",
|
|
120691
|
+
optionalEnv: ["OPENCODE_RAG_URL"],
|
|
120692
|
+
config: {
|
|
120693
|
+
enabled: true,
|
|
120694
|
+
type: "local",
|
|
120695
|
+
command: ["node", resolveAssetScript("mcp", "rag.mjs")],
|
|
120696
|
+
environment: {
|
|
120697
|
+
OPENCODE_RAG_URL: "{env:OPENCODE_RAG_URL:-http://localhost:9002/tools/search}"
|
|
120698
|
+
},
|
|
120699
|
+
timeout: 600000
|
|
120700
|
+
}
|
|
120701
|
+
},
|
|
120702
|
+
context7: {
|
|
120703
|
+
name: "context7",
|
|
120704
|
+
enabledByDefault: true,
|
|
120705
|
+
install: "remote",
|
|
120706
|
+
optionalEnv: ["CONTEXT7_API_KEY"],
|
|
120707
|
+
config: {
|
|
120708
|
+
enabled: true,
|
|
120709
|
+
type: "remote",
|
|
120710
|
+
url: "https://mcp.context7.com/mcp",
|
|
120711
|
+
headers: { "X-API-KEY": "{env:CONTEXT7_API_KEY}" },
|
|
120712
|
+
timeout: 600000
|
|
120713
|
+
}
|
|
120714
|
+
},
|
|
120715
|
+
mempalace: {
|
|
120716
|
+
name: "mempalace",
|
|
120717
|
+
enabledByDefault: true,
|
|
120718
|
+
install: "python",
|
|
120719
|
+
optionalEnv: ["MEMPALACE_PYTHON", "MEMPALACE_PALACE_PATH", "HIAI_MCP_AUTO_INSTALL"],
|
|
120720
|
+
config: {
|
|
120721
|
+
enabled: true,
|
|
120722
|
+
type: "local",
|
|
120723
|
+
command: ["node", resolveAssetScript("mcp", "mempalace.mjs"), "--palace", "./.opencode/palace"],
|
|
120724
|
+
timeout: 600000
|
|
120725
|
+
}
|
|
120634
120726
|
}
|
|
120635
|
-
|
|
120727
|
+
};
|
|
120728
|
+
function createDefaultMcpConfig() {
|
|
120729
|
+
return Object.fromEntries(Object.entries(HIAI_MCP_REGISTRY).map(([name, entry]) => [
|
|
120730
|
+
name,
|
|
120731
|
+
{ ...entry.config, enabled: entry.enabledByDefault }
|
|
120732
|
+
]));
|
|
120636
120733
|
}
|
|
120734
|
+
|
|
120735
|
+
// src/config/defaults.ts
|
|
120736
|
+
import { join as join66 } from "path";
|
|
120637
120737
|
var defaultConfig = {
|
|
120638
120738
|
agents: {
|
|
120639
120739
|
bob: { model: MODEL_PRESETS.high },
|
|
@@ -120666,49 +120766,7 @@ var defaultConfig = {
|
|
|
120666
120766
|
"unspecified-high": { model: MODEL_PRESETS.high, variant: "max" }
|
|
120667
120767
|
},
|
|
120668
120768
|
categoryRequirements: {},
|
|
120669
|
-
mcp:
|
|
120670
|
-
playwright: {
|
|
120671
|
-
enabled: true,
|
|
120672
|
-
command: createNpmPackageCommand("@playwright/mcp@latest"),
|
|
120673
|
-
timeout: 600000
|
|
120674
|
-
},
|
|
120675
|
-
stitch: {
|
|
120676
|
-
enabled: true,
|
|
120677
|
-
type: "remote",
|
|
120678
|
-
url: "https://stitch.googleapis.com/mcp",
|
|
120679
|
-
headers: { "X-Goog-Api-Key": "{env:STITCH_AI_API_KEY}" },
|
|
120680
|
-
timeout: 600000
|
|
120681
|
-
},
|
|
120682
|
-
"sequential-thinking": {
|
|
120683
|
-
enabled: true,
|
|
120684
|
-
command: createUpstreamNpxCommand("@modelcontextprotocol/server-sequential-thinking"),
|
|
120685
|
-
timeout: 600000
|
|
120686
|
-
},
|
|
120687
|
-
firecrawl: {
|
|
120688
|
-
enabled: true,
|
|
120689
|
-
command: createUpstreamNpxCommand("firecrawl-mcp"),
|
|
120690
|
-
timeout: 600000,
|
|
120691
|
-
environment: { FIRECRAWL_API_KEY: "{env:FIRECRAWL_API_KEY}" }
|
|
120692
|
-
},
|
|
120693
|
-
rag: {
|
|
120694
|
-
enabled: true,
|
|
120695
|
-
type: "remote",
|
|
120696
|
-
url: "http://localhost:9002",
|
|
120697
|
-
timeout: 600000
|
|
120698
|
-
},
|
|
120699
|
-
context7: {
|
|
120700
|
-
enabled: true,
|
|
120701
|
-
type: "remote",
|
|
120702
|
-
url: "https://mcp.context7.com/mcp",
|
|
120703
|
-
headers: { "X-API-KEY": "{env:CONTEXT7_API_KEY}" },
|
|
120704
|
-
timeout: 600000
|
|
120705
|
-
},
|
|
120706
|
-
mempalace: {
|
|
120707
|
-
enabled: true,
|
|
120708
|
-
command: ["node", resolveAssetScript("mcp", "mempalace.mjs"), "--palace", "./.opencode/palace"],
|
|
120709
|
-
timeout: 600000
|
|
120710
|
-
}
|
|
120711
|
-
},
|
|
120769
|
+
mcp: createDefaultMcpConfig(),
|
|
120712
120770
|
lsp: {
|
|
120713
120771
|
typescript: {
|
|
120714
120772
|
command: ["typescript-language-server", "--stdio"],
|
|
@@ -120719,11 +120777,11 @@ var defaultConfig = {
|
|
|
120719
120777
|
extensions: [".svelte"]
|
|
120720
120778
|
},
|
|
120721
120779
|
eslint: {
|
|
120722
|
-
command:
|
|
120780
|
+
command: ["node", join66(import.meta.dirname, "..", "assets", "runtime", "npm-package-runner.mjs"), "eslint-lsp", "--stdio"],
|
|
120723
120781
|
extensions: [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs", ".svelte"]
|
|
120724
120782
|
},
|
|
120725
120783
|
bash: {
|
|
120726
|
-
command:
|
|
120784
|
+
command: ["node", join66(import.meta.dirname, "..", "assets", "runtime", "npm-package-runner.mjs"), "bash-language-server", "start"],
|
|
120727
120785
|
extensions: [".sh", ".bash"]
|
|
120728
120786
|
},
|
|
120729
120787
|
pyright: {
|
|
@@ -120796,7 +120854,7 @@ function deepMerge2(base, override) {
|
|
|
120796
120854
|
function findConfigFile(searchDirs) {
|
|
120797
120855
|
for (const dir of searchDirs) {
|
|
120798
120856
|
for (const filename of CONFIG_FILENAMES) {
|
|
120799
|
-
const candidate =
|
|
120857
|
+
const candidate = join67(dir, filename);
|
|
120800
120858
|
if (existsSync56(candidate))
|
|
120801
120859
|
return candidate;
|
|
120802
120860
|
}
|
|
@@ -120869,8 +120927,8 @@ function normalizeCompactLspConfig(rawConfig) {
|
|
|
120869
120927
|
function loadConfig(projectDir) {
|
|
120870
120928
|
const searchDirs = [
|
|
120871
120929
|
projectDir,
|
|
120872
|
-
|
|
120873
|
-
|
|
120930
|
+
join67(projectDir, ".opencode"),
|
|
120931
|
+
join67(process.env.HOME || "", ".config", "opencode")
|
|
120874
120932
|
];
|
|
120875
120933
|
const configPath = findConfigFile(searchDirs);
|
|
120876
120934
|
if (!configPath)
|
|
@@ -120883,17 +120941,20 @@ function loadConfig(projectDir) {
|
|
|
120883
120941
|
return deepMerge2(BASE_CONFIG, normalized);
|
|
120884
120942
|
}
|
|
120885
120943
|
function resolveEnvVars(value) {
|
|
120886
|
-
return value.replace(/\{env:([^}]+)\}/g, (_,
|
|
120944
|
+
return value.replace(/\{env:([^}]+)\}/g, (_, expression) => {
|
|
120945
|
+
const [key, fallback] = String(expression).split(":-", 2);
|
|
120946
|
+
return process.env[key] || fallback || "";
|
|
120947
|
+
});
|
|
120887
120948
|
}
|
|
120888
120949
|
// src/shared/migrate-legacy-config-file.ts
|
|
120889
120950
|
init_logger();
|
|
120890
120951
|
init_plugin_identity();
|
|
120891
120952
|
import { existsSync as existsSync57, readFileSync as readFileSync43, renameSync as renameSync3, rmSync as rmSync2 } from "fs";
|
|
120892
|
-
import { join as
|
|
120953
|
+
import { join as join68, dirname as dirname18, basename as basename9 } from "path";
|
|
120893
120954
|
function buildCanonicalPath(legacyPath) {
|
|
120894
120955
|
const dir = dirname18(legacyPath);
|
|
120895
120956
|
const ext = basename9(legacyPath).includes(".jsonc") ? ".jsonc" : ".json";
|
|
120896
|
-
return
|
|
120957
|
+
return join68(dir, `${CONFIG_BASENAME}${ext}`);
|
|
120897
120958
|
}
|
|
120898
120959
|
function archiveLegacyConfigFile(legacyPath) {
|
|
120899
120960
|
const backupPath = `${legacyPath}.bak`;
|
|
@@ -122454,7 +122515,7 @@ function createRuntimeFallbackHook(ctx, options) {
|
|
|
122454
122515
|
}
|
|
122455
122516
|
// src/hooks/write-existing-file-guard/hook.ts
|
|
122456
122517
|
import { existsSync as existsSync60, realpathSync as realpathSync6 } from "fs";
|
|
122457
|
-
import { basename as basename11, dirname as dirname20, isAbsolute as isAbsolute11, join as
|
|
122518
|
+
import { basename as basename11, dirname as dirname20, isAbsolute as isAbsolute11, join as join70, normalize as normalize2, relative as relative8, resolve as resolve14 } from "path";
|
|
122458
122519
|
|
|
122459
122520
|
// src/hooks/write-existing-file-guard/tool-execute-before-handler.ts
|
|
122460
122521
|
import { existsSync as existsSync59 } from "fs";
|
|
@@ -122629,7 +122690,7 @@ function toCanonicalPath2(absolutePath) {
|
|
|
122629
122690
|
} else {
|
|
122630
122691
|
const absoluteDir = dirname20(absolutePath);
|
|
122631
122692
|
const resolvedDir = existsSync60(absoluteDir) ? realpathSync6.native(absoluteDir) : absoluteDir;
|
|
122632
|
-
canonicalPath =
|
|
122693
|
+
canonicalPath = join70(resolvedDir, basename11(absolutePath));
|
|
122633
122694
|
}
|
|
122634
122695
|
return normalize2(canonicalPath);
|
|
122635
122696
|
}
|
|
@@ -123906,12 +123967,12 @@ init_plugin_identity();
|
|
|
123906
123967
|
|
|
123907
123968
|
// src/hooks/legacy-plugin-toast/auto-migrate.ts
|
|
123908
123969
|
import { existsSync as existsSync61, readFileSync as readFileSync45 } from "fs";
|
|
123909
|
-
import { join as
|
|
123970
|
+
import { join as join71 } from "path";
|
|
123910
123971
|
init_plugin_identity();
|
|
123911
123972
|
function detectOpenCodeConfigPath(overrideConfigDir) {
|
|
123912
123973
|
if (overrideConfigDir) {
|
|
123913
|
-
const jsoncPath =
|
|
123914
|
-
const jsonPath =
|
|
123974
|
+
const jsoncPath = join71(overrideConfigDir, "opencode.jsonc");
|
|
123975
|
+
const jsonPath = join71(overrideConfigDir, "opencode.json");
|
|
123915
123976
|
if (existsSync61(jsoncPath))
|
|
123916
123977
|
return jsoncPath;
|
|
123917
123978
|
if (existsSync61(jsonPath))
|
|
@@ -124457,7 +124518,7 @@ var DEFAULT_MAX_DIAGNOSTICS = 200;
|
|
|
124457
124518
|
var DEFAULT_MAX_DIRECTORY_FILES = 50;
|
|
124458
124519
|
// src/tools/lsp/server-config-loader.ts
|
|
124459
124520
|
import { existsSync as existsSync63, readFileSync as readFileSync47 } from "fs";
|
|
124460
|
-
import { join as
|
|
124521
|
+
import { join as join72 } from "path";
|
|
124461
124522
|
function loadJsonFile(path7) {
|
|
124462
124523
|
if (!existsSync63(path7))
|
|
124463
124524
|
return null;
|
|
@@ -124471,9 +124532,9 @@ function getConfigPaths2() {
|
|
|
124471
124532
|
const cwd = process.cwd();
|
|
124472
124533
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
124473
124534
|
return {
|
|
124474
|
-
project: detectPluginConfigFile(
|
|
124535
|
+
project: detectPluginConfigFile(join72(cwd, ".opencode")).path,
|
|
124475
124536
|
user: detectPluginConfigFile(configDir).path,
|
|
124476
|
-
opencode: detectConfigFile(
|
|
124537
|
+
opencode: detectConfigFile(join72(configDir, "opencode")).path
|
|
124477
124538
|
};
|
|
124478
124539
|
}
|
|
124479
124540
|
function loadAllConfigs() {
|
|
@@ -124543,19 +124604,19 @@ function getMergedServers() {
|
|
|
124543
124604
|
|
|
124544
124605
|
// src/tools/lsp/server-installation.ts
|
|
124545
124606
|
import { existsSync as existsSync64 } from "fs";
|
|
124546
|
-
import { delimiter, join as
|
|
124607
|
+
import { delimiter, join as join74 } from "path";
|
|
124547
124608
|
|
|
124548
124609
|
// src/tools/lsp/server-path-bases.ts
|
|
124549
|
-
import { join as
|
|
124610
|
+
import { join as join73 } from "path";
|
|
124550
124611
|
function getLspServerAdditionalPathBases(workingDirectory) {
|
|
124551
124612
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
124552
|
-
const dataDir =
|
|
124613
|
+
const dataDir = join73(getDataDir(), "opencode");
|
|
124553
124614
|
return [
|
|
124554
|
-
|
|
124555
|
-
|
|
124556
|
-
|
|
124557
|
-
|
|
124558
|
-
|
|
124615
|
+
join73(workingDirectory, "node_modules", ".bin"),
|
|
124616
|
+
join73(configDir, "bin"),
|
|
124617
|
+
join73(configDir, "node_modules", ".bin"),
|
|
124618
|
+
join73(dataDir, "bin"),
|
|
124619
|
+
join73(dataDir, "bin", "node_modules", ".bin")
|
|
124559
124620
|
];
|
|
124560
124621
|
}
|
|
124561
124622
|
|
|
@@ -124586,14 +124647,14 @@ function isServerInstalled(command) {
|
|
|
124586
124647
|
const paths = pathEnv.split(delimiter);
|
|
124587
124648
|
for (const p of paths) {
|
|
124588
124649
|
for (const suffix of exts) {
|
|
124589
|
-
if (existsSync64(
|
|
124650
|
+
if (existsSync64(join74(p, cmd + suffix))) {
|
|
124590
124651
|
return true;
|
|
124591
124652
|
}
|
|
124592
124653
|
}
|
|
124593
124654
|
}
|
|
124594
124655
|
for (const base of getLspServerAdditionalPathBases(process.cwd())) {
|
|
124595
124656
|
for (const suffix of exts) {
|
|
124596
|
-
if (existsSync64(
|
|
124657
|
+
if (existsSync64(join74(base, cmd + suffix))) {
|
|
124597
124658
|
return true;
|
|
124598
124659
|
}
|
|
124599
124660
|
}
|
|
@@ -125850,7 +125911,7 @@ import { resolve as resolve18 } from "path";
|
|
|
125850
125911
|
|
|
125851
125912
|
// src/tools/lsp/directory-diagnostics.ts
|
|
125852
125913
|
import { existsSync as existsSync67, lstatSync as lstatSync2, readdirSync as readdirSync19 } from "fs";
|
|
125853
|
-
import { extname as extname6, join as
|
|
125914
|
+
import { extname as extname6, join as join75, resolve as resolve17 } from "path";
|
|
125854
125915
|
var SKIP_DIRECTORIES = new Set(["node_modules", ".git", "dist", "build", ".next", "out"]);
|
|
125855
125916
|
function collectFilesWithExtension(dir, extension, maxFiles) {
|
|
125856
125917
|
const files = [];
|
|
@@ -125866,7 +125927,7 @@ function collectFilesWithExtension(dir, extension, maxFiles) {
|
|
|
125866
125927
|
for (const entry of entries) {
|
|
125867
125928
|
if (files.length >= maxFiles)
|
|
125868
125929
|
return;
|
|
125869
|
-
const fullPath =
|
|
125930
|
+
const fullPath = join75(currentDir, entry);
|
|
125870
125931
|
let stat;
|
|
125871
125932
|
try {
|
|
125872
125933
|
stat = lstatSync2(fullPath);
|
|
@@ -125969,7 +126030,7 @@ async function aggregateDiagnosticsForDirectory(directory, extension, severity,
|
|
|
125969
126030
|
|
|
125970
126031
|
// src/tools/lsp/infer-extension.ts
|
|
125971
126032
|
import { readdirSync as readdirSync20, lstatSync as lstatSync3 } from "fs";
|
|
125972
|
-
import { extname as extname7, join as
|
|
126033
|
+
import { extname as extname7, join as join76 } from "path";
|
|
125973
126034
|
var SKIP_DIRECTORIES2 = new Set(["node_modules", ".git", "dist", "build", ".next", "out"]);
|
|
125974
126035
|
var MAX_SCAN_ENTRIES = 500;
|
|
125975
126036
|
function inferExtensionFromDirectory(directory) {
|
|
@@ -125987,7 +126048,7 @@ function inferExtensionFromDirectory(directory) {
|
|
|
125987
126048
|
for (const entry of entries) {
|
|
125988
126049
|
if (scanned >= MAX_SCAN_ENTRIES)
|
|
125989
126050
|
return;
|
|
125990
|
-
const fullPath =
|
|
126051
|
+
const fullPath = join76(dir, entry);
|
|
125991
126052
|
let stat;
|
|
125992
126053
|
try {
|
|
125993
126054
|
stat = lstatSync3(fullPath);
|
|
@@ -126156,12 +126217,12 @@ var DEFAULT_MAX_MATCHES = 500;
|
|
|
126156
126217
|
|
|
126157
126218
|
// src/tools/ast-grep/sg-cli-path.ts
|
|
126158
126219
|
import { createRequire as createRequire4 } from "module";
|
|
126159
|
-
import { dirname as dirname21, join as
|
|
126220
|
+
import { dirname as dirname21, join as join78 } from "path";
|
|
126160
126221
|
import { existsSync as existsSync69, statSync as statSync9 } from "fs";
|
|
126161
126222
|
|
|
126162
126223
|
// src/tools/ast-grep/downloader.ts
|
|
126163
126224
|
import { existsSync as existsSync68 } from "fs";
|
|
126164
|
-
import { join as
|
|
126225
|
+
import { join as join77 } from "path";
|
|
126165
126226
|
import { homedir as homedir14 } from "os";
|
|
126166
126227
|
import { createRequire as createRequire3 } from "module";
|
|
126167
126228
|
init_logger();
|
|
@@ -126189,12 +126250,12 @@ var PLATFORM_MAP2 = {
|
|
|
126189
126250
|
function getCacheDir3() {
|
|
126190
126251
|
if (process.platform === "win32") {
|
|
126191
126252
|
const localAppData = process.env.LOCALAPPDATA || process.env.APPDATA;
|
|
126192
|
-
const base2 = localAppData ||
|
|
126193
|
-
return
|
|
126253
|
+
const base2 = localAppData || join77(homedir14(), "AppData", "Local");
|
|
126254
|
+
return join77(base2, CACHE_DIR_NAME, "bin");
|
|
126194
126255
|
}
|
|
126195
126256
|
const xdgCache = process.env.XDG_CACHE_HOME;
|
|
126196
|
-
const base = xdgCache ||
|
|
126197
|
-
return
|
|
126257
|
+
const base = xdgCache || join77(homedir14(), ".cache");
|
|
126258
|
+
return join77(base, CACHE_DIR_NAME, "bin");
|
|
126198
126259
|
}
|
|
126199
126260
|
function getBinaryName3() {
|
|
126200
126261
|
return process.platform === "win32" ? "sg.exe" : "sg";
|
|
@@ -126211,7 +126272,7 @@ async function downloadAstGrep(version3 = DEFAULT_VERSION) {
|
|
|
126211
126272
|
}
|
|
126212
126273
|
const cacheDir = getCacheDir3();
|
|
126213
126274
|
const binaryName = getBinaryName3();
|
|
126214
|
-
const binaryPath =
|
|
126275
|
+
const binaryPath = join77(cacheDir, binaryName);
|
|
126215
126276
|
if (existsSync68(binaryPath)) {
|
|
126216
126277
|
return binaryPath;
|
|
126217
126278
|
}
|
|
@@ -126220,7 +126281,7 @@ async function downloadAstGrep(version3 = DEFAULT_VERSION) {
|
|
|
126220
126281
|
const downloadUrl = `https://github.com/${REPO2}/releases/download/${version3}/${assetName}`;
|
|
126221
126282
|
log(`[${PUBLISHED_PACKAGE_NAME}] Downloading ast-grep binary...`);
|
|
126222
126283
|
try {
|
|
126223
|
-
const archivePath =
|
|
126284
|
+
const archivePath = join77(cacheDir, assetName);
|
|
126224
126285
|
ensureCacheDir(cacheDir);
|
|
126225
126286
|
await downloadArchive(downloadUrl, archivePath);
|
|
126226
126287
|
await extractZipArchive(archivePath, cacheDir);
|
|
@@ -126274,7 +126335,7 @@ function findSgCliPathSync() {
|
|
|
126274
126335
|
const require2 = createRequire4(import.meta.url);
|
|
126275
126336
|
const cliPackageJsonPath = require2.resolve("@ast-grep/cli/package.json");
|
|
126276
126337
|
const cliDirectory = dirname21(cliPackageJsonPath);
|
|
126277
|
-
const sgPath =
|
|
126338
|
+
const sgPath = join78(cliDirectory, binaryName);
|
|
126278
126339
|
if (existsSync69(sgPath) && isValidBinary(sgPath)) {
|
|
126279
126340
|
return sgPath;
|
|
126280
126341
|
}
|
|
@@ -126286,7 +126347,7 @@ function findSgCliPathSync() {
|
|
|
126286
126347
|
const packageJsonPath = require2.resolve(`${platformPackage}/package.json`);
|
|
126287
126348
|
const packageDirectory = dirname21(packageJsonPath);
|
|
126288
126349
|
const astGrepBinaryName = process.platform === "win32" ? "ast-grep.exe" : "ast-grep";
|
|
126289
|
-
const binaryPath =
|
|
126350
|
+
const binaryPath = join78(packageDirectory, astGrepBinaryName);
|
|
126290
126351
|
if (existsSync69(binaryPath) && isValidBinary(binaryPath)) {
|
|
126291
126352
|
return binaryPath;
|
|
126292
126353
|
}
|
|
@@ -126689,19 +126750,19 @@ var {spawn: spawn18 } = globalThis.Bun;
|
|
|
126689
126750
|
|
|
126690
126751
|
// src/tools/grep/constants.ts
|
|
126691
126752
|
import { existsSync as existsSync73 } from "fs";
|
|
126692
|
-
import { join as
|
|
126753
|
+
import { join as join80, dirname as dirname22 } from "path";
|
|
126693
126754
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
126694
126755
|
|
|
126695
126756
|
// src/tools/grep/downloader.ts
|
|
126696
126757
|
import { existsSync as existsSync72, readdirSync as readdirSync21 } from "fs";
|
|
126697
|
-
import { join as
|
|
126758
|
+
import { join as join79 } from "path";
|
|
126698
126759
|
init_plugin_identity();
|
|
126699
126760
|
function findFileRecursive(dir, filename) {
|
|
126700
126761
|
try {
|
|
126701
126762
|
const entries = readdirSync21(dir, { withFileTypes: true, recursive: true });
|
|
126702
126763
|
for (const entry of entries) {
|
|
126703
126764
|
if (entry.isFile() && entry.name === filename) {
|
|
126704
|
-
return
|
|
126765
|
+
return join79(entry.parentPath ?? dir, entry.name);
|
|
126705
126766
|
}
|
|
126706
126767
|
}
|
|
126707
126768
|
} catch {
|
|
@@ -126722,11 +126783,11 @@ function getPlatformKey() {
|
|
|
126722
126783
|
}
|
|
126723
126784
|
function getInstallDir() {
|
|
126724
126785
|
const homeDir = process.env.HOME || process.env.USERPROFILE || ".";
|
|
126725
|
-
return
|
|
126786
|
+
return join79(homeDir, ".cache", CACHE_DIR_NAME, "bin");
|
|
126726
126787
|
}
|
|
126727
126788
|
function getRgPath() {
|
|
126728
126789
|
const isWindows2 = process.platform === "win32";
|
|
126729
|
-
return
|
|
126790
|
+
return join79(getInstallDir(), isWindows2 ? "rg.exe" : "rg");
|
|
126730
126791
|
}
|
|
126731
126792
|
async function extractTarGz2(archivePath, destDir) {
|
|
126732
126793
|
const platformKey = getPlatformKey();
|
|
@@ -126743,7 +126804,7 @@ async function extractZip2(archivePath, destDir) {
|
|
|
126743
126804
|
const binaryName = process.platform === "win32" ? "rg.exe" : "rg";
|
|
126744
126805
|
const foundPath = findFileRecursive(destDir, binaryName);
|
|
126745
126806
|
if (foundPath) {
|
|
126746
|
-
const destPath =
|
|
126807
|
+
const destPath = join79(destDir, binaryName);
|
|
126747
126808
|
if (foundPath !== destPath) {
|
|
126748
126809
|
const { renameSync: renameSync4 } = await import("fs");
|
|
126749
126810
|
renameSync4(foundPath, destPath);
|
|
@@ -126764,7 +126825,7 @@ async function downloadAndInstallRipgrep() {
|
|
|
126764
126825
|
ensureCacheDir(installDir);
|
|
126765
126826
|
const filename = `ripgrep-${RG_VERSION}-${config4.platform}.${config4.extension}`;
|
|
126766
126827
|
const url3 = `https://github.com/BurntSushi/ripgrep/releases/download/${RG_VERSION}/${filename}`;
|
|
126767
|
-
const archivePath =
|
|
126828
|
+
const archivePath = join79(installDir, filename);
|
|
126768
126829
|
try {
|
|
126769
126830
|
await downloadArchive(url3, archivePath);
|
|
126770
126831
|
if (config4.extension === "tar.gz") {
|
|
@@ -126811,11 +126872,11 @@ function getOpenCodeBundledRg() {
|
|
|
126811
126872
|
const isWindows2 = process.platform === "win32";
|
|
126812
126873
|
const rgName = isWindows2 ? "rg.exe" : "rg";
|
|
126813
126874
|
const candidates = [
|
|
126814
|
-
|
|
126815
|
-
|
|
126816
|
-
|
|
126817
|
-
|
|
126818
|
-
|
|
126875
|
+
join80(getDataDir(), "opencode", "bin", rgName),
|
|
126876
|
+
join80(execDir, rgName),
|
|
126877
|
+
join80(execDir, "bin", rgName),
|
|
126878
|
+
join80(execDir, "..", "bin", rgName),
|
|
126879
|
+
join80(execDir, "..", "libexec", rgName)
|
|
126819
126880
|
];
|
|
126820
126881
|
for (const candidate of candidates) {
|
|
126821
126882
|
if (existsSync73(candidate)) {
|
|
@@ -127945,9 +128006,9 @@ var skill = createSkillTool();
|
|
|
127945
128006
|
init_tool();
|
|
127946
128007
|
|
|
127947
128008
|
// src/tools/session-manager/constants.ts
|
|
127948
|
-
import { join as
|
|
127949
|
-
var TODO_DIR2 =
|
|
127950
|
-
var TRANSCRIPT_DIR2 =
|
|
128009
|
+
import { join as join81 } from "path";
|
|
128010
|
+
var TODO_DIR2 = join81(getClaudeConfigDir(), "todos");
|
|
128011
|
+
var TRANSCRIPT_DIR2 = join81(getClaudeConfigDir(), "transcripts");
|
|
127951
128012
|
var SESSION_LIST_DESCRIPTION = `List all OpenCode sessions with optional filtering.
|
|
127952
128013
|
|
|
127953
128014
|
Returns a list of available session IDs with metadata including message count, date range, and agents used.
|
|
@@ -128022,7 +128083,7 @@ Has Transcript: Yes (234 entries)`;
|
|
|
128022
128083
|
// src/tools/session-manager/file-storage.ts
|
|
128023
128084
|
import { existsSync as existsSync74 } from "fs";
|
|
128024
128085
|
import { readdir, readFile } from "fs/promises";
|
|
128025
|
-
import { join as
|
|
128086
|
+
import { join as join82 } from "path";
|
|
128026
128087
|
async function getFileMainSessions(directory) {
|
|
128027
128088
|
if (!existsSync74(SESSION_STORAGE))
|
|
128028
128089
|
return [];
|
|
@@ -128032,13 +128093,13 @@ async function getFileMainSessions(directory) {
|
|
|
128032
128093
|
for (const projectDir of projectDirs) {
|
|
128033
128094
|
if (!projectDir.isDirectory())
|
|
128034
128095
|
continue;
|
|
128035
|
-
const projectPath =
|
|
128096
|
+
const projectPath = join82(SESSION_STORAGE, projectDir.name);
|
|
128036
128097
|
const sessionFiles = await readdir(projectPath);
|
|
128037
128098
|
for (const file3 of sessionFiles) {
|
|
128038
128099
|
if (!file3.endsWith(".json"))
|
|
128039
128100
|
continue;
|
|
128040
128101
|
try {
|
|
128041
|
-
const content = await readFile(
|
|
128102
|
+
const content = await readFile(join82(projectPath, file3), "utf-8");
|
|
128042
128103
|
const meta3 = JSON.parse(content);
|
|
128043
128104
|
if (meta3.parentID)
|
|
128044
128105
|
continue;
|
|
@@ -128065,7 +128126,7 @@ async function getFileAllSessions() {
|
|
|
128065
128126
|
for (const entry of entries) {
|
|
128066
128127
|
if (!entry.isDirectory())
|
|
128067
128128
|
continue;
|
|
128068
|
-
const sessionPath =
|
|
128129
|
+
const sessionPath = join82(dir, entry.name);
|
|
128069
128130
|
const files = await readdir(sessionPath);
|
|
128070
128131
|
if (files.some((file3) => file3.endsWith(".json"))) {
|
|
128071
128132
|
sessions.push(entry.name);
|
|
@@ -128094,7 +128155,7 @@ async function getFileSessionMessages(sessionID) {
|
|
|
128094
128155
|
if (!file3.endsWith(".json"))
|
|
128095
128156
|
continue;
|
|
128096
128157
|
try {
|
|
128097
|
-
const content = await readFile(
|
|
128158
|
+
const content = await readFile(join82(messageDir, file3), "utf-8");
|
|
128098
128159
|
const meta3 = JSON.parse(content);
|
|
128099
128160
|
const parts = await readParts2(meta3.id);
|
|
128100
128161
|
messages.push({
|
|
@@ -128120,7 +128181,7 @@ async function getFileSessionMessages(sessionID) {
|
|
|
128120
128181
|
});
|
|
128121
128182
|
}
|
|
128122
128183
|
async function readParts2(messageID) {
|
|
128123
|
-
const partDir =
|
|
128184
|
+
const partDir = join82(PART_STORAGE, messageID);
|
|
128124
128185
|
if (!existsSync74(partDir))
|
|
128125
128186
|
return [];
|
|
128126
128187
|
const parts = [];
|
|
@@ -128130,7 +128191,7 @@ async function readParts2(messageID) {
|
|
|
128130
128191
|
if (!file3.endsWith(".json"))
|
|
128131
128192
|
continue;
|
|
128132
128193
|
try {
|
|
128133
|
-
const content = await readFile(
|
|
128194
|
+
const content = await readFile(join82(partDir, file3), "utf-8");
|
|
128134
128195
|
parts.push(JSON.parse(content));
|
|
128135
128196
|
} catch {
|
|
128136
128197
|
continue;
|
|
@@ -128149,7 +128210,7 @@ async function getFileSessionTodos(sessionID) {
|
|
|
128149
128210
|
const todoFiles = allFiles.filter((file3) => file3 === `${sessionID}.json`);
|
|
128150
128211
|
for (const file3 of todoFiles) {
|
|
128151
128212
|
try {
|
|
128152
|
-
const content = await readFile(
|
|
128213
|
+
const content = await readFile(join82(TODO_DIR2, file3), "utf-8");
|
|
128153
128214
|
const data = JSON.parse(content);
|
|
128154
128215
|
if (!Array.isArray(data))
|
|
128155
128216
|
continue;
|
|
@@ -128171,7 +128232,7 @@ async function getFileSessionTodos(sessionID) {
|
|
|
128171
128232
|
async function getFileSessionTranscript(sessionID) {
|
|
128172
128233
|
if (!existsSync74(TRANSCRIPT_DIR2))
|
|
128173
128234
|
return 0;
|
|
128174
|
-
const transcriptFile =
|
|
128235
|
+
const transcriptFile = join82(TRANSCRIPT_DIR2, `${sessionID}.jsonl`);
|
|
128175
128236
|
if (!existsSync74(transcriptFile))
|
|
128176
128237
|
return 0;
|
|
128177
128238
|
try {
|
|
@@ -130554,7 +130615,7 @@ async function resolveMultimodalLookerAgentMetadata(ctx) {
|
|
|
130554
130615
|
import * as childProcess from "child_process";
|
|
130555
130616
|
import { existsSync as existsSync75, mkdtempSync, readFileSync as readFileSync50, rmSync as rmSync3, unlinkSync as unlinkSync10, writeFileSync as writeFileSync18 } from "fs";
|
|
130556
130617
|
import { tmpdir as tmpdir7 } from "os";
|
|
130557
|
-
import { dirname as dirname25, join as
|
|
130618
|
+
import { dirname as dirname25, join as join83 } from "path";
|
|
130558
130619
|
var SUPPORTED_FORMATS = new Set([
|
|
130559
130620
|
"image/jpeg",
|
|
130560
130621
|
"image/png",
|
|
@@ -130595,8 +130656,8 @@ function convertImageToJpeg(inputPath, mimeType) {
|
|
|
130595
130656
|
if (!existsSync75(inputPath)) {
|
|
130596
130657
|
throw new Error(`File not found: ${inputPath}`);
|
|
130597
130658
|
}
|
|
130598
|
-
const tempDir = mkdtempSync(
|
|
130599
|
-
const outputPath =
|
|
130659
|
+
const tempDir = mkdtempSync(join83(tmpdir7(), "opencode-img-"));
|
|
130660
|
+
const outputPath = join83(tempDir, "converted.jpg");
|
|
130600
130661
|
log(`[image-converter] Converting ${mimeType} to JPEG: ${inputPath}`);
|
|
130601
130662
|
try {
|
|
130602
130663
|
if (process.platform === "darwin") {
|
|
@@ -130661,9 +130722,9 @@ function cleanupConvertedImage(filePath) {
|
|
|
130661
130722
|
}
|
|
130662
130723
|
}
|
|
130663
130724
|
function convertBase64ImageToJpeg(base64Data, mimeType) {
|
|
130664
|
-
const tempDir = mkdtempSync(
|
|
130725
|
+
const tempDir = mkdtempSync(join83(tmpdir7(), "opencode-b64-"));
|
|
130665
130726
|
const inputExt = mimeType.split("/")[1] || "bin";
|
|
130666
|
-
const inputPath =
|
|
130727
|
+
const inputPath = join83(tempDir, `input.${inputExt}`);
|
|
130667
130728
|
const tempFiles = [inputPath];
|
|
130668
130729
|
try {
|
|
130669
130730
|
const cleanBase64 = base64Data.replace(/^data:[^;]+;base64,/, "");
|
|
@@ -132861,7 +132922,7 @@ function applyFallbackEntrySettings(input) {
|
|
|
132861
132922
|
init_agent_display_names();
|
|
132862
132923
|
// src/features/claude-code-agent-loader/loader.ts
|
|
132863
132924
|
import { existsSync as existsSync78, readdirSync as readdirSync22 } from "fs";
|
|
132864
|
-
import { join as
|
|
132925
|
+
import { join as join84 } from "path";
|
|
132865
132926
|
|
|
132866
132927
|
// src/features/claude-code-agent-loader/agent-definitions-loader.ts
|
|
132867
132928
|
import { existsSync as existsSync77, readFileSync as readFileSync52 } from "fs";
|
|
@@ -132979,7 +133040,7 @@ function loadAgentsFromDir(agentsDir, scope) {
|
|
|
132979
133040
|
for (const entry of entries) {
|
|
132980
133041
|
if (!isMarkdownFile(entry))
|
|
132981
133042
|
continue;
|
|
132982
|
-
const agentPath =
|
|
133043
|
+
const agentPath = join84(agentsDir, entry.name);
|
|
132983
133044
|
const agent = parseMarkdownAgentFile(agentPath, scope);
|
|
132984
133045
|
if (agent) {
|
|
132985
133046
|
agents.push(agent);
|
|
@@ -132988,7 +133049,7 @@ function loadAgentsFromDir(agentsDir, scope) {
|
|
|
132988
133049
|
return agents;
|
|
132989
133050
|
}
|
|
132990
133051
|
function loadUserAgents() {
|
|
132991
|
-
const userAgentsDir =
|
|
133052
|
+
const userAgentsDir = join84(getClaudeConfigDir(), "agents");
|
|
132992
133053
|
const agents = loadAgentsFromDir(userAgentsDir, "user");
|
|
132993
133054
|
const result = Object.create(null);
|
|
132994
133055
|
for (const agent of agents) {
|
|
@@ -132997,7 +133058,7 @@ function loadUserAgents() {
|
|
|
132997
133058
|
return result;
|
|
132998
133059
|
}
|
|
132999
133060
|
function loadProjectAgents(directory) {
|
|
133000
|
-
const projectAgentsDir =
|
|
133061
|
+
const projectAgentsDir = join84(directory ?? process.cwd(), ".claude", "agents");
|
|
133001
133062
|
const agents = loadAgentsFromDir(projectAgentsDir, "project");
|
|
133002
133063
|
const result = Object.create(null);
|
|
133003
133064
|
for (const agent of agents) {
|
|
@@ -133007,7 +133068,7 @@ function loadProjectAgents(directory) {
|
|
|
133007
133068
|
}
|
|
133008
133069
|
function loadOpencodeGlobalAgents() {
|
|
133009
133070
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
133010
|
-
const opencodeAgentsDir =
|
|
133071
|
+
const opencodeAgentsDir = join84(configDir, "agents");
|
|
133011
133072
|
const agents = loadAgentsFromDir(opencodeAgentsDir, "opencode");
|
|
133012
133073
|
const result = Object.create(null);
|
|
133013
133074
|
for (const agent of agents) {
|
|
@@ -133016,7 +133077,7 @@ function loadOpencodeGlobalAgents() {
|
|
|
133016
133077
|
return result;
|
|
133017
133078
|
}
|
|
133018
133079
|
function loadOpencodeProjectAgents(directory) {
|
|
133019
|
-
const opencodeProjectDir =
|
|
133080
|
+
const opencodeProjectDir = join84(directory ?? process.cwd(), ".opencode", "agents");
|
|
133020
133081
|
const agents = loadAgentsFromDir(opencodeProjectDir, "opencode-project");
|
|
133021
133082
|
const result = Object.create(null);
|
|
133022
133083
|
for (const agent of agents) {
|
|
@@ -133559,7 +133620,7 @@ function createDelegateTask(options) {
|
|
|
133559
133620
|
init_constants();
|
|
133560
133621
|
// src/tools/task/task-create.ts
|
|
133561
133622
|
init_tool();
|
|
133562
|
-
import { join as
|
|
133623
|
+
import { join as join87 } from "path";
|
|
133563
133624
|
|
|
133564
133625
|
// src/tools/task/types.ts
|
|
133565
133626
|
var TaskStatusSchema = exports_external.enum(["pending", "in_progress", "completed", "deleted"]);
|
|
@@ -133613,18 +133674,18 @@ var TaskDeleteInputSchema = exports_external.object({
|
|
|
133613
133674
|
});
|
|
133614
133675
|
|
|
133615
133676
|
// src/features/claude-tasks/storage.ts
|
|
133616
|
-
import { join as
|
|
133677
|
+
import { join as join86, dirname as dirname27, basename as basename14, isAbsolute as isAbsolute12 } from "path";
|
|
133617
133678
|
import { existsSync as existsSync80, mkdirSync as mkdirSync16, readFileSync as readFileSync54, writeFileSync as writeFileSync19, renameSync as renameSync4, unlinkSync as unlinkSync11, readdirSync as readdirSync23 } from "fs";
|
|
133618
133679
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
133619
133680
|
function getTaskDir(config4 = {}) {
|
|
133620
133681
|
const tasksConfig = config4.bob?.tasks;
|
|
133621
133682
|
const storagePath = tasksConfig?.storage_path;
|
|
133622
133683
|
if (storagePath) {
|
|
133623
|
-
return isAbsolute12(storagePath) ? storagePath :
|
|
133684
|
+
return isAbsolute12(storagePath) ? storagePath : join86(process.cwd(), storagePath);
|
|
133624
133685
|
}
|
|
133625
133686
|
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
|
133626
133687
|
const listId = resolveTaskListId(config4);
|
|
133627
|
-
return
|
|
133688
|
+
return join86(configDir, "tasks", listId);
|
|
133628
133689
|
}
|
|
133629
133690
|
function sanitizePathSegment(value) {
|
|
133630
133691
|
return value.replace(/[^a-zA-Z0-9_-]/g, "-") || "default";
|
|
@@ -133683,7 +133744,7 @@ function generateTaskId() {
|
|
|
133683
133744
|
return `T-${randomUUID2()}`;
|
|
133684
133745
|
}
|
|
133685
133746
|
function acquireLock(dirPath) {
|
|
133686
|
-
const lockPath =
|
|
133747
|
+
const lockPath = join86(dirPath, ".lock");
|
|
133687
133748
|
const lockId = randomUUID2();
|
|
133688
133749
|
const createLock = (timestamp2) => {
|
|
133689
133750
|
writeFileSync19(lockPath, JSON.stringify({ id: lockId, timestamp: timestamp2 }), {
|
|
@@ -133896,7 +133957,7 @@ async function handleCreate(args, config4, ctx, context) {
|
|
|
133896
133957
|
threadID: context.sessionID
|
|
133897
133958
|
};
|
|
133898
133959
|
const validatedTask = TaskObjectSchema.parse(task);
|
|
133899
|
-
writeJsonAtomic(
|
|
133960
|
+
writeJsonAtomic(join87(taskDir, `${taskId}.json`), validatedTask);
|
|
133900
133961
|
await syncTaskTodoUpdate(ctx, validatedTask, context.sessionID);
|
|
133901
133962
|
return JSON.stringify({
|
|
133902
133963
|
task: {
|
|
@@ -133919,7 +133980,7 @@ async function handleCreate(args, config4, ctx, context) {
|
|
|
133919
133980
|
}
|
|
133920
133981
|
// src/tools/task/task-get.ts
|
|
133921
133982
|
init_tool();
|
|
133922
|
-
import { join as
|
|
133983
|
+
import { join as join88 } from "path";
|
|
133923
133984
|
var TASK_ID_PATTERN = /^T-[A-Za-z0-9-]+$/;
|
|
133924
133985
|
function parseTaskId(id) {
|
|
133925
133986
|
if (!TASK_ID_PATTERN.test(id))
|
|
@@ -133944,7 +134005,7 @@ Returns null if the task does not exist or the file is invalid.`,
|
|
|
133944
134005
|
return JSON.stringify({ error: "invalid_task_id" });
|
|
133945
134006
|
}
|
|
133946
134007
|
const taskDir = getTaskDir(config4);
|
|
133947
|
-
const taskPath =
|
|
134008
|
+
const taskPath = join88(taskDir, `${taskId}.json`);
|
|
133948
134009
|
const task = readJsonSafe(taskPath, TaskObjectSchema);
|
|
133949
134010
|
return JSON.stringify({ task: task ?? null });
|
|
133950
134011
|
} catch (error92) {
|
|
@@ -133958,7 +134019,7 @@ Returns null if the task does not exist or the file is invalid.`,
|
|
|
133958
134019
|
}
|
|
133959
134020
|
// src/tools/task/task-list.ts
|
|
133960
134021
|
init_tool();
|
|
133961
|
-
import { join as
|
|
134022
|
+
import { join as join89 } from "path";
|
|
133962
134023
|
import { existsSync as existsSync81, readdirSync as readdirSync24 } from "fs";
|
|
133963
134024
|
function createTaskList(config4) {
|
|
133964
134025
|
return tool({
|
|
@@ -133979,7 +134040,7 @@ Returns summary format: id, subject, status, owner, blockedBy (not full descript
|
|
|
133979
134040
|
}
|
|
133980
134041
|
const allTasks = [];
|
|
133981
134042
|
for (const fileId of files) {
|
|
133982
|
-
const task = readJsonSafe(
|
|
134043
|
+
const task = readJsonSafe(join89(taskDir, `${fileId}.json`), TaskObjectSchema);
|
|
133983
134044
|
if (task) {
|
|
133984
134045
|
allTasks.push(task);
|
|
133985
134046
|
}
|
|
@@ -134008,7 +134069,7 @@ Returns summary format: id, subject, status, owner, blockedBy (not full descript
|
|
|
134008
134069
|
}
|
|
134009
134070
|
// src/tools/task/task-update.ts
|
|
134010
134071
|
init_tool();
|
|
134011
|
-
import { join as
|
|
134072
|
+
import { join as join90 } from "path";
|
|
134012
134073
|
var TASK_ID_PATTERN2 = /^T-[A-Za-z0-9-]+$/;
|
|
134013
134074
|
function parseTaskId2(id) {
|
|
134014
134075
|
if (!TASK_ID_PATTERN2.test(id))
|
|
@@ -134056,7 +134117,7 @@ async function handleUpdate(args, config4, ctx, context) {
|
|
|
134056
134117
|
return JSON.stringify({ error: "task_lock_unavailable" });
|
|
134057
134118
|
}
|
|
134058
134119
|
try {
|
|
134059
|
-
const taskPath =
|
|
134120
|
+
const taskPath = join90(taskDir, `${taskId}.json`);
|
|
134060
134121
|
const task = readJsonSafe(taskPath, TaskObjectSchema);
|
|
134061
134122
|
if (!task) {
|
|
134062
134123
|
return JSON.stringify({ error: "task_not_found" });
|
|
@@ -134926,7 +134987,7 @@ Diff.prototype = {
|
|
|
134926
134987
|
tokenize: function tokenize(value) {
|
|
134927
134988
|
return Array.from(value);
|
|
134928
134989
|
},
|
|
134929
|
-
join: function
|
|
134990
|
+
join: function join91(chars) {
|
|
134930
134991
|
return chars.join("");
|
|
134931
134992
|
},
|
|
134932
134993
|
postProcess: function postProcess(changeObjects) {
|
|
@@ -137187,7 +137248,7 @@ function unregisterManagerForCleanup(manager) {
|
|
|
137187
137248
|
|
|
137188
137249
|
// src/features/background-agent/compaction-aware-message-resolver.ts
|
|
137189
137250
|
import { readdirSync as readdirSync25, readFileSync as readFileSync55 } from "fs";
|
|
137190
|
-
import { join as
|
|
137251
|
+
import { join as join92 } from "path";
|
|
137191
137252
|
function hasFullAgentAndModel(message) {
|
|
137192
137253
|
return !!message.agent && !isCompactionAgent(message.agent) && !!message.model?.providerID && !!message.model?.modelID;
|
|
137193
137254
|
}
|
|
@@ -137266,7 +137327,7 @@ function findNearestMessageExcludingCompaction(messageDir, sessionID) {
|
|
|
137266
137327
|
const messages = [];
|
|
137267
137328
|
for (const file3 of files) {
|
|
137268
137329
|
try {
|
|
137269
|
-
const content = readFileSync55(
|
|
137330
|
+
const content = readFileSync55(join92(messageDir, file3), "utf-8");
|
|
137270
137331
|
const parsed = JSON.parse(content);
|
|
137271
137332
|
if (hasCompactionPartInStorage(parsed.id) || isCompactionAgent(parsed.agent)) {
|
|
137272
137333
|
continue;
|
|
@@ -137356,7 +137417,7 @@ function handleSessionIdleBackgroundEvent(args) {
|
|
|
137356
137417
|
}
|
|
137357
137418
|
|
|
137358
137419
|
// src/features/background-agent/manager.ts
|
|
137359
|
-
import { join as
|
|
137420
|
+
import { join as join93 } from "path";
|
|
137360
137421
|
|
|
137361
137422
|
// src/features/background-agent/task-poller.ts
|
|
137362
137423
|
init_plugin_identity();
|
|
@@ -139032,7 +139093,7 @@ ${originalText}`;
|
|
|
139032
139093
|
parentSessionID: task.parentSessionID
|
|
139033
139094
|
});
|
|
139034
139095
|
}
|
|
139035
|
-
const messageDir =
|
|
139096
|
+
const messageDir = join93(MESSAGE_STORAGE, task.parentSessionID);
|
|
139036
139097
|
const currentMessage = messageDir ? findNearestMessageExcludingCompaction(messageDir, task.parentSessionID) : null;
|
|
139037
139098
|
agent = currentMessage?.agent ?? task.parentAgent;
|
|
139038
139099
|
model = currentMessage?.model?.providerID && currentMessage?.model?.modelID ? { providerID: currentMessage.model.providerID, modelID: currentMessage.model.modelID } : undefined;
|
|
@@ -139364,10 +139425,10 @@ ${originalText}`;
|
|
|
139364
139425
|
}
|
|
139365
139426
|
// src/features/mcp-oauth/storage.ts
|
|
139366
139427
|
import { chmodSync as chmodSync2, existsSync as existsSync82, mkdirSync as mkdirSync17, readFileSync as readFileSync56, renameSync as renameSync5, unlinkSync as unlinkSync12, writeFileSync as writeFileSync20 } from "fs";
|
|
139367
|
-
import { dirname as dirname28, join as
|
|
139428
|
+
import { dirname as dirname28, join as join94 } from "path";
|
|
139368
139429
|
var STORAGE_FILE_NAME = "mcp-oauth.json";
|
|
139369
139430
|
function getMcpOauthStoragePath() {
|
|
139370
|
-
return
|
|
139431
|
+
return join94(getOpenCodeConfigDir({ binary: "opencode" }), STORAGE_FILE_NAME);
|
|
139371
139432
|
}
|
|
139372
139433
|
function normalizeHost(serverHost) {
|
|
139373
139434
|
let host = serverHost.trim();
|
|
@@ -146066,7 +146127,7 @@ var SESSION_TIMEOUT_MS3 = 10 * 60 * 1000;
|
|
|
146066
146127
|
var MIN_STABILITY_TIME_MS4 = 10 * 1000;
|
|
146067
146128
|
// src/features/claude-code-mcp-loader/loader.ts
|
|
146068
146129
|
import { existsSync as existsSync83, readFileSync as readFileSync57 } from "fs";
|
|
146069
|
-
import { join as
|
|
146130
|
+
import { join as join95 } from "path";
|
|
146070
146131
|
import { homedir as homedir15 } from "os";
|
|
146071
146132
|
init_logger();
|
|
146072
146133
|
function getMcpConfigPaths() {
|
|
@@ -146074,10 +146135,10 @@ function getMcpConfigPaths() {
|
|
|
146074
146135
|
const cwd = process.cwd();
|
|
146075
146136
|
const explicitClaudeConfigDir = process.env.CLAUDE_CONFIG_DIR?.trim() || process.env.OPENCODE_CONFIG_DIR?.trim();
|
|
146076
146137
|
const candidates = [
|
|
146077
|
-
...explicitClaudeConfigDir ? [] : [{ path:
|
|
146078
|
-
{ path:
|
|
146079
|
-
{ path:
|
|
146080
|
-
{ path:
|
|
146138
|
+
...explicitClaudeConfigDir ? [] : [{ path: join95(homedir15(), ".claude.json"), scope: "user" }],
|
|
146139
|
+
{ path: join95(claudeConfigDir, ".mcp.json"), scope: "user" },
|
|
146140
|
+
{ path: join95(cwd, ".mcp.json"), scope: "project" },
|
|
146141
|
+
{ path: join95(cwd, ".claude", ".mcp.json"), scope: "local" }
|
|
146081
146142
|
];
|
|
146082
146143
|
const seen = new Set;
|
|
146083
146144
|
return candidates.filter(({ path: path9 }) => {
|
|
@@ -154407,7 +154468,7 @@ async function applyAgentConfig(params) {
|
|
|
154407
154468
|
init_agent_display_names();
|
|
154408
154469
|
// src/features/claude-code-command-loader/loader.ts
|
|
154409
154470
|
import { promises as fs14 } from "fs";
|
|
154410
|
-
import { join as
|
|
154471
|
+
import { join as join96, basename as basename15 } from "path";
|
|
154411
154472
|
init_logger();
|
|
154412
154473
|
async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix = "") {
|
|
154413
154474
|
try {
|
|
@@ -154438,7 +154499,7 @@ async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix
|
|
|
154438
154499
|
if (entry.isDirectory()) {
|
|
154439
154500
|
if (entry.name.startsWith("."))
|
|
154440
154501
|
continue;
|
|
154441
|
-
const subDirPath =
|
|
154502
|
+
const subDirPath = join96(commandsDir, entry.name);
|
|
154442
154503
|
const subPrefix = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
154443
154504
|
const subCommands = await loadCommandsFromDir(subDirPath, scope, visited, subPrefix);
|
|
154444
154505
|
commands2.push(...subCommands);
|
|
@@ -154446,7 +154507,7 @@ async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix
|
|
|
154446
154507
|
}
|
|
154447
154508
|
if (!isMarkdownFile(entry))
|
|
154448
154509
|
continue;
|
|
154449
|
-
const commandPath =
|
|
154510
|
+
const commandPath = join96(commandsDir, entry.name);
|
|
154450
154511
|
const baseCommandName = basename15(entry.name, ".md");
|
|
154451
154512
|
const commandName = prefix ? `${prefix}/${baseCommandName}` : baseCommandName;
|
|
154452
154513
|
try {
|
|
@@ -154505,12 +154566,12 @@ function commandsToRecord(commands2) {
|
|
|
154505
154566
|
return result;
|
|
154506
154567
|
}
|
|
154507
154568
|
async function loadUserCommands() {
|
|
154508
|
-
const userCommandsDir =
|
|
154569
|
+
const userCommandsDir = join96(getClaudeConfigDir(), "commands");
|
|
154509
154570
|
const commands2 = await loadCommandsFromDir(userCommandsDir, "user");
|
|
154510
154571
|
return commandsToRecord(commands2);
|
|
154511
154572
|
}
|
|
154512
154573
|
async function loadProjectCommands(directory) {
|
|
154513
|
-
const projectCommandsDir =
|
|
154574
|
+
const projectCommandsDir = join96(directory ?? process.cwd(), ".claude", "commands");
|
|
154514
154575
|
const commands2 = await loadCommandsFromDir(projectCommandsDir, "project");
|
|
154515
154576
|
return commandsToRecord(commands2);
|
|
154516
154577
|
}
|
|
@@ -154625,15 +154686,6 @@ function createWebsearchConfig(config4) {
|
|
|
154625
154686
|
}
|
|
154626
154687
|
var websearch = createWebsearchConfig();
|
|
154627
154688
|
|
|
154628
|
-
// src/mcp/context7.ts
|
|
154629
|
-
var context7 = {
|
|
154630
|
-
type: "remote",
|
|
154631
|
-
url: "https://mcp.context7.com/mcp",
|
|
154632
|
-
enabled: true,
|
|
154633
|
-
headers: process.env.CONTEXT7_API_KEY ? { Authorization: `Bearer ${process.env.CONTEXT7_API_KEY}` } : undefined,
|
|
154634
|
-
oauth: false
|
|
154635
|
-
};
|
|
154636
|
-
|
|
154637
154689
|
// src/mcp/grep-app.ts
|
|
154638
154690
|
var grep_app = {
|
|
154639
154691
|
type: "remote",
|
|
@@ -154651,19 +154703,11 @@ function createBuiltinMcps(disabledMcps = [], config4) {
|
|
|
154651
154703
|
mcps.websearch = websearchConfig;
|
|
154652
154704
|
}
|
|
154653
154705
|
}
|
|
154654
|
-
if (!disabledMcps.includes("context7")) {
|
|
154655
|
-
mcps.context7 = context7;
|
|
154656
|
-
}
|
|
154657
154706
|
if (!disabledMcps.includes("grep_app")) {
|
|
154658
154707
|
mcps.grep_app = grep_app;
|
|
154659
154708
|
}
|
|
154660
154709
|
return mcps;
|
|
154661
154710
|
}
|
|
154662
|
-
// src/mcp/index.ts
|
|
154663
|
-
import { join as join96 } from "path";
|
|
154664
|
-
var __dirname = "C:\\hiai\\hiai-opencode-public\\src\\mcp";
|
|
154665
|
-
var ASSETS_DIR = join96(import.meta.dirname || __dirname, "..", "assets", "mcp");
|
|
154666
|
-
|
|
154667
154711
|
// src/shared/runtime-plugin-config.ts
|
|
154668
154712
|
function mergeRecords(base, override) {
|
|
154669
154713
|
if (!base && !override)
|
|
@@ -159638,7 +159682,8 @@ function configureBundledBunPtyLibrary() {
|
|
|
159638
159682
|
const libraryName = process.platform === "win32" ? "rust_pty.dll" : process.platform === "darwin" ? process.arch === "arm64" ? "librust_pty_arm64.dylib" : "librust_pty.dylib" : process.arch === "arm64" ? "librust_pty_arm64.so" : "librust_pty.so";
|
|
159639
159683
|
const candidates = [
|
|
159640
159684
|
join104(import.meta.dirname, "..", "node_modules", "bun-pty", "rust-pty", "target", "release", libraryName),
|
|
159641
|
-
join104(import.meta.dirname, "..", "..", "bun-pty", "rust-pty", "target", "release", libraryName)
|
|
159685
|
+
join104(import.meta.dirname, "..", "..", "bun-pty", "rust-pty", "target", "release", libraryName),
|
|
159686
|
+
join104(import.meta.dirname, "..", "..", "..", "bun-pty", "rust-pty", "target", "release", libraryName)
|
|
159642
159687
|
];
|
|
159643
159688
|
const resolved = candidates.find((candidate) => existsSync90(candidate));
|
|
159644
159689
|
if (resolved) {
|