🔧 fix(vscode): worktree 目录配置改用插件自带设置面板,撤销 VS Code 原生配置

上一版误把 worktree 目录模板注册成 VS Code 原生设置(contributes.configuration
+ workspace.getConfiguration),但本插件有自己的设置面板(SettingsModal,存 globalState)。
改为:
- Settings 新增 worktreeDirectory 字段(默认 ~/Sources/worktree/$project_name/$feature_name,
  留空回退默认),贯穿 store/handler/两端 messages/useIssues/App/SettingsModal
- SettingsModal「钩子」分组新增「工作树目录」输入项,走既有 save/load 流程
- handleImplement 改从 getSettings(panel.context).worktreeDirectory 读模板
- 删除 package.json 的 contributes.configuration(meta.ts 为 gitignore 生成物,已本地还原)

deriveSlug / resolveWorktreeDir / ~ 展开 / 绝对路径 / feature/<slug> 逻辑不变。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-24 02:56:33 +08:00
co-authored by Claude Opus 4.7
parent 11ea6b345c
commit 9a69aeed48
10 changed files with 74 additions and 13 deletions
+15
View File
@@ -86,6 +86,14 @@ export interface Settings {
* disabled because there's nothing to fast-forward.
*/
autoBuildBranch: string
/**
* Directory template for the worktree created when implementing a plan.
* Placeholders: `$project_root` (workspace abs path), `$project_name` (its
* basename), `$feature_name` (the spec/plan slug). A leading `~` expands to
* the user's home dir. Empty string means "use the default
* `~/Sources/worktree/$project_name/$feature_name`".
*/
worktreeDirectory: string
/**
* Path to a user-provided shell script that runs *after* the extension
* creates a worktree via `git worktree add`. Empty string means use the
@@ -157,6 +165,7 @@ function defaults(ctx: ExtensionContext): Settings {
reviewPrompt: readDefaultPrompt(ctx.extensionPath, 'review'),
devBranch: 'main',
autoBuildBranch: '',
worktreeDirectory: '~/Sources/worktree/$project_name/$feature_name',
worktreePostCreateScript: '',
worktreePreRemoveScript: '',
implTabPreCreateScript: '',
@@ -200,6 +209,11 @@ export function getSettings(ctx: ExtensionContext): Settings {
const autoBuildBranch = typeof stored.autoBuildBranch === 'string'
? stored.autoBuildBranch
: base.autoBuildBranch
// worktree dir template: empty/blank means "use the default template", so
// fall back to base (unlike the hook paths below, where '' is meaningful).
const worktreeDirectory = typeof stored.worktreeDirectory === 'string' && stored.worktreeDirectory.length > 0
? stored.worktreeDirectory
: base.worktreeDirectory
// worktree hook script paths: '' is meaningful (= "use default
// .spx/worktree-*.sh"), so don't coerce. Non-string legacy values fall
// back to ''. The hook runner resolves '' to the default at execution
@@ -238,6 +252,7 @@ export function getSettings(ctx: ExtensionContext): Settings {
reviewPrompt,
devBranch,
autoBuildBranch,
worktreeDirectory,
worktreePostCreateScript,
worktreePreRemoveScript,
implTabPreCreateScript,