stigmergy 1.1.2 → 1.1.4

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.
@@ -1,59 +1,59 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Stigmergy CLI 简化发布脚本
5
- */
6
-
7
- const { execSync } = 'child_process';
8
- const { readFile } from 'fs/promises';
9
- const { join, dirname } from 'path';
10
- const { fileURLToPath } from 'url';
11
-
12
- const __filename = fileURLToPath(import.meta.url);
13
- const __dirname = dirname(__filename);
14
-
15
- console.log('🚀 Stigmergy CLI 发布工具');
16
-
17
- async function main() {
18
- try {
19
- // 读取package.json
20
- const packagePath = join(__dirname, 'package.json');
21
- const pkg = JSON.parse(await readFile(packagePath, 'utf8'));
22
-
23
- console.log(`📦 包名: ${pkg.name}`);
24
- console.log(`📦 版本: ${pkg.version}`);
25
- console.log(`📦 描述: ${pkg.description}`);
26
-
27
- // 检查必要文件
28
- const requiredFiles = ['src/main.js', 'package.json', 'README.md', 'LICENSE'];
29
- console.log('📍 检查必要文件...');
30
-
31
- for (const file of requiredFiles) {
32
- try {
33
- execSync(`test -f ${file}`, { cwd: __dirname });
34
- console.log(`✅ ${file} 存在`);
35
- } catch {
36
- console.log(`❌ ${file} 不存在`);
37
- throw new Error(`缺少必要文件: ${file}`);
38
- }
39
- }
40
-
41
- // 模拟npm发布
42
- console.log('📤 模拟npm发布...');
43
- console.log('⚠️ 注意: 这是模拟发布,实际发布需要:');
44
- console.log(' 1. npm login');
45
- console.log(' 2. node scripts/simple-publish.js');
46
- console.log(' 3. npm publish');
47
-
48
- console.log('✅ 模拟发布完成!');
49
- console.log('📦 包准备就绪,可以实际发布');
50
-
51
- } catch (error) {
52
- console.error('❌ 发布过程失败:', error.message);
53
- process.exit(1);
54
- }
55
- }
56
-
57
- if (import.meta.url === `file://${process.argv[1]}`) {
58
- main();
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Stigmergy CLI 简化发布脚本
5
+ */
6
+
7
+ const { execSync } = 'child_process';
8
+ const { readFile } from 'fs/promises';
9
+ const { join, dirname } from 'path';
10
+ const { fileURLToPath } from 'url';
11
+
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = dirname(__filename);
14
+
15
+ console.log('🚀 Stigmergy CLI 发布工具');
16
+
17
+ async function main() {
18
+ try {
19
+ // 读取package.json
20
+ const packagePath = join(__dirname, 'package.json');
21
+ const pkg = JSON.parse(await readFile(packagePath, 'utf8'));
22
+
23
+ console.log(`📦 包名: ${pkg.name}`);
24
+ console.log(`📦 版本: ${pkg.version}`);
25
+ console.log(`📦 描述: ${pkg.description}`);
26
+
27
+ // 检查必要文件
28
+ const requiredFiles = ['src/index.js', 'package.json', 'README.md', 'LICENSE'];
29
+ console.log('📍 检查必要文件...');
30
+
31
+ for (const file of requiredFiles) {
32
+ try {
33
+ execSync(`test -f ${file}`, { cwd: __dirname });
34
+ console.log(`✅ ${file} 存在`);
35
+ } catch {
36
+ console.log(`❌ ${file} 不存在`);
37
+ throw new Error(`缺少必要文件: ${file}`);
38
+ }
39
+ }
40
+
41
+ // 模拟npm发布
42
+ console.log('📤 模拟npm发布...');
43
+ console.log('⚠️ 注意: 这是模拟发布,实际发布需要:');
44
+ console.log(' 1. npm login');
45
+ console.log(' 2. node scripts/simple-publish.js');
46
+ console.log(' 3. npm publish');
47
+
48
+ console.log('✅ 模拟发布完成!');
49
+ console.log('📦 包准备就绪,可以实际发布');
50
+
51
+ } catch (error) {
52
+ console.error('❌ 发布过程失败:', error.message);
53
+ process.exit(1);
54
+ }
55
+ }
56
+
57
+ if (import.meta.url === `file://${process.argv[1]}`) {
58
+ main();
59
59
  }
package/src/cli/router.js CHANGED
@@ -61,6 +61,8 @@ async function main() {
61
61
  ' init Initialize Stigmergy configuration (alias for setup)',
62
62
  );
63
63
  console.log(' call "<prompt>" Execute prompt with auto-routed AI CLI');
64
+ console.log(' fibonacci <n> Calculate the nth Fibonacci number');
65
+ console.log(' fibonacci seq <n> Generate the first n Fibonacci numbers');
64
66
  console.log(' errors Display error report and statistics');
65
67
  console.log('');
66
68
  console.log('[WORKFLOW] Automated Workflow:');
@@ -82,17 +84,9 @@ async function main() {
82
84
  switch (command) {
83
85
  case 'version':
84
86
  case '--version': {
85
- // Use the version from configuration instead of hardcoding
86
- const config = {
87
- version: '1.0.94',
88
- initialized: true,
89
- createdAt: new Date().toISOString(),
90
- lastUpdated: new Date().toISOString(),
91
- defaultCLI: 'claude',
92
- enableCrossCLI: true,
93
- enableMemory: true,
94
- };
95
- console.log(`Stigmergy CLI v${config.version}`);
87
+ // Use the version from package.json instead of hardcoding
88
+ const packageJson = require('../../package.json');
89
+ console.log(`Stigmergy CLI v${packageJson.version}`);
96
90
  break;
97
91
  }
98
92
 
@@ -243,6 +237,50 @@ async function main() {
243
237
  break;
244
238
 
245
239
 
240
+ case 'fibonacci': {
241
+ if (args.length < 2) {
242
+ console.log('[ERROR] Please provide a number');
243
+ console.log('Usage: stigmergy fibonacci <n>');
244
+ console.log('Calculates the nth Fibonacci number or generates a sequence of n Fibonacci numbers');
245
+ console.log('Examples:');
246
+ console.log(' stigmergy fibonacci 10 # Calculates the 10th Fibonacci number');
247
+ console.log(' stigmergy fibonacci seq 10 # Generates the first 10 Fibonacci numbers');
248
+ process.exit(1);
249
+ }
250
+
251
+ const Calculator = require('../calculator');
252
+ const calc = new Calculator();
253
+
254
+ try {
255
+ if (args[1] === 'seq' && args.length >= 3) {
256
+ // Generate a sequence of Fibonacci numbers
257
+ const n = parseInt(args[2]);
258
+ if (isNaN(n)) {
259
+ console.log('[ERROR] Invalid number provided');
260
+ process.exit(1);
261
+ }
262
+
263
+ const sequence = calc.fibonacciSequence(n);
264
+ console.log(`First ${n} Fibonacci numbers:`);
265
+ console.log(sequence.join(', '));
266
+ } else {
267
+ // Calculate a single Fibonacci number
268
+ const n = parseInt(args[1]);
269
+ if (isNaN(n)) {
270
+ console.log('[ERROR] Invalid number provided');
271
+ process.exit(1);
272
+ }
273
+
274
+ const result = calc.fibonacci(n);
275
+ console.log(`F(${n}) = ${result}`);
276
+ }
277
+ } catch (error) {
278
+ console.log(`[ERROR] ${error.message}`);
279
+ process.exit(1);
280
+ }
281
+ break;
282
+ }
283
+
246
284
  case 'call': {
247
285
  if (args.length < 2) {
248
286
  console.log('[ERROR] Please provide a prompt');
@@ -8,7 +8,7 @@ class HookDeploymentManager {
8
8
  constructor() {
9
9
  this.deploymentDir = path.join(os.homedir(), '.stigmergy', 'hooks');
10
10
  this.supportedCLIs = [
11
- 'claude', 'gemini', 'qwencode', 'iflow', 'qoder', 'codebuddy', 'codex', 'copilot'
11
+ 'claude', 'gemini', 'qwen', 'iflow', 'qodercli', 'codebuddy', 'codex', 'copilot'
12
12
  ];
13
13
  }
14
14
 
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Test file for Fibonacci functionality in Calculator class
3
+ */
4
+
5
+ const Calculator = require('../src/calculator');
6
+
7
+ console.log("Testing Fibonacci functionality...");
8
+
9
+ const calc = new Calculator();
10
+
11
+ // Test Fibonacci function
12
+ console.log("\n1. Testing Fibonacci function:");
13
+
14
+ // Test F(0) = 0
15
+ console.log("\n1.1 Testing F(0):");
16
+ try {
17
+ const result = calc.fibonacci(0);
18
+ console.log(`calc.fibonacci(0) = ${result}`);
19
+ if (result === 0) {
20
+ console.log("✅ F(0) test passed");
21
+ } else {
22
+ console.log("❌ F(0) test failed");
23
+ }
24
+ } catch (error) {
25
+ console.log("❌ F(0) test failed with error:", error.message);
26
+ }
27
+
28
+ // Test F(1) = 1
29
+ console.log("\n1.2 Testing F(1):");
30
+ try {
31
+ const result = calc.fibonacci(1);
32
+ console.log(`calc.fibonacci(1) = ${result}`);
33
+ if (result === 1) {
34
+ console.log("✅ F(1) test passed");
35
+ } else {
36
+ console.log("❌ F(1) test failed");
37
+ }
38
+ } catch (error) {
39
+ console.log("❌ F(1) test failed with error:", error.message);
40
+ }
41
+
42
+ // Test F(2) = 1
43
+ console.log("\n1.3 Testing F(2):");
44
+ try {
45
+ const result = calc.fibonacci(2);
46
+ console.log(`calc.fibonacci(2) = ${result}`);
47
+ if (result === 1) {
48
+ console.log("✅ F(2) test passed");
49
+ } else {
50
+ console.log("❌ F(2) test failed");
51
+ }
52
+ } catch (error) {
53
+ console.log("❌ F(2) test failed with error:", error.message);
54
+ }
55
+
56
+ // Test F(10) = 55
57
+ console.log("\n1.4 Testing F(10):");
58
+ try {
59
+ const result = calc.fibonacci(10);
60
+ console.log(`calc.fibonacci(10) = ${result}`);
61
+ if (result === 55) {
62
+ console.log("✅ F(10) test passed");
63
+ } else {
64
+ console.log("❌ F(10) test failed");
65
+ }
66
+ } catch (error) {
67
+ console.log("❌ F(10) test failed with error:", error.message);
68
+ }
69
+
70
+ // Test Fibonacci with negative number
71
+ console.log("\n1.5 Testing Fibonacci with negative number:");
72
+ try {
73
+ calc.fibonacci(-5);
74
+ console.log("❌ Fibonacci with negative number test failed - should have thrown an error");
75
+ } catch (error) {
76
+ console.log("✅ Fibonacci with negative number correctly threw error:", error.message);
77
+ }
78
+
79
+ // Test Fibonacci with non-integer
80
+ console.log("\n1.6 Testing Fibonacci with non-integer:");
81
+ try {
82
+ calc.fibonacci(5.5);
83
+ console.log("❌ Fibonacci with non-integer test failed - should have thrown an error");
84
+ } catch (error) {
85
+ console.log("✅ Fibonacci with non-integer correctly threw error:", error.message);
86
+ }
87
+
88
+ // Test Fibonacci sequence function
89
+ console.log("\n2. Testing Fibonacci sequence function:");
90
+
91
+ // Test sequence of 0 elements
92
+ console.log("\n2.1 Testing sequence of 0 elements:");
93
+ try {
94
+ const sequence = calc.fibonacciSequence(0);
95
+ console.log(`calc.fibonacciSequence(0) = [${sequence.join(', ')}]`);
96
+ if (sequence.length === 0) {
97
+ console.log("✅ Sequence of 0 elements test passed");
98
+ } else {
99
+ console.log("❌ Sequence of 0 elements test failed");
100
+ }
101
+ } catch (error) {
102
+ console.log("❌ Sequence of 0 elements test failed with error:", error.message);
103
+ }
104
+
105
+ // Test sequence of 1 element
106
+ console.log("\n2.2 Testing sequence of 1 element:");
107
+ try {
108
+ const sequence = calc.fibonacciSequence(1);
109
+ console.log(`calc.fibonacciSequence(1) = [${sequence.join(', ')}]`);
110
+ if (sequence.length === 1 && sequence[0] === 0) {
111
+ console.log("✅ Sequence of 1 element test passed");
112
+ } else {
113
+ console.log("❌ Sequence of 1 element test failed");
114
+ }
115
+ } catch (error) {
116
+ console.log("❌ Sequence of 1 element test failed with error:", error.message);
117
+ }
118
+
119
+ // Test sequence of 2 elements
120
+ console.log("\n2.3 Testing sequence of 2 elements:");
121
+ try {
122
+ const sequence = calc.fibonacciSequence(2);
123
+ console.log(`calc.fibonacciSequence(2) = [${sequence.join(', ')}]`);
124
+ if (sequence.length === 2 && sequence[0] === 0 && sequence[1] === 1) {
125
+ console.log("✅ Sequence of 2 elements test passed");
126
+ } else {
127
+ console.log("❌ Sequence of 2 elements test failed");
128
+ }
129
+ } catch (error) {
130
+ console.log("❌ Sequence of 2 elements test failed with error:", error.message);
131
+ }
132
+
133
+ // Test sequence of 10 elements
134
+ console.log("\n2.4 Testing sequence of 10 elements:");
135
+ try {
136
+ const sequence = calc.fibonacciSequence(10);
137
+ console.log(`calc.fibonacciSequence(10) = [${sequence.join(', ')}]`);
138
+ const expected = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34];
139
+ let passed = true;
140
+ if (sequence.length !== expected.length) {
141
+ passed = false;
142
+ } else {
143
+ for (let i = 0; i < sequence.length; i++) {
144
+ if (sequence[i] !== expected[i]) {
145
+ passed = false;
146
+ break;
147
+ }
148
+ }
149
+ }
150
+
151
+ if (passed) {
152
+ console.log("✅ Sequence of 10 elements test passed");
153
+ } else {
154
+ console.log("❌ Sequence of 10 elements test failed");
155
+ }
156
+ } catch (error) {
157
+ console.log("❌ Sequence of 10 elements test failed with error:", error.message);
158
+ }
159
+
160
+ // Test Fibonacci sequence with negative number
161
+ console.log("\n2.5 Testing Fibonacci sequence with negative number:");
162
+ try {
163
+ calc.fibonacciSequence(-5);
164
+ console.log("❌ Fibonacci sequence with negative number test failed - should have thrown an error");
165
+ } catch (error) {
166
+ console.log("✅ Fibonacci sequence with negative number correctly threw error:", error.message);
167
+ }
168
+
169
+ // Test Fibonacci sequence with non-integer
170
+ console.log("\n2.6 Testing Fibonacci sequence with non-integer:");
171
+ try {
172
+ calc.fibonacciSequence(5.5);
173
+ console.log("❌ Fibonacci sequence with non-integer test failed - should have thrown an error");
174
+ } catch (error) {
175
+ console.log("✅ Fibonacci sequence with non-integer correctly threw error:", error.message);
176
+ }
177
+
178
+ console.log("\n✅ All Fibonacci tests completed!");