stigmergy 1.2.6 → 1.2.10
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 +69 -20
- package/STIGMERGY.md +26 -7
- package/docs/MULTI_USER_WIKI_COLLABORATION_SYSTEM.md +523 -0
- package/docs/PROMPT_BASED_SKILLS_SYSTEM_DESIGN.md +458 -0
- package/docs/SKILL_IMPLEMENTATION_CONSTRAINTS_AND_ALIGNMENT.md +423 -0
- package/docs/TECHNICAL_FEASIBILITY_ANALYSIS.md +308 -0
- package/examples/multilingual-hook-demo.js +125 -0
- package/package.json +30 -19
- package/scripts/dependency-analyzer.js +101 -0
- package/scripts/generate-cli-docs.js +64 -0
- package/scripts/postuninstall.js +46 -0
- package/scripts/preuninstall.js +85 -0
- package/scripts/run-layered-tests.js +3 -3
- package/src/adapters/claude/install_claude_integration.js +37 -37
- package/src/adapters/codebuddy/install_codebuddy_integration.js +66 -63
- package/src/adapters/codex/install_codex_integration.js +54 -55
- package/src/adapters/copilot/install_copilot_integration.js +46 -46
- package/src/adapters/gemini/install_gemini_integration.js +68 -68
- package/src/adapters/iflow/install_iflow_integration.js +77 -77
- package/src/adapters/qoder/install_qoder_integration.js +76 -76
- package/src/adapters/qwen/install_qwen_integration.js +23 -23
- package/src/cli/router.js +713 -163
- package/src/commands/skill-bridge.js +39 -0
- package/src/commands/skill-handler.js +150 -0
- package/src/commands/skill.js +127 -0
- package/src/core/cache_cleaner.js +767 -767
- package/src/core/cli_help_analyzer.js +680 -680
- package/src/core/cli_parameter_handler.js +132 -132
- package/src/core/cli_path_detector.js +573 -0
- package/src/core/cli_tools.js +160 -89
- package/src/core/coordination/index.js +16 -16
- package/src/core/coordination/nodejs/AdapterManager.js +130 -102
- package/src/core/coordination/nodejs/CLCommunication.js +132 -132
- package/src/core/coordination/nodejs/CLIIntegrationManager.js +272 -272
- package/src/core/coordination/nodejs/HealthChecker.js +76 -76
- package/src/core/coordination/nodejs/HookDeploymentManager.js +463 -274
- package/src/core/coordination/nodejs/StatisticsCollector.js +71 -71
- package/src/core/coordination/nodejs/index.js +90 -90
- package/src/core/coordination/nodejs/utils/Logger.js +29 -29
- package/src/core/directory_permission_manager.js +568 -0
- package/src/core/enhanced_cli_installer.js +609 -0
- package/src/core/error_handler.js +406 -406
- package/src/core/installer.js +263 -119
- package/src/core/memory_manager.js +83 -83
- package/src/core/multilingual/language-pattern-manager.js +200 -0
- package/src/core/persistent_shell_configurator.js +468 -0
- package/src/core/rest_client.js +160 -160
- package/src/core/skills/StigmergySkillManager.js +357 -0
- package/src/core/skills/__tests__/SkillInstaller.test.js +275 -0
- package/src/core/skills/__tests__/SkillParser.test.js +202 -0
- package/src/core/skills/__tests__/SkillReader.test.js +189 -0
- package/src/core/skills/cli-command-test.js +201 -0
- package/src/core/skills/comprehensive-e2e-test.js +473 -0
- package/src/core/skills/e2e-test.js +267 -0
- package/src/core/skills/embedded-openskills/SkillInstaller.js +438 -0
- package/src/core/skills/embedded-openskills/SkillParser.js +123 -0
- package/src/core/skills/embedded-openskills/SkillReader.js +143 -0
- package/src/core/skills/integration-test.js +248 -0
- package/src/core/skills/package.json +6 -0
- package/src/core/skills/regression-test.js +285 -0
- package/src/core/skills/run-all-tests.js +129 -0
- package/src/core/skills/sync-test.js +210 -0
- package/src/core/skills/test-runner.js +242 -0
- package/src/core/smart_router.js +261 -249
- package/src/core/upgrade_manager.js +48 -20
- package/src/index.js +30 -30
- package/src/test/cli-availability-checker.js +194 -194
- package/src/test/test-environment.js +289 -289
- package/src/utils/helpers.js +18 -35
- package/src/utils.js +921 -921
- package/src/weatherProcessor.js +228 -228
- package/test/multilingual/hook-deployment.test.js +91 -0
- package/test/multilingual/language-pattern-manager.test.js +140 -0
- package/test/multilingual/system-test.js +85 -0
- package/src/auth.js +0 -173
- package/src/auth_command.js +0 -208
- package/src/calculator.js +0 -313
- package/src/core/enhanced_installer.js +0 -479
- package/src/core/enhanced_uninstaller.js +0 -638
- package/src/data_encryption.js +0 -143
- package/src/data_structures.js +0 -440
- package/src/deploy.js +0 -55
package/README.md
CHANGED
|
@@ -1,38 +1,79 @@
|
|
|
1
1
|
# Stigmergy CLI Multi-Agents System
|
|
2
2
|
|
|
3
|
-
A comprehensive system for collaboration between multiple AI CLI tools. This
|
|
4
|
-
|
|
5
|
-
## Packages
|
|
6
|
-
|
|
7
|
-
- `stigmergy` (Core): Main coordination system for multi-agent AI CLI tools
|
|
8
|
-
- `@stigmergy/skills`: Natural language skills for AI CLI tools
|
|
9
|
-
- `@stigmergy/resume`: Cross-CLI memory sharing and session recovery
|
|
10
|
-
- `@stigmergy/sessions`: Cross-CLI session management and recovery
|
|
3
|
+
A comprehensive system for collaboration between multiple AI CLI tools. This system enables seamless cross-CLI communication and intelligent task routing between different AI tools.
|
|
11
4
|
|
|
12
5
|
## Features
|
|
13
6
|
|
|
14
|
-
- 🤖 Multi-agent AI CLI tools collaboration (Claude, Gemini, Qwen,
|
|
15
|
-
- 🎯 Natural language skills processing
|
|
7
|
+
- 🤖 Multi-agent AI CLI tools collaboration (Claude, Gemini, Qwen, iFlow, Qoder, CodeBuddy, Copilot, Codex)
|
|
8
|
+
- 🎯 Natural language skills processing and cross-CLI task routing
|
|
16
9
|
- 🧠 Cross-CLI memory sharing and session recovery
|
|
17
10
|
- 🔗 Hook integration for seamless AI tool usage
|
|
18
|
-
- 🌍
|
|
11
|
+
- 🌍 JavaScript-based implementation (no Python dependencies)
|
|
19
12
|
- ⚡ Intelligent command routing and execution
|
|
20
13
|
|
|
21
14
|
## Quick Start
|
|
22
15
|
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
### Installation (One Command)
|
|
17
|
+
|
|
18
|
+
**Windows:**
|
|
19
|
+
```powershell
|
|
20
|
+
# Method 1: Right-click PowerShell and "Run as Administrator"
|
|
25
21
|
npm install -g stigmergy
|
|
26
22
|
|
|
27
|
-
#
|
|
28
|
-
npm install -g
|
|
23
|
+
# Method 2: Start PowerShell as Administrator from command line
|
|
24
|
+
Start-Process PowerShell -Verb RunAs -ArgumentList "npm install -g stigmergy"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**macOS/Linux:**
|
|
28
|
+
```bash
|
|
29
|
+
sudo npm install -g stigmergy
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Setup and Use
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Install all AI CLI tools
|
|
36
|
+
stigmergy install
|
|
29
37
|
|
|
30
|
-
#
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
# Deploy hooks for cross-CLI integration
|
|
39
|
+
stigmergy deploy
|
|
40
|
+
|
|
41
|
+
# Use cross-CLI collaboration
|
|
42
|
+
stigmergy claude "write a Python function"
|
|
43
|
+
stigmergy gemini "translate this text"
|
|
44
|
+
stigmergy qwen "analyze this code"
|
|
34
45
|
```
|
|
35
46
|
|
|
47
|
+
### Permission Issues?
|
|
48
|
+
|
|
49
|
+
**Windows:**
|
|
50
|
+
```powershell
|
|
51
|
+
# If you get permission errors:
|
|
52
|
+
npm install -g stigmergy --force
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**macOS/Linux:**
|
|
56
|
+
```bash
|
|
57
|
+
# If you get permission errors:
|
|
58
|
+
sudo npm install -g stigmergy --unsafe-perm=true --allow-root
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Cross-CLI Communication
|
|
62
|
+
|
|
63
|
+
When you need to call other AI tools, use the following format:
|
|
64
|
+
```bash
|
|
65
|
+
stigmergy <tool_name> <task_description>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Examples:
|
|
69
|
+
```bash
|
|
70
|
+
stigmergy claude "write a Python function"
|
|
71
|
+
stigmergy gemini "translate this text"
|
|
72
|
+
stigmergy qwen "analyze this code"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Available tools: claude, gemini, qwen, iflow, qodercli, codebuddy, copilot, codex
|
|
76
|
+
|
|
36
77
|
## Documentation
|
|
37
78
|
|
|
38
79
|
- [Main System](./README.md)
|
|
@@ -42,4 +83,12 @@ sg-sessions stats
|
|
|
42
83
|
|
|
43
84
|
## Contributing
|
|
44
85
|
|
|
45
|
-
This project
|
|
86
|
+
This project is a collaboration between multiple AI systems:
|
|
87
|
+
- Claude (Anthropic)
|
|
88
|
+
- Qwen (Alibaba)
|
|
89
|
+
- iFlow (Intelligent Workflow)
|
|
90
|
+
- QoderCLI
|
|
91
|
+
- GLM4.5 (Zhipu AI)
|
|
92
|
+
- And other AI systems
|
|
93
|
+
|
|
94
|
+
Contributions are welcome!
|
package/STIGMERGY.md
CHANGED
|
@@ -14,22 +14,41 @@ Cross-CLI communication is enabled between all supported AI tools:
|
|
|
14
14
|
- GitHub Copilot
|
|
15
15
|
- OpenAI Codex
|
|
16
16
|
|
|
17
|
+
## Project Contributors
|
|
18
|
+
|
|
19
|
+
This project is made possible through the contribution of various AI systems:
|
|
20
|
+
- Claude (Anthropic)
|
|
21
|
+
- Qwen (Alibaba)
|
|
22
|
+
- iFlow (Intelligent Workflow)
|
|
23
|
+
- QoderCLI
|
|
24
|
+
- GLM4.5 (Zhipu AI)
|
|
25
|
+
- And other AI systems
|
|
26
|
+
|
|
17
27
|
## Cross-CLI Collaboration
|
|
18
28
|
|
|
19
|
-
|
|
29
|
+
Stigmergy provides a unified command interface for cross-CLI communication:
|
|
20
30
|
|
|
21
31
|
### How It Works
|
|
22
32
|
1. Each CLI tool has hooks deployed by Stigmergy
|
|
23
|
-
2.
|
|
33
|
+
2. Use the stigmergy command to route tasks to specific AI tools
|
|
24
34
|
3. The target tool executes the requested task and returns results
|
|
25
35
|
|
|
26
36
|
### Usage Pattern
|
|
27
|
-
|
|
37
|
+
Use the stigmergy command with the following format:
|
|
38
|
+
```bash
|
|
39
|
+
stigmergy <tool_name> <task_description>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Examples:
|
|
28
43
|
```bash
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
44
|
+
stigmergy claude "write a Python function"
|
|
45
|
+
stigmergy gemini "translate this text"
|
|
46
|
+
stigmergy qwen "analyze this code"
|
|
47
|
+
stigmergy iflow "create a workflow"
|
|
48
|
+
stigmergy qodercli "review this code"
|
|
49
|
+
stigmergy codebuddy "help me debug"
|
|
50
|
+
stigmergy copilot "suggest improvements"
|
|
51
|
+
stigmergy codex "generate documentation"
|
|
33
52
|
```
|
|
34
53
|
|
|
35
54
|
## Project Memory and Documentation
|
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
# 多用户Wiki协同编辑技能系统设计
|
|
2
|
+
|
|
3
|
+
## 🎯 系统概述
|
|
4
|
+
|
|
5
|
+
基于Wiki理念的多用户实时协同编辑系统,让多个用户能够同时编辑、创建和优化AI技能,实现真正的"集体智慧"技能开发。
|
|
6
|
+
|
|
7
|
+
## 🏗️ 系统架构
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
11
|
+
│ Wiki协同编辑系统 │
|
|
12
|
+
├─────────────────────────────────────────────────────────────┤
|
|
13
|
+
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
|
|
14
|
+
│ │ 前端编辑器 │ │ 实时同步层 │ │ 后端服务层 │ │
|
|
15
|
+
│ │ │ │ │ │ │ │
|
|
16
|
+
│ │ • Monaco │ │ • WebSocket │ │ • Express │ │
|
|
17
|
+
│ │ • Yjs协作 │ │ • CRDT算法 │ │ • MongoDB │ │
|
|
18
|
+
│ │ • 实时预览 │ │ • 冲突解决 │ │ • Redis缓存 │ │
|
|
19
|
+
│ └─────────────┘ └─────────────┘ └─────────────┘ │
|
|
20
|
+
│ │ │ │ │
|
|
21
|
+
│ ▼ ▼ ▼ │
|
|
22
|
+
│ ┌─────────────────────────────────────────────────────┐ │
|
|
23
|
+
│ │ AI技能处理引擎 │ │
|
|
24
|
+
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │
|
|
25
|
+
│ │ │ 版本控制 │ │ 技能解析器 │ │ 自动测试 │ │ │
|
|
26
|
+
│ │ │ │ │ │ │ │ │ │
|
|
27
|
+
│ │ │ • Git集成 │ │ • 实时解析 │ │ • 自动验证 │ │ │
|
|
28
|
+
│ │ │ • 分支管理 │ │ • 语法检查 │ │ • 性能测试 │ │ │
|
|
29
|
+
│ │ │ • 合并请求 │ │ • 智能提示 │ │ • 安全扫描 │ │ │
|
|
30
|
+
│ │ └─────────────┘ └─────────────┘ └─────────────┘ │ │
|
|
31
|
+
│ └─────────────────────────────────────────────────────┘ │
|
|
32
|
+
└─────────────────────────────────────────────────────────────┘
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 🎨 核心功能模块
|
|
36
|
+
|
|
37
|
+
### 1. 实时协同编辑器
|
|
38
|
+
|
|
39
|
+
#### 前端实现(基于Monaco Editor + Yjs)
|
|
40
|
+
```javascript
|
|
41
|
+
// 协同编辑器初始化
|
|
42
|
+
class CollaborativeEditor {
|
|
43
|
+
constructor(container, skillId) {
|
|
44
|
+
this.editor = monaco.editor.create(container, {
|
|
45
|
+
theme: 'vs-dark',
|
|
46
|
+
language: 'markdown',
|
|
47
|
+
automaticLayout: true
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Yjs协同编辑集成
|
|
51
|
+
this.yDoc = new Y.Doc();
|
|
52
|
+
this.yText = this.yDoc.getText('skill-content');
|
|
53
|
+
|
|
54
|
+
// WebSocket连接
|
|
55
|
+
this.websocket = new WebSocket(`ws://localhost:3001/skills/${skillId}`);
|
|
56
|
+
|
|
57
|
+
// 绑定协同编辑
|
|
58
|
+
this.bindCollaboration();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
bindCollaboration() {
|
|
62
|
+
// Monaco Editor与Yjs绑定
|
|
63
|
+
const binding = new MonacoBinding(this.yText, this.editor);
|
|
64
|
+
|
|
65
|
+
// WebSocket同步
|
|
66
|
+
this.websocket.onmessage = (event) => {
|
|
67
|
+
const update = JSON.parse(event.data);
|
|
68
|
+
Y.applyUpdate(this.yDoc, update);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// 本地更改同步
|
|
72
|
+
this.yDoc.on('update', (update) => {
|
|
73
|
+
this.websocket.send(JSON.stringify(update));
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### 后端WebSocket服务器
|
|
80
|
+
```javascript
|
|
81
|
+
// WebSocket服务器
|
|
82
|
+
class SkillCollaborationServer {
|
|
83
|
+
constructor() {
|
|
84
|
+
this.wss = new WebSocket.Server({ port: 3001 });
|
|
85
|
+
this.skillRooms = new Map(); // 技能房间管理
|
|
86
|
+
this.setupRoutes();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
setupRoutes() {
|
|
90
|
+
this.wss.on('connection', (ws, request) => {
|
|
91
|
+
const skillId = this.extractSkillId(request.url);
|
|
92
|
+
this.joinSkillRoom(ws, skillId);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
joinSkillRoom(ws, skillId) {
|
|
97
|
+
if (!this.skillRooms.has(skillId)) {
|
|
98
|
+
this.skillRooms.set(skillId, new Set());
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const room = this.skillRooms.get(skillId);
|
|
102
|
+
room.add(ws);
|
|
103
|
+
|
|
104
|
+
// 广播给房间内其他用户
|
|
105
|
+
ws.on('message', (message) => {
|
|
106
|
+
room.forEach(client => {
|
|
107
|
+
if (client !== ws && client.readyState === WebSocket.OPEN) {
|
|
108
|
+
client.send(message);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// 用户离开时清理
|
|
114
|
+
ws.on('close', () => {
|
|
115
|
+
room.delete(ws);
|
|
116
|
+
if (room.size === 0) {
|
|
117
|
+
this.skillRooms.delete(skillId);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 2. Wiki版本控制系统
|
|
125
|
+
|
|
126
|
+
#### Git集成管理
|
|
127
|
+
```javascript
|
|
128
|
+
class WikiVersionControl {
|
|
129
|
+
constructor(skillRepo) {
|
|
130
|
+
this.repo = skillRepo;
|
|
131
|
+
this.git = simpleGit(skillRepo);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// 自动保存版本
|
|
135
|
+
async saveVersion(skillId, content, author, message) {
|
|
136
|
+
const timestamp = new Date().toISOString();
|
|
137
|
+
const filename = `skills/${skillId}.md`;
|
|
138
|
+
|
|
139
|
+
// 写入文件
|
|
140
|
+
await fs.writeFile(filename, content);
|
|
141
|
+
|
|
142
|
+
// Git操作
|
|
143
|
+
await this.git.add(filename);
|
|
144
|
+
await this.git.commit(`${message}\n\nAuthor: ${author}\nTime: ${timestamp}`);
|
|
145
|
+
|
|
146
|
+
// 创建标签(可选)
|
|
147
|
+
if (message.includes('发布')) {
|
|
148
|
+
await this.git.addTag(`v${Date.now()}`, filename);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// 获取版本历史
|
|
153
|
+
async getVersionHistory(skillId) {
|
|
154
|
+
const log = await this.git.log({
|
|
155
|
+
file: `skills/${skillId}.md`,
|
|
156
|
+
maxCount: 50
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
return log.all.map(commit => ({
|
|
160
|
+
hash: commit.hash,
|
|
161
|
+
message: commit.message,
|
|
162
|
+
author: commit.author_name,
|
|
163
|
+
date: commit.date,
|
|
164
|
+
changes: commit.diff?.changes
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// 分支管理
|
|
169
|
+
async createBranch(skillId, branchName, author) {
|
|
170
|
+
await this.git.checkoutLocalBranch(branchName);
|
|
171
|
+
await this.saveVersion(skillId, '', author, `创建分支: ${branchName}`);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// 合并请求
|
|
175
|
+
async mergeRequest(sourceBranch, targetBranch, reviewer) {
|
|
176
|
+
await this.git.checkoutBranch(targetBranch);
|
|
177
|
+
await this.git.merge([sourceBranch]);
|
|
178
|
+
await this.git.push('origin', targetBranch);
|
|
179
|
+
|
|
180
|
+
// 通知审查者
|
|
181
|
+
await this.notifyReviewer(reviewer, sourceBranch, targetBranch);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### 3. 智能技能解析器
|
|
187
|
+
|
|
188
|
+
#### 实时解析引擎
|
|
189
|
+
```javascript
|
|
190
|
+
class RealTimeSkillParser {
|
|
191
|
+
constructor() {
|
|
192
|
+
this.parser = new Parser();
|
|
193
|
+
this.debounceTimer = null;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// 实时解析(防抖处理)
|
|
197
|
+
parseRealTime(content, callback) {
|
|
198
|
+
clearTimeout(this.debounceTimer);
|
|
199
|
+
|
|
200
|
+
this.debounceTimer = setTimeout(async () => {
|
|
201
|
+
try {
|
|
202
|
+
const parsed = await this.parser.parse(content);
|
|
203
|
+
const validation = await this.validateSkill(parsed);
|
|
204
|
+
|
|
205
|
+
callback({
|
|
206
|
+
success: true,
|
|
207
|
+
parsed,
|
|
208
|
+
validation,
|
|
209
|
+
timestamp: new Date().toISOString()
|
|
210
|
+
});
|
|
211
|
+
} catch (error) {
|
|
212
|
+
callback({
|
|
213
|
+
success: false,
|
|
214
|
+
error: error.message,
|
|
215
|
+
suggestions: this.getSuggestions(error)
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}, 500); // 500ms防抖
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// 技能验证
|
|
222
|
+
async validateSkill(parsed) {
|
|
223
|
+
const validation = {
|
|
224
|
+
errors: [],
|
|
225
|
+
warnings: [],
|
|
226
|
+
suggestions: []
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
// 结构验证
|
|
230
|
+
if (!parsed.name) {
|
|
231
|
+
validation.errors.push('技能名称不能为空');
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (!parsed.triggers || parsed.triggers.length === 0) {
|
|
235
|
+
validation.warnings.push('没有定义触发条件,技能可能无法被调用');
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// 语法验证
|
|
239
|
+
if (parsed.workflow) {
|
|
240
|
+
parsed.workflow.forEach((step, index) => {
|
|
241
|
+
if (!step.action) {
|
|
242
|
+
validation.errors.push(`步骤${index + 1}缺少执行动作`);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// 性能建议
|
|
248
|
+
if (parsed.tools && parsed.tools.length > 5) {
|
|
249
|
+
validation.suggestions.push('考虑减少依赖工具数量以提高性能');
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return validation;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// 智能建议
|
|
256
|
+
getSuggestions(error) {
|
|
257
|
+
const suggestions = [];
|
|
258
|
+
|
|
259
|
+
if (error.message.includes('syntax')) {
|
|
260
|
+
suggestions.push('检查YAML语法是否正确');
|
|
261
|
+
suggestions.push('确保缩进使用空格而非制表符');
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (error.message.includes('trigger')) {
|
|
265
|
+
suggestions.push('添加关键词触发条件,如:keywords: ["翻译", "translate"]');
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return suggestions;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### 4. 多用户权限管理
|
|
274
|
+
|
|
275
|
+
#### 基于角色的权限系统
|
|
276
|
+
```javascript
|
|
277
|
+
class WikiPermissionManager {
|
|
278
|
+
constructor() {
|
|
279
|
+
this.roles = new Map();
|
|
280
|
+
this.permissions = new Map();
|
|
281
|
+
this.setupDefaultRoles();
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
setupDefaultRoles() {
|
|
285
|
+
// 定义角色
|
|
286
|
+
this.roles.set('owner', {
|
|
287
|
+
name: '所有者',
|
|
288
|
+
permissions: ['read', 'write', 'delete', 'manage_users', 'merge']
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
this.roles.set('editor', {
|
|
292
|
+
name: '编辑者',
|
|
293
|
+
permissions: ['read', 'write', 'suggest']
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
this.roles.set('viewer', {
|
|
297
|
+
name: '查看者',
|
|
298
|
+
permissions: ['read', 'comment']
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
this.roles.set('guest', {
|
|
302
|
+
name: '访客',
|
|
303
|
+
permissions: ['read']
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// 检查权限
|
|
308
|
+
hasPermission(userId, skillId, permission) {
|
|
309
|
+
const userRole = this.getUserRole(userId, skillId);
|
|
310
|
+
const rolePermissions = this.roles.get(userRole)?.permissions || [];
|
|
311
|
+
|
|
312
|
+
return rolePermissions.includes(permission);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// 分配角色
|
|
316
|
+
assignRole(userId, skillId, role, assignedBy) {
|
|
317
|
+
// 检查分配者权限
|
|
318
|
+
if (!this.hasPermission(assignedBy, skillId, 'manage_users')) {
|
|
319
|
+
throw new Error('无权限分配角色');
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
this.permissions.set(`${userId}:${skillId}`, role);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// 协作规则
|
|
326
|
+
getCollaborationRules(skillId) {
|
|
327
|
+
return {
|
|
328
|
+
maxConcurrentEditors: 10,
|
|
329
|
+
editConflictResolution: 'latest_wins',
|
|
330
|
+
suggestionRequired: false,
|
|
331
|
+
autoSaveInterval: 30000, // 30秒
|
|
332
|
+
versionControl: true
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
## 🎯 用户界面设计
|
|
339
|
+
|
|
340
|
+
### 1. 主编辑界面
|
|
341
|
+
```html
|
|
342
|
+
<!-- Wiki协同编辑主界面 -->
|
|
343
|
+
<div class="wiki-editor">
|
|
344
|
+
<!-- 顶部工具栏 -->
|
|
345
|
+
<div class="editor-toolbar">
|
|
346
|
+
<div class="toolbar-left">
|
|
347
|
+
<h1 contenteditable="true" class="skill-title">{{ skill.name }}</h1>
|
|
348
|
+
<span class="skill-status">{{ status }}</span>
|
|
349
|
+
</div>
|
|
350
|
+
|
|
351
|
+
<div class="toolbar-right">
|
|
352
|
+
<button class="btn-save" @click="save">💾 保存</button>
|
|
353
|
+
<button class="btn-preview" @click="togglePreview">👁️ 预览</button>
|
|
354
|
+
<button class="btn-share" @click="share">🔗 分享</button>
|
|
355
|
+
<div class="active-users">
|
|
356
|
+
<div v-for="user in activeUsers" :key="user.id"
|
|
357
|
+
class="user-avatar"
|
|
358
|
+
:style="{backgroundColor: user.color}">
|
|
359
|
+
{{ user.initial }}
|
|
360
|
+
</div>
|
|
361
|
+
</div>
|
|
362
|
+
</div>
|
|
363
|
+
</div>
|
|
364
|
+
|
|
365
|
+
<!-- 主编辑区域 -->
|
|
366
|
+
<div class="editor-main">
|
|
367
|
+
<!-- 左侧编辑器 -->
|
|
368
|
+
<div class="editor-pane">
|
|
369
|
+
<div class="editor-tabs">
|
|
370
|
+
<div class="tab active" @click="switchTab('edit')">编辑</div>
|
|
371
|
+
<div class="tab" @click="switchTab('preview')">预览</div>
|
|
372
|
+
<div class="tab" @click="switchTab('debug')">调试</div>
|
|
373
|
+
</div>
|
|
374
|
+
|
|
375
|
+
<div id="monaco-editor" class="monaco-editor"></div>
|
|
376
|
+
</div>
|
|
377
|
+
|
|
378
|
+
<!-- 右侧辅助面板 -->
|
|
379
|
+
<div class="assistant-panel">
|
|
380
|
+
<!-- 实时解析结果 -->
|
|
381
|
+
<div class="parse-results">
|
|
382
|
+
<h3>解析结果</h3>
|
|
383
|
+
<div v-if="parseResult.errors.length > 0" class="errors">
|
|
384
|
+
<div v-for="error in parseResult.errors"
|
|
385
|
+
class="error-item"
|
|
386
|
+
:key="error.line">
|
|
387
|
+
❌ {{ error.message }}
|
|
388
|
+
</div>
|
|
389
|
+
</div>
|
|
390
|
+
|
|
391
|
+
<div v-if="parseResult.warnings.length > 0" class="warnings">
|
|
392
|
+
<div v-for="warning in parseResult.warnings"
|
|
393
|
+
class="warning-item"
|
|
394
|
+
:key="warning.line">
|
|
395
|
+
⚠️ {{ warning.message }}
|
|
396
|
+
</div>
|
|
397
|
+
</div>
|
|
398
|
+
</div>
|
|
399
|
+
|
|
400
|
+
<!-- 协作者列表 -->
|
|
401
|
+
<div class="collaborators">
|
|
402
|
+
<h3>协作者</h3>
|
|
403
|
+
<div v-for="user in collaborators" :key="user.id" class="collaborator">
|
|
404
|
+
<div class="user-info">
|
|
405
|
+
<span class="user-name">{{ user.name }}</span>
|
|
406
|
+
<span class="user-role">{{ user.role }}</span>
|
|
407
|
+
</div>
|
|
408
|
+
<div class="user-status" :class="user.status">
|
|
409
|
+
{{ user.status === 'online' ? '🟢' : '🔴' }}
|
|
410
|
+
</div>
|
|
411
|
+
</div>
|
|
412
|
+
</div>
|
|
413
|
+
|
|
414
|
+
<!-- 版本历史 -->
|
|
415
|
+
<div class="version-history">
|
|
416
|
+
<h3>版本历史</h3>
|
|
417
|
+
<div v-for="version in versions" :key="version.hash" class="version-item">
|
|
418
|
+
<div class="version-info">
|
|
419
|
+
<span class="version-message">{{ version.message }}</span>
|
|
420
|
+
<span class="version-author">{{ version.author }}</span>
|
|
421
|
+
<span class="version-time">{{ formatTime(version.date) }}</span>
|
|
422
|
+
</div>
|
|
423
|
+
<button @click="restoreVersion(version.hash)" class="btn-restore">
|
|
424
|
+
恢复
|
|
425
|
+
</button>
|
|
426
|
+
</div>
|
|
427
|
+
</div>
|
|
428
|
+
</div>
|
|
429
|
+
</div>
|
|
430
|
+
|
|
431
|
+
<!-- 底部状态栏 -->
|
|
432
|
+
<div class="editor-statusbar">
|
|
433
|
+
<div class="status-left">
|
|
434
|
+
<span>行: {{ cursorPosition.line }}, 列: {{ cursorPosition.column }}</span>
|
|
435
|
+
<span>字数: {{ wordCount }}</span>
|
|
436
|
+
</div>
|
|
437
|
+
<div class="status-right">
|
|
438
|
+
<span v-if="isSaving" class="saving-indicator">💾 保存中...</span>
|
|
439
|
+
<span v-else-if="lastSaved" class="saved-indicator">
|
|
440
|
+
✅ 已保存于 {{ formatTime(lastSaved) }}
|
|
441
|
+
</span>
|
|
442
|
+
<span class="connection-status" :class="connectionStatus">
|
|
443
|
+
{{ connectionStatus === 'connected' ? '🟢' : '🔴' }}
|
|
444
|
+
</span>
|
|
445
|
+
</div>
|
|
446
|
+
</div>
|
|
447
|
+
</div>
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
### 2. 移动端适配
|
|
451
|
+
```css
|
|
452
|
+
/* 移动端响应式设计 */
|
|
453
|
+
@media (max-width: 768px) {
|
|
454
|
+
.wiki-editor {
|
|
455
|
+
flex-direction: column;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
.editor-main {
|
|
459
|
+
flex-direction: column;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
.assistant-panel {
|
|
463
|
+
position: fixed;
|
|
464
|
+
bottom: 0;
|
|
465
|
+
left: 0;
|
|
466
|
+
right: 0;
|
|
467
|
+
height: 40vh;
|
|
468
|
+
transform: translateY(calc(100% - 50px));
|
|
469
|
+
transition: transform 0.3s ease;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
.assistant-panel.expanded {
|
|
473
|
+
transform: translateY(0);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
## 🚀 实施计划
|
|
479
|
+
|
|
480
|
+
### 第一阶段:基础协同编辑(1-2个月)
|
|
481
|
+
- [x] 系统架构设计
|
|
482
|
+
- [ ] WebSocket实时通信
|
|
483
|
+
- [ ] Monaco Editor集成
|
|
484
|
+
- [ ] 基础冲突解决
|
|
485
|
+
|
|
486
|
+
### 第二阶段:Wiki功能完善(2-3个月)
|
|
487
|
+
- [ ] 版本控制系统
|
|
488
|
+
- [ ] 权限管理
|
|
489
|
+
- [ ] 用户认证
|
|
490
|
+
- [ ] 移动端适配
|
|
491
|
+
|
|
492
|
+
### 第三阶段:智能辅助功能(3-4个月)
|
|
493
|
+
- [ ] 实时语法解析
|
|
494
|
+
- [ ] 智能提示系统
|
|
495
|
+
- [ ] 自动补全
|
|
496
|
+
- [ ] 性能优化
|
|
497
|
+
|
|
498
|
+
### 第四阶段:高级功能(4-6个月)
|
|
499
|
+
- [ ] 技能测试平台
|
|
500
|
+
- [ ] 自动化部署
|
|
501
|
+
- [ ] 社区功能
|
|
502
|
+
- [ ] 分析统计
|
|
503
|
+
|
|
504
|
+
## 📊 技术优势
|
|
505
|
+
|
|
506
|
+
1. **实时性**:基于WebSocket的毫秒级同步
|
|
507
|
+
2. **可靠性**:CRDT算法保证数据一致性
|
|
508
|
+
3. **扩展性**:微服务架构支持水平扩展
|
|
509
|
+
4. **易用性**:直观的Wiki风格编辑体验
|
|
510
|
+
5. **智能化**:AI辅助的语法检查和优化建议
|
|
511
|
+
|
|
512
|
+
## 🎯 预期效果
|
|
513
|
+
|
|
514
|
+
- **协作效率提升200%**:多人同时编辑,实时同步
|
|
515
|
+
- **技能质量提升150%**:AI辅助检查和优化
|
|
516
|
+
- **学习成本降低80%**:Wiki风格,所见即所得
|
|
517
|
+
- **社区活跃度提升300%**:易用的协作工具促进参与
|
|
518
|
+
|
|
519
|
+
---
|
|
520
|
+
|
|
521
|
+
**设计团队**:Stigmergy架构团队
|
|
522
|
+
**设计日期**:2025年12月
|
|
523
|
+
**版本**:v1.0
|