Skip to content

feat: 增强 setup_workspace 隐式触发识别#225

Merged
lishuceo merged 5 commits intomainfrom
feat/proactive-workspace-setup-v2
Apr 10, 2026
Merged

feat: 增强 setup_workspace 隐式触发识别#225
lishuceo merged 5 commits intomainfrom
feat/proactive-workspace-setup-v2

Conversation

@lishuceo
Copy link
Copy Markdown
Owner

Summary

  • 在 system prompt 中新增"积极识别仓库意图"章节,列出 6 种隐式触发 setup_workspace 的场景
  • 新增"源码验证原则":涉及具体仓库代码时必须 setup_workspace 进行源码验证
  • 同步更新 setup_workspace MCP tool description,补充 3 条隐式触发场景

动机

此前 Claude 只在用户显式说"切换到 X 仓库"或提到 repo URL 时才触发 setup_workspace。当用户隐式引用仓库(如讨论 urhox 架构、提到某仓库的 CLAUDE.md、问代码实现细节)时,Claude 倾向于在默认工作目录"空谈",缺少 CLAUDE.md 等项目上下文。

改动

src/claude/executor.ts — system prompt

新增"积极识别仓库意图"段落,覆盖 6 种隐式场景:

  1. 提到项目特有文件路径(如 "urhox 的 CLAUDE.md")
  2. 讨论特定项目的架构/代码
  3. 引用外部报告中的代码片段
  4. 问题涉及项目特有技术栈/概念
  5. 用户提到仓库名或组织名
  6. 需要查看/验证实际代码才能准确回答

新增"源码验证原则":不能凭训练知识回答关于特定仓库代码的问题。

src/workspace/tool.ts — tool description

补充 3 条隐式触发场景到 MCP tool 描述。

Test plan

  • 飞书对话测试隐式场景:问 "urhox 的 CLAUDE.md 里写了什么"
  • 验证显式场景仍正常工作
  • 验证通用问题不触发误判

🤖 Generated with Claude Code

在 system prompt 和 tool description 中增加隐式仓库意图识别场景:
- 提到项目特有文件路径(如 "urhox 的 CLAUDE.md")
- 讨论特定项目的架构/代码
- 引用外部报告中的代码片段
- 问题涉及项目特有技术栈
- 需要查看实际源码才能准确回答

新增"源码验证原则":涉及具体仓库代码时必须 setup_workspace
进行源码验证,不能仅凭训练知识回答。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@claude
Copy link
Copy Markdown

claude Bot commented Apr 10, 2026

Claude finished @lishuceo's task in 50s —— View job


PR Review: feat: 增强 setup_workspace 隐式触发识别

  • Check for previous review comments
  • Read changed files and diff
  • Perform code review
  • Post review summary

✅ Approved

This PR is a prompt-only change (no logic, no runtime behavior change) that adds guidance to help the agent proactively identify implicit repository references and trigger setup_workspace.

Changes reviewed:

  1. src/claude/executor.ts (+13 lines) — Adds a "积极识别仓库意图" section to the system prompt with 6 implicit trigger patterns and a "源码验证原则". Well-structured, fits naturally after the existing workspace management instructions and before the directory access restrictions.

  2. src/workspace/tool.ts (+3 lines) — Adds 3 matching implicit trigger scenarios to the MCP tool description, consistent with the system prompt additions.

Assessment:

  • The additions are well-scoped and address a real UX gap (agent not switching workspaces when users implicitly reference repos).
  • System prompt and tool description stay in sync — the tool description mirrors the key scenarios from the prompt.
  • No bugs, security issues, or architectural concerns — these are pure prompt/documentation changes.
  • The examples are concrete and project-specific (urhox, maker, anycode), which helps the agent pattern-match effectively.
  • Fits cleanly into the existing prompt structure without disrupting the flow.

No issues found. Clean, focused PR.

避免对特定仓库名(urhox/maker 等)过拟合,让识别模式适用于任何部署。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@claude
Copy link
Copy Markdown

claude Bot commented Apr 10, 2026

Claude finished @lishuceo's task in 47s —— View job


PR Review: feat: 增强 setup_workspace 隐式触发识别

  • Check and resolve previous review comments — no previous inline comments found
  • Read current diff and changed files
  • Perform code review
  • Post review summary

✅ Approved

Commits reviewed: acd747c (initial feature) + 86c9393 (remove hardcoded repo names)

This is a prompt-only change — no runtime logic modified. Both files add well-structured guidance text for the agent.

src/claude/executor.ts (+13 lines): Adds a "积极识别仓库意图" subsection under the existing workspace management prompt. Lists 6 implicit trigger patterns and a "源码验证原则". Placement is correct — sits between the general workspace rule and the directory access restrictions, maintaining logical flow.

src/workspace/tool.ts (+3 lines): Adds 3 matching implicit trigger scenarios to the MCP tool description array. These are consistent with the system prompt additions and follow the existing list format.

Assessment:

  • No bugs, security issues, or architectural concerns — pure prompt text additions
  • System prompt and tool description are kept in sync
  • The second commit properly removed hardcoded project names (urhox/maker/anycode), replacing them with generic patterns (X/Y/Z placeholders) — good for reusability
  • Follows existing code patterns: template literals with variable interpolation, Chinese documentation style

No issues found. Clean, focused change.

@claude
Copy link
Copy Markdown

claude Bot commented Apr 10, 2026

Claude finished @lishuceo's task in 44s —— View job


PR Review: feat: 增强 setup_workspace 隐式触发识别

  • Check and resolve previous inline review comments — no previous inline comments found
  • Read current diff and changed files
  • Read full source files for context
  • Perform code review
  • Post review summary

✅ Approved

Commits reviewed: acd747c8b42ccc (3 commits, including merge from main)

This is a prompt-only change — no runtime logic modified. Both files add well-structured guidance text for the agent.

src/claude/executor.ts (+13 lines): Adds a "积极识别仓库意图" subsection to the system prompt listing 6 implicit trigger patterns plus a "源码验证原则". Placement is correct — sits between the general workspace rule (line 353) and the directory access restrictions (line 368), maintaining logical flow.

src/workspace/tool.ts (+3 lines): Adds 3 matching implicit trigger scenarios to the MCP tool description array. Consistent with the system prompt additions and follows the existing list format.

Assessment:

  • No bugs, security issues, or architectural concerns — pure prompt text additions
  • System prompt and tool description are kept in sync — the 3 new tool description items correspond to patterns 1, 2, and 6 from the system prompt
  • Uses generic placeholders (X/Y/Z) instead of hardcoded project names — good for reusability across deployments
  • Follows existing code patterns: template literals, Chinese documentation style, numbered list format

No issues found. Clean, focused change.

@claude
Copy link
Copy Markdown

claude Bot commented Apr 10, 2026

Claude finished @lishuceo's task in 45s —— View job


PR Review: feat: 增强 setup_workspace 隐式触发识别

  • Check and resolve previous inline review comments — no previous inline comments found
  • Read current diff and changed files
  • Read full source files for context
  • Perform code review
  • Post review summary

✅ Approved

This is a prompt-only change (no runtime logic modified) that adds guidance for proactive implicit workspace detection.

src/claude/executor.ts (+13 lines): Adds "积极识别仓库意图" subsection with 6 implicit trigger patterns and a "源码验证原则". Correctly placed between the general workspace rule (line 353) and directory access restrictions (line 368), maintaining logical flow.

src/workspace/tool.ts (+3 lines): Adds 3 matching implicit trigger scenarios to the MCP tool description. Consistent with the system prompt additions and follows the existing list format.

Assessment:

  • No bugs, security issues, or architectural concerns
  • System prompt and tool description are kept in sync — tool description items correspond to patterns 1, 2, and 6 from the system prompt
  • Uses generic placeholders (X/Y/Z) instead of hardcoded project names — good for reusability
  • Follows existing code patterns: template literals, Chinese documentation style, numbered list format

No issues found.

@lishuceo lishuceo merged commit 639e3f8 into main Apr 10, 2026
3 of 4 checks passed
@lishuceo lishuceo deleted the feat/proactive-workspace-setup-v2 branch April 10, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant