chatccc 0.2.242 → 0.2.244
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/deepccc-agent/os-prompts/darwin.md +8 -0
- package/deepccc-agent/os-prompts/linux.md +8 -0
- package/deepccc-agent/os-prompts/win32.md +9 -0
- package/deepccc-agent/package.json +63 -62
- package/deepccc-agent/src/__tests__/chat-session.test.ts +617 -522
- package/deepccc-agent/src/index.ts +53 -1
- package/package.json +73 -73
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|
8
8
|
import { generateText, isLoopFinished, stepCountIs, streamText, type TextStreamPart } from "ai";
|
|
9
|
-
import { readFileSync } from "node:fs";
|
|
9
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
10
|
+
import { homedir } from "node:os";
|
|
10
11
|
import { join } from "node:path";
|
|
12
|
+
import { fileURLToPath } from "node:url";
|
|
11
13
|
|
|
12
14
|
import { config as appConfig, RAW_STREAM_LOGS_DIR } from "./config.js";
|
|
13
15
|
import {
|
|
@@ -120,6 +122,52 @@ function buildRuntimeWorkspacePrompt(cwd: string): string {
|
|
|
120
122
|
].join("\n");
|
|
121
123
|
}
|
|
122
124
|
|
|
125
|
+
/**
|
|
126
|
+
* 各操作系统特有的命令行指引(文本资产,维护在 os-prompts/ 目录,而非硬编码):
|
|
127
|
+
*
|
|
128
|
+
* - 内置文件:包内 os-prompts/<platform>.md(win32/darwin/linux),随 npm 包分发;
|
|
129
|
+
* - 用户覆盖:~/.deepccc/prompts/<platform>.md 存在时完全替代内置内容(可自定义)。
|
|
130
|
+
*
|
|
131
|
+
* 文件内容自带标题(如 "## Windows Command-Line Notes"),读取后 trim 直接作为
|
|
132
|
+
* 一个段落注入固定规则区(项目指令之前)。未知平台或文件缺失时返回空字符串。
|
|
133
|
+
*/
|
|
134
|
+
export function loadPlatformCommandPrompt(
|
|
135
|
+
platform: string = process.platform,
|
|
136
|
+
dirs: { builtinDir?: string; userDir?: string } = {},
|
|
137
|
+
): string {
|
|
138
|
+
const filename =
|
|
139
|
+
platform === "win32" ? "win32.md" :
|
|
140
|
+
platform === "darwin" ? "darwin.md" :
|
|
141
|
+
platform === "linux" ? "linux.md" :
|
|
142
|
+
null;
|
|
143
|
+
if (!filename) return "";
|
|
144
|
+
|
|
145
|
+
// import.meta.url 定位包根:chatccc 源码运行时指向 deepccc-agent/os-prompts/,
|
|
146
|
+
// deepccc dist 运行时指向包根 os-prompts/(dist/index.js 的 ../os-prompts/)。
|
|
147
|
+
const builtinDir =
|
|
148
|
+
dirs.builtinDir ?? fileURLToPath(new URL("../os-prompts/", import.meta.url));
|
|
149
|
+
const userDir = dirs.userDir ?? join(homedir(), ".deepccc", "prompts");
|
|
150
|
+
|
|
151
|
+
// 用户覆盖优先;读取失败时静默回退内置,内置也失败则返回空。
|
|
152
|
+
const userFile = join(userDir, filename);
|
|
153
|
+
if (existsSync(userFile)) {
|
|
154
|
+
try {
|
|
155
|
+
return readFileSync(userFile, "utf-8").trim();
|
|
156
|
+
} catch {
|
|
157
|
+
// fall through to builtin
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const builtinFile = join(builtinDir, filename);
|
|
161
|
+
if (existsSync(builtinFile)) {
|
|
162
|
+
try {
|
|
163
|
+
return readFileSync(builtinFile, "utf-8").trim();
|
|
164
|
+
} catch {
|
|
165
|
+
return "";
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return "";
|
|
169
|
+
}
|
|
170
|
+
|
|
123
171
|
function normalizeMaxSteps(value: number | undefined): number | undefined {
|
|
124
172
|
if (value === undefined) return undefined;
|
|
125
173
|
if (!Number.isFinite(value) || !Number.isInteger(value) || value <= 0) {
|
|
@@ -269,6 +317,10 @@ export class ChatSession {
|
|
|
269
317
|
*/
|
|
270
318
|
private buildSystemPrompt(skills: BuiltinSkill[]): string {
|
|
271
319
|
const systemContent = [SYSTEM_PROMPT];
|
|
320
|
+
const platformPrompt = loadPlatformCommandPrompt();
|
|
321
|
+
if (platformPrompt) {
|
|
322
|
+
systemContent.push("", platformPrompt);
|
|
323
|
+
}
|
|
272
324
|
const projectInstructions = readProjectInstructionFiles(this.cwd);
|
|
273
325
|
if (projectInstructions) {
|
|
274
326
|
systemContent.push("", projectInstructions);
|
package/package.json
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "chatccc",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Feishu bot bridge for Claude Code",
|
|
5
|
-
"license": "Apache-2.0",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"main": "./src/index.ts",
|
|
8
|
-
"bin": {
|
|
9
|
-
"chatccc": "bin/chatccc.mjs",
|
|
10
|
-
"cccagent": "bin/cccagent.mjs"
|
|
11
|
-
},
|
|
12
|
-
"files": [
|
|
13
|
-
"src/",
|
|
14
|
-
"deepccc-agent/",
|
|
15
|
-
"bin/",
|
|
16
|
-
"scripts/postinstall-sharp-check.mjs",
|
|
17
|
-
"demo/ilink_echo_probe.ts",
|
|
18
|
-
"agent-prompts/",
|
|
19
|
-
"im-skills/",
|
|
20
|
-
".agents/skills/create-chatccc-feishu-app/",
|
|
21
|
-
".claude/skills/create-chatccc-feishu-app/",
|
|
22
|
-
".cursor/skills/create-chatccc-feishu-app/",
|
|
23
|
-
"images/img_readme_*.jpg",
|
|
24
|
-
"images/img_readme_*.png",
|
|
25
|
-
"images/avatars/status_*.png",
|
|
26
|
-
"images/avatars/badges/",
|
|
27
|
-
"images/avatars/combinations/",
|
|
28
|
-
"package.json",
|
|
29
|
-
"README.md",
|
|
30
|
-
"config.sample.json"
|
|
31
|
-
],
|
|
32
|
-
"scripts": {
|
|
33
|
-
"dev": "tsx src/index.ts",
|
|
34
|
-
"chatccc": "tsx src/index.ts",
|
|
35
|
-
"start": "tsx src/index.ts",
|
|
36
|
-
"demo:bot-test": "tsx demo/bot_test.ts",
|
|
37
|
-
"demo:bot-test:local": "tsx demo/bot_test.ts --local",
|
|
38
|
-
"demo:create-group": "tsx src/index.ts",
|
|
39
|
-
"demo:create-group:local": "tsx src/index.ts --local",
|
|
40
|
-
"demo:permission-check": "tsx demo/permission_check.ts",
|
|
41
|
-
"demo:claude-hi": "tsx demo/claude_say_hi.ts",
|
|
42
|
-
"demo:codex-hi": "tsx demo/codex_say_hi.ts",
|
|
43
|
-
"demo:codex-app-server-approval": "tsx demo/codex-app-server-approval/approval_demo.ts",
|
|
44
|
-
"demo:ilink-echo": "tsx demo/ilink_echo_probe.ts",
|
|
45
|
-
"claude-proxy": "tsx src/litellm-proxy.ts",
|
|
46
|
-
"test": "vitest run",
|
|
47
|
-
"test:deepccc": "vitest run --root deepccc-agent",
|
|
48
|
-
"test:watch": "vitest",
|
|
49
|
-
"postinstall": "node scripts/postinstall-sharp-check.mjs"
|
|
50
|
-
},
|
|
51
|
-
"dependencies": {
|
|
52
|
-
"@ai-sdk/openai-compatible": "^2.0.47",
|
|
53
|
-
"@larksuiteoapi/node-sdk": "^1.59.0",
|
|
54
|
-
"@openilink/openilink-sdk-node": "^0.6.0",
|
|
55
|
-
"@vscode/ripgrep": "^1.18.0",
|
|
56
|
-
"ai": "^6.0.184",
|
|
57
|
-
"nodemailer": "^8.0.7",
|
|
58
|
-
"qrcode-terminal": "^0.12.0",
|
|
59
|
-
"sharp": "^0.34.5",
|
|
60
|
-
"tsx": "^4.0.0",
|
|
61
|
-
"ws": "^8.18.0"
|
|
62
|
-
},
|
|
63
|
-
"devDependencies": {
|
|
64
|
-
"@types/node": "^20.0.0",
|
|
65
|
-
"@types/qrcode-terminal": "^0.12.2",
|
|
66
|
-
"@types/ws": "^8.18.1",
|
|
67
|
-
"typescript": "^5.0.0",
|
|
68
|
-
"vitest": "^3.2.4"
|
|
69
|
-
},
|
|
70
|
-
"engines": {
|
|
71
|
-
"node": ">=20"
|
|
72
|
-
}
|
|
73
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "chatccc",
|
|
3
|
+
"version": "0.2.244",
|
|
4
|
+
"description": "Feishu bot bridge for Claude Code",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./src/index.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"chatccc": "bin/chatccc.mjs",
|
|
10
|
+
"cccagent": "bin/cccagent.mjs"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"src/",
|
|
14
|
+
"deepccc-agent/",
|
|
15
|
+
"bin/",
|
|
16
|
+
"scripts/postinstall-sharp-check.mjs",
|
|
17
|
+
"demo/ilink_echo_probe.ts",
|
|
18
|
+
"agent-prompts/",
|
|
19
|
+
"im-skills/",
|
|
20
|
+
".agents/skills/create-chatccc-feishu-app/",
|
|
21
|
+
".claude/skills/create-chatccc-feishu-app/",
|
|
22
|
+
".cursor/skills/create-chatccc-feishu-app/",
|
|
23
|
+
"images/img_readme_*.jpg",
|
|
24
|
+
"images/img_readme_*.png",
|
|
25
|
+
"images/avatars/status_*.png",
|
|
26
|
+
"images/avatars/badges/",
|
|
27
|
+
"images/avatars/combinations/",
|
|
28
|
+
"package.json",
|
|
29
|
+
"README.md",
|
|
30
|
+
"config.sample.json"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"dev": "tsx src/index.ts",
|
|
34
|
+
"chatccc": "tsx src/index.ts",
|
|
35
|
+
"start": "tsx src/index.ts",
|
|
36
|
+
"demo:bot-test": "tsx demo/bot_test.ts",
|
|
37
|
+
"demo:bot-test:local": "tsx demo/bot_test.ts --local",
|
|
38
|
+
"demo:create-group": "tsx src/index.ts",
|
|
39
|
+
"demo:create-group:local": "tsx src/index.ts --local",
|
|
40
|
+
"demo:permission-check": "tsx demo/permission_check.ts",
|
|
41
|
+
"demo:claude-hi": "tsx demo/claude_say_hi.ts",
|
|
42
|
+
"demo:codex-hi": "tsx demo/codex_say_hi.ts",
|
|
43
|
+
"demo:codex-app-server-approval": "tsx demo/codex-app-server-approval/approval_demo.ts",
|
|
44
|
+
"demo:ilink-echo": "tsx demo/ilink_echo_probe.ts",
|
|
45
|
+
"claude-proxy": "tsx src/litellm-proxy.ts",
|
|
46
|
+
"test": "vitest run",
|
|
47
|
+
"test:deepccc": "vitest run --root deepccc-agent",
|
|
48
|
+
"test:watch": "vitest",
|
|
49
|
+
"postinstall": "node scripts/postinstall-sharp-check.mjs"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@ai-sdk/openai-compatible": "^2.0.47",
|
|
53
|
+
"@larksuiteoapi/node-sdk": "^1.59.0",
|
|
54
|
+
"@openilink/openilink-sdk-node": "^0.6.0",
|
|
55
|
+
"@vscode/ripgrep": "^1.18.0",
|
|
56
|
+
"ai": "^6.0.184",
|
|
57
|
+
"nodemailer": "^8.0.7",
|
|
58
|
+
"qrcode-terminal": "^0.12.0",
|
|
59
|
+
"sharp": "^0.34.5",
|
|
60
|
+
"tsx": "^4.0.0",
|
|
61
|
+
"ws": "^8.18.0"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@types/node": "^20.0.0",
|
|
65
|
+
"@types/qrcode-terminal": "^0.12.2",
|
|
66
|
+
"@types/ws": "^8.18.1",
|
|
67
|
+
"typescript": "^5.0.0",
|
|
68
|
+
"vitest": "^3.2.4"
|
|
69
|
+
},
|
|
70
|
+
"engines": {
|
|
71
|
+
"node": ">=20"
|
|
72
|
+
}
|
|
73
|
+
}
|