Commit Graph

379 Commits

Author SHA1 Message Date
LofiSu
0f0346f73e Merge pull request #27 from LofiSu/experimental
Experimental
2026-02-09 15:59:41 +08:00
LofiSu
cef8d389fd refactor(frontend): consolidate citation logic, slim exports and impl
- SafeCitationContent: add loadingOnly and renderBody props.
  - loadingOnly: show only loading indicator or null (e.g. write_file step).
  - renderBody(parsed): custom body renderer (e.g. artifact preview).

- message-group write_file: use SafeCitationContent(content, isLoading,
  rehypePlugins, loadingOnly) instead of local useParsedCitations +
  shouldShowCitationLoading + CitationsLoadingIndicator. Pass rehypePlugins
  into ToolCall.

- artifact-file-detail markdown preview: use SafeCitationContent with
  renderBody((p) => <ArtifactFilePreview ... cleanContent={p.cleanContent}
  citationMap={p.citationMap} />). Remove local shouldShowCitationLoading
  and CitationsLoadingIndicator branch.

- core/citations: inline buildCitationMap into use-parsed-citations, remove
  from utils; stop exporting hasCitationsBlock (internal to shouldShowCitationLoading).

- inline-citation: make InlineCitationCard, InlineCitationCardBody,
  InlineCitationSource file-private (no longer exported).

Co-authored-by: Cursor <cursoragent@cursor.com>

---
refactor(前端): 收拢引用逻辑、精简导出与实现

- SafeCitationContent 新增 loadingOnly、renderBody。
  - loadingOnly:仅显示加载或 null(如 write_file 步骤)。
  - renderBody(parsed):自定义正文渲染(如 artifact 预览)。

- message-group write_file:改用 SafeCitationContent(loadingOnly),去掉
  本地 useParsedCitations + shouldShowCitationLoading + CitationsLoadingIndicator,
  并向 ToolCall 传入 rehypePlugins。

- artifact-file-detail 的 markdown 预览:改用 SafeCitationContent +
  renderBody 渲染 ArtifactFilePreview,去掉本地加载判断与
  CitationsLoadingIndicator 分支。

- core/citations:buildCitationMap 内联到 use-parsed-citations 并从 utils
  删除;hasCitationsBlock 不再导出(仅 shouldShowCitationLoading 内部使用)。

- inline-citation:InlineCitationCard/Body/Source 改为文件内私有,不再导出。
2026-02-09 15:58:59 +08:00
LofiSu
d9a86c10e8 fix(frontend): no half-finished citations, correct state when SSE ends
Citations:
- In shouldShowCitationLoading, treat any unreplaced [cite-N] in cleanContent
  as show-loading (no body). Fixes Ultra and other modes when refs arrive
  before the <citations> block in the stream.
- Single rule: hasUnreplacedCitationRefs(cleanContent) => true forces loading;
  then isLoading && hasCitationsBlock(rawContent) for streaming indicator.

SSE end state:
- When stream finishes, SDK may set isLoading=false before client state has
  the final message content, so UI stayed wrong until refresh.
- Store onFinish(state) as finalState in chat page; clear when stream starts.
- Pass messagesOverride={finalState.messages} to MessageList when not loading
  so the list uses server-complete messages right after SSE ends (no refresh).

Chore:
- Stop tracking .githooks/pre-commit; add .githooks/ to .gitignore (local only).

Co-authored-by: Cursor <cursoragent@cursor.com>

---
fix(前端): 杜绝半成品引用,SSE 结束时展示正确状态

引用:
- shouldShowCitationLoading 中只要 cleanContent 仍含未替换的 [cite-N] 就
  只显示加载、不渲染正文,解决流式时引用块未到就出现 [cite-1] 的问题。
- 规则:hasUnreplacedCitationRefs(cleanContent) 为真则一律显示加载;
  此外 isLoading && hasCitationsBlock 用于流式时显示「正在整理引用」。

SSE 结束状态:
- 流结束时 SDK 可能先置 isLoading=false,客户端 messages 尚未包含
  最终内容,导致需刷新才显示正确。
- 在对话页保存 onFinish(state) 为 finalState,流开始时清空。
- 非加载时向 MessageList 传入 messagesOverride={finalState.messages},
  列表在 SSE 结束后立即用服务端完整消息渲染,无需刷新。

杂项:
- 取消跟踪 .githooks/pre-commit,.gitignore 增加 .githooks/(仅本地)。
2026-02-09 15:15:20 +08:00
LofiSu
4f9d1d524e feat(frontend): unify citation logic and prevent half-finished citations
- Add SafeCitationContent as single component for citation-aware body:
  useParsedCitations + shouldShowCitationLoading; show loading until
  citations complete, then render body with createCitationMarkdownComponents.
  Supports optional remarkPlugins, rehypePlugins, isHuman, img.

- Refactor MessageListItem: assistant message body now uses
  SafeCitationContent only; remove duplicate useParsedCitations,
  shouldShowCitationLoading, createCitationMarkdownComponents and
  CitationsLoadingIndicator logic. Human messages keep plain
  AIElementMessageResponse (no citation parsing).

- Use SafeCitationContent for clarification, present-files (message-list),
  thinking steps and write_file loading (message-group), subtask result
  (subtask-card). Artifact markdown preview keeps same guard
  (shouldShowCitationLoading) with ArtifactFilePreview.

- Unify loading condition: shouldShowCitationLoading(rawContent,
  cleanContent, isLoading) is the single source of truth. Show loading when
  (isLoading && hasCitationsBlock(rawContent)) or when
  (hasCitationsBlock(rawContent) && hasUnreplacedCitationRefs(cleanContent))
  so Pro/Ultra modes also show "loading citations" and half-finished
  [cite-N] never appear.

- message-group write_file: replace hasCitationsBlock + threadIsLoading
  with shouldShowCitationLoading(fileContent, cleanContent,
  threadIsLoading && isLast) for consistency.

- citations/utils: parse incomplete <citations> during streaming;
  remove isCitationsBlockIncomplete; keep hasUnreplacedCitationRefs
  internal; document display rule in file header.

Co-authored-by: Cursor <cursoragent@cursor.com>

---
feat(前端): 统一引用逻辑并杜绝半成品引用

- 新增 SafeCitationContent 作为引用正文的唯一出口:内部使用
  useParsedCitations + shouldShowCitationLoading,在引用未就绪时只显示
  「正在整理引用」,就绪后用 createCitationMarkdownComponents 渲染正文;
  支持可选 remarkPlugins、rehypePlugins、isHuman、img。

- 重构 MessageListItem:助手消息正文仅通过 SafeCitationContent 渲染,
  删除重复的 useParsedCitations、shouldShowCitationLoading、
  createCitationMarkdownComponents、CitationsLoadingIndicator 等逻辑;
  用户消息仍用 AIElementMessageResponse,不做引用解析。

- 澄清、present-files(message-list)、思考步骤与 write_file 加载
  (message-group)、子任务结果(subtask-card)均使用
  SafeCitationContent;Artifact 的 markdown 预览仍用同一 guard
  shouldShowCitationLoading,正文由 ArtifactFilePreview 渲染。

- 统一加载条件:shouldShowCitationLoading(rawContent, cleanContent,
  isLoading) 为唯一判断。在「流式中且已有引用块」或「有引用块且
  cleanContent 中仍有未替换的 [cite-N]」时仅显示加载,从而在 Pro/Ultra
  下也能看到「正在整理引用」,且永不出现半成品 [cite-N]。

- message-group 的 write_file:用 shouldShowCitationLoading(
  fileContent, cleanContent, threadIsLoading && isLast) 替代
  hasCitationsBlock + threadIsLoading,与其他场景一致。

- citations/utils:流式时解析未闭合的 <citations>;移除
  isCitationsBlockIncomplete;hasUnreplacedCitationRefs 保持内部使用;
  在文件头注释中说明展示规则。
2026-02-09 15:01:51 +08:00
Henry Li
cbe0f3b32f feat: update translations 2026-02-09 13:57:46 +08:00
hetao
f68b3c26c3 feat: enforce subagent concurrency limit of 3 per turn with batch execution
Strengthen the SUBAGENT_SECTION prompt to prevent the model from launching
more than 3 subagents in a single response. When >3 sub-tasks are needed,
the model is now explicitly instructed to plan and execute in sequential
batches of ≤3. Reinforced at three prompt injection points: thinking style,
main subagent instructions, and critical reminders.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 13:50:54 +08:00
LofiSu
804d988002 chore: add pre-commit hook to reject *@bytedance.com author/committer email
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 13:46:18 +08:00
hetao
caf12da0f2 feat: add DanglingToolCallMiddleware and SubagentLimitMiddleware
Add two new middlewares to improve robustness of the agent pipeline:
- DanglingToolCallMiddleware injects placeholder ToolMessages for
  interrupted tool calls, preventing LLM errors from malformed history
- SubagentLimitMiddleware truncates excess parallel task tool calls at
  the model response level, replacing the runtime check in task_tool

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 13:22:49 +08:00
LofiSu
2c3ddbb9e5 Merge pull request #26 from LofiSu/experimental
引用(Citations)优化、Gateway 路径工具抽离、模式悬停说明与中英文国际化
2026-02-09 13:10:37 +08:00
LofiSu
da9b8e3333 Merge upstream/experimental, resolve conflicts in input-box, message-group, en-US, zh-CN
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 13:10:14 +08:00
LofiSu
1c9a969a70 i18n(zh-CN): keep Pro and Ultra as English in mode labels
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 13:02:54 +08:00
LofiSu
0fff2880d3 Merge upstream/experimental and resolve conflicts; citations + path_utils + mode-hover
## 冲突解决 (Resolve conflicts)
- input-box.tsx: 保留 ModeHoverGuide 包裹的模式选择器(PR #26 的 mode-hover-guide)
- message-group.tsx: 保留 getCleanContent / hasCitationsBlock / useParsedCitations
- message-list-item.tsx: 保留 useParsedCitations,移除重复的 MessageLink(使用 CitationAwareLink)
- artifact-file-detail.tsx: 保留 CitationAwareLink、useParsedCitations、contentWithoutCitationsFromParsed
- artifacts.py: 保留 path_utils 与 _extract_citation_urls + remove_citations_block 精简实现
- citations/index.ts: 保留并补充 contentWithoutCitationsFromParsed 导出
- en-US.ts: 保留 Ultra 模式描述 "Reasoning, planning and execution with subagents..."
- zh-CN.ts: 保留「超级」标签,描述保留「思考、计划并执行,可调用子代理分工协作...」

## PR #26 代码改动汇总

### 1. Citations(引用)
- lead_agent prompt: 增加 Web search 与子代理合成时的 citation 提示
- general_purpose: 子代理 system prompt 增加 <citations_format> 说明
- frontend utils: 新增 contentWithoutCitationsFromParsed,removeAllCitations 基于单次解析
- frontend artifact: 使用 contentWithoutCitationsFromParsed(parsed) 避免对同一内容解析两次
- backend artifacts: _extract_citation_urls + remove_citations_block,json 提到顶部

### 2. path_utils(路径解析)
- 新增 backend/src/gateway/path_utils.py:resolve_thread_virtual_path,防 path traversal
- artifacts.py / skills.py:删除内联路径解析,统一使用 path_utils

### 3. Mode hover guide
- input-box: 模式选择器外包 ModeHoverGuide,悬停展示模式说明

### 4. i18n
- en: ultraModeDescription 与 zh: ultraMode / ultraModeDescription 与上游对齐并保留 PR 文案

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 13:01:01 +08:00
LofiSu
2a39947830 feat: citations prompts, path_utils, and citation code cleanup
- Prompt: add citation reminders for web_search and subagent synthesis (lead_agent, general_purpose)
- Gateway: add path_utils for shared thread virtual path resolution; refactor artifacts and skills to use it
- Citations: simplify removeAllCitations (single parse); backend _extract_citation_urls and remove_citations_block cleanup

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 12:55:12 +08:00
LofiSu
8168ea47b3 chore(frontend): remove unused Citation UI components from inline-citation
- Remove InlineCitation, InlineCitationText, InlineCitationCardTrigger
- Remove InlineCitationCarousel and all Carousel subcomponents (Content, Item, Header, Index, Prev, Next)
- Remove InlineCitationQuote
- Drop Carousel/carousel and ArrowLeft/ArrowRight icon imports; keep only CitationLink, CitationAwareLink, CitationsLoadingIndicator and their dependencies

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 12:49:31 +08:00
LofiSu
d265bdb245 feat(frontend): add mode hover guide and adjust mode i18n
## 中文

### 代码改动
- **新增** `frontend/src/components/workspace/mode-hover-guide.tsx`
  - 新增 ModeHoverGuide 组件:接收 mode (flash/thinking/pro/ultra) 与 children,用 Tooltip 包裹
  - hover 时展示该模式名称与简介,支持 showTitle 控制是否显示模式名
  - 文案通过 useI18n 从 inputBox 的 *Mode / *ModeDescription 读取,中英文已支持
- **修改** `frontend/src/components/workspace/input-box.tsx`
  - 在模式选择器触发按钮外包一层 ModeHoverGuide,悬停当前模式时显示说明
- **修改** `frontend/src/core/i18n/locales/zh-CN.ts`
  - ultraModeDescription:改为完整描述「思考、计划并执行,可调用子代理分工协作,适合复杂多步骤任务,能力最强」(不再仅写「专业模式加子代理」)
  - proMode / ultraMode:中文环境下保留英文原文 "Pro"、"Ultra",不再翻译为「专业」「超级」
- **修改** `frontend/src/core/i18n/locales/en-US.ts`
  - ultraModeDescription:改为 "Reasoning, planning and execution with subagents to divide work; best for complex multi-step tasks"

### 说明
为 Flash / 思考 / Pro / Ultra 四种模式增加 hover 说明,并统一超级模式文案与 Pro/Ultra 在中文下的展示。

Co-authored-by: Cursor <cursoragent@cursor.com>

---

## English

### Code changes
- **Add** `frontend/src/components/workspace/mode-hover-guide.tsx`
  - New ModeHoverGuide component: takes mode (flash/thinking/pro/ultra) and children, wraps in Tooltip
  - On hover shows mode name and short description; showTitle toggles mode name in tooltip
  - Copy from useI18n (inputBox *Mode / *ModeDescription), i18n in zh-CN and en-US
- **Update** `frontend/src/components/workspace/input-box.tsx`
  - Wrap mode selector trigger with ModeHoverGuide so hovering shows current mode description
- **Update** `frontend/src/core/i18n/locales/zh-CN.ts`
  - ultraModeDescription: full description (reasoning, planning, execution, subagents, complex tasks); no longer "Pro + subagents" only
  - proMode / ultraMode: keep English "Pro" and "Ultra" in zh locale instead of "专业" / "超级"
- **Update** `frontend/src/core/i18n/locales/en-US.ts`
  - ultraModeDescription: "Reasoning, planning and execution with subagents to divide work; best for complex multi-step tasks"

### Summary
Hover guide for all four modes (Flash / Reasoning / Pro / Ultra); clearer Ultra copy and Pro/Ultra labels in Chinese.
2026-02-09 12:33:16 +08:00
LofiSu
30e1760211 refactor(frontend): simplify and deduplicate Citation-related code
- Extract removeCitationsBlocks in utils, reuse in parseCitations and removeAllCitations
- Add hasCitationsBlock; isCitationsBlockIncomplete now uses it
- Add useParsedCitations hook (parseCitations + buildCitationMap) for message/artifact
- Add CitationAwareLink to unify link rendering (message-list-item + artifact-file-detail)
- Add getCleanContent helper; message-group uses it and useParsedCitations
- ArtifactFileDetail: single useParsedCitations, pass cleanContent/citationMap to Preview
- Stop exporting buildCitationMap and removeCitationsBlocks from citations index
- Remove duplicate MessageLink and inline link logic in artifact preview

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 12:13:06 +08:00
LofiSu
f0423b88ac Merge branch 'hetaoBackend:experimental' into experimental 2026-02-09 11:58:56 +08:00
Henry Li
8b053a4415 feat: update workspace header to conditionally render title based on environment variable 2026-02-09 09:20:32 +08:00
Henry Li
305e8969ef feat: make it golden 2026-02-09 09:15:39 +08:00
Henry Li
ddbda4e38f feat: make the title golden in Ultra mode 2026-02-09 08:59:40 +08:00
LofiSu
2d70aaa969 fix(frontend): citations display + refactor link/citation utils
- Citations: no underline while streaming (message links); artifact markdown external links as citation cards
- Refactor: add isExternalUrl, syntheticCitationFromLink in core/citations; shared externalLinkClass in lib/utils; simplify message-list-item and artifact-file-detail link rendering

修复引用展示并抽离链接/引用工具
- 引用:流式输出时链接不这下划线;Artifact 内 Markdown 外链以引用卡片展示
- 重构:core/citations 新增 isExternalUrl、syntheticCitationFromLink;lib/utils 共享 externalLinkClass;精简消息与 Artifact 中的链接渲染逻辑

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 04:03:15 +08:00
LofiSu
d72aad8063 fix(frontend): build + remove hover tooltips in step links
- Fix Turbopack build: replace raw-loader .md import with inlined about-content.ts; drop raw-loader from next.config and package.json
- Remove all hover tooltips on step-area links (web_fetch, read_file, ls, bash, write_file, web_search) so hidden steps no longer show popups

修复:构建错误与步骤链接悬停提示
- 修复 Turbopack 构建:用内联 about-content.ts 替代 raw-loader 导入 about.md,并移除 next.config 与 package.json 中的 raw-loader
- 移除步骤区域内所有链接的悬停提示(查看网页、读文件、列目录、bash、写文件、网页搜索),隐藏步骤悬停不再弹出内容

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 03:42:16 +08:00
LofiSu
fe06be8258 Revert "fix(frontend): Turbopack about page + remove hover on web search/citations"
This reverts commit 7e9e061f20fcec1f1a9c35be40d9407c05ed82be.
2026-02-09 03:23:51 +08:00
LofiSu
842c4ecac0 fix(frontend): Turbopack about page + remove hover on web search/citations
- About: use aboutMarkdown from about-content.ts instead of raw-loader for
  about.md (fixes Turbopack 'Cannot find module raw-loader')
- Web search: remove Tooltip from web_search and web_fetch result links
- Citations: remove HoverCard from CitationLink so no hover popup on badges

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 03:23:02 +08:00
Henry Li
cebf2599c9 feat: add mode in welcome 2026-02-09 00:41:25 +08:00
Henry Li
25b60e732f feat: set golden color for ultra 2026-02-09 00:30:20 +08:00
Henry Li
f146e35ee7 feat: rewording 2026-02-08 23:44:36 +08:00
hetaoBackend
6eb4cdd3ec feat: disallow present_files tool in subagents and add market-analysis skill
Add "present_files" to disallowed_tools for bash and general-purpose
subagents to prevent them from presenting files directly. Also add the
new market-analysis skill for generating consulting-grade reports.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 23:38:55 +08:00
Henry Li
8a2351593c feat: add special effect for Ultra mode 2026-02-08 23:22:51 +08:00
hetaoBackend
2703eb0b22 docs: revise backend README and CLAUDE.md to reflect full architecture
Updated documentation to accurately cover all backend subsystems including
subagents, memory, middleware chain, sandbox, MCP, skills, and gateway API.
Fixed broken MCP_SETUP.md link in root README.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 22:50:42 +08:00
Henry Li
010aba1e28 feat: add realtime subagent status report 2026-02-08 22:43:51 +08:00
hetaoBackend
808e028338 feat: limit concurrent subagents to 3 per turn
Prevent resource exhaustion by capping the number of parallel subagents.
Adds runtime enforcement in task_tool and updates prompts/examples accordingly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 22:12:21 +08:00
hetaoBackend
96bace7ab6 feat: add real-time streaming of subagent AI messages
Enable task tool to capture and stream AI messages as they are generated by subagents. This replaces simple polling status updates with detailed message-level progress updates.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-08 21:29:45 +08:00
Henry Li
0355493a16 feat: rewording and add initial animation 2026-02-08 21:24:17 +08:00
hetaoBackend
17365e40d5 fix: fix sub agent timeout 2026-02-08 21:09:18 +08:00
Henry Li
5d4cecbb84 refactor: optimize task handling in message list 2026-02-07 18:42:24 +08:00
Henry Li
de8ff9d336 feat: add ambilight 2026-02-07 18:42:08 +08:00
Henry Li
d9a52f07e7 feat: add handling for task timeout and enhance Streamdown plugin for word animation 2026-02-07 18:06:22 +08:00
Henry Li
260953fb81 feat: adjust position 2026-02-07 18:00:24 +08:00
Henry Li
b135449c07 fix: adjust suggestion positioning and height for improved UI layout 2026-02-07 17:56:06 +08:00
hetaoBackend
f41d9b3be5 refactor: optimize task tool parameter order and improve task tracking
- Reorder task tool parameters to prioritize description first for better usability
- Add tool_call_id injection for better task traceability
- Use tool_call_id as task_id in executor for consistent tracking
- Simplify event messages by removing redundant task_type field
- Update task examples in prompt to reflect new parameter order

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 16:56:13 +08:00
Henry Li
3e2883e2a3 feat: support subtasks 2026-02-07 16:14:48 +08:00
Henry Li
39a5d8dc30 Merge remote-tracking branch 'refs/remotes/origin/experimental' into experimental 2026-02-07 16:13:48 +08:00
LofiSu
e4eb4a65cf Merge pull request #25 from LofiSu/feat/citations
feat(citations): add shared citation components and optimize code
2026-02-07 12:13:32 +08:00
Henry Li
91a05acdf8 feat: enhance workspace navigation menu with conditional rendering and mounted state 2026-02-07 11:10:24 +08:00
Henry Li
60be7ee20d docs: update description for surprise-me skill to enhance clarity 2026-02-07 10:51:43 +08:00
Henry Li
c758a28a3e styles: format 2026-02-07 10:50:08 +08:00
Henry Li
a122f76e36 feat: add animations 2026-02-07 10:30:35 +08:00
LofiSu
f0075e0d64 Merge upstream/experimental into feat/citations
Resolved conflicts:
- backend/src/gateway/routers/artifacts.py: Keep citations block removal for markdown downloads
- frontend/src/components/workspace/messages/message-list-item.tsx: Keep improved citation handling with rehypePlugins, humanMessagePlugins, and CitationsLoadingIndicator

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-07 00:53:16 +08:00
Henry Li
5ed15d79c9 fix: fix markdown table 2026-02-06 22:00:55 +08:00