metame-cli 1.5.11 → 1.5.12
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/index.js +64 -7
- package/package.json +3 -2
- package/scripts/daemon-agent-commands.js +6 -2
- package/scripts/daemon-bridges.js +23 -9
- package/scripts/daemon-claude-engine.js +87 -28
- package/scripts/daemon-command-router.js +16 -0
- package/scripts/daemon-command-session-route.js +3 -1
- package/scripts/daemon-engine-runtime.js +1 -5
- package/scripts/daemon-message-pipeline.js +113 -44
- package/scripts/daemon-reactive-lifecycle.js +405 -9
- package/scripts/daemon-session-commands.js +3 -2
- package/scripts/daemon-session-store.js +82 -27
- package/scripts/daemon-team-dispatch.js +21 -5
- package/scripts/daemon-utils.js +3 -1
- package/scripts/daemon.js +1 -0
- package/scripts/docs/file-transfer.md +1 -0
- package/scripts/hooks/intent-file-transfer.js +2 -1
- package/scripts/hooks/intent-perpetual.js +109 -0
- package/scripts/hooks/intent-research.js +112 -0
- package/scripts/intent-registry.js +4 -0
- package/scripts/ops-mission-queue.js +258 -0
- package/scripts/ops-verifier.js +197 -0
- package/skills/agent-browser/SKILL.md +153 -0
- package/skills/agent-reach/SKILL.md +66 -0
- package/skills/agent-reach/evolution.json +13 -0
- package/skills/deep-research/SKILL.md +77 -0
- package/skills/find-skills/SKILL.md +133 -0
- package/skills/heartbeat-task-manager/SKILL.md +63 -0
- package/skills/macos-local-orchestrator/SKILL.md +192 -0
- package/skills/macos-local-orchestrator/agents/openai.yaml +4 -0
- package/skills/macos-local-orchestrator/references/tooling-landscape.md +70 -0
- package/skills/macos-mail-calendar/SKILL.md +394 -0
- package/skills/mcp-installer/SKILL.md +138 -0
- package/skills/skill-creator/LICENSE.txt +202 -0
- package/skills/skill-creator/README.md +72 -0
- package/skills/skill-creator/SKILL.md +96 -0
- package/skills/skill-creator/evolution.json +6 -0
- package/skills/skill-creator/references/creation-guide.md +116 -0
- package/skills/skill-creator/references/evolution-guide.md +74 -0
- package/skills/skill-creator/references/output-patterns.md +82 -0
- package/skills/skill-creator/references/workflows.md +28 -0
- package/skills/skill-creator/scripts/align_all.py +32 -0
- package/skills/skill-creator/scripts/auto_evolve_hook.js +247 -0
- package/skills/skill-creator/scripts/init_skill.py +303 -0
- package/skills/skill-creator/scripts/merge_evolution.py +70 -0
- package/skills/skill-creator/scripts/package_skill.py +110 -0
- package/skills/skill-creator/scripts/quick_validate.py +103 -0
- package/skills/skill-creator/scripts/setup.py +141 -0
- package/skills/skill-creator/scripts/smart_stitch.py +82 -0
- package/skills/skill-manager/SKILL.md +112 -0
- package/skills/skill-manager/scripts/delete_skill.py +31 -0
- package/skills/skill-manager/scripts/list_skills.py +61 -0
- package/skills/skill-manager/scripts/scan_and_check.py +125 -0
- package/skills/skill-manager/scripts/sync_index.py +144 -0
- package/skills/skill-manager/scripts/update_helper.py +39 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: macos-mail-calendar
|
|
3
|
+
description: |
|
|
4
|
+
macOS 系统邮箱与日历访问。通过 AppleScript 直接读写 Mail.app 和 Calendar.app,
|
|
5
|
+
支持用户系统中所有已配置的邮箱账户(QQ、163、Gmail、Outlook、iCloud 等)和所有日历。
|
|
6
|
+
零配置,无需 IMAP 密码或第三方依赖。
|
|
7
|
+
触发词:邮件、邮箱、收件箱、日历、日程、会议、schedule、email、mail、calendar。
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# macOS 邮箱与日历
|
|
11
|
+
|
|
12
|
+
通过 Bash 工具执行 `osascript` 访问 macOS 系统 Mail.app 和 Calendar.app。
|
|
13
|
+
用户系统中添加的所有邮箱和日历账户自动可用,无需额外配置。
|
|
14
|
+
|
|
15
|
+
## 重要原则
|
|
16
|
+
|
|
17
|
+
1. **只读优先** — 读取、搜索操作直接执行;发送邮件、创建/删除事件必须先向用户确认
|
|
18
|
+
2. **隐私** — 不要一次性读取大量邮件正文,先列出摘要让用户选择
|
|
19
|
+
3. **性能** — 搜索时限定范围(账户、日期、数量),避免遍历全部邮件
|
|
20
|
+
4. **编码** — AppleScript 输出是 UTF-8,中文邮件正常显示
|
|
21
|
+
5. **错误处理** — Mail.app 或 Calendar.app 未打开时 osascript 会自动启动它们(后台)
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 邮箱操作
|
|
26
|
+
|
|
27
|
+
### 列出所有邮箱账户
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
osascript -e 'tell application "Mail" to get name of every account'
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### 读取最近 N 封收件箱邮件(摘要)
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
osascript -e '
|
|
37
|
+
tell application "Mail"
|
|
38
|
+
set msgs to messages 1 thru 10 of inbox
|
|
39
|
+
set output to ""
|
|
40
|
+
repeat with m in msgs
|
|
41
|
+
set output to output & "FROM: " & (sender of m) & linefeed & "SUBJECT: " & (subject of m) & linefeed & "DATE: " & (date received of m as string) & linefeed & "READ: " & (read status of m) & linefeed & "---" & linefeed
|
|
42
|
+
end repeat
|
|
43
|
+
return output
|
|
44
|
+
end tell
|
|
45
|
+
'
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
调整 `1 thru 10` 中的数字控制数量。
|
|
49
|
+
|
|
50
|
+
### 读取特定账户的收件箱
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
osascript -e '
|
|
54
|
+
tell application "Mail"
|
|
55
|
+
set acct to account "ACCOUNT_NAME"
|
|
56
|
+
set mb to mailbox "INBOX" of acct
|
|
57
|
+
set msgs to messages 1 thru 5 of mb
|
|
58
|
+
set output to ""
|
|
59
|
+
repeat with m in msgs
|
|
60
|
+
set output to output & "FROM: " & (sender of m) & linefeed & "SUBJECT: " & (subject of m) & linefeed & "DATE: " & (date received of m as string) & linefeed & "---" & linefeed
|
|
61
|
+
end repeat
|
|
62
|
+
return output
|
|
63
|
+
end tell
|
|
64
|
+
'
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 搜索邮件(按主题关键词)
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
osascript -e '
|
|
71
|
+
tell application "Mail"
|
|
72
|
+
set foundMsgs to (messages of inbox whose subject contains "关键词")
|
|
73
|
+
set cnt to count of foundMsgs
|
|
74
|
+
if cnt = 0 then return "未找到匹配邮件"
|
|
75
|
+
if cnt > 20 then set cnt to 20
|
|
76
|
+
set output to "找到 " & (count of foundMsgs) & " 封,显示前 " & cnt & " 封:" & linefeed
|
|
77
|
+
repeat with i from 1 to cnt
|
|
78
|
+
set m to item i of foundMsgs
|
|
79
|
+
set output to output & i & ". " & (sender of m) & " | " & (subject of m) & " | " & (date received of m as string) & linefeed
|
|
80
|
+
end repeat
|
|
81
|
+
return output
|
|
82
|
+
end tell
|
|
83
|
+
'
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 搜索邮件(按发件人)
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
osascript -e '
|
|
90
|
+
tell application "Mail"
|
|
91
|
+
set foundMsgs to (messages of inbox whose sender contains "someone@example.com")
|
|
92
|
+
-- 后续同上
|
|
93
|
+
end tell
|
|
94
|
+
'
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 读取邮件正文
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
osascript -e '
|
|
101
|
+
tell application "Mail"
|
|
102
|
+
set m to message INDEX of inbox
|
|
103
|
+
set c to content of m
|
|
104
|
+
if length of c > 2000 then
|
|
105
|
+
return text 1 thru 2000 of c
|
|
106
|
+
else
|
|
107
|
+
return c
|
|
108
|
+
end if
|
|
109
|
+
end tell
|
|
110
|
+
'
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
将 `INDEX` 替换为邮件序号(1 = 最新)。正文截断到 2000 字符避免输出过长。
|
|
114
|
+
|
|
115
|
+
### 读取邮件附件信息
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
osascript -e '
|
|
119
|
+
tell application "Mail"
|
|
120
|
+
set m to message INDEX of inbox
|
|
121
|
+
set atts to mail attachments of m
|
|
122
|
+
if (count of atts) = 0 then return "无附件"
|
|
123
|
+
set output to ""
|
|
124
|
+
repeat with a in atts
|
|
125
|
+
set output to output & "NAME: " & (name of a) & " | SIZE: " & (MIME type of a) & linefeed
|
|
126
|
+
end repeat
|
|
127
|
+
return output
|
|
128
|
+
end tell
|
|
129
|
+
'
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### 标记邮件已读/未读
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# 标记已读
|
|
136
|
+
osascript -e 'tell application "Mail" to set read status of message INDEX of inbox to true'
|
|
137
|
+
|
|
138
|
+
# 标记未读
|
|
139
|
+
osascript -e 'tell application "Mail" to set read status of message INDEX of inbox to false'
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### 发送邮件(需用户确认!)
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
osascript -e '
|
|
146
|
+
tell application "Mail"
|
|
147
|
+
set newMsg to make new outgoing message with properties {subject:"主题", content:"正文内容", visible:true}
|
|
148
|
+
tell newMsg
|
|
149
|
+
make new to recipient at end of to recipients with properties {address:"收件人@example.com"}
|
|
150
|
+
end tell
|
|
151
|
+
send newMsg
|
|
152
|
+
end tell
|
|
153
|
+
'
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**重要**:发送前必须将完整的收件人、主题、正文展示给用户确认。
|
|
157
|
+
|
|
158
|
+
### 创建草稿(不发送)
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
osascript -e '
|
|
162
|
+
tell application "Mail"
|
|
163
|
+
set newMsg to make new outgoing message with properties {subject:"主题", content:"正文内容", visible:true}
|
|
164
|
+
tell newMsg
|
|
165
|
+
make new to recipient at end of to recipients with properties {address:"收件人@example.com"}
|
|
166
|
+
end tell
|
|
167
|
+
-- 不调用 send,邮件留在草稿箱
|
|
168
|
+
end tell
|
|
169
|
+
'
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### 统计未读邮件
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
osascript -e '
|
|
176
|
+
tell application "Mail"
|
|
177
|
+
set unreadCount to unread count of inbox
|
|
178
|
+
return "未读邮件: " & unreadCount
|
|
179
|
+
end tell
|
|
180
|
+
'
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## 日历操作
|
|
186
|
+
|
|
187
|
+
### 列出所有日历
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
osascript -e 'tell application "Calendar" to get name of every calendar'
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### 查看今天的日程
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
osascript -e '
|
|
197
|
+
tell application "Calendar"
|
|
198
|
+
set today to current date
|
|
199
|
+
set time of today to 0
|
|
200
|
+
set tomorrow to today + 1 * days
|
|
201
|
+
set output to ""
|
|
202
|
+
repeat with cal in calendars
|
|
203
|
+
set evts to (every event of cal whose start date ≥ today and start date < tomorrow)
|
|
204
|
+
repeat with e in evts
|
|
205
|
+
set output to output & "📅 " & (name of cal) & " | " & (summary of e) & " | " & (start date of e as string)
|
|
206
|
+
try
|
|
207
|
+
set output to output & " ~ " & (end date of e as string)
|
|
208
|
+
end try
|
|
209
|
+
try
|
|
210
|
+
set loc to location of e
|
|
211
|
+
if loc is not "" and loc is not missing value then
|
|
212
|
+
set output to output & " | 📍" & loc
|
|
213
|
+
end if
|
|
214
|
+
end try
|
|
215
|
+
set output to output & linefeed
|
|
216
|
+
end repeat
|
|
217
|
+
end repeat
|
|
218
|
+
if output = "" then return "今天没有日程安排 ✨"
|
|
219
|
+
return output
|
|
220
|
+
end tell
|
|
221
|
+
'
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### 查看指定日期的日程
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
osascript -e '
|
|
228
|
+
tell application "Calendar"
|
|
229
|
+
set targetDate to date "2026-02-15"
|
|
230
|
+
set time of targetDate to 0
|
|
231
|
+
set nextDay to targetDate + 1 * days
|
|
232
|
+
set output to ""
|
|
233
|
+
repeat with cal in calendars
|
|
234
|
+
set evts to (every event of cal whose start date ≥ targetDate and start date < nextDay)
|
|
235
|
+
repeat with e in evts
|
|
236
|
+
set output to output & (name of cal) & " | " & (summary of e) & " | " & (start date of e as string) & linefeed
|
|
237
|
+
end repeat
|
|
238
|
+
end repeat
|
|
239
|
+
if output = "" then return "该日无日程"
|
|
240
|
+
return output
|
|
241
|
+
end tell
|
|
242
|
+
'
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### 查看本周日程
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
osascript -e '
|
|
249
|
+
tell application "Calendar"
|
|
250
|
+
set today to current date
|
|
251
|
+
set time of today to 0
|
|
252
|
+
set weekEnd to today + 7 * days
|
|
253
|
+
set output to ""
|
|
254
|
+
repeat with cal in calendars
|
|
255
|
+
set evts to (every event of cal whose start date ≥ today and start date < weekEnd)
|
|
256
|
+
repeat with e in evts
|
|
257
|
+
set output to output & (start date of e as string) & " | " & (name of cal) & " | " & (summary of e) & linefeed
|
|
258
|
+
end repeat
|
|
259
|
+
end repeat
|
|
260
|
+
if output = "" then return "本周无日程"
|
|
261
|
+
return output
|
|
262
|
+
end tell
|
|
263
|
+
'
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### 创建日历事件(需用户确认!)
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
osascript -e '
|
|
270
|
+
tell application "Calendar"
|
|
271
|
+
tell calendar "日历名称"
|
|
272
|
+
set startDate to date "2026-02-15 14:00:00"
|
|
273
|
+
set endDate to date "2026-02-15 15:00:00"
|
|
274
|
+
make new event with properties {summary:"会议主题", start date:startDate, end date:endDate, location:"会议室 A"}
|
|
275
|
+
end tell
|
|
276
|
+
end tell
|
|
277
|
+
'
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
**重要**:创建前必须向用户确认日历名称、时间、主题。
|
|
281
|
+
|
|
282
|
+
### 创建带提醒的事件
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
osascript -e '
|
|
286
|
+
tell application "Calendar"
|
|
287
|
+
tell calendar "日历名称"
|
|
288
|
+
set startDate to date "2026-02-15 14:00:00"
|
|
289
|
+
set endDate to date "2026-02-15 15:00:00"
|
|
290
|
+
set newEvent to make new event with properties {summary:"会议", start date:startDate, end date:endDate}
|
|
291
|
+
-- 提前15分钟提醒
|
|
292
|
+
tell newEvent
|
|
293
|
+
make new display alarm at end of display alarms with properties {trigger interval:-15}
|
|
294
|
+
end tell
|
|
295
|
+
end tell
|
|
296
|
+
end tell
|
|
297
|
+
'
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### 创建全天事件
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
osascript -e '
|
|
304
|
+
tell application "Calendar"
|
|
305
|
+
tell calendar "日历名称"
|
|
306
|
+
set eventDate to date "2026-02-15"
|
|
307
|
+
make new event with properties {summary:"休假", start date:eventDate, allday event:true}
|
|
308
|
+
end tell
|
|
309
|
+
end tell
|
|
310
|
+
'
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### 搜索日历事件
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
osascript -e '
|
|
317
|
+
tell application "Calendar"
|
|
318
|
+
set output to ""
|
|
319
|
+
repeat with cal in calendars
|
|
320
|
+
set evts to (every event of cal whose summary contains "关键词")
|
|
321
|
+
repeat with e in evts
|
|
322
|
+
set output to output & (name of cal) & " | " & (summary of e) & " | " & (start date of e as string) & linefeed
|
|
323
|
+
end repeat
|
|
324
|
+
end repeat
|
|
325
|
+
if output = "" then return "未找到匹配事件"
|
|
326
|
+
return output
|
|
327
|
+
end tell
|
|
328
|
+
'
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### 删除事件(需用户确认!)
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
osascript -e '
|
|
335
|
+
tell application "Calendar"
|
|
336
|
+
tell calendar "日历名称"
|
|
337
|
+
set evts to (every event whose summary is "要删除的事件名")
|
|
338
|
+
repeat with e in evts
|
|
339
|
+
delete e
|
|
340
|
+
end repeat
|
|
341
|
+
end tell
|
|
342
|
+
end tell
|
|
343
|
+
'
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
## 打开原生应用
|
|
349
|
+
|
|
350
|
+
当用户想直接查看邮箱或日历时,用 `open` 命令跳转到原生 App:
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
# 打开 Mail.app
|
|
354
|
+
open -a "Mail"
|
|
355
|
+
|
|
356
|
+
# 打开 Calendar.app
|
|
357
|
+
open -a "Calendar"
|
|
358
|
+
|
|
359
|
+
# 打开 Calendar.app 并跳到指定日期
|
|
360
|
+
open "x-apple-calevent://"
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
## 常见问题
|
|
366
|
+
|
|
367
|
+
### AppleScript 超时
|
|
368
|
+
如果邮箱数据量大,搜索可能耗时较长。对 Bash 工具设置 `timeout: 30000`(30秒)。
|
|
369
|
+
|
|
370
|
+
### 日期格式
|
|
371
|
+
macOS AppleScript 日期格式跟随系统区域设置。中文系统通常接受:
|
|
372
|
+
- `date "2026-02-15"`
|
|
373
|
+
- `date "2026-02-15 14:00:00"`
|
|
374
|
+
- `date "2026年2月15日"`
|
|
375
|
+
|
|
376
|
+
如果日期解析出错,用这个格式:
|
|
377
|
+
```applescript
|
|
378
|
+
set d to current date
|
|
379
|
+
set year of d to 2026
|
|
380
|
+
set month of d to 2
|
|
381
|
+
set day of d to 15
|
|
382
|
+
set time of d to 14 * hours
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### 首次访问权限
|
|
386
|
+
首次运行时 macOS 会弹出权限请求对话框("允许终端/xxx 控制 Mail/Calendar")。
|
|
387
|
+
用户需要在 **系统设置 → 隐私与安全性 → 自动化** 中授权。
|
|
388
|
+
|
|
389
|
+
### 邮件正文编码
|
|
390
|
+
`content of message` 返回纯文本。如果需要 HTML 版本:
|
|
391
|
+
```applescript
|
|
392
|
+
set htmlContent to source of message INDEX of inbox
|
|
393
|
+
```
|
|
394
|
+
但 HTML 很长,建议只在用户明确需要时使用。
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# MCP 安装与管理协议
|
|
2
|
+
|
|
3
|
+
当用户要求安装、启用或管理 MCP 工具时,执行本协议。
|
|
4
|
+
|
|
5
|
+
触发词:安装 MCP、装个 MCP、启用 XXX、mcp install、浏览器自动化、安装 playwright
|
|
6
|
+
|
|
7
|
+
## 核心原则
|
|
8
|
+
|
|
9
|
+
1. **先调研,再写配置** — 不凭感觉猜配置,先搜索官方文档
|
|
10
|
+
2. **写完配置即生效** — daemon 每次 spawn 新进程会自动加载最新配置,无需重启
|
|
11
|
+
3. **发现缺失就自己装** — 不要停下来问用户
|
|
12
|
+
|
|
13
|
+
## MCP 配置格式
|
|
14
|
+
|
|
15
|
+
配置文件:`~/.config/opencode/opencode.json`(全局)或项目目录下 `opencode.json`
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"mcp": {
|
|
20
|
+
"服务名称": {
|
|
21
|
+
"type": "local",
|
|
22
|
+
"command": ["npx", "-y", "@some/mcp-server@latest"],
|
|
23
|
+
"environment": { "API_KEY": "xxx" },
|
|
24
|
+
"enabled": true,
|
|
25
|
+
"timeout": 30000
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Local 类型(最常见)
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"type": "local",
|
|
36
|
+
"command": ["命令", "参数1", "参数2"],
|
|
37
|
+
"environment": {},
|
|
38
|
+
"enabled": true,
|
|
39
|
+
"timeout": 5000
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
- `command`: 字符串数组,第一个元素是可执行文件,后面是参数
|
|
44
|
+
- `environment`: 可选,环境变量
|
|
45
|
+
- `enabled`: 可选,默认 true
|
|
46
|
+
- `timeout`: 可选,请求超时毫秒数,默认 5000
|
|
47
|
+
|
|
48
|
+
### Remote 类型
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"type": "remote",
|
|
53
|
+
"url": "https://api.example.com/mcp",
|
|
54
|
+
"headers": { "Authorization": "Bearer xxx" },
|
|
55
|
+
"enabled": true
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 安装流程
|
|
60
|
+
|
|
61
|
+
### 第 1 步:调研
|
|
62
|
+
|
|
63
|
+
用户说"帮我装个 XXX MCP"时:
|
|
64
|
+
|
|
65
|
+
1. 搜索该 MCP server 的 npm 包名或 GitHub 仓库
|
|
66
|
+
2. 查找官方文档中的启动命令和配置方式
|
|
67
|
+
3. 确认需要哪些环境变量(API Key 等)
|
|
68
|
+
|
|
69
|
+
常见 MCP server 速查:
|
|
70
|
+
|
|
71
|
+
| 名称 | 包名 | 命令 |
|
|
72
|
+
|------|------|------|
|
|
73
|
+
| Playwright(浏览器) | `@playwright/mcp` | `["npx", "-y", "@playwright/mcp@latest", "--browser", "chrome"]` |
|
|
74
|
+
| Filesystem(文件系统) | `@anthropic/mcp-filesystem` | `["npx", "-y", "@anthropic/mcp-filesystem@latest", "/path"]` |
|
|
75
|
+
| GitHub | `@anthropic/mcp-github` | `["npx", "-y", "@anthropic/mcp-github@latest"]`,需要 `GITHUB_TOKEN` |
|
|
76
|
+
| Slack | `@anthropic/mcp-slack` | `["npx", "-y", "@anthropic/mcp-slack@latest"]`,需要 `SLACK_TOKEN` |
|
|
77
|
+
| Memory(知识图谱) | `@anthropic/mcp-memory` | `["npx", "-y", "@anthropic/mcp-memory@latest"]` |
|
|
78
|
+
|
|
79
|
+
如果不在速查表中,**必须先搜索**:
|
|
80
|
+
```bash
|
|
81
|
+
npm search mcp-server-XXX 2>/dev/null || echo "未找到,尝试 GitHub 搜索"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 第 2 步:安装依赖
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# 检查基础依赖
|
|
88
|
+
which npx node 2>/dev/null || echo "需要安装 Node.js"
|
|
89
|
+
which brew 2>/dev/null || echo "需要安装 Homebrew"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
如果缺 Node.js:
|
|
93
|
+
```bash
|
|
94
|
+
brew install node # 如果有 brew
|
|
95
|
+
# 或
|
|
96
|
+
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | /bin/bash
|
|
97
|
+
eval "$(/opt/homebrew/bin/brew shellenv)"
|
|
98
|
+
brew install node
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
预热 MCP 包(下载到缓存):
|
|
102
|
+
```bash
|
|
103
|
+
npx -y @some/mcp-server@latest --help 2>/dev/null || true
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### 第 3 步:写入配置
|
|
107
|
+
|
|
108
|
+
读取现有配置,合并新 MCP 条目:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# 读取现有配置
|
|
112
|
+
cat ~/.config/opencode/opencode.json 2>/dev/null || echo '{}'
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
然后用文件写入工具把新的 MCP 条目合并进 `mcp` 字段。**不要覆盖已有配置**,只添加新条目。
|
|
116
|
+
|
|
117
|
+
### 第 4 步:确认
|
|
118
|
+
|
|
119
|
+
告知用户:"XXX MCP 已配置完成,下一条消息就能使用新工具了。"
|
|
120
|
+
|
|
121
|
+
如果需要 API Key 等凭据,告知用户设置环境变量的方法。
|
|
122
|
+
|
|
123
|
+
## 环境自愈(自动触发)
|
|
124
|
+
|
|
125
|
+
当执行任务过程中遇到以下情况时,**自动执行修复**:
|
|
126
|
+
|
|
127
|
+
| 错误信息 | 自动修复 |
|
|
128
|
+
|---------|---------|
|
|
129
|
+
| `command not found: npx` | `brew install node` |
|
|
130
|
+
| `command not found: brew` | 安装 Homebrew |
|
|
131
|
+
| `ENOENT` + mcp server | `npx -y @包名@latest --help` 预热 |
|
|
132
|
+
| npm 缓存损坏 | `rm -rf ~/.npm/_npx` 后重试 |
|
|
133
|
+
|
|
134
|
+
## 注意事项
|
|
135
|
+
|
|
136
|
+
- Homebrew 安装需要 sudo 密码时才告知用户
|
|
137
|
+
- 不要在 daemon 环境下启用 Playwright MCP(启动慢 ~20s,已在代码中自动跳过)
|
|
138
|
+
- API Key 类环境变量建议写入 `~/.zshrc` 或 `~/.bashrc` 而非配置文件明文
|