stigmergy 1.0.93 → 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/bin/stigmergy.cmd +1 -1
- 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 +643 -720
- 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
package/bin/stigmergy
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
#!/bin/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Cross-platform launcher for Stigmergy CLI
|
|
4
|
+
// This replaces the problematic shell script to ensure Windows compatibility
|
|
5
|
+
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const { spawn } = require('child_process');
|
|
8
|
+
|
|
9
|
+
// Get the path to the main script
|
|
10
|
+
const mainScript = path.join(__dirname, '..', 'src', 'main_english.js');
|
|
11
|
+
|
|
12
|
+
// Spawn the Node.js process with the main script and all arguments
|
|
13
|
+
const child = spawn(process.execPath, [mainScript, ...process.argv.slice(2)], {
|
|
14
|
+
stdio: 'inherit'
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// Forward exit code
|
|
18
|
+
child.on('close', (code) => {
|
|
19
|
+
process.exit(code);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Handle errors
|
|
23
|
+
child.on('error', (error) => {
|
|
24
|
+
console.error('[ERROR] Failed to start Stigmergy CLI:', error.message);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
});
|
package/bin/stigmergy.cmd
CHANGED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Hash Table Data Structure
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This project includes a HashTable implementation with collision handling using chaining. The implementation is part of the utility functions in `src/utils.js`.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Hash Function**: Uses a prime-based hashing algorithm for better distribution
|
|
10
|
+
- **Collision Handling**: Implements chaining to handle hash collisions
|
|
11
|
+
- **Key Operations**:
|
|
12
|
+
- `set(key, value)`: Insert a key-value pair
|
|
13
|
+
- `get(key)`: Retrieve a value by key
|
|
14
|
+
- `keys()`: Get all keys in the hash table
|
|
15
|
+
- `values()`: Get all values in the hash table
|
|
16
|
+
|
|
17
|
+
## Implementation Details
|
|
18
|
+
|
|
19
|
+
### Hash Function
|
|
20
|
+
|
|
21
|
+
The hash function uses a prime number (31) to reduce collisions:
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
_hash(key) {
|
|
25
|
+
let total = 0;
|
|
26
|
+
const WEIRD_PRIME = 31;
|
|
27
|
+
for (let i = 0; i < Math.min(key.length, 100); i++) {
|
|
28
|
+
const char = key[i];
|
|
29
|
+
const value = char.charCodeAt(0) - 96;
|
|
30
|
+
total = (total * WEIRD_PRIME + value) % this.keyMap.length;
|
|
31
|
+
}
|
|
32
|
+
return total;
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Collision Handling
|
|
37
|
+
|
|
38
|
+
Collisions are handled using chaining - when two keys hash to the same index, they are stored in an array at that index:
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
set(key, value) {
|
|
42
|
+
const index = this._hash(key);
|
|
43
|
+
if (!this.keyMap[index]) {
|
|
44
|
+
this.keyMap[index] = [];
|
|
45
|
+
}
|
|
46
|
+
this.keyMap[index].push([key, value]);
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Usage
|
|
52
|
+
|
|
53
|
+
```javascript
|
|
54
|
+
const { HashTable } = require('./src/utils');
|
|
55
|
+
|
|
56
|
+
// Create a new hash table
|
|
57
|
+
const ht = new HashTable(17);
|
|
58
|
+
|
|
59
|
+
// Set key-value pairs
|
|
60
|
+
ht.set("maroon", "#800000");
|
|
61
|
+
ht.set("yellow", "#FFFF00");
|
|
62
|
+
|
|
63
|
+
// Get values
|
|
64
|
+
console.log(ht.get("maroon")); // #800000
|
|
65
|
+
|
|
66
|
+
// Get all keys/values
|
|
67
|
+
console.log(ht.keys());
|
|
68
|
+
console.log(ht.values());
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Time Complexity
|
|
72
|
+
|
|
73
|
+
- **Insertion**: O(1) average case, O(n) worst case
|
|
74
|
+
- **Lookup**: O(1) average case, O(n) worst case
|
|
75
|
+
- **Deletion**: O(1) average case, O(n) worst case
|
|
76
|
+
|
|
77
|
+
The worst case occurs when all elements hash to the same index, creating a single long chain.
|
|
78
|
+
|
|
79
|
+
## Test Files
|
|
80
|
+
|
|
81
|
+
- `test/hash-table-test.js`: Basic functionality tests
|
|
82
|
+
- `test/collision-test.js`: Collision handling demonstration
|
|
83
|
+
- `test/hash-table-demo.js`: Comprehensive usage example
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# Weather Data Processing API
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This module provides functions for processing weather data from various sources and converting it into standardized formats for analysis and display. It handles data from different weather APIs and sensors, normalizing the output for consistent consumption.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
The weather processor is part of the Stigmergy CLI utility functions. No additional installation is required.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
const { processWeatherData } = require('./src/weatherProcessor');
|
|
15
|
+
|
|
16
|
+
// Process raw weather data
|
|
17
|
+
const processedData = processWeatherData(rawWeatherData, {
|
|
18
|
+
unit: 'celsius',
|
|
19
|
+
includeForecasts: true,
|
|
20
|
+
forecastDays: 5
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## API Reference
|
|
25
|
+
|
|
26
|
+
### `processWeatherData(rawData, options)`
|
|
27
|
+
|
|
28
|
+
Processes raw weather data and generates standardized output.
|
|
29
|
+
|
|
30
|
+
#### Parameters
|
|
31
|
+
|
|
32
|
+
| Parameter | Type | Description |
|
|
33
|
+
|-----------|------|-------------|
|
|
34
|
+
| `rawData` | Object | Raw weather data from API or sensor |
|
|
35
|
+
| `options` | Object | Processing options |
|
|
36
|
+
|
|
37
|
+
##### Options
|
|
38
|
+
|
|
39
|
+
| Option | Type | Default | Description |
|
|
40
|
+
|--------|------|---------|-------------|
|
|
41
|
+
| `unit` | string | `'celsius'` | Temperature unit (`'celsius'`, `'fahrenheit'`, `'kelvin'`) |
|
|
42
|
+
| `includeForecasts` | boolean | `false` | Whether to include forecast data |
|
|
43
|
+
| `forecastDays` | number | `5` | Number of forecast days to include (1-7) |
|
|
44
|
+
|
|
45
|
+
#### Returns
|
|
46
|
+
|
|
47
|
+
| Type | Description |
|
|
48
|
+
|------|-------------|
|
|
49
|
+
| Object | Processed weather data with standardized format |
|
|
50
|
+
|
|
51
|
+
#### Throws
|
|
52
|
+
|
|
53
|
+
- `Error`: If input data is invalid or missing required fields
|
|
54
|
+
- `Error`: If unit option is invalid
|
|
55
|
+
- `Error`: If forecastDays is outside the valid range (1-7)
|
|
56
|
+
|
|
57
|
+
#### Example
|
|
58
|
+
|
|
59
|
+
```javascript
|
|
60
|
+
const rawData = {
|
|
61
|
+
location: {
|
|
62
|
+
name: "London",
|
|
63
|
+
country: "UK",
|
|
64
|
+
lat: 51.5074,
|
|
65
|
+
lon: -0.1278
|
|
66
|
+
},
|
|
67
|
+
current: {
|
|
68
|
+
temp: 285.15,
|
|
69
|
+
feels_like: 283.15,
|
|
70
|
+
humidity: 72,
|
|
71
|
+
pressure: 1013,
|
|
72
|
+
wind_speed: 3.5,
|
|
73
|
+
wind_deg: 180,
|
|
74
|
+
visibility: 10000,
|
|
75
|
+
clouds: 40,
|
|
76
|
+
weather: [{
|
|
77
|
+
description: "scattered clouds",
|
|
78
|
+
icon: "03d"
|
|
79
|
+
}]
|
|
80
|
+
},
|
|
81
|
+
forecast: [
|
|
82
|
+
{
|
|
83
|
+
dt: 1640995200,
|
|
84
|
+
temp: { min: 282.15, max: 286.15 },
|
|
85
|
+
humidity: 65,
|
|
86
|
+
pressure: 1015,
|
|
87
|
+
wind_speed: 2.8,
|
|
88
|
+
wind_deg: 160,
|
|
89
|
+
pop: 0.2,
|
|
90
|
+
weather: [{ description: "light rain" }]
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const processedData = processWeatherData(rawData, {
|
|
96
|
+
unit: 'celsius',
|
|
97
|
+
includeForecasts: true,
|
|
98
|
+
forecastDays: 3
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Returns:
|
|
102
|
+
// {
|
|
103
|
+
// timestamp: "2025-12-08T10:30:00.000Z",
|
|
104
|
+
// location: {
|
|
105
|
+
// name: "London",
|
|
106
|
+
// country: "UK",
|
|
107
|
+
// coordinates: { lat: 51.5074, lon: -0.1278 }
|
|
108
|
+
// },
|
|
109
|
+
// current: {
|
|
110
|
+
// temperature: { value: 12, unit: "celsius", feelsLike: 10 },
|
|
111
|
+
// humidity: 72,
|
|
112
|
+
// pressure: 1013,
|
|
113
|
+
// wind: { speed: 3.5, direction: 180 },
|
|
114
|
+
// visibility: 10000,
|
|
115
|
+
// cloudiness: 40,
|
|
116
|
+
// description: "scattered clouds",
|
|
117
|
+
// icon: "03d"
|
|
118
|
+
// },
|
|
119
|
+
// forecasts: [
|
|
120
|
+
// {
|
|
121
|
+
// date: "2022-01-01",
|
|
122
|
+
// temperature: { min: 9, max: 13, unit: "celsius" },
|
|
123
|
+
// humidity: 65,
|
|
124
|
+
// pressure: 1015,
|
|
125
|
+
// wind: { speed: 2.8, direction: 160 },
|
|
126
|
+
// precipitation: { probability: 0.2, amount: 0 },
|
|
127
|
+
// description: "light rain"
|
|
128
|
+
// }
|
|
129
|
+
// ]
|
|
130
|
+
// }
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Data Structures
|
|
134
|
+
|
|
135
|
+
### Processed Weather Data
|
|
136
|
+
|
|
137
|
+
The returned object has the following structure:
|
|
138
|
+
|
|
139
|
+
```javascript
|
|
140
|
+
{
|
|
141
|
+
timestamp: string, // ISO timestamp of processing
|
|
142
|
+
location: {
|
|
143
|
+
name: string, // Location name
|
|
144
|
+
country: string, // Country code
|
|
145
|
+
coordinates: {
|
|
146
|
+
lat: number, // Latitude
|
|
147
|
+
lon: number // Longitude
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
current: {
|
|
151
|
+
temperature: {
|
|
152
|
+
value: number, // Temperature value
|
|
153
|
+
unit: string, // Temperature unit
|
|
154
|
+
feelsLike: number // "Feels like" temperature
|
|
155
|
+
},
|
|
156
|
+
humidity: number, // Humidity percentage (0-100)
|
|
157
|
+
pressure: number, // Atmospheric pressure in hPa
|
|
158
|
+
wind: {
|
|
159
|
+
speed: number, // Wind speed
|
|
160
|
+
direction: number // Wind direction in degrees
|
|
161
|
+
},
|
|
162
|
+
visibility: number, // Visibility in meters
|
|
163
|
+
cloudiness: number, // Cloud cover percentage (0-100)
|
|
164
|
+
description: string, // Weather description
|
|
165
|
+
icon: string // Weather icon code
|
|
166
|
+
},
|
|
167
|
+
forecasts: [ // Array of forecast objects (if enabled)
|
|
168
|
+
{
|
|
169
|
+
date: string, // Forecast date (YYYY-MM-DD)
|
|
170
|
+
temperature: {
|
|
171
|
+
min: number, // Minimum temperature
|
|
172
|
+
max: number, // Maximum temperature
|
|
173
|
+
unit: string // Temperature unit
|
|
174
|
+
},
|
|
175
|
+
humidity: number, // Humidity percentage
|
|
176
|
+
pressure: number, // Atmospheric pressure in hPa
|
|
177
|
+
wind: {
|
|
178
|
+
speed: number, // Wind speed
|
|
179
|
+
direction: number // Wind direction in degrees
|
|
180
|
+
},
|
|
181
|
+
precipitation: {
|
|
182
|
+
probability: number, // Precipitation probability (0-1)
|
|
183
|
+
amount: number // Precipitation amount
|
|
184
|
+
},
|
|
185
|
+
description: string // Weather description
|
|
186
|
+
}
|
|
187
|
+
]
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Supported Data Sources
|
|
192
|
+
|
|
193
|
+
The processor can handle data from various weather services including:
|
|
194
|
+
- OpenWeatherMap
|
|
195
|
+
- WeatherAPI
|
|
196
|
+
- AccuWeather
|
|
197
|
+
- National Weather Service
|
|
198
|
+
- Custom sensor data
|
|
199
|
+
|
|
200
|
+
## Error Handling
|
|
201
|
+
|
|
202
|
+
The function validates input data and throws descriptive errors for:
|
|
203
|
+
- Invalid input data types
|
|
204
|
+
- Missing required fields
|
|
205
|
+
- Invalid configuration options
|
|
206
|
+
|
|
207
|
+
Always wrap calls in try-catch blocks for production code:
|
|
208
|
+
|
|
209
|
+
```javascript
|
|
210
|
+
try {
|
|
211
|
+
const weatherData = processWeatherData(rawData, options);
|
|
212
|
+
// Process weather data
|
|
213
|
+
} catch (error) {
|
|
214
|
+
console.error('Failed to process weather data:', error.message);
|
|
215
|
+
// Handle error appropriately
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Testing
|
|
220
|
+
|
|
221
|
+
Unit tests are available in `test/weather-processor.test.js` and can be run with:
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
npm test -- test/weather-processor.test.js
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Related Modules
|
|
228
|
+
|
|
229
|
+
- `src/utils.js`: Contains utility functions used by the weather processor
|
|
230
|
+
- `src/adapters/`: Contains API-specific adapters for different weather services
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Stigmergy CLI 最佳实践规范
|
|
2
|
+
|
|
3
|
+
## 项目核心理念
|
|
4
|
+
|
|
5
|
+
### 核心原则
|
|
6
|
+
1. **用户主导**:用户决定如何分工和协同
|
|
7
|
+
2. **CLI自主**:各CLI工具自主决定调用其他工具
|
|
8
|
+
3. **系统支撑**:项目只提供基础支撑和上下文传递机制
|
|
9
|
+
|
|
10
|
+
## 智能路由系统规范
|
|
11
|
+
|
|
12
|
+
### 基础路由功能
|
|
13
|
+
智能路由系统只负责最基本的关键字识别和CLI转发,不做深度语义分析。
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
// 智能路由只做最基本的关键字识别和CLI转发
|
|
17
|
+
async smartRoute(userInput) {
|
|
18
|
+
const input = userInput.trim();
|
|
19
|
+
|
|
20
|
+
// 简单的关键字匹配,不深度解析语义
|
|
21
|
+
for (const [toolName, toolInfo] of Object.entries(this.tools)) {
|
|
22
|
+
// 只检查工具名称关键字
|
|
23
|
+
if (input.toLowerCase().includes(toolName.toLowerCase())) {
|
|
24
|
+
// 提取工具后的完整指令
|
|
25
|
+
const prompt = input.replace(new RegExp(`.*${toolName}\\s*`, 'gi'), '').trim();
|
|
26
|
+
return { tool: toolName, prompt: prompt || input };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// 默认路由到首选工具
|
|
31
|
+
return { tool: this.defaultTool, prompt: input };
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 上下文传递机制
|
|
36
|
+
系统提供标准化的上下文传递机制,确保各CLI工具能够访问共享状态。
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
// 在执行CLI时传递项目上下文
|
|
40
|
+
async executeCLI(toolName, prompt) {
|
|
41
|
+
// 准备环境变量传递上下文
|
|
42
|
+
const env = {
|
|
43
|
+
...process.env,
|
|
44
|
+
STIGMERGY_CONTEXT: JSON.stringify(this.getCurrentContext()),
|
|
45
|
+
STIGMERGY_PROJECT_DIR: process.cwd(),
|
|
46
|
+
STIGMERGY_MEMORY_FILE: this.memory.globalMemoryFile
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// 执行CLI命令
|
|
50
|
+
const child = spawn(toolName, [prompt], {
|
|
51
|
+
stdio: 'inherit',
|
|
52
|
+
shell: true,
|
|
53
|
+
env: env
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return child;
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 内存和状态共享
|
|
61
|
+
提供全局内存管理机制,供各CLI工具读写共享状态。
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
class MemoryManager {
|
|
65
|
+
// 提供全局内存文件供各CLI读写
|
|
66
|
+
async getGlobalMemory() {
|
|
67
|
+
try {
|
|
68
|
+
const data = await fs.readFile(this.globalMemoryFile, 'utf8');
|
|
69
|
+
return JSON.parse(data);
|
|
70
|
+
} catch {
|
|
71
|
+
return { interactions: [], collaborations: [] };
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async updateGlobalMemory(updateFn) {
|
|
76
|
+
const memory = await this.getGlobalMemory();
|
|
77
|
+
const updatedMemory = updateFn(memory);
|
|
78
|
+
await fs.writeFile(this.globalMemoryFile, JSON.stringify(updatedMemory, null, 2));
|
|
79
|
+
return updatedMemory;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## 系统架构
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
用户输入 → 智能路由 → CLI工具A → (用户决定) → CLI工具B → (用户决定) → CLI工具C
|
|
88
|
+
↓ ↓ ↓ ↓ ↓
|
|
89
|
+
上下文传递 环境变量 用户控制 环境变量 用户控制
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## 系统提供的核心支撑
|
|
93
|
+
|
|
94
|
+
### 标准化接口
|
|
95
|
+
提供给各CLI的标准接口:
|
|
96
|
+
|
|
97
|
+
```javascript
|
|
98
|
+
// 提供给各CLI的标准接口
|
|
99
|
+
const StigmergyAPI = {
|
|
100
|
+
// 获取当前上下文
|
|
101
|
+
getContext: () => this.memory.getGlobalMemory(),
|
|
102
|
+
|
|
103
|
+
// 更新上下文
|
|
104
|
+
updateContext: (updateFn) => this.memory.updateGlobalMemory(updateFn),
|
|
105
|
+
|
|
106
|
+
// 调用其他CLI的标准方法
|
|
107
|
+
callCLI: (toolName, prompt) => this.executeCLI(toolName, prompt),
|
|
108
|
+
|
|
109
|
+
// 获取CLI模式信息
|
|
110
|
+
getCLIPattern: (toolName) => this.analyzer.getCLIPattern(toolName)
|
|
111
|
+
};
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### 环境变量标准化
|
|
115
|
+
系统自动设置的标准环境变量:
|
|
116
|
+
|
|
117
|
+
```javascript
|
|
118
|
+
// 系统自动设置的标准环境变量
|
|
119
|
+
const standardEnv = {
|
|
120
|
+
STIGMERGY_ENABLED: 'true',
|
|
121
|
+
STIGMERGY_VERSION: packageVersion,
|
|
122
|
+
STIGMERGY_PROJECT_DIR: process.cwd(),
|
|
123
|
+
STIGMERGY_CONTEXT_FILE: globalMemoryFile,
|
|
124
|
+
STIGMERGY_CLI_PATTERNS: cliPatternsFile,
|
|
125
|
+
STIGMERGY_TEMP_DIR: tempDir
|
|
126
|
+
};
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## 最佳实践总结
|
|
130
|
+
|
|
131
|
+
1. **保持简单**:智能路由只做最基本的工具识别和转发
|
|
132
|
+
2. **用户至上**:完全由用户和各CLI决定协作流程
|
|
133
|
+
3. **标准支撑**:提供统一的上下文传递和状态管理机制
|
|
134
|
+
4. **透明机制**:各CLI都能访问相同的上下文和历史信息
|
|
135
|
+
5. **灵活扩展**:CLI可以自由决定是否调用其他工具
|