♻️ refactor(vscode): 续聊里的原型段落搬进模板文件

那段正文原先拼在 prompts.ts 里,设置面板看不到也改不了。现在落到
prompts/brainstorm-continue-prototype.md,面板「提示词」组多一项「续聊·原型段落」,
占位符 {prototypeFile} / {issueNumber} / {prototypeSessionId};取值为空的整行会被
删掉,免得留下半句没有值的说明。

同时把措辞收紧:原型改动只能 ListAgents + SendMessage 给已开着的原型会话,
点名禁止派子代理 / fork 分身 / 自己动插件代码。

Claude-Session: https://claude.ai/code/session_01Kgmb1LvrPmFX3NoUDB4zZC
This commit is contained in:
cruldra committed 2026-09-15 00:28:58 +08:00
1 parent f9537abf97
commit 43a0bf6bad
10 files changed
+84 -17

No files matched your search

+17 -16
View File
@@ -38,35 +38,36 @@ export function getBrainstormContinuePrompt(
// id (e.g. LXF-12) so the cc agent references the real issue (readable via
// `opencli yt issues show <id>`), not a non-existent gitea number.
const out = tpl.split('{issueNumber}').join(vars.issueRef ?? String(vars.issueNumber))
return fillPrototypeRef(out, vars.prototypeFile, {
return fillPrototypeRef(ctx, out, vars.prototypeFile, {
issueNumber: vars.issueRef ?? String(vars.issueNumber),
prototypeSessionId: vars.prototypeSessionId,
})
}
/**
* `{prototypeRef}` 在模板里独占一段:有原型插件就填一段「先读它」的交代,
* 没有就连同前后空行一起抹掉——否则模板里会留下一个空洞段落。
* `{prototypeRef}` 在模板里独占一段:工单挂了原型插件就填进设置里的「原型段落」
* 模板,没挂就连同前后空行一起抹掉——否则模板里会留下一个空洞段落。
*
* 段落模板里凡是某个占位符取值为空的整行直接删掉(如没有原型会话 id 时那条
* 「原型会话 id:」),免得留下半句没有值的说明。
*/
function fillPrototypeRef(
ctx: ExtensionContext,
tpl: string,
prototypeFile: string | undefined,
ctx: { issueNumber: string, prototypeSessionId: string | undefined },
vars: { issueNumber: string, prototypeSessionId: string | undefined },
): string {
if (!prototypeFile)
return tpl.replace(/\n*\{prototypeRef\}\n*/g, '\n\n').trimEnd()
const idHint = ctx.prototypeSessionId
? `,会话 id ${ctx.prototypeSessionId}(它 transcript 的文件名就是这个 id)`
: ''
const lines = [
`工单已有原型插件 ${prototypeFile},先读它了解已经定下来的界面和交互,在此基础上只对齐还不明确的地方,不要从零重画。`,
// 原型改动必须回到那个已经开着的原型会话去做:它手里有整套画图上下文。
// 派子代理 / fork 分身都是另起一个没上下文的新实例,画出来的东西和已有
// 原型对不上,还会和它抢着改同一份插件代码。
`**原型要改时只能交给本工单已经开着的原型会话**(终端名 issue-${ctx.issueNumber}-原型${idHint}):先 ListAgents 找到它,再 SendMessage 说清要改哪块、为什么改、改完怎么算对,然后等它回报。`,
`严禁用下面这些方式代替:Agent 工具派子代理 / fork 分身 / 后台代理,自己动插件代码,翻 git log 猜会话。ListAgents 里没有这个原型会话就**停下告诉我**去工单面板的「原型会话id」行点 ▶ 起一个,不要自作主张换别的做法。`,
]
return tpl.split('{prototypeRef}').join(lines.join('\n\n'))
const values: Record<string, string> = {
prototypeFile,
issueNumber: vars.issueNumber,
prototypeSessionId: vars.prototypeSessionId ?? '',
}
const para = getSettings(ctx).prototypeRefPrompt.split('\n').filter(line => !Object.entries(values).some(([k, v]) => v === '' && line.includes(`{${k}}`))).join('\n').replace(/\{(prototypeFile|issueNumber|prototypeSessionId)\}/g, (_m, k: string) => values[k]).trim()
return tpl.split('{prototypeRef}').join(para)
}
export function getImplementPlanPrompt(ctx: ExtensionContext, vars: { planFile: string, issueNumber: number, issueRef?: string }): string {