by adom
Registry-native cross-agent auto-update hook, claude-rc (the keeper for Claude Remote Control), and Claude's start-here: a managed block in ~/.claude/CLAUDE.md plus adom-context, a SessionStart printout of where the session runs, who is signed in and which machines are reachable. Keeps adom/core apps and skills current from wiki.adom.inc on every Claude Code and Codex prompt, and keeps `claude rc` alive so users can open AI threads on their container from the Claude mobile app or claude.ai/code.
master
Colby Knox
Publish 1.4.7
7d19532
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
"""Install/uninstall the start-here block and SessionStart hook into a throwaway HOME."""
import json
import os
from pathlib import Path
import subprocess
import tempfile
import unittest
PKG = Path(__file__).resolve().parents[1]
BEGIN = "<!-- adom/hook:begin"
END = "<!-- adom/hook:end -->"
class StartHereTest(unittest.TestCase):
def setUp(self):
self.temp = tempfile.TemporaryDirectory(prefix="adom-hook-start-here-")
self.addCleanup(self.temp.cleanup)
self.home = Path(self.temp.name)
# A fake crontab keeps install.sh off the real user's crontab (it is per-user, not per-HOME).
fakebin = self.home / "fakebin"
fakebin.mkdir()
(fakebin / "crontab").write_text("#!/bin/sh\n[ \"$1\" = -l ] && exit 1\ncat >/dev/null\n")
(fakebin / "crontab").chmod(0o755)
self.env = dict(os.environ, HOME=str(self.home), PATH=f"{fakebin}:/usr/bin:/bin",
ADOM_HOOK_NO_MODEL_DEFAULT="1")
self.claude_md = self.home / ".claude" / "CLAUDE.md"
def run_script(self, name):
p = subprocess.run(["bash", str(PKG / name)], env=self.env, capture_output=True,
text=True, timeout=60)
self.assertEqual(p.returncode, 0, p.stdout + p.stderr)
return p.stdout + p.stderr
def session_start_cmds(self):
d = json.loads((self.home / ".claude" / "settings.json").read_text())
return [h["command"] for g in d.get("hooks", {}).get("SessionStart", []) for h in g["hooks"]]
def test_fresh_install_writes_block_and_hook(self):
self.run_script("install.sh")
text = self.claude_md.read_text()
self.assertEqual(text.count(BEGIN), 1)
self.assertIn("# Adom: start here", text)
ctx = self.home / ".local" / "bin" / "adom-context"
self.assertTrue(os.access(ctx, os.X_OK))
self.assertEqual(self.session_start_cmds(), [f"{ctx} --hook"])
def test_reinstall_is_idempotent_and_keeps_user_text(self):
self.claude_md.parent.mkdir(parents=True)
self.claude_md.write_text("# My notes\nkeep me\n")
self.run_script("install.sh")
self.run_script("install.sh")
text = self.claude_md.read_text()
self.assertTrue(text.startswith("# My notes\nkeep me\n"))
self.assertEqual(text.count(BEGIN), 1)
self.assertEqual(len(self.session_start_cmds()), 1)
self.assertEqual((self.claude_md.parent / "CLAUDE.md.before-adom-hook").read_text(),
"# My notes\nkeep me\n")
def test_stale_block_is_replaced_in_place(self):
self.claude_md.parent.mkdir(parents=True)
self.claude_md.write_text(f"above\n{BEGIN} old -->\nold body\n{END}\nbelow\n")
self.run_script("install.sh")
text = self.claude_md.read_text()
self.assertNotIn("old body", text)
self.assertTrue(text.startswith("above\n" + BEGIN))
self.assertTrue(text.endswith(END + "\nbelow\n"))
def test_malformed_block_is_left_alone(self):
self.claude_md.parent.mkdir(parents=True)
self.claude_md.write_text(f"{BEGIN} -->\nno end marker\n")
out = self.run_script("install.sh")
self.assertIn("malformed", out)
self.assertEqual(self.claude_md.read_text(), f"{BEGIN} -->\nno end marker\n")
def test_opt_out_skips_block_and_hook(self):
(self.home / ".adom").mkdir()
(self.home / ".adom" / "no-start-here").touch()
self.run_script("install.sh")
self.assertFalse(self.claude_md.exists())
self.assertEqual(self.session_start_cmds(), [])
def test_uninstall_removes_only_the_block(self):
self.claude_md.parent.mkdir(parents=True)
self.claude_md.write_text("# My notes\n")
self.run_script("install.sh")
self.run_script("uninstall.sh")
self.assertEqual(self.claude_md.read_text(), "# My notes\n")
self.assertEqual(self.session_start_cmds(), [])
self.assertFalse((self.home / ".local" / "bin" / "adom-context").exists())
def test_skill_budget_set_only_if_absent(self):
settings = self.home / ".claude" / "settings.json"
self.run_script("install.sh")
self.assertEqual(json.loads(settings.read_text())["skillListingBudgetFraction"], 0.02)
d = json.loads(settings.read_text())
d["skillListingBudgetFraction"] = 0.05
settings.write_text(json.dumps(d))
self.run_script("install.sh")
self.assertEqual(json.loads(settings.read_text())["skillListingBudgetFraction"], 0.05)
def test_context_hook_never_fails_without_tools(self):
# No adom-wiki, adom-bridge or Hydrogen here: every probe reads as unknown.
p = subprocess.run(["python3", str(PKG / "adom-context"), "--hook"],
env=dict(self.env, PATH="/usr/bin:/bin", ADOM_HD_CONTROL_URL=""),
capture_output=True, text=True, timeout=10)
self.assertEqual(p.returncode, 0, p.stderr)
self.assertIn("- Where:", p.stdout)
self.assertIn("Adom sign-in: unknown", p.stdout)
def machines_line(self, targets):
# A stand-in adom-bridge that answers `targets` with the given rows.
fakebin = self.home / "bridgebin"
fakebin.mkdir(exist_ok=True)
(fakebin / "adom-bridge").write_text("#!/bin/sh\ncat <<'JSON'\n"
+ json.dumps({"status": "ok", "targets": targets}) + "\nJSON\n")
(fakebin / "adom-bridge").chmod(0o755)
p = subprocess.run(["python3", str(PKG / "adom-context")],
env=dict(self.env, PATH=f"{fakebin}:/usr/bin:/bin", ADOM_HD_CONTROL_URL=""),
capture_output=True, text=True, timeout=10)
self.assertEqual(p.returncode, 0, p.stderr)
return next(l for l in p.stdout.splitlines() if "Adom Bridge machines" in l)
def test_missing_reachable_is_not_offline(self):
# A 1.9.x CLI: no reachable field, only connectedAt (adom/hook#7).
line = self.machines_line([{"name": "mac", "os": "macOS", "connectedAt": "2026-12-04T10:00:00Z", "version": "1.9.234"}])
self.assertIn("mac (macOS, reachable)", line)
self.assertNotIn("offline", line)
def test_machine_states(self):
line = self.machines_line([
{"name": "a", "os": "Windows", "reachable": True},
{"name": "b", "os": "Windows", "reachable": False},
{"name": "c", "os": "Linux", "reachable": "mesh"},
{"name": "d", "os": "macOS", "connected": True},
{"name": "e", "os": "macOS"},
])
self.assertIn("a (Windows, reachable)", line)
self.assertIn("b (Windows, offline)", line)
self.assertIn("c (Linux, mesh, dials on demand)", line)
self.assertIn("d (macOS, reachable)", line)
self.assertIn("e (macOS, status unknown, check with `adom-bridge --target e status`)", line)
if __name__ == "__main__":
unittest.main()