@geeseeker/easyai-dev 3.0.5 → 3.0.6

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.
Files changed (2) hide show
  1. package/README_AI.md +69 -6
  2. package/package.json +1 -1
package/README_AI.md CHANGED
@@ -52,7 +52,10 @@ easyAI 的 MCP Server 已打包在 npm 包中,无需本地编译。
52
52
 
53
53
  3. **注入 easyAI MCP Server 配置**:
54
54
 
55
- 向用户展示将要添加的配置内容,**请求用户确认**后再写入:
55
+ 向用户展示将要添加的配置内容,**请求用户确认**后再写入。
56
+
57
+ **关键**:必须包含 `EASYAI_PROJECT_ROOT` 环境变量,指向用户项目的绝对路径。
58
+ MCP Server 通过 `npx` 运行时,进程的工作目录不在项目内,需要此环境变量才能定位项目。
56
59
 
57
60
  ```
58
61
  我将在 Antigravity MCP 配置文件中添加 easyAI MCP Server:
@@ -62,12 +65,18 @@ easyAI 的 MCP Server 已打包在 npm 包中,无需本地编译。
62
65
  新增条目:
63
66
  "easyai-mcp-server": {
64
67
  "command": "npx",
65
- "args": ["-y", "@geeseeker/easyai-dev", "serve"]
68
+ "args": ["-y", "@geeseeker/easyai-dev", "serve"],
69
+ "env": {
70
+ "EASYAI_PROJECT_ROOT": "<用户项目的绝对路径>"
71
+ }
66
72
  }
67
73
 
68
74
  是否确认添加?
69
75
  ```
70
76
 
77
+ > **`EASYAI_PROJECT_ROOT` 必须是项目根目录的绝对路径**(包含 `.trellis/` 的目录)。
78
+ > 例如:`/home/user/projects/my-app` 或 `/Users/user/projects/my-app`。
79
+
71
80
  4. **用户确认后,写入配置**:
72
81
 
73
82
  将 `easyai-mcp-server` 条目添加到 `mcpServers` 对象中(保留已有的其他 MCP Server 配置不变)。
@@ -83,9 +92,22 @@ easyAI 的 MCP Server 已打包在 npm 包中,无需本地编译。
83
92
 
84
93
  > 这是一个**必须的断点**,MCP 配置修改后需要重启 IDE 才能生效。
85
94
 
86
- 6. **验证 MCP 连接**:用户确认重启后,尝试调用任意 easyai MCP 工具(如 `project_status`)验证连接。
87
- - 如果调用失败,检查配置文件内容是否正确,协助用户排查。
88
- - 如果没有 easyai MCP 工具可用,说明配置尚未生效,需要再次检查配置和重启。
95
+ 6. **验证 MCP 连接**:
96
+
97
+ 用户确认重启后,按以下顺序验证:
98
+
99
+ a. 尝试读取 MCP 资源 `trellis://status`
100
+
101
+ b. **如果成功** → 包含 `git`、`tasks`、`journal` 字段 → MCP 工作正常,进入 S2
102
+
103
+ c. **如果报错「无法找到项目根目录」** → 按以下步骤自修复:
104
+ 1. 读取 `~/.gemini/antigravity/mcp_config.json`
105
+ 2. 检查 `easyai-mcp-server` 条目是否包含 `env.EASYAI_PROJECT_ROOT`
106
+ 3. 如果缺失,添加 `"env": { "EASYAI_PROJECT_ROOT": "<项目绝对路径>" }`
107
+ 4. 如果已有但路径错误,修正为正确的项目根目录路径
108
+ 5. 告知用户需要再次重启 IDE
109
+
110
+ d. **如果没有 easyai MCP 工具可用** → 配置尚未生效,检查配置文件并重启
89
111
 
90
112
  ---
91
113
 
@@ -140,6 +162,40 @@ npx @geeseeker/easyai-dev check .
140
162
 
141
163
  ## 故障排查
142
164
 
165
+ AI 遇到 MCP 相关报错时,应**先自行诊断和修复**,不要将底层错误暴露给用户。
166
+
167
+ ### 「无法找到项目根目录」
168
+
169
+ **这是最常见的问题**。MCP Server 需要知道项目根目录才能工作。
170
+
171
+ **诊断**:错误信息中会包含 `cwd(...)` 和 `__dirname(...)` 两个路径,表示它在这两条路径上都没找到 `.trellis` 目录。
172
+
173
+ **自动修复步骤**(AI 应自行执行,无需用户介入):
174
+
175
+ 1. 读取 `~/.gemini/antigravity/mcp_config.json`
176
+ 2. 找到 `easyai-mcp-server` 条目
177
+ 3. 检查是否包含 `env.EASYAI_PROJECT_ROOT`
178
+ 4. 如果缺失或路径错误 → 修正为当前项目根目录(包含 `.trellis/` 的目录)的绝对路径:
179
+ ```json
180
+ "easyai-mcp-server": {
181
+ "command": "npx",
182
+ "args": ["-y", "@geeseeker/easyai-dev", "serve"],
183
+ "env": {
184
+ "EASYAI_PROJECT_ROOT": "/绝对路径/到/项目根"
185
+ }
186
+ }
187
+ ```
188
+ 5. 告知用户「MCP 配置已自动修复,请重启 IDE」
189
+ 6. 用户重启后,再次验证
190
+
191
+ **根因说明**:MCP Server 检测项目根的优先级为:
192
+
193
+ 1. `EASYAI_PROJECT_ROOT` 环境变量(推荐,最可靠)
194
+ 2. `process.cwd()` 向上遍历查找 `.trellis`(IDE 工作目录在项目内时有效)
195
+ 3. `__dirname` 向上遍历(MCP Server 安装在项目 `node_modules` 内时有效)
196
+
197
+ 通过 `npx -y` 运行时,cwd 和 `__dirname` 通常都在项目外,因此**必须设置环境变量**。
198
+
143
199
  ### MCP Server 无法启动
144
200
 
145
201
  ```bash
@@ -148,7 +204,7 @@ node --version # 需要 >= 18
148
204
 
149
205
  # 手动测试 MCP Server
150
206
  npx @geeseeker/easyai-dev serve
151
- # 正常情况下会输出 "easyAI MCP Server v0.1.0 started" 到 stderr
207
+ # 正常情况下会输出 "easyAI MCP Server started" 到 stderr
152
208
  ```
153
209
 
154
210
  ### MCP 配置文件路径不确定
@@ -176,3 +232,10 @@ npx @geeseeker/easyai-dev init .
176
232
  npx @geeseeker/easyai-dev update .
177
233
  # 只更新 .agents/ 和 .trellis/spec/,不影响用户数据
178
234
  ```
235
+
236
+ ### 切换项目
237
+
238
+ 如果用户切换到不同项目,需要更新 MCP 配置中的 `EASYAI_PROJECT_ROOT`:
239
+
240
+ 1. 修改 `~/.gemini/antigravity/mcp_config.json` 中的路径
241
+ 2. 重启 IDE
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geeseeker/easyai-dev",
3
- "version": "3.0.5",
3
+ "version": "3.0.6",
4
4
  "description": "easyAI — 让用户以纯客户的视角进行软件开发",
5
5
  "type": "module",
6
6
  "bin": {