Skip to content

Commit 597c2e8

Browse files
authored
Merge pull request #91 from atkrv/status-ide-detection
feat: show active pack, pack count, and IDE status in `peon status`
2 parents 43e1a37 + fb81bad commit 597c2e8

1 file changed

Lines changed: 71 additions & 5 deletions

File tree

peon.sh

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,79 @@ case "${1:-}" in
369369
status)
370370
[ -f "$PAUSED_FILE" ] && echo "peon-ping: paused" || echo "peon-ping: active"
371371
python3 -c "
372-
import json
372+
import json, os
373+
374+
config_path = '$CONFIG'
375+
peon_dir = '$PEON_DIR'
376+
377+
# --- Config ---
373378
try:
374-
c = json.load(open('$CONFIG'))
375-
dn = c.get('desktop_notifications', True)
376-
print('peon-ping: desktop notifications ' + ('on' if dn else 'off'))
379+
c = json.load(open(config_path))
377380
except:
378-
print('peon-ping: desktop notifications on')
381+
c = {}
382+
383+
dn = c.get('desktop_notifications', True)
384+
print('peon-ping: desktop notifications ' + ('on' if dn else 'off'))
385+
386+
# --- Active pack ---
387+
active = c.get('active_pack', 'peon')
388+
packs_dir = os.path.join(peon_dir, 'packs')
389+
display_name = active
390+
pack_count = 0
391+
if os.path.isdir(packs_dir):
392+
for d in os.listdir(packs_dir):
393+
dpath = os.path.join(packs_dir, d)
394+
if not os.path.isdir(dpath):
395+
continue
396+
has_manifest = (
397+
os.path.exists(os.path.join(dpath, 'openpeon.json')) or
398+
os.path.exists(os.path.join(dpath, 'manifest.json'))
399+
)
400+
if has_manifest:
401+
pack_count += 1
402+
if d == active:
403+
for mname in ('openpeon.json', 'manifest.json'):
404+
mpath = os.path.join(dpath, mname)
405+
if os.path.exists(mpath):
406+
try:
407+
display_name = json.load(open(mpath)).get('display_name', active)
408+
except:
409+
pass
410+
break
411+
print(f'peon-ping: active pack: {active} ({display_name})')
412+
print(f'peon-ping: {pack_count} pack(s) installed')
413+
414+
# --- IDE detection ---
415+
home = os.path.expanduser('~')
416+
claude_dir = os.environ.get('CLAUDE_CONFIG_DIR', os.path.join(home, '.claude'))
417+
xdg_config = os.environ.get('XDG_CONFIG_HOME', os.path.join(home, '.config'))
418+
opencode_dir = os.path.join(xdg_config, 'opencode')
419+
420+
ides = []
421+
422+
# Claude Code: check if hooks are registered
423+
claude_hooks_dir = os.path.join(claude_dir, 'hooks', 'peon-ping')
424+
if os.path.isdir(claude_dir):
425+
if os.path.exists(os.path.join(claude_hooks_dir, 'peon.sh')):
426+
ides.append(('Claude Code', claude_dir, 'installed'))
427+
else:
428+
ides.append(('Claude Code', claude_dir, 'detected (not set up)'))
429+
430+
# OpenCode: check if plugin is installed
431+
opencode_plugin = os.path.join(opencode_dir, 'plugins', 'peon-ping.ts')
432+
if os.path.isdir(opencode_dir):
433+
if os.path.exists(opencode_plugin):
434+
ides.append(('OpenCode', opencode_dir, 'installed'))
435+
else:
436+
ides.append(('OpenCode', opencode_dir, 'detected (not set up)'))
437+
438+
if ides:
439+
print('peon-ping: IDEs')
440+
for name, path, status in ides:
441+
marker = '[x]' if 'installed' == status else '[ ]'
442+
print(f' {marker} {name:12s} {path} ({status})')
443+
else:
444+
print('peon-ping: no supported IDEs detected')
379445
"
380446
exit 0 ;;
381447
notifications)

0 commit comments

Comments
 (0)