cicy-desktop 2.1.236 → 2.1.238

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.
@@ -1,166 +0,0 @@
1
- ---
2
- inclusion: always
3
- ---
4
-
5
- # Git 开发工作流程 - Git Development Workflow
6
-
7
- ## ⚠️ 开发前必读
8
-
9
- **在开始任何开发任务前,必须完整阅读本文档并严格遵循所有规范。**
10
-
11
- 违反规范将导致:
12
- - ❌ 代码被拒绝合并
13
- - ❌ 浪费时间重做
14
- - ❌ 影响项目质量
15
-
16
- ## 🚨 核心原则(必须遵守)
17
-
18
- 1. **开发前必读本文档** - 不要凭记忆或猜测
19
- 2. **严格遵循每个阶段** - 不要跳过任何步骤
20
- 3. **遇到问题先分析** - 不要盲目重试
21
- 4. **测试驱动开发** - 一功能一测试
22
- 5. **全部测试通过才提交** - npm test 必须 100% 通过
23
-
24
- ## 新功能/Bug修复标准流程
25
-
26
- 当收到开发新功能或修复bug的请求时,严格遵循以下流程:
27
-
28
- ### 阶段1:需求分析
29
- 1. **用户提出需求**
30
- 2. **AI 制定可行方案**
31
- - 分析技术实现路径
32
- - 评估工作量和风险
33
- - 提出具体实现方案
34
- 3. **询问用户是否有补充**
35
- 4. **等待用户确认"开始"**
36
-
37
- ### 阶段2:环境准备(用户说"开始"后执行)
38
- ```bash
39
- # 分支命名规范:
40
- # - 新功能:feat-MMDD-功能简述
41
- # - Bug修复:fix-MMDD-问题简述
42
-
43
- # 1. 直接在工作目录克隆并创建分支
44
- mkdir -p ~/projects/cicy-desktop/branches/
45
- git clone -b origin/main git@github.com:cicy-ai/cicy-desktop.git ~/projects/cicy-desktop/branches/<branch-name>
46
- sudo ln -s /<branch-name> ~/projects/cicy-desktop/branches/<branch-name>
47
- cd /<branch-name>
48
- git fetch origin
49
- git checkout -b <branch-name> origin/main
50
-
51
- # 2. 安装依赖
52
- npm install
53
- ```
54
-
55
- ### 阶段3:需求文档化
56
- 在工作目录创建 `task/task-<branch-name>.md` 文档,包含:
57
-
58
- ```markdown
59
- # 任务:[功能/Bug简述]
60
-
61
- ## 需求描述
62
- [用户原始需求]
63
-
64
- ## 实现方案
65
- [技术方案详细说明]
66
-
67
- ## TODO 清单
68
- - [ ] 任务1
69
- - [ ] 任务2
70
- - [ ] 任务3
71
-
72
- ## 验收标准
73
- - [ ] 功能正常工作
74
- - [ ] 所有测试通过
75
- - [ ] 代码符合规范
76
- - [ ] 文档已更新
77
- ```
78
-
79
- ### 阶段4:开发实现
80
- ```bash
81
- # 在工作目录进行开发
82
- cd /<branch-name>
83
-
84
- # ⚠️ 必须遵循:一功能一测试
85
- # ❌ 禁止:写完所有代码再测试
86
- # ✅ 正确:每完成一个功能立即测试
87
-
88
- # 实时更新 TASK.md 中的完成状态
89
- ```
90
-
91
- **核心原则:增量开发,持续验证**
92
-
93
- ### 阶段5:本地测试(❗强制要求)
94
- ```bash
95
- # ⚠️ 必须运行完整测试套件
96
- npm test
97
-
98
- # ❌ 如果测试失败,绝对不能提交
99
- # ✅ 必须所有测试通过才能进入下一阶段
100
- # ✅ 验证所有验收标准
101
- ```
102
-
103
- **⚠️ 警告:如果跳过此步骤直接提交,视为严重违规!**
104
-
105
- **遇到测试失败时:**
106
- 1. ❌ 不要盲目重试
107
- 2. ✅ 仔细阅读错误信息
108
- 3. ✅ 分析失败原因(依赖缺失?代码错误?环境问题?)
109
- 4. ✅ 总结问题根源
110
- 5. ✅ 制定修复方案
111
- 6. ✅ 修复后再次测试
112
-
113
- ### 阶段6:提交和推送
114
- ```bash
115
- # 提交更改
116
- git add .
117
- git commit -m "feat/fix: 简要描述更改内容"
118
-
119
- # 推送到远程
120
- git push origin <branch-name>
121
- ```
122
-
123
- ### 阶段7:创建 Pull Request
124
- ```bash
125
- # 使用 GitHub CLI 创建 PR
126
- gh pr create --base main --head <branch-name> --title "标题" --body "详细描述"
127
-
128
- # 或手动在 GitHub 网页创建 PR
129
- ```
130
-
131
- ## 分支命名示例
132
-
133
- ### 新功能
134
- - `feat-0206-add-cdp-scroll`
135
- - `feat-0206-multi-account-support`
136
- - `feat-0206-network-monitor`
137
-
138
- ### Bug修复
139
- - `fix-0206-window-close-crash`
140
- - `fix-0206-screenshot-memory-leak`
141
- - `fix-0206-test-timeout`
142
-
143
- ## 工作目录结构
144
- ```
145
- ~/
146
- ├── projects/
147
- │ └── cicy-desktop/main # 主仓库
148
- └── projects/cicy-desktop/branches/
149
- ├── feat-0206-feature1/
150
- ├── fix-0206-bug1/
151
- └── feat-0206-feature2/
152
- ```
153
-
154
- ## 核心原则
155
- - ✅ 始终基于 `origin/main` 创建新分支
156
- - ✅ 使用独立工作目录避免污染主仓库
157
- - ✅ **本地测试必须全部通过才能提交(npm test)**
158
- - ✅ **一功能一测试,不要全写完再测试**
159
- - ✅ 分支名称包含日期和清晰的功能/问题描述
160
- - ✅ 提交信息遵循 conventional commits 规范
161
- - ❌ **禁止跳过测试直接提交代码**
162
- - ❌ **禁止一次性写完所有代码**
163
-
164
- ---
165
- **制定时间:2026-02-06**
166
- **适用项目:cicy-desktop**
package/AGENTS.md DELETED
@@ -1,275 +0,0 @@
1
- # AGENTS.md
2
-
3
- This file provides guidelines for AI agents working on this codebase.
4
-
5
- ## Build, Lint, and Test Commands
6
-
7
- ### Core Commands
8
-
9
- ```bash
10
- # Start the MCP server (runs Electron app with MCP endpoint)
11
- npm start
12
-
13
- # Start with specific port
14
- npm start -- --port=8102
15
-
16
- # Start with URL and single window mode
17
- npm start -- --url=http://example.com --one-window
18
-
19
- # Run all tests (Jest with forceExit to handle Electron processes)
20
- npm test
21
-
22
- # Run a single test file
23
- npm test -- api.ping.test.js
24
-
25
- # Run tests matching a pattern
26
- npm test -- --testNamePattern="ping"
27
-
28
- # Format code with Prettier
29
- npm run format
30
-
31
- # Check formatting
32
- npm run format:check
33
-
34
- # Build distributables
35
- npm run build
36
- ```
37
-
38
- ### Test Configuration
39
-
40
- - Tests are in `tests/` directory with pattern `*.test.js`
41
- - Jest runs with `--runInBand` (serial execution) due to Electron's single-process nature
42
- - Tests use supertest for HTTP API testing
43
- - Tests spawn actual Electron processes on dynamic ports
44
- - Auth token loaded from `~/global.json`
45
- - Test utilities in `tests/test-utils.js`
46
-
47
- ## Code Style Guidelines
48
-
49
- ### Language
50
-
51
- - **CommonJS** only - use `require()` not ES modules
52
- - Plain JavaScript - no TypeScript
53
- - ES6+ features: async/await, arrow functions, template literals
54
-
55
- ### File Organization
56
-
57
- ```
58
- src/
59
- main.js # Main entry: Electron + Express + MCP server
60
- config.js # Configuration constants
61
- tools/ # MCP tool implementations
62
- ping.js
63
- window-tools.js
64
- cdp-tools.js
65
- exec-js.js
66
- utils/ # Utility modules
67
- window-utils.js
68
- window-monitor.js
69
- cdp-utils.js
70
- snapshot-utils.js
71
- auth.js
72
- tests/ # Test files
73
- test-utils.js # Shared test utilities
74
- *.test.js # Individual test files
75
- ```
76
-
77
- ### Imports Order
78
-
79
- ```javascript
80
- // 1. Built-in Node modules
81
- const fs = require("fs");
82
- const path = require("path");
83
-
84
- // 2. External dependencies
85
- const { BrowserWindow } = require("electron");
86
- const { z } = require("zod");
87
- const express = require("express");
88
-
89
- // 3. Internal modules
90
- const { config } = require("../config");
91
- const { createWindow } = require("../utils/window-utils");
92
- ```
93
-
94
- ### Naming Conventions
95
-
96
- - **Classes**: PascalCase (`AuthManager`, `BrowserWindow`)
97
- - **Functions/variables**: camelCase (`getWindows`, `registerTool`)
98
- - **Constants**: SCREAMING_SNAKE_CASE (`PORT`, `LOGS_DIR`)
99
- - **Tool names**: snake_case (`open_window`, `get_windows`)
100
- - **File names**: kebab-case for tests (`api.ping.test.js`)
101
-
102
- ### Error Handling
103
-
104
- All tool handlers must return structured MCP responses:
105
-
106
- ```javascript
107
- try {
108
- // ... operation
109
- return {
110
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
111
- };
112
- } catch (error) {
113
- return {
114
- content: [{ type: "text", text: `Error: ${error.message}` }],
115
- isError: true,
116
- };
117
- }
118
- ```
119
-
120
- ### Tool Registration Pattern
121
-
122
- ```javascript
123
- const { z } = require("zod");
124
-
125
- function registerTools(registerTool) {
126
- registerTool(
127
- "tool_name",
128
- "Description of what the tool does",
129
- z.object({
130
- win_id: z.number().optional().default(1).describe("Window ID"),
131
- param: z.string().describe("Required parameter"),
132
- }),
133
- async ({ win_id, param }) => {
134
- try {
135
- // Implementation
136
- return { content: [{ type: "text", text: "result" }] };
137
- } catch (error) {
138
- return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true };
139
- }
140
- },
141
- { tag: "Category" } // OpenAPI grouping tag
142
- );
143
- }
144
-
145
- module.exports = registerTools;
146
- ```
147
-
148
- ### Response Formats
149
-
150
- ```javascript
151
- // Text response
152
- return { content: [{ type: "text", text: "message" }] };
153
-
154
- // JSON response
155
- return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
156
-
157
- // Image response (NativeImage from Electron)
158
- return {
159
- content: [
160
- { type: "text", text: `Image: ${width}x${height}` },
161
- { type: "image", data: base64String, mimeType: "image/png" },
162
- ],
163
- };
164
-
165
- // Error response
166
- return { content: [{ type: "text", text: "error message" }], isError: true };
167
- ```
168
-
169
- ### Common Patterns
170
-
171
- #### Window Lookup
172
-
173
- ```javascript
174
- const win = BrowserWindow.fromId(win_id);
175
- if (!win) throw new Error(`Window ${win_id} not found`);
176
- ```
177
-
178
- #### JSON Serialization with BigInt
179
-
180
- ```javascript
181
- JSON.stringify(result, (key, value) => (typeof value === "bigint" ? value.toString() : value), 2);
182
- ```
183
-
184
- #### NativeImage Handling
185
-
186
- ```javascript
187
- if (result?.constructor.name === "NativeImage") {
188
- const size = result.getSize();
189
- const base64 = result.toPNG().toString("base64");
190
- return {
191
- content: [
192
- { type: "text", text: `Image: ${size.width}x${size.height}` },
193
- { type: "image", data: base64, mimeType: "image/png" },
194
- ],
195
- };
196
- }
197
- ```
198
-
199
- ### Testing Patterns
200
-
201
- ```javascript
202
- const { setPort, setupTest, teardownTest, sendRequest } = require("./test-utils");
203
-
204
- describe("Feature Test Suite", () => {
205
- beforeAll(async () => {
206
- setPort(8102); // Set test port
207
- await setupTest(); // Start Electron + establish SSE
208
- }, 30000);
209
-
210
- afterAll(async () => {
211
- await teardownTest(); // Cleanup
212
- });
213
-
214
- test("should do something", async () => {
215
- const response = await sendRequest("tools/call", {
216
- name: "tool_name",
217
- arguments: { param: "value" },
218
- });
219
- expect(response.result).toBeDefined();
220
- });
221
- });
222
- ```
223
-
224
- ### Logging
225
-
226
- Use electron-log with consistent format:
227
-
228
- ```javascript
229
- const log = require("electron-log");
230
- log.info("[MCP] Server starting");
231
- log.error("[MCP] Error:", error);
232
- ```
233
-
234
- ### Security
235
-
236
- - Never log secrets or API keys
237
- - Validate all inputs with Zod schemas
238
- - Return structured errors without internal details
239
- - Auth token loaded from `~/global.json`
240
-
241
- ### Electron Best Practices
242
-
243
- - Use `electronApp.whenReady()` for initialization
244
- - Handle `window-all-closed` event properly
245
- - Enable remote debugging with `--remote-debugging-port`
246
- - Use `nodeIntegration: false` and `contextIsolation: true`
247
- - Multi-account support via `partition: persist:sandbox-{accountIdx}`
248
-
249
- ## Master/Worker Cluster Commands
250
-
251
- ```bash
252
- # Start Master server (port 8100)
253
- npm run start:master
254
-
255
- # Start Worker registered to Master
256
- MASTER_TOKEN=$(jq -r '.api_token' ~/global.json)
257
- PORT=8101 CICY_MASTER_URL="http://127.0.0.1:8100" CICY_MASTER_TOKEN="$MASTER_TOKEN" npm start
258
-
259
- # Master API endpoints
260
- curl http://127.0.0.1:8100/api/ping
261
- curl http://127.0.0.1:8100/api/workers
262
- curl http://127.0.0.1:8100/api/agents
263
-
264
- # Worker direct API (requires auth token from ~/global.json)
265
- curl -H "Authorization: Bearer $TOKEN" http://127.0.0.1:8101/rpc/tools
266
- curl -H "Authorization: Bearer $TOKEN" -X POST http://127.0.0.1:8101/rpc/tools/call \
267
- -H "Content-Type: application/json" \
268
- -d '{"name":"ping","arguments":{}}'
269
- ```
270
-
271
- ### Master Token
272
-
273
- - Token stored in `~/global.json` as `api_token`
274
- - Token file created automatically on first startup if missing
275
- - Token passed to workers via `CICY_MASTER_TOKEN` env var