stigmergy 1.2.0 → 1.2.6
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/LICENSE +18 -18
- package/README.md +28 -223
- package/STIGMERGY.md +61 -61
- package/docs/PROJECT_CONSTITUTION.md +433 -433
- package/docs/PROJECT_STRUCTURE_CURRENT.md +80 -80
- package/examples/calculator-example.js +72 -72
- package/examples/cline_usage_examples.md +364 -364
- package/examples/encryption-example.js +67 -67
- package/examples/json-parser-example.js +120 -120
- package/examples/json-validation-example.js +64 -64
- package/examples/rest-client-example.js +52 -52
- package/examples/rest_client_example.js +54 -54
- package/package.json +36 -15
- package/scripts/build.js +74 -74
- package/scripts/post-deployment-config.js +296 -296
- package/scripts/preinstall-check.js +173 -173
- package/scripts/publish.js +58 -268
- package/scripts/run-layered-tests.js +247 -0
- package/scripts/safe-install.js +139 -139
- package/scripts/simple-publish.js +57 -59
- package/src/adapters/claude/install_claude_integration.js +292 -0
- package/src/adapters/codebuddy/install_codebuddy_integration.js +349 -0
- package/src/adapters/codex/install_codex_integration.js +395 -0
- package/src/adapters/copilot/install_copilot_integration.js +716 -0
- package/src/adapters/gemini/install_gemini_integration.js +304 -0
- package/src/adapters/iflow/install_iflow_integration.js +304 -0
- package/src/adapters/qoder/install_qoder_integration.js +1090 -0
- package/src/adapters/qwen/install_qwen_integration.js +285 -0
- package/src/auth.js +173 -173
- package/src/auth_command.js +208 -208
- package/src/calculator.js +313 -313
- package/src/cli/router.js +417 -38
- package/src/core/cache_cleaner.js +767 -744
- package/src/core/cli_help_analyzer.js +680 -674
- package/src/core/cli_parameter_handler.js +132 -127
- package/src/core/cli_tools.js +89 -89
- package/src/core/coordination/index.js +16 -16
- package/src/core/coordination/nodejs/AdapterManager.js +102 -89
- package/src/core/coordination/nodejs/CLCommunication.js +132 -124
- package/src/core/coordination/nodejs/CLIIntegrationManager.js +272 -236
- package/src/core/coordination/nodejs/HealthChecker.js +76 -77
- package/src/core/coordination/nodejs/HookDeploymentManager.js +263 -190
- package/src/core/coordination/nodejs/StatisticsCollector.js +71 -71
- package/src/core/coordination/nodejs/index.js +90 -72
- package/src/core/coordination/nodejs/utils/Logger.js +29 -29
- package/src/core/enhanced_installer.js +479 -456
- package/src/core/enhanced_uninstaller.js +638 -618
- package/src/core/error_handler.js +406 -406
- package/src/core/installer.js +815 -294
- package/src/core/memory_manager.js +83 -83
- package/src/core/rest_client.js +160 -160
- package/src/core/smart_router.js +249 -146
- package/src/core/upgrade_manager.js +76 -59
- package/src/data_encryption.js +143 -143
- package/src/data_structures.js +440 -440
- package/src/deploy.js +55 -55
- package/src/index.js +30 -30
- package/src/test/cli-availability-checker.js +194 -0
- package/src/test/test-environment.js +289 -0
- package/src/utils/helpers.js +35 -35
- package/src/utils.js +921 -915
- package/src/weatherProcessor.js +228 -228
- package/test/cache-cleaner-implemented.test.js +0 -328
- package/test/cache-cleaner.test.js +0 -390
- package/test/calculator.test.js +0 -215
- package/test/collision-test.js +0 -26
- package/test/comprehensive-enhanced-features.test.js +0 -252
- package/test/comprehensive-execution-test.js +0 -428
- package/test/conflict-prevention-test.js +0 -95
- package/test/cross-cli-detection-test.js +0 -33
- package/test/csv-processing-test.js +0 -36
- package/test/deploy-hooks-test.js +0 -250
- package/test/e2e/claude-cli-test.js +0 -128
- package/test/e2e/collaboration-test.js +0 -75
- package/test/e2e/comprehensive-test.js +0 -431
- package/test/e2e/error-handling-test.js +0 -90
- package/test/e2e/individual-tool-test.js +0 -143
- package/test/e2e/other-cli-test.js +0 -130
- package/test/e2e/qoder-cli-test.js +0 -128
- package/test/e2e/run-e2e-tests.js +0 -73
- package/test/e2e/test-data.js +0 -88
- package/test/e2e/test-utils.js +0 -222
- package/test/encryption-simple-test.js +0 -110
- package/test/encryption.test.js +0 -129
- package/test/enhanced-main-alignment.test.js +0 -298
- package/test/enhanced-uninstaller-implemented.test.js +0 -271
- package/test/enhanced-uninstaller.test.js +0 -284
- package/test/error-handling-test.js +0 -341
- package/test/fibonacci.test.js +0 -178
- package/test/final-deploy-test.js +0 -221
- package/test/final-install-test.js +0 -226
- package/test/hash-table-demo.js +0 -33
- package/test/hash-table-test.js +0 -26
- package/test/hash_table_test.js +0 -114
- package/test/hook-system-integration-test.js +0 -307
- package/test/iflow-integration-test.js +0 -292
- package/test/improved-install-test.js +0 -362
- package/test/install-command-test.js +0 -370
- package/test/json-parser-test.js +0 -161
- package/test/json-validation-test.js +0 -164
- package/test/natural-language-skills-test.js +0 -320
- package/test/nl-integration-test.js +0 -179
- package/test/parameter-parsing-test.js +0 -143
- package/test/plugin-deployment-test.js +0 -316
- package/test/postinstall-test.js +0 -269
- package/test/python-plugins-test.js +0 -259
- package/test/real-test.js +0 -435
- package/test/remaining-adapters-test.js +0 -256
- package/test/rest-client-test.js +0 -56
- package/test/rest_client.test.js +0 -85
- package/test/safe-installation-cleaner.test.js +0 -343
- package/test/simple-iflow-hook-test.js +0 -137
- package/test/stigmergy-upgrade-test.js +0 -243
- package/test/system-compatibility-test.js +0 -467
- package/test/tdd-deploy-fix-test.js +0 -324
- package/test/tdd-fixes-test.js +0 -211
- package/test/third-party-skills-test.js +0 -321
- package/test/tool-selection-integration-test.js +0 -158
- package/test/unit/calculator-full.test.js +0 -191
- package/test/unit/calculator-simple.test.js +0 -96
- package/test/unit/calculator.test.js +0 -97
- package/test/unit/cli-scanner.test.js +0 -291
- package/test/unit/cli_parameter_handler.test.js +0 -116
- package/test/unit/cross-cli-executor.test.js +0 -399
- package/test/weather-processor.test.js +0 -104
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* TDD Test Suite for Hook System Integration
|
|
5
|
-
* Tests real integration between hooks and AI CLI tools
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const assert = require('assert');
|
|
9
|
-
const fs = require('fs');
|
|
10
|
-
const path = require('path');
|
|
11
|
-
|
|
12
|
-
// Test 1: Hook Installation Verification
|
|
13
|
-
function testHookInstallation() {
|
|
14
|
-
console.log('TEST 1: Hook Installation Verification');
|
|
15
|
-
console.log('---------------------------------------');
|
|
16
|
-
|
|
17
|
-
const hookDirectories = [
|
|
18
|
-
'.claude/hooks',
|
|
19
|
-
'.gemini/hooks',
|
|
20
|
-
'.qwen/hooks',
|
|
21
|
-
'.iflow/hooks',
|
|
22
|
-
'.codebuddy/hooks'
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
const results = [];
|
|
26
|
-
for (const hookDir of hookDirectories) {
|
|
27
|
-
const exists = fs.existsSync(hookDir);
|
|
28
|
-
results.push({ directory: hookDir, exists });
|
|
29
|
-
console.log(`${exists ? '✅' : '❌'} ${hookDir}: ${exists ? 'Found' : 'Missing'}`);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const installedCount = results.filter(r => r.exists).length;
|
|
33
|
-
console.log(`\nHook directories installed: ${installedCount}/${hookDirectories.length}`);
|
|
34
|
-
|
|
35
|
-
return installedCount === hookDirectories.length;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Test 2: Hook Content Verification
|
|
39
|
-
function testHookContentVerification() {
|
|
40
|
-
console.log('TEST 2: Hook Content Verification');
|
|
41
|
-
console.log('-----------------------------------');
|
|
42
|
-
|
|
43
|
-
const hookFiles = [
|
|
44
|
-
{ path: '.claude/hooks/skill-forced-eval-hook.sh', expectedContent: ['skill', 'natural', 'language'] },
|
|
45
|
-
{ path: '.gemini/hooks/skill-forced-eval-hook.js', expectedContent: ['skill', 'parse', 'detect'] },
|
|
46
|
-
{ path: '.qwen/hooks/skill-forced-eval-hook.py', expectedContent: ['skill', 'analysis', 'translate'] }
|
|
47
|
-
];
|
|
48
|
-
|
|
49
|
-
let validHooks = 0;
|
|
50
|
-
for (const hookFile of hookFiles) {
|
|
51
|
-
if (fs.existsSync(hookFile.path)) {
|
|
52
|
-
const content = fs.readFileSync(hookFile.path, 'utf8');
|
|
53
|
-
const hasRequiredContent = hookFile.expectedContent.every(keyword =>
|
|
54
|
-
content.toLowerCase().includes(keyword.toLowerCase())
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
console.log(`${hasRequiredContent ? '✅' : '❌'} ${hookFile.path}: ${hasRequiredContent ? 'Valid' : 'Invalid content'}`);
|
|
58
|
-
if (hasRequiredContent) validHooks++;
|
|
59
|
-
} else {
|
|
60
|
-
console.log(`❌ ${hookFile.path}: File not found`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
console.log(`\nValid hooks: ${validHooks}/${hookFiles.length}`);
|
|
65
|
-
return validHooks > 0;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Test 3: Hook Execution Simulation
|
|
69
|
-
function testHookExecution() {
|
|
70
|
-
console.log('TEST 3: Hook Execution Simulation');
|
|
71
|
-
console.log('------------------------------------');
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
// This will fail initially since we haven't implemented real hook integration
|
|
75
|
-
const HookIntegrationManager = require('../package/src/hooks/hook-integration-manager.cjs');
|
|
76
|
-
const hookManager = new HookIntegrationManager();
|
|
77
|
-
|
|
78
|
-
const testScenarios = [
|
|
79
|
-
{
|
|
80
|
-
tool: 'claude',
|
|
81
|
-
input: '请分析这个React组件的安全性',
|
|
82
|
-
expectedSkill: 'code-analysis'
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
tool: 'gemini',
|
|
86
|
-
input: 'Translate this comment to English',
|
|
87
|
-
expectedSkill: 'translation'
|
|
88
|
-
}
|
|
89
|
-
];
|
|
90
|
-
|
|
91
|
-
let passed = 0;
|
|
92
|
-
for (const scenario of testScenarios) {
|
|
93
|
-
console.log(`Testing ${scenario.tool} hook with: "${scenario.input}"`);
|
|
94
|
-
|
|
95
|
-
try {
|
|
96
|
-
const result = hookManager.processHookInput(scenario.tool, scenario.input);
|
|
97
|
-
|
|
98
|
-
if (result.detected && result.skill === scenario.expectedSkill) {
|
|
99
|
-
console.log(`✅ Hook correctly detected ${result.skill}`);
|
|
100
|
-
passed++;
|
|
101
|
-
} else {
|
|
102
|
-
console.log(`❌ Hook failed to detect skill (expected: ${scenario.expectedSkill})`);
|
|
103
|
-
}
|
|
104
|
-
} catch (error) {
|
|
105
|
-
console.log(`❌ Hook execution error: ${error.message}`);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
console.log(`\nHook execution tests: ${passed}/${testScenarios.length} passed`);
|
|
110
|
-
return passed === testScenarios.length;
|
|
111
|
-
|
|
112
|
-
} catch (error) {
|
|
113
|
-
console.log(`❌ Hook execution test failed: ${error.message}`);
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// Test 4: Character Encoding Verification
|
|
119
|
-
function testCharacterEncoding() {
|
|
120
|
-
console.log('TEST 4: Character Encoding Verification');
|
|
121
|
-
console.log('----------------------------------------');
|
|
122
|
-
|
|
123
|
-
const filesToCheck = [
|
|
124
|
-
'package/src/index.js',
|
|
125
|
-
'package/src/skills/skills-manager.js',
|
|
126
|
-
'package/src/natural-language/nl-parser.cjs',
|
|
127
|
-
'hooks/install-hooks.js'
|
|
128
|
-
];
|
|
129
|
-
|
|
130
|
-
let pureAnsiFiles = 0;
|
|
131
|
-
let problematicFiles = [];
|
|
132
|
-
|
|
133
|
-
for (const file of filesToCheck) {
|
|
134
|
-
if (fs.existsSync(file)) {
|
|
135
|
-
const content = fs.readFileSync(file, 'utf8');
|
|
136
|
-
|
|
137
|
-
// Check for non-ANSI characters (simplified check)
|
|
138
|
-
const hasNonAnsi = /[^\x00-\x7F]/.test(content);
|
|
139
|
-
|
|
140
|
-
if (!hasNonAnsi) {
|
|
141
|
-
console.log(`✅ ${file}: Pure ANSI encoding`);
|
|
142
|
-
pureAnsiFiles++;
|
|
143
|
-
} else {
|
|
144
|
-
console.log(`❌ ${file}: Contains non-ANSI characters`);
|
|
145
|
-
problematicFiles.push(file);
|
|
146
|
-
}
|
|
147
|
-
} else {
|
|
148
|
-
console.log(`⚠️ ${file}: File not found`);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
console.log(`\nPure ANSI files: ${pureAnsiFiles}/${filesToCheck.length}`);
|
|
153
|
-
if (problematicFiles.length > 0) {
|
|
154
|
-
console.log(`Files needing encoding fixes: ${problematicFiles.join(', ')}`);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return pureAnsiFiles === filesToCheck.length;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// Test 5: Real AI Tool Calling
|
|
161
|
-
async function testRealAIToolCalling() {
|
|
162
|
-
console.log('TEST 5: Real AI Tool Calling');
|
|
163
|
-
console.log('-------------------------------');
|
|
164
|
-
|
|
165
|
-
try {
|
|
166
|
-
// This will fail initially since we haven't implemented real AI calling
|
|
167
|
-
const RealAIExecutor = require('../package/src/ai/real-executor.cjs');
|
|
168
|
-
const executor = new RealAIExecutor();
|
|
169
|
-
|
|
170
|
-
const testCalls = [
|
|
171
|
-
{
|
|
172
|
-
tool: 'claude',
|
|
173
|
-
command: '请将以下文本翻译成英文:Hello World',
|
|
174
|
-
expectedSuccess: true
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
tool: 'gemini',
|
|
178
|
-
command: '分析这个函数的复杂度',
|
|
179
|
-
expectedSuccess: true
|
|
180
|
-
}
|
|
181
|
-
];
|
|
182
|
-
|
|
183
|
-
let successful = 0;
|
|
184
|
-
for (const test of testCalls) {
|
|
185
|
-
console.log(`Testing ${test.tool} real execution...`);
|
|
186
|
-
|
|
187
|
-
try {
|
|
188
|
-
const result = await executor.executeCommand(test.tool, test.command);
|
|
189
|
-
|
|
190
|
-
if (result.success === test.expectedSuccess) {
|
|
191
|
-
console.log(`✅ ${test.tool} execution successful`);
|
|
192
|
-
successful++;
|
|
193
|
-
} else {
|
|
194
|
-
console.log(`❌ ${test.tool} execution failed (expected: ${test.expectedSuccess})`);
|
|
195
|
-
}
|
|
196
|
-
} catch (error) {
|
|
197
|
-
console.log(`❌ ${test.tool} execution error: ${error.message}`);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
console.log(`\nReal AI tool calls: ${successful}/${testCalls.length} successful`);
|
|
202
|
-
return successful === testCalls.length;
|
|
203
|
-
|
|
204
|
-
} catch (error) {
|
|
205
|
-
console.log(`❌ Real AI tool calling test failed: ${error.message}`);
|
|
206
|
-
return false;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// Test 6: Cross-Platform Compatibility
|
|
211
|
-
function testCrossPlatformCompatibility() {
|
|
212
|
-
console.log('TEST 6: Cross-Platform Compatibility');
|
|
213
|
-
console.log('--------------------------------------');
|
|
214
|
-
|
|
215
|
-
const platform = process.platform;
|
|
216
|
-
console.log(`Current platform: ${platform}`);
|
|
217
|
-
|
|
218
|
-
// Test file paths work on current platform
|
|
219
|
-
const testPaths = [
|
|
220
|
-
'package/src/index.js',
|
|
221
|
-
'package/src/skills/skills-manager.cjs',
|
|
222
|
-
'.claude/settings.json'
|
|
223
|
-
];
|
|
224
|
-
|
|
225
|
-
let validPaths = 0;
|
|
226
|
-
for (const testPath of testPaths) {
|
|
227
|
-
const normalizedPath = path.normalize(testPath);
|
|
228
|
-
const works = fs.existsSync(normalizedPath) || !fs.existsSync(testPath);
|
|
229
|
-
|
|
230
|
-
console.log(`${works ? '✅' : '❌'} ${testPath}: ${works ? 'Valid' : 'Invalid path'}`);
|
|
231
|
-
if (works) validPaths++;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
console.log(`\nValid paths: ${validPaths}/${testPaths.length}`);
|
|
235
|
-
return validPaths === testPaths.length;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// Main test runner
|
|
239
|
-
async function runTests() {
|
|
240
|
-
console.log('==============================================');
|
|
241
|
-
console.log('TDD: HOOK SYSTEM & ENCODING & REAL AI');
|
|
242
|
-
console.log('==============================================');
|
|
243
|
-
console.log('');
|
|
244
|
-
|
|
245
|
-
const results = [];
|
|
246
|
-
|
|
247
|
-
// Test 1: Hook installation
|
|
248
|
-
results.push(testHookInstallation());
|
|
249
|
-
console.log('');
|
|
250
|
-
|
|
251
|
-
// Test 2: Hook content
|
|
252
|
-
results.push(testHookContentVerification());
|
|
253
|
-
console.log('');
|
|
254
|
-
|
|
255
|
-
// Test 3: Hook execution (will fail initially)
|
|
256
|
-
results.push(testHookExecution());
|
|
257
|
-
console.log('');
|
|
258
|
-
|
|
259
|
-
// Test 4: Character encoding
|
|
260
|
-
results.push(testCharacterEncoding());
|
|
261
|
-
console.log('');
|
|
262
|
-
|
|
263
|
-
// Test 5: Real AI tool calling (will fail initially)
|
|
264
|
-
results.push(await testRealAIToolCalling());
|
|
265
|
-
console.log('');
|
|
266
|
-
|
|
267
|
-
// Test 6: Cross-platform compatibility
|
|
268
|
-
results.push(testCrossPlatformCompatibility());
|
|
269
|
-
console.log('');
|
|
270
|
-
|
|
271
|
-
// Summary
|
|
272
|
-
const passed = results.filter(r => r === true).length;
|
|
273
|
-
const total = results.length;
|
|
274
|
-
|
|
275
|
-
console.log('==============================================');
|
|
276
|
-
console.log('TDD COMPREHENSIVE TEST SUMMARY');
|
|
277
|
-
console.log('==============================================');
|
|
278
|
-
console.log(`Tests passed: ${passed}/${total}`);
|
|
279
|
-
|
|
280
|
-
if (passed === total) {
|
|
281
|
-
console.log('🎉 All tests passed! System is fully integrated and production-ready!');
|
|
282
|
-
} else {
|
|
283
|
-
console.log('⚠️ Some tests failed. Implementation needed for:');
|
|
284
|
-
console.log(' • Hook System Integration (Medium Priority)');
|
|
285
|
-
console.log(' • Character Encoding Internationalization (Low Priority)');
|
|
286
|
-
console.log(' • Real AI Tool Calling (Medium Priority)');
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
return passed === total;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
// Run tests if called directly
|
|
293
|
-
if (require.main === module) {
|
|
294
|
-
runTests().then(success => {
|
|
295
|
-
process.exit(success ? 0 : 1);
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
module.exports = {
|
|
300
|
-
testHookInstallation,
|
|
301
|
-
testHookContentVerification,
|
|
302
|
-
testHookExecution,
|
|
303
|
-
testCharacterEncoding,
|
|
304
|
-
testRealAIToolCalling,
|
|
305
|
-
testCrossPlatformCompatibility,
|
|
306
|
-
runTests
|
|
307
|
-
};
|
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* iFlow Stigmergy Integration Test
|
|
5
|
-
* This script tests if iFlow can properly detect and use Stigmergy hooks
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const fs = require('fs').promises;
|
|
9
|
-
const path = require('path');
|
|
10
|
-
const os = require('os');
|
|
11
|
-
const { spawn } = require('child_process');
|
|
12
|
-
|
|
13
|
-
class IFlowIntegrationTester {
|
|
14
|
-
constructor() {
|
|
15
|
-
this.iflowConfigDir = path.join(os.homedir(), '.iflow');
|
|
16
|
-
this.iflowHooksDir = path.join(this.iflowConfigDir, 'hooks');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Check if iFlow config directory exists
|
|
20
|
-
async checkIFlowConfig() {
|
|
21
|
-
try {
|
|
22
|
-
await fs.access(this.iflowConfigDir);
|
|
23
|
-
return true;
|
|
24
|
-
} catch (error) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Check if iFlow hooks directory exists and has Stigmergy files
|
|
30
|
-
async checkIFlowHooks() {
|
|
31
|
-
try {
|
|
32
|
-
await fs.access(this.iflowHooksDir);
|
|
33
|
-
const files = await fs.readdir(this.iflowHooksDir);
|
|
34
|
-
const stigmergyFiles = files.filter(file =>
|
|
35
|
-
file.includes('stigmergy') ||
|
|
36
|
-
file.includes('Stigmergy') ||
|
|
37
|
-
file.includes('hook') ||
|
|
38
|
-
file.includes('adapter')
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
exists: true,
|
|
43
|
-
files: files,
|
|
44
|
-
stigmergyFiles: stigmergyFiles,
|
|
45
|
-
path: this.iflowHooksDir
|
|
46
|
-
};
|
|
47
|
-
} catch (error) {
|
|
48
|
-
return {
|
|
49
|
-
exists: false,
|
|
50
|
-
files: [],
|
|
51
|
-
stigmergyFiles: [],
|
|
52
|
-
path: this.iflowHooksDir
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Check if iFlow has hooks configuration
|
|
58
|
-
async checkIFlowHooksConfig() {
|
|
59
|
-
// Check multiple possible config locations
|
|
60
|
-
const configLocations = [
|
|
61
|
-
path.join(os.homedir(), '.config', 'iflow', 'hooks.yml'),
|
|
62
|
-
path.join(os.homedir(), '.config', 'iflow', 'hooks.yaml'),
|
|
63
|
-
path.join(os.homedir(), '.iflow', 'hooks.yml'),
|
|
64
|
-
path.join(os.homedir(), '.iflow', 'hooks.yaml'),
|
|
65
|
-
path.join(os.homedir(), '.iflow', 'config.yml'),
|
|
66
|
-
path.join(os.homedir(), '.iflow', 'settings.json')
|
|
67
|
-
];
|
|
68
|
-
|
|
69
|
-
for (const configFile of configLocations) {
|
|
70
|
-
try {
|
|
71
|
-
await fs.access(configFile);
|
|
72
|
-
const content = await fs.readFile(configFile, 'utf8');
|
|
73
|
-
if (content.includes('hooks') || content.includes('plugins') || content.includes('CrossCLIHookAdapter')) {
|
|
74
|
-
return {
|
|
75
|
-
exists: true,
|
|
76
|
-
path: configFile,
|
|
77
|
-
hasHooksSection: true,
|
|
78
|
-
contentPreview: content.substring(0, 200)
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
} catch (error) {
|
|
82
|
-
// File doesn't exist, continue to next
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return {
|
|
87
|
-
exists: false,
|
|
88
|
-
path: null,
|
|
89
|
-
hasHooksSection: false,
|
|
90
|
-
contentPreview: ''
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Test iFlow hooks command
|
|
95
|
-
async testIFlowHooksCommand() {
|
|
96
|
-
return new Promise((resolve) => {
|
|
97
|
-
const child = spawn('iflow', ['hooks'], {
|
|
98
|
-
stdio: 'pipe',
|
|
99
|
-
timeout: 10000
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
let stdout = '';
|
|
103
|
-
let stderr = '';
|
|
104
|
-
|
|
105
|
-
child.stdout.on('data', (data) => {
|
|
106
|
-
stdout += data.toString();
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
child.stderr.on('data', (data) => {
|
|
110
|
-
stderr += data.toString();
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
child.on('close', (code) => {
|
|
114
|
-
resolve({
|
|
115
|
-
success: code === 0,
|
|
116
|
-
code: code,
|
|
117
|
-
stdout: stdout,
|
|
118
|
-
stderr: stderr,
|
|
119
|
-
output: stdout + stderr
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
child.on('error', (error) => {
|
|
124
|
-
resolve({
|
|
125
|
-
success: false,
|
|
126
|
-
error: error.message,
|
|
127
|
-
stdout: '',
|
|
128
|
-
stderr: '',
|
|
129
|
-
output: ''
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Test iFlow plugin command
|
|
136
|
-
async testIFlowPluginCommand() {
|
|
137
|
-
return new Promise((resolve) => {
|
|
138
|
-
const child = spawn('iflow', ['plugins'], {
|
|
139
|
-
stdio: 'pipe',
|
|
140
|
-
timeout: 10000
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
let stdout = '';
|
|
144
|
-
let stderr = '';
|
|
145
|
-
|
|
146
|
-
child.stdout.on('data', (data) => {
|
|
147
|
-
stdout += data.toString();
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
child.stderr.on('data', (data) => {
|
|
151
|
-
stderr += data.toString();
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
child.on('close', (code) => {
|
|
155
|
-
resolve({
|
|
156
|
-
success: code === 0,
|
|
157
|
-
code: code,
|
|
158
|
-
stdout: stdout,
|
|
159
|
-
stderr: stderr,
|
|
160
|
-
output: stdout + stderr
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
child.on('error', (error) => {
|
|
165
|
-
resolve({
|
|
166
|
-
success: false,
|
|
167
|
-
error: error.message,
|
|
168
|
-
stdout: '',
|
|
169
|
-
stderr: '',
|
|
170
|
-
output: ''
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// Run comprehensive iFlow integration test
|
|
177
|
-
async runIntegrationTest() {
|
|
178
|
-
console.log('iFlow Stigmergy Integration Test');
|
|
179
|
-
console.log('='.repeat(40));
|
|
180
|
-
|
|
181
|
-
// Test 1: Check iFlow configuration
|
|
182
|
-
console.log('\n[Test 1] Checking iFlow configuration...');
|
|
183
|
-
const configExists = await this.checkIFlowConfig();
|
|
184
|
-
console.log(` Config directory exists: ${configExists ? '✓' : '✗'}`);
|
|
185
|
-
|
|
186
|
-
// Test 2: Check iFlow hooks directory
|
|
187
|
-
console.log('\n[Test 2] Checking iFlow hooks directory...');
|
|
188
|
-
const hooksInfo = await this.checkIFlowHooks();
|
|
189
|
-
console.log(` Hooks directory exists: ${hooksInfo.exists ? '✓' : '✗'}`);
|
|
190
|
-
console.log(` Total files: ${hooksInfo.files.length}`);
|
|
191
|
-
console.log(` Stigmergy-related files: ${hooksInfo.stigmergyFiles.length}`);
|
|
192
|
-
if (hooksInfo.stigmergyFiles.length > 0) {
|
|
193
|
-
console.log(' Stigmergy files found:');
|
|
194
|
-
hooksInfo.stigmergyFiles.forEach(file => console.log(` - ${file}`));
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// Test 3: Check hooks configuration
|
|
198
|
-
console.log('\n[Test 3] Checking hooks configuration...');
|
|
199
|
-
const hooksConfig = await this.checkIFlowHooksConfig();
|
|
200
|
-
console.log(` Config file exists: ${hooksConfig.exists ? '✓' : '✗'}`);
|
|
201
|
-
console.log(` Has hooks section: ${hooksConfig.hasHooksSection ? '✓' : '✗'}`);
|
|
202
|
-
|
|
203
|
-
// Test 4: Test iFlow hooks command
|
|
204
|
-
console.log('\n[Test 4] Testing iFlow hooks command...');
|
|
205
|
-
const hooksCommandResult = await this.testIFlowHooksCommand();
|
|
206
|
-
console.log(` Command success: ${hooksCommandResult.success ? '✓' : '✗'}`);
|
|
207
|
-
console.log(` Exit code: ${hooksCommandResult.code}`);
|
|
208
|
-
if (hooksCommandResult.output) {
|
|
209
|
-
const preview = hooksCommandResult.output.substring(0, 200);
|
|
210
|
-
console.log(` Output preview: ${preview}${hooksCommandResult.output.length > 200 ? '...' : ''}`);
|
|
211
|
-
|
|
212
|
-
// Check if Stigmergy is mentioned in output
|
|
213
|
-
if (hooksCommandResult.output.toLowerCase().includes('stigmergy')) {
|
|
214
|
-
console.log(' ✓ Stigmergy detected in hooks output');
|
|
215
|
-
} else {
|
|
216
|
-
console.log(' ✗ Stigmergy not detected in hooks output');
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// Test 5: Test iFlow plugin command
|
|
221
|
-
console.log('\n[Test 5] Testing iFlow plugin command...');
|
|
222
|
-
const pluginCommandResult = await this.testIFlowPluginCommand();
|
|
223
|
-
console.log(` Command success: ${pluginCommandResult.success ? '✓' : '✗'}`);
|
|
224
|
-
console.log(` Exit code: ${pluginCommandResult.code}`);
|
|
225
|
-
if (pluginCommandResult.output) {
|
|
226
|
-
const preview = pluginCommandResult.output.substring(0, 200);
|
|
227
|
-
console.log(` Output preview: ${preview}${pluginCommandResult.output.length > 200 ? '...' : ''}`);
|
|
228
|
-
|
|
229
|
-
// Check if Stigmergy is mentioned in output
|
|
230
|
-
if (pluginCommandResult.output.toLowerCase().includes('stigmergy')) {
|
|
231
|
-
console.log(' ✓ Stigmergy detected in plugins output');
|
|
232
|
-
} else {
|
|
233
|
-
console.log(' ✗ Stigmergy not detected in plugins output');
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// Summary
|
|
238
|
-
console.log('\n' + '='.repeat(40));
|
|
239
|
-
console.log('Integration Test Summary:');
|
|
240
|
-
console.log('='.repeat(40));
|
|
241
|
-
|
|
242
|
-
const results = {
|
|
243
|
-
configExists,
|
|
244
|
-
hooksDirectoryExists: hooksInfo.exists,
|
|
245
|
-
stigmergyHooksPresent: hooksInfo.stigmergyFiles.length > 0,
|
|
246
|
-
hooksCommandWorks: hooksCommandResult.success,
|
|
247
|
-
pluginsCommandWorks: pluginCommandResult.success,
|
|
248
|
-
stigmergyDetectedInHooks: hooksCommandResult.output.toLowerCase().includes('stigmergy'),
|
|
249
|
-
stigmergyDetectedInPlugins: pluginCommandResult.output.toLowerCase().includes('stigmergy')
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
Object.entries(results).forEach(([test, result]) => {
|
|
253
|
-
console.log(`${test}: ${result ? '✓ PASS' : '✗ FAIL'}`);
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
const passedTests = Object.values(results).filter(Boolean).length;
|
|
257
|
-
const totalTests = Object.values(results).length;
|
|
258
|
-
|
|
259
|
-
console.log(`\nOverall Result: ${passedTests}/${totalTests} tests passed`);
|
|
260
|
-
|
|
261
|
-
if (passedTests === totalTests) {
|
|
262
|
-
console.log('✓ iFlow Stigmergy integration is working correctly!');
|
|
263
|
-
} else if (passedTests > 0) {
|
|
264
|
-
console.log('⚠ iFlow Stigmergy integration is partially working.');
|
|
265
|
-
} else {
|
|
266
|
-
console.log('✗ iFlow Stigmergy integration is not working.');
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
return results;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// Run the test
|
|
274
|
-
async function runIFlowIntegrationTest() {
|
|
275
|
-
const tester = new IFlowIntegrationTester();
|
|
276
|
-
const results = await tester.runIntegrationTest();
|
|
277
|
-
|
|
278
|
-
return results;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// Export for use in other modules
|
|
282
|
-
module.exports = { IFlowIntegrationTester };
|
|
283
|
-
|
|
284
|
-
// Run if called directly
|
|
285
|
-
if (require.main === module) {
|
|
286
|
-
runIFlowIntegrationTest().then(results => {
|
|
287
|
-
process.exit(0);
|
|
288
|
-
}).catch(error => {
|
|
289
|
-
console.error('[Test Failed]:', error.message);
|
|
290
|
-
process.exit(1);
|
|
291
|
-
});
|
|
292
|
-
}
|