🔧 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:
@@ -840,6 +840,7 @@ export class KanbanWebviewPanel {
|
||||
reviewPrompt: s.reviewPrompt,
|
||||
devBranch: s.devBranch,
|
||||
autoBuildBranch: s.autoBuildBranch,
|
||||
worktreeDirectory: s.worktreeDirectory,
|
||||
worktreePostCreateScript: s.worktreePostCreateScript,
|
||||
worktreePreRemoveScript: s.worktreePreRemoveScript,
|
||||
implTabPreCreateScript: s.implTabPreCreateScript,
|
||||
@@ -899,6 +900,7 @@ export class KanbanWebviewPanel {
|
||||
reviewPrompt: s.reviewPrompt,
|
||||
devBranch: s.devBranch,
|
||||
autoBuildBranch: s.autoBuildBranch,
|
||||
worktreeDirectory: s.worktreeDirectory,
|
||||
worktreePostCreateScript: s.worktreePostCreateScript,
|
||||
worktreePreRemoveScript: s.worktreePreRemoveScript,
|
||||
implTabPreCreateScript: s.implTabPreCreateScript,
|
||||
|
||||
@@ -684,8 +684,9 @@ export async function handleImplement(
|
||||
// worktree 目录名用 spec/plan 的 slug(可读、与 spec 目录同名),不再用 planFile 的 hash。
|
||||
const slug = deriveSlug(planFile)
|
||||
const branch = `feature/${slug}`
|
||||
// 目录走 superpowers.worktreeDirectory 模板(设置里可改),默认 ~/Sources/worktree/<项目>/<slug>。
|
||||
const worktreeTemplate = workspace.getConfiguration('superpowers').get<string>('worktreeDirectory')
|
||||
// 目录模板取自插件自己的设置面板(globalState),不是 VS Code 原生配置;
|
||||
// 留空时回退到默认 ~/Sources/worktree/<项目>/<slug>。
|
||||
const worktreeTemplate = getSettings(panel.context).worktreeDirectory
|
||||
|| '~/Sources/worktree/$project_name/$feature_name'
|
||||
const worktreePath = resolveWorktreeDir(worktreeTemplate, workspaceRoot, slug)
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ export async function handleSettingsSave(panel: KanbanWebviewPanel, payload: {
|
||||
reviewPrompt: string
|
||||
devBranch: string
|
||||
autoBuildBranch: string
|
||||
worktreeDirectory: string
|
||||
worktreePostCreateScript: string
|
||||
worktreePreRemoveScript: string
|
||||
implTabPreCreateScript: string
|
||||
@@ -43,6 +44,9 @@ export async function handleSettingsSave(panel: KanbanWebviewPanel, payload: {
|
||||
const trimmedYtToken = payload.youtrackToken.trim()
|
||||
const trimmedDevBranch = payload.devBranch.trim()
|
||||
const trimmedAutoBuildBranch = payload.autoBuildBranch.trim()
|
||||
// worktree dir template: '' = "use default", so don't preserve blanks
|
||||
// specially — getSettings falls back to the default at read time.
|
||||
const trimmedWorktreeDir = payload.worktreeDirectory.trim()
|
||||
// Hook script paths: keep '' meaningful (= "use default
|
||||
// .spx/*.sh"). Just strip whitespace.
|
||||
const trimmedPostCreate = payload.worktreePostCreateScript.trim()
|
||||
@@ -71,6 +75,7 @@ export async function handleSettingsSave(panel: KanbanWebviewPanel, payload: {
|
||||
reviewPrompt: payload.reviewPrompt || prev.reviewPrompt,
|
||||
devBranch: trimmedDevBranch || prev.devBranch,
|
||||
autoBuildBranch: trimmedAutoBuildBranch,
|
||||
worktreeDirectory: trimmedWorktreeDir || prev.worktreeDirectory,
|
||||
worktreePostCreateScript: trimmedPostCreate,
|
||||
worktreePreRemoveScript: trimmedPreRemove,
|
||||
implTabPreCreateScript: trimmedImplPre,
|
||||
@@ -89,6 +94,7 @@ export async function handleSettingsSave(panel: KanbanWebviewPanel, payload: {
|
||||
// fallback at read time.
|
||||
devBranch: trimmedDevBranch,
|
||||
autoBuildBranch: trimmedAutoBuildBranch,
|
||||
worktreeDirectory: trimmedWorktreeDir,
|
||||
worktreePostCreateScript: trimmedPostCreate,
|
||||
worktreePreRemoveScript: trimmedPreRemove,
|
||||
implTabPreCreateScript: trimmedImplPre,
|
||||
@@ -168,6 +174,7 @@ export async function handleEditSettingsRequest(panel: KanbanWebviewPanel): Prom
|
||||
reviewPrompt: s.reviewPrompt,
|
||||
devBranch: s.devBranch,
|
||||
autoBuildBranch: s.autoBuildBranch,
|
||||
worktreeDirectory: s.worktreeDirectory,
|
||||
worktreePostCreateScript: s.worktreePostCreateScript,
|
||||
worktreePreRemoveScript: s.worktreePreRemoveScript,
|
||||
implTabPreCreateScript: s.implTabPreCreateScript,
|
||||
|
||||
@@ -61,6 +61,7 @@ export type ExtensionToWebview
|
||||
reviewPrompt: string
|
||||
devBranch: string
|
||||
autoBuildBranch: string
|
||||
worktreeDirectory: string
|
||||
worktreePostCreateScript: string
|
||||
worktreePreRemoveScript: string
|
||||
implTabPreCreateScript: string
|
||||
@@ -115,6 +116,7 @@ export type WebviewToExtension
|
||||
reviewPrompt: string
|
||||
devBranch: string
|
||||
autoBuildBranch: string
|
||||
worktreeDirectory: string
|
||||
worktreePostCreateScript: string
|
||||
worktreePreRemoveScript: string
|
||||
implTabPreCreateScript: string
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user