Give the own home a rule and a hook
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
It runs in the container of the Dockerfile beside it, from a clone of this repo: `first-chunk-e2e/run` starts it. The machine holds a stock Claude Code with its own `~/.claude`, to which this adds a `CLAUDE.md`. build-release then runs a task in a small project, with claude calling the mock Messages API. The run passes where the chunk finished on the setup's instructions, no request held the person's own, and `~/.claude` and `~/.claude.json` hold what they held before.
|
It runs in the container of the Dockerfile beside it, from a clone of this repo: `first-chunk-e2e/run` starts it. The machine holds a stock Claude Code with its own `~/.claude`, to which this adds a `CLAUDE.md`. build-release then runs a task in a small project, with claude calling the mock Messages API. The run passes where the chunk finished on the setup's instructions, no request held the person's own, and `~/.claude` and `~/.claude.json` hold what they held before.
|
||||||
"""
|
"""
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -17,8 +18,15 @@ HOME = pathlib.Path.home()
|
|||||||
PROJECT = HOME / "code" / "first-project"
|
PROJECT = HOME / "code" / "first-project"
|
||||||
ARCHIVE = HOME / ".local/state/build-release/transcripts/first-project"
|
ARCHIVE = HOME / ".local/state/build-release/transcripts/first-project"
|
||||||
CONFIG = HOME / ".config/build-release/first-project/config.toml"
|
CONFIG = HOME / ".config/build-release/first-project/config.toml"
|
||||||
# The line the person's own CLAUDE.md holds. No request may hold it: nothing in `~/.claude` loads in the loop's home.
|
# What the person's own `~/.claude` holds beside the stock install's files. Nothing in it loads in the loop's home, so no request may hold either instruction, and the hook never runs.
|
||||||
OWN_INSTRUCTION = "Sign every reply as the newcomer's own claude."
|
OWN_INSTRUCTION = "Sign every reply as the newcomer's own claude."
|
||||||
|
OWN_RULE = "Open every reply with the newcomer's own greeting."
|
||||||
|
OWN_HOOK_RAN = HOME / "own-hook-ran"
|
||||||
|
OWN_FILES = {
|
||||||
|
"CLAUDE.md": OWN_INSTRUCTION + "\n",
|
||||||
|
"rules/greeting.md": OWN_RULE + "\n",
|
||||||
|
"settings.json": json.dumps({"hooks": {"SessionStart": [{"hooks": [{"type": "command", "command": f"touch {OWN_HOOK_RAN}"}]}]}}) + "\n",
|
||||||
|
}
|
||||||
# A heading of the setup's CLAUDE.md, which the worker's request holds where the loop's home loaded.
|
# A heading of the setup's CLAUDE.md, which the worker's request holds where the loop's home loaded.
|
||||||
SETUP_INSTRUCTION = "## Working loop"
|
SETUP_INSTRUCTION = "## Working loop"
|
||||||
# What build-release asks a project's first chunk, and the model the newcomer types: one on the shipped routing ladder.
|
# What build-release asks a project's first chunk, and the model the newcomer types: one on the shipped routing ladder.
|
||||||
@@ -113,12 +121,11 @@ def failures(requests: mock_messages_api.Requests, before: dict[str, str]) -> li
|
|||||||
found.append(f"no chunk finished within {PATIENCE} s; the loop's tmux windows show:\n{windows()}")
|
found.append(f"no chunk finished within {PATIENCE} s; the loop's tmux windows show:\n{windows()}")
|
||||||
if not any(SETUP_INSTRUCTION in text for text in texts):
|
if not any(SETUP_INSTRUCTION in text for text in texts):
|
||||||
found.append(f"none of claude's {len(texts)} requests held the setup's CLAUDE.md, so the loop's home did not load")
|
found.append(f"none of claude's {len(texts)} requests held the setup's CLAUDE.md, so the loop's home did not load")
|
||||||
for n, text in enumerate(texts):
|
for instruction in (OWN_INSTRUCTION, OWN_RULE):
|
||||||
if OWN_INSTRUCTION in text:
|
if any(instruction in text for text in texts):
|
||||||
i = text.index(OWN_INSTRUCTION)
|
found.append(f"a request held the person's own instruction `{instruction}`, so `~/.claude` loaded in the loop")
|
||||||
print("DEBUG", n, len(texts), text[max(0, i - 700):i + 100], "\nSTART", text[:600], file=sys.stderr)
|
if OWN_HOOK_RAN.exists():
|
||||||
if any(OWN_INSTRUCTION in text for text in texts):
|
found.append("the hook of the person's own `~/.claude/settings.json` ran in the loop")
|
||||||
found.append("a request held the person's own CLAUDE.md, so `~/.claude` loaded in the loop")
|
|
||||||
after = snapshot(HOME / ".claude", HOME / ".claude.json")
|
after = snapshot(HOME / ".claude", HOME / ".claude.json")
|
||||||
for path in sorted(before.keys() | after.keys()):
|
for path in sorted(before.keys() | after.keys()):
|
||||||
if before.get(path) != after.get(path):
|
if before.get(path) != after.get(path):
|
||||||
@@ -127,7 +134,9 @@ def failures(requests: mock_messages_api.Requests, before: dict[str, str]) -> li
|
|||||||
|
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
(HOME / ".claude" / "CLAUDE.md").write_text(OWN_INSTRUCTION + "\n", encoding="utf-8")
|
for name, text in OWN_FILES.items():
|
||||||
|
(HOME / ".claude" / name).parent.mkdir(exist_ok=True)
|
||||||
|
(HOME / ".claude" / name).write_text(text, encoding="utf-8")
|
||||||
before = snapshot(HOME / ".claude", HOME / ".claude.json")
|
before = snapshot(HOME / ".claude", HOME / ".claude.json")
|
||||||
project_made()
|
project_made()
|
||||||
requests = mock_messages_api.Requests()
|
requests = mock_messages_api.Requests()
|
||||||
|
|||||||
Reference in New Issue
Block a user