Skip to content

Commit 48be718

Browse files
committed
feat: support system prompt
1 parent adf2521 commit 48be718

File tree

4 files changed

+481
-476
lines changed

4 files changed

+481
-476
lines changed

package.json

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -81,57 +81,57 @@
8181
"yauzl": "^3.1.3"
8282
},
8383
"dependencies": {
84-
"@opensumi/ide-addons": "3.8.1-next-1741160259.0",
85-
"@opensumi/ide-ai-native": "3.8.1-next-1741160259.0",
86-
"@opensumi/ide-comments": "3.8.1-next-1741160259.0",
87-
"@opensumi/ide-core-browser": "3.8.1-next-1741160259.0",
88-
"@opensumi/ide-core-common": "3.8.1-next-1741160259.0",
89-
"@opensumi/ide-core-electron-main": "3.8.1-next-1741160259.0",
90-
"@opensumi/ide-core-node": "3.8.1-next-1741160259.0",
91-
"@opensumi/ide-debug": "3.8.1-next-1741160259.0",
92-
"@opensumi/ide-decoration": "3.8.1-next-1741160259.0",
93-
"@opensumi/ide-design": "3.8.1-next-1741160259.0",
94-
"@opensumi/ide-editor": "3.8.1-next-1741160259.0",
95-
"@opensumi/ide-electron-basic": "3.8.1-next-1741160259.0",
96-
"@opensumi/ide-explorer": "3.8.1-next-1741160259.0",
97-
"@opensumi/ide-express-file-server": "3.8.1-next-1741160259.0",
98-
"@opensumi/ide-extension": "3.8.1-next-1741160259.0",
99-
"@opensumi/ide-extension-manager": "3.8.1-next-1741160259.0",
100-
"@opensumi/ide-extension-storage": "3.8.1-next-1741160259.0",
101-
"@opensumi/ide-file-scheme": "3.8.1-next-1741160259.0",
102-
"@opensumi/ide-file-search": "3.8.1-next-1741160259.0",
103-
"@opensumi/ide-file-service": "3.8.1-next-1741160259.0",
104-
"@opensumi/ide-file-tree-next": "3.8.1-next-1741160259.0",
105-
"@opensumi/ide-i18n": "3.8.1-next-1741160259.0",
106-
"@opensumi/ide-keymaps": "3.8.1-next-1741160259.0",
107-
"@opensumi/ide-logs": "3.8.1-next-1741160259.0",
108-
"@opensumi/ide-main-layout": "3.8.1-next-1741160259.0",
109-
"@opensumi/ide-markdown": "3.8.1-next-1741160259.0",
110-
"@opensumi/ide-markers": "3.8.1-next-1741160259.0",
111-
"@opensumi/ide-menu-bar": "3.8.1-next-1741160259.0",
112-
"@opensumi/ide-monaco": "3.8.1-next-1741160259.0",
113-
"@opensumi/ide-monaco-enhance": "3.8.1-next-1741160259.0",
114-
"@opensumi/ide-opened-editor": "3.8.1-next-1741160259.0",
115-
"@opensumi/ide-outline": "3.8.1-next-1741160259.0",
116-
"@opensumi/ide-output": "3.8.1-next-1741160259.0",
117-
"@opensumi/ide-overlay": "3.8.1-next-1741160259.0",
118-
"@opensumi/ide-preferences": "3.8.1-next-1741160259.0",
119-
"@opensumi/ide-process": "3.8.1-next-1741160259.0",
120-
"@opensumi/ide-quick-open": "3.8.1-next-1741160259.0",
121-
"@opensumi/ide-remote-opener": "3.8.1-next-1741160259.0",
122-
"@opensumi/ide-scm": "3.8.1-next-1741160259.0",
123-
"@opensumi/ide-search": "3.8.1-next-1741160259.0",
124-
"@opensumi/ide-status-bar": "3.8.1-next-1741160259.0",
125-
"@opensumi/ide-storage": "3.8.1-next-1741160259.0",
126-
"@opensumi/ide-task": "3.8.1-next-1741160259.0",
127-
"@opensumi/ide-terminal-next": "3.8.1-next-1741160259.0",
128-
"@opensumi/ide-testing": "3.8.1-next-1741160259.0",
129-
"@opensumi/ide-theme": "3.8.1-next-1741160259.0",
130-
"@opensumi/ide-toolbar": "3.8.1-next-1741160259.0",
131-
"@opensumi/ide-variable": "3.8.1-next-1741160259.0",
132-
"@opensumi/ide-webview": "3.8.1-next-1741160259.0",
133-
"@opensumi/ide-workspace": "3.8.1-next-1741160259.0",
134-
"@opensumi/ide-workspace-edit": "3.8.1-next-1741160259.0",
84+
"@opensumi/ide-addons": "3.8.1-next-1741253659.0",
85+
"@opensumi/ide-ai-native": "3.8.1-next-1741253659.0",
86+
"@opensumi/ide-comments": "3.8.1-next-1741253659.0",
87+
"@opensumi/ide-core-browser": "3.8.1-next-1741253659.0",
88+
"@opensumi/ide-core-common": "3.8.1-next-1741253659.0",
89+
"@opensumi/ide-core-electron-main": "3.8.1-next-1741253659.0",
90+
"@opensumi/ide-core-node": "3.8.1-next-1741253659.0",
91+
"@opensumi/ide-debug": "3.8.1-next-1741253659.0",
92+
"@opensumi/ide-decoration": "3.8.1-next-1741253659.0",
93+
"@opensumi/ide-design": "3.8.1-next-1741253659.0",
94+
"@opensumi/ide-editor": "3.8.1-next-1741253659.0",
95+
"@opensumi/ide-electron-basic": "3.8.1-next-1741253659.0",
96+
"@opensumi/ide-explorer": "3.8.1-next-1741253659.0",
97+
"@opensumi/ide-express-file-server": "3.8.1-next-1741253659.0",
98+
"@opensumi/ide-extension": "3.8.1-next-1741253659.0",
99+
"@opensumi/ide-extension-manager": "3.8.1-next-1741253659.0",
100+
"@opensumi/ide-extension-storage": "3.8.1-next-1741253659.0",
101+
"@opensumi/ide-file-scheme": "3.8.1-next-1741253659.0",
102+
"@opensumi/ide-file-search": "3.8.1-next-1741253659.0",
103+
"@opensumi/ide-file-service": "3.8.1-next-1741253659.0",
104+
"@opensumi/ide-file-tree-next": "3.8.1-next-1741253659.0",
105+
"@opensumi/ide-i18n": "3.8.1-next-1741253659.0",
106+
"@opensumi/ide-keymaps": "3.8.1-next-1741253659.0",
107+
"@opensumi/ide-logs": "3.8.1-next-1741253659.0",
108+
"@opensumi/ide-main-layout": "3.8.1-next-1741253659.0",
109+
"@opensumi/ide-markdown": "3.8.1-next-1741253659.0",
110+
"@opensumi/ide-markers": "3.8.1-next-1741253659.0",
111+
"@opensumi/ide-menu-bar": "3.8.1-next-1741253659.0",
112+
"@opensumi/ide-monaco": "3.8.1-next-1741253659.0",
113+
"@opensumi/ide-monaco-enhance": "3.8.1-next-1741253659.0",
114+
"@opensumi/ide-opened-editor": "3.8.1-next-1741253659.0",
115+
"@opensumi/ide-outline": "3.8.1-next-1741253659.0",
116+
"@opensumi/ide-output": "3.8.1-next-1741253659.0",
117+
"@opensumi/ide-overlay": "3.8.1-next-1741253659.0",
118+
"@opensumi/ide-preferences": "3.8.1-next-1741253659.0",
119+
"@opensumi/ide-process": "3.8.1-next-1741253659.0",
120+
"@opensumi/ide-quick-open": "3.8.1-next-1741253659.0",
121+
"@opensumi/ide-remote-opener": "3.8.1-next-1741253659.0",
122+
"@opensumi/ide-scm": "3.8.1-next-1741253659.0",
123+
"@opensumi/ide-search": "3.8.1-next-1741253659.0",
124+
"@opensumi/ide-status-bar": "3.8.1-next-1741253659.0",
125+
"@opensumi/ide-storage": "3.8.1-next-1741253659.0",
126+
"@opensumi/ide-task": "3.8.1-next-1741253659.0",
127+
"@opensumi/ide-terminal-next": "3.8.1-next-1741253659.0",
128+
"@opensumi/ide-testing": "3.8.1-next-1741253659.0",
129+
"@opensumi/ide-theme": "3.8.1-next-1741253659.0",
130+
"@opensumi/ide-toolbar": "3.8.1-next-1741253659.0",
131+
"@opensumi/ide-variable": "3.8.1-next-1741253659.0",
132+
"@opensumi/ide-webview": "3.8.1-next-1741253659.0",
133+
"@opensumi/ide-workspace": "3.8.1-next-1741253659.0",
134+
"@opensumi/ide-workspace-edit": "3.8.1-next-1741253659.0",
135135
"@opensumi/tree-sitter-wasm": "1.1.2",
136136
"@vscode/spdlog": "^0.15.0",
137137
"buffer": "^6.0.3",

src/ai/browser/prompt.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { IMarkerErrorData } from '@opensumi/ide-ai-native/lib/browser/contrib/intelligent-completions/source/lint-error.source';
22
import { EInlineOperation } from './constants'
33

4+
export const DefaultSystemPrompt = 'You are a powerful AI coding assistant working in CodeFuse IDE, a AI Native IDE based on CodeFuse and OpenSumi. You collaborate with a USER to solve coding tasks, which may involve creating, modifying, or debugging code, or answering questions. When the USER sends a message, relevant context (e.g., open files, cursor position, edit history, linter errors) may be attached. Use this information as needed.\n\n<tool_calling>\nYou have access to tools to assist with tasks. Follow these rules:\n1. Always adhere to the tool call schema and provide all required parameters.\n2. Only use tools explicitly provided; ignore unavailable ones.\n3. Avoid mentioning tool names to the USER (e.g., say "I will edit your file" instead of "I need to use the edit_file tool").\n4. Only call tools when necessary; respond directly if the task is general or you already know the answer.\n5. Explain to the USER why you’re using a tool before calling it.\n</tool_calling>\n\n<making_code_changes>\nWhen modifying code:\n1. Use code edit tools instead of outputting code unless explicitly requested.\n2. Limit tool calls to one per turn.\n3. Ensure generated code is immediately executable by including necessary imports, dependencies, and endpoints.\n4. For new projects, create a dependency management file (e.g., requirements.txt) and a README.\n5. For web apps, design a modern, user-friendly UI.\n6. Avoid generating non-textual or excessively long code.\n7. Read file contents before editing, unless appending a small change or creating a new file.\n8. Fix introduced linter errors if possible, but stop after 3 attempts and ask the USER for guidance.\n9. Reapply reasonable code edits if they weren’t followed initially.\n</making_code_changes>\n\nUse the appropriate tools to fulfill the USER’s request, ensuring all required parameters are provided or inferred from context.';
5+
46
export const explainPrompt = (language: string, code: string) => {
57
return `你将获得一段代码, 你的任务是以简洁的方式解释它,用中文回答。代码内容是: \n\`\`\`${language}\n${code}\n\`\`\``;
68
};

src/bootstrap/browser/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import { CoreBrowserModule, ELECTRON_HEADER } from '@/core/browser';
5757
import { AIFeatureModule, AI_MENU_BAR_LEFT_ACTION } from '@/ai/browser';
5858
import { AutoUpdaterModule } from '@/auto-updater/browser'
5959
import logo from '@/core/browser/assets/logo.svg'
60+
import { DefaultSystemPrompt } from '@/ai/browser/prompt';
6061

6162
// 临时修复 bash 打开 -l 参数不支持导致报错的问题
6263
terminalPreferenceSchema.properties['terminal.integrated.shellArgs.osx'].default = [];
@@ -178,6 +179,7 @@ async function renderApp() {
178179
// 开启 Code Edits
179180
[AINativeSettingSectionsId.CodeEditsLintErrors]: true,
180181
[AINativeSettingSectionsId.CodeEditsLineChange]: true,
182+
[AINativeSettingSectionsId.SystemPrompt]: DefaultSystemPrompt,
181183
},
182184
onigWasmUri: URI.file(electronEnv.onigWasmPath).toString(true),
183185
treeSitterWasmDirectoryUri: URI.file(electronEnv.treeSitterWasmDirectoryPath).toString(true),

0 commit comments

Comments
 (0)