@deepseek-ai/dsh-experimental-forge-github 0.0.0-stage → 0.2.2-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,43 @@
1
+ /** Runs the GitHub CLI on the host with a scrubbed, non-interactive environment. */
2
+ /** Complete output of one `gh` invocation that ran to an exit code. */
3
+ export interface GhOutput {
4
+ /** Process exit code. */
5
+ readonly exitCode: number;
6
+ /** Standard output without its final newline. */
7
+ readonly stdout: string;
8
+ /** Standard error without its final newline. */
9
+ readonly stderr: string;
10
+ }
11
+ /** Runs `gh` with literal arguments; rejects when the process cannot run to an exit code. */
12
+ export type GhRunner = (args: readonly string[], signal: AbortSignal) => Promise<GhOutput>;
13
+ /** Resolved executable and limits for `gh`. */
14
+ export interface GhConfig {
15
+ /** Executable name or absolute host path. */
16
+ readonly ghCommand: string;
17
+ /** Deadline in milliseconds for one invocation. */
18
+ readonly timeoutMs: number;
19
+ /** Maximum captured bytes per output stream. */
20
+ readonly maxOutputBytes: number;
21
+ }
22
+ /** Thrown when the `gh` executable cannot start, for example because it is not installed. */
23
+ export declare class GhUnavailableError extends Error {
24
+ name: string;
25
+ }
26
+ /** Thrown when one invocation outlives `timeoutMs`; the process is killed. */
27
+ export declare class GhTimeoutError extends Error {
28
+ name: string;
29
+ }
30
+ /** Thrown when an output stream exceeds `maxOutputBytes`; the process is killed. */
31
+ export declare class GhOutputLimitError extends Error {
32
+ name: string;
33
+ }
34
+ /**
35
+ * Build a runner for `gh` on the host. The child inherits the scrubbed parent
36
+ * environment, so variables whose names contain KEY, PASSWORD, SECRET, or
37
+ * TOKEN never reach it and `gh` authenticates from its own credential store.
38
+ * Prompts, update notices, pagers, and colors are disabled.
39
+ * @param config - executable and limits.
40
+ * @returns the runner.
41
+ */
42
+ export declare function ghRunner(config: GhConfig): GhRunner;
43
+ //# sourceMappingURL=gh.d.ts.map
@@ -0,0 +1,45 @@
1
+ /** GitHub GraphQL documents and their mapping into provider-neutral results. */
2
+ import type { ChangeRequestKey, ChangeRequestRef, ChangeRequestSnapshot, ForgeFailure, ForgeRepository } from '@deepseek-ai/dsh-experimental-forge';
3
+ /** Head-branch lookup; variables `owner`, `name`, and `branch` are passed as strings. */
4
+ export declare const HEAD_QUERY = "query($owner: String!, $name: String!, $branch: String!) {\n repository(owner: $owner, name: $name) {\n defaultBranchRef { name }\n pullRequests(headRefName: $branch, states: OPEN, first: 20, orderBy: { field: CREATED_AT, direction: DESC }) { nodes { number isCrossRepository } }\n }\n}";
5
+ /**
6
+ * Distinguish GraphQL response fields from HTTP error bodies.
7
+ * @param body - parsed JSON returned by GitHub.
8
+ * @returns whether the object carries GraphQL data or errors; field validation remains with the query mapper.
9
+ */
10
+ export declare function hasGraphqlFields(body: unknown): boolean;
11
+ /** One batched snapshot query and the change request behind each alias. */
12
+ export interface SnapshotQuery {
13
+ /** GraphQL document with one aliased field per change request. */
14
+ readonly document: string;
15
+ /** Change requests keyed by alias path `r<i>.p<j>`. */
16
+ readonly targets: ReadonlyMap<string, ChangeRequestRef>;
17
+ }
18
+ /**
19
+ * Build one query that reads every change request in `refs`, grouping them by
20
+ * repository. Owners, names, and numbers are validated before they are inlined.
21
+ * @param refs - change requests on one host.
22
+ * @returns the document and its alias targets.
23
+ * @throws when an owner, name, or number cannot be inlined safely.
24
+ */
25
+ export declare function snapshotQuery(refs: readonly ChangeRequestRef[]): SnapshotQuery;
26
+ /**
27
+ * Map a snapshot response, including GitHub's partial-error form, into one
28
+ * result per alias target. Path-scoped errors apply to their repository or
29
+ * pull request; errors without a path apply to every unresolved target. A
30
+ * repository without readable merge settings offers no merge.
31
+ * @param body - parsed JSON printed by `gh api graphql`.
32
+ * @param query - the query that produced the response.
33
+ * @returns a snapshot or failure for every target.
34
+ */
35
+ export declare function mapSnapshotResponse(body: unknown, query: SnapshotQuery): Map<ChangeRequestKey, ChangeRequestSnapshot | ForgeFailure>;
36
+ /**
37
+ * Map a head-branch lookup of {@link HEAD_QUERY}, which selects open pull requests, into change requests.
38
+ * @param body - parsed JSON printed by `gh api graphql`.
39
+ * @param repository - repository that was queried.
40
+ * @param branch - head branch that was queried.
41
+ * @returns open non-fork change requests for `branch`, or none when it is the default branch.
42
+ * @throws when the response is malformed or the repository is not visible.
43
+ */
44
+ export declare function mapHeadResponse(body: unknown, repository: ForgeRepository, branch: string): ChangeRequestRef[];
45
+ //# sourceMappingURL=graphql.d.ts.map
@@ -0,0 +1,19 @@
1
+ /** Registers the GitHub provider of `ctx.forge`, which reads pull requests through the GitHub CLI on the host. */
2
+ import type { Context } from '@deepseek-ai/cordis';
3
+ import z from '@deepseek-ai/schemastery';
4
+ export declare const name = "forge-github";
5
+ export declare const inject: string[];
6
+ /** GitHub CLI executable, served hosts, and invocation limits. */
7
+ export interface Config {
8
+ /** GitHub CLI executable name or absolute host path. */
9
+ ghCommand?: string;
10
+ /** Host names this provider serves; list GitHub Enterprise hosts explicitly. */
11
+ hosts?: string[];
12
+ /** Deadline in milliseconds for one `gh` invocation. */
13
+ timeoutMs?: number;
14
+ /** Maximum captured bytes per `gh` output stream. */
15
+ maxOutputBytes?: number;
16
+ }
17
+ export declare const Config: z<Config>;
18
+ export declare function apply(ctx: Context, config: Config): void;
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,49 @@
1
+ /** GitHub implementation of the forge provider contract. */
2
+ import type { ChangeRequestKey, ChangeRequestRef, ChangeRequestSnapshot, ForgeActionFailure, ForgeFailure, ForgeProvider, ForgeReadiness, ForgeRepository, MergeRequest } from '@deepseek-ai/dsh-experimental-forge';
3
+ import type { GhRunner } from './gh.ts';
4
+ /** Reads GitHub and GitHub Enterprise pull requests through a `gh` runner. */
5
+ export declare class GitHubProvider implements ForgeProvider {
6
+ private readonly gh;
7
+ readonly forge = "github";
8
+ private readonly hosts;
9
+ /**
10
+ * @param gh - runner that executes `gh` on the host.
11
+ * @param hosts - host names this provider serves, such as `github.com` and Enterprise hosts.
12
+ */
13
+ constructor(gh: GhRunner, hosts: readonly string[]);
14
+ repositoryFromRemote(url: string): ForgeRepository | undefined;
15
+ changeRequestFromUrl(url: string): ChangeRequestRef | undefined;
16
+ changeRequestUrl(ref: ChangeRequestRef): string;
17
+ fetch(refs: readonly ChangeRequestRef[], signal: AbortSignal): Promise<ReadonlyMap<ChangeRequestKey, ChangeRequestSnapshot | ForgeFailure>>;
18
+ findByHead(repository: ForgeRepository, branch: string, signal: AbortSignal): Promise<readonly ChangeRequestRef[]>;
19
+ /**
20
+ * Mark a draft pull request ready for review with `gh pr ready`; one that
21
+ * is already ready stays ready.
22
+ */
23
+ markReady(ref: ChangeRequestRef, signal: AbortSignal): Promise<ForgeActionFailure | undefined>;
24
+ /**
25
+ * Merge a pull request through the REST merge endpoint with the expected
26
+ * head commit, so GitHub refuses with 409 once new commits arrived. Unlike
27
+ * `gh pr merge`, it never enables auto-merge, never joins a merge queue, and
28
+ * never deletes the head branch.
29
+ */
30
+ merge(ref: ChangeRequestRef, request: MergeRequest, signal: AbortSignal): Promise<ForgeActionFailure | undefined>;
31
+ /** Read the pull request's diff with `gh pr diff`, which GitHub computes against the merge base. */
32
+ diff(ref: ChangeRequestRef, signal: AbortSignal): Promise<string | ForgeFailure>;
33
+ /** Read one file at a commit through the contents API in its raw form. */
34
+ fileText(ref: ChangeRequestRef, commit: string, path: string, signal: AbortSignal): Promise<string | ForgeFailure>;
35
+ fileUrl(ref: ChangeRequestRef, commit: string, path: string): string;
36
+ readiness(host: string, signal: AbortSignal): Promise<ForgeReadiness>;
37
+ /**
38
+ * Run one reading `gh` command, returning its output. A refusal, a `gh` that
39
+ * cannot start, output over `maxOutputBytes`, and a run past `timeoutMs` become failures.
40
+ */
41
+ private read;
42
+ /** Run one changing `gh` command; a refusal or a `gh` that cannot start becomes a failure. */
43
+ private act;
44
+ /** Run one `gh` command; a `gh` that cannot start resolves to its error, and every other rejection passes on. */
45
+ private attempt;
46
+ private hostFailure;
47
+ private fetchHost;
48
+ }
49
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1,44 @@
1
+ /** GitHub remote URL and pull request URL parsing, and validation of the parts inlined into requests. */
2
+ import type { ChangeRequestRef, ForgeRepository } from '@deepseek-ai/dsh-experimental-forge';
3
+ /** Host, owner, and repository name addressed by a URL. */
4
+ export interface GitHubLocation {
5
+ /** Lowercase host name. */
6
+ readonly host: string;
7
+ /** Owner as the URL spells it. */
8
+ readonly owner: string;
9
+ /** Repository name without a `.git` suffix. */
10
+ readonly name: string;
11
+ }
12
+ /**
13
+ * Check one owner or repository name segment.
14
+ * @param value - candidate segment.
15
+ * @returns whether GitHub permits the segment and it is not a dot path.
16
+ */
17
+ export declare function isSegment(value: string): boolean;
18
+ /**
19
+ * Validate a pull request before its owner, name, and number are inlined into
20
+ * a GraphQL document, a `gh` argument, or an API path.
21
+ * @param ref - pull request on a GitHub host.
22
+ * @returns its repository.
23
+ * @throws when the owner or name is not a permitted segment or the number is not a positive integer.
24
+ */
25
+ export declare function checkedRepository(ref: ChangeRequestRef): ForgeRepository;
26
+ /**
27
+ * Parse a Git remote URL. Accepts `http(s)://[user@]host[:port]/owner/name`,
28
+ * `ssh://[user@]host[:port]/owner/name`, `git://host/owner/name`, and the
29
+ * scp-like `[user@]host:owner/name`, each with an optional `.git` suffix or
30
+ * trailing slash. HTTP(S) ports belong to the host identity; SSH and Git
31
+ * transport ports do not.
32
+ * @param url - fetch or push URL as Git reports it.
33
+ * @returns the location, or undefined for other URL shapes.
34
+ */
35
+ export declare function parseRemoteUrl(url: string): GitHubLocation | undefined;
36
+ /**
37
+ * Parse a pull request web URL such as `https://github.com/owner/name/pull/12/files`.
38
+ * @param url - web URL of a pull request.
39
+ * @returns the location and number, or undefined for other URLs.
40
+ */
41
+ export declare function parsePullRequestUrl(url: string): (GitHubLocation & {
42
+ readonly number: number;
43
+ }) | undefined;
44
+ //# sourceMappingURL=urls.d.ts.map
package/locale/de.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "GitHub-Änderungsanfragen",
4
+ "description": "Lesen Sie GitHub-Änderungsanfragen für die forge-Registry über die GitHub CLI auf dem Host."
5
+ }
6
+ }
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "GitHub change requests",
4
+ "description": "Read GitHub change requests for the forge registry through the GitHub CLI on the host."
5
+ }
6
+ }
package/locale/es.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Solicitudes de cambio de GitHub",
4
+ "description": "Lea las solicitudes de cambio de GitHub para el registro de forge mediante la CLI de GitHub en el host."
5
+ }
6
+ }
package/locale/fr.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Demandes de modification GitHub",
4
+ "description": "Lisez les demandes de modification GitHub pour le registre forge via la CLI GitHub sur l'hôte."
5
+ }
6
+ }
package/locale/ja.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "GitHub の変更リクエスト",
4
+ "description": "ホスト上の GitHub CLI を使って、forge レジストリ向けに GitHub の変更リクエストを読み取ります。"
5
+ }
6
+ }
package/locale/pt.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Solicitações de alteração do GitHub",
4
+ "description": "Leia as solicitações de alteração do GitHub para o registro do forge por meio da CLI do GitHub no host."
5
+ }
6
+ }
package/locale/ru.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Запросы на изменение GitHub",
4
+ "description": "Считывайте запросы на изменение GitHub для реестра forge через GitHub CLI на хосте."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "GitHub 变更请求",
4
+ "description": "通过宿主上的 GitHub CLI 为 forge 注册表读取 GitHub 变更请求。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,47 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-experimental-forge-github",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "description": "GitHub provider for the experimental forge registry, read through the GitHub CLI on the host",
4
+ "version": "0.2.2-alpha.2",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "type": "module",
9
+ "main": "lib/index.js",
10
+ "types": "lib/types/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./lib/types/index.d.ts",
14
+ "default": "./lib/index.js"
15
+ },
16
+ "./locale/*.json": "./locale/*.json",
17
+ "./src/*": "./src/*",
18
+ "./package.json": "./package.json"
19
+ },
20
+ "files": [
21
+ "locale/*.json",
22
+ "lib/index.js",
23
+ "lib/types/**/*.d.ts"
24
+ ],
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
29
+ "directory": "packages/experimental/forge-github"
30
+ },
31
+ "dependencies": {
32
+ "@deepseek-ai/schemastery": "~3.18.6-alpha.1",
33
+ "@deepseek-ai/dsh-timeout": "0.2.2-alpha.2",
34
+ "execa": "^10.0.1",
35
+ "zod": "^4.4.3"
36
+ },
37
+ "peerDependencies": {
38
+ "@deepseek-ai/cordis": "~4.0.6-alpha.1",
39
+ "@deepseek-ai/dsh-experimental-forge": "0.2.2-alpha.2",
40
+ "@deepseek-ai/dsh-subprocess": "0.2.2-alpha.2"
41
+ },
42
+ "devDependencies": {
43
+ "@deepseek-ai/cordis": "~4.0.6-alpha.1",
44
+ "@deepseek-ai/dsh-experimental-forge": "0.2.2-alpha.2",
45
+ "@deepseek-ai/dsh-subprocess": "0.2.2-alpha.2"
46
+ }
6
47
  }