feat: add system prompt customization options in SDK and CLI#2400
feat: add system prompt customization options in SDK and CLI#2400tanzhenxin merged 3 commits intomainfrom
Conversation
📋 Review SummaryThis PR adds system prompt customization options to the TypeScript SDK and CLI, allowing users to either override or append to the default system prompt. The implementation is well-structured with comprehensive test coverage across all affected packages (SDK, CLI, and Core). The changes follow existing project conventions and maintain backward compatibility. 🔍 General Feedback
🎯 Specific Feedback🟡 High
🟢 Medium
🔵 Low
✅ Highlights
|
5bc9cee to
ee33a3c
Compare
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
| z.string().min(1, 'systemPrompt must be a non-empty string'), | ||
| QuerySystemPromptPresetSchema, | ||
| ]) | ||
| .optional(), |
There was a problem hiding this comment.
If systemPrompt is string | QuerySystemPromptPresetSchema, what is the equivalent usage of a CLI call with both systemPrompt and appendSystemPrompt specified? Say:
qwen --systemPrompt 'system context' --appendSystemPrompt 'appended context'
Though the CLI arguments hint that these two can be combined, SDK's query does not support passing both systemPrompt and appendSystemPrompt because I can either use string(systemPrompt only) or QuerySystemPromptPresetSchema(appendSystemPrompt only because preset and type are non-optional literals).
There was a problem hiding this comment.
There isn’t a direct equivalent for this in the SDK.
For CLI:
qwen --systemPrompt "system context" --appendSystemPrompt "appended context"In the SDK, this should be written by simply concatenating the content:
{
systemPrompt: "system context. appended context"
}In other words, appendSystemPrompt is not modeled as a separate field in the SDK — you should manually merge the prompts.
Also, the SDK API here is designed with reference to Claude Code’s approach.
…text - Add helper functions for better code organization (createPrintableKey, getCompleteCsiSequenceLength, parsePlainTextPrefix) - Drop unsupported Kitty CSI-u keys without blocking subsequent input - Recover plain text that arrives in same chunk after unsupported CSI-u keys - Add comprehensive tests for edge cases (CAPS_LOCK, event metadata variants) Improves robustness of Kitty keyboard protocol parsing by gracefully handling unsupported key codes and ensuring plain text input is not lost. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
TLDR
This PR adds system prompt customization options to both the TypeScript SDK and CLI. Users can now override or append to the default system prompt when using the SDK or CLI.
Dive Deeper
This change introduces flexible system prompt configuration:
SDK: Added
systemPromptoption toQueryOptionsthat accepts either:type: 'preset',presetname, and optionalappendtext to extend a presetCLI: Updated config handling to support the new system prompt options
Core: Modified prompt handling in the core package to support the new customization options
The changes are fully tested with unit tests across all affected packages.
Reviewer Test Plan
npm run buildnpm test(all tests should pass)Testing Matrix
Tested on macOS with npm run and unit tests passing.
Linked issues / bugs
No linked issues
🤖 Generated with Qwen Code