scriveno 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +222 -0
  3. package/agents/continuity-checker.md +85 -0
  4. package/agents/drafter.md +248 -0
  5. package/agents/plan-checker.md +209 -0
  6. package/agents/researcher.md +114 -0
  7. package/agents/translator.md +204 -0
  8. package/agents/voice-checker.md +154 -0
  9. package/bin/install.js +1620 -0
  10. package/commands/scr/add-note.md +51 -0
  11. package/commands/scr/add-unit.md +101 -0
  12. package/commands/scr/art-direction.md +225 -0
  13. package/commands/scr/autopilot-publish.md +210 -0
  14. package/commands/scr/autopilot-translate.md +237 -0
  15. package/commands/scr/autopilot.md +200 -0
  16. package/commands/scr/back-matter.md +630 -0
  17. package/commands/scr/back-translate.md +197 -0
  18. package/commands/scr/beta-reader.md +97 -0
  19. package/commands/scr/blurb.md +149 -0
  20. package/commands/scr/book-proposal.md +210 -0
  21. package/commands/scr/build-ebook.md +448 -0
  22. package/commands/scr/build-poetry-submission.md +202 -0
  23. package/commands/scr/build-print.md +598 -0
  24. package/commands/scr/build-smashwords.md +171 -0
  25. package/commands/scr/build-world.md +158 -0
  26. package/commands/scr/cast-list.md +104 -0
  27. package/commands/scr/chapter-header.md +158 -0
  28. package/commands/scr/character-arc.md +108 -0
  29. package/commands/scr/character-ref.md +160 -0
  30. package/commands/scr/character-sheet.md +143 -0
  31. package/commands/scr/character-touch.md +157 -0
  32. package/commands/scr/character-voice-sample.md +111 -0
  33. package/commands/scr/check-notes.md +50 -0
  34. package/commands/scr/cleanup.md +159 -0
  35. package/commands/scr/compare.md +112 -0
  36. package/commands/scr/complete-draft.md +49 -0
  37. package/commands/scr/continuity-check.md +129 -0
  38. package/commands/scr/copy-edit.md +118 -0
  39. package/commands/scr/cover-art.md +382 -0
  40. package/commands/scr/cultural-adaptation.md +177 -0
  41. package/commands/scr/demo.md +93 -0
  42. package/commands/scr/dialogue-audit.md +143 -0
  43. package/commands/scr/discuss.md +118 -0
  44. package/commands/scr/discussion-questions.md +129 -0
  45. package/commands/scr/do.md +68 -0
  46. package/commands/scr/draft.md +97 -0
  47. package/commands/scr/editor-review.md +466 -0
  48. package/commands/scr/export.md +942 -0
  49. package/commands/scr/fast.md +65 -0
  50. package/commands/scr/front-matter.md +696 -0
  51. package/commands/scr/health.md +113 -0
  52. package/commands/scr/help.md +121 -0
  53. package/commands/scr/history.md +92 -0
  54. package/commands/scr/illustrate-scene.md +211 -0
  55. package/commands/scr/import.md +95 -0
  56. package/commands/scr/insert-unit.md +108 -0
  57. package/commands/scr/line-edit.md +146 -0
  58. package/commands/scr/manager.md +77 -0
  59. package/commands/scr/manuscript-stats.md +139 -0
  60. package/commands/scr/map-illustration.md +213 -0
  61. package/commands/scr/map-manuscript.md +134 -0
  62. package/commands/scr/merge-units.md +136 -0
  63. package/commands/scr/multi-publish.md +344 -0
  64. package/commands/scr/new-character.md +167 -0
  65. package/commands/scr/new-revision.md +50 -0
  66. package/commands/scr/new-work.md +148 -0
  67. package/commands/scr/next.md +125 -0
  68. package/commands/scr/originality-check.md +170 -0
  69. package/commands/scr/outline.md +131 -0
  70. package/commands/scr/pacing-analysis.md +170 -0
  71. package/commands/scr/panel-layout.md +225 -0
  72. package/commands/scr/pause-work.md +88 -0
  73. package/commands/scr/plan.md +112 -0
  74. package/commands/scr/plant-seed.md +57 -0
  75. package/commands/scr/plot-graph.md +199 -0
  76. package/commands/scr/polish.md +141 -0
  77. package/commands/scr/profile-writer.md +154 -0
  78. package/commands/scr/progress.md +51 -0
  79. package/commands/scr/publish.md +455 -0
  80. package/commands/scr/query-letter.md +183 -0
  81. package/commands/scr/quick-write.md +82 -0
  82. package/commands/scr/relationship-map.md +129 -0
  83. package/commands/scr/remove-unit.md +120 -0
  84. package/commands/scr/reorder-units.md +126 -0
  85. package/commands/scr/resume-work.md +97 -0
  86. package/commands/scr/sacred/annotation-layer.md +105 -0
  87. package/commands/scr/sacred/chronology.md +121 -0
  88. package/commands/scr/sacred/concordance.md +88 -0
  89. package/commands/scr/sacred/cross-reference.md +97 -0
  90. package/commands/scr/sacred/doctrinal-check.md +129 -0
  91. package/commands/scr/sacred/genealogy.md +107 -0
  92. package/commands/scr/sacred/source-tracking.md +101 -0
  93. package/commands/scr/sacred/verse-numbering.md +103 -0
  94. package/commands/scr/sacred-numbering-format.md +103 -0
  95. package/commands/scr/save.md +109 -0
  96. package/commands/scr/scan.md +291 -0
  97. package/commands/scr/sensitivity-review.md +169 -0
  98. package/commands/scr/series-bible.md +127 -0
  99. package/commands/scr/session-report.md +80 -0
  100. package/commands/scr/settings.md +58 -0
  101. package/commands/scr/split-unit.md +123 -0
  102. package/commands/scr/spread-layout.md +187 -0
  103. package/commands/scr/storyboard.md +262 -0
  104. package/commands/scr/subject-touch.md +168 -0
  105. package/commands/scr/submit.md +50 -0
  106. package/commands/scr/subplot-map.md +147 -0
  107. package/commands/scr/sync.md +116 -0
  108. package/commands/scr/synopsis.md +137 -0
  109. package/commands/scr/theme-tracker.md +128 -0
  110. package/commands/scr/thread.md +83 -0
  111. package/commands/scr/timeline.md +141 -0
  112. package/commands/scr/track.md +564 -0
  113. package/commands/scr/translate.md +260 -0
  114. package/commands/scr/translation-glossary.md +298 -0
  115. package/commands/scr/translation-memory.md +310 -0
  116. package/commands/scr/troubleshoot.md +59 -0
  117. package/commands/scr/undo.md +106 -0
  118. package/commands/scr/validate.md +133 -0
  119. package/commands/scr/versions.md +94 -0
  120. package/commands/scr/voice-check.md +133 -0
  121. package/commands/scr/voice-test.md +68 -0
  122. package/data/CONSTRAINTS.json +1606 -0
  123. package/data/demo/.manuscript/BRIEF.md +37 -0
  124. package/data/demo/.manuscript/CHARACTERS.md +90 -0
  125. package/data/demo/.manuscript/OUTLINE.md +46 -0
  126. package/data/demo/.manuscript/PLOT-GRAPH.md +75 -0
  127. package/data/demo/.manuscript/STATE.md +44 -0
  128. package/data/demo/.manuscript/STYLE-GUIDE.md +119 -0
  129. package/data/demo/.manuscript/THEMES.md +51 -0
  130. package/data/demo/.manuscript/WORK.md +51 -0
  131. package/data/demo/.manuscript/config.json +59 -0
  132. package/data/demo/.manuscript/drafts/body/1-the-letter-DRAFT.md +51 -0
  133. package/data/demo/.manuscript/drafts/body/2-the-workshop-DRAFT.md +51 -0
  134. package/data/demo/.manuscript/drafts/body/3-the-pier-DRAFT.md +45 -0
  135. package/data/demo/.manuscript/drafts/body/4-the-clock-DRAFT.md +59 -0
  136. package/data/demo/.manuscript/plans/5-the-reunion-PLAN.md +52 -0
  137. package/data/demo/.manuscript/reviews/2-the-workshop-REVIEW.md +61 -0
  138. package/data/export-templates/scriveno-academic.latex +184 -0
  139. package/data/export-templates/scriveno-acm.latex +67 -0
  140. package/data/export-templates/scriveno-apa7.latex +83 -0
  141. package/data/export-templates/scriveno-book.typst +175 -0
  142. package/data/export-templates/scriveno-chapbook.typst +121 -0
  143. package/data/export-templates/scriveno-elsevier.latex +76 -0
  144. package/data/export-templates/scriveno-epub.css +386 -0
  145. package/data/export-templates/scriveno-fixed-layout-epub.css +76 -0
  146. package/data/export-templates/scriveno-fixed-layout.opf +23 -0
  147. package/data/export-templates/scriveno-ieee.latex +77 -0
  148. package/data/export-templates/scriveno-lncs.latex +79 -0
  149. package/data/export-templates/scriveno-picturebook.typst +113 -0
  150. package/data/export-templates/scriveno-poetry-submission-styles.md +45 -0
  151. package/data/export-templates/scriveno-poetry-submission.docx +0 -0
  152. package/data/export-templates/scriveno-smashwords-styles.md +45 -0
  153. package/data/export-templates/scriveno-smashwords.docx +0 -0
  154. package/data/export-templates/scriveno-stageplay.typst +129 -0
  155. package/data/proof/creative-context/README.md +79 -0
  156. package/data/proof/voice-dna/GUIDED-SAMPLE.md +19 -0
  157. package/data/proof/voice-dna/README.md +45 -0
  158. package/data/proof/voice-dna/STYLE-GUIDE-EXCERPT.md +43 -0
  159. package/data/proof/voice-dna/UNGUIDED-SAMPLE.md +11 -0
  160. package/data/proof/watchmaker-flow/README.md +78 -0
  161. package/docs/architecture.md +425 -0
  162. package/docs/command-reference.md +2384 -0
  163. package/docs/configuration.md +228 -0
  164. package/docs/context-protocol.md +81 -0
  165. package/docs/contributing.md +430 -0
  166. package/docs/creative-context.md +158 -0
  167. package/docs/development.md +152 -0
  168. package/docs/drafter-quality.md +127 -0
  169. package/docs/getting-started.md +198 -0
  170. package/docs/history-protocol.md +96 -0
  171. package/docs/proof-artifacts.md +56 -0
  172. package/docs/publishing.md +296 -0
  173. package/docs/release-notes.md +457 -0
  174. package/docs/runtime-support.md +77 -0
  175. package/docs/sacred-texts.md +296 -0
  176. package/docs/shipped-assets.md +129 -0
  177. package/docs/testing.md +156 -0
  178. package/docs/translation.md +343 -0
  179. package/docs/voice-dna.md +297 -0
  180. package/docs/work-types.md +339 -0
  181. package/lib/architectural-profiles.js +134 -0
  182. package/package.json +54 -0
  183. package/templates/BRIEF.md +51 -0
  184. package/templates/CHARACTERS.md +64 -0
  185. package/templates/CONTEXT.md +56 -0
  186. package/templates/OUTLINE.md +36 -0
  187. package/templates/RECORD.md +68 -0
  188. package/templates/STATE.md +50 -0
  189. package/templates/STYLE-GUIDE.md +121 -0
  190. package/templates/THEMES.md +36 -0
  191. package/templates/WORK.md +67 -0
  192. package/templates/WORLD.md +62 -0
  193. package/templates/WRITING-RULES.md +156 -0
  194. package/templates/academic/ARGUMENT-MAP.md +40 -0
  195. package/templates/academic/CONCEPTS.md +34 -0
  196. package/templates/academic/CONTEXT.md +29 -0
  197. package/templates/academic/PROPOSAL.md +37 -0
  198. package/templates/academic/QUESTIONS.md +24 -0
  199. package/templates/config.json +72 -0
  200. package/templates/pitfalls/comic.md +54 -0
  201. package/templates/pitfalls/commentary.md +62 -0
  202. package/templates/pitfalls/memoir.md +48 -0
  203. package/templates/pitfalls/novel.md +53 -0
  204. package/templates/pitfalls/poetry_collection.md +63 -0
  205. package/templates/pitfalls/research_paper.md +66 -0
  206. package/templates/pitfalls/runbook.md +64 -0
  207. package/templates/pitfalls/screenplay.md +54 -0
  208. package/templates/platforms/README.md +16 -0
  209. package/templates/platforms/apple/manifest.yaml +20 -0
  210. package/templates/platforms/bn/manifest.yaml +20 -0
  211. package/templates/platforms/d2d/manifest.yaml +20 -0
  212. package/templates/platforms/google/manifest.yaml +20 -0
  213. package/templates/platforms/ingram/manifest.yaml +44 -0
  214. package/templates/platforms/kdp/manifest.yaml +42 -0
  215. package/templates/platforms/kobo/manifest.yaml +20 -0
  216. package/templates/platforms/smashwords/manifest.yaml +26 -0
  217. package/templates/sacred/COSMOLOGY.md +88 -0
  218. package/templates/sacred/DOCTRINES.md +45 -0
  219. package/templates/sacred/FIGURES.md +69 -0
  220. package/templates/sacred/FRAMEWORK.md +98 -0
  221. package/templates/sacred/LINEAGES.md +52 -0
  222. package/templates/sacred/README.md +20 -0
  223. package/templates/sacred/THEOLOGICAL-ARC.md +69 -0
  224. package/templates/sacred/catholic/manifest.yaml +93 -0
  225. package/templates/sacred/islamic-hafs/manifest.yaml +134 -0
  226. package/templates/sacred/islamic-warsh/manifest.yaml +134 -0
  227. package/templates/sacred/jewish/manifest.yaml +56 -0
  228. package/templates/sacred/orthodox/manifest.yaml +98 -0
  229. package/templates/sacred/pali/manifest.yaml +20 -0
  230. package/templates/sacred/protestant/manifest.yaml +86 -0
  231. package/templates/sacred/sanskrit/manifest.yaml +20 -0
  232. package/templates/sacred/tewahedo/manifest.yaml +106 -0
  233. package/templates/sacred/tibetan/manifest.yaml +20 -0
  234. package/templates/technical/AUDIENCE.md +26 -0
  235. package/templates/technical/DEPENDENCIES.md +19 -0
  236. package/templates/technical/DOC-BRIEF.md +45 -0
  237. package/templates/technical/PROCEDURES.md +37 -0
  238. package/templates/technical/REFERENCES.md +36 -0
  239. package/templates/technical/SYSTEM.md +25 -0
@@ -0,0 +1,942 @@
1
+ ---
2
+ description: Compile and export manuscript to publication-ready formats.
3
+ argument-hint: "[--format <format>] [--formatted] [--print-ready] [--skip-validate]"
4
+ ---
5
+
6
+ # /scr:export -- Manuscript Export
7
+
8
+ Assemble the manuscript from OUTLINE.md and export to the specified format. Handles manuscript assembly, metadata generation, external tool detection, and format-specific Pandoc/Typst invocation.
9
+
10
+ ## Usage
11
+
12
+ ```
13
+ /scr:export # interactive picker
14
+ /scr:export --format <format> [--formatted] [--print-ready] [--skip-validate]
15
+ ```
16
+
17
+ If `--format` is omitted, run the interactive picker (see STEP 0). Otherwise jump straight to STEP 1 with the requested format.
18
+
19
+ ---
20
+
21
+ ### STEP 0: INTERACTIVE PICKER (only when --format is omitted)
22
+
23
+ Load `.manuscript/config.json` and the installed `CONSTRAINTS.json` (same paths as STEP 1) so you know the work type group. For every option below, check it against the `exports` section of `CONSTRAINTS.json` and skip any row that is not available for the current work type group.
24
+
25
+ Show the writer this prompt and wait for an answer:
26
+
27
+ > What do you want to export?
28
+ >
29
+ > **Single file**
30
+ > 1. **markdown** -- one `.md` file (no external tools required)
31
+ > 2. **docx** -- manuscript Word document (requires Pandoc)
32
+ > 3. **pdf** -- manuscript PDF (requires Pandoc + Typst)
33
+ > 4. **epub** -- standalone EPUB (requires Pandoc)
34
+ > 5. **latex** -- LaTeX source (academic / sacred only)
35
+ > 6. **fountain** -- screenplay text (script work types only)
36
+ > 7. **fdx** -- Final Draft XML (script work types only, requires Screenplain)
37
+ >
38
+ > **Print / store packaging**
39
+ > 8. **pdf --print-ready** -- print interior PDF with trim size and margins
40
+ > 9. **docx --formatted** -- designed DOCX for review copies
41
+ > 10. **kdp-package** -- Amazon KDP print upload bundle
42
+ > 11. **ingram-package** -- IngramSpark CMYK PDF/X-1a bundle
43
+ >
44
+ > **Submission packages**
45
+ > 12. **query-package** -- agent query bundle (query letter + synopsis + sample)
46
+ > 13. **submission-package** -- full submission bundle (DOCX + synopsis + cover letter + bio)
47
+ >
48
+ > Pick a number, or type the format name. Type `publish` if you want a guided multi-format pipeline instead -- that lives in `/scr:publish`.
49
+
50
+ Map the answer to the corresponding `--format` value (and `--formatted` / `--print-ready` modifiers where applicable), then proceed to STEP 1 as if the writer had passed it on the command line.
51
+
52
+ If the writer answers `publish`, do not run the export; tell them to run `/scr:publish` and stop.
53
+
54
+ ---
55
+
56
+ **Primary Formats:**
57
+
58
+ | Format | Flag | Output | Requires |
59
+ |--------|------|--------|----------|
60
+ | Markdown | `--format markdown` | `.manuscript/output/manuscript.md` | Nothing |
61
+ | DOCX (manuscript) | `--format docx` | `.manuscript/output/manuscript.docx` | Pandoc |
62
+ | DOCX (formatted) | `--format docx --formatted` | `.manuscript/output/manuscript-formatted.docx` | Pandoc |
63
+ | PDF (manuscript) | `--format pdf` | `.manuscript/output/manuscript.pdf` | Pandoc, Typst |
64
+ | PDF (print-ready) | `--format pdf --print-ready` | `.manuscript/output/manuscript-print.pdf` | Pandoc, Typst |
65
+ | EPUB | `--format epub` | `.manuscript/output/manuscript.epub` | Pandoc |
66
+
67
+ **Secondary Formats (Plan 02):**
68
+
69
+ | Format | Flag | Output | Requires |
70
+ |--------|------|--------|----------|
71
+ | Fountain | `--format fountain` | `.manuscript/output/screenplay.fountain` | Nothing |
72
+ | FDX | `--format fdx` | `.manuscript/output/screenplay.fdx` | Screenplain |
73
+ | LaTeX | `--format latex` | `.manuscript/output/manuscript.tex` | Pandoc |
74
+
75
+ **Packages (Plan 02):**
76
+
77
+ | Package | Flag | Output | Requires |
78
+ |---------|------|--------|----------|
79
+ | KDP | `--format kdp-package` | `.manuscript/output/kdp-package/` | Pandoc, Typst |
80
+ | IngramSpark | `--format ingram-package` | `.manuscript/output/ingram-package/` | Pandoc, Typst, Ghostscript |
81
+ | Query | `--format query-package` | `.manuscript/output/query-package/` | Pandoc |
82
+ | Submission | `--format submission-package` | `.manuscript/output/submission-package/` | Pandoc |
83
+
84
+ ## Instruction
85
+
86
+ You are a **manuscript export specialist**. Your job is to assemble the complete manuscript from its component files and convert it to the requested format using external tools.
87
+
88
+ ---
89
+
90
+ ### STEP 0: BOOTSTRAP (context-cost protocol)
91
+
92
+ Read `.manuscript/CONTEXT.md` first if it exists. If its `Updated` timestamp is newer than `.manuscript/STATE.md` and newer than the newest file in `.manuscript/drafts/body/`, use it as your orientation source for project title, work type, and recent activity. In STEP 1, skip the raw-file loads of `config.json` and `STATE.md` for those fields -- still load `CONSTRAINTS.json` (export availability rules) and the assembly inputs (`OUTLINE.md`, drafts, front-matter, back-matter, metadata) since the export pipeline needs them in full.
93
+
94
+ If CONTEXT.md is missing, stale, or contradicts STATE.md, fall back to the original loads in STEP 1 unchanged. See `docs/context-protocol.md` for the contract.
95
+
96
+ ---
97
+
98
+ ### STEP 1: LOAD CONTEXT
99
+
100
+ Load the following project files:
101
+
102
+ - `.manuscript/config.json` -- to get `work_type`, title, author, language, and project settings
103
+ - Scriveno's installed/shared `CONSTRAINTS.json` (global `~/.scriveno/data/CONSTRAINTS.json` or project `.scriveno/data/CONSTRAINTS.json`) -- to check `exports` section for format availability by work type group
104
+
105
+ **Check format availability:**
106
+
107
+ Look up the requested format in `CONSTRAINTS.json` under the `exports` section. Map the format flag to the constraint key:
108
+
109
+ | Flag | Constraint Key |
110
+ |------|---------------|
111
+ | `markdown` | `markdown` |
112
+ | `docx` | `docx_manuscript` |
113
+ | `docx --formatted` | `docx_formatted` |
114
+ | `pdf` | `pdf_manuscript` |
115
+ | `pdf --print-ready` | `pdf_print_ready` |
116
+ | `epub` | `epub` |
117
+ | `fountain` | `fountain` |
118
+ | `fdx` | `fdx` |
119
+ | `latex` | `latex` |
120
+ | `kdp-package` | `kdp_package` |
121
+ | `ingram-package` | `ingram_package` |
122
+ | `query-package` | `query_package` |
123
+ | `submission-package` | `submission_package` |
124
+
125
+ Find the current work type's group in `CONSTRAINTS.json` under `work_type_groups`. Check if the group is in the format's `available` list (or if `available` contains `"all"`).
126
+
127
+ If the format is **not available** for the current work type:
128
+ > This format is not available for [work_type] projects. Available export formats for [group] work types are: [list available formats].
129
+
130
+ Then **stop**.
131
+
132
+ ---
133
+
134
+ ### STEP 1.5: VALIDATE MANUSCRIPT
135
+
136
+ **Check for scaffold markers in `.manuscript/drafts/`.**
137
+
138
+ Scan all `.md` files in `.manuscript/drafts/` for:
139
+ - Lines containing `[Fill in` (covers `[Fill in:]`, `[Fill in or delete:]`)
140
+ - Lines containing `[Delete if not applicable:]`
141
+ - Lines containing `Alternate 1:` or `Alternate 2:`
142
+ - Files with more than one `# ` (top-level H1) heading
143
+
144
+ **Note:** `{{VAR}}` tokens are NOT scaffold markers and must not be flagged. They are writer content placeholders, out of scope for this gate.
145
+
146
+ **If `--skip-validate` was passed:**
147
+
148
+ > **Warning: Validate gate skipped (`--skip-validate`). Your manuscript may contain
149
+ > unresolved scaffold markers. Run `/scr:validate` to check before submitting.**
150
+
151
+ Proceed to STEP 2.
152
+
153
+ **If markers are found** (and `--skip-validate` was not passed):
154
+
155
+ > **Export blocked: unresolved scaffold markers found.**
156
+ >
157
+ > [list each as: `path/to/file.md:LINE_NUMBER: marker text`]
158
+ >
159
+ > **Fix:** Run `/scr:cleanup --apply` to remove scaffold markers, or manually
160
+ > edit the listed files, then re-run this export command.
161
+
162
+ Then **stop** -- do not proceed to STEP 2.
163
+
164
+ If no markers found: proceed to STEP 2.
165
+
166
+ ---
167
+
168
+ ### STEP 1.6: FRONT-MATTER GATE
169
+
170
+ **1.6a -- Scaffold exclusion**
171
+
172
+ Check if `.manuscript/front-matter/` exists.
173
+
174
+ If the directory does not exist:
175
+ > **Note:** No front matter found -- run `/scr:front-matter` first if you want publication front matter included.
176
+
177
+ Proceed to 1.6b.
178
+
179
+ If the directory exists, scan all `.md` files in `.manuscript/front-matter/`. For each file, check the first 10 lines for a YAML block containing `scaffold: true`. Build a scaffold exclusion list of the paths of all files where `scaffold: true` is found.
180
+
181
+ If any files were added to the scaffold exclusion list, note them for the assembly step (STEP 3b) and show:
182
+ > **Note:** [N] scaffold front-matter element(s) will be excluded from this export:
183
+ > - `.manuscript/front-matter/12-preface.md` (scaffold: true -- edit and set scaffold: false to include)
184
+ >
185
+ > To include a scaffold element, open the file and change `scaffold: true` to `scaffold: false`.
186
+
187
+ If no scaffold files were found, show no note.
188
+
189
+ **1.6b -- GENERATE element auto-refresh**
190
+
191
+ If `.manuscript/front-matter/` does not exist, skip auto-refresh and proceed to STEP 2.
192
+
193
+ If `.manuscript/WORK.md` does not exist, skip auto-refresh and proceed to STEP 2.
194
+
195
+ Compare the modification timestamp of `.manuscript/WORK.md` against each of the following GENERATE front-matter files:
196
+ - `.manuscript/front-matter/01-half-title.md`
197
+ - `.manuscript/front-matter/03-title-page.md`
198
+ - `.manuscript/front-matter/04-copyright.md`
199
+ - `.manuscript/front-matter/07-toc.md`
200
+
201
+ To compare timestamps, use the appropriate command for the platform:
202
+ - macOS: `stat -f %m <file>`
203
+ - Linux: `stat -c %Y <file>`
204
+ - Windows: `(Get-Item '<file>').LastWriteTimeUtc.Ticks`
205
+ - If timestamp comparison is not possible, assume WORK.md is newer and regenerate.
206
+
207
+ If WORK.md is newer than ANY of those 4 files, or if ANY of those 4 files do not exist:
208
+ Re-run the GENERATE step from `/scr:front-matter` for elements 1, 3, 4, and 7 only (half-title, title page, copyright page, TOC) using current WORK.md metadata. Regenerate all four even if only one triggered the condition. Do NOT regenerate scaffold elements (5, 6, 11, 12, 13) or any other elements.
209
+
210
+ If WORK.md is not newer than all 4 files and all 4 files exist: skip regeneration silently.
211
+
212
+ Proceed to STEP 2.
213
+
214
+ ---
215
+
216
+ ### STEP 2: CHECK PREREQUISITES
217
+
218
+ Check for required external tools based on the requested format.
219
+
220
+ **For markdown:** No external tools needed. Skip to Step 3.
221
+
222
+ **For docx, epub, latex, query-package:** Check for Pandoc:
223
+
224
+ ```bash
225
+ command -v pandoc >/dev/null 2>&1
226
+ ```
227
+
228
+ If Pandoc is not found:
229
+
230
+ > **Pandoc is required for this export format but is not installed.**
231
+ >
232
+ > **Install Pandoc:**
233
+ > - macOS: `brew install pandoc`
234
+ > - Linux: `sudo apt install pandoc`
235
+ > - Windows: `choco install pandoc`
236
+ > - Or download from https://pandoc.org/installing.html
237
+ >
238
+ > After installing, run this export command again.
239
+
240
+ Then **stop** -- do not attempt export without the required tool.
241
+
242
+ **For pdf (both manuscript and print-ready):** Also check for Typst:
243
+
244
+ ```bash
245
+ command -v typst >/dev/null 2>&1
246
+ ```
247
+
248
+ If Typst is not found:
249
+
250
+ > **Typst is required for PDF export but is not installed.**
251
+ >
252
+ > **Install Typst:**
253
+ > - macOS: `brew install typst`
254
+ > - Linux: Download from https://github.com/typst/typst/releases
255
+ > - Windows: `winget install typst`
256
+ > - Or visit https://typst.app for installation options
257
+ >
258
+ > After installing, run this export command again.
259
+
260
+ Then **stop**.
261
+
262
+ **For fdx:** Check for Screenplain:
263
+
264
+ ```bash
265
+ command -v screenplain >/dev/null 2>&1
266
+ ```
267
+
268
+ If not found, provide install instructions (`pip install screenplain`) and stop.
269
+
270
+ **For fountain:** No external tools needed.
271
+
272
+ ---
273
+
274
+ ### STEP 3: ASSEMBLE MANUSCRIPT
275
+
276
+ This step builds the complete manuscript from its component files. All formats use this assembled file as input.
277
+
278
+ **3a. Read OUTLINE.md for document order:**
279
+
280
+ Read `.manuscript/OUTLINE.md` and parse the scene/chapter list. Extract the ordered list of body units (scenes, chapters, sections) with their file paths in `.manuscript/drafts/body/`.
281
+
282
+ **3b. Scan front matter:**
283
+
284
+ Read all files in `.manuscript/front-matter/` directory. Sort by numeric prefix to maintain Chicago Manual of Style order:
285
+
286
+ ```
287
+ 01-half-title.md
288
+ 02-series-title.md
289
+ 03-title-page.md
290
+ 04-copyright.md
291
+ ...
292
+ ```
293
+
294
+ **Scaffold exclusion:** Omit any files whose path appears in the scaffold exclusion list from STEP 1.6a. These files have `scaffold: true` in their frontmatter and are not yet ready for publication.
295
+
296
+ If no front matter files exist:
297
+ > **Note:** No front matter found. Consider running `/scr:front-matter` to generate title page, copyright, and other publishing elements.
298
+
299
+ Proceed with body content only.
300
+
301
+ **3c. Read body drafts:**
302
+
303
+ For each unit listed in OUTLINE.md, look for the corresponding draft file in `.manuscript/drafts/body/`. Read in OUTLINE.md order.
304
+
305
+ For any unit listed in OUTLINE.md that has no draft file:
306
+ > **Warning:** Missing draft for "[unit name]" -- skipping. Expected file: `.manuscript/drafts/body/[filename]`
307
+
308
+ Track all missing units for the final report.
309
+
310
+ **3d. Scan back matter:**
311
+
312
+ Read all files in `.manuscript/back-matter/` directory. Sort alphabetically.
313
+
314
+ If no back matter exists, proceed without -- back matter is optional.
315
+
316
+ **3e. Concatenate:**
317
+
318
+ Assemble the full manuscript in this order:
319
+
320
+ 1. Front matter files (sorted by numeric prefix)
321
+ 2. Body draft files (ordered by OUTLINE.md)
322
+ 3. Back matter files (sorted alphabetically)
323
+
324
+ Insert `\newpage` page break markers between major sections (between each front matter element, between front matter and body, between chapters/sections, between body and back matter).
325
+
326
+ **3f. Create output directory and write assembled file:**
327
+
328
+ ```bash
329
+ mkdir -p .manuscript/output
330
+ ```
331
+
332
+ Write the assembled content to `.manuscript/output/assembled-manuscript.md`.
333
+
334
+ **3g. Generate metadata.yaml:**
335
+
336
+ Read `.manuscript/config.json` and `.manuscript/WORK.md` (if it exists) to generate Pandoc metadata:
337
+
338
+ ```yaml
339
+ ---
340
+ title: "[title from config.json]"
341
+ subtitle: "[subtitle if available]"
342
+ author:
343
+ - name: "[author from config.json]"
344
+ language: "[language from config.json, default en-US]"
345
+ rights: "Copyright [year] [author]. All rights reserved."
346
+ date: "[current year]"
347
+ description: "[description if available]"
348
+ ---
349
+ ```
350
+
351
+ Write to `.manuscript/output/metadata.yaml`.
352
+
353
+ ---
354
+
355
+ ### STEP 4: EXPORT BY FORMAT
356
+
357
+ Execute the format-specific export command using the assembled manuscript and metadata.
358
+
359
+ ---
360
+
361
+ #### FORMAT: markdown (EXP-01)
362
+
363
+ The assembled file IS the output. No external tools needed.
364
+
365
+ ```bash
366
+ cp .manuscript/output/assembled-manuscript.md .manuscript/output/manuscript.md
367
+ ```
368
+
369
+ ---
370
+
371
+ #### FORMAT: docx (EXP-02)
372
+
373
+ Manuscript export DOCX using Pandoc's default Word styling.
374
+
375
+ ```bash
376
+ pandoc .manuscript/output/assembled-manuscript.md \
377
+ -o .manuscript/output/manuscript.docx \
378
+ --metadata-file=.manuscript/output/metadata.yaml \
379
+ --toc \
380
+ --toc-depth=1
381
+ ```
382
+
383
+ **Current shipped behavior:** Scriveno does not currently bundle a manuscript DOCX reference document in `data/export-templates/`. This command uses Pandoc's default DOCX styling. If you need standard manuscript formatting (for example 12pt, double-spaced, 1-inch margins), supply your own `.docx` reference document via Pandoc's optional `--reference-doc`.
384
+
385
+ ---
386
+
387
+ #### FORMAT: docx --formatted (EXP-03)
388
+
389
+ Designed/typeset DOCX for review copies and ARCs.
390
+
391
+ ```bash
392
+ pandoc .manuscript/output/assembled-manuscript.md \
393
+ -o .manuscript/output/manuscript-formatted.docx \
394
+ --metadata-file=.manuscript/output/metadata.yaml \
395
+ --toc \
396
+ --toc-depth=2
397
+ ```
398
+
399
+ **Current shipped behavior:** Scriveno does not currently bundle a formatted DOCX reference document in `data/export-templates/`. The shipped command path uses Pandoc's default DOCX output. If you want a styled review-copy layout, supply your own Pandoc reference document as an optional `--reference-doc`.
400
+
401
+ ---
402
+
403
+ #### FORMAT: pdf (EXP-04)
404
+
405
+ Manuscript-format PDF via Typst engine.
406
+
407
+ ```bash
408
+ pandoc .manuscript/output/assembled-manuscript.md \
409
+ -o .manuscript/output/manuscript.pdf \
410
+ --pdf-engine=typst \
411
+ --metadata-file=.manuscript/output/metadata.yaml \
412
+ --toc \
413
+ --toc-depth=1
414
+ ```
415
+
416
+ ---
417
+
418
+ #### FORMAT: pdf --print-ready (EXP-05)
419
+
420
+ Print-ready PDF with book interior formatting for KDP/IngramSpark.
421
+
422
+ Read trim size from `.manuscript/config.json` if set, otherwise use defaults (6in x 9in).
423
+
424
+ ```bash
425
+ pandoc .manuscript/output/assembled-manuscript.md \
426
+ -o .manuscript/output/manuscript-print.pdf \
427
+ --pdf-engine=typst \
428
+ --template=data/export-templates/scriveno-book.typst \
429
+ --metadata-file=.manuscript/output/metadata.yaml \
430
+ --toc \
431
+ --toc-depth=2 \
432
+ -V paperwidth=6in \
433
+ -V paperheight=9in \
434
+ -V margin-inside=0.75in \
435
+ -V margin-outside=0.5in \
436
+ -V margin-top=0.75in \
437
+ -V margin-bottom=0.75in
438
+ ```
439
+
440
+ If `config.json` contains `trim_width` and `trim_height`, use those values instead of defaults for `paperwidth` and `paperheight`.
441
+
442
+ ---
443
+
444
+ #### FORMAT: epub (EXP-06)
445
+
446
+ EPUB 3 with metadata, table of contents, cover image, and custom CSS.
447
+
448
+ ```bash
449
+ pandoc .manuscript/output/assembled-manuscript.md \
450
+ -o .manuscript/output/manuscript.epub \
451
+ --metadata-file=.manuscript/output/metadata.yaml \
452
+ --epub-cover-image=.manuscript/build/ebook-cover.jpg \
453
+ --css=data/export-templates/scriveno-epub.css \
454
+ --toc \
455
+ --toc-depth=2 \
456
+ --split-level=1
457
+ ```
458
+
459
+ **Cover image:** If `.manuscript/build/ebook-cover.jpg` (or `.png`) does not exist:
460
+ > **Note:** No ebook cover found at `.manuscript/build/ebook-cover.jpg` or `.png`. EPUB will be generated without a cover. To add a cover, place your front-cover-only RGB ebook asset there and re-run the export.
461
+
462
+ Run the command without the `--epub-cover-image` flag.
463
+
464
+ ---
465
+
466
+ #### FORMAT: fountain (EXP-07)
467
+
468
+ Fountain is a plain-text screenplay format. The agent converts the assembled manuscript markdown directly to Fountain-formatted text -- no external tool needed.
469
+
470
+ **Work type check:** Look up `fountain` in `CONSTRAINTS.json` under `exports`. It is available only for `script` group work types (screenplay, stage_play, tv_pilot, tv_series_bible, audio_drama, libretto). If the current work type's group is not in the `available` list, inform the writer and **stop**.
471
+
472
+ **Conversion rules (Markdown to Fountain):**
473
+
474
+ 1. **Scene headings:** Lines starting with `## ` or `### ` that contain location context become Fountain sluglines. Prefix with `INT.` or `EXT.` based on content. If ambiguous, use the heading text as-is prefixed with `.` (forced scene heading in Fountain).
475
+ 2. **Character names:** Any line that is ALL CAPS followed by dialogue on the next line stays as-is (Fountain format).
476
+ 3. **Dialogue:** Lines immediately following a CHARACTER NAME are dialogue. Wrap parenthetical directions in `()`.
477
+ 4. **Action:** Regular prose paragraphs become action blocks (plain text with blank line separators).
478
+ 5. **Transitions:** Lines ending with `TO:` (e.g., `CUT TO:`, `FADE TO:`) are transitions. Alternatively, prefix with `>`.
479
+ 6. **Title page:** Generate from metadata:
480
+ ```
481
+ Title: [title from config.json]
482
+ Credit: Written by
483
+ Author: [author from config.json]
484
+ Draft date: [current date]
485
+ ```
486
+
487
+ Write the converted Fountain text to:
488
+
489
+ ```bash
490
+ mkdir -p .manuscript/output
491
+ # Write Fountain-formatted content to:
492
+ # .manuscript/output/screenplay.fountain
493
+ ```
494
+
495
+ **Optional screenplay PDF:** After generating the Fountain file, check if Afterwriting is available:
496
+
497
+ ```bash
498
+ command -v afterwriting >/dev/null 2>&1
499
+ ```
500
+
501
+ If Afterwriting is installed, offer to generate a screenplay PDF:
502
+
503
+ ```bash
504
+ afterwriting \
505
+ --source .manuscript/output/screenplay.fountain \
506
+ --pdf .manuscript/output/screenplay.pdf \
507
+ --overwrite
508
+ ```
509
+
510
+ If Afterwriting is not installed:
511
+ > **Optional:** To generate a formatted screenplay PDF, install Afterwriting: `npm i -g afterwriting`
512
+ > Then run: `afterwriting --source .manuscript/output/screenplay.fountain --pdf .manuscript/output/screenplay.pdf --overwrite`
513
+
514
+ ---
515
+
516
+ #### FORMAT: fdx (EXP-08)
517
+
518
+ Final Draft XML format via Screenplain, using Fountain as an intermediate.
519
+
520
+ **Work type check:** Look up `fdx` in `CONSTRAINTS.json` under `exports`. It is available only for `script` group work types with a `screenplay_or_tv_only` constraint. If the current work type is not eligible, inform the writer and **stop**.
521
+
522
+ **Step 1: Ensure Fountain export exists**
523
+
524
+ Check if `.manuscript/output/screenplay.fountain` exists. If not, run the Fountain export first (see FORMAT: fountain above). FDX export chains through Fountain as an intermediate format: markdown -> fountain -> fdx.
525
+
526
+ **Step 2: Check for Screenplain**
527
+
528
+ ```bash
529
+ command -v screenplain >/dev/null 2>&1
530
+ ```
531
+
532
+ If Screenplain is not found:
533
+
534
+ > **Screenplain is required for FDX export but is not installed.**
535
+ >
536
+ > **Install Screenplain:**
537
+ > ```
538
+ > pip install screenplain
539
+ > ```
540
+ >
541
+ > After installing, run this export command again.
542
+
543
+ Then **stop** -- do not attempt FDX export without Screenplain.
544
+
545
+ **Step 3: Convert Fountain to FDX**
546
+
547
+ ```bash
548
+ screenplain --format fdx .manuscript/output/screenplay.fountain \
549
+ .manuscript/output/screenplay.fdx
550
+ ```
551
+
552
+ Output: `.manuscript/output/screenplay.fdx`
553
+
554
+ ---
555
+
556
+ #### FORMAT: latex (EXP-09)
557
+
558
+ LaTeX source file for academic and sacred text work types, via Pandoc with the academic template.
559
+
560
+ **Work type check:** Look up `latex` in `CONSTRAINTS.json` under `exports`. It is available only for `academic` and `sacred` group work types. For sacred work types, LaTeX export is intended for critical editions. If the current work type's group is not in the `available` list, inform the writer and **stop**.
561
+
562
+ **Check for Pandoc** (same as other Pandoc-dependent formats -- see Step 2 above).
563
+
564
+ **Check for bibliography file:**
565
+
566
+ If `.manuscript/bibliography.bib` exists, include bibliography flags. If it does not exist:
567
+
568
+ > **Note:** No bibliography file found at `.manuscript/bibliography.bib`. LaTeX export will proceed without bibliography support. To add citations, create a BibTeX file at `.manuscript/bibliography.bib` and re-run the export.
569
+
570
+ **Export command (with bibliography):**
571
+
572
+ ```bash
573
+ pandoc .manuscript/output/assembled-manuscript.md \
574
+ -o .manuscript/output/manuscript.tex \
575
+ --template=data/export-templates/scriveno-academic.latex \
576
+ --metadata-file=.manuscript/output/metadata.yaml \
577
+ --toc \
578
+ --bibliography=.manuscript/bibliography.bib \
579
+ --citeproc
580
+ ```
581
+
582
+ **Export command (without bibliography):**
583
+
584
+ ```bash
585
+ pandoc .manuscript/output/assembled-manuscript.md \
586
+ -o .manuscript/output/manuscript.tex \
587
+ --template=data/export-templates/scriveno-academic.latex \
588
+ --metadata-file=.manuscript/output/metadata.yaml \
589
+ --toc
590
+ ```
591
+
592
+ Output: `.manuscript/output/manuscript.tex`
593
+
594
+ ---
595
+
596
+ #### FORMAT: kdp-package (EXP-10)
597
+
598
+ Bundle a KDP print submission package with interior PDF, a canonical cover handoff brief, and metadata.
599
+
600
+ **Work type check:** Look up `kdp_package` in `CONSTRAINTS.json` under `exports`. Available for `prose`, `visual`, `poetry`, and `sacred` group work types. If the current work type's group is not in the `available` list, inform the writer and **stop**.
601
+
602
+ **Step 1: Ensure print-ready PDF exists**
603
+
604
+ Check if `.manuscript/output/manuscript-print.pdf` exists. If not, run the `pdf --print-ready` export first (see FORMAT: pdf --print-ready above).
605
+
606
+ **Step 2: Resolve the canonical cover asset contract**
607
+
608
+ Use these canonical cover locations:
609
+
610
+ - Ebook front cover: `.manuscript/build/ebook-cover.jpg` (or `.png`)
611
+ - Paperback full wrap: `.manuscript/build/paperback-cover.pdf`
612
+ - Hardcover case wrap: `.manuscript/build/hardcover-cover.pdf`
613
+
614
+ For this KDP print package, the relevant finished print asset is `.manuscript/build/paperback-cover.pdf`.
615
+
616
+ **Do not calculate final print-cover wrap geometry from hard-coded paper factors in this command.** Exact paperback wrap width, spine width, and bleed-safe template geometry must come from the active platform cover template tool.
617
+
618
+ **Step 3: Create KDP package directory and files**
619
+
620
+ ```bash
621
+ mkdir -p .manuscript/output/kdp-package
622
+ cp .manuscript/output/manuscript-print.pdf .manuscript/output/kdp-package/interior.pdf
623
+ ```
624
+
625
+ If `.manuscript/build/paperback-cover.pdf` exists, copy it into the package as `cover.pdf`. If it does not exist, still generate the package and note that the print cover is pending.
626
+
627
+ **Generate `cover-specs.md`** as a delivery brief:
628
+
629
+ ```markdown
630
+ # KDP Cover Specifications
631
+
632
+ ## Canonical Asset
633
+ - Expected print cover file: `.manuscript/build/paperback-cover.pdf`
634
+ - If present, packaged copy: `.manuscript/output/kdp-package/cover.pdf`
635
+
636
+ ## Delivery Contract
637
+ - Format: PDF/X-1a:2001 preferred for print handoff
638
+ - Resolution: 300 DPI minimum
639
+ - Bleed: 0.125" outer edges
640
+ - Surface: back + spine + front in one full-wrap PDF
641
+ - Fonts embedded
642
+ - Transparency flattened
643
+
644
+ ## Notes
645
+ - Generate exact wrap geometry from the current platform template tool using the real trim size, page count, and binding
646
+ - Keep the ebook front cover separate at `.manuscript/build/ebook-cover.jpg`
647
+ - Keep editable source files under `.manuscript/build/source/`
648
+ ```
649
+
650
+ **Generate `kdp-metadata.md`** with publishing metadata:
651
+
652
+ ```markdown
653
+ # KDP Metadata
654
+
655
+ - **Title:** [title from config.json]
656
+ - **Author:** [author from config.json]
657
+ - **Language:** [language from config.json]
658
+ - **Description:** [from WORK.md if available]
659
+ - **Categories:** [suggest based on work_type and genre]
660
+ - **Keywords:** [suggest 7 keywords based on themes and genre]
661
+ - **Page count:** [page_count] (estimated from word count)
662
+ ```
663
+
664
+ Output: `.manuscript/output/kdp-package/` containing `interior.pdf`, `cover-specs.md`, `kdp-metadata.md`, and `cover.pdf` when `.manuscript/build/paperback-cover.pdf` exists
665
+
666
+ ---
667
+
668
+ #### FORMAT: ingram-package (EXP-11)
669
+
670
+ Bundle an IngramSpark submission package with CMYK PDF/X-1a interior, canonical print-cover handoff notes, and metadata.
671
+
672
+ **Work type check:** Look up `ingram_package` in `CONSTRAINTS.json` under `exports`. Available for `prose`, `visual`, `poetry`, and `sacred` group work types. If the current work type's group is not in the `available` list, inform the writer and **stop**.
673
+
674
+ **Step 1: Ensure print-ready PDF exists**
675
+
676
+ Check if `.manuscript/output/manuscript-print.pdf` exists. If not, run the `pdf --print-ready` export first.
677
+
678
+ **Step 2: Check for Ghostscript**
679
+
680
+ ```bash
681
+ command -v gs >/dev/null 2>&1
682
+ ```
683
+
684
+ If Ghostscript is not found:
685
+
686
+ > **Ghostscript is required for IngramSpark PDF/X-1a conversion but is not installed.**
687
+ >
688
+ > **Install Ghostscript:**
689
+ > - macOS: `brew install ghostscript`
690
+ > - Linux: `sudo apt install ghostscript`
691
+ > - Windows: Download from https://ghostscript.com/releases/gsdnld.html
692
+ >
693
+ > After installing, run this export command again.
694
+
695
+ Then **stop**.
696
+
697
+ **Step 3: Convert to CMYK PDF/X-1a**
698
+
699
+ ```bash
700
+ mkdir -p .manuscript/output/ingram-package
701
+
702
+ gs -dPDFX -dBATCH -dNOPAUSE \
703
+ -dPDFXCompatibilityPolicy=1 \
704
+ -sColorConversionStrategy=CMYK \
705
+ -sDEVICE=pdfwrite \
706
+ -sOutputFile=.manuscript/output/ingram-package/manuscript-cmyk.pdf \
707
+ .manuscript/output/manuscript-print.pdf
708
+ ```
709
+
710
+ > **ICC Color Profile Warning:** CMYK conversion quality depends on ICC color profiles installed on your system. The converted PDF should be reviewed for color accuracy before submission to IngramSpark. Colors may shift during RGB-to-CMYK conversion, especially blues and greens.
711
+
712
+ **Step 4: Prepare cover brief and metadata**
713
+
714
+ Use the canonical print-cover asset at `.manuscript/build/paperback-cover.pdf`.
715
+
716
+ If `.manuscript/build/paperback-cover.pdf` exists, copy it into the package as `cover.pdf`.
717
+
718
+ **Generate `cover-specs.md`** and **`ingram-metadata.md`** in the package directory with the IngramSpark-specific handoff requirements:
719
+
720
+ ```markdown
721
+ # IngramSpark Cover Specifications
722
+
723
+ ## Canonical Asset
724
+ - Expected print cover file: `.manuscript/build/paperback-cover.pdf`
725
+ - If present, packaged copy: `.manuscript/output/ingram-package/cover.pdf`
726
+
727
+ ## IngramSpark-Specific Requirements
728
+ - Cover file must be PDF/X-1a compliant (CMYK color space)
729
+ - Full-wrap cover: front + spine + back in a single PDF
730
+ - Resolution: 300 DPI minimum
731
+ - All fonts must be embedded
732
+ - No transparency (flatten before submission)
733
+ - Exact wrap width, spine width, and guide lines must come from the current IngramSpark Cover Template Generator
734
+ - For hardcover/case wrap work, keep the separate case-wrap file at `.manuscript/build/hardcover-cover.pdf`
735
+ ```
736
+
737
+ Output: `.manuscript/output/ingram-package/` containing `manuscript-cmyk.pdf`, `cover-specs.md`, `ingram-metadata.md`, and `cover.pdf` when `.manuscript/build/paperback-cover.pdf` exists
738
+
739
+ ---
740
+
741
+ #### FORMAT: query-package (EXP-12)
742
+
743
+ Bundle a query submission package with query letter, synopsis, and sample chapters for agent/editor queries.
744
+
745
+ **Work type check:** Look up `query_package` in `CONSTRAINTS.json` under `exports`. Available for `prose`, `script`, and `sacred` group work types. If the current work type's group is not in the `available` list, inform the writer and **stop**.
746
+
747
+ **Step 1: Check prerequisites**
748
+
749
+ Check for the following files:
750
+
751
+ | File | Source | If Missing |
752
+ |------|--------|------------|
753
+ | Query letter | `.manuscript/marketing/QUERY-LETTER.md` | Suggest running `/scr:query-letter` to generate one |
754
+ | Synopsis | `.manuscript/marketing/SYNOPSIS-*.md` | Suggest running `/scr:synopsis` to generate one |
755
+ | Sample chapters | First 3 body units from OUTLINE.md | Assembled from `.manuscript/drafts/body/` |
756
+
757
+ If query letter or synopsis are missing:
758
+ > **Missing prerequisites for query package:**
759
+ > - [List missing items]
760
+ >
761
+ > **Generate missing pieces:**
762
+ > - Query letter: `/scr:query-letter`
763
+ > - Synopsis: `/scr:synopsis`
764
+ >
765
+ > Or continue with available materials only? The package will be incomplete.
766
+
767
+ If the writer chooses to continue, assemble what is available. Otherwise, **stop** and let them generate the missing pieces first.
768
+
769
+ **Step 2: Extract sample chapters**
770
+
771
+ Read OUTLINE.md and extract the first 3 body units (chapters/scenes). Read their draft files from `.manuscript/drafts/body/` and concatenate into `sample-chapters.md`.
772
+
773
+ **Step 3: Assemble query package**
774
+
775
+ ```bash
776
+ mkdir -p .manuscript/output/query-package
777
+ ```
778
+
779
+ Copy `.manuscript/marketing/QUERY-LETTER.md` into the package directory as `query-letter.md`.
780
+
781
+ Select the synopsis file from `.manuscript/marketing/` in this order of preference:
782
+ 1. `SYNOPSIS-1p.md`
783
+ 2. `SYNOPSIS-2p.md`
784
+ 3. Any other `SYNOPSIS-*.md`
785
+
786
+ Copy the chosen synopsis into the package directory as `synopsis.md`. Then create a combined DOCX:
787
+
788
+ ```bash
789
+ pandoc .manuscript/output/query-package/query-letter.md \
790
+ .manuscript/output/query-package/synopsis.md \
791
+ .manuscript/output/query-package/sample-chapters.md \
792
+ -o .manuscript/output/query-package/query-package.docx
793
+ ```
794
+
795
+ The shipped query-package flow uses Pandoc's default DOCX styling. If you want a custom manuscript look, provide your own Pandoc reference document when running the underlying command.
796
+
797
+ Output: `.manuscript/output/query-package/` containing `query-letter.md`, `synopsis.md`, `sample-chapters.md`, `query-package.docx`
798
+
799
+ ---
800
+
801
+ #### FORMAT: submission-package (EXP-13)
802
+
803
+ Bundle a full manuscript submission package with complete DOCX, synopsis, cover letter, and author bio for publisher/agent submission.
804
+
805
+ **Work type check:** Look up `submission_package` in `CONSTRAINTS.json` under `exports`. Available for `prose`, `script`, and `sacred` group work types. If the current work type's group is not in the `available` list, inform the writer and **stop**.
806
+
807
+ **Step 1: Check prerequisites**
808
+
809
+ Check for the following files:
810
+
811
+ | File | Source | If Missing |
812
+ |------|--------|------------|
813
+ | Full manuscript DOCX | `.manuscript/output/manuscript.docx` | Run `/scr:export --format docx` first |
814
+ | Synopsis | `.manuscript/marketing/SYNOPSIS-*.md` | Suggest running `/scr:synopsis` |
815
+ | Cover letter | `.manuscript/marketing/QUERY-LETTER.md` | Suggest running `/scr:query-letter` (adapted as cover letter) |
816
+ | Author bio | `.manuscript/back-matter/about-author.md` | Suggest running `/scr:back-matter --element about-author` |
817
+
818
+ If prerequisites are missing:
819
+ > **Missing prerequisites for submission package:**
820
+ > - [List missing items]
821
+ >
822
+ > **Generate missing pieces:**
823
+ > - Full manuscript: `/scr:export --format docx`
824
+ > - Synopsis: `/scr:synopsis`
825
+ > - Cover letter: `/scr:query-letter`
826
+ > - Author bio: `/scr:back-matter --element about-author`
827
+ >
828
+ > Or continue with available materials only?
829
+
830
+ **Step 2: Assemble submission package**
831
+
832
+ ```bash
833
+ mkdir -p .manuscript/output/submission-package
834
+ ```
835
+
836
+ Copy available files into the package directory:
837
+
838
+ - `manuscript.docx` -- full manuscript in standard format
839
+ - `synopsis.md` -- chosen from `.manuscript/marketing/SYNOPSIS-*.md` (prefer `1p`, then `2p`)
840
+ - `cover-letter.md` -- adapted from `.manuscript/marketing/QUERY-LETTER.md` for this specific submission
841
+ - `about-author.md` -- author bio from back matter
842
+
843
+ **Step 3: Generate submission checklist**
844
+
845
+ Create `submission-checklist.md` in the package directory:
846
+
847
+ ```markdown
848
+ # Submission Checklist
849
+
850
+ - [ ] Manuscript DOCX reviewed for formatting (12pt, double-spaced, 1" margins)
851
+ - [ ] Synopsis is [1-2 pages / per agent guidelines]
852
+ - [ ] Cover letter personalized for target agent/editor
853
+ - [ ] Author bio is current and appropriate length
854
+ - [ ] All files named per submission guidelines
855
+ - [ ] Word count noted: [word_count] words
856
+ - [ ] Genre/category confirmed: [genre from WORK.md]
857
+
858
+ ## Common Submission Requirements
859
+ - Most agents want: query letter + synopsis + first [10/25/50] pages
860
+ - Some want: full manuscript attached
861
+ - Always follow the specific agent's submission guidelines
862
+ ```
863
+
864
+ Output: `.manuscript/output/submission-package/` containing `manuscript.docx`, `synopsis.md`, `cover-letter.md`, `about-author.md`, `submission-checklist.md`
865
+
866
+ ---
867
+
868
+ ### STEP 5: REPORT
869
+
870
+ After export completes, report:
871
+
872
+ 1. **Output file path** and file size
873
+ 2. **Assembly summary:**
874
+ - Number of front matter elements included
875
+ - Number of body units included (and any missing/skipped)
876
+ - Number of back matter elements included
877
+ - Total word count of assembled manuscript
878
+ 3. **Warnings** from assembly (missing units, missing front matter, missing cover image)
879
+ 4. **Format-specific notes:**
880
+ - For EPUB: suggest validation with EPUBCheck if Java is available
881
+ ```bash
882
+ command -v java >/dev/null 2>&1
883
+ ```
884
+ If Java is available: "Consider validating your EPUB with EPUBCheck: `java -jar epubcheck.jar .manuscript/output/manuscript.epub`"
885
+ - For DOCX: note that styling comes from the reference document
886
+ - For PDF --print-ready: confirm the trim size and margins used
887
+
888
+ **Example output:**
889
+
890
+ > **Export complete!**
891
+ >
892
+ > **File:** `.manuscript/output/manuscript.epub` (1.2 MB)
893
+ >
894
+ > **Assembly:**
895
+ > - 8 front matter elements
896
+ > - 24 body units (2 missing: "Chapter 12", "Epilogue")
897
+ > - 3 back matter elements
898
+ > - 78,450 words
899
+ >
900
+ > **Warnings:**
901
+ > - Missing draft for "Chapter 12" -- skipped
902
+ > - Missing draft for "Epilogue" -- skipped
903
+ > - No cover image found -- EPUB generated without cover
904
+ >
905
+ > **Next steps:**
906
+ > - Add missing chapters and re-export
907
+ > - Validate EPUB: `java -jar epubcheck.jar .manuscript/output/manuscript.epub`
908
+
909
+ ---
910
+
911
+ ### STEP 6: HISTORY LOG
912
+
913
+ After the export completes (success or failure), append one line to `.manuscript/HISTORY.log` per `docs/history-protocol.md`:
914
+
915
+ ```
916
+ {ISO timestamp} | scr:export | format={resolved format} | files={output filename or package dir} | outcome={ok|failed:<short-reason>}
917
+ ```
918
+
919
+ For multi-file packages (kdp-package, ingram-package, query-package, submission-package), record the package directory in `files=` rather than enumerating individual files. Create HISTORY.log if it does not exist.
920
+
921
+ ## Response Contract
922
+
923
+ Every writer-facing response must end with one to four next-command suggestions. Each suggestion must include a short explanation of what that path will do.
924
+
925
+ Use this format:
926
+
927
+ ```markdown
928
+ Next commands:
929
+ - `/scr:...`: One short sentence explaining what this path will do.
930
+ - `/scr:...`: One short sentence explaining what this alternate path will do.
931
+ ```
932
+
933
+ If exactly one path is clearly best, provide one suggestion. If two, three, or four useful paths exist, show them as alternatives. Do not force a linear path when the writer has a real choice.
934
+
935
+ If the writer seems unsure or no specific next command is obvious, include this default option:
936
+
937
+ ```markdown
938
+ Next commands:
939
+ - `/scr:next`: Inspect the project state and choose the right next step.
940
+ ```
941
+
942
+ If the command stops because a prerequisite is missing, suggest the command that fixes the prerequisite. Keep every explanation practical and writer-facing.