@kokorolx/ai-sandbox-wrapper 3.4.3 → 4.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.
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ dockerfile_snippet() {
5
+ cat <<'SNIPPET'
6
+ # open-design is a service-type tool (long-running daemon)
7
+ # It uses its own upstream image, not ai-base
8
+ # This snippet is included for convention only; the base image builder
9
+ # does NOT inline open-design (it runs as a separate container)
10
+ SNIPPET
11
+ }
12
+
13
+ if [[ "${SNIPPET_MODE:-}" == "1" ]]; then
14
+ return 0 2>/dev/null || exit 0
15
+ fi
16
+
17
+ TOOL="open-design"
18
+ # NOTE: upstream vanjayak/open-design currently publishes only the 'latest' tag (as of 2026-05).
19
+ # When upstream starts publishing version tags (e.g., 0.8.0-preview), pin via OPEN_DESIGN_IMAGE_TAG
20
+ # or OPEN_DESIGN_IMAGE to avoid breaking changes.
21
+ OPEN_DESIGN_IMAGE_TAG="${OPEN_DESIGN_IMAGE_TAG:-latest}"
22
+ OPEN_DESIGN_IMAGE="${OPEN_DESIGN_IMAGE:-docker.io/vanjayak/open-design:${OPEN_DESIGN_IMAGE_TAG}}"
23
+ OPEN_DESIGN_VERSION="${OPEN_DESIGN_VERSION:-${OPEN_DESIGN_IMAGE_TAG}}"
24
+
25
+ echo "Installing $TOOL (Open Design daemon — long-running HTTP service)..."
26
+ echo " Upstream image: $OPEN_DESIGN_IMAGE"
27
+
28
+ mkdir -p "dockerfiles/$TOOL"
29
+ mkdir -p "$HOME/.ai-sandbox/tools/$TOOL/home"
30
+
31
+ # Generate Dockerfile (idempotent — overwrites existing)
32
+ cat > "dockerfiles/$TOOL/Dockerfile" <<EOF
33
+ FROM $OPEN_DESIGN_IMAGE
34
+
35
+ # Force daemon to bind on all interfaces inside the container.
36
+ # Bearer token auth (OD_API_TOKEN env) protects the daemon.
37
+ ENV OD_BIND_HOST=0.0.0.0
38
+
39
+ # Document the port (publishing is controlled by ai-run --expose)
40
+ EXPOSE 7456
41
+
42
+ # Daemon entrypoint is provided by upstream image (do not override)
43
+ EOF
44
+
45
+ # Build image
46
+ echo "Building Docker image for $TOOL..."
47
+ docker build ${DOCKER_NO_CACHE:+--no-cache} -t "ai-$TOOL:latest" "dockerfiles/$TOOL"
48
+
49
+ echo "✅ $TOOL installed (Open Design daemon)"
50
+ echo ""
51
+ echo "Features:"
52
+ echo " ✓ Long-running HTTP daemon (port 7456 inside container)"
53
+ echo " ✓ Bearer token auth (OD_API_TOKEN)"
54
+ echo " ✓ Persistent state via named volume (ai-open-design-data)"
55
+ echo " ✓ Internal-only by default (use --expose to publish to host)"
56
+ echo ""
57
+ echo "Usage:"
58
+ echo " ai-run open-design init # one-time: generate token, network, volume"
59
+ echo " ai-run open-design start # boot daemon"
60
+ echo " ai-run open-design status # check health"
@@ -26,11 +26,11 @@ if [[ ! -d "$OPENCLAW_REPO_DIR/.git" ]]; then
26
26
  git clone https://github.com/openclaw/openclaw.git "$OPENCLAW_REPO_DIR"
27
27
  else
28
28
  echo "📦 OpenClaw repository already exists, pulling latest..."
29
- cd "$OPENCLAW_REPO_DIR"
29
+ cd "$OPENCLAW_REPO_DIR" || exit 1
30
30
  git pull origin main || git pull origin master || true
31
31
  fi
32
32
 
33
- cd "$OPENCLAW_REPO_DIR"
33
+ cd "$OPENCLAW_REPO_DIR" || exit 1
34
34
 
35
35
  # Build OpenClaw Docker image using their docker-compose
36
36
  echo "🔨 Building OpenClaw Docker image..."
@@ -4,9 +4,12 @@ set -e
4
4
  dockerfile_snippet() {
5
5
  cat <<'SNIPPET'
6
6
  USER root
7
- RUN curl -fsSL https://opencode.ai/install | bash && \
7
+ ENV HOME=/root
8
+ RUN curl -fsSL --retry 3 --retry-delay 5 https://opencode.ai/install | bash && \
8
9
  mv /root/.opencode/bin/opencode /usr/local/bin/opencode && \
9
10
  rm -rf /root/.opencode
11
+ USER agent
12
+ ENV HOME=/home/agent
10
13
  SNIPPET
11
14
  }
12
15
 
@@ -32,11 +35,13 @@ if [[ -n "$OPENCODE_VERSION" ]]; then
32
35
  FROM ai-base:latest
33
36
 
34
37
  USER root
35
- RUN curl -fsSL https://opencode.ai/install | bash -s -- --version $OPENCODE_VERSION && \\
38
+ ENV HOME=/root
39
+ RUN curl -fsSL --retry 3 --retry-delay 5 https://opencode.ai/install | bash -s -- --version $OPENCODE_VERSION && \\
36
40
  mv /root/.opencode/bin/opencode /usr/local/bin/opencode && \\
37
41
  rm -rf /root/.opencode
38
42
 
39
43
  USER agent
44
+ ENV HOME=/home/agent
40
45
  ENTRYPOINT ["opencode"]
41
46
  EOF
42
47
  else
@@ -44,11 +49,13 @@ else
44
49
  FROM ai-base:latest
45
50
 
46
51
  USER root
47
- RUN curl -fsSL https://opencode.ai/install | bash && \
52
+ ENV HOME=/root
53
+ RUN curl -fsSL --retry 3 --retry-delay 5 https://opencode.ai/install | bash && \
48
54
  mv /root/.opencode/bin/opencode /usr/local/bin/opencode && \
49
55
  rm -rf /root/.opencode
50
56
 
51
57
  USER agent
58
+ ENV HOME=/home/agent
52
59
  ENTRYPOINT ["opencode"]
53
60
  EOF
54
61
  fi
@@ -189,6 +189,7 @@ pmcp::with_lock() {
189
189
  sleep 0.1
190
190
  waited=$((waited + 1))
191
191
  done
192
+ # shellcheck disable=SC2064 # intentional: capture $mutex value at trap definition time
192
193
  trap "rmdir '$mutex' 2>/dev/null || true" EXIT
193
194
  "$@"
194
195
  local rc=$?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kokorolx/ai-sandbox-wrapper",
3
- "version": "3.4.3",
3
+ "version": "4.0.0",
4
4
  "description": "Docker-based security sandbox for AI coding agents. Isolate Claude, Gemini, Aider, and other AI tools from your host system.",
5
5
  "keywords": [
6
6
  "ai",
package/setup.sh CHANGED
@@ -281,8 +281,8 @@ echo "📁 Legacy workspaces file: $WORKSPACES_FILE"
281
281
  WORKSPACE="${WORKSPACES[0]}"
282
282
 
283
283
  # Tool definitions
284
- TOOL_OPTIONS="amp,opencode,openclaw,droid,claude,gemini,kilo,qwen,codex,qoder,auggie,codebuddy,jules,shai"
285
- TOOL_DESCS="AI coding assistant from @sourcegraph/amp,Open-source coding tool from opencode-ai,OpenClaw AI gateway (Docker Compose),Factory CLI from factory.ai,Claude Code CLI from Anthropic,Google Gemini CLI (free tier),AI pair programmer (Git-native),Kilo Code (500+ models),Alibaba Qwen CLI (1M context),OpenAI Codex terminal agent,Qoder AI CLI assistant,Augment Auggie CLI,Tencent CodeBuddy CLI,Google Jules CLI,OVHcloud SHAI agent"
284
+ TOOL_OPTIONS="amp,opencode,openclaw,open-design,droid,claude,gemini,kilo,qwen,codex,qoder,auggie,codebuddy,jules,shai"
285
+ TOOL_DESCS="AI coding assistant from @sourcegraph/amp,Open-source coding tool from opencode-ai,OpenClaw AI gateway (Docker Compose),Open Design daemon (HTTP service — agent-driven design generation),Factory CLI from factory.ai,Claude Code CLI from Anthropic,Google Gemini CLI (free tier),AI pair programmer (Git-native),Kilo Code (500+ models),Alibaba Qwen CLI (1M context),OpenAI Codex terminal agent,Qoder AI CLI assistant,Augment Auggie CLI,Tencent CodeBuddy CLI,Google Jules CLI,OVHcloud SHAI agent"
286
286
 
287
287
  # Pre-select previously installed tools
288
288
  PRESELECTED_TOOLS=""
@@ -303,7 +303,7 @@ echo "Installing tools: ${TOOLS[*]}"
303
303
 
304
304
  CONTAINERIZED_TOOLS=()
305
305
  for tool in "${TOOLS[@]}"; do
306
- if [[ "$tool" =~ ^(amp|opencode|openclaw|claude|aider|droid|gemini|kilo|qwen|codex|qoder|auggie|codebuddy|jules|shai)$ ]]; then
306
+ if [[ "$tool" =~ ^(amp|opencode|openclaw|open-design|claude|aider|droid|gemini|kilo|qwen|codex|qoder|auggie|codebuddy|jules|shai)$ ]]; then
307
307
  CONTAINERIZED_TOOLS+=("$tool")
308
308
  fi
309
309
  done
@@ -311,8 +311,8 @@ done
311
311
  echo ""
312
312
  if [[ ${#CONTAINERIZED_TOOLS[@]} -gt 0 ]]; then
313
313
  # Category 1: AI Enhancement Tools (spec-driven development, UI/UX, browser automation)
314
- AI_TOOL_OPTIONS="spec-kit,ux-ui-promax,openspec,playwright,rtk"
315
- AI_TOOL_DESCS="Spec-driven development toolkit,UI/UX design intelligence tool,OpenSpec - spec-driven development,Browser automation + Chromium/Firefox/WebKit (~500MB),RTK token optimizer - reduces LLM token usage by 60-90% (~5MB)"
314
+ AI_TOOL_OPTIONS="spec-kit,ux-ui-promax,openspec,playwright,rtk,pup,open-design"
315
+ AI_TOOL_DESCS="Spec-driven development toolkit,UI/UX design intelligence tool,OpenSpec - spec-driven development,Browser automation + Chromium/Firefox/WebKit (~500MB),RTK token optimizer - reduces LLM token usage by 60-90% (~5MB),Datadog Pup CLI - AI-agent-ready observability CLI (~10MB),Open Design daemon - AI design generation service (port 7456)"
316
316
 
317
317
  multi_select "Select AI Enhancement Tools (installed in containers)" "$AI_TOOL_OPTIONS" "$AI_TOOL_DESCS"
318
318
  AI_ENHANCEMENT_TOOLS=("${SELECTED_ITEMS[@]}")
@@ -390,6 +390,8 @@ if [[ $NEEDS_BASE_IMAGE -eq 1 ]]; then
390
390
  INSTALL_CHROME_DEVTOOLS_MCP="${INSTALL_CHROME_DEVTOOLS_MCP:-0}"
391
391
  INSTALL_PLAYWRIGHT_MCP="${INSTALL_PLAYWRIGHT_MCP:-0}"
392
392
  INSTALL_RTK="${INSTALL_RTK:-0}"
393
+ INSTALL_PUP="${INSTALL_PUP:-0}"
394
+ INSTALL_OPEN_DESIGN="${INSTALL_OPEN_DESIGN:-0}"
393
395
 
394
396
  for addon in "${ADDITIONAL_TOOLS[@]}"; do
395
397
  case "$addon" in
@@ -417,10 +419,16 @@ if [[ $NEEDS_BASE_IMAGE -eq 1 ]]; then
417
419
  rtk)
418
420
  INSTALL_RTK=1
419
421
  ;;
422
+ pup)
423
+ INSTALL_PUP=1
424
+ ;;
425
+ open-design)
426
+ INSTALL_OPEN_DESIGN=1
427
+ ;;
420
428
  esac
421
429
  done
422
430
 
423
- export INSTALL_SPEC_KIT INSTALL_UX_UI_PROMAX INSTALL_OPENSPEC INSTALL_PLAYWRIGHT INSTALL_RUBY INSTALL_CHROME_DEVTOOLS_MCP INSTALL_PLAYWRIGHT_MCP INSTALL_RTK
431
+ export INSTALL_SPEC_KIT INSTALL_UX_UI_PROMAX INSTALL_OPENSPEC INSTALL_PLAYWRIGHT INSTALL_RUBY INSTALL_CHROME_DEVTOOLS_MCP INSTALL_PLAYWRIGHT_MCP INSTALL_RTK INSTALL_PUP INSTALL_OPEN_DESIGN
424
432
 
425
433
  # Save MCP selections to ~/.ai-sandbox/config.json for ai-run auto-configuration
426
434
  SANDBOX_CONFIG="$HOME/.ai-sandbox/config.json"
@@ -435,6 +443,54 @@ if [[ $NEEDS_BASE_IMAGE -eq 1 ]]; then
435
443
  jq --argjson mcp "$MCP_INSTALLED" '.mcp.installed = $mcp' "$SANDBOX_CONFIG" > "$SANDBOX_CONFIG.tmp" && mv "$SANDBOX_CONFIG.tmp" "$SANDBOX_CONFIG"
436
444
  chmod 600 "$SANDBOX_CONFIG"
437
445
  echo "✅ MCP tool selections saved to config"
446
+
447
+ # Auto-detect host browser for ai-run's "Host Chrome CDP mode". That mode
448
+ # is gated on .mcp.chromePath being set in config.json, but setup never
449
+ # wrote it -- users had to manually edit the file. Detect a sensible
450
+ # default the first time an MCP browser tool is selected; preserve any
451
+ # existing value the user set themselves.
452
+ if [[ "$INSTALL_CHROME_DEVTOOLS_MCP" -eq 1 || "$INSTALL_PLAYWRIGHT_MCP" -eq 1 ]]; then
453
+ EXISTING_CHROME_PATH=$(jq -r '.mcp.chromePath // empty' "$SANDBOX_CONFIG" 2>/dev/null)
454
+ if [[ -z "$EXISTING_CHROME_PATH" ]]; then
455
+ DETECTED_CHROME_PATH=""
456
+ case "$(uname -s)" in
457
+ Darwin)
458
+ # Stable Chrome first, then Chromium, then popular forks.
459
+ for candidate in \
460
+ "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
461
+ "/Applications/Chromium.app/Contents/MacOS/Chromium" \
462
+ "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser" \
463
+ "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge" \
464
+ "/Applications/Arc.app/Contents/MacOS/Arc"; do
465
+ if [[ -f "$candidate" ]]; then
466
+ DETECTED_CHROME_PATH="$candidate"
467
+ break
468
+ fi
469
+ done
470
+ ;;
471
+ Linux)
472
+ for cmd in google-chrome-stable google-chrome chromium chromium-browser brave-browser microsoft-edge; do
473
+ if command -v "$cmd" &>/dev/null; then
474
+ DETECTED_CHROME_PATH=$(command -v "$cmd")
475
+ break
476
+ fi
477
+ done
478
+ ;;
479
+ esac
480
+
481
+ if [[ -n "$DETECTED_CHROME_PATH" ]]; then
482
+ jq --arg path "$DETECTED_CHROME_PATH" '.mcp.chromePath = $path' "$SANDBOX_CONFIG" > "$SANDBOX_CONFIG.tmp" \
483
+ && mv "$SANDBOX_CONFIG.tmp" "$SANDBOX_CONFIG"
484
+ chmod 600 "$SANDBOX_CONFIG"
485
+ echo "🌐 Host browser detected for CDP: $DETECTED_CHROME_PATH"
486
+ echo " (ai-run will launch this with --remote-debugging-port for MCP browser tools.)"
487
+ echo " To change or disable, edit .mcp.chromePath in $SANDBOX_CONFIG"
488
+ else
489
+ echo "ℹ️ No host browser auto-detected for CDP mode."
490
+ echo " To enable, set .mcp.chromePath in $SANDBOX_CONFIG to a Chrome/Chromium binary."
491
+ fi
492
+ fi
493
+ fi
438
494
  fi
439
495
  fi
440
496
 
@@ -448,8 +504,14 @@ TOOLS="$TOOLS_CSV" \
448
504
  INSTALL_CHROME_DEVTOOLS_MCP="$INSTALL_CHROME_DEVTOOLS_MCP" \
449
505
  INSTALL_PLAYWRIGHT_MCP="$INSTALL_PLAYWRIGHT_MCP" \
450
506
  INSTALL_RTK="$INSTALL_RTK" \
507
+ INSTALL_PUP="$INSTALL_PUP" \
451
508
  bash "$SCRIPT_DIR/lib/build-sandbox.sh"
452
509
 
510
+ # Install open-design as a separate daemon container (not part of sandbox image)
511
+ if [[ "${INSTALL_OPEN_DESIGN:-0}" -eq 1 ]]; then
512
+ bash "$SCRIPT_DIR/lib/install-open-design.sh"
513
+ fi
514
+
453
515
  OLD_IMAGES=()
454
516
  for tool in "${TOOLS[@]}"; do
455
517
  if docker image inspect "ai-${tool}:latest" &>/dev/null; then
@@ -538,6 +600,9 @@ if [[ ${#ADDITIONAL_TOOLS[@]} -gt 0 ]]; then
538
600
  rtk)
539
601
  echo " rtk - Token optimizer for AI coding agents (60-90% savings)"
540
602
  ;;
603
+ open-design)
604
+ echo " open-design - AI design generation daemon (port 7456)"
605
+ ;;
541
606
  esac
542
607
  done
543
608
  fi
@@ -0,0 +1,186 @@
1
+ ---
2
+ name: dd-pup
3
+ description: "Datadog CLI (pup) for AI agents. OAuth2 auth with token refresh. Query logs, metrics, monitors, traces, and more."
4
+ compatibility: "OpenCode with pup binary installed"
5
+ metadata:
6
+ author: datadog-labs
7
+ version: "1.0.0"
8
+ repository: https://github.com/DataDog/pup
9
+ ---
10
+
11
+ # pup (Datadog CLI)
12
+
13
+ Pup CLI for Datadog API operations. Supports OAuth2 and API key auth.
14
+
15
+ ## Quick Reference
16
+
17
+ | Task | Command |
18
+ |------|---------|
19
+ | Search error logs | `pup logs search --query "status:error" --from 1h` |
20
+ | List monitors | `pup monitors list` |
21
+ | Create downtime | `pup downtime create --file downtime.json` |
22
+ | Find slow traces | `pup traces search --query="@duration:>500000000" --from="1h"` |
23
+ | List incidents | `pup incidents list` |
24
+ | Query metrics | `pup metrics query --query "avg:system.cpu.user{*}"` |
25
+ | List hosts | `pup infrastructure hosts list` |
26
+ | Check SLOs | `pup slos list` |
27
+ | On-call teams | `pup on-call teams list` |
28
+ | Security signals | `pup security signals list --query "*" --from 24h` |
29
+ | Check auth | `pup auth status` |
30
+ | Refresh token | `pup auth refresh` |
31
+
32
+ ## Prerequisites
33
+
34
+ ```bash
35
+ # Install pup via Homebrew (recommended)
36
+ brew tap datadog-labs/pack
37
+ brew install pup
38
+
39
+ # Or build from source
40
+ cargo install --git https://github.com/DataDog/pup
41
+ ```
42
+
43
+ ## Auth
44
+
45
+ ```bash
46
+ pup auth login # OAuth2 browser flow (recommended)
47
+ pup auth status # Check token validity
48
+ pup auth refresh # Refresh expired token (no browser)
49
+ pup auth logout # Clear credentials
50
+ ```
51
+
52
+ **⚠️ Tokens expire (~1 hour)**. If a command fails with 401/403:
53
+ ```bash
54
+ pup auth refresh # Try refresh first
55
+ pup auth login # If refresh fails, full re-auth
56
+ ```
57
+
58
+ ### Headless/CI (no browser)
59
+
60
+ ```bash
61
+ export DD_API_KEY=your-api-key
62
+ export DD_APP_KEY=your-app-key
63
+ export DD_SITE=datadoghq.com # or datadoghq.eu, etc.
64
+ ```
65
+
66
+ ## Command Reference
67
+
68
+ ### Monitors
69
+
70
+ ```bash
71
+ pup monitors list --limit 10
72
+ pup monitors list --tags "env:prod"
73
+ pup monitors get 12345
74
+ pup monitors search --query "High CPU"
75
+ pup monitors create --file monitor.json
76
+ pup monitors delete 12345
77
+ ```
78
+
79
+ ### Logs
80
+
81
+ ```bash
82
+ pup logs search --query "status:error" --from 1h
83
+ pup logs search --query "service:payment-api" --from 1h --limit 100
84
+ pup logs aggregate --query "service:api" --compute count --from 1h
85
+ ```
86
+
87
+ ### Metrics
88
+
89
+ ```bash
90
+ pup metrics query --query "avg:system.cpu.user{*}" --from 1h
91
+ pup metrics list --filter "system.*"
92
+ ```
93
+
94
+ ### APM / Services
95
+
96
+ ```bash
97
+ pup apm services list --env production
98
+ pup apm services stats --env production
99
+ pup apm dependencies list --env production
100
+ ```
101
+
102
+ ### Traces
103
+
104
+ ```bash
105
+ pup traces search --query="service:api-gateway" --from="1h"
106
+ pup traces search --query="service:api @duration:>1000000000" --from="1h"
107
+ pup traces aggregate --query="service:api" --compute="avg(@duration)" --group-by="resource_name" --from="1h"
108
+ ```
109
+
110
+ ### Infrastructure / Hosts
111
+
112
+ ```bash
113
+ pup infrastructure hosts list
114
+ pup infrastructure hosts list --filter "env:prod"
115
+ ```
116
+
117
+ ### Dashboards
118
+
119
+ ```bash
120
+ pup dashboards list
121
+ pup dashboards get abc-123
122
+ pup dashboards create --file dashboard.json
123
+ ```
124
+
125
+ ### SLOs
126
+
127
+ ```bash
128
+ pup slos list
129
+ pup slos get slo-123
130
+ pup slos status slo-123 --from 30d --to now
131
+ ```
132
+
133
+ ### Security
134
+
135
+ ```bash
136
+ pup security signals list --query "*" --from 24h
137
+ pup security rules list
138
+ ```
139
+
140
+ ### Live Debugger
141
+
142
+ ```bash
143
+ pup debugger context my-svc --env prod
144
+ pup symdb search --service my-svc --query MyController --view probe-locations
145
+ pup debugger probes create --service my-svc --env prod \
146
+ --probe-location "com.example.MyController:handleRequest" \
147
+ --capture "request.id" --ttl 1h
148
+ pup debugger probes watch --fields "message,captures,timestamp" --timeout 60
149
+ ```
150
+
151
+ ## Subcommand Discovery
152
+
153
+ ```bash
154
+ pup --help # List all commands
155
+ pup <cmd> --help # Command-specific help
156
+ pup agent schema # Machine-readable output
157
+ ```
158
+
159
+ ## Error Handling
160
+
161
+ | Error | Cause | Fix |
162
+ |-------|-------|-----|
163
+ | 401 Unauthorized | Token expired | `pup auth refresh` |
164
+ | 403 Forbidden | Missing scope | Check app key permissions |
165
+ | 404 Not Found | Wrong ID/resource | Verify resource exists |
166
+ | Rate limited | Too many requests | Add delays between calls |
167
+
168
+ ## Sites
169
+
170
+ | Site | `DD_SITE` value |
171
+ |------|-----------------|
172
+ | US1 (default) | `datadoghq.com` |
173
+ | US3 | `us3.datadoghq.com` |
174
+ | US5 | `us5.datadoghq.com` |
175
+ | EU1 | `datadoghq.eu` |
176
+ | AP1 | `ap1.datadoghq.com` |
177
+ | US1-FED | `ddog-gov.com` |
178
+
179
+ ## Detection
180
+
181
+ Before using pup commands, verify it's installed:
182
+ ```bash
183
+ pup --version
184
+ ```
185
+
186
+ If `pup` is not found, skip this skill.
@@ -1,103 +0,0 @@
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%).
@@ -1,118 +0,0 @@
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 |