Repository navigation
Conversation
DSH loads AGENTS.md at two scopes: the harness home ($DSH_HOME, default ~/.dsh) and, from the .git project root down to the cwd, each directory as the agent reaches it. It has no user-configurable command hook, so the only surface to configure is the instructions file; the `full` awareness block teaches the agent to prefix its own shell commands with `rtk`. - `rtk init --agent dsh` writes the block to ./AGENTS.md - `rtk init -g --agent dsh` writes it to $DSH_HOME/AGENTS.md - `--uninstall` removes the block and leaves user content intact - `dsh::is_configured` joins AGENT_PROBES, so a configured DSH suppresses the "No hook installed" warning The awareness note shared by every instructions-only agent moves to `init/mod.rs`, where the other cross-module helpers already live, so DSH reuses it instead of carrying a copy.
📊 Automated PR Analysis
SummaryAdds DeepSeek Harness (DSH) agent support to rtk init, writing an RTK awareness block into AGENTS.md (locally or at $DSH_HOME globally) since DSH has no configurable command hook. Also wires DSH into agent detection, the hook-configured probe list, and shares the instructions-only awareness note helper by moving it to init/mod.rs. Review Checklist
Analyzed automatically by wshm · This is an automated analysis, not a human review. |
|
Hey @KuSh 👋 small one for you: adds DeepSeek Harness to The one call I'd like a second opinion on: I left DSH out of engine/src/harness.rs — every field there is hook shaped and DSH has no tool-call hook, so a profile would promise read/deny/rewrite that doesn't exist. Happy to add one if you'd rather have the consistency. No rush, whenever you get a chance, thanks! |
|
A dsh-side rewrite path does exist — it is plugin shaped, not hook shaped. @nrenvo's read is right at the hook layer: DSH has no What DSH does expose to plugins is the shell capability itself: a plugin can wrap I built it on
On the question in the PR: I don't think DSH needs a Happy to share the plugin as a reference implementation if that is useful for the discussion. Reference implementation (MIT): https://github.com/ismoss/dsh-rtk — the wrapper, the exit-code handling and the token check, with the tests that came out of it. |
DSH's `tools/pre-execute` event is allow/deny only and cannot rewrite
`exec.arguments`. The only seam that can change a command's text before it
runs is `ctx.shell`, a cordis service every bash/pwsh tool call and
background job resolves through. A global install (`-g`, machine-level,
same scope as the plugin's own profile data) now installs a cordis plugin
(`hooks/dsh/rtk-rewrite/`) into every discovered DSH profile that patches
`ctx.shell.execute`, asks `rtk rewrite` for the RTK form, and swaps the
spawned command text when one is accepted. A project-local install (no
`-g`) is unchanged: only the AGENTS.md awareness block.
- `ctx.shell` is a cordis-tracked service proxy (a fresh wrapper per
access), so the patch targets the real instance behind
`Symbol.for("cordis.original")`, not whatever proxy a given access
returns.
- Only `rtk rewrite` exit 0/3 are accepted; a deny (exit 2) is left to
DSH's own permission system, never simulated.
- A rewrite is only applied when it is provably the original command with
one or more literal `rtk`/`rtk.exe` tokens inserted (tokenized on shell
operators), and when every inserted `rtk <name>` prefix names a
subcommand on a trusted whitelist that excludes host-sensitive aliases
(PowerShell's `ls` returns an object stream, not text).
- Install/uninstall operate on every profile under
`$DSH_HOME/profiles/` (a directory counts as a profile when it has its
own `package.json`, which excludes the shared pnpm-hoisted
`profiles/node_modules/`), writing the plugin package and appending one
idempotent `insert` entry to each profile's own `cordis.patch.yml`
without touching any other entry already there. Uninstall removes
exactly that.
- Known limitation documented in `hooks/dsh/README.md`: this is a
post-hoc substitution, not a real pre-execution hook, so DSH's session
history and UI still show the model's original command; a persistent
terminal (pty) session does not go through `ctx.shell` at all and is
never rewritten.
Testing:
- `cargo fmt --all && cargo fmt --manifest-path proxy/Cargo.toml --all`
- `cargo clippy --all-targets`: no warnings
- `cargo test --lib`: 4551 passed, 0 failed (33 new DSH tests)
- `cargo test --all`: no new failures (3 pre-existing failures in
`guard_integration_test`/`ng_build_test`, confirmed present on
`develop` before this change, environment-dependent and unrelated)
- `node --test hooks/dsh/rtk-rewrite/rtk.test.mjs`: 33 passed
- Manual: install/uninstall/dry-run/idempotency against an isolated
`$DSH_HOME`
- Manual, against this machine's real DSH desktop app (installed, HMR
reload observed within seconds, no restart needed, then fully
uninstalled and the profile files diffed back to their original
content): a live, unprefixed `git status` from this machine's actual
DSH bash tool was intercepted and rewritten to `rtk git status`
(confirmed via the plugin's own rewrite log); a live `grep -rn <pat>
<file>` chained after `cd` with `&&` was rewritten to `cd ... && rtk
grep -rn <pat> <file>` (only the grep side changed); `echo hello` was
left unchanged, confirming the whitelist/no-rewrite path is not a
pass-through bug.
…upport # Conflicts: # src/lib.rs
…upport # Conflicts: # hooks/README.md
|
Read through the plugin and it matches the design this thread converged on, so no design concerns from me — it is the right seam and the right guard. Three small things from running the same approach against dsh 0.2.1-rc.3 on Windows for a few days, take or leave:
|
|
Thanks for the thoughtful feedback and the Windows testing! I've added a conservative fast path for simple commands to avoid unnecessary |
|
A concrete failure mode in the installer, from a week of running the same design on Windows — worth fixing before this ships, because it fails silently. Writing the package into That is not hypothetical: it happened to my equivalent package today (2026-11-06) on dsh 0.2.1-rc.3 / Windows. What made it stick: declare it as a dependency of the profile instead of copying it, which is also how the other locally-developed plugins in a profile are mounted: "dependencies": {
"rtk-rewrite": "link:C:/Users/<user>/.dsh/plugins/rtk-rewrite"
}then Two follow-ups this implies:
|
|
AGENTS.md can be much leaner, since rtk-rewrite already handles command rewriting, there is no need to repeat rtk usage instructions there. It only needs to tell the agent how to bypass rtk (using |
KuSh
left a comment
There was a problem hiding this comment.
Round 1 of 3 — CHANGES REQUESTED
Claim: rtk init [-g] --agent dsh adds the RTK block to AGENTS.md (project or $DSH_HOME), and with -g installs a cordis plugin into every DSH profile that rewrites ctx.shell commands through rtk rewrite.
Scope: accept if narrowed to "rtk init [-g] --agent dsh [--uninstall] manages the RTK block in ./AGENTS.md or $DSH_HOME/AGENTS.md" (round 1, frozen). The plugin moves to #5343 with the rows measured below: on a stock DSH 0.2.2-rc.5 profile it stops DSH from starting, and pnpm ≥ 11 removes it on the next plugin install. That is more than one round can verify. #3934 makes the same narrowed claim on a layout that no longer merges, so this PR is the one to keep. Maintainer PRs: checked against #4653, #3875, #4458 and #5100; all merge clean with develop + this PR.
Ran: real DSH 0.2.2-rc.5 in Docker, driven through a mock OpenAI endpoint. 8 tool-call commands with the plugin and without it; install, HMR, uninstall and fail-open; plugin durability across dsh plugin add and pnpm install with pnpm 10, 11 and 12. rtk init local, -g, --dry-run, repeat and --uninstall on head vs merge-base. rtk rewrite and rtk hook check --agent dsh on 25 commands; the missing-hook warning with and without this PR. Invariants: non-default targets ($DSH_HOME, two profiles, CRLF and comment-tail patch files), under the hook, every decision. Savings n/a: no filter added.
Pins: Rust: 22 decisions mutated, 7 survived. JS plugin: 30 mutated, 11 survived (4 of them equivalent on real rtk rewrite output). The survivors inside the narrowed claim are listed under item 2; the rest went into #5343.
Matrix: executed this round; pin check: executed this round
CI @8e6b3bc1: all green. Locally, develop + this PR: fmt, clippy, 5986 tests pass.
Blocks merge (2, frozen at round 1)
src/hooks/hook_check.rs:29— a rules-file install counted as an active hook.dsh::is_configuredreturns true for any./AGENTS.mdthat carries the RTK block.rtk init --agent kimiwrites the same block, andis_any_agent_configured()suppresses Claude Code's missing-hook warning. So a Claude Code user without the hook, working in a project where Kimi or DSH instructions were installed, no longer sees[rtk] /!\ No hook installed. On develop the warning prints (same HOME with~/.claudeand no hook, same project,rtk git status):[rtk] /!\ No hook installed — run rtk init -g …. With this PR, nothing. Kimi, Kilo Code and Cline are rules-file agents and none of them is inAGENT_PROBES. Must satisfy: that row prints the warning again, and a test pins it.src/lib.rs:2395andsrc/lib.rs:3102— unpinned behaviour (-grouting). Evidence:uninstall_dsh(global, …)→uninstall_dsh(false, …)passes 4628/4628, and so doesrun_dsh_mode(global, …)→run_dsh_mode(false, …). Thedsh.rstests call the*_athelpers with a path, so nothing checks that-greaches$DSH_HOME. Test must: runrtk init -g --agent dsh, thenrtk init -g --agent dsh --uninstall, withDSH_HOME=<scratch>and the current directory set to another scratch dir. Install writes<DSH_HOME>/AGENTS.mdand leaves the current directory untouched; uninstall removes the block from<DSH_HOME>/AGENTS.md. Both mutations must turn it red.
Filed as follow-ups
- #5343 DSH: rewrite commands through a cordis plugin — cut by the narrowed claim. It carries:
- the boot failure:
append_dsh_patchappends block YAML after the[]that DSH ships, and DSH then exits onfailed to parse overlay …/cordis.patch.yml: YAMLException … (6:1); - the pnpm ≥ 11 pruning: the plugin goes to
.ignored/or is deleted, the patch entry stays, DSH logsCannot find package 'rtk-rewrite', and rerunning init reports success; rtk hook check --agent dshdisagreeing with the plugin on 3 of 5 commands;- the surviving mutations.
- the boot failure:
Checked and correct — no need to re-verify
- The AGENTS.md block, local and
-g: created when the file is missing; user content kept; repeat is a no-op;--dry-runwrites nothing; uninstall removes exactly the block. $DSH_HOMEtakes precedence over~/.dsh.- A local install touches no profile.
dshasRulesOnlyindecision.rsmatches the narrowed claim.- Moving
print_instructions_agents_awareness_notetoinit/mod.rschanges no output. - The CI matrix is green, and develop + this PR passes fmt, clippy and the full suite.
Your questions
- "I left DSH out of engine/src/harness.rs … Happy to add one if you'd rather have the consistency." → Drop it. After the narrowing nothing hook-shaped is installed, so leaving the row out is the accurate profile.
Next
To merge: the narrowed claim (drop the plugin, hooks/dsh/, the profile code and the plugin parts of the README), plus items 1 and 2. The plugin work and the rows it has to pass are in #5343.
Rounds: 1/3. Threads: 2 open (waiting on the author), 0 resolved this round.
| super::init::opencode::is_configured, | ||
| super::init::codex::is_configured, | ||
| super::init::droid::is_configured, | ||
| super::init::dsh::is_configured, |
There was a problem hiding this comment.
Item 1: this probe counts any local AGENTS.md that carries the RTK block as an active hook. rtk init --agent kimi writes the same block, so in such a project Claude Code's [rtk] /!\ No hook installed warning no longer prints (it does on develop). Kimi, Kilo Code and Cline are rules-file agents and none of them is in AGENT_PROBES. Must satisfy: with ~/.claude present and no hook, rtk git status in a project whose AGENTS.md has the RTK block prints the warning again, and a test pins it.
| hooks::init::uninstall_vibe(ctx)?; | ||
| Ok(0) | ||
| } else if agent == Some(AgentTarget::Dsh) { | ||
| hooks::init::uninstall_dsh(global, ctx)?; |
There was a problem hiding this comment.
Item 2: uninstall_dsh(global, ctx) → uninstall_dsh(false, ctx) passes 4628/4628. A test that runs rtk init -g --agent dsh --uninstall with DSH_HOME=<scratch> and the current directory set to another scratch dir must assert the block is removed from <DSH_HOME>/AGENTS.md, and this mutation must turn it red.
| } else if agent == Some(AgentTarget::Vibe) { | ||
| hooks::init::run_vibe_mode(global, hook_only, patch_mode, ctx)?; | ||
| } else if agent == Some(AgentTarget::Dsh) { | ||
| hooks::init::run_dsh_mode(global, ctx)?; |
There was a problem hiding this comment.
Item 2: run_dsh_mode(global, ctx) → run_dsh_mode(false, ctx) passes 4628/4628; the dsh.rs tests call the *_at helpers with a path. A test that runs rtk init -g --agent dsh with DSH_HOME=<scratch> and the current directory set to another scratch dir must assert <DSH_HOME>/AGENTS.md gets the block and the current directory stays untouched, and this mutation must turn it red.
…_PROBES/global-routing coverage Round 1 review on rtk-ai#4809 (KuSh) asked to narrow this PR to "rtk init [-g] --agent dsh [--uninstall] manages the RTK block in AGENTS.md" and move the cordis plugin (hooks/dsh/rtk-rewrite/) to a follow-up issue: on a stock DSH profile it fails to parse and pnpm >= 11 prunes it silently, more than one round can verify. - Drop the plugin install/uninstall code, hooks/dsh/rtk-rewrite/, and the plugin parts of hooks/dsh/README.md and hooks/README.md. - Remove dsh::is_configured from AGENT_PROBES: it only checks for the shared AGENTS.md marker block, which Kimi/Kilo Code/Cline also write, so it could silence a Claude Code user's missing-hook warning in a project that only has one of those rules-file agents configured. Kimi etc. were never probed for the same reason; DSH now follows the same precedent. Added a hook_check test pinning that a Kimi or DSH block alone does not suppress the warning. - Added an integration test pinning rtk init -g --agent dsh's routing to $DSH_HOME (and its uninstall counterpart), since the existing dsh.rs unit tests only exercise the *_at helpers directly and never the global branch's own home resolution.
Pushed — dropped the plugin per your call (filed as #5343), dropped dsh::is_configured from AGENT_PROBES, and pinned both gaps with tests (Kimi/DSH suppression + -g routing). Thanks for the thorough round 1, let me know if anything's still off! |
Summary
Adds DeepSeek Harness to rtk init, in two parts.
Part 1 (original scope): DSH reads AGENTS.md at the harness home ($DSH_HOME, default ~/.dsh) and every directory from the project root down to the cwd. It has no command hook, so the instructions file is the only surface. rtk init --agent dsh writes to ./AGENTS.md, rtk init -g --agent dsh writes to $DSH_HOME/AGENTS.md, --uninstall removes it and keeps user content.
Part 2 (this update): DSH's tools/pre-execute event is allow/deny only, it can't rewrite the command text. The only seam that can change a command before it runs is ctx.shell, a cordis service every bash/pwsh call resolves through. A global install (-g) now also installs a cordis plugin into every DSH profile that patches ctx.shell.execute, asks rtk rewrite for the RTK form, and swaps the command before it spawns. Local install is unchanged, AGENTS.md only, since the plugin is machine level config.
Safety: only accepts an allow or ask rewrite from rtk rewrite, verified to be the original command with just an rtk prefix inserted and nothing else changed, and only for a whitelisted set of subcommands. A deny is left to DSH's own permission system.
Known limitation, documented in hooks/dsh/README.md: this is a post hoc substitution not a real pre execution hook, so DSH's own session history and UI still show the original command. A persistent terminal session doesn't go through ctx.shell and is never rewritten.
Test plan
Closes #3847