feat: config 加载支持 zmo.json/zmo.jsonc 文件名(优先于 opencode.*)

全局配置加载、globalConfigFile、项目/.opencode 目录、managed 目录
均加入 zmo.json/zmo.jsonc 查找,优先级高于 opencode.* 兼容名。
用户可直接用 ~/.config/zmo/zmo.jsonc 配置。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 20:46:49 +08:00
co-authored by Claude Opus 4.7
parent 52eb90e7c3
commit 6953fce7c6
+5 -3
View File
@@ -138,7 +138,7 @@ export class Service extends Context.Service<Service, Interface>()("@opencode/Co
export const use = serviceUse(Service) export const use = serviceUse(Service)
function globalConfigFile() { function globalConfigFile() {
const candidates = ["opencode.jsonc", "opencode.json", "config.json"].map((file) => const candidates = ["zmo.jsonc", "zmo.json", "opencode.jsonc", "opencode.json", "config.json"].map((file) =>
path.join(Global.Path.config, file), path.join(Global.Path.config, file),
) )
for (const file of candidates) { for (const file of candidates) {
@@ -250,6 +250,8 @@ export const layer = Layer.effect(
result = mergeConfig(result, yield* loadFile(path.join(Global.Path.config, "config.json"), env)) result = mergeConfig(result, yield* loadFile(path.join(Global.Path.config, "config.json"), env))
result = mergeConfig(result, yield* loadFile(path.join(Global.Path.config, "opencode.json"), env)) result = mergeConfig(result, yield* loadFile(path.join(Global.Path.config, "opencode.json"), env))
result = mergeConfig(result, yield* loadFile(path.join(Global.Path.config, "opencode.jsonc"), env)) result = mergeConfig(result, yield* loadFile(path.join(Global.Path.config, "opencode.jsonc"), env))
result = mergeConfig(result, yield* loadFile(path.join(Global.Path.config, "zmo.json"), env))
result = mergeConfig(result, yield* loadFile(path.join(Global.Path.config, "zmo.jsonc"), env))
const legacy = path.join(Global.Path.config, "config") const legacy = path.join(Global.Path.config, "config")
if (existsSync(legacy)) { if (existsSync(legacy)) {
@@ -414,7 +416,7 @@ export const layer = Layer.effect(
for (const dir of directories) { for (const dir of directories) {
if (dir.endsWith(".opencode") || dir === Flag.OPENCODE_CONFIG_DIR) { if (dir.endsWith(".opencode") || dir === Flag.OPENCODE_CONFIG_DIR) {
for (const file of ["opencode.json", "opencode.jsonc"]) { for (const file of ["zmo.json", "zmo.jsonc", "opencode.json", "opencode.jsonc"]) {
const source = path.join(dir, file) const source = path.join(dir, file)
log.debug(`loading config from ${source}`) log.debug(`loading config from ${source}`)
yield* merge(source, yield* loadFile(source, authEnv)) yield* merge(source, yield* loadFile(source, authEnv))
@@ -509,7 +511,7 @@ export const layer = Layer.effect(
const managedDir = ConfigManaged.managedConfigDir() const managedDir = ConfigManaged.managedConfigDir()
if (existsSync(managedDir)) { if (existsSync(managedDir)) {
for (const file of ["opencode.json", "opencode.jsonc"]) { for (const file of ["zmo.json", "zmo.jsonc", "opencode.json", "opencode.jsonc"]) {
const source = path.join(managedDir, file) const source = path.join(managedDir, file)
yield* merge(source, yield* loadFile(source), "global") yield* merge(source, yield* loadFile(source), "global")
} }