dsh-web
zhu1090093659/dsh-webDeepSeek Harness(DSH)Web 插件聚合生态包 · 一切皆插件,创意工坊分发(dsh-market.com)
The ast_grep (structural code search) and ast_edit (structural rewrite) tools for DeepSeek Harness over the packaged ast-grep native engine.
[!NOTE]
📦 This plugin lives in the dsh-plugins monorepo — file issues & pull requests there.
npm: @hy-sde-org/dsh-tool-astA standalone package, installable as one plugin (two tools) for the DeepSeek Harness CLI:
package · tools · installed by users? @hy-sde-org/dsh-tool-ast · ast_grep (structural code search) + ast_edit (structural rewrite, preview-first) · yes
ast_grep and ast_edit are a full parity port of oh-my-pi's coding-agent ast tools onto the harness tool contract (ctx.tools, ctx.fs, ctx.subprocess, ctx.systemPrompt). The engine is the packaged `@ast-grep/cli` native binary — it ships inside the npm dependency, so the plugin works on stock DeepSeek Harness deployments with zero upstream changes and no system ast-grep install.
class, or declaration matching a tree pattern instead of a text substring: console.log($MSG) finds every console.log call, fn($X) finds every function fn with one argument. Patterns bind metavariables ($NAME, $_, $$$NAME) so a search can be turned directly into a rewrite.
with a template that references the captured metavariables (console.log($MSG) → log.debug($MSG)). It always PREVIEWS first (apply defaults to false); pass apply: true to write the files. Rewrites are 1:1 structural substitutions — never text search-and-replace.
Both share one engine, one error vocabulary (AST_*), one set of caps, and one filesystem seam — which is why they ship in one package rather than two.
edit toolFor coding agents, edit (targeted, literal, line-anchored text changes) and ast_edit (structural AST changes) are complementary, not alternatives:
· edit / ast_edit in omp · edit / ast_edit in this package pairing · auto-added together when edit is requested · both tools ship in this one package apply model · edit applies directly; ast_edit previews + staged resolve · ast_edit previews by default; apply: true writes guidance · "For one-off text edits, prefer the Edit tool" · idiomatic: ast_edit for codemods → edit for follow-ups
Both mutation paths write through the same ctx.fs seam (observation watermark, version guard, sandbox policy), so they compose safely in one session. The harness companion-preset pattern (code-edit) mounts a rich edit beside ast_edit; this package's bundle (below) provides read/write beside ast_grep/ast_edit, and can be pointed at the rich @hy-sde-org/dsh-tool-edit if you want the full editor.
Text grep answers "where does this string appear"; an AST pattern answers "where does this code shape appear". ast_grep matches tree structure — console.log($MSG) finds every console.log call, fn($X) every one-argument call to fn — so a codemod cannot be missed because of formatting or string coincidence. Because patterns bind metavariables ($NAME, $_, $$$NAME), the match that found the problem turns directly into the fix: ast_edit rewrites every matched node with a template referencing the captures, always previews first (apply defaults to false), and writes only on apply: true — a 1:1 structural substitution, never a text search-and-replace.
For coding agents this is complementary to the edit tool, not an alternative: the idiomatic flow is ast_edit for codemods, edit for follow-ups. Both mutation paths write through the same ctx.fs seam, so they compose safely in one session — the relationship is detailed under *Relationship to the edit tool* below.
engines floor) with npm and pnpm on PATH;dsh CLI — the package's peerbaseline is @deepseek-ai/cordis ~4.0.4 and @deepseek-ai/dsh-* ^0.2.0-rc.2;
@ast-grep/cli native binary ships inside the npm dependency, so nosystem ast-grep install is needed.
pnpm install --global @deepseek-ai/dsh# both tools arrive in one command
dsh plugin --profile web add @hy-sde-org/dsh-tool-astdsh plugin add reconciles the profile's bundle list from the installed dsh.bundle.patch export, so after installation the hy-sde-ast-tool-ast row below is immediately active in the named profile.
You can also just depend on the package from your own tooling:
npm install @hy-sde-org/dsh-tool-ast # or pnpm add / yarn addgit clone git@github.com:hy-sde/dsh-plugins.git
cd dsh-plugins
pnpm install
pnpm --filter @hy-sde-org/dsh-tool-ast build
AST_TGZ="$(cd dsh-tool-ast/packages/tool-ast && pnpm pack --pack-destination /tmp | tail -n 1)"
dsh plugin --profile web add "$AST_TGZ"dsh web --dump-config # look for the hy-sde-ast-tool-ast rowStart the harness (dsh web) and ask the agent to search or rewrite structurally. The model-facing calls:
ast_grep with pat: "console.log($MSG)" and lang: "TypeScript" — everyconsole.log call, matched by tree shape rather than text, first 100 matches with $MSG captured per node.
ast_edit with pat: "console.log($MSG)", rewrite: "log.debug($MSG)",path: "src" — previews every proposed rewrite; re-run with apply: true to write the files through the fs edit-intent waterfall (version-guarded, observation ledger).
dsh plugin --profile web remove @hy-sde-org/dsh-tool-astAlready shipped? If a future DeepSeek Harness release adopts structural
search/rewrite itself, skip installation — adding this bundle on top would
duplicate the loader row and fail at boot.
The plugin's cordis.patch.yml mounts one plain host row, exactly like the official harness's own tool-ast row in the stock base bundle. It consumes the deployment's host services — tools, subprocess (stock base mounts @deepseek-ai/dsh-subprocess-local), systemPrompt, and fs (stock base provides ctx.fs host-wide via @deepseek-ai/dsh-fs-sandbox) — so it needs no filesystem realm of its own:
hy-sde-ast-tool-ast — @hy-sde-org/dsh-tool-ast, registeringast_grep/ast_edit beside the deployment's read/write/edit tools, sharing their fs instance, observation ledger, and sandbox policy.
Configure per deployment by patching the row by id:
- id: hy-sde-ast-tool-ast
config:
astGrepMaxMatches: 200
astEditMaxHunkBytes: 8000
timeoutMs: 45000edit pluginInstall @hy-sde-org/dsh-tool-edit and this bundle together — that is the verified composition. Neither owns a filesystem realm, they share the host ctx.fs, and their tool sets are disjoint (ast_grep/ast_edit vs edit), so they compose freely on stock and hy-sde harnesses alike.
@ast-grep/cli package, resolvedby createRequire from the plugin — the platform binary arrives with pnpm install, identical to how ripgrep tooling ships.
globs, paths) is its own argv element — a hostile pattern stays inert.
--json=stream output is parsed line-by-line; amalformed line fails the run (AST_FAILED) rather than being dropped.
exit 1 + stderr = AST_FIND_ERROR (bad path); exit 2 = AST_USAGE_ERROR; else AST_FAILED. Cooperative timeout / cancellation → AST_ABORTED.
ast_edit defaults topreview; apply: true writes only through the fs edit-intent waterfall with the observation/version guard, never a raw engine write.
Config). The defaults:astGrepMaxMatches 100, astGrepMaxNodeBytes 2000, astEditMaxHunkBytes 4000, astEditMaxFiles 200, searchMetaMaxBytes 65536, rawOutputMaxBytes 8 MiB, graceMs 3000, stderrMaxBytes 64 KiB, timeoutMs 30000.
pnpm install
pnpm -r check # strict typecheck (tsc --noEmit)
pnpm -r test # engine unit tests + real-engine integration suite
pnpm -r build # tsc -> dist
bash scripts/release-public.sh --check # pre-publish validation
bash scripts/release-public.sh --publish # publish to npmThe test suite runs the REAL packaged ast-grep against real temp files, exercising ast_grep, ast_edit preview and apply (observation/version guard), sandbox denial mapping, and abort classification — no mocks of the engine.
packages/tool-ast/ @hy-sde-org/dsh-tool-ast — the plugin (both tools)
cordis.patch.yml the installable harness bundle
src/core.ts the engine: binary resolution, spawn, argv, JSON parse,
error vocabulary
src/search.ts the ast_grep tool body
src/edit.ts the ast_edit tool body (preview / apply)This package is licensed MIT — the same license as its upstream oh-my-pi (https://github.com/can1357/oh-my-pi). The ast_grep and ast_edit tools are a full parity port of oh-my-pi's coding-agent ast tools (MIT License, © Mario Zechner 2025, © Can Bölük 2025-2026); the upstream copyright holders are recorded in LICENSE next to this package's own notice, and the upstream notice text is reproduced in full in THIRD-PARTY-NOTICES.md.
This plugin is a separate installable package; the harness remains the property of its own project.