feat(copilot): 统一行内引用与来源检查器(Fixes #30) - #88
Open
lhy-dcf wants to merge 8 commits into
Open
Conversation
- 新增 core citations 契约:⟦cite:<toolCallId>⟧ 标记解析、CitationSource 投影、稳定编号分配 - pi-tools 工具结果尾部附带 EVIDENCE 行,供模型引用真实来源 id - Pi 系统提示词加入引用指令(仅引用会话中出现过的 id,禁止在 fence 内放置标记) - 抽取确定性 computeEnvelopeId,与持久化信封 id 规则一致
- AnswerContent 渲染可点击 [n] 上标;编造/未知 id 诚实降级为灰色 ?(绝不虚构出处) - 行内标记与类型化答案块 evidence chip 共用同一编号空间,流式期间优雅降级 - 新增 SourceInspector 对话框:分组展示 provider、新鲜度、lineage、脱敏快照与哈希; 入口为消息底部 Sources (n) 按钮与引用 chip 深链 - i18n 补齐 agent.citation.* 与 agent.sources.* 中英文案
helsome
requested changes
Sep 12, 2026
helsome
left a comment
Owner
There was a problem hiding this comment.
实现和测试报告本身已经很完整:Bun 1.4.2 / Windows,focused 101+137+25 全绿、全仓 1392 / 0 fail、typecheck 全绿。当前只卡验收证据,不要求扩大架构:
- 按 CONTRIBUTING,补实际 UI 截图:至少包含 inline citation、Sources 入口、SourceInspector 打开后的实际界面;已有界面改动最好给 Before/After。
- #30 自身明确要求一条真实 Copilot 回答同时混合至少 1 个 Web 来源 + 1 个 structured financial evidence,并展示从正文 citation 打开对应 evidence 的完整路径。请补这一次真实 production-path 验收(截图序列或录屏均可)和实际结果。
- #84 刚合入 main,请 rebase 最新 main 后跑基础 CI。
现有组件测试不需要重跑扩大;补齐 UI/真实路径证据后即可继续审核。
helsome
requested changes
Sep 12, 2026
helsome
left a comment
Owner
There was a problem hiding this comment.
实现和测试报告本身已经很完整:Bun 1.4.2 / Windows,focused 101+137+25 全绿、全仓 1392 / 0 fail、typecheck 全绿。当前只卡验收证据,不要求扩大架构:
- 按 CONTRIBUTING,补实际 UI 截图:至少包含 inline citation、Sources 入口、SourceInspector 打开后的实际界面;已有界面改动最好给 Before/After。
- #30 自身明确要求一条真实 Copilot 回答同时混合至少 1 个 Web 来源 + 1 个 structured financial evidence,并展示从正文 citation 打开对应 evidence 的完整路径。请补这一次真实 production-path 验收(截图序列或录屏均可)和实际结果。
- #84 刚合入 main,请 rebase 最新 main 后跑基础 CI。
现有组件测试不需要重跑扩大;补齐 UI/真实路径证据后即可继续审核。
UI 层存在两套 locale 策略的格式化器并行:lib/money 跟随操作系统 locale,@finagent/i18n 跟随应用内语言设置(规范 §52-59 要求所有 money/percent 值经由 i18n 层渲染)。实测 zh-CN Windows 上 TodayView 同屏出现 $12,345.67(PortfolioCard,i18n 路径)与 US$100.00 (Watchlist movers,lib/money 路径)混排,应用内语言切换与货币 呈现脱钩。 - lib/money 改为 @finagent/i18n 的薄委托层:formatMoney→ formatCurrency、formatSignedMoney 组合保留、formatPercent→ i18n formatPercent、formatQuantity→formatNumber(0 位小数)、 formatFreshness→formatMarketTime;五个调用点签名不变 - 保留白名单外货币回退语义(plain number + ISO code,如 '1,234.5 BTC') - 行为变化说明:formatPercent 由 toFixed(2) 改为 i18n 的最多两位 小数('+2.50%'→'+2.5%'),与应用其余 i18n 输出一致;相关测试 断言同步更新 - 新增双 locale 回归测试:i18nSetCurrentLocale 在 en-US/zh-CN 间 切换,断言 formatMoney 输出 $12,345.67 / US$12,345.67 Closes helsome#86 Co-authored-by: yjg-djb <189134749+yjg-djb@users.noreply.github.com>
Co-authored-by: wcy12378 <kris@folio.local>
- AnswerContent:消息携带证据记录即构建引用上下文(不再要求文本含行内标记), 纯块引用消息(如本地确定性后端回答)的证据 chip 正确编号并可深链 - AgentPanel:run 结束后从存储重载消息列表——run_completed 事件不携带 financialEvidence,合成消息的检查器此前看不到证据信封 - 新增验收工具:copilot-citation-acceptance.ts(真实模型混合来源引用 E2E)、 longbridge-shim.ts(CLI 夹具回放垫片)、citation-acceptance.mjs(GUI 截图驱动)
- GUI 截图(local 确定性后端 + demo 数据管线):S2 类型化答案块编号证据 chip [1][2]、 S4 SourceInspector 分组列表与详情、S5 证据 chip 深链定位到证据信封 (证据已核验 / fe_ id / 哈希 / 数值 / lineage) - 真实模型 production-path E2E(copilot-citation-acceptance.ts):混合来源提问 (结构化行情 + Web 新闻),回答含 6 个 ⟦cite:⟧ 标记,全部解析到真实工具调用 (0 编造),引用→证据信封逐条可解析 - 垫片范围声明:仅 longbridge CLI 传输层用夹具回放(bun --compile 单文件垫片), 能力清单/解析器/sanitizer/证据信封构建全部真实 - 证据文件存于 docs/evidence/issue30/,PR 描述直接引用
lhy-dcf
force-pushed
the
feat/copilot-inline-citations
branch
from
September 12, 2026 12:11
5785d06 to
350453d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改了什么
Closes #30
为 Copilot 建立统一行内引用系统与来源检查器,回答中每个数据性论断都能定位到具体来源:
packages/core/citations.ts):⟦cite:<toolCallId>⟧显式标记语法、parseCitationSegments解析、CitationSource投影、稳定编号分配。pi-tools.ts工具结果尾部附带EVIDENCE: <toolCallId>行;Pi 系统提示词引用指令(只引用会话中出现过的 id);确定性computeEnvelopeId。AnswerContent渲染可点击[n]上标(编造/未知 id 诚实降级为灰色?);行内标记与类型化答案块 evidence chip 共用同一编号空间;SourceInspector对话框(分组、provider、新鲜度、lineage、脱敏快照与哈希);入口为消息底部 "Sources (n)" 与引用 chip 深链。UI 截图(真实应用,真实数据管线)
S2 — 类型化答案块的编号证据 chip(本地确定性后端 + demo 数据管线):
S4 — SourceInspector 打开(分组来源 + 展开详情):
S5 — 从正文证据 chip 深链定位到证据信封详情(证据已核验 / fe_ id / 哈希 / 数值 / lineage):
真实模型 production-path 验收(新增 E2E)
apps/electron/e2e/copilot-citation-acceptance.ts(live 模式,opt-in):真实 AgentKernel(Pi runtime,真实模型)+ 真实 Pi 扩展工具链(能力清单、解析器、sanitizer、证据信封构建全部真实),唯一 stub 是longbridgeCLI 传输层——用bun build --compile的夹具回放垫片替代(攻击面无关,stub 范围与 #89 PR 同口径声明)。混合来源提问的实际运行结果(问题:"What is Apple's latest stock price? Summarize the latest news about Apple too, and cite the sources for each claim."):
⟦cite:…⟧标记buildFinancialEvidence信封(fe_ id、provider、kind=quote)逐条可解析(citation-resolution.json)实际回答摘录(完整见
docs/evidence/issue30/copilot-citation-answer.json):验收过程中发现并修复两个真实缺陷(本 PR 附带):
AnswerContent此前只对含行内标记的文本构建引用上下文——纯块引用消息(本地确定性后端)的证据 chip 不编号、不可深链;run_completed事件不携带financialEvidence,渲染端合成消息在 run 刚结束时检查器看不到证据信封——现在 run 结束后自动从存储重载消息列表。Rebase 与基础 CI
环境限制声明
验收环境无 Longbridge CLI:GUI 截图使用
FINAGENT_DEMO_DATA=1(示例数据带徽标)+ 确定性 local 后端;E2E 使用夹具回放垫片。两者的管线(信封构建、编号、解析、检查器)均真实;接入 Longbridge 后同一验收脚本可直接产出真实来源版本。已知未完成项(P2)
EVIDENCE:行被隐私包装剥掉,组合类工具引用降级。