Files
Jyotisha/frontend/tests/consultation-voice-contract.test.ts
T
Jesse_Chen 46f38422f6
Independent Staging Quality Gate / validate (push) Failing after 7m21s
Independent Staging Quality Gate / publish (push) Has been skipped
fix(consult): speak like a person instead of a calculation report
Keep skill truth boundaries, but stop asking the model to announce skipped domains or parrot tool JSON.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-18 17:54:42 +08:00

36 lines
2.1 KiB
TypeScript

import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import test from "node:test";
const voice = readFileSync(new URL("../src/mastra/product-voice.ts", import.meta.url), "utf8");
const mastra = readFileSync(new URL("../src/mastra/index.ts", import.meta.url), "utf8");
const route = readFileSync(new URL("../src/app/api/consult/route.ts", import.meta.url), "utf8");
test("product voice overrides skill report format without relaxing truth boundaries", () => {
assert.match(voice, /VISIBLE VOICE \(overrides skill report format\)/);
assert.match(voice, /govern METHOD and TRUTH BOUNDARIES only/);
assert.match(voice, /Never copy the skill's report structure, Technique Audit Table/);
assert.match(voice, /Answer the user's actual question in the first sentence/);
assert.match(voice, /本轮未完整计算/);
assert.match(voice, /你更适合把已经积累的专业能力做成长期事业/);
assert.match(mastra, /productConversationVoice/);
assert.match(mastra, /Visible chat format is owned by VISIBLE VOICE above/);
assert.match(mastra, /private working notes, not user-facing copy/);
assert.match(mastra, /Follow the skill's method and truth boundaries/);
assert.match(mastra, /Do not use a restricted technique/);
assert.match(mastra, /Do not announce a skipped-domain inventory/);
assert.doesNotMatch(mastra, /Name the domains you did cover, say plainly that the remaining ones were not calculated/);
assert.doesNotMatch(mastra, /2-5 short paragraphs/);
});
test("consult user turn no longer dumps tool JSON that the model would parrot", () => {
const chartBranch = route.slice(route.indexOf("const toolInput = consultationInputSchema.parse"));
assert.match(chartBranch, /请直接用口语回答下面的问题[\s\S]*?resolvedQuestion\.modelQuestion/);
assert.doesNotMatch(chartBranch, /JSON\.stringify\(toolInput\)/);
assert.doesNotMatch(chartBranch, /经过服务端校验的工具参数/);
assert.match(route, /请用口语直接回答,不要复述内部字段或报本轮算了什么/);
assert.match(chartBranch, /await runConsultationWorkflow\(toolInput/);
});