This commit is contained in:
Lars committed 2026-08-29 20:28:59 +02:00
1 parent be11f82f84
commit e42f751fdc
47 files changed
+3359 -301

No files matched your search

+24 -9
View File
@@ -1186,23 +1186,34 @@ def _assemble_brief(profile_id: str) -> None:
)
def compile_task_brief(profile_id: str, task: str = "journal_generate") -> str:
def compile_task_brief(
profile_id: str,
task: str = "journal_generate",
*,
include_core: bool = True,
include_facet: bool = True,
include_traits: bool = True,
) -> str:
"""Compact confirmed style brief. Historical texts are selected separately.
Unconfirmed profiles do not become a style authority. Journal adapters attach
final entries as STYLE_EXAMPLES, not as extra rules in this brief.
final entries as STYLE_EXAMPLES, not as extra rules in this brief. Callers may
omit core, facet or traits; omitted parts are not rendered as empty headings.
"""
profile = get_profile(profile_id)
if task != "journal_generate":
core = (profile.get("core") or {}).get("value") or ""
return _clip_field(core, TASK_BRIEF_MAX_CHARS)
if not include_core and not include_facet and not include_traits:
return ""
if not has_confirmed_profile(profile_id):
return NEUTRAL_JOURNAL_STYLE
parts: list[str] = []
core_text = ((profile.get("core") or {}).get("value") or "").strip()
if core_text:
core_text = ((profile.get("core") or {}).get("value") or "").strip() if include_core else ""
if include_core and core_text:
clipped = _clip_field(core_text, TASK_BRIEF_CORE_CHARS)
if clipped:
parts.append("Core: " + clipped)
@@ -1214,13 +1225,14 @@ def compile_task_brief(profile_id: str, task: str = "journal_generate") -> str:
),
None,
)
facet_text = ((facet or {}).get("value") or "").strip()
if facet_text and _norm_overlap(facet_text, core_text) < 0.8:
facet_text = ((facet or {}).get("value") or "").strip() if include_facet else ""
if include_facet and facet_text and _norm_overlap(facet_text, core_text) < 0.8:
clipped = _clip_field(facet_text, TASK_BRIEF_FACET_CHARS)
if clipped:
parts.append("Autobiografisches Journaling (Facet-Delta): " + clipped)
selected = _select_task_traits(profile.get("traits") or [])
selected = _select_task_traits(profile.get("traits") or []) if include_traits else []
used_statements = [core_text, facet_text]
trait_lines: list[str] = []
for item in selected:
statement = (item.get("statement") or "").strip()
if any(_norm_overlap(statement, previous) >= 0.85 for previous in used_statements if previous):
@@ -1228,8 +1240,9 @@ def compile_task_brief(profile_id: str, task: str = "journal_generate") -> str:
clipped = _clip_field(statement, TASK_BRIEF_TRAIT_CHARS)
if not clipped:
continue
parts.append(f"- {item.get('label') or item.get('slug')}: {clipped}")
trait_lines.append(f"- {item.get('label') or item.get('slug')}: {clipped}")
used_statements.append(statement)
parts.extend(trait_lines)
brief = "\n".join(part for part in parts if part).strip()
while len(brief) > TASK_BRIEF_MAX_CHARS and parts:
last = parts.pop()
@@ -1240,7 +1253,9 @@ def compile_task_brief(profile_id: str, task: str = "journal_generate") -> str:
brief = "\n".join(parts).strip()
break
brief = "\n".join(parts).strip()
return brief or NEUTRAL_JOURNAL_STYLE
if include_core and include_facet and include_traits:
return brief or NEUTRAL_JOURNAL_STYLE
return brief
def has_facets(profile_id: str) -> bool: