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.
- package/README.md +39 -0
- package/dist/bin.d.ts +6 -0
- package/dist/bin.js +105 -0
- package/dist/cli.d.ts +5 -0
- package/dist/cli.js +335 -0
- package/dist/commands/add.d.ts +11 -0
- package/dist/commands/add.js +459 -0
- package/dist/commands/browse.d.ts +4 -0
- package/dist/commands/browse.js +379 -0
- package/dist/commands/config.d.ts +10 -0
- package/dist/commands/config.js +121 -0
- package/dist/commands/info.d.ts +9 -0
- package/dist/commands/info.js +122 -0
- package/dist/commands/init.d.ts +10 -0
- package/dist/commands/init.js +458 -0
- package/dist/commands/list.d.ts +10 -0
- package/dist/commands/list.js +76 -0
- package/dist/commands/mcp-config.d.ts +10 -0
- package/dist/commands/mcp-config.js +49 -0
- package/dist/commands/remotes.d.ts +22 -0
- package/dist/commands/remotes.js +196 -0
- package/dist/commands/remove.d.ts +8 -0
- package/dist/commands/remove.js +61 -0
- package/dist/commands/routines.d.ts +29 -0
- package/dist/commands/routines.js +363 -0
- package/dist/commands/run.d.ts +12 -0
- package/dist/commands/run.js +104 -0
- package/dist/commands/scheduler.d.ts +27 -0
- package/dist/commands/scheduler.js +350 -0
- package/dist/commands/search.d.ts +9 -0
- package/dist/commands/search.js +159 -0
- package/dist/commands/secrets.d.ts +28 -0
- package/dist/commands/secrets.js +236 -0
- package/dist/commands/serve.d.ts +13 -0
- package/dist/commands/serve.js +49 -0
- package/dist/commands/start.d.ts +8 -0
- package/dist/commands/start.js +27 -0
- package/dist/commands/update.d.ts +17 -0
- package/dist/commands/update.js +210 -0
- package/dist/core/config.d.ts +91 -0
- package/dist/core/config.js +738 -0
- package/dist/core/execute.d.ts +51 -0
- package/dist/core/execute.js +475 -0
- package/dist/core/link.d.ts +39 -0
- package/dist/core/link.js +214 -0
- package/dist/core/lockfile.d.ts +63 -0
- package/dist/core/lockfile.js +140 -0
- package/dist/core/manifest.d.ts +96 -0
- package/dist/core/manifest.js +224 -0
- package/dist/core/registry.d.ts +74 -0
- package/dist/core/registry.js +116 -0
- package/dist/core/remote-client.d.ts +98 -0
- package/dist/core/remote-client.js +252 -0
- package/dist/core/remotes.d.ts +88 -0
- package/dist/core/remotes.js +206 -0
- package/dist/core/routine-engine.d.ts +124 -0
- package/dist/core/routine-engine.js +699 -0
- package/dist/core/routines.d.ts +36 -0
- package/dist/core/routines.js +132 -0
- package/dist/core/scheduler-daemon.d.ts +10 -0
- package/dist/core/scheduler-daemon.js +77 -0
- package/dist/core/scheduler.d.ts +131 -0
- package/dist/core/scheduler.js +492 -0
- package/dist/core/secrets.d.ts +48 -0
- package/dist/core/secrets.js +384 -0
- package/dist/lib/cli.d.ts +84 -0
- package/dist/lib/cli.js +216 -0
- package/dist/mcp/adapter.d.ts +35 -0
- package/dist/mcp/adapter.js +94 -0
- package/dist/mcp/config-gen.d.ts +31 -0
- package/dist/mcp/config-gen.js +75 -0
- package/dist/mcp/server.d.ts +41 -0
- package/dist/mcp/server.js +296 -0
- package/dist/server/service.d.ts +85 -0
- package/dist/server/service.js +304 -0
- package/package.json +6 -3
- package/src/bin.ts +0 -118
- package/src/cli.ts +0 -409
- package/src/commands/add.ts +0 -562
- package/src/commands/browse.ts +0 -449
- package/src/commands/config.ts +0 -154
- package/src/commands/info.ts +0 -102
- package/src/commands/init.ts +0 -514
- package/src/commands/list.ts +0 -72
- package/src/commands/mcp-config.ts +0 -69
- package/src/commands/remotes.ts +0 -253
- package/src/commands/remove.ts +0 -78
- package/src/commands/routines.ts +0 -427
- package/src/commands/run.ts +0 -127
- package/src/commands/scheduler.ts +0 -438
- package/src/commands/search.ts +0 -148
- package/src/commands/secrets.ts +0 -292
- package/src/commands/serve.ts +0 -66
- package/src/commands/start.ts +0 -40
- package/src/commands/update.ts +0 -252
- package/src/core/config.ts +0 -845
- package/src/core/execute.ts +0 -569
- package/src/core/link.ts +0 -246
- package/src/core/lockfile.ts +0 -187
- package/src/core/manifest.ts +0 -327
- package/src/core/registry.ts +0 -165
- package/src/core/remote-client.ts +0 -419
- package/src/core/remotes.ts +0 -268
- package/src/core/routine-engine.ts +0 -895
- package/src/core/routines.ts +0 -171
- package/src/core/scheduler-daemon.ts +0 -94
- package/src/core/scheduler.ts +0 -606
- package/src/core/secrets.ts +0 -430
- package/src/lib/cli.ts +0 -261
- package/src/mcp/adapter.ts +0 -131
- package/src/mcp/config-gen.ts +0 -106
- package/src/mcp/server.ts +0 -365
- package/src/server/service.ts +0 -434
package/README.md
CHANGED
|
@@ -91,8 +91,47 @@ cli4ai update
|
|
|
91
91
|
| Command | Description |
|
|
92
92
|
|---------|-------------|
|
|
93
93
|
| `cli4ai run <pkg> <cmd> [args]` | Run a tool command |
|
|
94
|
+
| `cli4ai run --remote <name> <pkg> <cmd>` | Run on remote server |
|
|
94
95
|
| `cli4ai start <pkg>` | Start package as MCP server |
|
|
95
96
|
|
|
97
|
+
### Remote Servers
|
|
98
|
+
|
|
99
|
+
Run tools on remote machines. Perfect for accessing tools on other computers or servers.
|
|
100
|
+
|
|
101
|
+
| Command | Description |
|
|
102
|
+
|---------|-------------|
|
|
103
|
+
| `cli4ai serve` | Start remote server (default port 4100) |
|
|
104
|
+
| `cli4ai remotes add <name> <url>` | Add a remote server |
|
|
105
|
+
| `cli4ai remotes list` | List configured remotes |
|
|
106
|
+
| `cli4ai remotes remove <name>` | Remove a remote |
|
|
107
|
+
| `cli4ai list --remote <name>` | List packages on remote |
|
|
108
|
+
| `cli4ai info --remote <name> <pkg>` | Get package info from remote |
|
|
109
|
+
| `cli4ai search --remote <name> <query>` | Search packages on remote |
|
|
110
|
+
|
|
111
|
+
**Example: Set up remote execution**
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# On the server machine
|
|
115
|
+
cli4ai serve --port 4100
|
|
116
|
+
|
|
117
|
+
# On your local machine
|
|
118
|
+
cli4ai remotes add my-server http://192.168.1.100:4100
|
|
119
|
+
|
|
120
|
+
# Run tools remotely
|
|
121
|
+
cli4ai run --remote my-server github notifs
|
|
122
|
+
cli4ai list --remote my-server
|
|
123
|
+
cli4ai info --remote my-server twitter
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Serve options:**
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
cli4ai serve # Start on port 4100
|
|
130
|
+
cli4ai serve --port 8080 # Custom port
|
|
131
|
+
cli4ai serve --api-key mysecretkey # Require authentication
|
|
132
|
+
cli4ai serve --scope read,write # Restrict to specific scopes
|
|
133
|
+
```
|
|
134
|
+
|
|
96
135
|
## MCP Integration
|
|
97
136
|
|
|
98
137
|
cli4ai tools can run as MCP servers for Claude:
|
package/dist/bin.d.ts
ADDED
package/dist/bin.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* cli4ai - The package manager for AI CLI tools
|
|
4
|
+
* cli4ai.com
|
|
5
|
+
*/
|
|
6
|
+
import { createProgram } from './cli.js';
|
|
7
|
+
import { VERSION } from './lib/cli.js';
|
|
8
|
+
import { getNpmGlobalPackages } from './core/config.js';
|
|
9
|
+
// ANSI codes
|
|
10
|
+
const RESET = '\x1B[0m';
|
|
11
|
+
const BOLD = '\x1B[1m';
|
|
12
|
+
const DIM = '\x1B[2m';
|
|
13
|
+
const CYAN = '\x1B[36m';
|
|
14
|
+
const WHITE = '\x1B[37m';
|
|
15
|
+
const GREEN = '\x1B[32m';
|
|
16
|
+
const YELLOW = '\x1B[33m';
|
|
17
|
+
const MAGENTA = '\x1B[35m';
|
|
18
|
+
/**
|
|
19
|
+
* Sleep helper
|
|
20
|
+
*/
|
|
21
|
+
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
|
|
22
|
+
/**
|
|
23
|
+
* Robot eating dots animation
|
|
24
|
+
*/
|
|
25
|
+
async function showAnimation() {
|
|
26
|
+
const width = 35;
|
|
27
|
+
const robot = ['[•_•]', '[•_•]', '[°_°]', '[•_•]'];
|
|
28
|
+
const food = '·';
|
|
29
|
+
for (let pos = 0; pos <= width; pos++) {
|
|
30
|
+
process.stderr.write('\r\x1B[K');
|
|
31
|
+
const frame = robot[pos % robot.length];
|
|
32
|
+
const trail = ' '.repeat(pos) + food.repeat(width - pos);
|
|
33
|
+
process.stderr.write(` ${CYAN}${frame}${RESET}${DIM}${trail}${RESET}`);
|
|
34
|
+
await sleep(20);
|
|
35
|
+
}
|
|
36
|
+
process.stderr.write('\r\x1B[K');
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Animate the robot face (blinking)
|
|
40
|
+
*/
|
|
41
|
+
async function animateRobotFace() {
|
|
42
|
+
const faces = ['[•_•]', '[•_•]', '[-_-]', '[•_•]', '[•_•]', '[°_°]', '[•_•]'];
|
|
43
|
+
const line = ` ${BOLD}${CYAN}cli4ai${RESET} ${DIM}─${RESET} ${WHITE}cli4ai.com${RESET}`;
|
|
44
|
+
for (const face of faces) {
|
|
45
|
+
process.stderr.write(`\r ${CYAN}${face}${RESET}${line}`);
|
|
46
|
+
await sleep(120);
|
|
47
|
+
}
|
|
48
|
+
console.error('');
|
|
49
|
+
}
|
|
50
|
+
async function showBanner() {
|
|
51
|
+
if (!process.stderr.isTTY)
|
|
52
|
+
return;
|
|
53
|
+
console.error('');
|
|
54
|
+
// Fun robot eating animation
|
|
55
|
+
await showAnimation();
|
|
56
|
+
// Animated robot branding (blinking)
|
|
57
|
+
await animateRobotFace();
|
|
58
|
+
console.error(` ${DIM}The package manager for AI CLI tools${RESET}`);
|
|
59
|
+
console.error(` ${DIM}v${VERSION}${RESET}`);
|
|
60
|
+
console.error('');
|
|
61
|
+
console.error(` ${BOLD}Commands${RESET}`);
|
|
62
|
+
console.error(` ${DIM}${'─'.repeat(40)}${RESET}`);
|
|
63
|
+
console.error(` ${GREEN}browse${RESET} ${DIM}Browse & install packages${RESET}`);
|
|
64
|
+
console.error(` ${GREEN}run${RESET} ${CYAN}<pkg> <cmd>${RESET} ${DIM}Run a tool command${RESET}`);
|
|
65
|
+
console.error(` ${GREEN}ls${RESET} ${DIM}List installed packages${RESET}`);
|
|
66
|
+
console.error(` ${GREEN}update${RESET} ${DIM}Update all packages${RESET}`);
|
|
67
|
+
console.error('');
|
|
68
|
+
console.error(` ${DIM}Run${RESET} ${WHITE}cli4ai --help${RESET} ${DIM}for all commands${RESET}`);
|
|
69
|
+
console.error('');
|
|
70
|
+
// Check for updates in background (non-blocking)
|
|
71
|
+
checkUpdatesInBackground();
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Check for updates without blocking - spawns detached process
|
|
75
|
+
*/
|
|
76
|
+
function checkUpdatesInBackground() {
|
|
77
|
+
// Quick local check only - don't hit network
|
|
78
|
+
try {
|
|
79
|
+
const packages = getNpmGlobalPackages();
|
|
80
|
+
if (packages.length > 0) {
|
|
81
|
+
// Spawn a background process to check updates and cache results
|
|
82
|
+
const { spawn } = require('child_process');
|
|
83
|
+
const child = spawn('sh', ['-c', 'timeout 3 npm view cli4ai version 2>/dev/null > /tmp/.cli4ai-update-check 2>&1 &'], {
|
|
84
|
+
detached: true,
|
|
85
|
+
stdio: ['ignore', 'ignore', 'ignore']
|
|
86
|
+
});
|
|
87
|
+
child.unref();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// Ignore errors - this is best effort
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Check if running without command (just `cli4ai`)
|
|
95
|
+
const args = process.argv.slice(2);
|
|
96
|
+
const hasCommand = args.length > 0 && !args[0].startsWith('-');
|
|
97
|
+
const isHelp = args.includes('--help') || args.includes('-h');
|
|
98
|
+
const isVersion = args.includes('--version') || args.includes('-v');
|
|
99
|
+
if (!hasCommand && !isHelp && !isVersion) {
|
|
100
|
+
showBanner().then(() => process.exit(0));
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
const program = createProgram();
|
|
104
|
+
program.parse(process.argv);
|
|
105
|
+
}
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cli4ai CLI - Main program setup
|
|
3
|
+
*/
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import { BRAND, VERSION, withErrorHandling } from './lib/cli.js';
|
|
6
|
+
// Commands
|
|
7
|
+
import { initCommand } from './commands/init.js';
|
|
8
|
+
import { addCommand } from './commands/add.js';
|
|
9
|
+
import { removeCommand } from './commands/remove.js';
|
|
10
|
+
import { listCommand } from './commands/list.js';
|
|
11
|
+
import { runCommand } from './commands/run.js';
|
|
12
|
+
import { infoCommand } from './commands/info.js';
|
|
13
|
+
import { searchCommand } from './commands/search.js';
|
|
14
|
+
import { configCommand } from './commands/config.js';
|
|
15
|
+
import { mcpConfigCommand } from './commands/mcp-config.js';
|
|
16
|
+
import { startCommand } from './commands/start.js';
|
|
17
|
+
import { secretsSetCommand, secretsGetCommand, secretsListCommand, secretsDeleteCommand, secretsInitCommand } from './commands/secrets.js';
|
|
18
|
+
import { browseCommand } from './commands/browse.js';
|
|
19
|
+
import { updateCommand } from './commands/update.js';
|
|
20
|
+
import { routinesListCommand, routinesRunCommand, routinesShowCommand, routinesCreateCommand, routinesEditCommand, routinesRemoveCommand } from './commands/routines.js';
|
|
21
|
+
import { schedulerStartCommand, schedulerStopCommand, schedulerStatusCommand, schedulerLogsCommand, schedulerHistoryCommand, schedulerRunCommand } from './commands/scheduler.js';
|
|
22
|
+
import { remotesListCommand, remotesAddCommand, remotesUpdateCommand, remotesRemoveCommand, remotesShowCommand, remotesTestCommand, remotesPackagesCommand } from './commands/remotes.js';
|
|
23
|
+
import { serveCommand } from './commands/serve.js';
|
|
24
|
+
export function createProgram() {
|
|
25
|
+
const program = new Command()
|
|
26
|
+
.name('cli4ai')
|
|
27
|
+
.version(VERSION, '-v, --version', 'Show version')
|
|
28
|
+
.description('The package manager for AI CLI tools')
|
|
29
|
+
.addHelpText('beforeAll', `\n${BRAND}\n`)
|
|
30
|
+
.configureOutput({
|
|
31
|
+
writeErr: (str) => {
|
|
32
|
+
if (!str.includes('"error"')) {
|
|
33
|
+
process.stderr.write(str);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
38
|
+
// PACKAGE MANAGEMENT
|
|
39
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
40
|
+
program
|
|
41
|
+
.command('init [name]')
|
|
42
|
+
.description('Create a new cli4ai tool project')
|
|
43
|
+
.option('-t, --template <template>', 'Template to use (basic, api, browser)', 'basic')
|
|
44
|
+
.option('-r, --runtime <runtime>', 'Runtime (node, bun)', 'node')
|
|
45
|
+
.option('-y, --yes', 'Skip prompts, use defaults')
|
|
46
|
+
.action(withErrorHandling(initCommand));
|
|
47
|
+
program
|
|
48
|
+
.command('add <packages...>')
|
|
49
|
+
.description('Install packages')
|
|
50
|
+
.option('-l, --local', 'Install from local path')
|
|
51
|
+
.option('-g, --global', 'Install globally')
|
|
52
|
+
.option('-D, --save-dev', 'Save as dev dependency')
|
|
53
|
+
.option('-y, --yes', 'Skip confirmation prompt')
|
|
54
|
+
.action(withErrorHandling(addCommand));
|
|
55
|
+
program
|
|
56
|
+
.command('remove <packages...>')
|
|
57
|
+
.alias('rm')
|
|
58
|
+
.alias('uninstall')
|
|
59
|
+
.description('Remove packages')
|
|
60
|
+
.option('-g, --global', 'Remove from global packages')
|
|
61
|
+
.action(withErrorHandling(removeCommand));
|
|
62
|
+
program
|
|
63
|
+
.command('list')
|
|
64
|
+
.alias('ls')
|
|
65
|
+
.description('List installed packages')
|
|
66
|
+
.option('-g, --global', 'List global packages')
|
|
67
|
+
.option('-r, --remote <name>', 'List packages on a remote server')
|
|
68
|
+
.option('--json', 'Output as JSON')
|
|
69
|
+
.action(withErrorHandling(listCommand));
|
|
70
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
71
|
+
// EXECUTION
|
|
72
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
73
|
+
program
|
|
74
|
+
.command('run <package> [command] [args...]')
|
|
75
|
+
.description('Run a tool command')
|
|
76
|
+
.option('-e, --env <vars...>', 'Environment variables (KEY=value)')
|
|
77
|
+
.option('--scope <level>', 'Permission scope: read, write, or full (default: full)')
|
|
78
|
+
.option('--sandbox', 'Run in sandboxed environment with restricted file system access')
|
|
79
|
+
.option('-r, --remote <name>', 'Execute on a remote cli4ai service')
|
|
80
|
+
.option('--timeout <ms>', 'Timeout in milliseconds')
|
|
81
|
+
// Allow passing tool flags through (e.g. `cli4ai run chrome screenshot --full-page`)
|
|
82
|
+
.allowUnknownOption(true)
|
|
83
|
+
.addHelpText('after', `
|
|
84
|
+
|
|
85
|
+
Examples:
|
|
86
|
+
cli4ai run github trending
|
|
87
|
+
cli4ai run chrome screenshot https://example.com --full-page
|
|
88
|
+
cli4ai run github list-issues --scope read
|
|
89
|
+
cli4ai run untrusted-pkg process --sandbox
|
|
90
|
+
cli4ai run browser screenshot --remote chrome-server
|
|
91
|
+
|
|
92
|
+
Pass-through:
|
|
93
|
+
Use "--" to pass flags that would otherwise be parsed by cli4ai:
|
|
94
|
+
cli4ai run <pkg> <cmd> -- --help
|
|
95
|
+
|
|
96
|
+
Security:
|
|
97
|
+
--scope read Only allow read operations (no mutations)
|
|
98
|
+
--scope write Allow write operations
|
|
99
|
+
--scope full Full access (default)
|
|
100
|
+
--sandbox Restrict file system access to temp directories
|
|
101
|
+
|
|
102
|
+
Remote Execution:
|
|
103
|
+
--remote <name> Execute on a configured remote service
|
|
104
|
+
Use "cli4ai remotes add" to configure remotes
|
|
105
|
+
`)
|
|
106
|
+
.action(withErrorHandling(runCommand));
|
|
107
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
108
|
+
// DISCOVERY
|
|
109
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
110
|
+
program
|
|
111
|
+
.command('info <package>')
|
|
112
|
+
.description('Show package information')
|
|
113
|
+
.option('--versions', 'Show all available versions')
|
|
114
|
+
.option('-r, --remote <name>', 'Get info from a remote server')
|
|
115
|
+
.action(withErrorHandling(infoCommand));
|
|
116
|
+
program
|
|
117
|
+
.command('search <query>')
|
|
118
|
+
.description('Search for packages')
|
|
119
|
+
.option('-l, --limit <n>', 'Max results', '20')
|
|
120
|
+
.option('-r, --remote <name>', 'Search packages on a remote server')
|
|
121
|
+
.action(withErrorHandling(searchCommand));
|
|
122
|
+
program
|
|
123
|
+
.command('browse')
|
|
124
|
+
.description('Interactive package browser')
|
|
125
|
+
.action(withErrorHandling(browseCommand));
|
|
126
|
+
program
|
|
127
|
+
.command('update')
|
|
128
|
+
.alias('upgrade')
|
|
129
|
+
.description('Update installed packages')
|
|
130
|
+
.option('-s, --self', 'Update cli4ai framework only')
|
|
131
|
+
.option('-a, --all', 'Update cli4ai framework and all packages')
|
|
132
|
+
.option('-y, --yes', 'Skip confirmation prompt')
|
|
133
|
+
.action(withErrorHandling(updateCommand));
|
|
134
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
135
|
+
// CONFIGURATION
|
|
136
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
137
|
+
program
|
|
138
|
+
.command('config [key] [value]')
|
|
139
|
+
.description('Get or set configuration')
|
|
140
|
+
.option('--list', 'List all config values')
|
|
141
|
+
.option('--add-registry <path>', 'Add local registry path')
|
|
142
|
+
.option('--remove-registry <path>', 'Remove local registry path')
|
|
143
|
+
.action(withErrorHandling(configCommand));
|
|
144
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
145
|
+
// MCP INTEGRATION
|
|
146
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
147
|
+
program
|
|
148
|
+
.command('mcp-config')
|
|
149
|
+
.description('Generate MCP configuration for Claude Code')
|
|
150
|
+
.option('-g, --global', 'Use global packages only')
|
|
151
|
+
.option('-p, --package <name>', 'Generate for specific package')
|
|
152
|
+
.option('--snippet', 'Output as config snippet (use with --package)')
|
|
153
|
+
.action(withErrorHandling(mcpConfigCommand));
|
|
154
|
+
program
|
|
155
|
+
.command('start <package>')
|
|
156
|
+
.description('Start MCP server for a package')
|
|
157
|
+
.option('--stdio', 'Use stdio transport (default)')
|
|
158
|
+
.action(withErrorHandling(startCommand));
|
|
159
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
160
|
+
// SECRETS MANAGEMENT
|
|
161
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
162
|
+
const secrets = program
|
|
163
|
+
.command('secrets')
|
|
164
|
+
.description('Manage secrets for CLI tools');
|
|
165
|
+
secrets
|
|
166
|
+
.command('set <key> [value]')
|
|
167
|
+
.description('Set a secret (prompts for value if not provided)')
|
|
168
|
+
.action(withErrorHandling(secretsSetCommand));
|
|
169
|
+
secrets
|
|
170
|
+
.command('get <key>')
|
|
171
|
+
.description('Get a secret value')
|
|
172
|
+
.action(withErrorHandling(secretsGetCommand));
|
|
173
|
+
secrets
|
|
174
|
+
.command('list')
|
|
175
|
+
.alias('ls')
|
|
176
|
+
.description('List all secrets')
|
|
177
|
+
.option('-p, --package <name>', 'Show secrets for a specific package')
|
|
178
|
+
.action(withErrorHandling(secretsListCommand));
|
|
179
|
+
secrets
|
|
180
|
+
.command('delete <key>')
|
|
181
|
+
.alias('rm')
|
|
182
|
+
.description('Delete a secret')
|
|
183
|
+
.action(withErrorHandling(secretsDeleteCommand));
|
|
184
|
+
secrets
|
|
185
|
+
.command('init <package>')
|
|
186
|
+
.description('Interactive setup for a package\'s required secrets')
|
|
187
|
+
.action(withErrorHandling(secretsInitCommand));
|
|
188
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
189
|
+
// HELP
|
|
190
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
191
|
+
program.addHelpCommand('help [command]', 'Show help for command');
|
|
192
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
193
|
+
// ROUTINES
|
|
194
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
195
|
+
const routines = program
|
|
196
|
+
.command('routines')
|
|
197
|
+
.description('Manage and run routines');
|
|
198
|
+
routines
|
|
199
|
+
.command('list')
|
|
200
|
+
.alias('ls')
|
|
201
|
+
.description('List available routines')
|
|
202
|
+
.option('-g, --global', 'Use global routines only')
|
|
203
|
+
.option('--json', 'Output as JSON')
|
|
204
|
+
.action(withErrorHandling(routinesListCommand));
|
|
205
|
+
routines
|
|
206
|
+
.command('show <name>')
|
|
207
|
+
.description('Show routine definition')
|
|
208
|
+
.option('-g, --global', 'Use global routines only')
|
|
209
|
+
.action(withErrorHandling(routinesShowCommand));
|
|
210
|
+
routines
|
|
211
|
+
.command('create <name>')
|
|
212
|
+
.description('Create a new routine')
|
|
213
|
+
.option('-g, --global', 'Create routine globally')
|
|
214
|
+
.option('--type <type>', 'Routine type (yaml, json, bash)', 'yaml')
|
|
215
|
+
.action(withErrorHandling(routinesCreateCommand));
|
|
216
|
+
routines
|
|
217
|
+
.command('edit <name>')
|
|
218
|
+
.description('Edit a routine in $EDITOR')
|
|
219
|
+
.option('-g, --global', 'Use global routine only')
|
|
220
|
+
.action(withErrorHandling(routinesEditCommand));
|
|
221
|
+
routines
|
|
222
|
+
.command('remove <name>')
|
|
223
|
+
.alias('rm')
|
|
224
|
+
.description('Remove a routine')
|
|
225
|
+
.option('-g, --global', 'Use global routine only')
|
|
226
|
+
.action(withErrorHandling(routinesRemoveCommand));
|
|
227
|
+
routines
|
|
228
|
+
.command('run <name> [args...]')
|
|
229
|
+
.description('Run a routine')
|
|
230
|
+
.option('-g, --global', 'Use global routine only')
|
|
231
|
+
.option('--var <vars...>', 'Variables (KEY=value)')
|
|
232
|
+
.option('--dry-run', 'Show execution plan without running')
|
|
233
|
+
.action(withErrorHandling(routinesRunCommand));
|
|
234
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
235
|
+
// SCHEDULER
|
|
236
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
237
|
+
const scheduler = program
|
|
238
|
+
.command('scheduler')
|
|
239
|
+
.description('Manage scheduled routine execution');
|
|
240
|
+
scheduler
|
|
241
|
+
.command('start')
|
|
242
|
+
.description('Start the scheduler daemon')
|
|
243
|
+
.option('-f, --foreground', 'Run in foreground (blocking)')
|
|
244
|
+
.action(withErrorHandling(schedulerStartCommand));
|
|
245
|
+
scheduler
|
|
246
|
+
.command('stop')
|
|
247
|
+
.description('Stop the scheduler daemon')
|
|
248
|
+
.action(withErrorHandling(schedulerStopCommand));
|
|
249
|
+
scheduler
|
|
250
|
+
.command('status')
|
|
251
|
+
.description('Show scheduler status and upcoming runs')
|
|
252
|
+
.action(withErrorHandling(schedulerStatusCommand));
|
|
253
|
+
scheduler
|
|
254
|
+
.command('logs')
|
|
255
|
+
.description('View scheduler logs')
|
|
256
|
+
.option('-f, --follow', 'Follow log output')
|
|
257
|
+
.option('-n, --lines <n>', 'Number of lines to show', '50')
|
|
258
|
+
.action(withErrorHandling(schedulerLogsCommand));
|
|
259
|
+
scheduler
|
|
260
|
+
.command('history [routine]')
|
|
261
|
+
.description('View routine execution history')
|
|
262
|
+
.option('-n, --limit <n>', 'Number of records to show', '20')
|
|
263
|
+
.action(withErrorHandling(schedulerHistoryCommand));
|
|
264
|
+
scheduler
|
|
265
|
+
.command('run <routine>')
|
|
266
|
+
.description('Manually trigger a scheduled routine')
|
|
267
|
+
.action(withErrorHandling(schedulerRunCommand));
|
|
268
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
269
|
+
// REMOTE EXECUTION
|
|
270
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
271
|
+
program
|
|
272
|
+
.command('serve')
|
|
273
|
+
.description('Start cli4ai as a remote service')
|
|
274
|
+
.option('-p, --port <port>', 'Port to listen on', '4100')
|
|
275
|
+
.option('-H, --host <host>', 'Host to bind to', '0.0.0.0')
|
|
276
|
+
.option('-k, --api-key <key>', 'API key for authentication')
|
|
277
|
+
.option('--scope <levels>', 'Comma-separated allowed scopes (read,write,full)')
|
|
278
|
+
.option('--cwd <dir>', 'Working directory for execution')
|
|
279
|
+
.addHelpText('after', `
|
|
280
|
+
|
|
281
|
+
Examples:
|
|
282
|
+
cli4ai serve # Start on port 4100
|
|
283
|
+
cli4ai serve --port 8080 # Start on port 8080
|
|
284
|
+
cli4ai serve --api-key mysecretkey # Require API key
|
|
285
|
+
cli4ai serve --scope read,write # Restrict to read/write operations
|
|
286
|
+
|
|
287
|
+
The service exposes these endpoints:
|
|
288
|
+
GET /health - Service health check
|
|
289
|
+
GET /packages - List available packages
|
|
290
|
+
GET /packages/:name - Get package info
|
|
291
|
+
POST /run - Execute a tool
|
|
292
|
+
POST /routines/:name/run - Run a routine
|
|
293
|
+
`)
|
|
294
|
+
.action(withErrorHandling(serveCommand));
|
|
295
|
+
const remotes = program
|
|
296
|
+
.command('remotes')
|
|
297
|
+
.description('Manage remote cli4ai services');
|
|
298
|
+
remotes
|
|
299
|
+
.command('list')
|
|
300
|
+
.alias('ls')
|
|
301
|
+
.description('List configured remotes')
|
|
302
|
+
.action(withErrorHandling(remotesListCommand));
|
|
303
|
+
remotes
|
|
304
|
+
.command('add <name> <url>')
|
|
305
|
+
.description('Add a remote service')
|
|
306
|
+
.option('-k, --api-key <key>', 'API key for authentication')
|
|
307
|
+
.option('-d, --description <desc>', 'Description of this remote')
|
|
308
|
+
.option('--no-test', 'Skip connection test')
|
|
309
|
+
.action(withErrorHandling(remotesAddCommand));
|
|
310
|
+
remotes
|
|
311
|
+
.command('update <name>')
|
|
312
|
+
.description('Update a remote service')
|
|
313
|
+
.option('-u, --url <url>', 'New URL')
|
|
314
|
+
.option('-k, --api-key <key>', 'New API key')
|
|
315
|
+
.option('-d, --description <desc>', 'New description')
|
|
316
|
+
.action(withErrorHandling(remotesUpdateCommand));
|
|
317
|
+
remotes
|
|
318
|
+
.command('remove <name>')
|
|
319
|
+
.alias('rm')
|
|
320
|
+
.description('Remove a remote')
|
|
321
|
+
.action(withErrorHandling(remotesRemoveCommand));
|
|
322
|
+
remotes
|
|
323
|
+
.command('show <name>')
|
|
324
|
+
.description('Show remote details')
|
|
325
|
+
.action(withErrorHandling(remotesShowCommand));
|
|
326
|
+
remotes
|
|
327
|
+
.command('test <name>')
|
|
328
|
+
.description('Test connection to a remote')
|
|
329
|
+
.action(withErrorHandling(remotesTestCommand));
|
|
330
|
+
remotes
|
|
331
|
+
.command('packages <name>')
|
|
332
|
+
.description('List packages on a remote')
|
|
333
|
+
.action(withErrorHandling(remotesPackagesCommand));
|
|
334
|
+
return program;
|
|
335
|
+
}
|