This commit is contained in:
Lars committed 2026-08-25 17:16:35 +02:00
1 parent fd7102e3b3
commit 60f0d2830d
17 files changed
+1502 -257

No files matched your search

+51
View File
@@ -84,6 +84,7 @@ __all__ = [
"EXISTING_BEFORE_NEW",
"seed_catalog",
"INITIAL_BUILD_SOURCES",
"compile_task_brief",
]
@@ -1061,6 +1062,56 @@ def _assemble_brief(profile_id: str) -> None:
)
def compile_task_brief(profile_id: str, task: str = "journal_generate") -> str:
"""Runtime brief for one task. Not an export, import, or proposal format."""
from writing_profile_schema import is_meta_style_text
profile = get_profile(profile_id)
parts = []
core = profile.get("core") or {}
if core.get("value"):
parts.append("Core: " + (core.get("value") or ""))
traits = [item for item in profile.get("traits") or [] if item.get("status") == "active"]
if task == "journal_generate":
facet = next(
(
item
for item in profile.get("facets") or []
if item.get("facet_key") == "autobiographical_journal" and (item.get("value") or "")
),
None,
)
if facet:
parts.append("Autobiografisches Journaling (Facet-Delta): " + (facet.get("value") or ""))
relevant = [
item
for item in traits
if item.get("facet_key") in {"autobiographical_journal", "core", ""} and (item.get("statement") or "")
]
if not relevant:
relevant = [item for item in traits if item.get("statement")]
for item in relevant[:6]:
line = f"- {item.get('label') or item.get('slug')}: {item.get('statement')}"
exemplars = [
ref.get("excerpt")
for ref in item.get("exemplars") or []
if ref.get("excerpt") and not is_meta_style_text(ref.get("excerpt"))
]
if exemplars:
line += " Beispiel: " + exemplars[0][:TRAIT_EXCERPT_CHARS]
parts.append(line)
if parts:
return "\n".join(parts).strip()
ranked = _load_ranked_sources(profile_id)
snippets = (ranked.get("journal_entry") or [])[:2] + (ranked.get("imported_text") or [])[:1]
lines = []
for item in snippets:
body = plain_text(item.get("body") or "")[:280]
if body and not is_meta_style_text(body):
lines.append(body)
return "\n\n".join(lines).strip()
def has_facets(profile_id: str) -> bool:
"""True when a semantic layer or trait exists. Not a substitute for confirmed lifecycle."""
with get_db() as conn: