Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix: use correct OpenCode config path ~/.config/opencode/opencode.json

yh c366d8b8f72dc
diff --git a/README.md b/README.md
index 35b08efa0..86f1b3c00 100644
--- a/README.md
+++ b/README.md
@@ -197,7 +197,7 @@ You need at least one coding agent installed:
curl -fsSL https://opencode.ai/install | bash
```
-**Required:** Add to `~/.opencode/opencode.json` to skip permission prompts:
+**Required:** Add to `~/.config/opencode/opencode.json` to skip permission prompts:
```json
{
diff --git a/README_ZH.md b/README_ZH.md
index 79a50c6de..fef695030 100644
--- a/README_ZH.md
+++ b/README_ZH.md
@@ -197,7 +197,7 @@ vibe doctor # 诊断问题
curl -fsSL https://opencode.ai/install | bash
```
-**必须配置:** 在 `~/.opencode/opencode.json` 中添加以下配置:
+**必须配置:** 在 `~/.config/opencode/opencode.json` 中添加以下配置:
```json
{
diff --git a/ui/src/context/ApiContext.tsx b/ui/src/context/ApiContext.tsx
index 7daabc55f..29759d115 100644
--- a/ui/src/context/ApiContext.tsx
+++ b/ui/src/context/ApiContext.tsx
@@ -12,7 +12,7 @@ export type ApiContextType = {
slackManifest: () => Promise<{ ok: boolean; manifest?: string; manifest_compact?: string; error?: string }>;
doctor: () => Promise<any>;
opencodeOptions: (cwd: string) => Promise<any>;
- opencodeSetupPermission: () => Promise<{ ok: boolean; message: string; config_paths: string[] }>;
+ opencodeSetupPermission: () => Promise<{ ok: boolean; message: string; config_path: string }>;
getLogs: (lines?: number) => Promise<{ logs: LogEntry[]; total: number }>;
getVersion: () => Promise<VersionInfo>;
doUpgrade: () => Promise<UpgradeResult>;
diff --git a/vibe/api.py b/vibe/api.py
index bbb2fd7ef..be7dfc17c 100644
--- a/vibe/api.py
+++ b/vibe/api.py
@@ -435,57 +435,53 @@ def do_upgrade(auto_restart: bool = True) -> dict:
def setup_opencode_permission() -> dict:
- """Set OpenCode permission to 'allow' in config files.
+ """Set OpenCode permission to 'allow' in config file.
- Updates both ~/.opencode/opencode.json (OpenCode official) and
- ~/.config/opencode/opencode.json (XDG standard) to ensure compatibility.
+ Uses ~/.config/opencode/opencode.json as per OpenCode official documentation.
Returns:
- {"ok": bool, "message": str, "config_paths": list[str]}
+ {"ok": bool, "message": str, "config_path": str}
"""
from pathlib import Path
- paths_to_update = [
- Path.home() / ".opencode" / "opencode.json",
- Path.home() / ".config" / "opencode" / "opencode.json",
- ]
- updated_paths = []
- errors = []
+ config_path = Path.home() / ".config" / "opencode" / "opencode.json"
- for config_path in paths_to_update:
- try:
- config_path.parent.mkdir(parents=True, exist_ok=True)
-
- config = {}
- if config_path.exists():
- content = config_path.read_text(encoding="utf-8").strip()
- if content:
- config = json.loads(content)
- if not isinstance(config, dict):
- errors.append(f"{config_path}: not a JSON object")
- continue
-
- if config.get("permission") != "allow":
- config["permission"] = "allow"
- config_path.write_text(
- json.dumps(config, indent=2) + "\n", encoding="utf-8"
- )
+ try:
+ config_path.parent.mkdir(parents=True, exist_ok=True)
+
+ config = {}
+ if config_path.exists():
+ content = config_path.read_text(encoding="utf-8").strip()
+ if content:
+ config = json.loads(content)
+ if not isinstance(config, dict):
+ return {
+ "ok": False,
+ "message": "Config is not a JSON object",
+ "config_path": str(config_path),
+ }
+
+ if config.get("permission") == "allow":
+ return {
+ "ok": True,
+ "message": "Permission already set",
+ "config_path": str(config_path),
+ }
- updated_paths.append(str(config_path))
- except json.JSONDecodeError as e:
- errors.append(f"{config_path}: invalid JSON - {e}")
- except Exception as e:
- errors.append(f"{config_path}: {e}")
+ config["permission"] = "allow"
+ config_path.write_text(json.dumps(config, indent=2) + "\n", encoding="utf-8")
- if not updated_paths:
+ return {
+ "ok": True,
+ "message": "Permission set to 'allow'",
+ "config_path": str(config_path),
+ }
+ except json.JSONDecodeError as e:
return {
"ok": False,
- "message": f"Failed to update any config: {'; '.join(errors)}",
- "config_paths": [],
+ "message": f"Invalid JSON: {e}",
+ "config_path": str(config_path),
}
-
- message = f"Permission set in {len(updated_paths)} config(s)"
- if errors:
- message += f" (warnings: {'; '.join(errors)})"
-
- return {"ok": True, "message": message, "config_paths": updated_paths}
+ except Exception as e:
+ logger.error(f"Failed to setup OpenCode permission: {e}")
+ return {"ok": False, "message": str(e), "config_path": str(config_path)}