fix(agents): harden shell adapter bridge and address double-check review feedback

- create_session.sh: add explicit case fallback for delegate_agent (R1)
- lib_py.agents: add spawn-spec, resume-spec, exit-key argv CLI subcommands (R2)
- resume_session.sh, stop_session.sh: replace python string interpolation with safe argv subcommands (R2)
- stop_session.sh: dynamically iterate adapter.identity_cache_fields (R3)
- verify_session.py, workspace_uuid.py: remove dead imports (R9/N4)
- tests/test_a4_adapter_contract.py: add CLI bridge subcommand, clean-env PYTHONPATH safety, and fallback contract tests (R12/N1)
- SKILL.md, docs, logs: synchronize IMPROVEMENTS.md, LOG.md, and resolve_session_id wording (R8/R10/R11)
- promote verified peer review reports for cline (e7b9812b) and claude (31730364)
This commit is contained in:
2026-08-17 08:54:57 +09:00
parent 7708d3ade3
commit 5ed39f899b
14 changed files with 615 additions and 31 deletions
+34
View File
@@ -46,6 +46,40 @@ def main():
print(f"ERROR: {ex}", file=sys.stderr)
sys.exit(5)
elif cmd == 'spawn-spec':
agent_name = sys.argv[2] if len(sys.argv) > 2 else ''
binary = sys.argv[3] if len(sys.argv) > 3 else agent_name
uuid = sys.argv[4] if len(sys.argv) > 4 else ''
use_wrapper = (sys.argv[5].lower() in ('1', 'true', 'yes')) if len(sys.argv) > 5 else False
adapter = get_adapter(agent_name)
if not adapter:
sys.exit(1)
print(adapter.spawn_spec(binary, uuid, use_wrapper=use_wrapper))
sys.exit(0)
elif cmd == 'resume-spec':
agent_name = sys.argv[2] if len(sys.argv) > 2 else ''
binary = sys.argv[3] if len(sys.argv) > 3 else agent_name
uuid = sys.argv[4] if len(sys.argv) > 4 else ''
workspace = sys.argv[5] if len(sys.argv) > 5 else ''
adapter = get_adapter(agent_name)
if not adapter:
sys.exit(1)
from lib_py.agents.base import DiscoveryContext
ctx = DiscoveryContext(workspace, agent_name) if workspace else None
mat = adapter.verify_artifact(uuid, ctx) if (ctx and uuid) else False
print(adapter.resume_spec(binary, uuid, materialized=mat))
sys.exit(0)
elif cmd == 'exit-key':
agent_name = sys.argv[2] if len(sys.argv) > 2 else ''
adapter = get_adapter(agent_name)
if adapter:
print(adapter.exit_key)
sys.exit(0)
print('/exit')
sys.exit(0)
else:
print(f"ERROR: Unknown CLI command {cmd!r}", file=sys.stderr)
sys.exit(1)
-3
View File
@@ -79,11 +79,8 @@ def workspace_key(path):
p = path
return p.replace("/", "-").replace("_", "-")
from lib_py.paths import resolve_home
def verify_session_uuid(ws, agent, uuid, row=None, home_dir=None, claude_dir=None, mode="discover"):
import os, json, sqlite3
from lib_py.paths import resolve_home
from lib_py.agents.registry import get_adapter
from lib_py.agents.base import DiscoveryContext
+2 -2
View File
@@ -1,8 +1,8 @@
# workspace_uuid.py — workspace UUID discovery logic
# Extracted from lib.sh find_workspace_uuid PYEOF block
import os, sys, json, glob, sqlite3
from lib_py.verify_session import verify_session_uuid, workspace_key, mam_orchestrator_uuids, mam_row_own_uuid
import os, sys, json, sqlite3
from lib_py.verify_session import verify_session_uuid, mam_orchestrator_uuids, mam_row_own_uuid
OWN_KEY = {
'claude': 'claude_session_id_own',