cli4ai 1.1.5 → 1.2.1

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 (113) hide show
  1. package/README.md +39 -0
  2. package/dist/bin.d.ts +6 -0
  3. package/dist/bin.js +105 -0
  4. package/dist/cli.d.ts +5 -0
  5. package/dist/cli.js +335 -0
  6. package/dist/commands/add.d.ts +11 -0
  7. package/dist/commands/add.js +459 -0
  8. package/dist/commands/browse.d.ts +4 -0
  9. package/dist/commands/browse.js +379 -0
  10. package/dist/commands/config.d.ts +10 -0
  11. package/dist/commands/config.js +121 -0
  12. package/dist/commands/info.d.ts +9 -0
  13. package/dist/commands/info.js +122 -0
  14. package/dist/commands/init.d.ts +10 -0
  15. package/dist/commands/init.js +458 -0
  16. package/dist/commands/list.d.ts +10 -0
  17. package/dist/commands/list.js +76 -0
  18. package/dist/commands/mcp-config.d.ts +10 -0
  19. package/dist/commands/mcp-config.js +49 -0
  20. package/dist/commands/remotes.d.ts +22 -0
  21. package/dist/commands/remotes.js +196 -0
  22. package/dist/commands/remove.d.ts +8 -0
  23. package/dist/commands/remove.js +61 -0
  24. package/dist/commands/routines.d.ts +29 -0
  25. package/dist/commands/routines.js +363 -0
  26. package/dist/commands/run.d.ts +12 -0
  27. package/dist/commands/run.js +104 -0
  28. package/dist/commands/scheduler.d.ts +27 -0
  29. package/dist/commands/scheduler.js +350 -0
  30. package/dist/commands/search.d.ts +9 -0
  31. package/dist/commands/search.js +159 -0
  32. package/dist/commands/secrets.d.ts +28 -0
  33. package/dist/commands/secrets.js +236 -0
  34. package/dist/commands/serve.d.ts +13 -0
  35. package/dist/commands/serve.js +49 -0
  36. package/dist/commands/start.d.ts +8 -0
  37. package/dist/commands/start.js +27 -0
  38. package/dist/commands/update.d.ts +17 -0
  39. package/dist/commands/update.js +210 -0
  40. package/dist/core/config.d.ts +91 -0
  41. package/dist/core/config.js +738 -0
  42. package/dist/core/execute.d.ts +51 -0
  43. package/dist/core/execute.js +475 -0
  44. package/dist/core/link.d.ts +39 -0
  45. package/dist/core/link.js +214 -0
  46. package/dist/core/lockfile.d.ts +63 -0
  47. package/dist/core/lockfile.js +140 -0
  48. package/dist/core/manifest.d.ts +96 -0
  49. package/dist/core/manifest.js +224 -0
  50. package/dist/core/registry.d.ts +74 -0
  51. package/dist/core/registry.js +116 -0
  52. package/dist/core/remote-client.d.ts +98 -0
  53. package/dist/core/remote-client.js +252 -0
  54. package/dist/core/remotes.d.ts +88 -0
  55. package/dist/core/remotes.js +206 -0
  56. package/dist/core/routine-engine.d.ts +124 -0
  57. package/dist/core/routine-engine.js +699 -0
  58. package/dist/core/routines.d.ts +36 -0
  59. package/dist/core/routines.js +132 -0
  60. package/dist/core/scheduler-daemon.d.ts +10 -0
  61. package/dist/core/scheduler-daemon.js +77 -0
  62. package/dist/core/scheduler.d.ts +131 -0
  63. package/dist/core/scheduler.js +492 -0
  64. package/dist/core/secrets.d.ts +48 -0
  65. package/dist/core/secrets.js +384 -0
  66. package/dist/lib/cli.d.ts +84 -0
  67. package/dist/lib/cli.js +216 -0
  68. package/dist/mcp/adapter.d.ts +35 -0
  69. package/dist/mcp/adapter.js +94 -0
  70. package/dist/mcp/config-gen.d.ts +31 -0
  71. package/dist/mcp/config-gen.js +75 -0
  72. package/dist/mcp/server.d.ts +41 -0
  73. package/dist/mcp/server.js +296 -0
  74. package/dist/server/service.d.ts +85 -0
  75. package/dist/server/service.js +304 -0
  76. package/package.json +6 -3
  77. package/src/bin.ts +0 -118
  78. package/src/cli.ts +0 -409
  79. package/src/commands/add.ts +0 -562
  80. package/src/commands/browse.ts +0 -449
  81. package/src/commands/config.ts +0 -154
  82. package/src/commands/info.ts +0 -102
  83. package/src/commands/init.ts +0 -514
  84. package/src/commands/list.ts +0 -72
  85. package/src/commands/mcp-config.ts +0 -69
  86. package/src/commands/remotes.ts +0 -253
  87. package/src/commands/remove.ts +0 -78
  88. package/src/commands/routines.ts +0 -427
  89. package/src/commands/run.ts +0 -127
  90. package/src/commands/scheduler.ts +0 -438
  91. package/src/commands/search.ts +0 -148
  92. package/src/commands/secrets.ts +0 -292
  93. package/src/commands/serve.ts +0 -66
  94. package/src/commands/start.ts +0 -40
  95. package/src/commands/update.ts +0 -252
  96. package/src/core/config.ts +0 -845
  97. package/src/core/execute.ts +0 -569
  98. package/src/core/link.ts +0 -246
  99. package/src/core/lockfile.ts +0 -187
  100. package/src/core/manifest.ts +0 -327
  101. package/src/core/registry.ts +0 -165
  102. package/src/core/remote-client.ts +0 -419
  103. package/src/core/remotes.ts +0 -268
  104. package/src/core/routine-engine.ts +0 -895
  105. package/src/core/routines.ts +0 -171
  106. package/src/core/scheduler-daemon.ts +0 -94
  107. package/src/core/scheduler.ts +0 -606
  108. package/src/core/secrets.ts +0 -430
  109. package/src/lib/cli.ts +0 -261
  110. package/src/mcp/adapter.ts +0 -131
  111. package/src/mcp/config-gen.ts +0 -106
  112. package/src/mcp/server.ts +0 -365
  113. package/src/server/service.ts +0 -434
package/src/cli.ts DELETED
@@ -1,409 +0,0 @@
1
- /**
2
- * cli4ai CLI - Main program setup
3
- */
4
-
5
- import { Command } from 'commander';
6
- import { BRAND, VERSION, withErrorHandling } from './lib/cli.js';
7
-
8
- // Commands
9
- import { initCommand } from './commands/init.js';
10
- import { addCommand } from './commands/add.js';
11
- import { removeCommand } from './commands/remove.js';
12
- import { listCommand } from './commands/list.js';
13
- import { runCommand } from './commands/run.js';
14
- import { infoCommand } from './commands/info.js';
15
- import { searchCommand } from './commands/search.js';
16
- import { configCommand } from './commands/config.js';
17
- import { mcpConfigCommand } from './commands/mcp-config.js';
18
- import { startCommand } from './commands/start.js';
19
- import {
20
- secretsSetCommand,
21
- secretsGetCommand,
22
- secretsListCommand,
23
- secretsDeleteCommand,
24
- secretsInitCommand
25
- } from './commands/secrets.js';
26
- import { browseCommand } from './commands/browse.js';
27
- import { updateCommand } from './commands/update.js';
28
- import { routinesListCommand, routinesRunCommand, routinesShowCommand, routinesCreateCommand, routinesEditCommand, routinesRemoveCommand } from './commands/routines.js';
29
- import {
30
- schedulerStartCommand,
31
- schedulerStopCommand,
32
- schedulerStatusCommand,
33
- schedulerLogsCommand,
34
- schedulerHistoryCommand,
35
- schedulerRunCommand
36
- } from './commands/scheduler.js';
37
- import {
38
- remotesListCommand,
39
- remotesAddCommand,
40
- remotesUpdateCommand,
41
- remotesRemoveCommand,
42
- remotesShowCommand,
43
- remotesTestCommand,
44
- remotesPackagesCommand
45
- } from './commands/remotes.js';
46
- import { serveCommand } from './commands/serve.js';
47
-
48
- export function createProgram(): Command {
49
- const program = new Command()
50
- .name('cli4ai')
51
- .version(VERSION, '-v, --version', 'Show version')
52
- .description('The package manager for AI CLI tools')
53
- .addHelpText('beforeAll', `\n${BRAND}\n`)
54
- .configureOutput({
55
- writeErr: (str) => {
56
- if (!str.includes('"error"')) {
57
- process.stderr.write(str);
58
- }
59
- }
60
- });
61
-
62
- // ═══════════════════════════════════════════════════════════════════════════
63
- // PACKAGE MANAGEMENT
64
- // ═══════════════════════════════════════════════════════════════════════════
65
-
66
- program
67
- .command('init [name]')
68
- .description('Create a new cli4ai tool project')
69
- .option('-t, --template <template>', 'Template to use (basic, api, browser)', 'basic')
70
- .option('-r, --runtime <runtime>', 'Runtime (node, bun)', 'node')
71
- .option('-y, --yes', 'Skip prompts, use defaults')
72
- .action(withErrorHandling(initCommand));
73
-
74
- program
75
- .command('add <packages...>')
76
- .description('Install packages')
77
- .option('-l, --local', 'Install from local path')
78
- .option('-g, --global', 'Install globally')
79
- .option('-D, --save-dev', 'Save as dev dependency')
80
- .option('-y, --yes', 'Skip confirmation prompt')
81
- .action(withErrorHandling(addCommand));
82
-
83
- program
84
- .command('remove <packages...>')
85
- .alias('rm')
86
- .alias('uninstall')
87
- .description('Remove packages')
88
- .option('-g, --global', 'Remove from global packages')
89
- .action(withErrorHandling(removeCommand));
90
-
91
- program
92
- .command('list')
93
- .alias('ls')
94
- .description('List installed packages')
95
- .option('-g, --global', 'List global packages')
96
- .option('--json', 'Output as JSON')
97
- .action(withErrorHandling(listCommand));
98
-
99
- // ═══════════════════════════════════════════════════════════════════════════
100
- // EXECUTION
101
- // ═══════════════════════════════════════════════════════════════════════════
102
-
103
- program
104
- .command('run <package> [command] [args...]')
105
- .description('Run a tool command')
106
- .option('-e, --env <vars...>', 'Environment variables (KEY=value)')
107
- .option('--scope <level>', 'Permission scope: read, write, or full (default: full)')
108
- .option('--sandbox', 'Run in sandboxed environment with restricted file system access')
109
- .option('-r, --remote <name>', 'Execute on a remote cli4ai service')
110
- .option('--timeout <ms>', 'Timeout in milliseconds')
111
- // Allow passing tool flags through (e.g. `cli4ai run chrome screenshot --full-page`)
112
- .allowUnknownOption(true)
113
- .addHelpText('after', `
114
-
115
- Examples:
116
- cli4ai run github trending
117
- cli4ai run chrome screenshot https://example.com --full-page
118
- cli4ai run github list-issues --scope read
119
- cli4ai run untrusted-pkg process --sandbox
120
- cli4ai run browser screenshot --remote chrome-server
121
-
122
- Pass-through:
123
- Use "--" to pass flags that would otherwise be parsed by cli4ai:
124
- cli4ai run <pkg> <cmd> -- --help
125
-
126
- Security:
127
- --scope read Only allow read operations (no mutations)
128
- --scope write Allow write operations
129
- --scope full Full access (default)
130
- --sandbox Restrict file system access to temp directories
131
-
132
- Remote Execution:
133
- --remote <name> Execute on a configured remote service
134
- Use "cli4ai remotes add" to configure remotes
135
- `)
136
- .action(withErrorHandling(runCommand));
137
-
138
- // ═══════════════════════════════════════════════════════════════════════════
139
- // DISCOVERY
140
- // ═══════════════════════════════════════════════════════════════════════════
141
-
142
- program
143
- .command('info <package>')
144
- .description('Show package information')
145
- .option('--versions', 'Show all available versions')
146
- .action(withErrorHandling(infoCommand));
147
-
148
- program
149
- .command('search <query>')
150
- .description('Search for packages')
151
- .option('-l, --limit <n>', 'Max results', '20')
152
- .action(withErrorHandling(searchCommand));
153
-
154
- program
155
- .command('browse')
156
- .description('Interactive package browser')
157
- .action(withErrorHandling(browseCommand));
158
-
159
- program
160
- .command('update')
161
- .alias('upgrade')
162
- .description('Update installed packages')
163
- .option('-s, --self', 'Update cli4ai framework only')
164
- .option('-a, --all', 'Update cli4ai framework and all packages')
165
- .option('-y, --yes', 'Skip confirmation prompt')
166
- .action(withErrorHandling(updateCommand));
167
-
168
- // ═══════════════════════════════════════════════════════════════════════════
169
- // CONFIGURATION
170
- // ═══════════════════════════════════════════════════════════════════════════
171
-
172
- program
173
- .command('config [key] [value]')
174
- .description('Get or set configuration')
175
- .option('--list', 'List all config values')
176
- .option('--add-registry <path>', 'Add local registry path')
177
- .option('--remove-registry <path>', 'Remove local registry path')
178
- .action(withErrorHandling(configCommand));
179
-
180
- // ═══════════════════════════════════════════════════════════════════════════
181
- // MCP INTEGRATION
182
- // ═══════════════════════════════════════════════════════════════════════════
183
-
184
- program
185
- .command('mcp-config')
186
- .description('Generate MCP configuration for Claude Code')
187
- .option('-g, --global', 'Use global packages only')
188
- .option('-p, --package <name>', 'Generate for specific package')
189
- .option('--snippet', 'Output as config snippet (use with --package)')
190
- .action(withErrorHandling(mcpConfigCommand));
191
-
192
- program
193
- .command('start <package>')
194
- .description('Start MCP server for a package')
195
- .option('--stdio', 'Use stdio transport (default)')
196
- .action(withErrorHandling(startCommand));
197
-
198
- // ═══════════════════════════════════════════════════════════════════════════
199
- // SECRETS MANAGEMENT
200
- // ═══════════════════════════════════════════════════════════════════════════
201
-
202
- const secrets = program
203
- .command('secrets')
204
- .description('Manage secrets for CLI tools');
205
-
206
- secrets
207
- .command('set <key> [value]')
208
- .description('Set a secret (prompts for value if not provided)')
209
- .action(withErrorHandling(secretsSetCommand));
210
-
211
- secrets
212
- .command('get <key>')
213
- .description('Get a secret value')
214
- .action(withErrorHandling(secretsGetCommand));
215
-
216
- secrets
217
- .command('list')
218
- .alias('ls')
219
- .description('List all secrets')
220
- .option('-p, --package <name>', 'Show secrets for a specific package')
221
- .action(withErrorHandling(secretsListCommand));
222
-
223
- secrets
224
- .command('delete <key>')
225
- .alias('rm')
226
- .description('Delete a secret')
227
- .action(withErrorHandling(secretsDeleteCommand));
228
-
229
- secrets
230
- .command('init <package>')
231
- .description('Interactive setup for a package\'s required secrets')
232
- .action(withErrorHandling(secretsInitCommand));
233
-
234
- // ═══════════════════════════════════════════════════════════════════════════
235
- // HELP
236
- // ═══════════════════════════════════════════════════════════════════════════
237
-
238
- program.addHelpCommand('help [command]', 'Show help for command');
239
-
240
- // ═══════════════════════════════════════════════════════════════════════════
241
- // ROUTINES
242
- // ═══════════════════════════════════════════════════════════════════════════
243
-
244
- const routines = program
245
- .command('routines')
246
- .description('Manage and run routines');
247
-
248
- routines
249
- .command('list')
250
- .alias('ls')
251
- .description('List available routines')
252
- .option('-g, --global', 'Use global routines only')
253
- .option('--json', 'Output as JSON')
254
- .action(withErrorHandling(routinesListCommand));
255
-
256
- routines
257
- .command('show <name>')
258
- .description('Show routine definition')
259
- .option('-g, --global', 'Use global routines only')
260
- .action(withErrorHandling(routinesShowCommand));
261
-
262
- routines
263
- .command('create <name>')
264
- .description('Create a new routine')
265
- .option('-g, --global', 'Create routine globally')
266
- .option('--type <type>', 'Routine type (yaml, json, bash)', 'yaml')
267
- .action(withErrorHandling(routinesCreateCommand));
268
-
269
- routines
270
- .command('edit <name>')
271
- .description('Edit a routine in $EDITOR')
272
- .option('-g, --global', 'Use global routine only')
273
- .action(withErrorHandling(routinesEditCommand));
274
-
275
- routines
276
- .command('remove <name>')
277
- .alias('rm')
278
- .description('Remove a routine')
279
- .option('-g, --global', 'Use global routine only')
280
- .action(withErrorHandling(routinesRemoveCommand));
281
-
282
- routines
283
- .command('run <name> [args...]')
284
- .description('Run a routine')
285
- .option('-g, --global', 'Use global routine only')
286
- .option('--var <vars...>', 'Variables (KEY=value)')
287
- .option('--dry-run', 'Show execution plan without running')
288
- .action(withErrorHandling(routinesRunCommand));
289
-
290
- // ═══════════════════════════════════════════════════════════════════════════
291
- // SCHEDULER
292
- // ═══════════════════════════════════════════════════════════════════════════
293
-
294
- const scheduler = program
295
- .command('scheduler')
296
- .description('Manage scheduled routine execution');
297
-
298
- scheduler
299
- .command('start')
300
- .description('Start the scheduler daemon')
301
- .option('-f, --foreground', 'Run in foreground (blocking)')
302
- .action(withErrorHandling(schedulerStartCommand));
303
-
304
- scheduler
305
- .command('stop')
306
- .description('Stop the scheduler daemon')
307
- .action(withErrorHandling(schedulerStopCommand));
308
-
309
- scheduler
310
- .command('status')
311
- .description('Show scheduler status and upcoming runs')
312
- .action(withErrorHandling(schedulerStatusCommand));
313
-
314
- scheduler
315
- .command('logs')
316
- .description('View scheduler logs')
317
- .option('-f, --follow', 'Follow log output')
318
- .option('-n, --lines <n>', 'Number of lines to show', '50')
319
- .action(withErrorHandling(schedulerLogsCommand));
320
-
321
- scheduler
322
- .command('history [routine]')
323
- .description('View routine execution history')
324
- .option('-n, --limit <n>', 'Number of records to show', '20')
325
- .action(withErrorHandling(schedulerHistoryCommand));
326
-
327
- scheduler
328
- .command('run <routine>')
329
- .description('Manually trigger a scheduled routine')
330
- .action(withErrorHandling(schedulerRunCommand));
331
-
332
- // ═══════════════════════════════════════════════════════════════════════════
333
- // REMOTE EXECUTION
334
- // ═══════════════════════════════════════════════════════════════════════════
335
-
336
- program
337
- .command('serve')
338
- .description('Start cli4ai as a remote service')
339
- .option('-p, --port <port>', 'Port to listen on', '4100')
340
- .option('-H, --host <host>', 'Host to bind to', '0.0.0.0')
341
- .option('-k, --api-key <key>', 'API key for authentication')
342
- .option('--scope <levels>', 'Comma-separated allowed scopes (read,write,full)')
343
- .option('--cwd <dir>', 'Working directory for execution')
344
- .addHelpText('after', `
345
-
346
- Examples:
347
- cli4ai serve # Start on port 4100
348
- cli4ai serve --port 8080 # Start on port 8080
349
- cli4ai serve --api-key mysecretkey # Require API key
350
- cli4ai serve --scope read,write # Restrict to read/write operations
351
-
352
- The service exposes these endpoints:
353
- GET /health - Service health check
354
- GET /packages - List available packages
355
- GET /packages/:name - Get package info
356
- POST /run - Execute a tool
357
- POST /routines/:name/run - Run a routine
358
- `)
359
- .action(withErrorHandling(serveCommand));
360
-
361
- const remotes = program
362
- .command('remotes')
363
- .description('Manage remote cli4ai services');
364
-
365
- remotes
366
- .command('list')
367
- .alias('ls')
368
- .description('List configured remotes')
369
- .action(withErrorHandling(remotesListCommand));
370
-
371
- remotes
372
- .command('add <name> <url>')
373
- .description('Add a remote service')
374
- .option('-k, --api-key <key>', 'API key for authentication')
375
- .option('-d, --description <desc>', 'Description of this remote')
376
- .option('--no-test', 'Skip connection test')
377
- .action(withErrorHandling(remotesAddCommand));
378
-
379
- remotes
380
- .command('update <name>')
381
- .description('Update a remote service')
382
- .option('-u, --url <url>', 'New URL')
383
- .option('-k, --api-key <key>', 'New API key')
384
- .option('-d, --description <desc>', 'New description')
385
- .action(withErrorHandling(remotesUpdateCommand));
386
-
387
- remotes
388
- .command('remove <name>')
389
- .alias('rm')
390
- .description('Remove a remote')
391
- .action(withErrorHandling(remotesRemoveCommand));
392
-
393
- remotes
394
- .command('show <name>')
395
- .description('Show remote details')
396
- .action(withErrorHandling(remotesShowCommand));
397
-
398
- remotes
399
- .command('test <name>')
400
- .description('Test connection to a remote')
401
- .action(withErrorHandling(remotesTestCommand));
402
-
403
- remotes
404
- .command('packages <name>')
405
- .description('List packages on a remote')
406
- .action(withErrorHandling(remotesPackagesCommand));
407
-
408
- return program;
409
- }