deepccc 0.1.20 → 0.1.22
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/dist/index.js +32 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -60,6 +60,10 @@ const SUMMARY_SYSTEM_PROMPT = [
|
|
|
60
60
|
].join("\n");
|
|
61
61
|
export const DEFAULT_COMPACTION_TIMEOUT_MS = 90 * 1000;
|
|
62
62
|
const MAX_COMPACTION_OUTPUT_TOKENS = 16_384;
|
|
63
|
+
const ANTHROPIC_TOOL_JSON_COMPATIBILITY_NOTE = [
|
|
64
|
+
"[Protocol compatibility note]",
|
|
65
|
+
"tool-call arguments use JSON encoding; the final reply does not need to be JSON unless the user requests it.",
|
|
66
|
+
].join("\n");
|
|
63
67
|
// ---------------------------------------------------------------------------
|
|
64
68
|
// 类型定义
|
|
65
69
|
// ---------------------------------------------------------------------------
|
|
@@ -100,6 +104,26 @@ function buildRuntimeWorkspacePrompt(cwd) {
|
|
|
100
104
|
"文件工具通过 DeepCCC 在本地执行。可行时优先使用带 SHA-256 前置条件的受保护编辑,避免覆盖并发用户修改。",
|
|
101
105
|
].join("\n");
|
|
102
106
|
}
|
|
107
|
+
function addAnthropicToolJsonCompatibilityNote(messages) {
|
|
108
|
+
let lastUserIndex = -1;
|
|
109
|
+
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
110
|
+
if (messages[index]?.role === "user") {
|
|
111
|
+
lastUserIndex = index;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (lastUserIndex < 0)
|
|
116
|
+
return messages;
|
|
117
|
+
// 部分 Anthropic→OpenAI/Ark 转换器会用 response_format=json_object
|
|
118
|
+
// 实现工具调用,却只在 messages 中校验 JSON 关键词、不读取顶层 system。
|
|
119
|
+
// 这里仅声明工具参数的编码方式,并明确不要求普通最终回复输出 JSON。
|
|
120
|
+
return messages.map((message, index) => (index === lastUserIndex
|
|
121
|
+
? {
|
|
122
|
+
...message,
|
|
123
|
+
content: `${message.content}\n\n${ANTHROPIC_TOOL_JSON_COMPATIBILITY_NOTE}`,
|
|
124
|
+
}
|
|
125
|
+
: message));
|
|
126
|
+
}
|
|
103
127
|
/**
|
|
104
128
|
* 各操作系统特有的命令行指引(文本资产,维护在 os-prompts/ 目录,而非硬编码):
|
|
105
129
|
*
|
|
@@ -118,7 +142,9 @@ export function loadPlatformCommandPrompt(platform = process.platform, dirs = {}
|
|
|
118
142
|
return "";
|
|
119
143
|
// import.meta.url 定位包根:chatccc 源码运行时指向 deepccc-agent/os-prompts/,
|
|
120
144
|
// deepccc dist 运行时指向包根 os-prompts/(dist/index.js 的 ../os-prompts/)。
|
|
121
|
-
const
|
|
145
|
+
const adjacentBuiltinDir = fileURLToPath(new URL("../os-prompts/", import.meta.url));
|
|
146
|
+
const embeddedBuiltinDir = fileURLToPath(new URL("../../../deepccc-agent/os-prompts/", import.meta.url));
|
|
147
|
+
const builtinDir = dirs.builtinDir ?? (existsSync(adjacentBuiltinDir) ? adjacentBuiltinDir : embeddedBuiltinDir);
|
|
122
148
|
const userDir = dirs.userDir ?? join(homedir(), ".deepccc", "prompts");
|
|
123
149
|
// 用户覆盖优先;读取失败时静默回退内置,内置也失败则返回空。
|
|
124
150
|
const userFile = join(userDir, filename);
|
|
@@ -277,6 +303,10 @@ export class ChatSession {
|
|
|
277
303
|
const skills = await scanSkillsDirs(this.skillDirs);
|
|
278
304
|
const system = this.buildSystemPrompt(skills);
|
|
279
305
|
this.systemPrompt = system;
|
|
306
|
+
const contextMessages = this.context.buildModelMessages();
|
|
307
|
+
const modelMessages = this.provider === "anthropic"
|
|
308
|
+
? addAnthropicToolJsonCompatibilityNote(contextMessages)
|
|
309
|
+
: contextMessages;
|
|
280
310
|
// effort 按协议映射:
|
|
281
311
|
// - OpenAI 兼容:providerOptions.deepseek.reasoningEffort 由 @ai-sdk/openai-compatible
|
|
282
312
|
// 自动映射为请求体 reasoning_effort 字段(DeepSeek 原生支持);
|
|
@@ -291,7 +321,7 @@ export class ChatSession {
|
|
|
291
321
|
const generationOptions = {
|
|
292
322
|
model: this.model,
|
|
293
323
|
system,
|
|
294
|
-
messages:
|
|
324
|
+
messages: modelMessages,
|
|
295
325
|
tools: createBuiltinFileTools(this.cwd, { permissionGate: this.permissionGate }),
|
|
296
326
|
stopWhen: maxSteps !== undefined ? stepCountIs(maxSteps) : isLoopFinished(),
|
|
297
327
|
abortSignal: signal,
|