Rename granted, model and project for what they hold and return
This commit is contained in:
+13
-13
@@ -201,19 +201,19 @@ def sections(text):
|
|||||||
|
|
||||||
def session_name(root):
|
def session_name(root):
|
||||||
# "A " is the human's cue in the session picker that the session is the loop's.
|
# "A " is the human's cue in the session picker that the session is the loop's.
|
||||||
return f"A {project(root)} loop-claude"
|
return f"A {project_name(root)} loop-claude"
|
||||||
|
|
||||||
|
|
||||||
def archive(root, path, note):
|
def archive(root, path, note):
|
||||||
# Stamped by mtime, so a transcript unchanged since its last archive maps to the file already written.
|
# Stamped by mtime, so a transcript unchanged since its last archive maps to the file already written.
|
||||||
folder = os.path.join(ARCHIVE, project(root))
|
folder = os.path.join(ARCHIVE, project_name(root))
|
||||||
try:
|
try:
|
||||||
stamp = time.strftime("%Y-%m-%dT%H-%M-%SZ", time.gmtime(os.path.getmtime(path)))
|
stamp = time.strftime("%Y-%m-%dT%H-%M-%SZ", time.gmtime(os.path.getmtime(path)))
|
||||||
make_private(folder)
|
make_private(folder)
|
||||||
dest = os.path.join(folder, f"{stamp}.md")
|
dest = os.path.join(folder, f"{stamp}.md")
|
||||||
if not os.path.exists(dest):
|
if not os.path.exists(dest):
|
||||||
with open(os.open(dest, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600), "w", encoding="utf-8") as copy:
|
with open(os.open(dest, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600), "w", encoding="utf-8") as copy:
|
||||||
copy.write(f"# {stamp} {project(root)}\n\n{note}\n\n{render(entries(path))}\n")
|
copy.write(f"# {stamp} {project_name(root)}\n\n{note}\n\n{render(entries(path))}\n")
|
||||||
print(f"transcript: {dest}", file=sys.stderr)
|
print(f"transcript: {dest}", file=sys.stderr)
|
||||||
except OSError as failure:
|
except OSError as failure:
|
||||||
print(f"could not archive the transcript: {failure}", file=sys.stderr)
|
print(f"could not archive the transcript: {failure}", file=sys.stderr)
|
||||||
@@ -242,11 +242,11 @@ def replace_json(path, data, **dump):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def model(variable, chosen):
|
def model_flags(variable, chosen):
|
||||||
return ["--model", os.environ.get(variable) or chosen]
|
return ["--model", os.environ.get(variable) or chosen]
|
||||||
|
|
||||||
|
|
||||||
def project(root):
|
def project_name(root):
|
||||||
return root.removeprefix(os.path.expanduser("~/code/")).lstrip("/")
|
return root.removeprefix(os.path.expanduser("~/code/")).lstrip("/")
|
||||||
|
|
||||||
|
|
||||||
@@ -297,7 +297,7 @@ def project_model(root):
|
|||||||
if os.environ.get("LOOP_CLAUDE_JUDGE_MODEL") and os.environ.get("LOOP_CLAUDE_WORKER_MODEL"):
|
if os.environ.get("LOOP_CLAUDE_JUDGE_MODEL") and os.environ.get("LOOP_CLAUDE_WORKER_MODEL"):
|
||||||
return ""
|
return ""
|
||||||
saved = os.path.expanduser("~/.claude/loop-claude-models.json")
|
saved = os.path.expanduser("~/.claude/loop-claude-models.json")
|
||||||
name = project(root)
|
name = project_name(root)
|
||||||
models = read_models(saved)
|
models = read_models(saved)
|
||||||
if isinstance(models, Stop):
|
if isinstance(models, Stop):
|
||||||
return models
|
return models
|
||||||
@@ -456,7 +456,7 @@ def worker_args(task, name, session_id, chosen, resuming):
|
|||||||
"--output-format", "stream-json",
|
"--output-format", "stream-json",
|
||||||
"--permission-mode", "bypassPermissions",
|
"--permission-mode", "bypassPermissions",
|
||||||
"--verbose",
|
"--verbose",
|
||||||
*model("LOOP_CLAUDE_WORKER_MODEL", chosen),
|
*model_flags("LOOP_CLAUDE_WORKER_MODEL", chosen),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -488,7 +488,7 @@ def judge(root, task, premises, transcript, chosen):
|
|||||||
args = [
|
args = [
|
||||||
"-p",
|
"-p",
|
||||||
"--json-schema", json.dumps(JUDGE_SCHEMA),
|
"--json-schema", json.dumps(JUDGE_SCHEMA),
|
||||||
*model("LOOP_CLAUDE_JUDGE_MODEL", chosen),
|
*model_flags("LOOP_CLAUDE_JUDGE_MODEL", chosen),
|
||||||
"--no-session-persistence",
|
"--no-session-persistence",
|
||||||
"--output-format", "json",
|
"--output-format", "json",
|
||||||
"--permission-mode", "bypassPermissions",
|
"--permission-mode", "bypassPermissions",
|
||||||
@@ -538,7 +538,7 @@ def interrupt(root, session_id, chosen, path, question):
|
|||||||
return "stdin or stdout is not a terminal"
|
return "stdin or stdout is not a terminal"
|
||||||
trust(checkouts(root))
|
trust(checkouts(root))
|
||||||
before = human_turns(entries(path))
|
before = human_turns(entries(path))
|
||||||
subprocess.run(["claude", *model("LOOP_CLAUDE_WORKER_MODEL", chosen), "--permission-mode", "bypassPermissions", "--resume", str(session_id)], cwd=root)
|
subprocess.run(["claude", *model_flags("LOOP_CLAUDE_WORKER_MODEL", chosen), "--permission-mode", "bypassPermissions", "--resume", str(session_id)], cwd=root)
|
||||||
return "" if human_turns(entries(path)) > before else "the interrupt ended without the human typing anything"
|
return "" if human_turns(entries(path)) > before else "the interrupt ended without the human typing anything"
|
||||||
|
|
||||||
|
|
||||||
@@ -562,15 +562,15 @@ def trust(paths):
|
|||||||
if not isinstance(projects, dict) or not all(isinstance(record, dict) for record in projects.values()):
|
if not isinstance(projects, dict) or not all(isinstance(record, dict) for record in projects.values()):
|
||||||
print(f"could not read {config}: not an object whose \"projects\" maps paths to objects", file=sys.stderr)
|
print(f"could not read {config}: not an object whose \"projects\" maps paths to objects", file=sys.stderr)
|
||||||
return
|
return
|
||||||
granted = [path for path in paths if not projects.get(path, {}).get("hasTrustDialogAccepted")]
|
untrusted = [path for path in paths if not projects.get(path, {}).get("hasTrustDialogAccepted")]
|
||||||
if not granted:
|
if not untrusted:
|
||||||
return
|
return
|
||||||
for path in granted:
|
for path in untrusted:
|
||||||
projects.setdefault(path, {})["hasTrustDialogAccepted"] = True
|
projects.setdefault(path, {})["hasTrustDialogAccepted"] = True
|
||||||
if failure := replace_json(config, data, indent=2):
|
if failure := replace_json(config, data, indent=2):
|
||||||
print(f"could not write {config}: {failure.strerror}", file=sys.stderr)
|
print(f"could not write {config}: {failure.strerror}", file=sys.stderr)
|
||||||
return
|
return
|
||||||
print("trusted for the interrupt: " + ", ".join(granted), file=sys.stderr)
|
print("trusted for the interrupt: " + ", ".join(untrusted), file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -122,10 +122,10 @@ class CheckoutRoot(unittest.TestCase):
|
|||||||
class Project(unittest.TestCase):
|
class Project(unittest.TestCase):
|
||||||
def test_names_a_checkout_relative_to_code_and_any_other_relative_to_root(self):
|
def test_names_a_checkout_relative_to_code_and_any_other_relative_to_root(self):
|
||||||
with unittest.mock.patch.dict(os.environ, {"HOME": "/h"}):
|
with unittest.mock.patch.dict(os.environ, {"HOME": "/h"}):
|
||||||
self.assertEqual(loop.project("/h/code/a/b"), "a/b")
|
self.assertEqual(loop.project_name("/h/code/a/b"), "a/b")
|
||||||
self.assertEqual(loop.session_name("/h/code/a/b"), "A a/b loop-claude")
|
self.assertEqual(loop.session_name("/h/code/a/b"), "A a/b loop-claude")
|
||||||
self.assertEqual(loop.project("/h/code"), "h/code")
|
self.assertEqual(loop.project_name("/h/code"), "h/code")
|
||||||
self.assertEqual(loop.project("/srv/x"), "srv/x")
|
self.assertEqual(loop.project_name("/srv/x"), "srv/x")
|
||||||
self.assertEqual(loop.session_name("/srv/x"), "A srv/x loop-claude")
|
self.assertEqual(loop.session_name("/srv/x"), "A srv/x loop-claude")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ Ships when a four-seat scoring run puts every dimension and the overall at 7.0 o
|
|||||||
|
|
||||||
Shape, 7.0:
|
Shape, 7.0:
|
||||||
|
|
||||||
- Rename `granted` in `trust` for the paths it holds before the write, and `model` and `project` for what they return.
|
|
||||||
- Move `agents/review-protocol.md` out of `agents/`, beside what binds to it.
|
- Move `agents/review-protocol.md` out of `agents/`, beside what binds to it.
|
||||||
- Split `larv-review` §7 so a fix's re-entry reads without the whole skill open.
|
- Split `larv-review` §7 so a fix's re-entry reads without the whole skill open.
|
||||||
- Keep the fits-in-a-head thresholds in one place in `agents/systems-architect.md`, today four.
|
- Keep the fits-in-a-head thresholds in one place in `agents/systems-architect.md`, today four.
|
||||||
|
|||||||
Reference in New Issue
Block a user