Answer stability round 1: 0 🔴, 2 🟡 (0 misread); inject home into the goals file lookup and rename readme in ranking
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
import pathlib
|
||||
|
||||
from failure import Failure
|
||||
from project_config.main import goals_file
|
||||
from loop_claude.project.text_file import read_utf8
|
||||
from records.markdown_text import sections
|
||||
|
||||
|
||||
def read_premises(root: str) -> str | Failure:
|
||||
"""## Goals and ## Audience in the file root's project config names for them; a Failure where no config names it, it cannot be read, or it lacks either, or holds one twice or empty."""
|
||||
path = goals_file(root)
|
||||
def read_premises(root: str, home: pathlib.Path) -> str | Failure:
|
||||
"""The goals file's path, then its ## Goals and ## Audience; the goals file is the one that the config under home of root's project names. A Failure where no config names root's checkout, the file cannot be read, or the file lacks a section, holds one twice or leaves one empty."""
|
||||
path = goals_file(root, home)
|
||||
if isinstance(path, Failure):
|
||||
return Failure(f"{path.reason} - no premises.")
|
||||
text = read_utf8(str(path.parent), path.name, "no premises")
|
||||
@@ -16,9 +18,9 @@ def read_premises(root: str) -> str | Failure:
|
||||
for name in ("Goals", "Audience"):
|
||||
bodies = found.get(name, [])
|
||||
if not bodies:
|
||||
return Failure(f"{path.name} has no ## {name} heading - no premises.")
|
||||
return Failure(f"{path} has no ## {name} heading - no premises.")
|
||||
if len(bodies) > 1:
|
||||
return Failure(f"{path.name} has ## {name} more than once - no premises.")
|
||||
return Failure(f"{path} has ## {name} more than once - no premises.")
|
||||
if not bodies[0]:
|
||||
return Failure(f"{path.name} has no text under ## {name} - no premises.")
|
||||
return f"## Goals\n{found['Goals'][0]}\n\n## Audience\n{found['Audience'][0]}"
|
||||
return Failure(f"{path} has no text under ## {name} - no premises.")
|
||||
return f"{path}:\n## Goals\n{found['Goals'][0]}\n\n## Audience\n{found['Audience'][0]}"
|
||||
|
||||
Reference in New Issue
Block a user