Skip to content

DSH: rewrite commands through a cordis plugin (follow-up to #4809) #5343

Backlog

Description

@KuSh

#4809 is narrowed to the AGENTS.md part of rtk init --agent dsh. This issue keeps the rewrite plugin it also shipped (hooks/dsh/rtk-rewrite/, which wraps ctx.shell.execute and calls rtk rewrite), with what was measured on a real DeepSeek Harness 0.2.2-rc.5 (Docker, mock OpenAI endpoint, head 8e6b3bc).

Once DSH has loaded it, the plugin works: git status, git log -3, cd sub && git status and git status && echo done ran as rtk … (they show in rtk gain --history). HMR picks up both install and uninstall within about 4 s, and with no rtk on PATH the original command runs.

What an integration has to pass first:

  1. Boot on a stock profile. DSH creates profiles/<name>/cordis.patch.yml as three comment lines followed by []. Appending a block - insert: after that gives invalid YAML. On its next start DSH exits with failed to parse overlay …/cordis.patch.yml: YAMLException: end of the stream or a document separator is expected (6:1). The file has to be edited as YAML, not as text. That also covers removing an entry the user has extended with config:, and a file saved with CRLF line endings.
  2. Survive the profile's package manager. The package is copied into <profile>/node_modules/rtk-rewrite without being declared. With pnpm 11.29 and 12.23, the next dsh plugin add <x> or pnpm install moves it to node_modules/.ignored/ or deletes it, and the patch entry stays behind. DSH then logs rtk-rewrite (rtk-rewrite): failed to import: … Cannot find package 'rtk-rewrite' and commands run unrewritten. Rerunning rtk init -g --agent dsh reports a normal install without mentioning that the plugin had been missing. pnpm 10.34 keeps it. Declaring it as a profile dependency was suggested on feat(init): add DeepSeek Harness (DSH) agent support #4809 but has not been measured.
  3. Agree with rtk hook check --agent dsh. The plugin decides on its own whether to apply the rewrite: a whitelist, an insertion-only token check, and the original command on a deny. On 3 of 5 commands hook check reports a rewrite the plugin does not apply (git push under a deny rule, git status && ls -la, cat README.md). Either the diagnostic models the plugin, or those decisions move into rtk rewrite.
  4. Pin its decisions. These mutations still pass the plugin's 35 tests: removing the isSafeRewrite gate in apply; whitelist every → some; a catch that rethrows; no timeout (the timeout test's mock exits 0 with empty stdout, so it passes either way); patching ctx.shell without cordis.original. On the Rust side: --uninstall --dry-run deleting the plugin directory and rewriting the patch for real, and the - id: rtk-rewrite exact-line match.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions