Files
deepseek-harness/packages/experimental/forge-github/tests/fixtures.ts
T
Yichen Jiang dcbfd8079a feat(experimental): bind code host change requests to Sessions
Add the experimental forge capability seam:

- dsh-experimental-forge: provider-neutral repository and change request
  references, a provider registry, and shared status polling. Watchers of
  one change request share one loop; each forge has one batched fetch in
  flight, and the cadence follows check, mergeability, and lifecycle state.
- dsh-experimental-forge-github: GitHub provider that runs the GitHub CLI
  on the host with a scrubbed environment and reads every due pull request
  of a host in one GraphQL query.
- dsh-experimental-forge-session: a host-only projection derives Session
  bindings from gh pr create and git push shell results and from
  plugin:forge-session/binding records; push results trigger head-branch
  discovery of open pull requests, and Session watchers poll bound change
  requests through ctx.forge.
2026-10-20 11:49:25 +08:00

57 lines
2.1 KiB
TypeScript

import type { ChangeRequestRef, ForgeRepository } from '@deepseek-ai/dsh-experimental-forge'
/** Repository on github.com used across the provider tests. */
export const demo: ForgeRepository = { forge: 'github', host: 'github.com', owner: 'octo', name: 'demo' }
/** Build a pull request reference in `demo` or another repository. */
export function pull(number: number, repository: ForgeRepository = demo): ChangeRequestRef {
return { repository, number }
}
/** One CheckRun context node as GitHub returns it. */
export function checkRun(name: string, status: string, conclusion: string | null, workflow: string | null = 'ci'): Record<string, unknown> {
return {
__typename: 'CheckRun',
name,
status,
conclusion,
detailsUrl: `https://github.com/octo/demo/actions/runs/1/job/${name}`,
checkSuite: workflow === null ? { workflowRun: null } : { workflowRun: { workflow: { name: workflow } } },
}
}
/** One StatusContext node as GitHub returns it. */
export function statusContext(context: string, state: string): Record<string, unknown> {
return { __typename: 'StatusContext', context, state, targetUrl: null }
}
/** A pull request node with the fields the snapshot query selects. */
export function pullRequestNode(number: number, overrides: Record<string, unknown> = {}, contexts: unknown[] = [], rollupState: string | null = 'SUCCESS'): Record<string, unknown> {
return {
number,
url: `https://github.com/octo/demo/pull/${number}`,
title: `Change ${number}`,
state: 'OPEN',
isDraft: false,
updatedAt: '2026-10-09T01:02:03Z',
author: { login: 'octo' },
headRefName: `topic-${number}`,
headRefOid: 'f'.repeat(40),
baseRefName: 'master',
mergeable: 'MERGEABLE',
reviewDecision: null,
reviewThreads: { nodes: [{ isResolved: true }, { isResolved: false }, { isResolved: false }] },
commits: {
nodes: [{
commit: {
statusCheckRollup: rollupState === null ? null : {
state: rollupState,
contexts: { pageInfo: { hasNextPage: false }, nodes: contexts },
},
},
}],
},
...overrides,
}
}