Skip to content

feat(install): add DeepSeek Harness (dsh) platform support - #5443

Draft
estebanmunchjones2019 wants to merge 6 commits into
Graphify-Labs:v8from
estebanmunchjones2019:feat/dsh-support
Draft

estebanmunchjones2019 wants to merge 6 commits into
Graphify-Labs:v8from
estebanmunchjones2019:feat/dsh-support

Conversation

@estebanmunchjones2019

@estebanmunchjones2019 estebanmunchjones2019 commented Nov 24, 2026 •

Copy link
Copy Markdown

What this does

graphify dsh install (or graphify install --platform dsh) sets graphify up for DeepSeek Harness.

DeepSeek Harness does not read a hooks file by itself — it only runs hooks when a small adapter package is mounted. So one install writes three things:

  1. The graphify skill in ~/.dsh/skills/graphify/ (or ./.dsh/skills/graphify/ with --project).
  2. ~/.dsh/hooks.json (or ./.dsh/hooks.json): the "before a tool runs" hooks, in the same format Claude Code uses.
  3. The entry that turns the adapter on — a fenced block in ~/.dsh/cordis.patch.yml, the layer every profile applies, or a small ./.dsh/graphify.cordis.yml file for a project install.

Restart DeepSeek Harness afterwards. A project install is started with dsh --patch .dsh/graphify.cordis.yml; a user install needs no extra flags.

What the agent sees

  • Plain install — advice only. Before the agent reads source files or searches the code it gets one line saying the project has a knowledge graph and pointing at graphify query. The session also opens with that line, so the agent knows about the graph before its first tool call.
  • --strict — one refusal. Exactly what Claude Code's strict mode does: the first raw file read or code search is declined with a message telling the agent to query the graph first and retry, and the retry is allowed. One refusal per session, never more, so a task cannot get stuck. It works at either scope.

There is no third setting and no repeat-deny mode. Claude Code has one deny policy, and DeepSeek Harness gets that same policy through the same code — nothing stronger, nothing configurable.

Files the graph does not index, files outside the project, and graphify's own output directory are never refused.

Other changes

  • The guard understands both sets of tool names (Read/read, Grep/grep, Bash/bash) and both argument shapes (an object or a JSON string), so one policy serves both hosts instead of a second copy.
  • A new host-neutral hook-guard session event for hosts whose session start also fires on startup/resume/clear, not only on compaction. Claude Code keeps its compact-only hook, so its behaviour is unchanged.
  • The adapter version is pinned to 0.2.3-alpha.2. The published latest tag is much older and does not send the events these hooks need, and a newer DeepSeek Harness refuses to load it.
  • graphify detect skips .dsh/hooks.json and .dsh/graphify.cordis.yml — files the installer writes, not source to describe.
  • README platform table and always-on paragraph, plus the generated dsh skill bundle.

Testing

Started from a clean machine: graphify was removed from DeepSeek Harness first (graphify dsh uninstall, leftover files deleted), then installed again from scratch. The fresh install recreated the skill, hooks.json and the patch fence, and dsh --dump-config showed the graphify-hooks row mounted.

Live sessions, all on the headless profile with dsh 0.2.3-alpha.2 and adapter 0.2.3-alpha.2, run in a copy of this repository (25,230 graph nodes, 1,276 indexed files):

  • Session start. The first user message in the session log is the graphify line with source.kind: "hooks-claude-code" — the injection lands before the first tool call.
  • Reading the graph. Asked which functions wire up the dsh hooks and where they live, the agent made six graphify query / graphify explain calls and answered from graph nodes (_dsh_wiring at L2434, _dsh_install at L2450, and so on) without opening a single source file.
  • The strict refusal. Asked to read graphify/install.py before any query, the call was refused with the redirect: hook/invoked followed by hook/result: deny in the session log, the marker written under graphify-out/cache/hook_sessions/, then the retry allowed. The same sequence reproduced in a small scratch project.
  • Staying quiet when already oriented. Once the agent had run graphify query itself, later reads passed — that is the design: the guard says nothing while a recent query is on record.

Unit tests: 42 in tests/test_hook_dsh.py and tests/test_install_dsh.py — the payload shape the adapter really sends (parsed arguments, workspace-relative path), the one-refusal-then-advice contract, a query releasing the next read, a compaction restoring the block, installing where $DSH_HOME is unset, install → uninstall → install, uninstall on a machine that never installed, refusing a hooks.json that cannot be merged, graphify install --platform dsh --strict, an executable path containing a space, a single-file grep refusal, and the installer's own command executed end to end. test_detect, test_skillgen and test_hook_nudge_wording pass alongside them, uv run python -m tools.skillgen --check passes, and the full suite is 11,690 passed, 167 skipped, 1 xfailed. Its one red test, test_graph_context_cache_reload.py::test_concurrent_first_load_of_new_path_builds_once, is timing-dependent and fails on the untouched base too (5 runs on each: base 2 pass / 3 fail, branch 3 pass / 2 fail).

One correction to how this branch described its last commit: a fresh capture shows the adapter hands the hook the tool arguments as an object, not as the model's raw JSON text. The string form is accepted as extra tolerance and covered by a test, but it was not what made the live session work — a run with that parsing removed still refuses correctly.

Companion edit

The published docs site (docs.graphify.com) is not in this repo and needs its own paragraph for the dsh platform.

A dsh user got no skill and no way to make the harness consult a built
graph; the only route was text in AGENTS.md, which the model is free to
ignore. DSH ships @deepseek-ai/dsh-hooks-claude-code, a bridge that
replays a Claude-Code hooks.json onto its own pre-tool seams, so the gap
was install wiring and tool-name vocabulary, not a second guard.

- guard: a per-host tool-name vocabulary (read/grep/glob/bash beside the
  Claude-cased names) takes the same policy branches, so one module
  serves both dialects.
- guard: opt-in `until-query` deny mode with its own cap. `once` remains
  the mode every install records by default, so no host is installed
  stricter than another.
- guard: new host-neutral `session` kind that states the graph on any
  start source and resets the nudge/deny budget after a compaction.
- installer: `graphify dsh install|uninstall` writes the skill, a
  Claude-shaped .dsh/hooks.json and a cordis overlay that mounts the
  bridge. Advisory by default; `--strict` opts into the one-shot deny at
  either scope, matching `graphify claude install --strict`. Lowercase
  matchers and a seconds-based timeout match DSH's parser.
- detect: the two dsh files graphify writes whole are recognised so
  they never become graph nodes.
- skillgen: rendered dsh skill bundle and references; README platform
  table and always-on paragraph.
- tests: DSH payload shapes, both deny modes and caps, the three-artifact
  install, merge/uninstall safety, and advisory-vs-strict hook flags.

Co-Authored-By: DeepSeek <noreply@deepseek.com>
`dsh plugin add` refuses a bridge older than the running runtime, so the
0.2.2-rc.5 pin fails on a current dsh (0.2.3-alpha.2): the command the
install prints is rejected before anything mounts. Track the current
line, and say in the rendered reference that a user on a different line
installs the bridge version matching their runtime.

Also correct that reference's hook-policy sentence, which still claimed
the install carries `--strict --deny-mode until-query`; a plain install
is advisory and `--strict` opts into the one-shot deny.

Co-Authored-By: DeepSeek <noreply@deepseek.com>
DeepSeek Harness's Claude-Code bridge passes `tool_input` as the JSON text
the model emitted rather than a parsed object, so the guard returned at
its `isinstance(t, dict)` check: every DSH hook fired and did nothing -
no nudge, no deny, even on a strict install. Caught by a live session;
the dict-shaped fixtures could not see it.

Parse the string form, keep failing open on anything unparseable, and pin
both with DSH payload tests.

Co-Authored-By: DeepSeek <noreply@deepseek.com>
@github-actions

Copy link
Copy Markdown

Thanks for the pull request, @estebanmunchjones2019. A maintainer will review it soon.

Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions.

A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic.

…payload

The live payload from dsh 0.2.3-alpha.2 + bridge 0.2.3-alpha.2 carries a
parsed `tool_input` holding a workspace-relative path, not the absolute one
every read fixture used. Add that shape, plus the gaps the review found:

- install with $DSH_HOME unset (the default path, never exercised);
- install -> uninstall -> install restores exactly one fence and two groups;
- uninstall on a never-installed machine writes nothing;
- a hooks.json whose `hooks` is not an object is refused, not clobbered;
- `graphify install --platform dsh --strict` skips the Claude-only note;
- a user-scope exe path with a space is quoted in the hook command;
- grep of one indexed file denies once and then advises;
- GRAPHIFY_HOOK_DENY_CAP=0 means never deny;
- the command the installer writes actually produces the deny when executed.

Co-Authored-By: DeepSeek <noreply@deepseek.com>
Claude Code has one deny policy and no flag to change it, and the point of
this branch is to give DeepSeek Harness that same behaviour. The opt-in
`--deny-mode` surface added earlier worked against that: it had no
counterpart in the reference host, and a mode recorded without `--strict`
was a policy that could never fire.

Remove the whole surface - `--deny-mode` (installer and hook dispatch),
`GRAPHIFY_HOOK_DENY_MODE`, `GRAPHIFY_HOOK_DENY_CAP`, the `<sid>.denials`
counter and `_claim_denial` - and restore the `_READ_DENY` / `_SEARCH_DENY`
payloads verbatim, so `_run_hook_guard(kind, strict)` emits exactly what
Claude Code installs emit.

Tests: the deny-mode cases become one-shot contract cases (one block, then
advice; a query releases the next read; a compaction restores the block), and
the installer tests drop the flag cases. README, the dsh hooks fragment and
its rendered artifacts follow.

Co-Authored-By: DeepSeek <noreply@deepseek.com>
The fragment was edited but the rendered reference was left out of the
previous commit, so the shipped skill still described a flag the guard no
longer has.

Co-Authored-By: DeepSeek <noreply@deepseek.com>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant