cli-box-skill 0.0.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 ADDED
@@ -0,0 +1,39 @@
1
+ # cli-box-skill
2
+
3
+ macOS desktop automation sandbox for AI agents.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g cli-box-skill
9
+ ```
10
+
11
+ ## What is cli-box?
12
+
13
+ A macOS sandbox that lets AI agents (Claude Code, OpenCode, etc.) run CLI tools in isolated windows with screenshot feedback and input simulation.
14
+
15
+ ## Quick start
16
+
17
+ ```bash
18
+ cli-box start claude # Start Claude Code sandbox
19
+ cli-box start zsh # Start zsh sandbox
20
+ cli-box list # List active sandboxes
21
+ cli-box screenshot --id <id> -o shot.png # Screenshot
22
+ cli-box close <id> # Close sandbox
23
+ ```
24
+
25
+ ## No npm?
26
+
27
+ ```bash
28
+ bash <(curl -fsSL https://raw.githubusercontent.com/ZN-Ice/cli-box/main/skill/install.sh)
29
+ ```
30
+
31
+ ## Links
32
+
33
+ - [GitHub](https://github.com/ZN-Ice/cli-box)
34
+ - [Full README](https://github.com/ZN-Ice/cli-box#readme)
35
+ - [Installation Guide](https://github.com/ZN-Ice/cli-box/blob/main/docs/guide/installation.md)
36
+
37
+ ## License
38
+
39
+ Apache 2.0
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * cli-box wrapper — finds the platform binary and delegates.
5
+ * Allows `npx cli-box` or global `cli-box` command to work.
6
+ */
7
+
8
+ import { createRequire } from 'module';
9
+ import { spawn } from 'child_process';
10
+ import path from 'path';
11
+ import os from 'os';
12
+
13
+ const platform = process.platform === 'darwin' ? 'darwin' :
14
+ process.platform === 'win32' ? 'win32' : 'linux';
15
+ const arch = process.arch === 'arm64' ? 'arm64' : 'x64';
16
+ const platformPkgName = `cli-box-${platform}-${arch}`;
17
+
18
+ let binPath;
19
+ try {
20
+ const require = createRequire(import.meta.url);
21
+ const pkgJsonPath = require.resolve(`${platformPkgName}/package.json`);
22
+ const pkgDir = path.dirname(pkgJsonPath);
23
+ binPath = path.join(pkgDir, 'bin', 'cli-box');
24
+ } catch (e) {
25
+ // Fallback: check ~/.cli-box/bin/
26
+ binPath = path.join(os.homedir(), '.cli-box', 'bin', 'cli-box');
27
+ }
28
+
29
+ const args = process.argv.slice(2);
30
+ const child = spawn(binPath, args, { stdio: 'inherit' });
31
+ child.on('exit', (code) => process.exit(code ?? 1));
32
+ child.on('error', (err) => {
33
+ console.error(`Failed to run cli-box: ${err.message}`);
34
+ console.error('Install via: npm install -g cli-box-skill');
35
+ console.error('Or: bash <(curl -fsSL https://raw.githubusercontent.com/ZN-Ice/cli-box/main/skill/install.sh)');
36
+ process.exit(1);
37
+ });
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "cli-box-skill",
3
+ "version": "0.0.1",
4
+ "description": "macOS desktop automation sandbox for AI agents",
5
+ "main": "postinstall.mjs",
6
+ "bin": {
7
+ "cli-box": "./bin/cli-box-wrapper.js"
8
+ },
9
+ "scripts": {
10
+ "postinstall": "node postinstall.mjs"
11
+ },
12
+ "optionalDependencies": {
13
+ "cli-box-darwin-arm64": "0.0.1",
14
+ "cli-box-electron-darwin-arm64": "0.0.1"
15
+ },
16
+ "files": [
17
+ "skill/SKILL.md",
18
+ "skill/install.sh",
19
+ "postinstall.mjs",
20
+ "bin/",
21
+ "README.md"
22
+ ],
23
+ "keywords": [
24
+ "cli-box",
25
+ "macos",
26
+ "automation",
27
+ "sandbox",
28
+ "claude-code",
29
+ "opencode",
30
+ "skill",
31
+ "desktop",
32
+ "screenshot"
33
+ ],
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/ZN-Ice/cli-box.git"
37
+ },
38
+ "author": "ZN-Ice",
39
+ "license": "Apache-2.0"
40
+ }
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * cli-box postinstall script
5
+ *
6
+ * Runs after `npm install -g cli-box-skill`.
7
+ * 1. Finds the installed platform package (cli-box-darwin-arm64)
8
+ * 2. Creates symlinks in ~/.cli-box/bin/
9
+ * 3. Installs SKILL.md to .claude/skills/cli-box/ and .opencode/skills/cli-box/
10
+ */
11
+
12
+ import { createRequire } from 'module';
13
+ import fs from 'fs';
14
+ import path from 'path';
15
+ import os from 'os';
16
+
17
+ const home = os.homedir();
18
+ const binDir = path.join(home, '.cli-box', 'bin');
19
+
20
+ function info(msg) { console.log(` ➜ ${msg}`); }
21
+ function ok(msg) { console.log(` ✓ ${msg}`); }
22
+ function warn(msg) { console.warn(` ⚠ ${msg}`); }
23
+
24
+ // 1. Detect platform
25
+ const platform = process.platform === 'darwin' ? 'darwin' :
26
+ process.platform === 'win32' ? 'win32' : 'linux';
27
+ const arch = process.arch === 'arm64' ? 'arm64' : 'x64';
28
+ const platformPkgName = `cli-box-${platform}-${arch}`;
29
+
30
+ info(`Platform: ${platform}-${arch}`);
31
+
32
+ // 2. Find platform package
33
+ let platformPkgDir;
34
+ try {
35
+ const require = createRequire(import.meta.url);
36
+ const pkgJsonPath = require.resolve(`${platformPkgName}/package.json`);
37
+ platformPkgDir = path.dirname(pkgJsonPath);
38
+ ok(`Found platform package: ${platformPkgName}`);
39
+ } catch (e) {
40
+ warn(`Platform package ${platformPkgName} not found. Skipping binary setup.`);
41
+ warn('You can install binaries manually via: bash <(curl -fsSL https://raw.githubusercontent.com/ZN-Ice/cli-box/main/skill/install.sh)');
42
+ process.exit(0);
43
+ }
44
+
45
+ // 3. Create symlinks
46
+ try {
47
+ fs.mkdirSync(binDir, { recursive: true });
48
+
49
+ const bins = ['cli-box', 'cli-box-daemon'];
50
+ for (const bin of bins) {
51
+ const src = path.join(platformPkgDir, 'bin', bin);
52
+ const dst = path.join(binDir, bin);
53
+
54
+ if (fs.existsSync(src)) {
55
+ fs.rmSync(dst, { force: true });
56
+ fs.symlinkSync(src, dst);
57
+ fs.chmodSync(src, 0o755);
58
+ ok(`${bin} → ${src}`);
59
+ } else {
60
+ warn(`${bin} not found in platform package`);
61
+ }
62
+ }
63
+ } catch (e) {
64
+ warn(`Failed to create symlinks: ${e.message}`);
65
+ }
66
+
67
+ // 4. Install SKILL.md
68
+ const skillSrc = path.join(path.dirname(new URL(import.meta.url).pathname), 'skill', 'SKILL.md');
69
+
70
+ const targets = [
71
+ path.join(home, '.claude', 'skills', 'cli-box'),
72
+ path.join(home, '.config', 'opencode', 'skills', 'cli-box'),
73
+ ];
74
+
75
+ for (const target of targets) {
76
+ try {
77
+ if (fs.existsSync(path.dirname(target))) {
78
+ fs.mkdirSync(target, { recursive: true });
79
+ fs.copyFileSync(skillSrc, path.join(target, 'SKILL.md'));
80
+ ok(`SKILL.md → ${target}/`);
81
+ }
82
+ } catch (e) {
83
+ // Silent — target harness may not be installed
84
+ }
85
+ }
86
+
87
+ // 5. Done
88
+ console.log('');
89
+ console.log(' cli-box installed successfully!');
90
+ console.log('');
91
+ console.log(' Add to PATH:');
92
+ console.log(` export PATH="$HOME/.cli-box/bin:$PATH"`);
93
+ console.log('');
94
+ console.log(' Quick start:');
95
+ console.log(' cli-box start claude');
96
+ console.log(' cli-box start zsh');
97
+ console.log(' cli-box list');
98
+ console.log('');
package/skill/SKILL.md ADDED
@@ -0,0 +1,132 @@
1
+ ---
2
+ name: cli-box
3
+ description: macOS desktop automation sandbox — run CLI tools and macOS apps in isolated sandbox windows with screenshot feedback and input simulation
4
+ ---
5
+
6
+ # cli-box
7
+
8
+ macOS desktop automation sandbox. Launch isolated sandbox windows from the CLI, run any CLI tool (Claude Code, OpenCode, zsh, etc.) inside them, and automate via screenshot + keyboard/mouse simulation.
9
+
10
+ ## Prerequisites
11
+
12
+ - macOS 14.0+ (Sonoma), Apple Silicon or Intel
13
+ - **Accessibility** permission (System Settings → Privacy & Security → Accessibility)
14
+ - **Screen Recording** permission (System Settings → Privacy & Security → Screen Recording)
15
+
16
+ Both permissions must be granted manually. Add `cli-box` and `CLI Box.app` to both lists.
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install -g cli-box-skill
22
+ ```
23
+
24
+ Or via GitHub Release:
25
+
26
+ ```bash
27
+ bash <(curl -fsSL https://raw.githubusercontent.com/ZN-Ice/cli-box/main/skill/install.sh)
28
+ ```
29
+
30
+ ## Quick Start
31
+
32
+ ```bash
33
+ # Start a sandbox running Claude Code
34
+ cli-box start claude
35
+
36
+ # Start a sandbox running zsh
37
+ cli-box start zsh
38
+
39
+ # List all active sandboxes
40
+ cli-box list
41
+
42
+ # Take a screenshot of a sandbox
43
+ cli-box screenshot --id <sandbox-id> -o screenshot.png
44
+
45
+ # Type text into a sandbox (PTY mode for CLI tools)
46
+ cli-box type --id <sandbox-id> --pty "hello world"
47
+
48
+ # Press Enter to send
49
+ cli-box key --id <sandbox-id> --pty Return
50
+
51
+ # Close a sandbox
52
+ cli-box close <sandbox-id>
53
+ ```
54
+
55
+ ## Commands
56
+
57
+ ### Sandbox Management
58
+
59
+ | Command | Description |
60
+ |---------|-------------|
61
+ | `cli-box start [command]` | Start sandbox (default: zsh). Supports `claude`, `opencode`, `zsh`, `bash`, or any CLI |
62
+ | `cli-box start /path/to/App.app` | Start sandbox with a macOS application |
63
+ | `cli-box start claude -- -p "question"` | Start sandbox with arguments |
64
+ | `cli-box list` | List all active sandboxes with ID, title, status, port |
65
+ | `cli-box close <id>` | Close a sandbox and clean up |
66
+ | `cli-box inspect <id>` | Show sandbox details |
67
+
68
+ ### Input Simulation
69
+
70
+ | Command | Description |
71
+ |---------|-------------|
72
+ | `cli-box type --id <id> --pty "text"` | Type text via PTY (recommended for CLI tools) |
73
+ | `cli-box key --id <id> --pty Return` | Press a key via PTY |
74
+ | `cli-box key --id <id> --pty ctrl+c` | Send Ctrl+C |
75
+ | `cli-box key --id <id> --pty up` | Arrow keys |
76
+ | `cli-box click --id <id> 100 200` | Mouse click at coordinates (CGEvent) |
77
+
78
+ ### Screenshots
79
+
80
+ | Command | Description |
81
+ |---------|-------------|
82
+ | `cli-box screenshot --id <id>` | Screenshot to stdout (base64) |
83
+ | `cli-box screenshot --id <id> -o file.png` | Screenshot to file |
84
+
85
+ ### MCP Integration
86
+
87
+ Add to `.claude/settings.json` or `.opencode/config.json`:
88
+
89
+ ```json
90
+ {
91
+ "mcpServers": {
92
+ "cli-box": {
93
+ "command": "cli-box",
94
+ "args": ["mcp-serve"]
95
+ }
96
+ }
97
+ }
98
+ ```
99
+
100
+ Then use tools: `start_sandbox`, `screenshot`, `click`, `type_text`, `press_key`, `close_sandbox`, `list_sandboxes`.
101
+
102
+ ## Typical Workflow
103
+
104
+ ```bash
105
+ # 1. Start sandbox
106
+ cli-box start claude
107
+ # → Returns: Sandbox started: abc123
108
+
109
+ # 2. Wait for tool to initialize
110
+ sleep 10
111
+
112
+ # 3. Screenshot to see current state
113
+ cli-box screenshot --id abc123 -o state.png
114
+
115
+ # 4. Interact
116
+ cli-box type --id abc123 --pty "Write a hello world function"
117
+ cli-box key --id abc123 --pty Return
118
+
119
+ # 5. Wait and screenshot again
120
+ sleep 15
121
+ cli-box screenshot --id abc123 -o result.png
122
+
123
+ # 6. Clean up
124
+ cli-box close abc123
125
+ ```
126
+
127
+ ## Notes
128
+
129
+ - CLI tools (claude, opencode, zsh) should always use `--pty` mode for input
130
+ - CGEvent mode (no `--pty`) is for GUI app sandboxes only
131
+ - Each sandbox gets its own Electron tab and HTTP port
132
+ - The daemon auto-starts on first `cli-box start` and manages all sandboxes
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # cli-box skill installer
5
+ # Downloads binaries from GitHub Release and sets up skill files
6
+
7
+ REPO="ZN-Ice/cli-box"
8
+ VERSION="${CLI_BOX_VERSION:-latest}"
9
+ INSTALL_DIR="$HOME/.cli-box/bin"
10
+ SKILL_CLAUDE_DIR="$HOME/.claude/skills/cli-box"
11
+ SKILL_OPENCODE_DIR="$HOME/.config/opencode/skills/cli-box"
12
+
13
+ info() { echo " ➜ $*"; }
14
+ ok() { echo " ✓ $*"; }
15
+ err() { echo " ✗ $*" >&2; exit 1; }
16
+
17
+ echo ""
18
+ echo "=============================================="
19
+ echo " cli-box — Skill Installer"
20
+ echo "=============================================="
21
+ echo ""
22
+
23
+ # Check prerequisites
24
+ if ! command -v curl &>/dev/null; then
25
+ err "curl not found — please install curl"
26
+ fi
27
+
28
+ if [[ "$(uname)" != "Darwin" ]]; then
29
+ err "cli-box only supports macOS"
30
+ fi
31
+
32
+ # Determine version
33
+ if [ "$VERSION" = "latest" ]; then
34
+ info "Fetching latest release version..."
35
+ VERSION=$(curl -fsSL "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name"' | sed 's/.*"tag_name": *"//' | sed 's/".*//')
36
+ if [ -z "$VERSION" ]; then
37
+ err "Failed to fetch latest version"
38
+ fi
39
+ fi
40
+ ok "Version: $VERSION"
41
+
42
+ # Download skill tarball
43
+ info "Downloading cli-box-skill.tar.gz..."
44
+ TMPDIR=$(mktemp -d)
45
+ trap 'rm -rf "$TMPDIR"' EXIT
46
+
47
+ DOWNLOAD_URL="https://github.com/$REPO/releases/download/$VERSION/cli-box-skill.tar.gz"
48
+ if ! curl -fsSL "$DOWNLOAD_URL" -o "$TMPDIR/cli-box-skill.tar.gz"; then
49
+ err "Failed to download from $DOWNLOAD_URL"
50
+ fi
51
+ ok "Downloaded"
52
+
53
+ # Extract
54
+ info "Extracting..."
55
+ tar xzf "$TMPDIR/cli-box-skill.tar.gz" -C "$TMPDIR"
56
+
57
+ # Install binaries
58
+ info "Installing binaries to $INSTALL_DIR..."
59
+ mkdir -p "$INSTALL_DIR"
60
+ cp "$TMPDIR/bin/cli-box" "$INSTALL_DIR/"
61
+ cp "$TMPDIR/bin/cli-box-daemon" "$INSTALL_DIR/"
62
+ chmod +x "$INSTALL_DIR/cli-box" "$INSTALL_DIR/cli-box-daemon"
63
+ ok "Binaries installed"
64
+
65
+ # Install skill to Claude Code
66
+ if [ -d "$(dirname "$SKILL_CLAUDE_DIR")" ]; then
67
+ info "Installing skill to Claude Code..."
68
+ mkdir -p "$SKILL_CLAUDE_DIR"
69
+ cp "$TMPDIR/SKILL.md" "$SKILL_CLAUDE_DIR/"
70
+ ok "Skill installed to $SKILL_CLAUDE_DIR"
71
+ fi
72
+
73
+ # Install skill to OpenCode
74
+ if [ -d "$(dirname "$SKILL_OPENCODE_DIR")" ]; then
75
+ info "Installing skill to OpenCode..."
76
+ mkdir -p "$SKILL_OPENCODE_DIR"
77
+ cp "$TMPDIR/SKILL.md" "$SKILL_OPENCODE_DIR/"
78
+ ok "Skill installed to $SKILL_OPENCODE_DIR"
79
+ fi
80
+
81
+ # Check PATH
82
+ if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
83
+ echo ""
84
+ info "Add to your PATH:"
85
+ echo " export PATH=\"\$HOME/.cli-box/bin:\$PATH\""
86
+ echo ""
87
+ info "Add to ~/.zshrc or ~/.bashrc for persistence."
88
+ fi
89
+
90
+ # Verify
91
+ echo ""
92
+ info "Verifying installation..."
93
+ if "$INSTALL_DIR/cli-box" --version &>/dev/null; then
94
+ ok "cli-box installed: $($INSTALL_DIR/cli-box --version 2>&1 || echo 'ok')"
95
+ else
96
+ ok "cli-box binary installed (version check requires daemon)"
97
+ fi
98
+
99
+ echo ""
100
+ echo "=============================================="
101
+ echo " Installation complete!"
102
+ echo ""
103
+ echo " Quick start:"
104
+ echo " cli-box start claude # Start Claude Code sandbox"
105
+ echo " cli-box start zsh # Start zsh sandbox"
106
+ echo " cli-box list # List active sandboxes"
107
+ echo ""
108
+ echo " Permissions required:"
109
+ echo " System Settings → Privacy & Security → Accessibility"
110
+ echo " System Settings → Privacy & Security → Screen Recording"
111
+ echo "=============================================="
112
+ echo ""