✨ feat(vscode): 新增第五种工单会话「原型会话」

照测试会话那条链路补一份 prototype:

- 消息与路由:session/start-prototype、session/resume-prototype、
  issue/update-prototype-profile-path,都进只读门禁
- 会话:handleStartPrototypeSession / handleResumePrototypeSession,
  终端名 issue-N-原型;cwd 有 worktree 用 worktree、没有退主仓库根
  (原 resolveTestSessionCwd 改名 resolveWorktreeOrRootCwd 两种会话共用)
- 不要求有 PR,任何阶段都能起;前置工单锁仍然拦
- 提示词:新增 prompts/prototype.md,设置里可改,占位符 {issueNumber}
- profile:工单级 prototypeProfilePath > 设置里的原型默认 profile >
  内置默认,与其它会话互不回退
- 状态字段 prototypeSessionId / prototypeProfilePath / prototypeTabOpen
  贯通 gitea、youtrack、本机 state 与移交包
- 详情面板加「原型会话id」「原型配置文件」两行,设置面板加对应两项

Claude-Session: https://claude.ai/code/session_01Kgmb1LvrPmFX3NoUDB4zZC
This commit is contained in:
cruldra committed 2026-09-14 10:20:30 +08:00
1 parent 3fff796a61
commit b62e58d739
27 files changed
+760 -50

No files matched your search

+41 -3
View File
@@ -44,6 +44,7 @@ export interface SettingsValues {
autoReview: boolean
reviewPrompt: string
testPrompt: string
prototypePrompt: string
devBranch: string
releaseBranchPrefix: string
jenkinsJob: string
@@ -59,6 +60,7 @@ export interface SettingsValues {
defaultBrainstormProfilePath: string
defaultImplementProfilePath: string
defaultTestProfilePath: string
defaultPrototypeProfilePath: string
conflictResolutionProfilePath: string
commitProfilePath: string
prDiffSummaryProfilePath: string
@@ -84,6 +86,7 @@ export interface SettingsOverlayState {
autoReview: boolean
reviewPrompt: string
testPrompt: string
prototypePrompt: string
devBranch: string
releaseBranchPrefix: string
jenkinsJob: string
@@ -99,6 +102,7 @@ export interface SettingsOverlayState {
defaultBrainstormProfilePath: string
defaultImplementProfilePath: string
defaultTestProfilePath: string
defaultPrototypeProfilePath: string
conflictResolutionProfilePath: string
commitProfilePath: string
prDiffSummaryProfilePath: string
@@ -192,6 +196,8 @@ export interface UseIssuesResult {
startReviewSession: (issueNumber: number) => void
startTestSession: (issueNumber: number) => void
resumeTestSession: (sessionId: string, issueNumber: number, cwd?: string) => void
startPrototypeSession: (issueNumber: number) => void
resumePrototypeSession: (sessionId: string, issueNumber: number, cwd?: string) => void
focusSession: (issueNumber: number) => void
openFile: (path: string) => void
implement: (issueNumber: number, planFile: string, profilePath?: string, sessionId?: string) => void
@@ -213,7 +219,7 @@ export interface UseIssuesResult {
* Dispose the matching session terminal tab. Extension reacts via
* onDidCloseTerminal and clears `*TabOpen` so the X button disappears.
*/
closeSessionTab: (issueNumber: number, kind: 'brainstorm' | 'implement' | 'review' | 'test') => void
closeSessionTab: (issueNumber: number, kind: 'brainstorm' | 'implement' | 'review' | 'test' | 'prototype') => void
/**
* Spawn a fresh "规划" cc tab for an existing issue whose sessionId is
* still empty. Extension 用工单级 brainstormProfilePath(空 = 默认),
@@ -242,6 +248,11 @@ export interface UseIssuesResult {
* postMessage 持久化到 state JSON。失败时扩展端 push `issue/patch` 回滚。
*/
updateIssueTestProfilePath: (issueNumber: number, testProfilePath: string) => void
/**
* 覆盖该工单原型会话专用的 Claude 配置文件,乐观更新本地 state 后
* postMessage 持久化到 state JSON。失败时扩展端 push `issue/patch` 回滚。
*/
updateIssuePrototypeProfilePath: (issueNumber: number, prototypeProfilePath: string) => void
logs: LogEntry[]
fetchLogs: () => void
clearLogs: () => void
@@ -424,6 +435,7 @@ export function useIssues(): UseIssuesResult {
autoReview: values.autoReview,
reviewPrompt: values.reviewPrompt,
testPrompt: values.testPrompt,
prototypePrompt: values.prototypePrompt,
devBranch: values.devBranch,
releaseBranchPrefix: values.releaseBranchPrefix,
jenkinsJob: values.jenkinsJob,
@@ -439,6 +451,7 @@ export function useIssues(): UseIssuesResult {
defaultBrainstormProfilePath: values.defaultBrainstormProfilePath,
defaultImplementProfilePath: values.defaultImplementProfilePath,
defaultTestProfilePath: values.defaultTestProfilePath,
defaultPrototypeProfilePath: values.defaultPrototypeProfilePath,
conflictResolutionProfilePath: values.conflictResolutionProfilePath,
commitProfilePath: values.commitProfilePath,
prDiffSummaryProfilePath: values.prDiffSummaryProfilePath,
@@ -562,6 +575,15 @@ export function useIssues(): UseIssuesResult {
postMessage({ type: 'session/resume-test', sessionId, issueNumber, cwd })
}, [markSessionTabPending])
const startPrototypeSession = useCallback((issueNumber: number): void => {
postMessage({ type: 'session/start-prototype', issueNumber })
}, [])
const resumePrototypeSession = useCallback((sessionId: string, issueNumber: number, cwd?: string): void => {
markSessionTabPending(sessionId)
postMessage({ type: 'session/resume-prototype', sessionId, issueNumber, cwd })
}, [markSessionTabPending])
const openFile = useCallback((path: string): void => {
postMessage({ type: 'editor/open-file', path })
}, [])
@@ -641,7 +663,7 @@ export function useIssues(): UseIssuesResult {
}, [])
const closeSessionTab = useCallback(
(issueNumber: number, kind: 'brainstorm' | 'implement' | 'review' | 'test'): void => {
(issueNumber: number, kind: 'brainstorm' | 'implement' | 'review' | 'test' | 'prototype'): void => {
postMessage({ type: 'session/close-tab', issueNumber, kind })
},
[],
@@ -734,6 +756,20 @@ export function useIssues(): UseIssuesResult {
postMessage({ type: 'issue/update-test-profile-path', issueNumber, testProfilePath })
}, [])
const updateIssuePrototypeProfilePath = useCallback((issueNumber: number, prototypeProfilePath: string): void => {
setState((prev) => {
if (prev.status !== 'ready')
return prev
return {
status: 'ready',
issues: prev.issues.map(i =>
i.number === issueNumber ? { ...i, prototypeProfilePath } : i,
),
}
})
postMessage({ type: 'issue/update-prototype-profile-path', issueNumber, prototypeProfilePath })
}, [])
const fetchLogs = useCallback((): void => {
postMessage({ type: 'logs/fetch' })
}, [])
@@ -890,6 +926,7 @@ export function useIssues(): UseIssuesResult {
autoReview: msg.autoReview,
reviewPrompt: msg.reviewPrompt,
testPrompt: msg.testPrompt,
prototypePrompt: msg.prototypePrompt,
devBranch: msg.devBranch,
releaseBranchPrefix: msg.releaseBranchPrefix,
jenkinsJob: msg.jenkinsJob,
@@ -905,6 +942,7 @@ export function useIssues(): UseIssuesResult {
defaultBrainstormProfilePath: msg.defaultBrainstormProfilePath,
defaultImplementProfilePath: msg.defaultImplementProfilePath,
defaultTestProfilePath: msg.defaultTestProfilePath,
defaultPrototypeProfilePath: msg.defaultPrototypeProfilePath,
conflictResolutionProfilePath: msg.conflictResolutionProfilePath,
commitProfilePath: msg.commitProfilePath,
prDiffSummaryProfilePath: msg.prDiffSummaryProfilePath,
@@ -999,5 +1037,5 @@ export function useIssues(): UseIssuesResult {
return cleanup
}, [clearPrDiffSummaryRunning, markHandoffRunning])
return { state, settings, avatars, isSessionTabPending, globalAutoReview, youtrackConfigured, importYouTrack, toasts, profiles, setIssues, refresh, refreshing, scope, toggleScope, saveSettings, listYouTrackProjects, youtrackProjects, dismissSettings, requestEditAuth, createIssue, dismissToast, openUrl, resumeSession, resumeReviewSession, startReviewSession, startTestSession, resumeTestSession, focusSession, openFile, implement, generatePrDiffSummary, isPrDiffSummaryRunning, openPr, openWorktree, deleteWorktree, mergeBranch, deleteIssue, closeIssue, closeSessionTab, continueBrainstorm, changeColumn, setDependency, clearDependency, updateIssueAutoReview, updateIssueProfilePath, updateIssueBrainstormProfilePath, clearBrainstormSession, updateIssueTestProfilePath, logs, fetchLogs, clearLogs, pendingSelectId, clearPendingSelect, commitRunning, runCommit, hasChanges, release, runRelease, cherryPick, dismissCherryPick, confirmCherryPick, envLocked, envFileCount, envLockRunning, envLockTitle, toggleEnvLock, me, handoffUsers, requestHandoffUsers, startHandoff, acceptHandoff, isHandoffRunning }
return { state, settings, avatars, isSessionTabPending, globalAutoReview, youtrackConfigured, importYouTrack, toasts, profiles, setIssues, refresh, refreshing, scope, toggleScope, saveSettings, listYouTrackProjects, youtrackProjects, dismissSettings, requestEditAuth, createIssue, dismissToast, openUrl, resumeSession, resumeReviewSession, startReviewSession, startTestSession, resumeTestSession, startPrototypeSession, resumePrototypeSession, focusSession, openFile, implement, generatePrDiffSummary, isPrDiffSummaryRunning, openPr, openWorktree, deleteWorktree, mergeBranch, deleteIssue, closeIssue, closeSessionTab, continueBrainstorm, changeColumn, setDependency, clearDependency, updateIssueAutoReview, updateIssueProfilePath, updateIssueBrainstormProfilePath, clearBrainstormSession, updateIssueTestProfilePath, updateIssuePrototypeProfilePath, logs, fetchLogs, clearLogs, pendingSelectId, clearPendingSelect, commitRunning, runCommit, hasChanges, release, runRelease, cherryPick, dismissCherryPick, confirmCherryPick, envLocked, envFileCount, envLockRunning, envLockTitle, toggleEnvLock, me, handoffUsers, requestHandoffUsers, startHandoff, acceptHandoff, isHandoffRunning }
}