@liangjie559567/ultrapower 7.2.0 → 7.4.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.
Files changed (92) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/agents/AGENTS.md +1 -1
  4. package/bridge/AGENTS.md +1 -1
  5. package/bridge/codex-server.cjs +2 -2
  6. package/bridge/gemini-server.cjs +1 -1
  7. package/bridge/mcp-server.cjs +17 -1
  8. package/commands/AGENTS.md +1 -1
  9. package/dist/cli/utils/setup.d.ts.map +1 -1
  10. package/dist/cli/utils/setup.js +19 -1
  11. package/dist/cli/utils/setup.js.map +1 -1
  12. package/dist/cli/utils/update.d.ts.map +1 -1
  13. package/dist/cli/utils/update.js +3 -1
  14. package/dist/cli/utils/update.js.map +1 -1
  15. package/dist/features/mcp-autodiscovery/capability-matcher.d.ts +17 -0
  16. package/dist/features/mcp-autodiscovery/capability-matcher.d.ts.map +1 -0
  17. package/dist/features/mcp-autodiscovery/capability-matcher.js +26 -0
  18. package/dist/features/mcp-autodiscovery/capability-matcher.js.map +1 -0
  19. package/dist/features/mcp-autodiscovery/config-injector.d.ts +11 -0
  20. package/dist/features/mcp-autodiscovery/config-injector.d.ts.map +1 -0
  21. package/dist/features/mcp-autodiscovery/config-injector.js +28 -0
  22. package/dist/features/mcp-autodiscovery/config-injector.js.map +1 -0
  23. package/dist/features/mcp-autodiscovery/index.d.ts +6 -0
  24. package/dist/features/mcp-autodiscovery/index.d.ts.map +1 -0
  25. package/dist/features/mcp-autodiscovery/index.js +5 -0
  26. package/dist/features/mcp-autodiscovery/index.js.map +1 -0
  27. package/dist/features/mcp-autodiscovery/installer.d.ts +10 -0
  28. package/dist/features/mcp-autodiscovery/installer.d.ts.map +1 -0
  29. package/dist/features/mcp-autodiscovery/installer.js +21 -0
  30. package/dist/features/mcp-autodiscovery/installer.js.map +1 -0
  31. package/dist/features/mcp-autodiscovery/registry-client.d.ts +9 -0
  32. package/dist/features/mcp-autodiscovery/registry-client.d.ts.map +1 -0
  33. package/dist/features/mcp-autodiscovery/registry-client.js +34 -0
  34. package/dist/features/mcp-autodiscovery/registry-client.js.map +1 -0
  35. package/dist/features/mcp-autodiscovery/types.d.ts +19 -0
  36. package/dist/features/mcp-autodiscovery/types.d.ts.map +1 -0
  37. package/dist/features/mcp-autodiscovery/types.js +2 -0
  38. package/dist/features/mcp-autodiscovery/types.js.map +1 -0
  39. package/dist/features/unified-context/context-manager.d.ts +24 -0
  40. package/dist/features/unified-context/context-manager.d.ts.map +1 -0
  41. package/dist/features/unified-context/context-manager.js +59 -0
  42. package/dist/features/unified-context/context-manager.js.map +1 -0
  43. package/dist/features/unified-context/index.d.ts +3 -0
  44. package/dist/features/unified-context/index.d.ts.map +1 -0
  45. package/dist/features/unified-context/index.js +3 -0
  46. package/dist/features/unified-context/index.js.map +1 -0
  47. package/dist/features/unified-context/mcp-memory-client.d.ts +14 -0
  48. package/dist/features/unified-context/mcp-memory-client.d.ts.map +1 -0
  49. package/dist/features/unified-context/mcp-memory-client.js +68 -0
  50. package/dist/features/unified-context/mcp-memory-client.js.map +1 -0
  51. package/dist/lib/atomic-write.d.ts.map +1 -1
  52. package/dist/lib/atomic-write.js +21 -2
  53. package/dist/lib/atomic-write.js.map +1 -1
  54. package/dist/lib/upgrade.d.ts +12 -0
  55. package/dist/lib/upgrade.d.ts.map +1 -0
  56. package/dist/lib/upgrade.js +119 -0
  57. package/dist/lib/upgrade.js.map +1 -0
  58. package/dist/mcp/adapters/memory-adapter.d.ts +2 -2
  59. package/dist/mcp/adapters/state-adapter.d.ts +4 -4
  60. package/dist/mcp/adapters/trace-adapter.d.ts +1 -1
  61. package/dist/team/message-router.d.ts +2 -2
  62. package/dist/team/message-router.d.ts.map +1 -1
  63. package/dist/team/message-router.js +4 -4
  64. package/dist/team/message-router.js.map +1 -1
  65. package/dist/team/task-router.d.ts +1 -1
  66. package/dist/team/task-router.d.ts.map +1 -1
  67. package/dist/team/task-router.js +2 -2
  68. package/dist/team/task-router.js.map +1 -1
  69. package/dist/team/unified-team.d.ts +4 -1
  70. package/dist/team/unified-team.d.ts.map +1 -1
  71. package/dist/team/unified-team.js +17 -8
  72. package/dist/team/unified-team.js.map +1 -1
  73. package/docs/AGENTS.md +4 -3
  74. package/docs/CLAUDE.md +1 -1
  75. package/docs/INSTALL.md +47 -7
  76. package/docs/REFERENCE.md +1 -1
  77. package/docs/UPGRADE.md +88 -0
  78. package/docs/UPGRADE_VERIFICATION.md +6 -6
  79. package/docs/dev-standards/AGENTS.md +68 -0
  80. package/docs/mcp-intelligent-orchestration.md +302 -0
  81. package/docs/migration/v6.0.0.md +2 -2
  82. package/docs/plans/2026-03-14-mcp-intelligent-orchestration.md +679 -0
  83. package/docs/standards/README.md +1 -1
  84. package/hooks/AGENTS.md +1 -1
  85. package/package.json +1 -1
  86. package/scripts/AGENTS.md +1 -1
  87. package/scripts/plugin-setup.mjs +23 -22
  88. package/scripts/upgrade-complete.sh +34 -0
  89. package/scripts/upgrade.mjs +158 -0
  90. package/skills/AGENTS.md +3 -2
  91. package/templates/AGENTS.md +1 -1
  92. package/templates/hooks/session-start.mjs +2 -2
@@ -65,15 +65,15 @@ updated 1 package in 3.2s
65
65
  **步骤 3: 刷新 hooks 和配置**
66
66
 
67
67
  ```bash
68
- omc install --force --skip-claude-check --refresh-hooks
68
+ omc setup
69
69
  ```
70
70
 
71
71
  **预期输出**:
72
72
  ```
73
- [OMC] Refreshing hooks...
73
+ [OMC] Syncing hooks...
74
74
  [OMC] Updated 47 hooks
75
75
  [OMC] Reconciled CLAUDE.md
76
- Installation complete
76
+ Setup complete
77
77
  ```
78
78
 
79
79
  **步骤 4: 重启 Claude Code**
@@ -152,7 +152,7 @@ rm -rf ~/.claude/plugins/marketplaces/omc
152
152
  # 方式 A: npm 全局安装
153
153
 
154
154
  npm install -g @liangjie559567/ultrapower@latest
155
- omc install --force
155
+ omc setup
156
156
 
157
157
  # 方式 B: 插件市场安装
158
158
 
@@ -339,7 +339,7 @@ npm install -g @liangjie559567/ultrapower@5.5.13
339
339
 
340
340
  # 刷新配置
341
341
 
342
- omc install --force --refresh-hooks
342
+ omc setup
343
343
  ```
344
344
 
345
345
  ### 场景 2: 配置损坏
@@ -386,7 +386,7 @@ rm -rf .omc/
386
386
  # 重新安装
387
387
 
388
388
  npm install -g @liangjie559567/ultrapower@latest
389
- omc install --force
389
+ omc setup
390
390
  ```
391
391
 
392
392
  ---
@@ -0,0 +1,68 @@
1
+ <!-- Parent: ../AGENTS.md -->
2
+ <!-- Generated: 2026-03-14 | Updated: 2026-03-14 -->
3
+
4
+ # docs/dev-standards/ - 开发规范体系
5
+
6
+ **用途:** 编码前检查清单、充分性验证、质量审查规范。确保所有实现遵循一致的标准。
7
+
8
+ **核心职责:** 定义编码流程、工具选择决策树、上下文收集协议。
9
+
10
+ ## 关键文件
11
+
12
+ | 文件 | 描述 |
13
+ | ------ | ------ |
14
+ | `dev-standards.md` | 编码要求、语言规范、验证机制 |
15
+ | `context-collection.md` | 编码前强制检索清单(7步) |
16
+ | `sufficiency-checklist.md` | 充分性验证清单(7项必查) |
17
+ | `workflow.md` | 工作流程、工具链顺序 |
18
+ | `tools-integration.md` | 工具选择决策树 |
19
+ | `quality-review.md` | 质量审查规范 |
20
+ | `context-summary-template.md` | 上下文摘要模板 |
21
+
22
+ ## 强制执行点
23
+
24
+ | 阶段 | 检查项 | 文档 |
25
+ | ------ | ------ | ------ |
26
+ | 编码前 | 7步检索清单 + 充分性验证 | context-collection.md |
27
+ | 编码中 | 遵循项目约定、复用组件 | dev-standards.md |
28
+ | 编码后 | 质量审查 + 本地验证 | quality-review.md |
29
+
30
+ ## 面向 AI 智能体
31
+
32
+ ### 在此目录中工作
33
+
34
+ 1. **执行编码前检查**
35
+ - 读取 `context-collection.md` 的 7 步清单
36
+ - 运行 `sufficiency-checklist.md` 的 7 项验证
37
+ - 填充 `context-summary-template.md`
38
+
39
+ 2. **选择工具**
40
+ - 查看 `tools-integration.md` 的决策树
41
+ - 根据任务类型选择合适工具
42
+ - 记录工具选择理由
43
+
44
+ 3. **质量审查**
45
+ - 遵循 `quality-review.md` 的规范
46
+ - 验证编码标准
47
+ - 检查测试覆盖率
48
+
49
+ ### 常见任务
50
+
51
+ ```typescript
52
+ // 检查充分性
53
+ import { SUFFICIENCY_CHECKLIST } from './sufficiency-checklist';
54
+ const checks = SUFFICIENCY_CHECKLIST.map(c => c.verify());
55
+
56
+ // 收集上下文
57
+ import { CONTEXT_COLLECTION_STEPS } from './context-collection';
58
+ const context = await Promise.all(
59
+ CONTEXT_COLLECTION_STEPS.map(s => s.execute())
60
+ );
61
+ ```
62
+
63
+ ### 修改检查清单
64
+
65
+ - [ ] 规范文档已更新
66
+ - [ ] 示例代码已验证
67
+ - [ ] 检查清单项完整
68
+ - [ ] 工具决策树准确
@@ -0,0 +1,302 @@
1
+ # MCP Intelligent Orchestration System
2
+
3
+ ## 概述
4
+
5
+ MCP 智能编排系统为 ultrapower 提供自动化的 MCP 服务器发现、能力匹配和配置生成功能。
6
+
7
+ ## 核心功能
8
+
9
+ ### 1. MCP Registry 客户端
10
+
11
+ 自动从 MCP Registry API 获取可用服务器列表:
12
+
13
+ ```typescript
14
+ import { MCPRegistryClient } from '@liangjie559567/ultrapower';
15
+
16
+ const client = new MCPRegistryClient();
17
+ const servers = await client.listServers();
18
+ const memoryServer = await client.getServerById('memory');
19
+ ```
20
+
21
+ **特性:**
22
+ - 1 小时缓存机制
23
+ - 支持能力查询过滤
24
+ - HTTP 错误处理
25
+
26
+ ### 2. 能力匹配引擎
27
+
28
+ 根据任务需求自动匹配最合适的 MCP 服务器:
29
+
30
+ ```typescript
31
+ import { CapabilityMatcher } from '@liangjie559567/ultrapower';
32
+
33
+ const matcher = new CapabilityMatcher();
34
+ const matches = await matcher.findMatches({
35
+ taskDescription: 'Store agent context',
36
+ requiredCapabilities: ['knowledge-graph', 'memory']
37
+ });
38
+
39
+ // 返回按置信度排序的匹配结果
40
+ matches.forEach(match => {
41
+ console.log(`${match.server.name}: ${match.confidence * 100}%`);
42
+ });
43
+ ```
44
+
45
+ ### 3. 配置生成器
46
+
47
+ 自动生成 MCP 服务器配置:
48
+
49
+ ```typescript
50
+ import { ConfigInjector } from '@liangjie559567/ultrapower';
51
+
52
+ const injector = new ConfigInjector();
53
+ const config = injector.generateConfig({
54
+ id: 'memory',
55
+ name: 'MCP Memory',
56
+ package: { type: 'uvx', name: '@modelcontextprotocol/server-memory' }
57
+ });
58
+
59
+ // 输出:
60
+ // {
61
+ // command: 'uvx',
62
+ // args: ['@modelcontextprotocol/server-memory']
63
+ // }
64
+ ```
65
+
66
+ **安全特性:**
67
+ - 包名正则验证(防止命令注入)
68
+ - 仅支持 npm/uvx/docker 三种类型
69
+
70
+ ### 4. 安装助手
71
+
72
+ 生成安全的安装命令:
73
+
74
+ ```typescript
75
+ import { MCPInstaller } from '@liangjie559567/ultrapower';
76
+
77
+ const installer = new MCPInstaller();
78
+
79
+ // 检查是否为官方服务器
80
+ if (installer.isOfficialServer('@modelcontextprotocol/server-memory')) {
81
+ const cmd = installer.getInstallCommand({
82
+ type: 'uvx',
83
+ name: '@modelcontextprotocol/server-memory'
84
+ });
85
+ console.log(cmd); // "uvx @modelcontextprotocol/server-memory"
86
+ }
87
+ ```
88
+
89
+ **官方服务器白名单:**
90
+ - `@modelcontextprotocol/server-memory`
91
+ - `@modelcontextprotocol/server-filesystem`
92
+ - `mcp-server-fetch`
93
+ - `mcp-server-git`
94
+
95
+ ## 集成示例
96
+
97
+ ### 基础集成
98
+
99
+ ```typescript
100
+ import {
101
+ MCPRegistryClient,
102
+ CapabilityMatcher,
103
+ ConfigInjector
104
+ } from '@liangjie559567/ultrapower';
105
+
106
+ async function setupMCPServer(taskDescription: string) {
107
+ // 1. 查询可用服务器
108
+ const client = new MCPRegistryClient();
109
+ const servers = await client.listServers();
110
+
111
+ // 2. 匹配能力
112
+ const matcher = new CapabilityMatcher();
113
+ const matches = await matcher.findMatches({
114
+ taskDescription,
115
+ requiredCapabilities: ['memory', 'knowledge-graph']
116
+ });
117
+
118
+ if (matches.length === 0) {
119
+ throw new Error('No matching MCP server found');
120
+ }
121
+
122
+ // 3. 生成配置
123
+ const bestMatch = matches[0];
124
+ const injector = new ConfigInjector();
125
+ const config = injector.generateConfig(bestMatch.server);
126
+
127
+ return config;
128
+ }
129
+ ```
130
+
131
+ ### 团队上下文同步
132
+
133
+ ```typescript
134
+ import { UnifiedContextManager } from '@liangjie559567/ultrapower';
135
+ import { setContextManager } from '@liangjie559567/ultrapower/team';
136
+
137
+ async function initTeamContext(teamName: string) {
138
+ // 初始化上下文管理器
139
+ const contextManager = new UnifiedContextManager();
140
+ await contextManager.initialize();
141
+
142
+ // 为团队设置上下文管理器
143
+ setContextManager(teamName, contextManager);
144
+
145
+ // 存储 agent 上下文
146
+ await contextManager.setAgentContext('agent-1', {
147
+ currentTask: 'Implement feature X',
148
+ dependencies: ['agent-2']
149
+ });
150
+
151
+ // 获取共享上下文
152
+ const sharedContext = await contextManager.getSharedContext();
153
+ return sharedContext;
154
+ }
155
+ ```
156
+
157
+ ## 安全加固
158
+
159
+ ### 命令注入防护
160
+
161
+ 所有包名经过严格正则验证:
162
+
163
+ ```typescript
164
+ const PACKAGE_NAME_REGEX = /^[@a-z0-9-_./]+$/i;
165
+
166
+ if (!PACKAGE_NAME_REGEX.test(packageName)) {
167
+ throw new Error(`Invalid package name: ${packageName}`);
168
+ }
169
+ ```
170
+
171
+ ### HTTP 错误处理
172
+
173
+ 所有 Registry API 调用包含状态码检查:
174
+
175
+ ```typescript
176
+ const response = await fetch(url);
177
+ if (!response.ok) {
178
+ throw new Error(`Registry API error: ${response.status}`);
179
+ }
180
+ ```
181
+
182
+ ### 多团队状态隔离
183
+
184
+ 使用 Map 实现团队级上下文隔离:
185
+
186
+ ```typescript
187
+ const contextManagers = new Map<string, UnifiedContextManager>();
188
+
189
+ export function setContextManager(teamName: string, manager: UnifiedContextManager) {
190
+ contextManagers.set(teamName, manager);
191
+ }
192
+ ```
193
+
194
+ ## 性能优化
195
+
196
+ ### 并行上下文同步
197
+
198
+ 使用 `Promise.all()` 并行处理多个 agent 上下文:
199
+
200
+ ```typescript
201
+ await Promise.all(
202
+ Object.entries(sharedContext).map(([agentId, context]) =>
203
+ contextManager.setAgentContext(agentId, context)
204
+ )
205
+ );
206
+ ```
207
+
208
+ **性能基准:**
209
+ - 10 个 agent 上下文同步 < 500ms
210
+ - 50 个并发操作 < 2000ms
211
+
212
+ ## API 参考
213
+
214
+ ### MCPRegistryClient
215
+
216
+ ```typescript
217
+ class MCPRegistryClient {
218
+ async listServers(query?: CapabilityQuery): Promise<MCPServerDescriptor[]>
219
+ async searchByCapability(capability: string): Promise<MCPServerDescriptor[]>
220
+ async getServerById(id: string): Promise<MCPServerDescriptor | null>
221
+ }
222
+ ```
223
+
224
+ ### CapabilityMatcher
225
+
226
+ ```typescript
227
+ class CapabilityMatcher {
228
+ async findMatches(requirement: TaskRequirement): Promise<Match[]>
229
+ }
230
+
231
+ interface Match {
232
+ server: MCPServerDescriptor;
233
+ confidence: number;
234
+ matchedCapabilities: string[];
235
+ }
236
+ ```
237
+
238
+ ### ConfigInjector
239
+
240
+ ```typescript
241
+ class ConfigInjector {
242
+ generateConfig(server: Pick<MCPServerDescriptor, 'id' | 'name' | 'package'>): MCPConfig
243
+ }
244
+ ```
245
+
246
+ ### MCPInstaller
247
+
248
+ ```typescript
249
+ class MCPInstaller {
250
+ isOfficialServer(packageName: string): boolean
251
+ getInstallCommand(pkg: PackageInfo): string
252
+ }
253
+ ```
254
+
255
+ ## 测试
256
+
257
+ 运行完整测试套件:
258
+
259
+ ```bash
260
+ npm test -- src/features/mcp-autodiscovery/__tests__/
261
+ ```
262
+
263
+ **测试覆盖:**
264
+ - 单元测试:17 个
265
+ - 安全测试:5 个
266
+ - 性能测试:2 个
267
+ - 集成测试:1 个
268
+
269
+ ## 故障排查
270
+
271
+ ### Registry API 连接失败
272
+
273
+ ```typescript
274
+ try {
275
+ const servers = await client.listServers();
276
+ } catch (error) {
277
+ if (error.message.includes('Registry API error')) {
278
+ // 检查网络连接或使用缓存数据
279
+ }
280
+ }
281
+ ```
282
+
283
+ ### MCP Memory 服务器未启动
284
+
285
+ 确保 MCP Memory 服务器正在运行:
286
+
287
+ ```bash
288
+ uvx @modelcontextprotocol/server-memory
289
+ ```
290
+
291
+ ### 包名验证失败
292
+
293
+ 确保包名符合规范:
294
+ - 仅包含字母、数字、连字符、下划线、点和斜杠
295
+ - 可选 `@` 前缀(用于 scoped packages)
296
+
297
+ ## 下一步
298
+
299
+ - [ ] 添加更多官方服务器到白名单
300
+ - [ ] 实现服务器健康检查
301
+ - [ ] 添加配置持久化
302
+ - [ ] 支持自定义 Registry URL
@@ -161,7 +161,7 @@ atomicWriteJsonSyncWithRetry(filePath: string, data: unknown, maxRetries?: numbe
161
161
 
162
162
  ```bash
163
163
  npm install -g @liangjie559567/ultrapower@latest
164
- omc install --force --skip-claude-check --refresh-hooks
164
+ omc setup
165
165
  ```
166
166
 
167
167
  ### 2. 验证升级
@@ -207,7 +207,7 @@ grep "field_filtered" .omc/logs/security-audit.jsonl
207
207
 
208
208
  ```bash
209
209
  npm install -g @liangjie559567/ultrapower@5.6.11
210
- omc install --force --skip-claude-check --refresh-hooks
210
+ omc setup
211
211
  ```
212
212
 
213
213
  **注意**:回滚后将失去 v6.0.0 的安全加固。