Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
48f7848
feat(flags): add the Code Mode flag
dean0x Nov 18, 2026
b8ec662
feat(code-mode): centralize local checks
dean0x Nov 18, 2026
2273c72
feat(flags): guard Code Mode enables
dean0x Nov 18, 2026
9541741
feat(proxy): guard enable with Code Mode on
dean0x Nov 18, 2026
5ea183d
feat(init): warn about Code Mode blockers
dean0x Nov 18, 2026
3f52715
docs: document the Code Mode flag
dean0x Nov 18, 2026
0241a51
fix: address self-review issues
dean0x Nov 18, 2026
c7f498e
test: unmock flags view after each test
dean0x Nov 18, 2026
16480bc
docs(knowledge): update installer-shadowing-wizard-flags feature know…
dean0x Nov 19, 2026
6eb1f4a
docs(knowledge): update external-model-routing feature knowledge base
dean0x Nov 19, 2026
15c8fbf
test: cover Code Mode flag guard paths
dean0x Nov 19, 2026
b4b9e81
fix(proxy): bound status reads of settings
dean0x Nov 19, 2026
eb65b84
docs: state the result of a file close error
dean0x Nov 19, 2026
e8027c6
docs: clarify Code Mode tool call rules
dean0x Nov 19, 2026
9beb458
test: pin Code Mode and proxy read errors
dean0x Nov 19, 2026
6feb6b7
docs(knowledge): update external-model-routing feature knowledge base
dean0x Nov 19, 2026
820c985
Merge remote-tracking branch 'origin/main' into feat/code-mode-direct
dean0x Nov 19, 2026
dcc4a18
Merge remote-tracking branch 'origin/main' into feat/code-mode-direct
dean0x Nov 22, 2026
3070d8b
test(reader): check file handle failures
dean0x Nov 22, 2026
6097b5c
fix(proxy): reject non-object state roots
dean0x Nov 22, 2026
d2943fb
fix(flags): refuse unreadable settings
dean0x Nov 22, 2026
d508c9c
docs(changelog): note the flags settings-file limit
dean0x Nov 22, 2026
e117014
Merge remote-tracking branch 'origin/main' into feat/code-mode-direct
dean0x Nov 22, 2026
4afd1e2
Merge remote-tracking branch 'origin/main' into feat/code-mode-direct
dean0x Nov 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions .devflow/features/external-model-routing/KNOWLEDGE.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .devflow/features/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
- **installer-shadowing-backups** — src/targets/claude-code, src/cli/commands, src/core — Use when changing the install backup session, shipped set, retired name lists, folder swaps or the bare legacy skill hash gate. Keywords: install-backups, retired, hash gate, swap.
- **installer-shadowing-init-seed** — src/cli/commands, src/core — Use when changing init seeding (resolveInitSeed, resolveSeed*, --reset), manifest self-heal, writeManagedConfig, queue drain, --hud-only, proxy preflight order or migrations. Keywords: init-seed, manifest.
- **installer-shadowing-init-artifacts** — src/targets/claude-code, src/assets/scripts/hooks — Use when changing DEVFLOW_GITIGNORE_BLOCK, computeDevflowGitignore, ensure-root-gitignore or init's CLAUDE.md import audit and stamp. Keywords: gitignore carve-out, claudeignore, audit stamp.
- **installer-shadowing-wizard-flags** — src/cli, src/core — Use when changing prompt-io, the compliance, attribution or gate-level wizard step, init --gate-level, the flags CLI/TUI, convergeFlagsIntoSettings or settingHoldsManagedShape. Keywords: wizard, flags, TUI, gate level.
- **installer-shadowing-wizard-flags** — src/cli, src/core — Use when changing a wizard step, init --gate-level, the flags CLI/TUI, convergeFlagsIntoSettings, settingHoldsManagedShape or the code-mode flag. Keywords: wizard, flags, TUI, gate level, Code Mode, proxy.
- **installer-shadowing-tracker-wiring** — src/core, src/cli, src/targets — Use when changing the tracker wizard step, devflow tracker (--set/--status), the Tracker agent install, the manifest tracker group or init's tracker convergence. Keywords: tracker, provider, sentinel.
- **curation-capture-system** — src/assets/scripts/hooks, src/core, src/cli, src/hud — Use when changing the capture hooks, memory/curation queues, machine feature switches or ledger root, or choosing which curation KB to read. Keywords: capture-prompt, queue-append, manifest.json, DF_LEDGER_ROOT.
- **curation-capture-system-store** — hooks/lib, json-helper, core/curation-store — Use when changing curation-store.cjs, a json-helper curation op, the observation or ledger schema, the one lock, or rendered decisions.md, pitfalls.md and index.md. Keywords: put-observation, assign-anchor.
Expand Down
142 changes: 77 additions & 65 deletions .devflow/features/installer-shadowing-wizard-flags/KNOWLEDGE.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- **Experimental Code Mode flag.** Use `devflow flags --enable code-mode` for direct Claude Code sessions. The flag is off by default. This change applies to new sessions only. Code Mode does not start while the Devflow proxy or `disable-nonessential-traffic` is on. `devflow flags` does not change a user `settings.json` that is over 1 MiB or is not valid UTF-8, and leaves the file as it is.
- The HUD can show a Claude week quota forecast from the current session's data. The forecast is off by default and needs no tokenmeter data. Run `devflow hud --forecast` to turn it on. Run `devflow hud --no-forecast` to turn it off. Devflow saves your choice in the `forecast` field of `~/.devflow/hud.json`. When the HUD and the forecast are on, the HUD adds the `weekForecast` component.
- **Parallel sessions.** Working memory pairs turns within each session. If two sessions write the same note, in one batch or in separate batches, the note header flags the shared note for four hours. Use one worktree for each parallel session.

Expand Down
16 changes: 12 additions & 4 deletions docs/cli-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ npx devflow-kit flags --unset <ids> # Reset flag(s) to neutral, comma-separ

`--enable` and `--disable` accept boolean flags only. Non-boolean flags (enum, number, string) use `--set id=value`. Passing a non-boolean id to `--enable`/`--disable` prints an error and redirects to `--set`.

All 32 flags by kind and devflow default:
All 33 flags by kind and Devflow default:

| Flag ID | Kind | Target | Devflow Default |
|---------|------|--------|-----------------|
Expand All @@ -507,7 +507,7 @@ All 32 flags by kind and devflow default:
| `brief` | boolean | env `CLAUDE_CODE_BRIEF` | `false` |
| `thinking-summaries` | boolean | setting `showThinkingSummaries` | `false` |
| `subprocess-env-scrub` | boolean | env `CLAUDE_CODE_SUBPROCESS_ENV_SCRUB` | `false` |
| `disable-nonessential-traffic` | boolean | env `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` | `false` |
| `disable-nonessential-traffic` | boolean | env `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` | `false` (Code Mode does not start if this flag is on) |
| `forked-subagents` | boolean | env `CLAUDE_CODE_FORK_SUBAGENT` | `false` |
| `disable-adaptive-thinking` | boolean | env `CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING` | `false` |
| `always-thinking` | boolean | setting `alwaysThinkingEnabled` | `false` |
Expand All @@ -516,6 +516,7 @@ All 32 flags by kind and devflow default:
| `disable-1m-context` | boolean | env `CLAUDE_CODE_DISABLE_1M_CONTEXT` | `false` |
| `disable-autoupdater` | boolean | env `DISABLE_AUTOUPDATER` | `false` |
| `agent-teams` | boolean | env `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS` | `false` |
| `code-mode` | boolean | env `CLAUDE_CODE_EXPERIMENTAL_CODE_MODE` | `false`⁶ |
| `enable-todo-tools` | boolean | env `CLAUDE_CODE_ENABLE_TODO_TOOLS` | `false` |
| `suppress-attribution` | boolean | setting `attribution` | `false` ²|
| `subagent-spawn-depth` | number | env `CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH` | unset (upstream: 3) |
Expand All @@ -537,6 +538,13 @@ All 32 flags by kind and devflow default:

⁵ `subagent-cache-5m` writes `"5m"`, so subagents write 5-minute prompt-cache entries while the main session keeps the 1-hour TTL of `prompt-caching-1h`. Disabling or uninstalling deletes the key only when it holds `"5m"`. When the key already holds another value (say `"1h"`), `devflow init` and the flags TUI record the flag off and keep your value; `init --reset` writes `"5m"`.

⁶ `code-mode` is experimental and off by default. This change applies to new sessions only. Code Mode does not work with `claude -p`. Deny rules, ask rules, and `PreToolUse` hooks still apply to each tool call.

- **Blockers.** Code Mode does not start with the Devflow proxy or `disable-nonessential-traffic` on. A custom `ANTHROPIC_BASE_URL`, `apiKeyHelper`, `ANTHROPIC_AUTH_TOKEN`, or OpenTelemetry export also blocks Code Mode. Code Mode with `agent-teams` needs Claude Code v2.1.326 or later.
- **User settings only.** Claude Code reads the enable value only from `env` in user settings. A `0` in the shell or in any settings file takes priority. A project setting cannot turn Code Mode on. Devflow checks only local state and the user settings `env`, not shell exports or project settings.
- **Values Devflow keeps.** Devflow writes `"1"` to enable Code Mode. If the key has a different value, Devflow keeps your value and records `code-mode` off on the next flag write. An explicit request to turn `code-mode` on can replace that value. Devflow removes the key only if it holds `"1"`.
- **Refusals and warnings.** Devflow refuses to turn `code-mode` on while the Devflow proxy is on. Run `devflow proxy --disable` first. Devflow warns about the proxy and `disable-nonessential-traffic` only while Code Mode is on. Devflow does not check the other blockers. If both Code Mode and the proxy are on after proxy preflight, `devflow init` warns and keeps both on.

## External Model Routing (Devflow Proxy)

Route Devflow agents through GPT models via your OpenAI/Codex subscription. When enabled, a local Devflow proxy relay intercepts agent requests and forwards them to the configured model.
Expand All @@ -552,9 +560,9 @@ npx devflow-kit proxy --enable --port <n> # Enable on a specific port (default:

| Option | Description |
|--------|-------------|
| `--enable` | Enable routing — runs preflight, writes `~/.devflow/proxy.json` and `~/.devflow/proxy-routing.json`, starts and verifies the relay, injects `ANTHROPIC_BASE_URL` and `CLAUDE_CODE_DISABLE_UNKNOWN_MODEL_WINDOW_ENFORCEMENT` into `settings.json`, applies saved agent model mapping |
| `--enable` | Enable routing — runs preflight, writes `~/.devflow/proxy.json` and `~/.devflow/proxy-routing.json`, starts and verifies the relay, injects `ANTHROPIC_BASE_URL` and `CLAUDE_CODE_DISABLE_UNKNOWN_MODEL_WINDOW_ENFORCEMENT` into `settings.json`, applies saved agent model mapping. If Code Mode is on, this command refuses the change. Run `devflow flags --disable code-mode` first. |
| `--disable` | Disable routing — reverts agent frontmatter to Claude defaults, removes env override; mapping is preserved for re-enable; the relay process is left running for live sessions (a manual `kill <pid>` hint is shown) |
| `--status` | Show feature state (enabled/disabled, port), relay process and PID, `ANTHROPIC_BASE_URL` and `CLAUDE_CODE_DISABLE_UNKNOWN_MODEL_WINDOW_ENFORCEMENT` env state, Codex auth content (not just existence), external-mapped agent count, cached model registry, and proxy log path |
| `--status` | Show feature state (enabled/disabled, port), relay process and PID, `ANTHROPIC_BASE_URL` and `CLAUDE_CODE_DISABLE_UNKNOWN_MODEL_WINDOW_ENFORCEMENT` env state, Codex auth content (not just existence), external-mapped agent count, cached model registry, and proxy log path. Warn about the proxy or `disable-nonessential-traffic` only while Code Mode is on. |
| `--port <n>` | Override the relay port (default 4141); takes effect on next enable |

Takes effect in new Claude Code sessions after `--enable`. The relay auto-starts on `SessionStart` via the `ensure-proxy` hook; `UserPromptSubmit` exits immediately with no action (SessionStart handles all relay-start and warning logic). Routing state is stored in `~/.devflow/proxy.json`; per-agent model mapping in `~/.devflow/agent-models.json`.
Expand Down
3 changes: 2 additions & 1 deletion docs/reference/file-organization.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ devflow/
│ │ ├── paths.ts # getPackageRoot + asset path helpers
│ │ ├── assets.ts # skillsDir, agentsDir, rulesDir, scriptsDir, commandsDir,
│ │ │ # compiledAgentsDir, agentSourceDirs (dist-first order owner)
│ │ ├── flags.ts # Claude Code flag registry (32 flags)
│ │ ├── flags.ts # Claude Code flag registry (33 flags)
│ │ ├── code-mode.ts # Code Mode checks, warnings, and refusal messages
│ │ ├── fs-atomic.ts # Atomic write helper (D34)
│ │ ├── claude-md-audit.ts # Typed seam onto scripts/claude-md-audit.cjs: roots, the one init note, the stamp write (lstat-checked)
│ │ ├── manifest.ts # Manifest read/write
Expand Down
11 changes: 11 additions & 0 deletions docs/reference/proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,14 @@ External model routing: running Devflow agents on GPT models through a local rel
## External Model Routing

**External Model Routing (Devflow Proxy)**: Routes Devflow agents through GPT models via an OpenAI/Codex subscription using a local relay. Feature state is manifest-gated (like ambient/hud/rules): `manifest.features.proxy` is the source of truth; `~/.devflow/proxy.json` holds runtime authority (enabled, port, binPath, configPath, resolvedAt, devflowVersion). `~/.devflow/proxy-routing.json` holds the routing config; `buildRoutingConfigJson` writes port-only on a fresh write (no `anthropic` block injected — the relay's own default governs); user-set keys in `logLevel`/`anthropic`/`providers`/`limits` blocks are preserved from existing content; the 0.4.0 routing runtime rejects unrecognised top-level keys and hard-fails on registered legacy keys — `anthropic.streamIdleTimeoutMs`, `limits.connectTimeoutMs`, `limits.maxConcurrentRequests`, `limits.maxBodyBytes`, `limits.maxUpstreamSockets`, `limits.streamIdleTimeoutMs`, `limits.requestTimeoutMs`, `limits.maxSseEventBytes` — which `buildRoutingConfigJson` strips. The `ensure-proxy` hook (SessionStart + UserPromptSubmit, registered/removed by `addProxyHooks`/`removeProxyHooks`) auto-starts the relay when a session begins; hook removal is unconditional on disable. `ANTHROPIC_BASE_URL` and `CLAUDE_CODE_DISABLE_UNKNOWN_MODEL_WINDOW_ENFORCEMENT` are injected into (and stripped from) `settings.json` at CLI enable/disable time via `applyProxyEnv`/`applyProxyTeardownToSettings`, not by the hook; env stripping is evidence-gated on `~/.devflow/proxy.json` existing (`proxyJsonExists()`); the URL delete is port-scoped to avoid clobbering foreign gateways; preflight refuses a foreign `ANTHROPIC_BASE_URL` before adopting a healthy relay; the `ensure-proxy` hook re-resolves a missing `binPath` before warning. Toggle via `devflow proxy --enable/--disable/--status` or via the Advanced init wizard. Enabling runs `runProxyPreflight` (4 checks: bin, codex auth, port, settings), spawns the relay, then gates on a post-spawn doctor verification against the live relay (doctor requires a running relay to pass); on doctor failure the enable rolls back, killing the relay only if it spawned it. Init runs the same preflight but never spawns or runs doctor — the first session's ensure-proxy hook starts the relay; on init preflight failure: warning + force-disabled, init never aborted. Disabling reverts agent frontmatter to Claude defaults but preserves the model mapping for re-enable. Default OFF; Advanced-only — never part of Recommended defaults.

## Code Mode

Code Mode needs a direct Claude Code session. It does not start while the Devflow proxy is on.

- To turn Code Mode on, first run `devflow proxy --disable`.
- If Code Mode is on, `devflow proxy --enable` refuses the change. First run `devflow flags --disable code-mode`.
- `devflow proxy --status` warns about the proxy and `disable-nonessential-traffic` only while Code Mode is on.
- If both Code Mode and the proxy are on after proxy preflight, `devflow init` warns and keeps both on.

See [Feature Flags](../cli-reference.md#feature-flags) for the other Code Mode blockers.
Loading
Loading