* feat(forge): let providers declare their hosts, names, sign-in, and review decisions Prepare the forge contract for a second provider: - ForgeProvider lists the hosts it serves and names itself (label, changeRequestNoun); registering a provider that lists a host another registered provider lists throws, so each URL has at most one provider. ctx.forge.describe(forge) returns the family's ForgeDescription. - ForgeReadiness carries the sign-in command, which the panel's sign-in banner shows instead of building `gh auth login` for the github family. - ForgeReviewData lists the review decisions the host lets the reader record; the review dialog offers only those instead of hardcoding the GitHub rule that a pull request's author may only comment. - ForgeReviewThread.original may name a later commit the host carried the thread to while its lines stayed unchanged. - The changes view names the code host and its word for a change request from the entry's ForgeDescription instead of hardcoding GitHub and PR. The GitHub provider declares its configured hosts, GitHub, pull requests, `gh auth login --hostname <host>`, and reads viewerDidAuthor for the review decisions. Upgrade guide: forge-provider-hosts. * feat(forge-gitlab): read GitLab merge requests through the GitLab CLI Add the experimental forge-gitlab provider. It serves the configured GitLab hosts through glab: status batches over GraphQL, head-pinned patches from merge request diff versions, commit listings, merge bases, pipeline jobs, closing issues, and review threads mapped from REST discussions, including outdated threads' hunks. The forge bundle composes the provider, disabled by default. * feat(forge-gitlab): write GitLab reviews, retry pipelines, request reviews, and rebase The GitLab provider now writes through glab as well as reading: comments start discussions at positions derived from the head's diff version, pending replies and comments are draft notes that a review publishes with its summary and review state, and approving checks the head through GitLab's sha parameter. Review reads carry the signed-in user's rights from GraphQL, their draft notes as the pending review, and the decisions GitLab lets them record. Snapshots name the head pipeline as every job's rerun, offer rebase as the branch update, and follow GitLab's permissions for reruns and review requests. updateBranch's contract now states how a provider whose host takes no expected head checks it. * feat(forge): let forge providers register the commands that bind change requests forge-session no longer recognizes gh commands by itself. A provider now registers a declarative ForgeCommandRule through ctx.forgeSession.registerCommands: its executable, creation and reference subcommands, change request page path, JSON URL members, declared options, and a pure select that maps one parsed reference command to a URL or a read-only lookup. forge-github registers gh and forge-gitlab registers glab, which adds glab mr create, view, update, and checkout, including numbers with -R: a full project URL binds directly, and other repository forms resolve through glab mr view in the call's shell. forge-session keeps the shared parts: the literal shell tokenizer, option parsing, output reading, lookups, and the projection. The forgeChangeRequests state version derives from the recognized rules, so a changed rule set refolds every Session, including commands that ran before the provider loaded. Ending a registration keeps its rule recognized until restart, so unloading providers at shutdown does not rewrite every checkpoint. * refactor(forge-gitlab): publish the GitLab provider as @deepseek-ai/dsh-forge-gitlab New experimental packages omit the experimental prefix so that promotion keeps their npm name. Register the directory in EXPERIMENTAL_PACKAGE_NAME_EXCEPTIONS instead of growing the legacy prefixed list, and rename every dependency, configuration row, path mapping, and document that names the package. * fix(forge-gitlab): keep review writes, comment positions, and reads within GitLab's facts and the limits - After GitLab refuses a publication, read the drafts again: delete them only when all remain, since GitLab can publish them before it refuses the summary, and report the outcome as unknown otherwise. A rollback that leaves drafts reports how many may remain. - Place comments on files GitLab collapsed through the diff compared from their texts, and let a file's new path name it over another file's old path after chained renames. - Keep the final newline of raw file reads. - Apply maxOutputBytes to the complete review result, and report a read whose rights stop early or skip a discussion's later notes as truncated. - Serve a version over maxCachedVersionBytes without keeping it. - Resolve uploaded avatars GitLab names by their path on the host. - Schedule bounded reads through p-limit. * fix(forge-session): run lookups only for live command rules and keep the projection registered - Reference lookups use the rules of live registrations, so a disposed provider's rule still folds but starts no gh or glab process. - A failed re-registration registers the projection again with the earlier rules, so clients keep its view; an error is logged only when that fails too. - Document the startup re-registration, test that the checkpointed state version survives a real Loader start, shutdown, and restart, and record that starting without a provider removes the bindings only its commands made. - Describe the changes view's pending review and single comment without naming GitHub, which keeps its own rule in forge-github, and render registerCommands as code in the generated service reference. * fix(forge-bundle): name GitLab merge requests in the bundle description The bundle now follows GitLab merge requests as well as GitHub pull requests, so the description's first sentence in every locale names both kinds of change request. * feat(forge): bind the change requests that gh api and glab api requests name Models often read a merge request through `glab api` or a pull request through `gh api` instead of `glab mr view` or `gh pr view`, which left the change request unbound. A command rule now declares raw API request subcommands beside its reference subcommands, each group with its own options, since `-f` is a value of `gh api` and a flag of `gh pr checkout`. An API request binds, as referenced, only the change request its REST path names, such as `projects/group%2Fapp/merge_requests/7/changes` or `repos/octo/demo/pulls/7/files`; its output is not read, since one request can list many change requests. A path whose host the command names binds directly, and one without a host, or with the current repository's placeholders, resolves through the CLI's view command in the call's shell. The gh and glab rules move to version 2. * docs(forge): add forge-gitlab and the forge-session peers to the module graph Regenerate docs/module-graph for the renamed GitLab provider and the optional forge-session peer of both providers. * test(web): refresh the forge bundle description in the recommended plugin catalog The creation recommendation recording carries every recommended plugin's description; refresh it for the forge bundle description that now names GitLab merge requests and the glab sign-in. * chore(forge-gitlab): carry the 0.2.2-rc.3 release version and move upgrade guides to v0.2.2-rc.3
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, reads their diffs and files, reads and writes their review threads, 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
- Understand the implementation
- Further Exploration
- Model Experience
- Known Limitations and Deferred Work
- Dev Note
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 an async disposer that cancels and drains that registration's calls. Results arriving after cancellation are discarded. One provider serves one forge family on the hosts its hosts lists, and names itself with label, such as GitHub, and changeRequestNoun, pull-request or merge-request; registering a second provider for the same family, or one that lists a host, compared without case, that a registered provider lists, throws. Registration changes announce forge/providers-changed; registering a provider polls its existing watches immediately. repositoryFromRemote(url) and changeRequestFromUrl(url) return the match of the provider that serves the URL's host, and describe(forge) returns a family's ForgeDescription, its label and changeRequestNoun, or undefined without a provider. 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 and, while it cannot sign in, the shell command that signs the user in as signIn.
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, failed with the host's reason, or unknown when the host's answer did not confirm the outcome, so the change may have been applied and must be checked on the host before it is tried again. 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.
diff(ref, headSha, signal) reads the change request's unified patch at head commit headSha as the host computes it, with a/ and b/ path prefixes, and fileText(ref, commit, path, signal) reads one file of its repository at a commit. Both delegate to the provider of the reference's forge, throw when none is registered, and resolve to the text or to a ForgeFailure, which is too-large when the host or the provider refuses an answer over its size limit. A provider returns a patch only when it describes headSha; once the head is another commit, diff resolves to stale. The first stale read at a head commit polls a watched change request at once so its next status names the current head; later stale reads at that commit wait for the regular poll, which bounds reads while the host's answers briefly disagree. When the latest status of a watched change request names headSha and carries baseSha, the base commit the host recorded with that head, diff passes it to the provider, which may start reading from it before it confirms the head. Snapshots carry unresolvedThreads with threadsTruncated, which marks the count as a lower bound when the provider counted only some review threads. fileUrl(ref, commit, path) returns the web page of that file at that commit.
Providers may implement commits and compare together. commits(ref, signal) lists a change request's commits oldest first, each with its full object name, first parent, title, author, and author time, at one head commit and with a truncated flag; compare(ref, base, head, signal) reads the unified patch from commit base to commit head. The registry returns undefined from commits and an unavailable failure from compare when the provider lacks either method, so a consumer can offer commit views only where both exist.
Providers may implement viewedFiles and setViewed together. viewedFiles(ref, headSha, signal) reads the signed-in user's viewed marks on the files of a change request at head commit headSha, each viewed, unviewed, or dismissed when the file changed after it was marked, with a truncated flag; setViewed(ref, { path, viewed, headSha }, signal) sets or clears one file's mark only while the head is still headSha. Both report a moved head as stale, which polls a watched change request as a stale diff does. When the provider lacks either method, viewedFiles returns undefined and setViewed a failed failure, so a consumer keeps viewed marks itself.
Providers may implement mergeBase(ref, base, head, signal), which names the commit whose files the old side of a change request's diff shows; ctx.forge.mergeBase returns unsupported without it. After a review write, a submitted review, or a viewed mark the host accepted, the registry announces forge/review-changed with the change request and the change, whichever plugin made it; an outcome that is unknown, refused, stale, or unsupported is not announced. The extension API lists what other plugins may rely on.
Snapshots carry the overview of a change request. reviewers lists requested reviewers first, then the latest reviewer of each account with their verdict and the commit it was given at; closingIssues lists the issues the host closes when the change request merges; reviewersTruncated and closingIssuesTruncated mark lists the provider read only in part. branchUpdates names the methods that would bring a head behind its base up to date for the signed-in user, empty when the head is current, conflicts, or may not be updated, so a consumer cannot tell a user without that right that the head is behind. canRequestReviews and canRerunChecks state the signed-in user's rights, and each check's rerun names the host run that reruns it, or null; checks that name one run rerun together once none of them is pending.
Providers may implement rerunChecks(ref, { headSha }, signal), which reruns the failed checks of head commit headSha whose run has no pending check; requestReviews(ref, { reviewers }, signal) together with reviewerCandidates(ref, query, signal), which lists accounts a review can be requested from with the host's suggestions first; and updateBranch(ref, { method, headSha }, signal), which merges or rebases the base into the head only while the head is still headSha. Each action resolves to undefined once the host accepted it or to a ForgeActionFailure, and polls a watched change request once it settles. The registry fails an action the provider lacks with failed, without polling, and returns unsupported from reviewerCandidates unless the provider implements both review request methods.
fetchChecks(ref, signal) reads one change request’s complete checks on demand. It has its own fetchTimeoutMs deadline and does not occupy the polling batch or publish to its watchers. Failure leaves previously polled snapshots intact. A provider without fetchChecks returns unavailable. Caller cancellation and provider or service disposal abort the read; disposal waits for it to settle.
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 polling 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 change requests use idleIntervalMs to detect reopening; merged requests stop automatic polling. refresh(ref) polls a watched change request at once, including after a terminal state; if a fetch is already in flight for its forge, another fetch starts immediately after it settles. A failed read repeats after activeIntervalMs doubled for each consecutive failure, up to maxBackoffMs, which must be at least activeIntervalMs. Unregistering a provider settles its watched change requests as unavailable. Polling stops when the last watcher leaves. The configuration catalog lists the defaults.
Reaching fetchTimeoutMs aborts the fetch signal with FORGE_FETCH_TIMEOUT. Providers must stop their work and settle when the signal aborts; rejected fetches become unavailable failures. A provider that ignores cancellation can stall polling and service disposal.
Providers may implement submitReview to publish a line comment or a completed review at an explicit head commit. The registry returns unsupported when that capability is absent and refreshes watched status after a submission. Successful writes return their web URL; failures distinguish changed heads, refusals, and unknown outcomes. Callers must reconcile unknown outcomes before another submission. Comments a user keeps for a later review go to the code host's pending review through writeReview, not to the polling registry.
Providers may implement readReview to read a change request's review threads at one head commit. readReview(ref, headSha, signal) returns ForgeReviewData, the threads with each line thread's position at the head and at the commit it was written on, and reviewEvents, the decisions the host lets the signed-in user record in a submitted review, only when the read names headSha as the head; otherwise stale, which polls a watched change request at once, once per head commit shared with stale diff reads. The registry returns an unsupported failure when the provider lacks the method.
Providers may implement writeReview to change a change request's review threads and the signed-in user's pending review. writeReview(ref, write, signal) takes one ForgeReviewWrite: a reply, published at once or with pending inside the pending review; resolving or unresolving a thread; editing or deleting a comment; adding a line comment at the head to the pending review; or submitting or discarding the pending review. A pending reply or comment starts a pending review when the user has none. The provider writes only while the head is still write.headSha; otherwise it returns stale, which polls a watched change request as a stale read does, and after any other result the registry polls a watched change request at once. A write is never retried, and an unknown result must be checked on the host before the write is tried again. The registry returns unsupported when the provider lacks the method. ForgeReviewData names the user's pending review and whether the user may reply to and resolve each thread, edit and delete each comment, and add to, submit, and discard a pending review; a provider without writeReview reports none of these permissions.
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
- Forge subsystem — provider contract, change request types, and service reference.
- GitHub provider — the provider for GitHub hosts.
- Session bindings — the consumer that binds change requests to Sessions.
- Binding decision — why bindings derive from shell results and status stays on the host.
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.