Skip to content

Commit 86728a2

Browse files
claudedanjdewhurst
authored andcommitted
feat: add continuity engine, manuscript import, and PR automation templates
- New src/continuity.js: deterministic continuity checks wired into a new 'story continuity' command and folded into doctor, report, and next. Catches dead characters appearing after their died-in chapter, payoffs before plants, questions resolved before introduced, unfired Chekhov promises, POV/cast mismatches, chapter numbering gaps, completion-state contradictions, and broken continuity/state.md references. - New schema fields: optional character died-in, and chapter/scene mentions for posthumous or flashback references that should stay legal. - New src/import.js: 'story import' splits an existing manuscript (file or directory) into a new project with accurate word counts and registries, and prints recurring proper-name candidates for bible building. - New examples/the-unraveled-thread: deliberately broken project whose exact findings are asserted by check-examples.js, doubling as the README demo and a regression test. Harbor example enriched with populated continuity state, a planted promise, and an open question. - New templates/github: story-checks.yml CI for story repos and draft-next-chapter.yml for writing a book via scheduled chapter PRs. - CLI failure summaries now use a failure message instead of repeating the success message. Docs, skills, JSON schema updated; version 0.3.0. https://claude.ai/code/session_01XVwAnE2xRMVd7CZR4MrSU1
1 parent 8197155 commit 86728a2

61 files changed

Lines changed: 2766 additions & 221 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "story-skills",
3-
"version": "0.2.1",
3+
"version": "0.3.0",
44
"description": "A suite of cross-referenced skills and CLI maintenance tools for end-to-end story writing powered by markdown. Covers story initialization, character management, worldbuilding, plot structure, chapter writing, revision, validation, reporting, indexing, word counts, and manuscript export.",
55
"author": {
66
"name": "Daniel Dewhurst"

.codex-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "story-skills",
3-
"version": "0.2.1",
3+
"version": "0.3.0",
44
"description": "A suite of cross-referenced skills and CLI maintenance tools for end-to-end story writing powered by markdown. Covers story initialization, character management, worldbuilding, plot structure, chapter writing, revision, validation, reporting, indexing, word counts, and manuscript export.",
55
"author": {
66
"name": "Daniel Dewhurst",

README.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
Story Skills gives agents a shared project format for fiction: a story bible, character files, worldbuilding notes, factions, artifacts, plot arcs, scene state, continuity questions, promises/payoffs, timelines, and chapter drafts. Everything is plain markdown with YAML frontmatter, packaged as standard Agent Skills with Codex and Claude Code plugin support.
88

9+
The companion CLI treats the story bible as a checkable contract: a **continuity engine** catches dead characters walking, payoffs that land before their setup, unfired Chekhov guns, and stale story state — deterministically, before a reader ever could.
10+
911
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
1012
[![Agent Skills](https://img.shields.io/badge/Agent_Skills-SKILL.md-blue)](https://agentskills.io)
1113
[![Codex](https://img.shields.io/badge/Codex-plugin-10A37F)](https://developers.openai.com/codex)
@@ -40,6 +42,26 @@ bunx skills add danjdewhurst/story-skills
4042

4143
Then ask **"Start a new story"** to scaffold the project.
4244

45+
## 🔎 The Continuity Engine
46+
47+
Long-range consistency is the thing language models are worst at and prompts cannot fix. Story Skills makes it deterministic: character deaths, promises/payoffs, open questions, scene casts, and durable knowledge/object state live in frontmatter, and `story continuity` treats contradictions like a compiler treats type errors.
48+
49+
[`examples/the-unraveled-thread/`](examples/the-unraveled-thread/) is a deliberately broken mystery. It passes `story validate` and `story links` cleanly — every file is well-formed — but the story itself doesn't hold together:
50+
51+
```text
52+
$ story continuity examples/the-unraveled-thread
53+
Continuity check failed: 4 errors, 3 warnings
54+
error: chapters/chapter-04.md lists edran-vale, who died in chapter-02; move posthumous appearances to mentions
55+
error: continuity/promises/the-broken-compass.md pays off in chapter-02 before it is planted in chapter-03
56+
error: continuity/questions/who-burned-the-mill.md resolves in chapter-02 before it is introduced in chapter-03
57+
error: continuity/state.md knowledge-state[0] references missing chapter chapter-05
58+
warning: chapters/chapter-03.md POV character nessa-thorn is not listed in characters
59+
warning: continuity/promises/the-sealed-letter.md was planted in chapter-01, 3 chapters ago, and has no payoff yet
60+
warning: continuity/state.md object-state[0] status active conflicts with worldbuilding/artifacts/vales-compass.md status destroyed
61+
```
62+
63+
These findings are exact, file-addressed, and reproducible — CI asserts them on every commit. Intentional flashbacks and posthumous appearances stay legal via the chapter `mentions` field. `story doctor` and `story next` fold the same checks into prioritized repair actions.
64+
4365
## ✍️ Highly Recommended: Better Writing
4466

4567
For stronger chapter drafts and revision passes, install [forjd/better-writing](https://github.com/forjd/better-writing) alongside Story Skills. It adds voice calibration, anti-generic writing checks, and a final prose-quality pass.
@@ -225,7 +247,7 @@ For non-agent use:
225247
| **plot-structure** | Plans arcs with structures like three-act, hero's journey, Save the Cat, and kishotenketsu | *"Create a plot arc"* |
226248
| **chapter-writing** | Drafts chapters through an outline-first workflow that pulls from story context | *"Write the next chapter"* |
227249
| **revision-continuity** | Revises drafts, audits continuity, and keeps character state, timeline, and arc changes consistent | *"Continuity-check chapter 3"* |
228-
| **story-maintenance** | Runs deterministic CLI checks for validation, reports, indexing, links, word counts, and export | *"Validate my story project"* |
250+
| **story-maintenance** | Runs deterministic CLI checks for validation, continuity, reports, indexing, links, word counts, import, and export | *"Validate my story project"* |
229251

230252
For stronger prose, pair **chapter-writing** with [**better-writing**](https://github.com/forjd/better-writing).
231253

@@ -253,6 +275,8 @@ The CLI is for deterministic maintenance only. Agents should write story content
253275
| `story reindex [path]` | Rebuild registry tables from the current markdown files |
254276
| `story wordcount [path] --write` | Count chapter prose and update chapter frontmatter plus the chapter registry |
255277
| `story links [path]` | Check character, location, chapter, and arc cross-references/backlinks |
278+
| `story continuity [path]` | Check deterministic continuity contracts: deaths, promises/payoffs, questions, casts, and durable state |
279+
| `story import draft.md --title "The Lost Coast"` | Split an existing manuscript into a new story project and suggest entity candidates |
256280
| `story report [path] --actionable` | Summarize inventory and optionally include next actions |
257281
| `story next [path]` | Recommend the next deterministic writing or maintenance actions |
258282
| `story doctor [path]` | Show health checks with actionable repair steps |
@@ -278,6 +302,25 @@ bun run check:fallback
278302
node skills/story-maintenance/scripts/story.js --help
279303
```
280304

305+
## 🤖 Write A Book Via Pull Requests
306+
307+
A story project with deterministic checks is a story project an agent can advance unattended. The [`templates/github/`](templates/github/) workflows turn a story repository into a self-drafting book:
308+
309+
- [`story-checks.yml`](templates/github/story-checks.yml) runs `story validate`, `story links`, and `story continuity` on every push and pull request, so a chapter PR cannot merge with a continuity contradiction.
310+
- [`draft-next-chapter.yml`](templates/github/draft-next-chapter.yml) runs [Claude Code](https://github.com/anthropics/claude-code-action) on a schedule: it asks `story next` for the next deterministic action, drafts the next chapter with the chapter-writing skill, updates scene records and continuity state, runs the maintenance checks, and opens a pull request for review.
311+
312+
Copy both files into `.github/workflows/` in the repository that holds your story project, add an `ANTHROPIC_API_KEY` secret, and review one chapter PR per morning.
313+
314+
## 📥 Import An Existing Manuscript
315+
316+
Most writers don't start from a blank page. `story import` reverse-engineers a Story Skills project from work in progress:
317+
318+
```shell
319+
story import draft.md --title "The Lost Coast" --genre mystery
320+
```
321+
322+
It splits the manuscript on chapter headings (or imports a directory of chapter files), creates the full project layout with accurate word counts and registries, and prints recurring proper-name candidates so an agent can follow up with `story add character` and `story add location` to build out the bible.
323+
281324
## 📁 Project Structure
282325

283326
Running **story-init** creates this layout:
@@ -328,7 +371,8 @@ Every story element is a markdown file with YAML frontmatter. The skills cross-r
328371

329372
- Read [**The Cormorant Tide**](https://github.com/danjdewhurst/the-cormorant-tide), a full story project generated with Story Skills.
330373
- Explore [`examples/the-last-ember/`](examples/the-last-ember/) for a complete fantasy example: three characters, two locations, a magic system, a plot arc with foreshadowing, and a drafted first chapter.
331-
- Explore [`examples/harbor-of-second-light/`](examples/harbor-of-second-light/) for a near-future coastal mystery example with memory technology, a posthumous witness arc, and a drafted first chapter.
374+
- Explore [`examples/harbor-of-second-light/`](examples/harbor-of-second-light/) for a near-future coastal mystery example with memory technology, a posthumous witness arc, populated continuity state, and a drafted first chapter.
375+
- Explore [`examples/the-unraveled-thread/`](examples/the-unraveled-thread/) for a deliberately broken project that demonstrates every class of finding the continuity engine reports.
332376

333377
## 🚢 Releasing
334378

docs/first-20-minutes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,12 @@ story wordcount . --write
6363
story reindex .
6464
story links .
6565
story validate .
66+
story continuity .
6667
story next .
6768
story doctor .
6869
```
6970

70-
Use `story next .` before a drafting session. Use `story doctor .` when something feels inconsistent or stale.
71+
Use `story next .` before a drafting session. Use `story doctor .` when something feels inconsistent or stale. Use `story continuity .` after every chapter to catch contradictions - dead characters reappearing, payoffs landing before their setup, stale story state - before a reader does.
7172

7273
## 6. Build The Manuscript
7374

docs/schema-v2.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ glossary/terms/
3333
- Registries are deterministic and rebuilt with `story reindex .`.
3434
- Chapter prose word counts are recalculated with `story wordcount . --write`.
3535
- Cross-reference integrity is checked with `story links .`.
36+
- Continuity contracts (deaths, promises/payoffs, questions, casts, durable state) are checked with `story continuity .`.
3637

3738
## Entity Frontmatter
3839

@@ -46,6 +47,8 @@ Required: `name`, `role`, `status`.
4647

4748
Optional lists: `aliases`, `relationships`, `locations`, `tags`.
4849

50+
Optional scalar: `died-in`, the chapter id in which the character dies on the page. Set it together with `status: deceased`; `story continuity` then errors on appearances in later chapters. Characters who died before chapter 1 should use `status: deceased` without `died-in`.
51+
4952
### Worldbuilding
5053

5154
Locations require `name` and `type`. Systems require `name` and `type`.
@@ -60,14 +63,22 @@ Arcs require `name`, `type`, and `status`; they may list `characters`, `themes`,
6063

6164
### Chapters And Scenes
6265

63-
Chapters require `title`, `number`, and `status`; optional reference lists are `locations`, `characters`, and `arcs-advanced`.
66+
Chapters require `title`, `number`, and `status`; optional reference lists are `locations`, `characters`, `mentions`, and `arcs-advanced`.
67+
68+
Scenes require `title`, `chapter`, `scene`, and `status`. Scenes carry machine-readable continuity fields: `pov`, `location`, `characters`, `mentions`, `arcs-advanced`, and `state-changes`.
6469

65-
Scenes require `title`, `chapter`, `scene`, and `status`. Scenes carry machine-readable continuity fields: `pov`, `location`, `characters`, `arcs-advanced`, and `state-changes`.
70+
`characters` means present in-scene. `mentions` means referenced, remembered, recorded, or seen in flashback; deceased characters may appear there without triggering continuity errors.
6671

6772
### Continuity
6873

6974
`continuity/state.md` stores `current-chapter`, `character-state`, `object-state`, and `knowledge-state`.
7075

76+
State entries are lists of mappings checked by `story continuity`:
77+
78+
- `character-state` entries reference an existing `character` and optionally a `location`, plus free-form `physical`, `emotional`, and `knowledge` notes.
79+
- `object-state` entries reference an existing `artifact`, an optional `owner` (character or faction), an optional `location`, and a `status` that must agree with the artifact file.
80+
- `knowledge-state` entries reference an existing `character`, a non-empty `knows` fact, and an optional `learned-in` chapter id.
81+
7182
Questions require `title` and `status`; optional chapter references are `introduced` and `resolved`.
7283

7384
Promises require `title` and `status`; optional chapter references are `planted` and `payoff`.

examples/harbor-of-second-light/chapters/chapter-01.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ locations:
77
- port-kestrel
88
characters:
99
- mara-quill
10+
mentions:
1011
- theo-quill
1112
arcs-advanced:
1213
- the-drowned-witness

examples/harbor-of-second-light/continuity/promises/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ story: harbor-of-second-light
99

1010
| Promise | Status | Planted | File |
1111
|---------|--------|---------|------|
12-
| *No promises yet* | | | |
12+
| The Bell Failsafe | planted | chapter-01 | [the-bell-failsafe](the-bell-failsafe.md) |
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
title: The Bell Failsafe
3+
status: planted
4+
planted: chapter-01
5+
payoff: ""
6+
arcs:
7+
- the-drowned-witness
8+
characters:
9+
- mara-quill
10+
- theo-quill
11+
---
12+
13+
# The Bell Failsafe
14+
15+
## Setup
16+
17+
The bell under Bellwether Reef rang on its own when the storm cracked the sealed chamber. Theo built it as a failsafe: if the bell rings, the archive is live again.
18+
19+
## Payoff
20+
21+
A later chapter must reveal what the failsafe was meant to summon - and who else heard the bell.
22+
23+
## Tracking Notes
24+
25+
Keep planted and payoff chapters current.

examples/harbor-of-second-light/continuity/questions/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ story: harbor-of-second-light
99

1010
| Question | Status | Introduced | File |
1111
|----------|--------|------------|------|
12-
| *No questions yet* | | | |
12+
| What Happened On Blackout Night | open | chapter-01 | [what-happened-on-blackout-night](what-happened-on-blackout-night.md) |
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: What Happened On Blackout Night
3+
status: open
4+
introduced: chapter-01
5+
resolved: ""
6+
characters:
7+
- mara-quill
8+
- theo-quill
9+
- ilya-venn
10+
---
11+
12+
# What Happened On Blackout Night
13+
14+
## Question
15+
16+
Theo's recording says the Afterimage Archive was active during the Blackout Night. Twelve residents died and Theo took the blame. What was the archive doing, and on whose orders?
17+
18+
## Evidence
19+
20+
- The sealed chamber under Bellwether Reef carries Harbor Authority plating.
21+
- Theo's recording was hidden before his death and addressed to Mara.
22+
- Councillor Venn controls the archive-keeper appointments.
23+
24+
## Resolution Plan
25+
26+
Resolve once Mara confronts Venn with the lantern's contents.

0 commit comments

Comments
 (0)