Files
deepseek-harness/packages/experimental/forge-session
Yichen Jiang 80254034c7 feat(forge): mark change requests ready and merge them from the panel
An expanded card now marks a draft ready for review and merges a change
request that the host would merge now:

- The forge seam gains provider actions `markReady` and `merge`, which
  return a typed `ForgeActionFailure`; the registry polls a watched change
  request at once after either settles. Snapshots carry `mergeReady` and
  the `mergeMethods` the repository allows, the user's usual one first.
- GitHub marks ready with `gh pr ready` and merges through the REST merge
  endpoint with the head SHA the card showed, so new commits refuse the
  merge; it never enables auto-merge, joins a merge queue, or deletes the
  head branch.
- The panel Remote acts only on visible bindings of the Session, and the
  card offers 标记为可评审 for drafts and a 合并 menu with the allowed
  methods and a confirmation, reporting each outcome in a toast.
- The forge panel e2e replaces the worktree branch before the ARIA
  capture normalizes durations, so a random suffix no longer breaks it.
2026-10-20 11:50:10 +08:00
..

description, kind
description kind
Bind change requests to the Session that created, pushed, or tracked them, and watch their status. package-reference

@deepseek-ai/dsh-experimental-forge-session

English | 中文

Summary

List the pull requests a Session is working on without a separate registry. A host-only projection derives bindings from the Session's own gh pr create and git push shell results and from binding records. After each push, the service looks up open change requests for the pushed branches and records the unbound ones. Watching a Session polls its bound change requests through ctx.forge.

Table of Contents


Use this package

Mount the service with the forge registry, a provider, and the Session projection registry.

- name: '@deepseek-ai/dsh-session-projection'
- name: '@deepseek-ai/dsh-experimental-forge'
- name: '@deepseek-ai/dsh-experimental-forge-github'
- name: '@deepseek-ai/dsh-experimental-forge-session'

ctx.forgeSession.changeRequests(session) returns the visible bindings in first-recorded order. Each entry carries the URL, its origin (created, discovered, or tracked), the provider reference or null when no provider serves the URL, and the latest polling result or null. watch(session, listener) is an effect on the calling fiber: while a Session has a watcher, every visible binding that a provider serves is polled, and listeners receive the complete list after each later binding change or polling result. track(session, url) binds a URL under the provider's canonical form, or restores a dismissed binding, and throws when no provider recognizes the URL. dismiss(session, url) hides a visible binding; other URLs leave the log unchanged.

A bash or pwsh call binds evidence only from its first result, and only when the tool execution itself succeeded; the command's exit status does not matter. A command containing gh pr create or gh pr new binds every /pull/<number> URL in its text output. A command containing git push, optionally with leading -C, -c, or long Git options, records each branch listed under a To <remote> line as created, updated, forced, or already up to date; rejected, deleted, tag, and non-branch refs are skipped. For each pushed branch whose remote a provider serves, the service runs ctx.forge.findByHead within discoveryTimeoutMs and appends a discover record for every returned change request that is not bound, including dismissed ones. Every push repeats the lookup; failures are logged as warnings. URLs that differ only in scheme, letter case, query, fragment, or trailing slashes name the same binding.

Binding actions are plugin:forge-session/binding records listed in the experimental persistence catalog; fork and resume carry them with the shell events, so a fork starts with its parent's bindings. discoveryTimeoutMs is listed in the configuration catalog.


Understand the implementation

Implementation internals — click to expand

The forgeChangeRequests projection has no client view. It keeps shell calls awaiting their first result, every binding with its dismissal state, and each pushed branch with the sequence number of the latest result that reported it. Pending calls are dropped at turn/end. The service reacts to a tool/result event by discovering exactly the pushes whose sequence number equals the event's, and refreshes watchers when the bindings array changes. Disposing the service aborts lookups and drops their results.

Source Responsibility
src/index.ts Discovery, track and dismiss records, and Session watches
src/projection.ts Fold of shell calls, results, and binding records
src/commands.ts Command classification and output parsing
src/types.ts Binding record, projection state, and entry types

Further Exploration


Model Experience

None, as bindings, discovery records, and polled status stay on the host; binding records never enter model requests.

KV Cache effect

None. Binding records are ignorable plugin records outside the model-visible conversation.

Known Limitations and Deferred Work

  • Textual command recognition — only bash and pwsh commands containing gh pr create, gh pr new, or git push count, and only /pull/<number> URLs bind. Scripts, aliases, gh api calls, other CLIs such as glab, and git push --porcelain output are not recognized; track binds such change requests.
  • Push-triggered discovery — a change request opened elsewhere after the latest push appears only after another push or a track.
  • No model tool — the model cannot read or change bindings yet.
  • Per-Session bindings — subagent Sessions keep their own bindings; a parent Session does not aggregate them.
  • Silent lookup failures — lookup failures reach the host log only; neither the Session nor its watchers see them.

Dev Note

Working context for maintainers — click to expand

None.