novelws 1.2.0

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 (320) hide show
  1. package/CHANGELOG.md +161 -0
  2. package/LICENSE +22 -0
  3. package/README.md +372 -0
  4. package/dist/cli.d.ts +3 -0
  5. package/dist/cli.d.ts.map +1 -0
  6. package/dist/cli.js +50 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/commands/check.d.ts +6 -0
  9. package/dist/commands/check.d.ts.map +1 -0
  10. package/dist/commands/check.js +32 -0
  11. package/dist/commands/check.js.map +1 -0
  12. package/dist/commands/init.d.ts +6 -0
  13. package/dist/commands/init.d.ts.map +1 -0
  14. package/dist/commands/init.js +160 -0
  15. package/dist/commands/init.js.map +1 -0
  16. package/dist/commands/plugin.d.ts +6 -0
  17. package/dist/commands/plugin.d.ts.map +1 -0
  18. package/dist/commands/plugin.js +135 -0
  19. package/dist/commands/plugin.js.map +1 -0
  20. package/dist/commands/upgrade.d.ts +6 -0
  21. package/dist/commands/upgrade.d.ts.map +1 -0
  22. package/dist/commands/upgrade.js +92 -0
  23. package/dist/commands/upgrade.js.map +1 -0
  24. package/dist/core/config.d.ts +72 -0
  25. package/dist/core/config.d.ts.map +1 -0
  26. package/dist/core/config.js +136 -0
  27. package/dist/core/config.js.map +1 -0
  28. package/dist/core/errors.d.ts +59 -0
  29. package/dist/core/errors.d.ts.map +1 -0
  30. package/dist/core/errors.js +125 -0
  31. package/dist/core/errors.js.map +1 -0
  32. package/dist/core/platform.d.ts +27 -0
  33. package/dist/core/platform.d.ts.map +1 -0
  34. package/dist/core/platform.js +75 -0
  35. package/dist/core/platform.js.map +1 -0
  36. package/dist/core/template.d.ts +35 -0
  37. package/dist/core/template.d.ts.map +1 -0
  38. package/dist/core/template.js +94 -0
  39. package/dist/core/template.js.map +1 -0
  40. package/dist/plugins/identifier.d.ts +13 -0
  41. package/dist/plugins/identifier.d.ts.map +1 -0
  42. package/dist/plugins/identifier.js +72 -0
  43. package/dist/plugins/identifier.js.map +1 -0
  44. package/dist/plugins/installers/base.d.ts +27 -0
  45. package/dist/plugins/installers/base.d.ts.map +1 -0
  46. package/dist/plugins/installers/base.js +30 -0
  47. package/dist/plugins/installers/base.js.map +1 -0
  48. package/dist/plugins/installers/github.d.ts +22 -0
  49. package/dist/plugins/installers/github.d.ts.map +1 -0
  50. package/dist/plugins/installers/github.js +133 -0
  51. package/dist/plugins/installers/github.js.map +1 -0
  52. package/dist/plugins/installers/local.d.ts +16 -0
  53. package/dist/plugins/installers/local.d.ts.map +1 -0
  54. package/dist/plugins/installers/local.js +69 -0
  55. package/dist/plugins/installers/local.js.map +1 -0
  56. package/dist/plugins/installers/npm.d.ts +20 -0
  57. package/dist/plugins/installers/npm.d.ts.map +1 -0
  58. package/dist/plugins/installers/npm.js +99 -0
  59. package/dist/plugins/installers/npm.js.map +1 -0
  60. package/dist/plugins/manager.d.ts +77 -0
  61. package/dist/plugins/manager.d.ts.map +1 -0
  62. package/dist/plugins/manager.js +349 -0
  63. package/dist/plugins/manager.js.map +1 -0
  64. package/dist/plugins/registry.d.ts +48 -0
  65. package/dist/plugins/registry.d.ts.map +1 -0
  66. package/dist/plugins/registry.js +111 -0
  67. package/dist/plugins/registry.js.map +1 -0
  68. package/dist/plugins/types.d.ts +66 -0
  69. package/dist/plugins/types.d.ts.map +1 -0
  70. package/dist/plugins/types.js +2 -0
  71. package/dist/plugins/types.js.map +1 -0
  72. package/dist/plugins/validator.d.ts +19 -0
  73. package/dist/plugins/validator.d.ts.map +1 -0
  74. package/dist/plugins/validator.js +164 -0
  75. package/dist/plugins/validator.js.map +1 -0
  76. package/dist/utils/logger.d.ts +13 -0
  77. package/dist/utils/logger.d.ts.map +1 -0
  78. package/dist/utils/logger.js +48 -0
  79. package/dist/utils/logger.js.map +1 -0
  80. package/dist/utils/project.d.ts +24 -0
  81. package/dist/utils/project.d.ts.map +1 -0
  82. package/dist/utils/project.js +61 -0
  83. package/dist/utils/project.js.map +1 -0
  84. package/dist/version.d.ts +3 -0
  85. package/dist/version.d.ts.map +1 -0
  86. package/dist/version.js +21 -0
  87. package/dist/version.js.map +1 -0
  88. package/package.json +76 -0
  89. package/plugins/authentic-voice/README.md +31 -0
  90. package/plugins/authentic-voice/commands/authentic-voice.md +73 -0
  91. package/plugins/authentic-voice/commands/authenticity-audit.md +37 -0
  92. package/plugins/authentic-voice/config.yaml +30 -0
  93. package/plugins/authentic-voice/experts/authentic-editor.md +27 -0
  94. package/plugins/export/README.md +319 -0
  95. package/plugins/export/commands/export.md +460 -0
  96. package/plugins/export/commands/generate-cover.md +256 -0
  97. package/plugins/export/commands/metadata.md +309 -0
  98. package/plugins/export/config.yaml +47 -0
  99. package/plugins/export/experts/publishing-expert.md +171 -0
  100. package/plugins/export/templates/epub/chapter-template.html +13 -0
  101. package/plugins/export/templates/epub/cover-template.html +14 -0
  102. package/plugins/export/templates/epub/stylesheet.css +200 -0
  103. package/plugins/export/templates/pdf/ebook-style.css +137 -0
  104. package/plugins/export/templates/pdf/print-style.css +179 -0
  105. package/plugins/export/templates/platforms/jinjiang-format.md +101 -0
  106. package/plugins/export/templates/platforms/qidian-format.md +108 -0
  107. package/plugins/export/templates/platforms/tomato-format.md +95 -0
  108. package/plugins/translate/README.md +265 -0
  109. package/plugins/translate/commands/glossary.md +731 -0
  110. package/plugins/translate/commands/translate-preview.md +543 -0
  111. package/plugins/translate/commands/translate.md +649 -0
  112. package/plugins/translate/config.yaml +43 -0
  113. package/plugins/translate/experts/literary-translator.md +605 -0
  114. package/templates/commands/analyze.md +1485 -0
  115. package/templates/commands/checklist.md +434 -0
  116. package/templates/commands/clarify.md +257 -0
  117. package/templates/commands/constitution.md +257 -0
  118. package/templates/commands/expert.md +136 -0
  119. package/templates/commands/plan.md +749 -0
  120. package/templates/commands/recap.md +613 -0
  121. package/templates/commands/relations.md +96 -0
  122. package/templates/commands/revise.md +341 -0
  123. package/templates/commands/specify.md +682 -0
  124. package/templates/commands/tasks.md +142 -0
  125. package/templates/commands/timeline.md +73 -0
  126. package/templates/commands/track-init.md +137 -0
  127. package/templates/commands/track.md +463 -0
  128. package/templates/commands/write.md +1264 -0
  129. package/templates/config/keyword-mappings.json +106 -0
  130. package/templates/knowledge/audit-config.json +26 -0
  131. package/templates/knowledge/character-profiles.md +152 -0
  132. package/templates/knowledge/character-voices.md +137 -0
  133. package/templates/knowledge/locations.md +184 -0
  134. package/templates/knowledge/world-setting.md +121 -0
  135. package/templates/knowledge-base/README.md +285 -0
  136. package/templates/knowledge-base/character-archetypes/01-hero.md +233 -0
  137. package/templates/knowledge-base/character-archetypes/02-mentor.md +177 -0
  138. package/templates/knowledge-base/character-archetypes/03-shadow.md +221 -0
  139. package/templates/knowledge-base/character-archetypes/04-ally.md +178 -0
  140. package/templates/knowledge-base/character-archetypes/05-shapeshifter.md +177 -0
  141. package/templates/knowledge-base/character-archetypes/06-trickster.md +181 -0
  142. package/templates/knowledge-base/character-archetypes/07-threshold-guardian.md +177 -0
  143. package/templates/knowledge-base/character-archetypes/08-herald.md +180 -0
  144. package/templates/knowledge-base/character-archetypes/09-father.md +249 -0
  145. package/templates/knowledge-base/character-archetypes/10-mother.md +202 -0
  146. package/templates/knowledge-base/character-archetypes/11-child.md +183 -0
  147. package/templates/knowledge-base/character-archetypes/12-sage.md +202 -0
  148. package/templates/knowledge-base/character-archetypes/README.md +60 -0
  149. package/templates/knowledge-base/character-archetypes/application-guide.md +222 -0
  150. package/templates/knowledge-base/character-archetypes/archetype-combinations.md +242 -0
  151. package/templates/knowledge-base/character-archetypes/config.yaml +28 -0
  152. package/templates/knowledge-base/character-archetypes/examples-analysis.md +223 -0
  153. package/templates/knowledge-base/craft/character-arc.md +1153 -0
  154. package/templates/knowledge-base/craft/dialogue.md +1170 -0
  155. package/templates/knowledge-base/craft/pacing.md +1200 -0
  156. package/templates/knowledge-base/craft/scene-structure.md +1136 -0
  157. package/templates/knowledge-base/craft/show-not-tell.md +1012 -0
  158. package/templates/knowledge-base/emotional-beats/01-first-meeting.md +145 -0
  159. package/templates/knowledge-base/emotional-beats/02-bonding-moment.md +226 -0
  160. package/templates/knowledge-base/emotional-beats/03-declaration.md +284 -0
  161. package/templates/knowledge-base/emotional-beats/04-triumph.md +240 -0
  162. package/templates/knowledge-base/emotional-beats/05-reunion.md +396 -0
  163. package/templates/knowledge-base/emotional-beats/06-forgiveness.md +204 -0
  164. package/templates/knowledge-base/emotional-beats/07-betrayal.md +204 -0
  165. package/templates/knowledge-base/emotional-beats/08-loss.md +214 -0
  166. package/templates/knowledge-base/emotional-beats/09-rejection.md +254 -0
  167. package/templates/knowledge-base/emotional-beats/10-failure.md +244 -0
  168. package/templates/knowledge-base/emotional-beats/11-misunderstanding.md +205 -0
  169. package/templates/knowledge-base/emotional-beats/12-farewell.md +283 -0
  170. package/templates/knowledge-base/emotional-beats/13-revelation.md +242 -0
  171. package/templates/knowledge-base/emotional-beats/14-point-of-no-return.md +215 -0
  172. package/templates/knowledge-base/emotional-beats/15-dark-night.md +244 -0
  173. package/templates/knowledge-base/emotional-beats/16-sacrifice.md +246 -0
  174. package/templates/knowledge-base/emotional-beats/17-awakening.md +246 -0
  175. package/templates/knowledge-base/emotional-beats/18-confrontation.md +217 -0
  176. package/templates/knowledge-base/emotional-beats/19-bittersweet-goodbye.md +368 -0
  177. package/templates/knowledge-base/emotional-beats/20-moral-dilemma.md +248 -0
  178. package/templates/knowledge-base/emotional-beats/21-temptation.md +240 -0
  179. package/templates/knowledge-base/emotional-beats/22-redemption.md +210 -0
  180. package/templates/knowledge-base/emotional-beats/README.md +104 -0
  181. package/templates/knowledge-base/emotional-beats/beat-sequences.md +276 -0
  182. package/templates/knowledge-base/emotional-beats/config.yaml +30 -0
  183. package/templates/knowledge-base/emotional-beats/pacing-guide.md +390 -0
  184. package/templates/knowledge-base/genres/historical.md +1127 -0
  185. package/templates/knowledge-base/genres/mystery.md +1123 -0
  186. package/templates/knowledge-base/genres/revenge.md +846 -0
  187. package/templates/knowledge-base/genres/romance.md +948 -0
  188. package/templates/knowledge-base/genres/sci-fi.md +156 -0
  189. package/templates/knowledge-base/genres/thriller.md +166 -0
  190. package/templates/knowledge-base/genres/wuxia.md +143 -0
  191. package/templates/knowledge-base/references/README.md +96 -0
  192. package/templates/knowledge-base/references/china-1920s/culture.md +423 -0
  193. package/templates/knowledge-base/references/china-1920s/daily-life.md +616 -0
  194. package/templates/knowledge-base/references/china-1920s/overview.md +298 -0
  195. package/templates/knowledge-base/references/china-1920s/society.md +703 -0
  196. package/templates/knowledge-base/references/china-1920s/warlords.md +427 -0
  197. package/templates/knowledge-base/references/cultivation-world/daily-life.md +108 -0
  198. package/templates/knowledge-base/references/cultivation-world/overview.md +64 -0
  199. package/templates/knowledge-base/references/cultivation-world/power-system.md +108 -0
  200. package/templates/knowledge-base/references/cultivation-world/sects.md +104 -0
  201. package/templates/knowledge-base/references/cultivation-world/world-setting.md +108 -0
  202. package/templates/knowledge-base/references/modern-workplace/corporate.md +115 -0
  203. package/templates/knowledge-base/references/modern-workplace/daily-life.md +129 -0
  204. package/templates/knowledge-base/references/modern-workplace/overview.md +73 -0
  205. package/templates/knowledge-base/references/modern-workplace/relationships.md +107 -0
  206. package/templates/knowledge-base/references/modern-workplace/tech-industry.md +131 -0
  207. package/templates/knowledge-base/references/tang-dynasty/culture.md +135 -0
  208. package/templates/knowledge-base/references/tang-dynasty/daily-life.md +139 -0
  209. package/templates/knowledge-base/references/tang-dynasty/overview.md +76 -0
  210. package/templates/knowledge-base/references/tang-dynasty/politics.md +121 -0
  211. package/templates/knowledge-base/references/tang-dynasty/society.md +126 -0
  212. package/templates/knowledge-base/requirements/README.md +240 -0
  213. package/templates/knowledge-base/requirements/anti-ai-v3.md +46 -0
  214. package/templates/knowledge-base/requirements/anti-ai-v4.md +430 -0
  215. package/templates/knowledge-base/requirements/fast-paced.md +552 -0
  216. package/templates/knowledge-base/requirements/no-poison.md +60 -0
  217. package/templates/knowledge-base/requirements/romance-angst.md +102 -0
  218. package/templates/knowledge-base/requirements/romance-sweet.md +63 -0
  219. package/templates/knowledge-base/requirements/serious-literature.md +45 -0
  220. package/templates/knowledge-base/requirements/strong-emotion.md +60 -0
  221. package/templates/knowledge-base/styles/README.md +302 -0
  222. package/templates/knowledge-base/styles/ancient-style.md +579 -0
  223. package/templates/knowledge-base/styles/literary.md +439 -0
  224. package/templates/knowledge-base/styles/minimal.md +472 -0
  225. package/templates/knowledge-base/styles/natural-voice.md +930 -0
  226. package/templates/knowledge-base/styles/web-novel.md +525 -0
  227. package/templates/memory/constitution.md +140 -0
  228. package/templates/memory/personal-voice.md +113 -0
  229. package/templates/scripts/README.md +187 -0
  230. package/templates/scripts/bash/analyze-story.sh +170 -0
  231. package/templates/scripts/bash/check-consistency.sh +463 -0
  232. package/templates/scripts/bash/check-plot.sh +374 -0
  233. package/templates/scripts/bash/check-timeline.sh +346 -0
  234. package/templates/scripts/bash/check-world.sh +395 -0
  235. package/templates/scripts/bash/check-writing-state.sh +854 -0
  236. package/templates/scripts/bash/clarify-story.sh +117 -0
  237. package/templates/scripts/bash/common.sh +151 -0
  238. package/templates/scripts/bash/constitution.sh +114 -0
  239. package/templates/scripts/bash/generate-tasks.sh +65 -0
  240. package/templates/scripts/bash/init-tracking.sh +183 -0
  241. package/templates/scripts/bash/manage-relations.sh +174 -0
  242. package/templates/scripts/bash/plan-story.sh +100 -0
  243. package/templates/scripts/bash/specify-story.sh +93 -0
  244. package/templates/scripts/bash/tasks-story.sh +96 -0
  245. package/templates/scripts/bash/test-word-count.sh +182 -0
  246. package/templates/scripts/bash/tests/bench-preload-cache.sh +100 -0
  247. package/templates/scripts/bash/tests/run-all-benchmarks.sh +16 -0
  248. package/templates/scripts/bash/tests/test-cache-semantics.sh +199 -0
  249. package/templates/scripts/bash/tests/test-cross-platform.sh +35 -0
  250. package/templates/scripts/bash/tests/test-edge-cases-bash.sh +60 -0
  251. package/templates/scripts/bash/tests/test-phase1-bash.sh +28 -0
  252. package/templates/scripts/bash/tests/test-preload-cache.sh +123 -0
  253. package/templates/scripts/bash/tests/test-regex-precompile.sh +89 -0
  254. package/templates/scripts/bash/tests/test-regression-bash.sh +42 -0
  255. package/templates/scripts/bash/tests/test-task6-verification.sh +200 -0
  256. package/templates/scripts/bash/text-audit.sh +144 -0
  257. package/templates/scripts/bash/track-progress.sh +194 -0
  258. package/templates/scripts/powershell/analyze-story.ps1 +171 -0
  259. package/templates/scripts/powershell/check-analyze-stage.ps1 +110 -0
  260. package/templates/scripts/powershell/check-consistency.ps1 +138 -0
  261. package/templates/scripts/powershell/check-plot.ps1 +139 -0
  262. package/templates/scripts/powershell/check-timeline.ps1 +112 -0
  263. package/templates/scripts/powershell/check-writing-state.ps1 +490 -0
  264. package/templates/scripts/powershell/check-writing-state.ps1.backup +135 -0
  265. package/templates/scripts/powershell/clarify-story.ps1 +107 -0
  266. package/templates/scripts/powershell/common.ps1 +36 -0
  267. package/templates/scripts/powershell/constitution.ps1 +142 -0
  268. package/templates/scripts/powershell/generate-tasks.ps1 +75 -0
  269. package/templates/scripts/powershell/init-tracking.ps1 +98 -0
  270. package/templates/scripts/powershell/manage-relations.ps1 +134 -0
  271. package/templates/scripts/powershell/plan-story.ps1 +96 -0
  272. package/templates/scripts/powershell/specify-story.ps1 +82 -0
  273. package/templates/scripts/powershell/tests/bench-ps-cache.ps1 +80 -0
  274. package/templates/scripts/powershell/tests/test-cross-platform.ps1 +27 -0
  275. package/templates/scripts/powershell/tests/test-edge-cases-ps.ps1 +29 -0
  276. package/templates/scripts/powershell/tests/test-phase1-ps.ps1 +28 -0
  277. package/templates/scripts/powershell/tests/test-ps-cache.ps1 +73 -0
  278. package/templates/scripts/powershell/tests/test-regression-ps.ps1 +40 -0
  279. package/templates/scripts/powershell/text-audit.ps1 +100 -0
  280. package/templates/scripts/powershell/track-progress.ps1 +105 -0
  281. package/templates/skills/genre-knowledge/fantasy/SKILL.md +355 -0
  282. package/templates/skills/genre-knowledge/mystery/SKILL.md +337 -0
  283. package/templates/skills/genre-knowledge/romance/SKILL.md +228 -0
  284. package/templates/skills/genre-knowledge/sci-fi/SKILL.md +65 -0
  285. package/templates/skills/genre-knowledge/thriller/SKILL.md +95 -0
  286. package/templates/skills/quality-assurance/consistency-checker/SKILL.md +341 -0
  287. package/templates/skills/quality-assurance/continuity-tracker/SKILL.md +157 -0
  288. package/templates/skills/quality-assurance/forgotten-elements/SKILL.md +147 -0
  289. package/templates/skills/quality-assurance/getting-started/SKILL.md +224 -0
  290. package/templates/skills/quality-assurance/pacing-monitor/SKILL.md +143 -0
  291. package/templates/skills/quality-assurance/pov-validator/SKILL.md +135 -0
  292. package/templates/skills/quality-assurance/pre-write-checklist/SKILL.md +583 -0
  293. package/templates/skills/quality-assurance/requirement-detector/CONFLICT_RESOLUTION.md +119 -0
  294. package/templates/skills/quality-assurance/requirement-detector/EXAMPLES.md +146 -0
  295. package/templates/skills/quality-assurance/requirement-detector/KEYWORDS.md +160 -0
  296. package/templates/skills/quality-assurance/requirement-detector/SKILL.md +149 -0
  297. package/templates/skills/quality-assurance/setting-detector/SKILL.md +611 -0
  298. package/templates/skills/quality-assurance/style-detector/CONFLICT_RESOLUTION.md +126 -0
  299. package/templates/skills/quality-assurance/style-detector/EXAMPLES.md +206 -0
  300. package/templates/skills/quality-assurance/style-detector/KEYWORDS.md +207 -0
  301. package/templates/skills/quality-assurance/style-detector/SKILL.md +126 -0
  302. package/templates/skills/quality-assurance/workflow-guide/SKILL.md +381 -0
  303. package/templates/skills/writing-techniques/character-arc/SKILL.md +267 -0
  304. package/templates/skills/writing-techniques/dialogue-techniques/SKILL.md +366 -0
  305. package/templates/skills/writing-techniques/multi-thread-narrative/SKILL.md +553 -0
  306. package/templates/skills/writing-techniques/multi-thread-narrative/experts/thread-analyst.md +226 -0
  307. package/templates/skills/writing-techniques/pacing-control/SKILL.md +377 -0
  308. package/templates/skills/writing-techniques/reader-expectation/SKILL.md +578 -0
  309. package/templates/skills/writing-techniques/reader-expectation/experts/expectation-analyst.md +209 -0
  310. package/templates/skills/writing-techniques/revision-polish/SKILL.md +496 -0
  311. package/templates/skills/writing-techniques/revision-polish/experts/revision-editor.md +221 -0
  312. package/templates/skills/writing-techniques/scene-structure/SKILL.md +361 -0
  313. package/templates/skills/writing-techniques/style-learning/SKILL.md +436 -0
  314. package/templates/specification-example.md +146 -0
  315. package/templates/tracking/character-state.json +78 -0
  316. package/templates/tracking/plot-tracker.json +62 -0
  317. package/templates/tracking/relationships.json +70 -0
  318. package/templates/tracking/timeline.json +49 -0
  319. package/templates/tracking/tracking-log.md +110 -0
  320. package/templates/tracking/validation-rules.json +128 -0
@@ -0,0 +1,117 @@
1
+ #!/bin/bash
2
+
3
+ # 澄清故事大纲的支撑脚本
4
+ # 用于 /clarify 命令,扫描并返回当前故事路径
5
+
6
+ set -e
7
+
8
+ # Source common functions
9
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10
+ source "$SCRIPT_DIR/common.sh"
11
+
12
+ # Parse arguments
13
+ JSON_MODE=false
14
+ PATHS_ONLY=false
15
+
16
+ while [[ $# -gt 0 ]]; do
17
+ case $1 in
18
+ --json)
19
+ JSON_MODE=true
20
+ shift
21
+ ;;
22
+ --paths-only)
23
+ PATHS_ONLY=true
24
+ shift
25
+ ;;
26
+ *)
27
+ shift
28
+ ;;
29
+ esac
30
+ done
31
+
32
+ # Get project root
33
+ PROJECT_ROOT=$(get_project_root)
34
+ cd "$PROJECT_ROOT"
35
+
36
+ # Find the current story directory
37
+ STORIES_DIR="stories"
38
+ if [ ! -d "$STORIES_DIR" ]; then
39
+ if [ "$JSON_MODE" = true ]; then
40
+ echo '{"error": "No stories directory found"}'
41
+ else
42
+ echo "错误:未找到 stories 目录,请先运行 /story 创建故事大纲"
43
+ fi
44
+ exit 1
45
+ fi
46
+
47
+ # Get the latest story (assuming single story for now, can be enhanced)
48
+ STORY_DIR=$(find "$STORIES_DIR" -maxdepth 1 -type d ! -name "stories" | sort -r | head -n 1)
49
+
50
+ if [ -z "$STORY_DIR" ]; then
51
+ if [ "$JSON_MODE" = true ]; then
52
+ echo '{"error": "No story found"}'
53
+ else
54
+ echo "错误:未找到故事,请先运行 /story 创建故事大纲"
55
+ fi
56
+ exit 1
57
+ fi
58
+
59
+ # Extract story name from directory
60
+ STORY_NAME=$(basename "$STORY_DIR")
61
+
62
+ # Find story file (新格式 specification.md)
63
+ STORY_FILE="$STORY_DIR/specification.md"
64
+ if [ ! -f "$STORY_FILE" ]; then
65
+ if [ "$JSON_MODE" = true ]; then
66
+ echo '{"error": "Story file not found (specification.md required)"}'
67
+ else
68
+ echo "错误:未找到故事文件 specification.md"
69
+ fi
70
+ exit 1
71
+ fi
72
+
73
+ # Check if clarification already exists
74
+ CLARIFICATION_EXISTS=false
75
+ if grep -q "## 澄清记录" "$STORY_FILE" 2>/dev/null; then
76
+ CLARIFICATION_EXISTS=true
77
+ fi
78
+
79
+ # Count existing clarification sessions
80
+ CLARIFICATION_COUNT=0
81
+ if [ "$CLARIFICATION_EXISTS" = true ]; then
82
+ CLARIFICATION_COUNT=$(grep -c "### 澄清会话" "$STORY_FILE" 2>/dev/null || echo "0")
83
+ fi
84
+
85
+ # Output in JSON format if requested
86
+ if [ "$JSON_MODE" = true ]; then
87
+ if [ "$PATHS_ONLY" = true ]; then
88
+ # Minimal output for command template
89
+ cat <<EOF
90
+ {
91
+ "STORY_PATH": "$STORY_FILE",
92
+ "STORY_NAME": "$STORY_NAME",
93
+ "STORY_DIR": "$STORY_DIR"
94
+ }
95
+ EOF
96
+ else
97
+ # Full output for analysis
98
+ cat <<EOF
99
+ {
100
+ "STORY_PATH": "$STORY_FILE",
101
+ "STORY_NAME": "$STORY_NAME",
102
+ "STORY_DIR": "$STORY_DIR",
103
+ "CLARIFICATION_EXISTS": $CLARIFICATION_EXISTS,
104
+ "CLARIFICATION_COUNT": $CLARIFICATION_COUNT,
105
+ "PROJECT_ROOT": "$PROJECT_ROOT"
106
+ }
107
+ EOF
108
+ fi
109
+ else
110
+ echo "找到故事:$STORY_NAME"
111
+ echo "文件路径:$STORY_FILE"
112
+ if [ "$CLARIFICATION_EXISTS" = true ]; then
113
+ echo "已有澄清会话:$CLARIFICATION_COUNT 次"
114
+ else
115
+ echo "尚未进行过澄清"
116
+ fi
117
+ fi
@@ -0,0 +1,151 @@
1
+ #!/usr/bin/env bash
2
+ # 通用函数库
3
+
4
+ # 获取项目根目录
5
+ get_project_root() {
6
+ if [ -f ".specify/config.json" ]; then
7
+ pwd
8
+ else
9
+ # 向上查找包含 .specify 的目录
10
+ current=$(pwd)
11
+ while [ "$current" != "/" ]; do
12
+ if [ -f "$current/.specify/config.json" ]; then
13
+ echo "$current"
14
+ return 0
15
+ fi
16
+ current=$(dirname "$current")
17
+ done
18
+ echo "错误: 未找到小说项目根目录" >&2
19
+ exit 1
20
+ fi
21
+ }
22
+
23
+ # 获取当前故事目录
24
+ get_current_story() {
25
+ PROJECT_ROOT=$(get_project_root)
26
+ STORIES_DIR="$PROJECT_ROOT/stories"
27
+
28
+ # 找到最新的故事目录
29
+ if [ -d "$STORIES_DIR" ]; then
30
+ latest=$(ls -t "$STORIES_DIR" 2>/dev/null | head -1)
31
+ if [ -n "$latest" ]; then
32
+ echo "$STORIES_DIR/$latest"
33
+ fi
34
+ fi
35
+ }
36
+
37
+ # 获取活跃故事名称(只返回名称,不返回路径)
38
+ get_active_story() {
39
+ story_dir=$(get_current_story)
40
+ if [ -n "$story_dir" ]; then
41
+ basename "$story_dir"
42
+ else
43
+ # 如果没有故事,返回默认名称
44
+ echo "story-$(date +%Y%m%d)"
45
+ fi
46
+ }
47
+
48
+ # 创建带编号的目录
49
+ create_numbered_dir() {
50
+ base_dir="$1"
51
+ prefix="$2"
52
+
53
+ mkdir -p "$base_dir"
54
+
55
+ # 找到最高编号
56
+ highest=0
57
+ for dir in "$base_dir"/*; do
58
+ [ -d "$dir" ] || continue
59
+ dirname=$(basename "$dir")
60
+ number=$(echo "$dirname" | grep -o '^[0-9]\+' || echo "0")
61
+ number=$((10#$number))
62
+ if [ "$number" -gt "$highest" ]; then
63
+ highest=$number
64
+ fi
65
+ done
66
+
67
+ # 返回下一个编号
68
+ next=$((highest + 1))
69
+ printf "%03d" "$next"
70
+ }
71
+
72
+ # 输出 JSON(用于与 AI 助手通信)
73
+ output_json() {
74
+ echo "$1"
75
+ }
76
+
77
+ # 确保文件存在
78
+ ensure_file() {
79
+ file="$1"
80
+ template="$2"
81
+
82
+ if [ ! -f "$file" ]; then
83
+ if [ -f "$template" ]; then
84
+ cp "$template" "$file"
85
+ else
86
+ touch "$file"
87
+ fi
88
+ fi
89
+ }
90
+
91
+ # 准确的中文字数统计
92
+ # 排除Markdown标记、空格、换行符,只统计实际内容
93
+ count_chinese_words() {
94
+ local file="$1"
95
+
96
+ if [ ! -f "$file" ]; then
97
+ echo "0"
98
+ return
99
+ fi
100
+
101
+ # 移除Markdown标记和格式符号,然后统计字符
102
+ # 1. 移除代码块
103
+ # 2. 移除标题标记 (#)
104
+ # 3. 移除强调标记 (* 和 _)
105
+ # 4. 移除链接标记 ([ ] ( ))
106
+ # 5. 移除引用标记 (>)
107
+ # 6. 移除列表标记 (- *)
108
+ # 7. 移除空格、换行、制表符
109
+ # 8. 统计剩余字符数
110
+ local word_count=$(cat "$file" | \
111
+ sed '/^```/,/^```/d' | \
112
+ sed 's/^#\+[[:space:]]*//' | \
113
+ sed 's/\*\*//g' | \
114
+ sed 's/__//g' | \
115
+ sed 's/\*//g' | \
116
+ sed 's/_//g' | \
117
+ sed 's/\[//g' | \
118
+ sed 's/\]//g' | \
119
+ sed 's/(http[^)]*)//g' | \
120
+ sed 's/^>[[:space:]]*//' | \
121
+ sed 's/^[[:space:]]*[-*][[:space:]]*//' | \
122
+ sed 's/^[[:space:]]*[0-9]\+\.[[:space:]]*//' | \
123
+ tr -d '[:space:]' | \
124
+ tr -d '[:punct:]' | \
125
+ grep -o . | \
126
+ wc -l | \
127
+ tr -d ' ')
128
+
129
+ echo "$word_count"
130
+ }
131
+
132
+ # 显示友好的字数信息
133
+ # 参数: 文件路径, 最小字数(可选), 最大字数(可选)
134
+ show_word_count_info() {
135
+ local file="$1"
136
+ local min_words="${2:-0}"
137
+ local max_words="${3:-999999}"
138
+ local actual_words=$(count_chinese_words "$file")
139
+
140
+ echo "字数:$actual_words"
141
+
142
+ if [ "$min_words" -gt 0 ]; then
143
+ if [ "$actual_words" -lt "$min_words" ]; then
144
+ echo "⚠️ 未达到最低字数要求(最小:${min_words})"
145
+ elif [ "$actual_words" -gt "$max_words" ]; then
146
+ echo "⚠️ 超过最大字数限制(最大:${max_words})"
147
+ else
148
+ echo "✅ 符合字数要求(${min_words}-${max_words})"
149
+ fi
150
+ fi
151
+ }
@@ -0,0 +1,114 @@
1
+ #!/bin/bash
2
+
3
+ # 小说创作宪法管理脚本
4
+ # 用于 /constitution 命令
5
+
6
+ set -e
7
+
8
+ # Source common functions
9
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10
+ source "$SCRIPT_DIR/common.sh"
11
+
12
+ # 获取命令参数
13
+ COMMAND="${1:-check}"
14
+
15
+ # Get project root
16
+ PROJECT_ROOT=$(get_project_root)
17
+ cd "$PROJECT_ROOT"
18
+
19
+ # 定义文件路径
20
+ CONSTITUTION_FILE=".specify/memory/constitution.md"
21
+
22
+ case "$COMMAND" in
23
+ check)
24
+ # 检查宪法文件是否存在
25
+ if [ -f "$CONSTITUTION_FILE" ]; then
26
+ echo "✅ 宪法文件已存在:$CONSTITUTION_FILE"
27
+ # 提取版本信息
28
+ VERSION=$(grep -E "^- 版本:" "$CONSTITUTION_FILE" 2>/dev/null | cut -d':' -f2 | tr -d ' ' || echo "未知")
29
+ UPDATED=$(grep -E "^- 最后修订:" "$CONSTITUTION_FILE" 2>/dev/null | cut -d':' -f2 | tr -d ' ' || echo "未知")
30
+ echo " 版本:$VERSION"
31
+ echo " 最后修订:$UPDATED"
32
+ exit 0
33
+ else
34
+ echo "❌ 尚未创建宪法文件"
35
+ echo " 建议:运行 /constitution 创建创作宪法"
36
+ exit 1
37
+ fi
38
+ ;;
39
+
40
+ init)
41
+ # 初始化宪法文件
42
+ mkdir -p "$(dirname "$CONSTITUTION_FILE")"
43
+
44
+ if [ -f "$CONSTITUTION_FILE" ]; then
45
+ echo "宪法文件已存在,准备更新"
46
+ else
47
+ echo "准备创建新的宪法文件"
48
+ fi
49
+ ;;
50
+
51
+ validate)
52
+ # 验证宪法文件格式
53
+ if [ ! -f "$CONSTITUTION_FILE" ]; then
54
+ echo "错误:宪法文件不存在"
55
+ exit 1
56
+ fi
57
+
58
+ echo "验证宪法文件..."
59
+
60
+ # 检查必要章节
61
+ REQUIRED_SECTIONS=("核心价值观" "质量标准" "创作风格" "内容规范" "读者契约")
62
+ MISSING_SECTIONS=()
63
+
64
+ for section in "${REQUIRED_SECTIONS[@]}"; do
65
+ if ! grep -q "## .* $section" "$CONSTITUTION_FILE"; then
66
+ MISSING_SECTIONS+=("$section")
67
+ fi
68
+ done
69
+
70
+ if [ ${#MISSING_SECTIONS[@]} -gt 0 ]; then
71
+ echo "⚠️ 缺少以下章节:"
72
+ for section in "${MISSING_SECTIONS[@]}"; do
73
+ echo " - $section"
74
+ done
75
+ else
76
+ echo "✅ 所有必要章节都存在"
77
+ fi
78
+
79
+ # 检查版本信息
80
+ if grep -q "^- 版本:" "$CONSTITUTION_FILE"; then
81
+ echo "✅ 版本信息完整"
82
+ else
83
+ echo "⚠️ 缺少版本信息"
84
+ fi
85
+ ;;
86
+
87
+ export)
88
+ # 导出宪法摘要
89
+ if [ ! -f "$CONSTITUTION_FILE" ]; then
90
+ echo "错误:宪法文件不存在"
91
+ exit 1
92
+ fi
93
+
94
+ echo "# 创作宪法摘要"
95
+ echo ""
96
+
97
+ # 提取核心原则
98
+ echo "## 核心原则"
99
+ grep -A 1 "^### 原则" "$CONSTITUTION_FILE" | grep "^**声明**" | cut -d':' -f2- || echo "(未找到原则声明)"
100
+
101
+ echo ""
102
+ echo "## 质量底线"
103
+ grep -A 1 "^### 标准" "$CONSTITUTION_FILE" | grep "^**要求**" | cut -d':' -f2- || echo "(未找到质量标准)"
104
+
105
+ echo ""
106
+ echo "详细内容请查看:$CONSTITUTION_FILE"
107
+ ;;
108
+
109
+ *)
110
+ echo "未知命令:$COMMAND"
111
+ echo "支持的命令:check, init, validate, export"
112
+ exit 1
113
+ ;;
114
+ esac
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env bash
2
+ # 生成写作任务
3
+
4
+ set -e
5
+
6
+ # 加载通用函数
7
+ SCRIPT_DIR=$(dirname "$0")
8
+ source "$SCRIPT_DIR/common.sh"
9
+
10
+ # 获取当前故事目录
11
+ STORY_DIR=$(get_current_story)
12
+
13
+ if [ -z "$STORY_DIR" ]; then
14
+ echo "错误: 未找到故事项目" >&2
15
+ exit 1
16
+ fi
17
+
18
+ # 检查前置条件
19
+ if [ ! -f "$STORY_DIR/specification.md" ]; then
20
+ echo "错误: 未找到故事规格,请先使用 /specify 命令" >&2
21
+ exit 1
22
+ fi
23
+
24
+ if [ ! -f "$STORY_DIR/outline.md" ]; then
25
+ echo "错误: 未找到章节规划,请先使用 /outline 命令" >&2
26
+ exit 1
27
+ fi
28
+
29
+ # 获取当前日期
30
+ CURRENT_DATE=$(date '+%Y-%m-%d')
31
+ CURRENT_DATETIME=$(date '+%Y-%m-%d %H:%M:%S')
32
+
33
+ # 创建任务文件,预先填充基础信息
34
+ TASKS_FILE="$STORY_DIR/tasks.md"
35
+ cat > "$TASKS_FILE" << EOF
36
+ # 写作任务清单
37
+
38
+ ## 任务概览
39
+ - **创建日期**:${CURRENT_DATE}
40
+ - **最后更新**:${CURRENT_DATE}
41
+ - **任务状态**:待生成
42
+
43
+ ---
44
+ EOF
45
+
46
+ # 创建进度追踪文件
47
+ PROGRESS_FILE="$STORY_DIR/progress.json"
48
+ if [ ! -f "$PROGRESS_FILE" ]; then
49
+ cat > "$PROGRESS_FILE" << EOF
50
+ {
51
+ "created_at": "${CURRENT_DATETIME}",
52
+ "updated_at": "${CURRENT_DATETIME}",
53
+ "total_chapters": 0,
54
+ "completed": 0,
55
+ "in_progress": 0,
56
+ "word_count": 0
57
+ }
58
+ EOF
59
+ fi
60
+
61
+ # 输出结果
62
+ echo "TASKS_FILE: $TASKS_FILE"
63
+ echo "PROGRESS_FILE: $PROGRESS_FILE"
64
+ echo "CURRENT_DATE: $CURRENT_DATE"
65
+ echo "STATUS: ready"
@@ -0,0 +1,183 @@
1
+ #!/bin/bash
2
+
3
+ echo "🚀 初始化追踪系统..."
4
+
5
+ # 检查前置条件
6
+ story_exists=false
7
+ outline_exists=false
8
+
9
+ # 查找 specification 文件
10
+ if ls stories/*/specification.md 1> /dev/null 2>&1; then
11
+ story_exists=true
12
+ story_file=$(ls stories/*/specification.md | head -1)
13
+ fi
14
+
15
+ # 查找 outline 文件
16
+ if ls stories/*/outline.md 1> /dev/null 2>&1; then
17
+ outline_exists=true
18
+ outline_file=$(ls stories/*/outline.md | head -1)
19
+ fi
20
+
21
+ if [ "$story_exists" = false ] || [ "$outline_exists" = false ]; then
22
+ echo "❌ 请先完成 /specify 和 /plan 命令"
23
+ echo " 缺少: ${story_exists:+}${story_exists:-specification.md} ${outline_exists:+}${outline_exists:-outline.md}"
24
+ exit 1
25
+ fi
26
+
27
+ # 创建追踪目录
28
+ mkdir -p spec/tracking
29
+
30
+ # 获取故事名称
31
+ story_dir=$(dirname "$story_file")
32
+ story_name=$(basename "$story_dir")
33
+
34
+ echo "📖 为《${story_name}》初始化追踪系统..."
35
+
36
+ # 初始化 plot-tracker.json
37
+ if [ ! -f "spec/tracking/plot-tracker.json" ]; then
38
+ echo "📝 创建 plot-tracker.json..."
39
+ cat > spec/tracking/plot-tracker.json <<EOF
40
+ {
41
+ "novel": "${story_name}",
42
+ "lastUpdated": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
43
+ "currentState": {
44
+ "chapter": 0,
45
+ "volume": 1,
46
+ "mainPlotStage": "准备阶段",
47
+ "location": "待定",
48
+ "timepoint": "故事开始前"
49
+ },
50
+ "plotlines": {
51
+ "main": {
52
+ "name": "主线剧情",
53
+ "description": "待从大纲提取",
54
+ "status": "待开始",
55
+ "currentNode": "起点",
56
+ "completedNodes": [],
57
+ "upcomingNodes": [],
58
+ "plannedClimax": {
59
+ "chapter": null,
60
+ "description": "待规划"
61
+ }
62
+ },
63
+ "subplots": []
64
+ },
65
+ "foreshadowing": [],
66
+ "conflicts": {
67
+ "active": [],
68
+ "resolved": [],
69
+ "upcoming": []
70
+ },
71
+ "checkpoints": {
72
+ "volumeEnd": [],
73
+ "majorEvents": []
74
+ },
75
+ "notes": {
76
+ "plotHoles": [],
77
+ "inconsistencies": [],
78
+ "reminders": ["请根据实际故事内容更新追踪数据"]
79
+ }
80
+ }
81
+ EOF
82
+ fi
83
+
84
+ # 初始化 timeline.json
85
+ if [ ! -f "spec/tracking/timeline.json" ]; then
86
+ echo "⏰ 创建 timeline.json..."
87
+ cat > spec/tracking/timeline.json <<EOF
88
+ {
89
+ "novel": "${story_name}",
90
+ "lastUpdated": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
91
+ "storyTimeUnit": "天",
92
+ "realWorldReference": null,
93
+ "timeline": [
94
+ {
95
+ "chapter": 0,
96
+ "storyTime": "第0天",
97
+ "description": "故事开始前",
98
+ "events": ["待添加"],
99
+ "location": "待定"
100
+ }
101
+ ],
102
+ "parallelEvents": [],
103
+ "timeSpan": {
104
+ "start": "第0天",
105
+ "current": "第0天",
106
+ "elapsed": "0天"
107
+ }
108
+ }
109
+ EOF
110
+ fi
111
+
112
+ # 初始化 relationships.json
113
+ if [ ! -f "spec/tracking/relationships.json" ]; then
114
+ echo "👥 创建 relationships.json..."
115
+ cat > spec/tracking/relationships.json <<EOF
116
+ {
117
+ "novel": "${story_name}",
118
+ "lastUpdated": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
119
+ "characters": {
120
+ "主角": {
121
+ "name": "待设定",
122
+ "relationships": {
123
+ "allies": [],
124
+ "enemies": [],
125
+ "romantic": [],
126
+ "neutral": []
127
+ }
128
+ }
129
+ },
130
+ "factions": {},
131
+ "relationshipChanges": [],
132
+ "currentTensions": []
133
+ }
134
+ EOF
135
+ fi
136
+
137
+ # 初始化 character-state.json
138
+ if [ ! -f "spec/tracking/character-state.json" ]; then
139
+ echo "📍 创建 character-state.json..."
140
+ cat > spec/tracking/character-state.json <<EOF
141
+ {
142
+ "novel": "${story_name}",
143
+ "lastUpdated": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
144
+ "characters": {
145
+ "主角": {
146
+ "name": "待设定",
147
+ "status": "健康",
148
+ "location": "待定",
149
+ "possessions": [],
150
+ "skills": [],
151
+ "lastSeen": {
152
+ "chapter": 0,
153
+ "description": "尚未出场"
154
+ },
155
+ "development": {
156
+ "physical": 0,
157
+ "mental": 0,
158
+ "emotional": 0,
159
+ "power": 0
160
+ }
161
+ }
162
+ },
163
+ "groupPositions": {},
164
+ "importantItems": {}
165
+ }
166
+ EOF
167
+ fi
168
+
169
+ echo ""
170
+ echo "✅ 追踪系统初始化完成!"
171
+ echo ""
172
+ echo "📊 已创建以下追踪文件:"
173
+ echo " • spec/tracking/plot-tracker.json - 情节追踪"
174
+ echo " • spec/tracking/timeline.json - 时间线管理"
175
+ echo " • spec/tracking/relationships.json - 关系网络"
176
+ echo " • spec/tracking/character-state.json - 角色状态"
177
+ echo ""
178
+ echo "💡 下一步:"
179
+ echo " 1. 使用 /write 开始创作(会自动更新追踪数据)"
180
+ echo " 2. 定期使用 /track 查看综合报告"
181
+ echo " 3. 使用 /plot-check 等命令进行一致性检查"
182
+ echo ""
183
+ echo "📝 提示:追踪文件已预填充基础结构,会在写作过程中自动更新"