Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(answers): 按需使用富组件,普通回复默认文字

Dashf9f069e631d5
diff --git a/docs/rich-answers.md b/docs/rich-answers.md
index 6df0a0056b..dcbb76ee18 100644
--- a/docs/rich-answers.md
+++ b/docs/rich-answers.md
@@ -34,15 +34,25 @@ Desktop 使用原生 React 组件;Mobile 使用原生 View/Text 与既有媒
模型自由组合布局;简单回答、代码和显式要求的格式保持简洁。组件仅适用于 Cindy 正文,外部渠道沿用其格式。编辑控件只改变本地查看状态;带 `send` 的按钮或表单在显式点击后提交可见用户消息,不直接执行工具。原有执行、停止、上下文压缩及工作过程折叠流程不变。计算可引用输入与其它计算节点;缺失、循环或非法计算显示局部不可用,不伪造零值。流式尚未到达的引用先等待。
-公共交付说明以表达目标、阅读层次和视觉组织为框架,明确要求优雅、美观、易读;模型根据内容自行决定组件、布局和强调方式,不使用场景白名单或固定组件组合。图文、图标、图表与控件是可组合能力,不要求用户点名后才使用。协议例子只说明语法,验收场景不构成输出模板。简短内容仍可简短表达,用户指定格式优先。
+2026-10-27 用户确认将组件改为按需使用:普通交流、解释、进度和简短结果默认直接使用文字或 Markdown;图表、交互、媒体展示或结构化排版明显有助于理解时,以及用户明确要求组件时,才使用 `cindy-ui`。普通文字不为装饰而套进 `text` / `markdown` 组件,混合回答仅把受益的部分做成组件,周围说明保留 Markdown。模型仍可自主选择有用的可视化,用户指定格式优先。
-公共说明开头直接要求主动把组件与 Markdown 组合使用,适用于各种题材和答案长度;不只描述“可以渲染”的能力。说明原位压缩重复介绍,不增加预置段落、发现调用或额外模型调用。组件协议、颜色边界和三个 Harness 的注入位置不变。
+这取代此前“各种题材和答案长度都主动使用组件”的要求;适用判据放在共用 `RICH_ANSWER_GUIDE`,宿主注入与能力查询读同一份说明。协议例子只说明选用组件后的语法,不要求每条回复套用。组件协议、颜色边界和三个 Harness 的注入位置不变,也不增加发现调用或额外模型调用。更新后的静态文本首次使用会使对应提示词缓存前缀变化,后续请求仍保持稳定。
流程图按阅读效果与用户指定格式选择表达方式:`diagram` 是 Mermaid 自动布局的入口,不是所有流程图的必选组件;需要控制几何与连线路径时可以用 `svg`,也可以把小图与文字、分栏、折叠区或页签组合。两种格式都不能保证天然易读。用户要求画图或看样稿时应实际展示图,而不是只描述布局方案。
复杂图应保留判断、分支、汇合和回路,通过路径分组、结果标注及对应清楚的连接点减少交叉线;分段展示时必须交代段间关系并保留完整逻辑。按实际显示宽度检查文字,不把整张 Mermaid 或 SVG 缩小当成可读性方案。`svg` 没有内建缩放、平移或节点点击能力;需要小屏可读时用现有组件分段组织,不虚构渲染器交互。此选择指引复用上述公共入口,不改 Harness 原生指令、组件协议或历史消息渲染。
-当前图表外观仍由组件固定,仅支持单系列折线/条形与数据标签。用户已否决其视觉效果;下述数据正确性和展示检查不代表视觉设计通过。更新后的通用交付说明已完成三 Harness 真实生成复测(见末节),图表设计空间与默认样式仍待优化。当前版本按用户要求进入 PR 评审,送审不代表视觉优化或全部验收已经完成。
+当前图表外观仍由组件固定,仅支持单系列折线/条形与数据标签。用户已否决其视觉效果;下述数据正确性和展示检查不代表视觉设计通过。2026-10-18 的通用交付说明完成过三 Harness 真实生成复测(见后文),图表设计空间与默认样式仍待优化;这不代表本次按需使用规则已完成三 Harness 复测。
+
+### 按需使用抽测(2026-10-27)
+
+用户已确认本次宿主提示词改动。以仓内 Claude Code 2.1.296 的原生 system append 注入修改前后完整 `ANSWER_DELIVERY_PROMPT`,在临时空目录禁用工具、MCP、hooks、技能与会话持久化,运行四次独立合成请求;实际回答模型为 `claude-opus-5-5`。这是提示词行为抽测,不是桌面/手机 UI 或伙伴生命周期验收。
+
+- 同一句“17 加 25 是多少?”:旧说明输出文字加 `stat` 组件,新说明只输出“17 加 25 等于 **42**。”;模型报告的输出 token(含思考)从 97 变为 22,耗时分别为 3.50 / 3.47 秒。
+- 新说明下的简短进度请求只输出普通文字;月份费用计算器请求仍输出滑块与引用月份的总价计算组件。
+- 静态说明从 10521 变为 10829 字符,重复组装逐字一致。新说明首次请求建立缓存;随后两个请求各读取 5923 个缓存 token。没有调整注入顺序、模型路由、工具定义或事件转换,也未在产品路径新增模型调用或热路径计算。
+
+共享包 `tsc --noEmit`、现有 `richAnswer.test.ts` 19 项测试通过。上述单模型、单次样本只证明本次请求的行为与缓存复用,不能推断全部模型的稳定成功率或整体性能提升;本轮未重测 Codex / Pi 或真实客户端呈现。
## 验收状态
diff --git a/packages/maker-shared/src/richAnswerGuide.ts b/packages/maker-shared/src/richAnswerGuide.ts
index fb039c4783..6fcb2c75d6 100644
--- a/packages/maker-shared/src/richAnswerGuide.ts
+++ b/packages/maker-shared/src/richAnswerGuide.ts
@@ -1,5 +1,7 @@
/** Single delivery protocol used by host instructions and optional capability lookup. */
-export const RICH_ANSWER_GUIDE = `Write streaming cindy-ui components directly in progress messages or final answers, alongside Markdown. Choose content and layout freely; no HTML file, tool call or extra model call is needed.
+export const RICH_ANSWER_GUIDE = `Default to plain text or Markdown for ordinary conversation, explanations, progress updates and concise results. Use cindy-ui only when charts, interaction, media presentation or structured layout materially improve understanding, or when the user explicitly requests components. Do not wrap plain prose in text or markdown components just for decoration. Keep surrounding prose in Markdown and use components only for the parts that benefit. Follow the user's requested format.
+
+When components are useful, write them directly in progress messages or final answers, alongside Markdown. Choose content and layout freely; no HTML file, tool call or extra model call is needed.
Your canvas is inline on Cindy's conversation surface. Layout, hierarchy, typography and spacing are yours; colors and backgrounds belong to Cindy so answers stay calm and consistent.
@@ -41,7 +43,7 @@ value and chart data may use a scalar, {ref:"stateKeyOrComputedNodeId"}, or {op,
For example, a button with props {"label":"Plan my trip","send":{"op":"concat","args":["Plan a ",{"ref":"days"},"-day trip to ",{"ref":"destination"}]}} sends the displayed sentence after the user clicks. Define days and destination controls first. Do not request passwords, tokens or other credentials in these controls.
-Complete rendered-answer example, not a prescribed answer layout. Include BOTH fence lines shown below in your output, with one JSON object per line; do not copy only the JSON:
+Component syntax example, not a prescribed answer layout. When using components, include BOTH fence lines shown below, with one JSON object per line; do not copy only the JSON:
\`\`\`cindy-ui
{"version":1,"seq":1,"op":"create","id":"months","kind":"range","props":{"label":"Months","min":1,"max":24,"default":6}}
{"seq":2,"op":"create","id":"cost","kind":"stat","props":{"label":"Total","prefix":"¥","value":{"op":"mul","args":[{"ref":"months"},20]}}}
@@ -52,7 +54,7 @@ Keep blocks under 128 KB, with no more than 2048 nodes and depth 32. Finish each
/** Host addition only: native CLI instructions and execution remain unchanged. */
export const ANSWER_DELIVERY_PROMPT = `## Cindy answer delivery
-Create beautiful, elegant, readable answers. On Cindy surfaces, compose your answer in cindy-ui components, with Markdown within or alongside them. This applies across subjects and answer lengths; no rich-media request, fixed scenario or template is needed. Follow user format preferences. You own layout, typography and charts; Cindy supplies colors. Defaults are fallbacks. Preserve native workflows.
+Create clear, readable answers. Choose plain text, Markdown or cindy-ui components according to the guidance below. When using components, you own layout, typography and charts; Cindy supplies colors. Preserve native workflows.
The component protocol is rendered on Cindy conversation surfaces. External channels retain their required formats. Controls hold local viewing state. Optional button/form send actions let the user explicitly submit visible text as a normal message to continue the conversation; they do not directly execute work or tools.