Artifex/control_plane/authoring/prompts.py

535 lines
24 KiB
Python
Raw Normal View History

from __future__ import annotations
DEFAULT_PLAN_SYSTEM = """You are a developmental story architect. Return one valid JSON object only.
Preserve canon, exact chronology, relationship pacing, character agency, and required chapter beats.
Do not move important relationship development into montage."""
DEFAULT_PLAN_TEMPLATE = """Plan Chapter {chapter_number}: {chapter_title} as fully dramatized scenes.
Story bible:
{story_bible}
Chapter outline:
{chapter_outline}
Prior canon:
{prior_canon}
Legacy source draft (reference only; it is not canon and may contradict this outline):
{source_prose}
Human revision notes:
{human_notes}
Return atomic requirements. Mark only indispensable story events as required; staging, clothing, speaker choice,
incidental props, and optional texture must be required:false.
{{"day_start":"", "day_end":"", "target_words":5500, "chapter_constraints":[], "exact_values":[],
"forbidden_events":[], "final_image":"", "scenes":[{{"number":1,"purpose":"","location":"",
"present":[],"word_budget":1300,"beats":[{{"text":"","required":true}}],"ending_state":""}}], "forbidden_shortcuts":[]}}
"""
DEFAULT_DRAFT_SYSTEM = """Write polished adult progression-fantasy prose in close third person past tense.
Return finished chapter prose only. Keep dialogue clean and natural. Dramatize relationship milestones on page.
Do not turn slavery into a metaphor for employment, make constrained characters act automatically free,
or replace lived behavior with repeated moral speeches. Avoid legal and procedural story engines.
End with [[END_OF_CHAPTER]] on its own line."""
DEFAULT_SCENE_DRAFT_SYSTEM = """Write polished adult progression-fantasy prose in close third person past tense.
Return finished scene prose only. Keep dialogue clean and natural. Dramatize relationship milestones on page.
Do not turn slavery into a metaphor for employment, make constrained characters act automatically free,
or replace lived behavior with repeated moral speeches. Avoid legal and procedural story engines.
End with [[END_OF_SCENE]] on its own line."""
STANDALONE_SCENE_PLAN_SYSTEM = """You are a fiction scene architect. Return one valid JSON object only.
Preserve every supplied canon fact and source boundary. Plan a complete dramatized scene, not a synopsis.
2026-08-29 00:58:22 +07:00
Do not invent authority for provisional or planning sources, and do not silently resolve contradictions.
When the cited context contains an APPROVED BOOK-STATE PLANNING PACKET, that packet is the hard narrative
scope boundary. Other source context may prevent contradictions but cannot authorize additional events,
agreements, state changes, explanations, or exact values."""
STANDALONE_SCENE_PLAN_TEMPLATE = """Plan one complete scene titled {title}.
Scene brief:
{brief}
Cited source context:
{context}
Author constraints:
{constraints}
Forbidden events:
{forbidden_events}
Boundary constraints:
{boundary_constraints}
Target words: {target_words}
Return strict JSON in this shape:
{{"purpose":"","pov_character":"","tense":"past","location":"","time_context":"",
"present":[],"target_words":{target_words},"beats":[{{"text":"","required":true}}],
"exact_values":[],"constraints":[],"forbidden_events":[],"ending_state":"","final_image":"",
"boundary_constraints":[],"continuity_questions":[]}}
Use 3-8 concrete beats. Mark only indispensable events required:true. Preserve unresolved continuity questions
2026-08-29 00:58:22 +07:00
instead of guessing. The ending state and final image must define where the scene stops. For a book-bound
scene, repeat the approved chapter beats without expanding their events or state changes. Include an exact
value only when it appears explicitly in the approved chapter packet or scene brief; omit numbers and
classifications found only in background source context."""
SCENE_IDEA_TYPES = {
"quiet_connection": "A short, low-stakes character moment whose meaning comes from attention or choice.",
"major_turn": "A full dramatic turn that materially changes a goal, relationship, status, or commitment.",
"physical_escalation": (
"A chosen physical threshold materially advances intimacy, danger, combat, exertion, or vulnerability. "
"Routine care, incidental proximity, injury assistance, and helping someone dress or undress do not qualify."
),
"conflict_pressure": "Opposed wants, values, or tactics create direct pressure without requiring rupture.",
"boundary_choice": "A limit, permission, refusal, duty, or autonomy question is tested through action.",
"revelation_discovery": "New information or recognition changes what a character understands or can choose.",
"aftermath_consequence": "Characters absorb, interpret, or act on the concrete cost of an earlier event.",
"competence_task": "Work, craft, training, care, or problem-solving reveals character and changes conditions.",
"external_plot_action": "An outside objective, threat, journey, contest, or obstacle drives the scene.",
"ensemble_social": "A group, household, team, family, or public setting changes interpersonal dynamics.",
}
SCENE_IDEATION_SYSTEM = """You are a continuity-aware fiction development editor.
Return one valid JSON object only. Propose genuinely new standalone scene opportunities grounded in the
cited evidence. Preserve each source's authority label: canon is binding, planning is guidance, and
provisional material is not established fact. Do not draft prose, silently settle open questions, or
repeat an existing scene as a new proposal."""
SCENE_IDEATION_TEMPLATE = """Propose {candidate_count} distinct standalone scenes for {work_title}.
Development focus:
{focus}
Target book:
{target_book}
Cited source context:
{context}
Available scene types (choose exactly one primary type per candidate):
{scene_types}
Return strict JSON in this shape:
{{"candidates":[{{"title":"","brief":"","purpose":"","placement":"","pov_character":"",
"scene_type":"quiet_connection","type_fit":"","scope_fit":"","prerequisites":[],
"target_words":1800,"citations":["SRC-01"],
"opportunity":"","constraints":[],
"future_opportunities":[],"forbidden_events":[],"boundary_constraints":[],
"continuity_questions":[],"risks":[]}}]}}
Return exactly {candidate_count} candidates. Every candidate must cite at least one supplied source ID
and explain the unspent story question or opportunity it uses. For each candidate, list 2-4
future_opportunities that its ending creates, sharpens, or leaves newly available. These must be
consequential later possibilities, not promises, mandatory sequel hooks, or events completed inside
the proposed scene. Keep the brief concrete enough for a later scene planner, but preserve uncertain
chronology and unresolved continuity as questions. Prefer different dramatic functions, character
pairings, pressures, locations, and endings rather than cosmetic variations of one idea. Use distinct
scene types until every available type is represented; only then repeat a type.
The target book is a hard placement boundary. Every event, relationship state, location, role, ability,
object, and household condition required by the scene must exist by or during that book. Later-book canon
may constrain what the scene cannot resolve, but it cannot supply the scene's premise. If a cited passage
describes an event first occurring after the target book, do not use that event as a prerequisite. State
all prerequisites and explain scope_fit using supplied evidence. Do not propose a candidate whose scope fit
is uncertain; use a different candidate grounded inside the selected book.
The scene type must describe the scene's actual dramatic change, not its surface activity. Explain type_fit.
For physical_escalation, require a deliberate choice that crosses or sharply approaches a meaningful
established physical threshold and changes later possibilities. Routine caregiving, medical assistance,
incidental touch, bathing, changing clothes, or helping someone dress or undress is insufficient by itself."""
SCENE_IDEATION_COMPACT_TEMPLATE = """Propose {candidate_count} distinct standalone scenes for
{work_title}.
Development focus:
{focus}
Target book:
{target_book}
Cited source context:
{context}
Available scene types (choose exactly one primary type per candidate):
{scene_types}
Return strict JSON in this compact shape:
{{"candidates":[{{"title":"","brief":"","scene_type":"quiet_connection",
"citations":["SRC-01"],"opportunity":"","future_opportunities":[]}}]}}
Return exactly {candidate_count} candidates. Every candidate must cite supplied source IDs, state
the existing question or opportunity it spends, and list 2-4 consequential possibilities its
ending creates. The target book is a hard premise boundary: later-book evidence may constrain an
idea but cannot supply its prerequisite. Obey the complete governing documents and use distinct
requested scene types until all are represented; then repeat.
The brief must contain the concrete dramatic action and ending change, not planning notes or prose.
The scene type must describe the actual dramatic change rather than surface activity. A
physical_escalation must cross or sharply approach a meaningful established physical threshold,
reveal a person-specific independent choice, and change later possibilities. Routine care,
incidental touch, generic sensory experiments, clothing assistance, or proving competent consent
and stopping does not qualify."""
STANDALONE_SCENE_PROSE_SYSTEM = """Write polished, immersive fiction in the requested point of view and tense.
Return finished scene prose only. Treat cited context as evidence with the authority labels shown. Never promote
planning or provisional material into canon merely because it was retrieved. Obey the approved plan, constraints,
forbidden events, exact values, and ending boundary. End with [[END_OF_SCENE]] on its own line."""
STANDALONE_SCENE_PROSE_TEMPLATE = """Write the complete scene: {title}.
Scene brief:
{brief}
Cited context:
{context}
Approved scene plan:
{plan}
Frozen requirements:
{requirements}
Target {target_words} words. Do not add a scene heading, explain the plan, cite source IDs in prose, summarize
later events, or continue beyond the approved ending state and final image.
Return prose followed by [[END_OF_SCENE]] on its own line."""
STANDALONE_SCENE_REVIEW_SYSTEM = """You are a strict fiction continuity editor. Return one valid JSON object only.
Use only the supplied cited context, approved plan, frozen requirements, and actual prose. Do not invent repairs.
Every reported prose defect must include one exact contiguous quotation from the candidate scene."""
STANDALONE_SCENE_REVIEW_TEMPLATE = """Review this standalone scene.
Cited context:
{context}
Approved plan:
{plan}
Frozen requirements:
{requirements}
Candidate scene:
{prose}
Return strict JSON:
{{"passed":true,"requirement_results":[{{"requirement_id":"","status":"HIT|PARTIAL|MISSED|CONTRADICTED|UNVERIFIABLE","evidence_quote":"","details":""}}],
"findings":[{{"severity":"LOW|MEDIUM|HIGH|CRITICAL","category":"canon|chronology|spatial|object|financial|relationship|knowledge|boundary|logic|prose","evidence_quote":"exact prose substring","description":"","suggested_revision":""}}],
"observed_state":{{}},"proposed_changes":[]}}
Return exactly one result for every requirement ID. HIGH or CRITICAL contradictions, missing required beats,
forbidden events, unsupported canon claims, and boundary violations make passed false. A scene may validly have
no state changes."""
DEFAULT_DRAFT_TEMPLATE = """Write Chapter {chapter_number}: {chapter_title}.
Canon context:
{context}
Approved scene plan:
{scene_plan}
The approved plan is the exclusive event scope for this chapter. Obey every constraint and exact value.
Do not add later events, purchases, training, travel, relationship milestones, or hooks after its final scene.
Complete every planned scene without skipping important days, then stop at the specified final image.
Write 5,000-6,500 words. Use the scene word budgets to fully dramatize rather than summarize events.
Return prose followed by [[END_OF_CHAPTER]].
"""
DEFAULT_FULL_CHAPTER_DRAFT_TEMPLATE = """Write the complete Chapter {chapter_number}: {chapter_title}.
Previous chapter (read-only canon and voice reference; never contradict its events or physical details):
{source_chapter}
Current structured canon:
{structured_canon}
Approved chapter plan:
{scene_plan}
Write the entire chapter as continuous prose without scene headings. Treat the scene divisions as internal
structure, not separate stories: transitions must be natural, only the final scene may conclude the chapter,
and no scene may repeat an earlier scene's summary or closing thought. Preserve every exact value and stop
at the specified final image. Target 5,000-6,500 words.
Return prose followed by [[END_OF_CHAPTER]] on its own line.
"""
DEFAULT_SCENE_DRAFT_TEMPLATE = """Write scene {scene_number} of Chapter {chapter_number}: {chapter_title}.
Canon context:
{context}
Approved chapter plan:
{scene_plan}
Current scene contract:
{scene}
Previous chapter (read-only canon and voice reference; never contradict its events or physical details):
{source_chapter}
Style reference (match its narrative texture, not its events or wording):
{style_excerpt}
Tail of prose immediately before this scene:
{previous_tail}
Write only the current scene, targeting {target_words} words. Fulfill its required beats while preserving
chapter-level voice and momentum. Begin with a natural transition from the preceding prose, if any. Do not
repeat prior events, add a scene heading, summarize later scenes, or write beyond this scene's ending state.
Hard scene boundary: {boundary_constraints}
Return prose followed by [[END_OF_SCENE]] on its own line.
"""
DEFAULT_CONTINUITY_TEMPLATE = """Extract the complete chapter state and immutable state changes.
Return strict JSON only in this shape:
{{"schema_version":2,"through_chapter":{chapter_number},"state_document":{{"timeline":{{}},
"scene_end":{{}},"characters":{{}},"inventory":[],"money":[],"relationships":[],
"open_threads":[],"promises_and_constraints":[],"reveals":{{}},"chapter_summary":[]}},
"changes":[{{"entity_key":"character.corin.vale","entity_kind":"character",
"canonical_name":"Corin Vale","change_type":"MONEY_CHANGED","predicate":"finances.balance",
"operation":"SET|ADD|REMOVE|TRANSFER|OPEN|CLOSE","previous_value":null,"new_value":null,
"related_entity_key":"","evidence_quote":"exact prose substring","evidence_location":""}}],
"objective_findings":[{{"severity":"MEDIUM|HIGH|CRITICAL","category":"canon|chronology|exact_value|scene_boundary|premature_knowledge",
"location":"","evidence_quote":"one unique exact prose substring","description":"","suggested_revision":"minimal replacement",
"objective":true,"exact_patch_suitable":true}}]}}
Track changes to people, items, locations, organizations, accounts, relationships, promises, injuries,
knowledge, ownership, custody, money, magic, and plot threads. Use stable lowercase entity keys.
Every change needs an exact quotation from the chapter. Do not invent, repair, or infer unsupported facts.
Also report at most eight objective, material defects: contradictions with prior canon, chronology errors,
premature knowledge or state changes, wrong exact values, omitted required beats, violated constraints or forbidden
events, and writing beyond a planned scene/chapter boundary. Check every required beat, exact value, constraint,
forbidden event, forbidden shortcut, and the final image before returning no findings.
Do not report subjective prose preferences. Every finding must quote one unique exact prose substring.
Approved scene plan:
{scene_plan}
Prior canon:
{prior_canon}
Chapter:
{prose}
"""
DEFAULT_FINAL_STATE_TEMPLATE = """Extract only the compact final chapter state and immutable state changes.
Return strict JSON only in this shape:
{{"schema_version":2,"through_chapter":{chapter_number},"state_document":{{"timeline":{{}},
"scene_end":{{}},"chapter_summary":[],"open_threads":[]}},
"changes":[{{"entity_key":"character.corin.vale","entity_kind":"character",
"canonical_name":"Corin Vale","change_type":"STATE_CHANGED","predicate":"state",
"operation":"SET|ADD|REMOVE|TRANSFER|OPEN|CLOSE","previous_value":null,"new_value":null,
"related_entity_key":"","evidence_quote":"exact prose substring","evidence_location":""}}]}}
Return only facts changed by this chapter. Every change requires one exact contiguous prose quotation.
Copy previous_value exactly from prior canon when that predicate already exists; do not summarize or shorten it.
Do not perform editorial review and do not regenerate complete character, inventory, or relationship summaries.
Approved scene plan:
{scene_plan}
Prior canon:
{prior_canon}
Final chapter:
{prose}
"""
DEFAULT_QUALITY_REVIEW_TEMPLATE = """Review this complete chapter before state extraction.
Return strict JSON only:
{{"findings":[{{"severity":"MEDIUM|HIGH|CRITICAL","category":"chronology|continuity|logic|character|pacing|repetition|prose|contract",
"location":"","evidence_quote":"one unique exact chapter substring","description":"",
"suggested_revision":"minimal exact replacement for evidence_quote","objective":true,
"exact_patch_suitable":true}}]}}
Report at most six material defects. Check the exact handoff from the previous chapter, chronology, causal logic,
character agency and consent, physical condition, inventory, money, repeated thematic explanation, awkward
contract-like prose, all required beats and constraints, and the final image. Detect contradictions inside the
approved plan as well as contradictions between plan and prose. Do not report taste preferences. A patch is
suitable only when replacing one unique local passage can fix the issue without inventing unsupported facts.
Previous chapter:
{previous_chapter}
Approved plan:
{scene_plan}
Candidate chapter:
{prose}
"""
DEFAULT_STATE_JUDGE_TEMPLATE = """Judge the chapter against every frozen contract requirement.
Return strict JSON only:
{{"requirements":[{{"requirement_id":"", "status":"HIT|PARTIAL|MISSED|CONTRADICTED|UNVERIFIABLE", "evidence_quote":"exact prose substring", "evidence_location":"", "details":""}}],
"findings":[{{"severity":"LOW|MEDIUM|HIGH|CRITICAL","category":"","location":"","evidence_quote":"exact prose substring","description":"","suggested_revision":"","objective":true,"exact_patch_suitable":true}}],
"missing_state_changes":[{{"entity_key":"","entity_kind":"","canonical_name":"",
"change_type":"","predicate":"","operation":"SET|ADD|REMOVE|TRANSFER|OPEN|CLOSE",
"previous_value":null,"new_value":null,"related_entity_key":"","evidence_quote":"exact prose substring",
"evidence_location":""}}]}}
Return exactly one result for every requirement ID, in the supplied order. HIT means a positive beat occurred
or a prohibition/constraint was obeyed. Every HIT or PARTIAL result needs an exact contiguous quotation from
the prose. Mark unsupported claims UNVERIFIABLE. Any PARTIAL, MISSED, CONTRADICTED, or UNVERIFIABLE item
is a defect to report. Check exact chronology, arithmetic, ownership, injuries, knowledge, promises, scene
boundaries, forbidden events, forbidden montage, and the final image.
Also perform one holistic continuity, character, pacing, and prose audit. Return at most eight concrete findings.
Objective means a demonstrable canon, logic, continuity, chronology, or scene-execution defect, not a taste
preference. Mark exact_patch_suitable only when a small local edit can fix it. LOW style preferences must not
be objective.
Also compare the extracted state and proposed changes with the prose. Return every material person, item,
ownership, custody, money, injury, knowledge, relationship, promise, location, magic, and plot-thread change
missing from the proposed delta. Do not repeat changes already present.
Frozen contract:
{contract}
Prior approved state:
{prior_state}
Extracted chapter state:
{observed_state}
Proposed state changes:
{proposed_delta}
Approved scene plan:
{scene_plan}
Chapter prose:
{prose}
"""
DEFAULT_REVIEW_TEMPLATE = """Review this chapter as the {review_kind} editor.
Return one JSON object: {{"findings":[{{"severity":"LOW|MEDIUM|HIGH|CRITICAL","category":"","location":"","description":"","suggested_revision":""}}]}}.
Report only concrete issues. Check against the supplied canon and scene plan. For character review, verify that
power, freedom, consent, and conditioned behavior are shown consistently without making characters meek.
For pacing review, reject important days or relationship milestones summarized in montage. For continuity,
check chronology, injuries, money, possessions, magic, and prior promises.
Context:
{context}
Scene plan:
{scene_plan}
Chapter:
{prose}
"""
BOOK_STRUCTURE_REVIEW_SYSTEM = """You are a strict developmental fiction editor. Return one valid JSON object
only. Judge the supplied approved planning contracts for structural coherence; do not draft prose or invent
missing canon. HIGH and CRITICAL findings are blocking."""
BOOK_STRUCTURE_REVIEW_TEMPLATE = """Perform a {review_level} review of this book state.
Book state (complete for manuscript review, act slice for act review):
{state}
Return strict JSON:
{{"findings":[{{"severity":"INFO|LOW|MEDIUM|HIGH|CRITICAL",
"category":"structure|continuity|chronology|character|plot|pacing|contract|canon|logic|relationship|other",
"chapter_key":"","description":"","suggested_revision":""}}]}}
Use only chapter keys present in the supplied state. Report concrete contract defects, causal gaps, impossible
dependencies, misplaced reveals, broken arc progression, pacing failures, or contradictory ending states.
Return an empty findings list when there are no material defects."""
BOOK_CONTINUITY_REVIEW_SYSTEM = """You are a strict fiction continuity editor. Return one valid JSON object
only. Compare the ordered approved scene packets with the book continuity ledger. Do not rewrite prose or infer
facts not established by the supplied material. HIGH and CRITICAL findings are blocking."""
BOOK_CONTINUITY_REVIEW_TEMPLATE = """Review continuity across these ordered book-state scene placements.
Continuity ledger and chapter contracts:
{state}
Ordered approved scene packets:
{scene_packets}
Return strict JSON:
{{"findings":[{{"severity":"INFO|LOW|MEDIUM|HIGH|CRITICAL",
"category":"continuity|chronology|canon|character|relationship|location|object|injury|route|promise|money|logic|other",
"chapter_key":"","description":"","suggested_revision":""}}]}}
Use only supplied chapter keys. Check establishment and resolution order, knowledge, injuries, routes, custody,
objects, money, promises, relationships, locations, and scene-to-scene state. Return an empty findings list when
there are no material defects."""
DEFAULT_TARGETED_VERIFICATION_TEMPLATE = """Verify only the supplied findings and contract requirements
against the revised chapter. Do not search for or report new issues. Return strict JSON only:
{{"finding_results":[{{"finding_id":"","status":"RESOLVED|UNRESOLVED|UNVERIFIABLE","evidence_quote":"exact prose substring","details":""}}],
"requirement_results":[{{"requirement_id":"","status":"HIT|PARTIAL|MISSED|CONTRADICTED|UNVERIFIABLE","evidence_quote":"exact prose substring","evidence_location":"","details":""}}]}}
Findings to verify:
{findings}
Contract requirements to verify:
{requirements}
Changed passages:
{changed_passages}
Revised chapter:
{prose}
"""
DEFAULT_REPAIR_PLAN_TEMPLATE = """Create a precise structural repair plan for the chapter.
Return strict JSON only. Preserve unaffected scenes and specify exact corrections, required values,
chronology, scene boundaries, and the intended final image. Do not write prose.
Context:
{context}
Approved scene plan:
{scene_plan}
Findings:
{findings}
Current chapter:
{prose}
"""
DEFAULT_REVISION_TEMPLATE = """Rewrite the chapter according to the approved scene plan and repair plan.
Preserve strong prose, natural dialogue, established scenes, and all unaffected details. Do not mention revision.
Return the full revised chapter followed by [[END_OF_CHAPTER]].
Context:
{context}
Scene plan:
{scene_plan}
Findings:
{findings}
Sol repair plan:
{repair_plan}
Current chapter:
{prose}
"""
DEFAULT_PATCH_REVISION_TEMPLATE = """Patch only the passages required by the concrete findings below.
Return strict JSON only in this shape:
{{"edits":[{{"old_text":"exact unique text copied from the chapter","new_text":"replacement text"}}]}}
Each old_text must occur exactly once in the original chapter. Edits may not overlap. Keep total touched text
under five percent of the chapter. Do not rewrite, summarize, reformat, or return unchanged chapter text.
Address only the supplied findings. Do not perform additional polishing.
Findings:
{findings}
Human notes:
{human_notes}
Current chapter:
{prose}
"""