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,316 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Stigmergy Plugin Deployment Test
|
|
5
|
-
* This script tests the plugin deployment mechanism for all supported CLI tools
|
|
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
|
-
// CLI Tools Configuration (same as in main_english.js)
|
|
14
|
-
const CLI_TOOLS = {
|
|
15
|
-
claude: {
|
|
16
|
-
name: 'Claude CLI',
|
|
17
|
-
version: 'claude --version',
|
|
18
|
-
install: 'npm install -g @anthropic-ai/claude-cli',
|
|
19
|
-
hooksDir: path.join(os.homedir(), '.claude', 'hooks'),
|
|
20
|
-
config: path.join(os.homedir(), '.claude', 'config.json')
|
|
21
|
-
},
|
|
22
|
-
gemini: {
|
|
23
|
-
name: 'Gemini CLI',
|
|
24
|
-
version: 'gemini --version',
|
|
25
|
-
install: 'npm install -g @google/generative-ai-cli',
|
|
26
|
-
hooksDir: path.join(os.homedir(), '.gemini', 'extensions'),
|
|
27
|
-
config: path.join(os.homedir(), '.gemini', 'config.json')
|
|
28
|
-
},
|
|
29
|
-
qwen: {
|
|
30
|
-
name: 'Qwen CLI',
|
|
31
|
-
version: 'qwen --version',
|
|
32
|
-
install: 'npm install -g @qwen-code/qwen-code',
|
|
33
|
-
hooksDir: path.join(os.homedir(), '.qwen', 'hooks'),
|
|
34
|
-
config: path.join(os.homedir(), '.qwen', 'config.json')
|
|
35
|
-
},
|
|
36
|
-
iflow: {
|
|
37
|
-
name: 'iFlow CLI',
|
|
38
|
-
version: 'iflow --version',
|
|
39
|
-
install: 'npm install -g iflow-cli',
|
|
40
|
-
hooksDir: path.join(os.homedir(), '.iflow', 'hooks'),
|
|
41
|
-
config: path.join(os.homedir(), '.iflow', 'config.json')
|
|
42
|
-
},
|
|
43
|
-
qodercli: {
|
|
44
|
-
name: 'Qoder CLI',
|
|
45
|
-
version: 'qodercli --version',
|
|
46
|
-
install: 'npm install -g @qoder-ai/qodercli',
|
|
47
|
-
hooksDir: path.join(os.homedir(), '.qoder', 'hooks'),
|
|
48
|
-
config: path.join(os.homedir(), '.qoder', 'config.json')
|
|
49
|
-
},
|
|
50
|
-
codebuddy: {
|
|
51
|
-
name: 'CodeBuddy CLI',
|
|
52
|
-
version: 'codebuddy --version',
|
|
53
|
-
install: 'npm install -g codebuddy-cli',
|
|
54
|
-
hooksDir: path.join(os.homedir(), '.codebuddy', 'hooks'),
|
|
55
|
-
config: path.join(os.homedir(), '.codebuddy', 'config.json')
|
|
56
|
-
},
|
|
57
|
-
copilot: {
|
|
58
|
-
name: 'GitHub Copilot CLI',
|
|
59
|
-
version: 'copilot --version',
|
|
60
|
-
install: 'npm install -g @github/copilot-cli',
|
|
61
|
-
hooksDir: path.join(os.homedir(), '.copilot', 'mcp'),
|
|
62
|
-
config: path.join(os.homedir(), '.copilot', 'config.json')
|
|
63
|
-
},
|
|
64
|
-
codex: {
|
|
65
|
-
name: 'OpenAI Codex CLI',
|
|
66
|
-
version: 'codex --version',
|
|
67
|
-
install: 'npm install -g openai-codex-cli',
|
|
68
|
-
hooksDir: path.join(os.homedir(), '.config', 'codex', 'slash_commands'),
|
|
69
|
-
config: path.join(os.homedir(), '.codex', 'config.json')
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
class PluginDeploymentTester {
|
|
74
|
-
constructor() {
|
|
75
|
-
this.results = {};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Check if a CLI tool is installed
|
|
79
|
-
async isToolInstalled(toolName) {
|
|
80
|
-
const tool = CLI_TOOLS[toolName];
|
|
81
|
-
if (!tool) return false;
|
|
82
|
-
|
|
83
|
-
// Extract the actual command from the version string
|
|
84
|
-
const command = tool.version.split(' ')[0];
|
|
85
|
-
|
|
86
|
-
return new Promise((resolve) => {
|
|
87
|
-
const child = spawn(command, ['--version'], {
|
|
88
|
-
stdio: 'pipe',
|
|
89
|
-
timeout: 5000
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
let output = '';
|
|
93
|
-
let error = '';
|
|
94
|
-
|
|
95
|
-
child.stdout.on('data', (data) => {
|
|
96
|
-
output += data.toString();
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
child.stderr.on('data', (data) => {
|
|
100
|
-
error += data.toString();
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
child.on('close', (code) => {
|
|
104
|
-
resolve(code === 0 && (output.length > 0 || error.length > 0));
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
child.on('error', () => {
|
|
108
|
-
resolve(false);
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// Check if hooks directory exists and has files
|
|
114
|
-
async checkHooksDirectory(toolName) {
|
|
115
|
-
const tool = CLI_TOOLS[toolName];
|
|
116
|
-
if (!tool) return { exists: false, files: [] };
|
|
117
|
-
|
|
118
|
-
try {
|
|
119
|
-
await fs.access(tool.hooksDir);
|
|
120
|
-
const files = await fs.readdir(tool.hooksDir);
|
|
121
|
-
return {
|
|
122
|
-
exists: true,
|
|
123
|
-
files: files,
|
|
124
|
-
path: tool.hooksDir
|
|
125
|
-
};
|
|
126
|
-
} catch (error) {
|
|
127
|
-
return { exists: false, files: [], path: tool.hooksDir };
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Check if Stigmergy assets exist
|
|
132
|
-
async checkStigmergyAssets(toolName) {
|
|
133
|
-
const assetsPath = path.join(os.homedir(), '.stigmergy', 'assets', 'adapters', toolName);
|
|
134
|
-
try {
|
|
135
|
-
await fs.access(assetsPath);
|
|
136
|
-
const files = await fs.readdir(assetsPath);
|
|
137
|
-
return { exists: true, files: files, path: assetsPath };
|
|
138
|
-
} catch (error) {
|
|
139
|
-
return { exists: false, files: [], path: assetsPath };
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Test deployment for a specific tool
|
|
144
|
-
async testToolDeployment(toolName) {
|
|
145
|
-
console.log(`\n[Test] Testing ${toolName} deployment...`);
|
|
146
|
-
|
|
147
|
-
const result = {
|
|
148
|
-
toolName,
|
|
149
|
-
installed: false,
|
|
150
|
-
hooksDir: { exists: false, files: [] },
|
|
151
|
-
assets: { exists: false, files: [] },
|
|
152
|
-
deploymentStatus: 'unknown'
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
// Check if tool is installed
|
|
156
|
-
result.installed = await this.isToolInstalled(toolName);
|
|
157
|
-
console.log(` Installed: ${result.installed ? '✓' : '✗'}`);
|
|
158
|
-
|
|
159
|
-
// Check hooks directory
|
|
160
|
-
result.hooksDir = await this.checkHooksDirectory(toolName);
|
|
161
|
-
console.log(` Hooks Dir: ${result.hooksDir.exists ? '✓' : '✗'} (${result.hooksDir.files.length} files)`);
|
|
162
|
-
if (result.hooksDir.exists) {
|
|
163
|
-
console.log(` Path: ${result.hooksDir.path}`);
|
|
164
|
-
result.hooksDir.files.forEach(file => console.log(` - ${file}`));
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// Check Stigmergy assets
|
|
168
|
-
result.assets = await this.checkStigmergyAssets(toolName);
|
|
169
|
-
console.log(` Assets: ${result.assets.exists ? '✓' : '✗'} (${result.assets.files.length} files)`);
|
|
170
|
-
if (result.assets.exists) {
|
|
171
|
-
console.log(` Path: ${result.assets.path}`);
|
|
172
|
-
result.assets.files.forEach(file => console.log(` - ${file}`));
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// Determine deployment status
|
|
176
|
-
if (result.installed && result.hooksDir.exists && result.hooksDir.files.length > 0) {
|
|
177
|
-
result.deploymentStatus = 'successful';
|
|
178
|
-
} else if (result.installed && result.hooksDir.exists) {
|
|
179
|
-
result.deploymentStatus = 'partial'; // Directory exists but no files
|
|
180
|
-
} else if (result.installed) {
|
|
181
|
-
result.deploymentStatus = 'missing_hooks'; // Installed but no hooks
|
|
182
|
-
} else {
|
|
183
|
-
result.deploymentStatus = 'not_installed';
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
console.log(` Status: ${result.deploymentStatus}`);
|
|
187
|
-
|
|
188
|
-
return result;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// Test all tools
|
|
192
|
-
async testAllTools() {
|
|
193
|
-
console.log('Stigmergy Plugin Deployment Test');
|
|
194
|
-
console.log('='.repeat(40));
|
|
195
|
-
|
|
196
|
-
const toolNames = Object.keys(CLI_TOOLS);
|
|
197
|
-
const results = [];
|
|
198
|
-
|
|
199
|
-
for (const toolName of toolNames) {
|
|
200
|
-
const result = await this.testToolDeployment(toolName);
|
|
201
|
-
results.push(result);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// Summary
|
|
205
|
-
console.log('\n' + '='.repeat(40));
|
|
206
|
-
console.log('Deployment Summary:');
|
|
207
|
-
console.log('='.repeat(40));
|
|
208
|
-
|
|
209
|
-
const statusCounts = {
|
|
210
|
-
successful: 0,
|
|
211
|
-
partial: 0,
|
|
212
|
-
missing_hooks: 0,
|
|
213
|
-
not_installed: 0
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
results.forEach(result => {
|
|
217
|
-
statusCounts[result.deploymentStatus]++;
|
|
218
|
-
console.log(`${result.toolName}: ${result.deploymentStatus}`);
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
console.log('\nStatus Counts:');
|
|
222
|
-
Object.entries(statusCounts).forEach(([status, count]) => {
|
|
223
|
-
console.log(` ${status}: ${count}`);
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
// Identify issues
|
|
227
|
-
const issues = results.filter(r => r.deploymentStatus !== 'successful');
|
|
228
|
-
if (issues.length > 0) {
|
|
229
|
-
console.log('\nIssues Found:');
|
|
230
|
-
issues.forEach(issue => {
|
|
231
|
-
console.log(` ${issue.toolName}: ${issue.deploymentStatus}`);
|
|
232
|
-
if (issue.deploymentStatus === 'partial') {
|
|
233
|
-
console.log(` Hooks directory exists but is empty`);
|
|
234
|
-
} else if (issue.deploymentStatus === 'missing_hooks') {
|
|
235
|
-
console.log(` Tool installed but hooks not deployed`);
|
|
236
|
-
} else if (issue.deploymentStatus === 'not_installed') {
|
|
237
|
-
console.log(` Tool not installed`);
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
return results;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// Test iFlow specifically
|
|
246
|
-
async testIFlowIntegration() {
|
|
247
|
-
console.log('\n[iFlow Integration Test]');
|
|
248
|
-
console.log('-'.repeat(20));
|
|
249
|
-
|
|
250
|
-
// Check if iFlow config can detect hooks
|
|
251
|
-
const iflowConfigPath = path.join(os.homedir(), '.iflow', 'config.yml');
|
|
252
|
-
try {
|
|
253
|
-
await fs.access(iflowConfigPath);
|
|
254
|
-
const configContent = await fs.readFile(iflowConfigPath, 'utf8');
|
|
255
|
-
console.log('iFlow config file found');
|
|
256
|
-
|
|
257
|
-
if (configContent.includes('hooks') || configContent.includes('plugins')) {
|
|
258
|
-
console.log('✓ Hooks/plugins section found in iFlow config');
|
|
259
|
-
} else {
|
|
260
|
-
console.log('✗ No hooks/plugins section found in iFlow config');
|
|
261
|
-
}
|
|
262
|
-
} catch (error) {
|
|
263
|
-
console.log('iFlow config file not found or not readable');
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// Try to run iFlow with hook detection
|
|
267
|
-
try {
|
|
268
|
-
const child = spawn('iflow', ['hooks'], {
|
|
269
|
-
stdio: 'pipe',
|
|
270
|
-
timeout: 10000
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
let output = '';
|
|
274
|
-
child.stdout.on('data', (data) => {
|
|
275
|
-
output += data.toString();
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
await new Promise((resolve) => {
|
|
279
|
-
child.on('close', resolve);
|
|
280
|
-
child.on('error', resolve);
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
if (output.includes('stigmergy') || output.includes('Stigmergy')) {
|
|
284
|
-
console.log('✓ iFlow can detect Stigmergy hooks');
|
|
285
|
-
} else {
|
|
286
|
-
console.log('✗ iFlow cannot detect Stigmergy hooks');
|
|
287
|
-
console.log('Output:', output.substring(0, 200) + '...');
|
|
288
|
-
}
|
|
289
|
-
} catch (error) {
|
|
290
|
-
console.log('Could not test iFlow hook detection:', error.message);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// Run the tests
|
|
296
|
-
async function runDeploymentTests() {
|
|
297
|
-
const tester = new PluginDeploymentTester();
|
|
298
|
-
const results = await tester.testAllTools();
|
|
299
|
-
await tester.testIFlowIntegration();
|
|
300
|
-
|
|
301
|
-
return results;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// Export for use in other modules
|
|
305
|
-
module.exports = { PluginDeploymentTester };
|
|
306
|
-
|
|
307
|
-
// Run if called directly
|
|
308
|
-
if (require.main === module) {
|
|
309
|
-
runDeploymentTests().then(results => {
|
|
310
|
-
console.log('\n[Test Complete]');
|
|
311
|
-
process.exit(0);
|
|
312
|
-
}).catch(error => {
|
|
313
|
-
console.error('[Test Failed]:', error.message);
|
|
314
|
-
process.exit(1);
|
|
315
|
-
});
|
|
316
|
-
}
|
package/test/postinstall-test.js
DELETED
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Test for postinstall behavior and error handling
|
|
5
|
-
* This test verifies that the npm postinstall script works correctly
|
|
6
|
-
* and provides graceful degradation when problems occur
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const fs = require('fs').promises;
|
|
10
|
-
const path = require('path');
|
|
11
|
-
const os = require('os');
|
|
12
|
-
const { spawn } = require('child_process');
|
|
13
|
-
|
|
14
|
-
class PostInstallTester {
|
|
15
|
-
constructor() {
|
|
16
|
-
this.testResults = [];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Test 1: Verify postinstall script exists and is correct
|
|
20
|
-
async testPostInstallScript() {
|
|
21
|
-
console.log('[TEST 1] Verifying postinstall script configuration...');
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
// Read package.json
|
|
25
|
-
const packageJsonPath = path.join(__dirname, '..', 'package.json');
|
|
26
|
-
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'));
|
|
27
|
-
|
|
28
|
-
// Check if postinstall script exists
|
|
29
|
-
if (!packageJson.scripts || !packageJson.scripts.postinstall) {
|
|
30
|
-
console.log(' ✗ postinstall script not found in package.json');
|
|
31
|
-
this.testResults.push({
|
|
32
|
-
name: 'Postinstall Script Configuration',
|
|
33
|
-
passed: false,
|
|
34
|
-
details: 'postinstall script not found in package.json'
|
|
35
|
-
});
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const postinstallScript = packageJson.scripts.postinstall;
|
|
40
|
-
console.log(` Postinstall script: ${postinstallScript}`);
|
|
41
|
-
|
|
42
|
-
// Check if it calls the auto-install command
|
|
43
|
-
const hasAutoInstall = postinstallScript.includes('auto-install');
|
|
44
|
-
const hasMainScript = postinstallScript.includes('src/main_english.js');
|
|
45
|
-
|
|
46
|
-
if (hasAutoInstall && hasMainScript) {
|
|
47
|
-
console.log(' ✓ postinstall script correctly configured for auto-install');
|
|
48
|
-
} else {
|
|
49
|
-
console.log(' ✗ postinstall script missing auto-install configuration');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
this.testResults.push({
|
|
53
|
-
name: 'Postinstall Script Configuration',
|
|
54
|
-
passed: hasAutoInstall && hasMainScript,
|
|
55
|
-
details: hasAutoInstall && hasMainScript ?
|
|
56
|
-
'Correctly configured for auto-install' :
|
|
57
|
-
'Missing auto-install configuration'
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
return hasAutoInstall && hasMainScript;
|
|
61
|
-
} catch (error) {
|
|
62
|
-
console.log(` ✗ Failed to check postinstall script: ${error.message}`);
|
|
63
|
-
this.testResults.push({
|
|
64
|
-
name: 'Postinstall Script Configuration',
|
|
65
|
-
passed: false,
|
|
66
|
-
details: `Failed to check: ${error.message}`
|
|
67
|
-
});
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Test 2: Verify auto-install command exists
|
|
73
|
-
async testAutoInstallCommand() {
|
|
74
|
-
console.log('\n[TEST 2] Verifying auto-install command implementation...');
|
|
75
|
-
|
|
76
|
-
try {
|
|
77
|
-
// Read main script
|
|
78
|
-
const mainScriptPath = path.join(__dirname, '..', 'src', 'main_english.js');
|
|
79
|
-
const mainScript = await fs.readFile(mainScriptPath, 'utf8');
|
|
80
|
-
|
|
81
|
-
// Check if auto-install case exists
|
|
82
|
-
const hasAutoInstallCase = mainScript.includes('case \'auto-install\':') ||
|
|
83
|
-
mainScript.includes('case "auto-install":');
|
|
84
|
-
|
|
85
|
-
if (hasAutoInstallCase) {
|
|
86
|
-
console.log(' ✓ auto-install command implemented');
|
|
87
|
-
} else {
|
|
88
|
-
console.log(' ✗ auto-install command not implemented');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Check if it includes error handling
|
|
92
|
-
const hasErrorHandling = mainScript.includes('try {') && mainScript.includes('catch');
|
|
93
|
-
|
|
94
|
-
this.testResults.push({
|
|
95
|
-
name: 'Auto-Install Command Implementation',
|
|
96
|
-
passed: hasAutoInstallCase,
|
|
97
|
-
details: hasAutoInstallCase ?
|
|
98
|
-
'auto-install command implemented' :
|
|
99
|
-
'auto-install command not implemented'
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
return hasAutoInstallCase;
|
|
103
|
-
} catch (error) {
|
|
104
|
-
console.log(` ✗ Failed to check auto-install command: ${error.message}`);
|
|
105
|
-
this.testResults.push({
|
|
106
|
-
name: 'Auto-Install Command Implementation',
|
|
107
|
-
passed: false,
|
|
108
|
-
details: `Failed to check: ${error.message}`
|
|
109
|
-
});
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Test 3: Verify graceful degradation and user guidance
|
|
115
|
-
async testGracefulDegradation() {
|
|
116
|
-
console.log('\n[TEST 3] Verifying graceful degradation and user guidance...');
|
|
117
|
-
|
|
118
|
-
try {
|
|
119
|
-
// Read main script
|
|
120
|
-
const mainScriptPath = path.join(__dirname, '..', 'src', 'main_english.js');
|
|
121
|
-
const mainScript = await fs.readFile(mainScriptPath, 'utf8');
|
|
122
|
-
|
|
123
|
-
// Check if auto-install includes user guidance
|
|
124
|
-
const hasUserGuidance = mainScript.includes('For full functionality') ||
|
|
125
|
-
mainScript.includes('please run') ||
|
|
126
|
-
mainScript.includes('stigmergy install') ||
|
|
127
|
-
mainScript.includes('stigmergy setup');
|
|
128
|
-
|
|
129
|
-
if (hasUserGuidance) {
|
|
130
|
-
console.log(' ✓ User guidance messages found in auto-install');
|
|
131
|
-
} else {
|
|
132
|
-
console.log(' ✗ User guidance messages not found in auto-install');
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Check if it handles missing tools gracefully
|
|
136
|
-
const hasMissingToolsHandling = mainScript.includes('Skipping automatic installation') ||
|
|
137
|
-
mainScript.includes('missing AI CLI tools') ||
|
|
138
|
-
mainScript.includes('autoMissing');
|
|
139
|
-
|
|
140
|
-
if (hasMissingToolsHandling) {
|
|
141
|
-
console.log(' ✓ Missing tools handling found in auto-install');
|
|
142
|
-
} else {
|
|
143
|
-
console.log(' ✗ Missing tools handling not found in auto-install');
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// Check if it shows success message
|
|
147
|
-
const hasSuccessMessage = mainScript.includes('SUCCESS') &&
|
|
148
|
-
mainScript.includes('installed successfully');
|
|
149
|
-
|
|
150
|
-
this.testResults.push({
|
|
151
|
-
name: 'Graceful Degradation and Guidance',
|
|
152
|
-
passed: hasUserGuidance && hasMissingToolsHandling && hasSuccessMessage,
|
|
153
|
-
details: `User guidance: ${hasUserGuidance}, Missing tools handling: ${hasMissingToolsHandling}, Success message: ${hasSuccessMessage}`
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
return hasUserGuidance && hasMissingToolsHandling && hasSuccessMessage;
|
|
157
|
-
} catch (error) {
|
|
158
|
-
console.log(` ✗ Failed to check graceful degradation: ${error.message}`);
|
|
159
|
-
this.testResults.push({
|
|
160
|
-
name: 'Graceful Degradation and Guidance',
|
|
161
|
-
passed: false,
|
|
162
|
-
details: `Failed to check: ${error.message}`
|
|
163
|
-
});
|
|
164
|
-
return false;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// Test 4: Verify error handling in auto-install
|
|
169
|
-
async testErrorHandling() {
|
|
170
|
-
console.log('\n[TEST 4] Verifying error handling in auto-install...');
|
|
171
|
-
|
|
172
|
-
try {
|
|
173
|
-
// Read main script
|
|
174
|
-
const mainScriptPath = path.join(__dirname, '..', 'src', 'main_english.js');
|
|
175
|
-
const mainScript = await fs.readFile(mainScriptPath, 'utf8');
|
|
176
|
-
|
|
177
|
-
// Check if main function has error handling
|
|
178
|
-
const hasMainErrorHandling = mainScript.includes('main().catch') ||
|
|
179
|
-
mainScript.includes('try {') && mainScript.includes('catch');
|
|
180
|
-
|
|
181
|
-
if (hasMainErrorHandling) {
|
|
182
|
-
console.log(' ✓ Main function has error handling');
|
|
183
|
-
} else {
|
|
184
|
-
console.log(' ✗ Main function missing error handling');
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// Check if auto-install has specific error handling
|
|
188
|
-
const autoInstallSection = mainScript.split('case \'auto-install\':')[1] ||
|
|
189
|
-
mainScript.split('case "auto-install":')[1] || '';
|
|
190
|
-
|
|
191
|
-
const hasAutoInstallErrorHandling = autoInstallSection.includes('try {') &&
|
|
192
|
-
autoInstallSection.includes('catch');
|
|
193
|
-
|
|
194
|
-
this.testResults.push({
|
|
195
|
-
name: 'Error Handling',
|
|
196
|
-
passed: hasMainErrorHandling,
|
|
197
|
-
details: `Main error handling: ${hasMainErrorHandling}, Auto-install error handling: ${hasAutoInstallErrorHandling}`
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
return hasMainErrorHandling;
|
|
201
|
-
} catch (error) {
|
|
202
|
-
console.log(` ✗ Failed to check error handling: ${error.message}`);
|
|
203
|
-
this.testResults.push({
|
|
204
|
-
name: 'Error Handling',
|
|
205
|
-
passed: false,
|
|
206
|
-
details: `Failed to check: ${error.message}`
|
|
207
|
-
});
|
|
208
|
-
return false;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// Run all tests
|
|
213
|
-
async runAllTests() {
|
|
214
|
-
console.log('Postinstall Behavior and Error Handling Test');
|
|
215
|
-
console.log('='.repeat(50));
|
|
216
|
-
|
|
217
|
-
await this.testPostInstallScript();
|
|
218
|
-
await this.testAutoInstallCommand();
|
|
219
|
-
await this.testGracefulDegradation();
|
|
220
|
-
await this.testErrorHandling();
|
|
221
|
-
|
|
222
|
-
// Summary
|
|
223
|
-
console.log('\n' + '='.repeat(50));
|
|
224
|
-
console.log('Postinstall Test Summary:');
|
|
225
|
-
console.log('='.repeat(50));
|
|
226
|
-
|
|
227
|
-
let passedTests = 0;
|
|
228
|
-
this.testResults.forEach(result => {
|
|
229
|
-
console.log(`${result.name}: ${result.passed ? '✓ PASS' : '✗ FAIL'} - ${result.details}`);
|
|
230
|
-
if (result.passed) passedTests++;
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
console.log(`\nOverall Result: ${passedTests}/${this.testResults.length} tests passed`);
|
|
234
|
-
|
|
235
|
-
if (passedTests === this.testResults.length) {
|
|
236
|
-
console.log('✓ All postinstall tests passed! Package should work correctly.');
|
|
237
|
-
} else if (passedTests > 0) {
|
|
238
|
-
console.log('⚠ Some postinstall tests failed. Package may need improvements.');
|
|
239
|
-
} else {
|
|
240
|
-
console.log('✗ All postinstall tests failed. Package needs significant improvements.');
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
return {
|
|
244
|
-
totalTests: this.testResults.length,
|
|
245
|
-
passedTests: passedTests,
|
|
246
|
-
results: this.testResults
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
// Run the tests
|
|
252
|
-
async function runPostInstallTests() {
|
|
253
|
-
const tester = new PostInstallTester();
|
|
254
|
-
const results = await tester.runAllTests();
|
|
255
|
-
return results;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// Export for use in other modules
|
|
259
|
-
module.exports = { PostInstallTester };
|
|
260
|
-
|
|
261
|
-
// Run if called directly
|
|
262
|
-
if (require.main === module) {
|
|
263
|
-
runPostInstallTests().then(results => {
|
|
264
|
-
process.exit(results.passedTests === results.totalTests ? 0 : 1);
|
|
265
|
-
}).catch(error => {
|
|
266
|
-
console.error('[Test Failed]:', error.message);
|
|
267
|
-
process.exit(1);
|
|
268
|
-
});
|
|
269
|
-
}
|