feat: 大量系统提示词优化#446
Conversation
- 合并 getOutputEfficiencySection + getSimpleToneAndStyleSection 为精简的 Communication style - 精简 auto memory 指令:删除 4 种类型的详细说明和示例,仅保留核心 description - 精简 Agent 工具:删除 forkExamples 和 currentExamples 大段示例 - 精简 Bash 工具:合并 sleep 相关指导 - 精简 EnterPlanMode/ExitPlanMode:删除详细 GOOD/BAD 示例 - gitStatus MAX_STATUS_CHARS 从 2000 降到 1000 - 同步更新 prompt engineering audit 测试断言 Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
- prependUserContext: 将 claudeMd 从通用 <system-reminder> 提取为独立的 <project-instructions> 用户消息,不带免责声明,置于消息列表最前面 - queryModel: deferred tools 消息从 prepend 改为 append,避免抢占 project-instructions 的最高权重位置;标签规范化为 <system-reminder> Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
增强 SentryErrorBoundary 组件,捕获渲染错误时输出诊断信息 (错误消息 + component stack)到 stderr 和终端,而非静默返回 null。在 replLauncher 根节点和 Messages 组件层级包裹 Error Boundary,防止 Ink 内部的 Error Boundary 直接终止进程。 Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
📝 WalkthroughWalkthroughThis PR refactors the Sentry error boundary from TypeScript to TSX with enhanced error UI, updates multiple tool and system prompts for clarity, adjusts context and API message ordering, and refreshes repository documentation with expanded metadata and feature lists. ChangesSentry Error Boundary Refactoring
Prompt Engineering & System Guidance
Context & API Message Ordering
Documentation & Metadata
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/builtin-tools/src/tools/AgentTool/prompt.ts (1)
75-77:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winUpdate stale comment about fork-aware examples.
Line 76-Line 77 still states examples are swapped, but this function no longer appends example blocks. Please sync the comment with current behavior to avoid future confusion.
Suggested edit
- // Fork subagent feature: when enabled, insert the "When to fork" section - // (fork semantics, directive-style prompts) and swap in fork-aware examples. + // Fork subagent feature: when enabled, insert the "When to fork" section + // (fork semantics, directive-style prompts).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/builtin-tools/src/tools/AgentTool/prompt.ts` around lines 75 - 77, The comment above the forkEnabled declaration is stale: update the comment near the isForkSubagentEnabled() call/const forkEnabled to reflect current behavior (it only inserts the "When to fork" section and does not swap or append example blocks anymore). Replace the phrase about swapping in "fork-aware examples" with a short note that only the "When to fork" section is inserted when isForkSubagentEnabled() returns true, referencing the isForkSubagentEnabled() check and the forkEnabled variable so readers can locate the logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/Messages.tsx`:
- Line 3: The import in Messages.tsx uses a relative path for
SentryErrorBoundary (import { SentryErrorBoundary } from
'./SentryErrorBoundary.js'), which violates the repo rule requiring src/*
aliases; update the import to use the tsconfig alias (e.g., import from
'src/components/SentryErrorBoundary') and remove the explicit .js extension if
not needed so the module resolution and linting conform to the project's
import-path policy.
In `@src/context.ts`:
- Line 20: The truncation notice string still refers to “2k characters” even
though the constant MAX_STATUS_CHARS was changed to 1000; update the message
(wherever the truncation notice is constructed/returned — reference the constant
MAX_STATUS_CHARS and the function or variable that emits the notice) to reflect
the new 1,000-character limit or, better, interpolate/format the message using
MAX_STATUS_CHARS so it stays correct when the constant changes (e.g., replace
the hardcoded “2k characters” text with a dynamic reference to MAX_STATUS_CHARS
or the value "1000").
In `@src/replLauncher.tsx`:
- Line 21: Replace the relative dynamic import in replLauncher.tsx that loads
'./components/SentryErrorBoundary.js' with the repo alias path under src (e.g.,
import from 'src/components/SentryErrorBoundary.js') so it follows the tsconfig
alias-only policy; update the import string inside the await import(...) call
where SentryErrorBoundary is imported.
---
Outside diff comments:
In `@packages/builtin-tools/src/tools/AgentTool/prompt.ts`:
- Around line 75-77: The comment above the forkEnabled declaration is stale:
update the comment near the isForkSubagentEnabled() call/const forkEnabled to
reflect current behavior (it only inserts the "When to fork" section and does
not swap or append example blocks anymore). Replace the phrase about swapping in
"fork-aware examples" with a short note that only the "When to fork" section is
inserted when isForkSubagentEnabled() returns true, referencing the
isForkSubagentEnabled() check and the forkEnabled variable so readers can locate
the logic.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 39a3bb91-e2aa-4ee4-9f6d-97cfe6d34e3d
📒 Files selected for processing (16)
CLAUDE.mdpackages/builtin-tools/src/tools/AgentTool/__tests__/prompt.test.tspackages/builtin-tools/src/tools/AgentTool/prompt.tspackages/builtin-tools/src/tools/BashTool/prompt.tspackages/builtin-tools/src/tools/EnterPlanModeTool/prompt.tspackages/builtin-tools/src/tools/ExitPlanModeTool/prompt.tssrc/components/Messages.tsxsrc/components/SentryErrorBoundary.tssrc/components/SentryErrorBoundary.tsxsrc/constants/promptEngineeringAudit.runner.tssrc/constants/prompts.tssrc/context.tssrc/memdir/memoryTypes.tssrc/replLauncher.tsxsrc/services/api/claude.tssrc/utils/api.ts
💤 Files with no reviewable changes (3)
- src/components/SentryErrorBoundary.ts
- packages/builtin-tools/src/tools/AgentTool/tests/prompt.test.ts
- packages/builtin-tools/src/tools/ExitPlanModeTool/prompt.ts
| @@ -1,5 +1,6 @@ | |||
| import { feature } from 'bun:bundle'; | |||
| import chalk from 'chalk'; | |||
| import { SentryErrorBoundary } from './SentryErrorBoundary.js'; | |||
There was a problem hiding this comment.
Use src/* alias for this new import path
Line 3 introduces a relative import from the src tree. This violates the repo import-path rule and can cause consistency/lint failures.
Suggested fix
-import { SentryErrorBoundary } from './SentryErrorBoundary.js';
+import { SentryErrorBoundary } from 'src/components/SentryErrorBoundary.js';As per coding guidelines: “Import paths must use the src/* alias defined in tsconfig.json; do not use relative paths for imports from src directory”.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| import { SentryErrorBoundary } from './SentryErrorBoundary.js'; | |
| import { SentryErrorBoundary } from 'src/components/SentryErrorBoundary.js'; |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/components/Messages.tsx` at line 3, The import in Messages.tsx uses a
relative path for SentryErrorBoundary (import { SentryErrorBoundary } from
'./SentryErrorBoundary.js'), which violates the repo rule requiring src/*
aliases; update the import to use the tsconfig alias (e.g., import from
'src/components/SentryErrorBoundary') and remove the explicit .js extension if
not needed so the module resolution and linting conform to the project's
import-path policy.
| import { logError } from './utils/log.js' | ||
|
|
||
| const MAX_STATUS_CHARS = 2000 | ||
| const MAX_STATUS_CHARS = 1000 |
There was a problem hiding this comment.
Update truncation notice to match new limit
MAX_STATUS_CHARS is now 1000 at Line 20, but the message at Line 88 still says “2k characters,” which is now inaccurate.
Suggested fix
- '\n... (truncated because it exceeds 2k characters. If you need more information, run "git status" using BashTool)'
+ '\n... (truncated because it exceeds 1k characters. If you need more information, run "git status" using BashTool)'Also applies to: 88-89
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/context.ts` at line 20, The truncation notice string still refers to “2k
characters” even though the constant MAX_STATUS_CHARS was changed to 1000;
update the message (wherever the truncation notice is constructed/returned —
reference the constant MAX_STATUS_CHARS and the function or variable that emits
the notice) to reflect the new 1,000-character limit or, better,
interpolate/format the message using MAX_STATUS_CHARS so it stays correct when
the constant changes (e.g., replace the hardcoded “2k characters” text with a
dynamic reference to MAX_STATUS_CHARS or the value "1000").
| renderAndRun: (root: Root, element: React.ReactNode) => Promise<void>, | ||
| ): Promise<void> { | ||
| const { App } = await import('./components/App.js'); | ||
| const { SentryErrorBoundary } = await import('./components/SentryErrorBoundary.js'); |
There was a problem hiding this comment.
Switch dynamic import to src/* alias
Line 21 uses a relative import for a module under src/. Please align it with the repo’s alias-only import policy.
Suggested fix
- const { SentryErrorBoundary } = await import('./components/SentryErrorBoundary.js');
+ const { SentryErrorBoundary } = await import('src/components/SentryErrorBoundary.js');As per coding guidelines: “Import paths must use the src/* alias defined in tsconfig.json; do not use relative paths for imports from src directory”.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const { SentryErrorBoundary } = await import('./components/SentryErrorBoundary.js'); | |
| const { SentryErrorBoundary } = await import('src/components/SentryErrorBoundary.js'); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/replLauncher.tsx` at line 21, Replace the relative dynamic import in
replLauncher.tsx that loads './components/SentryErrorBoundary.js' with the repo
alias path under src (e.g., import from 'src/components/SentryErrorBoundary.js')
so it follows the tsconfig alias-only policy; update the import string inside
the await import(...) call where SentryErrorBoundary is imported.
Need help on this PR? Tag
@codesmithwith what you need.Summary by CodeRabbit
Release Notes
New Features
Documentation
Refactor