✨ feat(vscode): 审查通过写入工单状态并在卡片上区分
This commit is contained in:
1 parent
ac1b7ed641
commit
177e75910e
21 files changed
+203
-10
No files matched your search
@@ -188,3 +188,52 @@ export function planPromptMigration(
|
||||
next.promptTemplateVersion = PROMPT_TEMPLATE_VERSION
|
||||
return { blob: next, notes }
|
||||
}
|
||||
|
||||
function normalizePrompt(text: string): string {
|
||||
return text.replace(/\r\n/g, '\n').trim()
|
||||
}
|
||||
|
||||
/** 新版审查提示词里「审查结论」那一节,到下一个同级标题为止。 */
|
||||
export function reviewConclusionSection(nextDefault: string): string | null {
|
||||
const normalized = nextDefault.replace(/\r\n/g, '\n')
|
||||
const heading = '## 审查结论'
|
||||
const start = normalized.indexOf(heading)
|
||||
if (start < 0)
|
||||
return null
|
||||
const rest = normalized.slice(start)
|
||||
const relative = rest.slice(heading.length).search(/\n## /)
|
||||
const section = relative < 0 ? rest : rest.slice(0, heading.length + relative)
|
||||
const trimmed = section.trim()
|
||||
return trimmed.length > 0 ? trimmed : null
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置里已经存了一份审查提示词时:和改之前的默认一样就整段换成新文件;
|
||||
* 用户改过、且还没有 reviewPassed,只把「审查结论」接到末尾。
|
||||
* 返回 null 表示不用写盘。
|
||||
*/
|
||||
export function planReviewPromptMigration(
|
||||
stored: unknown,
|
||||
previousDefault: string,
|
||||
nextDefault: string,
|
||||
): { prompt: string, notes: MigrationNote[] } | null {
|
||||
if (typeof stored !== 'string' || stored.length === 0)
|
||||
return null
|
||||
if (normalizePrompt(stored) === normalizePrompt(previousDefault)) {
|
||||
if (normalizePrompt(nextDefault) === normalizePrompt(previousDefault))
|
||||
return null
|
||||
return {
|
||||
prompt: nextDefault,
|
||||
notes: [{ level: 'info', message: '审查提示词与旧版默认一致,已换成带审查结论的新版' }],
|
||||
}
|
||||
}
|
||||
if (stored.includes('reviewPassed'))
|
||||
return null
|
||||
const section = reviewConclusionSection(nextDefault)
|
||||
if (!section)
|
||||
return null
|
||||
return {
|
||||
prompt: `${stored.replace(/\s+$/, '')}\n\n${section}\n`,
|
||||
notes: [{ level: 'info', message: '审查提示词末尾已追加「审查结论」,其余段落未改' }],
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user