Files
magpie/docs/subsystems
yetone 8de4669fb6 library: hooks reach DeepSeek Harness through its Claude Code hooks plugin (eiyuuzaki2333 on X)
DSH was the one Library agent with no Hooks. Its plugin
@deepseek-ai/dsh-hooks-claude-code runs a Claude Code hooks.json on dsh's
interception points, so a hook given to dsh is written to
$DSH_HOME/magpie-hooks.json (Claude shape, dsh tool names bash|pwsh and
write|edit|str_replace_editor, the events the bridge runs). Each profile gets the
plugin and @deepseek-ai/dsh-hook-protocol installed at dsh's own version
(`dsh plugin --profile <name> add`), then one marked magpie-hooks insert row.
No row is written, and any magpie row is taken out, while the plugin isn't
there (a user removed it, or the install failed): dsh leaves out a row whose
plugin is missing, and a deny hook would then allow everything. A user's own
row for the plugin is left alone and said. Failed installs retry after 10 min.

Not supported by dsh, so left off (named in docs/subsystems/library.md):
subagents, slash commands, rules, env, project MCP/hooks, Claude plugins.

Run:
- real dsh 0.2.2-rc.5 on mote, sandbox HOME, fake model server: bash call
  denied through the bridge with the hook's reason shown to the model;
  without @deepseek-ai/dsh-hook-protocol the row fails to import (hence both
  packages are installed).
- mote: go test ./internal/library ./internal/agent -count=1 ok (before the
  removed-plugin fix); go test ./internal/library -run Hook ok after it;
  GOOS=windows, GOOS=linux and native go vet ./internal/library ok; gofmt -l clean.
- GUI library-hooks, project-hooks, library-rtk-nohook (12 tests, each
  covering en/zh/zh-TW/ja/de at 440px) in chromium and webkit: 12/12 both.
- New tests: TestHooksDsh*, red on the old code (dsh was no hook agent).
  The hooks page is driven by hookAgents, so no GUI change was needed.

Not tried: the full magpie sync against real dsh (full sync not run against
real dsh: the row format was written by hand and loaded by real dsh, the
install is faked in tests); Windows and WSL dsh; a dsh older than 0.2.2-rc.5;
session-start narrowing (dsh's source names unknown). Full suites run after
the tag.
2026-11-20 05:10:42 +08:00
..
2026-11-10 03:25:44 +08:00

Subsystem design references

These pages describe current responsibilities, runtime paths, state, and contracts. Start with the subsystem relevant to your task, then follow its source links to verify the implementation you change.

Subsystem Reference
Built-in subscriptions moving to plugins Provider and plugin ownership
Built-in plugins: registry, lifecycle, plugins.yml, presets, settings schemas, the window's kernel (slots, error boundary, kit) Plugin runtime
Plugins that run on the gateway's requests and replies Gateway middleware
Tools that plugins give, offered to every agent as an MCP server Plugin tools
Plugins that await context recall and observe completed replies Asynchronous gateway request hooks
Claude subscription turns across Claude Code runs Claude subscription bridge
How the gateway picks a provider, key or account, and falls back Gateway routing and fallback
Gateway Session Aggregation Gateway Session Aggregation
Connecting an agent's config to the gateway, drift, disconnect, WSL twins Agent wiring
Providers, keys, subscription accounts, refresh and allowance Providers and accounts
Instructions, MCP servers, skills and RTK written into agents Library
One MCP server, magpie, given to every agent in place of the Library's servers MCP router
Memory shared by every agent: the memory MCP server, the digest in instructions, the Memory tab Memory
One skill, magpie-skills, listing the Library's skills in place of each agent's own Skill router
Tray, panel, window, magpie web and the page's JSON API GUI app shell
Encrypted backups and setup synchronization over WebDAV, S3 or GitHub Sync and backup

A subsystem can span several packages or repositories. Its reference describes the behavior those parts provide together; it does not need to list every function.

Maintain a reference

Update the owning reference in the same PR when a change alters a documented responsibility, interface, state transition, runtime path, compatibility rule, or failure behavior. An internal refactor that preserves these contracts does not require a prose change.

Keep each fact in one reference and link to it from agent instructions or other pages. Link to source files and named symbols rather than copying implementation details that change frequently. Explain field meanings and constraints that signatures alone do not express.

For a new reference, include the responsibilities and boundaries, source of truth, main runtime paths, state transitions, important constraints, and existing verification commands. Include failure and compatibility behavior where relevant. Document current behavior separately from proposed changes; the proposal belongs in its issue or PR.

Describe a PR's semantic changes

For each affected subsystem, explain the observable change with its trigger and before/after behavior. Include changes to interfaces, state, compatibility, and failure behavior when relevant. Link the affected reference, implementation, and verification evidence. State when a refactor preserves the documented behavior.

For example, a change to plugin adoption should explain which migration state and account condition trigger it, which implementation handles requests before and after adoption, and which test exercises that transition.

This is an author-provided explanation that a reviewer verifies against the diff and surrounding code. It is not an automatically proven compatibility verdict.

Review a change

  1. Identify the affected subsystem and the actual runtime path, including plugin or built-in ownership.
  2. Compare the claimed before/after behavior with the base and head implementation. Trace relevant callers and state transitions beyond the changed lines.
  3. Check that changed contracts appear in the owning reference and that source links still resolve.
  4. Check that the cited tests or runtime evidence exercise the claimed behavior. Report checks that were not run.

A documentation update alone does not prove the implementation. Existing tests and runtime evidence remain necessary for behavior changes.