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.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(opencode): preserve BOM when inserting permission
cyh0c731287df61
diff --git a/tests/test_ui_api.py b/tests/test_ui_api.pyindex 5c90f4e66..5ad30464b 100644--- a/tests/test_ui_api.py+++ b/tests/test_ui_api.py@@ -366,6 +366,31 @@ def test_setup_opencode_permission_updates_last_duplicate_permission_entry(monke}+def test_setup_opencode_permission_preserves_leading_bom_when_inserting_multiline_property(+ monkeypatch, tmp_path+):+ config_path = tmp_path / ".config" / "opencode" / "opencode.json"+ config_path.parent.mkdir(parents=True, exist_ok=True)+ config_path.write_text(+ "\ufeff{\n \"model\": \"openai/gpt-5\"\n}\n",+ encoding="utf-8",+ )++ monkeypatch.setattr(api.Path, "home", lambda: tmp_path)++ result = api.setup_opencode_permission()+ updated_text = config_path.read_text(encoding="utf-8")++ assert result["ok"] is True+ assert result["config_path"] == str(config_path)+ assert updated_text.startswith("\ufeff{\n")+ assert updated_text.count("\ufeff") == 1+ assert parse_jsonc_object(updated_text) == {+ "model": "openai/gpt-5",+ "permission": "allow",+ }++def test_setup_opencode_permission_skips_comment_only_file_and_uses_next_valid_path(monkeypatch, tmp_path):xdg_path = tmp_path / ".config" / "opencode" / "opencode.json"legacy_path = tmp_path / ".opencode" / "opencode.json"diff --git a/vibe/opencode_config.py b/vibe/opencode_config.pyindex abf281974..a3c6860d1 100644--- a/vibe/opencode_config.py+++ b/vibe/opencode_config.py@@ -252,6 +252,10 @@ def _detect_newline(source: str) -> str:return "\r\n" if "\r\n" in source else "\n"+def _indent_slice(source: str, line_start: int, token_start: int) -> str:+ return source[line_start:token_start].replace("\ufeff", "")++def _scan_jsonc_top_level_properties(source: str) -> tuple[int, int, list[_JsoncTopLevelProperty]]:root_start = 1 if source.startswith("\ufeff") else 0root_start = _skip_jsonc_whitespace_and_comments(source, root_start)@@ -319,12 +323,12 @@ def set_jsonc_top_level_string_property(source: str, key: str, value: str) -> stnewline = _detect_newline(source)root_line_start = _line_start(source, root_start)closing_line_start = _line_start(source, root_end)- root_indent = source[root_line_start:root_start]+ root_indent = _indent_slice(source, root_line_start, root_start)first_property_indent = Noneif properties:first_property = properties[0]first_property_line_start = _line_start(source, first_property.key_start)- candidate_indent = source[first_property_line_start:first_property.key_start]+ candidate_indent = _indent_slice(source, first_property_line_start, first_property.key_start)if candidate_indent.strip() == "":first_property_indent = candidate_indent