fix(opencode): Mac review of the Linux fixes - a clean db has no sidecars on Mac either, the placeholder needs its example, a home install must run, status and reconcile read the db read-only (Issue #60, PR #62)
- tests: macOS SQLite keeps -wal/-shm after the last close (persistent WAL); the `clean` state removes them after the checkpointing close - the 2.x placeholder pattern requires the quoted example, so a typed `Ask anything…` is read as a draft - auth_ok takes ~/.opencode/bin/opencode only as an executable file - status.sh and reconcile.sh (drift C) open opencode.db with _ro_connect Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VCgu9Fa9iT7TbJUSzdq4Ff
This commit is contained in:
1 parent
6a4e385a78
commit
6a37c0019b
4 files changed
+40
-7
No files matched your search
@@ -76,7 +76,8 @@ class OpenCodeAgentAdapter(BaseAgentAdapter):
|
||||
def input_placeholder_pattern(self) -> Optional[str]:
|
||||
# 2.x home screen: `Ask anything… "<example>"`, the example picked per
|
||||
# launch and cut without its closing quote in a narrow box (Issue #60).
|
||||
return r'Ask anything(?:…|\.\.\.)(?: "[^"]*"?)?'
|
||||
# The example is required: a bare `Ask anything…` is a typed draft.
|
||||
return r'Ask anything(?:…|\.\.\.) "[^"]*"?'
|
||||
|
||||
@property
|
||||
def input_rule_pattern(self) -> Optional[str]:
|
||||
@@ -318,7 +319,8 @@ class OpenCodeAgentAdapter(BaseAgentAdapter):
|
||||
# opencode 2.x needs no login: a fresh HOME runs a free default model
|
||||
# and local providers have no key, so the binary is the whole check.
|
||||
home = os.environ.get("HOME_DIR") or os.environ.get("HOME") or os.path.expanduser("~")
|
||||
return bool(shutil.which("opencode")) or os.path.exists(f"{home}/.opencode/bin/opencode")
|
||||
local = f"{home}/.opencode/bin/opencode"
|
||||
return bool(shutil.which("opencode")) or (os.path.isfile(local) and os.access(local, os.X_OK))
|
||||
|
||||
def discover(self, ctx: DiscoveryContext) -> list:
|
||||
db = self._resolve_db(ctx)
|
||||
|
||||
@@ -950,7 +950,9 @@ for s in d.get('herdr_sessions', []):
|
||||
|
||||
valid_candidates = []
|
||||
try:
|
||||
conn = sqlite3.connect(odb)
|
||||
# read-only: nothing is created or removed beside the agent's db (Issue #60)
|
||||
from lib_py.agents.adapters.opencode import _ro_connect
|
||||
conn = _ro_connect(odb)
|
||||
cursor = conn.cursor()
|
||||
# opencode 2.x keeps sessions in session_v2 (a migrated 1.x `session`
|
||||
# table is no longer written).
|
||||
|
||||
@@ -112,8 +112,9 @@ def resume_on_disk(s):
|
||||
if not odb or not os.path.exists(odb):
|
||||
return 'MISSING'
|
||||
try:
|
||||
import sqlite3
|
||||
conn = sqlite3.connect(odb)
|
||||
# read-only: nothing is created or removed beside the agent's db (Issue #60)
|
||||
from lib_py.agents.adapters.opencode import _ro_connect
|
||||
conn = _ro_connect(odb)
|
||||
r = conn.execute("SELECT 1 FROM session_v2 WHERE id=?", (u,)).fetchone() # opencode 2.x
|
||||
conn.close()
|
||||
return 'yes' if r else 'MISSING'
|
||||
@@ -312,8 +313,9 @@ def resume_on_disk(s):
|
||||
if not odb or not os.path.exists(odb):
|
||||
return 'MISSING'
|
||||
try:
|
||||
import sqlite3
|
||||
conn = sqlite3.connect(odb)
|
||||
# read-only: nothing is created or removed beside the agent's db (Issue #60)
|
||||
from lib_py.agents.adapters.opencode import _ro_connect
|
||||
conn = _ro_connect(odb)
|
||||
r = conn.execute("SELECT 1 FROM session_v2 WHERE id=?", (u,)).fetchone() # opencode 2.x
|
||||
conn.close()
|
||||
return 'yes' if r else 'MISSING'
|
||||
|
||||
Reference in new issue
Block a user