feat(chat): answers open with a verdict card, a chart row of the areas used, a one-year strip, a short plain body and 接着问 (BUG-2281)

The answer stays one streamed markdown text in fixed headings (## 结论, ## 接下来一年, five body blocks per domain,
section it cannot read, and every answer stored before, renders as plain markdown as before. Lit areas and the
「偏吃力」 tone come from the answer's evidence keys and the Saturn-pressure coverage of the cited period rows (program,
on the receipt); 「有机会」 is wired but unassigned until the astrologer's rule (#340). The writing rules describe the
reader, keep every BUG-2247 check, and target about 1,200-1,600 characters of body.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXp2Vp62Ur3C7yRWQdSq
This commit is contained in:
2026-11-24 07:37:58 +08:00
co-authored by Claude Opus 5.5
parent 4f4709bc23
commit e0492edeb9
23 changed files with 1176 additions and 49 deletions
+20
View File
@@ -30795,3 +30795,23 @@
- 未处理:她的格局解释包(逐条 raw_row、effect_assessment 闸门)属第 3 批;事实里的行星、星座仍有英文名,由模型按合同写中文。
- 验证:`tests/test_yoga_expression_paths.py`(22 过、5 跳过)、`tests/test_expression_paths_wiring_2296.py`;同盘本地渲染 52 条路径(Yogada 4、部分成立 1、Raja 替代 3、同主题独立支持 7),细运未交出。
- 修复版本:`claude/density-b1`。
## BUG-2281 | 问答回答读不进去:字太多、结论不在最前、分析不是平常话,看着和普通聊天机器人一样
- 状态:fixed-pending-verify(本地提交,未推送;待负责人在 staging 看过再推)。
- 首次发现 / 最近更新:2026-11-24(内测用户反馈;负责人认可问答原型 `/workspace/eval-read-1116/chat-ux-prototype/chat-answer.html` 的回答样子和口吻)/ 2026-11-24。
- 现象:内测用户说回答读不懂:字太多,没有一上来就给结论,分析不是日常的话,产品看着和别的聊天机器人没两样。BUG-2247 之后首轮正文仍有约 1,800–3,100 字,结论只是第一段文字,时间线是一串加粗日期,追问建议在回答外另调一次模型。
- 触发条件:本命问答的首轮和追问(`answerMode` plain,问答页)。
- 根因:不是程序错误,是回答的形状和写法。写法(`product-voice.ts` chatConversationVoice、`consultation-thinking-plan.ts` CHAT_FIRST_TURN_SHAPE)要求 2,500–4,000 字、每条判断允许一句「星盘上这一点很明确」这类盘面理由,分节名按问题自起;页面(`chat-message-content.tsx`)把整篇当一段 Markdown 显示,没有结论卡、时间条,也看不出回答是从这个人的星盘里看出来的。
- 修复:
- 形状(新文件 `frontend/src/lib/chat-answer-shape.ts`):回答仍是一段流式 Markdown,按固定二级标题写——「## 结论」(一句话 + 按领域固定的三行标签:事业 最适合 / 先别碰 / 最好的时候;钱 钱从哪来 / 先别碰 / 最好的时候;感情 适合的人 / 先别碰 / 最好的时候;性格 长处 / 短处 / 适合;综合 眼下 / 该做 / 最好的时候;时间 最好的时候 / 最难的时候 / 该做)、「## 接下来一年」(每条「- **小标题**(年月到年月):一句。该做:……。别做:……〔T〕」,用户给了范围就照范围,最多 8 段,性格题不写)、五块正文(标题按领域固定:长处和短处 / 从最适合的排起 / 不适合的 / 现在就可以试的 / 要留意的)、「## 接着问」(三条,用户口吻)、「## 判断依据」。选标题而不是隐藏标记:落库、复制、导出和旧客户端看到的都是普通 Markdown;事实核对、编号展开、加粗配对(BUG-2248)和清理都按行处理,不碰标题。解析器严格:某一节读不出(标签不在固定表里、时间条目没有年月括号、超过 8 段、超过 3 行标签)就把这一节原样当 Markdown 显示;开头不是「## 结论」(这次之前存的所有回答、用户只要一两句、报告追问)就整篇按原来的样子显示。流式时先出结论卡,写到一半的行和标题先不显示,「接着问」整节写完才出现。
- 页面(新文件 `frontend/src/components/chat-answer-shape.tsx`,接在 `chat-message-content.tsx`,只在问答页 `structured` 时用;报告追问不变):结论卡;「这是从你的星盘里看出来的」一行,小星盘按用户选的南北印度样式只画格子、不画星,点亮这次用到的地方,下面一句平常话的地方名(新文件 `frontend/src/lib/chat-chart-areas.ts`:12 宫 → 性格、收入、兄弟姐妹和胆量、家、孩子和恋爱、每天的工作、感情和伴侣、突发的变化、贵人和远方、事业、朋友和愿望、花销和休息;不出现「第 N 宫」;无依赖,等待画面也用),点它展开「判断依据」;时间条按月数定宽,颜色和文字一起,图例只列用到的,点一段在下面固定高度的面板里看起止、那一句、该做、别做(所有面板叠在同一格里,高度取最长的一段,换选不跳);正文照旧 Markdown 全部展开;「接着问」用现有的追问按钮,点了直接发;「判断依据」「盘面数据」不变。
- 程序算的数据(新文件 `frontend/src/lib/chat-answer-shape-data.ts`,回执新字段 `answerShape`):点亮的地方取回答引用的编号(H / G / A 编号,AL、UL、AmK、DK、D10、D9、D2、D11 等各对应一宫;只引了行星时取行星所在宫),按引用次数排序,不由模型说;每段的「偏吃力」取这一段引用的运期行里土星压力段的天数,和正文 `pressure_unsaid` 检查同一个门槛(`PRESSURE_DAYS_FOR_HEAVY = 30`,从 `chat-evidence-keys.ts` 抽出共用);其余是「平稳」。「有机会」在组件和数据里都留了位置,规则要占星师认可(issue #340),`opportunityTone` 现在什么也不返回。回执没有 `answerShape`(流式中、旧回答、没有编号)时时间条不上色、不显示图例。
- 写法:读者写成一个从没接触过占星、嫌字多的人;句子短、一句一件事、平常话;正文里一句盘面理由都不写(「星盘上这一点很明确」也不写),原因只说用户认得出的样子;具体到岗位、做法、多少力气、年月;不推责、不保证;健康照旧写什么时候去看医生;原型的文字作写法示例。首轮正文(结论到要留意的)约 1,200–1,600 字,不设丢判断的上限。追问轮:「## 结论」一句 + 相关几条 + 问时间才有时间条 + 「接着问」。BUG-2247 的编号、时间线日期和压力检查、讲构造的句子检查、方向检查全部保留;时间线检查改为读小标题后面的年月括号(旧格式照旧)。
- 接着问:回答自带「## 接着问」时,路由直接存成这条回答的推荐问题,不再另调一次模型(BUG-1539 的生成调用只给旧形状回答用);页面在回答里显示,回答下面不再重复。
- 补写调用的放置表(`chat-answer-repair.ts` FIXED_SECTION)把「结论」「接下来…」「接着问」算作固定节,不往里补段落。
- 验证:`frontend/tests/chat-answer-shape-2281.test.tsx` 9 条(每节都在、每节缺一、读不出的节退回 Markdown、流式写到一半(8 个截断点)、页面不露 `##` / `**` / 〔编号〕 / 「第 N 宫」、旧回答渲染和改动前逐字相同、报告追问不读新形状、点亮的地方和每段语气来自编号和土星压力段、BUG-2247 的检查和展开在新形状上照常、写法里的固定标签和标题)。钉住的断言按「原值 / 新值 / 原因」改了:`chat-voice-2229`(标题、写法长度预算 6,300 → 7,500,实测 7,328)、`chat-plain-body-2247`、`consult-answer-the-question-20260927`、`consult-single-pass-answer-20260927`、`chat-bundle-splitting-contract`(message-markdown 包裹 2 → 3)。tsc、改动文件 ESLint 0 错误;读改动文件的前端测试和 chat / consult / voice / fact-guard / markdown 测试逐个文件跑(机器负载高,全套留给合并后由父会话跑)。2026-11-24 本地真实 `/api/consult` 路由(数据库和鉴权换桩、DeepSeek flash、本地引擎、公开盘)4 条,对比 BUG-2247 第二轮同一路由的数字:事业首轮 正文 3,080 → 1,643 字、全文 10,050 → 7,698 字、输入 142.9k → 141.7k、输出 10.1k → 11.2k token、75 → 70 秒;「我是一个什么样的人?」1,808 → 1,292 字、147.2k → 180.6k / 9.8k → 7.8k、76 → 55 秒;未来两年财运 2,650 → 1,590 字、168.0k → 167.9k / 12.0k → 10.4k、89 → 71 秒;事业追问(这次问的是首轮自己给的第一条「接着问」,BUG-2247 问的是「为什么这么说?依据是什么?」,不完全可比)1,361 → 803 字、155.3k → 192.8k / 5.8k → 3.4k、45 → 38 秒。读稿:初学者读不懂的句子 事业 1(「换到下一段周期」)、性格 1(「拼速度的场合你既容易吃到那股冲劲……是有得有失的一段」,补写改出来的)、财运 1(「换到另一段」)、追问 3(「这两件事在你盘里其实是一条路」「这一段主管的正是那颗同时管你事业和创意的星……被两套慢星一起点到」「两种推算时间的路子……另一种连起点都还有分歧」)。加粗结论带编号:事业 22/22、性格 17/17、财运 17/20(「现在就可以试的」三条没带)、追问 0/6(追问正文没写编号,判断依据照常有)。财运时间条第 5 段写「回稳」,程序按土星压力段标「偏吃力」(数据在 Sade Sati 里),文字和颜色不一致一处。答案和每条的 `answerShape`:`/workspace/eval-read-1116/chat-ux-prototype/build/answers/`;截图(组件渲染 + 11-23 staging 构建的样式表加本次 CSS,手机 390 / 桌面 1280,浅色 / 深色,选中「偏吃力」一段,「判断依据」展开):`/workspace/eval-read-1116/chat-ux-prototype/build/screens/`。
- 已知不足:追问正文仍会讲星盘构造、不带编号(追问规则 FOLLOW_UP_TIMING_RULE 要求正文用一句话说两种方法是否指到同一段,读者看不懂);时间条文字的语气和程序的颜色可能不一致(只有「偏吃力」由程序定,文字没有被要求跟着改);「有机会」等占星师规则;首轮全文(含判断依据)仍有 7–8 千字,判断依据行数没变。
- 防复发:新形状的节名和标签只在 `chat-answer-shape.ts` 里定义,写法、解析和页面都引用它;改标题必须同时过 `chat-answer-shape-2281` 的解析和渲染测试。旧回答渲染由同一测试逐字比对。
- 关联记录:BUG-2247(正文说人话、编号和判断依据,本次在它上面改形状和长度)、BUG-2248(加粗配对,新形状照常经过)、BUG-2241(土星压力段覆盖,时间条语气用它)、BUG-2239(运期覆盖行)、BUG-2235(补写只补必看层)、BUG-2229(问答写法)、BUG-1539(推荐问题按回答生成;新形状的回答自带)、BUG-2182(用户要的长度优先,照旧)。
- 修复版本:分支 `claude/chat-ux-answer`(本地提交,待父会话推送 staging)。
+8 -1
View File
@@ -154,6 +154,8 @@ import {
import { persistGuardedSessionTitle } from "@/lib/session-title-guard";
import { generateSessionTitle, shouldGenerateSessionTitle } from "@/lib/session-title-agent";
import { generateConsultationFollowUps } from "@/lib/consultation-follow-up-agent";
import { answerFollowUpQuestions } from "@/lib/chat-answer-shape";
import { splitJudgmentBasis } from "@/lib/consult-judgment-basis";
import { handleReportQuestionConsult } from "@/lib/report-question-consult";
import { handleSynastryReportConsult } from "@/lib/synastry-report-consult";
import { SYNASTRY_QUESTION_SECTION_IDS } from "@/lib/synastry-full-sections";
@@ -1108,7 +1110,10 @@ export async function POST(request: Request) {
const persistedThinking = thinkingText?.trim().slice(0, 4_000);
// BUG-1539: follow-ups written from this question and this answer, saved
// with it and sent on run.completed. Empty on any failure or timeout.
const followUps = await generateConsultationFollowUps({
// BUG-2281: an answer in the new shape wrote its own 「## 接着问」 questions in the same call; they are saved as this
// answer's follow-ups and the separate follow-up call is skipped.
const ownFollowUps = answerFollowUpQuestions(splitJudgmentBasis(reply.text).body).filter((item) => Array.from(item).length <= 40);
const followUps = ownFollowUps.length ? ownFollowUps : await generateConsultationFollowUps({
model: selectedModel,
question: visibleQuestion,
answer: reply.text,
@@ -1893,6 +1898,8 @@ export async function POST(request: Request) {
const chartData = consultChartDataFromCard(state.evidenceCard);
return chartData ? { chartData } : {};
})(),
// BUG-2281: lit chart areas and strip tones, derived from the answer's evidence keys (program, not model).
...(state.answerShape ? { answerShape: state.answerShape } : {}),
// BUG-1828:回执带本轮绑定盘实际生效的交点 / 位置口径;没有绑定盘的路径不加。
...(prepared.serverChart
? {
+50
View File
@@ -1999,6 +1999,56 @@ button.chat-chart-resize-handle:active { position: absolute; top: 0; left: -3px;
text-align: left;
}
.conversation-follow-up:hover { background: var(--color-canvas-muted); }
/* BUG-2281: an answer in the owner-approved prototype's shape — verdict card, the chart row, the one-year strip, body,
接着问, then the folded 判断依据. Product tokens only; colour and text label always together; the strip's panel keeps one
height for every selection (all panels share one grid cell). */
.chat-answer-shaped { display: flex; flex-direction: column; gap: var(--space-4); }
.chat-answer-shaped > .message-markdown { margin-top: var(--space-2); }
.chat-answer-label { margin: 0 0 var(--space-2); color: var(--color-ink-secondary); font-size: var(--type-caption); letter-spacing: .04em; }
.chat-answer-verdict { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); border-radius: 14px; background: var(--color-canvas-muted); }
.chat-answer-verdict-sentence { margin: 0; color: var(--color-ink); font-family: var(--font-display); font-size: var(--type-title-lg); line-height: 1.5; text-wrap: pretty; }
.chat-answer-verdict-facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px var(--space-3); margin: 0; font-size: var(--type-body-md); line-height: 1.5; }
.chat-answer-verdict-fact { display: contents; }
.chat-answer-verdict-fact dt { color: var(--color-ink-secondary); white-space: nowrap; }
.chat-answer-verdict-fact dd { margin: 0; color: var(--color-ink); min-width: 0; }
.chat-answer-areas[data-slot="button"] { display: flex; width: 100%; height: auto; justify-content: flex-start; align-items: center; gap: var(--space-3); padding: 10px var(--space-3); border: 1px solid var(--color-border); border-radius: 14px; background: transparent; color: var(--color-ink); font-weight: 400; text-align: left; white-space: normal; cursor: pointer; }
.chat-answer-areas[data-slot="button"]:hover { background: var(--color-canvas-muted); }
.chat-answer-areas:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.chat-answer-areas-chart { flex: none; width: 56px; height: 56px; }
.chat-answer-areas-chart polygon, .chat-answer-areas-chart rect { fill: var(--color-canvas); stroke: var(--color-canvas-strong); stroke-width: 8; stroke-linejoin: round; }
.chat-answer-areas-chart .is-lit { fill: color-mix(in srgb, var(--color-action) 30%, var(--color-canvas)); }
.chat-answer-areas-text { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 2px; }
.chat-answer-areas-title { font-size: var(--type-body-md); font-weight: 600; line-height: 1.4; }
.chat-answer-areas-names { color: var(--color-ink-secondary); font-size: var(--type-caption); line-height: 1.5; }
.chat-answer-areas-chevron { flex: none; width: 16px; height: 16px; color: var(--color-ink-tertiary); }
.chat-answer-strip { display: flex; flex-direction: column; gap: var(--space-2); }
.chat-answer-strip .chat-answer-label { margin: 0; }
.chat-answer-strip-bar, .chat-answer-strip-ticks { display: grid; gap: 3px; }
.chat-answer-strip-segment[data-slot="button"] { display: grid; min-width: 0; height: 44px; place-items: center; padding: 0 2px; border: 0; border-radius: 8px; color: var(--color-ink); font-size: var(--type-caption); font-weight: 400; line-height: 1.2; white-space: normal; cursor: pointer; overflow-wrap: anywhere; }
.chat-answer-strip-segment.is-pending[data-slot="button"], .chat-answer-strip-segment.is-steady[data-slot="button"] { background: var(--color-canvas-strong); }
.chat-answer-strip-segment.is-heavy[data-slot="button"] { background: color-mix(in srgb, var(--color-action) 26%, var(--color-canvas)); }
.chat-answer-strip-segment.is-chance[data-slot="button"] { background: color-mix(in srgb, var(--color-success) 22%, var(--color-canvas)); }
.chat-answer-strip-segment[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--color-ink); }
.chat-answer-strip-segment:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.chat-answer-strip-ticks { color: var(--color-ink-secondary); font-size: var(--type-caption); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chat-answer-strip-ticks span { min-width: 0; overflow: visible; }
.chat-answer-strip-detail { display: grid; padding: var(--space-3) 14px; border: 1px solid var(--color-border); border-radius: 14px; }
.chat-answer-strip-panel { display: flex; grid-area: 1 / 1; flex-direction: column; gap: 6px; visibility: hidden; font-size: var(--type-body-md); line-height: 1.55; }
.chat-answer-strip-panel[data-active] { visibility: visible; }
.chat-answer-strip-when { color: var(--color-ink-secondary); font-size: var(--type-caption); font-variant-numeric: tabular-nums; }
.chat-answer-strip-sentence { font-weight: 600; }
.chat-answer-strip-panel dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; margin: 0; }
.chat-answer-strip-panel dl > div { display: contents; }
.chat-answer-strip-panel dt { color: var(--color-ink-secondary); white-space: nowrap; }
.chat-answer-strip-panel dd { margin: 0; }
.chat-answer-strip-legend { display: flex; flex-wrap: wrap; gap: var(--space-3); color: var(--color-ink-secondary); font-size: var(--type-caption); }
.chat-answer-strip-legend i { display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 3px; vertical-align: -1px; }
.chat-answer-strip-legend i.is-steady { background: var(--color-canvas-strong); }
.chat-answer-strip-legend i.is-heavy { background: color-mix(in srgb, var(--color-action) 26%, var(--color-canvas)); }
.chat-answer-strip-legend i.is-chance { background: color-mix(in srgb, var(--color-success) 22%, var(--color-canvas)); }
.chat-answer-strip-note { margin: 0; color: var(--color-ink); font-size: var(--type-body-md); line-height: 1.6; }
.chat-answer-next .conversation-follow-ups { margin: 0; }
.chat-answer-next .conversation-follow-up { height: auto; min-height: 44px; padding-block: 10px; white-space: normal; text-align: left; }
.conversation-follow-up:disabled { cursor: not-allowed; opacity: .56; }
.message-actions button {
position: relative;
@@ -0,0 +1,205 @@
"use client";
import { ChevronRight } from "lucide-react";
import { useEffect, useState } from "react";
import { ConversationFollowUps } from "@/components/conversation-follow-ups";
import { Button } from "@/components/ui/button";
import type { ChartBoardStyle } from "@/lib/chart-board-style";
import { chartAreaHouses, chartAreaNames } from "@/lib/chat-chart-areas";
import {
ANSWER_TONE_LABELS,
currentMonthIndex,
FOLLOW_UP_HEADING,
type AnswerShape,
type AnswerTone,
type TimelineSegment,
} from "@/lib/chat-answer-shape";
import { CHART_SIZE, HOUSE_POLYGONS, polygonPoints } from "@/lib/north-indian-chart-geometry";
import { useUiStore } from "@/stores/ui-store";
/**
* BUG-2281: the parts of an answer in the owner-approved prototype's shape (verdict card, the chart row, the one-year
* strip, 接着问). The body and 「判断依据」 stay the existing markdown and fold (chat-message-content.tsx).
*/
export function AnswerVerdict({ verdict }: Readonly<{ verdict: AnswerShape["verdict"] }>) {
if (!verdict.sentence && !verdict.facts.length) return null;
return (
<section className="chat-answer-verdict" aria-label="结论">
{verdict.sentence ? <p className="chat-answer-verdict-sentence">{verdict.sentence}</p> : null}
{verdict.facts.length ? (
<dl className="chat-answer-verdict-facts">
{verdict.facts.map((fact) => (
<div key={fact.label} className="chat-answer-verdict-fact">
<dt>{fact.label}</dt>
<dd>{fact.value}</dd>
</div>
))}
</dl>
) : null}
</section>
);
}
const SIGNS = ["Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces"] as const;
/** South Indian fixed sign cells (row, column) by sign index, 0 = Aries (as in mini-varga-chart.tsx). */
const SOUTH_CELL: Readonly<Record<number, readonly [number, number]>> = {
11: [0, 0], 0: [0, 1], 1: [0, 2], 2: [0, 3], 10: [1, 0], 3: [1, 3], 9: [2, 0], 4: [2, 3], 8: [3, 0], 7: [3, 1], 6: [3, 2], 5: [3, 3],
};
/** The chart outline in the reader's board style with the answer's areas lit. Areas only, never planets (owner). */
export function AnswerAreasChart({ houses, ascendantSign, style }: Readonly<{ houses: readonly number[]; ascendantSign?: string; style: ChartBoardStyle }>) {
const lit = new Set(houses);
const ascendant = SIGNS.indexOf((ascendantSign ?? "") as (typeof SIGNS)[number]);
if (style === "south" && ascendant >= 0) {
const size = CHART_SIZE / 4;
return (
<svg className="chat-answer-areas-chart" data-chart-style="south" viewBox={`-4 -4 ${CHART_SIZE + 8} ${CHART_SIZE + 8}`} aria-hidden="true">
{Object.entries(SOUTH_CELL).map(([sign, [row, column]]) => {
const house = ((Number(sign) - ascendant + 12) % 12) + 1;
return <rect key={sign} x={column * size + 6} y={row * size + 6} width={size - 12} height={size - 12} rx={12} className={lit.has(house) ? "is-lit" : undefined} />;
})}
</svg>
);
}
return (
<svg className="chat-answer-areas-chart" data-chart-style="north" viewBox={`-4 -4 ${CHART_SIZE + 8} ${CHART_SIZE + 8}`} aria-hidden="true">
{Object.entries(HOUSE_POLYGONS).map(([house, points]) => (
<polygon key={house} points={polygonPoints(points)} className={lit.has(Number(house)) ? "is-lit" : undefined} />
))}
</svg>
);
}
function useBoardStyle(): ChartBoardStyle {
const style = useUiStore((state) => state.chartBoardStyle);
const hydrated = useUiStore((state) => state.chartBoardStyleHydrated);
const hydrate = useUiStore((state) => state.hydrateChartBoardStyle);
useEffect(() => {
if (!hydrated) hydrate();
}, [hydrate, hydrated]);
return style;
}
/** 「这是从你的星盘里看出来的」: the lit areas and their plain names; tapping opens 「判断依据」. */
export function AnswerAreas({ houses, ascendantSign, onOpen }: Readonly<{ houses: readonly number[]; ascendantSign?: string; onOpen: () => void }>) {
const style = useBoardStyle();
const list = chartAreaHouses(houses);
if (!list.length) return null;
const names = chartAreaNames(list);
return (
<Button type="button" variant="ghost" className="chat-answer-areas" onClick={onOpen}>
<AnswerAreasChart houses={list} ascendantSign={ascendantSign} style={style} />
<span className="chat-answer-areas-text">
<span className="chat-answer-areas-title">这是从你的星盘里看出来的</span>
<span className="chat-answer-areas-names">这次看了 {names.length} 个地方:{names.join("、")}</span>
</span>
<ChevronRight aria-hidden="true" className="chat-answer-areas-chevron" />
</Button>
);
}
/** 「12 月」「明年 5 月」「2029 年 1 月」 relative to this month's year. */
export function monthLabel(index: number, now = currentMonthIndex()): string {
const year = Math.floor(index / 12);
const month = (index % 12) + 1;
const diff = year - Math.floor(now / 12);
if (diff === 0) return `${month} 月`;
if (diff === 1) return `明年 ${month} 月`;
if (diff === 2) return `后年 ${month} 月`;
return `${year} 年 ${month} 月`;
}
/**
* The month under each segment's start: 「现在」 for a first stretch that starts now, the year only where it changes
* (「明年 2 月」 then 「5 月」), nothing under a segment shorter than two months (no room for the label).
*/
export function stripTicks(segments: readonly TimelineSegment[], weights: readonly number[], now = currentMonthIndex()): string[] {
let year = Math.floor(now / 12);
return segments.map((segment, index) => {
if (!segment.months || weights[index]! < 2) return "";
if (index === 0 && /^(?:现在|眼下|目前)/u.test(segment.range)) return "现在";
const start = segment.months[0];
const label = Math.floor(start / 12) === year ? `${(start % 12) + 1} 月` : monthLabel(start, now);
year = Math.floor(start / 12);
return label;
});
}
/** Segment widths in months (at least one each); equal widths when any range could not be read. */
export function segmentWeights(segments: readonly TimelineSegment[]): number[] {
if (segments.some((segment) => !segment.months)) return segments.map(() => 1);
return segments.map((segment) => Math.max(1, segment.months![1] - segment.months![0] + 1));
}
/**
* The one-year strip: one segment per timeline entry, widths by duration, colour and label together. Tapping a segment
* shows its range, sentence, 该做 and 别做 in the panel below; every panel sits in the same grid cell, so the panel is as
* tall as the longest one and does not change height with the selection. Tones come from the receipt (program-derived);
* without them (still streaming, or an answer without evidence keys) the segments are neutral and no legend shows.
*/
export function AnswerYearStrip({ timeline, tones }: Readonly<{ timeline: NonNullable<AnswerShape["timeline"]>; tones?: readonly AnswerTone[] }>) {
const [picked, setPicked] = useState(0);
const segments = timeline.segments;
if (!segments.length) return null;
const selected = Math.min(picked, segments.length - 1);
const known = tones && tones.length === segments.length ? tones : null;
const weights = segmentWeights(segments);
const columns = weights.map((weight) => `minmax(40px, ${weight}fr)`).join(" ");
const used = known ? (["chance", "steady", "heavy"] as const).filter((tone) => known.includes(tone)) : [];
return (
<section className="chat-answer-strip" aria-label={timeline.heading}>
<p className="chat-answer-label">{timeline.heading}</p>
<div className="chat-answer-strip-bar" style={{ gridTemplateColumns: columns }}>
{segments.map((segment, index) => (
<Button
key={`${index}-${segment.title}`}
type="button"
variant="ghost"
className={`chat-answer-strip-segment is-${known ? known[index] : "pending"}`}
aria-pressed={index === selected}
aria-label={`${segment.title},${segment.range}${known ? `,${ANSWER_TONE_LABELS[known[index]!]}` : ""}`}
onClick={() => setPicked(index)}
>
{segment.title}
</Button>
))}
</div>
<div className="chat-answer-strip-ticks" style={{ gridTemplateColumns: columns }} aria-hidden="true">
{stripTicks(segments, weights).map((tick, index) => <span key={index}>{tick}</span>)}
</div>
<div className="chat-answer-strip-detail" aria-live="polite">
{segments.map((segment, index) => (
<div key={index} className="chat-answer-strip-panel" data-active={index === selected ? "" : undefined} aria-hidden={index !== selected}>
<span className="chat-answer-strip-when">{segment.range}{known ? `,${ANSWER_TONE_LABELS[known[index]!]}` : ""}</span>
{segment.sentence ? <b className="chat-answer-strip-sentence">{segment.sentence}</b> : null}
{segment.doThis || segment.avoid ? (
<dl>
{segment.doThis ? <div><dt>该做</dt><dd>{segment.doThis}</dd></div> : null}
{segment.avoid ? <div><dt>别做</dt><dd>{segment.avoid}</dd></div> : null}
</dl>
) : null}
</div>
))}
</div>
{used.length ? (
<div className="chat-answer-strip-legend" aria-hidden="true">
{used.map((tone) => <span key={tone}><i className={`is-${tone}`} />{ANSWER_TONE_LABELS[tone]}</span>)}
</div>
) : null}
{timeline.note ? <p className="chat-answer-strip-note">{timeline.note}</p> : null}
</section>
);
}
/** 「接着问」: the answer's own three questions, each sends itself (the existing follow-up buttons). */
export function AnswerFollowUps({ questions, disabled, onSelect }: Readonly<{ questions: readonly string[]; disabled?: boolean; onSelect: (question: string) => void }>) {
if (!questions.length) return null;
return (
<section className="chat-answer-next" aria-label={FOLLOW_UP_HEADING}>
<p className="chat-answer-label">{FOLLOW_UP_HEADING}</p>
<ConversationFollowUps questions={questions} disabled={disabled} onSelect={onSelect} />
</section>
);
}
@@ -1,9 +1,11 @@
"use client";
import { memo, useEffect, useState, type ReactNode } from "react";
import { memo, useCallback, useEffect, useRef, useState, type ReactNode } from "react";
import { prefetchOnIdle } from "@/components/chat-chunk-prefetch";
import { AnswerAreas, AnswerFollowUps, AnswerVerdict, AnswerYearStrip } from "@/components/chat-answer-shape";
import { ConsultAnswerBasis } from "@/components/consult-answer-basis";
import { parseAnswerShape, type AnswerShapeData } from "@/lib/chat-answer-shape";
import { ConsultChartDataFold } from "@/components/consult-chart-data";
import { ConsultJudgmentBasis } from "@/components/consult-judgment-basis";
import type { ConsultChartData } from "@/lib/consult-chart-data";
@@ -129,6 +131,10 @@ export function ChatMessageContent({
basisRows,
chartData,
streaming = false,
structured = false,
answerShape,
onFollowUp,
followUpsDisabled = false,
}: {
text: string;
auditRows?: readonly TechniqueAuditRow[];
@@ -137,8 +143,23 @@ export function ChatMessageContent({
/** 「盘面数据」 under a settled answer (owner 2026-11-16), from the receipt. */
chartData?: ConsultChartData;
streaming?: boolean;
/** BUG-2281: the consultation chat reads the answer's fixed sections (verdict card, strip, 接着问); report chats do not. */
structured?: boolean;
/** BUG-2281: lit chart areas and strip tones from the receipt (program-derived). */
answerShape?: AnswerShapeData;
/** BUG-2281: sends one of the answer's own 「接着问」 questions; without it (older answers) the questions are not shown. */
onFollowUp?: (question: string) => void;
followUpsDisabled?: boolean;
}) {
const renderMarkdown = useMarkdownRenderer();
const answerRef = useRef<HTMLDivElement>(null);
// BUG-2281: the chart row opens the folded 「判断依据」 and brings it into view.
const openBasis = useCallback(() => {
const details = answerRef.current?.querySelector<HTMLDetailsElement>(".consult-judgment-basis details");
if (!details) return;
details.open = true;
details.scrollIntoView({ block: "nearest" });
}, []);
// The stored answer keeps every audit row; the page leaves out the external
// verification ones (联网, the verification gate, real cases; owner 2026-11-08).
// 产品 2026-11-16:正文之后的「## 判断依据」一节折叠显示,流式输出时也先收起。
@@ -150,6 +171,41 @@ export function ChatMessageContent({
const visibleText = withSteadyLayout(withNodeFirstMention(withoutExternalVerificationRows(withoutSelfChoiceNotes(judgment.body))));
// BUG-2007(2026-11-19):深度解读审计表末尾不再补 BUG-1834 的未核验说明。
const text = visibleText;
// BUG-2281: an answer that opens with 「## 结论」 is shown in the prototype's shape; any other answer (all stored before
// this change, a one-or-two-sentence answer, report chats) renders exactly as before.
const shape = structured ? parseAnswerShape(text, { streaming }) : null;
if (shape) {
const ascendant = chartData?.natal.find((row) => row.body === "Ascendant")?.sign;
const shapedBody = splitSpokenAnswerAndTechniqueAudit(shape.body).spoken;
return (
<div className="message-answer chat-answer-shaped" ref={answerRef}>
<AnswerVerdict verdict={shape.verdict} />
{!streaming && answerShape?.areas.length && judgment.basis ? (
<AnswerAreas houses={answerShape.areas} ascendantSign={ascendant} onOpen={openBasis} />
) : null}
{shape.timeline ? <AnswerYearStrip timeline={shape.timeline} tones={streaming ? undefined : answerShape?.tones} /> : null}
{shapedBody ? (
<div className="message-markdown">
<StreamingMarkdown text={shapedBody} renderMarkdown={renderMarkdown} streaming={streaming} />
</div>
) : null}
{!streaming && onFollowUp ? (
<AnswerFollowUps questions={shape.followUps} disabled={followUpsDisabled} onSelect={onFollowUp} />
) : null}
{judgment.basis ? (
<ConsultJudgmentBasis
basis={judgment.basis}
methodRows={!streaming ? basisRows : undefined}
scopeLine={!streaming && basisRows?.length ? consultScopeLine(answerUsedBookLibrary(judgment.basis)) : undefined}
>
<StreamingMarkdown text={withoutBasisNoise(withoutChatCitations(judgment.basis))} renderMarkdown={renderMarkdown} streaming={streaming} />
</ConsultJudgmentBasis>
) : null}
{!streaming && chartData ? <ConsultChartDataFold data={chartData} /> : null}
{!streaming && !judgment.basis && basisRows?.length ? <ConsultAnswerBasis rows={basisRows} scopeLine={consultScopeLine(answerUsedBookLibrary(judgment.basis))} /> : null}
</div>
);
}
const split = splitSpokenAnswerAndTechniqueAudit(text);
const rows = resolveTechniqueAuditRows(split, auditRows);
const layers = splitSpokenAndReport(split.spoken);
@@ -68,6 +68,9 @@ export const ChatMessageRow = memo(function ChatMessageRow({
stoppedNotice,
stepsInFooter = false,
question,
structured = false,
onFollowUp,
followUpsDisabled = false,
}: Readonly<{
message: ChatMessageView;
showActivity?: boolean;
@@ -82,6 +85,11 @@ export const ChatMessageRow = memo(function ChatMessageRow({
stepsInFooter?: boolean;
/** BUG-2048: the question this answers, for the status line's language. */
question?: string | null;
/** BUG-2281: read the answer's fixed sections (consultation chat only). */
structured?: boolean;
/** BUG-2281: sends one of the answer's own 「接着问」 questions (the latest answer only). */
onFollowUp?: (question: string) => void;
followUpsDisabled?: boolean;
}>) {
const messageRow = useRef<HTMLElement>(null);
const smalltalk = message.responseKind === "smalltalk";
@@ -214,6 +222,10 @@ export const ChatMessageRow = memo(function ChatMessageRow({
? undefined
: consultAnswerBasisRows(message.agentExecutionReceipt.techniqueAuditTable, message.agentExecutionReceipt.functionalProfile)}
streaming={message.state !== "settled"}
structured={structured && !smalltalk}
answerShape={smalltalk ? undefined : message.agentExecutionReceipt?.answerShape}
onFollowUp={onFollowUp}
followUpsDisabled={followUpsDisabled}
/>
)
: null;
+18 -5
View File
@@ -26,7 +26,9 @@ import {
noteUnsplitListRender,
} from "@/lib/home-streaming-render-probe";
import { AnswerChartLinkScope } from "@/components/answer-chart-link-scope";
import { memo, useEffect, useMemo, useState, type MutableRefObject } from "react";
import { memo, useCallback, useEffect, useMemo, useState, type MutableRefObject } from "react";
import { answerFollowUpQuestions } from "@/lib/chat-answer-shape";
import { splitJudgmentBasis } from "@/lib/consult-judgment-basis";
import {
BeforeBirthTimeChangeLabel,
RectificationOfferCard,
@@ -129,12 +131,16 @@ function MessageEntry({
// BUG-1539: follow-ups are the ones written for this answer from its own
// question (saved with it); the old keyword-picked chips put the same
// work / relationship / money lines under nearly every answer.
const followUps: readonly string[] = showActions
const followUpsAllowed = Boolean(showActions
&& message.renderKey === latestRegeneratableKey
&& sessionType === "consultation"
&& previousQuestion
? message.suggestions ?? []
&& previousQuestion);
// BUG-2281: an answer that wrote its own 「## 接着问」 shows them inside the answer, above 「判断依据」, not under it.
const ownFollowUps = sessionType === "consultation" && message.role === "assistant" && message.text
? answerFollowUpQuestions(splitJudgmentBasis(message.text).body)
: [];
const followUps: readonly string[] = followUpsAllowed && !ownFollowUps.length ? message.suggestions ?? [] : [];
const askFollowUp = useCallback((question: string) => actionsRef.current.onFollowUp(question), [actionsRef]);
if (returnRecord) {
return (
<div className="message-entry message-entry--divider">
@@ -153,7 +159,14 @@ function MessageEntry({
<>
<div className={`message-entry${latestAnswer ? " is-latest-answer" : ""}`}>
{beforeBirthTimeChange ? <BeforeBirthTimeChangeLabel /> : null}
<ChatMessageRow message={message} stepsInFooter={stepsInFooter} question={previousQuestion} />
<ChatMessageRow
message={message}
stepsInFooter={stepsInFooter}
question={previousQuestion}
structured={sessionType === "consultation"}
onFollowUp={followUpsAllowed && ownFollowUps.length ? askFollowUp : undefined}
followUpsDisabled={productEntrypointsDisabled}
/>
{showActions && (
<div className="message-footer">
<ChatMessageActions
+3 -2
View File
@@ -155,7 +155,8 @@ export function missingMustLayers(answer: string, card: EvidenceCard): Delivered
/** Marks 「the first heading that is not a fixed section」 in LAYER_SECTION (the question-named judgments heading). */
const JUDGMENT_FALLBACK = /(?!)/u;
const FIXED_SECTION = /一句话结论|落到生活|时间线|年盘|行运|风险|判断依据/u;
// BUG-2281: the new fixed sections (「结论」 card, the timeline 「接下来一年」, 「接着问」) never take a layer paragraph.
const FIXED_SECTION = /一句话结论|^##\s*结论|落到生活|时间线|接下来|未来|接着问|年盘|行运|风险|判断依据/u;
/** Where each layer's body text goes: the first heading matching one of these, in order; else 「判断依据」 only. */
export const LAYER_SECTION: Readonly<Record<string, readonly RegExp[]>> = {
@@ -174,7 +175,7 @@ export const LAYER_SECTION: Readonly<Record<string, readonly RegExp[]>> = {
};
export function sectionForLayer(answer: string, layer: string): string | null {
const heads = headings(answer).filter((line) => !/判断依据|一句话结论/u.test(line));
const heads = headings(answer).filter((line) => !/判断依据|一句话结论|^##\s*结论\s*$|接着问/u.test(line));
for (const pattern of LAYER_SECTION[layer] ?? []) {
const hit = pattern === JUDGMENT_FALLBACK
? heads.find((line) => !FIXED_SECTION.test(line))
@@ -0,0 +1,87 @@
/**
* BUG-2281: the program-derived data behind the answer's 「这是从你的星盘里看出来的」 row and its one-year strip, read from
* the keyed answer (before the evidence keys are expanded and removed) and the card. Nothing here is written by the model:
* the lit areas are the houses the answer's evidence keys point at, and each strip segment's tone comes from the Saturn
* pressure coverage of the period rows its timeline entry cites (the same threshold as the body's `pressure_unsaid` check).
*/
import type { EvidenceCard } from "./consultation-evidence-card.ts";
import { evidenceKeyRows, PRESSURE_DAYS_FOR_HEAVY, segmentPressureDays, type KeyRow } from "./chat-evidence-keys.ts";
import { normalizeEvidenceTags, TAG_RE, tagKeys } from "./chat-evidence-tags.ts";
import { splitJudgmentBasis } from "./consult-judgment-basis.ts";
import { chartAreaHouses } from "./chat-chart-areas.ts";
import { isTimelineHeading, VERDICT_HEADING, type AnswerShapeData, type AnswerTone } from "./chat-answer-shape.ts";
/** Keys that stand for one house without naming it as 「H」 or 「G」 (an arudha, a karaka, a domain chart). */
const HOUSE_OF_KEY: Readonly<Record<string, number>> = { AL: 1, UL: 7, AmK: 10, DK: 7, D10: 10, D9: 7, D2: 2, D11: 11, D4: 4, D7: 5, D24: 4 };
export function houseOfKey(key: string): number | null {
const hit = /^(?:H|G|A)(\d{1,2})$/u.exec(key);
if (hit) return Number(hit[1]);
return HOUSE_OF_KEY[key] ?? null;
}
const PLANET_KEY = /^(?:Su|Mo|Ma|Me|Ju|Ve|Sa|Ra|Ke)$/u;
/** Houses ordered by how often they are cited (most first), ties in the order of first citation. */
function byCitations(houses: readonly number[]): number[] {
const count = new Map<number, number>();
for (const house of houses) count.set(house, (count.get(house) ?? 0) + 1);
const order = chartAreaHouses(houses);
return order.sort((a, b) => count.get(b)! - count.get(a)! || order.indexOf(a) - order.indexOf(b));
}
/**
* The houses the answer looked at, the most cited first: house, Argala and arudha keys, plus the domain charts and
* karakas that stand for one house. An answer that cites planets only lights the houses they sit in. `keys` keeps every
* citation (repeats count).
*/
export function answerAreas(keys: readonly string[], rows: ReadonlyMap<string, KeyRow>): number[] {
const houses = byCitations(keys.flatMap((key) => (rows.has(key) ? [houseOfKey(key) ?? 0] : [])).filter((house) => house >= 1 && house <= 12));
if (houses.length) return houses;
return byCitations(keys.filter((key) => PLANET_KEY.test(key)).flatMap((key) => {
const house = /本命第 (\d{1,2}) 宫/u.exec(rows.get(key)?.text ?? "")?.[1];
return house ? [Number(house)] : [];
}));
}
/**
* The rule for 「有机会」 plugs in here. It needs the astrologer's approval (issue #340), so it returns nothing today and
* every segment without enough pressure is 「平稳」.
*/
export function opportunityTone(periods: readonly KeyRow[]): AnswerTone | null {
void periods;
return null;
}
export function segmentTone(periods: readonly KeyRow[]): AnswerTone {
if (periods.length && segmentPressureDays(periods) >= PRESSURE_DAYS_FOR_HEAVY) return "heavy";
return opportunityTone(periods) ?? "steady";
}
const keysOf = (line: string) => [...line.matchAll(TAG_RE)].flatMap((hit) => tagKeys(hit[1]!));
/** Areas and strip tones of a keyed answer; empty when the answer carries no keys or is not in the new shape. */
export function answerShapeData(keyedText: string, card: EvidenceCard | null): AnswerShapeData {
const empty: AnswerShapeData = { areas: [], tones: [] };
if (!card) return empty;
const rows = new Map(evidenceKeyRows(card).map((row) => [row.key, row]));
const text = normalizeEvidenceTags(keyedText);
const areas = answerAreas(keysOf(text), rows);
const tones: AnswerTone[] = [];
let first = "";
// 0 before the timeline section, 1 inside it, 2 after it (only the first one is the strip, as on the page).
let timeline = 0;
for (const line of splitJudgmentBasis(text).body.split("\n")) {
const heading = /^##[ \t]+(.+?)[ \t]*#*[ \t]*$/u.exec(line);
if (heading) {
const section = heading[1]!.replace(/\*\*/gu, "").replace(/[::]$/u, "").trim();
if (!first) first = section;
if (timeline === 1) timeline = 2;
else if (timeline === 0 && first === VERDICT_HEADING && section !== VERDICT_HEADING && isTimelineHeading(section)) timeline = 1;
continue;
}
if (timeline !== 1 || !/^[ \t]{0,3}[-*+][ \t]+\S/u.test(line)) continue;
tones.push(segmentTone(keysOf(line).flatMap((key) => (rows.get(key)?.period ? [rows.get(key)!] : []))));
}
return { areas, tones };
}
+268
View File
@@ -0,0 +1,268 @@
/**
* BUG-2281 (owner-approved chat prototype, 2026-11-24): the answer's shape.
*
* A first-turn chat answer is still one streamed markdown text (stored, copied and exported as it is), written in fixed
* sections that read as ordinary markdown and that the page turns into the prototype's parts:
*
* ## 结论 → the verdict card: one sentence, then up to three 「- **标签**:值」 lines (labels fixed below)
* ## 接下来一年 → the one-year strip: 「- **小标题**(2026 年 11 月到 12 月):一句话。该做:……。别做:……」
* ## 你的长处和短处 … 要留意的 → the body, rendered as markdown (headings fixed per domain below)
* ## 接着问 → three follow-up questions, tappable
* ## 判断依据 → folded, as before (split off before this parser runs)
*
* Why headings and not hidden markers: the stored text stays plain, readable markdown for copy, export and older
* clients; every step that rewrites the answer (fact guard, evidence-key expansion, bold balancing, clean-up) already
* works line by line on markdown and leaves headings alone. The parser is strict: a section it cannot read falls back to
* plain markdown in place, and an answer that does not open with 「## 结论」 (every answer stored before this change)
* renders exactly as before. The user never sees a marker: the fallback shows ordinary headings and lists.
*
* No imports: the page, the prompt builder and the server read the same constants.
*/
export const VERDICT_HEADING = "结论";
export const FOLLOW_UP_HEADING = "接着问";
export const DEFAULT_TIMELINE_HEADING = "接下来一年";
/** 「接下来一年」「接下来两年」「未来两年」「2027 到 2028 年」 */
const TIMELINE_HEADING_RE = /^(?:接下来|未来|今后|从现在|这几年|时间线|\d{4})/u;
export const MAX_TIMELINE_SEGMENTS = 8;
export function isTimelineHeading(heading: string): boolean {
return heading !== VERDICT_HEADING && TIMELINE_HEADING_RE.test(heading);
}
export const MAX_FOLLOW_UPS = 3;
export type AnswerShapeDomain = "career" | "wealth" | "relationship" | "personality" | "general" | "timing";
/** The verdict card's three labels per question domain (values are written by the model). */
export const VERDICT_LABELS: Readonly<Record<AnswerShapeDomain, readonly [string, string, string]>> = {
career: ["最适合", "先别碰", "最好的时候"],
wealth: ["钱从哪来", "先别碰", "最好的时候"],
relationship: ["适合的人", "先别碰", "最好的时候"],
personality: ["长处", "短处", "适合"],
general: ["眼下", "该做", "最好的时候"],
timing: ["最好的时候", "最难的时候", "该做"],
};
/** The body's five headings per domain: strengths and weak spots, options ranked, what does not suit, try now, watch. */
export const BODY_HEADINGS: Readonly<Record<AnswerShapeDomain, readonly [string, string, string, string, string]>> = {
career: ["你的长处和短处", "可以做的工作,从最适合的排起", "不适合你的", "现在就可以试的", "要留意的"],
wealth: ["你在钱上的长处和短处", "来钱的路,从最适合的排起", "不适合你的", "现在就可以试的", "要留意的"],
relationship: ["你在感情里的长处和短处", "适合你的人和相处方式,从最合适的排起", "不适合你的", "现在就可以试的", "要留意的"],
personality: ["你的长处和短处", "适合你的活法,从最合适的排起", "不适合你的", "现在就可以试的", "要留意的"],
general: ["你眼下的长处和短处", "最值得做的事,从最要紧的排起", "先别做的", "现在就可以试的", "要留意的"],
timing: ["这段时间你的长处和短处", "最值得做的事,从最要紧的排起", "先别做的", "现在就可以试的", "要留意的"],
};
export const DOMAIN_NAMES: Readonly<Record<AnswerShapeDomain, string>> = {
career: "事业、工作",
wealth: "钱、财运",
relationship: "感情、婚姻",
personality: "性格、我是什么样的人",
general: "整体、综合、健康和其他",
timing: "什么时候、哪一年",
};
const KNOWN_LABELS = new Set(Object.values(VERDICT_LABELS).flat());
/** Strip tones. 「有机会」 is in the shape but not assigned yet (its rule waits for the astrologer, issue #340). */
export type AnswerTone = "steady" | "heavy" | "chance";
export const ANSWER_TONE_LABELS: Readonly<Record<AnswerTone, string>> = { steady: "平稳", heavy: "偏吃力", chance: "有机会" };
/** Program-derived data for the answer's chart row and strip, carried on the receipt (never written by the model). */
export type AnswerShapeData = {
/** Houses 1–12 the answer's evidence keys point at. */
areas: number[];
/** One tone per timeline entry, in order. */
tones: AnswerTone[];
};
export type VerdictFact = Readonly<{ label: string; value: string }>;
export type TimelineSegment = Readonly<{
title: string;
range: string;
sentence: string;
doThis: string;
avoid: string;
/** Month indexes (year * 12 + month - 1) of the range's first and last month; null when the range names none. */
months: readonly [number, number] | null;
}>;
export type AnswerShape = Readonly<{
verdict: Readonly<{ sentence: string; facts: readonly VerdictFact[] }>;
timeline: Readonly<{ heading: string; segments: readonly TimelineSegment[]; note: string }> | null;
followUps: readonly string[];
/** The rest of the answer, in order, as markdown (body sections and any section that did not parse). */
body: string;
}>;
type Section = { heading: string; lines: string[] };
function sections(text: string): { preamble: string; list: Section[] } {
const list: Section[] = [];
const preamble: string[] = [];
for (const line of text.split(/\r?\n/u)) {
const heading = /^##[ \t]+(.+?)[ \t]*#*[ \t]*$/u.exec(line);
if (heading) list.push({ heading: heading[1]!.replace(/\*\*/gu, "").replace(/[::]$/u, "").trim(), lines: [] });
else if (list.length) list[list.length - 1]!.lines.push(line);
else preamble.push(line);
}
return { preamble: preamble.join("\n"), list };
}
const sectionMarkdown = (section: Section) => `## ${section.heading}\n${section.lines.join("\n")}`.replace(/\s+$/u, "");
const plain = (text: string) => text.replace(/\*\*/gu, "").replace(/\s+/gu, " ").trim();
/** List items of a section (continuation lines joined), and the loose lines; null when a line cannot be read. */
function items(lines: readonly string[]): { items: string[]; loose: string[] } {
const out: string[] = [];
const loose: string[] = [];
for (const line of lines) {
if (!line.trim()) continue;
if (/^[ \t]{0,3}[-*+][ \t]+\S/u.test(line)) out.push(line.replace(/^[ \t]{0,3}[-*+][ \t]+/u, "").trim());
else if (/^\d{1,2}[.、)][ \t]*\S/u.test(line.trim())) out.push(line.trim().replace(/^\d{1,2}[.、)][ \t]*/u, ""));
else if (out.length && /^[ \t]+\S/u.test(line)) out[out.length - 1] += line.trim();
else loose.push(line.trim());
}
return { items: out, loose };
}
const FACT_RE = /^(?:\*\*)?([^*::]{1,8}?)(?:\*\*)?[ \t]*[::][ \t]*(?:\*\*)?[ \t]*(.+?)$/u;
function parseVerdict(section: Section, streaming: boolean): AnswerShape["verdict"] | null {
const { items: list, loose } = items(section.lines);
const facts: VerdictFact[] = [];
for (const [index, item] of list.entries()) {
const hit = FACT_RE.exec(item);
const label = hit?.[1]?.trim() ?? "";
if (!hit || !KNOWN_LABELS.has(label)) {
// The line being written: wait for it.
if (streaming && index === list.length - 1) continue;
return null;
}
facts.push({ label, value: plain(hit[2]!).replace(/[。.]$/u, "") });
}
if (facts.length > 3) return null;
const sentence = plain(loose.join(""));
if (!sentence && !streaming) return null;
return { sentence, facts };
}
const ITEM_RE = /^\*\*([^*]{1,12}?)\*\*[ \t]*[((]([^()()]{2,40})[))][ \t]*[::]?[ \t]*(.*)$/u;
/** 「2026 年 11 月到 12 月」「现在到 2027 年 2 月」「2027 年 5 月下旬到 10 月」: first and last month, year carried. */
export function rangeMonths(range: string, fallbackStart?: number): readonly [number, number] | null {
const months: number[] = [];
let year: number | null = null;
for (const m of range.matchAll(/(\d{4})\s*年\s*(?:(\d{1,2})\s*月)?|(\d{4})-(\d{1,2})|(?<![\d年])(\d{1,2})\s*月/gu)) {
if (m[1]) { year = Number(m[1]); months.push(year * 12 + (m[2] ? Number(m[2]) : 1) - 1); continue; }
if (m[3]) { year = Number(m[3]); months.push(year * 12 + Number(m[4]) - 1); continue; }
if (m[5] && year !== null) {
let index = year * 12 + Number(m[5]) - 1;
// 「2026 年 11 月到 2 月」: the later month is in the next year.
if (months.length && index < months[months.length - 1]!) { year += 1; index += 12; }
months.push(index);
}
}
if (!months.length) return null;
const leadsWithNow = /^(?:现在|眼下|目前|今天|从现在)/u.test(range.trim());
const start = leadsWithNow && fallbackStart !== undefined ? fallbackStart : months[0]!;
const end = months[months.length - 1]!;
return end >= start ? [start, end] : null;
}
function splitAdvice(rest: string): { sentence: string; doThis: string; avoid: string } {
const text = plain(rest);
const doAt = text.search(/该做[::]/u);
const avoidAt = text.search(/别做[::]/u);
const cut = (from: number, to: number) => text.slice(from, to < 0 ? undefined : to).replace(/^(?:该做|别做)[::]\s*/u, "").trim();
const firstCut = [doAt, avoidAt].filter((at) => at >= 0).sort((a, b) => a - b)[0] ?? -1;
const sentence = (firstCut >= 0 ? text.slice(0, firstCut) : text).trim();
const doThis = doAt >= 0 ? cut(doAt, avoidAt > doAt ? avoidAt : -1) : "";
const avoid = avoidAt >= 0 ? cut(avoidAt, doAt > avoidAt ? doAt : -1) : "";
return { sentence, doThis, avoid };
}
function parseTimeline(section: Section, streaming: boolean, now: number): AnswerShape["timeline"] {
const { items: list, loose } = items(section.lines);
const segments: TimelineSegment[] = [];
let previousEnd: number | undefined = now;
for (const [index, item] of list.entries()) {
const hit = ITEM_RE.exec(item);
if (!hit) {
if (streaming && index === list.length - 1) continue;
return null;
}
const range = hit[2]!.trim();
const months = rangeMonths(range, previousEnd);
if (months) previousEnd = months[1] + 1;
segments.push({ title: hit[1]!.trim(), range, months, ...splitAdvice(hit[3] ?? "") });
}
if (!segments.length && !streaming) return null;
if (segments.length > MAX_TIMELINE_SEGMENTS) return null;
return { heading: section.heading, segments, note: plain(loose.join("")) };
}
function parseFollowUps(section: Section): string[] {
return items(section.lines).items
.map((item) => plain(item).replace(/^[「“"]|[」”"]$/gu, "").trim())
.filter(Boolean)
.slice(0, MAX_FOLLOW_UPS);
}
/** Month index of today, for a first stretch written 「现在到 ……」. */
export function currentMonthIndex(date = new Date()): number {
return date.getFullYear() * 12 + date.getMonth();
}
/**
* The answer body (「判断依据」 already split off) as its parts, or null when it is not in this shape (no 「## 结论」 at the
* top: older answers, a user who asked for one or two sentences, report chats). While streaming, the line being written
* is left out until it can be read, and a heading still being typed is not shown.
*/
export function parseAnswerShape(text: string, options: { streaming?: boolean; now?: number } = {}): AnswerShape | null {
const streaming = options.streaming === true;
let source = text;
if (streaming) {
const lastBreak = source.lastIndexOf("\n");
const lastLine = source.slice(lastBreak + 1);
if (/^\s*#/u.test(lastLine)) source = source.slice(0, Math.max(0, lastBreak));
}
const { preamble, list } = sections(source);
if (preamble.trim() || !list.length || list[0]!.heading !== VERDICT_HEADING) return null;
const now = options.now ?? currentMonthIndex();
let verdict: AnswerShape["verdict"] | null = null;
let timeline: AnswerShape["timeline"] = null;
let followUps: string[] = [];
const body: string[] = [];
list.forEach((section, index) => {
const last = index === list.length - 1;
const live = streaming && last;
if (index === 0) {
verdict = parseVerdict(section, live);
if (!verdict) body.push(sectionMarkdown(section));
return;
}
if (section.heading === FOLLOW_UP_HEADING) {
const parsed = parseFollowUps(section);
// While streaming, the questions show once the section is complete.
if (parsed.length && !live) followUps = parsed;
else if (!parsed.length && !live) body.push(sectionMarkdown(section));
return;
}
if (!timeline && isTimelineHeading(section.heading)) {
const parsed = parseTimeline(section, live, now);
if (parsed) { timeline = parsed; return; }
}
body.push(sectionMarkdown(section));
});
return {
verdict: verdict ?? { sentence: "", facts: [] },
timeline,
followUps,
body: body.join("\n\n"),
};
}
/** The 「## 接着问」 questions of a finished answer (for the saved suggestions; no separate model call). */
export function answerFollowUpQuestions(body: string): string[] {
return [...(parseAnswerShape(body)?.followUps ?? [])];
}
+34
View File
@@ -0,0 +1,34 @@
/**
* BUG-2281 (owner-approved chat prototype, 2026-11-24): the twelve houses as plain areas of life, for readers who have
* never heard of astrology. One fixed table used wherever the chat names the part of a chart it looked at (the answer's
* 「这是从你的星盘里看出来的」 row, the waiting screen). The words work for another person's chart too. Never 「第 N 宫」.
* Standalone on purpose: no imports, so any part of the chat can use it.
*/
export const CHART_AREA_NAMES: Readonly<Record<number, string>> = {
1: "性格",
2: "收入",
3: "兄弟姐妹和胆量",
4: "家",
5: "孩子和恋爱",
6: "每天的工作",
7: "感情和伴侣",
8: "突发的变化",
9: "贵人和远方",
10: "事业",
11: "朋友和愿望",
12: "花销和休息",
};
/** House numbers 1–12, in the order given, without repeats or anything outside 1–12. */
export function chartAreaHouses(houses: readonly number[]): number[] {
const out: number[] = [];
for (const house of houses) {
if (Number.isInteger(house) && house >= 1 && house <= 12 && !out.includes(house)) out.push(house);
}
return out;
}
/** 「性格、事业、每天的工作」: the plain names of the houses, in the order given. */
export function chartAreaNames(houses: readonly number[]): string[] {
return chartAreaHouses(houses).map((house) => CHART_AREA_NAMES[house]!);
}
+29 -6
View File
@@ -384,6 +384,29 @@ const LIGHT_SAID = new RegExp(`(?<!不|没|不是|谈不上|并不|并非|不会
const FIRST_HALF = /前半/u;
const SECOND_HALF = /后半/u;
/**
* BUG-2281: a stretch with this many days or more of Saturn pressure in its period rows is heavy — the body must say so
* (`pressure_unsaid` below) and the answer's one-year strip marks it 「偏吃力」. One threshold for both.
*/
export const PRESSURE_DAYS_FOR_HEAVY = 30;
/** Days of Saturn pressure in a stretch's cited period rows (the finest rows decide: sub-sub-periods over the rest). */
export function segmentPressureDays(periods: readonly KeyRow[]): number {
const withPeriod = periods.filter((row) => row.period);
const fine = withPeriod.filter((row) => row.label.includes("细运"));
return Math.max(0, ...(fine.length ? fine : withPeriod).map((row) => row.period!.pressure.reduce((sum, item) => sum + item.days, 0)));
}
/**
* BUG-2281: the bold lead of a timeline entry and the date bracket right after it. The answer's timeline entries are now
* 「- **小标题**(2026 年 11 月到 12 月):……」 (the strip reads them); older ones put the dates inside the bold lead.
*/
function timelineLead(plain: string): string {
const hit = /\*\*(.+?)\*\*(\s*[((][^()()]{2,40}[))])?/u.exec(plain);
if (!hit) return plain;
return hit[2] ? `${hit[2].trim().replace(/^[((]|[))]$/gu, "")}:${hit[1]}` : hit[1]!;
}
/** Each timeline entry (a body line with keys) against its rows: dates within a month, heavy / light against pressure. */
export function checkTimelineEntries(text: string, card: EvidenceCard | null): PlainFlag[] {
if (!card) return [];
@@ -397,10 +420,10 @@ export function checkTimelineEntries(text: string, card: EvidenceCard | null): P
const start = periods.map((row) => row.period!.from).sort()[0]!;
const end = periods.map((row) => row.period!.to).sort().reverse()[0]!;
const plain = withoutEvidenceTags(line);
const lead = /\*\*(.+?)\*\*/u.exec(plain)?.[1] ?? plain;
const lead = timelineLead(plain);
const months = monthsIn(lead.replace(/[((][^()()]*[))]/gu, ""));
const data = periods.map((row) => `${row.label}:土星压力段 ${row.period!.pressure.map((item) => `${item.name} ${item.word}`).join(";")}`).join("|");
const sentence = (lead === plain ? plain : `**${lead}**`).replace(/^\s*[-*]\s+/u, "").trim();
const sentence = (lead === plain ? plain : (/\*\*(.+?)\*\*(\s*[((][^()()]{2,40}[))])?/u.exec(plain)?.[0] ?? plain)).replace(/^\s*[-*]\s+/u, "").trim();
// The entry may split the cited periods into natural stretches (at an ingress, say), so it only has to lie inside
// them: a month of slack on each side for dates written to the month.
if (months.length) {
@@ -428,8 +451,8 @@ export function checkTimelineEntries(text: string, card: EvidenceCard | null): P
}
// BUG-2247 round 2 (wealth sample: a recommended stretch under Sade Sati said nothing about it): a stretch with a month
// or more of Saturn pressure says it is heavy, in plain words.
const pressureDays = Math.max(0, ...(fine.length ? fine : periods).map((row) => row.period!.pressure.reduce((sum, item) => sum + item.days, 0)));
if (pressureDays >= 30 && !HEAVY.test(plain) && !/压力|压着|费力|费劲|疲|沉|慢下来|收着|减量|别加量|悠着/u.test(plain)) {
const pressureDays = segmentPressureDays(periods);
if (pressureDays >= PRESSURE_DAYS_FOR_HEAVY && !HEAVY.test(plain) && !/压力|压着|费力|费劲|疲|沉|慢下来|收着|减量|别加量|悠着/u.test(plain)) {
out.push({ kind: "pressure_unsaid", sentence, card: `这一段有 ${pressureDays} 天在土星压力段里:${data};在这一条里用平常话说这一段(或哪部分)偏吃力、压力大,保留「**……**」加粗,不写术语` });
}
}
@@ -529,8 +552,8 @@ export function checkBodyDirection(text: string, card: EvidenceCard | null): Pla
const polar = (fine.length ? fine : cited).map((row) => row.polarity).filter((value) => value !== 0);
if (!polar.length) continue;
const plain = withoutEvidenceTags(line);
const lead = /\*\*(.+?)\*\*/u.exec(plain)?.[1] ?? plain;
const sentence = (lead === plain ? plain : `**${lead}**`).replace(/^\s*[-*]\s+/u, "").trim();
const lead = timelineLead(plain);
const sentence = (lead === plain ? plain : (/\*\*(.+?)\*\*(\s*[((][^()()]{2,40}[))])?/u.exec(plain)?.[0] ?? plain)).replace(/^\s*[-*]\s+/u, "").trim();
const positive = BODY_POSITIVE.test(lead) && !NEGATED.test(lead.slice(0, Math.max(0, lead.search(BODY_POSITIVE))).slice(-3)) && !BODY_NEGATIVE.test(lead);
const negative = /^\s*(?:\d{4}\s*年|现在|眼下)/u.test(lead) && BODY_NEGATIVE.test(lead) && !BODY_POSITIVE.test(lead);
const names = (fine.length ? fine : cited).filter((row) => row.polarity !== 0).map((row) => `${row.label}(主星${row.polarity > 0 ? "在这张盘里偏有利" : "在这张盘里偏不利:功能凶星、落陷或力量不到最低线"})`).join(";");
@@ -128,6 +128,11 @@ export const agentExecutionReceiptSchema = z.object({
functionalProfile: z.enum(["pvr_table30_v1", "bphs_exception_profile"]).optional(),
/** 产品 2026-11-16:页面按它生成「盘面数据」表(本命位置、现在的运程、慢星行运);旧回执没有。 */
chartData: consultChartDataSchema.optional(),
/** BUG-2281: houses the answer's evidence keys point at (the lit chart areas) and one tone per strip segment; older receipts have none. */
answerShape: z.object({
areas: z.array(z.number().int().min(1).max(12)).max(12),
tones: z.array(z.enum(["steady", "heavy", "chance"])).max(16),
}).strict().optional(),
// BUG-1828:本轮实际生效的交点 / 位置口径;旧回执没有这个字段仍能通过。
calculationProfile: z
.object({
@@ -583,8 +583,12 @@ export const TIMING_FOCUS_RULE = "讲时间时最多说三件天象或运期变
*/
// BUG-2247 原值:「……整份回答(含「判断依据」)大约 6 千到 9 千字……时间线按卡上 sub_periods 逐段写到细运……」;新值:正文 2,500 到 4,000 字、
// 说人话,时间线按问题定长短、合并成自然的几段,「判断依据」每条一句加编号;原因:负责人 2026-11-23「正文说人话,专业内容折叠在下面」。
// BUG-2281 原值:「……正文写给没接触过占星的人,大约 2,500 到 4,000 字……时间线按问题定长短(……),每段末尾写合并的 period_coverage
// 行的〔编号〕。正文写完后,最后写「## 判断依据」一节……」;新值:按 VISIBLE VOICE 的固定标题写(## 结论、时间那一节、五块正文、
// ## 接着问、## 判断依据),正文约 1,200 到 1,600 字、不为凑短删判断;原因:负责人 2026-11-24 认可的问答原型(结论在前、句子短、
// 页面按标题排成结论卡、时间条和可点的接着问)。
export const CHAT_FIRST_TURN_SHAPE =
"这是本会话的首轮回答:按系统提示里 VISIBLE VOICE 的写法回答用户这句话,用它列的分节(## 标题)写完整。正文写给没接触过占星的人,大约 2,500 到 4,000 字,判断一条不少,用平常话写透;用户说了要多长时按用户说的写。卡上为这个问题交付的层,和这件事有关的都要用进判断,正文只说结果,依据放进「判断依据」那一条的〔编号〕。时间线按问题定长短(性格题不写,一般问题写 12 个月合并成 4 到 6 段,用户给了范围就照范围、最多 8 段),每段末尾写合并的 period_coverage 行的〔编号〕。正文写完后,最后写「## 判断依据」一节,每条一句说明加〔编号〕。";
"这是本会话的首轮回答:按系统提示里 VISIBLE VOICE 的写法回答用户这句话,用它列的分节(## 标题)写完整,标题一字不改,按它的顺序写:## 结论(一句话加三行固定标签)、时间那一节(问题有时间的一面才写)、五块正文、## 接着问;正文写完后,最后写「## 判断依据」一节。正文写给没接触过占星的人,句子短,一句一件事,一句盘面上的理由都不写;从结论到「要留意的」大约 1,200 到 1,600 字,判断一条不少,写不下就把句子写短;用户说了要多长时按用户说的写。卡上为这个问题交付的层,和这件事有关的都要用进判断,正文只说结果,依据放进「判断依据」那一条的〔编号〕;正文每条判断和时间那一节每条末尾写〔编号〕。";
/** BUG-2229: a follow-up about time or one planet's period names both timing methods and whether they agree. */
// BUG-2247 原值:正文用平常话说 Vimshottari(大运小运)和 Narayana 各指向哪一段;新值:正文说两种推算方法有没有指到同一段,方法名和状态写进
@@ -630,7 +634,9 @@ export function followUpAnswerShapeInstruction(mode: ConsultationAnswerMode = DE
ANSWER_FROM_EVIDENCE,
answerModeTurnLine(mode),
mode === "plain"
? "这是追问轮:本会话前面已经写过完整解读。第一句就回答用户这句话,只引和这句话相关的盘面事实,讲清楚为准,不限字数,不重讲上一轮;写法按系统提示里的 VISIBLE VOICE。这一轮有新的判断时,末尾写「## 判断依据」,只列这一轮新的判断;没有新判断就不写这一节。用户明确换了领域或要求完整看一下时,按首轮写。"
// BUG-2281 原值:「……第一句就回答用户这句话……这一轮有新的判断时,末尾写「## 判断依据」……」;新值:先「## 结论」一句话、相关的几条、
// 问时间才写时间那一节、「## 接着问」三条,再「## 判断依据」;原因:问答原型的追问轮是轻一点的同一形状。
? "这是追问轮:本会话前面已经写过完整解读。先写「## 结论」,第一句就回答用户这句话;再只写和这句话直接相关的几条(每条先一句加粗的结论,再两三句短句),只引和这句话相关的盘面事实,讲清楚为准,不限字数,不重讲上一轮;写法按系统提示里的 VISIBLE VOICE(追问轮写法)。问的是时间才写时间那一节;然后「## 接着问」三条。这一轮有新的判断时,末尾写「## 判断依据」,只列这一轮新的判断;没有新判断就不写这一节。用户明确换了领域或要求完整看一下时,按首轮写。"
: "这是追问轮:本会话前面已经写过完整解读。先用一两句回答用户这句话,讲清楚为准,不限字数;再只写和这句话相关的技法路由、原始数据、Dasha 与证据等级,不重讲上一轮;冲突与阻塞项和 Technique Audit Table(列本轮用到的技法,加 Functional Benefic/Malefic、MEVG / Global Web Evidence、Real Case Calibration 三行)保留;写法按系统提示里的 VISIBLE VOICE。用户明确换了领域或要求完整看一下时,按首轮写。",
CAREER_FOLLOW_UP_RULE,
// BUG-2229: a follow-up about time or a period names both timing methods; the card's main cause comes first.
@@ -27,6 +27,7 @@ import { consultationWriteLabel } from "./consultation-activity-labels.ts";
import { consultationRunFailureMessage } from "./consultation-workflow-retry.ts";
import { logTruncatedReasoning } from "./consultation-budget.ts";
import { basisSourcesFromCard, withCompletedBasis } from "./chat-basis-completeness.ts";
import { answerShapeData } from "./chat-answer-shape-data.ts";
import { addImpliedKeys, bodyMechanismSentences, bodyTerms, checkBodyDirection, checkDirection, checkTimelineEntries, expandEvidenceKeys, hasEvidenceTags } from "./chat-evidence-keys.ts";
import { chineseNamesAndTerms, cleanChatAnswer } from "./chat-answer-checks.ts";
import { answerRepairPlan, answerRepairPrompt, applyAnswerRepair, parseAnswerRepair, withoutFailingFixes } from "./chat-answer-repair.ts";
@@ -1350,6 +1351,9 @@ export function streamAgentResponse(options: StreamAgentResponseOptions) {
const timeline = checkTimelineEntries(implied.output, card);
const direction = checkDirection(implied.output, card);
const expanded = expandEvidenceKeys(implied.output, card);
// BUG-2281: the lit chart areas and the strip tones, from the keys before they leave the text.
const shape = answerShapeData(implied.output, card);
options.state.answerShape = shape.areas.length || shape.tones.length ? shape : undefined;
options.state.answerChecks = {
...options.state.answerChecks,
plainBody: {
@@ -1,6 +1,7 @@
import { attachFastTransits } from "../lib/chat-transit-window.ts";
import { claimCardsWithTables } from "../lib/chat-answer-tables.ts";
import { claimCardsWithKeyedTables } from "../lib/chat-evidence-keys.ts";
import type { AnswerShapeData } from "../lib/chat-answer-shape.ts";
import {
RECTIFICATION_DIRECT_NEW_COPY,
RECTIFICATION_DIRECT_RESUME_COPY,
@@ -463,6 +464,8 @@ export type ConsultationRuntimeState = {
/** BUG-1948: the internal-word check on 「判断依据」 (lines found, rewritten, table-replaced, left) and words seen in the body. Internal only. */
internalWords?: { found: number; rewritten: number; tabled: number; remaining: number; body: string[] };
/** BUG-2229: what the deterministic clean-up and the layer repair did to this answer (records only). */
/** BUG-2281: lit chart areas and one-year strip tones, derived from the answer's evidence keys; goes on the receipt. */
answerShape?: AnswerShapeData;
answerChecks?: { steps?: unknown; flags?: number; asked?: string[]; optionalNotMentioned?: string[]; repair?: Record<string, number>; plainBody?: Record<string, unknown> };
};
+66 -21
View File
@@ -7,6 +7,19 @@ import {
type ConsultationAnswerMode,
} from "../lib/consultation-thinking-plan.ts";
import { GLOSSARY_LINE } from "../lib/chat-answer-checks.ts";
import {
BODY_HEADINGS, DEFAULT_TIMELINE_HEADING, DOMAIN_NAMES, FOLLOW_UP_HEADING, VERDICT_HEADING, VERDICT_LABELS, type AnswerShapeDomain,
} from "../lib/chat-answer-shape.ts";
const SHAPE_DOMAINS = Object.keys(VERDICT_LABELS) as AnswerShapeDomain[];
/** BUG-2281: the verdict card's fixed label trio per domain, as the model reads it. */
function verdictLabelLines(): string {
return SHAPE_DOMAINS.map((domain) => ` - ${DOMAIN_NAMES[domain]}:${VERDICT_LABELS[domain].map((label) => `「- **${label}**:……」`).join("")}`).join("\n");
}
/** BUG-2281: the body's five fixed headings per domain. */
function bodyHeadingLines(): string {
return SHAPE_DOMAINS.map((domain) => ` - ${DOMAIN_NAMES[domain]}:${BODY_HEADINGS[domain].map((heading) => `「## ${heading}」`).join("")}`).join("\n");
}
/**
* The one statement of how a consultation answer is written (BUG-1540,
@@ -204,42 +217,74 @@ const NO_BLAME_LINE = plainVoiceLine("- 不推责");
* Kept: red lines, 不推责, length priority (BUG-2182), yes / no first (BUG-1974), method status (now in 「判断依据」), 落陷取消写「有缓解」(BUG-2280)
* (BUG-2169), classical sayings weighed (BUG-2153), natal vs annual Sahams, Argala house numbers, the precomputed tables.
*/
/*
* BUG-2281 (owner-approved chat prototype 2026-11-24; a beta user could not read the answers: too many words, no clear
* conclusion first, analysis not in everyday language).
* 原值 (BUG-2247): first turn in sections 一句话结论 / 判断 / 落到生活里 / 时间线 / 要留意的 / 判断依据, body about 2,500–4,000
* characters, one plain cause sentence allowed per judgment (「星盘上这一点很明确」), timeline entries 「- **日期:小标题**:……」,
* a closing question allowed. 新值: fixed headings the page turns into the prototype's parts — 「## 结论」 (one sentence + the
* domain's fixed label trio), the timeline 「- **小标题**(年月到年月):一句。该做:……。别做:……〔T〕」, five body blocks with
* fixed headings per domain (every item a bold conclusion + two or three short sentences), 「## 接着问」 (three questions in
* the user's voice), then 「## 判断依据」 as before; the reader described sentence by sentence with the prototype's text as
* the worked example; no chart reasons in the body at all; body about 1,200–1,600 characters with no cap that drops
* judgments. 原因: the owner approved the prototype's layout and tone. Kept: evidence keys on every judgment, the
* timeline keys and pressure words, 「判断依据」, red lines, length priority (BUG-2182), yes / no first (BUG-1974).
*/
export const chatConversationVoice = `VISIBLE VOICE
读的人:一个从没接触过占星的普通人,带着一件真实的事来问。他要一个明确的结论、听得懂的理由,和接下来每一段该怎么过。对着「你」说,语气温和、直接,说平常话,不叫名字(上下文里的称呼只用来知道是谁)。只是打招呼、道谢、告别时回一句话,20 字以内,不讲星盘。
读的人:一个从没接触过占星的普通人,带着一件真实的事来问。她嫌字多、读不进去,要先看到结论,再看懂每一条在日子里是什么样子、接下来每一段该怎么过。对着「你」说,像跟一个从没听说过占星的朋友讲话,语气温和、直接,不叫名字(上下文里的称呼只用来知道是谁)。只是打招呼、道谢、告别时回一句话,20 字以内,不讲星盘。
用户说了要多长(「一两句话」「简单说」「只要结论」)时正文就只写那么长:「一两句话」只写一两句,不分段、不套下面的分节,优先于下面所有要求;「## 判断依据」照常。
正文(用户读的部分)说人话:
- 正文里不写宫位编号和「宫」字、不写技法和运程的名字(大运、小运、细运、Narayana、Sade Sati、Kantaka、Argala、Yoga、Saham、D9、D10、A10、SAV、Shadbala 这类都不写)、不写分盘、相位、行运、上升、落陷、入旺、功能吉星这些词,不写星座名、行星名、分数、度数和英文。全文唯一能用的盘面词是「星盘」。
- 正文不讲星盘的构造,换成平常话也不讲:哪颗星管什么、哪颗星落在哪里、什么照着或点着什么、表里排第几、哪一层怎样、运期换成了哪颗星,这些都只在「判断依据」里。理由最多一句短话,说用户自己认得出的样子或处境(「你做事向来稳,不爱被人催」「这几年钱来得多,花得也多」),或者直接说「星盘上这一点很明确」「有几处同时指向这里」;不列数据、不讲推导。写完正文自己查一遍:凡是在说「哪一颗、哪一处、哪个位置、哪一层、哪一格」怎样的句子,都改成那件事在生活里的样子。
句子怎么写:
- 句子短,一句只说一件事;一段两三句。用平常日子里的词,不用书面词和比喻。
- 正文里不写宫位编号和「宫」字,一句盘面上的理由都不写:不写星、运期、分盘、相位、星座、分数、度数、技法名(大运、小运、细运、Narayana、Sade Sati、Kantaka、Argala、Yoga、Saham、D9、D10、A10、SAV、Shadbala、行运、上升、落陷、入旺、功能吉星这类都不写),也不写「星盘上……的位置」「有几处指向这里」这类话。全文唯一能用的盘面词是「星盘」。为什么这么判断,全部放进「判断依据」。要说原因时,只说用户自己认得出的样子或处境(「你做事向来稳,不爱被人催」)。
- 正文不讲星盘的构造,换成平常话也不讲:哪颗星管什么、哪颗星落在哪里、什么照着或点着什么、表里排第几、哪一层怎样、运期换成了哪颗星,这些都只在「判断依据」里。写完正文自己查一遍:凡是在说「哪一颗、哪一处、哪个位置、哪一层、哪一格」怎样的句子,都改成那件事在生活里的样子。
- 写具体的事:工作写到岗位和做法,钱写到从哪来、怎么留,感情写到相处的样子和对方大致的样子,时间写到年月,建议写到做多少(「把下半年的活砍掉两成」「先谈两三个老客户」)。
- 判断由你下:不推回给用户,不写「定不了」「都可能」;拿不准时说更偏哪一种,用一个「多半」。不写保证的话(一定、必然、注定),也不在后面补一句叫人别当真的话。帮忙的一面和拖后腿的一面都写,最后合成一个明确的判断。
- 用户自己用了专业词,或者问依据(「依据是什么」「哪个宫」「大运是什么」「为什么这么说」)时,可以照他的问法用这些词,每个词第一次出现时用几个字解释;这时候数据也可以写进正文。
- 判断要落到生活里:事业说到岗位和职能、适合怎样的工作方式;钱说到收入从哪来、以什么形式来、留不留得住;感情说到相处的样子和对方大致的样子;身体说到先在哪里出现、平时怎么照顾。说清适合什么、不适合什么、可以试的几件事。
- 判断由你下:不推回给用户,不写「定不了」「都可能」;拿不准时说更偏哪一种、出现什么情况就要改看另一种。不写保证的话(一定、必然、注定),也不在后面补一句叫人别当真的话。帮忙的一面和拖后腿的一面都写,最后合成一个明确的判断。
首轮回答的结构(用 ## 标题,按这个顺序写):
## 一句话结论:一两句话,结论加时间窗(例如「先收后放,2028 到 2029 年最好」);用户问能不能、会不会、是不是的时候,第一句先答能或不能、会或不会(拿不准就说多半能、多半不会),再说条件。
## 判断(标题按问题起,用平常话,例如「适合的方向」「你是什么样的人」「钱从哪来、留不留得住」):按依据多少排出两到四条,每条先一句 **加粗** 的白话结论,再写它在日子里具体是什么样子,最后最多一句平常话的原因;每条段末写〔〕和这条判断用到的表行编号(程序会去掉,用来核对)。
## 落到生活里:适合怎么做、不适合走哪条路、可以试的事。
## 时间线:按问题定长短——
- 问的不是时间(例如「我是什么样的人」「我适合什么」的性格题):不写这一节,改成在「落到生活里」末尾用一两句说眼下这一段大概是什么状态。
- 一般的问题:写接下来 12 个月,按自然的几段合并成 4 到 6 条,再用一句话说 12 个月之后下一个真正的转折点在什么时候。
- 用户说了范围(未来两年、到 2030 年):照他的范围写,仍按自然的段落合并,最多 8 条。
每条写成「- **2026 年 12 月到 2027 年 4 月:一个平常话的小标题**:这一段是什么样子;该做什么;别做什么」,不写原因、不讲星盘;这一段(或其中一部分)在土星压力段里就直说偏吃力(「这一段整体偏吃力,别给自己加量」「4 月初之前做事容易卡」);日期写到年月,只有真正的转折点才写到哪一天。每条末尾写〔〕和它合并的 period_coverage 行的编号(例如〔T3 T4〕),日期从这些行来:第一行的开始到最后一行的结束;「整段 / 前半 / 后半 / 偏吃力」照这些行的「土星压力段」写。不把每个细小的运期单独列一条。
## 要留意的:几条风险,每条写什么时候、会是什么样子、怎么应对。
## 判断依据:正文每条判断一条,按正文的顺序,写成「- **判断短句**:一句说明。(依据性质)〔编号〕」。〔〕里写这条判断用到的表行编号(precomputed_tables 里每行前面的〔〕,例如〔H10 Sa D10 FB〕),程序会把这些行原样列出来,所以这里不抄数据、不重复正文的话。「一句说明」只写表行里没有的:两套推时间的方法 Vimshottari 和 Narayana 有没有指到同一段(卡上 Narayana 标为候选、起算有一步没定时写「只有一种方法指到这里」)、格局的状态(照卡上状态,待核就写待核)、落陷有没有缓解(卡上写有缓解就写「落陷,但有缓解」,不写待核)、年盘或 Mudda 带来的变化、卡上 classical_texts 的「传统说法:大意;在这张盘里:哪些条件撑住或削弱它」;没有这些就只写编号。这句说明最多 40 个字,不写宫位、星座、度数、分数、个数和运期日期(这些都在编号的行里,再写一遍就是重复;行里没有的数字和「相等」这类比较不写)。首轮大约 8 到 12 条:按正文的判断写,时间线不单独成条(程序把时间线各段合成一条),要留意的几条用到的行并进相关判断那一条。括号里的依据性质从这几样里选:几种方法一致、只有一种方法支持、出生时间稍有出入就会变、相关分盘还没核实、不同方法对这段时间说法不同,不写字母等级。时间线各段的编号已经写在正文那几条后面,这里不再列。卡上算出、又和用户问的事有关的第二套运程的当前段和下一段(Narayana、Chara)、Jaimini 代表星(AmK、DK 等)、对口的分盘,都在相关那一条的编号里带上(例如〔N1 AmK D10〕)。说明里写到木星土星同时作用某一块时,Position 写「进入」,Aspect 写「照到」,不写「经过」。
首轮回答的结构(用 ## 标题,按这个顺序,标题照下面的字写,页面按标题把回答排成卡片和时间条):
## ${VERDICT_HEADING}
第一行一句话回答这个问题,先给结论;用户问能不能、会不会、是不是的时候,第一句先答能或不能、会或不会(拿不准就说多半能、多半不会),再说条件。接着三行,按问题的领域选一组标签,标签一字不改,冒号后面写你的判断,每行 15 字以内:
${verdictLabelLines()}
## ${DEFAULT_TIMELINE_HEADING}(问题有时间的一面才写。问的不是时间(例如「我是什么样的人」「我适合什么」的性格题)不写这一节。用户说了范围就照他的范围写,标题改成「接下来两年」「2027 到 2028 年」这样)
每条一行,写成「- **小标题**(2026 年 11 月到 12 月):一句话说这一段是什么样子。该做:……。别做:……。〔T3 T4〕」。小标题 2 到 4 个字(收尾、起步、最好用、守住、松一点);括号里只写起止年月,第一段从「现在」写起(「现在到 2026 年 12 月」);只有真正的转折点才写到哪一天。一般问题写接下来 12 个月,按自然的几段合并成 4 到 6 条;用户说了范围就照他的范围写,仍按自然的段落合并,最多 8 条。末尾〔〕写它合并的 period_coverage 行的编号,起止从这些行来:第一行的开始到最后一行的结束;这一段(或其中一部分)在土星压力段里就在那句话里直说偏吃力,「整段 / 前半 / 后半」照这些行的「土星压力段」写。不把每个细小的运期单独列一条。最后可以另起一行(不加「-」)用一句话说 12 个月之后下一个真正的转折点。
接下来五块,标题按领域照写:
${bodyHeadingLines()}
每块两到四条。每条单独一段:先一句 **加粗** 的话,它本身就是一个结论;后面两三句短句,说它在日子里是什么样子、具体怎么做。段末写〔〕和这条判断用到的表行编号(程序会去掉,用来核对)。第二块的各条按合适程度排,加粗句开头写「一、」「二、」「三、」。「要留意的」每条写什么时候、会是什么样子、怎么应对。
正文(从「${VERDICT_HEADING}」到「要留意的」)大约 1,200 到 1,600 字。这是读的人能读完的长度,但不为凑短删掉判断:卡上和这件事有关的判断都要写到,写不下就把句子写短。
## ${FOLLOW_UP_HEADING}
三行,每行「- ……?」:读完这一篇最可能接着问的三个具体问题,跟这篇的内容走(某一段时间怎么过、某个选择要不要做),用用户自己的口吻(「我」),平常话,每条 25 字以内,不重复刚才问的那句。
## 判断依据:正文每条判断一条,按正文的顺序,写成「- **判断短句**:一句说明。(依据性质)〔编号〕」。〔〕里写这条判断用到的表行编号(precomputed_tables 里每行前面的〔〕,例如〔H10 Sa D10 FB〕),程序会把这些行原样列出来,所以这里不抄数据、不重复正文的话。「一句说明」只写表行里没有的:两套推时间的方法 Vimshottari 和 Narayana 有没有指到同一段(卡上 Narayana 标为候选、起算有一步没定时写「只有一种方法指到这里」)、格局的状态(照卡上状态,待核就写待核)、落陷有没有缓解(卡上写有缓解就写「落陷,但有缓解」,不写待核)、年盘或 Mudda 带来的变化、卡上 classical_texts 的「传统说法:大意;在这张盘里:哪些条件撑住或削弱它」;没有这些就只写编号。这句说明最多 40 个字,不写宫位、星座、度数、分数、个数和运期日期(这些都在编号的行里,再写一遍就是重复;行里没有的数字和「相等」这类比较不写)。首轮大约 8 到 12 条:按正文的判断写,时间线不单独成条(程序把时间线各段合成一条),要留意的几条用到的行并进相关判断那一条。括号里的依据性质从这几样里选:几种方法一致、只有一种方法支持、出生时间稍有出入就会变、相关分盘还没核实、不同方法对这段时间说法不同,不写字母等级。时间那一节各段的编号已经写在那几条后面,这里不再列。卡上算出、又和用户问的事有关的第二套运程的当前段和下一段(Narayana、Chara)、Jaimini 代表星(AmK、DK 等)、对口的分盘,都在相关那一条的编号里带上(例如〔N1 AmK D10〕)。说明里写到木星土星同时作用某一块时,Position 写「进入」,Aspect 写「照到」,不写「经过」。
写法示例(问「我适合做什么样的工作?」;只学结构、句子长短和用词,内容按这张盘写):
## ${VERDICT_HEADING}
你适合把手上的专业做深,靠写、讲、教和一对一帮人解决问题吃饭,不适合带一大队人往大里做。
- **最适合**:写东西、讲课、做顾问
- **先别碰**:招很多人、借钱扩张
- **最好的时候**:2026 年 12 月到 2027 年 5 月
## ${DEFAULT_TIMELINE_HEADING}
- **守住**(2027 年 5 月到 10 月):会比较累,先守住。该做:把手上的客户服务好,主动少接两成的活。别做:别开新摊子,别答应做不完的事。〔T4〕
## ${BODY_HEADINGS.career[0]}
**你更适合一对一,不适合管一大群人。** 和一个人或者一个小团队坐下来把事情谈透,是你最舒服、也最出活的状态。带很多人、天天开会协调,会很快把你耗空。〔H7 Me〕
**你吃亏在不好意思谈钱。** 报价的时候你容易先替对方省钱。价格、做到哪一步算完、能改几次,都先写下来再开工。〔H2 Sa〕
## ${FOLLOW_UP_HEADING}
- 明年 5 月之后那段难的时候,我该怎么过?
- 我现在这份工作要不要换?
- 我该怎么给自己定价?
怎么写
- 卡上为这道题交付的层,和这件事有关的都要用进判断,正文只说它们带来的结果,依据写进「判断依据」那一条的编号或说明;对这件事不起作用的层不写,不列「中性」「用不上」的清单。
- 推荐某一段时,同一句里用平常话说这段是不是压力大的时候(照 period_coverage 那一行的「土星压力段」:有就说「这一段压力偏大」,没有就不提)。
- 推荐某一段时(结论卡的「最好的时候」也算),同一句里用平常话说这段是不是压力大的时候(照 period_coverage 那一行的「土星压力段」:有就说「这一段压力偏大」,没有就不提)。
- 正文的日期写到年月;卡上没写出生时间已校正时,第一次写日期顺带说一句这些时间按出生时间推,出生时间差几分钟会移动几天。
- 建议要具体:每段时间写做什么、不做什么。不给医疗、法律、投资指令:不推荐具体投资品,不开药,不列化验单;健康只写作息、减负、什么情况该去看医生。
- 用户说过的事实照用。可以在末尾问一句现在的处境(在哪一行、现在的关系状态)帮着再收窄;不请用户回想过去的事来帮着推将来,用户讲的过往经历也不用来改对将来的判断。
- 用户说过的事实照用。不在正文末尾另问用户问题,想帮着收窄(在哪一行、现在的关系状态)就写成「接着问」里的一条;不请用户回想过去的事来帮着推将来,用户讲的过往经历也不用来改对将来的判断。
- 可以用 ## 标题、列表和加粗;不画表格。
- 用到行星和星座时都写中文,罗睺、计都;同一个东西全篇一个叫法。
- ${GLOSSARY_LINE}(这张表用在「判断依据」和用户自己问到这些词的时候。)
- 卡上 columns、use、label、note、boundary 这些字段是写给你看的说明,不是写给用户的话:正文和判断依据都不照抄、不转述它们,不写「这一句」「不是二选一」这类讲写法本身的话。
- 本命盘上的 Sahams 和年盘上的 Sahams 是两组不同的点:判断依据里写哪一组就照哪一组的行,写明是哪一张盘上的。
- 卡上 precomputed_tables 是按卡算好的表(宫主、行星、运期起止和时长、细运和行运的重叠、慢星时间表、双重行运、土星压力段、其他运程):判断时只照这些表,不自己重新数、不自己推算时长;它们每行前面的〔编号〕用来在「判断依据」和时间线里引用。
- 追问轮不套上面的分节:第一句就回答这一句,只讲和它相关的;有新判断时末尾写「## 判断依据」,格式同上(编号照写)。用户问依据、问为什么时,正文可以说出是哪颗星、哪一块、哪一段运期,每个专业词第一次出现时用几个字解释。
- 追问轮写得轻一些:先「## ${VERDICT_HEADING}」一句话直接回答这一句(上面那组标签里用得上的可以带一两行);再只写和它直接相关的几条,每条同样先一句加粗的结论、再两三句;问的是时间时才写时间那一节(格式同上);然后「## ${FOLLOW_UP_HEADING}」三条;有新判断时末尾写「## 判断依据」,格式同上(编号照写)。用户问依据、问为什么时,正文可以说出是哪颗星、哪一块、哪一段运期,每个专业词第一次出现时用几个字解释。
${NO_BLAME_LINE} 方法状态那一句(只有一种方法指向、两套没对上)是证据本身的事实,写在「判断依据」那一条里,不算这一类。
红线(这几条之外靠你的判断):
@@ -249,7 +294,7 @@ ${SAFETY_RED_LINE}
- 不自造卡上没有的格局名,不把运期写成推着谁、替谁收尾的角色,空的那一块不单独下结论(看管它的那颗星现在怎样)。
- 不以「根据计算结果」「综合来看」「从星盘来看」开头;不写一切都会好、相信自己、加油。
- 不写软件和程序库的名字,不引书名、作者、表号、章节和页码;不写间隔号;不写字母等级和打分;不提联网检索、外部资料或案例核对;不写技法审计表。
- 不写内部字段名、规则编号、英文状态码、JSON 和表格;〔编号〕只写在时间线每条末尾和「判断依据」每条末尾。
- 不写内部字段名、规则编号、英文状态码、JSON 和表格;〔编号〕只写在正文每条判断末尾、时间那一节每条末尾和「判断依据」每条末尾。
${DOWNGRADE_ROUTES}`;
@@ -0,0 +1,271 @@
// BUG-2281 (owner-approved chat prototype, 2026-11-24): the answer's shape — verdict card, chart row, one-year strip,
// plain body, 接着问, folded 判断依据 — carried as fixed markdown headings the page reads with a strict parser.
import "./install-test-document";
import assert from "node:assert/strict";
import test from "node:test";
import React from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { ChatMessageContent } from "../src/components/chat-message-content.tsx";
import { segmentWeights } from "../src/components/chat-answer-shape.tsx";
import { cleanChatAnswer } from "../src/lib/chat-answer-checks.ts";
import { answerFollowUpQuestions, BODY_HEADINGS, parseAnswerShape, rangeMonths, VERDICT_LABELS } from "../src/lib/chat-answer-shape.ts";
import { answerShapeData, opportunityTone } from "../src/lib/chat-answer-shape-data.ts";
import { CHART_AREA_NAMES, chartAreaNames } from "../src/lib/chat-chart-areas.ts";
import { checkTimelineEntries, evidenceKeyRows, expandEvidenceKeys } from "../src/lib/chat-evidence-keys.ts";
import { loadChatMarkdown } from "../src/lib/chat-markdown-loader.ts";
import { streamingMarkdownView } from "../src/lib/chat-streaming-markdown.ts";
import { splitJudgmentBasis } from "../src/lib/consult-judgment-basis.ts";
import type { EvidenceCard } from "../src/lib/consultation-evidence-card.ts";
import { CHAT_FIRST_TURN_SHAPE } from "../src/lib/consultation-thinking-plan.ts";
import { chatConversationVoice } from "../src/mastra/product-voice.ts";
// The public test chart of chat-plain-body-2247.test.ts (Rodden AA), same cut.
const SIGNS = ["Capricorn", "Aquarius", "Pisces", "Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius"];
function card(): EvidenceCard {
return {
domains: ["career"],
base: {
natal: {
ascendant: { sign: "Capricorn" },
houses: Object.fromEntries(SIGNS.map((sign, index) => [String(index + 1), sign])),
functional_benefic_malefic: {
functional_benefics: ["Mercury", "Saturn", "Venus"], functional_malefics: ["Jupiter", "Mars"], functional_neutrals: ["Moon", "Sun"], yogakarakas: ["Venus"],
owned_houses: { Jupiter: [3, 12], Mars: [4, 11], Mercury: [6, 9], Moon: [7], Saturn: [1, 2], Sun: [8], Venus: [5, 10] },
},
planets: {
Moon: { sign: "Taurus", house: 5, degree_in_sign: 11.49, nakshatra: "Rohini", status: "入旺(Exalted)" },
Saturn: { sign: "Capricorn", house: 1, degree_in_sign: 3.46, nakshatra: "Uttara Ashadha", status: "入庙(Own)", retrograde: true },
Jupiter: { sign: "Capricorn", house: 1, degree_in_sign: 8.99, nakshatra: "Uttara Ashadha", status: "落陷(Debilitated)" },
Venus: { sign: "Gemini", house: 6, degree_in_sign: 9.92, nakshatra: "Ardra", status: "极友(Great Friend)" },
},
more: {
sav_all_houses: { rows: { 1: ["Capricorn", 23, "挑战"], 2: ["Aquarius", 24, "挑战"], 3: ["Pisces", 32, "极吉"], 4: ["Aries", 32, "极吉"], 5: ["Taurus", 31, "极吉"], 6: ["Gemini", 29, "吉利"], 7: ["Cancer", 27, "中等"], 8: ["Leo", 21, "挑战"], 9: ["Virgo", 25, "中等"], 10: ["Libra", 33, "极吉"], 11: ["Scorpio", 37, "极吉"], 12: ["Sagittarius", 23, "挑战"] } },
argala_all_houses: { rows: { 10: { verdict: "待定", helpers: [{ natal_house: 6, planets: "Venus", state: "待定" }], blockers: [] } } },
},
},
timing: {
vimshottari: {
mahadasha: { lord: "Saturn", start: "2011-06-24", end: "2030-06-24" },
antardasha: { lord: "Rahu", start: "2025-02-04", end: "2027-12-12" },
antardashas_in_mahadasha: [["Rahu", "2025-02-04", "2027-12-12"], ["Jupiter", "2027-12-12", "2030-06-24"]],
},
sub_periods: { rows: [["Saturn", "Rahu", "Ketu", "2026-10-04", "2026-12-04"], ["Saturn", "Rahu", "Venus", "2026-12-04", "2027-05-26"], ["Saturn", "Rahu", "Sun", "2027-05-26", "2027-07-17"]] },
transits_detail: {
reference_date: "2026-11-23",
bodies: { Jupiter: { sign: "Leo" }, Saturn: { sign: "Pisces" }, Rahu: { sign: "Aquarius" }, Ketu: { sign: "Leo" } },
key_dates_window: { start: "2026-11-23", end: "2030-11-23" },
key_dates: [{ kind: "ingress", date: "2027-05-20", body: "saturn", to_sign: "Aries" }],
},
},
},
domain_sections: {
career: { double_transit: { houses_checked: [9, 10], by_house: { rows: { 9: [["2026-11-23", "2027-02-05"]], 10: [["2026-11-23", "2027-02-05"], ["2027-05-20", "2030-11-23"]] } } } },
},
} as unknown as EvidenceCard;
}
const periodKey = (head: string) => evidenceKeyRows(card()).find((row) => row.table === "timing.period_coverage" && row.text.startsWith(head))!.key;
const NOW = 2026 * 12 + 10; // 2026-11
const VERDICT = [
"## 结论",
"你适合把手上的专业做深,靠写、讲、教吃饭,不适合带一大队人往大里做。",
"- **最适合**:写东西、讲课、做顾问",
"- **先别碰**:招很多人、借钱扩张",
"- **最好的时候**:2026 年 12 月到 2027 年 5 月",
].join("\n");
const TIMELINE = [
"## 接下来一年",
"- **收尾**(现在到 2026 年 12 月):把手上的事收干净。该做:把欠着的活交掉。别做:这十来天别谈新的合作。",
"- **最好用**(2026 年 12 月到 2027 年 5 月):这一年最值得用的一段。该做:谈客户、定价、开课。别做:重要的合同别拖到 5 月以后。",
"- **守住**(2027 年 5 月到 10 月):会比较累,偏吃力。该做:主动少接两成的活。别做:别开新摊子。",
"12 个月之后,下一个转折在 2028 年 1 月。",
].join("\n");
const BODY = [
"## 你的长处和短处",
"**你更适合一对一,不适合管一大群人。** 和一个小团队坐下来把事情谈透,是你最出活的状态。带很多人会很快把你耗空。",
"",
"## 要留意的",
"**明年 5 月到 10 月,先累在身体上。** 提前把下半年的活砍掉两成。连着两三周睡不好,就去看医生。",
].join("\n");
const NEXT = ["## 接着问", "- 明年 5 月之后那段难的时候,我该怎么过?", "- 我现在这份工作要不要换?", "- 我该怎么给自己定价?"].join("\n");
const BASIS = "## 判断依据\n\n- **更适合一对一**:几种方法一致。(几种方法一致)";
const FULL = [VERDICT, TIMELINE, BODY, NEXT].join("\n\n");
test("BUG-2281: every section present — verdict, strip, body, 接着问", () => {
const shape = parseAnswerShape(FULL, { now: NOW })!;
assert.equal(shape.verdict.sentence, "你适合把手上的专业做深,靠写、讲、教吃饭,不适合带一大队人往大里做。");
assert.deepEqual(shape.verdict.facts.map((fact) => fact.label), ["最适合", "先别碰", "最好的时候"]);
assert.equal(shape.verdict.facts[2]!.value, "2026 年 12 月到 2027 年 5 月");
assert.equal(shape.timeline!.heading, "接下来一年");
assert.deepEqual(shape.timeline!.segments.map((segment) => segment.title), ["收尾", "最好用", "守住"]);
const [first, second] = shape.timeline!.segments;
assert.equal(first!.sentence, "把手上的事收干净。");
assert.equal(first!.doThis, "把欠着的活交掉。");
assert.equal(first!.avoid, "这十来天别谈新的合作。");
assert.deepEqual(first!.months, [NOW, 2026 * 12 + 11]);
assert.deepEqual(second!.months, [2026 * 12 + 11, 2027 * 12 + 4]);
assert.deepEqual(segmentWeights(shape.timeline!.segments), [2, 6, 6]);
assert.equal(shape.timeline!.note, "12 个月之后,下一个转折在 2028 年 1 月。");
assert.deepEqual(shape.followUps, ["明年 5 月之后那段难的时候,我该怎么过?", "我现在这份工作要不要换?", "我该怎么给自己定价?"]);
assert.match(shape.body, /^## 你的长处和短处/u);
assert.doesNotMatch(shape.body, /## 结论|## 接下来一年|## 接着问|该做:/u);
assert.deepEqual(answerFollowUpQuestions(FULL), shape.followUps);
});
test("BUG-2281: each section missing — the rest still reads; without 「## 结论」 at the top it is not this shape", () => {
const noTimeline = parseAnswerShape([VERDICT, BODY, NEXT].join("\n\n"))!;
assert.equal(noTimeline.timeline, null);
assert.equal(noTimeline.followUps.length, 3);
const noNext = parseAnswerShape([VERDICT, TIMELINE, BODY].join("\n\n"))!;
assert.deepEqual(noNext.followUps, []);
const sentenceOnly = parseAnswerShape(["## 结论", "多半能,但要等到明年春天。", "", BODY].join("\n"))!;
assert.equal(sentenceOnly.verdict.sentence, "多半能,但要等到明年春天。");
assert.deepEqual(sentenceOnly.verdict.facts, []);
const noBody = parseAnswerShape([VERDICT, NEXT].join("\n\n"))!;
assert.equal(noBody.body, "");
// Older answers (BUG-2247 「一句话结论」), a one-sentence answer and report-chat answers are not this shape.
assert.equal(parseAnswerShape("## 一句话结论\n\n先稳住。\n\n## 时间线\n\n- **2026 年 12 月:打底子**:照常做。"), null);
assert.equal(parseAnswerShape("多半能,明年春天。"), null);
assert.equal(parseAnswerShape(`开头一段。\n\n${FULL}`), null);
});
test("BUG-2281: a malformed section falls back to plain markdown in place, never raw markers", () => {
const badLabel = parseAnswerShape(FULL.replace("- **先别碰**:", "- **第 10 宫**:"))!;
assert.equal(badLabel.verdict.sentence, "");
assert.match(badLabel.body, /^## 结论\n你适合/u);
const badItem = parseAnswerShape(FULL.replace("- **守住**(2027 年 5 月到 10 月):", "- **2027 年 5 月到 10 月:守住**:"))!;
assert.equal(badItem.timeline, null);
assert.match(badItem.body, /## 接下来一年\n- \*\*收尾\*\*/u);
const many = Array.from({ length: 9 }, (_, index) => `- **第${index}段**(2027 年 ${index + 1} 月到 ${index + 1} 月):一句。`).join("\n");
assert.equal(parseAnswerShape(`${VERDICT}\n\n## 接下来两年\n${many}`)!.timeline, null);
assert.equal(parseAnswerShape(`${VERDICT}\n\n## 接着问\n随便问。`)!.followUps.length, 0);
// Four labels are more than the card holds.
assert.equal(parseAnswerShape(VERDICT.replace("- **最好的时候**", "- **长处**:x\n- **最好的时候**"))!.verdict.facts.length, 0);
assert.deepEqual(rangeMonths("2026 年 11 月到 2 月"), [2026 * 12 + 10, 2027 * 12 + 1]);
assert.equal(rangeMonths("这几周"), null);
});
test("BUG-2281: streamed partially — verdict first, a half line or half heading is held back", () => {
const cuts = [12, 40, VERDICT.indexOf("- **先别") + 6, VERDICT.length + 6, VERDICT.length + 40, FULL.indexOf("- **守住") + 10, FULL.indexOf("## 接着问") + 4, FULL.length - 5];
for (const cut of cuts) {
const view = streamingMarkdownView(FULL.slice(0, cut));
const shape = parseAnswerShape(view, { streaming: true, now: NOW });
assert.ok(shape, `cut ${cut}`);
assert.doesNotMatch(shape!.body, /^## (?:结|接)/mu, `cut ${cut}: no half heading or special section in the body`);
assert.doesNotMatch(`${shape!.verdict.sentence}${shape!.verdict.facts.map((fact) => fact.label + fact.value).join("")}`, /\*|#/u);
}
const midFacts = parseAnswerShape(streamingMarkdownView(FULL.slice(0, VERDICT.indexOf("- **先别") + 6)), { streaming: true })!;
assert.deepEqual(midFacts.verdict.facts.map((fact) => fact.label), ["最适合"]);
const midStrip = parseAnswerShape(streamingMarkdownView(FULL.slice(0, FULL.indexOf("- **守住") + 10)), { streaming: true, now: NOW })!;
assert.equal(midStrip.timeline!.segments.length, 2);
// The questions show once their section is complete.
assert.deepEqual(parseAnswerShape(streamingMarkdownView(FULL.slice(0, FULL.length - 5)), { streaming: true })!.followUps, []);
assert.equal(parseAnswerShape(streamingMarkdownView("## 结"), { streaming: true }), null);
});
test("BUG-2281: the page — verdict card, chart row with the lit areas, strip, body, 接着问, folded basis; no markers shown", async () => {
await loadChatMarkdown();
const text = `${FULL}\n\n${BASIS}`;
const markup = renderToStaticMarkup(
<ChatMessageContent text={text} structured answerShape={{ areas: [1, 10, 6, 2], tones: ["steady", "steady", "heavy"] }} onFollowUp={() => undefined} />,
);
assert.match(markup, /class="chat-answer-verdict"/u);
assert.match(markup, /<dt>最适合<\/dt><dd>写东西、讲课、做顾问<\/dd>/u);
assert.match(markup, /这次看了 4 个地方:性格、事业、每天的工作、收入/u);
assert.equal((markup.match(/class="is-lit"/gu) ?? []).length, 4);
assert.equal((markup.match(/chat-answer-strip-segment is-/gu) ?? []).length, 3);
assert.match(markup, /chat-answer-strip-segment is-heavy/u);
assert.match(markup, /<span>偏吃力<\/span>|<i class="is-heavy"><\/i>偏吃力/u);
assert.doesNotMatch(markup, /<i class="is-chance">/u, "the legend shows only the tones in use");
assert.match(markup, /class="chat-answer-next"/u);
assert.match(markup, /consult-judgment-basis/u);
assert.ok(markup.indexOf("chat-answer-next") < markup.indexOf("consult-judgment-basis"));
const visible = markup.replace(/<[^>]+>/gu, "");
assert.doesNotMatch(visible, /##|\*\*|〔/u);
assert.doesNotMatch(visible, /第 \d+ 宫/u);
// Without the receipt's tones the strip is neutral and shows no legend; without a send callback no questions.
const bare = renderToStaticMarkup(<ChatMessageContent text={text} structured />);
assert.doesNotMatch(bare, /chat-answer-strip-legend|chat-answer-areas|chat-answer-next/u);
assert.match(bare, /chat-answer-strip-segment is-pending/u);
// Tones that do not match the segments are not used.
assert.doesNotMatch(renderToStaticMarkup(<ChatMessageContent text={text} structured answerShape={{ areas: [], tones: ["heavy"] }} />), /is-heavy/u);
});
test("BUG-2281: stored answers from before this change render exactly as before; report chats are not read for the shape", async () => {
await loadChatMarkdown();
const old = "## 一句话结论\n\n先稳住,2027 年下半年再往前推。\n\n## 时间线\n\n- **2026 年 12 月到 2027 年 5 月:打底子**:照常做。\n\n## 判断依据\n\n- **底子稳**:说明。(几种方法一致)";
assert.equal(renderToStaticMarkup(<ChatMessageContent text={old} structured />), renderToStaticMarkup(<ChatMessageContent text={old} />));
// A new-shape text in a surface that does not opt in (report chats) keeps today's rendering.
assert.doesNotMatch(renderToStaticMarkup(<ChatMessageContent text={FULL} />), /chat-answer-verdict/u);
});
test("BUG-2281: lit areas come from the answer's evidence keys; strip tones from the cited rows' Saturn pressure", () => {
const venus = periodKey("金星细运");
const sun = periodKey("太阳细运");
const keyed = [
VERDICT, "",
"## 接下来一年",
`- **打底子**(2026 年 12 月到 2027 年 5 月):照常做。该做:把活做扎实。别做:别急着换。〔${venus}〕`,
`- **守住**(2027 年 5 月到 7 月):偏吃力。该做:少接两成。别做:别加量。〔${sun}〕`,
"- **松一点**(2027 年 8 月到 10 月):缓一缓。",
"",
"## 你的长处和短处",
"**你更适合一对一。** 和一个人谈透最出活。〔H10 Sa〕",
"",
NEXT, "",
"## 判断依据", "",
"- **适合一对一**:两种方法指到同一段。(几种方法一致)〔FB H10 H6〕",
].join("\n");
const data = answerShapeData(keyed, card());
assert.deepEqual(data.areas, [10, 6]);
assert.deepEqual(chartAreaNames(data.areas), ["事业", "每天的工作"]);
// Venus sub-sub-period: 6 days under Sade Sati (from 2027-05-20) → steady; Sun: all of it → heavy; no keys → steady.
assert.deepEqual(data.tones, ["steady", "heavy", "steady"]);
assert.equal(opportunityTone([]), null, "「有机会」 waits for the astrologer's rule (issue #340)");
// An answer citing planets only lights the houses they sit in; an old-shape answer has no tones.
assert.deepEqual(answerShapeData("## 结论\n好。\n\n## 判断依据\n\n- **x**:〔Sa Ve〕", card()).areas, [1, 6]);
assert.deepEqual(answerShapeData(`## 时间线\n\n- **2026 年 12 月到 2027 年 5 月:打底子**:照常做。〔${venus}〕`, card()).tones, []);
assert.deepEqual(answerShapeData(keyed, null), { areas: [], tones: [] });
// The table has a plain name for every house and no house numbers.
assert.equal(Object.keys(CHART_AREA_NAMES).length, 12);
assert.ok(Object.values(CHART_AREA_NAMES).every((name) => !/宫|\d/u.test(name)));
});
test("BUG-2281: the BUG-2247 checks and the pipeline keep working on the new shape", () => {
const venus = periodKey("金星细运");
// The timeline date check reads the bracket after the short title.
const wrong = `## 结论\n好。\n\n## 接下来一年\n\n- **打底子**(2027 年 2 月到 2027 年 9 月):照常做。〔${venus}〕\n\n## 判断依据\n\n- **x**:〔Sa〕`;
const flags = checkTimelineEntries(wrong, card());
assert.equal(flags[0]?.kind, "timeline_dates");
assert.ok(wrong.includes(flags[0]!.sentence), "the flagged sentence is found in the text for the repair");
const right = wrong.replace("2027 年 2 月到 2027 年 9 月", "2026 年 12 月到 2027 年 5 月");
assert.deepEqual(checkTimelineEntries(right, card()).filter((flag) => flag.kind === "timeline_dates"), []);
// Expansion: body and timeline keys leave the text, the rows go to 判断依据, the shape still parses.
const keyed = `${VERDICT}\n\n## 接下来一年\n- **打底子**(2026 年 12 月到 2027 年 5 月):照常做。该做:做扎实。别做:别换。〔${venus}〕\n\n## 你的长处和短处\n**你更适合一对一。** 谈透最出活。〔H10 Sa〕\n\n${NEXT}\n\n## 判断依据\n\n- **适合一对一**:说明。(几种方法一致)〔FB H10〕`;
const expanded = expandEvidenceKeys(keyed, card()).output;
const cleaned = cleanChatAnswer(expanded, card()).output;
const split = splitJudgmentBasis(cleaned);
assert.doesNotMatch(split.body, /〔/u);
const shape = parseAnswerShape(split.body)!;
assert.equal(shape.verdict.facts.length, 3);
assert.equal(shape.timeline!.segments[0]!.doThis, "做扎实。");
assert.equal(shape.followUps.length, 3);
assert.match(split.basis!, /时间线各段/u);
});
test("BUG-2281: the writing rules carry the fixed headings, the label trios, the reader and the worked example", () => {
for (const labels of Object.values(VERDICT_LABELS)) for (const label of labels) assert.ok(chatConversationVoice.includes(`- **${label}**:`), label);
for (const headings of Object.values(BODY_HEADINGS)) for (const heading of headings) assert.ok(chatConversationVoice.includes(`「## ${heading}」`), heading);
assert.match(chatConversationVoice, /## 结论\n/u);
assert.match(chatConversationVoice, /## 接着问\n/u);
assert.match(chatConversationVoice, /- \*\*小标题\*\*(2026 年 11 月到 12 月):一句话说这一段是什么样子。该做:……。别做:……。〔T3 T4〕/u);
assert.match(chatConversationVoice, /一句只说一件事/u);
assert.match(chatConversationVoice, /一句盘面上的理由都不写/u);
assert.match(chatConversationVoice, /1,200 到 1,600 字/u);
assert.match(chatConversationVoice, /去看医生/u);
assert.match(CHAT_FIRST_TURN_SHAPE, /1,200 到 1,600 字/u);
assert.match(CHAT_FIRST_TURN_SHAPE, /## 接着问/u);
});
@@ -57,7 +57,8 @@ test("the pre-markdown fallback renders prose but never raw markdown", () => {
// 新值: 2
// 原因: 回答改为两层可见性(口语层 + 折叠的完整分析),两层各有一个包裹。
// 这条仍然数包裹个数,不得放宽成 >= 1——它防的是"升级到 markdown 时换了壳"。
assert.equal(contentSource.match(/className="message-markdown"/g)?.length, 2);
// 原值(2): 2;新值(2): 3;原因(2): BUG-2281,结论卡形状的回答正文有自己的一个包裹(同一个 message-markdown 类),旧形状的两层不变。
assert.equal(contentSource.match(/className="message-markdown"/g)?.length, 3);
assert.match(contentSource, /className="message-answer"/);
// 原值:对话回答渲染「本轮技法」折叠块(TechniqueAuditDisclosure)
// 新值:对话回答不再渲染技法清单
+6 -2
View File
@@ -155,7 +155,10 @@ test("BUG-2247: the page never shows keys; the body term scan lists what a begin
});
test("BUG-2247: the chat voice writes a plain body, a scaled timeline, no annual section, and one evidence line plus keys", () => {
assert.match(chatConversationVoice, /正文里不写宫位编号和「宫」字、不写技法和运程的名字/u);
// 原值:/正文里不写宫位编号和「宫」字、不写技法和运程的名字/
// 新值:/正文里不写宫位编号和「宫」字,一句盘面上的理由都不写/(技法和运程名在同一句里列出)
// 原因:BUG-2281,问答原型定正文一句盘面理由都不写,规则改成描述读者的句子写法。
assert.match(chatConversationVoice, /正文里不写宫位编号和「宫」字,一句盘面上的理由都不写:不写星、运期[^\n]*技法名(大运、小运、细运、Narayana/u);
assert.match(chatConversationVoice, /全文唯一能用的盘面词是「星盘」/u);
assert.match(chatConversationVoice, /正文不讲星盘的构造,换成平常话也不讲/u);
assert.match(chatConversationVoice, /时间线不单独成条(程序把时间线各段合成一条)/u);
@@ -165,7 +168,8 @@ test("BUG-2247: the chat voice writes a plain body, a scaled timeline, no annual
assert.match(chatConversationVoice, /用户自己用了专业词,或者问依据/u);
assert.doesNotMatch(chatConversationVoice, /## 年盘和行运/u);
assert.match(chatConversationVoice, /「- \*\*判断短句\*\*:一句说明。(依据性质)〔编号〕」/u);
assert.match(CHAT_FIRST_TURN_SHAPE, /大约 2,500 到 4,000 字/u);
// 原值:/大约 2,500 到 4,000 字/;新值:/大约 1,200 到 1,600 字/;原因:BUG-2281,问答原型(beta 用户读不完;负责人定正文约 1,200–1,600 字、不为凑短删判断)。
assert.match(CHAT_FIRST_TURN_SHAPE, /大约 1,200 到 1,600 字/u);
assert.doesNotMatch(CONSULTATION_MUST_MENTION.career!, /回答里要讲到/u);
});
+12 -4
View File
@@ -27,7 +27,10 @@ test("BUG-2229: the plain chat voice is the sectioned voice; the old plain voice
// 原值:["## 一句话结论", "## 时间线", "## 年盘和行运", "## 风险和要留意的", "## 判断依据"]
// 新值:没有「年盘和行运」一节,「风险和要留意的」改叫「要留意的」
// 原因:BUG-2247,负责人 2026-11-23「正文说人话,专业内容折叠在下面」,年盘的作用写进判断依据。
for (const heading of ["## 一句话结论", "## 时间线", "## 要留意的", "## 判断依据"]) assert.ok(voice.includes(heading), heading);
// 原值:["## 一句话结论", "## 时间线", "## 要留意的", "## 判断依据"]
// 新值:["## 结论", "## 接下来一年", "## 要留意的", "## 接着问", "## 判断依据"]
// 原因:BUG-2281,问答原型的固定标题(页面按标题排成结论卡、时间条、接着问)。
for (const heading of ["## 结论", "## 接下来一年", "「## 要留意的」", "## 接着问", "## 判断依据"]) assert.ok(voice.includes(heading), heading);
assert.ok(!voice.includes("## 年盘和行运"));
// Kept: no blame-shifting (the product line word for word), safety and biography red lines, no grades / books / software.
assert.ok(voice.includes(productConversationVoice.split("\n").find((line) => line.startsWith("- 不推责"))!));
@@ -54,7 +57,8 @@ test("BUG-2229: the plain chat voice is the sectioned voice; the old plain voice
// The voice's size is watched like the old one's (4,580 for productConversationVoice): 5,496 characters on 2026-11-23.
// 原值:5_700;新值:6_100(实测 6,015);原因:BUG-2241 固定解释表补上 Narayana 以外 staging 复查没解释的词(Shoola、Sthira、Rupa、Ashtama Shani 等 23 条)。
// 原值:6_100;新值:6_300;原因:BUG-2241 负责人 2026-11-23 定压力段进数据,写法加一条「推荐某一段时同一句说和土星压力段重叠没有」。
assert.ok([...voice].length <= 6_300, String([...voice].length));
// 原值:6_300;新值:7_500(实测 7,328);原因:BUG-2281 加了六个领域的固定标签和正文标题、读者的句子写法和原型的写法示例。
assert.ok([...voice].length <= 7_500, String([...voice].length));
// A stable prefix for provider-side caching: nothing per request (no dates, no ids) in the voice.
assert.doesNotMatch(voice, /\d{4}-\d{2}-\d{2}|requestId|\$\{/u);
});
@@ -64,9 +68,13 @@ test("BUG-2229: first-turn shape, follow-up rules, skeleton and checklists", ()
// 原值:/6 千到 9 千字/、/sub_periods 逐段写到细运/、追问 /Vimshottari(大运小运)和 Narayana/
// 新值:正文 2,500 到 4,000 字、时间线按问题合并成几段、追问的方法名写进判断依据
// 原因:BUG-2247,负责人 2026-11-23「正文说人话,专业内容折叠在下面」。
assert.match(CHAT_FIRST_TURN_SHAPE, /大约 2,500 到 4,000 字/u);
// 原值:/大约 2,500 到 4,000 字/、/一般问题写 12 个月合并成 4 到 6 段/
// 新值:/大约 1,200 到 1,600 字/、首轮提示只点名分节(时间那一节的长短规则在 VISIBLE VOICE 里)
// 原因:BUG-2281,问答原型(负责人 2026-11-24 认可)。
assert.match(CHAT_FIRST_TURN_SHAPE, /大约 1,200 到 1,600 字/u);
assert.match(CHAT_FIRST_TURN_SHAPE, /用户说了要多长时按用户说的写/u);
assert.match(CHAT_FIRST_TURN_SHAPE, /一般问题写 12 个月合并成 4 到 6 段/u);
assert.match(CHAT_FIRST_TURN_SHAPE, /时间那一节(问题有时间的一面才写)/u);
assert.match(chatConversationVoice, /写接下来 12 个月,按自然的几段合并成 4 到 6 条/u);
const follow = followUpAnswerShapeInstruction("plain");
assert.match(follow, /方法名(Vimshottari、Narayana)和卡上的状态写进「判断依据」/u);
assert.match(follow, /追问的第一段先说卡上给出的主因/u);
@@ -117,8 +117,10 @@ test("the first turn of a session keeps the opener-plus-skeleton shape (control)
// 原因: BUG-1603(产品 2026-11-05):回答难读——开场讲盘不讲人、依据成串、结尾很少有能做的事
// 原值(2): 每段第一句加粗结论、结尾两三件能做的事、三到六段;新值(2): VISIBLE VOICE 的固定分节(一句话结论 … 判断依据),
// 每段时间写做什么、不做什么;原因(2): BUG-2229,负责人 2026-11-23 定首轮按分节写完整
assert.match(writerPrompt, /## 一句话结论/);
assert.match(writerPrompt, /## 时间线/);
// 原值(3): /## 一句话结论/、/## 时间线/;新值(3): /## 结论/、/## 接下来一年/、/## 接着问/;原因(3): BUG-2281,问答原型的固定标题。
assert.match(writerPrompt, /## 结论/);
assert.match(writerPrompt, /## 接下来一年/);
assert.match(writerPrompt, /## 接着问/);
assert.match(writerPrompt, /每段时间写做什么、不做什么/);
for (const heading of Object.values(REPORT_HEADING)) {
assert.equal(writerPrompt.includes(`## ${heading}`), false, heading);
@@ -289,8 +289,10 @@ test("the writing instructions travel with the user turn the loop sees", async (
// 新值: 每段以一句加粗的白话结论开头;结尾给两三件能去做的具体事
// 原因: BUG-1603(产品 2026-11-05):回答难读,开场讲盘不讲人、结尾很少有能做的事
// 原值(2): 每段第一句加粗结论、结尾两三件能做的事、三到六段;新值(2): VISIBLE VOICE 的固定分节;原因(2): BUG-2229,负责人 2026-11-23
assert.match(writerPrompt, /## 一句话结论/);
assert.match(writerPrompt, /## 时间线/);
// 原值(3): /## 一句话结论/、/## 时间线/;新值(3): /## 结论/、/## 接下来一年/、/## 接着问/;原因(3): BUG-2281,问答原型的固定标题。
assert.match(writerPrompt, /## 结论/);
assert.match(writerPrompt, /## 接下来一年/);
assert.match(writerPrompt, /## 接着问/);
assert.match(writerPrompt, /每段时间写做什么、不做什么/);
for (const heading of Object.values(REPORT_HEADING)) {
assert.equal(writerPrompt.includes(`## ${heading}`), false, heading);