Fix blank project.yml files -- add name, goal, genre, audience, chapter counts and correct intent templates for whispers-in-the-dark, echoes-of-the-forest, book-marketing-agency, and marketing-strategy

This commit is contained in:
David Baity
2026-04-30 23:54:16 -04:00
parent 44884eeb60
commit 4c943a30ee
10 changed files with 860 additions and 4 deletions

View File

@@ -0,0 +1,127 @@
name: human_polish_brief
description: "Produces a targeted human polish brief for a chapter that requires voice correction, style diversity improvement, or AI-fingerprint reduction."
debug: false
model: power
system: agent_prompt
agent_prompt:
- "= identity.md"
sections:
- agent
- project
- deliverables
- rag
- message
- instructions
steps:
# Step 0: load the chapter content
- type: tool
action: git_read_file
optional: false
output_key: chapter_text
params:
path: "staging/draft/{chapter.slug}.md"
# Step 1: load the slop gate flag report if available
- type: tool
action: git_read_file
optional: true
output_key: slop_gate_report
params:
path: "staging/flags/slop_gate_flag_{task.parent_id}.md"
# Step 2: load voice signature for comparison
- type: tool
action: git_read_file
optional: true
output_key: voice_signature
params:
path: "agents/{agent.name}/voice_signature.json"
# Step 3: load the chapter outline for this chapter
- type: tool
action: git_read_file
optional: true
output_key: chapter_brief
params:
path: "staging/briefs/brief-{chapter.slug}.md"
# Step 4: produce the full human polish brief
- type: think
max_tokens: 3000
output_key: polish_brief
hint: |
You are {agent.name}, producing a Human Polish Brief for {project.name}.
The brief tells a human editor exactly what to fix in this chapter and why.
Chapter content: the DELIVERABLES section above.
Slop gate report: {slop_gate_report}
Author voice signature: {voice_signature}
Chapter brief / outline: {chapter_brief}
Structure your brief as follows:
## Human Polish Brief -- {chapter.slug}
### Why This Chapter Needs Human Revision
[2-3 sentences: what triggered this brief. Be specific. Cite gate scores if available.]
### Priority Revision Targets
[4-8 numbered items. For each:]
- LOCATION: paragraph N or approximate position in chapter
- QUOTE: the exact passage (1-3 sentences) that needs revision
- PROBLEM: what makes this feel AI-generated or voice-wrong
- DIRECTION: what the human should do instead (specific, not vague)
### Voice Calibration Notes
[3-5 bullet points on what authentic voice for this author and project sounds like.
If voice_signature is available, reference the pacing_profile and register.
If not available, derive from the project genre and character context.]
### Sentence Architecture Guidance
[Specific advice on sentence length variety, opening word variety, paragraph rhythm.
Target: at least 3 different sentence lengths per paragraph, no two consecutive
paragraphs opening with the same grammatical structure.]
### Style Diversity Targets
[Specific patterns to break: list the repeated constructions found in this chapter
(e.g., "5 of 12 paragraphs begin with 'She'") and alternatives.]
### Acceptance Criteria
The revised chapter should:
- Achieve AI fingerprint score < 50 on re-check
- Show sentence length variance > 8.0
- Have opening word repetition rate < 0.25
- Preserve all plot beats and character beats from the chapter brief
- Maintain the genre and audience register
Output ONLY the brief text above. No preamble.
# Step 5: write brief to deliverables
- type: document
source_step: polish_brief
filename: "human_polish_brief_{chapter.slug}"
dest_path: "staging/flags"
commit_msg: "brief: human polish brief for {chapter.slug} -- task {task.id}"
# Step 6: reply to channel
- type: reply
target: channel
channel_name: "crimson_leaf_publishing:live-feed"
hint: |
Post: "Human Polish Brief ready for {chapter.slug}. Saved to staging/flags/.
Assign to a human editor or David for manual revision before re-running the slop gate."
adjudication:
enabled: true
pass_threshold: 65
deliverable_type: brief
criteria:
specificity:
weight: 40
description: "Revision targets quote actual text and give specific direction"
completeness:
weight: 35
description: "All required sections present with meaningful content"
actionability:
weight: 25
description: "A human editor can follow the brief without additional context"

405
templates/kdp_publish.yml Normal file
View File

@@ -0,0 +1,405 @@
name: kdp_publish
description: "KDP publishing pipeline. Hard prerequisites in order: chapter readiness, manuscript-level slop gate (AI fingerprint + style diversity + human polish log within 7 days), KDP compliance, KDP throttle window. Failing any prerequisite halts upload and routes to a remediation task. No operator override -- the only path past a failed gate is the remediation task succeeding and the pipeline being re-run."
debug: false
model: power
system: agent_prompt
agent_prompt:
- "= identity.md"
sections:
- agent
- project
- deliverables
- rag
- message
- instructions
steps:
# =========================================================================
# STAGE 1: Readiness check -- all chapters polished?
# =========================================================================
- type: tool
action: git_read_file
optional: false
output_key: canonical_manifest
params:
path: "canonical_manifest.json"
- type: tool
action: git_read_file
optional: true
output_key: pipeline_status
params:
path: "pipeline_status.json"
- type: tool
action: git_read_file
optional: false
output_key: book_metadata
params:
path: "publishing/metadata.yml"
- type: think
max_tokens: 600
output_key: readiness_check
hint: |
You are {agent.name} checking if {project.name} is ready for KDP submission.
Canonical manifest: {canonical_manifest}
Pipeline status: {pipeline_status}
Check:
1. Are ALL chapters listed in the manifest in "polished" status?
2. Is the total word count above 20,000 words? (KDP minimum for a full novel)
3. Is there a metadata.yml with title, description, keywords, categories,
author name, and price_usd?
If all checks pass, output:
READINESS: GO
[brief summary of chapter count, word count, and book title]
If any check fails, output:
READINESS: BLOCKED
[specific list of what is missing]
- type: think
max_tokens: 20
output_key: readiness_status
hint: |
Read the READINESS line from the check above.
Output ONLY the word: GO or BLOCKED. Nothing else.
- type: branch
condition: "{readiness_status} == BLOCKED"
target: publish_blocked
# =========================================================================
# STAGE 2: Assemble manuscript and inject AI disclosure into description
# =========================================================================
- type: tool
action: assemble_manuscript
optional: false
output_key: manuscript_result
params:
project_id: "{project.id}"
output_format: "plain_text"
- type: think
max_tokens: 800
output_key: enriched_metadata
hint: |
You are preparing the KDP submission metadata for {project.name}.
Existing metadata YAML:
{book_metadata}
Sprint 84j requirement: the description MUST contain an AI-disclosure
sentence near the end. KDP's content-policy rule R007 requires this and
Tool.SlopDetector.check_kdp_compliance will fail without it.
If the description already contains language matching any of:
"AI-assisted", "AI assisted", "AI-generated", "AI generated",
"artificial intelligence", "written with AI", "created with AI"
then leave it as-is.
Otherwise, append exactly one short paragraph at the END of the description:
"This book was developed with AI assistance under human creative direction.
The story, characters, and creative choices were shaped by the author in
collaboration with an AI writers' room."
Re-emit the FULL metadata as a JSON object with these keys (use real values
from the YAML; do not invent any):
title, author, description, price_usd, keywords (array), categories (array)
Output ONLY the JSON. No preamble, no markdown fence.
# =========================================================================
# STAGE 3: Slop gate -- AI fingerprint + style diversity (manuscript-level)
# Hard prerequisite for KDP upload. Failure spawns human_polish_brief.
# =========================================================================
- type: tool
capability: Tool_SlopDetector
optional: false
output_key: ai_fingerprint
params:
action: "detect_ai_fingerprint"
text: "{manuscript_result.text}"
provider_pool: ["local_heuristic"]
- type: tool
capability: Tool_SlopDetector
optional: false
output_key: style_analysis
params:
action: "analyse_style_diversity"
text: "{manuscript_result.text}"
- type: tool
action: git_read_file
optional: true
output_key: human_polish_log
params:
path: "publishing/human_polish_log.md"
- type: think
max_tokens: 800
output_key: slop_gate_assessment
hint: |
You are {agent.name} acting as the manuscript-level slop gate for
{project.name}. Sprint 84j requires three independent pass conditions
before KDP upload may proceed. Be strict. Do NOT rationalise borderline
results upward.
AI fingerprint (Tool.SlopDetector.detect_ai_fingerprint): {ai_fingerprint}
Style diversity (Tool.SlopDetector.analyse_style_diversity): {style_analysis}
Human polish log (publishing/human_polish_log.md): {human_polish_log}
Today is {task.created_utc}.
DIMENSION 1 -- AI FINGERPRINT (PASS if aggregate_score < 65)
Read aggregate_score from ai_fingerprint. Lower is better.
If aggregate_score < 65: PASS
Otherwise: FAIL with the score and any provider disagreement noted
DIMENSION 2 -- STYLISTIC QUALITY (PASS if all of the below)
- sentence_length_variance > 8.0 (chapter rhythm not flat)
- opening_word_repetition_rate < 0.15 (paragraphs do not all start the same)
- metaphor_family_clusters >= 3 (imagery is not single-register)
- dialogue_tag_diversity >= 6 (or 0 if there is genuinely no dialogue)
Any single failure means the dimension FAILs. List which thresholds missed.
DIMENSION 3 -- HUMAN POLISH (PASS if there is a polish_log entry whose
timestamp is within the last 7 days)
If human_polish_log is empty or its newest entry is older than 7 days:
FAIL.
If a polish entry exists within 7 days: PASS.
OUTPUT EXACTLY this format:
KDP_FINGERPRINT: PASS|FAIL
<one-sentence justification with score>
KDP_STYLE: PASS|FAIL
<one-sentence justification with the specific style metrics that crossed/missed>
KDP_POLISH: PASS|FAIL
<one-sentence justification citing the most recent polish_log timestamp or its absence>
KDP_OVERALL: PASS|FAIL
<PASS only if all three dimensions are PASS; otherwise FAIL>
REMEDIATION_BRIEF:
<if KDP_OVERALL is FAIL: 3-6 sentences describing what the human polish task should
target -- specific chapters, specific style metrics, specific opening passages.
If KDP_OVERALL is PASS: write the literal string "n/a">
- type: think
max_tokens: 20
output_key: slop_gate_status
hint: |
Read the KDP_OVERALL line from the assessment above.
Output ONLY the word: PASS or FAIL. Nothing else.
- type: document
source_step: slop_gate_assessment
filename: "slop-gate-{task.id}"
dest_path: "deliverables/slop-gate"
commit_msg: "slop_gate: manuscript verdict for kdp_publish task {task.id}"
- type: branch
condition: "{slop_gate_status} == FAIL"
target: slop_gate_failed
# =========================================================================
# STAGE 4: KDP compliance check (Tool.SlopDetector check_kdp_compliance)
# =========================================================================
- type: tool
capability: Tool_SlopDetector
optional: false
output_key: compliance_result
params:
action: "check_kdp_compliance"
metadata: "{enriched_metadata}"
manuscript_text: "{manuscript_result.text}"
- type: think
max_tokens: 400
output_key: compliance_evaluation
hint: |
Review the KDP compliance check result: {compliance_result}
If all_pass is true: output GO
If any rule failed: list the failed rules and output BLOCKED with reasons.
Output exactly:
COMPLIANCE: GO
or
COMPLIANCE: BLOCKED
[list of failed rules with rule_id and issue]
- type: think
max_tokens: 20
output_key: compliance_status
hint: |
Read the COMPLIANCE line from the evaluation above.
Output ONLY the word: GO or BLOCKED. Nothing else.
- type: branch
condition: "{compliance_status} == BLOCKED"
target: compliance_blocked
# =========================================================================
# STAGE 5: KDP throttle gate -- daily and weekly upload caps
# =========================================================================
- type: tool
action: kdp_throttle_check
optional: false
output_key: throttle_result
- type: think
max_tokens: 20
output_key: throttle_status
hint: |
Read the throttle_result JSON: {throttle_result}
Output ONLY one of these two words based on the verdict field:
PROCEED (if verdict is "PROCEED")
HALT (if verdict is "HALT")
Nothing else.
- type: branch
condition: "{throttle_status} == HALT"
target: throttle_blocked
# =========================================================================
# STAGE 6: Format manuscript and validate cover (Tool.AmazonKdp)
# =========================================================================
- type: tool
capability: Tool_AmazonKdp
optional: false
output_key: format_result
params:
action: "kdp_format_manuscript"
manuscript_text: "{manuscript_result.text}"
manuscript_result: "{manuscript_result}"
- type: tool
capability: Tool_AmazonKdp
optional: false
output_key: cover_validation
params:
action: "kdp_validate_cover"
image_path: "publishing/cover.jpg"
# =========================================================================
# STAGE 7: Upload (only reached when ALL gates pass)
# =========================================================================
- type: tool
capability: Tool_AmazonKdp
optional: false
output_key: upload_result
params:
action: "kdp_upload_book"
metadata: "{enriched_metadata}"
epub_path: "{format_result.epub_artifact_path}"
cover_path: "publishing/cover.jpg"
is_ai_assisted: true
# Record the upload against the throttle counter so the next run respects the cap.
- type: tool
action: kdp_throttle_record
optional: true
output_key: throttle_record_result
- type: document
source_step: upload_result
filename: "kdp_submission_{task.id}"
dest_path: "publishing/submissions"
commit_msg: "kdp: submission record {task.id} -- ASIN {upload_result.asin}"
- type: reply
target: channel
channel_name: "crimson_leaf_publishing:live-feed"
hint: |
Post: "PUBLISHED: {project.name} live on Amazon.
ASIN: {upload_result.asin}
Status: {upload_result.status}
URL: {upload_result.sales_page_url}"
- type: close
rag_update: true
# =========================================================================
# FAIL PATHS
# =========================================================================
- type: label
name: slop_gate_failed
- type: tool
action: enqueue_strategy
optional: false
params:
company_slug: "crimson_leaf_publishing"
project_slug: "{project.slug}"
task_type: "human_polish_brief"
content: "Slop gate failed for {project.name} during kdp_publish task {task.id}. See deliverables/slop-gate/slop-gate-{task.id}.md for the assessment. The remediation brief in that document defines what the human polish pass must address. Re-run kdp_publish after the polish is committed to the manuscript and a new entry appears in publishing/human_polish_log.md."
- type: reply
target: channel
channel_name: "crimson_leaf_publishing:live-feed"
hint: |
Post: "KDP upload HALTED for {project.name} -- slop gate failed.
Verdict written to deliverables/slop-gate/. Human polish task spawned.
Re-run kdp_publish after human polish is committed."
- type: close
rag_update: false
- type: label
name: publish_blocked
- type: reply
target: channel
channel_name: "crimson_leaf_publishing:live-feed"
hint: |
Post: "KDP publish BLOCKED for {project.name} -- manuscript not ready.
Details: {readiness_check}"
- type: close
rag_update: false
- type: label
name: compliance_blocked
- type: reply
target: channel
channel_name: "crimson_leaf_publishing:live-feed"
hint: |
Post: "KDP publish BLOCKED for {project.name} -- compliance check failed.
Details: {compliance_evaluation}"
- type: close
rag_update: false
- type: label
name: throttle_blocked
- type: reply
target: channel
channel_name: "crimson_leaf_publishing:live-feed"
hint: |
Post: "KDP upload DEFERRED for {project.name} -- throttle window not open.
Throttle response: {throttle_result}.
Retry kdp_publish after the throttle window opens. The slop gate, compliance,
and assembly results all PASSED -- only the rate limit is blocking."
- type: close
rag_update: false
adjudication:
enabled: false

145
templates/slop_gate.yml Normal file
View File

@@ -0,0 +1,145 @@
name: slop_gate
description: "AI-slop detection gate -- runs after chapter_production to catch AI fingerprinting. Fails the gate if aggregate AI score is too high; routes to human_polish_brief if flagged."
debug: false
model: power
system: agent_prompt
agent_prompt:
- "= identity.md"
sections:
- agent
- project
- rag
- message
- instructions
steps:
# Step 0: load the chapter content from staging
- type: tool
action: git_read_file
optional: false
output_key: chapter_text
params:
path: "staging/draft/{chapter.slug}.md"
# Step 1: run AI fingerprint detection via Tool.SlopDetector
- type: tool
capability: Tool_SlopDetector
optional: false
output_key: ai_detection_result
params:
action: "detect_ai_fingerprint"
text: "{chapter_text}"
provider_pool: ["local_heuristic"]
# Step 2: run style diversity analysis
- type: tool
capability: Tool_SlopDetector
optional: true
output_key: style_analysis_result
params:
action: "analyse_style_diversity"
text: "{chapter_text}"
# Step 3: load the author voice signature for comparison
- type: tool
action: git_read_file
optional: true
output_key: voice_signature
params:
path: "agents/{agent.name}/voice_signature.json"
# Step 4: evaluate the detection results
- type: think
max_tokens: 800
output_key: gate_evaluation
hint: |
You are {agent.name} evaluating a slop gate check for a chapter from {project.name}.
AI detection result: {ai_detection_result}
Style diversity analysis: {style_analysis_result}
Author voice signature: {voice_signature}
Rules:
- If aggregate_score >= 75: the chapter has strong AI fingerprinting. Flag it.
- If aggregate_score >= 50 and sentence_length_variance < 5.0: mixed signal. Flag it.
- If aggregate_score < 50 and opening_word_repetition_rate < 0.3: PASS.
- If voice_signature is available and pacing_profile or register is very different
from the signature, note the drift even if score is below threshold.
Output one of:
GATE_STATUS: PASS
GATE_STATUS: FLAG
Then provide 2-3 sentences explaining the decision.
If flagging, list 2-3 specific signals that triggered the flag (e.g., sentence
length variance, AI fingerprint score, opening word repetition).
# Step 5: extract the gate status
- type: think
max_tokens: 20
output_key: gate_status
hint: |
Read the GATE_STATUS line from the evaluation above.
Output ONLY the word: PASS or FLAG. Nothing else.
# Step 6: if PASS -- close and log
- type: branch
condition: "{gate_status} == PASS"
target: close_gate
# Step 7: if FLAG -- produce human polish brief and halt chapter for review
- type: think
max_tokens: 1200
output_key: polish_brief
hint: |
The slop gate has flagged this chapter. You are writing a Human Polish Brief --
a set of specific, actionable instructions for a human editor to revise this chapter.
Base your brief on:
- The AI detection signals identified in the evaluation
- The style diversity analysis (which sentence patterns are too uniform?)
- The voice signature drift (if any)
- The actual chapter text
Your brief must include:
1. WHAT TRIGGERED THE FLAG: the specific signals (be numerical where possible)
2. THE CORE PROBLEM: one sentence describing the main issue (e.g., "Every paragraph
begins with a pronoun and has nearly identical sentence length.")
3. REVISION TARGETS: 4-6 specific passages or patterns that need human rewriting.
Quote the actual text. Say what makes it feel AI-generated.
4. VOICE GUIDANCE: what the author's authentic voice should feel like for this
project and chapter. Reference the voice signature if available.
5. ACCEPTANCE CRITERIA: what the chapter needs to score on re-check to pass the gate.
Output ONLY the brief text. No preamble.
- type: document
source_step: polish_brief
filename: "slop_gate_flag_{task.id}"
dest_path: "staging/flags"
commit_msg: "slop_gate: flag {chapter.slug} for human polish -- task {task.id}"
- type: reply
target: channel
channel_name: "crimson_leaf_publishing:live-feed"
hint: |
Post: "Slop gate FLAGGED {chapter.slug} -- human polish required. Brief saved to
staging/flags/. AI score: {ai_detection_result.aggregate_score}."
- type: close
rag_update: false
# Gate pass path
- type: label
name: close_gate
- type: reply
target: channel
channel_name: "crimson_leaf_publishing:live-feed"
hint: |
Post: "Slop gate PASSED {chapter.slug} -- AI score within acceptable range."
- type: close
rag_update: false
adjudication:
enabled: false