@opensumi/ide-ai-native 3.9.1-next-1749181695.0 → 3.9.1-next-1749196667.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/ai-core.contribution.d.ts.map +1 -1
- package/lib/browser/ai-core.contribution.js +4 -9
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/chat/apply.service.d.ts +0 -3
- package/lib/browser/chat/apply.service.d.ts.map +1 -1
- package/lib/browser/chat/apply.service.js +0 -47
- package/lib/browser/chat/apply.service.js.map +1 -1
- package/lib/browser/chat/chat-model.d.ts.map +1 -1
- package/lib/browser/chat/chat-model.js +1 -3
- package/lib/browser/chat/chat-model.js.map +1 -1
- package/lib/browser/chat/chat-proxy.service.d.ts +2 -0
- package/lib/browser/chat/chat-proxy.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-proxy.service.js +57 -50
- package/lib/browser/chat/chat-proxy.service.js.map +1 -1
- package/lib/browser/chat/chat.feature.registry.d.ts +1 -4
- package/lib/browser/chat/chat.feature.registry.d.ts.map +1 -1
- package/lib/browser/chat/chat.feature.registry.js +0 -6
- package/lib/browser/chat/chat.feature.registry.js.map +1 -1
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +8 -33
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/ChatEditor.js +2 -2
- package/lib/browser/components/ChatEditor.js.map +1 -1
- package/lib/browser/components/ChatHistory.d.ts.map +1 -1
- package/lib/browser/components/ChatHistory.js +1 -2
- package/lib/browser/components/ChatHistory.js.map +1 -1
- package/lib/browser/components/ChatMentionInput.d.ts.map +1 -1
- package/lib/browser/components/ChatMentionInput.js +30 -148
- package/lib/browser/components/ChatMentionInput.js.map +1 -1
- package/lib/browser/components/ChatReply.js +2 -2
- package/lib/browser/components/ChatReply.js.map +1 -1
- package/lib/browser/components/ChatToolRender.d.ts.map +1 -1
- package/lib/browser/components/ChatToolRender.js +2 -7
- package/lib/browser/components/ChatToolRender.js.map +1 -1
- package/lib/browser/components/ChatToolRender.module.less +0 -25
- package/lib/browser/components/components.module.less +8 -37
- package/lib/browser/components/mention-input/mention-input.d.ts.map +1 -1
- package/lib/browser/components/mention-input/mention-input.js +14 -150
- package/lib/browser/components/mention-input/mention-input.js.map +1 -1
- package/lib/browser/components/mention-input/mention-input.module.less +1 -165
- package/lib/browser/components/mention-input/types.d.ts +1 -28
- package/lib/browser/components/mention-input/types.d.ts.map +1 -1
- package/lib/browser/components/mention-input/types.js +0 -1
- package/lib/browser/components/mention-input/types.js.map +1 -1
- package/lib/browser/components/utils.d.ts +2 -2
- package/lib/browser/context/llm-context.service.d.ts +2 -21
- package/lib/browser/context/llm-context.service.d.ts.map +1 -1
- package/lib/browser/context/llm-context.service.js +20 -162
- package/lib/browser/context/llm-context.service.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/decoration/additions-deletions.decoration.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/decoration/additions-deletions.decoration.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/diff-computer.js +1 -1
- package/lib/browser/contrib/intelligent-completions/diff-computer.js.map +1 -1
- package/lib/browser/contrib/terminal/terminal.feature.registry.js.map +1 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +0 -7
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/layout/ai-layout.d.ts.map +1 -1
- package/lib/browser/layout/ai-layout.js +4 -6
- package/lib/browser/layout/ai-layout.js.map +1 -1
- package/lib/browser/layout/tabbar.view.d.ts +1 -1
- package/lib/browser/layout/tabbar.view.d.ts.map +1 -1
- package/lib/browser/layout/tabbar.view.js +12 -5
- package/lib/browser/layout/tabbar.view.js.map +1 -1
- package/lib/browser/mcp/base-apply.service.d.ts +4 -5
- package/lib/browser/mcp/base-apply.service.d.ts.map +1 -1
- package/lib/browser/mcp/base-apply.service.js +5 -23
- package/lib/browser/mcp/base-apply.service.js.map +1 -1
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts +1 -3
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts.map +1 -1
- package/lib/browser/mcp/mcp-server-proxy.service.js +0 -4
- package/lib/browser/mcp/mcp-server-proxy.service.js.map +1 -1
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js.map +1 -1
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/ListDir.js.map +1 -1
- package/lib/browser/mcp/tools/runTerminalCmd.js.map +1 -1
- package/lib/browser/preferences/schema.d.ts.map +1 -1
- package/lib/browser/preferences/schema.js +0 -5
- package/lib/browser/preferences/schema.js.map +1 -1
- package/lib/browser/types.d.ts +1 -8
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/types.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.js.map +1 -1
- package/lib/common/index.d.ts +1 -5
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +0 -2
- package/lib/common/index.js.map +1 -1
- package/lib/common/llm-context.d.ts +0 -19
- package/lib/common/llm-context.d.ts.map +1 -1
- package/lib/common/llm-context.js.map +1 -1
- package/lib/common/model.d.ts +0 -1
- package/lib/common/model.d.ts.map +1 -1
- package/lib/common/model.js.map +1 -1
- package/lib/common/prompts/context-prompt-provider.d.ts +2 -0
- package/lib/common/prompts/context-prompt-provider.d.ts.map +1 -1
- package/lib/common/prompts/context-prompt-provider.js +29 -35
- package/lib/common/prompts/context-prompt-provider.js.map +1 -1
- package/lib/common/types.d.ts +0 -21
- package/lib/common/types.d.ts.map +1 -1
- package/lib/common/types.js.map +1 -1
- package/lib/common/utils.d.ts +0 -1
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +2 -5
- package/lib/common/utils.js.map +1 -1
- package/lib/node/anthropic/anthropic-language-model.d.ts +1 -1
- package/lib/node/base-language-model.d.ts +1 -2
- package/lib/node/base-language-model.d.ts.map +1 -1
- package/lib/node/base-language-model.js +2 -12
- package/lib/node/base-language-model.js.map +1 -1
- package/lib/node/deepseek/deepseek-language-model.d.ts +1 -1
- package/lib/node/mcp/sumi-mcp-server.d.ts +1 -3
- package/lib/node/mcp/sumi-mcp-server.d.ts.map +1 -1
- package/lib/node/mcp/sumi-mcp-server.js +1 -7
- package/lib/node/mcp/sumi-mcp-server.js.map +1 -1
- package/lib/node/mcp-server-manager-impl.d.ts +1 -3
- package/lib/node/mcp-server-manager-impl.d.ts.map +1 -1
- package/lib/node/mcp-server-manager-impl.js +2 -14
- package/lib/node/mcp-server-manager-impl.js.map +1 -1
- package/package.json +25 -26
- package/src/browser/ai-core.contribution.ts +4 -14
- package/src/browser/chat/apply.service.ts +1 -62
- package/src/browser/chat/chat-model.ts +1 -3
- package/src/browser/chat/chat-proxy.service.ts +81 -68
- package/src/browser/chat/chat.feature.registry.ts +1 -17
- package/src/browser/chat/chat.view.tsx +10 -40
- package/src/browser/components/ChatEditor.tsx +1 -1
- package/src/browser/components/ChatHistory.tsx +1 -2
- package/src/browser/components/ChatMentionInput.tsx +35 -180
- package/src/browser/components/ChatReply.tsx +4 -4
- package/src/browser/components/ChatToolRender.module.less +0 -25
- package/src/browser/components/ChatToolRender.tsx +2 -10
- package/src/browser/components/components.module.less +8 -37
- package/src/browser/components/mention-input/mention-input.module.less +1 -165
- package/src/browser/components/mention-input/mention-input.tsx +31 -232
- package/src/browser/components/mention-input/types.ts +0 -29
- package/src/browser/context/llm-context.service.ts +21 -182
- package/src/browser/contrib/intelligent-completions/decoration/additions-deletions.decoration.ts +1 -1
- package/src/browser/contrib/intelligent-completions/diff-computer.ts +1 -1
- package/src/browser/contrib/terminal/terminal.feature.registry.ts +1 -1
- package/src/browser/index.ts +0 -8
- package/src/browser/layout/ai-layout.tsx +8 -12
- package/src/browser/layout/tabbar.view.tsx +23 -10
- package/src/browser/mcp/base-apply.service.ts +10 -30
- package/src/browser/mcp/mcp-server-proxy.service.ts +1 -6
- package/src/browser/mcp/tools/getDiagnosticsByPath.ts +1 -1
- package/src/browser/mcp/tools/getOpenEditorFileDiagnostics.ts +1 -1
- package/src/browser/mcp/tools/handlers/ListDir.ts +1 -1
- package/src/browser/mcp/tools/runTerminalCmd.ts +1 -1
- package/src/browser/preferences/schema.ts +0 -5
- package/src/browser/types.ts +0 -12
- package/src/browser/widget/inline-stream-diff/live-preview.component.tsx +1 -0
- package/src/common/index.ts +1 -6
- package/src/common/llm-context.ts +0 -23
- package/src/common/model.ts +0 -1
- package/src/common/prompts/context-prompt-provider.ts +40 -55
- package/src/common/types.ts +0 -18
- package/src/common/utils.ts +1 -4
- package/src/node/base-language-model.ts +14 -11
- package/src/node/mcp/sumi-mcp-server.ts +2 -10
- package/src/node/mcp-server-manager-impl.ts +2 -17
- package/lib/browser/components/mention-input/mention-select.d.ts +0 -28
- package/lib/browser/components/mention-input/mention-select.d.ts.map +0 -1
- package/lib/browser/components/mention-input/mention-select.js +0 -136
- package/lib/browser/components/mention-input/mention-select.js.map +0 -1
- package/lib/browser/components/mention-input/mention-select.module.less +0 -297
- package/lib/browser/rules/rules.contribution.d.ts +0 -29
- package/lib/browser/rules/rules.contribution.d.ts.map +0 -1
- package/lib/browser/rules/rules.contribution.js +0 -94
- package/lib/browser/rules/rules.contribution.js.map +0 -1
- package/lib/browser/rules/rules.module.less +0 -175
- package/lib/browser/rules/rules.service.d.ts +0 -25
- package/lib/browser/rules/rules.service.d.ts.map +0 -1
- package/lib/browser/rules/rules.service.js +0 -180
- package/lib/browser/rules/rules.service.js.map +0 -1
- package/lib/browser/rules/rules.view.d.ts +0 -3
- package/lib/browser/rules/rules.view.d.ts.map +0 -1
- package/lib/browser/rules/rules.view.js +0 -76
- package/lib/browser/rules/rules.view.js.map +0 -1
- package/lib/common/image-compression.d.ts +0 -25
- package/lib/common/image-compression.d.ts.map +0 -1
- package/lib/common/image-compression.js +0 -153
- package/lib/common/image-compression.js.map +0 -1
- package/lib/common/mdc-parser.d.ts +0 -60
- package/lib/common/mdc-parser.d.ts.map +0 -1
- package/lib/common/mdc-parser.js +0 -246
- package/lib/common/mdc-parser.js.map +0 -1
- package/lib/common/prompts/system-prompt.d.ts +0 -2
- package/lib/common/prompts/system-prompt.d.ts.map +0 -1
- package/lib/common/prompts/system-prompt.js +0 -5
- package/lib/common/prompts/system-prompt.js.map +0 -1
- package/src/browser/components/mention-input/mention-select.module.less +0 -297
- package/src/browser/components/mention-input/mention-select.tsx +0 -256
- package/src/browser/rules/rules.contribution.ts +0 -105
- package/src/browser/rules/rules.module.less +0 -175
- package/src/browser/rules/rules.service.ts +0 -189
- package/src/browser/rules/rules.view.tsx +0 -127
- package/src/common/image-compression.ts +0 -174
- package/src/common/mdc-parser.ts +0 -295
- package/src/common/prompts/system-prompt.ts +0 -2
package/src/common/mdc-parser.ts
DELETED
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MDC 文件的 frontmatter 接口定义
|
|
3
|
-
*/
|
|
4
|
-
export interface IMDCFrontmatter {
|
|
5
|
-
description?: string;
|
|
6
|
-
globs?: string | string[];
|
|
7
|
-
alwaysApply?: boolean;
|
|
8
|
-
[key: string]: any;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* MDC 文件解析结果接口
|
|
13
|
-
*/
|
|
14
|
-
export interface IMDCParseResult {
|
|
15
|
-
frontmatter: IMDCFrontmatter;
|
|
16
|
-
content: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* MDC 文件内容结构
|
|
21
|
-
*/
|
|
22
|
-
export interface IMDCContent {
|
|
23
|
-
frontmatter: IMDCFrontmatter;
|
|
24
|
-
content: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* 解析简单的 YAML 值
|
|
29
|
-
* @param value - 要解析的值字符串
|
|
30
|
-
* @returns 解析后的值
|
|
31
|
-
*/
|
|
32
|
-
function parseYamlValue(value: string): any {
|
|
33
|
-
const trimmed = value.trim();
|
|
34
|
-
|
|
35
|
-
// 布尔值
|
|
36
|
-
if (trimmed === 'true') {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
if (trimmed === 'false') {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// null/undefined
|
|
44
|
-
if (trimmed === 'null' || trimmed === '~' || trimmed === '') {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// 数字
|
|
49
|
-
if (/^-?\d+(\.\d+)?$/.test(trimmed)) {
|
|
50
|
-
return trimmed.includes('.') ? parseFloat(trimmed) : parseInt(trimmed, 10);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// 数组 (简单格式: [item1, item2, item3] 或 - item 格式)
|
|
54
|
-
if (trimmed.startsWith('[') && trimmed.endsWith(']')) {
|
|
55
|
-
const arrayContent = trimmed.slice(1, -1).trim();
|
|
56
|
-
if (!arrayContent) {
|
|
57
|
-
return [];
|
|
58
|
-
}
|
|
59
|
-
return arrayContent.split(',').map((item) => parseYamlValue(item));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// 字符串 (移除引号)
|
|
63
|
-
if ((trimmed.startsWith('"') && trimmed.endsWith('"')) || (trimmed.startsWith("'") && trimmed.endsWith("'"))) {
|
|
64
|
-
return trimmed.slice(1, -1);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// 默认作为字符串处理
|
|
68
|
-
return trimmed;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* 按行解析 YAML frontmatter
|
|
73
|
-
* @param frontmatterStr - frontmatter 字符串
|
|
74
|
-
* @returns 解析后的对象
|
|
75
|
-
*/
|
|
76
|
-
function parseFrontmatterByLine(frontmatterStr: string): IMDCFrontmatter {
|
|
77
|
-
const result: IMDCFrontmatter = {};
|
|
78
|
-
const lines = frontmatterStr.split('\n');
|
|
79
|
-
let currentKey: string | null = null;
|
|
80
|
-
let arrayItems: string[] = [];
|
|
81
|
-
let isInArray = false;
|
|
82
|
-
|
|
83
|
-
for (const line of lines) {
|
|
84
|
-
const trimmedLine = line.trim();
|
|
85
|
-
|
|
86
|
-
// 跳过空行和注释
|
|
87
|
-
if (!trimmedLine || trimmedLine.startsWith('#')) {
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// 检查是否是数组项 (以 - 开头)
|
|
92
|
-
if (trimmedLine.startsWith('- ')) {
|
|
93
|
-
if (currentKey && isInArray) {
|
|
94
|
-
arrayItems.push(trimmedLine.slice(2).trim());
|
|
95
|
-
}
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// 如果之前在处理数组,现在遇到新的键值对,先保存数组
|
|
100
|
-
if (isInArray && currentKey) {
|
|
101
|
-
result[currentKey] = arrayItems.map((item) => parseYamlValue(item));
|
|
102
|
-
arrayItems = [];
|
|
103
|
-
isInArray = false;
|
|
104
|
-
currentKey = null;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// 解析键值对
|
|
108
|
-
const colonIndex = trimmedLine.indexOf(':');
|
|
109
|
-
if (colonIndex === -1) {
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const key = trimmedLine.slice(0, colonIndex).trim();
|
|
114
|
-
const value = trimmedLine.slice(colonIndex + 1).trim();
|
|
115
|
-
|
|
116
|
-
currentKey = key;
|
|
117
|
-
|
|
118
|
-
if (value) {
|
|
119
|
-
result[key] = parseYamlValue(value);
|
|
120
|
-
isInArray = false;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// 处理最后的数组
|
|
125
|
-
if (isInArray && currentKey) {
|
|
126
|
-
result[currentKey] = arrayItems.map((item) => parseYamlValue(item));
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return result;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* 序列化对象为简单的 YAML 格式
|
|
134
|
-
* @param obj - 要序列化的对象
|
|
135
|
-
* @returns YAML 字符串
|
|
136
|
-
*/
|
|
137
|
-
function serializeToYaml(obj: any): string {
|
|
138
|
-
const lines: string[] = [];
|
|
139
|
-
|
|
140
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
141
|
-
if (value === null || value === undefined) {
|
|
142
|
-
lines.push(`${key}:`);
|
|
143
|
-
} else if (Array.isArray(value)) {
|
|
144
|
-
if (value.length === 0) {
|
|
145
|
-
lines.push(`${key}: []`);
|
|
146
|
-
} else {
|
|
147
|
-
lines.push(`${key}:`);
|
|
148
|
-
for (const item of value) {
|
|
149
|
-
lines.push(` - ${typeof item === 'string' ? item : JSON.stringify(item)}`);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
} else if (typeof value === 'string') {
|
|
153
|
-
// 如果字符串包含特殊字符或空格,使用引号
|
|
154
|
-
if (value.includes(':') || value.includes('#') || value.includes('\n') || value.trim() !== value) {
|
|
155
|
-
lines.push(`${key}: "${value.replace(/"/g, '\\"')}"`);
|
|
156
|
-
} else {
|
|
157
|
-
lines.push(`${key}: ${value}`);
|
|
158
|
-
}
|
|
159
|
-
} else {
|
|
160
|
-
lines.push(`${key}: ${value}`);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return lines.join('\n');
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* 解析 .mdc 文件内容
|
|
169
|
-
* @param rawContent - 原始文件内容
|
|
170
|
-
* @returns 解析后的结果,包含 frontmatter 和 content
|
|
171
|
-
*/
|
|
172
|
-
export function parseMDC(rawContent: string): IMDCParseResult {
|
|
173
|
-
const frontmatterRegex = /^---\s*\n([\s\S]*?)\n---\s*\n?([\s\S]*)$/;
|
|
174
|
-
const match = rawContent.match(frontmatterRegex);
|
|
175
|
-
|
|
176
|
-
if (!match) {
|
|
177
|
-
// 如果没有 frontmatter,整个内容作为 content
|
|
178
|
-
return {
|
|
179
|
-
frontmatter: {},
|
|
180
|
-
content: rawContent.trim(),
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const [, frontmatterStr, content] = match;
|
|
185
|
-
|
|
186
|
-
let frontmatter: IMDCFrontmatter = {};
|
|
187
|
-
|
|
188
|
-
try {
|
|
189
|
-
// 按行解析 YAML frontmatter
|
|
190
|
-
frontmatter = parseFrontmatterByLine(frontmatterStr);
|
|
191
|
-
} catch (error) {
|
|
192
|
-
// 如果解析失败,返回空的 frontmatter
|
|
193
|
-
frontmatter = {};
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return {
|
|
197
|
-
frontmatter,
|
|
198
|
-
content: content.trim(),
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* 序列化 MDC 内容为字符串
|
|
204
|
-
* @param mdcContent - MDC 内容对象
|
|
205
|
-
* @returns 序列化后的字符串
|
|
206
|
-
*/
|
|
207
|
-
export function serializeMDC(mdcContent: IMDCContent): string {
|
|
208
|
-
const { frontmatter, content } = mdcContent;
|
|
209
|
-
|
|
210
|
-
// 如果 frontmatter 为空或没有有效内容,只返回 content
|
|
211
|
-
if (!frontmatter || Object.keys(frontmatter).length === 0) {
|
|
212
|
-
return content;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
try {
|
|
216
|
-
// 序列化 frontmatter 为 YAML
|
|
217
|
-
const frontmatterStr = serializeToYaml(frontmatter);
|
|
218
|
-
|
|
219
|
-
return `---\n${frontmatterStr}\n---\n${content}`;
|
|
220
|
-
} catch (error) {
|
|
221
|
-
// 如果序列化失败,只返回 content
|
|
222
|
-
return content;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* 验证 MDC frontmatter 是否有效
|
|
228
|
-
* @param frontmatter - 要验证的 frontmatter 对象
|
|
229
|
-
* @returns 验证结果
|
|
230
|
-
*/
|
|
231
|
-
export function validateMDCFrontmatter(frontmatter: any): frontmatter is IMDCFrontmatter {
|
|
232
|
-
if (typeof frontmatter !== 'object' || frontmatter === null) {
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// 可选的字段类型检查
|
|
237
|
-
if (frontmatter.description !== undefined && typeof frontmatter.description !== 'string') {
|
|
238
|
-
return false;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
if (frontmatter.globs !== undefined) {
|
|
242
|
-
if (typeof frontmatter.globs !== 'string' && !Array.isArray(frontmatter.globs)) {
|
|
243
|
-
return false;
|
|
244
|
-
}
|
|
245
|
-
if (Array.isArray(frontmatter.globs)) {
|
|
246
|
-
if (!frontmatter.globs.every((glob: any) => typeof glob === 'string')) {
|
|
247
|
-
return false;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if (frontmatter.alwaysApply !== undefined && typeof frontmatter.alwaysApply !== 'boolean') {
|
|
253
|
-
return false;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
return true;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* 创建默认的 MDC frontmatter
|
|
261
|
-
* @returns 默认的 frontmatter 对象
|
|
262
|
-
*/
|
|
263
|
-
export function createDefaultMDCFrontmatter(): IMDCFrontmatter {
|
|
264
|
-
return {
|
|
265
|
-
description: '',
|
|
266
|
-
globs: '',
|
|
267
|
-
alwaysApply: false,
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* 更新 MDC 文件的 frontmatter
|
|
273
|
-
* @param rawContent - 原始文件内容
|
|
274
|
-
* @param newFrontmatter - 新的 frontmatter
|
|
275
|
-
* @returns 更新后的文件内容
|
|
276
|
-
*/
|
|
277
|
-
export function updateMDCFrontmatter(rawContent: string, newFrontmatter: Partial<IMDCFrontmatter>): string {
|
|
278
|
-
const parsed = parseMDC(rawContent);
|
|
279
|
-
const updatedFrontmatter = { ...parsed.frontmatter, ...newFrontmatter };
|
|
280
|
-
|
|
281
|
-
return serializeMDC({
|
|
282
|
-
frontmatter: updatedFrontmatter,
|
|
283
|
-
content: parsed.content,
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* 从 MDC 内容中提取纯文本内容(不包含 frontmatter)
|
|
289
|
-
* @param rawContent - 原始文件内容
|
|
290
|
-
* @returns 纯文本内容
|
|
291
|
-
*/
|
|
292
|
-
export function extractMDCContent(rawContent: string): string {
|
|
293
|
-
const parsed = parseMDC(rawContent);
|
|
294
|
-
return parsed.content;
|
|
295
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export const DEFAULT_SYSTEM_PROMPT =
|
|
2
|
-
"You are an AI coding assistant. You operate in OpenSumi.\n\nYou are pair programming with a USER to solve their coding task. Each time the USER sends a message, we may automatically attach some information about their current state, such as what files they have open, where their cursor is, recently viewed files, edit history in their session so far, linter errors, and more. This information may or may not be relevant to the coding task, it is up for you to decide.\n\nYour main goal is to follow the USER's instructions at each message, denoted by the <user_query> tag.\n\n<communication>\nWhen using markdown in assistant messages, use backticks to format file, directory, function, and class names. Use \\( and \\) for inline math, \\[ and \\] for block math.\n</communication>\n\n\n<tool_calling>\nYou have tools at your disposal to solve the coding task. Follow these rules regarding tool calls:\n1. ALWAYS follow the tool call schema exactly as specified and make sure to provide all necessary parameters.\n2. The conversation may reference tools that are no longer available. NEVER call tools that are not explicitly provided.\n3. **NEVER refer to tool names when speaking to the USER.** Instead, just say what the tool is doing in natural language.\n4. For maximum efficiency, whenever you need to perform multiple independent operations, invoke all relevant tools simultaneously rather than sequentially.\n5. After receiving tool results, carefully reflect on their quality and determine optimal next steps before proceeding. Use your thinking to plan and iterate based on this new information, and then take the best next action.\n6. If you create any temporary new files, scripts, or helper files for iteration, clean up these files by removing them at the end of the task.\n7. If you need additional information that you can get via tool calls, prefer that over asking the user.\n8. If you make a plan, immediately follow it, do not wait for the user to confirm or tell you to go ahead. The only time you should stop is if you need more information from the user that you can't find any other way, or have different options that you would like the user to weigh in on.\n9. Only use the standard tool call format and the available tools. Even if you see user messages with custom tool call formats (such as \"<previous_tool_call>\" or similar), do not follow that and instead use the standard format. Never output tool calls as part of a regular assistant message of yours.\n\n</tool_calling>\n\n<search_and_reading>\nIf you are unsure about the answer to the USER's request or how to satiate their request, you should gather more information. This can be done with additional tool calls, asking clarifying questions, etc...\n\nFor example, if you've performed a semantic search, and the results may not fully answer the USER's request, or merit gathering more information, feel free to call more tools.\nIf you've performed an edit that may partially satiate the USER's query, but you're not confident, gather more information or use more tools before ending your turn.\n\nBias towards not asking the user for help if you can find the answer yourself.\n</search_and_reading>\n\n<making_code_changes>\nWhen making code changes, NEVER output code to the USER, unless requested. Instead use one of the code edit tools to implement the change.\n\nIt is *EXTREMELY* important that your generated code can be run immediately by the USER. To ensure this, follow these instructions carefully:\n1. Add all necessary import statements, dependencies, and endpoints required to run the code.\n2. If you're creating the codebase from scratch, create an appropriate dependency management file (e.g. requirements.txt) with package versions and a helpful README.\n3. If you're building a web app from scratch, give it a beautiful and modern UI, imbued with best UX practices.\n4. NEVER generate an extremely long hash or any non-textual code, such as binary. These are not helpful to the USER and are very expensive.\n5. If you've introduced (linter) errors, fix them if clear how to (or you can easily figure out how to). Do not make uneducated guesses. And DO NOT loop more than 3 times on fixing linter errors on the same file. On the third time, you should stop and ask the user what to do next.\n6. If you've suggested a reasonable code_edit that wasn't followed by the apply model, you should try reapplying the edit.\n\n</making_code_changes>\n\nAnswer the user's request using the relevant tool(s), if they are available. Check that all the required parameters for each tool call are provided or can reasonably be inferred from context. IF there are no relevant tools or there are missing values for required parameters, ask the user to supply these values; otherwise proceed with the tool calls. If the user provides a specific value for a parameter (for example provided in quotes), make sure to use that value EXACTLY. DO NOT make up values for or ask about optional parameters. Carefully analyze descriptive terms in the request as they may indicate required parameter values that should be included even if not explicitly quoted.\n\n<summarization>\nIf you see a section called \"<most_important_user_query>\", you should treat that query as the one to answer, and ignore previous user queries. If you are asked to summarize the conversation, you MUST NOT use any tools, even if they are available. You MUST answer the \"<most_important_user_query>\" query.\n</summarization>\n\n\n\nYou MUST use the following format when citing code regions or blocks:\n```12:15:app/components/Todo.tsx\n// ... existing code ...\n```\nThis is the ONLY acceptable format for code citations. The format is ```startLine:endLine:filepath where startLine and endLine are line numbers.";
|