|
| 1 | +# External Files Written by Superset Desktop |
| 2 | + |
| 3 | +This document lists all files written by the Superset desktop app outside of user projects. |
| 4 | +Understanding these files is critical for maintaining dev/prod separation and avoiding conflicts. |
| 5 | + |
| 6 | +## Environment-Specific Directories |
| 7 | + |
| 8 | +The app uses different home directories based on environment: |
| 9 | +- **Development**: `~/.superset-dev/` |
| 10 | +- **Production**: `~/.superset/` |
| 11 | + |
| 12 | +This separation prevents dev and prod from interfering with each other. |
| 13 | + |
| 14 | +## Files in `~/.superset[-dev]/` |
| 15 | + |
| 16 | +### `bin/` - Agent Wrapper Scripts |
| 17 | + |
| 18 | +| File | Purpose | |
| 19 | +|------|---------| |
| 20 | +| `claude` | Wrapper for Claude Code CLI that injects notification hooks | |
| 21 | +| `codex` | Wrapper for Codex CLI that injects notification hooks | |
| 22 | +| `opencode` | Wrapper for OpenCode CLI that sets `OPENCODE_CONFIG_DIR` | |
| 23 | + |
| 24 | +These wrappers are added to `PATH` via shell integration, allowing them to intercept |
| 25 | +agent commands and inject Superset-specific configuration. |
| 26 | + |
| 27 | +### `hooks/` - Notification Hook Scripts |
| 28 | + |
| 29 | +| File | Purpose | |
| 30 | +|------|---------| |
| 31 | +| `notify.sh` | Shell script called by agents when they complete or need input | |
| 32 | +| `claude-settings.json` | Claude Code settings file with hook configuration | |
| 33 | +| `opencode/plugin/superset-notify.js` | OpenCode plugin for lifecycle events | |
| 34 | + |
| 35 | +### `zsh/` and `bash/` - Shell Integration |
| 36 | + |
| 37 | +| File | Purpose | |
| 38 | +|------|---------| |
| 39 | +| `init.zsh` | Zsh initialization script (sources .zshrc, sets up PATH) | |
| 40 | +| `init.bash` | Bash initialization script (sources .bashrc, sets up PATH) | |
| 41 | + |
| 42 | +## Global Files (AVOID ADDING NEW ONES) |
| 43 | + |
| 44 | +**DO NOT write to global locations** like `~/.config/`, `~/Library/`, etc. |
| 45 | +These cause dev/prod conflicts when both environments are running. |
| 46 | + |
| 47 | +### Known Issues with Global Files |
| 48 | + |
| 49 | +Previously, the OpenCode plugin was written to `~/.config/opencode/plugin/superset-notify.js`. |
| 50 | +This caused severe issues: |
| 51 | +1. Dev would overwrite prod's plugin with incompatible protocol |
| 52 | +2. Prod terminals would send events that dev's server couldn't handle |
| 53 | +3. Users received spam notifications for every agent message |
| 54 | + |
| 55 | +**Solution**: The global plugin is no longer written. On startup, any stale global plugin |
| 56 | +with our marker is deleted to prevent conflicts from older versions. |
| 57 | + |
| 58 | +## Shell RC File Modifications |
| 59 | + |
| 60 | +The app modifies shell RC files to add the Superset bin directory to PATH: |
| 61 | + |
| 62 | +| Shell | RC File | Modification | |
| 63 | +|-------|---------|--------------| |
| 64 | +| Zsh | `~/.zshrc` | Prepends `~/.superset[-dev]/bin` to PATH | |
| 65 | +| Bash | `~/.bashrc` | Prepends `~/.superset[-dev]/bin` to PATH | |
| 66 | + |
| 67 | +## Terminal Environment Variables |
| 68 | + |
| 69 | +Each terminal session receives these environment variables: |
| 70 | + |
| 71 | +| Variable | Purpose | |
| 72 | +|----------|---------| |
| 73 | +| `SUPERSET_PANE_ID` | Unique identifier for the terminal pane | |
| 74 | +| `SUPERSET_TAB_ID` | Identifier for the containing tab | |
| 75 | +| `SUPERSET_WORKSPACE_ID` | Identifier for the workspace | |
| 76 | +| `SUPERSET_WORKSPACE_NAME` | Human-readable workspace name | |
| 77 | +| `SUPERSET_WORKSPACE_PATH` | Filesystem path to the workspace | |
| 78 | +| `SUPERSET_ROOT_PATH` | Root path of the project | |
| 79 | +| `SUPERSET_PORT` | Port for the notification server | |
| 80 | +| `SUPERSET_ENV` | Environment (`development` or `production`) | |
| 81 | +| `SUPERSET_HOOK_VERSION` | Hook protocol version for compatibility | |
| 82 | + |
| 83 | +## Adding New External Files |
| 84 | + |
| 85 | +Before adding new files outside of `~/.superset[-dev]/`: |
| 86 | + |
| 87 | +1. **Consider if it's necessary** - Can you use the environment-specific directory instead? |
| 88 | +2. **Check for conflicts** - Will dev and prod overwrite each other? |
| 89 | +3. **Update this document** - Add the file to the appropriate section |
| 90 | +4. **Add cleanup logic** - If migrating from global to local, clean up the old location |
| 91 | + |
| 92 | +## Debugging Cross-Environment Issues |
| 93 | + |
| 94 | +If you suspect dev/prod cross-talk: |
| 95 | + |
| 96 | +1. Check logs for "Environment mismatch" warnings |
| 97 | +2. Verify `SUPERSET_ENV` and `SUPERSET_PORT` are set correctly in terminal |
| 98 | +3. Delete stale global files: `rm -rf ~/.config/opencode/plugin/superset-notify.js` |
| 99 | +4. Restart both dev and prod apps to regenerate hooks |
0 commit comments