From 176f02a00c87622de03eabde77d81c2a8dc60a3c Mon Sep 17 00:00:00 2001 From: qyh15 Date: Wed, 25 Nov 2026 10:32:59 +0800 Subject: [PATCH] =?UTF-8?q?feat(grill-me):=20=E5=A2=9E=E5=8A=A0=E4=B8=9E?= =?UTF-8?q?=E7=9B=B8=E8=87=AA=E5=8A=A8=E9=9C=80=E6=B1=82=E6=BE=84=E6=B8=85?= =?UTF-8?q?=E8=A7=84=E5=88=99=E4=B8=8E=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 丞相仅在需求存在关键歧义时自动加载 grilling 追问,结果回写同一 R-xxx;grill-me 保留用户手动入口。新增提示词契约与需求回写专项测试,全量 97 项通过。 --- .dsh/skills/NOTICE.md | 32 +++++++ .dsh/skills/grill-me/SKILL.md | 7 ++ .dsh/skills/grill-me/agents/openai.yaml | 5 ++ .dsh/skills/grilling/SKILL.md | 30 +++++++ .dsh/skills/grilling/agents/openai.yaml | 3 + sansheng/README.md | 9 +- sansheng/src/host/prompt.js | 5 ++ sansheng/test/grill-me.test.js | 112 ++++++++++++++++++++++++ sansheng/test/prompt.test.js | 23 +++++ 9 files changed, 225 insertions(+), 1 deletion(-) create mode 100644 .dsh/skills/NOTICE.md create mode 100644 .dsh/skills/grill-me/SKILL.md create mode 100644 .dsh/skills/grill-me/agents/openai.yaml create mode 100644 .dsh/skills/grilling/SKILL.md create mode 100644 .dsh/skills/grilling/agents/openai.yaml create mode 100644 sansheng/test/grill-me.test.js diff --git a/.dsh/skills/NOTICE.md b/.dsh/skills/NOTICE.md new file mode 100644 index 0000000..70b6e67 --- /dev/null +++ b/.dsh/skills/NOTICE.md @@ -0,0 +1,32 @@ +# Third-party skills + +The following skills are copied from [mattpocock/skills](https://github.com/mattpocock/skills): + +- `grilling/SKILL.md` and `grilling/agents/openai.yaml` +- `grill-me/SKILL.md` and `grill-me/agents/openai.yaml` + +They are licensed under the MIT License: + +```text +MIT License + +Copyright (c) 2026 Matt Pocock + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` diff --git a/.dsh/skills/grill-me/SKILL.md b/.dsh/skills/grill-me/SKILL.md new file mode 100644 index 0000000..3947ff9 --- /dev/null +++ b/.dsh/skills/grill-me/SKILL.md @@ -0,0 +1,7 @@ +--- +name: grill-me +description: A relentless interview to sharpen a plan or design. +disable-model-invocation: true +--- + +Call the Skill tool with "grilling". diff --git a/.dsh/skills/grill-me/agents/openai.yaml b/.dsh/skills/grill-me/agents/openai.yaml new file mode 100644 index 0000000..4d6fb0c --- /dev/null +++ b/.dsh/skills/grill-me/agents/openai.yaml @@ -0,0 +1,5 @@ +interface: + display_name: "Grill Me" + short_description: "Sharpen a plan through interview" +policy: + allow_implicit_invocation: false diff --git a/.dsh/skills/grilling/SKILL.md b/.dsh/skills/grilling/SKILL.md new file mode 100644 index 0000000..d2f09a1 --- /dev/null +++ b/.dsh/skills/grilling/SKILL.md @@ -0,0 +1,30 @@ +--- +name: grilling +description: Grill the user relentlessly about a plan, decision, or idea. Use when the user wants to stress-test their thinking, or uses any 'grill' trigger phrases. +--- + +Interview the user relentlessly until you reach a shared understanding. Map this as a **design tree**: every decision branches into the decisions that hang off it. + +Work the tree in **rounds**. The **frontier** is every decision whose prerequisites are already settled: the questions you can ask _now_ without guessing at answers you haven't heard yet. Ask the whole frontier in one round: number each question and give your recommended answer. Then wait for the user's answers before the next round. + +Format a round like so: + +``` +❓ **Q1** - ****: + +➡️ + +--- + +❓ **Q2** - ****: + +➡️ +``` + +Word each question so "yes" accepts your recommended answer. + +Each round the user answers reshapes the tree: settled decisions push the frontier outward and unblock questions that depended on them. Recompute the frontier and ask the next round. A question whose answer depends on another question still open in this round belongs to a _later_ round, not this one. + +Finding _facts_ is your job, never the user's. When a frontier question needs a fact from the environment (filesystem, tools, etc.), dispatch a sub-agent with a fresh context window to find it; don't ask the user for anything you could look up yourself. Don't block on it: a running exploration is an unsettled prerequisite, so only the questions downstream of it wait for the sub-agent to report; ask the rest of the frontier now. The _decisions_ are the user's: put each to them and wait. + +The session is done when the frontier is empty: every branch of the design tree visited, nothing left silently assumed. Do not act on it until the user confirms you have reached a shared understanding. diff --git a/.dsh/skills/grilling/agents/openai.yaml b/.dsh/skills/grilling/agents/openai.yaml new file mode 100644 index 0000000..ddbdb96 --- /dev/null +++ b/.dsh/skills/grilling/agents/openai.yaml @@ -0,0 +1,3 @@ +interface: + display_name: "Grilling" + short_description: "Stress-test thinking a round of questions at a time" diff --git a/sansheng/README.md b/sansheng/README.md index bd8bc7c..be41496 100644 --- a/sansheng/README.md +++ b/sansheng/README.md @@ -14,9 +14,16 @@ - 派工工具随席位绑定即时注册:新建、恢复、重建后同一次 DSH 启动内即可派工;重新绑定后旧会话失去该席位工具权限。 - 派工失败明确区分「本席派工工具未就绪」「目标部门未开启」「任务投递失败」,以项目真实席位绑定和会话 ID 为准。 - 尚书可按需汇总项目真实任务与结果,明确区分「已派工/已收到」和「已完成」,不拦截丞相直接派工。 +- 丞相需求澄清(Grill Me):仅在存在关键歧义、冲突或缺失时自动加载 `grilling` skill 追问;代码解释、状态查询、普通讨论和已足够明确的需求不触发。追问结果回写原 `R-xxx` 并递增 revision,保留 `missingInfo`;不创建任务、不派工、不生成批准凭证。 **本包尚未安装到用户的日常 DSH profile,也未改动日常 DSH 配置。** +## Grill Me 技能依赖 + +- 丞相自动追问使用 `grilling` skill;`grill-me` 是用户手动入口,正文只转调 `grilling`。 +- 上游 `grill-me` 带 `disable-model-invocation: true`,DSH 会把它从模型目录和 `skill` 工具中排除,所以模型侧自动加载的是 `grilling`,不是 `grill-me`。 +- 本仓库根目录 `.dsh/skills/` 保留两份技能副本(MIT,来源:mattpocock/skills);用户级 `~/.dsh/skills/` 已安装扁平文件 `grilling.md` 与 `grill-me.md`,供所有项目加载。技能缺失时丞相必须明确报告,不得伪造调用。 + ## 目录 - `index.js` — 宿主插件入口(`name` / `inject` / `apply`)。 @@ -24,4 +31,4 @@ - `src/host/` — 项目状态存储、严格会话创建/恢复、模型配置(不写 profile)、提示词 section、HTTP `api/sansheng`。 - `src/client/` — Web 工作台(纯视图模型 + React 接线 + 传输层)。 - `src/native/` — dsh-go 原生面板(纯视图树构造 + bridge 接线)。 -- `test/` — fake ctx 单元/集成测试。 +- `test/` — fake ctx 单元/集成测试。 \ No newline at end of file diff --git a/sansheng/src/host/prompt.js b/sansheng/src/host/prompt.js index 63101da..befb63b 100644 --- a/sansheng/src/host/prompt.js +++ b/sansheng/src/host/prompt.js @@ -19,6 +19,11 @@ export function renderSeatPrompt({ project, seatId, seat }) { '只有用户明确说出「发布 R-001 给中书」这类发布意图时,才可调用 sansheng_requirement_publish,且只能发布给中书省。你严禁直接向六部派工;sansheng_dispatch_task 已停用,任何直接派工都会被系统拒绝且无副作用。', '中书拟案和门下审核后,你只能向用户展示方案、影响范围、风险和验收方式,并等待用户明确说「批准执行 R-001」;只有那时才可调用 sansheng_requirement_approve。你不得代替用户确认,不得代替三省六部伪造或填写执行结果。', '需求改口、扩大范围或增加要求时,必须用 sansheng_requirement_upsert 更新原需求(revision 自动增加);旧发布命令和旧批准立即失效,旧任务会停止推进并等待重新确认。', + 'Grill Me 需求澄清规则:先判断用户输入是否包含「提出或变更需求」的立项意图。仅在需求存在关键歧义、冲突或缺失时触发:目标有多种合理理解;范围、非目标或验收标准缺失;前后要求存在冲突;关键约束、优先级或使用场景不明确;不同选择会明显影响架构、成本或风险;继续拟案必须依赖猜测。触发时调用 skill({ name: "grilling" }) 并严格按该 skill 的规则追问,不要自行另写一套提问逻辑。代码解释、状态查询、资料阅读、普通讨论、暂不立项的想法交流、已足够明确可直接整理的需求,以及用户明确说「别问了」「直接整理」「保留假设出方案」时不触发。用户主动说「Grill Me」「拷问我」时直接进入追问。', + 'Grill Me 追问前先自行查清可自行查明的事实,不询问用户本可自行查到的信息。新需求进入追问时可先建立 discussing 状态的 R-xxx 草稿并保留用户原话;已有需求在原条目上继续,不另建重复条目。', + 'Grill Me 追问结束后,必须用 sansheng_requirement_upsert 回写同一个 R-xxx 的 summary、scope、nonGoals、acceptanceCriteria、risks、dependencies、missingInfo、judgement、judgementReason;更新已有需求必须携带 expectedRevision。信息足够才可进入 ready;仍有未决事项保持 discussing,不得为了结束追问强行标记为可发布。', + 'Grill Me 只做需求澄清,不创建任务、不派工、不生成批准凭证。停止条件:已足以形成清晰范围与验收标准;skill 自身判断可以结束;用户要求停止或直接整理;用户接受保留部分假设继续。停止时输出:需求编号与 revision、已确认内容、范围与非目标、验收标准、仍需保留的假设或待确认项、当前状态(discussing / ready)、下一步所需用户命令。即使达到 ready,也只能提示「如需进入中书拟案,请明确发送『发布 R-xxx 给中书』」,不得自动发布、批准或派工。', + 'grill-me 是用户手动入口;模型侧自动加载的是 grilling。若 skill 加载失败或不可用,必须明确告知未加载成功,不得假装使用 grill-me/grilling,也不得自行复制一套同名提示词冒充。', ) } else { lines.push( diff --git a/sansheng/test/grill-me.test.js b/sansheng/test/grill-me.test.js new file mode 100644 index 0000000..5b12acd --- /dev/null +++ b/sansheng/test/grill-me.test.js @@ -0,0 +1,112 @@ +import test from 'node:test' +import assert from 'node:assert/strict' +import { installPromptSection } from '../src/host/prompt.js' +import { setupService, seatById } from './helpers.js' +import { createSeatToolDefinitions } from '../src/host/tools.js' + +async function setupGrill() { + const env = await setupService({ prompt: true }) + const opened = await env.service.open({ path: '/grill-me', name: 'Grill Me 项目' }) + env.projectId = opened.project.id + await env.service.enable(env.projectId) + const view = await env.service.project(env.projectId) + env.leadSession = seatById(view, 'lead').sessionId + env.tools = Object.fromEntries( + createSeatToolDefinitions({ store: env.store, service: env.service }).map(def => [def.name, def]), + ) + return env +} + +function run(env, name, args) { + return env.tools[name].execute(args, { agent: env.fake.sessions.get(env.leadSession) }) +} + +test('Grill Me 规则只注入丞相,且写明触发、停止与授权边界', async () => { + const env = await setupGrill() + installPromptSection(env.fake.ctx, { store: env.store }) + const section = env.fake.getPromptSection() + const view = await env.service.project(env.projectId) + + const lead = section.text({ agent: { id: seatById(view, 'lead').sessionId } }) + for (const keyword of ['关键歧义', '代码解释', '别问了', 'Grill Me', '拷问我', 'expectedRevision', 'discussing', 'ready', '不得自动发布、批准或派工', 'skill 加载失败']) { + assert.ok(lead.includes(keyword), `丞相提示缺少关键词:${keyword}`) + } + + const other = section.text({ agent: { id: seatById(view, 'gongbu').sessionId } }) + assert.ok(!other.includes('Grill Me 需求澄清规则')) + assert.ok(!other.includes('skill({ name: "grilling" })')) +}) + +test('Grill 结果回写同一个需求:revision 递增且不产生任务副作用', async () => { + const env = await setupGrill() + const created = await run(env, 'sansheng_requirement_upsert', { + title: '做一个有用的东西', + originalText: '帮我做点有用的东西,具体你看着办', + summary: '待澄清', + judgement: 'needs_discussion', + judgementReason: '目标、范围、验收标准都不明确', + missingInfo: '目标场景、范围边界、验收标准', + }) + assert.equal(created.ok, true, created.error) + assert.equal(created.created, true) + assert.equal(created.requirement.revision, 1) + assert.equal(created.requirement.status, 'discussing') + + const id = created.requirement.id + const updated = await run(env, 'sansheng_requirement_upsert', { + id, + expectedRevision: 1, + summary: '做一个本地多语言 Hello World 展示页', + scope: '本地静态页面 + 三种可运行语言示例', + nonGoals: '不部署公网,不引入构建依赖', + acceptanceCriteria: '三种语言均可真实运行;窄屏可用;可重跑;成功和失败有区分', + risks: '浏览器兼容性', + dependencies: '本机 Python / Node / 浏览器', + missingInfo: '无', + judgement: 'can_do', + judgementReason: '追问后范围与验收标准已明确', + }) + assert.equal(updated.ok, true, updated.error) + assert.equal(updated.created, false) + assert.equal(updated.requirement.id, id) + assert.equal(updated.requirement.revision, 2) + assert.equal(updated.requirement.status, 'ready') + + const tasks = (await env.service.tasks(env.projectId)).tasks + assert.equal(tasks.length, 0, 'Grill Me 回写需求不得创建任务') +}) + +test('Grill 期间旧 revision 更新被拒绝,且保留原需求不重复新建', async () => { + const env = await setupGrill() + const first = await run(env, 'sansheng_requirement_upsert', { + title: '改版需求', + originalText: '先按旧方案做', + judgement: 'needs_discussion', + missingInfo: '待确认', + }) + assert.equal(first.ok, true, first.error) + const id = first.requirement.id + + const second = await run(env, 'sansheng_requirement_upsert', { + id, + expectedRevision: 1, + summary: '第一轮追问后的整理', + judgement: 'needs_discussion', + missingInfo: '验收标准待确认', + }) + assert.equal(second.ok, true, second.error) + assert.equal(second.requirement.revision, 2) + + const stale = await run(env, 'sansheng_requirement_upsert', { + id, + expectedRevision: 1, + summary: '基于旧版本的覆盖', + }) + assert.equal(stale.ok, false) + assert.equal(stale.reason, 'sansheng/requirement-conflict') + + const list = await env.service.requirements(env.projectId) + assert.equal(list.requirements.length, 1, '同一需求不能因 Grill Me 产生重复条目') + assert.equal(list.requirements[0].id, id) + assert.equal(list.requirements[0].revision, 2) +}) diff --git a/sansheng/test/prompt.test.js b/sansheng/test/prompt.test.js index 4351c23..11f3a84 100644 --- a/sansheng/test/prompt.test.js +++ b/sansheng/test/prompt.test.js @@ -36,3 +36,26 @@ test('补充说明出现在提示里', async () => { const text = fake.getPromptSection().text({ agent: { id: seatById(p, 'libu').sessionId } }) assert.match(text, /先问清目标/) }) + +test('丞相提示包含 Grill Me 规则,其他九席不注入', async () => { + const { service, store, fake } = await setupService() + installPromptSection(fake.ctx, { store }) + const opened = await service.open({ path: '/pp3', name: 'Grill 项目' }) + await service.enable(opened.project.id) + const p = await service.project(opened.project.id) + const section = fake.getPromptSection() + + const leadText = section.text({ agent: { id: seatById(p, 'lead').sessionId } }) + assert.match(leadText, /Grill Me 需求澄清规则/) + assert.ok(leadText.includes('skill({ name: "grilling" })')) + assert.match(leadText, /expectedRevision/) + assert.match(leadText, /不创建任务、不派工、不生成批准凭证/) + assert.match(leadText, /不得假装使用 grill-me\/grilling/) + assert.match(leadText, /发布 R-xxx 给中书/) + + for (const seatId of ['zhongshu', 'menxia', 'shangshu', 'libu', 'hubu', 'lipu', 'bingbu', 'xingbu', 'gongbu']) { + const text = section.text({ agent: { id: seatById(p, seatId).sessionId } }) + assert.doesNotMatch(text, /Grill Me/) + assert.ok(!text.includes('skill({ name: "grilling" })')) + } +})