Skip to content

DCP Fork: Fixed issues, Polished and improved. - #699

Open
linsaftw wants to merge 4 commits into
Tarquinen:masterfrom
linsaftw:dcp/upstream-pr
Open

linsaftw wants to merge 4 commits into
Tarquinen:masterfrom
linsaftw:dcp/upstream-pr

Conversation

@linsaftw

@linsaftw linsaftw commented Dec 2, 2026 •

Copy link
Copy Markdown

Root cause and fix

Grouped changes

  • P0/compat: nudge-to-system-prompt, V1 clone-before-mutate, V2 restore adjacency, RPC guard, V2 response sanitization, V1 wire fallback.
  • Compress/state: protected-output dedupe, plan-mode preservation, compaction stats refresh, session state deletion, tokenizer bounds.
  • Commands/host: V1/V2 command registration, TUI RPC guard, percentage context limits.
  • Tests: regressions for leak/adjacency, permissions, compaction, persistence, commands, plus a scoped non-live V1/V2 lab that drives real OpenCode containers over HTTP and WebSocket.
  • Dependencies: overrides pin tar@8.0.5, ws@8.23.1, and cross-spawn@7.1.2 so the repo's own npm audit --audit-level=high gate passes.

Issues/PRs addressed

Integrated or ported with per-item evidence: #559 #564 #569 #582 #597 #608 #616 #628 #632 #639 #642 #648 #658 #659 #663 #666 #669 #670 #671 #672 #687 #688 #694 #695 #696 #698.

Full disposition ledger for all 57 open issues and 33 open PRs, including deferred items with reasons (e.g. #647 cross-cutting tool-call ID reuse, #693 compaction-state semantics, #649 low-value hot-path refactor), is in docs/engineering/UPSTREAM_BACKLOG.md.

Evidence

  • npx tsc --noEmit — exit 0.
  • npm test — exit 0; 154 main tests + 8 logger tests pass.
  • npx prettier --check . — exit 0.
  • npx tsup — exit 0.
  • npm audit --audit-level=high — exit 0 after the dependency pins; the remaining 30 findings are moderate dev-transitive packages (@npmcli/*, @opentelemetry/*, @opencode/plugin, @opentui/solid, ip-address, gcp-metadata).
  • Scoped non-live lab on a packed artifact with real OpenCode containers: V2 over HTTP and WebSocket plus V1 over HTTP, in both range and message modes, all report compression: true; RPC, manual compress, decompress, recompress, permissions, concurrent sessions, restart, and native compaction pass.

Notes

  • No config migration is required for existing DCP configs.
  • The V1 wire fallback is a compatibility path for hosts that do not fire the messages transform for the main request; it is guarded to LLM-shaped JSON POST bodies, never rewrites /api/ requests, and restores the original global fetch from the plugin dispose hook so a reload does not leave a stale wrapper.
  • Deferred upstream items are documented with concrete reasons rather than silently dropped.

- Move nudges to the request-only system prompt and avoid synthetic assistant
  text before tool-call adjacency, so DCP markers cannot leak into visible or
  persisted conversation content.
- Harden V1 message handling (clone before mutation) and V2 restore IDs so
  reasoning/tool-call pairing survives compression.
- Add a guarded V1 wire-transform fallback for hosts where the messages
  transform hook is not fired for the main request.
- State/persistence/compaction: delete persisted state on session.deleted,
  refresh stale stats after compaction, preserve plan-mode transitions,
  deduplicate protected tool outputs across recompression, bound tokenizer
  lookups.
- Register V1/V2 commands through a single path and guard RPC when the host
  does not expose it.
- Default context limits to model-window percentages.
- Add regressions for nudges, adjacency, permissions, persistence, commands,
  and a scoped non-live V1/V2 lab; record per-item upstream dispositions in
  docs/engineering/UPSTREAM_BACKLOG.md.

Refs: Tarquinen#608
Refs: Tarquinen#632
Refs: Tarquinen#642
Refs: Tarquinen#666
Refs: Tarquinen#687
Refs: Tarquinen#688
Refs: Tarquinen#664
Tests that exercise session persistence did not override the XDG dirs, so a
local or CI test run wrote session state into the user's real
~/.local/share/opencode/storage/plugin/dcp directory. Load an env shim ahead
of the test runner so module-level storage/config paths resolve into a temp
sandbox.
The repo's PR check runs `npm audit --audit-level=high`, which failed on
tar 7.5.x (installed transitively through @opencode/plugin tooling), ws 8.21.x,
and cross-spawn 7.0.6 (GHSA-ghv9-86vm-4v8m). Pinning the patched releases
keeps the audit gate green; remaining findings are moderate dev-transitive
packages.
…dy V1 wire guard

- resetOnCompaction zeroed totalPruneTokens, the lifetime savings total that
  global stats aggregate across session files. Only the pending counter is
  stale after compaction, so keep the lifetime total.
- installV1WireTransform patched globalThis.fetch and never restored it; add
  uninstallV1WireTransform and call it from the plugin dispose hook.
- Replace the per-session V1 wire suppression flag with a per-body marker
  check. Host versions fire the transform hook for aux agents (title/summary)
  while skipping the main request, so a session flag suppressed the real
  request; conversely the system prompt documents marker syntax and must be
  excluded from detection.
- Drop in-memory session state on session.deleted so long-lived processes do
  not retain blocks and summaries for deleted sessions.

Refs: Tarquinen#559
Refs: Tarquinen#564
Refs: Tarquinen#664
@linsaftw

linsaftw commented Dec 2, 2026

Copy link
Copy Markdown
Author

Works very good

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