Ship the official Analyzer system prompt and make it loadable/overridable, per MASTER_SPEC §13. - prompts/analyzer_system_prompt.md: the official prompt assembled from §13.1- §13.12 (deterministic semantic parser; extract explicit concepts only; never generate tags or invent information; ignore subjective/artistic language; explicit camera/lighting/environment only; independent characters with scene-level interactions; preserve unknown concepts; return valid JSON only, no markdown) plus the §12.2 Scene JSON output shape and example. - compiler/analyzer/system_prompt.py: load_default_system_prompt() reads the shipped default; resolve_system_prompt(config) returns config.analyzer. system_prompt when set, otherwise the default. - Add optional analyzer.system_prompt to the config model and schema (nullable). Tests: default file loads, a parametrized drift guard asserting every required §13 directive is present, output-shape keys present, config override and default resolution, and config round-trip of the override. Co-authored-by: kunail0804 <kunail0804@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
29 lines
971 B
Python
29 lines
971 B
Python
"""Loading of the official Analyzer system prompt (MASTER_SPEC §13).
|
|
|
|
The default prompt ships under ``prompts/`` and defines the Analyzer's behaviour
|
|
(extract explicit concepts only; never generate tags or invent information). It is
|
|
overridable via ``config.analyzer.system_prompt``.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from compiler.common.config import Config
|
|
|
|
DEFAULT_SYSTEM_PROMPT_PATH = (
|
|
Path(__file__).resolve().parent.parent.parent / "prompts" / "analyzer_system_prompt.md"
|
|
)
|
|
|
|
|
|
def load_default_system_prompt() -> str:
|
|
"""Return the official system prompt shipped under ``prompts/``."""
|
|
return DEFAULT_SYSTEM_PROMPT_PATH.read_text(encoding="utf-8")
|
|
|
|
|
|
def resolve_system_prompt(config: Config) -> str:
|
|
"""Return the configured system prompt, or the shipped default when unset."""
|
|
if config.analyzer.system_prompt is not None:
|
|
return config.analyzer.system_prompt
|
|
return load_default_system_prompt()
|