|
| 1 | +# Go Cobra CLI: `open-cursor` |
| 2 | + |
| 3 | +This repo currently ships: |
| 4 | +- A Go TUI installer (`cmd/installer`) |
| 5 | +- An npm package (`@rama_nigg/open-cursor`) that contains the plugin bundle and a Node-based installer CLI (invokable via `npm exec -- @rama_nigg/open-cursor install`) |
| 6 | + |
| 7 | +The next step is a first-class Go Cobra CLI with consistent `open-cursor` branding, shared install logic, and a clean path toward a “just works” npm install. |
| 8 | + |
| 9 | +## Branding |
| 10 | + |
| 11 | +Print this ASCII header at startup (root command help and `open-cursor version`): |
| 12 | + |
| 13 | +```text |
| 14 | + ▄▄▄ ▄▄▄▄ ▄▄▄▄▄ ▄▄ ▄▄ ▄▄▄ ▄▄ ▄▄ ▄▄▄▄ ▄▄▄▄ ▄▄▄ ▄▄▄▄ |
| 15 | +██ ██ ██ ██ ██▄▄ ███▄██ ▄▄▄ ██ ▀▀ ██ ██ ██ ██ ██▄▄▄ ██ ██ ██ ██ |
| 16 | +▀█▄█▀ ██▀▀ ██▄▄▄ ██ ▀██ ▀█▄█▀ ▀█▄█▀ ██▀█▄ ▄▄▄█▀ ▀█▄█▀ ██▀█▄ |
| 17 | +``` |
| 18 | + |
| 19 | +Source: `/home/nomadx/bit/opencursor.txt`. |
| 20 | + |
| 21 | +Reference implementation style: `/home/nomadx/Documents/jellywatch/cmd/jellywatch/main.go`. |
| 22 | + |
| 23 | +## CLI UX (v1) |
| 24 | + |
| 25 | +Binary name: `open-cursor` |
| 26 | + |
| 27 | +Commands: |
| 28 | +- `open-cursor install` |
| 29 | + - Ensure plugin file exists: `~/.config/opencode/plugin/cursor-acp.js` (or XDG equivalent) |
| 30 | + - Ensure provider config exists/merged in `opencode.json` (baseURL + models) |
| 31 | + - Best-effort ensure `@ai-sdk/openai-compatible` is installed in `~/.config/opencode` |
| 32 | +- `open-cursor sync-models` |
| 33 | + - Run `cursor-agent models`, update provider models in config |
| 34 | +- `open-cursor status` |
| 35 | + - Print config path, plugin path, provider enabled, baseURL, model count |
| 36 | + - Optional `--json` output for scripts |
| 37 | +- `open-cursor uninstall` |
| 38 | + - Remove plugin link and provider entry (with backup) |
| 39 | +- Optional (later): `open-cursor doctor` |
| 40 | + - Validate cursor-agent presence, login state, and common misconfigurations |
| 41 | + |
| 42 | +Flags (consistent across install/sync/uninstall): |
| 43 | +- `--config <path>` default `$XDG_CONFIG_HOME/opencode/opencode.json` (else `~/.config/opencode/opencode.json`) |
| 44 | +- `--plugin-dir <path>` default `$XDG_CONFIG_HOME/opencode/plugin` |
| 45 | +- `--base-url <url>` default `http://127.0.0.1:32124/v1` |
| 46 | +- `--copy` copy plugin-entry instead of symlink |
| 47 | +- `--skip-models` (install only) |
| 48 | +- `--no-backup` |
| 49 | + |
| 50 | +Backups: |
| 51 | +- Always create `<config>.bak.<timestamp>` unless `--no-backup`. |
| 52 | + |
| 53 | +## Architecture (avoid duplication) |
| 54 | + |
| 55 | +Refactor the existing Go installer logic so both the TUI installer and Cobra CLI share the same core code. |
| 56 | + |
| 57 | +Proposed packages: |
| 58 | +- `internal/opencodeconfig` |
| 59 | + - Read/write config |
| 60 | + - Backup config |
| 61 | + - Ensure provider `cursor-acp` exists and is merged (preserve user fields) |
| 62 | + - Ensure plugin array includes `cursor-acp` |
| 63 | +- `internal/cursoragent` |
| 64 | + - Run `cursor-agent models` |
| 65 | + - Parse model list into a stable shape |
| 66 | +- `internal/pluginlink` |
| 67 | + - Create plugin symlink/copy at `.../opencode/plugin/cursor-acp.js` |
| 68 | + - Resolve plugin entry source: |
| 69 | + - source install: `<repo>/dist/plugin-entry.js` |
| 70 | + - npm install: `node_modules/.../dist/plugin-entry.js` if applicable |
| 71 | +- `internal/installsteps` |
| 72 | + - Composed operations: Install, SyncModels, Status, Uninstall |
| 73 | + |
| 74 | +Then: |
| 75 | +- Cobra CLI lives in `cmd/open-cursor` |
| 76 | +- TUI installer (`cmd/installer`) becomes a UI wrapper over `internal/installsteps` |
| 77 | + |
| 78 | +## NPM Distribution Strategy (later) |
| 79 | + |
| 80 | +Today’s npm flow works via Node and `npm exec`. |
| 81 | + |
| 82 | +Longer-term: |
| 83 | +- Publish prebuilt `open-cursor` binaries to GitHub Releases (darwin/linux, amd64/arm64). |
| 84 | +- Add npm `postinstall` downloader that installs the appropriate binary into the package directory. |
| 85 | +- Expose that binary via npm `bin` (thin JS shim that execs the binary). |
| 86 | +- Keep Node installer as fallback if binary download fails. |
| 87 | + |
| 88 | +## Testing (minimum) |
| 89 | + |
| 90 | +Add a small integration test harness in Go: |
| 91 | +- run `open-cursor install --config <tmp>/opencode.json --plugin-dir <tmp>/plugin` |
| 92 | +- assert: |
| 93 | + - plugin file exists |
| 94 | + - provider entry exists with models |
| 95 | + - backups are created unless `--no-backup` |
| 96 | + |
| 97 | +## Versioning / Publishing |
| 98 | + |
| 99 | +Do not publish to npm for docs-only changes. |
| 100 | +Only publish when user-facing behavior changes (plugin behavior, installer behavior, CLI behavior). |
| 101 | + |
0 commit comments