@kokorolx/ai-sandbox-wrapper 2.7.0 โ†’ 3.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/bin/cli.js CHANGED
@@ -23,6 +23,7 @@ Commands:
23
23
  setup Run interactive setup (configure workspaces, select tools)
24
24
  update Interactive menu to manage config (workspaces, git, networks)
25
25
  clean Interactive cleanup for caches/configs
26
+ clean cache [type] Clear shared package caches (npm, bun, pip, playwright-browsers)
26
27
  config show [--json] Display current global configuration
27
28
  config tool <tool> [--show] Display host paths and config for a specific tool
28
29
 
@@ -326,9 +327,9 @@ async function runConfigTool(toolName, showContent) {
326
327
  process.exit(1);
327
328
  }
328
329
 
329
- const toolHome = path.join(SANDBOX_DIR, 'tools', toolName, 'home');
330
+ const toolHome = path.join(SANDBOX_DIR, 'home');
330
331
  console.log(`\n๐Ÿ” Sandbox Configuration for: ${toolName}`);
331
- console.log(`Host Home: ${toolHome}`);
332
+ console.log(`Sandbox Home: ${toolHome}`);
332
333
 
333
334
  if (!fs.existsSync(toolHome)) {
334
335
  console.log('Status: โš ๏ธ Not yet initialized (folder missing on host)');
@@ -1259,6 +1260,45 @@ async function manageNetworksMenu(rl) {
1259
1260
  }
1260
1261
  }
1261
1262
 
1263
+ // ============================================================================
1264
+ // CLEAN CACHE COMMAND (non-interactive)
1265
+ // ============================================================================
1266
+ const CACHE_TYPES = ['npm', 'bun', 'pip', 'playwright-browsers']
1267
+
1268
+ function runCleanCache(cacheType) {
1269
+ const cacheDir = path.join(SANDBOX_DIR, 'cache')
1270
+
1271
+ if (cacheType && !CACHE_TYPES.includes(cacheType)) {
1272
+ console.error(`โŒ Unknown cache type: ${cacheType}`)
1273
+ console.error(`Valid types: ${CACHE_TYPES.join(', ')}`)
1274
+ process.exit(1)
1275
+ }
1276
+
1277
+ const targets = cacheType ? [cacheType] : CACHE_TYPES
1278
+
1279
+ let totalFreed = 0
1280
+ for (const t of targets) {
1281
+ const targetPath = path.join(cacheDir, t)
1282
+ if (!pathExists(targetPath)) {
1283
+ console.log(` โญ ${t}/ (not found)`)
1284
+ continue
1285
+ }
1286
+ const size = getPathSize(targetPath)
1287
+ const sizeNum = typeof size === 'number' ? size : 0
1288
+ try {
1289
+ fs.rmSync(targetPath, { recursive: true, force: true })
1290
+ fs.mkdirSync(targetPath, { recursive: true })
1291
+ totalFreed += sizeNum
1292
+ console.log(` โœ“ ${t}/ cleared (${formatBytes(sizeNum)})`)
1293
+ } catch (err) {
1294
+ const msg = err && err.message ? err.message : String(err)
1295
+ console.error(` โŒ ${t}/: ${msg}`)
1296
+ }
1297
+ }
1298
+
1299
+ console.log(`\n๐Ÿงน Freed ${formatBytes(totalFreed)}`)
1300
+ }
1301
+
1262
1302
  // Parse subcommand and options
1263
1303
  const subCommand = positionalArgs[1];
1264
1304
  const subArg = positionalArgs[2];
@@ -1286,11 +1326,15 @@ switch (command) {
1286
1326
  });
1287
1327
  break;
1288
1328
  case 'clean':
1289
- runClean().catch((err) => {
1290
- const message = err && err.message ? err.message : String(err);
1291
- console.error('โŒ Cleanup failed:', message);
1292
- process.exit(1);
1293
- });
1329
+ if (subCommand === 'cache') {
1330
+ runCleanCache(subArg)
1331
+ } else {
1332
+ runClean().catch((err) => {
1333
+ const message = err && err.message ? err.message : String(err)
1334
+ console.error('โŒ Cleanup failed:', message)
1335
+ process.exit(1)
1336
+ })
1337
+ }
1294
1338
  break;
1295
1339
  case 'config':
1296
1340
  if (subCommand === 'show') {
@@ -6,15 +6,21 @@ FROM node:22-bookworm-slim
6
6
 
7
7
  ARG AGENT_UID=1001
8
8
 
9
- RUN apt-get update && apt-get install -y --no-install-recommends git curl ssh ca-certificates jq python3 python3-pip python3-venv python3-dev python3-setuptools build-essential libopenblas-dev pipx unzip xclip wl-clipboard ripgrep && curl -LsSf https://astral.sh/uv/install.sh | UV_INSTALL_DIR=/usr/local/bin sh && rm -rf /var/lib/apt/lists/* && pipx ensurepath
9
+ RUN apt-get update && apt-get install -y --no-install-recommends git curl ssh ca-certificates jq python3 python3-pip python3-venv python3-dev python3-setuptools build-essential libopenblas-dev pipx unzip xclip wl-clipboard ripgrep tmux fd-find sqlite3 poppler-utils qpdf tesseract-ocr && curl -LsSf https://astral.sh/uv/install.sh | UV_INSTALL_DIR=/usr/local/bin sh && rm -rf /var/lib/apt/lists/* && pipx ensurepath
10
+
11
+ # Install Python PDF processing tools for PDF skill
12
+ RUN pip3 install --no-cache-dir --break-system-packages pypdf pdfplumber reportlab pytesseract pdf2image
10
13
 
11
14
  RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg && chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null && apt-get update && apt-get install -y gh && rm -rf /var/lib/apt/lists/*
12
15
 
16
+ # Install bun (used by most AI tool install scripts)
17
+ RUN npm install -g bun
18
+
13
19
  # Install pnpm globally using npm (not bun, for stability)
14
20
  RUN npm install -g pnpm
15
21
 
16
22
  # Install TypeScript and LSP tools using npm
17
- RUN npm install -g typescript typescript-language-server
23
+ RUN npm install -g typescript typescript-language-server pyright vscode-langservers-extracted
18
24
 
19
25
  # Verify installations
20
26
  RUN node --version && npm --version && pnpm --version && tsc --version
@@ -40,6 +46,10 @@ RUN mkdir -p /usr/local/lib/openspec && \
40
46
  chmod +x /usr/local/bin/openspec
41
47
  # Install RTK - token optimizer for AI coding agents (built from source)
42
48
  COPY --from=rtk-builder /usr/local/cargo/bin/rtk /usr/local/bin/rtk
49
+ # Install RTK OpenCode skills (auto-discovered by OpenCode agents)
50
+ RUN mkdir -p /home/agent/.config/opencode/skills/rtk /home/agent/.config/opencode/skills/rtk-setup
51
+ COPY skills/rtk/SKILL.md /home/agent/.config/opencode/skills/rtk/SKILL.md
52
+ COPY skills/rtk-setup/SKILL.md /home/agent/.config/opencode/skills/rtk-setup/SKILL.md
43
53
  RUN apt-get update && apt-get install -y --no-install-recommends \
44
54
  libglib2.0-0 \
45
55
  libnspr4 \
@@ -77,7 +87,9 @@ RUN mkdir -p /opt/playwright-browsers && \
77
87
  npx playwright-core install-deps chromium && \
78
88
  chmod -R 777 /opt/playwright-browsers && \
79
89
  ln -sf $(ls -d /opt/playwright-browsers/chromium-*/chrome-linux/chrome | head -1) /opt/chromium
80
- RUN touch /opt/.mcp-playwright-installed
90
+ ENV CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS=1
91
+ RUN npm install -g chrome-devtools-mcp@latest && \
92
+ touch /opt/.mcp-chrome-devtools-installed
81
93
 
82
94
  # Create workspace
83
95
  WORKDIR /workspace
@@ -0,0 +1,103 @@
1
+ ---
2
+ name: rtk
3
+ description: "Token optimizer for AI coding agents. Wraps common CLI commands with rtk to reduce LLM token consumption by 60-90%."
4
+ compatibility: "OpenCode with RTK binary installed"
5
+ metadata:
6
+ author: Sisyphus
7
+ version: "1.0.0"
8
+ ---
9
+
10
+ # RTK โ€” Rust Token Killer
11
+
12
+ **Purpose**: Reduce token consumption by 60-90% on shell commands. RTK filters and compresses command output before it reaches your context.
13
+
14
+ ## When This Skill Activates
15
+
16
+ This skill is loaded automatically. Once active, **always** prefix supported commands with `rtk`.
17
+
18
+ ## Command Mappings (MANDATORY)
19
+
20
+ When running shell commands via Bash tool, use `rtk` prefix for these commands:
21
+
22
+ | Instead of | Use | Savings |
23
+ |-----------|-----|---------|
24
+ | `git status` | `rtk git status` | ~80% |
25
+ | `git diff` | `rtk git diff` | ~75% |
26
+ | `git log` | `rtk git log` | ~80% |
27
+ | `git add/commit/push/pull` | `rtk git add/commit/push/pull` | ~90% |
28
+ | `ls` / `ls -la` | `rtk ls` | ~80% |
29
+ | `cat file` | `rtk read file` | ~70% |
30
+ | `grep pattern .` | `rtk grep pattern .` | ~80% |
31
+ | `rg pattern` | `rtk grep pattern .` | ~80% |
32
+ | `npm test` / `cargo test` / `pytest` | `rtk test <cmd>` | ~90% |
33
+ | `npm run build` / `cargo build` | `rtk err <cmd>` | ~80% |
34
+ | `gh pr list/view` | `rtk gh pr list/view` | ~70% |
35
+ | `docker ps` | `rtk docker ps` | ~80% |
36
+ | `eslint` / `tsc` | `rtk lint` / `rtk tsc` | ~80% |
37
+
38
+ ## Searching Inside `node_modules` / Ignored Directories
39
+
40
+ By default, `rtk grep` respects `.gitignore` rules โ€” meaning `node_modules`, `.nuxt`, `dist`, etc. are **excluded**. This is the right behavior 99% of the time.
41
+
42
+ When you **need** to search inside ignored directories (debugging a library, checking an API signature, tracing a dependency bug):
43
+
44
+ ```bash
45
+ # Search all files including node_modules (--no-ignore bypasses .gitignore)
46
+ rtk grep "defineStore" . --no-ignore
47
+
48
+ # Search a specific package only (combine --no-ignore with --glob)
49
+ rtk grep "defineStore" . --no-ignore --glob 'node_modules/pinia/**'
50
+ ```
51
+
52
+ **What does NOT work:**
53
+ - `rtk grep "pattern" node_modules/pinia/` โ€” still excluded even with direct path
54
+ - `rtk grep "pattern" . --glob 'node_modules/**'` โ€” glob alone doesn't override .gitignore
55
+
56
+ **Key flag: `--no-ignore`** โ€” this is the ONLY way to search ignored directories with rtk grep.
57
+
58
+ ### Other useful `rtk grep` flags
59
+
60
+ ```bash
61
+ rtk grep "pattern" . -t ts # Filter by file type (ts, py, rust, etc.)
62
+ rtk grep "pattern" . -m 100 # Increase max results (default: 50)
63
+ rtk grep "pattern" . -u # Ultra-compact mode (even fewer tokens)
64
+ rtk grep "pattern" . -l 120 # Max line length before truncation (default: 80)
65
+ ```
66
+
67
+ ## Commands to NOT Wrap
68
+
69
+ Do NOT prefix these with `rtk` (unsupported or counterproductive):
70
+
71
+ - `npx`, `npm install`, `pip install` (package managers)
72
+ - `node`, `python3`, `ruby` (interpreters)
73
+ - `nano-brain`, `openspec`, `opencode` (custom tools)
74
+ - Heredocs (`<<EOF`)
75
+ - Piped commands (`cmd1 | cmd2`) โ€” wrap only the first command if applicable
76
+ - Commands already prefixed with `rtk`
77
+
78
+ ## How RTK Works
79
+
80
+ ```
81
+ Without RTK: git status โ†’ 50 lines raw output โ†’ 2,000 tokens
82
+ With RTK: rtk git status โ†’ "3 modified, 1 untracked โœ“" โ†’ 200 tokens
83
+ ```
84
+
85
+ RTK runs the real command, then filters/compresses the output. The agent sees a compact summary instead of verbose raw output.
86
+
87
+ ## Detection
88
+
89
+ Before using RTK commands, verify it's installed:
90
+ ```bash
91
+ rtk --version
92
+ ```
93
+
94
+ If `rtk` is not found, skip this skill โ€” run commands normally without the `rtk` prefix.
95
+
96
+ ## Token Savings Reference
97
+
98
+ Typical 30-min coding session:
99
+ - Without RTK: ~150,000 tokens
100
+ - With RTK: ~45,000 tokens
101
+ - **Savings: ~70%**
102
+
103
+ Biggest wins: test output (`rtk test` โ€” 90%), git operations (`rtk git` โ€” 80%), file reading (`rtk read` โ€” 70%).
@@ -0,0 +1,118 @@
1
+ ---
2
+ name: rtk-setup
3
+ description: "One-time setup + ongoing enforcement of RTK (Rust Token Killer) across sessions and subagents. Persists RTK instructions to AGENTS.md and propagates to delegated tasks."
4
+ compatibility: "OpenCode with RTK binary installed"
5
+ metadata:
6
+ author: Sisyphus
7
+ version: "1.0.0"
8
+ ---
9
+
10
+ # RTK Setup โ€” Persistent RTK Enforcement
11
+
12
+ This skill performs **setup** (persist RTK instructions) and **ongoing enforcement** (use rtk, propagate to subagents).
13
+
14
+ ## Phase 1: Detection (ALWAYS run first)
15
+
16
+ Run these checks before anything else:
17
+
18
+ ```bash
19
+ rtk --version
20
+ ```
21
+
22
+ - If `rtk` is NOT found โ†’ **STOP**. Tell the user: "RTK is not installed. Install it first: `cargo install --git https://github.com/rtk-ai/rtk --locked`". Do NOT proceed with setup.
23
+ - If `rtk` IS found โ†’ continue.
24
+
25
+ ### Check oh-my-opencode
26
+
27
+ ```bash
28
+ ls ~/.config/opencode/oh-my-opencode.json 2>/dev/null
29
+ ```
30
+
31
+ - If found โ†’ omo is installed. Note this for Phase 2.
32
+ - If not found โ†’ skip omo-specific steps.
33
+
34
+ ## Phase 2: Setup (persist to AGENTS.md)
35
+
36
+ Check BOTH of these files for the RTK managed block:
37
+
38
+ 1. **User-level**: `~/.config/opencode/AGENTS.md`
39
+ 2. **Project-level**: `./AGENTS.md` (current workspace)
40
+
41
+ For EACH file, check if `<!-- RTK:START -->` exists. If it does NOT exist, **append** the following managed block to the file (create the file if it doesn't exist). NEVER replace existing content โ€” only append.
42
+
43
+ ```markdown
44
+ <!-- RTK:START -->
45
+ <!-- Managed block - do not edit manually. Updated by: rtk-setup skill -->
46
+
47
+ ## RTK Token Optimizer
48
+
49
+ This project uses **RTK** (Rust Token Killer) to reduce LLM token consumption by 60-90%.
50
+
51
+ ### Rules for ALL agents (including subagents)
52
+
53
+ **ALWAYS** prefix these commands with `rtk`:
54
+
55
+ | Command | Use instead |
56
+ |---------|-------------|
57
+ | `git status/diff/log/add/commit/push/pull` | `rtk git ...` |
58
+ | `ls`, `ls -la` | `rtk ls` |
59
+ | `cat file` | `rtk read file` |
60
+ | `grep pattern .` / `rg pattern` | `rtk grep pattern .` |
61
+ | `npm test` / `cargo test` / `pytest` | `rtk test <cmd>` |
62
+ | `npm run build` / `cargo build` | `rtk err <cmd>` |
63
+ | `gh pr list/view` | `rtk gh pr list/view` |
64
+ | `docker ps` | `rtk docker ps` |
65
+ | `eslint` / `tsc` | `rtk lint` / `rtk tsc` |
66
+
67
+ **Do NOT** prefix: `npx`, `npm install`, `pip install`, `node`, `python3`, heredocs, piped commands.
68
+
69
+ <!-- RTK:END -->
70
+ ```
71
+
72
+ ### If oh-my-opencode is installed
73
+
74
+ After updating AGENTS.md files, check if the omo config at `~/.config/opencode/oh-my-opencode.json` has `prompt_append` fields on agents. If it does, inform the user:
75
+
76
+ > "omo is installed. For maximum coverage, you can add RTK instructions to agent `prompt_append` fields in `oh-my-opencode.json`. This ensures subagents always use rtk even when AGENTS.md is not loaded. Want me to do this?"
77
+
78
+ **Only modify `oh-my-opencode.json` if the user explicitly confirms.** If they confirm, append this line to the `prompt_append` of `sisyphus-junior` agent (the primary coder):
79
+
80
+ ```
81
+ \n\nRTK: ALWAYS prefix shell commands with `rtk` when available (git, ls, grep, test, build). Example: `rtk git status` not `git status`.
82
+ ```
83
+
84
+ Do NOT modify other agents' prompt_append unless asked.
85
+
86
+ ## Phase 3: Ongoing Enforcement (EVERY time this skill is loaded)
87
+
88
+ ### For the current agent
89
+
90
+ From this point forward in this session, **you MUST**:
91
+
92
+ 1. **Use `rtk` prefix** for all supported shell commands (see table above)
93
+ 2. **Verify rtk is available** before first use: `rtk --version`
94
+ 3. If rtk is not available in the current environment, fall back to normal commands silently
95
+
96
+ ### For subagent delegation
97
+
98
+ When delegating ANY task that involves shell commands (via `task()`, `delegate_task()`, or any delegation mechanism), **ALWAYS** add this to the `MUST DO` section of the delegation prompt:
99
+
100
+ ```
101
+ - Use `rtk` prefix for shell commands when available (git, ls, grep, test, build). Run `rtk --version` first to check. If not installed, use normal commands. Examples: `rtk git status`, `rtk ls`, `rtk grep pattern .`, `rtk test npm test`.
102
+ ```
103
+
104
+ This is NON-NEGOTIABLE. Subagents do not read AGENTS.md, so RTK instructions MUST be passed explicitly in every delegation prompt.
105
+
106
+ ### Quick reference for subagent prompts
107
+
108
+ Copy-paste this one-liner into MUST DO sections:
109
+
110
+ > Use `rtk` prefix for all shell commands (git, ls, grep, test, build, docker). Example: `rtk git status` not `git status`. If `rtk` is not found, use normal commands.
111
+
112
+ ## Summary
113
+
114
+ | Phase | When | What |
115
+ |-------|------|------|
116
+ | Detection | Always first | Check rtk installed, check omo |
117
+ | Setup | Once (idempotent) | Append RTK block to AGENTS.md (user + project) |
118
+ | Enforcement | Every session | Use rtk yourself, propagate to all subagents |
@@ -0,0 +1,133 @@
1
+ # Build RTK from source (multi-stage: only binary is kept, Rust toolchain discarded)
2
+ FROM rust:bookworm AS rtk-builder
3
+ RUN cargo install --git https://github.com/rtk-ai/rtk --locked
4
+
5
+ FROM node:22-bookworm-slim
6
+
7
+ ARG AGENT_UID=1001
8
+
9
+ RUN apt-get update && apt-get install -y --no-install-recommends git curl ssh ca-certificates jq python3 python3-pip python3-venv python3-dev python3-setuptools build-essential libopenblas-dev pipx unzip xclip wl-clipboard ripgrep tmux fd-find sqlite3 poppler-utils qpdf tesseract-ocr && curl -LsSf https://astral.sh/uv/install.sh | UV_INSTALL_DIR=/usr/local/bin sh && rm -rf /var/lib/apt/lists/* && pipx ensurepath
10
+
11
+ # Install Python PDF processing tools for PDF skill
12
+ RUN pip3 install --no-cache-dir --break-system-packages pypdf pdfplumber reportlab pytesseract pdf2image
13
+
14
+ RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg && chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null && apt-get update && apt-get install -y gh && rm -rf /var/lib/apt/lists/*
15
+
16
+ # Install bun (used by most AI tool install scripts)
17
+ RUN npm install -g bun
18
+
19
+ # Install pnpm globally using npm (not bun, for stability)
20
+ RUN npm install -g pnpm
21
+
22
+ # Install TypeScript and LSP tools using npm
23
+ RUN npm install -g typescript typescript-language-server pyright vscode-langservers-extracted
24
+
25
+ # Verify installations
26
+ RUN node --version && npm --version && pnpm --version && tsc --version
27
+
28
+ # Install additional tools (if selected)
29
+ RUN PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install specify-cli --pip-args="git+https://github.com/github/spec-kit.git" && \
30
+ chmod +x /usr/local/bin/specify && \
31
+ ln -sf /usr/local/bin/specify /usr/local/bin/specify-cli
32
+ RUN mkdir -p /usr/local/lib/uipro-cli && \
33
+ cd /usr/local/lib/uipro-cli && \
34
+ npm init -y && \
35
+ npm install uipro-cli && \
36
+ ln -sf /usr/local/lib/uipro-cli/node_modules/.bin/uipro /usr/local/bin/uipro && \
37
+ ln -sf /usr/local/bin/uipro /usr/local/bin/uipro-cli && \
38
+ chmod -R 755 /usr/local/lib/uipro-cli && \
39
+ chmod +x /usr/local/bin/uipro
40
+ RUN mkdir -p /usr/local/lib/openspec && \
41
+ cd /usr/local/lib/openspec && \
42
+ npm init -y && \
43
+ npm install @fission-ai/openspec && \
44
+ ln -sf /usr/local/lib/openspec/node_modules/.bin/openspec /usr/local/bin/openspec && \
45
+ chmod -R 755 /usr/local/lib/openspec && \
46
+ chmod +x /usr/local/bin/openspec
47
+ # Install RTK - token optimizer for AI coding agents (built from source)
48
+ COPY --from=rtk-builder /usr/local/cargo/bin/rtk /usr/local/bin/rtk
49
+ # Install RTK OpenCode skills (auto-discovered by OpenCode agents)
50
+ RUN mkdir -p /home/agent/.config/opencode/skills/rtk /home/agent/.config/opencode/skills/rtk-setup
51
+ COPY skills/rtk/SKILL.md /home/agent/.config/opencode/skills/rtk/SKILL.md
52
+ COPY skills/rtk-setup/SKILL.md /home/agent/.config/opencode/skills/rtk-setup/SKILL.md
53
+ RUN apt-get update && apt-get install -y --no-install-recommends \
54
+ libglib2.0-0 \
55
+ libnspr4 \
56
+ libnss3 \
57
+ libdbus-1-3 \
58
+ libatk1.0-0 \
59
+ libatk-bridge2.0-0 \
60
+ libcups2 \
61
+ libxcb1 \
62
+ libxkbcommon0 \
63
+ libatspi2.0-0 \
64
+ libx11-6 \
65
+ libxcomposite1 \
66
+ libxdamage1 \
67
+ libxext6 \
68
+ libxfixes3 \
69
+ libxrandr2 \
70
+ libgbm1 \
71
+ libdrm2 \
72
+ libcairo2 \
73
+ libpango-1.0-0 \
74
+ libasound2 \
75
+ fonts-liberation \
76
+ libappindicator3-1 \
77
+ libu2f-udev \
78
+ libvulkan1 \
79
+ libxshmfence1 \
80
+ xdg-utils \
81
+ wget \
82
+ && rm -rf /var/lib/apt/lists/*
83
+ ENV PLAYWRIGHT_BROWSERS_PATH=/opt/playwright-browsers
84
+ RUN mkdir -p /opt/playwright-browsers && \
85
+ npm install -g @playwright/mcp@latest && \
86
+ npx playwright-core install --no-shell chromium && \
87
+ npx playwright-core install-deps chromium && \
88
+ chmod -R 777 /opt/playwright-browsers && \
89
+ ln -sf $(ls -d /opt/playwright-browsers/chromium-*/chrome-linux/chrome | head -1) /opt/chromium
90
+ ENV CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS=1
91
+ RUN npm install -g chrome-devtools-mcp@latest && \
92
+ touch /opt/.mcp-chrome-devtools-installed
93
+
94
+ # Create workspace
95
+ WORKDIR /workspace
96
+
97
+ # Non-root user for security (match host UID)
98
+ RUN useradd -m -u ${AGENT_UID} -d /home/agent agent && \
99
+ mkdir -p /home/agent/.cache /home/agent/.npm /home/agent/.opencode /home/agent/.config && \
100
+ chown -R agent:agent /home/agent/.cache /home/agent/.npm /home/agent/.opencode /home/agent/.config /workspace && \
101
+ ([ -d /opt/playwright-browsers ] && chown -R agent:agent /opt/playwright-browsers || true)
102
+
103
+ # === amp ===
104
+ USER root
105
+ RUN mkdir -p /usr/local/lib/amp && \
106
+ cd /usr/local/lib/amp && \
107
+ bun init -y && \
108
+ bun add @sourcegraph/amp && \
109
+ ln -s /usr/local/lib/amp/node_modules/.bin/amp /usr/local/bin/amp
110
+
111
+ # === opencode ===
112
+ USER root
113
+ RUN curl -fsSL https://opencode.ai/install | bash && \
114
+ mv /root/.opencode/bin/opencode /usr/local/bin/opencode && \
115
+ rm -rf /root/.opencode
116
+
117
+ # === claude ===
118
+ USER root
119
+ RUN apt-get update && apt-get install -y --no-install-recommends tmux && rm -rf /var/lib/apt/lists/*
120
+ RUN npm install -g @kaitranntt/ccs --ignore-scripts && \
121
+ mkdir -p /home/agent/.ccs && \
122
+ chown -R agent:agent /home/agent/.ccs && \
123
+ which ccs && ccs --version && \
124
+ sed -i 's/fs\.symlinkSync(sourcePath, targetPath, symlinkType)/fs\.symlinkSync(require("path").relative(require("path").dirname(targetPath), sourcePath), targetPath, symlinkType)/g' /usr/local/lib/node_modules/@kaitranntt/ccs/dist/utils/claude-symlink-manager.js
125
+ RUN export HOME=/root && curl -fsSL https://claude.ai/install.sh | bash && \
126
+ mkdir -p /usr/local/share && \
127
+ mv /root/.local/share/claude /usr/local/share/claude && \
128
+ ln -sf /usr/local/share/claude/versions/$(ls /usr/local/share/claude/versions | head -1) /usr/local/bin/claude
129
+ USER agent
130
+
131
+ USER agent
132
+ ENV HOME=/home/agent
133
+ CMD ["bash"]
@@ -0,0 +1,103 @@
1
+ ---
2
+ name: rtk
3
+ description: "Token optimizer for AI coding agents. Wraps common CLI commands with rtk to reduce LLM token consumption by 60-90%."
4
+ compatibility: "OpenCode with RTK binary installed"
5
+ metadata:
6
+ author: Sisyphus
7
+ version: "1.0.0"
8
+ ---
9
+
10
+ # RTK โ€” Rust Token Killer
11
+
12
+ **Purpose**: Reduce token consumption by 60-90% on shell commands. RTK filters and compresses command output before it reaches your context.
13
+
14
+ ## When This Skill Activates
15
+
16
+ This skill is loaded automatically. Once active, **always** prefix supported commands with `rtk`.
17
+
18
+ ## Command Mappings (MANDATORY)
19
+
20
+ When running shell commands via Bash tool, use `rtk` prefix for these commands:
21
+
22
+ | Instead of | Use | Savings |
23
+ |-----------|-----|---------|
24
+ | `git status` | `rtk git status` | ~80% |
25
+ | `git diff` | `rtk git diff` | ~75% |
26
+ | `git log` | `rtk git log` | ~80% |
27
+ | `git add/commit/push/pull` | `rtk git add/commit/push/pull` | ~90% |
28
+ | `ls` / `ls -la` | `rtk ls` | ~80% |
29
+ | `cat file` | `rtk read file` | ~70% |
30
+ | `grep pattern .` | `rtk grep pattern .` | ~80% |
31
+ | `rg pattern` | `rtk grep pattern .` | ~80% |
32
+ | `npm test` / `cargo test` / `pytest` | `rtk test <cmd>` | ~90% |
33
+ | `npm run build` / `cargo build` | `rtk err <cmd>` | ~80% |
34
+ | `gh pr list/view` | `rtk gh pr list/view` | ~70% |
35
+ | `docker ps` | `rtk docker ps` | ~80% |
36
+ | `eslint` / `tsc` | `rtk lint` / `rtk tsc` | ~80% |
37
+
38
+ ## Searching Inside `node_modules` / Ignored Directories
39
+
40
+ By default, `rtk grep` respects `.gitignore` rules โ€” meaning `node_modules`, `.nuxt`, `dist`, etc. are **excluded**. This is the right behavior 99% of the time.
41
+
42
+ When you **need** to search inside ignored directories (debugging a library, checking an API signature, tracing a dependency bug):
43
+
44
+ ```bash
45
+ # Search all files including node_modules (--no-ignore bypasses .gitignore)
46
+ rtk grep "defineStore" . --no-ignore
47
+
48
+ # Search a specific package only (combine --no-ignore with --glob)
49
+ rtk grep "defineStore" . --no-ignore --glob 'node_modules/pinia/**'
50
+ ```
51
+
52
+ **What does NOT work:**
53
+ - `rtk grep "pattern" node_modules/pinia/` โ€” still excluded even with direct path
54
+ - `rtk grep "pattern" . --glob 'node_modules/**'` โ€” glob alone doesn't override .gitignore
55
+
56
+ **Key flag: `--no-ignore`** โ€” this is the ONLY way to search ignored directories with rtk grep.
57
+
58
+ ### Other useful `rtk grep` flags
59
+
60
+ ```bash
61
+ rtk grep "pattern" . -t ts # Filter by file type (ts, py, rust, etc.)
62
+ rtk grep "pattern" . -m 100 # Increase max results (default: 50)
63
+ rtk grep "pattern" . -u # Ultra-compact mode (even fewer tokens)
64
+ rtk grep "pattern" . -l 120 # Max line length before truncation (default: 80)
65
+ ```
66
+
67
+ ## Commands to NOT Wrap
68
+
69
+ Do NOT prefix these with `rtk` (unsupported or counterproductive):
70
+
71
+ - `npx`, `npm install`, `pip install` (package managers)
72
+ - `node`, `python3`, `ruby` (interpreters)
73
+ - `nano-brain`, `openspec`, `opencode` (custom tools)
74
+ - Heredocs (`<<EOF`)
75
+ - Piped commands (`cmd1 | cmd2`) โ€” wrap only the first command if applicable
76
+ - Commands already prefixed with `rtk`
77
+
78
+ ## How RTK Works
79
+
80
+ ```
81
+ Without RTK: git status โ†’ 50 lines raw output โ†’ 2,000 tokens
82
+ With RTK: rtk git status โ†’ "3 modified, 1 untracked โœ“" โ†’ 200 tokens
83
+ ```
84
+
85
+ RTK runs the real command, then filters/compresses the output. The agent sees a compact summary instead of verbose raw output.
86
+
87
+ ## Detection
88
+
89
+ Before using RTK commands, verify it's installed:
90
+ ```bash
91
+ rtk --version
92
+ ```
93
+
94
+ If `rtk` is not found, skip this skill โ€” run commands normally without the `rtk` prefix.
95
+
96
+ ## Token Savings Reference
97
+
98
+ Typical 30-min coding session:
99
+ - Without RTK: ~150,000 tokens
100
+ - With RTK: ~45,000 tokens
101
+ - **Savings: ~70%**
102
+
103
+ Biggest wins: test output (`rtk test` โ€” 90%), git operations (`rtk git` โ€” 80%), file reading (`rtk read` โ€” 70%).