Files
deepseek-harness/packages/experimental/forge
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
Register code host providers and poll change request status through one provider-neutral service. package-reference

@deepseek-ai/dsh-experimental-forge

English | 中文

Summary

Read and act on pull requests and merge requests without coupling consumers to one code host. A provider maps remote and change request URLs to provider-neutral references, finds change requests by head branch, reads their status in batches, and marks drafts ready or merges on request. Watchers of one change request share a single polling loop whose cadence follows check, mergeability, and lifecycle state.

Table of Contents


Use this package

Mount the registry with at least one provider package, such as the GitHub provider.

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

ctx.forge.register(provider) is an effect on the calling fiber and returns its disposer. One provider serves one forge family; registering a second provider for the same family throws. repositoryFromRemote(url) and changeRequestFromUrl(url) ask providers in registration order and return the first match. changeRequestUrl(ref), findByHead(repository, branch, signal), and readiness(repository, signal) delegate to the provider of the reference's forge and throw when none is registered; readiness reports whether the provider can reach the host with current credentials.

markReady(ref, signal) marks a draft ready for review, and merge(ref, { method, headSha }, signal) merges a change request only while its head is still headSha. Both delegate to the provider of the reference's forge, throw when none is registered, and resolve to undefined once the host accepted the change or to a ForgeActionFailure: unauthenticated, stale when the head moved past headSha, or failed with the host's reason. After either settles, a watched change request is polled at once. Snapshots carry mergeReady, whether the host would merge the change request now for the signed-in user, and mergeMethods, the methods the repository accepts with that user's usual one first.

ctx.forge.watch(ref, listener) is also an effect. The first watcher of a change request polls it at once; latest(ref) returns the most recent result. Each forge has at most one fetch in flight, and that fetch includes every due change request of the forge. An open change request is polled every activeIntervalMs while checks are pending or mergeability is unknown, and every idleIntervalMs otherwise. Closed and merged change requests are not polled again. refresh(ref) polls a watched change request at once, including after a terminal state; a fetch already in flight for its forge serves the request. A failed read repeats after activeIntervalMs doubled for each consecutive failure, up to maxBackoffMs. A fetch that exceeds fetchTimeoutMs settles as an unavailable failure whose message names FORGE_FETCH_TIMEOUT. Unregistering a provider settles its watched change requests as unavailable. Polling stops when the last watcher leaves. The configuration catalog lists the defaults.


Understand the implementation

Implementation internals — click to expand

One timer covers all watched change requests. When it fires, the service groups due change requests by forge and starts one batched provider fetch per idle forge. A listener that throws is logged and skipped. Disposing the service aborts in-flight fetches and waits for them to settle.

Source Responsibility
src/index.ts Provider registration, URL mapping, watch lifetime, and batched polling
src/schedule.ts Delay before the next poll of one change request
src/keys.ts Case-insensitive canonical identity of a change request
src/types.ts Repository, change request, status, and provider types

Further Exploration


Model Experience

None, as providers and watchers exchange code host status without contributing model context.

KV Cache effect

None. No model request contains data from this package.

Known Limitations and Deferred Work

  • Polling only — status reaches watchers on the next scheduled poll or refresh; there is no webhook intake.
  • Process-local results — latest results live in memory and are lost on restart; the next watcher polls again.

Dev Note

Working context for maintainers — click to expand

None.