cli4ai 1.2.0 → 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 -412
  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 -133
  83. package/src/commands/init.ts +0 -514
  84. package/src/commands/list.ts +0 -95
  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 -185
  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,412 +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('-r, --remote <name>', 'List packages on a remote server')
97
- .option('--json', 'Output as JSON')
98
- .action(withErrorHandling(listCommand));
99
-
100
- // ═══════════════════════════════════════════════════════════════════════════
101
- // EXECUTION
102
- // ═══════════════════════════════════════════════════════════════════════════
103
-
104
- program
105
- .command('run <package> [command] [args...]')
106
- .description('Run a tool command')
107
- .option('-e, --env <vars...>', 'Environment variables (KEY=value)')
108
- .option('--scope <level>', 'Permission scope: read, write, or full (default: full)')
109
- .option('--sandbox', 'Run in sandboxed environment with restricted file system access')
110
- .option('-r, --remote <name>', 'Execute on a remote cli4ai service')
111
- .option('--timeout <ms>', 'Timeout in milliseconds')
112
- // Allow passing tool flags through (e.g. `cli4ai run chrome screenshot --full-page`)
113
- .allowUnknownOption(true)
114
- .addHelpText('after', `
115
-
116
- Examples:
117
- cli4ai run github trending
118
- cli4ai run chrome screenshot https://example.com --full-page
119
- cli4ai run github list-issues --scope read
120
- cli4ai run untrusted-pkg process --sandbox
121
- cli4ai run browser screenshot --remote chrome-server
122
-
123
- Pass-through:
124
- Use "--" to pass flags that would otherwise be parsed by cli4ai:
125
- cli4ai run <pkg> <cmd> -- --help
126
-
127
- Security:
128
- --scope read Only allow read operations (no mutations)
129
- --scope write Allow write operations
130
- --scope full Full access (default)
131
- --sandbox Restrict file system access to temp directories
132
-
133
- Remote Execution:
134
- --remote <name> Execute on a configured remote service
135
- Use "cli4ai remotes add" to configure remotes
136
- `)
137
- .action(withErrorHandling(runCommand));
138
-
139
- // ═══════════════════════════════════════════════════════════════════════════
140
- // DISCOVERY
141
- // ═══════════════════════════════════════════════════════════════════════════
142
-
143
- program
144
- .command('info <package>')
145
- .description('Show package information')
146
- .option('--versions', 'Show all available versions')
147
- .option('-r, --remote <name>', 'Get info from a remote server')
148
- .action(withErrorHandling(infoCommand));
149
-
150
- program
151
- .command('search <query>')
152
- .description('Search for packages')
153
- .option('-l, --limit <n>', 'Max results', '20')
154
- .option('-r, --remote <name>', 'Search packages on a remote server')
155
- .action(withErrorHandling(searchCommand));
156
-
157
- program
158
- .command('browse')
159
- .description('Interactive package browser')
160
- .action(withErrorHandling(browseCommand));
161
-
162
- program
163
- .command('update')
164
- .alias('upgrade')
165
- .description('Update installed packages')
166
- .option('-s, --self', 'Update cli4ai framework only')
167
- .option('-a, --all', 'Update cli4ai framework and all packages')
168
- .option('-y, --yes', 'Skip confirmation prompt')
169
- .action(withErrorHandling(updateCommand));
170
-
171
- // ═══════════════════════════════════════════════════════════════════════════
172
- // CONFIGURATION
173
- // ═══════════════════════════════════════════════════════════════════════════
174
-
175
- program
176
- .command('config [key] [value]')
177
- .description('Get or set configuration')
178
- .option('--list', 'List all config values')
179
- .option('--add-registry <path>', 'Add local registry path')
180
- .option('--remove-registry <path>', 'Remove local registry path')
181
- .action(withErrorHandling(configCommand));
182
-
183
- // ═══════════════════════════════════════════════════════════════════════════
184
- // MCP INTEGRATION
185
- // ═══════════════════════════════════════════════════════════════════════════
186
-
187
- program
188
- .command('mcp-config')
189
- .description('Generate MCP configuration for Claude Code')
190
- .option('-g, --global', 'Use global packages only')
191
- .option('-p, --package <name>', 'Generate for specific package')
192
- .option('--snippet', 'Output as config snippet (use with --package)')
193
- .action(withErrorHandling(mcpConfigCommand));
194
-
195
- program
196
- .command('start <package>')
197
- .description('Start MCP server for a package')
198
- .option('--stdio', 'Use stdio transport (default)')
199
- .action(withErrorHandling(startCommand));
200
-
201
- // ═══════════════════════════════════════════════════════════════════════════
202
- // SECRETS MANAGEMENT
203
- // ═══════════════════════════════════════════════════════════════════════════
204
-
205
- const secrets = program
206
- .command('secrets')
207
- .description('Manage secrets for CLI tools');
208
-
209
- secrets
210
- .command('set <key> [value]')
211
- .description('Set a secret (prompts for value if not provided)')
212
- .action(withErrorHandling(secretsSetCommand));
213
-
214
- secrets
215
- .command('get <key>')
216
- .description('Get a secret value')
217
- .action(withErrorHandling(secretsGetCommand));
218
-
219
- secrets
220
- .command('list')
221
- .alias('ls')
222
- .description('List all secrets')
223
- .option('-p, --package <name>', 'Show secrets for a specific package')
224
- .action(withErrorHandling(secretsListCommand));
225
-
226
- secrets
227
- .command('delete <key>')
228
- .alias('rm')
229
- .description('Delete a secret')
230
- .action(withErrorHandling(secretsDeleteCommand));
231
-
232
- secrets
233
- .command('init <package>')
234
- .description('Interactive setup for a package\'s required secrets')
235
- .action(withErrorHandling(secretsInitCommand));
236
-
237
- // ═══════════════════════════════════════════════════════════════════════════
238
- // HELP
239
- // ═══════════════════════════════════════════════════════════════════════════
240
-
241
- program.addHelpCommand('help [command]', 'Show help for command');
242
-
243
- // ═══════════════════════════════════════════════════════════════════════════
244
- // ROUTINES
245
- // ═══════════════════════════════════════════════════════════════════════════
246
-
247
- const routines = program
248
- .command('routines')
249
- .description('Manage and run routines');
250
-
251
- routines
252
- .command('list')
253
- .alias('ls')
254
- .description('List available routines')
255
- .option('-g, --global', 'Use global routines only')
256
- .option('--json', 'Output as JSON')
257
- .action(withErrorHandling(routinesListCommand));
258
-
259
- routines
260
- .command('show <name>')
261
- .description('Show routine definition')
262
- .option('-g, --global', 'Use global routines only')
263
- .action(withErrorHandling(routinesShowCommand));
264
-
265
- routines
266
- .command('create <name>')
267
- .description('Create a new routine')
268
- .option('-g, --global', 'Create routine globally')
269
- .option('--type <type>', 'Routine type (yaml, json, bash)', 'yaml')
270
- .action(withErrorHandling(routinesCreateCommand));
271
-
272
- routines
273
- .command('edit <name>')
274
- .description('Edit a routine in $EDITOR')
275
- .option('-g, --global', 'Use global routine only')
276
- .action(withErrorHandling(routinesEditCommand));
277
-
278
- routines
279
- .command('remove <name>')
280
- .alias('rm')
281
- .description('Remove a routine')
282
- .option('-g, --global', 'Use global routine only')
283
- .action(withErrorHandling(routinesRemoveCommand));
284
-
285
- routines
286
- .command('run <name> [args...]')
287
- .description('Run a routine')
288
- .option('-g, --global', 'Use global routine only')
289
- .option('--var <vars...>', 'Variables (KEY=value)')
290
- .option('--dry-run', 'Show execution plan without running')
291
- .action(withErrorHandling(routinesRunCommand));
292
-
293
- // ═══════════════════════════════════════════════════════════════════════════
294
- // SCHEDULER
295
- // ═══════════════════════════════════════════════════════════════════════════
296
-
297
- const scheduler = program
298
- .command('scheduler')
299
- .description('Manage scheduled routine execution');
300
-
301
- scheduler
302
- .command('start')
303
- .description('Start the scheduler daemon')
304
- .option('-f, --foreground', 'Run in foreground (blocking)')
305
- .action(withErrorHandling(schedulerStartCommand));
306
-
307
- scheduler
308
- .command('stop')
309
- .description('Stop the scheduler daemon')
310
- .action(withErrorHandling(schedulerStopCommand));
311
-
312
- scheduler
313
- .command('status')
314
- .description('Show scheduler status and upcoming runs')
315
- .action(withErrorHandling(schedulerStatusCommand));
316
-
317
- scheduler
318
- .command('logs')
319
- .description('View scheduler logs')
320
- .option('-f, --follow', 'Follow log output')
321
- .option('-n, --lines <n>', 'Number of lines to show', '50')
322
- .action(withErrorHandling(schedulerLogsCommand));
323
-
324
- scheduler
325
- .command('history [routine]')
326
- .description('View routine execution history')
327
- .option('-n, --limit <n>', 'Number of records to show', '20')
328
- .action(withErrorHandling(schedulerHistoryCommand));
329
-
330
- scheduler
331
- .command('run <routine>')
332
- .description('Manually trigger a scheduled routine')
333
- .action(withErrorHandling(schedulerRunCommand));
334
-
335
- // ═══════════════════════════════════════════════════════════════════════════
336
- // REMOTE EXECUTION
337
- // ═══════════════════════════════════════════════════════════════════════════
338
-
339
- program
340
- .command('serve')
341
- .description('Start cli4ai as a remote service')
342
- .option('-p, --port <port>', 'Port to listen on', '4100')
343
- .option('-H, --host <host>', 'Host to bind to', '0.0.0.0')
344
- .option('-k, --api-key <key>', 'API key for authentication')
345
- .option('--scope <levels>', 'Comma-separated allowed scopes (read,write,full)')
346
- .option('--cwd <dir>', 'Working directory for execution')
347
- .addHelpText('after', `
348
-
349
- Examples:
350
- cli4ai serve # Start on port 4100
351
- cli4ai serve --port 8080 # Start on port 8080
352
- cli4ai serve --api-key mysecretkey # Require API key
353
- cli4ai serve --scope read,write # Restrict to read/write operations
354
-
355
- The service exposes these endpoints:
356
- GET /health - Service health check
357
- GET /packages - List available packages
358
- GET /packages/:name - Get package info
359
- POST /run - Execute a tool
360
- POST /routines/:name/run - Run a routine
361
- `)
362
- .action(withErrorHandling(serveCommand));
363
-
364
- const remotes = program
365
- .command('remotes')
366
- .description('Manage remote cli4ai services');
367
-
368
- remotes
369
- .command('list')
370
- .alias('ls')
371
- .description('List configured remotes')
372
- .action(withErrorHandling(remotesListCommand));
373
-
374
- remotes
375
- .command('add <name> <url>')
376
- .description('Add a remote service')
377
- .option('-k, --api-key <key>', 'API key for authentication')
378
- .option('-d, --description <desc>', 'Description of this remote')
379
- .option('--no-test', 'Skip connection test')
380
- .action(withErrorHandling(remotesAddCommand));
381
-
382
- remotes
383
- .command('update <name>')
384
- .description('Update a remote service')
385
- .option('-u, --url <url>', 'New URL')
386
- .option('-k, --api-key <key>', 'New API key')
387
- .option('-d, --description <desc>', 'New description')
388
- .action(withErrorHandling(remotesUpdateCommand));
389
-
390
- remotes
391
- .command('remove <name>')
392
- .alias('rm')
393
- .description('Remove a remote')
394
- .action(withErrorHandling(remotesRemoveCommand));
395
-
396
- remotes
397
- .command('show <name>')
398
- .description('Show remote details')
399
- .action(withErrorHandling(remotesShowCommand));
400
-
401
- remotes
402
- .command('test <name>')
403
- .description('Test connection to a remote')
404
- .action(withErrorHandling(remotesTestCommand));
405
-
406
- remotes
407
- .command('packages <name>')
408
- .description('List packages on a remote')
409
- .action(withErrorHandling(remotesPackagesCommand));
410
-
411
- return program;
412
- }