refactor(agents): configure dsh from its profile patch (#415)

This commit is contained in:
ryan4yin | 二花 authored and GitHub committed 2026-10-08 15:29:31 +08:00
1 parent 9e2633f496
commit 60bd70bd0c
8 files changed
+45 -172

No files matched your search

+4 -2
View File
@@ -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/<name>/cordis.patch.yml`. See [dsh.md](./dsh.md) for the layer order and the
settings that bite.
## Deployed rule targets
+41
View File
@@ -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/<name>/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 <profile> --dump-config # composed tree with every layer applied
dsh <profile> --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.
-63
View File
@@ -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/<name>/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/<name>/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.
-70
View File
@@ -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
-12
View File
@@ -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;
}
-5
View File
@@ -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.
@@ -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";
}
@@ -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;
}