✨ feat(vscode): 审查通过写入工单状态并在卡片上区分

This commit is contained in:
cruldra committed 2026-10-03 03:22:20 +08:00
1 parent ac1b7ed641
commit 177e75910e
21 files changed
+203 -10

No files matched your search

@@ -1,9 +1,11 @@
import { readFileSync } from 'node:fs'
import * as path from 'node:path'
import { describe, expect, it } from 'vitest'
import { PREVIOUS_DEFAULT_REVIEW_PROMPT } from './previousReviewPrompt'
import {
composeBrainstormTemplate,
planPromptMigration,
planReviewPromptMigration,
PROMPT_TEMPLATE_VERSION,
splitIfBlock,
upgradePlaceholders,
@@ -147,3 +149,43 @@ describe('planPromptMigration', () => {
expect(merged).toContain('工单已有原型插件 {{prototypeFile}}')
})
})
describe('planReviewPromptMigration', () => {
const nextDefault = readFileSync(
path.resolve(__dirname, '../../prompts/review.md'),
'utf-8',
)
it('和改之前的默认一样时,整段换成现在的文件', () => {
const result = planReviewPromptMigration(
PREVIOUS_DEFAULT_REVIEW_PROMPT,
PREVIOUS_DEFAULT_REVIEW_PROMPT,
nextDefault,
)
expect(result).not.toBeNull()
expect(result!.prompt).toBe(nextDefault)
expect(result!.prompt).toContain('{"reviewPassed":true}')
expect(result!.notes[0]?.message).toContain('旧版默认')
})
it('用户改过、还没有 reviewPassed 时,只把审查结论接到末尾', () => {
const custom = '先看 diff,再写意见。\n不要跑无关命令。\n'
const result = planReviewPromptMigration(custom, PREVIOUS_DEFAULT_REVIEW_PROMPT, nextDefault)
expect(result).not.toBeNull()
expect(result!.prompt.startsWith('先看 diff,再写意见。\n不要跑无关命令。\n\n## 审查结论\n')).toBe(true)
expect(result!.prompt).toContain('reviewPassed')
expect(result!.prompt).toContain('小建议不算不通过')
expect(result!.prompt).not.toContain('## 严禁')
expect(result!.prompt).not.toContain('tea pulls')
})
it('已经写了 reviewPassed 的不改', () => {
const custom = '我自己的审查。\nreviewPassed 我写过了。\n'
expect(planReviewPromptMigration(custom, PREVIOUS_DEFAULT_REVIEW_PROMPT, nextDefault)).toBeNull()
})
it('没存审查提示词时不改', () => {
expect(planReviewPromptMigration('', PREVIOUS_DEFAULT_REVIEW_PROMPT, nextDefault)).toBeNull()
expect(planReviewPromptMigration(undefined, PREVIOUS_DEFAULT_REVIEW_PROMPT, nextDefault)).toBeNull()
})
})