feat(opencode): wire 29-point CLI lifecycle scripts, drift-C reconciler, and skill docs
This commit is contained in:
@@ -53,12 +53,12 @@ def resume_on_disk(s):
|
||||
name = s.get('name', '')
|
||||
cwd = (s.get('pane') or {}).get('cwd', '')
|
||||
agent = None
|
||||
for a in ('claude', 'agy', 'hermes', 'grok'):
|
||||
for a in ('claude', 'agy', 'hermes', 'grok', 'opencode'):
|
||||
if any(name.endswith(f'-{r}-{a}') for r in ('creator', 'planner', 'reviewer')) or name.endswith(f'-{a}'):
|
||||
agent = a
|
||||
break
|
||||
if not agent:
|
||||
for a in ('claude', 'agy', 'hermes', 'grok'):
|
||||
for a in ('claude', 'agy', 'hermes', 'grok', 'opencode'):
|
||||
if f"-{a}" in name or f"_{a}" in name:
|
||||
agent = a
|
||||
break
|
||||
@@ -97,6 +97,34 @@ def resume_on_disk(s):
|
||||
ws_slug = urllib.parse.quote(cwd, safe='')
|
||||
return 'yes' if os.path.exists(f"{home}/.grok/sessions/{ws_slug}/{u}/chat_history.jsonl") else 'MISSING'
|
||||
return 'no'
|
||||
if agent == 'opencode':
|
||||
u = s.get('opencode_session_id_own')
|
||||
if u:
|
||||
base_dir = f"{home}/.local/share/opencode"
|
||||
odb = None
|
||||
for cand in [f"{base_dir}/opencode.db", f"{base_dir}/storage.db"]:
|
||||
if os.path.exists(cand):
|
||||
odb = cand
|
||||
break
|
||||
if not odb and os.path.isdir(f"{base_dir}/project"):
|
||||
for root, _, files in os.walk(f"{base_dir}/project"):
|
||||
for f in files:
|
||||
if f.endswith(".db"):
|
||||
odb = os.path.join(root, f)
|
||||
break
|
||||
if odb:
|
||||
break
|
||||
if not odb or not os.path.exists(odb):
|
||||
return 'MISSING'
|
||||
try:
|
||||
import sqlite3
|
||||
conn = sqlite3.connect(odb)
|
||||
r = conn.execute("SELECT 1 FROM session WHERE id=?", (u,)).fetchone()
|
||||
conn.close()
|
||||
return 'yes' if r else 'MISSING'
|
||||
except Exception:
|
||||
return 'MISSING'
|
||||
return 'no'
|
||||
return '?'
|
||||
|
||||
|
||||
@@ -202,18 +230,79 @@ def resume_on_disk(s):
|
||||
# workspace-SCOPED check only — per-row own id, never a global identity (P0-C)
|
||||
name = s.get('name', '')
|
||||
cwd = (s.get('pane') or {}).get('cwd', '')
|
||||
if name.endswith('-creator-claude'):
|
||||
agent = None
|
||||
for a in ('claude', 'agy', 'hermes', 'grok', 'opencode'):
|
||||
if any(name.endswith(f'-{r}-{a}') for r in ('creator', 'planner', 'reviewer')) or name.endswith(f'-{a}'):
|
||||
agent = a
|
||||
break
|
||||
if not agent:
|
||||
for a in ('claude', 'agy', 'hermes', 'grok', 'opencode'):
|
||||
if f"-{a}" in name or f"_{a}" in name:
|
||||
agent = a
|
||||
break
|
||||
|
||||
if agent == 'claude':
|
||||
u = s.get('claude_session_id_own')
|
||||
if u:
|
||||
key = cwd.replace('/', '-').replace('_', '-')
|
||||
return 'yes' if os.path.exists(f"{claude_project_dir}/{key}/{u}.jsonl") else 'MISSING'
|
||||
key = cwd.replace('/', '-').replace('_', '-')
|
||||
return 'scan' if glob.glob(f"{claude_project_dir}/{key}/*.jsonl") else 'no'
|
||||
if name.endswith('-creator-agy'):
|
||||
if agent == 'agy':
|
||||
u = s.get('agy_conversation_id_own')
|
||||
if u:
|
||||
return 'yes' if os.path.exists(f"{home}/.gemini/antigravity-cli/conversations/{u}.db") else 'MISSING'
|
||||
return 'no'
|
||||
if agent == 'hermes':
|
||||
u = s.get('hermes_conversation_id_own')
|
||||
if u:
|
||||
hdb = f"{home}/.hermes/state.db"
|
||||
if not os.path.exists(hdb):
|
||||
return 'MISSING'
|
||||
try:
|
||||
import sqlite3
|
||||
conn = sqlite3.connect(hdb)
|
||||
r = conn.execute("SELECT 1 FROM sessions WHERE id=?", (u,)).fetchone()
|
||||
conn.close()
|
||||
return 'yes' if r else 'MISSING'
|
||||
except Exception:
|
||||
return 'MISSING'
|
||||
return 'no'
|
||||
if agent == 'grok':
|
||||
u = s.get('grok_session_id_own')
|
||||
if u:
|
||||
import urllib.parse
|
||||
ws_slug = urllib.parse.quote(cwd, safe='')
|
||||
return 'yes' if os.path.exists(f"{home}/.grok/sessions/{ws_slug}/{u}/chat_history.jsonl") else 'MISSING'
|
||||
return 'no'
|
||||
if agent == 'opencode':
|
||||
u = s.get('opencode_session_id_own')
|
||||
if u:
|
||||
base_dir = f"{home}/.local/share/opencode"
|
||||
odb = None
|
||||
for cand in [f"{base_dir}/opencode.db", f"{base_dir}/storage.db"]:
|
||||
if os.path.exists(cand):
|
||||
odb = cand
|
||||
break
|
||||
if not odb and os.path.isdir(f"{base_dir}/project"):
|
||||
for root, _, files in os.walk(f"{base_dir}/project"):
|
||||
for f in files:
|
||||
if f.endswith(".db"):
|
||||
odb = os.path.join(root, f)
|
||||
break
|
||||
if odb:
|
||||
break
|
||||
if not odb or not os.path.exists(odb):
|
||||
return 'MISSING'
|
||||
try:
|
||||
import sqlite3
|
||||
conn = sqlite3.connect(odb)
|
||||
r = conn.execute("SELECT 1 FROM session WHERE id=?", (u,)).fetchone()
|
||||
conn.close()
|
||||
return 'yes' if r else 'MISSING'
|
||||
except Exception:
|
||||
return 'MISSING'
|
||||
return 'no'
|
||||
return '?'
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user