Compare commits

..

2 Commits

View File

@@ -5,247 +5,187 @@ description: Use when analyzing manuscript chapters for repeated phrases, contin
# Manuscript Analysis # Manuscript Analysis
Multi-agent pipeline for analyzing manuscript chapters. Invoke with book number and chapter range: `/manuscript-analysis 1 1-5` Three-agent pipeline for analyzing manuscript chapters. Invoke with book number and chapter range: `/manuscript-analysis 1 1-5`
## On Invoke ## On Invoke
Parse args: first arg = book number (`BOOK`), second arg = chapter range (`XX-YY`). If missing, ask the user. Parse args: first = book number (`BOOK`), second = chapter range (`XX-YY`). If missing, ask.
Set `XX` = start chapter (zero-padded), `YY` = end chapter (zero-padded). Zero-pad `XX` and `YY` to 2 digits.
### Validate ### Validate
1. For each chapter in range, verify `chapters/book{BOOK}/ch{NN}-final.md` exists 1. Verify each `chapters/book{BOOK}/ch{NN}-final.md` exists. If any missing, report and stop.
2. If any are missing, report which and stop 2. Ensure `notes/analysis/` exists.
3. Create `notes/analysis/` directory if it doesn't exist
### File Naming ### Output file naming
All output files use: `notes/analysis/book{BOOK}-{type}-ch{XX}-{YY}.md` `notes/analysis/book{BOOK}-{type}-ch{XX}-{YY}.md`
Where `{XX}` and `{YY}` are zero-padded to 2 digits (e.g., `ch01-05`, `ch16-21`).
--- ---
## Phase 1: Phrase Analysis ## Dispatch (parallel)
Run two agents **sequentially** (1B depends on 1A's output). Dispatch all three agents **in a single message** with parallel Agent tool calls. They are independent. Use `subagent_type: "general-purpose"` for each.
### Agent 1A — Phrase Indexer All three prompts share these rules — include them verbatim at the bottom of each agent prompt:
Dispatch via Agent tool with `subagent_type: "general-purpose"`:
``` ```
prompt: | RULES:
You are a phrase indexer for a manuscript analysis pipeline. Your job is to find repeated phrases across chapter files. - Do NOT spawn subagents. Do all work directly.
- Tool-call budget: ≤15 calls total. Prioritize ruthlessly.
**Target chapters:** Read these files fully: - Write your full report to the specified output file.
{list each chapters/book{BOOK}/ch{NN}-final.md in the range XX to YY} - Return to the orchestrator a summary ≤300 words with file:line refs for
the top findings. Do NOT restate the file contents in your response.
**Task:**
1. Read all target chapter files
2. Extract candidate phrases: multi-word expressions (2-4 words) that appear 3 or more times within the target range. Also flag distinctive single words used excessively (adverbs, specific adjectives — not common words like "the", "was", "had", "said").
3. For EACH candidate phrase, use the Grep tool to count occurrences across ALL chapter files in chapters/book{BOOK}/ (not just the target range). Use: Grep with pattern="{phrase}" path="chapters/book{BOOK}/" output_mode="count"
4. Record results in a markdown table with columns: Phrase | Count in Ch {XX}-{YY} | Count in Full Book | Chapters Found In
5. Sort by full-book count descending
6. Write the complete index to: notes/analysis/book{BOOK}-phrase-index-ch{XX}-{YY}.md
**Important:**
- Use Grep for counting — do NOT try to load all chapters into context
- Include both the target-range count and the full-book count
- Skip extremely common phrases ("he said", "I was", "it was") — focus on distinctive repeated expressions
- Include a header noting the date, book number, and chapter range analyzed
Do NOT use the Agent tool. Do all work directly. Write only research output, no code.
``` ```
### Agent 1B — Phrase Analyst ### Agent A — Phrase & Pattern Analyst
After Agent 1A completes, dispatch: Output: `notes/analysis/book{BOOK}-phrase-analysis-ch{XX}-{YY}.md`
``` ```
prompt: | You are a literary editor analyzing a manuscript for repetition patterns.
You are a literary editor analyzing a fantasy manuscript for phrase repetition patterns.
**Read these files:** READ:
- Target chapters: {list each chapters/book{BOOK}/ch{NN}-final.md in the range XX to YY} - Target chapters: {list chapters/book{BOOK}/ch{NN}-final.md for XX..YY}
- Phrase index: notes/analysis/book{BOOK}-phrase-index-ch{XX}-{YY}.md (from prior analysis) - Voice guidelines: CLAUDE.md sections 5 and 11
- Voice guidelines: CLAUDE.md (sections 5 and 11 — Phelan's voice and style guide)
**Task:** TASK:
1. Read the target chapters with a literary editor's eye Read the target chapters. Identify:
2. Using the phrase index as a starting point, analyze: 1. Crutch phrases — repeated constructions that are authorial habit, not voice
- **Structural repetition**: Repeated sentence structures, paragraph openings, or narrative beats (not just repeated words) 2. Structural repetition — paragraph openings, sentence shapes, scene-break patterns
- **Crutch phrases**: Transitions, beats, or narration patterns that appear to be authorial habit rather than character voice 3. Overused transitions
- **Overused transitions**: Words/phrases used to connect scenes or ideas that have become repetitive 4. Intentional voice patterns to PROTECT (per CLAUDE.md) — list these so
3. Distinguish between: future cleanup passes don't prune features
- **Intentional voice patterns**: Phelan's established mannerisms per CLAUDE.md (dry observations, ADD tangents, precise cataloguing) — these are FEATURES, not bugs 5. Deliberate callbacks to PROTECT — thematic repetition that is load-bearing
- **Authorial habits**: Repetition that doesn't serve the voice or narrative
- **Intentional callbacks**: Phrases repeated deliberately for thematic or narrative effect
4. For each finding, provide: the phrase/pattern, example quotes with chapter references, frequency assessment, and whether it's voice vs. habit
5. Write the complete analysis to: notes/analysis/book{BOOK}-phrase-analysis-ch{XX}-{YY}.md
**Format the output as:** You may use a few targeted Grep counts if a phrase looks suspicious, but do
- Header with date, book, chapter range NOT build an exhaustive index. A literary-editor read of three chapters
- Section 1: Crutch Phrases & Overused Expressions (highest priority) finds crutches directly. Budget grep calls within the 15-call total.
OUTPUT FILE FORMAT:
- Header: date, book, chapter range
- Section 1: Crutch Phrases & Overused Expressions (priority order)
- Section 2: Structural Repetition Patterns - Section 2: Structural Repetition Patterns
- Section 3: Overused Transitions - Section 3: Overused Transitions
- Section 4: Intentional Voice Patterns (noted but not flagged as problems) - Section 4: Protected Voice Patterns
- Section 5: Effective Callbacks & Deliberate Repetition - Section 5: Protected Callbacks
Do NOT use the Agent tool. Do all work directly. Write only research output, no code. [+ shared RULES block]
```
### Agent B — Continuity Checker
Output: `notes/analysis/book{BOOK}-continuity-ch{XX}-{YY}.md`
If `(YY - XX + 1) > 7`, split into two parallel agents (B1 = first half, B2 = second half), each writing its own file — then the orchestrator merges into the final continuity file during aggregation.
```
You are a continuity editor finding inconsistencies and contradictions.
READ:
- Target chapters: {list chapters/book{BOOK}/ch{NN}-final.md for assigned range}
- world/story-summary-book{BOOK}.md
- world/timeline-book{BOOK}.md
- world/magic/exploits-log.md
- world/magic/runic-flow-rules.md
- world/economy.md
- Relevant files in characters/ (Glob first, read only ones referenced in the chapters)
- Relevant files in world/locations/ (same approach)
CHECK:
1. Timeline (bells, days, elapsed time vs. timeline file)
2. Character consistency (names, knowledge, descriptions vs. character files)
3. World facts (currency, locations, magic usage vs. reference files)
4. Plot threads (picked up / dangling per story summary)
5. Internal contradictions within the target range
Each finding: Category | Severity (Critical/Important/Minor) | quote with
chapter ref | what it contradicts | suggested fix.
OUTPUT FILE FORMAT:
- Header: date, book, chapter range
- Summary table by severity
- Findings grouped by category, numbered
[+ shared RULES block]
```
### Agent C — Story Craft Analyst
Output: `notes/analysis/book{BOOK}-storycraft-ch{XX}-{YY}.md`
```
You are a developmental editor analyzing story craft quality.
READ:
- Target chapters: {list chapters/book{BOOK}/ch{NN}-final.md for XX..YY}
- world/story-summary-book{BOOK}.md
- outline/book{BOOK}-outline.md
- CLAUDE.md
- chapters/book{BOOK}/CLAUDE.md
ANALYZE 8 categories:
1. Premise & Conflict — clarity, escalation, per-chapter mini-conflict
2. Character Arcs — Phelan's growth, supporting cast serving their briefs
3. Foreshadowing — seeds planted, earlier setups being paid off
4. POV Consistency — every paragraph sounds like Phelan, observe vs. know
5. Pacing — action/investigation/quiet distribution, chapter-length fit
6. World-Building Integration — woven vs. dumped
7. The Noise Convention — frequency (4-6 establishing, 3-5 ongoing), narrative work
8. What's Working Well — specific craft wins with quotes
For each: assessment, 1-3 examples with chapter refs, suggestions.
OUTPUT FILE FORMAT:
- Header: date, book, chapter range
- 2-3 sentence executive summary
- 8 numbered sections
[+ shared RULES block]
``` ```
--- ---
## Phase 2: Continuity Check ## Phase 2: Aggregation
Determine agent count: if `(YY - XX + 1) > 7`, split into two agents (2A handles first half of range, 2B handles second half). Otherwise, use one agent. Performed by the orchestrator directly. Do NOT dispatch a subagent.
### Agent 2A — Continuity Checker 1. Work from the **returned summaries** of the three agents. Do NOT re-read the full output files unless a summary is unclear or a finding needs verification.
Dispatch via Agent tool with `subagent_type: "general-purpose"`: 2. If continuity was split (B1 + B2), read both continuity files and merge into one before writing the aggregate.
``` 3. Write the consolidated report to `notes/analysis/book{BOOK}-analysis-ch{XX}-{YY}.md`:
prompt: |
You are a continuity editor for a fantasy manuscript. Your job is to find inconsistencies, timeline errors, and contradictions.
**Read these files:**
- Target chapters: {list each chapters/book{BOOK}/ch{NN}-final.md in the assigned range}
- Story summary: world/story-summary-book{BOOK}.md
- Timeline: world/timeline-book{BOOK}.md
- Exploits log: world/magic/exploits-log.md
- Magic rules: world/magic/runic-flow-rules.md
- Economy: world/economy.md
- All files in characters/ (use Glob to find them, then read relevant ones)
- All files in world/locations/ (use Glob to find them, then read relevant ones)
**Check for:**
1. **Timeline consistency**: Do bell references, day-of-week mentions, and elapsed time match the timeline file? Flag any mismatches with specific quotes.
2. **Character consistency**: Are names spelled consistently? Do characters know things they shouldn't (or forget things they should know)? Do physical descriptions match character files?
3. **World-building facts**: Do currency amounts match economy.md? Do location descriptions match location files? Does magic usage follow runic-flow rules?
4. **Plot threads**: Are threads from earlier chapters (per story summary) picked up appropriately? Are there dangling threads that seem forgotten?
5. **Internal contradictions**: Do facts within the target range contradict each other? (e.g., a character described as tall in ch3 and short in ch5)
**For each finding, provide:**
- Category (Timeline / Character / World / Plot Thread / Internal)
- Severity (Critical = plot hole or major contradiction, Important = notable inconsistency, Minor = nitpick)
- The specific text with chapter and approximate location
- What it contradicts (with reference to the source file)
- Suggested resolution
**Write the complete report to:** notes/analysis/book{BOOK}-continuity-ch{XX}-{YY}.md
**Format:**
- Header with date, book, chapter range
- Summary of findings by severity
- Detailed findings grouped by category
- Each finding numbered for easy reference
Do NOT use the Agent tool. Do all work directly. Write only research output, no code.
```
If the range was split, Agent 2B gets an identical prompt but with its half of the chapter range. After both complete, the orchestrator merges their outputs into a single `book{BOOK}-continuity-ch{XX}-{YY}.md` file.
---
## Phase 3: Story Craft
### Agent 3A — Story Craft Analyst
Dispatch via Agent tool with `subagent_type: "general-purpose"`:
```
prompt: |
You are a developmental editor analyzing a fantasy manuscript for story craft quality.
**Read these files:**
- Target chapters: {list each chapters/book{BOOK}/ch{NN}-final.md in the range XX to YY}
- Story summary: world/story-summary-book{BOOK}.md
- Book outline: outline/book{BOOK}-outline.md
- Master instructions: CLAUDE.md (full file — contains voice guide, style rules, character bible)
- Book-specific instructions: chapters/book{BOOK}/CLAUDE.md
**Analyze the following 8 categories:**
1. **Premise & Conflict**: Is the central conflict clear and advancing across these chapters? Are stakes escalating appropriately? Does each chapter have its own mini-conflict that serves the larger arc?
2. **Character Arcs**: Is Phelan's growth visible (even if incremental)? Are supporting cast members serving their narrative functions as defined in CLAUDE.md? Are character motivations clear and consistent?
3. **Foreshadowing**: Are seeds being planted for future payoffs? Are setups subtle enough to avoid telegraphing? Are earlier setups (from story summary) being paid off in these chapters?
4. **POV Consistency**: Does every paragraph sound like Phelan? Are there slips into omniscient narration? Does Phelan observe/deduce information rather than magically knowing it?
5. **Pacing**: How are action/investigation/quiet beats distributed? Are there stretches that drag or rush? Does chapter length vary appropriately with content?
6. **World-Building Integration**: Is world detail woven into action and observation, or dumped as exposition? Does the world feel lived-in?
7. **The Noise Convention**: Are parenthetical tangents (*like this*) at the right frequency (4-6 per chapter establishing, 3-5 ongoing)? Are they doing narrative work (revealing character, advancing plot, providing humor) rather than just being decorative?
8. **What's Working Well**: Specific callouts of strong passages, effective techniques, great character moments, and well-executed craft. Be specific with quotes.
**For each category, provide:**
- Overall assessment for the chapter range
- Specific examples with chapter references and quotes
- Suggestions where applicable
**Write the complete analysis to:** notes/analysis/book{BOOK}-storycraft-ch{XX}-{YY}.md
**Format:**
- Header with date, book, chapter range
- Executive summary (2-3 sentences)
- One section per analysis category (numbered 1-8)
- Each section: assessment, examples, suggestions
Do NOT use the Agent tool. Do all work directly. Write only research output, no code.
```
---
## Phase 4: Aggregation
The orchestrator (you, the main session) performs this phase directly. Do NOT dispatch a subagent.
1. Read all intermediate reports:
- `notes/analysis/book{BOOK}-phrase-index-ch{XX}-{YY}.md`
- `notes/analysis/book{BOOK}-phrase-analysis-ch{XX}-{YY}.md`
- `notes/analysis/book{BOOK}-continuity-ch{XX}-{YY}.md`
- `notes/analysis/book{BOOK}-storycraft-ch{XX}-{YY}.md`
2. Write a consolidated report to `notes/analysis/book{BOOK}-analysis-ch{XX}-{YY}.md` with:
**Format:**
``` ```
# Manuscript Analysis: Book {BOOK}, Chapters {XX}{YY} # Manuscript Analysis: Book {BOOK}, Chapters {XX}{YY}
**Date:** {today} **Date:** {today}
**Chapters analyzed:** {count} **Chapters analyzed:** {count}
**Analysis phases:** Phrase Analysis, Continuity, Story Craft
## Summary ## Summary
- Critical issues: {count} - Critical: {n} | Important: {n} | Suggestions: {n}
- Important issues: {count}
- Suggestions: {count}
## Critical Issues ## Critical Issues
{items from all reports rated Critical — plot holes, major continuity breaks, significant voice failures} {plot holes, major contradictions, significant voice failures}
## Important Issues ## Important Issues
{items rated Important — repeated phrases needing attention, notable inconsistencies, craft improvements} {notable repetition, continuity mismatches, craft fixes}
## Suggestions ## Suggestions
{lower-priority items — minor repetition, style polish, optional improvements} {minor polish, optional improvements}
## What's Working Well ## What's Working Well
{positive findings from story craft report} {craft wins from story-craft summary}
## Protected Patterns (do not touch in cleanup)
{voice features and callbacks flagged by phrase analyst}
## Detailed Reports ## Detailed Reports
See individual analysis files for full details:
- Phrase index: book{BOOK}-phrase-index-ch{XX}-{YY}.md
- Phrase analysis: book{BOOK}-phrase-analysis-ch{XX}-{YY}.md - Phrase analysis: book{BOOK}-phrase-analysis-ch{XX}-{YY}.md
- Continuity: book{BOOK}-continuity-ch{XX}-{YY}.md - Continuity: book{BOOK}-continuity-ch{XX}-{YY}.md
- Story craft: book{BOOK}-storycraft-ch{XX}-{YY}.md - Story craft: book{BOOK}-storycraft-ch{XX}-{YY}.md
``` ```
3. Deduplicate: if multiple agents flagged the same issue, consolidate into one entry and note which analyses found it. 4. Deduplicate cross-agent findings; note which analyses flagged each.
4. Present a brief summary to the user with the consolidated report path and top findings. 5. Present a brief summary to the user (headline count + top 3-5 issues + path to aggregate file).