@kokorolx/ai-sandbox-wrapper 2.7.0 → 3.0.0
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/ai-run +208 -102
- package/bin/cli.js +51 -7
- package/dockerfiles/base/Dockerfile +7 -0
- package/dockerfiles/base/skills/rtk/SKILL.md +103 -0
- package/dockerfiles/base/skills/rtk-setup/SKILL.md +118 -0
- package/dockerfiles/sandbox/Dockerfile +114 -0
- package/dockerfiles/sandbox/skills/rtk/SKILL.md +103 -0
- package/dockerfiles/sandbox/skills/rtk-setup/SKILL.md +118 -0
- package/lib/build-sandbox.sh +89 -0
- package/lib/install-aider.sh +11 -1
- package/lib/install-amp.sh +20 -12
- package/lib/install-auggie.sh +16 -1
- package/lib/install-base.sh +25 -0
- package/lib/install-claude.sh +20 -1
- package/lib/install-codebuddy.sh +16 -1
- package/lib/install-codex.sh +16 -1
- package/lib/install-droid.sh +15 -0
- package/lib/install-gemini.sh +16 -1
- package/lib/install-jules.sh +16 -1
- package/lib/install-kilo.sh +12 -2
- package/lib/install-openclaw.sh +10 -1
- package/lib/install-opencode.sh +17 -4
- package/lib/install-qoder.sh +16 -1
- package/lib/install-qwen.sh +16 -1
- package/lib/install-shai.sh +13 -1
- package/package.json +1 -1
- package/setup.sh +55 -52
|
@@ -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,114 @@
|
|
|
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 && 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
|
+
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
|
+
|
|
13
|
+
# Install bun (used by most AI tool install scripts)
|
|
14
|
+
RUN npm install -g bun
|
|
15
|
+
|
|
16
|
+
# Install pnpm globally using npm (not bun, for stability)
|
|
17
|
+
RUN npm install -g pnpm
|
|
18
|
+
|
|
19
|
+
# Install TypeScript and LSP tools using npm
|
|
20
|
+
RUN npm install -g typescript typescript-language-server
|
|
21
|
+
|
|
22
|
+
# Verify installations
|
|
23
|
+
RUN node --version && npm --version && pnpm --version && tsc --version
|
|
24
|
+
|
|
25
|
+
# Install additional tools (if selected)
|
|
26
|
+
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" && \
|
|
27
|
+
chmod +x /usr/local/bin/specify && \
|
|
28
|
+
ln -sf /usr/local/bin/specify /usr/local/bin/specify-cli
|
|
29
|
+
RUN mkdir -p /usr/local/lib/uipro-cli && \
|
|
30
|
+
cd /usr/local/lib/uipro-cli && \
|
|
31
|
+
npm init -y && \
|
|
32
|
+
npm install uipro-cli && \
|
|
33
|
+
ln -sf /usr/local/lib/uipro-cli/node_modules/.bin/uipro /usr/local/bin/uipro && \
|
|
34
|
+
ln -sf /usr/local/bin/uipro /usr/local/bin/uipro-cli && \
|
|
35
|
+
chmod -R 755 /usr/local/lib/uipro-cli && \
|
|
36
|
+
chmod +x /usr/local/bin/uipro
|
|
37
|
+
RUN mkdir -p /usr/local/lib/openspec && \
|
|
38
|
+
cd /usr/local/lib/openspec && \
|
|
39
|
+
npm init -y && \
|
|
40
|
+
npm install @fission-ai/openspec && \
|
|
41
|
+
ln -sf /usr/local/lib/openspec/node_modules/.bin/openspec /usr/local/bin/openspec && \
|
|
42
|
+
chmod -R 755 /usr/local/lib/openspec && \
|
|
43
|
+
chmod +x /usr/local/bin/openspec
|
|
44
|
+
# Install RTK - token optimizer for AI coding agents (built from source)
|
|
45
|
+
COPY --from=rtk-builder /usr/local/cargo/bin/rtk /usr/local/bin/rtk
|
|
46
|
+
# Install RTK OpenCode skills (auto-discovered by OpenCode agents)
|
|
47
|
+
RUN mkdir -p /home/agent/.config/opencode/skills/rtk /home/agent/.config/opencode/skills/rtk-setup
|
|
48
|
+
COPY skills/rtk/SKILL.md /home/agent/.config/opencode/skills/rtk/SKILL.md
|
|
49
|
+
COPY skills/rtk-setup/SKILL.md /home/agent/.config/opencode/skills/rtk-setup/SKILL.md
|
|
50
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
51
|
+
libglib2.0-0 \
|
|
52
|
+
libnspr4 \
|
|
53
|
+
libnss3 \
|
|
54
|
+
libdbus-1-3 \
|
|
55
|
+
libatk1.0-0 \
|
|
56
|
+
libatk-bridge2.0-0 \
|
|
57
|
+
libcups2 \
|
|
58
|
+
libxcb1 \
|
|
59
|
+
libxkbcommon0 \
|
|
60
|
+
libatspi2.0-0 \
|
|
61
|
+
libx11-6 \
|
|
62
|
+
libxcomposite1 \
|
|
63
|
+
libxdamage1 \
|
|
64
|
+
libxext6 \
|
|
65
|
+
libxfixes3 \
|
|
66
|
+
libxrandr2 \
|
|
67
|
+
libgbm1 \
|
|
68
|
+
libdrm2 \
|
|
69
|
+
libcairo2 \
|
|
70
|
+
libpango-1.0-0 \
|
|
71
|
+
libasound2 \
|
|
72
|
+
fonts-liberation \
|
|
73
|
+
libappindicator3-1 \
|
|
74
|
+
libu2f-udev \
|
|
75
|
+
libvulkan1 \
|
|
76
|
+
libxshmfence1 \
|
|
77
|
+
xdg-utils \
|
|
78
|
+
wget \
|
|
79
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
80
|
+
ENV PLAYWRIGHT_BROWSERS_PATH=/opt/playwright-browsers
|
|
81
|
+
RUN mkdir -p /opt/playwright-browsers && \
|
|
82
|
+
npm install -g @playwright/mcp@latest && \
|
|
83
|
+
npx playwright-core install --no-shell chromium && \
|
|
84
|
+
npx playwright-core install-deps chromium && \
|
|
85
|
+
chmod -R 777 /opt/playwright-browsers && \
|
|
86
|
+
ln -sf $(ls -d /opt/playwright-browsers/chromium-*/chrome-linux/chrome | head -1) /opt/chromium
|
|
87
|
+
RUN touch /opt/.mcp-playwright-installed
|
|
88
|
+
|
|
89
|
+
# Create workspace
|
|
90
|
+
WORKDIR /workspace
|
|
91
|
+
|
|
92
|
+
# Non-root user for security (match host UID)
|
|
93
|
+
RUN useradd -m -u ${AGENT_UID} -d /home/agent agent && \
|
|
94
|
+
mkdir -p /home/agent/.cache /home/agent/.npm /home/agent/.opencode /home/agent/.config && \
|
|
95
|
+
chown -R agent:agent /home/agent/.cache /home/agent/.npm /home/agent/.opencode /home/agent/.config /workspace && \
|
|
96
|
+
([ -d /opt/playwright-browsers ] && chown -R agent:agent /opt/playwright-browsers || true)
|
|
97
|
+
|
|
98
|
+
# === amp ===
|
|
99
|
+
USER root
|
|
100
|
+
RUN mkdir -p /usr/local/lib/amp && \
|
|
101
|
+
cd /usr/local/lib/amp && \
|
|
102
|
+
bun init -y && \
|
|
103
|
+
bun add @sourcegraph/amp && \
|
|
104
|
+
ln -s /usr/local/lib/amp/node_modules/.bin/amp /usr/local/bin/amp
|
|
105
|
+
|
|
106
|
+
# === opencode ===
|
|
107
|
+
USER root
|
|
108
|
+
RUN curl -fsSL https://opencode.ai/install | bash && \
|
|
109
|
+
mv /root/.opencode/bin/opencode /usr/local/bin/opencode && \
|
|
110
|
+
rm -rf /root/.opencode
|
|
111
|
+
|
|
112
|
+
USER agent
|
|
113
|
+
ENV HOME=/home/agent
|
|
114
|
+
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%).
|
|
@@ -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,89 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
TOOLS="${TOOLS:-}"
|
|
5
|
+
if [[ -z "$TOOLS" ]]; then
|
|
6
|
+
echo "❌ No tools selected. Set TOOLS=tool1,tool2,..."
|
|
7
|
+
exit 1
|
|
8
|
+
fi
|
|
9
|
+
|
|
10
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
11
|
+
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
12
|
+
cd "$PROJECT_DIR"
|
|
13
|
+
|
|
14
|
+
SANDBOX_DIR="dockerfiles/sandbox"
|
|
15
|
+
mkdir -p "$SANDBOX_DIR"
|
|
16
|
+
|
|
17
|
+
echo "🔄 Generating unified sandbox Dockerfile..."
|
|
18
|
+
echo " Tools: $TOOLS"
|
|
19
|
+
|
|
20
|
+
GENERATE_ONLY=1 INSTALL_RTK="${INSTALL_RTK:-0}" \
|
|
21
|
+
INSTALL_PLAYWRIGHT_MCP="${INSTALL_PLAYWRIGHT_MCP:-0}" \
|
|
22
|
+
INSTALL_CHROME_DEVTOOLS_MCP="${INSTALL_CHROME_DEVTOOLS_MCP:-0}" \
|
|
23
|
+
INSTALL_PLAYWRIGHT="${INSTALL_PLAYWRIGHT:-0}" \
|
|
24
|
+
INSTALL_RUBY="${INSTALL_RUBY:-0}" \
|
|
25
|
+
INSTALL_SPEC_KIT="${INSTALL_SPEC_KIT:-0}" \
|
|
26
|
+
INSTALL_UX_UI_PROMAX="${INSTALL_UX_UI_PROMAX:-0}" \
|
|
27
|
+
INSTALL_OPENSPEC="${INSTALL_OPENSPEC:-0}" \
|
|
28
|
+
bash "$SCRIPT_DIR/install-base.sh"
|
|
29
|
+
|
|
30
|
+
BASE_DOCKERFILE="dockerfiles/base/Dockerfile"
|
|
31
|
+
if [[ ! -f "$BASE_DOCKERFILE" ]]; then
|
|
32
|
+
echo "❌ Base Dockerfile not found at $BASE_DOCKERFILE"
|
|
33
|
+
exit 1
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
BASE_CONTENT=$(cat "$BASE_DOCKERFILE")
|
|
37
|
+
BASE_PREAMBLE=$(echo "$BASE_CONTENT" | sed '/^USER agent$/,$d')
|
|
38
|
+
|
|
39
|
+
{
|
|
40
|
+
echo "$BASE_PREAMBLE"
|
|
41
|
+
echo ""
|
|
42
|
+
|
|
43
|
+
IFS=',' read -ra TOOL_ARRAY <<< "$TOOLS"
|
|
44
|
+
for tool in "${TOOL_ARRAY[@]}"; do
|
|
45
|
+
tool=$(echo "$tool" | tr -d ' ')
|
|
46
|
+
INSTALL_SCRIPT="$SCRIPT_DIR/install-${tool}.sh"
|
|
47
|
+
|
|
48
|
+
if [[ ! -f "$INSTALL_SCRIPT" ]]; then
|
|
49
|
+
echo "⚠️ Warning: No install script for '$tool', skipping" >&2
|
|
50
|
+
continue
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
echo "# === $tool ==="
|
|
54
|
+
SNIPPET_MODE=1 source "$INSTALL_SCRIPT"
|
|
55
|
+
dockerfile_snippet
|
|
56
|
+
echo ""
|
|
57
|
+
done
|
|
58
|
+
|
|
59
|
+
echo "USER agent"
|
|
60
|
+
echo "ENV HOME=/home/agent"
|
|
61
|
+
echo "CMD [\"bash\"]"
|
|
62
|
+
} > "$SANDBOX_DIR/Dockerfile"
|
|
63
|
+
|
|
64
|
+
if [[ -d "dockerfiles/base/skills" ]]; then
|
|
65
|
+
cp -r "dockerfiles/base/skills" "$SANDBOX_DIR/"
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
echo "✅ Dockerfile generated at $SANDBOX_DIR/Dockerfile"
|
|
69
|
+
|
|
70
|
+
echo "🔨 Building ai-sandbox:latest..."
|
|
71
|
+
HOST_UID=$(id -u)
|
|
72
|
+
docker build ${DOCKER_NO_CACHE:+--no-cache} \
|
|
73
|
+
--build-arg AGENT_UID="${HOST_UID}" \
|
|
74
|
+
-t "ai-sandbox:latest" "$SANDBOX_DIR"
|
|
75
|
+
|
|
76
|
+
echo "✅ ai-sandbox:latest built successfully"
|
|
77
|
+
|
|
78
|
+
SANDBOX_CONFIG="$HOME/.ai-sandbox/config.json"
|
|
79
|
+
if command -v jq &>/dev/null && [[ -f "$SANDBOX_CONFIG" ]]; then
|
|
80
|
+
TOOLS_JSON=$(echo "$TOOLS" | tr ',' '\n' | jq -R . | jq -s .)
|
|
81
|
+
jq --argjson tools "$TOOLS_JSON" '.tools.installed = $tools' "$SANDBOX_CONFIG" > "$SANDBOX_CONFIG.tmp" \
|
|
82
|
+
&& mv "$SANDBOX_CONFIG.tmp" "$SANDBOX_CONFIG"
|
|
83
|
+
chmod 600 "$SANDBOX_CONFIG"
|
|
84
|
+
echo "✅ Saved tools list to $SANDBOX_CONFIG"
|
|
85
|
+
fi
|
|
86
|
+
|
|
87
|
+
echo ""
|
|
88
|
+
echo "🎉 Sandbox ready with tools: $TOOLS"
|
|
89
|
+
echo " Run: docker run --rm -it ai-sandbox:latest"
|
package/lib/install-aider.sh
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
set -e
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
dockerfile_snippet() {
|
|
5
|
+
cat <<'SNIPPET'
|
|
6
|
+
USER agent
|
|
7
|
+
RUN python3 -m pip install --break-system-packages aider-install && aider-install
|
|
8
|
+
SNIPPET
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if [[ "${SNIPPET_MODE:-}" == "1" ]]; then
|
|
12
|
+
return 0 2>/dev/null || exit 0
|
|
13
|
+
fi
|
|
14
|
+
|
|
5
15
|
TOOL="aider"
|
|
6
16
|
|
|
7
17
|
echo "Installing $TOOL (Python-based AI pair programmer)..."
|
package/lib/install-amp.sh
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
set -e
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
dockerfile_snippet() {
|
|
5
|
+
cat <<'SNIPPET'
|
|
6
|
+
USER root
|
|
7
|
+
RUN mkdir -p /usr/local/lib/amp && \
|
|
8
|
+
cd /usr/local/lib/amp && \
|
|
9
|
+
bun init -y && \
|
|
10
|
+
bun add @sourcegraph/amp && \
|
|
11
|
+
ln -s /usr/local/lib/amp/node_modules/.bin/amp /usr/local/bin/amp
|
|
12
|
+
SNIPPET
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if [[ "${SNIPPET_MODE:-}" == "1" ]]; then
|
|
16
|
+
return 0 2>/dev/null || exit 0
|
|
17
|
+
fi
|
|
18
|
+
|
|
5
19
|
TOOL="amp"
|
|
6
20
|
|
|
7
21
|
echo "Installing $TOOL (Sourcegraph Amp)..."
|
|
@@ -15,20 +29,14 @@ mkdir -p "$HOME/.ai-sandbox/tools/$TOOL/home"
|
|
|
15
29
|
cat <<'EOF' > "dockerfiles/$TOOL/Dockerfile"
|
|
16
30
|
FROM ai-base:latest
|
|
17
31
|
|
|
18
|
-
# Switch to root only for installing bun globally (needed for the system)
|
|
19
32
|
USER root
|
|
20
|
-
RUN
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
# Install Amp into user directory
|
|
24
|
-
RUN mkdir -p /home/agent/lib/amp && \
|
|
25
|
-
cd /home/agent/lib/amp && \
|
|
33
|
+
RUN mkdir -p /usr/local/lib/amp && \
|
|
34
|
+
cd /usr/local/lib/amp && \
|
|
26
35
|
bun init -y && \
|
|
27
|
-
bun add @sourcegraph/amp
|
|
28
|
-
|
|
29
|
-
# Add the node_modules .bin to PATH
|
|
30
|
-
ENV PATH="/home/agent/lib/amp/node_modules/.bin:${PATH}"
|
|
36
|
+
bun add @sourcegraph/amp && \
|
|
37
|
+
ln -s /usr/local/lib/amp/node_modules/.bin/amp /usr/local/bin/amp
|
|
31
38
|
|
|
39
|
+
USER agent
|
|
32
40
|
ENTRYPOINT ["amp"]
|
|
33
41
|
EOF
|
|
34
42
|
|
package/lib/install-auggie.sh
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
set -e
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
dockerfile_snippet() {
|
|
5
|
+
cat <<'SNIPPET'
|
|
6
|
+
USER root
|
|
7
|
+
RUN mkdir -p /usr/local/lib/auggie && \
|
|
8
|
+
cd /usr/local/lib/auggie && \
|
|
9
|
+
bun init -y && \
|
|
10
|
+
bun add @augmentcode/auggie && \
|
|
11
|
+
ln -s /usr/local/lib/auggie/node_modules/.bin/auggie /usr/local/bin/auggie
|
|
12
|
+
USER agent
|
|
13
|
+
SNIPPET
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if [[ "${SNIPPET_MODE:-}" == "1" ]]; then
|
|
17
|
+
return 0 2>/dev/null || exit 0
|
|
18
|
+
fi
|
|
19
|
+
|
|
5
20
|
TOOL="auggie"
|
|
6
21
|
|
|
7
22
|
echo "Installing $TOOL (Augment Auggie CLI)..."
|
package/lib/install-base.sh
CHANGED
|
@@ -49,6 +49,22 @@ RUN cargo install --git https://github.com/rtk-ai/rtk --locked
|
|
|
49
49
|
ADDITIONAL_TOOLS_INSTALL+='# Install RTK - token optimizer for AI coding agents (built from source)
|
|
50
50
|
COPY --from=rtk-builder /usr/local/cargo/bin/rtk /usr/local/bin/rtk
|
|
51
51
|
'
|
|
52
|
+
# Copy RTK OpenCode skills into build context so they can be COPY'd into the image
|
|
53
|
+
SCRIPT_BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
54
|
+
RTK_SKILLS_SRC="${SCRIPT_BASE_DIR}/../skills"
|
|
55
|
+
if [[ -d "$RTK_SKILLS_SRC/rtk" && -d "$RTK_SKILLS_SRC/rtk-setup" ]]; then
|
|
56
|
+
mkdir -p "dockerfiles/base/skills/rtk" "dockerfiles/base/skills/rtk-setup"
|
|
57
|
+
cp "$RTK_SKILLS_SRC/rtk/SKILL.md" "dockerfiles/base/skills/rtk/SKILL.md"
|
|
58
|
+
cp "$RTK_SKILLS_SRC/rtk-setup/SKILL.md" "dockerfiles/base/skills/rtk-setup/SKILL.md"
|
|
59
|
+
ADDITIONAL_TOOLS_INSTALL+='# Install RTK OpenCode skills (auto-discovered by OpenCode agents)
|
|
60
|
+
RUN mkdir -p /home/agent/.config/opencode/skills/rtk /home/agent/.config/opencode/skills/rtk-setup
|
|
61
|
+
COPY skills/rtk/SKILL.md /home/agent/.config/opencode/skills/rtk/SKILL.md
|
|
62
|
+
COPY skills/rtk-setup/SKILL.md /home/agent/.config/opencode/skills/rtk-setup/SKILL.md
|
|
63
|
+
'
|
|
64
|
+
echo " ✅ RTK OpenCode skills will be copied into container"
|
|
65
|
+
else
|
|
66
|
+
echo " ⚠️ RTK skills not found at $RTK_SKILLS_SRC — skipping skill installation"
|
|
67
|
+
fi
|
|
52
68
|
fi
|
|
53
69
|
|
|
54
70
|
if [[ "${INSTALL_PLAYWRIGHT:-0}" -eq 1 ]]; then
|
|
@@ -212,6 +228,9 @@ RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | d
|
|
|
212
228
|
&& apt-get install -y gh \
|
|
213
229
|
&& rm -rf /var/lib/apt/lists/*
|
|
214
230
|
|
|
231
|
+
# Install bun (used by most AI tool install scripts)
|
|
232
|
+
RUN npm install -g bun
|
|
233
|
+
|
|
215
234
|
# Install pnpm globally using npm (not bun, for stability)
|
|
216
235
|
RUN npm install -g pnpm
|
|
217
236
|
|
|
@@ -235,6 +254,12 @@ USER agent
|
|
|
235
254
|
ENV HOME=/home/agent
|
|
236
255
|
EOF
|
|
237
256
|
|
|
257
|
+
# GENERATE_ONLY mode: write Dockerfile but don't build
|
|
258
|
+
if [[ "${GENERATE_ONLY:-0}" -eq 1 ]]; then
|
|
259
|
+
echo "✅ Base Dockerfile generated at dockerfiles/base/Dockerfile"
|
|
260
|
+
exit 0
|
|
261
|
+
fi
|
|
262
|
+
|
|
238
263
|
echo "Building base Docker image..."
|
|
239
264
|
HOST_UID=$(id -u)
|
|
240
265
|
docker build ${DOCKER_NO_CACHE:+--no-cache} \
|