Skip to content

Commit 98a3448

Browse files
Kasper Jungeclaude
authored andcommitted
refactor: use PrimitiveEntry named fields instead of positional destructuring
Access prim.path, prim.frontmatter, and prim.body by name instead of unpacking to (entry, frontmatter, body). This makes field access self-documenting — prim.path.name is clearly Path.name, whereas the old entry.name required tracing through discover_primitives to understand. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 04ae041 commit 98a3448

4 files changed

Lines changed: 28 additions & 28 deletions

File tree

src/ralphify/checks.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,23 @@ def discover_checks(root: Path = Path(".")) -> list[Check]:
5757
are skipped with a warning. Defaults: ``timeout=_DEFAULT_TIMEOUT``, ``enabled=True``.
5858
"""
5959
checks = []
60-
for entry, frontmatter, body in discover_primitives(root, "checks", CHECK_MARKER):
61-
script = find_run_script(entry)
62-
command = frontmatter.get("command")
60+
for prim in discover_primitives(root, "checks", CHECK_MARKER):
61+
script = find_run_script(prim.path)
62+
command = prim.frontmatter.get("command")
6363

6464
if not script and not command:
65-
warnings.warn(f"Check '{entry.name}' has neither a run.* script nor a command — skipping")
65+
warnings.warn(f"Check '{prim.path.name}' has neither a run.* script nor a command — skipping")
6666
continue
6767

6868
checks.append(
6969
Check(
70-
name=entry.name,
71-
path=entry,
70+
name=prim.path.name,
71+
path=prim.path,
7272
command=command,
7373
script=script,
74-
timeout=frontmatter.get("timeout", _DEFAULT_TIMEOUT),
75-
enabled=frontmatter.get("enabled", True),
76-
failure_instruction=body,
74+
timeout=prim.frontmatter.get("timeout", _DEFAULT_TIMEOUT),
75+
enabled=prim.frontmatter.get("enabled", True),
76+
failure_instruction=prim.body,
7777
)
7878
)
7979

src/ralphify/contexts.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ def discover_contexts(root: Path = Path(".")) -> list[Context]:
5353
"""Discover contexts in root/.ralph/contexts/ directories."""
5454
return [
5555
Context(
56-
name=entry.name,
57-
path=entry,
58-
command=frontmatter.get("command"),
59-
script=find_run_script(entry),
60-
timeout=frontmatter.get("timeout", _DEFAULT_TIMEOUT),
61-
enabled=frontmatter.get("enabled", True),
62-
static_content=body,
56+
name=prim.path.name,
57+
path=prim.path,
58+
command=prim.frontmatter.get("command"),
59+
script=find_run_script(prim.path),
60+
timeout=prim.frontmatter.get("timeout", _DEFAULT_TIMEOUT),
61+
enabled=prim.frontmatter.get("enabled", True),
62+
static_content=prim.body,
6363
)
64-
for entry, frontmatter, body in discover_primitives(root, "contexts", CONTEXT_MARKER)
64+
for prim in discover_primitives(root, "contexts", CONTEXT_MARKER)
6565
]
6666

6767

src/ralphify/instructions.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ def discover_instructions(root: Path = Path(".")) -> list[Instruction]:
3535
"""
3636
return [
3737
Instruction(
38-
name=entry.name,
39-
path=entry,
40-
enabled=frontmatter.get("enabled", True),
41-
content=body,
38+
name=prim.path.name,
39+
path=prim.path,
40+
enabled=prim.frontmatter.get("enabled", True),
41+
content=prim.body,
4242
)
43-
for entry, frontmatter, body in discover_primitives(root, "instructions", INSTRUCTION_MARKER)
43+
for prim in discover_primitives(root, "instructions", INSTRUCTION_MARKER)
4444
]
4545

4646

src/ralphify/prompts.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ def discover_prompts(root: Path = Path(".")) -> list[Prompt]:
3232
"""
3333
return [
3434
Prompt(
35-
name=entry.name,
36-
path=entry,
37-
description=frontmatter.get("description", ""),
38-
enabled=frontmatter.get("enabled", True),
39-
content=body,
35+
name=prim.path.name,
36+
path=prim.path,
37+
description=prim.frontmatter.get("description", ""),
38+
enabled=prim.frontmatter.get("enabled", True),
39+
content=prim.body,
4040
)
41-
for entry, frontmatter, body in discover_primitives(root, "prompts", PROMPT_MARKER)
41+
for prim in discover_primitives(root, "prompts", PROMPT_MARKER)
4242
]
4343

4444

0 commit comments

Comments
 (0)