stigmergy 1.0.94 → 1.0.95
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/bin/stigmergy +26 -12
- package/docs/HASH_TABLE.md +83 -0
- package/docs/WEATHER_PROCESSOR_API.md +230 -0
- package/docs/best_practices.md +135 -0
- package/docs/development_guidelines.md +392 -0
- package/docs/requirements_specification.md +148 -0
- package/docs/system_design.md +314 -0
- package/docs/tdd_implementation_plan.md +384 -0
- package/docs/test_report.md +49 -0
- package/examples/calculator-example.js +72 -0
- package/examples/json-validation-example.js +64 -0
- package/examples/rest-client-example.js +52 -0
- package/package.json +21 -17
- package/scripts/post-deployment-config.js +9 -2
- package/src/auth.js +171 -0
- package/src/auth_command.js +195 -0
- package/src/calculator.js +220 -0
- package/src/core/cli_help_analyzer.js +625 -562
- package/src/core/cli_parameter_handler.js +121 -0
- package/src/core/cli_tools.js +89 -0
- package/src/core/error_handler.js +307 -0
- package/src/core/memory_manager.js +76 -0
- package/src/core/smart_router.js +133 -0
- package/src/deploy.js +50 -0
- package/src/main_english.js +642 -719
- package/src/main_fixed.js +1035 -0
- package/src/utils.js +529 -0
- package/src/weatherProcessor.js +205 -0
- package/test/calculator.test.js +215 -0
- package/test/collision-test.js +26 -0
- package/test/csv-processing-test.js +36 -0
- package/test/e2e/claude-cli-test.js +128 -0
- package/test/e2e/collaboration-test.js +75 -0
- package/test/e2e/comprehensive-test.js +431 -0
- package/test/e2e/error-handling-test.js +90 -0
- package/test/e2e/individual-tool-test.js +143 -0
- package/test/e2e/other-cli-test.js +130 -0
- package/test/e2e/qoder-cli-test.js +128 -0
- package/test/e2e/run-e2e-tests.js +73 -0
- package/test/e2e/test-data.js +88 -0
- package/test/e2e/test-utils.js +222 -0
- package/test/hash-table-demo.js +33 -0
- package/test/hash-table-test.js +26 -0
- package/test/json-validation-test.js +164 -0
- package/test/rest-client-test.js +56 -0
- package/test/unit/calculator-full.test.js +191 -0
- package/test/unit/calculator-simple.test.js +96 -0
- package/test/unit/calculator.test.js +97 -0
- package/test/unit/cli_parameter_handler.test.js +116 -0
- package/test/weather-processor.test.js +104 -0
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
# Stigmergy CLI 开发规范
|
|
2
|
+
|
|
3
|
+
## 1. 代码风格规范
|
|
4
|
+
|
|
5
|
+
### 1.1 命名规范
|
|
6
|
+
- **变量命名**:使用camelCase,如`userName`, `cliPatterns`
|
|
7
|
+
- **常量命名**:使用UPPER_SNAKE_CASE,如`MAX_RETRY_COUNT`, `DEFAULT_TOOL`
|
|
8
|
+
- **函数命名**:使用camelCase,如`analyzeCLI`, `getCLIPattern`
|
|
9
|
+
- **类命名**:使用PascalCase,如`SmartRouter`, `MemoryManager`
|
|
10
|
+
- **文件命名**:使用snake_case,如`smart_router.js`, `cli_help_analyzer.js`
|
|
11
|
+
|
|
12
|
+
### 1.2 注释规范
|
|
13
|
+
```javascript
|
|
14
|
+
/**
|
|
15
|
+
* 智能路由类
|
|
16
|
+
* 负责根据用户输入将请求路由到合适的CLI工具
|
|
17
|
+
*/
|
|
18
|
+
class SmartRouter {
|
|
19
|
+
/**
|
|
20
|
+
* 初始化智能路由
|
|
21
|
+
* @returns {Promise<void>}
|
|
22
|
+
*/
|
|
23
|
+
async initialize() {
|
|
24
|
+
// 实现初始化逻辑
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 智能路由决策
|
|
29
|
+
* @param {string} userInput - 用户输入
|
|
30
|
+
* @returns {Promise<Object>} 路由结果
|
|
31
|
+
*/
|
|
32
|
+
async smartRoute(userInput) {
|
|
33
|
+
// 实现路由逻辑
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 1.3 错误处理规范
|
|
39
|
+
```javascript
|
|
40
|
+
try {
|
|
41
|
+
const result = await someAsyncOperation();
|
|
42
|
+
return result;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
// 记录错误日志
|
|
45
|
+
console.error(`[ERROR] Operation failed: ${error.message}`, error);
|
|
46
|
+
|
|
47
|
+
// 抛出自定义错误或返回默认值
|
|
48
|
+
throw new Error(`Operation failed: ${error.message}`);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 2. 模块设计规范
|
|
53
|
+
|
|
54
|
+
### 2.1 模块结构
|
|
55
|
+
```
|
|
56
|
+
src/
|
|
57
|
+
├── core/ # 核心模块
|
|
58
|
+
│ ├── smart_router.js # 智能路由
|
|
59
|
+
│ ├── cli_help_analyzer.js # CLI帮助分析器
|
|
60
|
+
│ └── memory_manager.js # 内存管理器
|
|
61
|
+
├── adapters/ # 适配器模块
|
|
62
|
+
│ └── [tool_name]/ # 各工具适配器
|
|
63
|
+
├── utils/ # 工具模块
|
|
64
|
+
└── main_english.js # 主入口文件
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 2.2 模块导出规范
|
|
68
|
+
```javascript
|
|
69
|
+
// smart_router.js
|
|
70
|
+
class SmartRouter {
|
|
71
|
+
// 类实现
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// 导出类和重要函数
|
|
75
|
+
module.exports = SmartRouter;
|
|
76
|
+
|
|
77
|
+
// 或者导出多个项
|
|
78
|
+
module.exports = {
|
|
79
|
+
SmartRouter,
|
|
80
|
+
someUtilityFunction
|
|
81
|
+
};
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## 3. 异步编程规范
|
|
85
|
+
|
|
86
|
+
### 3.1 Promise使用
|
|
87
|
+
```javascript
|
|
88
|
+
// 推荐:使用async/await
|
|
89
|
+
async function processData() {
|
|
90
|
+
try {
|
|
91
|
+
const result = await fetchData();
|
|
92
|
+
return await processResult(result);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
throw new Error(`Processing failed: ${error.message}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// 避免:回调地狱
|
|
99
|
+
// 不推荐嵌套过多的Promise链
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### 3.2 错误边界处理
|
|
103
|
+
```javascript
|
|
104
|
+
async function robustOperation() {
|
|
105
|
+
const maxRetries = 3;
|
|
106
|
+
let lastError;
|
|
107
|
+
|
|
108
|
+
for (let i = 0; i < maxRetries; i++) {
|
|
109
|
+
try {
|
|
110
|
+
return await riskyOperation();
|
|
111
|
+
} catch (error) {
|
|
112
|
+
lastError = error;
|
|
113
|
+
if (i < maxRetries - 1) {
|
|
114
|
+
// 重试前等待
|
|
115
|
+
await new Promise(resolve => setTimeout(resolve, 1000 * (i + 1)));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
throw new Error(`Operation failed after ${maxRetries} retries: ${lastError.message}`);
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## 4. 文件操作规范
|
|
125
|
+
|
|
126
|
+
### 4.1 异步文件操作
|
|
127
|
+
```javascript
|
|
128
|
+
const fs = require('fs/promises');
|
|
129
|
+
|
|
130
|
+
// 推荐:使用fs/promises
|
|
131
|
+
async function readFileAsync(filePath) {
|
|
132
|
+
try {
|
|
133
|
+
const data = await fs.readFile(filePath, 'utf8');
|
|
134
|
+
return data;
|
|
135
|
+
} catch (error) {
|
|
136
|
+
if (error.code === 'ENOENT') {
|
|
137
|
+
throw new Error(`File not found: ${filePath}`);
|
|
138
|
+
}
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// 避免:使用同步方法
|
|
144
|
+
// const data = fs.readFileSync(filePath, 'utf8'); // 不推荐
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### 4.2 路径处理
|
|
148
|
+
```javascript
|
|
149
|
+
const path = require('path');
|
|
150
|
+
|
|
151
|
+
// 推荐:使用path模块处理路径
|
|
152
|
+
const configPath = path.join(os.homedir(), '.stigmergy', 'config.json');
|
|
153
|
+
|
|
154
|
+
// 避免:字符串拼接路径
|
|
155
|
+
// const configPath = os.homedir() + '/.stigmergy/config.json'; // 不推荐
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## 5. 环境变量规范
|
|
159
|
+
|
|
160
|
+
### 5.1 环境变量使用
|
|
161
|
+
```javascript
|
|
162
|
+
// 推荐:使用解构赋值和默认值
|
|
163
|
+
const {
|
|
164
|
+
STIGMERGY_ENABLED = 'true',
|
|
165
|
+
STIGMERGY_VERSION = '1.0.0',
|
|
166
|
+
NODE_ENV = 'development'
|
|
167
|
+
} = process.env;
|
|
168
|
+
|
|
169
|
+
// 避免:直接访问process.env
|
|
170
|
+
// if (process.env.STIGMERGY_ENABLED === 'true') // 不推荐
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### 5.2 配置管理
|
|
174
|
+
```javascript
|
|
175
|
+
class ConfigManager {
|
|
176
|
+
constructor() {
|
|
177
|
+
this.config = {
|
|
178
|
+
enabled: process.env.STIGMERGY_ENABLED === 'true',
|
|
179
|
+
version: process.env.STIGMERGY_VERSION || '1.0.0',
|
|
180
|
+
debug: process.env.NODE_ENV === 'development'
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
get(key) {
|
|
185
|
+
return this.config[key];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
set(key, value) {
|
|
189
|
+
this.config[key] = value;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## 6. 日志规范
|
|
195
|
+
|
|
196
|
+
### 6.1 日志级别
|
|
197
|
+
```javascript
|
|
198
|
+
const LOG_LEVELS = {
|
|
199
|
+
ERROR: 0,
|
|
200
|
+
WARN: 1,
|
|
201
|
+
INFO: 2,
|
|
202
|
+
DEBUG: 3
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
class Logger {
|
|
206
|
+
constructor(level = LOG_LEVELS.INFO) {
|
|
207
|
+
this.level = level;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
error(message, error) {
|
|
211
|
+
if (this.level >= LOG_LEVELS.ERROR) {
|
|
212
|
+
console.error(`[ERROR] ${message}`, error);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
warn(message) {
|
|
217
|
+
if (this.level >= LOG_LEVELS.WARN) {
|
|
218
|
+
console.warn(`[WARN] ${message}`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
info(message) {
|
|
223
|
+
if (this.level >= LOG_LEVELS.INFO) {
|
|
224
|
+
console.log(`[INFO] ${message}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
debug(message) {
|
|
229
|
+
if (this.level >= LOG_LEVELS.DEBUG) {
|
|
230
|
+
console.log(`[DEBUG] ${message}`);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### 6.2 日志格式
|
|
237
|
+
```javascript
|
|
238
|
+
// 统一日志格式
|
|
239
|
+
[LEVEL] TIMESTAMP MESSAGE [CONTEXT]
|
|
240
|
+
|
|
241
|
+
// 示例
|
|
242
|
+
[INFO] 2023-12-08T10:30:00.000Z CLI tool analysis completed [claude]
|
|
243
|
+
[ERROR] 2023-12-08T10:30:01.000Z Failed to execute command [qwen]
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## 7. 测试规范
|
|
247
|
+
|
|
248
|
+
### 7.1 测试文件命名
|
|
249
|
+
- 单元测试:`*.test.js`
|
|
250
|
+
- 集成测试:`*.integration.test.js`
|
|
251
|
+
- 端到端测试:`*.e2e.test.js`
|
|
252
|
+
|
|
253
|
+
### 7.2 测试结构
|
|
254
|
+
```javascript
|
|
255
|
+
describe('ModuleName', () => {
|
|
256
|
+
let instance;
|
|
257
|
+
|
|
258
|
+
beforeEach(() => {
|
|
259
|
+
instance = new ModuleName();
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
afterEach(() => {
|
|
263
|
+
// 清理资源
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
describe('methodName', () => {
|
|
267
|
+
test('should do something when condition', async () => {
|
|
268
|
+
// 准备测试数据
|
|
269
|
+
|
|
270
|
+
// 执行测试
|
|
271
|
+
|
|
272
|
+
// 验证结果
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## 8. 安全规范
|
|
279
|
+
|
|
280
|
+
### 8.1 输入验证
|
|
281
|
+
```javascript
|
|
282
|
+
function validateInput(input) {
|
|
283
|
+
if (typeof input !== 'string') {
|
|
284
|
+
throw new TypeError('Input must be a string');
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
if (input.length > 10000) {
|
|
288
|
+
throw new Error('Input too long');
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// 检查危险字符
|
|
292
|
+
if (/[;&|`$<>]/.test(input)) {
|
|
293
|
+
throw new Error('Invalid characters in input');
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
return input.trim();
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### 8.2 命令执行安全
|
|
301
|
+
```javascript
|
|
302
|
+
const { spawn } = require('child_process');
|
|
303
|
+
|
|
304
|
+
function safeExecuteCommand(command, args = []) {
|
|
305
|
+
// 验证命令和参数
|
|
306
|
+
if (!command || typeof command !== 'string') {
|
|
307
|
+
throw new Error('Invalid command');
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// 过滤参数中的危险字符
|
|
311
|
+
const safeArgs = args.filter(arg =>
|
|
312
|
+
typeof arg === 'string' && !/[;&|`$<>]/.test(arg)
|
|
313
|
+
);
|
|
314
|
+
|
|
315
|
+
// 使用spawn而不是exec
|
|
316
|
+
return spawn(command, safeArgs, {
|
|
317
|
+
stdio: 'inherit',
|
|
318
|
+
shell: false // 避免shell注入
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## 9. 性能规范
|
|
324
|
+
|
|
325
|
+
### 9.1 内存管理
|
|
326
|
+
```javascript
|
|
327
|
+
// 及时释放大对象引用
|
|
328
|
+
function processData(largeData) {
|
|
329
|
+
try {
|
|
330
|
+
// 处理数据
|
|
331
|
+
return processResult(largeData);
|
|
332
|
+
} finally {
|
|
333
|
+
// 清理大对象
|
|
334
|
+
largeData = null;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// 使用流处理大文件
|
|
339
|
+
const fs = require('fs');
|
|
340
|
+
const { pipeline } = require('stream/promises');
|
|
341
|
+
|
|
342
|
+
async function processLargeFile(inputPath, outputPath) {
|
|
343
|
+
const readStream = fs.createReadStream(inputPath);
|
|
344
|
+
const writeStream = fs.createWriteStream(outputPath);
|
|
345
|
+
|
|
346
|
+
await pipeline(
|
|
347
|
+
readStream,
|
|
348
|
+
transformStream,
|
|
349
|
+
writeStream
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### 9.2 缓存策略
|
|
355
|
+
```javascript
|
|
356
|
+
class CacheManager {
|
|
357
|
+
constructor() {
|
|
358
|
+
this.cache = new Map();
|
|
359
|
+
this.ttl = 24 * 60 * 60 * 1000; // 24小时
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
get(key) {
|
|
363
|
+
const item = this.cache.get(key);
|
|
364
|
+
if (!item) return null;
|
|
365
|
+
|
|
366
|
+
if (Date.now() - item.timestamp > this.ttl) {
|
|
367
|
+
this.cache.delete(key);
|
|
368
|
+
return null;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
return item.value;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
set(key, value) {
|
|
375
|
+
this.cache.set(key, {
|
|
376
|
+
value,
|
|
377
|
+
timestamp: Date.now()
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
cleanup() {
|
|
382
|
+
const now = Date.now();
|
|
383
|
+
for (const [key, item] of this.cache.entries()) {
|
|
384
|
+
if (now - item.timestamp > this.ttl) {
|
|
385
|
+
this.cache.delete(key);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
遵循这些开发规范可以确保代码质量、可维护性和团队协作效率。
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Stigmergy CLI 系统需求规格说明书
|
|
2
|
+
|
|
3
|
+
## 1. 引言
|
|
4
|
+
|
|
5
|
+
### 1.1 目的
|
|
6
|
+
本文档定义了Stigmergy CLI多智能体协作系统的功能需求和非功能需求,确保系统能够为用户提供高效的AI CLI工具协作体验。
|
|
7
|
+
|
|
8
|
+
### 1.2 范围
|
|
9
|
+
本系统旨在提供一个基础支撑平台,让用户能够自由决定如何使用各种AI CLI工具进行分工和协作,同时确保各工具间能够有效传递上下文信息。
|
|
10
|
+
|
|
11
|
+
### 1.3 核心理念
|
|
12
|
+
- 用户主导:用户决定如何分工和协同
|
|
13
|
+
- CLI自主:各CLI工具自主决定调用其他工具
|
|
14
|
+
- 系统支撑:项目只提供基础支撑和上下文传递机制
|
|
15
|
+
|
|
16
|
+
## 2. 总体描述
|
|
17
|
+
|
|
18
|
+
### 2.1 产品概述
|
|
19
|
+
Stigmergy CLI是一个多智能体AI CLI工具协作系统,支持多种AI CLI工具(如Claude、Qwen、Gemini等)在同一项目环境中协同工作。
|
|
20
|
+
|
|
21
|
+
### 2.2 产品功能
|
|
22
|
+
- 智能路由:基于用户输入将请求路由到合适的CLI工具
|
|
23
|
+
- 上下文管理:维护和传递项目上下文信息
|
|
24
|
+
- 状态共享:提供全局内存管理机制
|
|
25
|
+
- CLI模式分析:分析和缓存CLI工具的使用模式
|
|
26
|
+
|
|
27
|
+
### 2.3 用户特征
|
|
28
|
+
- AI开发者和研究人员
|
|
29
|
+
- 需要使用多个AI工具协同工作的技术人员
|
|
30
|
+
- 希望简化多CLI工具管理的用户
|
|
31
|
+
|
|
32
|
+
### 2.4 运行环境
|
|
33
|
+
- Node.js >= 16.0.0
|
|
34
|
+
- 支持Windows、macOS和Linux操作系统
|
|
35
|
+
- 需要安装各种AI CLI工具
|
|
36
|
+
|
|
37
|
+
## 3. 功能需求
|
|
38
|
+
|
|
39
|
+
### 3.1 智能路由系统 (FR-001)
|
|
40
|
+
|
|
41
|
+
#### 3.1.1 基础路由功能
|
|
42
|
+
**描述**:系统应能根据用户输入的关键字识别目标CLI工具并转发请求。
|
|
43
|
+
**优先级**:高
|
|
44
|
+
**输入**:用户输入的自然语言指令
|
|
45
|
+
**处理**:
|
|
46
|
+
1. 解析用户输入,识别CLI工具关键字
|
|
47
|
+
2. 提取目标工具后的指令内容
|
|
48
|
+
3. 将指令转发到相应CLI工具
|
|
49
|
+
**输出**:CLI工具的执行结果
|
|
50
|
+
|
|
51
|
+
#### 3.1.2 默认路由功能
|
|
52
|
+
**描述**:当无法识别特定CLI工具时,系统应能将请求路由到默认工具。
|
|
53
|
+
**优先级**:高
|
|
54
|
+
**输入**:无法明确识别CLI工具的用户输入
|
|
55
|
+
**处理**:
|
|
56
|
+
1. 检查用户输入是否包含已知CLI工具关键字
|
|
57
|
+
2. 如果未找到匹配,使用默认CLI工具
|
|
58
|
+
**输出**:默认CLI工具的执行结果
|
|
59
|
+
|
|
60
|
+
### 3.2 上下文管理系统 (FR-002)
|
|
61
|
+
|
|
62
|
+
#### 3.2.1 环境变量传递
|
|
63
|
+
**描述**:系统应在执行CLI工具时传递必要的环境变量。
|
|
64
|
+
**优先级**:高
|
|
65
|
+
**输入**:CLI工具名称和执行参数
|
|
66
|
+
**处理**:
|
|
67
|
+
1. 设置标准环境变量(项目目录、上下文文件路径等)
|
|
68
|
+
2. 执行CLI工具并传递环境变量
|
|
69
|
+
**输出**:带有环境变量的CLI工具执行
|
|
70
|
+
|
|
71
|
+
#### 3.2.2 全局内存管理
|
|
72
|
+
**描述**:系统应提供全局内存文件供各CLI工具读写共享状态。
|
|
73
|
+
**优先级**:高
|
|
74
|
+
**输入**:内存读写请求
|
|
75
|
+
**处理**:
|
|
76
|
+
1. 提供内存读取接口
|
|
77
|
+
2. 提供内存更新接口
|
|
78
|
+
3. 确保并发安全
|
|
79
|
+
**输出**:内存数据或更新确认
|
|
80
|
+
|
|
81
|
+
### 3.3 CLI模式分析系统 (FR-003)
|
|
82
|
+
|
|
83
|
+
#### 3.3.1 CLI帮助信息分析
|
|
84
|
+
**描述**:系统应能分析CLI工具的帮助信息并缓存模式。
|
|
85
|
+
**优先级**:中
|
|
86
|
+
**输入**:CLI工具名称
|
|
87
|
+
**处理**:
|
|
88
|
+
1. 执行CLI工具的帮助命令
|
|
89
|
+
2. 解析帮助信息提取命令模式
|
|
90
|
+
3. 缓存分析结果
|
|
91
|
+
**输出**:CLI工具模式信息
|
|
92
|
+
|
|
93
|
+
#### 3.3.2 模式缓存管理
|
|
94
|
+
**描述**:系统应能管理和更新CLI模式缓存。
|
|
95
|
+
**优先级**:中
|
|
96
|
+
**输入**:缓存管理请求
|
|
97
|
+
**处理**:
|
|
98
|
+
1. 检查缓存有效性
|
|
99
|
+
2. 更新过期缓存
|
|
100
|
+
3. 处理缓存失效情况
|
|
101
|
+
**输出**:缓存状态信息
|
|
102
|
+
|
|
103
|
+
## 4. 非功能需求
|
|
104
|
+
|
|
105
|
+
### 4.1 性能需求
|
|
106
|
+
- CLI工具路由延迟应小于100ms
|
|
107
|
+
- 内存读写操作应小于50ms
|
|
108
|
+
- CLI模式分析应在5秒内完成
|
|
109
|
+
|
|
110
|
+
### 4.2 可靠性需求
|
|
111
|
+
- 系统应能处理CLI工具执行失败的情况
|
|
112
|
+
- 系统应提供错误恢复机制
|
|
113
|
+
- 系统应保证内存数据的一致性
|
|
114
|
+
|
|
115
|
+
### 4.3 可用性需求
|
|
116
|
+
- 系统应提供清晰的错误提示信息
|
|
117
|
+
- 系统应支持命令行帮助信息
|
|
118
|
+
- 系统应提供详细的日志记录
|
|
119
|
+
|
|
120
|
+
### 4.4 安全性需求
|
|
121
|
+
- 系统不应执行危险的系统命令
|
|
122
|
+
- 系统应保护敏感的环境变量
|
|
123
|
+
- 系统应防止未经授权的内存访问
|
|
124
|
+
|
|
125
|
+
## 5. 外部接口需求
|
|
126
|
+
|
|
127
|
+
### 5.1 用户界面
|
|
128
|
+
- 命令行界面(CLI)
|
|
129
|
+
- 标准输入输出流
|
|
130
|
+
|
|
131
|
+
### 5.2 硬件接口
|
|
132
|
+
- 标准计算机硬件
|
|
133
|
+
- 网络连接(用于CLI工具通信)
|
|
134
|
+
|
|
135
|
+
### 5.3 软件接口
|
|
136
|
+
- Node.js运行时环境
|
|
137
|
+
- 各种AI CLI工具
|
|
138
|
+
- 文件系统API
|
|
139
|
+
|
|
140
|
+
## 6. 其他需求
|
|
141
|
+
|
|
142
|
+
### 6.1 国际化需求
|
|
143
|
+
- 支持英文环境
|
|
144
|
+
- 支持UTF-8编码
|
|
145
|
+
|
|
146
|
+
### 6.2 可扩展性需求
|
|
147
|
+
- 支持新增CLI工具
|
|
148
|
+
- 支持插件化扩展
|