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,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NPM 安装器
|
|
3
|
-
*
|
|
4
|
-
* 从 npm registry 下载并安装插件。
|
|
5
|
-
* 继承 BaseInstaller,复用公共 tar 解压逻辑。
|
|
6
|
-
*/
|
|
7
|
-
import fs from 'fs-extra';
|
|
8
|
-
import path from 'path';
|
|
9
|
-
import { pipeline } from 'stream/promises';
|
|
10
|
-
import { createWriteStream } from 'fs';
|
|
11
|
-
import { BaseInstaller } from './base.js';
|
|
12
|
-
import { NetworkError, PluginInstallError } from '../../core/errors.js';
|
|
13
|
-
import { logger } from '../../utils/logger.js';
|
|
14
|
-
export class NpmInstaller extends BaseInstaller {
|
|
15
|
-
registry;
|
|
16
|
-
constructor(options) {
|
|
17
|
-
super();
|
|
18
|
-
this.registry = options?.registryUrl || 'https://registry.npmjs.org';
|
|
19
|
-
}
|
|
20
|
-
async getPackageInfo(name) {
|
|
21
|
-
const url = `${this.registry}/${encodeURIComponent(name).replace('%40', '@')}`;
|
|
22
|
-
let response;
|
|
23
|
-
try {
|
|
24
|
-
response = await fetch(url);
|
|
25
|
-
}
|
|
26
|
-
catch (error) {
|
|
27
|
-
throw new NetworkError(url, undefined, error instanceof Error ? error.message : '网络连接失败');
|
|
28
|
-
}
|
|
29
|
-
if (!response.ok) {
|
|
30
|
-
if (response.status === 404) {
|
|
31
|
-
throw new PluginInstallError(name, 'npm', `包 ${name} 在 npm registry 中未找到`);
|
|
32
|
-
}
|
|
33
|
-
throw new NetworkError(url, response.status);
|
|
34
|
-
}
|
|
35
|
-
return await response.json();
|
|
36
|
-
}
|
|
37
|
-
async getTarballUrl(name, version) {
|
|
38
|
-
const info = await this.getPackageInfo(name);
|
|
39
|
-
const targetVersion = version || info['dist-tags']?.latest;
|
|
40
|
-
if (!targetVersion) {
|
|
41
|
-
throw new PluginInstallError(name, 'npm', '未找到可用版本');
|
|
42
|
-
}
|
|
43
|
-
const versionInfo = info.versions?.[targetVersion];
|
|
44
|
-
if (!versionInfo) {
|
|
45
|
-
throw new PluginInstallError(name, 'npm', `版本 ${targetVersion} 不存在`);
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
url: versionInfo.dist.tarball,
|
|
49
|
-
version: targetVersion,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
async downloadTarball(url, destPath) {
|
|
53
|
-
let response;
|
|
54
|
-
try {
|
|
55
|
-
response = await fetch(url);
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
throw new NetworkError(url, undefined, error instanceof Error ? error.message : '下载失败');
|
|
59
|
-
}
|
|
60
|
-
if (!response.ok || !response.body) {
|
|
61
|
-
throw new NetworkError(url, response.status, '下载 tarball 失败');
|
|
62
|
-
}
|
|
63
|
-
const fileStream = createWriteStream(destPath);
|
|
64
|
-
// @ts-ignore - Node.js fetch body is a ReadableStream
|
|
65
|
-
await pipeline(response.body, fileStream);
|
|
66
|
-
}
|
|
67
|
-
async install(identifier, destDir) {
|
|
68
|
-
const { name, version } = identifier;
|
|
69
|
-
logger.info(`从 npm registry 获取 ${name}...`);
|
|
70
|
-
// 1. 获取 tarball URL
|
|
71
|
-
const tarball = await this.getTarballUrl(name, version);
|
|
72
|
-
// 2. 创建临时目录
|
|
73
|
-
const tmpDir = await this.createTempDir('nws-npm-');
|
|
74
|
-
const tarballPath = path.join(tmpDir, 'package.tgz');
|
|
75
|
-
try {
|
|
76
|
-
// 3. 下载
|
|
77
|
-
logger.info(`下载 ${name}@${tarball.version}...`);
|
|
78
|
-
await this.downloadTarball(tarball.url, tarballPath);
|
|
79
|
-
// 4. 解压(npm tarball 有一层 package/ 包装)
|
|
80
|
-
const extractPath = path.join(tmpDir, 'extracted');
|
|
81
|
-
await this.extractTarball(tarballPath, extractPath, 1);
|
|
82
|
-
// 5. 验证 config.yaml
|
|
83
|
-
const configPath = path.join(extractPath, 'config.yaml');
|
|
84
|
-
if (!await fs.pathExists(configPath)) {
|
|
85
|
-
throw new PluginInstallError(name, 'npm', `包 ${name} 中未找到 config.yaml`);
|
|
86
|
-
}
|
|
87
|
-
// 6. 移动到目标
|
|
88
|
-
const pluginName = path.basename(name);
|
|
89
|
-
const pluginDir = path.join(destDir, pluginName);
|
|
90
|
-
await fs.ensureDir(path.dirname(pluginDir));
|
|
91
|
-
await fs.move(extractPath, pluginDir, { overwrite: true });
|
|
92
|
-
return { version: tarball.version, pluginPath: pluginDir };
|
|
93
|
-
}
|
|
94
|
-
finally {
|
|
95
|
-
await this.cleanup(tmpDir);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
//# sourceMappingURL=npm.js.map
|
|
@@ -1 +0,0 @@
|
|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AAC,UAAU,CAAC,EAAE,CAAC;gBACrC,MAAM,IAAI,kBAAkB,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,IAAI,mBAAmB,CAAC,CAAC;YAC1E,CAAC;YAED,WAAW;YACX,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACvC,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;YACjD,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;YAC5C,MAAM,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAE3D,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;QAC7D,CAAC;gBAAS,CAAC;YACT,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 插件管理器
|
|
3
|
-
*
|
|
4
|
-
* 协调层:安装器选择 → 安装 → 验证 → 注册 → 注入。
|
|
5
|
-
* 注册表管理已拆到 registry.ts,安装器已拆到 installers/。
|
|
6
|
-
*
|
|
7
|
-
* Bug 修复:
|
|
8
|
-
* - removePlugin() 现在会清理注入的命令文件
|
|
9
|
-
* - installPlugin() 统一更新注册表
|
|
10
|
-
*/
|
|
11
|
-
import { PluginConfig } from './types.js';
|
|
12
|
-
import { PluginRegistry } from './registry.js';
|
|
13
|
-
export declare class PluginManager {
|
|
14
|
-
private projectRoot;
|
|
15
|
-
private pluginsDir;
|
|
16
|
-
private commandsDir;
|
|
17
|
-
private skillsDir;
|
|
18
|
-
private registry;
|
|
19
|
-
private npmInstaller;
|
|
20
|
-
private githubInstaller;
|
|
21
|
-
private localInstaller;
|
|
22
|
-
constructor(projectRoot: string);
|
|
23
|
-
/**
|
|
24
|
-
* 扫描并加载所有插件
|
|
25
|
-
*/
|
|
26
|
-
loadPlugins(): Promise<void>;
|
|
27
|
-
/**
|
|
28
|
-
* 扫描插件目录
|
|
29
|
-
*/
|
|
30
|
-
private scanPlugins;
|
|
31
|
-
/**
|
|
32
|
-
* 加载单个插件(注入 commands 和 skills)
|
|
33
|
-
*/
|
|
34
|
-
private loadPlugin;
|
|
35
|
-
/**
|
|
36
|
-
* 注入插件命令
|
|
37
|
-
*/
|
|
38
|
-
private injectCommands;
|
|
39
|
-
/**
|
|
40
|
-
* 注入插件 Skills
|
|
41
|
-
*/
|
|
42
|
-
private injectSkills;
|
|
43
|
-
/**
|
|
44
|
-
* 清理插件注入的命令文件
|
|
45
|
-
*/
|
|
46
|
-
private cleanupCommands;
|
|
47
|
-
/**
|
|
48
|
-
* 列出所有已安装的插件
|
|
49
|
-
*/
|
|
50
|
-
listPlugins(): Promise<PluginConfig[]>;
|
|
51
|
-
/**
|
|
52
|
-
* 从本地路径安装插件(内置插件)
|
|
53
|
-
*/
|
|
54
|
-
installPlugin(pluginName: string, source?: string): Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* 移除插件
|
|
57
|
-
* 修复: 现在会读取配置并清理注入的命令文件
|
|
58
|
-
*/
|
|
59
|
-
removePlugin(pluginName: string): Promise<void>;
|
|
60
|
-
/**
|
|
61
|
-
* 检查插件是否已安装
|
|
62
|
-
*/
|
|
63
|
-
isPluginInstalled(name: string): Promise<boolean>;
|
|
64
|
-
/**
|
|
65
|
-
* 远程安装插件(支持 npm/GitHub/local)
|
|
66
|
-
*/
|
|
67
|
-
installRemotePlugin(input: string): Promise<void>;
|
|
68
|
-
/**
|
|
69
|
-
* 更新插件
|
|
70
|
-
*/
|
|
71
|
-
updatePlugin(name: string): Promise<void>;
|
|
72
|
-
/**
|
|
73
|
-
* 获取已安装插件的注册表信息
|
|
74
|
-
*/
|
|
75
|
-
getRegistry(): Promise<PluginRegistry>;
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/plugins/manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EAAE,YAAY,EAAkB,MAAM,YAAY,CAAC;AAM1D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAS/C,qBAAa,aAAa;IACxB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,cAAc,CAAiB;gBAE3B,WAAW,EAAE,MAAM;IAY/B;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBlC;;OAEG;YACW,WAAW;IAyBzB;;OAEG;YACW,UAAU;IA8BxB;;OAEG;YACW,cAAc;IAkB5B;;OAEG;YACW,YAAY;IAkB1B;;OAEG;YACW,eAAe;IAc7B;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAe5C;;OAEG;IACG,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmCvE;;;OAGG;IACG,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoCrD;;OAEG;IACG,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKvD;;OAEG;IACG,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA8EvD;;OAEG;IACG,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB/C;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,cAAc,CAAC;CAI7C"}
|
package/dist/plugins/manager.js
DELETED
|
@@ -1,349 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 插件管理器
|
|
3
|
-
*
|
|
4
|
-
* 协调层:安装器选择 → 安装 → 验证 → 注册 → 注入。
|
|
5
|
-
* 注册表管理已拆到 registry.ts,安装器已拆到 installers/。
|
|
6
|
-
*
|
|
7
|
-
* Bug 修复:
|
|
8
|
-
* - removePlugin() 现在会清理注入的命令文件
|
|
9
|
-
* - installPlugin() 统一更新注册表
|
|
10
|
-
*/
|
|
11
|
-
import fs from 'fs-extra';
|
|
12
|
-
import path from 'path';
|
|
13
|
-
import { logger } from '../utils/logger.js';
|
|
14
|
-
import { parsePluginIdentifier } from './identifier.js';
|
|
15
|
-
import { NpmInstaller } from './installers/npm.js';
|
|
16
|
-
import { GitHubInstaller } from './installers/github.js';
|
|
17
|
-
import { LocalInstaller } from './installers/local.js';
|
|
18
|
-
import { PluginValidator } from './validator.js';
|
|
19
|
-
import { PluginRegistry } from './registry.js';
|
|
20
|
-
import { getProjectPaths } from '../core/config.js';
|
|
21
|
-
import { PluginNotFoundError, PluginAlreadyInstalledError, PluginValidationError, PluginInstallError, } from '../core/errors.js';
|
|
22
|
-
export class PluginManager {
|
|
23
|
-
projectRoot;
|
|
24
|
-
pluginsDir;
|
|
25
|
-
commandsDir;
|
|
26
|
-
skillsDir;
|
|
27
|
-
registry;
|
|
28
|
-
npmInstaller;
|
|
29
|
-
githubInstaller;
|
|
30
|
-
localInstaller;
|
|
31
|
-
constructor(projectRoot) {
|
|
32
|
-
this.projectRoot = projectRoot;
|
|
33
|
-
const paths = getProjectPaths(projectRoot);
|
|
34
|
-
this.pluginsDir = paths.plugins;
|
|
35
|
-
this.commandsDir = paths.commands;
|
|
36
|
-
this.skillsDir = paths.skills;
|
|
37
|
-
this.registry = new PluginRegistry(paths.pluginRegistry);
|
|
38
|
-
this.npmInstaller = new NpmInstaller();
|
|
39
|
-
this.githubInstaller = new GitHubInstaller();
|
|
40
|
-
this.localInstaller = new LocalInstaller();
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* 扫描并加载所有插件
|
|
44
|
-
*/
|
|
45
|
-
async loadPlugins() {
|
|
46
|
-
try {
|
|
47
|
-
await fs.ensureDir(this.pluginsDir);
|
|
48
|
-
const plugins = await this.scanPlugins();
|
|
49
|
-
if (plugins.length === 0) {
|
|
50
|
-
logger.info('没有发现插件');
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
logger.info(`发现 ${plugins.length} 个插件`);
|
|
54
|
-
for (const pluginName of plugins) {
|
|
55
|
-
await this.loadPlugin(pluginName);
|
|
56
|
-
}
|
|
57
|
-
logger.success('所有插件加载完成');
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
logger.error('加载插件失败:', error);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* 扫描插件目录
|
|
65
|
-
*/
|
|
66
|
-
async scanPlugins() {
|
|
67
|
-
try {
|
|
68
|
-
if (!await fs.pathExists(this.pluginsDir)) {
|
|
69
|
-
return [];
|
|
70
|
-
}
|
|
71
|
-
const entries = await fs.readdir(this.pluginsDir, { withFileTypes: true });
|
|
72
|
-
const plugins = [];
|
|
73
|
-
for (const entry of entries) {
|
|
74
|
-
if (entry.isDirectory()) {
|
|
75
|
-
const configPath = path.join(this.pluginsDir, entry.name, 'config.yaml');
|
|
76
|
-
if (await fs.pathExists(configPath)) {
|
|
77
|
-
plugins.push(entry.name);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return plugins;
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
logger.error('扫描插件目录失败:', error);
|
|
85
|
-
return [];
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* 加载单个插件(注入 commands 和 skills)
|
|
90
|
-
*/
|
|
91
|
-
async loadPlugin(pluginName) {
|
|
92
|
-
try {
|
|
93
|
-
logger.info(`加载插件: ${pluginName}`);
|
|
94
|
-
const configPath = path.join(this.pluginsDir, pluginName, 'config.yaml');
|
|
95
|
-
const config = await PluginValidator.parseConfig(configPath);
|
|
96
|
-
if (!config) {
|
|
97
|
-
logger.warn(`插件 ${pluginName} 配置无效`);
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
if (config.commands && config.commands.length > 0) {
|
|
101
|
-
await this.injectCommands(pluginName, config.commands);
|
|
102
|
-
}
|
|
103
|
-
if (config.skills && config.skills.length > 0) {
|
|
104
|
-
await this.injectSkills(pluginName, config.skills);
|
|
105
|
-
}
|
|
106
|
-
logger.success(`插件 ${pluginName} 加载成功`);
|
|
107
|
-
if (config.installation?.message) {
|
|
108
|
-
console.log(config.installation.message);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
catch (error) {
|
|
112
|
-
logger.error(`加载插件 ${pluginName} 失败:`, error);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* 注入插件命令
|
|
117
|
-
*/
|
|
118
|
-
async injectCommands(pluginName, commands) {
|
|
119
|
-
for (const cmd of commands) {
|
|
120
|
-
try {
|
|
121
|
-
const sourcePath = path.join(this.pluginsDir, pluginName, cmd.file);
|
|
122
|
-
const destPath = path.join(this.commandsDir, `${cmd.id}.md`);
|
|
123
|
-
await fs.ensureDir(this.commandsDir);
|
|
124
|
-
await fs.copy(sourcePath, destPath);
|
|
125
|
-
logger.debug(`注入命令: /${cmd.id}`);
|
|
126
|
-
}
|
|
127
|
-
catch (error) {
|
|
128
|
-
logger.error(`注入命令 ${cmd.id} 失败:`, error);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* 注入插件 Skills
|
|
134
|
-
*/
|
|
135
|
-
async injectSkills(pluginName, skills) {
|
|
136
|
-
for (const skill of skills) {
|
|
137
|
-
try {
|
|
138
|
-
const sourcePath = path.join(this.pluginsDir, pluginName, skill.file);
|
|
139
|
-
const destPath = path.join(this.skillsDir, pluginName, path.basename(skill.file));
|
|
140
|
-
await fs.ensureDir(path.dirname(destPath));
|
|
141
|
-
await fs.copy(sourcePath, destPath);
|
|
142
|
-
logger.debug(`注入 Skill: ${skill.id}`);
|
|
143
|
-
}
|
|
144
|
-
catch (error) {
|
|
145
|
-
logger.error(`注入 Skill ${skill.id} 失败:`, error);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* 清理插件注入的命令文件
|
|
151
|
-
*/
|
|
152
|
-
async cleanupCommands(commands) {
|
|
153
|
-
for (const cmd of commands) {
|
|
154
|
-
try {
|
|
155
|
-
const cmdPath = path.join(this.commandsDir, `${cmd.id}.md`);
|
|
156
|
-
if (await fs.pathExists(cmdPath)) {
|
|
157
|
-
await fs.remove(cmdPath);
|
|
158
|
-
logger.debug(`清理命令: /${cmd.id}`);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
catch (error) {
|
|
162
|
-
logger.error(`清理命令 ${cmd.id} 失败:`, error);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* 列出所有已安装的插件
|
|
168
|
-
*/
|
|
169
|
-
async listPlugins() {
|
|
170
|
-
const plugins = await this.scanPlugins();
|
|
171
|
-
const configs = [];
|
|
172
|
-
for (const pluginName of plugins) {
|
|
173
|
-
const configPath = path.join(this.pluginsDir, pluginName, 'config.yaml');
|
|
174
|
-
const config = await PluginValidator.parseConfig(configPath);
|
|
175
|
-
if (config) {
|
|
176
|
-
configs.push(config);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
return configs;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* 从本地路径安装插件(内置插件)
|
|
183
|
-
*/
|
|
184
|
-
async installPlugin(pluginName, source) {
|
|
185
|
-
try {
|
|
186
|
-
logger.info(`安装插件: ${pluginName}`);
|
|
187
|
-
if (source) {
|
|
188
|
-
const result = await this.localInstaller.installFromPath(source, pluginName, this.pluginsDir);
|
|
189
|
-
// 更新注册表
|
|
190
|
-
await this.registry.load();
|
|
191
|
-
const configPath = path.join(this.pluginsDir, pluginName, 'config.yaml');
|
|
192
|
-
const config = await PluginValidator.parseConfig(configPath);
|
|
193
|
-
this.registry.add({
|
|
194
|
-
name: pluginName,
|
|
195
|
-
version: result.version,
|
|
196
|
-
source: 'builtin',
|
|
197
|
-
installedAt: new Date().toISOString(),
|
|
198
|
-
path: `plugins/${pluginName}`,
|
|
199
|
-
commands: config?.commands?.map(c => c.id),
|
|
200
|
-
skills: config?.skills?.map(s => s.id),
|
|
201
|
-
});
|
|
202
|
-
await this.registry.save();
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
logger.warn('未指定安装源,请使用 installRemotePlugin() 进行远程安装');
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
await this.loadPlugin(pluginName);
|
|
209
|
-
logger.success(`插件 ${pluginName} 安装成功`);
|
|
210
|
-
}
|
|
211
|
-
catch (error) {
|
|
212
|
-
logger.error(`安装插件 ${pluginName} 失败:`, error);
|
|
213
|
-
throw error;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* 移除插件
|
|
218
|
-
* 修复: 现在会读取配置并清理注入的命令文件
|
|
219
|
-
*/
|
|
220
|
-
async removePlugin(pluginName) {
|
|
221
|
-
try {
|
|
222
|
-
logger.info(`移除插件: ${pluginName}`);
|
|
223
|
-
const pluginPath = path.join(this.pluginsDir, pluginName);
|
|
224
|
-
// 先读取配置,获取需要清理的命令和 Skills
|
|
225
|
-
const configPath = path.join(pluginPath, 'config.yaml');
|
|
226
|
-
const config = await PluginValidator.parseConfig(configPath);
|
|
227
|
-
// 清理注入的命令文件
|
|
228
|
-
if (config?.commands && config.commands.length > 0) {
|
|
229
|
-
await this.cleanupCommands(config.commands);
|
|
230
|
-
}
|
|
231
|
-
// 清理注入的 Skills
|
|
232
|
-
const pluginSkillsDir = path.join(this.skillsDir, pluginName);
|
|
233
|
-
if (await fs.pathExists(pluginSkillsDir)) {
|
|
234
|
-
await fs.remove(pluginSkillsDir);
|
|
235
|
-
}
|
|
236
|
-
// 删除插件目录
|
|
237
|
-
await fs.remove(pluginPath);
|
|
238
|
-
// 更新注册表
|
|
239
|
-
await this.registry.load();
|
|
240
|
-
this.registry.remove(pluginName);
|
|
241
|
-
await this.registry.save();
|
|
242
|
-
logger.success(`插件 ${pluginName} 移除成功`);
|
|
243
|
-
}
|
|
244
|
-
catch (error) {
|
|
245
|
-
logger.error(`移除插件 ${pluginName} 失败:`, error);
|
|
246
|
-
throw error;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* 检查插件是否已安装
|
|
251
|
-
*/
|
|
252
|
-
async isPluginInstalled(name) {
|
|
253
|
-
await this.registry.load();
|
|
254
|
-
return this.registry.has(name);
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* 远程安装插件(支持 npm/GitHub/local)
|
|
258
|
-
*/
|
|
259
|
-
async installRemotePlugin(input) {
|
|
260
|
-
const identifier = parsePluginIdentifier(input);
|
|
261
|
-
// 检查是否已安装
|
|
262
|
-
if (await this.isPluginInstalled(identifier.name)) {
|
|
263
|
-
throw new PluginAlreadyInstalledError(identifier.name);
|
|
264
|
-
}
|
|
265
|
-
logger.info(`安装插件: ${input}`);
|
|
266
|
-
let installedVersion;
|
|
267
|
-
let pluginPath;
|
|
268
|
-
// 根据类型选择安装器
|
|
269
|
-
switch (identifier.type) {
|
|
270
|
-
case 'npm': {
|
|
271
|
-
const result = await this.npmInstaller.install(identifier, this.pluginsDir);
|
|
272
|
-
installedVersion = result.version;
|
|
273
|
-
pluginPath = result.pluginPath;
|
|
274
|
-
break;
|
|
275
|
-
}
|
|
276
|
-
case 'github': {
|
|
277
|
-
const result = await this.githubInstaller.install(identifier, this.pluginsDir);
|
|
278
|
-
installedVersion = result.version;
|
|
279
|
-
pluginPath = result.pluginPath;
|
|
280
|
-
break;
|
|
281
|
-
}
|
|
282
|
-
case 'local': {
|
|
283
|
-
const result = await this.localInstaller.install(identifier, this.pluginsDir);
|
|
284
|
-
installedVersion = result.version;
|
|
285
|
-
pluginPath = result.pluginPath;
|
|
286
|
-
break;
|
|
287
|
-
}
|
|
288
|
-
default:
|
|
289
|
-
throw new PluginInstallError(identifier.name, identifier.type, '不支持的插件来源');
|
|
290
|
-
}
|
|
291
|
-
// 验证插件
|
|
292
|
-
const validation = await PluginValidator.validate(pluginPath);
|
|
293
|
-
if (!validation.valid) {
|
|
294
|
-
await fs.remove(pluginPath);
|
|
295
|
-
throw new PluginValidationError(identifier.name, validation.errors, validation.warnings);
|
|
296
|
-
}
|
|
297
|
-
if (validation.warnings.length > 0) {
|
|
298
|
-
for (const warning of validation.warnings) {
|
|
299
|
-
logger.warn(warning);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
// 加载插件(注入 commands 和 skills)
|
|
303
|
-
await this.loadPlugin(identifier.name);
|
|
304
|
-
// 读取配置获取 commands/skills 信息
|
|
305
|
-
const configPath = path.join(pluginPath, 'config.yaml');
|
|
306
|
-
const config = await PluginValidator.parseConfig(configPath);
|
|
307
|
-
// 更新注册表
|
|
308
|
-
await this.registry.load();
|
|
309
|
-
const metadata = {
|
|
310
|
-
name: identifier.name,
|
|
311
|
-
version: installedVersion,
|
|
312
|
-
source: identifier.type,
|
|
313
|
-
installedAt: new Date().toISOString(),
|
|
314
|
-
path: `plugins/${identifier.name}`,
|
|
315
|
-
registry: identifier.type === 'npm' ? 'https://registry.npmjs.org' : undefined,
|
|
316
|
-
repository: identifier.repository,
|
|
317
|
-
commands: config?.commands?.map(c => c.id),
|
|
318
|
-
skills: config?.skills?.map(s => s.id),
|
|
319
|
-
};
|
|
320
|
-
this.registry.add(metadata);
|
|
321
|
-
await this.registry.save();
|
|
322
|
-
logger.success(`插件 ${identifier.name}@${installedVersion} 安装成功`);
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* 更新插件
|
|
326
|
-
*/
|
|
327
|
-
async updatePlugin(name) {
|
|
328
|
-
await this.registry.load();
|
|
329
|
-
const plugin = this.registry.find(name);
|
|
330
|
-
if (!plugin) {
|
|
331
|
-
throw new PluginNotFoundError(name);
|
|
332
|
-
}
|
|
333
|
-
// 移除旧版本
|
|
334
|
-
await this.removePlugin(name);
|
|
335
|
-
// 重新安装
|
|
336
|
-
const input = plugin.source === 'npm'
|
|
337
|
-
? plugin.name
|
|
338
|
-
: plugin.repository || plugin.name;
|
|
339
|
-
await this.installRemotePlugin(input);
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* 获取已安装插件的注册表信息
|
|
343
|
-
*/
|
|
344
|
-
async getRegistry() {
|
|
345
|
-
await this.registry.load();
|
|
346
|
-
return this.registry;
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
//# sourceMappingURL=manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/plugins/manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,O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CAAC,CAAC;QACtC,CAAC;QAED,QAAQ;QACR,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAE9B,OAAO;QACP,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,KAAK,KAAK;YACnC,CAAC,CAAC,MAAM,CAAC,IAAI;YACb,CAAC,CAAC,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC;QAErC,MAAM,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW;QACf,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 插件注册表管理
|
|
3
|
-
*
|
|
4
|
-
* 独立管理 .specify/plugins.json 的读写,
|
|
5
|
-
* 从 manager.ts 中拆出以实现职责单一。
|
|
6
|
-
*/
|
|
7
|
-
import { PluginRegistryData, PluginMetadata } from './types.js';
|
|
8
|
-
export declare class PluginRegistry {
|
|
9
|
-
private registryPath;
|
|
10
|
-
private data;
|
|
11
|
-
private loaded;
|
|
12
|
-
constructor(registryPath: string);
|
|
13
|
-
/**
|
|
14
|
-
* 从磁盘加载注册表
|
|
15
|
-
*/
|
|
16
|
-
load(): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* 保存注册表到磁盘
|
|
19
|
-
*/
|
|
20
|
-
save(): Promise<void>;
|
|
21
|
-
/**
|
|
22
|
-
* 添加插件元数据
|
|
23
|
-
*/
|
|
24
|
-
add(metadata: PluginMetadata): void;
|
|
25
|
-
/**
|
|
26
|
-
* 移除插件
|
|
27
|
-
* 返回 true 表示成功移除,false 表示未找到
|
|
28
|
-
*/
|
|
29
|
-
remove(name: string): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* 查找插件
|
|
32
|
-
*/
|
|
33
|
-
find(name: string): PluginMetadata | undefined;
|
|
34
|
-
/**
|
|
35
|
-
* 检查插件是否存在
|
|
36
|
-
*/
|
|
37
|
-
has(name: string): boolean;
|
|
38
|
-
/**
|
|
39
|
-
* 列出所有插件
|
|
40
|
-
*/
|
|
41
|
-
list(): PluginMetadata[];
|
|
42
|
-
/**
|
|
43
|
-
* 获取原始注册表数据
|
|
44
|
-
*/
|
|
45
|
-
getData(): PluginRegistryData;
|
|
46
|
-
private ensureLoaded;
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/plugins/registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAQhE,qBAAa,cAAc;IACzB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,IAAI,CAAqB;IACjC,OAAO,CAAC,MAAM,CAAkB;gBAEpB,YAAY,EAAE,MAAM;IAKhC;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAmB3B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAY3B;;OAEG;IACH,GAAG,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAOnC;;;OAGG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAO7B;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAK9C;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAK1B;;OAEG;IACH,IAAI,IAAI,cAAc,EAAE;IAKxB;;OAEG;IACH,OAAO,IAAI,kBAAkB;IAK7B,OAAO,CAAC,YAAY;CAKrB"}
|