@kokorolx/ai-sandbox-wrapper 1.2.1 → 2.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 CHANGED
@@ -8,7 +8,46 @@ AI coding tools like Claude, Gemini, and Aider have full access to your filesyst
8
8
 
9
9
  **What you get:** Peace of mind using AI coding tools without risking your personal and system data.
10
10
 
11
- *Last updated: Thursday, January 22, 2026*
11
+ *Last updated: Wednesday, January 29, 2026*
12
+
13
+ ## ⚠️ Breaking Change: v2.0.0 - Config Directory Reorganization
14
+
15
+ **Version 2.0.0** reorganizes the directory structure to a tool-centric layout and introduces a unified `config.json`.
16
+
17
+ ### New Structure (v2)
18
+ ```
19
+ ~/.ai-sandbox/
20
+ ├── config.json # Unified config (workspaces, git, networks)
21
+ ├── tools/ # Tool-centric organization
22
+ │ ├── claude/
23
+ │ │ ├── home/ # Tool config (was: ~/.ai-sandbox/home/claude/)
24
+ │ │ └── cache/ # Tool cache (was: ~/.ai-sandbox/cache/claude/)
25
+ │ ├── gemini/
26
+ │ │ ├── home/
27
+ │ │ └── cache/
28
+ │ └── ... (other tools)
29
+ └── shared/
30
+ └── git/ # Shared git config
31
+ ├── ssh/ # SSH keys and config
32
+ └── keys/ # Per-workspace key selections
33
+ ```
34
+
35
+ ### Automatic Migration
36
+
37
+ When you run any AI tool, the wrapper automatically migrates:
38
+
39
+ | Old Location | New Location |
40
+ |--------------|-------------|
41
+ | `~/.ai-sandbox/home/<tool>/` | `~/.ai-sandbox/tools/<tool>/home/` |
42
+ | `~/.ai-sandbox/cache/<tool>/` | `~/.ai-sandbox/tools/<tool>/cache/` |
43
+ | `~/.ai-sandbox/cache/git/` | `~/.ai-sandbox/shared/git/` |
44
+ | `~/.ai-sandbox/git-keys/` | `~/.ai-sandbox/shared/git/keys/` |
45
+ | `~/.ai-sandbox/workspaces` (file) | `config.json.workspaces` |
46
+ | `~/.ai-sandbox/git-allowed` (file) | `config.json.git.allowedWorkspaces` |
47
+
48
+ **No action required** - migration happens automatically on first run.
49
+
50
+ **Legacy file compatibility**: Old files (`workspaces`, `git-allowed`) are still read as fallback.
12
51
 
13
52
  ## 🛡️ Why Use This?
14
53
 
@@ -53,6 +92,13 @@ cd ai-sandbox-wrapper
53
92
  ./setup.sh
54
93
  ```
55
94
 
95
+ **Fresh build (no Docker cache):**
96
+ ```bash
97
+ npx @kokorolx/ai-sandbox-wrapper setup --no-cache
98
+ # or
99
+ ./setup.sh --no-cache
100
+ ```
101
+
56
102
  ### Step 3: Follow the Interactive Prompts
57
103
  1. **Whitelist workspaces** - Enter the directories where you want AI tools to access (e.g., `~/projects,~/code`)
58
104
  2. **Select tools** - Use arrow keys to move, space to select, Enter to confirm
@@ -64,7 +110,7 @@ cd ai-sandbox-wrapper
64
110
  source ~/.zshrc
65
111
 
66
112
  # Add your API keys (only if using tools that require them)
67
- nano ~/.ai-env # Add ANTHROPIC_API_KEY, OPENAI_API_KEY, etc.
113
+ nano ~/.ai-sandbox/env # Add ANTHROPIC_API_KEY, OPENAI_API_KEY, etc.
68
114
  ```
69
115
 
70
116
  ### Step 5: Run Your First Tool
@@ -105,16 +151,16 @@ claude --version
105
151
  If you want to give AI access to more project directories later:
106
152
  ```bash
107
153
  # Add a new workspace
108
- echo '/path/to/new/project' >> ~/.ai-workspaces
154
+ echo '/path/to/new/project' >> ~/.ai-sandbox/workspaces
109
155
 
110
156
  # View current allowed directories
111
- cat ~/.ai-workspaces
157
+ cat ~/.ai-sandbox/workspaces
112
158
  ```
113
159
 
114
160
  ### Configure API Keys (If Needed)
115
161
  Some tools require API keys to work properly:
116
162
  ```bash
117
- nano ~/.ai-env
163
+ nano ~/.ai-sandbox/env
118
164
  ```
119
165
  Then add your keys in the format: `KEY_NAME=your_actual_key_here`
120
166
  Examples:
@@ -194,62 +240,79 @@ docker pull registry.gitlab.com/kokorolee/ai-sandbox-wrapper/ai-aider:latest
194
240
 
195
241
  ## 📁 Directory Structure
196
242
 
197
- AI Sandbox Wrapper creates and manages the following directories in your home folder:
243
+ AI Sandbox Wrapper creates and manages a single consolidated directory in your home folder:
198
244
 
199
245
  | Directory | Purpose | Contents |
200
246
  |-----------|---------|----------|
201
247
  | `~/bin/` | Executables | `ai-run` wrapper and symlinks to tool scripts |
202
- | `~/.ai-env` | API keys | Environment variables passed to containers (API keys) |
203
- | `~/.ai-workspaces` | Security | List of whitelisted directories AI can access |
204
- | `~/.ai-git-allowed` | Security | Workspaces where Git credentials are allowed |
205
- | `~/.ai-cache/` | Caching | Tool-specific cache directories (e.g., `~/.ai-cache/claude/`) |
206
- | `~/.ai-home/` | Config | Tool home directories with persistent configs |
248
+ | `~/.ai-sandbox/` | All config | Consolidated configuration directory (see structure below) |
207
249
  | `~/.ai-images/` | Local images | Locally built Docker images (if not using registry) |
208
250
 
251
+ ### Sandbox Structure
252
+
253
+ ```
254
+ ~/.ai-sandbox/
255
+ ├── cache/ # Tool-specific cache directories
256
+ │ ├── claude/ # Claude Code cache
257
+ │ ├── gemini/ # Gemini CLI cache
258
+ │ ├── aider/ # Aider cache
259
+ │ └── git/ # Git credentials cache (when enabled)
260
+ │ └── ssh/ # SSH keys and config for allowed workspace
261
+ ├── home/ # Tool home directories with persistent configs
262
+ │ ├── claude/ # .claude.json and settings
263
+ │ ├── gemini/ # Gemini configuration
264
+ │ ├── aider/ # Aider config and history
265
+ │ └── .gitconfig # Git configuration (when Git access enabled)
266
+ ├── config.json # Network configuration
267
+ ├── workspaces # List of whitelisted directories AI can access
268
+ ├── env # API keys (format: KEY=value, one per line)
269
+ ├── git-allowed # Workspaces with persistent Git access
270
+ ├── git-keys/ # Saved SSH key selections for each workspace
271
+ │ └── {hash} # MD5-hashed workspace path
272
+ └── .migrated # Migration marker (prevents re-migration)
273
+ ```
274
+
209
275
  ### Key Files
210
276
 
211
277
  | File | Purpose |
212
278
  |------|---------|
213
- | `~/.ai-env` | API keys (format: `KEY=value`, one per line) |
214
- | `~/.ai-git-allowed` | Workspaces with persistent Git access (one path per line) |
215
- | `~/.ai-git-keys-*` | Saved SSH key selections for each workspace (md5-hashed) |
216
-
217
- ### Cache Structure
218
-
219
- ```
220
- ~/.ai-cache/
221
- ├── claude/ # Claude Code cache
222
- ├── gemini/ # Gemini CLI cache
223
- ├── aider/ # Aider cache
224
- ├── git/ # Git credentials cache (when enabled)
225
- │ └── ssh/ # SSH keys and config for allowed workspace
226
- ```
227
-
228
- ### Home Structure
229
-
230
- ```
231
- ~/.ai-home/
232
- ├── claude/ # .claude.json and settings
233
- ├── gemini/ # Gemini configuration
234
- ├── aider/ # Aider config and history
235
- └── .gitconfig # Git configuration (when Git access enabled)
236
- ```
279
+ | `~/.ai-sandbox/config.json` | Unified config (workspaces, git access, networks) |
280
+ | `~/.ai-sandbox/env` | API keys (format: `KEY=value`, one per line) |
281
+ | `~/.ai-sandbox/workspaces` | Legacy workspace file (fallback) |
282
+ | `~/.ai-sandbox/git-allowed` | Legacy git-allowed file (fallback) |
237
283
 
238
284
  ## ⚙️ Configuration
239
285
 
240
286
  ### API Keys
241
287
  ```bash
242
288
  # Edit environment file
243
- nano ~/.ai-env
289
+ nano ~/.ai-sandbox/env
244
290
  ```
245
291
 
246
292
  ### Workspace Management
247
293
  ```bash
248
- # Add workspace
249
- echo '/path/to/project' >> ~/.ai-workspaces
294
+ # CLI commands (recommended)
295
+ npx @kokorolx/ai-sandbox-wrapper workspace list
296
+ npx @kokorolx/ai-sandbox-wrapper workspace add ~/projects/my-new-app
297
+ npx @kokorolx/ai-sandbox-wrapper workspace remove ~/old-project
250
298
 
251
- # List workspaces
252
- cat ~/.ai-workspaces
299
+ # Interactive menu
300
+ npx @kokorolx/ai-sandbox-wrapper update
301
+
302
+ # Legacy (still works)
303
+ echo '/path/to/project' >> ~/.ai-sandbox/workspaces
304
+ cat ~/.ai-sandbox/workspaces
305
+ ```
306
+
307
+ ### Git Access Management
308
+ ```bash
309
+ # CLI commands
310
+ npx @kokorolx/ai-sandbox-wrapper git status
311
+ npx @kokorolx/ai-sandbox-wrapper git enable ~/projects/myrepo
312
+ npx @kokorolx/ai-sandbox-wrapper git disable ~/projects/myrepo
313
+
314
+ # Interactive menu
315
+ npx @kokorolx/ai-sandbox-wrapper update
253
316
  ```
254
317
 
255
318
  ### Network Configuration
@@ -274,12 +337,24 @@ Network selections are saved to `~/.ai-sandbox/config.json`:
274
337
  - **Global**: Default for all workspaces
275
338
 
276
339
  ```bash
340
+ # CLI commands
341
+ npx @kokorolx/ai-sandbox-wrapper network list
342
+ npx @kokorolx/ai-sandbox-wrapper network add mynetwork --global
343
+ npx @kokorolx/ai-sandbox-wrapper network add dev-network --workspace ~/projects/myapp
344
+ npx @kokorolx/ai-sandbox-wrapper network remove mynetwork --global
345
+
277
346
  # View current config
278
- cat ~/.ai-sandbox/config.json
347
+ npx @kokorolx/ai-sandbox-wrapper config show
348
+ npx @kokorolx/ai-sandbox-wrapper config show --json
279
349
 
280
- # Example config structure
350
+ # Example config.json structure (v2)
281
351
  {
282
- "version": 1,
352
+ "version": 2,
353
+ "workspaces": ["/Users/you/projects/my-app"],
354
+ "git": {
355
+ "allowedWorkspaces": ["/Users/you/projects/my-repo"],
356
+ "keySelections": {}
357
+ },
283
358
  "networks": {
284
359
  "global": ["shared-services"],
285
360
  "workspaces": {
@@ -298,13 +373,13 @@ When running without the flag, saved networks are used silently:
298
373
 
299
374
  ### Environment Variables
300
375
 
301
- All environment variables are configured in `~/.ai-env` or passed at runtime:
376
+ All environment variables are configured in `~/.ai-sandbox/env` or passed at runtime:
302
377
 
303
378
  #### Image Source
304
379
  Choose between locally built images or pre-built GitLab registry images:
305
380
 
306
381
  ```bash
307
- # Add to ~/.ai-env
382
+ # Add to ~/.ai-sandbox/env
308
383
 
309
384
  # Use locally built images (default)
310
385
  AI_IMAGE_SOURCE=local
@@ -373,7 +448,7 @@ rails server -b 0.0.0.0
373
448
  ```
374
449
 
375
450
  #### API Keys
376
- Configure in `~/.ai-env`:
451
+ Configure in `~/.ai-sandbox/env`:
377
452
 
378
453
  ```bash
379
454
  # Required for Claude tools
@@ -395,16 +470,18 @@ Each tool supports project-specific config files that override global settings:
395
470
 
396
471
  | Tool | Project Config | Global Config Location |
397
472
  |------|----------------|------------------------|
398
- | Claude | `.claude.json` | `~/.claude/` |
399
- | Gemini | `.gemini.json` | `~/.config/gemini/` |
400
- | Aider | `.aider.conf` | `~/.config/aider/` |
401
- | Opencode | `.opencode.json` | `~/.config/opencode/` |
402
- | Kilo | `.kilo.json` | `~/.config/kilo/` |
403
- | Codex | `.codex.json` | `~/.config/codex/` |
404
- | Amp | `.amp.json` | `~/.config/amp/` |
473
+ | Claude | `.claude.json` | `~/.ai-sandbox/home/claude/.claude/` |
474
+ | Gemini | `.gemini.json` | `~/.ai-sandbox/home/gemini/.config/gemini/` |
475
+ | Aider | `.aider.conf` | `~/.ai-sandbox/home/aider/.config/aider/` |
476
+ | Opencode | `.opencode.json` | `~/.ai-sandbox/home/opencode/.config/opencode/` |
477
+ | Kilo | `.kilo.json` | `~/.ai-sandbox/home/kilo/.config/kilo/` |
478
+ | Codex | `.codex.json` | `~/.ai-sandbox/home/codex/.config/codex/` |
479
+ | Amp | `.amp.json` | `~/.ai-sandbox/home/amp/.config/amp/` |
405
480
 
406
481
  **Priority:** Project config > Global config > Container defaults
407
482
 
483
+ **Note:** Existing configs from `~/.config/{tool}/` or `~/.claude/` are automatically migrated to the new location on first run.
484
+
408
485
  ```bash
409
486
  # Example: Project-specific Claude config
410
487
  cat > .claude.json << 'EOF'
@@ -418,14 +495,15 @@ EOF
418
495
 
419
496
  ### Tool-Specific Config Locations
420
497
 
421
- When using global configs (not project-specific), they're stored in:
498
+ All tool configs are consolidated under `~/.ai-sandbox/home/{tool}/`:
422
499
 
423
500
  ```
424
- ~/.ai-home/{tool}/
501
+ ~/.ai-sandbox/home/{tool}/
425
502
  ├── .config/ # Tool configuration
426
503
  │ └── {tool}/ # Per-tool config directory
427
504
  ├── .local/share/ # Tool data (cache, sessions)
428
- └── .cache/ # Runtime cache
505
+ ├── .cache/ # Runtime cache
506
+ └── .claude/ # Claude-specific (for claude tool)
429
507
  ```
430
508
 
431
509
  Each tool's config is mounted to `/home/agent/` inside the container.
@@ -516,10 +594,10 @@ Allow AI tool to access Git credentials for this workspace?
516
594
  **Managing Git access:**
517
595
  ```bash
518
596
  # View allowed workspaces
519
- cat ~/.ai-git-allowed
597
+ cat ~/.ai-sandbox/git-allowed
520
598
 
521
599
  # Remove a workspace from allowed list
522
- nano ~/.ai-git-allowed # Delete the line
600
+ nano ~/.ai-sandbox/git-allowed # Delete the line
523
601
  ```
524
602
 
525
603
  **Why this is secure:**
@@ -571,11 +649,11 @@ nano ~/.ai-git-allowed # Delete the line
571
649
  - Look for the Docker image: `docker images | grep ai-`
572
650
 
573
651
  **"Outside whitelisted workspace" error**
574
- - Add your current directory: `echo "$(pwd)" >> ~/.ai-workspaces`
652
+ - Add your current directory: `echo "$(pwd)" >> ~/.ai-sandbox/workspaces`
575
653
  - Or navigate to a directory you whitelisted during setup
576
654
 
577
655
  **API key errors**
578
- - Check your keys in: `cat ~/.ai-env`
656
+ - Check your keys in: `cat ~/.ai-sandbox/env`
579
657
  - Make sure keys are in format: `KEY_NAME=actual_key_value`
580
658
 
581
659
  ### Getting Help
@@ -583,9 +661,9 @@ nano ~/.ai-git-allowed # Delete the line
583
661
  If you're still having issues:
584
662
  1. Check that Docker is running
585
663
  2. Re-run `./setup.sh` to reinstall
586
- 3. Look at the configuration files in your home directory:
587
- - `~/.ai-workspaces` - should contain your project directories
588
- - `~/.ai-env` - should contain your API keys (if needed)
664
+ 3. Look at the configuration files in `~/.ai-sandbox/`:
665
+ - `~/.ai-sandbox/workspaces` - should contain your project directories
666
+ - `~/.ai-sandbox/env` - should contain your API keys (if needed)
589
667
  4. View Docker images: `docker images` to see if tools built successfully
590
668
 
591
669
  ## 📚 Quick Reference
@@ -614,15 +692,15 @@ ai-run opencode --shell # or -s
614
692
  See [SHELL-MODE-USAGE.md](SHELL-MODE-USAGE.md) for detailed examples and use cases.
615
693
 
616
694
  ### Configuration Files
617
- - `~/.ai-env` - Store API keys here
618
- - `~/.ai-workspaces` - Whitelisted project directories
619
- - `~/.ai-cache/` - Tool cache (persistent)
620
- - `~/.ai-home/` - Tool configurations (persistent)
695
+ - `~/.ai-sandbox/env` - Store API keys here
696
+ - `~/.ai-sandbox/workspaces` - Whitelisted project directories
697
+ - `~/.ai-sandbox/cache/` - Tool cache (persistent)
698
+ - `~/.ai-sandbox/home/` - Tool configurations (persistent)
621
699
 
622
700
  ### Common Tasks
623
701
  ```bash
624
702
  # Add a new project directory to AI access
625
- echo '/path/to/my/new/project' >> ~/.ai-workspaces
703
+ echo '/path/to/my/new/project' >> ~/.ai-sandbox/workspaces
626
704
 
627
705
  # Check what tools are installed
628
706
  ls ~/bin/
@@ -632,6 +710,63 @@ source ~/.zshrc
632
710
 
633
711
  # Update to latest version
634
712
  npx @kokorolx/ai-sandbox-wrapper@latest setup
713
+
714
+ # Clean up caches and configs
715
+ npx @kokorolx/ai-sandbox-wrapper clean
716
+ ```
717
+
718
+ ### Cleanup Command
719
+
720
+ The `clean` command provides an interactive way to remove AI Sandbox directories:
721
+
722
+ ```bash
723
+ npx @kokorolx/ai-sandbox-wrapper clean
724
+ ```
725
+
726
+ **Features:**
727
+ - Two-level menu: First select category, then specific tools/items
728
+ - Shows directory sizes before deletion
729
+ - Groups items by risk level (🟢 Safe, 🟡 Medium, 🔴 Critical)
730
+ - Requires typing "yes" to confirm deletion
731
+
732
+ **Categories:**
733
+ | Category | Contents | Risk |
734
+ |----------|----------|------|
735
+ | Tool caches | `~/.ai-sandbox/cache/{tool}/` | 🟢 Safe to delete |
736
+ | Tool configs | `~/.ai-sandbox/home/{tool}/` | 🟡 Loses settings |
737
+ | Global config | `~/.ai-sandbox/workspaces`, `~/.ai-sandbox/env`, etc. | 🟡🔴 Mixed |
738
+ | Everything | `~/.ai-sandbox/` | 🔴 Full reset |
739
+
740
+ **Example:**
741
+ ```
742
+ 🧹 AI Sandbox Cleanup
743
+
744
+ What would you like to clean?
745
+ 1. Tool caches (~/.ai-sandbox/cache/) - Safe to delete
746
+ 2. Tool configs (~/.ai-sandbox/home/) - Loses settings
747
+ 3. Global config files - Loses preferences
748
+ 4. Everything (~/.ai-sandbox/) - Full reset
749
+
750
+ Enter selection (or 'q' to quit): 1
751
+
752
+ 📁 Tool Caches (~/.ai-sandbox/cache/)
753
+
754
+ Select tools to clear:
755
+ 1. claude/ (45.2 MB)
756
+ 2. opencode/ (120.5 MB)
757
+
758
+ Enter selection (comma-separated, 'all', or 'b' to go back): 1
759
+
760
+ You are about to delete:
761
+ - ~/.ai-sandbox/cache/claude/ (45.2 MB)
762
+
763
+ Total: 45.2 MB
764
+
765
+ Type 'yes' to confirm: yes
766
+
767
+ ✓ Deleted ~/.ai-sandbox/cache/claude/
768
+
769
+ Deleted 1 items, freed 45.2 MB
635
770
  ```
636
771
 
637
772
  ## 🤝 Contributing