stigmergy 1.2.13 → 1.3.2-beta.0

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 (48) hide show
  1. package/README.md +39 -3
  2. package/STIGMERGY.md +3 -0
  3. package/config/enhanced-cli-config.json +438 -0
  4. package/docs/CLI_TOOLS_AGENT_SKILL_ANALYSIS.md +463 -0
  5. package/docs/ENHANCED_CLI_AGENT_SKILL_CONFIG.md +285 -0
  6. package/docs/INSTALLER_ARCHITECTURE.md +257 -0
  7. package/docs/SUDO_PROBLEM_AND_SOLUTION.md +529 -0
  8. package/package.json +14 -5
  9. package/scripts/analyze-router.js +168 -0
  10. package/scripts/test-runner.js +344 -0
  11. package/src/cli/commands/autoinstall.js +158 -0
  12. package/src/cli/commands/errors.js +190 -0
  13. package/src/cli/commands/install.js +142 -0
  14. package/src/cli/commands/permissions.js +108 -0
  15. package/src/cli/commands/project.js +449 -0
  16. package/src/cli/commands/resume.js +136 -0
  17. package/src/cli/commands/scan.js +97 -0
  18. package/src/cli/commands/skills.js +158 -0
  19. package/src/cli/commands/status.js +106 -0
  20. package/src/cli/commands/system.js +301 -0
  21. package/src/cli/router-beta.js +477 -0
  22. package/src/cli/utils/environment.js +75 -0
  23. package/src/cli/utils/formatters.js +47 -0
  24. package/src/cli/utils/skills_cache.js +92 -0
  25. package/src/core/cache_cleaner.js +1 -0
  26. package/src/core/cli_adapters.js +345 -0
  27. package/src/core/cli_help_analyzer.js +473 -1
  28. package/src/core/cli_path_detector.js +2 -1
  29. package/src/core/cli_tools.js +107 -0
  30. package/src/core/coordination/nodejs/HookDeploymentManager.js +185 -422
  31. package/src/core/coordination/nodejs/HookDeploymentManager.refactored.js +323 -0
  32. package/src/core/coordination/nodejs/generators/CLIAdapterGenerator.js +363 -0
  33. package/src/core/coordination/nodejs/generators/ResumeSessionGenerator.js +701 -0
  34. package/src/core/coordination/nodejs/generators/SkillsIntegrationGenerator.js +1210 -0
  35. package/src/core/coordination/nodejs/generators/index.js +12 -0
  36. package/src/core/enhanced_cli_installer.js +220 -30
  37. package/src/core/enhanced_cli_parameter_handler.js +395 -0
  38. package/src/core/execution_mode_detector.js +222 -0
  39. package/src/core/installer.js +51 -70
  40. package/src/core/local_skill_scanner.js +732 -0
  41. package/src/core/multilingual/language-pattern-manager.js +1 -1
  42. package/src/core/skills/StigmergySkillManager.js +26 -8
  43. package/src/core/smart_router.js +279 -2
  44. package/src/index.js +10 -4
  45. package/test/cli-integration.test.js +304 -0
  46. package/test/enhanced-cli-agent-skill-test.js +485 -0
  47. package/test/specific-cli-agent-skill-analysis.js +385 -0
  48. package/src/cli/router.js +0 -1783
@@ -0,0 +1,345 @@
1
+ /**
2
+ * CLI Tools Adapters
3
+ * Provides tool-specific parameter mapping for interactive and one-time modes
4
+ *
5
+ * Each CLI tool has different parameter conventions:
6
+ * - claude: Uses -p for one-time, default is interactive
7
+ * - qwen: Uses -p for one-time, -i for prompt-interactive
8
+ * - codex: Uses 'exec' subcommand for one-time, default is interactive
9
+ *
10
+ * This adapter normalizes these differences.
11
+ */
12
+
13
+ /**
14
+ * CLI Adapters Configuration
15
+ * Maps each tool's parameters for different execution modes
16
+ */
17
+ const CLI_ADAPTERS = {
18
+ /**
19
+ * Claude CLI Adapter
20
+ *
21
+ * Documentation:
22
+ * - Default: Interactive mode
23
+ * - -p, --print: Non-interactive (print and exit)
24
+ *
25
+ * Examples:
26
+ * - Interactive: claude "prompt" or just claude
27
+ * - One-time: claude -p "prompt"
28
+ */
29
+ claude: {
30
+ // Execute prompt and keep CLI running for continuous conversation
31
+ interactive: (prompt) => {
32
+ // Claude defaults to interactive mode
33
+ // If prompt provided, pass it as positional argument
34
+ return prompt ? [prompt] : [];
35
+ },
36
+
37
+ // Execute prompt and exit (return control to caller)
38
+ oneTime: (prompt) => {
39
+ // Use -p flag for non-interactive output
40
+ return ['-p', prompt];
41
+ },
42
+
43
+ // Check if tool supports this mode
44
+ supportsInteractive: true,
45
+ supportsOneTime: true,
46
+ defaultMode: 'interactive'
47
+ },
48
+
49
+ /**
50
+ * Gemini CLI Adapter
51
+ *
52
+ * Note: Full behavior to be verified (may vary by version)
53
+ */
54
+ gemini: {
55
+ interactive: (prompt) => {
56
+ // Assuming similar to claude (to be verified)
57
+ return prompt ? [prompt] : [];
58
+ },
59
+
60
+ oneTime: (prompt) => {
61
+ // Assuming -p for print mode (to be verified)
62
+ return ['-p', prompt];
63
+ },
64
+
65
+ supportsInteractive: true,
66
+ supportsOneTime: true,
67
+ defaultMode: 'interactive',
68
+ verified: false // Needs testing
69
+ },
70
+
71
+ /**
72
+ * Qwen CLI Adapter
73
+ *
74
+ * Documentation:
75
+ * - Default: Interactive CLI
76
+ * - -p, --prompt: One-shot (deprecated)
77
+ * - -i, --prompt-interactive: Execute prompt then stay interactive
78
+ *
79
+ * Examples:
80
+ * - Interactive: qwen -i "prompt" or just qwen
81
+ * - One-time: qwen -p "prompt" (deprecated) or qwen "prompt" (positional, one-shot)
82
+ */
83
+ qwen: {
84
+ interactive: (prompt) => {
85
+ // Use -i flag for "prompt-interactive" mode
86
+ // This executes the prompt and then keeps the CLI running
87
+ return prompt ? ['-i', prompt] : [];
88
+ },
89
+
90
+ oneTime: (prompt) => {
91
+ // Use -p for one-shot mode (though deprecated, still works)
92
+ // Or could use positional prompt (which defaults to one-shot)
93
+ return ['-p', prompt];
94
+ },
95
+
96
+ supportsInteractive: true,
97
+ supportsOneTime: true,
98
+ defaultMode: 'interactive',
99
+ verified: true
100
+ },
101
+
102
+ /**
103
+ * Codebuddy CLI Adapter
104
+ *
105
+ * Note: Behavior to be verified
106
+ */
107
+ codebuddy: {
108
+ interactive: (prompt) => {
109
+ return prompt ? [prompt] : [];
110
+ },
111
+
112
+ oneTime: (prompt) => {
113
+ // Assuming -p for print mode (to be verified)
114
+ return ['-p', prompt];
115
+ },
116
+
117
+ supportsInteractive: true,
118
+ supportsOneTime: true,
119
+ defaultMode: 'interactive',
120
+ verified: false
121
+ },
122
+
123
+ /**
124
+ * Codex CLI Adapter
125
+ *
126
+ * Documentation:
127
+ * - Default: Interactive CLI
128
+ * - 'exec' subcommand: Non-interactive execution
129
+ *
130
+ * Examples:
131
+ * - Interactive: codex "prompt" or just codex
132
+ * - One-time: codex exec "prompt"
133
+ */
134
+ codex: {
135
+ interactive: (prompt) => {
136
+ // Codex defaults to interactive mode
137
+ // If prompt provided, pass it as positional argument
138
+ return prompt ? [prompt] : [];
139
+ },
140
+
141
+ oneTime: (prompt) => {
142
+ // Use 'exec' subcommand for non-interactive execution
143
+ return ['exec', prompt];
144
+ },
145
+
146
+ supportsInteractive: true,
147
+ supportsOneTime: true,
148
+ defaultMode: 'interactive',
149
+ verified: true
150
+ },
151
+
152
+ /**
153
+ * iFlow CLI Adapter
154
+ *
155
+ * Note: Behavior to be verified
156
+ */
157
+ iflow: {
158
+ interactive: (prompt) => {
159
+ return prompt ? [prompt] : [];
160
+ },
161
+
162
+ oneTime: (prompt) => {
163
+ return ['-p', prompt];
164
+ },
165
+
166
+ supportsInteractive: true,
167
+ supportsOneTime: true,
168
+ defaultMode: 'interactive',
169
+ verified: false
170
+ },
171
+
172
+ /**
173
+ * QoderCLI Adapter
174
+ *
175
+ * Note: Behavior to be verified
176
+ */
177
+ qodercli: {
178
+ interactive: (prompt) => {
179
+ return prompt ? [prompt] : [];
180
+ },
181
+
182
+ oneTime: (prompt) => {
183
+ return ['-p', prompt];
184
+ },
185
+
186
+ supportsInteractive: true,
187
+ supportsOneTime: true,
188
+ defaultMode: 'interactive',
189
+ verified: false
190
+ },
191
+
192
+ /**
193
+ * Copilot CLI Adapter
194
+ *
195
+ * Note: Behavior to be verified
196
+ */
197
+ copilot: {
198
+ interactive: (prompt) => {
199
+ return prompt ? [prompt] : [];
200
+ },
201
+
202
+ oneTime: (prompt) => {
203
+ return ['-p', prompt];
204
+ },
205
+
206
+ supportsInteractive: true,
207
+ supportsOneTime: true,
208
+ defaultMode: 'interactive',
209
+ verified: false
210
+ },
211
+
212
+ /**
213
+ * Kode CLI Adapter
214
+ *
215
+ * Note: Behavior to be verified
216
+ */
217
+ kode: {
218
+ interactive: (prompt) => {
219
+ return prompt ? [prompt] : [];
220
+ },
221
+
222
+ oneTime: (prompt) => {
223
+ return ['-p', prompt];
224
+ },
225
+
226
+ supportsInteractive: true,
227
+ supportsOneTime: true,
228
+ defaultMode: 'interactive',
229
+ verified: false
230
+ }
231
+ };
232
+
233
+ /**
234
+ * CLI Adapter Class
235
+ * Provides methods to get appropriate arguments for each tool and mode
236
+ */
237
+ class CLIAdapterManager {
238
+ constructor() {
239
+ this.adapters = CLI_ADAPTERS;
240
+ }
241
+
242
+ /**
243
+ * Get arguments for a specific tool and execution mode
244
+ * @param {string} toolName - Name of the CLI tool
245
+ * @param {string} mode - 'interactive' or 'one-time'
246
+ * @param {string} prompt - User prompt to pass
247
+ * @returns {Array<string>} Array of arguments to pass to the CLI tool
248
+ */
249
+ getArguments(toolName, mode, prompt) {
250
+ const adapter = this.adapters[toolName];
251
+
252
+ if (!adapter) {
253
+ throw new Error(`Unknown CLI tool: ${toolName}`);
254
+ }
255
+
256
+ // Normalize mode name: 'one-time' -> 'oneTime', 'interactive' -> 'interactive'
257
+ const normalizedMode = mode === 'one-time' ? 'oneTime' : mode;
258
+
259
+ const modeFunction = adapter[normalizedMode];
260
+
261
+ if (typeof modeFunction !== 'function') {
262
+ throw new Error(`Tool ${toolName} does not support ${mode} mode`);
263
+ }
264
+
265
+ return modeFunction(prompt);
266
+ }
267
+
268
+ /**
269
+ * Check if a tool supports a specific mode
270
+ * @param {string} toolName - Name of the CLI tool
271
+ * @param {string} mode - 'interactive' or 'one-time'
272
+ * @returns {boolean} True if supported
273
+ */
274
+ supportsMode(toolName, mode) {
275
+ const adapter = this.adapters[toolName];
276
+ return adapter && adapter.supports && adapter.supports.includes(mode);
277
+ }
278
+
279
+ /**
280
+ * Get the default mode for a tool
281
+ * @param {string} toolName - Name of the CLI tool
282
+ * @returns {string} 'interactive' or 'one-time'
283
+ */
284
+ getDefaultMode(toolName) {
285
+ const adapter = this.adapters[toolName];
286
+ return adapter ? adapter.defaultMode : 'one-time';
287
+ }
288
+
289
+ /**
290
+ * Check if tool configuration has been verified
291
+ * @param {string} toolName - Name of the CLI tool
292
+ * @returns {boolean} True if configuration is verified
293
+ */
294
+ isVerified(toolName) {
295
+ const adapter = this.adapters[toolName];
296
+ return adapter ? adapter.verified === true : false;
297
+ }
298
+
299
+ /**
300
+ * Get list of all supported tools
301
+ * @returns {Array<string>} Array of tool names
302
+ */
303
+ getSupportedTools() {
304
+ return Object.keys(this.adapters);
305
+ }
306
+
307
+ /**
308
+ * Get adapter information for a tool
309
+ * @param {string} toolName - Name of the CLI tool
310
+ * @returns {Object} Adapter configuration
311
+ */
312
+ getAdapterInfo(toolName) {
313
+ return this.adapters[toolName] || null;
314
+ }
315
+
316
+ /**
317
+ * Print adapter configuration (for debugging)
318
+ * @param {string} toolName - Name of the CLI tool
319
+ * @param {boolean} verbose - Show detailed information
320
+ */
321
+ printAdapterInfo(toolName, verbose = false) {
322
+ const adapter = this.adapters[toolName];
323
+
324
+ if (!adapter) {
325
+ console.log(`[ADAPTER] No adapter found for: ${toolName}`);
326
+ return;
327
+ }
328
+
329
+ console.log(`[ADAPTER] ${toolName} Configuration:`);
330
+ console.log(` - Supports Interactive: ${adapter.supportsInteractive ? '✅' : '❌'}`);
331
+ console.log(` - Supports One-Time: ${adapter.supportsOneTime ? '✅' : '❌'}`);
332
+ console.log(` - Default Mode: ${adapter.defaultMode}`);
333
+ console.log(` - Verified: ${adapter.verified ? '✅' : '⚠️ (needs testing)'}`);
334
+
335
+ if (verbose && adapter.supportsInteractive && adapter.supportsOneTime) {
336
+ console.log(` - Interactive Example: ${toolName} ${this.getArguments(toolName, 'interactive', 'your prompt').join(' ')}`);
337
+ console.log(` - One-Time Example: ${toolName} ${this.getArguments(toolName, 'one-time', 'your prompt').join(' ')}`);
338
+ }
339
+ }
340
+ }
341
+
342
+ module.exports = {
343
+ CLI_ADAPTERS,
344
+ CLIAdapterManager
345
+ };