summaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authorHank Stoever <[email protected]>2026-02-05 18:10:35 -0800
committerGitHub <[email protected]>2026-02-05 20:10:35 -0600
commit229cdafcc43ef53611a12dc2e8137575669e8706 (patch)
tree6d25296ec68975c483b79126d2ba9887358bf723 /packages
parent154d0ebf536c8bcb08603db2f66315a3dcd4b987 (diff)
downloadopencode-229cdafcc43ef53611a12dc2e8137575669e8706.tar.gz
opencode-229cdafcc43ef53611a12dc2e8137575669e8706.zip
fix(config): handle $ character with {file:} pattern (#12390)
Co-authored-by: Hank Stoever <[email protected]>
Diffstat (limited to 'packages')
-rw-r--r--packages/opencode/src/config/config.ts2
-rw-r--r--packages/opencode/test/config/config.test.ts19
2 files changed, 20 insertions, 1 deletions
diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts
index ed1b15500..c56bd6c78 100644
--- a/packages/opencode/src/config/config.ts
+++ b/packages/opencode/src/config/config.ts
@@ -1267,7 +1267,7 @@ export namespace Config {
})
).trim()
// escape newlines/quotes, strip outer quotes
- text = text.replace(match, JSON.stringify(fileContent).slice(1, -1))
+ text = text.replace(match, () => JSON.stringify(fileContent).slice(1, -1))
}
}
diff --git a/packages/opencode/test/config/config.test.ts b/packages/opencode/test/config/config.test.ts
index dee633110..91b87f649 100644
--- a/packages/opencode/test/config/config.test.ts
+++ b/packages/opencode/test/config/config.test.ts
@@ -193,6 +193,25 @@ test("handles file inclusion substitution", async () => {
})
})
+test("handles file inclusion with replacement tokens", async () => {
+ await using tmp = await tmpdir({
+ init: async (dir) => {
+ await Bun.write(path.join(dir, "included.md"), "const out = await Bun.$`echo hi`")
+ await writeConfig(dir, {
+ $schema: "https://opencode.ai/config.json",
+ theme: "{file:included.md}",
+ })
+ },
+ })
+ await Instance.provide({
+ directory: tmp.path,
+ fn: async () => {
+ const config = await Config.get()
+ expect(config.theme).toBe("const out = await Bun.$`echo hi`")
+ },
+ })
+})
+
test("validates config schema and throws on invalid fields", async () => {
await using tmp = await tmpdir({
init: async (dir) => {