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,123 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# 测试预加载缓存功能
|
|
4
|
-
|
|
5
|
-
echo "=== 测试预加载缓存 ==="
|
|
6
|
-
echo ""
|
|
7
|
-
|
|
8
|
-
# Bash 版本检测
|
|
9
|
-
BASH_MAJOR_VERSION="${BASH_VERSION%%.*}"
|
|
10
|
-
echo "Bash 主版本: $BASH_MAJOR_VERSION"
|
|
11
|
-
|
|
12
|
-
# 缓存存储
|
|
13
|
-
if [[ "$BASH_MAJOR_VERSION" -ge 4 ]]; then
|
|
14
|
-
declare -A FILE_MTIME_CACHE
|
|
15
|
-
echo "使用关联数组"
|
|
16
|
-
else
|
|
17
|
-
FILE_MTIME_CACHE_KEYS=()
|
|
18
|
-
FILE_MTIME_CACHE_VALUES=()
|
|
19
|
-
echo "使用线性数组"
|
|
20
|
-
fi
|
|
21
|
-
|
|
22
|
-
# 预加载函数
|
|
23
|
-
preload_file_mtimes() {
|
|
24
|
-
local file_path
|
|
25
|
-
local mtime
|
|
26
|
-
|
|
27
|
-
for file_path in "$@"; do
|
|
28
|
-
[ ! -f "$file_path" ] && continue
|
|
29
|
-
|
|
30
|
-
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
31
|
-
mtime=$(stat -f "%m" "$file_path" 2>/dev/null || echo "0")
|
|
32
|
-
else
|
|
33
|
-
mtime=$(stat -c "%Y" "$file_path" 2>/dev/null || echo "0")
|
|
34
|
-
fi
|
|
35
|
-
|
|
36
|
-
if [[ "$BASH_MAJOR_VERSION" -ge 4 ]]; then
|
|
37
|
-
FILE_MTIME_CACHE[$file_path]="$mtime"
|
|
38
|
-
else
|
|
39
|
-
FILE_MTIME_CACHE_KEYS+=("$file_path")
|
|
40
|
-
FILE_MTIME_CACHE_VALUES+=("$mtime")
|
|
41
|
-
fi
|
|
42
|
-
done
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
# 获取缓存的 mtime
|
|
46
|
-
get_file_mtime() {
|
|
47
|
-
local file_path="$1"
|
|
48
|
-
|
|
49
|
-
if [[ "$BASH_MAJOR_VERSION" -ge 4 ]]; then
|
|
50
|
-
echo "${FILE_MTIME_CACHE[$file_path]:-0}"
|
|
51
|
-
else
|
|
52
|
-
for i in "${!FILE_MTIME_CACHE_KEYS[@]}"; do
|
|
53
|
-
if [[ "${FILE_MTIME_CACHE_KEYS[$i]}" == "$file_path" ]]; then
|
|
54
|
-
echo "${FILE_MTIME_CACHE_VALUES[$i]}"
|
|
55
|
-
return 0
|
|
56
|
-
fi
|
|
57
|
-
done
|
|
58
|
-
echo "0"
|
|
59
|
-
fi
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
# 检查是否已缓存
|
|
63
|
-
is_file_cached() {
|
|
64
|
-
local file_path="$1"
|
|
65
|
-
|
|
66
|
-
if [[ "$BASH_MAJOR_VERSION" -ge 4 ]]; then
|
|
67
|
-
[[ ${FILE_MTIME_CACHE[$file_path]+isset} ]]
|
|
68
|
-
else
|
|
69
|
-
for key in "${FILE_MTIME_CACHE_KEYS[@]}"; do
|
|
70
|
-
[[ "$key" == "$file_path" ]] && return 0
|
|
71
|
-
done
|
|
72
|
-
return 1
|
|
73
|
-
fi
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
echo ""
|
|
77
|
-
echo "=== 测试 1: 预加载文件 ==="
|
|
78
|
-
files=(
|
|
79
|
-
"resources/config/keyword-mappings.json"
|
|
80
|
-
"templates/scripts/bash/check-writing-state.sh"
|
|
81
|
-
"templates/scripts/bash/common.sh"
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
echo "预加载 ${#files[@]} 个文件..."
|
|
85
|
-
preload_file_mtimes "${files[@]}"
|
|
86
|
-
|
|
87
|
-
echo "缓存大小: ${#FILE_MTIME_CACHE[@]}"
|
|
88
|
-
|
|
89
|
-
echo ""
|
|
90
|
-
echo "=== 测试 2: 检查缓存状态 ==="
|
|
91
|
-
for file in "${files[@]}"; do
|
|
92
|
-
if is_file_cached "$file"; then
|
|
93
|
-
mtime=$(get_file_mtime "$file")
|
|
94
|
-
echo "✅ $file (mtime: $mtime)"
|
|
95
|
-
else
|
|
96
|
-
echo "❌ $file 未缓存"
|
|
97
|
-
fi
|
|
98
|
-
done
|
|
99
|
-
|
|
100
|
-
echo ""
|
|
101
|
-
echo "=== 测试 3: 获取 mtime (不使用命令替换) ==="
|
|
102
|
-
for file in "${files[@]}"; do
|
|
103
|
-
get_file_mtime "$file"
|
|
104
|
-
done
|
|
105
|
-
|
|
106
|
-
echo ""
|
|
107
|
-
echo "=== 测试 4: 测试不存在的文件 ==="
|
|
108
|
-
nonexistent="/nonexistent/file.txt"
|
|
109
|
-
if is_file_cached "$nonexistent"; then
|
|
110
|
-
echo "❌ 不存在的文件被标记为已缓存"
|
|
111
|
-
else
|
|
112
|
-
echo "✅ 不存在的文件未被缓存"
|
|
113
|
-
fi
|
|
114
|
-
|
|
115
|
-
mtime=$(get_file_mtime "$nonexistent")
|
|
116
|
-
if [[ "$mtime" == "0" ]]; then
|
|
117
|
-
echo "✅ 未缓存文件返回 0"
|
|
118
|
-
else
|
|
119
|
-
echo "❌ 未缓存文件返回: $mtime"
|
|
120
|
-
fi
|
|
121
|
-
|
|
122
|
-
echo ""
|
|
123
|
-
echo "=== 测试完成 ==="
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
set -euo pipefail
|
|
4
|
-
|
|
5
|
-
echo "=== Phase 1 预编译正则表达式测试 ==="
|
|
6
|
-
echo ""
|
|
7
|
-
|
|
8
|
-
# 测试 1.1: 验证 JSON 结构
|
|
9
|
-
echo "测试 1.1: 验证 JSON 结构"
|
|
10
|
-
version=$(jq -r '.version' resources/config/keyword-mappings.json)
|
|
11
|
-
if [[ "$version" == "1.1.0" ]]; then
|
|
12
|
-
echo "✅ 版本号正确: $version"
|
|
13
|
-
else
|
|
14
|
-
echo "❌ 版本号错误: $version (期望 1.1.0)"
|
|
15
|
-
exit 1
|
|
16
|
-
fi
|
|
17
|
-
|
|
18
|
-
# 测试 1.2: 验证正则字段
|
|
19
|
-
echo ""
|
|
20
|
-
echo "测试 1.2: 验证正则字段"
|
|
21
|
-
mappings=(
|
|
22
|
-
"craft-knowledge.dialogue"
|
|
23
|
-
"craft-knowledge.character-arc"
|
|
24
|
-
"craft-knowledge.pacing"
|
|
25
|
-
"craft-knowledge.show-not-tell"
|
|
26
|
-
"craft-knowledge.scene-structure"
|
|
27
|
-
"genre-knowledge.romance"
|
|
28
|
-
"genre-knowledge.mystery"
|
|
29
|
-
"quality-assurance.consistency"
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
all_passed=true
|
|
33
|
-
for mapping in "${mappings[@]}"; do
|
|
34
|
-
# 使用 jq 的嵌套路径语法
|
|
35
|
-
category=$(echo "$mapping" | cut -d. -f1)
|
|
36
|
-
name=$(echo "$mapping" | cut -d. -f2)
|
|
37
|
-
|
|
38
|
-
regex=$(jq -r ".mappings[\"$category\"][\"$name\"].regex" resources/config/keyword-mappings.json)
|
|
39
|
-
regex_flags=$(jq -r ".mappings[\"$category\"][\"$name\"].regex_flags" resources/config/keyword-mappings.json)
|
|
40
|
-
|
|
41
|
-
if [[ -n "$regex" && "$regex" != "null" ]]; then
|
|
42
|
-
echo "✅ $mapping: regex='$regex', flags='$regex_flags'"
|
|
43
|
-
else
|
|
44
|
-
echo "❌ $mapping: 缺少 regex 字段"
|
|
45
|
-
all_passed=false
|
|
46
|
-
fi
|
|
47
|
-
done
|
|
48
|
-
|
|
49
|
-
if [[ "$all_passed" != true ]]; then
|
|
50
|
-
exit 1
|
|
51
|
-
fi
|
|
52
|
-
|
|
53
|
-
# 测试 1.3: 测试正则匹配
|
|
54
|
-
echo ""
|
|
55
|
-
echo "测试 1.3: 测试正则匹配"
|
|
56
|
-
declare -A test_cases=(
|
|
57
|
-
["dialogue:对话"]="craft-knowledge.dialogue"
|
|
58
|
-
["dialogue:conversation"]="craft-knowledge.dialogue"
|
|
59
|
-
["dialogue:DIALOGUE"]="craft-knowledge.dialogue" # 大小写不敏感
|
|
60
|
-
["pacing:节奏"]="craft-knowledge.pacing"
|
|
61
|
-
["pacing:太快"]="craft-knowledge.pacing"
|
|
62
|
-
["character-arc:character arc"]="craft-knowledge.character-arc" # 支持空格
|
|
63
|
-
["consistency:一致性"]="quality-assurance.consistency"
|
|
64
|
-
["romance:爱情"]="genre-knowledge.romance"
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
for test_case in "${!test_cases[@]}"; do
|
|
68
|
-
keyword=$(echo "$test_case" | cut -d: -f2)
|
|
69
|
-
mapping=${test_cases[$test_case]}
|
|
70
|
-
|
|
71
|
-
category=$(echo "$mapping" | cut -d. -f1)
|
|
72
|
-
name=$(echo "$mapping" | cut -d. -f2)
|
|
73
|
-
|
|
74
|
-
regex=$(jq -r ".mappings[\"$category\"][\"$name\"].regex" resources/config/keyword-mappings.json)
|
|
75
|
-
|
|
76
|
-
if echo "$keyword" | grep -iE "$regex" > /dev/null; then
|
|
77
|
-
echo "✅ $mapping + '$keyword' → 匹配成功"
|
|
78
|
-
else
|
|
79
|
-
echo "❌ $mapping + '$keyword' → 匹配失败"
|
|
80
|
-
all_passed=false
|
|
81
|
-
fi
|
|
82
|
-
done
|
|
83
|
-
|
|
84
|
-
if [[ "$all_passed" != true ]]; then
|
|
85
|
-
exit 1
|
|
86
|
-
fi
|
|
87
|
-
|
|
88
|
-
echo ""
|
|
89
|
-
echo "✅ 所有预编译正则测试通过 (3/3)"
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
set -euo pipefail
|
|
4
|
-
|
|
5
|
-
echo "=== Phase 1 回归测试 (Bash) ==="
|
|
6
|
-
echo ""
|
|
7
|
-
|
|
8
|
-
echo "测试 7.1: 脚本正常运行"
|
|
9
|
-
if bash templates/scripts/bash/check-writing-state.sh --help > /dev/null 2>&1; then
|
|
10
|
-
echo "✅ 脚本帮助信息正常"
|
|
11
|
-
else
|
|
12
|
-
echo "⚠️ 脚本无 --help 选项(可能是正常的)"
|
|
13
|
-
fi
|
|
14
|
-
|
|
15
|
-
echo ""
|
|
16
|
-
echo "测试 7.2: JSON 输出格式"
|
|
17
|
-
output=$(bash templates/scripts/bash/check-writing-state.sh 2>/dev/null || echo "{}")
|
|
18
|
-
|
|
19
|
-
if echo "$output" | jq empty 2>/dev/null; then
|
|
20
|
-
echo "✅ JSON 格式正确"
|
|
21
|
-
else
|
|
22
|
-
echo "❌ JSON 格式错误"
|
|
23
|
-
echo "输出内容:"
|
|
24
|
-
echo "$output"
|
|
25
|
-
exit 1
|
|
26
|
-
fi
|
|
27
|
-
|
|
28
|
-
echo ""
|
|
29
|
-
echo "测试 7.3: 必需字段存在性"
|
|
30
|
-
required_fields=("status")
|
|
31
|
-
all_exist=true
|
|
32
|
-
|
|
33
|
-
for field in "${required_fields[@]}"; do
|
|
34
|
-
if echo "$output" | jq -e ".$field" > /dev/null 2>&1; then
|
|
35
|
-
echo "✅ 字段存在: $field"
|
|
36
|
-
else
|
|
37
|
-
echo "⚠️ 字段不存在: $field(可能是预期的)"
|
|
38
|
-
fi
|
|
39
|
-
done
|
|
40
|
-
|
|
41
|
-
echo ""
|
|
42
|
-
echo "✅ Bash 回归测试通过"
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
set -euo pipefail
|
|
3
|
-
|
|
4
|
-
# Task 6 最终验证测试
|
|
5
|
-
# 验证 Bash 和 PowerShell 的跨平台缓存检测一致性
|
|
6
|
-
|
|
7
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
8
|
-
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../../.." && pwd)"
|
|
9
|
-
|
|
10
|
-
echo "=== Task 6 最终验证测试 ==="
|
|
11
|
-
echo "项目根目录: $PROJECT_ROOT"
|
|
12
|
-
echo ""
|
|
13
|
-
|
|
14
|
-
# ============================================
|
|
15
|
-
# 测试 1: Bash 缓存检测逻辑验证
|
|
16
|
-
# ============================================
|
|
17
|
-
echo "测试 1: Bash 缓存检测逻辑"
|
|
18
|
-
echo "----------------------------------------"
|
|
19
|
-
|
|
20
|
-
# 创建测试文件
|
|
21
|
-
TEST_FILE="$PROJECT_ROOT/stories/test-story/specification.md"
|
|
22
|
-
mkdir -p "$(dirname "$TEST_FILE")"
|
|
23
|
-
echo "# Test Specification" > "$TEST_FILE"
|
|
24
|
-
|
|
25
|
-
# 运行脚本并检查输出
|
|
26
|
-
cd "$PROJECT_ROOT"
|
|
27
|
-
OUTPUT=$(bash templates/scripts/bash/check-writing-state.sh --json 2>&1)
|
|
28
|
-
|
|
29
|
-
# 检查 JSON 字段存在性
|
|
30
|
-
echo "检查 JSON 输出字段..."
|
|
31
|
-
|
|
32
|
-
if echo "$OUTPUT" | grep -q '"cached"'; then
|
|
33
|
-
echo "✅ cached 字段存在"
|
|
34
|
-
else
|
|
35
|
-
echo "❌ cached 字段缺失"
|
|
36
|
-
exit 1
|
|
37
|
-
fi
|
|
38
|
-
|
|
39
|
-
if echo "$OUTPUT" | grep -q '"session_cache_enabled"'; then
|
|
40
|
-
echo "✅ session_cache_enabled 字段存在"
|
|
41
|
-
else
|
|
42
|
-
echo "❌ session_cache_enabled 字段缺失"
|
|
43
|
-
exit 1
|
|
44
|
-
fi
|
|
45
|
-
|
|
46
|
-
# 检查缓存值(第一次运行应该是 false)
|
|
47
|
-
CACHED_VALUE=$(echo "$OUTPUT" | grep '"cached"' | sed 's/.*: *\([^,]*\).*/\1/')
|
|
48
|
-
echo "当前 cached 值: $CACHED_VALUE"
|
|
49
|
-
|
|
50
|
-
if [[ "$CACHED_VALUE" == "false" ]]; then
|
|
51
|
-
echo "✅ 首次运行 cached=false(正确)"
|
|
52
|
-
else
|
|
53
|
-
echo "⚠️ 首次运行 cached=$CACHED_VALUE(可能已有缓存)"
|
|
54
|
-
fi
|
|
55
|
-
|
|
56
|
-
# 清理测试文件
|
|
57
|
-
rm -rf "$PROJECT_ROOT/stories/test-story"
|
|
58
|
-
|
|
59
|
-
echo ""
|
|
60
|
-
echo "测试 1 通过 ✅"
|
|
61
|
-
echo ""
|
|
62
|
-
|
|
63
|
-
# ============================================
|
|
64
|
-
# 测试 2: 验证缓存逻辑代码
|
|
65
|
-
# ============================================
|
|
66
|
-
echo "测试 2: 验证缓存逻辑代码"
|
|
67
|
-
echo "----------------------------------------"
|
|
68
|
-
|
|
69
|
-
# 检查 Bash 是否使用 get_file_mtime()
|
|
70
|
-
if grep -q 'local spec_mtime=$(get_file_mtime "$spec_file")' "$PROJECT_ROOT/templates/scripts/bash/check-writing-state.sh"; then
|
|
71
|
-
echo "✅ Bash 使用 get_file_mtime() 获取缓存值"
|
|
72
|
-
else
|
|
73
|
-
echo "❌ Bash 未使用 get_file_mtime()"
|
|
74
|
-
exit 1
|
|
75
|
-
fi
|
|
76
|
-
|
|
77
|
-
# 检查是否正确排除 mtime=-1 和 mtime=0
|
|
78
|
-
if grep -q 'if \[\[ "$spec_mtime" != "0" && "$spec_mtime" != "-1" \]\]; then' "$PROJECT_ROOT/templates/scripts/bash/check-writing-state.sh"; then
|
|
79
|
-
echo "✅ Bash 正确排除 mtime=-1 和 mtime=0"
|
|
80
|
-
else
|
|
81
|
-
echo "❌ Bash 缓存检测逻辑不正确"
|
|
82
|
-
exit 1
|
|
83
|
-
fi
|
|
84
|
-
|
|
85
|
-
# 检查注释是否包含语义说明
|
|
86
|
-
if grep -q '缓存语义: -1 = 文件不存在, 0 = stat 失败或未缓存, >0 = 成功读取' "$PROJECT_ROOT/templates/scripts/bash/check-writing-state.sh"; then
|
|
87
|
-
echo "✅ Bash 包含正确的缓存语义注释"
|
|
88
|
-
else
|
|
89
|
-
echo "❌ Bash 缺少缓存语义注释"
|
|
90
|
-
exit 1
|
|
91
|
-
fi
|
|
92
|
-
|
|
93
|
-
echo ""
|
|
94
|
-
echo "测试 2 通过 ✅"
|
|
95
|
-
echo ""
|
|
96
|
-
|
|
97
|
-
# ============================================
|
|
98
|
-
# 测试 3: PowerShell 缓存逻辑验证(代码审查)
|
|
99
|
-
# ============================================
|
|
100
|
-
echo "测试 3: PowerShell 缓存逻辑验证"
|
|
101
|
-
echo "----------------------------------------"
|
|
102
|
-
|
|
103
|
-
# 检查 PowerShell 是否使用正确的缓存检测逻辑
|
|
104
|
-
if grep -q '\$script:FileMTimeCache.ContainsKey(\$specFile) -and' "$PROJECT_ROOT/templates/scripts/powershell/check-writing-state.ps1"; then
|
|
105
|
-
echo "✅ PowerShell 检查缓存键存在性"
|
|
106
|
-
else
|
|
107
|
-
echo "❌ PowerShell 缺少缓存键检查"
|
|
108
|
-
exit 1
|
|
109
|
-
fi
|
|
110
|
-
|
|
111
|
-
if grep -q '\$script:FileMTimeCache\[\$specFile\] -ne \$null -and' "$PROJECT_ROOT/templates/scripts/powershell/check-writing-state.ps1"; then
|
|
112
|
-
echo "✅ PowerShell 排除 \$null(文件不存在)"
|
|
113
|
-
else
|
|
114
|
-
echo "❌ PowerShell 未排除 \$null"
|
|
115
|
-
exit 1
|
|
116
|
-
fi
|
|
117
|
-
|
|
118
|
-
if grep -q '\$script:FileMTimeCache\[\$specFile\] -ne \[DateTime\]::MinValue' "$PROJECT_ROOT/templates/scripts/powershell/check-writing-state.ps1"; then
|
|
119
|
-
echo "✅ PowerShell 排除 MinValue(读取失败)"
|
|
120
|
-
else
|
|
121
|
-
echo "❌ PowerShell 未排除 MinValue"
|
|
122
|
-
exit 1
|
|
123
|
-
fi
|
|
124
|
-
|
|
125
|
-
# 检查注释
|
|
126
|
-
if grep -q '缓存语义: \$null = 文件不存在, MinValue = stat 失败, DateTime = 成功读取' "$PROJECT_ROOT/templates/scripts/powershell/check-writing-state.ps1"; then
|
|
127
|
-
echo "✅ PowerShell 包含正确的缓存语义注释"
|
|
128
|
-
else
|
|
129
|
-
echo "❌ PowerShell 缺少缓存语义注释"
|
|
130
|
-
exit 1
|
|
131
|
-
fi
|
|
132
|
-
|
|
133
|
-
echo ""
|
|
134
|
-
echo "测试 3 通过 ✅"
|
|
135
|
-
echo ""
|
|
136
|
-
|
|
137
|
-
# ============================================
|
|
138
|
-
# 测试 4: 跨平台语义映射验证
|
|
139
|
-
# ============================================
|
|
140
|
-
echo "测试 4: 跨平台语义映射验证"
|
|
141
|
-
echo "----------------------------------------"
|
|
142
|
-
|
|
143
|
-
echo "语义映射表:"
|
|
144
|
-
echo " 场景 | Bash mtime | PowerShell 值 | 预期结果"
|
|
145
|
-
echo " ---------------------|-----------|---------------|-------------"
|
|
146
|
-
echo " 文件存在且成功读取 | >0 | DateTime | cached=true"
|
|
147
|
-
echo " 文件不存在 | -1 | \$null | cached=false"
|
|
148
|
-
echo " 文件读取失败 | 0 | MinValue | cached=false"
|
|
149
|
-
echo " 文件未缓存 | 0 | 键不存在 | cached=false"
|
|
150
|
-
|
|
151
|
-
echo ""
|
|
152
|
-
echo "✅ 跨平台语义映射一致(代码审查通过)"
|
|
153
|
-
echo ""
|
|
154
|
-
|
|
155
|
-
# ============================================
|
|
156
|
-
# 测试 5: 提交质量验证
|
|
157
|
-
# ============================================
|
|
158
|
-
echo "测试 5: 提交质量验证"
|
|
159
|
-
echo "----------------------------------------"
|
|
160
|
-
|
|
161
|
-
cd "$PROJECT_ROOT"
|
|
162
|
-
|
|
163
|
-
# 检查最新提交(Bash 修复)
|
|
164
|
-
LATEST_COMMIT=$(git log --oneline -1 --grep="修复 Bash 缓存检测" 2>/dev/null || echo "")
|
|
165
|
-
if [[ -n "$LATEST_COMMIT" ]]; then
|
|
166
|
-
echo "✅ 找到 Bash 修复提交: $LATEST_COMMIT"
|
|
167
|
-
else
|
|
168
|
-
echo "⚠️ 未找到明确的 Bash 修复提交"
|
|
169
|
-
fi
|
|
170
|
-
|
|
171
|
-
# 检查提交消息格式
|
|
172
|
-
if git log -1 --format=%B --grep="修复 Bash 缓存检测" 2>/dev/null | grep -q "Co-Authored-By: Claude"; then
|
|
173
|
-
echo "✅ 提交包含 Co-Authored-By 标记"
|
|
174
|
-
else
|
|
175
|
-
echo "⚠️ 提交缺少 Co-Authored-By 标记"
|
|
176
|
-
fi
|
|
177
|
-
|
|
178
|
-
echo ""
|
|
179
|
-
echo "测试 5 通过 ✅"
|
|
180
|
-
echo ""
|
|
181
|
-
|
|
182
|
-
# ============================================
|
|
183
|
-
# 最终结果
|
|
184
|
-
# ============================================
|
|
185
|
-
echo "========================================"
|
|
186
|
-
echo "✅ Task 6 最终验证测试全部通过"
|
|
187
|
-
echo "========================================"
|
|
188
|
-
echo ""
|
|
189
|
-
echo "验证项目:"
|
|
190
|
-
echo " [✅] Bash 使用 get_file_mtime() 获取缓存值"
|
|
191
|
-
echo " [✅] Bash 正确排除 mtime=-1 和 mtime=0"
|
|
192
|
-
echo " [✅] Bash 仅 mtime>0 时返回 cached=true"
|
|
193
|
-
echo " [✅] Bash 包含正确的缓存语义注释"
|
|
194
|
-
echo " [✅] PowerShell 检查缓存键存在性和值有效性"
|
|
195
|
-
echo " [✅] PowerShell 排除 \$null 和 MinValue"
|
|
196
|
-
echo " [✅] PowerShell 包含正确的缓存语义注释"
|
|
197
|
-
echo " [✅] 跨平台语义映射完全一致"
|
|
198
|
-
echo " [✅] JSON 输出包含 cached 和 session_cache_enabled 字段"
|
|
199
|
-
echo ""
|
|
200
|
-
echo "推荐操作: 标记 Task #56 为完成状态 ✓"
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# 文本人味自查(离线):连接词/空话密度、句长统计、抽象词密度
|
|
3
|
-
|
|
4
|
-
set -e
|
|
5
|
-
|
|
6
|
-
SCRIPT_DIR=$(dirname "$0")
|
|
7
|
-
source "$SCRIPT_DIR/common.sh"
|
|
8
|
-
|
|
9
|
-
PROJECT_ROOT=$(get_project_root)
|
|
10
|
-
|
|
11
|
-
FILE_PATH="$1"
|
|
12
|
-
if [ -z "$FILE_PATH" ] || [ ! -f "$FILE_PATH" ]; then
|
|
13
|
-
echo "用法: scripts/bash/text-audit.sh <file>"
|
|
14
|
-
exit 1
|
|
15
|
-
fi
|
|
16
|
-
|
|
17
|
-
# 选择配置:优先项目 resources/knowledge,其次 resources
|
|
18
|
-
CFG_PROJECT="$PROJECT_ROOT/resources/knowledge/audit-config.json"
|
|
19
|
-
CFG_TEMPLATE="$PROJECT_ROOT/resources/knowledge/audit-config.json"
|
|
20
|
-
if [ -f "$CFG_PROJECT" ]; then
|
|
21
|
-
CFG="$CFG_PROJECT"
|
|
22
|
-
elif [ -f "$CFG_TEMPLATE" ]; then
|
|
23
|
-
CFG="$CFG_TEMPLATE"
|
|
24
|
-
else
|
|
25
|
-
CFG=""
|
|
26
|
-
fi
|
|
27
|
-
|
|
28
|
-
python3 - "$FILE_PATH" "$CFG" << 'PY'
|
|
29
|
-
import json, re, sys, os, math
|
|
30
|
-
|
|
31
|
-
path = sys.argv[1]
|
|
32
|
-
cfg_path = sys.argv[2] if len(sys.argv) > 2 else ''
|
|
33
|
-
|
|
34
|
-
text = open(path, 'r', encoding='utf-8', errors='ignore').read()
|
|
35
|
-
|
|
36
|
-
default_cfg = {
|
|
37
|
-
"connector_phrases": ["首先","其次","再次","然后","然而","总而言之","综上所述","在某种程度","众所周知","在当下","随着"],
|
|
38
|
-
"empty_phrases": ["广泛关注","引发热议","影响深远","具有重要意义","有效提升","具有一定的指导意义","值得我们思考"],
|
|
39
|
-
"cliche_pairs": [],
|
|
40
|
-
"sentence_length": {"max_run_long":4, "max_run_short":5, "short_threshold":12, "long_threshold":35},
|
|
41
|
-
"abstract_nouns": ["价值","意义","认知","体系","模式","路径","方法论","趋势"],
|
|
42
|
-
"min_concrete_details": 3
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
cfg = default_cfg
|
|
46
|
-
if cfg_path and os.path.exists(cfg_path):
|
|
47
|
-
try:
|
|
48
|
-
with open(cfg_path, 'r', encoding='utf-8') as f:
|
|
49
|
-
loaded = json.load(f)
|
|
50
|
-
cfg.update(loaded)
|
|
51
|
-
except Exception:
|
|
52
|
-
pass
|
|
53
|
-
|
|
54
|
-
def count_occurrences(text, phrases):
|
|
55
|
-
res = {}
|
|
56
|
-
for p in phrases:
|
|
57
|
-
if not p: continue
|
|
58
|
-
res[p] = len(re.findall(re.escape(p), text))
|
|
59
|
-
return res
|
|
60
|
-
|
|
61
|
-
def split_sentences(t):
|
|
62
|
-
parts = re.split(r'[。!?!?\n]+', t)
|
|
63
|
-
return [s.strip() for s in parts if s.strip()]
|
|
64
|
-
|
|
65
|
-
def sentence_lengths(sents):
|
|
66
|
-
lens = [len(s) for s in sents]
|
|
67
|
-
if not lens:
|
|
68
|
-
return lens, 0, 0
|
|
69
|
-
avg = sum(lens)/len(lens)
|
|
70
|
-
var = sum((x-avg)**2 for x in lens)/len(lens)
|
|
71
|
-
return lens, avg, math.sqrt(var)
|
|
72
|
-
|
|
73
|
-
def runs(lens, short_th, long_th):
|
|
74
|
-
run_short = 0; run_long = 0
|
|
75
|
-
max_run_short = 0; max_run_long = 0
|
|
76
|
-
marks = []
|
|
77
|
-
for i, L in enumerate(lens):
|
|
78
|
-
if L <= short_th:
|
|
79
|
-
run_short += 1; max_run_short = max(max_run_short, run_short); run_long = 0
|
|
80
|
-
elif L >= long_th:
|
|
81
|
-
run_long += 1; max_run_long = max(max_run_long, run_long); run_short = 0
|
|
82
|
-
else:
|
|
83
|
-
run_short = 0; run_long = 0
|
|
84
|
-
return max_run_short, max_run_long
|
|
85
|
-
|
|
86
|
-
def abstract_density(sent, abstract_words):
|
|
87
|
-
cnt = sum(len(re.findall(re.escape(w), sent)) for w in abstract_words)
|
|
88
|
-
return cnt
|
|
89
|
-
|
|
90
|
-
connectors = count_occurrences(text, cfg["connector_phrases"])
|
|
91
|
-
empties = count_occurrences(text, cfg["empty_phrases"])
|
|
92
|
-
sents = split_sentences(text)
|
|
93
|
-
lens, avg, std = sentence_lengths(sents)
|
|
94
|
-
mx_run_short, mx_run_long = runs(lens, cfg["sentence_length"]["short_threshold"], cfg["sentence_length"]["long_threshold"])
|
|
95
|
-
|
|
96
|
-
abstract_scores = [(i, abstract_density(s, cfg["abstract_nouns"])) for i, s in enumerate(sents)]
|
|
97
|
-
abstract_scores.sort(key=lambda x: x[1], reverse=True)
|
|
98
|
-
abstract_top = [ (i, sents[i]) for i,score in abstract_scores[:5] if score>=2 ]
|
|
99
|
-
|
|
100
|
-
total_chars = len(text)
|
|
101
|
-
def ratio(count):
|
|
102
|
-
return (count / max(1,total_chars)) * 1000
|
|
103
|
-
|
|
104
|
-
print("━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
|
|
105
|
-
print("📊 离线文本人味自查报告")
|
|
106
|
-
print(f"文件: {os.path.basename(path)} 字符数: {total_chars}")
|
|
107
|
-
print("")
|
|
108
|
-
print("连接词密度(每千字出现次数)")
|
|
109
|
-
total_conn = sum(connectors.values())
|
|
110
|
-
print(f" 总计: {total_conn} | 比率: {ratio(total_conn):.2f}")
|
|
111
|
-
for k,v in sorted(connectors.items(), key=lambda x: -x[1])[:10]:
|
|
112
|
-
if v>0: print(f" - {k}: {v}")
|
|
113
|
-
|
|
114
|
-
print("")
|
|
115
|
-
print("空话/套话计数")
|
|
116
|
-
total_emp = sum(empties.values())
|
|
117
|
-
print(f" 总计: {total_emp} | 比率: {ratio(total_emp):.2f}")
|
|
118
|
-
for k,v in sorted(empties.items(), key=lambda x: -x[1])[:10]:
|
|
119
|
-
if v>0: print(f" - {k}: {v}")
|
|
120
|
-
|
|
121
|
-
print("")
|
|
122
|
-
print("句长统计")
|
|
123
|
-
print(f" 句子数: {len(lens)} | 平均: {avg:.1f} | 标准差: {std:.1f}")
|
|
124
|
-
print(f" 连续短句最大: {mx_run_short} (阈值 {cfg['sentence_length']['max_run_short']})")
|
|
125
|
-
print(f" 连续长句最大: {mx_run_long} (阈值 {cfg['sentence_length']['max_run_long']})")
|
|
126
|
-
|
|
127
|
-
print("")
|
|
128
|
-
print("抽象过载(示例段,≥2 抽象词)")
|
|
129
|
-
if abstract_top:
|
|
130
|
-
for idx, s in abstract_top:
|
|
131
|
-
snippet = s[:80] + ("…" if len(s)>80 else "")
|
|
132
|
-
print(f" - 第{idx+1}句: {snippet}")
|
|
133
|
-
else:
|
|
134
|
-
print(" 无显著抽象过载片段")
|
|
135
|
-
|
|
136
|
-
print("")
|
|
137
|
-
print("建议")
|
|
138
|
-
print(" - 用具体动作/器物/气味替代空话与抽象名词")
|
|
139
|
-
print(" - 打断长长串句子;合并过多的短句以形成起伏")
|
|
140
|
-
print(" - 复查连接词是否可删除或自然过渡")
|
|
141
|
-
print(" - 写前先列3个生活细节作为锚点")
|
|
142
|
-
print("━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
|
|
143
|
-
PY
|
|
144
|
-
|