refactor(lib): extract large inline python blocks to lib_py package and optimize abstraction layer

This commit is contained in:
2026-08-13 22:57:11 +09:00
parent 29f3a338ce
commit e10db8966e
16 changed files with 1799 additions and 672 deletions
@@ -491,16 +491,40 @@ if herdr_confirmed:
workspace_root = os.path.abspath(os.path.join(os.path.dirname(yaml_path), '..'))
if os.path.exists(os.path.join(workspace_root, '.mam', f"purging-{name}")):
continue
if name.endswith('-creator-claude'):
agent = 'claude'
elif name.endswith('-creator-agy'):
agent = 'agy'
elif name.endswith('-creator-hermes'):
agent = 'hermes'
elif name.endswith('-creator-cline'):
agent = 'cline'
else:
agent = None
role = 'creator'
for r_name in ('creator', 'planner', 'reviewer'):
for a_name in ('claude', 'agy', 'hermes', 'cline'):
if name.endswith(f"-{r_name}-{a_name}"):
role = r_name
agent = a_name
break
if agent:
break
if not agent:
# Check MAM_MANAGED env marker from pane process environment if available
srv_opt = t.get('server', 'default')
pm_check = pane_meta(name, srv_opt)
if pm_check and pm_check.get('pid'):
try:
pid_val = pm_check['pid']
env_output = subprocess.check_output(['ps', 'eww', '-p', str(pid_val)], text=True, stderr=subprocess.DEVNULL)
for tok in env_output.split():
if tok.startswith('MAM_MANAGED='):
managed_path = tok.split('=', 1)[1]
if os.path.realpath(managed_path) == os.path.realpath(workspace_root):
for a_name in ('claude', 'agy', 'hermes', 'cline'):
if a_name in pm_check.get('cmd', '') or a_name in pm_check.get('cmd_full', ''):
agent = a_name
break
break
except Exception:
pass
if not agent:
continue
srv = t.get('server', 'default')
pm = pane_meta(name, srv)
if not pm:
@@ -528,6 +552,7 @@ if herdr_confirmed:
entry = {
'name': name,
'status': 'running',
'role': role,
'herdr_session_created_at': datetime.fromtimestamp(created_epoch, tz=timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ'),
'herdr_session_epoch': created_epoch,
'herdr_session': srv,