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.
- package/CHANGELOG.md +161 -0
- package/LICENSE +22 -0
- package/README.md +372 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +50 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/check.d.ts +6 -0
- package/dist/commands/check.d.ts.map +1 -0
- package/dist/commands/check.js +32 -0
- package/dist/commands/check.js.map +1 -0
- package/dist/commands/init.d.ts +6 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +160 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/plugin.d.ts +6 -0
- package/dist/commands/plugin.d.ts.map +1 -0
- package/dist/commands/plugin.js +135 -0
- package/dist/commands/plugin.js.map +1 -0
- package/dist/commands/upgrade.d.ts +6 -0
- package/dist/commands/upgrade.d.ts.map +1 -0
- package/dist/commands/upgrade.js +92 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/core/config.d.ts +72 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +136 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/errors.d.ts +59 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +125 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/platform.d.ts +27 -0
- package/dist/core/platform.d.ts.map +1 -0
- package/dist/core/platform.js +75 -0
- package/dist/core/platform.js.map +1 -0
- package/dist/core/template.d.ts +35 -0
- package/dist/core/template.d.ts.map +1 -0
- package/dist/core/template.js +94 -0
- package/dist/core/template.js.map +1 -0
- package/dist/plugins/identifier.d.ts +13 -0
- package/dist/plugins/identifier.d.ts.map +1 -0
- package/dist/plugins/identifier.js +72 -0
- package/dist/plugins/identifier.js.map +1 -0
- package/dist/plugins/installers/base.d.ts +27 -0
- package/dist/plugins/installers/base.d.ts.map +1 -0
- package/dist/plugins/installers/base.js +30 -0
- package/dist/plugins/installers/base.js.map +1 -0
- package/dist/plugins/installers/github.d.ts +22 -0
- package/dist/plugins/installers/github.d.ts.map +1 -0
- package/dist/plugins/installers/github.js +133 -0
- package/dist/plugins/installers/github.js.map +1 -0
- package/dist/plugins/installers/local.d.ts +16 -0
- package/dist/plugins/installers/local.d.ts.map +1 -0
- package/dist/plugins/installers/local.js +69 -0
- package/dist/plugins/installers/local.js.map +1 -0
- package/dist/plugins/installers/npm.d.ts +20 -0
- package/dist/plugins/installers/npm.d.ts.map +1 -0
- package/dist/plugins/installers/npm.js +99 -0
- package/dist/plugins/installers/npm.js.map +1 -0
- package/dist/plugins/manager.d.ts +77 -0
- package/dist/plugins/manager.d.ts.map +1 -0
- package/dist/plugins/manager.js +349 -0
- package/dist/plugins/manager.js.map +1 -0
- package/dist/plugins/registry.d.ts +48 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +111 -0
- package/dist/plugins/registry.js.map +1 -0
- package/dist/plugins/types.d.ts +66 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +2 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/plugins/validator.d.ts +19 -0
- package/dist/plugins/validator.d.ts.map +1 -0
- package/dist/plugins/validator.js +164 -0
- package/dist/plugins/validator.js.map +1 -0
- package/dist/utils/logger.d.ts +13 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +48 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/project.d.ts +24 -0
- package/dist/utils/project.d.ts.map +1 -0
- package/dist/utils/project.js +61 -0
- package/dist/utils/project.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +21 -0
- package/dist/version.js.map +1 -0
- package/package.json +76 -0
- package/plugins/authentic-voice/README.md +31 -0
- package/plugins/authentic-voice/commands/authentic-voice.md +73 -0
- package/plugins/authentic-voice/commands/authenticity-audit.md +37 -0
- package/plugins/authentic-voice/config.yaml +30 -0
- package/plugins/authentic-voice/experts/authentic-editor.md +27 -0
- package/plugins/export/README.md +319 -0
- package/plugins/export/commands/export.md +460 -0
- package/plugins/export/commands/generate-cover.md +256 -0
- package/plugins/export/commands/metadata.md +309 -0
- package/plugins/export/config.yaml +47 -0
- package/plugins/export/experts/publishing-expert.md +171 -0
- package/plugins/export/templates/epub/chapter-template.html +13 -0
- package/plugins/export/templates/epub/cover-template.html +14 -0
- package/plugins/export/templates/epub/stylesheet.css +200 -0
- package/plugins/export/templates/pdf/ebook-style.css +137 -0
- package/plugins/export/templates/pdf/print-style.css +179 -0
- package/plugins/export/templates/platforms/jinjiang-format.md +101 -0
- package/plugins/export/templates/platforms/qidian-format.md +108 -0
- package/plugins/export/templates/platforms/tomato-format.md +95 -0
- package/plugins/translate/README.md +265 -0
- package/plugins/translate/commands/glossary.md +731 -0
- package/plugins/translate/commands/translate-preview.md +543 -0
- package/plugins/translate/commands/translate.md +649 -0
- package/plugins/translate/config.yaml +43 -0
- package/plugins/translate/experts/literary-translator.md +605 -0
- package/templates/commands/analyze.md +1485 -0
- package/templates/commands/checklist.md +434 -0
- package/templates/commands/clarify.md +257 -0
- package/templates/commands/constitution.md +257 -0
- package/templates/commands/expert.md +136 -0
- package/templates/commands/plan.md +749 -0
- package/templates/commands/recap.md +613 -0
- package/templates/commands/relations.md +96 -0
- package/templates/commands/revise.md +341 -0
- package/templates/commands/specify.md +682 -0
- package/templates/commands/tasks.md +142 -0
- package/templates/commands/timeline.md +73 -0
- package/templates/commands/track-init.md +137 -0
- package/templates/commands/track.md +463 -0
- package/templates/commands/write.md +1264 -0
- package/templates/config/keyword-mappings.json +106 -0
- package/templates/knowledge/audit-config.json +26 -0
- package/templates/knowledge/character-profiles.md +152 -0
- package/templates/knowledge/character-voices.md +137 -0
- package/templates/knowledge/locations.md +184 -0
- package/templates/knowledge/world-setting.md +121 -0
- package/templates/knowledge-base/README.md +285 -0
- package/templates/knowledge-base/character-archetypes/01-hero.md +233 -0
- package/templates/knowledge-base/character-archetypes/02-mentor.md +177 -0
- package/templates/knowledge-base/character-archetypes/03-shadow.md +221 -0
- package/templates/knowledge-base/character-archetypes/04-ally.md +178 -0
- package/templates/knowledge-base/character-archetypes/05-shapeshifter.md +177 -0
- package/templates/knowledge-base/character-archetypes/06-trickster.md +181 -0
- package/templates/knowledge-base/character-archetypes/07-threshold-guardian.md +177 -0
- package/templates/knowledge-base/character-archetypes/08-herald.md +180 -0
- package/templates/knowledge-base/character-archetypes/09-father.md +249 -0
- package/templates/knowledge-base/character-archetypes/10-mother.md +202 -0
- package/templates/knowledge-base/character-archetypes/11-child.md +183 -0
- package/templates/knowledge-base/character-archetypes/12-sage.md +202 -0
- package/templates/knowledge-base/character-archetypes/README.md +60 -0
- package/templates/knowledge-base/character-archetypes/application-guide.md +222 -0
- package/templates/knowledge-base/character-archetypes/archetype-combinations.md +242 -0
- package/templates/knowledge-base/character-archetypes/config.yaml +28 -0
- package/templates/knowledge-base/character-archetypes/examples-analysis.md +223 -0
- package/templates/knowledge-base/craft/character-arc.md +1153 -0
- package/templates/knowledge-base/craft/dialogue.md +1170 -0
- package/templates/knowledge-base/craft/pacing.md +1200 -0
- package/templates/knowledge-base/craft/scene-structure.md +1136 -0
- package/templates/knowledge-base/craft/show-not-tell.md +1012 -0
- package/templates/knowledge-base/emotional-beats/01-first-meeting.md +145 -0
- package/templates/knowledge-base/emotional-beats/02-bonding-moment.md +226 -0
- package/templates/knowledge-base/emotional-beats/03-declaration.md +284 -0
- package/templates/knowledge-base/emotional-beats/04-triumph.md +240 -0
- package/templates/knowledge-base/emotional-beats/05-reunion.md +396 -0
- package/templates/knowledge-base/emotional-beats/06-forgiveness.md +204 -0
- package/templates/knowledge-base/emotional-beats/07-betrayal.md +204 -0
- package/templates/knowledge-base/emotional-beats/08-loss.md +214 -0
- package/templates/knowledge-base/emotional-beats/09-rejection.md +254 -0
- package/templates/knowledge-base/emotional-beats/10-failure.md +244 -0
- package/templates/knowledge-base/emotional-beats/11-misunderstanding.md +205 -0
- package/templates/knowledge-base/emotional-beats/12-farewell.md +283 -0
- package/templates/knowledge-base/emotional-beats/13-revelation.md +242 -0
- package/templates/knowledge-base/emotional-beats/14-point-of-no-return.md +215 -0
- package/templates/knowledge-base/emotional-beats/15-dark-night.md +244 -0
- package/templates/knowledge-base/emotional-beats/16-sacrifice.md +246 -0
- package/templates/knowledge-base/emotional-beats/17-awakening.md +246 -0
- package/templates/knowledge-base/emotional-beats/18-confrontation.md +217 -0
- package/templates/knowledge-base/emotional-beats/19-bittersweet-goodbye.md +368 -0
- package/templates/knowledge-base/emotional-beats/20-moral-dilemma.md +248 -0
- package/templates/knowledge-base/emotional-beats/21-temptation.md +240 -0
- package/templates/knowledge-base/emotional-beats/22-redemption.md +210 -0
- package/templates/knowledge-base/emotional-beats/README.md +104 -0
- package/templates/knowledge-base/emotional-beats/beat-sequences.md +276 -0
- package/templates/knowledge-base/emotional-beats/config.yaml +30 -0
- package/templates/knowledge-base/emotional-beats/pacing-guide.md +390 -0
- package/templates/knowledge-base/genres/historical.md +1127 -0
- package/templates/knowledge-base/genres/mystery.md +1123 -0
- package/templates/knowledge-base/genres/revenge.md +846 -0
- package/templates/knowledge-base/genres/romance.md +948 -0
- package/templates/knowledge-base/genres/sci-fi.md +156 -0
- package/templates/knowledge-base/genres/thriller.md +166 -0
- package/templates/knowledge-base/genres/wuxia.md +143 -0
- package/templates/knowledge-base/references/README.md +96 -0
- package/templates/knowledge-base/references/china-1920s/culture.md +423 -0
- package/templates/knowledge-base/references/china-1920s/daily-life.md +616 -0
- package/templates/knowledge-base/references/china-1920s/overview.md +298 -0
- package/templates/knowledge-base/references/china-1920s/society.md +703 -0
- package/templates/knowledge-base/references/china-1920s/warlords.md +427 -0
- package/templates/knowledge-base/references/cultivation-world/daily-life.md +108 -0
- package/templates/knowledge-base/references/cultivation-world/overview.md +64 -0
- package/templates/knowledge-base/references/cultivation-world/power-system.md +108 -0
- package/templates/knowledge-base/references/cultivation-world/sects.md +104 -0
- package/templates/knowledge-base/references/cultivation-world/world-setting.md +108 -0
- package/templates/knowledge-base/references/modern-workplace/corporate.md +115 -0
- package/templates/knowledge-base/references/modern-workplace/daily-life.md +129 -0
- package/templates/knowledge-base/references/modern-workplace/overview.md +73 -0
- package/templates/knowledge-base/references/modern-workplace/relationships.md +107 -0
- package/templates/knowledge-base/references/modern-workplace/tech-industry.md +131 -0
- package/templates/knowledge-base/references/tang-dynasty/culture.md +135 -0
- package/templates/knowledge-base/references/tang-dynasty/daily-life.md +139 -0
- package/templates/knowledge-base/references/tang-dynasty/overview.md +76 -0
- package/templates/knowledge-base/references/tang-dynasty/politics.md +121 -0
- package/templates/knowledge-base/references/tang-dynasty/society.md +126 -0
- package/templates/knowledge-base/requirements/README.md +240 -0
- package/templates/knowledge-base/requirements/anti-ai-v3.md +46 -0
- package/templates/knowledge-base/requirements/anti-ai-v4.md +430 -0
- package/templates/knowledge-base/requirements/fast-paced.md +552 -0
- package/templates/knowledge-base/requirements/no-poison.md +60 -0
- package/templates/knowledge-base/requirements/romance-angst.md +102 -0
- package/templates/knowledge-base/requirements/romance-sweet.md +63 -0
- package/templates/knowledge-base/requirements/serious-literature.md +45 -0
- package/templates/knowledge-base/requirements/strong-emotion.md +60 -0
- package/templates/knowledge-base/styles/README.md +302 -0
- package/templates/knowledge-base/styles/ancient-style.md +579 -0
- package/templates/knowledge-base/styles/literary.md +439 -0
- package/templates/knowledge-base/styles/minimal.md +472 -0
- package/templates/knowledge-base/styles/natural-voice.md +930 -0
- package/templates/knowledge-base/styles/web-novel.md +525 -0
- package/templates/memory/constitution.md +140 -0
- package/templates/memory/personal-voice.md +113 -0
- package/templates/scripts/README.md +187 -0
- package/templates/scripts/bash/analyze-story.sh +170 -0
- package/templates/scripts/bash/check-consistency.sh +463 -0
- package/templates/scripts/bash/check-plot.sh +374 -0
- package/templates/scripts/bash/check-timeline.sh +346 -0
- package/templates/scripts/bash/check-world.sh +395 -0
- package/templates/scripts/bash/check-writing-state.sh +854 -0
- package/templates/scripts/bash/clarify-story.sh +117 -0
- package/templates/scripts/bash/common.sh +151 -0
- package/templates/scripts/bash/constitution.sh +114 -0
- package/templates/scripts/bash/generate-tasks.sh +65 -0
- package/templates/scripts/bash/init-tracking.sh +183 -0
- package/templates/scripts/bash/manage-relations.sh +174 -0
- package/templates/scripts/bash/plan-story.sh +100 -0
- package/templates/scripts/bash/specify-story.sh +93 -0
- package/templates/scripts/bash/tasks-story.sh +96 -0
- package/templates/scripts/bash/test-word-count.sh +182 -0
- package/templates/scripts/bash/tests/bench-preload-cache.sh +100 -0
- package/templates/scripts/bash/tests/run-all-benchmarks.sh +16 -0
- package/templates/scripts/bash/tests/test-cache-semantics.sh +199 -0
- package/templates/scripts/bash/tests/test-cross-platform.sh +35 -0
- package/templates/scripts/bash/tests/test-edge-cases-bash.sh +60 -0
- package/templates/scripts/bash/tests/test-phase1-bash.sh +28 -0
- package/templates/scripts/bash/tests/test-preload-cache.sh +123 -0
- package/templates/scripts/bash/tests/test-regex-precompile.sh +89 -0
- package/templates/scripts/bash/tests/test-regression-bash.sh +42 -0
- package/templates/scripts/bash/tests/test-task6-verification.sh +200 -0
- package/templates/scripts/bash/text-audit.sh +144 -0
- package/templates/scripts/bash/track-progress.sh +194 -0
- package/templates/scripts/powershell/analyze-story.ps1 +171 -0
- package/templates/scripts/powershell/check-analyze-stage.ps1 +110 -0
- package/templates/scripts/powershell/check-consistency.ps1 +138 -0
- package/templates/scripts/powershell/check-plot.ps1 +139 -0
- package/templates/scripts/powershell/check-timeline.ps1 +112 -0
- package/templates/scripts/powershell/check-writing-state.ps1 +490 -0
- package/templates/scripts/powershell/check-writing-state.ps1.backup +135 -0
- package/templates/scripts/powershell/clarify-story.ps1 +107 -0
- package/templates/scripts/powershell/common.ps1 +36 -0
- package/templates/scripts/powershell/constitution.ps1 +142 -0
- package/templates/scripts/powershell/generate-tasks.ps1 +75 -0
- package/templates/scripts/powershell/init-tracking.ps1 +98 -0
- package/templates/scripts/powershell/manage-relations.ps1 +134 -0
- package/templates/scripts/powershell/plan-story.ps1 +96 -0
- package/templates/scripts/powershell/specify-story.ps1 +82 -0
- package/templates/scripts/powershell/tests/bench-ps-cache.ps1 +80 -0
- package/templates/scripts/powershell/tests/test-cross-platform.ps1 +27 -0
- package/templates/scripts/powershell/tests/test-edge-cases-ps.ps1 +29 -0
- package/templates/scripts/powershell/tests/test-phase1-ps.ps1 +28 -0
- package/templates/scripts/powershell/tests/test-ps-cache.ps1 +73 -0
- package/templates/scripts/powershell/tests/test-regression-ps.ps1 +40 -0
- package/templates/scripts/powershell/text-audit.ps1 +100 -0
- package/templates/scripts/powershell/track-progress.ps1 +105 -0
- package/templates/skills/genre-knowledge/fantasy/SKILL.md +355 -0
- package/templates/skills/genre-knowledge/mystery/SKILL.md +337 -0
- package/templates/skills/genre-knowledge/romance/SKILL.md +228 -0
- package/templates/skills/genre-knowledge/sci-fi/SKILL.md +65 -0
- package/templates/skills/genre-knowledge/thriller/SKILL.md +95 -0
- package/templates/skills/quality-assurance/consistency-checker/SKILL.md +341 -0
- package/templates/skills/quality-assurance/continuity-tracker/SKILL.md +157 -0
- package/templates/skills/quality-assurance/forgotten-elements/SKILL.md +147 -0
- package/templates/skills/quality-assurance/getting-started/SKILL.md +224 -0
- package/templates/skills/quality-assurance/pacing-monitor/SKILL.md +143 -0
- package/templates/skills/quality-assurance/pov-validator/SKILL.md +135 -0
- package/templates/skills/quality-assurance/pre-write-checklist/SKILL.md +583 -0
- package/templates/skills/quality-assurance/requirement-detector/CONFLICT_RESOLUTION.md +119 -0
- package/templates/skills/quality-assurance/requirement-detector/EXAMPLES.md +146 -0
- package/templates/skills/quality-assurance/requirement-detector/KEYWORDS.md +160 -0
- package/templates/skills/quality-assurance/requirement-detector/SKILL.md +149 -0
- package/templates/skills/quality-assurance/setting-detector/SKILL.md +611 -0
- package/templates/skills/quality-assurance/style-detector/CONFLICT_RESOLUTION.md +126 -0
- package/templates/skills/quality-assurance/style-detector/EXAMPLES.md +206 -0
- package/templates/skills/quality-assurance/style-detector/KEYWORDS.md +207 -0
- package/templates/skills/quality-assurance/style-detector/SKILL.md +126 -0
- package/templates/skills/quality-assurance/workflow-guide/SKILL.md +381 -0
- package/templates/skills/writing-techniques/character-arc/SKILL.md +267 -0
- package/templates/skills/writing-techniques/dialogue-techniques/SKILL.md +366 -0
- package/templates/skills/writing-techniques/multi-thread-narrative/SKILL.md +553 -0
- package/templates/skills/writing-techniques/multi-thread-narrative/experts/thread-analyst.md +226 -0
- package/templates/skills/writing-techniques/pacing-control/SKILL.md +377 -0
- package/templates/skills/writing-techniques/reader-expectation/SKILL.md +578 -0
- package/templates/skills/writing-techniques/reader-expectation/experts/expectation-analyst.md +209 -0
- package/templates/skills/writing-techniques/revision-polish/SKILL.md +496 -0
- package/templates/skills/writing-techniques/revision-polish/experts/revision-editor.md +221 -0
- package/templates/skills/writing-techniques/scene-structure/SKILL.md +361 -0
- package/templates/skills/writing-techniques/style-learning/SKILL.md +436 -0
- package/templates/specification-example.md +146 -0
- package/templates/tracking/character-state.json +78 -0
- package/templates/tracking/plot-tracker.json +62 -0
- package/templates/tracking/relationships.json +70 -0
- package/templates/tracking/timeline.json +49 -0
- package/templates/tracking/tracking-log.md +110 -0
- package/templates/tracking/validation-rules.json +128 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# 故事分析验证脚本
|
|
2
|
+
# 用于 /analyze 命令
|
|
3
|
+
|
|
4
|
+
param(
|
|
5
|
+
[string]$StoryName,
|
|
6
|
+
[string]$AnalysisType = "full" # full, compliance, quality, progress
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
# 导入通用函数
|
|
10
|
+
. "$PSScriptRoot\common.ps1"
|
|
11
|
+
|
|
12
|
+
# 获取项目根目录
|
|
13
|
+
$ProjectRoot = Get-ProjectRoot
|
|
14
|
+
Set-Location $ProjectRoot
|
|
15
|
+
|
|
16
|
+
# 确定故事路径
|
|
17
|
+
if ([string]::IsNullOrEmpty($StoryName)) {
|
|
18
|
+
$StoryName = Get-ActiveStory
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
$StoryDir = "stories\$StoryName"
|
|
22
|
+
|
|
23
|
+
# 检查必要文件
|
|
24
|
+
function Test-StoryFiles {
|
|
25
|
+
$missingFiles = @()
|
|
26
|
+
|
|
27
|
+
# 检查基准文档
|
|
28
|
+
if (-not (Test-Path ".specify\memory\constitution.md")) {
|
|
29
|
+
$missingFiles += "宪法文件"
|
|
30
|
+
}
|
|
31
|
+
if (-not (Test-Path "$StoryDir\specification.md")) {
|
|
32
|
+
$missingFiles += "规格文件"
|
|
33
|
+
}
|
|
34
|
+
if (-not (Test-Path "$StoryDir\creative-plan.md")) {
|
|
35
|
+
$missingFiles += "计划文件"
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if ($missingFiles.Count -gt 0) {
|
|
39
|
+
Write-Host "⚠️ 缺少以下基准文档:" -ForegroundColor Yellow
|
|
40
|
+
foreach ($file in $missingFiles) {
|
|
41
|
+
Write-Host " - $file"
|
|
42
|
+
}
|
|
43
|
+
return $false
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return $true
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
# 统计内容
|
|
50
|
+
function Get-ContentAnalysis {
|
|
51
|
+
$contentDir = "$StoryDir\content"
|
|
52
|
+
$totalWords = 0
|
|
53
|
+
$chapterCount = 0
|
|
54
|
+
|
|
55
|
+
if (Test-Path $contentDir) {
|
|
56
|
+
$mdFiles = Get-ChildItem "$contentDir\*.md" -ErrorAction SilentlyContinue
|
|
57
|
+
|
|
58
|
+
foreach ($file in $mdFiles) {
|
|
59
|
+
$chapterCount++
|
|
60
|
+
# 简单的字数统计(中文按字符算)
|
|
61
|
+
$content = Get-Content $file.FullName -Raw
|
|
62
|
+
$words = ($content -replace '\s', '').Length
|
|
63
|
+
$totalWords += $words
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
Write-Host "内容统计:"
|
|
68
|
+
Write-Host " 总字数:$totalWords"
|
|
69
|
+
Write-Host " 章节数:$chapterCount"
|
|
70
|
+
|
|
71
|
+
if ($chapterCount -gt 0) {
|
|
72
|
+
$avgLength = [math]::Round($totalWords / $chapterCount)
|
|
73
|
+
Write-Host " 平均章节长度:$avgLength"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
# 检查任务完成度
|
|
78
|
+
function Test-TaskCompletion {
|
|
79
|
+
$tasksFile = "$StoryDir\tasks.md"
|
|
80
|
+
|
|
81
|
+
if (-not (Test-Path $tasksFile)) {
|
|
82
|
+
Write-Host "任务文件不存在"
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
$content = Get-Content $tasksFile -Raw
|
|
87
|
+
$totalTasks = ([regex]::Matches($content, '^- \[', [System.Text.RegularExpressions.RegexOptions]::Multiline)).Count
|
|
88
|
+
$completedTasks = ([regex]::Matches($content, '^- \[x\]', [System.Text.RegularExpressions.RegexOptions]::Multiline)).Count
|
|
89
|
+
$inProgress = ([regex]::Matches($content, '^- \[~\]', [System.Text.RegularExpressions.RegexOptions]::Multiline)).Count
|
|
90
|
+
$pending = $totalTasks - $completedTasks - $inProgress
|
|
91
|
+
|
|
92
|
+
Write-Host "任务进度:"
|
|
93
|
+
Write-Host " 总任务:$totalTasks"
|
|
94
|
+
Write-Host " 已完成:$completedTasks"
|
|
95
|
+
Write-Host " 进行中:$inProgress"
|
|
96
|
+
Write-Host " 未开始:$pending"
|
|
97
|
+
|
|
98
|
+
if ($totalTasks -gt 0) {
|
|
99
|
+
$completionRate = [math]::Round(($completedTasks * 100) / $totalTasks)
|
|
100
|
+
Write-Host " 完成率:$completionRate%"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
# 检查规格符合度
|
|
105
|
+
function Test-SpecificationCompliance {
|
|
106
|
+
$specFile = "$StoryDir\specification.md"
|
|
107
|
+
|
|
108
|
+
Write-Host "规格符合度检查:"
|
|
109
|
+
|
|
110
|
+
if (Test-Path $specFile) {
|
|
111
|
+
$content = Get-Content $specFile -Raw
|
|
112
|
+
|
|
113
|
+
# 检查P0需求(简化版)
|
|
114
|
+
if ($content -match "### 必须包含(P0)") {
|
|
115
|
+
Write-Host " P0需求:检测到,需人工验证"
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
# 检查是否还有[需要澄清]标记
|
|
119
|
+
$unclearCount = ([regex]::Matches($content, '\[需要澄清\]')).Count
|
|
120
|
+
if ($unclearCount -gt 0) {
|
|
121
|
+
Write-Host " ⚠️ 仍有 $unclearCount 处需要澄清" -ForegroundColor Yellow
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
Write-Host " ✅ 所有决策已澄清" -ForegroundColor Green
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
# 主分析流程
|
|
130
|
+
Write-Host "故事分析报告"
|
|
131
|
+
Write-Host "============"
|
|
132
|
+
Write-Host "故事:$StoryName"
|
|
133
|
+
Write-Host "分析时间:$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')"
|
|
134
|
+
Write-Host ""
|
|
135
|
+
|
|
136
|
+
# 检查基准文档
|
|
137
|
+
if (-not (Test-StoryFiles)) {
|
|
138
|
+
Write-Host ""
|
|
139
|
+
Write-Host "❌ 无法进行完整分析,请先完成基准文档" -ForegroundColor Red
|
|
140
|
+
exit 1
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
Write-Host "✅ 基准文档完整" -ForegroundColor Green
|
|
144
|
+
Write-Host ""
|
|
145
|
+
|
|
146
|
+
# 根据分析类型执行
|
|
147
|
+
switch ($AnalysisType) {
|
|
148
|
+
"full" {
|
|
149
|
+
Get-ContentAnalysis
|
|
150
|
+
Write-Host ""
|
|
151
|
+
Test-TaskCompletion
|
|
152
|
+
Write-Host ""
|
|
153
|
+
Test-SpecificationCompliance
|
|
154
|
+
}
|
|
155
|
+
"quality" {
|
|
156
|
+
Get-ContentAnalysis
|
|
157
|
+
}
|
|
158
|
+
"progress" {
|
|
159
|
+
Test-TaskCompletion
|
|
160
|
+
}
|
|
161
|
+
"compliance" {
|
|
162
|
+
Test-SpecificationCompliance
|
|
163
|
+
}
|
|
164
|
+
default {
|
|
165
|
+
Write-Host "未知的分析类型:$AnalysisType" -ForegroundColor Red
|
|
166
|
+
exit 1
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
Write-Host ""
|
|
171
|
+
Write-Host "分析完成。详细报告已保存到:$StoryDir\analysis-report.md"
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env pwsh
|
|
2
|
+
# 检测 analyze 命令应该执行的阶段
|
|
3
|
+
# 返回 JSON 格式的阶段信息
|
|
4
|
+
|
|
5
|
+
param(
|
|
6
|
+
[switch]$Json
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
Set-StrictMode -Version Latest
|
|
10
|
+
$ErrorActionPreference = 'Stop'
|
|
11
|
+
|
|
12
|
+
# 加载公共函数
|
|
13
|
+
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
14
|
+
. (Join-Path $scriptDir "common.ps1")
|
|
15
|
+
|
|
16
|
+
# 获取项目根目录和故事目录
|
|
17
|
+
try {
|
|
18
|
+
$projectRoot = Get-ProjectRoot
|
|
19
|
+
$storyDir = Get-CurrentStoryDir
|
|
20
|
+
} catch {
|
|
21
|
+
Write-Error "错误: $_"
|
|
22
|
+
exit 1
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (-not $storyDir) {
|
|
26
|
+
Write-Error "错误: 未找到故事目录"
|
|
27
|
+
exit 1
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
# 默认返回值
|
|
31
|
+
$analyzeType = "content"
|
|
32
|
+
$chapterCount = 0
|
|
33
|
+
$hasSpec = $false
|
|
34
|
+
$hasPlan = $false
|
|
35
|
+
$hasTasks = $false
|
|
36
|
+
$reason = ""
|
|
37
|
+
|
|
38
|
+
# 检查规格文件
|
|
39
|
+
$specPath = Join-Path $storyDir "specification.md"
|
|
40
|
+
if (Test-Path $specPath) {
|
|
41
|
+
$hasSpec = $true
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
# 检查计划文件
|
|
45
|
+
$planPath = Join-Path $storyDir "creative-plan.md"
|
|
46
|
+
if (Test-Path $planPath) {
|
|
47
|
+
$hasPlan = $true
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# 检查任务文件
|
|
51
|
+
$tasksPath = Join-Path $storyDir "tasks.md"
|
|
52
|
+
if (Test-Path $tasksPath) {
|
|
53
|
+
$hasTasks = $true
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
# 统计章节数量
|
|
57
|
+
$contentDir = Join-Path $storyDir "content"
|
|
58
|
+
if (-not (Test-Path $contentDir)) {
|
|
59
|
+
$contentDir = Join-Path $storyDir "chapters"
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (Test-Path $contentDir) {
|
|
63
|
+
# 统计 .md 文件数量(排除索引文件)
|
|
64
|
+
$chapters = Get-ChildItem -Path $contentDir -Filter "*.md" -File |
|
|
65
|
+
Where-Object { $_.Name -notin @("README.md", "index.md") }
|
|
66
|
+
$chapterCount = $chapters.Count
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
# 决策逻辑
|
|
70
|
+
if ($chapterCount -eq 0) {
|
|
71
|
+
# 无章节内容 → 框架分析
|
|
72
|
+
$analyzeType = "framework"
|
|
73
|
+
$reason = "无章节内容,建议进行框架一致性分析"
|
|
74
|
+
} elseif ($chapterCount -lt 3) {
|
|
75
|
+
# 章节数量不足 → 框架分析(但提示可以开始写作)
|
|
76
|
+
$analyzeType = "framework"
|
|
77
|
+
$reason = "章节数量较少($chapterCount 章),建议继续写作或进行框架验证"
|
|
78
|
+
} else {
|
|
79
|
+
# 章节充足 → 内容分析
|
|
80
|
+
$analyzeType = "content"
|
|
81
|
+
$reason = "已完成 $chapterCount 章,可进行内容质量分析"
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
# 输出 JSON 或人类可读格式
|
|
85
|
+
if ($Json) {
|
|
86
|
+
# JSON 格式输出
|
|
87
|
+
$output = @{
|
|
88
|
+
analyze_type = $analyzeType
|
|
89
|
+
chapter_count = $chapterCount
|
|
90
|
+
has_spec = $hasSpec
|
|
91
|
+
has_plan = $hasPlan
|
|
92
|
+
has_tasks = $hasTasks
|
|
93
|
+
story_dir = $storyDir
|
|
94
|
+
reason = $reason
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
$output | ConvertTo-Json -Compress
|
|
98
|
+
} else {
|
|
99
|
+
# 人类可读输出
|
|
100
|
+
Write-Host "分析阶段检测结果"
|
|
101
|
+
Write-Host "=================="
|
|
102
|
+
Write-Host "故事目录: $storyDir"
|
|
103
|
+
Write-Host "章节数量: $chapterCount"
|
|
104
|
+
Write-Host "规格文件: $(if ($hasSpec) { '✅' } else { '❌' })"
|
|
105
|
+
Write-Host "计划文件: $(if ($hasPlan) { '✅' } else { '❌' })"
|
|
106
|
+
Write-Host "任务文件: $(if ($hasTasks) { '✅' } else { '❌' })"
|
|
107
|
+
Write-Host ""
|
|
108
|
+
Write-Host "推荐模式: $analyzeType"
|
|
109
|
+
Write-Host "原因: $reason"
|
|
110
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
#!/usr/bin/env pwsh
|
|
2
|
+
# 综合一致性检查(PowerShell)
|
|
3
|
+
|
|
4
|
+
Set-StrictMode -Version Latest
|
|
5
|
+
$ErrorActionPreference = 'Stop'
|
|
6
|
+
|
|
7
|
+
. "$PSScriptRoot/common.ps1"
|
|
8
|
+
|
|
9
|
+
$root = Get-ProjectRoot
|
|
10
|
+
$storyDir = Get-CurrentStoryDir
|
|
11
|
+
if (-not $storyDir) { throw "未找到故事项目(stories/*)" }
|
|
12
|
+
|
|
13
|
+
$progress = Join-Path $storyDir "progress.json"
|
|
14
|
+
$plot = Join-Path $storyDir "spec/tracking/plot-tracker.json"
|
|
15
|
+
if (-not (Test-Path $plot)) { $plot = Join-Path $root "spec/tracking/plot-tracker.json" }
|
|
16
|
+
$timeline = Join-Path $storyDir "spec/tracking/timeline.json"
|
|
17
|
+
if (-not (Test-Path $timeline)) { $timeline = Join-Path $root "spec/tracking/timeline.json" }
|
|
18
|
+
$rels = Join-Path $storyDir "spec/tracking/relationships.json"
|
|
19
|
+
if (-not (Test-Path $rels)) { $rels = Join-Path $root "spec/tracking/relationships.json" }
|
|
20
|
+
$charState = Join-Path $storyDir "spec/tracking/character-state.json"
|
|
21
|
+
if (-not (Test-Path $charState)) { $charState = Join-Path $root "spec/tracking/character-state.json" }
|
|
22
|
+
|
|
23
|
+
$TOTAL=0; $PASS=0; $WARN=0; $ERR=0
|
|
24
|
+
function Check([string]$name, [bool]$ok, [string]$msg) {
|
|
25
|
+
$script:TOTAL++
|
|
26
|
+
if ($ok) { Write-Host "✓ $name" -ForegroundColor Green; $script:PASS++ }
|
|
27
|
+
else { Write-Host "✗ $name: $msg" -ForegroundColor Red; $script:ERR++ }
|
|
28
|
+
}
|
|
29
|
+
function Warn([string]$msg) { Write-Host "⚠ $msg" -ForegroundColor Yellow; $script:WARN++ }
|
|
30
|
+
|
|
31
|
+
function Check-FileIntegrity {
|
|
32
|
+
Write-Host "📁 检查文件完整性"
|
|
33
|
+
Write-Host "────────────────"
|
|
34
|
+
Check "progress.json" (Test-Path $progress) "文件不存在"
|
|
35
|
+
Check "plot-tracker.json" (Test-Path $plot) "文件不存在"
|
|
36
|
+
Check "timeline.json" (Test-Path $timeline) "文件不存在"
|
|
37
|
+
Check "relationships.json" (Test-Path $rels) "文件不存在"
|
|
38
|
+
Check "character-state.json" (Test-Path $charState) "文件不存在"
|
|
39
|
+
Write-Host ""
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function Check-ChapterConsistency {
|
|
43
|
+
Write-Host "📖 检查章节号一致性"
|
|
44
|
+
Write-Host "───────────────────"
|
|
45
|
+
if ((Test-Path $progress) -and (Test-Path $plot)) {
|
|
46
|
+
$p = Get-Content -LiteralPath $progress -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
47
|
+
$j = Get-Content -LiteralPath $plot -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
48
|
+
$pCh = [int]($p.statistics.currentChapter ?? 0)
|
|
49
|
+
$plCh = [int]($j.currentState.chapter ?? 0)
|
|
50
|
+
Check "章节号同步" ($pCh -eq $plCh) "progress($pCh) != plot-tracker($plCh)"
|
|
51
|
+
if (Test-Path $charState) {
|
|
52
|
+
$cs = Get-Content -LiteralPath $charState -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
53
|
+
# 示例结构中 protagonist 字段不稳定,回退 characters->主角
|
|
54
|
+
$csCh = [int]($cs.protagonist.currentStatus.chapter)
|
|
55
|
+
if (-not $csCh) { $csCh = [int]($cs.characters.'主角'.lastSeen.chapter) }
|
|
56
|
+
if ($csCh) { Check "角色状态章节同步" ($pCh -eq $csCh) "与character-state($csCh)不一致" }
|
|
57
|
+
}
|
|
58
|
+
} else { Warn "部分追踪文件缺失,无法完成章节检查" }
|
|
59
|
+
Write-Host ""
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function Check-TimelineConsistency {
|
|
63
|
+
Write-Host "⏰ 检查时间线连续性"
|
|
64
|
+
Write-Host "───────────────────"
|
|
65
|
+
if (Test-Path $timeline) {
|
|
66
|
+
$j = Get-Content -LiteralPath $timeline -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
67
|
+
$events = @($j.events | Sort-Object chapter)
|
|
68
|
+
$issues=0; $prev=-1
|
|
69
|
+
foreach ($e in $events) { if ($prev -ge 0 -and $e.chapter -le $prev) { $issues++ }; $prev=$e.chapter }
|
|
70
|
+
Check "时间事件顺序" ($issues -eq 0) "发现${issues}个乱序事件"
|
|
71
|
+
$curTime = $j.storyTime.current
|
|
72
|
+
Check "当前时间设置" ([bool]$curTime) "当前故事时间未设置"
|
|
73
|
+
} else { Warn "时间线文件不存在" }
|
|
74
|
+
Write-Host ""
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function Check-CharacterConsistency {
|
|
78
|
+
Write-Host "👥 检查角色状态合理性"
|
|
79
|
+
Write-Host "─────────────────────"
|
|
80
|
+
if ((Test-Path $charState) -and (Test-Path $rels)) {
|
|
81
|
+
$cs = Get-Content -LiteralPath $charState -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
82
|
+
$rel = Get-Content -LiteralPath $rels -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
83
|
+
$name = $cs.protagonist.name
|
|
84
|
+
if (-not $name) { $name = $cs.characters.'主角'.name }
|
|
85
|
+
if ($name) {
|
|
86
|
+
$has = $false
|
|
87
|
+
if ($rel.characters) { $has = $rel.characters.PSObject.Properties.Name -contains $name }
|
|
88
|
+
Check "主角关系记录" $has "主角'$name'在relationships中无记录"
|
|
89
|
+
}
|
|
90
|
+
$loc = $cs.protagonist.currentStatus.location
|
|
91
|
+
if (-not $loc) { $loc = $cs.characters.'主角'.location }
|
|
92
|
+
Check "主角位置记录" ([bool]$loc) "主角当前位置未记录"
|
|
93
|
+
} else { Warn "角色追踪文件不完整" }
|
|
94
|
+
Write-Host ""
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function Check-ForeshadowingPlan {
|
|
98
|
+
Write-Host "🎯 检查伏笔管理"
|
|
99
|
+
Write-Host "──────────────"
|
|
100
|
+
if (Test-Path $plot) {
|
|
101
|
+
$j = Get-Content -LiteralPath $plot -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
102
|
+
$fs = @($j.foreshadowing)
|
|
103
|
+
$total = $fs.Count
|
|
104
|
+
$active = @($fs | Where-Object { $_.status -eq 'active' }).Count
|
|
105
|
+
Write-Host " 📊 伏笔统计: 总计${total}个,活跃${active}个"
|
|
106
|
+
if ($active -gt 10) { Warn "活跃伏笔过多(${active}个),可能造成读者困惑" }
|
|
107
|
+
} else { Warn "情节追踪文件不存在" }
|
|
108
|
+
Write-Host ""
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
Write-Host "═══════════════════════════════════════"
|
|
112
|
+
Write-Host "📊 综合一致性检查报告"
|
|
113
|
+
Write-Host "═══════════════════════════════════════"
|
|
114
|
+
Write-Host ""
|
|
115
|
+
|
|
116
|
+
Check-FileIntegrity
|
|
117
|
+
Check-ChapterConsistency
|
|
118
|
+
Check-TimelineConsistency
|
|
119
|
+
Check-CharacterConsistency
|
|
120
|
+
Check-ForeshadowingPlan
|
|
121
|
+
|
|
122
|
+
Write-Host "═══════════════════════════════════════"
|
|
123
|
+
Write-Host "📈 检查结果汇总"
|
|
124
|
+
Write-Host "───────────────────"
|
|
125
|
+
Write-Host " 总检查项: $TOTAL"
|
|
126
|
+
Write-Host " 通过: $PASS"
|
|
127
|
+
Write-Host " 警告: $WARN"
|
|
128
|
+
Write-Host " 错误: $ERR"
|
|
129
|
+
|
|
130
|
+
if ($ERR -eq 0 -and $WARN -eq 0) { Write-Host "`n✅ 完美!所有检查项全部通过" -ForegroundColor Green }
|
|
131
|
+
elseif ($ERR -eq 0) { Write-Host "`n⚠️ 存在$WARN 个警告,建议关注" -ForegroundColor Yellow }
|
|
132
|
+
else { Write-Host "`n❌ 发现$ERR 个错误,需要修正" -ForegroundColor Red }
|
|
133
|
+
|
|
134
|
+
Write-Host "═══════════════════════════════════════"
|
|
135
|
+
Write-Host "检查时间: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')"
|
|
136
|
+
|
|
137
|
+
if ($ERR -gt 0) { exit 1 } else { exit 0 }
|
|
138
|
+
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
#!/usr/bin/env pwsh
|
|
2
|
+
# 检查情节发展的一致性和连贯性(PowerShell)
|
|
3
|
+
|
|
4
|
+
Set-StrictMode -Version Latest
|
|
5
|
+
$ErrorActionPreference = 'Stop'
|
|
6
|
+
|
|
7
|
+
. "$PSScriptRoot/common.ps1"
|
|
8
|
+
|
|
9
|
+
$root = Get-ProjectRoot
|
|
10
|
+
$storyDir = Get-CurrentStoryDir
|
|
11
|
+
if (-not $storyDir) { throw "未找到故事项目(stories/*)" }
|
|
12
|
+
|
|
13
|
+
$plotPath = Join-Path $storyDir "spec/tracking/plot-tracker.json"
|
|
14
|
+
if (-not (Test-Path $plotPath)) { $plotPath = Join-Path $root "spec/tracking/plot-tracker.json" }
|
|
15
|
+
$outlinePath = Join-Path $storyDir "outline.md"
|
|
16
|
+
$progressPath = Join-Path $storyDir "progress.json"
|
|
17
|
+
|
|
18
|
+
function Ensure-PlotTracker {
|
|
19
|
+
if (-not (Test-Path $plotPath)) {
|
|
20
|
+
Write-Host "⚠️ 未找到情节追踪文件,正在创建..."
|
|
21
|
+
$tpl = Join-Path $root "templates/tracking/plot-tracker.json"
|
|
22
|
+
if (-not (Test-Path $tpl)) { throw "无法找到模板文件" }
|
|
23
|
+
New-Item -ItemType Directory -Path (Split-Path $plotPath -Parent) -Force | Out-Null
|
|
24
|
+
Copy-Item $tpl $plotPath -Force
|
|
25
|
+
}
|
|
26
|
+
if (-not (Test-Path $outlinePath)) { throw "未找到章节大纲 outline.md,请先使用 /outline" }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function Get-CurrentProgress {
|
|
30
|
+
if (Test-Path $progressPath) {
|
|
31
|
+
$p = Get-Content -LiteralPath $progressPath -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
32
|
+
return @{ chapter = ($p.statistics.currentChapter ?? 1); volume = ($p.statistics.currentVolume ?? 1) }
|
|
33
|
+
}
|
|
34
|
+
if (Test-Path $plotPath) {
|
|
35
|
+
$j = Get-Content -LiteralPath $plotPath -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
36
|
+
return @{ chapter = ($j.currentState.chapter ?? 1); volume = ($j.currentState.volume ?? 1) }
|
|
37
|
+
}
|
|
38
|
+
return @{ chapter = 1; volume = 1 }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function Analyze-PlotAlignment {
|
|
42
|
+
Write-Host "📊 情节发展检查报告"
|
|
43
|
+
Write-Host "━━━━━━━━━━━━━━━━━━━━"
|
|
44
|
+
$cur = Get-CurrentProgress
|
|
45
|
+
Write-Host "📍 当前进度:第$($cur.chapter)章(第$($cur.volume)卷)"
|
|
46
|
+
|
|
47
|
+
if (Test-Path $plotPath) {
|
|
48
|
+
$j = Get-Content -LiteralPath $plotPath -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
49
|
+
$main = $j.plotlines.main
|
|
50
|
+
$mainPlot = $main.currentNode
|
|
51
|
+
$status = $main.status
|
|
52
|
+
Write-Host "📖 主线进度:$mainPlot [$status]"
|
|
53
|
+
|
|
54
|
+
$completed = @($main.completedNodes)
|
|
55
|
+
Write-Host ""
|
|
56
|
+
Write-Host "✅ 已完成节点:$($completed.Count)个"
|
|
57
|
+
$completed | ForEach-Object { Write-Host " • $_" }
|
|
58
|
+
|
|
59
|
+
$upcoming = @($main.upcomingNodes)
|
|
60
|
+
if ($upcoming.Count -gt 0) {
|
|
61
|
+
Write-Host ""
|
|
62
|
+
Write-Host "→ 接下来的节点:"
|
|
63
|
+
$upcoming | Select-Object -First 3 | ForEach-Object { Write-Host " • $_" }
|
|
64
|
+
}
|
|
65
|
+
return @{ cur = $cur; json = $j }
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function Check-Foreshadowing($state) {
|
|
70
|
+
Write-Host ""
|
|
71
|
+
Write-Host "🎯 伏笔追踪"
|
|
72
|
+
Write-Host "───────────"
|
|
73
|
+
$j = $state.json
|
|
74
|
+
$curCh = [int]$state.cur.chapter
|
|
75
|
+
$fs = @($j.foreshadowing)
|
|
76
|
+
$total = $fs.Count
|
|
77
|
+
$active = @($fs | Where-Object { $_.status -eq 'active' }).Count
|
|
78
|
+
$resolved = @($fs | Where-Object { $_.status -eq 'resolved' }).Count
|
|
79
|
+
Write-Host "统计:总计${total}个,活跃${active}个,已回收${resolved}个"
|
|
80
|
+
|
|
81
|
+
if ($active -gt 0) {
|
|
82
|
+
Write-Host ""
|
|
83
|
+
Write-Host "⚠️ 待处理伏笔:"
|
|
84
|
+
$fs | Where-Object { $_.status -eq 'active' } | ForEach-Object {
|
|
85
|
+
$ch = $_.planted.chapter
|
|
86
|
+
Write-Host " • $($_.content)(第$ch章埋设)"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
$overdue = @($fs | Where-Object { $_.status -eq 'active' -and $_.planted.chapter -and ($curCh - [int]$_.planted.chapter) -gt 30 }).Count
|
|
91
|
+
if ($overdue -gt 0) { Write-Host ""; Write-Host "⚠️ 警告:有${overdue}个伏笔超过30章未处理" }
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function Check-Conflicts($state) {
|
|
95
|
+
Write-Host ""
|
|
96
|
+
Write-Host "⚔️ 冲突追踪"
|
|
97
|
+
Write-Host "───────────"
|
|
98
|
+
$active = @($state.json.conflicts.active)
|
|
99
|
+
$count = $active.Count
|
|
100
|
+
if ($count -gt 0) {
|
|
101
|
+
Write-Host "当前活跃冲突:${count}个"
|
|
102
|
+
$active | ForEach-Object { Write-Host (" • " + $_.name + " [" + $_.intensity + "]") }
|
|
103
|
+
} else { Write-Host "暂无活跃冲突" }
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function Generate-Suggestions($state) {
|
|
107
|
+
Write-Host ""
|
|
108
|
+
Write-Host "💡 建议"
|
|
109
|
+
Write-Host "───────"
|
|
110
|
+
$ch = [int]$state.cur.chapter
|
|
111
|
+
if ($ch -lt 10) { Write-Host "• 前10章是关键,确保有足够的钩子吸引读者" }
|
|
112
|
+
elseif ($ch -lt 30) { Write-Host "• 接近第一个小高潮,检查冲突是否足够激烈" }
|
|
113
|
+
elseif (($ch % 60) -gt 50) { Write-Host "• 接近卷尾,准备高潮和悬念设置" }
|
|
114
|
+
|
|
115
|
+
$activeFo = @($state.json.foreshadowing | Where-Object { $_.status -eq 'active' }).Count
|
|
116
|
+
if ($activeFo -gt 5) { Write-Host "• 活跃伏笔较多,考虑在接下来几章回收部分" }
|
|
117
|
+
$activeConf = @($state.json.conflicts.active).Count
|
|
118
|
+
if ($activeConf -eq 0 -and $ch -gt 5) { Write-Host "• 当前无活跃冲突,考虑引入新的矛盾点" }
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
Write-Host "🔍 开始检查情节一致性..."
|
|
122
|
+
Write-Host ""
|
|
123
|
+
Ensure-PlotTracker
|
|
124
|
+
$st = Analyze-PlotAlignment
|
|
125
|
+
Check-Foreshadowing $st
|
|
126
|
+
Check-Conflicts $st
|
|
127
|
+
Generate-Suggestions $st
|
|
128
|
+
|
|
129
|
+
Write-Host ""
|
|
130
|
+
Write-Host "━━━━━━━━━━━━━━━━━━━━"
|
|
131
|
+
Write-Host "✅ 检查完成"
|
|
132
|
+
|
|
133
|
+
# 更新时间戳
|
|
134
|
+
if (Test-Path $plotPath) {
|
|
135
|
+
$json = Get-Content -LiteralPath $plotPath -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
136
|
+
$json.lastUpdated = (Get-Date).ToString('yyyy-MM-ddTHH:mm:ss')
|
|
137
|
+
$json | ConvertTo-Json -Depth 12 | Set-Content -LiteralPath $plotPath -Encoding UTF8
|
|
138
|
+
}
|
|
139
|
+
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env pwsh
|
|
2
|
+
# 时间线管理与检查(PowerShell)
|
|
3
|
+
|
|
4
|
+
param(
|
|
5
|
+
[ValidateSet('show','add','check','sync')]
|
|
6
|
+
[string]$Command = 'show',
|
|
7
|
+
[string]$Param1,
|
|
8
|
+
[string]$Param2
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
Set-StrictMode -Version Latest
|
|
12
|
+
$ErrorActionPreference = 'Stop'
|
|
13
|
+
|
|
14
|
+
. "$PSScriptRoot/common.ps1"
|
|
15
|
+
|
|
16
|
+
$root = Get-ProjectRoot
|
|
17
|
+
$storyDir = Get-CurrentStoryDir
|
|
18
|
+
if (-not $storyDir) { throw "未找到故事项目(stories/*)" }
|
|
19
|
+
|
|
20
|
+
$timelinePath = Join-Path $storyDir "spec/tracking/timeline.json"
|
|
21
|
+
if (-not (Test-Path $timelinePath)) { $timelinePath = Join-Path $root "spec/tracking/timeline.json" }
|
|
22
|
+
|
|
23
|
+
function Init-Timeline {
|
|
24
|
+
if (-not (Test-Path $timelinePath)) {
|
|
25
|
+
Write-Host "⚠️ 未找到时间线文件,正在创建..."
|
|
26
|
+
$tpl = Join-Path $root "templates/tracking/timeline.json"
|
|
27
|
+
if (-not (Test-Path $tpl)) { throw "无法找到模板文件" }
|
|
28
|
+
New-Item -ItemType Directory -Path (Split-Path $timelinePath -Parent) -Force | Out-Null
|
|
29
|
+
Copy-Item $tpl $timelinePath -Force
|
|
30
|
+
Write-Host "✅ 时间线文件已创建"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function Show-Timeline {
|
|
35
|
+
Write-Host "📅 故事时间线"
|
|
36
|
+
Write-Host "━━━━━━━━━━━━━━━━━━━━"
|
|
37
|
+
if (-not (Test-Path $timelinePath)) { Write-Host "未找到时间线文件"; return }
|
|
38
|
+
$j = Get-Content -LiteralPath $timelinePath -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
39
|
+
$cur = $j.storyTime.current
|
|
40
|
+
if (-not $cur) { $cur = '未设定' }
|
|
41
|
+
Write-Host "⏰ 当前时间:$cur"
|
|
42
|
+
Write-Host ""
|
|
43
|
+
$events = @($j.events)
|
|
44
|
+
if ($events.Count -gt 0) {
|
|
45
|
+
Write-Host "📖 重要事件:"
|
|
46
|
+
Write-Host "───────────────"
|
|
47
|
+
$events | Sort-Object chapter -Descending | Select-Object -First 5 | ForEach-Object {
|
|
48
|
+
Write-Host ("第{0}章 | {1} | {2}" -f $_.chapter, $_.date, $_.event)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
$p = $j.parallelEvents.timepoints
|
|
52
|
+
if ($p) {
|
|
53
|
+
Write-Host ""
|
|
54
|
+
Write-Host "🔄 并行事件:"
|
|
55
|
+
$p.PSObject.Properties | ForEach-Object { Write-Host ("{0}: {1}" -f $_.Name, (@($_.Value) -join ', ')) }
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function Add-Event([int]$chapter, [string]$date, [string]$event) {
|
|
60
|
+
if (-not $chapter -or -not $date -or -not $event) { throw "用法: check-timeline.ps1 add <章节号> <时间> <事件描述>" }
|
|
61
|
+
Init-Timeline
|
|
62
|
+
$j = Get-Content -LiteralPath $timelinePath -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
63
|
+
if (-not $j.events) { $j | Add-Member -NotePropertyName events -NotePropertyValue @() }
|
|
64
|
+
$j.events += [pscustomobject]@{ chapter=$chapter; date=$date; event=$event; duration=''; participants=@() }
|
|
65
|
+
$j.events = @($j.events | Sort-Object chapter)
|
|
66
|
+
$j.lastUpdated = (Get-Date).ToString('yyyy-MM-ddTHH:mm:ss')
|
|
67
|
+
$j | ConvertTo-Json -Depth 12 | Set-Content -LiteralPath $timelinePath -Encoding UTF8
|
|
68
|
+
Write-Host "✅ 事件已添加:第${chapter}章 - $date - $event"
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function Check-Continuity {
|
|
72
|
+
Write-Host "🔍 检查时间线连续性"
|
|
73
|
+
Write-Host "━━━━━━━━━━━━━━━━━━━━"
|
|
74
|
+
if (-not (Test-Path $timelinePath)) { throw "时间线文件不存在" }
|
|
75
|
+
$j = Get-Content -LiteralPath $timelinePath -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
76
|
+
$chapters = @($j.events | Sort-Object chapter | ForEach-Object { $_.chapter })
|
|
77
|
+
$issues = 0
|
|
78
|
+
$prev = -1
|
|
79
|
+
foreach ($c in $chapters) {
|
|
80
|
+
if ($prev -ge 0 -and $c -le $prev) {
|
|
81
|
+
Write-Host "⚠️ 章节顺序异常:第$c 章出现在第$prev 章之后"
|
|
82
|
+
$issues++
|
|
83
|
+
}
|
|
84
|
+
$prev = $c
|
|
85
|
+
}
|
|
86
|
+
if ($issues -eq 0) { Write-Host "`n✅ 时间线检查通过,未发现逻辑问题" }
|
|
87
|
+
else { Write-Host "`n⚠️ 发现${issues}个潜在问题,请检查" }
|
|
88
|
+
$j.lastChecked = (Get-Date).ToString('yyyy-MM-ddTHH:mm:ss')
|
|
89
|
+
if (-not $j.anomalies) { $j | Add-Member anomalies (@{}) }
|
|
90
|
+
$j.anomalies.lastCheckIssues = $issues
|
|
91
|
+
$j | ConvertTo-Json -Depth 12 | Set-Content -LiteralPath $timelinePath -Encoding UTF8
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function Sync-Parallel([string]$timepoint, [string]$eventsCsv) {
|
|
95
|
+
if (-not $timepoint -or -not $eventsCsv) { throw "用法: check-timeline.ps1 sync <时间点> <事件列表,逗号分隔>" }
|
|
96
|
+
Init-Timeline
|
|
97
|
+
$j = Get-Content -LiteralPath $timelinePath -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
98
|
+
if (-not $j.parallelEvents) { $j | Add-Member -NotePropertyName parallelEvents -NotePropertyValue @{ timepoints=@{} } }
|
|
99
|
+
$events = $eventsCsv.Split(',').Trim()
|
|
100
|
+
$j.parallelEvents.timepoints[$timepoint] = $events
|
|
101
|
+
$j.lastUpdated = (Get-Date).ToString('yyyy-MM-ddTHH:mm:ss')
|
|
102
|
+
$j | ConvertTo-Json -Depth 12 | Set-Content -LiteralPath $timelinePath -Encoding UTF8
|
|
103
|
+
Write-Host "✅ 并行事件已同步:$timepoint"
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
switch ($Command) {
|
|
107
|
+
'show' { Init-Timeline; Show-Timeline }
|
|
108
|
+
'add' { Add-Event -chapter ([int]$Param1) -date $Param2 -event ($args | Select-Object -Skip 2 | Out-String).Trim() }
|
|
109
|
+
'check' { Check-Continuity }
|
|
110
|
+
'sync' { Sync-Parallel -timepoint $Param1 -eventsCsv $Param2 }
|
|
111
|
+
}
|
|
112
|
+
|