|
| 1 | +# Gobfile |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +A gobfile is a TOML configuration file that defines jobs for your project. When you launch the TUI (`gob tui`), jobs defined in the gobfile are automatically added and optionally started. |
| 6 | + |
| 7 | +**Location:** `.config/gobfile.toml` in your project directory |
| 8 | + |
| 9 | +## File Format |
| 10 | + |
| 11 | +```toml |
| 12 | +[[job]] |
| 13 | +command = "npm run dev" |
| 14 | +description = "Development server for the frontend app" |
| 15 | + |
| 16 | +[[job]] |
| 17 | +command = "npm run build:watch" |
| 18 | +description = "Watches TypeScript and rebuilds on change" |
| 19 | +autostart = false |
| 20 | + |
| 21 | +[[job]] |
| 22 | +command = "docker compose up db" |
| 23 | +# description and autostart are optional |
| 24 | +``` |
| 25 | + |
| 26 | +## Fields |
| 27 | + |
| 28 | +| Field | Type | Required | Default | Description | |
| 29 | +|-------|------|----------|---------|-------------| |
| 30 | +| `command` | string | Yes | - | The command to run | |
| 31 | +| `description` | string | No | - | Context about the job, shown in TUI and CLI | |
| 32 | +| `autostart` | boolean | No | `true` | Whether to start the job when TUI opens | |
| 33 | + |
| 34 | +## Behavior |
| 35 | + |
| 36 | +### When TUI Opens |
| 37 | + |
| 38 | +1. Gobfile is parsed from `.config/gobfile.toml` |
| 39 | +2. For each job in the file: |
| 40 | + - If a job with the same command exists and is running: skip |
| 41 | + - If a job with the same command exists and is stopped: restart it (if `autostart = true`) |
| 42 | + - If no matching job exists: create and start it (if `autostart = true`) |
| 43 | + - If `autostart = false`: create but don't start (shows as stopped) |
| 44 | +3. Jobs are started asynchronously (TUI doesn't wait for them) |
| 45 | + |
| 46 | +### When TUI Exits |
| 47 | + |
| 48 | +All jobs started from the gobfile are stopped. This includes: |
| 49 | +- Normal exit (pressing `q`) |
| 50 | +- Terminal close |
| 51 | +- SIGTERM/SIGINT signals |
| 52 | + |
| 53 | +Jobs that were already running before TUI opened are **not** stopped. |
| 54 | + |
| 55 | +### Description Updates |
| 56 | + |
| 57 | +Descriptions from the gobfile are applied when jobs are created. Currently, descriptions are not updated for existing jobs when the gobfile changes (see Future Enhancements in the project plan). |
| 58 | + |
| 59 | +## Use Cases |
| 60 | + |
| 61 | +### Development Environment |
| 62 | + |
| 63 | +Define all services needed for local development: |
| 64 | + |
| 65 | +```toml |
| 66 | +[[job]] |
| 67 | +command = "npm run dev" |
| 68 | +description = "Next.js dev server on port 3000" |
| 69 | + |
| 70 | +[[job]] |
| 71 | +command = "npm run api:dev" |
| 72 | +description = "API server on port 4000" |
| 73 | + |
| 74 | +[[job]] |
| 75 | +command = "docker compose up postgres redis" |
| 76 | +description = "Database and cache services" |
| 77 | +``` |
| 78 | + |
| 79 | +### Build Watchers |
| 80 | + |
| 81 | +Add watchers that rebuild on file changes: |
| 82 | + |
| 83 | +```toml |
| 84 | +[[job]] |
| 85 | +command = "npm run typecheck:watch" |
| 86 | +description = "TypeScript type checking in watch mode" |
| 87 | + |
| 88 | +[[job]] |
| 89 | +command = "npm run test:watch" |
| 90 | +description = "Jest tests in watch mode" |
| 91 | +autostart = false # Start manually when needed |
| 92 | +``` |
| 93 | + |
| 94 | +### AI Agent Context |
| 95 | + |
| 96 | +Descriptions help AI agents understand what each job does: |
| 97 | + |
| 98 | +```toml |
| 99 | +[[job]] |
| 100 | +command = "npm run dev" |
| 101 | +description = "Frontend dev server. Check this for UI errors. Runs on http://localhost:3000" |
| 102 | + |
| 103 | +[[job]] |
| 104 | +command = "npm run api" |
| 105 | +description = "Backend API. Check logs here for request/response debugging" |
| 106 | + |
| 107 | +[[job]] |
| 108 | +command = "npm run storybook" |
| 109 | +description = "Component library browser. Use for visual component testing" |
| 110 | +autostart = false |
| 111 | +``` |
| 112 | + |
| 113 | +When an AI agent runs `gob list`, it sees the descriptions and understands the purpose of each job. |
| 114 | + |
| 115 | +## CLI Descriptions |
| 116 | + |
| 117 | +Descriptions can also be set via CLI flags, independently of the gobfile: |
| 118 | + |
| 119 | +```bash |
| 120 | +# Add a job with description |
| 121 | +gob add --description "Build output watcher" npm run build:watch |
| 122 | + |
| 123 | +# Run a command with description |
| 124 | +gob run --description "Running full test suite" npm test |
| 125 | +``` |
| 126 | + |
| 127 | +This is useful for: |
| 128 | +- One-off jobs that aren't in the gobfile |
| 129 | +- Providing additional context for specific runs |
| 130 | +- AI agents documenting why they started a job |
| 131 | + |
| 132 | +## Version Control |
| 133 | + |
| 134 | +Consider whether to commit your gobfile: |
| 135 | + |
| 136 | +**Commit it** if: |
| 137 | +- The jobs are standard for all developers |
| 138 | +- The configuration doesn't contain machine-specific paths |
| 139 | +- You want consistent development environments |
| 140 | + |
| 141 | +**Don't commit it** if: |
| 142 | +- Jobs vary by developer preferences |
| 143 | +- Contains machine-specific configuration |
| 144 | +- You want each developer to customize their setup |
| 145 | + |
| 146 | +To exclude from version control: |
| 147 | +```bash |
| 148 | +echo ".config/gobfile.toml" >> .gitignore |
| 149 | +``` |
| 150 | + |
| 151 | +## Troubleshooting |
| 152 | + |
| 153 | +### Jobs not starting |
| 154 | + |
| 155 | +1. Check the file location: must be `.config/gobfile.toml` (not project root) |
| 156 | +2. Verify TOML syntax: use a TOML validator |
| 157 | +3. Check daemon logs: `$XDG_STATE_HOME/gob/daemon.log` |
| 158 | + |
| 159 | +### Jobs restarting unexpectedly |
| 160 | + |
| 161 | +Jobs are restarted if they were stopped and match a gobfile entry with `autostart = true`. To prevent this, either: |
| 162 | +- Set `autostart = false` for jobs you want to control manually |
| 163 | +- Remove the job from the gobfile |
| 164 | + |
| 165 | +### Description not showing |
| 166 | + |
| 167 | +- Ensure the job was created with a description (either from gobfile or `--description` flag) |
| 168 | +- In CLI: descriptions appear on the second line of `gob list` output |
| 169 | +- In TUI: description panel only appears when the selected job has one |
0 commit comments