From 60bd70bd0cd1dc3097f4df6c59a2c3b7f5ee03d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ryan4yin=20=7C=20=E4=BA=8C=E8=8A=B1?= Date: Thu, 8 Oct 2026 15:29:31 +0800 Subject: [PATCH] refactor(agents): configure dsh from its profile patch (#415) --- home/base/tui/agents/README.md | 6 +- home/base/tui/agents/dsh.md | 41 +++++++++++ home/base/tui/agents/dsh/README.md | 63 ----------------- home/base/tui/agents/dsh/cordis.patch.yml | 70 ------------------- home/base/tui/agents/dsh/default.nix | 12 ---- home/hosts/linux/idols-ruby.nix | 5 -- .../tests/home-manager-dsh/expected.nix | 5 -- .../tests/home-manager-dsh/expr.nix | 15 ---- 8 files changed, 45 insertions(+), 172 deletions(-) create mode 100644 home/base/tui/agents/dsh.md delete mode 100644 home/base/tui/agents/dsh/README.md delete mode 100644 home/base/tui/agents/dsh/cordis.patch.yml delete mode 100644 home/base/tui/agents/dsh/default.nix delete mode 100644 outputs/x86_64-linux/tests/home-manager-dsh/expected.nix delete mode 100644 outputs/x86_64-linux/tests/home-manager-dsh/expr.nix diff --git a/home/base/tui/agents/README.md b/home/base/tui/agents/README.md index a82c635d..613ae4c0 100644 --- a/home/base/tui/agents/README.md +++ b/home/base/tui/agents/README.md @@ -13,8 +13,10 @@ Nix dependency; this module only wires it into place. - `packages.nix`: agent CLIs (`codex`, `opencode2`, `pi`) from the `llm-agents` flake input, plus `pkgs.mcp-grafana` for the Grafana MCP server. - `env.nix`: telemetry and auto-update opt-outs for the agents. -- `dsh/`: the shared dsh home-layer patch linked to `~/.dsh/cordis.patch.yml`. See - [dsh/README.md](./dsh/README.md) for why the shared layer is linked and the profile patch is not. + +dsh is installed by this module but configured at runtime, not by Nix: profile patches live in +`~/.dsh/profiles//cordis.patch.yml`. See [dsh.md](./dsh.md) for the layer order and the +settings that bite. ## Deployed rule targets diff --git a/home/base/tui/agents/dsh.md b/home/base/tui/agents/dsh.md new file mode 100644 index 00000000..827ab50a --- /dev/null +++ b/home/base/tui/agents/dsh.md @@ -0,0 +1,41 @@ +# dsh configuration + +dsh is installed by this module (`packages.nix`) and configured at runtime, not by Nix. It boots a +profile: an ordered stack of patch layers over an empty root entry list, where later layers win. + +| # | Layer | Path | Writer | +| --- | --------- | -------------------------------------------- | --------------- | +| 1 | bundles | shipped with the profile | upstream | +| 2 | profile | `$DSH_HOME/profiles//cordis.patch.yml` | dsh, at runtime | +| 3 | home | `$DSH_HOME/cordis.patch.yml` | you | +| 4 | `--patch` | whatever the launcher passes | you | + +`$DSH_HOME` defaults to `~/.dsh`. Settings UI changes are written to the profile patch; a home-layer +row outranks it, so the UI rejects that setting with +`Configuration for "..." is overridden by a home patch`. This repository therefore ships no home +layer — profile patches are machine-local runtime state, the place for private endpoints (LAN +servers, staging gateways) too, and Nix only installs the CLI. + +Three behaviours that are easy to get wrong: + +- A patch row's `config` **replaces** the row's config object instead of deep-merging into it. + Repeat every key you mean to keep; the shipped `agent-loop` row repeats `agents: []` for this + reason. +- The web and desktop surfaces give each agent preset its own compaction service, so a top-level + `compaction-basic` row never reaches a session. Compact by setting the route's model + `contextWindow` and `maxTokens` instead. +- `dsh-llm-pi-ai` registers its providers once, so mount only one instance: a second one fails with + `provider "..." is already declared`. + +To see what your own patches actually change: + +```sh +dsh --dump-config # composed tree with every layer applied +dsh --dump-default-config # the same tree without the home layer or --patch overlays +``` + +The `dsh-base` bundle sets `agent-default-model` to the API-key route (`deepseek-official` / +`deepseek-flash`). The account route never falls back to an API key, so a host holding only +`DEEPSEEK_API_KEY` fails new sessions with `ACCOUNT_SIGN_IN_REQUIRED`. + +In this repository, `just dsh-web` boots the web profile through mihomo's mixed port. diff --git a/home/base/tui/agents/dsh/README.md b/home/base/tui/agents/dsh/README.md deleted file mode 100644 index 98a86262..00000000 --- a/home/base/tui/agents/dsh/README.md +++ /dev/null @@ -1,63 +0,0 @@ -# dsh - -Shared dsh (DeepSeek Harness) policy, linked into `~/.dsh/cordis.patch.yml`. - -## Layers - -dsh composes a profile from bundle patches, the profile's own `cordis.patch.yml`, then -`$DSH_HOME/cordis.patch.yml` (the "home" layer) and `--patch` overlays. The home layer is the only -one shared by every profile and surface, so the stable policy lives here. - -| Layer | Path | Writer | Tracked | -| ------- | ----------------------------------------- | ----------------------------- | ------- | -| home | `~/.dsh/cordis.patch.yml` | nix-config; dsh only reads it | yes | -| profile | `~/.dsh/profiles//cordis.patch.yml` | dsh, at runtime | no | - -dsh writes the profile patch but only reads the home layer, so linking the home layer is safe while -linking the profile patch would put runtime state in the checkout. Declared settings are edited -here, not in the Settings UI. - -## Which hosts deploy it - -A host only gets this link by importing the module. `home/linux/gui.nix` and `home/darwin` pull it -in through `home/base/tui`, so core-only servers miss it — `idols-ruby` installs dsh from -`environment.systemPackages` and imports `home/base/tui/agents/dsh` from its own home module. A new -host that ships dsh needs one of those two wirings. - -## Default model route - -`cordis.patch.yml` pins `agent-default-model` to the API-key route (`deepseek-official`). The -account route (`deepseek-account`) never falls back to an API key, so a host holding only -`DEEPSEEK_API_KEY` fails every freshly created session with `ACCOUNT_SIGN_IN_REQUIRED`. A host that -signs in instead can select an account model per session. - -## Compaction - -The web and desktop surfaces give each agent preset its own compaction service, so a top-level -`compaction-basic` row here never reaches a session. The effective knobs are the model -`contextWindow` and `maxTokens`: the `400000`/`32000` values set here place the first compaction -near 300k tokens. - -## Private and local model routes - -Endpoints that must not enter this repository — LAN/self-hosted servers and staging gateways — do -not belong in the home layer. Extend the base `llm-pi-ai` row from the profile patch instead: - -```yaml -# ~/.dsh/profiles//cordis.patch.yml -- id: llm-pi-ai - name: "@deepseek-ai/dsh-llm-pi-ai" - config: - providers: { ... } -``` - -`dsh-llm-pi-ai` registers its built-in providers once, so mount only one instance — a second one -fails with `provider "..." is already declared`. - -## Running it - -`just dsh-web` starts the harness without opening a browser and routes its outbound HTTP through -mihomo's mixed port. dsh's web fetch refuses a DNS answer it does not call public, and a fake-ip -resolver answers with `198.18.0.0/15`; a proxied hop lets mihomo resolve the origin instead, which -skips that check and leaves fake-ip acceleration intact. The policy reaches every Node fetch the -harness makes, so mihomo becomes a dependency for LLM, web search and HTTP MCP traffic too. diff --git a/home/base/tui/agents/dsh/cordis.patch.yml b/home/base/tui/agents/dsh/cordis.patch.yml deleted file mode 100644 index f9112073..00000000 --- a/home/base/tui/agents/dsh/cordis.patch.yml +++ /dev/null @@ -1,70 +0,0 @@ -# Shared dsh policy. Linked to ~/.dsh/cordis.patch.yml and applied as the -# $DSH_HOME ("home") layer, after each profile's own patch, so it covers every -# profile and surface. dsh only reads it — keep runtime preferences and local -# model routes in the profile patch (see README.md). -- id: agent-default-model - name: "@deepseek-ai/dsh-agent-default-model" - config: - provider: deepseek-official - model: deepseek-flash - reasoningEffort: high -- id: locale - name: "@deepseek-ai/dsh-client-locale" - config: - preference: zh -- id: agent-preset-registry - name: "@deepseek-ai/dsh-agent-preset-registry" - config: - default: standard - selectedDefault: ptc -- id: llm-deepseek - name: "@deepseek-ai/dsh-llm-deepseek-api-key" - config: - models: - - id: deepseek-flash - name: DeepSeek-V41-Flash - inputModalities: - - text - - image - systemPromptUpdate: in-history - toolUpdate: addition-only - contextWindow: 400000 - maxTokens: 32000 - - id: deepseek-v4-pro - name: DeepSeek-V4-Pro - description: - Stronger agentic coding, knowledge, and difficult reasoning; suited to complex or - quality-critical tasks at higher cost. - contextWindow: 500000 - inputModalities: - - text -- id: llm-deepseek-account - name: "@deepseek-ai/dsh-llm-deepseek-account" - config: - models: - - id: deepseek-flash - name: DeepSeek-V41-Flash - inputModalities: - - text - - image - systemPromptUpdate: in-history - toolUpdate: addition-only - contextWindow: 400000 - maxTokens: 32000 - - id: deepseek-v4-pro - name: DeepSeek-V4-Pro - description: - Stronger agentic coding, knowledge, and difficult reasoning; suited to complex or - quality-critical tasks at higher cost. - contextWindow: 500000 - inputModalities: - - text -- id: agent-loop - name: "@deepseek-ai/dsh-agent-loop" - config: - agents: [] - maxParallelToolCalls: 8 -- id: subagent - name: "@deepseek-ai/dsh-subagent" - config: - maxActiveSubagents: 3 diff --git a/home/base/tui/agents/dsh/default.nix b/home/base/tui/agents/dsh/default.nix deleted file mode 100644 index 68c915a1..00000000 --- a/home/base/tui/agents/dsh/default.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ - config, - ... -}: -let - # Out-of-store so repo edits apply without a rebuild (see README.md). - sharedPatch = "${config.home.homeDirectory}/nix-config/home/base/tui/agents/dsh/cordis.patch.yml"; -in -{ - # The shared dsh policy, read as $DSH_HOME/cordis.patch.yml. - home.file.".dsh/cordis.patch.yml".source = config.lib.file.mkOutOfStoreSymlink sharedPatch; -} diff --git a/home/hosts/linux/idols-ruby.nix b/home/hosts/linux/idols-ruby.nix index 7961b302..4577dfdf 100644 --- a/home/hosts/linux/idols-ruby.nix +++ b/home/hosts/linux/idols-ruby.nix @@ -2,11 +2,6 @@ imports = [ ../../linux/core.nix ../../linux/gui/i3 - # Ruby installs the dsh CLI system-wide from `hosts/idols-ruby/packages.nix` - # while running the core home stack, so it misses the agents module that the - # GUI hosts pull in through `home/linux/gui.nix`. Import just the dsh - # profile, which keeps its Settings-owned configuration in this repository. - ../../base/tui/agents/dsh ]; # Headless X11/i3 session for computer use. diff --git a/outputs/x86_64-linux/tests/home-manager-dsh/expected.nix b/outputs/x86_64-linux/tests/home-manager-dsh/expected.nix deleted file mode 100644 index 4fed1320..00000000 --- a/outputs/x86_64-linux/tests/home-manager-dsh/expected.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ - # The linked home-layer patch (see ../README.md). - keys = [ ".dsh/cordis.patch.yml" ]; - source = "/home/tester/nix-config/home/base/tui/agents/dsh/cordis.patch.yml"; -} diff --git a/outputs/x86_64-linux/tests/home-manager-dsh/expr.nix b/outputs/x86_64-linux/tests/home-manager-dsh/expr.nix deleted file mode 100644 index 1d8b65ec..00000000 --- a/outputs/x86_64-linux/tests/home-manager-dsh/expr.nix +++ /dev/null @@ -1,15 +0,0 @@ -# Evaluate the dsh module on its own: reading `home.file` from a real host would -# force the catppuccin theme derivations, turning an eval test into a build. -let - module = import ../../../../home/base/tui/agents/dsh/default.nix; - evaluated = module { - config = { - home.homeDirectory = "/home/tester"; - lib.file.mkOutOfStoreSymlink = path: path; - }; - }; -in -{ - keys = builtins.attrNames evaluated.home.file; - source = toString evaluated.home.file.".dsh/cordis.patch.yml".source; -}