stigmergy 1.2.6 → 1.2.8

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.
Files changed (59) hide show
  1. package/README.md +32 -17
  2. package/STIGMERGY.md +16 -7
  3. package/docs/MULTI_USER_WIKI_COLLABORATION_SYSTEM.md +523 -0
  4. package/docs/PROMPT_BASED_SKILLS_SYSTEM_DESIGN.md +458 -0
  5. package/docs/SKILL_IMPLEMENTATION_CONSTRAINTS_AND_ALIGNMENT.md +423 -0
  6. package/docs/TECHNICAL_FEASIBILITY_ANALYSIS.md +308 -0
  7. package/examples/multilingual-hook-demo.js +125 -0
  8. package/package.json +14 -17
  9. package/scripts/dependency-analyzer.js +101 -0
  10. package/scripts/generate-cli-docs.js +64 -0
  11. package/scripts/postuninstall.js +46 -0
  12. package/scripts/preuninstall.js +75 -0
  13. package/scripts/run-layered-tests.js +3 -3
  14. package/src/adapters/claude/install_claude_integration.js +17 -17
  15. package/src/adapters/codebuddy/install_codebuddy_integration.js +13 -13
  16. package/src/adapters/codex/install_codex_integration.js +27 -27
  17. package/src/adapters/copilot/install_copilot_integration.js +46 -46
  18. package/src/adapters/gemini/install_gemini_integration.js +10 -10
  19. package/src/adapters/iflow/install_iflow_integration.js +7 -7
  20. package/src/adapters/qoder/install_qoder_integration.js +12 -12
  21. package/src/adapters/qwen/install_qwen_integration.js +17 -17
  22. package/src/auth.js +173 -173
  23. package/src/auth_command.js +208 -208
  24. package/src/calculator.js +313 -313
  25. package/src/cli/router.js +151 -7
  26. package/src/core/cache_cleaner.js +767 -767
  27. package/src/core/cli_help_analyzer.js +680 -680
  28. package/src/core/cli_parameter_handler.js +132 -132
  29. package/src/core/cli_tools.js +89 -89
  30. package/src/core/coordination/index.js +16 -16
  31. package/src/core/coordination/nodejs/AdapterManager.js +102 -102
  32. package/src/core/coordination/nodejs/CLCommunication.js +132 -132
  33. package/src/core/coordination/nodejs/CLIIntegrationManager.js +272 -272
  34. package/src/core/coordination/nodejs/HealthChecker.js +76 -76
  35. package/src/core/coordination/nodejs/HookDeploymentManager.js +463 -274
  36. package/src/core/coordination/nodejs/StatisticsCollector.js +71 -71
  37. package/src/core/coordination/nodejs/index.js +90 -90
  38. package/src/core/coordination/nodejs/utils/Logger.js +29 -29
  39. package/src/core/enhanced_installer.js +479 -479
  40. package/src/core/enhanced_uninstaller.js +638 -638
  41. package/src/core/error_handler.js +406 -406
  42. package/src/core/installer.js +32 -32
  43. package/src/core/memory_manager.js +83 -83
  44. package/src/core/multilingual/language-pattern-manager.js +172 -0
  45. package/src/core/rest_client.js +160 -160
  46. package/src/core/smart_router.js +261 -249
  47. package/src/core/upgrade_manager.js +48 -20
  48. package/src/data_encryption.js +143 -143
  49. package/src/data_structures.js +440 -440
  50. package/src/deploy.js +55 -55
  51. package/src/index.js +30 -30
  52. package/src/test/cli-availability-checker.js +194 -194
  53. package/src/test/test-environment.js +289 -289
  54. package/src/utils/helpers.js +35 -35
  55. package/src/utils.js +921 -921
  56. package/src/weatherProcessor.js +228 -228
  57. package/test/multilingual/hook-deployment.test.js +91 -0
  58. package/test/multilingual/language-pattern-manager.test.js +140 -0
  59. package/test/multilingual/system-test.js +85 -0
@@ -1,102 +1,102 @@
1
- // src/core/coordination/nodejs/AdapterManager.js
2
- const fs = require('fs');
3
- const path = require('path');
4
- const os = require('os');
5
-
6
- class AdapterManager {
7
- constructor() {
8
- this.adapters = new Map();
9
- this.discoveryPaths = [
10
- path.join(__dirname, '..', '..', '..', 'adapters'),
11
- path.join(os.homedir(), '.stigmergy', 'adapters'),
12
- ];
13
- }
14
-
15
- async initialize() {
16
- console.log('[ADAPTER_MANAGER] Initializing adapter manager...');
17
- await this.discoverAdapters();
18
- }
19
-
20
- async discoverAdapters() {
21
- console.log('[ADAPTER_MANAGER] Discovering adapters...');
22
-
23
- for (const basePath of this.discoveryPaths) {
24
- if (fs.existsSync(basePath)) {
25
- try {
26
- const adapterDirs = fs
27
- .readdirSync(basePath, { withFileTypes: true })
28
- .filter((dirent) => dirent.isDirectory())
29
- .map((dirent) => dirent.name);
30
-
31
- console.log(
32
- `[ADAPTER_MANAGER] Found ${adapterDirs.length} adapter directories in ${basePath}`,
33
- );
34
-
35
- for (const dir of adapterDirs) {
36
- await this.loadAdapter(dir, basePath);
37
- }
38
- } catch (error) {
39
- console.warn(
40
- `[ADAPTER_MANAGER] Failed to read adapter directory ${basePath}:`,
41
- error.message,
42
- );
43
- }
44
- } else {
45
- console.log(
46
- `[ADAPTER_MANAGER] Adapter path does not exist: ${basePath}`,
47
- );
48
- }
49
- }
50
- }
51
-
52
- async loadAdapter(adapterName, basePath) {
53
- const adapterPath = path.join(basePath, adapterName, 'index.js');
54
-
55
- if (fs.existsSync(adapterPath)) {
56
- try {
57
- // Create a simple adapter wrapper for Node.js
58
- const adapter = {
59
- name: adapterName,
60
- path: adapterPath,
61
- available: true,
62
- version: '1.0.0-nodejs',
63
- isAvailable: async () => true,
64
- executeTask: async (task, context) => {
65
- // Simple task execution simulation
66
- return `[${adapterName.toUpperCase()} NODE.JS ADAPTER] Executed: ${task}`;
67
- },
68
- };
69
-
70
- this.adapters.set(adapterName, adapter);
71
- console.log(`[ADAPTER_MANAGER] Loaded Node.js adapter: ${adapterName}`);
72
- } catch (error) {
73
- console.warn(
74
- `[ADAPTER_MANAGER] Failed to load adapter from ${adapterPath}:`,
75
- error.message,
76
- );
77
- }
78
- } else {
79
- console.log(
80
- `[ADAPTER_MANAGER] Adapter index.js not found for: ${adapterName}`,
81
- );
82
- }
83
- }
84
-
85
- getAdapter(cliName) {
86
- return this.adapters.get(cliName.toLowerCase());
87
- }
88
-
89
- async listAdapters() {
90
- const adapterList = [];
91
- for (const [name, adapter] of this.adapters) {
92
- adapterList.push({
93
- name,
94
- available: await adapter.isAvailable(),
95
- version: adapter.version || 'unknown',
96
- });
97
- }
98
- return adapterList;
99
- }
100
- }
101
-
102
- module.exports = AdapterManager;
1
+ // src/core/coordination/nodejs/AdapterManager.js
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const os = require('os');
5
+
6
+ class AdapterManager {
7
+ constructor() {
8
+ this.adapters = new Map();
9
+ this.discoveryPaths = [
10
+ path.join(__dirname, '..', '..', '..', 'adapters'),
11
+ path.join(os.homedir(), '.stigmergy', 'adapters'),
12
+ ];
13
+ }
14
+
15
+ async initialize() {
16
+ console.log('[ADAPTER_MANAGER] Initializing adapter manager...');
17
+ await this.discoverAdapters();
18
+ }
19
+
20
+ async discoverAdapters() {
21
+ console.log('[ADAPTER_MANAGER] Discovering adapters...');
22
+
23
+ for (const basePath of this.discoveryPaths) {
24
+ if (fs.existsSync(basePath)) {
25
+ try {
26
+ const adapterDirs = fs
27
+ .readdirSync(basePath, { withFileTypes: true })
28
+ .filter((dirent) => dirent.isDirectory())
29
+ .map((dirent) => dirent.name);
30
+
31
+ console.log(
32
+ `[ADAPTER_MANAGER] Found ${adapterDirs.length} adapter directories in ${basePath}`,
33
+ );
34
+
35
+ for (const dir of adapterDirs) {
36
+ await this.loadAdapter(dir, basePath);
37
+ }
38
+ } catch (error) {
39
+ console.warn(
40
+ `[ADAPTER_MANAGER] Failed to read adapter directory ${basePath}:`,
41
+ error.message,
42
+ );
43
+ }
44
+ } else {
45
+ console.log(
46
+ `[ADAPTER_MANAGER] Adapter path does not exist: ${basePath}`,
47
+ );
48
+ }
49
+ }
50
+ }
51
+
52
+ async loadAdapter(adapterName, basePath) {
53
+ const adapterPath = path.join(basePath, adapterName, 'index.js');
54
+
55
+ if (fs.existsSync(adapterPath)) {
56
+ try {
57
+ // Create a simple adapter wrapper for Node.js
58
+ const adapter = {
59
+ name: adapterName,
60
+ path: adapterPath,
61
+ available: true,
62
+ version: '1.0.0-nodejs',
63
+ isAvailable: async () => true,
64
+ executeTask: async (task, context) => {
65
+ // Simple task execution simulation
66
+ return `[${adapterName.toUpperCase()} NODE.JS ADAPTER] Executed: ${task}`;
67
+ },
68
+ };
69
+
70
+ this.adapters.set(adapterName, adapter);
71
+ console.log(`[ADAPTER_MANAGER] Loaded Node.js adapter: ${adapterName}`);
72
+ } catch (error) {
73
+ console.warn(
74
+ `[ADAPTER_MANAGER] Failed to load adapter from ${adapterPath}:`,
75
+ error.message,
76
+ );
77
+ }
78
+ } else {
79
+ console.log(
80
+ `[ADAPTER_MANAGER] Adapter index.js not found for: ${adapterName}`,
81
+ );
82
+ }
83
+ }
84
+
85
+ getAdapter(cliName) {
86
+ return this.adapters.get(cliName.toLowerCase());
87
+ }
88
+
89
+ async listAdapters() {
90
+ const adapterList = [];
91
+ for (const [name, adapter] of this.adapters) {
92
+ adapterList.push({
93
+ name,
94
+ available: await adapter.isAvailable(),
95
+ version: adapter.version || 'unknown',
96
+ });
97
+ }
98
+ return adapterList;
99
+ }
100
+ }
101
+
102
+ module.exports = AdapterManager;
@@ -1,132 +1,132 @@
1
- // src/core/coordination/nodejs/CLCommunication.js
2
- const { spawn } = require('child_process');
3
- const path = require('path');
4
-
5
- class CLCommunication {
6
- constructor() {
7
- this.executionTimeout = 30000; // 30 seconds
8
- }
9
-
10
- async initialize() {
11
- console.log('[CL_COMMUNICATION] Initializing cross-CLI communication...');
12
- }
13
-
14
- async executeTask(sourceCLI, targetCLI, task, context) {
15
- console.log(
16
- `[CL_COMMUNICATION] Executing task from ${sourceCLI} to ${targetCLI}: ${task}`,
17
- );
18
-
19
- try {
20
- // Execute the target CLI with the task
21
- const result = await this.executeCLICommand(targetCLI, task);
22
- return result;
23
- } catch (error) {
24
- console.error(
25
- `[CL_COMMUNICATION] Failed to execute task for ${targetCLI}:`,
26
- error,
27
- );
28
- throw error;
29
- }
30
- }
31
-
32
- async executeCLICommand(cliName, task) {
33
- return new Promise((resolve, reject) => {
34
- // Prepare arguments based on the CLI type for non-interactive execution
35
- const args = this.prepareCLIArguments(cliName, task);
36
-
37
- // Spawn the CLI command
38
- const child = spawn(cliName, args, {
39
- encoding: 'utf8',
40
- timeout: this.executionTimeout,
41
- shell: true,
42
- });
43
-
44
- let stdout = '';
45
- let stderr = '';
46
-
47
- child.stdout.on('data', (data) => {
48
- stdout += data.toString();
49
- });
50
-
51
- child.stderr.on('data', (data) => {
52
- stderr += data.toString();
53
- });
54
-
55
- child.on('close', (code) => {
56
- if (code === 0) {
57
- resolve({
58
- success: true,
59
- output: stdout.trim(),
60
- code: code,
61
- });
62
- } else {
63
- reject({
64
- success: false,
65
- error:
66
- stderr.trim() ||
67
- stdout.trim() ||
68
- `Process exited with code ${code}`,
69
- code: code,
70
- });
71
- }
72
- });
73
-
74
- child.on('error', (error) => {
75
- reject({
76
- success: false,
77
- error: `Failed to spawn process: ${error.message}`,
78
- code: null,
79
- });
80
- });
81
-
82
- child.on('timeout', () => {
83
- child.kill();
84
- reject({
85
- success: false,
86
- error: `Command timed out after ${this.executionTimeout}ms`,
87
- code: null,
88
- });
89
- });
90
- });
91
- }
92
-
93
- prepareCLIArguments(cliName, task) {
94
- // Prepare arguments based on the CLI type for non-interactive execution
95
- const cliTypes = {
96
- // CLIs that support -p flag for prompt
97
- claude: ['-p', task],
98
- qwen: ['-p', task],
99
- gemini: ['-p', task],
100
- iflow: ['-p', task],
101
- // CLIs that support direct prompt as argument
102
- qodercli: [task],
103
- codebuddy: [task],
104
- copilot: [task],
105
- codex: [task],
106
- };
107
-
108
- const args = cliTypes[cliName];
109
- return args || ['-p', task]; // Default to -p flag if not specified
110
- }
111
-
112
- getAdapter(cliName) {
113
- // Return a real adapter that can execute CLI commands
114
- return {
115
- name: cliName,
116
- executeTask: async (task, context) => {
117
- try {
118
- const result = await this.executeCLICommand(cliName, task);
119
- return result.output;
120
- } catch (error) {
121
- return `[${cliName.toUpperCase()} ERROR] ${error.error || error.message}`;
122
- }
123
- },
124
- };
125
- }
126
-
127
- generateTaskId() {
128
- return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
129
- }
130
- }
131
-
132
- module.exports = CLCommunication;
1
+ // src/core/coordination/nodejs/CLCommunication.js
2
+ const { spawn } = require('child_process');
3
+ const path = require('path');
4
+
5
+ class CLCommunication {
6
+ constructor() {
7
+ this.executionTimeout = 30000; // 30 seconds
8
+ }
9
+
10
+ async initialize() {
11
+ console.log('[CL_COMMUNICATION] Initializing cross-CLI communication...');
12
+ }
13
+
14
+ async executeTask(sourceCLI, targetCLI, task, context) {
15
+ console.log(
16
+ `[CL_COMMUNICATION] Executing task from ${sourceCLI} to ${targetCLI}: ${task}`,
17
+ );
18
+
19
+ try {
20
+ // Execute the target CLI with the task
21
+ const result = await this.executeCLICommand(targetCLI, task);
22
+ return result;
23
+ } catch (error) {
24
+ console.error(
25
+ `[CL_COMMUNICATION] Failed to execute task for ${targetCLI}:`,
26
+ error,
27
+ );
28
+ throw error;
29
+ }
30
+ }
31
+
32
+ async executeCLICommand(cliName, task) {
33
+ return new Promise((resolve, reject) => {
34
+ // Prepare arguments based on the CLI type for non-interactive execution
35
+ const args = this.prepareCLIArguments(cliName, task);
36
+
37
+ // Spawn the CLI command
38
+ const child = spawn(cliName, args, {
39
+ encoding: 'utf8',
40
+ timeout: this.executionTimeout,
41
+ shell: true,
42
+ });
43
+
44
+ let stdout = '';
45
+ let stderr = '';
46
+
47
+ child.stdout.on('data', (data) => {
48
+ stdout += data.toString();
49
+ });
50
+
51
+ child.stderr.on('data', (data) => {
52
+ stderr += data.toString();
53
+ });
54
+
55
+ child.on('close', (code) => {
56
+ if (code === 0) {
57
+ resolve({
58
+ success: true,
59
+ output: stdout.trim(),
60
+ code: code,
61
+ });
62
+ } else {
63
+ reject({
64
+ success: false,
65
+ error:
66
+ stderr.trim() ||
67
+ stdout.trim() ||
68
+ `Process exited with code ${code}`,
69
+ code: code,
70
+ });
71
+ }
72
+ });
73
+
74
+ child.on('error', (error) => {
75
+ reject({
76
+ success: false,
77
+ error: `Failed to spawn process: ${error.message}`,
78
+ code: null,
79
+ });
80
+ });
81
+
82
+ child.on('timeout', () => {
83
+ child.kill();
84
+ reject({
85
+ success: false,
86
+ error: `Command timed out after ${this.executionTimeout}ms`,
87
+ code: null,
88
+ });
89
+ });
90
+ });
91
+ }
92
+
93
+ prepareCLIArguments(cliName, task) {
94
+ // Prepare arguments based on the CLI type for non-interactive execution
95
+ const cliTypes = {
96
+ // CLIs that support -p flag for prompt
97
+ claude: ['-p', task],
98
+ qwen: ['-p', task],
99
+ gemini: ['-p', task],
100
+ iflow: ['-p', task],
101
+ // CLIs that support direct prompt as argument
102
+ qodercli: [task],
103
+ codebuddy: [task],
104
+ copilot: [task],
105
+ codex: [task],
106
+ };
107
+
108
+ const args = cliTypes[cliName];
109
+ return args || ['-p', task]; // Default to -p flag if not specified
110
+ }
111
+
112
+ getAdapter(cliName) {
113
+ // Return a real adapter that can execute CLI commands
114
+ return {
115
+ name: cliName,
116
+ executeTask: async (task, context) => {
117
+ try {
118
+ const result = await this.executeCLICommand(cliName, task);
119
+ return result.output;
120
+ } catch (error) {
121
+ return `[${cliName.toUpperCase()} ERROR] ${error.error || error.message}`;
122
+ }
123
+ },
124
+ };
125
+ }
126
+
127
+ generateTaskId() {
128
+ return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
129
+ }
130
+ }
131
+
132
+ module.exports = CLCommunication;