@mumulinya167/cc-web 1.0.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/README.md +61 -0
- package/bin/ccm.js +680 -0
- package/bin/server.js +4428 -0
- package/bin/setup.js +148 -0
- package/configs/config-template.toml +54 -0
- package/mcp-feishu/.env.example +2 -0
- package/mcp-feishu/package-lock.json +1194 -0
- package/mcp-feishu/package.json +23 -0
- package/mcp-feishu/src/cli.ts +239 -0
- package/mcp-feishu/src/feishu-client.ts +209 -0
- package/mcp-feishu/src/index.ts +55 -0
- package/mcp-feishu/src/tools.ts +222 -0
- package/mcp-feishu/tsconfig.json +18 -0
- package/package.json +27 -0
- package/public/index.html +6604 -0
- package/templates/CLAUDE-backend.md +105 -0
- package/templates/CLAUDE-frontend.md +61 -0
package/bin/setup.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// ccm 初始化安装脚本
|
|
3
|
+
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const os = require("os");
|
|
7
|
+
const { execSync } = require("child_process");
|
|
8
|
+
const readline = require("readline");
|
|
9
|
+
|
|
10
|
+
const CCM_DIR = path.join(os.homedir(), ".cc-connect");
|
|
11
|
+
const CONFIGS_DIR = path.join(CCM_DIR, "configs");
|
|
12
|
+
const PID_DIR = path.join(CCM_DIR, "pids");
|
|
13
|
+
const LOG_DIR = path.join(CCM_DIR, "logs");
|
|
14
|
+
const PACKAGE_DIR = path.resolve(__dirname, "..");
|
|
15
|
+
const MCP_DIR = path.join(PACKAGE_DIR, "mcp-feishu");
|
|
16
|
+
|
|
17
|
+
console.log("\n╔══════════════════════════════════════╗");
|
|
18
|
+
console.log("║ ccm 安装程序 ║");
|
|
19
|
+
console.log("╚══════════════════════════════════════╝\n");
|
|
20
|
+
|
|
21
|
+
// 1. 创建目录
|
|
22
|
+
console.log("[1/6] 创建目录结构...");
|
|
23
|
+
[CCM_DIR, CONFIGS_DIR, PID_DIR, LOG_DIR].forEach((dir) => {
|
|
24
|
+
if (!fs.existsSync(dir)) {
|
|
25
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
26
|
+
console.log(` ✓ ${dir}`);
|
|
27
|
+
} else {
|
|
28
|
+
console.log(` ✓ ${dir} (已存在)`);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// 2. 检查 cc-connect
|
|
33
|
+
console.log("\n[2/6] 检查 cc-connect...");
|
|
34
|
+
try {
|
|
35
|
+
const version = execSync("cc-connect --version", { encoding: "utf-8" }).trim();
|
|
36
|
+
console.log(` ✓ ${version}`);
|
|
37
|
+
} catch {
|
|
38
|
+
console.log(" ✗ 未安装,正在安装...");
|
|
39
|
+
try {
|
|
40
|
+
execSync("npm install -g cc-connect", { stdio: "inherit" });
|
|
41
|
+
console.log(" ✓ 安装成功");
|
|
42
|
+
} catch {
|
|
43
|
+
console.log(" ✗ 安装失败,请手动运行: npm install -g cc-connect");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 3. 安装飞书 MCP 依赖
|
|
48
|
+
console.log("\n[3/6] 安装飞书 MCP 依赖...");
|
|
49
|
+
if (fs.existsSync(MCP_DIR)) {
|
|
50
|
+
const mcpNodeModules = path.join(MCP_DIR, "node_modules");
|
|
51
|
+
if (!fs.existsSync(mcpNodeModules)) {
|
|
52
|
+
try {
|
|
53
|
+
execSync("npm install", { cwd: MCP_DIR, stdio: "inherit" });
|
|
54
|
+
console.log(" ✓ 依赖安装完成");
|
|
55
|
+
} catch {
|
|
56
|
+
console.log(" ✗ 依赖安装失败,请手动运行: cd mcp-feishu && npm install");
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
console.log(" ✓ 依赖已存在");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 创建 .env 模板
|
|
63
|
+
const envFile = path.join(MCP_DIR, ".env");
|
|
64
|
+
if (!fs.existsSync(envFile)) {
|
|
65
|
+
fs.writeFileSync(envFile, "FEISHU_APP_ID=\nFEISHU_APP_SECRET=\n");
|
|
66
|
+
console.log(" ✓ 已创建 .env 模板(需填写凭证)");
|
|
67
|
+
} else {
|
|
68
|
+
console.log(" ✓ .env 已存在");
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
console.log(" ⚠ mcp-feishu 目录不存在,跳过");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// 4. 配置 Claude Code MCP
|
|
75
|
+
console.log("\n[4/6] 配置 Claude Code MCP...");
|
|
76
|
+
const claudeMcpPath = path.join(os.homedir(), ".claude", ".mcp.json");
|
|
77
|
+
const mcpConfig = {
|
|
78
|
+
command: "node",
|
|
79
|
+
args: [path.join(MCP_DIR, "dist", "index.js").replace(/\\/g, "/")],
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
let claudeMcp = {};
|
|
84
|
+
if (fs.existsSync(claudeMcpPath)) {
|
|
85
|
+
claudeMcp = JSON.parse(fs.readFileSync(claudeMcpPath, "utf-8"));
|
|
86
|
+
}
|
|
87
|
+
if (!claudeMcp.mcpServers) claudeMcp.mcpServers = {};
|
|
88
|
+
claudeMcp.mcpServers["feishu"] = mcpConfig;
|
|
89
|
+
fs.writeFileSync(claudeMcpPath, JSON.stringify(claudeMcp, null, 2));
|
|
90
|
+
console.log(` ✓ Claude Code MCP 已配置: ${claudeMcpPath}`);
|
|
91
|
+
} catch (e) {
|
|
92
|
+
console.log(` ✗ 配置失败: ${e.message}`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 5. 配置 Cursor MCP
|
|
96
|
+
console.log("\n[5/6] 配置 Cursor MCP...");
|
|
97
|
+
const cursorMcpPath = path.join(os.homedir(), ".cursor", "mcp.json");
|
|
98
|
+
const cursorMcpConfig = {
|
|
99
|
+
command: "node",
|
|
100
|
+
args: [path.join(MCP_DIR, "dist", "index.js").replace(/\\/g, "/")],
|
|
101
|
+
env: {
|
|
102
|
+
FEISHU_APP_ID: "",
|
|
103
|
+
FEISHU_APP_SECRET: "",
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
let cursorMcp = {};
|
|
109
|
+
if (fs.existsSync(cursorMcpPath)) {
|
|
110
|
+
cursorMcp = JSON.parse(fs.readFileSync(cursorMcpPath, "utf-8"));
|
|
111
|
+
}
|
|
112
|
+
if (!cursorMcp.mcpServers) cursorMcp.mcpServers = {};
|
|
113
|
+
cursorMcp.mcpServers["feishu"] = cursorMcpConfig;
|
|
114
|
+
fs.writeFileSync(cursorMcpPath, JSON.stringify(cursorMcp, null, 2));
|
|
115
|
+
console.log(` ✓ Cursor MCP 已配置: ${cursorMcpPath}`);
|
|
116
|
+
} catch (e) {
|
|
117
|
+
console.log(` ✗ 配置失败: ${e.message}`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// 6. 创建 projects.txt
|
|
121
|
+
console.log("\n[6/6] 初始化项目列表...");
|
|
122
|
+
const projectsFile = path.join(CCM_DIR, "projects.txt");
|
|
123
|
+
if (!fs.existsSync(projectsFile)) {
|
|
124
|
+
fs.writeFileSync(projectsFile, "可用项目列表:\n\n");
|
|
125
|
+
console.log(" ✓ 创建 projects.txt");
|
|
126
|
+
} else {
|
|
127
|
+
console.log(" ✓ projects.txt 已存在");
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// 完成
|
|
131
|
+
console.log("\n═══════════════════════════════════════");
|
|
132
|
+
console.log(" 安装完成!");
|
|
133
|
+
console.log("═══════════════════════════════════════\n");
|
|
134
|
+
console.log(" 接下来:");
|
|
135
|
+
console.log("");
|
|
136
|
+
console.log(" 1. 填写飞书凭证:");
|
|
137
|
+
console.log(` 编辑 ${path.join(MCP_DIR, ".env")}`);
|
|
138
|
+
console.log(" 填入 FEISHU_APP_ID 和 FEISHU_APP_SECRET");
|
|
139
|
+
console.log("");
|
|
140
|
+
console.log(" 2. 创建项目:");
|
|
141
|
+
console.log(" ccm --init");
|
|
142
|
+
console.log("");
|
|
143
|
+
console.log(" 3. 或者扫码创建飞书机器人:");
|
|
144
|
+
console.log(" cc-connect feishu setup --project 项目名 --config 配置文件路径");
|
|
145
|
+
console.log("");
|
|
146
|
+
console.log(" 4. 启动:");
|
|
147
|
+
console.log(" ccm start all");
|
|
148
|
+
console.log("");
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# cc-connect 项目配置模板
|
|
2
|
+
# 复制此文件并重命名为 config-你的项目名.toml
|
|
3
|
+
|
|
4
|
+
language = "zh"
|
|
5
|
+
|
|
6
|
+
[[projects]]
|
|
7
|
+
name = "your-project-name"
|
|
8
|
+
work_dir = "D:\\path\\to\\your\\project"
|
|
9
|
+
admin_from = "*"
|
|
10
|
+
|
|
11
|
+
[projects.agent]
|
|
12
|
+
type = "claudecode"
|
|
13
|
+
mode = "default"
|
|
14
|
+
|
|
15
|
+
[projects.agent.options]
|
|
16
|
+
work_dir = "D:\\path\\to\\your\\project"
|
|
17
|
+
|
|
18
|
+
[[projects.platforms]]
|
|
19
|
+
type = "feishu"
|
|
20
|
+
|
|
21
|
+
[projects.platforms.options]
|
|
22
|
+
app_id = "your-feishu-app-id"
|
|
23
|
+
app_secret = "your-feishu-app-secret"
|
|
24
|
+
enable_feishu_card = true
|
|
25
|
+
thread_isolation = true
|
|
26
|
+
progress_style = "card"
|
|
27
|
+
|
|
28
|
+
# 自定义命令
|
|
29
|
+
[[commands]]
|
|
30
|
+
name = "history"
|
|
31
|
+
description = "查看会话历史记录"
|
|
32
|
+
exec = "cc-connect sessions show {{1}} -n {{2:20}}"
|
|
33
|
+
|
|
34
|
+
[[commands]]
|
|
35
|
+
name = "sessions"
|
|
36
|
+
description = "列出所有会话"
|
|
37
|
+
exec = "cc-connect sessions list"
|
|
38
|
+
|
|
39
|
+
[[commands]]
|
|
40
|
+
name = "projects"
|
|
41
|
+
description = "查看所有可操作的代码项目目录"
|
|
42
|
+
exec = "cmd /c type C:\\Users\\你的用户名\\.cc-connect\\projects.txt"
|
|
43
|
+
|
|
44
|
+
[[aliases]]
|
|
45
|
+
name = "历史"
|
|
46
|
+
command = "/history"
|
|
47
|
+
|
|
48
|
+
[[aliases]]
|
|
49
|
+
name = "会话"
|
|
50
|
+
command = "/sessions"
|
|
51
|
+
|
|
52
|
+
[[aliases]]
|
|
53
|
+
name = "项目"
|
|
54
|
+
command = "/projects"
|