@deepseek-ai/dsh-experimental-forge 0.0.0-stage → 0.2.2-alpha.3
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.
- package/LICENSE +21 -0
- package/README.i18n.yaml +37 -0
- package/README.md +103 -2
- package/README.zh.md +104 -0
- package/lib/index.js +537 -0
- package/lib/types/index.d.ts +185 -0
- package/lib/types/keys.d.ts +10 -0
- package/lib/types/schedule.d.ts +22 -0
- package/lib/types/types.d.ts +226 -0
- package/locale/de.json +6 -0
- package/locale/en.json +6 -0
- package/locale/es.json +6 -0
- package/locale/fr.json +6 -0
- package/locale/ja.json +6 -0
- package/locale/pt.json +6 -0
- package/locale/ru.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +42 -3
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/** Registry of code-host providers with provider-neutral change requests and shared status polling. */
|
|
2
|
+
import { Context, Service } from '@deepseek-ai/cordis';
|
|
3
|
+
import z from '@deepseek-ai/schemastery';
|
|
4
|
+
import type { ChangeRequestListener, ChangeRequestRef, ChangeRequestSnapshot, ChangeRequestUpdate, Config, ForgeActionFailure, ForgeFailure, ForgeProvider, ForgeReadiness, ForgeRepository, ForgeReviewRequest, ForgeReviewResult, MergeRequest } from './types.ts';
|
|
5
|
+
export { changeRequestKey } from './keys.ts';
|
|
6
|
+
export type * from './types.ts';
|
|
7
|
+
declare module '@deepseek-ai/cordis' {
|
|
8
|
+
interface Context {
|
|
9
|
+
forge: ForgeService;
|
|
10
|
+
}
|
|
11
|
+
interface Events {
|
|
12
|
+
/**
|
|
13
|
+
* Announces a provider registration or withdrawal after the registry changes.
|
|
14
|
+
* Listener failures are logged without preventing other listeners from running.
|
|
15
|
+
* @param forge - family whose provider changed.
|
|
16
|
+
* @mode parallel
|
|
17
|
+
*/
|
|
18
|
+
'forge/providers-changed'(forge: string): void | Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Registry of forge providers. Watchers of one change request share a single
|
|
23
|
+
* polling loop; each forge has at most one fetch in flight, which batches
|
|
24
|
+
* every due change request of that forge.
|
|
25
|
+
*/
|
|
26
|
+
export declare class ForgeService extends Service {
|
|
27
|
+
static Config: z<Config>;
|
|
28
|
+
private readonly config;
|
|
29
|
+
private readonly providers;
|
|
30
|
+
private readonly watches;
|
|
31
|
+
private readonly fetching;
|
|
32
|
+
private readonly pending;
|
|
33
|
+
private readonly lifetime;
|
|
34
|
+
private timer;
|
|
35
|
+
/**
|
|
36
|
+
* Poll what is due. A field rather than a method, so the timer runs it on
|
|
37
|
+
* the instance itself: a polling round started through a caller's `ctx.forge`
|
|
38
|
+
* would otherwise run on that caller's shadow receiver, and every later round
|
|
39
|
+
* would nest one more shadow until a property write overflows the stack.
|
|
40
|
+
*/
|
|
41
|
+
private readonly tick;
|
|
42
|
+
constructor(ctx: Context, config: Config);
|
|
43
|
+
/**
|
|
44
|
+
* Register the provider of one forge family as an effect on the calling
|
|
45
|
+
* fiber. Watches of that forge receive an `unavailable` failure when the
|
|
46
|
+
* registration ends. Unregistering cancels and awaits its in-flight calls;
|
|
47
|
+
* results from the withdrawn registration are discarded.
|
|
48
|
+
* @param provider - provider to serve `provider.forge`.
|
|
49
|
+
* @returns the disposer that unregisters the provider and waits for its calls to finish.
|
|
50
|
+
* @throws when another provider already serves the same forge.
|
|
51
|
+
*/
|
|
52
|
+
register(provider: ForgeProvider): () => Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Map a Git remote URL to a repository through the first provider that serves it.
|
|
55
|
+
* @param url - fetch or push URL as Git reports it.
|
|
56
|
+
* @returns the repository, or undefined when no provider serves the URL.
|
|
57
|
+
*/
|
|
58
|
+
repositoryFromRemote(url: string): ForgeRepository | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Map a change request web URL through the first provider that serves it.
|
|
61
|
+
* @param url - web URL of a pull or merge request.
|
|
62
|
+
* @returns the change request, or undefined when no provider serves the URL.
|
|
63
|
+
*/
|
|
64
|
+
changeRequestFromUrl(url: string): ChangeRequestRef | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Build the canonical web URL of a change request.
|
|
67
|
+
* @param ref - change request served by a registered provider.
|
|
68
|
+
* @returns the provider's canonical URL.
|
|
69
|
+
* @throws when no provider serves the change request's forge.
|
|
70
|
+
*/
|
|
71
|
+
changeRequestUrl(ref: ChangeRequestRef): string;
|
|
72
|
+
/**
|
|
73
|
+
* Find open change requests whose head is `branch`, excluding the default branch and forks.
|
|
74
|
+
* @param repository - repository served by a registered provider.
|
|
75
|
+
* @param branch - head branch name on the host.
|
|
76
|
+
* @param signal - cancellation for the lookup.
|
|
77
|
+
* @returns matching change requests, newest first as the provider reports them.
|
|
78
|
+
* @throws when no provider serves the repository's forge or the lookup fails.
|
|
79
|
+
*/
|
|
80
|
+
findByHead(repository: ForgeRepository, branch: string, signal: AbortSignal): Promise<readonly ChangeRequestRef[]>;
|
|
81
|
+
/**
|
|
82
|
+
* Report whether the provider can reach the repository's host with current credentials.
|
|
83
|
+
* @param repository - repository served by a registered provider.
|
|
84
|
+
* @param signal - cancellation for the probe.
|
|
85
|
+
* @returns the provider's readiness for the host.
|
|
86
|
+
* @throws when no provider serves the repository's forge.
|
|
87
|
+
*/
|
|
88
|
+
readiness(repository: ForgeRepository, signal: AbortSignal): Promise<ForgeReadiness>;
|
|
89
|
+
/**
|
|
90
|
+
* Mark a draft change request ready for review, then poll it at once when it is watched.
|
|
91
|
+
* @param ref - change request served by a registered provider.
|
|
92
|
+
* @param signal - cancellation of the request.
|
|
93
|
+
* @returns undefined once the host accepted the change, or why it did not.
|
|
94
|
+
* @throws when no provider serves the change request's forge, or with `signal.reason` when it aborts.
|
|
95
|
+
*/
|
|
96
|
+
markReady(ref: ChangeRequestRef, signal: AbortSignal): Promise<ForgeActionFailure | undefined>;
|
|
97
|
+
/**
|
|
98
|
+
* Merge a change request while its head is still `request.headSha`, then
|
|
99
|
+
* poll it at once when it is watched.
|
|
100
|
+
* @param ref - change request served by a registered provider.
|
|
101
|
+
* @param request - merge method and the head commit the user confirmed.
|
|
102
|
+
* @param signal - cancellation of the request.
|
|
103
|
+
* @returns undefined once the host merged it, or why it did not.
|
|
104
|
+
* @throws when no provider serves the change request's forge, or with `signal.reason` when it aborts.
|
|
105
|
+
*/
|
|
106
|
+
merge(ref: ChangeRequestRef, request: MergeRequest, signal: AbortSignal): Promise<ForgeActionFailure | undefined>;
|
|
107
|
+
/**
|
|
108
|
+
* Read complete check details independently of periodic polling.
|
|
109
|
+
* @param ref - change request served by a registered provider.
|
|
110
|
+
* @param signal - cancellation of the detail view.
|
|
111
|
+
* @returns a complete snapshot or the provider's failure; unsupported providers return unavailable.
|
|
112
|
+
* @throws on cancellation, provider disposal, or expiry of this read's own `fetchTimeoutMs` deadline.
|
|
113
|
+
*/
|
|
114
|
+
fetchChecks(ref: ChangeRequestRef, signal: AbortSignal): Promise<ChangeRequestSnapshot | ForgeFailure>;
|
|
115
|
+
/**
|
|
116
|
+
* Read the changes of a change request as its host computes them.
|
|
117
|
+
* @param ref - change request served by a registered provider.
|
|
118
|
+
* @param signal - cancellation of the read.
|
|
119
|
+
* @returns one unified patch with `a/` and `b/` path prefixes, or why the host did not provide it.
|
|
120
|
+
* @throws when no provider serves the change request's forge, or with `signal.reason` when it aborts.
|
|
121
|
+
*/
|
|
122
|
+
diff(ref: ChangeRequestRef, signal: AbortSignal): Promise<string | ForgeFailure>;
|
|
123
|
+
/**
|
|
124
|
+
* Publish one comment or a completed review, then refresh the watched status.
|
|
125
|
+
* @param ref - change request served by a registered provider.
|
|
126
|
+
* @param request - explicitly selected commit, comments, and review decision.
|
|
127
|
+
* @param signal - request cancellation.
|
|
128
|
+
* @returns a publication URL or a failure, including an unknown write outcome.
|
|
129
|
+
*/
|
|
130
|
+
submitReview(ref: ChangeRequestRef, request: ForgeReviewRequest, signal: AbortSignal): Promise<ForgeReviewResult>;
|
|
131
|
+
/**
|
|
132
|
+
* Read the text of one file at a commit of a change request's repository.
|
|
133
|
+
* @param ref - change request served by a registered provider.
|
|
134
|
+
* @param commit - commit object name.
|
|
135
|
+
* @param path - path relative to the repository root.
|
|
136
|
+
* @param signal - cancellation of the read.
|
|
137
|
+
* @returns the text, or why the host did not provide it.
|
|
138
|
+
* @throws when no provider serves the change request's forge, or with `signal.reason` when it aborts.
|
|
139
|
+
*/
|
|
140
|
+
fileText(ref: ChangeRequestRef, commit: string, path: string, signal: AbortSignal): Promise<string | ForgeFailure>;
|
|
141
|
+
/**
|
|
142
|
+
* Build the web page of one file at a commit of a change request's repository.
|
|
143
|
+
* @param ref - change request served by a registered provider.
|
|
144
|
+
* @param commit - commit object name.
|
|
145
|
+
* @param path - path relative to the repository root.
|
|
146
|
+
* @returns the provider's URL.
|
|
147
|
+
* @throws when no provider serves the change request's forge.
|
|
148
|
+
*/
|
|
149
|
+
fileUrl(ref: ChangeRequestRef, commit: string, path: string): string;
|
|
150
|
+
/**
|
|
151
|
+
* Watch one change request as an effect on the calling fiber. The first
|
|
152
|
+
* watcher starts polling at once; listeners receive every later result,
|
|
153
|
+
* and `latest` returns the current one. Polling stops when the last watcher
|
|
154
|
+
* leaves. Listeners must not throw; a thrown error is logged and skipped.
|
|
155
|
+
* @param ref - change request to poll.
|
|
156
|
+
* @param listener - receives each polling result.
|
|
157
|
+
* @returns the disposer that stops this watch.
|
|
158
|
+
*/
|
|
159
|
+
watch(ref: ChangeRequestRef, listener: ChangeRequestListener): () => void;
|
|
160
|
+
/**
|
|
161
|
+
* Poll a watched change request at once, including after a terminal state.
|
|
162
|
+
* A fetch already in flight is followed immediately by another fetch; an
|
|
163
|
+
* unwatched change request is unchanged.
|
|
164
|
+
* @param ref - change request to poll.
|
|
165
|
+
*/
|
|
166
|
+
refresh(ref: ChangeRequestRef): void;
|
|
167
|
+
/**
|
|
168
|
+
* Read the latest polling result of a watched change request.
|
|
169
|
+
* @param ref - change request to read.
|
|
170
|
+
* @returns the latest result, or undefined before the first result or without a watch.
|
|
171
|
+
*/
|
|
172
|
+
latest(ref: ChangeRequestRef): ChangeRequestUpdate | undefined;
|
|
173
|
+
private provider;
|
|
174
|
+
private providersChanged;
|
|
175
|
+
private registration;
|
|
176
|
+
private invoke;
|
|
177
|
+
private missing;
|
|
178
|
+
private schedule;
|
|
179
|
+
private poll;
|
|
180
|
+
/** Fetch one forge's batch; never rejects. */
|
|
181
|
+
private fetch;
|
|
182
|
+
private settle;
|
|
183
|
+
}
|
|
184
|
+
export default ForgeService;
|
|
185
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Canonical identities for change requests. */
|
|
2
|
+
import type { ChangeRequestKey, ChangeRequestRef } from './types.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Build the canonical identity of a change request. Host, owner, and name
|
|
5
|
+
* compare case-insensitively, as they do on the hosts this vocabulary serves.
|
|
6
|
+
* @param ref - change request to identify.
|
|
7
|
+
* @returns `<forge>:<host>/<owner>/<name>#<number>` in lowercase.
|
|
8
|
+
*/
|
|
9
|
+
export declare function changeRequestKey(ref: ChangeRequestRef): ChangeRequestKey;
|
|
10
|
+
//# sourceMappingURL=keys.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Poll cadence for watched change requests. */
|
|
2
|
+
import type { ChangeRequestSnapshot, ForgeFailure } from './types.ts';
|
|
3
|
+
/** Resolved intervals that pace polling. */
|
|
4
|
+
export interface PollIntervals {
|
|
5
|
+
/** Delay while checks run or mergeability is unknown. */
|
|
6
|
+
readonly activeIntervalMs: number;
|
|
7
|
+
/** Delay for a closed request or an open request whose checks have settled. */
|
|
8
|
+
readonly idleIntervalMs: number;
|
|
9
|
+
/** Largest delay after consecutive failures. */
|
|
10
|
+
readonly maxBackoffMs: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Choose the delay before the next poll of one change request. Failures back
|
|
14
|
+
* off exponentially from the active interval; merged change requests stop
|
|
15
|
+
* polling, while closed ones use the idle cadence to detect reopening.
|
|
16
|
+
* @param result - latest snapshot or failure.
|
|
17
|
+
* @param failures - consecutive failures, counting `result` when it is one.
|
|
18
|
+
* @param intervals - configured cadence.
|
|
19
|
+
* @returns the delay in milliseconds, or undefined after a terminal state.
|
|
20
|
+
*/
|
|
21
|
+
export declare function nextPollDelay(result: ChangeRequestSnapshot | ForgeFailure, failures: number, intervals: PollIntervals): number | undefined;
|
|
22
|
+
//# sourceMappingURL=schedule.d.ts.map
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/** Provider-neutral vocabulary for code hosts, their change requests, and provider contracts. */
|
|
2
|
+
import type { Branded } from '@deepseek-ai/dsh-brand';
|
|
3
|
+
/** One repository on a code host, identified the way its provider addresses it. */
|
|
4
|
+
export interface ForgeRepository {
|
|
5
|
+
/** Provider family that serves the repository, such as `github`. */
|
|
6
|
+
readonly forge: string;
|
|
7
|
+
/** Lowercase host name, such as `github.com`. */
|
|
8
|
+
readonly host: string;
|
|
9
|
+
/** Owner or namespace path as the host spells it. */
|
|
10
|
+
readonly owner: string;
|
|
11
|
+
/** Repository name as the host spells it. */
|
|
12
|
+
readonly name: string;
|
|
13
|
+
}
|
|
14
|
+
/** One change request (pull request or merge request) in a repository. */
|
|
15
|
+
export interface ChangeRequestRef {
|
|
16
|
+
/** Repository that holds the change request. */
|
|
17
|
+
readonly repository: ForgeRepository;
|
|
18
|
+
/** Host-assigned change request number. */
|
|
19
|
+
readonly number: number;
|
|
20
|
+
}
|
|
21
|
+
/** Canonical identity of a change request across providers; built by `changeRequestKey`. */
|
|
22
|
+
export type ChangeRequestKey = Branded<'ChangeRequestKey'>;
|
|
23
|
+
/** Lifecycle state of a change request. */
|
|
24
|
+
export type ChangeRequestState = 'open' | 'closed' | 'merged';
|
|
25
|
+
/** Normalized outcome of one status check. */
|
|
26
|
+
export type CheckState = 'pending' | 'success' | 'failure' | 'neutral' | 'skipped' | 'cancelled';
|
|
27
|
+
/** One status check reported for the head commit of a change request. */
|
|
28
|
+
export interface ChangeRequestCheck {
|
|
29
|
+
/** Check name as the host displays it. */
|
|
30
|
+
readonly name: string;
|
|
31
|
+
/** Normalized check outcome. */
|
|
32
|
+
readonly state: CheckState;
|
|
33
|
+
/** Web page for the check, or null when the host reports none. */
|
|
34
|
+
readonly url: string | null;
|
|
35
|
+
/** Workflow that produced the check, or null when the host reports none. */
|
|
36
|
+
readonly workflow: string | null;
|
|
37
|
+
/** ISO 8601 time the check started, or null before it starts and when the host reports none. */
|
|
38
|
+
readonly startedAt: string | null;
|
|
39
|
+
/** ISO 8601 time the check completed, or null while it runs and when the host reports none. */
|
|
40
|
+
readonly completedAt: string | null;
|
|
41
|
+
}
|
|
42
|
+
/** Combined outcome of all checks on the head commit. */
|
|
43
|
+
export type ChecksRollup = 'none' | 'pending' | 'success' | 'failure';
|
|
44
|
+
/** Whether the change request can merge into its base without conflicts. */
|
|
45
|
+
export type Mergeability = 'mergeable' | 'conflicting' | 'unknown';
|
|
46
|
+
/** Aggregate review outcome required by the host's merge rules. */
|
|
47
|
+
export type ReviewDecision = 'approved' | 'changes-requested' | 'review-required' | 'none';
|
|
48
|
+
/** How a merge brings the commits of a change request into its base branch. */
|
|
49
|
+
export type MergeMethod = 'merge' | 'squash' | 'rebase';
|
|
50
|
+
/** Status of one change request at the time its provider read it. */
|
|
51
|
+
export interface ChangeRequestSnapshot {
|
|
52
|
+
/** Change request the snapshot describes. */
|
|
53
|
+
readonly ref: ChangeRequestRef;
|
|
54
|
+
/** Web page of the change request. */
|
|
55
|
+
readonly url: string;
|
|
56
|
+
/** Title as the author wrote it. */
|
|
57
|
+
readonly title: string;
|
|
58
|
+
/** Lifecycle state. */
|
|
59
|
+
readonly state: ChangeRequestState;
|
|
60
|
+
/** Whether the author marked the change request as a draft. */
|
|
61
|
+
readonly draft: boolean;
|
|
62
|
+
/** Author login, or null when the host hides it. */
|
|
63
|
+
readonly author: string | null;
|
|
64
|
+
/** Branch that carries the proposed commits. */
|
|
65
|
+
readonly headBranch: string;
|
|
66
|
+
/** Commit object name at the head of the change request. */
|
|
67
|
+
readonly headSha: string;
|
|
68
|
+
/** Branch the change request merges into. */
|
|
69
|
+
readonly baseBranch: string;
|
|
70
|
+
/** Lines the change request adds. */
|
|
71
|
+
readonly additions: number;
|
|
72
|
+
/** Lines the change request deletes. */
|
|
73
|
+
readonly deletions: number;
|
|
74
|
+
/** Merge conflict status; `unknown` while the host computes it. */
|
|
75
|
+
readonly mergeability: Mergeability;
|
|
76
|
+
/**
|
|
77
|
+
* Whether the host would merge the change request now for the signed-in
|
|
78
|
+
* user: open, not a draft, and meeting the base branch's merge rules.
|
|
79
|
+
*/
|
|
80
|
+
readonly mergeReady: boolean;
|
|
81
|
+
/** Merge methods the repository accepts, the signed-in user's usual one first. */
|
|
82
|
+
readonly mergeMethods: readonly MergeMethod[];
|
|
83
|
+
/** Aggregate review outcome. */
|
|
84
|
+
readonly reviewDecision: ReviewDecision;
|
|
85
|
+
/** Checks on the head commit in host order. */
|
|
86
|
+
readonly checks: readonly ChangeRequestCheck[];
|
|
87
|
+
/** Combined check outcome. */
|
|
88
|
+
readonly checksRollup: ChecksRollup;
|
|
89
|
+
/** Whether the host reported more checks than `checks` contains. */
|
|
90
|
+
readonly checksTruncated: boolean;
|
|
91
|
+
/** Number of review threads that are not resolved. */
|
|
92
|
+
readonly unresolvedThreads: number;
|
|
93
|
+
/** ISO 8601 time of the host's last update to the change request. */
|
|
94
|
+
readonly updatedAt: string;
|
|
95
|
+
/** ISO 8601 time the change request was merged or closed, or null while it is open. */
|
|
96
|
+
readonly closedAt: string | null;
|
|
97
|
+
}
|
|
98
|
+
/** Why a provider could not read a change request. */
|
|
99
|
+
export interface ForgeFailure {
|
|
100
|
+
/**
|
|
101
|
+
* `not-found`: the host does not expose it; `unauthenticated`: credentials are missing or rejected;
|
|
102
|
+
* `too-large`: the host or the provider refuses an answer over its size limit, so reading again fails
|
|
103
|
+
* the same way; `unavailable`: any other failure.
|
|
104
|
+
*/
|
|
105
|
+
readonly code: 'not-found' | 'unauthenticated' | 'too-large' | 'unavailable';
|
|
106
|
+
/** Human-readable cause. */
|
|
107
|
+
readonly message: string;
|
|
108
|
+
}
|
|
109
|
+
/** Latest polling result delivered to watchers of one change request. */
|
|
110
|
+
export type ChangeRequestUpdate = {
|
|
111
|
+
/** Canonical identity of the watched change request. */
|
|
112
|
+
readonly key: ChangeRequestKey;
|
|
113
|
+
/** Epoch milliseconds when the result settled. */
|
|
114
|
+
readonly fetchedAt: number;
|
|
115
|
+
} & ({
|
|
116
|
+
/** Status read from the host. */
|
|
117
|
+
readonly snapshot: ChangeRequestSnapshot;
|
|
118
|
+
} | {
|
|
119
|
+
/** Reason the status could not be read. */
|
|
120
|
+
readonly failure: ForgeFailure;
|
|
121
|
+
});
|
|
122
|
+
/** A merge the user confirmed for the head commit they saw. */
|
|
123
|
+
export interface MergeRequest {
|
|
124
|
+
/** How the commits enter the base branch. */
|
|
125
|
+
readonly method: MergeMethod;
|
|
126
|
+
/** Commit object name the head must still have; the merge is refused once the head moves. */
|
|
127
|
+
readonly headSha: string;
|
|
128
|
+
}
|
|
129
|
+
/** One inline comment addressed to the old or new side of a pull request diff. */
|
|
130
|
+
export interface ForgeLineComment {
|
|
131
|
+
readonly path: string;
|
|
132
|
+
readonly side: 'L' | 'R';
|
|
133
|
+
readonly startLine: number;
|
|
134
|
+
readonly endLine: number;
|
|
135
|
+
readonly body: string;
|
|
136
|
+
}
|
|
137
|
+
/** A single published comment or one completed review containing all pending comments. */
|
|
138
|
+
export type ForgeReviewRequest = {
|
|
139
|
+
/** Commit the user reviewed; providers must check it before writing and address that commit explicitly. */
|
|
140
|
+
readonly headSha: string;
|
|
141
|
+
} & ({
|
|
142
|
+
readonly kind: 'comment';
|
|
143
|
+
readonly comment: ForgeLineComment;
|
|
144
|
+
} | {
|
|
145
|
+
readonly kind: 'review';
|
|
146
|
+
readonly event: 'comment' | 'approve' | 'request-changes';
|
|
147
|
+
readonly body: string;
|
|
148
|
+
readonly comments: readonly ForgeLineComment[];
|
|
149
|
+
});
|
|
150
|
+
/** Result of a review write; unknown outcomes must be checked on the host before another submission. */
|
|
151
|
+
export type ForgeReviewResult = {
|
|
152
|
+
readonly ok: true;
|
|
153
|
+
readonly url: string;
|
|
154
|
+
} | {
|
|
155
|
+
readonly ok: false;
|
|
156
|
+
readonly code: 'unsupported' | 'stale' | 'failed' | 'unknown';
|
|
157
|
+
readonly message: string;
|
|
158
|
+
};
|
|
159
|
+
/** Why a provider could not change a change request. */
|
|
160
|
+
export interface ForgeActionFailure {
|
|
161
|
+
/**
|
|
162
|
+
* `unauthenticated`: credentials are missing or rejected; `stale`: the head
|
|
163
|
+
* moved past the confirmed commit; `failed`: the host refused or could not be reached.
|
|
164
|
+
*/
|
|
165
|
+
readonly code: 'unauthenticated' | 'stale' | 'failed';
|
|
166
|
+
/** Human-readable cause, usually the host's own message. */
|
|
167
|
+
readonly message: string;
|
|
168
|
+
}
|
|
169
|
+
/** Whether a provider can reach one host with the current credentials. */
|
|
170
|
+
export interface ForgeReadiness {
|
|
171
|
+
/** `ready`, `unauthenticated` (sign-in needed), or `unavailable` (tool missing or host unreachable). */
|
|
172
|
+
readonly state: 'ready' | 'unauthenticated' | 'unavailable';
|
|
173
|
+
/** Human-readable detail, or null when ready. */
|
|
174
|
+
readonly message: string | null;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Host-specific access registered with `ctx.forge`. One provider serves one
|
|
178
|
+
* forge family; methods that take a signal must stop work when it aborts.
|
|
179
|
+
*/
|
|
180
|
+
export interface ForgeProvider {
|
|
181
|
+
/** Forge family name stored in every repository this provider returns. */
|
|
182
|
+
readonly forge: string;
|
|
183
|
+
/** Publish a comment or completed review. Omission declares that this provider cannot write reviews. */
|
|
184
|
+
submitReview?(ref: ChangeRequestRef, request: ForgeReviewRequest, signal: AbortSignal): Promise<ForgeReviewResult>;
|
|
185
|
+
/** Map a Git remote URL to its repository, or undefined when this provider does not serve it. */
|
|
186
|
+
repositoryFromRemote(url: string): ForgeRepository | undefined;
|
|
187
|
+
/** Map a change request web URL to its reference, or undefined when this provider does not serve it. */
|
|
188
|
+
changeRequestFromUrl(url: string): ChangeRequestRef | undefined;
|
|
189
|
+
/** Build the canonical web URL of a change request this provider serves. */
|
|
190
|
+
changeRequestUrl(ref: ChangeRequestRef): string;
|
|
191
|
+
/** Read the status of several change requests, returning one result per requested key. */
|
|
192
|
+
fetch(refs: readonly ChangeRequestRef[], signal: AbortSignal): Promise<ReadonlyMap<ChangeRequestKey, ChangeRequestSnapshot | ForgeFailure>>;
|
|
193
|
+
/** Read all checks for one change request on demand; omission declares that only the polling preview is available. */
|
|
194
|
+
fetchChecks?(ref: ChangeRequestRef, signal: AbortSignal): Promise<ChangeRequestSnapshot | ForgeFailure>;
|
|
195
|
+
/** Find open change requests whose head is `branch` in `repository`, excluding the default branch and forks. */
|
|
196
|
+
findByHead(repository: ForgeRepository, branch: string, signal: AbortSignal): Promise<readonly ChangeRequestRef[]>;
|
|
197
|
+
/** Report whether the provider can reach `host` with current credentials. */
|
|
198
|
+
readiness(host: string, signal: AbortSignal): Promise<ForgeReadiness>;
|
|
199
|
+
/** Mark a draft change request ready for review, resolving to undefined once the host accepted it. */
|
|
200
|
+
markReady(ref: ChangeRequestRef, signal: AbortSignal): Promise<ForgeActionFailure | undefined>;
|
|
201
|
+
/** Merge a change request while its head is still `request.headSha`, resolving to undefined once merged. */
|
|
202
|
+
merge(ref: ChangeRequestRef, request: MergeRequest, signal: AbortSignal): Promise<ForgeActionFailure | undefined>;
|
|
203
|
+
/** Read the changes of a change request as the host computes them, as one unified patch with `a/` and `b/` path prefixes. */
|
|
204
|
+
diff(ref: ChangeRequestRef, signal: AbortSignal): Promise<string | ForgeFailure>;
|
|
205
|
+
/** Read the text of `path` at `commit` in the change request's repository. */
|
|
206
|
+
fileText(ref: ChangeRequestRef, commit: string, path: string, signal: AbortSignal): Promise<string | ForgeFailure>;
|
|
207
|
+
/** Build the web page of `path` at `commit` in the change request's repository. */
|
|
208
|
+
fileUrl(ref: ChangeRequestRef, commit: string, path: string): string;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Receives every polling result for one watched change request.
|
|
212
|
+
* @param update - the settled result.
|
|
213
|
+
*/
|
|
214
|
+
export type ChangeRequestListener = (update: ChangeRequestUpdate) => void;
|
|
215
|
+
/** Poll cadence and fetch deadline for watched change requests. */
|
|
216
|
+
export interface Config {
|
|
217
|
+
/** Poll interval in milliseconds while checks run or mergeability is unknown. */
|
|
218
|
+
activeIntervalMs?: number;
|
|
219
|
+
/** Poll interval in milliseconds for a closed request or an open request whose checks have settled. */
|
|
220
|
+
idleIntervalMs?: number;
|
|
221
|
+
/** Largest delay in milliseconds between polls after consecutive failures. */
|
|
222
|
+
maxBackoffMs?: number;
|
|
223
|
+
/** Deadline in milliseconds for one provider fetch. */
|
|
224
|
+
fetchTimeoutMs?: number;
|
|
225
|
+
}
|
|
226
|
+
//# sourceMappingURL=types.d.ts.map
|
package/locale/de.json
ADDED
package/locale/en.json
ADDED
package/locale/es.json
ADDED
package/locale/fr.json
ADDED
package/locale/ja.json
ADDED
package/locale/pt.json
ADDED
package/locale/ru.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-experimental-forge",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"description": "Provider-neutral change request registry with shared status polling",
|
|
4
|
+
"version": "0.2.2-alpha.3",
|
|
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
|
+
"./types": {
|
|
17
|
+
"types": "./lib/types/types.d.ts"
|
|
18
|
+
},
|
|
19
|
+
"./locale/*.json": "./locale/*.json",
|
|
20
|
+
"./src/*": "./src/*",
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"locale/*.json",
|
|
25
|
+
"lib/index.js",
|
|
26
|
+
"lib/types/**/*.d.ts"
|
|
27
|
+
],
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
|
|
32
|
+
"directory": "packages/experimental/forge"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@deepseek-ai/schemastery": "~3.18.6-alpha.2",
|
|
36
|
+
"@deepseek-ai/dsh-brand": "0.2.2-alpha.3",
|
|
37
|
+
"@deepseek-ai/dsh-timeout": "0.2.2-alpha.3"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@deepseek-ai/cordis": "~4.0.6-alpha.2"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@deepseek-ai/cordis": "~4.0.6-alpha.2"
|
|
44
|
+
}
|
|
6
45
|
}
|