subconscious-cli 0.2.1 → 0.3.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
@@ -1,123 +1,247 @@
1
1
  # subconscious-cli
2
2
 
3
- Log in to Subconscious from your terminal, then launch your favorite coding
4
- agent against your hosted Subconscious model — no per-agent config required.
3
+ Log in to Subconscious, then run coding agents against the Subconscious gateway.
5
4
 
6
5
  ## Quick start
7
6
 
8
7
  ```bash
9
- npx subconscious-cli login # sign in, saves your API key
10
- npx subconscious-cli claude-code # launch Claude Code on Subconscious
8
+ npm install -g subconscious-cli
9
+ subc login
10
+ subc claude
11
11
  ```
12
12
 
13
- Installed globally it's just `subconscious <command>`:
13
+ Login creates both the saved credential and a ready-to-use `default` profile,
14
+ so Claude Code, Codex, and OpenCode can launch immediately. Persistent editor
15
+ and Pi integrations are installed per agent:
14
16
 
15
17
  ```bash
16
- npm install -g subconscious-cli
17
- subconscious login
18
- subconscious open-code
18
+ subc cursor install
19
+ subc copilot install
20
+ subc pi install
21
+ subc <agent> uninstall
22
+ ```
23
+
24
+ Top-level help (`subc`, `subc help`, or `subc --help`) displays the
25
+ Subconscious logo as portable ASCII art. Set `NO_COLOR=1` for a
26
+ monochrome version; redirected output automatically uses a plain wordmark.
27
+
28
+ Every command accepts `help` as a subcommand. These only read the selected
29
+ profile; they do not authenticate, install, configure, or launch anything:
30
+
31
+ ```bash
32
+ subc claude help
33
+ subc codex help
34
+ subc cursor help
35
+ subc config help
36
+ subc login help
19
37
  ```
20
38
 
21
- ## Launching coding agents
39
+ Agent help includes launch/install behavior, supported integration options, and
40
+ every relevant profile setting with API keys redacted.
41
+
42
+ `subc claude` launches the normal `claude` executable with the Subconscious
43
+ gateway environment applied for that process. Arguments pass through as usual:
22
44
 
23
- `subconscious <agent>` resolves your saved API key, injects the env vars that
24
- point the agent at Subconscious, and exec's the real CLI. Nothing is written to
25
- the agent's own config the provider is passed in-memory for that run only.
45
+ ```bash
46
+ subc claude --continue
47
+ subc codex exec "write a test"
48
+ subc opencode
49
+ subc pi
50
+ ```
26
51
 
27
- Install commands are **OS-specific** — the CLI picks the right one for your
28
- platform automatically. The table below shows the macOS/Linux command; on
29
- Windows the equivalent native installer is used instead.
52
+ ## Supported agents
30
53
 
31
- | Command | Launches | Requires (install, macOS/Linux) |
32
- | -------------------------- | ----------- | ------------------------------------------------------- |
33
- | `subconscious claude-code` | Claude Code | `curl -fsSL https://claude.ai/install.sh \| bash` |
34
- | `subconscious open-code` | OpenCode | `npm i -g opencode-ai` |
35
- | `subconscious aider` | Aider | `python3 -m pip install aider-install && aider-install` |
36
- | `subconscious codex` | Codex CLI | `npm i -g @openai/codex` |
54
+ The packaged integrations live in `cli/bin/runbook`.
37
55
 
38
- Claude Code uses its **native installer** (the `curl`/`irm` script above), with
39
- `npm i -g @anthropic-ai/claude-code` kept as an automatic fallback if the native
40
- installer fails.
56
+ | Command | Behavior |
57
+ | --- | --- |
58
+ | `subc claude` | Launch Claude Code with the runbook environment, context limits, subagent limits, and OTEL usage reporting |
59
+ | `subc codex` | Launch Codex with the runbook provider, temporary model catalog, and surgically merged compaction hooks |
60
+ | `subc opencode` | Launch OpenCode with the runbook provider, client header, and context/output limits |
61
+ | `subc cursor install` | Install/update Cursor conversation and compaction hooks |
62
+ | `subc copilot install` | Install/update the VS Code custom endpoint and Copilot hooks |
63
+ | `subc pi install` then `subc pi` | Merge the Pi provider, then launch |
41
64
 
42
- If the underlying agent isn't installed and you're in an interactive terminal,
43
- the CLI offers to install it for you (just press Enter), runs the right
44
- installer for your OS (trying the fallback if the primary fails), and launches
45
- it once the install succeeds. In a non-interactive context (CI) it instead
46
- prints the exact install command (and any fallback) and exits without running
47
- anything.
65
+ If Claude Code, Codex, or OpenCode is missing, an interactive terminal offers
66
+ to install it before launching. Pi requires `subc pi install` first; if its
67
+ executable or Subconscious provider is missing, the CLI exits with instructions
68
+ instead of installing the binary.
48
69
 
49
- Freshly-installed binaries (e.g. Aider and Claude Code land in `~/.local/bin`,
50
- npm globals in the npm prefix) often aren't on your current shell's `PATH` yet.
51
- The CLI looks in those common locations and launches the agent anyway. If it
52
- still can't find the binary right after install, it tells you to **open a new
53
- terminal** (or add the printed dir to `PATH`) and re-run the command — the
54
- install itself succeeded.
70
+ `subc codex` disables Codex apps and plugin tools for that launch by default so
71
+ requests remain below the gateway's 128-tool limit. Core coding tools remain
72
+ available. Use `subc codex --external-tools` to opt back in when targeting a
73
+ gateway with a larger tool limit. It also defaults reasoning effort to `max`,
74
+ which is the highest effort accepted by the Subconscious models; override it
75
+ with `subc codex --reasoning-effort high` when desired.
55
76
 
56
- Anything after the agent name is forwarded straight to it:
77
+ Persistent writes are merge/unmerge only. They never replace a user's
78
+ `config.toml`, `opencode.json`, `models.json`, `hooks.json`, or VS Code
79
+ provider list. Remove Subconscious files with the matching uninstall command:
57
80
 
58
81
  ```bash
59
- subconscious claude-code --resume
60
- subconscious codex exec "write a test"
82
+ subc cursor uninstall
83
+ subc copilot uninstall
84
+ subc pi uninstall
85
+ subc codex uninstall
86
+ subc claude uninstall
87
+ subc opencode uninstall
61
88
  ```
62
89
 
63
- ### Choosing a model
90
+ `subc claude uninstall` and `subc opencode uninstall` only clean leftover files
91
+ from older overwrite-style setup. Launch those agents with `subc claude` /
92
+ `subc opencode`; they do not need install.
64
93
 
65
- Defaults to `subconscious/tim-qwen3.6-27b`. Override per run with `--model`, or
66
- set `SUBCONSCIOUS_MODEL` in your environment:
94
+ Inspect a persistent integration with `subc <agent> status`. A one-off
95
+ `--api-key` passed to install takes precedence for that command but is not
96
+ saved to the selected profile.
97
+
98
+ Cursor still requires enabling its OpenAI API Key Override in Cursor Settings.
99
+ Copilot requires entering the custom endpoint key once through VS Code's
100
+ Manage Language Models UI. The install scripts print the relevant next steps.
101
+
102
+ The runbook scripts require Bash. Cursor, Copilot, Pi, and Codex hook merge
103
+ also require `jq`; Cursor and Copilot also require `curl`.
104
+
105
+ ## Runbook profiles
106
+
107
+ `subc login` automatically creates:
108
+
109
+ ```text
110
+ ~/.subconscious/profiles/default.env
111
+ ```
112
+
113
+ The file is mode `600` and contains the shared gateway URL, API key, model,
114
+ optional per-agent key overrides, and all Claude/Codex/OpenCode/Pi/Copilot
115
+ context and output settings used by the packaged runbook scripts.
67
116
 
68
117
  ```bash
69
- subconscious open-code --model subconscious/tim-qwen3.6-27b
70
- export SUBCONSCIOUS_MODEL=subconscious/tim-qwen3.6-27b
118
+ subc config # list every profile and its file path
119
+ subc -p staging config # print that path and env file
120
+ subc -p staging config --model subconscious/glm-5.2
121
+ subc config --gateway-url https://gateway.example
122
+ subc config path
123
+ subc config edit # open the selected profile in $VISUAL, $EDITOR, vim, or nano
124
+ subc -p staging config edit vim
125
+ subc config edit nano
71
126
  ```
72
127
 
73
- ### Pointing at a different endpoint
128
+ `subc config` lists each profile next to its `.env` path. `subc -p NAME config`
129
+ prints that path, then the file (API keys and other secrets redacted). Extra
130
+ `KEY=value` lines in the file are passed through to launches and override
131
+ Subconscious-injected defaults; resolved login identity (`GATEWAY_URL`,
132
+ `API_KEY`, `MODEL`) still comes from login, `--model`, and the matching flags.
133
+ In scripts and CI, keep using `subc config --gateway-url`, `--api-key`, and
134
+ `--model`.
74
135
 
75
- By default the CLI targets `https://api.subconscious.dev`. Override the base URL
76
- per run (or for a whole session) with `SUBCONSCIOUS_BASE_URL` it flows to both
77
- the Anthropic-style base and the OpenAI-compatible `/v1` base:
136
+ Each agent section can hold its own API key. An agent-specific key takes
137
+ precedence over the shared profile key and can be used on its own, so profiles
138
+ do not need an `API_KEY` when every configured agent has an explicit key.
139
+
140
+ Named profiles work like AWS CLI profiles:
78
141
 
79
142
  ```bash
80
- SUBCONSCIOUS_BASE_URL=http://localhost:9999 subconscious claude-code
143
+ subc -p staging config \
144
+ --gateway-url https://staging.example \
145
+ --api-key sk-staging-... \
146
+ --model subconscious/glm-5.2
147
+
148
+ subc -p staging claude
149
+ subc -p staging cursor install
81
150
  ```
82
151
 
83
- ## Auth commands
152
+ You can also select one with `SUBC_PROFILE=staging`. Explicit shell variables
153
+ such as `SUBCONSCIOUS_API_KEY`, `SUBCONSCIOUS_BASE_URL`,
154
+ `SUBCONSCIOUS_MODEL`, and agent-specific tuning variables override profile
155
+ values. A command-line `--model` override has the highest model precedence.
84
156
 
85
- ### `login`
157
+ ## Models and endpoint overrides
86
158
 
87
- Opens your browser to sign in (or create an account). After authentication, your
88
- API key is automatically generated and saved.
159
+ List the available models with `subc models`:
89
160
 
161
+ ```text
162
+ subconscious/glm-5.2 (default)
163
+ subconscious/tim-qwen3.6-27b
164
+ subconscious/deepseek-v4-flash-marathon
90
165
  ```
91
- Terminal Browser
92
- │ │
93
- │ 1. Start local callback server │
94
- │ 2. Open browser ───────────────►│
95
- │ │ 3. Sign in / sign up via Clerk
96
- │ │ 4. API key auto-created
97
- │ 5. Receive key ◄────────────────│
98
- │ 6. Save to ~/.subcon/config.json│
99
- │ │ "You can close this tab"
100
- ✓ Logged in! │
166
+
167
+ Select a model per run, save it in the current profile, or override it through
168
+ the environment:
169
+
170
+ ```bash
171
+ subc codex --model subconscious/glm-5.2
172
+ subc config --model subconscious/deepseek-v4-flash-marathon
173
+ export SUBCONSCIOUS_MODEL=subconscious/glm-5.2
101
174
  ```
102
175
 
103
- ### `logout`
176
+ The Claude Code, Codex, OpenCode, Pi, and Copilot integrations register all
177
+ three models with their native model pickers. The profile's `MODEL` remains the
178
+ active model where the agent supports setting one and is listed first in the
179
+ other catalogs. Cursor requires adding the three model IDs in its OpenAI API
180
+ Key Override settings; `subc cursor install` prints the complete list and the model
181
+ selected by the active profile. Use the printed `/v1` Base URL in Cursor
182
+ Settings; the profile itself stores the gateway origin so correlation hooks can
183
+ post to `/v1/agent-hooks`.
184
+
185
+ The default gateway is `https://api.subconscious.dev`. Profiles containing
186
+ the former exact default (`https://api.subconscious.dev`) migrate automatically;
187
+ custom gateway URLs are preserved. Override the active gateway with
188
+ `SUBCONSCIOUS_BASE_URL`:
189
+
190
+ ```bash
191
+ SUBCONSCIOUS_BASE_URL=http://localhost:9999 subc claude
192
+ ```
193
+
194
+ Agent-specific runbook tuning variables are also honored, including
195
+ `CLAUDE_CODE_AUTO_COMPACT_WINDOW`, `CODEX_CONTEXT_WINDOW`,
196
+ `OPENCODE_CONTEXT_LIMIT`, `PI_CONTEXT_WINDOW`, and the corresponding output or
197
+ max-context settings. Extra `KEY=value` lines in the profile env file are
198
+ passed through the same way and override Subconscious-injected defaults.
199
+
200
+ ## Authentication
104
201
 
105
- Removes your saved API key.
202
+ `subc login` opens a browser, completes sign-in, and saves the generated API
203
+ key to the selected runbook profile with mode `600`. For the default profile it
204
+ also maintains `~/.subconscious/config.json`.
106
205
 
107
- ### `whoami`
206
+ ```bash
207
+ subc login
208
+ subc update-key sk-new-key-...
209
+ subc update-url https://api.subconscious.dev
210
+ subc whoami
211
+ subc logout
212
+ ```
213
+
214
+ `subc update-key <api-key>` replaces the shared key in the selected profile.
215
+ For `default`, it also synchronizes `~/.subconscious/config.json`:
108
216
 
109
- Shows your current authentication status and which key is active.
217
+ ```bash
218
+ subc update-key sk-new-default-key-...
219
+ subc --profile staging update-key sk-new-staging-key-...
220
+ ```
110
221
 
111
- ## Where keys are stored
222
+ Because command arguments may be retained in shell history, `subc login` is
223
+ preferred when obtaining a new key interactively. If `SUBCONSCIOUS_API_KEY` is
224
+ set, it continues to override the updated saved key.
112
225
 
113
- Keys are saved to `~/.subcon/config.json` with `600` permissions
114
- (owner-read-only). The file looks like:
226
+ `subc update-url <gateway-url>` validates the URL and automatically updates
227
+ `GATEWAY_URL` in the default profile. No `--profile` option or separate config
228
+ command is needed:
115
229
 
116
- ```json
117
- {
118
- "subconscious_api_key": "sk-..."
119
- }
230
+ ```bash
231
+ subc update-url https://api.subconscious.dev
120
232
  ```
121
233
 
122
- Environment variable `SUBCONSCIOUS_API_KEY` takes precedence over the config
123
- file handy for CI or temporary overrides.
234
+ If `SUBC_PROFILE` already selects a named profile, that active profile is
235
+ updated automatically as well.
236
+
237
+ `SUBCONSCIOUS_BASE_URL` continues to take precedence when set. A configured
238
+ `CLAUDE_GATEWAY_URL` remains a Claude-specific override.
239
+
240
+ `SUBCONSCIOUS_API_KEY` takes precedence over profile and saved config keys,
241
+ which is useful for CI and temporary sessions. `subc logout` clears the
242
+ selected profile's shared key while preserving its non-secret runbook settings;
243
+ logging out of `default` also clears the backwards-compatible saved key.
244
+
245
+ Existing credentials and profiles under `~/.subcon` are copied into
246
+ `~/.subconscious` automatically on first use. The legacy files are left in
247
+ place so migration is recoverable.