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.
← Commit history
Publish 1.4.0
9 files changed
+534−33
README.md+16@@ -72,6 +72,22 @@ adom-wiki uninstall adom/hook Unwires the hook from both `~/.claude/settings.json` and `~/.codex/hooks.json`. +## Start here for Claude++Out of the box, Claude in an Adom workspace gets no orientation: the stock Claude Code+prompt, a long list of skills, and no idea whether it is on your PC or in the cloud. This+package gives it a starting point:++- a managed **start-here block** in `~/.claude/CLAUDE.md`: where it runs, the four CLIs,+ which skill to read for common tasks, and a few hard rules (never guess which machine to+ drive, look before taking over a screen, verify by looking). Your own text in that file is+ never touched.+- **`adom-context`**, printed at the start of every session: local Hydrogen workspace or+ cloud container, who is signed in, which of your machines are reachable, what is+ installed. Run it yourself any time.++Opt out with `touch ~/.adom/no-start-here` and reinstall.+ ## claude-rc: Remote Control, kept alive This package also installs `claude-rc`, which keeps Claude Code Remote Control (`claude
SKILL.md+31−7@@ -1,13 +1,13 @@ --- name: adom-hook description: >-- The two things adom wires into every Claude Code and Codex prompt: the registry-native- auto-update hook (keeps adom/core apps and skills current from wiki.adom.inc), and- claude-rc, which keeps Claude Remote Control alive so the user can open AI threads on- this container from their phone. Read when packages are behind or an update failed, and- when the user says claude rc, remote control, use my container from my phone, open a- thread from my phone, claude-rc status, or you see an "adom: Claude Remote Control" line- in your context.+ What adom wires into Claude Code and Codex: the registry-native auto-update hook (keeps+ adom/core apps and skills current from wiki.adom.inc); claude-rc, which keeps Claude+ Remote Control alive so the user can open AI threads from their phone; and Claude's+ start-here (the adom/hook block in ~/.claude/CLAUDE.md plus the adom-context SessionStart+ printout). Read when packages are behind or an update failed, when the user says claude+ rc, remote control, open a thread from my phone, claude-rc status, and when you want to+ change, debug or opt out of the start-here block or the "Adom context" lines. --- # adom-hook@@ -138,6 +138,30 @@ States: `unasked -> enabled | declined`, plus `disabled` (turned off later) and systemd is not reachable from inside either container (no bus, no sudo), so it is never used. Detection is `ADOM_DESKTOP_MODE=local` plus a live crond. +## Start here for Claude (1.4.0)++A fresh Claude in an Adom workspace used to get the stock Claude Code prompt and about 250+skills, most listed to it by name only, and nothing saying where it was. Codex already had an+entry point (adom/codex's block in `~/.codex/AGENTS.md`); this is Claude's.++- **`~/.claude/CLAUDE.md` block**, between `<!-- adom/hook:begin ... -->` and+ `<!-- adom/hook:end -->`, from `claude-start-here.md` in this package. Always loaded. It+ covers the two places a session can run (the local Hydrogen workspace, a cloud container),+ the four CLIs, a task-to-skill table, and the rules that save the most grief. Install+ rewrites only the block; everything outside it is the user's. The first write backs the+ file up to `CLAUDE.md.before-adom-hook`. A malformed block (one marker, or two of either)+ is left alone with a warning.+- **`adom-context`** (in `~/.local/bin`), run by a `SessionStart` hook as+ `adom-context --hook`. It prints live facts: local workspace (WSL on the user's PC, with+ `/mnt/c`) vs container, the Hydrogen control API, the Adom sign-in, Adom Bridge machines+ (with "this PC" and a warning when there are several and no primary), installed wiki+ packages, and a failed auto-update. Probes run in parallel with a 2.5 s cap and the hook+ always exits 0. `adom-context --json` gives the same as data.+- **Opt out:** `touch ~/.adom/no-start-here`, then reinstall (or delete the block and the+ SessionStart entry yourself); later installs respect the file.+- **Change the routing table** in `claude-start-here.md` and publish. Only name skills that+ ship in `adom/core` or `hydrogen-bootstrap`, so a fresh install has every one of them.+ ## Verbs | verb | what |
adom-contextadded+209@@ -0,0 +1,209 @@+#!/usr/bin/env python3+"""adom-context: what this Adom workspace is and what is live in it, in a few lines.++Claude Code's SessionStart hook runs `adom-context --hook` (wired by adom/hook), so a+fresh session starts knowing where it is instead of guessing from 250 skills. Safe to+run by hand any time; `--json` gives the same facts as data.++Every probe is optional and time-boxed, and they run in parallel: a missing CLI or a+down service reads as "unknown", never an error. Under --hook the exit code is always 0+and the whole run stays under ~3 s, because a SessionStart hook must never get in the+way of the session it is orienting.+"""+import json+import os+import socket+import subprocess+import sys+import urllib.request+from concurrent.futures import ThreadPoolExecutor+from pathlib import Path++HOME = Path.home()+ADOM = HOME / ".adom"+PROBE_TIMEOUT = 2.5+++def run_json(*cmd):+ try:+ p = subprocess.run(cmd, capture_output=True, text=True, timeout=PROBE_TIMEOUT)+ return json.loads(p.stdout) if p.stdout.strip() else None+ except Exception:+ return None+++def hydrogen_url():+ # hd-control-url is the live one (rewritten on every Hydrogen start);+ # hydrogen-control-url is the older name some installs still carry.+ for name in ("hd-control-url", "hydrogen-control-url"):+ try:+ url = (ADOM / name).read_text().strip()+ if url:+ return url+ except OSError:+ pass+ return os.environ.get("ADOM_HD_CONTROL_URL") or None+++def probe_hydrogen():+ url = hydrogen_url()+ if not url:+ return {"url": None, "up": False}+ try:+ with urllib.request.urlopen(url.rstrip("/") + "/health", timeout=PROBE_TIMEOUT) as r:+ return {"url": url, "up": r.status == 200}+ except Exception:+ return {"url": url, "up": False}+++def probe_where(hydrogen):+ """hydrogen-local: the WSL2 distro Hydrogen runs on the user's own PC.+ container: anything else (an Adom cloud container, a service box)."""+ try:+ wsl = "microsoft" in Path("/proc/version").read_text().lower()+ except OSError:+ wsl = False+ local = wsl and (os.environ.get("ADOM_DESKTOP_MODE") == "local" or hydrogen["url"] is not None)+ return {+ "kind": "hydrogen-local" if local else "container",+ "host": socket.gethostname(),+ "windows_drive": "/mnt/c" if local and Path("/mnt/c").is_dir() else None,+ }+++def probe_identity():+ d = run_json("adom-wiki", "whoami", "--json")+ user = ((d or {}).get("data") or {}).get("user") or {}+ if not user.get("username"):+ return None+ orgs = [o.get("name") for o in ((d.get("data") or {}).get("orgs") or []) if o.get("name")]+ return {"username": user["username"], "name": user.get("displayName"), "orgs": orgs}+++def probe_targets():+ d = run_json("adom-bridge", "targets")+ if not d or d.get("status") != "ok":+ return None+ return {+ "primary": d.get("primaryMachine"),+ "machines": [+ {"name": t.get("name"), "os": t.get("os"), "reachable": t.get("reachable"),+ "primary": bool(t.get("primary"))}+ for t in d.get("targets") or []+ ],+ }+++def probe_packages():+ # Same prefix order as check-updates.sh's self-heal.+ prefix = os.environ.get("ADOMPKG_PREFIX")+ for root in ([Path(prefix) / "adom_modules"] if prefix else []) + [+ HOME / "project" / "adom_modules", HOME / "adom_modules"]:+ if root.is_dir():+ break+ else:+ return []+ pkgs = []+ for manifest in sorted(root.glob("*/*/package.json")):+ try:+ m = json.loads(manifest.read_text())+ except Exception:+ continue+ org, slug = manifest.parent.parent.name, manifest.parent.name+ pkgs.append({"ref": f"{org}/{slug}", "version": m.get("version"), "type": m.get("type")})+ return pkgs+++def probe_update():+ try:+ status = (ADOM / "last-update.status").read_text().strip()+ except OSError:+ return None+ return "ok" if status == "0" else status+++def gather():+ with ThreadPoolExecutor(max_workers=5) as ex:+ hydrogen = ex.submit(probe_hydrogen)+ identity = ex.submit(probe_identity)+ targets = ex.submit(probe_targets)+ packages = ex.submit(probe_packages)+ update = ex.submit(probe_update)++ def result(f):+ try:+ return f.result(timeout=PROBE_TIMEOUT + 0.5)+ except Exception:+ return None++ h = result(hydrogen) or {"url": None, "up": False}+ return {+ "where": probe_where(h),+ "hydrogen": h,+ "identity": result(identity),+ "machines": result(targets),+ "packages": result(packages) or [],+ "last_update": result(update),+ }+++def render(c):+ w, lines = c["where"], ["Adom context (adom-context; rerun it any time):"]+ if w["kind"] == "hydrogen-local":+ lines.append(f"- Where: the Hydrogen local workspace, a WSL2 distro on the user's own PC "+ f"({w['host']}). {w['windows_drive'] or '/mnt/c'} is that PC's C: drive, so "+ "Windows files are reachable directly here; skills that say you run in a "+ "cloud container do not apply.")+ else:+ lines.append(f"- Where: a Linux container ({w['host']}), not the user's PC. Reach the "+ "user's machines only through adom-bridge.")+ h = c["hydrogen"]+ if h["url"]:+ lines.append(f"- Hydrogen control API: {h['url']} ({'up' if h['up'] else 'not answering'}).")+ i = c["identity"]+ if i:+ orgs = f", orgs: {', '.join(i['orgs'])}" if i["orgs"] else ""+ lines.append(f"- Signed in to Adom as {i['username']} ({i['name']}){orgs}.")+ else:+ lines.append("- Adom sign-in: unknown (`adom-wiki whoami` gave nothing).")+ m = c["machines"]+ if m is None:+ lines.append("- Adom Bridge machines: none reachable (adom-bridge missing or no relay).")+ else:+ # In the local workspace the distro's hostname is its PC's name, so one target+ # is the very machine the user is sitting at.+ here = w["host"].lower() if w["kind"] == "hydrogen-local" else None+ names = "; ".join(+ f"{t['name']} ({t['os']}, {'reachable' if t['reachable'] is True else t['reachable'] or 'offline'}"+ f"{', primary' if t['primary'] else ''}{', this PC' if (t['name'] or '').lower() == here else ''})"+ for t in m["machines"]) or "none"+ lines.append(f"- Adom Bridge machines: {names}.")+ if len(m["machines"]) > 1 and not m["primary"]:+ lines.append(" No primary machine is set: ask the user which one to use before "+ "driving any of them, and pass --target <name>.")+ pkgs = c["packages"]+ if pkgs:+ lines.append(f"- Installed wiki packages ({len(pkgs)}): "+ + ", ".join(p["ref"] for p in pkgs) + ".")+ if c["last_update"] not in (None, "ok"):+ lines.append(f"- Last auto-update: {c['last_update']} (see ~/.adom/last-update.log).")+ return "\n".join(lines)+++def main(argv):+ if "-h" in argv or "--help" in argv:+ print(__doc__.strip())+ print("\nusage: adom-context [--json | --hook]")+ return 0+ try:+ c = gather()+ print(json.dumps(c, indent=2) if "--json" in argv else render(c))+ except Exception as e:+ if "--hook" not in argv:+ raise+ print(f"adom-context failed ({e}); run `adom-context` to retry.")+ return 0+++if __name__ == "__main__":+ sys.exit(main(sys.argv[1:]))
claude-start-here.mdadded+53@@ -0,0 +1,53 @@+# Adom: start here++You are working in an **Adom workspace**. The "Adom context" lines at the top of this+session (from `adom-context`) say which kind, who is signed in, and which of the user's+machines are reachable. Rerun `adom-context` whenever that matters, it is instant.++## Where you are+- **Hydrogen local workspace**: a WSL2 distro on the user's own Windows PC, opened by the+ Adom Hydrogen app ("ah"). `/mnt/c` is that PC's C: drive. Hydrogen's control API is at+ `$(cat ~/.adom/hd-control-url)`.+- **Adom cloud container** (Hydrogen Cloud, "hc"): a Linux box on adom.cloud. The user's PCs are reachable only+ through Adom Bridge.++Some skills were written for only one of these. When a skill's claim about where you run+contradicts `adom-context`, trust `adom-context`.++## Your tools+All of these are on PATH; `<cli> --help` lists the verbs.++| CLI | Use it for |+|---|---|+| `adom-cli` | the Adom platform: profile, orgs, repos, cloud containers, Hydrogen webviews/panels |+| `adom-wiki` | wiki.adom.inc: find and install apps/skills/CLIs, pages, issues, PRs, releases |+| `adom-bridge` | the user's real machines (Adom Bridge, "ab"): shell, files, windows, screenshots, notifications, and the app bridges (KiCad, Fusion 360, Altium, pup browser) |+| `adom-parts-search` | parts across Mouser, DigiKey and JLCPCB |++## Which skill to read+Most of the installed skills are listed to you by name only. For these tasks, read the named skill before you start:++| Task | Skill |+|---|---|+| Adom platform: account, repos, containers, orgs, anything not below | `adom` (the hub; it routes further) |+| Do something on the user's PC, or in KiCad / Fusion 360 | `adom-bridge-discovery` |+| More than one machine is listed | `adom-bridge-multi-machine` |+| About to touch someone's screen, mouse or keyboard | `foreground-etiquette` |+| A browser the AI drives ("pup") | `hydrogen-pup` |+| Show the user a page or app in Hydrogen (webview) | `hydrogen-webview` |+| Find an app/skill for something, or "is there a tool for X" | `wiki-discovery` |+| Publish or edit a wiki page | `wiki-publish-safely` |+| Build an Adom app | `building-adom-apps` |+| Adom jargon (ab, ah, hc, pup, wv, nb, ...) | `definitions` |+| The Hydrogen app itself | `hydrogen-overview` |+| Something is broken, file it | `issue-reporting` |++If a skill named here is not installed, `adom-wiki search <topic>` finds the package that ships it.++## Rules that save the most grief+- **Never guess which machine to act on.** If more than one is listed and none is primary,+ ask the user, then pass `--target <name>`.+- **Look before you take over a screen.** A person or another AI thread may be using it.+- **Verify by looking.** Screenshot, pup, or read back the result before you say it worked.+- **Skills can be stale.** When a skill disagrees with what the live system tells you, trust+ the live system and tell the user which skill was wrong (`issue-reporting` files it).
install.sh+57−10@@ -49,21 +49,21 @@ if ! command -v python3 >/dev/null 2>&1; then exit 0 fi -# Wire a command into one agent config's hooks.UserPromptSubmit, removing any legacy-# auto-update hook first. $1 = config path, $2 = "1" to include a timeout field,-# $3 = the command (defaults to the auto-update hook).+# Wire a command into one agent config's hooks.<event> (UserPromptSubmit by default),+# removing any legacy auto-update hook first. $1 = config path, $2 = "1" to include a+# timeout field, $3 = the command (defaults to the auto-update hook), $4 = the event. wire() {- local path="$1" with_timeout="$2" cmd="${3:-$HOOK_CMD}"+ local path="$1" with_timeout="$2" cmd="${3:-$HOOK_CMD}" event="${4:-UserPromptSubmit}" mkdir -p "$(dirname "$path")"- python3 - "$path" "$cmd" "$with_timeout" <<'PY'+ python3 - "$path" "$cmd" "$with_timeout" "$event" <<'PY' import json, sys-path, cmd, with_timeout = sys.argv[1], sys.argv[2], sys.argv[3] == "1"+path, cmd, with_timeout, event = sys.argv[1], sys.argv[2], sys.argv[3] == "1", sys.argv[4] try: with open(path) as f: d = json.load(f) if not isinstance(d, dict): d = {} except Exception: d = {}-ups = d.setdefault("hooks", {}).setdefault("UserPromptSubmit", [])+ups = d.setdefault("hooks", {}).setdefault(event, []) # A legacy update hook is any command pointing at a check-updates.sh (gallia's # hooks/check-updates.sh, or this package's own pre-rename name). adom-core-update.sh # does not match, so the current hook is never removed.@@ -97,9 +97,9 @@ if changed: with open(path, "w") as f: json.dump(d, f, indent=2) note = " (retired %d legacy hook(s))" % removed if removed else ""- print(" wired %s into %s%s" % (cmd.split("/")[-1].split()[0], path, note))+ print(" wired %s into %s %s%s" % (cmd.split("/")[-1].split()[0], path, event, note)) else:- print(" %s already wired in %s" % (cmd.split("/")[-1].split()[0], path))+ print(" %s already wired in %s %s" % (cmd.split("/")[-1].split()[0], path, event)) PY } @@ -108,6 +108,53 @@ wire "${HOME}/.codex/hooks.json" 0 wire "${HOME}/.claude/settings.json" 1 "$RC_HOOK_CMD" wire "${HOME}/.codex/hooks.json" 0 "$RC_HOOK_CMD" +# --- Start here: orient every new Claude session (adom/hook 1.4.0) -------------+# A fresh Claude in an Adom workspace saw the stock Claude Code prompt and ~250 skills,+# most of them listed by name only, and nothing that said where it was or which few+# skills matter. Codex already gets an entry point (adom/codex's AGENTS.md block); this+# is Claude's: a managed "start here" block in the user-level ~/.claude/CLAUDE.md (always+# loaded), plus a SessionStart hook that prints live facts from adom-context (where the+# session runs, who is signed in, which machines are reachable). Text outside the block+# is the user's and is never touched. `touch ~/.adom/no-start-here` opts out of both.+CTX="${BIN_DIR}/adom-context"+install -m 0755 "$PKG_DIR/adom-context" "$CTX"+CTX_HOOK_CMD="$CTX --hook"+if [ -e "${HOME}/.adom/no-start-here" ]; then+ echo " start-here skipped (~/.adom/no-start-here is present)"+else+ python3 - "${HOME}/.claude/CLAUDE.md" "$PKG_DIR/claude-start-here.md" <<'PY'+import shutil, sys+from pathlib import Path+path, src = Path(sys.argv[1]), Path(sys.argv[2])+begin = "<!-- adom/hook:begin (managed by the adom/hook package and rewritten on every update; put your own notes outside this block) -->"+end = "<!-- adom/hook:end -->"+body = src.read_text().strip()+block = f"{begin}\n{body}\n{end}"+old = path.read_text() if path.exists() else ""+# Match on the marker prefix so a reworded begin comment still finds the old block.+b, e = old.find("<!-- adom/hook:begin"), old.find(end)+if (b < 0) != (e < 0) or old.count("<!-- adom/hook:begin") > 1 or old.count(end) > 1 or (b >= 0 and e < b):+ print(f" warning: the adom/hook block in {path} is malformed; left it as is for review", file=sys.stderr)+ sys.exit(0)+if b >= 0:+ new = old[:b] + block + old[e + len(end):]+else:+ new = (old.rstrip() + "\n\n" if old.strip() else "") + block + "\n"+if new == old:+ print(f" start-here block already current in {path}")+ sys.exit(0)+path.parent.mkdir(parents=True, exist_ok=True)+backup = path.with_name("CLAUDE.md.before-adom-hook")+if old and not backup.exists():+ shutil.copy2(path, backup)+tmp = path.with_name(".CLAUDE.md.adom-hook.tmp")+tmp.write_text(new)+tmp.replace(path)+print(f" wrote the start-here block into {path}")+PY+ wire "${HOME}/.claude/settings.json" 1 "$CTX_HOOK_CMD" SessionStart+fi+ # Re-assert supervision when consent already exists (re-install, image bake, migration). if grep -q '^state=enabled' "$RC_STATE" 2>/dev/null; then "$RC" enable || true@@ -231,4 +278,4 @@ if [ -f "$PKG_DIR/SKILL.md" ]; then cp "$PKG_DIR/SKILL.md" "$HOME/.claude/skills/adom-hook/SKILL.md" fi -echo "Installed adom-hook (auto-update wired for Claude + Codex; checks every ${ADOM_HOOK_INTERVAL:-1800}s; claude-rc staged, offer on next prompt)"+echo "Installed adom-hook (auto-update wired for Claude + Codex; checks every ${ADOM_HOOK_INTERVAL:-1800}s; claude-rc staged; start-here block + adom-context SessionStart for Claude)"
package.json+20−5@@ -1,10 +1,10 @@ { "slug": "hook",- "version": "1.3.11",+ "version": "1.4.0", "type": "app", "org": "adom", "bundled": true,- "description": "Registry-native cross-agent auto-update hook, plus claude-rc, the keeper for Claude Remote Control. 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.",+ "description": "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.", "dependencies": {}, "scripts": { "install": "./install.sh",@@ -20,7 +20,11 @@ "remote-control", "claude-rc", "mobile",- "watchdog"+ "watchdog",+ "onboarding",+ "start-here",+ "claude-md",+ "session-start" ], "discovery_triggers": [ "auto update skills and apps",@@ -36,7 +40,13 @@ "use my container from my phone", "spawn claude threads from mobile", "remote control not running",- "claude-rc status"+ "claude-rc status",+ "claude doesn't know where it is",+ "claude onboarding",+ "start here for claude",+ "adom-context",+ "what is this workspace",+ "which machine am i on" ], "hero": { "headline": "Always current. Zero clicks.",@@ -54,9 +64,14 @@ "src": "claude-rc", "dest": "~/.local/bin/claude-rc", "mode": "0755"+ },+ {+ "src": "adom-context",+ "dest": "~/.local/bin/adom-context",+ "mode": "0755" } ],- "changelog": "1.3.11: claude-rc no longer restarts remote control on every OAuth token refresh (about every 8 h, dropping live sessions). A newer credentials file restarts the server only when the signed-in account changed, or when the server has stayed off Connected for 5 minutes (hook#6).",+ "changelog": "1.4.0: Claude now starts every session oriented. install writes a managed start-here block into ~/.claude/CLAUDE.md (where you are, the four CLIs, a task-to-skill table, the rules that save the most grief; text outside the block is never touched) and wires a SessionStart hook that runs the new adom-context CLI (local Hydrogen workspace vs cloud container, Adom sign-in, Adom Bridge machines with a no-primary warning, installed packages, a failed auto-update). `touch ~/.adom/no-start-here` opts out. Mirrors adom/codex's AGENTS.md entry point.", "discovery_pitch": "Use when adom packages are behind or an update failed, and when the user asks about Claude Remote Control -- opening AI threads on this container from their phone or claude.ai/code.", "sample_prompts": [ {
page.json+20−5@@ -1,10 +1,10 @@ { "slug": "hook",- "version": "1.3.11",+ "version": "1.4.0", "type": "app", "org": "adom", "bundled": true,- "description": "Registry-native cross-agent auto-update hook, plus claude-rc, the keeper for Claude Remote Control. 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.",+ "description": "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.", "dependencies": {}, "scripts": { "install": "./install.sh",@@ -20,7 +20,11 @@ "remote-control", "claude-rc", "mobile",- "watchdog"+ "watchdog",+ "onboarding",+ "start-here",+ "claude-md",+ "session-start" ], "discovery_triggers": [ "auto update skills and apps",@@ -36,7 +40,13 @@ "use my container from my phone", "spawn claude threads from mobile", "remote control not running",- "claude-rc status"+ "claude-rc status",+ "claude doesn't know where it is",+ "claude onboarding",+ "start here for claude",+ "adom-context",+ "what is this workspace",+ "which machine am i on" ], "hero": { "type": "billboard",@@ -50,7 +60,7 @@ "name": "Kyle Bergstedt", "email": "[email protected]" },- "changelog": "1.3.11: claude-rc no longer restarts remote control on every OAuth token refresh (about every 8 h, dropping live sessions). A newer credentials file restarts the server only when the signed-in account changed, or when the server has stayed off Connected for 5 minutes (hook#6).",+ "changelog": "1.4.0: Claude now starts every session oriented. install writes a managed start-here block into ~/.claude/CLAUDE.md (where you are, the four CLIs, a task-to-skill table, the rules that save the most grief; text outside the block is never touched) and wires a SessionStart hook that runs the new adom-context CLI (local Hydrogen workspace vs cloud container, Adom sign-in, Adom Bridge machines with a no-primary warning, installed packages, a failed auto-update). `touch ~/.adom/no-start-here` opts out. Mirrors adom/codex's AGENTS.md entry point.", "discovery_pitch": "Use when adom packages are behind or an update failed, and when the user asks about Claude Remote Control -- opening AI threads on this container from their phone or claude.ai/code.", "sample_prompts": [ {@@ -76,6 +86,11 @@ "src": "claude-rc", "dest": "~/.local/bin/claude-rc", "mode": "0755"+ },+ {+ "src": "adom-context",+ "dest": "~/.local/bin/adom-context",+ "mode": "0755" } ], "tag": "latest"
tests/test_start_here.pyadded+103@@ -0,0 +1,103 @@+"""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_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)+++if __name__ == "__main__":+ unittest.main()
uninstall.sh+25−6@@ -5,17 +5,17 @@ HOOK="${HOME}/.adom/hooks/adom-core-update.sh" HOOK_CMD="bash $HOOK" unwire() {- local path="$1" cmd="${2:-$HOOK_CMD}"+ local path="$1" cmd="${2:-$HOOK_CMD}" event="${3:-UserPromptSubmit}" [ -f "$path" ] || return 0 command -v python3 >/dev/null 2>&1 || return 0- python3 - "$path" "$cmd" <<'PY'+ python3 - "$path" "$cmd" "$event" <<'PY' import json, sys-path, cmd = sys.argv[1], sys.argv[2]+path, cmd, event = sys.argv[1], sys.argv[2], sys.argv[3] try: with open(path) as f: d = json.load(f) except Exception: sys.exit(0)-ups = d.get("hooks", {}).get("UserPromptSubmit")+ups = d.get("hooks", {}).get(event) if isinstance(ups, list): kept = [] for g in ups:@@ -25,7 +25,7 @@ if isinstance(ups, list): kept.append(g) else: kept.append(g)- d["hooks"]["UserPromptSubmit"] = kept+ d["hooks"][event] = kept with open(path, "w") as f: json.dump(d, f, indent=2) PY }@@ -40,6 +40,25 @@ unwire "${HOME}/.claude/settings.json" "$RC hook" unwire "${HOME}/.codex/hooks.json" "$RC hook" rm -f "$RC" "${HOME}/.adom/claude-rc.state" +# The start-here block and its SessionStart context hook (1.4.0). Only the managed+# block is cut; the rest of ~/.claude/CLAUDE.md is the user's.+CTX="${HOME}/.local/bin/adom-context"+unwire "${HOME}/.claude/settings.json" "$CTX --hook" SessionStart+rm -f "$CTX"+if [ -f "${HOME}/.claude/CLAUDE.md" ] && command -v python3 >/dev/null 2>&1; then+ python3 - "${HOME}/.claude/CLAUDE.md" <<'PY'+import sys+from pathlib import Path+path = Path(sys.argv[1]); old = path.read_text()+b, end = old.find("<!-- adom/hook:begin"), "<!-- adom/hook:end -->"+e = old.find(end)+if b >= 0 and e > b:+ new = (old[:b].rstrip() + "\n" + old[e + len(end):].lstrip("\n")).strip()+ path.write_text(new + "\n" if new else "")+ print(" removed the start-here block from %s" % path)+PY+fi+ # Drop the headless cron trigger too, or uninstall would leave entries pointing at # a script it just deleted (cron would then log a failure every 30 minutes). if command -v crontab >/dev/null 2>&1; then@@ -52,4 +71,4 @@ fi rm -f "$HOOK" rm -rf "${HOME}/.claude/skills/adom-hook" rm -f "${HOME}/.adom/last-update.status" "${HOME}/.adom/last-update.log" "${HOME}/.adom/last-core-check"-echo "Removed adom-hook (auto-update and claude-rc unwired from Claude + Codex, cron entries dropped; ~/.adom/claude-rc.log kept)"+echo "Removed adom-hook (auto-update, claude-rc and the start-here block unwired from Claude + Codex, cron entries dropped; ~/.adom/claude-rc.log kept)"