novelws 4.0.0 → 5.0.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 +100 -623
- package/README.md +79 -594
- package/dist/cli.js +1 -3
- package/dist/cli.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +12 -99
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +17 -108
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/core/config.d.ts +1 -37
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +6 -45
- package/dist/core/config.js.map +1 -1
- package/dist/core/errors.d.ts +0 -31
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +0 -58
- package/dist/core/errors.js.map +1 -1
- package/dist/utils/diagnostics.d.ts +2 -16
- package/dist/utils/diagnostics.d.ts.map +1 -1
- package/dist/utils/diagnostics.js +5 -72
- package/dist/utils/diagnostics.js.map +1 -1
- package/dist/utils/project.d.ts +1 -1
- package/dist/utils/project.d.ts.map +1 -1
- package/dist/utils/project.js +3 -3
- package/dist/utils/project.js.map +1 -1
- package/package.json +1 -2
- package/templates/commands/analyze.md +65 -265
- package/templates/commands/expand.md +70 -0
- package/templates/commands/plan.md +47 -452
- package/templates/commands/specify.md +43 -869
- package/templates/commands/write.md +49 -643
- package/templates/dot-claude/CLAUDE.md +38 -202
- package/templates/resources/anti-ai.md +16 -0
- package/templates/resources/style-reference.md +19 -0
- package/templates/tracking/character-state.json +1 -76
- package/templates/tracking/plot-tracker.json +3 -60
- package/templates/tracking/relationships.json +1 -68
- package/templates/tracking/timeline.json +1 -47
- package/dist/commands/plugin.d.ts +0 -6
- package/dist/commands/plugin.d.ts.map +0 -1
- package/dist/commands/plugin.js +0 -135
- package/dist/commands/plugin.js.map +0 -1
- package/dist/plugins/identifier.d.ts +0 -13
- package/dist/plugins/identifier.d.ts.map +0 -1
- package/dist/plugins/identifier.js +0 -72
- package/dist/plugins/identifier.js.map +0 -1
- package/dist/plugins/installers/base.d.ts +0 -27
- package/dist/plugins/installers/base.d.ts.map +0 -1
- package/dist/plugins/installers/base.js +0 -30
- package/dist/plugins/installers/base.js.map +0 -1
- package/dist/plugins/installers/github.d.ts +0 -22
- package/dist/plugins/installers/github.d.ts.map +0 -1
- package/dist/plugins/installers/github.js +0 -133
- package/dist/plugins/installers/github.js.map +0 -1
- package/dist/plugins/installers/local.d.ts +0 -16
- package/dist/plugins/installers/local.d.ts.map +0 -1
- package/dist/plugins/installers/local.js +0 -69
- package/dist/plugins/installers/local.js.map +0 -1
- package/dist/plugins/installers/npm.d.ts +0 -20
- package/dist/plugins/installers/npm.d.ts.map +0 -1
- package/dist/plugins/installers/npm.js +0 -99
- package/dist/plugins/installers/npm.js.map +0 -1
- package/dist/plugins/manager.d.ts +0 -77
- package/dist/plugins/manager.d.ts.map +0 -1
- package/dist/plugins/manager.js +0 -349
- package/dist/plugins/manager.js.map +0 -1
- package/dist/plugins/registry.d.ts +0 -48
- package/dist/plugins/registry.d.ts.map +0 -1
- package/dist/plugins/registry.js +0 -111
- package/dist/plugins/registry.js.map +0 -1
- package/dist/plugins/types.d.ts +0 -66
- package/dist/plugins/types.d.ts.map +0 -1
- package/dist/plugins/types.js +0 -2
- package/dist/plugins/types.js.map +0 -1
- package/dist/plugins/validator.d.ts +0 -19
- package/dist/plugins/validator.d.ts.map +0 -1
- package/dist/plugins/validator.js +0 -164
- package/dist/plugins/validator.js.map +0 -1
- package/dist/utils/logger.d.ts +0 -13
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -48
- package/dist/utils/logger.js.map +0 -1
- package/plugins/authentic-voice/README.md +0 -31
- package/plugins/authentic-voice/commands/authentic-voice.md +0 -73
- package/plugins/authentic-voice/commands/authenticity-audit.md +0 -37
- package/plugins/authentic-voice/config.yaml +0 -30
- package/plugins/authentic-voice/experts/authentic-editor.md +0 -27
- package/plugins/export/README.md +0 -319
- package/plugins/export/commands/export.md +0 -460
- package/plugins/export/commands/generate-cover.md +0 -256
- package/plugins/export/commands/metadata.md +0 -309
- package/plugins/export/config.yaml +0 -47
- package/plugins/export/experts/publishing-expert.md +0 -171
- package/plugins/export/templates/epub/chapter-template.html +0 -13
- package/plugins/export/templates/epub/cover-template.html +0 -14
- package/plugins/export/templates/epub/stylesheet.css +0 -200
- package/plugins/export/templates/pdf/ebook-style.css +0 -137
- package/plugins/export/templates/pdf/print-style.css +0 -179
- package/plugins/export/templates/platforms/jinjiang-format.md +0 -101
- package/plugins/export/templates/platforms/qidian-format.md +0 -108
- package/plugins/export/templates/platforms/tomato-format.md +0 -95
- package/plugins/translate/README.md +0 -265
- package/plugins/translate/commands/glossary.md +0 -731
- package/plugins/translate/commands/translate-preview.md +0 -543
- package/plugins/translate/commands/translate.md +0 -649
- package/plugins/translate/config.yaml +0 -43
- package/plugins/translate/experts/literary-translator.md +0 -605
- package/templates/commands/character.md +0 -287
- package/templates/commands/checklist.md +0 -744
- package/templates/commands/clarify.md +0 -269
- package/templates/commands/constitution.md +0 -269
- package/templates/commands/expert.md +0 -188
- package/templates/commands/facts.md +0 -552
- package/templates/commands/guide.md +0 -900
- package/templates/commands/help-me.md +0 -221
- package/templates/commands/recap.md +0 -748
- package/templates/commands/relations.md +0 -385
- package/templates/commands/revise.md +0 -450
- package/templates/commands/search.md +0 -531
- package/templates/commands/tasks.md +0 -396
- package/templates/commands/timeline.md +0 -309
- package/templates/commands/track-init.md +0 -149
- package/templates/commands/track.md +0 -704
- package/templates/commands/volume-summary.md +0 -471
- package/templates/knowledge/audit-config.json +0 -26
- package/templates/knowledge/character-profiles.md +0 -152
- package/templates/knowledge/character-voices.md +0 -137
- package/templates/knowledge/locations.md +0 -184
- package/templates/knowledge/world-setting.md +0 -121
- package/templates/resources/character-archetypes/01-hero.md +0 -233
- package/templates/resources/character-archetypes/02-mentor.md +0 -177
- package/templates/resources/character-archetypes/03-shadow.md +0 -221
- package/templates/resources/character-archetypes/04-ally.md +0 -178
- package/templates/resources/character-archetypes/05-shapeshifter.md +0 -177
- package/templates/resources/character-archetypes/06-trickster.md +0 -181
- package/templates/resources/character-archetypes/07-threshold-guardian.md +0 -177
- package/templates/resources/character-archetypes/08-herald.md +0 -180
- package/templates/resources/character-archetypes/09-father.md +0 -249
- package/templates/resources/character-archetypes/10-mother.md +0 -202
- package/templates/resources/character-archetypes/11-child.md +0 -183
- package/templates/resources/character-archetypes/12-sage.md +0 -202
- package/templates/resources/character-archetypes/README.md +0 -60
- package/templates/resources/character-archetypes/application-guide.md +0 -222
- package/templates/resources/character-archetypes/archetype-combinations.md +0 -242
- package/templates/resources/character-archetypes/config.yaml +0 -28
- package/templates/resources/character-archetypes/examples-analysis.md +0 -223
- package/templates/resources/config/keyword-mappings.json +0 -226
- package/templates/resources/config/specification-example.md +0 -146
- package/templates/resources/craft/character-arc.md +0 -1153
- package/templates/resources/craft/dialogue.md +0 -1170
- package/templates/resources/craft/hook-design.md +0 -345
- package/templates/resources/craft/pacing.md +0 -1200
- package/templates/resources/craft/power-system.md +0 -254
- package/templates/resources/craft/scene-structure.md +0 -1136
- package/templates/resources/craft/show-not-tell.md +0 -1012
- package/templates/resources/craft/story-structures.md +0 -134
- package/templates/resources/craft/tension-management.md +0 -168
- package/templates/resources/emotional-beats/01-first-meeting.md +0 -145
- package/templates/resources/emotional-beats/02-bonding-moment.md +0 -226
- package/templates/resources/emotional-beats/03-declaration.md +0 -284
- package/templates/resources/emotional-beats/04-triumph.md +0 -240
- package/templates/resources/emotional-beats/05-reunion.md +0 -396
- package/templates/resources/emotional-beats/06-forgiveness.md +0 -204
- package/templates/resources/emotional-beats/07-betrayal.md +0 -204
- package/templates/resources/emotional-beats/08-loss.md +0 -214
- package/templates/resources/emotional-beats/09-rejection.md +0 -254
- package/templates/resources/emotional-beats/10-failure.md +0 -244
- package/templates/resources/emotional-beats/11-misunderstanding.md +0 -205
- package/templates/resources/emotional-beats/12-farewell.md +0 -283
- package/templates/resources/emotional-beats/13-revelation.md +0 -242
- package/templates/resources/emotional-beats/14-point-of-no-return.md +0 -215
- package/templates/resources/emotional-beats/15-dark-night.md +0 -244
- package/templates/resources/emotional-beats/16-sacrifice.md +0 -246
- package/templates/resources/emotional-beats/17-awakening.md +0 -246
- package/templates/resources/emotional-beats/18-confrontation.md +0 -217
- package/templates/resources/emotional-beats/19-bittersweet-goodbye.md +0 -368
- package/templates/resources/emotional-beats/20-moral-dilemma.md +0 -248
- package/templates/resources/emotional-beats/21-temptation.md +0 -240
- package/templates/resources/emotional-beats/22-redemption.md +0 -210
- package/templates/resources/emotional-beats/README.md +0 -104
- package/templates/resources/emotional-beats/beat-sequences.md +0 -276
- package/templates/resources/emotional-beats/config.yaml +0 -30
- package/templates/resources/emotional-beats/pacing-guide.md +0 -390
- package/templates/resources/genres/game-lit.md +0 -174
- package/templates/resources/genres/historical.md +0 -1127
- package/templates/resources/genres/horror.md +0 -211
- package/templates/resources/genres/military.md +0 -209
- package/templates/resources/genres/mystery.md +0 -1123
- package/templates/resources/genres/rebirth.md +0 -177
- package/templates/resources/genres/revenge.md +0 -846
- package/templates/resources/genres/romance.md +0 -948
- package/templates/resources/genres/sci-fi.md +0 -156
- package/templates/resources/genres/sports.md +0 -216
- package/templates/resources/genres/thriller.md +0 -166
- package/templates/resources/genres/urban.md +0 -170
- package/templates/resources/genres/workplace.md +0 -214
- package/templates/resources/genres/wuxia.md +0 -143
- package/templates/resources/genres/xuanhuan.md +0 -234
- package/templates/resources/genres/youth.md +0 -219
- package/templates/resources/memory/personal-voice.md +0 -113
- package/templates/resources/references/README.md +0 -96
- package/templates/resources/references/china-1920s/culture.md +0 -423
- package/templates/resources/references/china-1920s/daily-life.md +0 -616
- package/templates/resources/references/china-1920s/overview.md +0 -298
- package/templates/resources/references/china-1920s/society.md +0 -703
- package/templates/resources/references/china-1920s/warlords.md +0 -427
- package/templates/resources/references/cultivation-world/daily-life.md +0 -108
- package/templates/resources/references/cultivation-world/overview.md +0 -64
- package/templates/resources/references/cultivation-world/power-system.md +0 -108
- package/templates/resources/references/cultivation-world/sects.md +0 -104
- package/templates/resources/references/cultivation-world/world-setting.md +0 -108
- package/templates/resources/references/modern-workplace/corporate.md +0 -115
- package/templates/resources/references/modern-workplace/daily-life.md +0 -129
- package/templates/resources/references/modern-workplace/overview.md +0 -73
- package/templates/resources/references/modern-workplace/relationships.md +0 -107
- package/templates/resources/references/modern-workplace/tech-industry.md +0 -131
- package/templates/resources/references/tang-dynasty/culture.md +0 -135
- package/templates/resources/references/tang-dynasty/daily-life.md +0 -139
- package/templates/resources/references/tang-dynasty/overview.md +0 -76
- package/templates/resources/references/tang-dynasty/politics.md +0 -121
- package/templates/resources/references/tang-dynasty/society.md +0 -126
- package/templates/resources/requirements/README.md +0 -240
- package/templates/resources/requirements/anti-ai-v3.md +0 -46
- package/templates/resources/requirements/anti-ai-v4-deprecated.md +0 -442
- package/templates/resources/requirements/anti-ai-v5-balanced.md +0 -203
- package/templates/resources/requirements/concretization.md +0 -90
- package/templates/resources/requirements/fast-paced.md +0 -552
- package/templates/resources/requirements/no-poison.md +0 -60
- package/templates/resources/requirements/romance-angst.md +0 -102
- package/templates/resources/requirements/romance-sweet.md +0 -63
- package/templates/resources/requirements/serious-literature.md +0 -45
- package/templates/resources/requirements/strong-emotion.md +0 -60
- package/templates/resources/scripts/README.md +0 -187
- package/templates/resources/scripts/bash/analyze-story.sh +0 -170
- package/templates/resources/scripts/bash/check-analyze-stage.sh +0 -108
- package/templates/resources/scripts/bash/check-consistency.sh +0 -463
- package/templates/resources/scripts/bash/check-facts.sh +0 -214
- package/templates/resources/scripts/bash/check-plot.sh +0 -374
- package/templates/resources/scripts/bash/check-timeline.sh +0 -346
- package/templates/resources/scripts/bash/check-world.sh +0 -395
- package/templates/resources/scripts/bash/check-writing-state.sh +0 -854
- package/templates/resources/scripts/bash/clarify-story.sh +0 -117
- package/templates/resources/scripts/bash/common.sh +0 -151
- package/templates/resources/scripts/bash/constitution.sh +0 -114
- package/templates/resources/scripts/bash/generate-tasks.sh +0 -65
- package/templates/resources/scripts/bash/init-tracking.sh +0 -183
- package/templates/resources/scripts/bash/manage-relations.sh +0 -174
- package/templates/resources/scripts/bash/migrate-tracking.sh +0 -183
- package/templates/resources/scripts/bash/plan-story.sh +0 -100
- package/templates/resources/scripts/bash/specify-story.sh +0 -93
- package/templates/resources/scripts/bash/tasks-story.sh +0 -96
- package/templates/resources/scripts/bash/test-word-count.sh +0 -182
- package/templates/resources/scripts/bash/tests/bench-preload-cache.sh +0 -100
- package/templates/resources/scripts/bash/tests/run-all-benchmarks.sh +0 -16
- package/templates/resources/scripts/bash/tests/test-cache-semantics.sh +0 -199
- package/templates/resources/scripts/bash/tests/test-cross-platform.sh +0 -35
- package/templates/resources/scripts/bash/tests/test-edge-cases-bash.sh +0 -60
- package/templates/resources/scripts/bash/tests/test-phase1-bash.sh +0 -28
- package/templates/resources/scripts/bash/tests/test-preload-cache.sh +0 -123
- package/templates/resources/scripts/bash/tests/test-regex-precompile.sh +0 -89
- package/templates/resources/scripts/bash/tests/test-regression-bash.sh +0 -42
- package/templates/resources/scripts/bash/tests/test-task6-verification.sh +0 -200
- package/templates/resources/scripts/bash/text-audit.sh +0 -144
- package/templates/resources/scripts/bash/track-progress.sh +0 -194
- package/templates/resources/scripts/powershell/analyze-story.ps1 +0 -174
- package/templates/resources/scripts/powershell/check-analyze-stage.ps1 +0 -110
- package/templates/resources/scripts/powershell/check-consistency.ps1 +0 -138
- package/templates/resources/scripts/powershell/check-facts.ps1 +0 -195
- package/templates/resources/scripts/powershell/check-plot.ps1 +0 -139
- package/templates/resources/scripts/powershell/check-timeline.ps1 +0 -112
- package/templates/resources/scripts/powershell/check-writing-state.ps1 +0 -486
- package/templates/resources/scripts/powershell/clarify-story.ps1 +0 -107
- package/templates/resources/scripts/powershell/common.ps1 +0 -36
- package/templates/resources/scripts/powershell/constitution.ps1 +0 -145
- package/templates/resources/scripts/powershell/generate-tasks.ps1 +0 -70
- package/templates/resources/scripts/powershell/init-tracking.ps1 +0 -98
- package/templates/resources/scripts/powershell/manage-relations.ps1 +0 -134
- package/templates/resources/scripts/powershell/migrate-tracking.ps1 +0 -145
- package/templates/resources/scripts/powershell/plan-story.ps1 +0 -99
- package/templates/resources/scripts/powershell/specify-story.ps1 +0 -85
- package/templates/resources/scripts/powershell/tests/bench-ps-cache.ps1 +0 -80
- package/templates/resources/scripts/powershell/tests/test-cross-platform.ps1 +0 -27
- package/templates/resources/scripts/powershell/tests/test-edge-cases-ps.ps1 +0 -29
- package/templates/resources/scripts/powershell/tests/test-phase1-ps.ps1 +0 -28
- package/templates/resources/scripts/powershell/tests/test-ps-cache.ps1 +0 -73
- package/templates/resources/scripts/powershell/tests/test-regression-ps.ps1 +0 -40
- package/templates/resources/scripts/powershell/text-audit.ps1 +0 -102
- package/templates/resources/scripts/powershell/track-progress.ps1 +0 -105
- package/templates/resources/styles/README.md +0 -302
- package/templates/resources/styles/ancient-style.md +0 -579
- package/templates/resources/styles/literary.md +0 -439
- package/templates/resources/styles/minimal.md +0 -472
- package/templates/resources/styles/natural-voice.md +0 -930
- package/templates/resources/styles/web-novel.md +0 -525
- package/templates/skills/analysis/character-analysis/SKILL.md +0 -71
- package/templates/skills/analysis/foreshadow-analysis/SKILL.md +0 -45
- package/templates/skills/analysis/hook-analysis/SKILL.md +0 -111
- package/templates/skills/analysis/logic-analysis/SKILL.md +0 -58
- package/templates/skills/analysis/opening-analysis/SKILL.md +0 -59
- package/templates/skills/analysis/pacing-analysis/SKILL.md +0 -55
- package/templates/skills/analysis/power-analysis/SKILL.md +0 -148
- package/templates/skills/analysis/reader-analysis/SKILL.md +0 -117
- package/templates/skills/analysis/style-analysis/SKILL.md +0 -60
- package/templates/skills/analysis/voice-analysis/SKILL.md +0 -42
- package/templates/skills/auto-tracking/SKILL.md +0 -280
- package/templates/skills/genre-knowledge/fantasy/SKILL.md +0 -355
- package/templates/skills/genre-knowledge/mystery/SKILL.md +0 -337
- package/templates/skills/genre-knowledge/romance/SKILL.md +0 -228
- package/templates/skills/genre-knowledge/sci-fi/SKILL.md +0 -65
- package/templates/skills/genre-knowledge/thriller/SKILL.md +0 -95
- package/templates/skills/planning/volume-detail/SKILL.md +0 -219
- package/templates/skills/quality-assurance/consistency-checker/SKILL.md +0 -412
- package/templates/skills/quality-assurance/continuity-tracker/SKILL.md +0 -157
- package/templates/skills/quality-assurance/facts-checker/SKILL.md +0 -405
- package/templates/skills/quality-assurance/forgotten-elements/SKILL.md +0 -147
- package/templates/skills/quality-assurance/getting-started/SKILL.md +0 -224
- package/templates/skills/quality-assurance/hook-checker/SKILL.md +0 -164
- package/templates/skills/quality-assurance/hook-checker/experts/hook-analyst.md +0 -33
- package/templates/skills/quality-assurance/long-series-continuity/SKILL.md +0 -570
- package/templates/skills/quality-assurance/pacing-monitor/SKILL.md +0 -143
- package/templates/skills/quality-assurance/pov-validator/SKILL.md +0 -135
- package/templates/skills/quality-assurance/pre-write-checklist/SKILL.md +0 -583
- package/templates/skills/quality-assurance/requirement-detector/CONFLICT_RESOLUTION.md +0 -119
- package/templates/skills/quality-assurance/requirement-detector/EXAMPLES.md +0 -146
- package/templates/skills/quality-assurance/requirement-detector/KEYWORDS.md +0 -160
- package/templates/skills/quality-assurance/requirement-detector/SKILL.md +0 -149
- package/templates/skills/quality-assurance/setting-detector/SKILL.md +0 -611
- package/templates/skills/quality-assurance/style-detector/CONFLICT_RESOLUTION.md +0 -126
- package/templates/skills/quality-assurance/style-detector/EXAMPLES.md +0 -206
- package/templates/skills/quality-assurance/style-detector/KEYWORDS.md +0 -207
- package/templates/skills/quality-assurance/style-detector/SKILL.md +0 -264
- package/templates/skills/quality-assurance/voice-consistency-checker/SKILL.md +0 -103
- package/templates/skills/quality-assurance/voice-consistency-checker/experts/voice-analyst.md +0 -21
- package/templates/skills/quality-assurance/workflow-guide/SKILL.md +0 -381
- package/templates/skills/writing-techniques/character-arc/SKILL.md +0 -267
- package/templates/skills/writing-techniques/dialogue-techniques/SKILL.md +0 -366
- package/templates/skills/writing-techniques/multi-thread-narrative/SKILL.md +0 -708
- package/templates/skills/writing-techniques/multi-thread-narrative/experts/thread-analyst.md +0 -226
- package/templates/skills/writing-techniques/pacing-control/SKILL.md +0 -480
- package/templates/skills/writing-techniques/reader-expectation/SKILL.md +0 -1026
- package/templates/skills/writing-techniques/reader-expectation/experts/expectation-analyst.md +0 -209
- package/templates/skills/writing-techniques/revision-polish/SKILL.md +0 -496
- package/templates/skills/writing-techniques/revision-polish/experts/revision-editor.md +0 -221
- package/templates/skills/writing-techniques/scene-structure/SKILL.md +0 -361
- package/templates/skills/writing-techniques/style-learning/SKILL.md +0 -436
- package/templates/skills/writing-techniques/writing-balance/.gitkeep +0 -0
- package/templates/skills/writing-techniques/writing-balance/SKILL.md +0 -460
- package/templates/skills/writing-techniques/writing-techniques/SKILL.md +0 -727
- package/templates/tracking/story-facts.json +0 -5
- package/templates/tracking/summary/characters-summary.json +0 -7
- package/templates/tracking/summary/plot-summary.json +0 -13
- package/templates/tracking/summary/timeline-summary.json +0 -8
- package/templates/tracking/summary/volume-summaries.json +0 -5
- package/templates/tracking/tracking-log.md +0 -110
- package/templates/tracking/validation-rules.json +0 -128
- /package/templates/resources/{memory/constitution.md → constitution.md} +0 -0
|
@@ -1,486 +0,0 @@
|
|
|
1
|
-
# 检查写作状态脚本
|
|
2
|
-
# 用于 /write 命令
|
|
3
|
-
|
|
4
|
-
param(
|
|
5
|
-
[switch]$Json
|
|
6
|
-
)
|
|
7
|
-
|
|
8
|
-
# ============================================
|
|
9
|
-
# Phase 1: 文件时间戳缓存
|
|
10
|
-
# ============================================
|
|
11
|
-
#
|
|
12
|
-
# 缓存值约定:
|
|
13
|
-
# - LastWriteTime 对象: 文件存在,值为修改时间
|
|
14
|
-
# - $null: 文件不存在(预加载时已确认)
|
|
15
|
-
# - 未缓存: 键不存在于 HashTable 中
|
|
16
|
-
|
|
17
|
-
# 缓存存储(HashTable)
|
|
18
|
-
$script:FileMTimeCache = @{}
|
|
19
|
-
$script:PreloadCompleted = $false
|
|
20
|
-
|
|
21
|
-
# ============================================
|
|
22
|
-
# Phase 2: 资源去重机制
|
|
23
|
-
# ============================================
|
|
24
|
-
#
|
|
25
|
-
# 用于避免在单次脚本执行中重复检查同一资源文件
|
|
26
|
-
|
|
27
|
-
# Phase 2: 资源去重 HashTable
|
|
28
|
-
$script:loadedResourcesSet = @{}
|
|
29
|
-
|
|
30
|
-
# Phase 2: 检查资源是否已加载
|
|
31
|
-
# 参数: Path (string) - 资源路径
|
|
32
|
-
# 返回: $true(已加载),$false(未加载)
|
|
33
|
-
function Is-ResourceLoaded {
|
|
34
|
-
param([string]$path)
|
|
35
|
-
return $script:loadedResourcesSet.ContainsKey($path)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
# Phase 2: 标记资源为已加载
|
|
39
|
-
# 参数: Path (string) - 资源路径
|
|
40
|
-
function Mark-ResourceLoaded {
|
|
41
|
-
param([string]$path)
|
|
42
|
-
$script:loadedResourcesSet[$path] = $true
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
# ============================================
|
|
46
|
-
# Phase 3: 缓存文件清理机制
|
|
47
|
-
# ============================================
|
|
48
|
-
#
|
|
49
|
-
# 清理超过 24 小时的旧缓存文件,避免磁盘空间浪费
|
|
50
|
-
# 防御性设计:缓存目录不存在时直接返回
|
|
51
|
-
|
|
52
|
-
function Cleanup-OldCache {
|
|
53
|
-
$cacheDir = Join-Path $ProjectRoot ".claude" ".cache"
|
|
54
|
-
|
|
55
|
-
# 缓存目录不存在,无需清理
|
|
56
|
-
if (-not (Test-Path $cacheDir)) {
|
|
57
|
-
return
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
# 删除超过 24 小时的缓存文件
|
|
61
|
-
$cutoffTime = (Get-Date).AddDays(-1)
|
|
62
|
-
Get-ChildItem -Path $cacheDir -Filter "*.json" -File -ErrorAction SilentlyContinue |
|
|
63
|
-
Where-Object { $_.LastWriteTime -lt $cutoffTime } |
|
|
64
|
-
Remove-Item -Force -ErrorAction SilentlyContinue
|
|
65
|
-
|
|
66
|
-
# 删除空目录
|
|
67
|
-
Get-ChildItem -Path $cacheDir -Directory -ErrorAction SilentlyContinue |
|
|
68
|
-
Where-Object { (Get-ChildItem $_.FullName -ErrorAction SilentlyContinue).Count -eq 0 } |
|
|
69
|
-
Remove-Item -Force -ErrorAction SilentlyContinue
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
# 预加载文件修改时间到缓存
|
|
73
|
-
# 参数: FilePathList (string[]) - 文件路径列表
|
|
74
|
-
# 说明: 预加载策略避免多次磁盘访问
|
|
75
|
-
function Preload-FileMTimes {
|
|
76
|
-
param(
|
|
77
|
-
[Parameter(Mandatory=$true)]
|
|
78
|
-
[string[]]$FilePathList
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
foreach ($filePath in $FilePathList) {
|
|
82
|
-
# 文件不存在:记录为 $null
|
|
83
|
-
if (-not (Test-Path $filePath -PathType Leaf)) {
|
|
84
|
-
$script:FileMTimeCache[$filePath] = $null
|
|
85
|
-
continue
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
# 读取文件时间戳
|
|
89
|
-
try {
|
|
90
|
-
$fileInfo = Get-Item $filePath -ErrorAction Stop
|
|
91
|
-
$script:FileMTimeCache[$filePath] = $fileInfo.LastWriteTime
|
|
92
|
-
} catch {
|
|
93
|
-
# Get-Item 失败:记录为空 DateTime
|
|
94
|
-
$script:FileMTimeCache[$filePath] = [DateTime]::MinValue
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
# 获取文件修改时间(从缓存)
|
|
100
|
-
# 参数: FilePath (string) - 文件路径
|
|
101
|
-
# 返回: DateTime 对象,或 $null(文件不存在),或 MinValue(读取失败)
|
|
102
|
-
function Get-FileMTimeFromCache {
|
|
103
|
-
param(
|
|
104
|
-
[Parameter(Mandatory=$true)]
|
|
105
|
-
[string]$FilePath
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
if ($script:FileMTimeCache.ContainsKey($FilePath)) {
|
|
109
|
-
return $script:FileMTimeCache[$FilePath]
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
# 未缓存:返回 MinValue
|
|
113
|
-
return [DateTime]::MinValue
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
# 检查文件是否存在(基于缓存)
|
|
117
|
-
# 参数: FilePath (string) - 文件路径
|
|
118
|
-
# 返回: $true(文件存在),$false(文件不存在或未缓存)
|
|
119
|
-
function Test-FileExistsCached {
|
|
120
|
-
param(
|
|
121
|
-
[Parameter(Mandatory=$true)]
|
|
122
|
-
[string]$FilePath
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
$mtime = Get-FileMTimeFromCache $FilePath
|
|
126
|
-
|
|
127
|
-
# $null: 文件不存在
|
|
128
|
-
# MinValue: Get-Item 失败或未缓存
|
|
129
|
-
# 其他 DateTime: 文件存在
|
|
130
|
-
return ($null -ne $mtime -and $mtime -ne [DateTime]::MinValue)
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
# 导入通用函数
|
|
134
|
-
. "$PSScriptRoot\common.ps1"
|
|
135
|
-
|
|
136
|
-
# 获取项目根目录
|
|
137
|
-
$ProjectRoot = Get-ProjectRoot
|
|
138
|
-
Set-Location $ProjectRoot
|
|
139
|
-
|
|
140
|
-
# 获取当前故事
|
|
141
|
-
$StoryName = Get-ActiveStory
|
|
142
|
-
$StoryDir = Join-Path "stories" $StoryName
|
|
143
|
-
|
|
144
|
-
# 预加载文件时间戳(性能优化)
|
|
145
|
-
if (-not $script:PreloadCompleted) {
|
|
146
|
-
$preloadFileList = @(
|
|
147
|
-
# 知识库文件
|
|
148
|
-
(Join-Path $ProjectRoot "resources/craft/dialogue.md")
|
|
149
|
-
(Join-Path $ProjectRoot "resources/craft/scene-structure.md")
|
|
150
|
-
(Join-Path $ProjectRoot "resources/craft/character-arc.md")
|
|
151
|
-
(Join-Path $ProjectRoot "resources/craft/pacing.md")
|
|
152
|
-
(Join-Path $ProjectRoot "resources/craft/show-not-tell.md")
|
|
153
|
-
# Skill 文件
|
|
154
|
-
(Join-Path $ProjectRoot ".claude/skills/writing-techniques/dialogue-techniques/SKILL.md")
|
|
155
|
-
(Join-Path $ProjectRoot ".claude/skills/writing-techniques/scene-structure/SKILL.md")
|
|
156
|
-
(Join-Path $ProjectRoot ".claude/skills/writing-techniques/character-arc/SKILL.md")
|
|
157
|
-
(Join-Path $ProjectRoot ".claude/skills/writing-techniques/pacing-control/SKILL.md")
|
|
158
|
-
(Join-Path $ProjectRoot ".claude/skills/quality-assurance/consistency-checker/SKILL.md")
|
|
159
|
-
# 规格文件
|
|
160
|
-
(Join-Path $StoryDir "specification.md")
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
Preload-FileMTimes -FilePathList $preloadFileList
|
|
164
|
-
$script:PreloadCompleted = $true
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
# Phase 3: 清理旧缓存(轻量级,不影响性能)
|
|
168
|
-
Cleanup-OldCache
|
|
169
|
-
|
|
170
|
-
# ==================== 资源加载报告生成函数 ====================
|
|
171
|
-
|
|
172
|
-
function Generate-LoadReport {
|
|
173
|
-
param (
|
|
174
|
-
[string]$StoryDir
|
|
175
|
-
)
|
|
176
|
-
|
|
177
|
-
# Phase 3: 性能监控
|
|
178
|
-
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
|
|
179
|
-
|
|
180
|
-
$specFile = Join-Path $StoryDir "specification.md"
|
|
181
|
-
$warnings = @()
|
|
182
|
-
|
|
183
|
-
# 默认加载所有资源
|
|
184
|
-
$knowledgeBaseFiles = @(
|
|
185
|
-
"resources/craft/dialogue.md",
|
|
186
|
-
"resources/craft/scene-structure.md",
|
|
187
|
-
"resources/craft/character-arc.md",
|
|
188
|
-
"resources/craft/pacing.md",
|
|
189
|
-
"resources/craft/show-not-tell.md"
|
|
190
|
-
)
|
|
191
|
-
|
|
192
|
-
$skillsFiles = @(
|
|
193
|
-
".claude/skills/writing-techniques/dialogue-techniques",
|
|
194
|
-
".claude/skills/writing-techniques/scene-structure",
|
|
195
|
-
".claude/skills/writing-techniques/character-arc",
|
|
196
|
-
".claude/skills/writing-techniques/pacing-control",
|
|
197
|
-
".claude/skills/quality-assurance/consistency-checker"
|
|
198
|
-
)
|
|
199
|
-
|
|
200
|
-
$disabledResources = @()
|
|
201
|
-
$hasConfig = $false
|
|
202
|
-
|
|
203
|
-
if (Test-Path $specFile) {
|
|
204
|
-
$content = Get-Content $specFile -Raw
|
|
205
|
-
if ($content -match "resource-loading:") {
|
|
206
|
-
$hasConfig = $true
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
# 检查文件存在性(使用缓存 + Phase 2: 资源去重)
|
|
211
|
-
foreach ($kb in $knowledgeBaseFiles) {
|
|
212
|
-
# Phase 2: 资源去重检查
|
|
213
|
-
if (Is-ResourceLoaded $kb) {
|
|
214
|
-
continue
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
# 标记为已加载
|
|
218
|
-
Mark-ResourceLoaded $kb
|
|
219
|
-
|
|
220
|
-
# 检查文件是否存在(使用完整路径)
|
|
221
|
-
$fullPath = Join-Path $ProjectRoot $kb
|
|
222
|
-
if (-not (Test-FileExistsCached $fullPath)) {
|
|
223
|
-
$warnings += "知识库文件不存在: $kb"
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
foreach ($skill in $skillsFiles) {
|
|
228
|
-
$skillPath = "$skill/SKILL.md"
|
|
229
|
-
|
|
230
|
-
# Phase 2: 资源去重检查
|
|
231
|
-
if (Is-ResourceLoaded $skillPath) {
|
|
232
|
-
continue
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
# 标记为已加载
|
|
236
|
-
Mark-ResourceLoaded $skillPath
|
|
237
|
-
|
|
238
|
-
# 检查文件是否存在(使用完整路径)
|
|
239
|
-
$fullPath = Join-Path $ProjectRoot $skillPath
|
|
240
|
-
if (-not (Test-FileExistsCached $fullPath)) {
|
|
241
|
-
$warnings += "Skill 文件不存在: $skillPath"
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
# Phase 2: 检测缓存命中(基于 specification.md 是否已被缓存加载且有效)
|
|
246
|
-
# 仅当文件在缓存中且成功读取时,才视为"缓存命中"
|
|
247
|
-
# 缓存语义: $null = 文件不存在, MinValue = stat 失败, DateTime = 成功读取
|
|
248
|
-
$cached = $script:FileMTimeCache.ContainsKey($specFile) -and
|
|
249
|
-
$script:FileMTimeCache[$specFile] -ne $null -and
|
|
250
|
-
$script:FileMTimeCache[$specFile] -ne [DateTime]::MinValue
|
|
251
|
-
$cacheHint = "此报告基于缓存生成(specification.md 未修改)。AI 可复用本次会话中已加载的资源。"
|
|
252
|
-
|
|
253
|
-
# 生成 JSON
|
|
254
|
-
$report = @{
|
|
255
|
-
status = "ready"
|
|
256
|
-
timestamp = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
|
|
257
|
-
has_config = $hasConfig
|
|
258
|
-
cached = $cached
|
|
259
|
-
session_cache_enabled = $true
|
|
260
|
-
resources = @{
|
|
261
|
-
"knowledge-base" = $knowledgeBaseFiles
|
|
262
|
-
skills = $skillsFiles
|
|
263
|
-
disabled = $disabledResources
|
|
264
|
-
}
|
|
265
|
-
warnings = $warnings
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
# 仅在缓存命中时添加 cache_hint
|
|
269
|
-
if ($cached) {
|
|
270
|
-
$report.cache_hint = $cacheHint
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
# Phase 3: 性能指标
|
|
274
|
-
$stopwatch.Stop()
|
|
275
|
-
$report.performance = @{
|
|
276
|
-
generation_time_ms = $stopwatch.ElapsedMilliseconds
|
|
277
|
-
cache_hit = $cached
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
return $report | ConvertTo-Json -Depth 10
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
# JSON 模式
|
|
284
|
-
if ($Json) {
|
|
285
|
-
try {
|
|
286
|
-
$report = Generate-LoadReport -StoryDir $StoryDir
|
|
287
|
-
Write-Output $report
|
|
288
|
-
exit 0
|
|
289
|
-
} catch {
|
|
290
|
-
Write-Error "生成资源加载报告失败: $_"
|
|
291
|
-
exit 1
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
Write-Host "写作状态检查"
|
|
296
|
-
Write-Host "============"
|
|
297
|
-
Write-Host "当前故事:$StoryName"
|
|
298
|
-
Write-Host ""
|
|
299
|
-
|
|
300
|
-
# 检查方法论文档
|
|
301
|
-
function Test-MethodologyDocs {
|
|
302
|
-
$missing = @()
|
|
303
|
-
|
|
304
|
-
if (-not (Test-Path "resources\memory\constitution.md")) {
|
|
305
|
-
$missing += "宪法"
|
|
306
|
-
}
|
|
307
|
-
if (-not (Test-Path "$StoryDir\specification.md")) {
|
|
308
|
-
$missing += "规格"
|
|
309
|
-
}
|
|
310
|
-
if (-not (Test-Path "$StoryDir\creative-plan.md")) {
|
|
311
|
-
$missing += "计划"
|
|
312
|
-
}
|
|
313
|
-
if (-not (Test-Path "$StoryDir\tasks.md")) {
|
|
314
|
-
$missing += "任务"
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
if ($missing.Count -gt 0) {
|
|
318
|
-
Write-Host "⚠️ 缺少以下基准文档:" -ForegroundColor Yellow
|
|
319
|
-
foreach ($doc in $missing) {
|
|
320
|
-
Write-Host " - $doc"
|
|
321
|
-
}
|
|
322
|
-
Write-Host ""
|
|
323
|
-
Write-Host "建议按照七步方法论完成前置步骤:"
|
|
324
|
-
Write-Host "1. /constitution - 创建创作宪法"
|
|
325
|
-
Write-Host "2. /specify - 定义故事规格"
|
|
326
|
-
Write-Host "3. /clarify - 澄清关键决策"
|
|
327
|
-
Write-Host "4. /plan - 制定创作计划"
|
|
328
|
-
Write-Host "5. /tasks - 生成任务清单"
|
|
329
|
-
return $false
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
Write-Host "✅ 方法论文档完整" -ForegroundColor Green
|
|
333
|
-
return $true
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
# 检查待写作任务
|
|
337
|
-
function Test-PendingTasks {
|
|
338
|
-
$tasksFile = "$StoryDir\tasks.md"
|
|
339
|
-
|
|
340
|
-
if (-not (Test-Path $tasksFile)) {
|
|
341
|
-
Write-Host "❌ 任务文件不存在" -ForegroundColor Red
|
|
342
|
-
return $false
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
# 统计任务状态
|
|
346
|
-
$content = Get-Content $tasksFile -Raw
|
|
347
|
-
$pending = ([regex]::Matches($content, '^- \[ \]', [System.Text.RegularExpressions.RegexOptions]::Multiline)).Count
|
|
348
|
-
$inProgress = ([regex]::Matches($content, '^- \[~\]', [System.Text.RegularExpressions.RegexOptions]::Multiline)).Count
|
|
349
|
-
$completed = ([regex]::Matches($content, '^- \[x\]', [System.Text.RegularExpressions.RegexOptions]::Multiline)).Count
|
|
350
|
-
|
|
351
|
-
Write-Host ""
|
|
352
|
-
Write-Host "任务状态:"
|
|
353
|
-
Write-Host " 待开始:$pending"
|
|
354
|
-
Write-Host " 进行中:$inProgress"
|
|
355
|
-
Write-Host " 已完成:$completed"
|
|
356
|
-
|
|
357
|
-
if ($pending -eq 0 -and $inProgress -eq 0) {
|
|
358
|
-
Write-Host ""
|
|
359
|
-
Write-Host "🎉 所有任务已完成!" -ForegroundColor Green
|
|
360
|
-
Write-Host "建议运行 /analyze 进行综合验证"
|
|
361
|
-
return $true
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
# 显示下一个待写作任务
|
|
365
|
-
Write-Host ""
|
|
366
|
-
Write-Host "下一个写作任务:"
|
|
367
|
-
$lines = $content -split "`n"
|
|
368
|
-
foreach ($line in $lines) {
|
|
369
|
-
if ($line -match '^- \[ \]') {
|
|
370
|
-
Write-Host $line
|
|
371
|
-
break
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
return $true
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
# 检查已完成内容
|
|
379
|
-
function Test-CompletedContent {
|
|
380
|
-
$contentDir = "$StoryDir\content"
|
|
381
|
-
|
|
382
|
-
if (Test-Path $contentDir) {
|
|
383
|
-
$mdFiles = Get-ChildItem "$contentDir\*.md" -ErrorAction SilentlyContinue
|
|
384
|
-
$chapterCount = $mdFiles.Count
|
|
385
|
-
|
|
386
|
-
if ($chapterCount -gt 0) {
|
|
387
|
-
Write-Host ""
|
|
388
|
-
Write-Host "已完成章节:$chapterCount"
|
|
389
|
-
Write-Host "最近写作:"
|
|
390
|
-
|
|
391
|
-
$recentFiles = $mdFiles |
|
|
392
|
-
Sort-Object LastWriteTime -Descending |
|
|
393
|
-
Select-Object -First 3
|
|
394
|
-
|
|
395
|
-
foreach ($file in $recentFiles) {
|
|
396
|
-
Write-Host " - $($file.Name)"
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
else {
|
|
401
|
-
Write-Host ""
|
|
402
|
-
Write-Host "尚未开始写作"
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
# ==================== 新增:资源加载检查函数 ====================
|
|
407
|
-
|
|
408
|
-
function Check-KnowledgeBaseAvailable {
|
|
409
|
-
$missing = @()
|
|
410
|
-
$available = @()
|
|
411
|
-
|
|
412
|
-
$craftFiles = @(
|
|
413
|
-
"resources/craft/dialogue.md",
|
|
414
|
-
"resources/craft/scene-structure.md",
|
|
415
|
-
"resources/craft/character-arc.md",
|
|
416
|
-
"resources/craft/pacing.md",
|
|
417
|
-
"resources/craft/show-not-tell.md"
|
|
418
|
-
)
|
|
419
|
-
|
|
420
|
-
foreach ($file in $craftFiles) {
|
|
421
|
-
$fullPath = Join-Path $ProjectRoot $file
|
|
422
|
-
|
|
423
|
-
# 使用缓存检查文件是否存在
|
|
424
|
-
if (Test-FileExistsCached $fullPath) {
|
|
425
|
-
$available += $file
|
|
426
|
-
} else {
|
|
427
|
-
$missing += $file
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
if ($missing.Count -gt 0) {
|
|
432
|
-
Write-Host "⚠️ 缺少以下 knowledge-base 文件:"
|
|
433
|
-
foreach ($file in $missing) {
|
|
434
|
-
Write-Host " - $file"
|
|
435
|
-
}
|
|
436
|
-
return $false
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
Write-Host "✅ Knowledge-base 文件完整 ($($available.Count) 个)"
|
|
440
|
-
return $true
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
function Check-SkillsAvailable {
|
|
444
|
-
$missing = @()
|
|
445
|
-
$available = @()
|
|
446
|
-
|
|
447
|
-
$skillDirs = @(
|
|
448
|
-
".claude/skills/writing-techniques/dialogue-techniques",
|
|
449
|
-
".claude/skills/writing-techniques/scene-structure",
|
|
450
|
-
".claude/skills/writing-techniques/character-arc",
|
|
451
|
-
".claude/skills/writing-techniques/pacing-control"
|
|
452
|
-
)
|
|
453
|
-
|
|
454
|
-
foreach ($dir in $skillDirs) {
|
|
455
|
-
$skillPath = Join-Path $ProjectRoot "$dir/SKILL.md"
|
|
456
|
-
|
|
457
|
-
# 使用缓存检查文件是否存在
|
|
458
|
-
if (Test-FileExistsCached $skillPath) {
|
|
459
|
-
$available += $dir
|
|
460
|
-
} else {
|
|
461
|
-
$missing += $dir
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
if ($missing.Count -gt 0) {
|
|
466
|
-
Write-Host "⚠️ 缺少以下 skills:"
|
|
467
|
-
foreach ($dir in $missing) {
|
|
468
|
-
Write-Host " - $dir/SKILL.md"
|
|
469
|
-
}
|
|
470
|
-
return $false
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
Write-Host "✅ Skills 完整 ($($available.Count) 个)"
|
|
474
|
-
return $true
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
# 主流程
|
|
478
|
-
if (-not (Test-MethodologyDocs)) {
|
|
479
|
-
exit 1
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
Test-PendingTasks | Out-Null
|
|
483
|
-
Test-CompletedContent
|
|
484
|
-
|
|
485
|
-
Write-Host ""
|
|
486
|
-
Write-Host "准备就绪,可以开始写作"
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
param(
|
|
2
|
-
[switch]$Json,
|
|
3
|
-
[switch]$PathsOnly
|
|
4
|
-
)
|
|
5
|
-
|
|
6
|
-
# 澄清故事大纲的支撑脚本
|
|
7
|
-
# 用于 /clarify 命令,扫描并返回当前故事路径
|
|
8
|
-
|
|
9
|
-
Set-StrictMode -Version Latest
|
|
10
|
-
$ErrorActionPreference = "Stop"
|
|
11
|
-
|
|
12
|
-
# Get script directory
|
|
13
|
-
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
14
|
-
|
|
15
|
-
# Source common functions
|
|
16
|
-
. "$ScriptDir\common.ps1"
|
|
17
|
-
|
|
18
|
-
# Get project root
|
|
19
|
-
$ProjectRoot = Get-ProjectRoot
|
|
20
|
-
Set-Location $ProjectRoot
|
|
21
|
-
|
|
22
|
-
# Find the current story directory
|
|
23
|
-
$StoriesDir = "stories"
|
|
24
|
-
if (-not (Test-Path $StoriesDir -PathType Container)) {
|
|
25
|
-
if ($Json) {
|
|
26
|
-
Write-Output '{"error": "No stories directory found"}'
|
|
27
|
-
} else {
|
|
28
|
-
Write-Error "错误:未找到 stories 目录,请先运行 /specify 创建故事规格"
|
|
29
|
-
}
|
|
30
|
-
exit 1
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
# Get the latest story
|
|
34
|
-
$StoryDirs = Get-ChildItem -Path $StoriesDir -Directory | Sort-Object Name -Descending
|
|
35
|
-
if ($StoryDirs.Count -eq 0) {
|
|
36
|
-
if ($Json) {
|
|
37
|
-
Write-Output '{"error": "No story found"}'
|
|
38
|
-
} else {
|
|
39
|
-
Write-Error "错误:未找到故事,请先运行 /specify 创建故事规格"
|
|
40
|
-
}
|
|
41
|
-
exit 1
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
$StoryDir = $StoryDirs[0]
|
|
45
|
-
$StoryName = $StoryDir.Name
|
|
46
|
-
|
|
47
|
-
# Find story file (新格式 specification.md)
|
|
48
|
-
$StoryFile = Join-Path $StoryDir.FullName "specification.md"
|
|
49
|
-
|
|
50
|
-
if (-not (Test-Path $StoryFile -PathType Leaf)) {
|
|
51
|
-
if ($Json) {
|
|
52
|
-
Write-Output '{"error": "Story file not found (specification.md required)"}'
|
|
53
|
-
} else {
|
|
54
|
-
Write-Error "错误:未找到故事文件 specification.md"
|
|
55
|
-
}
|
|
56
|
-
exit 1
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
# Check if clarification already exists
|
|
60
|
-
$ClarificationExists = $false
|
|
61
|
-
$StoryContent = Get-Content $StoryFile -Raw
|
|
62
|
-
if ($StoryContent -match "## 澄清记录") {
|
|
63
|
-
$ClarificationExists = $true
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
# Count existing clarification sessions
|
|
67
|
-
$ClarificationCount = 0
|
|
68
|
-
if ($ClarificationExists) {
|
|
69
|
-
$matches = [regex]::Matches($StoryContent, "### 澄清会话")
|
|
70
|
-
$ClarificationCount = $matches.Count
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
# Convert paths to forward slashes for JSON
|
|
74
|
-
$StoryFilePath = $StoryFile.Replace('\', '/')
|
|
75
|
-
$StoryDirPath = $StoryDir.FullName.Replace('\', '/')
|
|
76
|
-
$ProjectRootPath = $ProjectRoot.Replace('\', '/')
|
|
77
|
-
|
|
78
|
-
# Output in JSON format if requested
|
|
79
|
-
if ($Json) {
|
|
80
|
-
if ($PathsOnly) {
|
|
81
|
-
# Minimal output for command template
|
|
82
|
-
$output = @{
|
|
83
|
-
STORY_PATH = $StoryFilePath
|
|
84
|
-
STORY_NAME = $StoryName
|
|
85
|
-
STORY_DIR = $StoryDirPath
|
|
86
|
-
}
|
|
87
|
-
} else {
|
|
88
|
-
# Full output for analysis
|
|
89
|
-
$output = @{
|
|
90
|
-
STORY_PATH = $StoryFilePath
|
|
91
|
-
STORY_NAME = $StoryName
|
|
92
|
-
STORY_DIR = $StoryDirPath
|
|
93
|
-
CLARIFICATION_EXISTS = $ClarificationExists
|
|
94
|
-
CLARIFICATION_COUNT = $ClarificationCount
|
|
95
|
-
PROJECT_ROOT = $ProjectRootPath
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
Write-Output (ConvertTo-Json $output -Compress)
|
|
99
|
-
} else {
|
|
100
|
-
Write-Output "找到故事:$StoryName"
|
|
101
|
-
Write-Output "文件路径:$StoryFile"
|
|
102
|
-
if ($ClarificationExists) {
|
|
103
|
-
Write-Output "已有澄清会话:$ClarificationCount 次"
|
|
104
|
-
} else {
|
|
105
|
-
Write-Output "尚未进行过澄清"
|
|
106
|
-
}
|
|
107
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env pwsh
|
|
2
|
-
# 公用函数(PowerShell)
|
|
3
|
-
|
|
4
|
-
Set-StrictMode -Version Latest
|
|
5
|
-
$ErrorActionPreference = 'Stop'
|
|
6
|
-
|
|
7
|
-
function Get-ProjectRoot {
|
|
8
|
-
$current = (Get-Location).Path
|
|
9
|
-
while ($true) {
|
|
10
|
-
$cfg = Join-Path $current "resources/config/config.json"
|
|
11
|
-
if (Test-Path $cfg) { return $current }
|
|
12
|
-
$parent = Split-Path $current -Parent
|
|
13
|
-
if (-not $parent -or $parent -eq $current) { break }
|
|
14
|
-
$current = $parent
|
|
15
|
-
}
|
|
16
|
-
throw "未找到项目根目录(缺少 resources/config/config.json)"
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function Get-CurrentStoryDir {
|
|
20
|
-
$root = Get-ProjectRoot
|
|
21
|
-
$stories = Join-Path $root "stories"
|
|
22
|
-
if (-not (Test-Path $stories)) { return $null }
|
|
23
|
-
$dirs = Get-ChildItem -Path $stories -Directory | Sort-Object LastWriteTime -Descending
|
|
24
|
-
if ($dirs.Count -gt 0) { return $dirs[0].FullName }
|
|
25
|
-
return $null
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function Get-ActiveStory {
|
|
29
|
-
$storyDir = Get-CurrentStoryDir
|
|
30
|
-
if ($storyDir) {
|
|
31
|
-
return Split-Path $storyDir -Leaf
|
|
32
|
-
}
|
|
33
|
-
# 如果没有故事,返回默认名称
|
|
34
|
-
return "story-$(Get-Date -Format 'yyyyMMdd')"
|
|
35
|
-
}
|
|
36
|
-
|