@deepseek-ai/dsh-experimental-client-ui-forge 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.
- package/LICENSE +21 -0
- package/README.i18n.yaml +37 -0
- package/README.md +134 -2
- package/README.zh.md +135 -0
- package/lib/client.js +8745 -0
- package/lib/index.js +3131 -0
- package/lib/typert.host.d.ts +3 -0
- package/lib/typert.host.js +2222 -0
- package/lib/typert.remote-client.d.ts +79 -0
- package/lib/typert.remote-client.js +1284 -0
- package/lib/types/client/ActionToast.d.ts +14 -0
- package/lib/types/client/ChangeRequestCard.d.ts +54 -0
- package/lib/types/client/ChangesTab.d.ts +49 -0
- package/lib/types/client/ChangesTabTitle.d.ts +13 -0
- package/lib/types/client/DiffFile.d.ts +75 -0
- package/lib/types/client/FileLabel.d.ts +20 -0
- package/lib/types/client/ForgeTab.d.ts +54 -0
- package/lib/types/client/ForgeTabTitle.d.ts +11 -0
- package/lib/types/client/HeaderButton.d.ts +27 -0
- package/lib/types/client/LocalChangesCard.d.ts +29 -0
- package/lib/types/client/RefreshGlyph.d.ts +18 -0
- package/lib/types/client/SessionHoverForge.d.ts +20 -0
- package/lib/types/client/SessionRowForge.d.ts +39 -0
- package/lib/types/client/WorktreeProgress.d.ts +44 -0
- package/lib/types/client/WorktreeToggle.d.ts +42 -0
- package/lib/types/client/changes-address.d.ts +70 -0
- package/lib/types/client/changes-store.d.ts +39 -0
- package/lib/types/client/checkout.d.ts +34 -0
- package/lib/types/client/diff-rows.d.ts +96 -0
- package/lib/types/client/format.d.ts +21 -0
- package/lib/types/client/glyphs.d.ts +33 -0
- package/lib/types/client/index.d.ts +25 -0
- package/lib/types/client/locales.d.ts +228 -0
- package/lib/types/client/mount.d.ts +17 -0
- package/lib/types/client/session-list.d.ts +46 -0
- package/lib/types/client/source.d.ts +146 -0
- package/lib/types/client/status.d.ts +95 -0
- package/lib/types/diff.d.ts +32 -0
- package/lib/types/git.d.ts +93 -0
- package/lib/types/index.d.ts +275 -0
- package/lib/types/local-diff.d.ts +93 -0
- package/lib/types/panel.d.ts +135 -0
- package/lib/types/parse.d.ts +57 -0
- package/lib/types/patch-cache.d.ts +33 -0
- package/lib/types/states.d.ts +89 -0
- package/lib/types/types.d.ts +395 -0
- package/lib/types/worktree.d.ts +225 -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 +123 -3
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/** Status derivations shared by the header entry, the change request cards, and the changes view. */
|
|
2
|
+
import type { ChangeRequestCheck, ChangeRequestSnapshot } from '@deepseek-ai/dsh-experimental-forge/types';
|
|
3
|
+
import type { ForgePanelChangeRequest, ForgePanelState } from '../types.ts';
|
|
4
|
+
import type { ForgePanelKey } from './locales.ts';
|
|
5
|
+
/**
|
|
6
|
+
* Glyph tone of a change request: its lifecycle state, `blocked` for an open
|
|
7
|
+
* one, not a draft, that needs its author, or `unknown` before the first snapshot.
|
|
8
|
+
*/
|
|
9
|
+
export type ChangeRequestTone = 'open' | 'blocked' | 'draft' | 'merged' | 'closed' | 'unknown';
|
|
10
|
+
/** Dictionary key of each tone's state name. */
|
|
11
|
+
export declare const TONE_LABEL: Record<ChangeRequestTone, ForgePanelKey>;
|
|
12
|
+
/** Combined check outcome shown on a collapsed card. */
|
|
13
|
+
export type CiSummary = {
|
|
14
|
+
readonly kind: 'none';
|
|
15
|
+
} | {
|
|
16
|
+
readonly kind: 'running';
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: 'passed';
|
|
19
|
+
}
|
|
20
|
+
/** `count` is the number of failed checks the host listed, which can be zero when the list is truncated. */
|
|
21
|
+
| {
|
|
22
|
+
readonly kind: 'failed';
|
|
23
|
+
readonly count: number;
|
|
24
|
+
};
|
|
25
|
+
/** Checks grouped by outcome; `other` holds neutral, skipped, and cancelled checks. */
|
|
26
|
+
export interface CheckCounts {
|
|
27
|
+
readonly failed: number;
|
|
28
|
+
readonly running: number;
|
|
29
|
+
readonly passed: number;
|
|
30
|
+
readonly other: number;
|
|
31
|
+
}
|
|
32
|
+
/** The most urgent fact of an open change request that the collapsed card names. */
|
|
33
|
+
export type ChangeRequestFlag = 'changesRequested' | 'conflicting' | 'draft';
|
|
34
|
+
/** The facts of a change request that decide its tone. */
|
|
35
|
+
export type ToneFacts = Pick<ChangeRequestSnapshot, 'state' | 'draft' | 'checksRollup' | 'reviewDecision' | 'mergeability'>;
|
|
36
|
+
/**
|
|
37
|
+
* Pick the glyph tone of a change request: an open draft is always `draft`;
|
|
38
|
+
* any other open one is `blocked` while its checks failed, changes were
|
|
39
|
+
* requested, or it conflicts with its base, and running checks, a pending
|
|
40
|
+
* review, and an unknown mergeability only wait and keep it `open`.
|
|
41
|
+
* @param snapshot - latest snapshot or listed state, or null before the first one.
|
|
42
|
+
* @returns the tone.
|
|
43
|
+
*/
|
|
44
|
+
export declare function toneOf(snapshot: ToneFacts | null): ChangeRequestTone;
|
|
45
|
+
/**
|
|
46
|
+
* Count the listed checks by outcome.
|
|
47
|
+
* @param checks - checks of the head commit.
|
|
48
|
+
* @returns the counts.
|
|
49
|
+
*/
|
|
50
|
+
export declare function checkCounts(checks: readonly ChangeRequestCheck[]): CheckCounts;
|
|
51
|
+
/**
|
|
52
|
+
* Summarize the checks of a change request from the host's combined outcome.
|
|
53
|
+
* @param snapshot - change request status.
|
|
54
|
+
* @returns the combined outcome with the failed count.
|
|
55
|
+
*/
|
|
56
|
+
export declare function ciSummary(snapshot: ChangeRequestSnapshot): CiSummary;
|
|
57
|
+
/**
|
|
58
|
+
* Pick the flag a collapsed card names: requested changes before merge
|
|
59
|
+
* conflicts before draft state; only open change requests carry one.
|
|
60
|
+
* @param snapshot - change request status.
|
|
61
|
+
* @returns the flag, or undefined when none applies.
|
|
62
|
+
*/
|
|
63
|
+
export declare function flagOf(snapshot: ChangeRequestSnapshot): ChangeRequestFlag | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Whether a change request needs the user, the condition its card draws as `blocked`.
|
|
66
|
+
* @param entry - bound change request.
|
|
67
|
+
* @returns whether the header marks it.
|
|
68
|
+
*/
|
|
69
|
+
export declare function needsAttention(entry: ForgePanelChangeRequest): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Pick the cards a Session's panel opens before the user expands or collapses
|
|
72
|
+
* one: the only open change request, drafts included, when exactly one is open.
|
|
73
|
+
* @param entries - bound change requests.
|
|
74
|
+
* @returns the URLs of the cards that start expanded.
|
|
75
|
+
*/
|
|
76
|
+
export declare function defaultExpanded(entries: readonly ForgePanelChangeRequest[]): ReadonlySet<string>;
|
|
77
|
+
/**
|
|
78
|
+
* Find the open change request, drafts included, whose head is the checked-out branch.
|
|
79
|
+
* @param state - panel state of the Session.
|
|
80
|
+
* @returns the change request, or undefined without one or while HEAD is detached.
|
|
81
|
+
*/
|
|
82
|
+
export declare function openChangeRequestOf(state: ForgePanelState): ForgePanelChangeRequest | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Read the change request number: the provider's reference, else the number at the end of the URL path.
|
|
85
|
+
* @param entry - bound change request.
|
|
86
|
+
* @returns the number, or null when neither names one.
|
|
87
|
+
*/
|
|
88
|
+
export declare function numberOf(entry: Pick<ForgePanelChangeRequest, 'ref' | 'url'>): number | null;
|
|
89
|
+
/**
|
|
90
|
+
* Measure how long a completed check ran.
|
|
91
|
+
* @param check - one check.
|
|
92
|
+
* @returns elapsed milliseconds, or undefined when either time is unknown or they are out of order.
|
|
93
|
+
*/
|
|
94
|
+
export declare function checkDuration(check: ChangeRequestCheck): number | undefined;
|
|
95
|
+
//# sourceMappingURL=status.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Unified patch parsing into the panel's browser-safe diff model, and the diff and size of an untracked file. */
|
|
2
|
+
import type { ForgeChangedFile, ForgeDiffFile } from './types.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Parse a Git-style unified patch, as `git diff` or a code host prints it,
|
|
5
|
+
* with `a/` and `b/` path prefixes. Hunk ranges follow jsdiff: a range that
|
|
6
|
+
* covers no line starts at the line it comes before.
|
|
7
|
+
* @param patch - the patch text.
|
|
8
|
+
* @returns one file per patch section in patch order.
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseDiff(patch: string): ForgeDiffFile[];
|
|
11
|
+
/**
|
|
12
|
+
* Describe an untracked file as added in full.
|
|
13
|
+
* @param path - path relative to the repository root.
|
|
14
|
+
* @param content - the file's bytes.
|
|
15
|
+
* @returns the file with one hunk of added lines, none when it is empty, or none and `binary` when its content is not text.
|
|
16
|
+
*/
|
|
17
|
+
export declare function untrackedFile(path: string, content: Uint8Array): ForgeDiffFile;
|
|
18
|
+
/**
|
|
19
|
+
* Decode file content as text the way Git decides it is not binary: no NUL
|
|
20
|
+
* byte among the first 8000 bytes, and, here, valid UTF-8 throughout.
|
|
21
|
+
* @param content - the bytes.
|
|
22
|
+
* @returns the text, or undefined for binary content.
|
|
23
|
+
*/
|
|
24
|
+
export declare function decodeText(content: Uint8Array): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Parse `git diff --numstat -z` output, in which a rename prints its counts,
|
|
27
|
+
* an empty path, and then the old and new paths as separate fields.
|
|
28
|
+
* @param output - the command's standard output.
|
|
29
|
+
* @returns one file per record, named by its new path; a binary file counts no lines.
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseNumstat(output: string): ForgeChangedFile[];
|
|
32
|
+
//# sourceMappingURL=diff.d.ts.map
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/** Read-only Git inspection of a Session's current directory in the Session's execution world. */
|
|
2
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
+
import type { Session } from '@deepseek-ai/dsh-session';
|
|
4
|
+
import type { GitRemote } from './parse.ts';
|
|
5
|
+
import type { ForgeBranches, ForgeCheckout } from './types.ts';
|
|
6
|
+
/** Resolved Git executable and process limits. */
|
|
7
|
+
export interface GitConfig {
|
|
8
|
+
/** Git executable name or absolute path. */
|
|
9
|
+
readonly gitCommand: string;
|
|
10
|
+
/** Deadline in milliseconds for one command, including executable lookup and confinement. */
|
|
11
|
+
readonly gitTimeoutMs: number;
|
|
12
|
+
/** Termination grace period in milliseconds for each process. */
|
|
13
|
+
readonly graceMs: number;
|
|
14
|
+
/** Maximum captured bytes per output stream. */
|
|
15
|
+
readonly maxOutputBytes: number;
|
|
16
|
+
}
|
|
17
|
+
/** Checkout facts with the upstream and remotes used to recognize the code host. */
|
|
18
|
+
export interface Inspection {
|
|
19
|
+
/** Facts the panel shows. */
|
|
20
|
+
readonly checkout: ForgeCheckout;
|
|
21
|
+
/** Canonical Git directory shared by every checkout of the repository. */
|
|
22
|
+
readonly commonDir: string;
|
|
23
|
+
/** Upstream branch such as `origin/main`, or null when none is configured or HEAD is detached. */
|
|
24
|
+
readonly upstream: string | null;
|
|
25
|
+
/** Remotes in listed order. */
|
|
26
|
+
readonly remotes: readonly GitRemote[];
|
|
27
|
+
}
|
|
28
|
+
/** Complete output of one Git command that exited with an allowed code. */
|
|
29
|
+
export interface GitOutput {
|
|
30
|
+
readonly stdout: string;
|
|
31
|
+
readonly stderr: string;
|
|
32
|
+
readonly exitCode: number;
|
|
33
|
+
}
|
|
34
|
+
/** Runs one Git subcommand in a fixed directory; output with an exit code outside `allowedExitCodes` throws. */
|
|
35
|
+
export type Git = (name: string, args: readonly string[], allowedExitCodes?: readonly number[]) => Promise<GitOutput>;
|
|
36
|
+
/** Thrown when a Git command prints more than `maxOutputBytes` on standard output. */
|
|
37
|
+
export declare class GitOutputTooLarge extends Error {
|
|
38
|
+
name: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Inspect the checkout containing `directory`. Every command runs through the
|
|
42
|
+
* mounted subprocess provider under a read-only confinement of the Session's
|
|
43
|
+
* sandbox policy and reads refs and configuration only, never the working
|
|
44
|
+
* tree. The top-level and shared Git directories Git prints are resolved
|
|
45
|
+
* through `ctx.fs` into canonical process paths, the form the
|
|
46
|
+
* working-directory service records.
|
|
47
|
+
* @param ctx - context that provides `fs`, `subprocess`, `sandbox`, and `sandboxPolicy`.
|
|
48
|
+
* @param config - executable and process limits.
|
|
49
|
+
* @param session - Session whose sandbox policy and execution world apply.
|
|
50
|
+
* @param directory - absolute directory to inspect.
|
|
51
|
+
* @param signal - cancellation of every command.
|
|
52
|
+
* @returns the checkout facts, shared Git directory, upstream, and remotes, or undefined when `directory` is not inside a checkout.
|
|
53
|
+
* @throws when Git cannot run, fails, times out, or prints more than `maxOutputBytes`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function inspectCheckout(ctx: Context, config: GitConfig, session: Session, directory: string, signal: AbortSignal): Promise<Inspection | undefined>;
|
|
56
|
+
/**
|
|
57
|
+
* List the local branches that can start a worktree of the checkout containing
|
|
58
|
+
* `directory`, under the same confinement as {@link inspectCheckout}.
|
|
59
|
+
* @param ctx - context that provides `subprocess`, `sandbox`, and `sandboxPolicy`.
|
|
60
|
+
* @param config - executable and process limits.
|
|
61
|
+
* @param session - Session whose sandbox policy and execution world apply.
|
|
62
|
+
* @param directory - absolute directory inside the checkout.
|
|
63
|
+
* @param limit - most branch names to return.
|
|
64
|
+
* @param signal - cancellation of every command.
|
|
65
|
+
* @returns the checked-out branch and local branches, the checked-out one first and then most recently committed first.
|
|
66
|
+
* @throws when `directory` is not inside a checkout, or Git cannot run, fails, times out, or prints more than `maxOutputBytes`.
|
|
67
|
+
*/
|
|
68
|
+
export declare function listBranches(ctx: Context, config: GitConfig, session: Session, directory: string, limit: number, signal: AbortSignal): Promise<ForgeBranches>;
|
|
69
|
+
/**
|
|
70
|
+
* Report whether a local branch exists, under the same confinement as {@link inspectCheckout}.
|
|
71
|
+
* @param ctx - context that provides `subprocess`, `sandbox`, and `sandboxPolicy`.
|
|
72
|
+
* @param config - executable and process limits.
|
|
73
|
+
* @param session - Session whose sandbox policy and execution world apply.
|
|
74
|
+
* @param repositoryRoot - absolute root of a checkout of the repository.
|
|
75
|
+
* @param branch - local branch name.
|
|
76
|
+
* @param signal - cancellation of the command.
|
|
77
|
+
* @returns whether `refs/heads/<branch>` exists.
|
|
78
|
+
* @throws when Git cannot run, fails, times out, or prints more than `maxOutputBytes`.
|
|
79
|
+
*/
|
|
80
|
+
export declare function hasBranch(ctx: Context, config: GitConfig, session: Session, repositoryRoot: string, branch: string, signal: AbortSignal): Promise<boolean>;
|
|
81
|
+
/**
|
|
82
|
+
* Bind the confined Git runner to one Session and directory: every command
|
|
83
|
+
* runs under a read-only confinement of the Session's sandbox policy with the
|
|
84
|
+
* scrubbed environment, the fixed command prefix, and `config`'s limits.
|
|
85
|
+
* @param ctx - context that provides `subprocess`, `sandbox`, and `sandboxPolicy`.
|
|
86
|
+
* @param config - executable and process limits.
|
|
87
|
+
* @param session - Session whose sandbox policy and execution world apply.
|
|
88
|
+
* @param directory - working directory of every command.
|
|
89
|
+
* @param signal - cancellation of every command.
|
|
90
|
+
* @returns the runner.
|
|
91
|
+
*/
|
|
92
|
+
export declare function gitIn(ctx: Context, config: GitConfig, session: Session, directory: string, signal: AbortSignal): Git;
|
|
93
|
+
//# sourceMappingURL=git.d.ts.map
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/** Host Remote of the forge panel: checkout, code host, sign-in, change request, and worktree state per Session. */
|
|
2
|
+
import { Context, Service } from '@deepseek-ai/cordis';
|
|
3
|
+
import z from '@deepseek-ai/schemastery';
|
|
4
|
+
import type { MergeMethod } from '@deepseek-ai/dsh-experimental-forge';
|
|
5
|
+
import type { Session } from '@deepseek-ai/dsh-session';
|
|
6
|
+
import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
7
|
+
import type { Config, ForgeBranches, ForgeChangeRequestDiff, ForgeChangeRequestStatesFrame, ForgeLocalDiff, ForgeLocalScope, ForgePanelState } from './types.ts';
|
|
8
|
+
export type * from './types.ts';
|
|
9
|
+
declare module '@deepseek-ai/cordis' {
|
|
10
|
+
interface Context {
|
|
11
|
+
/** Remote that serves the forge panel of the GUI. */
|
|
12
|
+
forgePanel: ForgePanelController;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Serves the forge panel. Following a Session inspects the checkout of its
|
|
17
|
+
* current directory read-only in the Session's execution world, recognizes the
|
|
18
|
+
* code host of the upstream remote or `origin`, probes sign-in for that host,
|
|
19
|
+
* and polls the Session's bound change requests through `ctx.forge` until the
|
|
20
|
+
* last follower of that Session leaves. A worktree request makes the panel
|
|
21
|
+
* create a branch and checkout through an optional `ctx.worktrees` and enter
|
|
22
|
+
* it while the Session's first message waits in the inbox, or at the first
|
|
23
|
+
* step proposal of a message no wait took. After a failed or stopped attempt
|
|
24
|
+
* the message keeps waiting for another attempt or for the request to be
|
|
25
|
+
* withdrawn. A message also waits while the worktree the Session works in is
|
|
26
|
+
* gone, until that worktree is checked out again or left for the source
|
|
27
|
+
* checkout. Changes to a Session's checkout run as Agent maintenance, so a
|
|
28
|
+
* message that arrives meanwhile waits for them.
|
|
29
|
+
*/
|
|
30
|
+
export declare class ForgePanelController extends TypertRemoteService {
|
|
31
|
+
static inject: string[];
|
|
32
|
+
static Config: z<Config>;
|
|
33
|
+
private readonly home;
|
|
34
|
+
private readonly config;
|
|
35
|
+
private readonly panels;
|
|
36
|
+
private worktreeStates;
|
|
37
|
+
private creations;
|
|
38
|
+
private readonly patches;
|
|
39
|
+
private states;
|
|
40
|
+
private readonly stopPanels;
|
|
41
|
+
private readonly stopStates;
|
|
42
|
+
constructor(ctx: Context, config: Config);
|
|
43
|
+
protected [Service.init](): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Stream the panel state of a Session: the current state first, then each
|
|
46
|
+
* later state. Intermediate states may be skipped when the reader is slower
|
|
47
|
+
* than the updates. The stream ends when `signal` aborts or the Remote stops.
|
|
48
|
+
* @param session - Session to follow.
|
|
49
|
+
* @param signal - ends the stream.
|
|
50
|
+
* @returns panel states in publication order.
|
|
51
|
+
*/
|
|
52
|
+
follow(session: Session, signal: AbortSignal): AsyncIterable<ForgePanelState>;
|
|
53
|
+
/**
|
|
54
|
+
* Stream the last known state of every change request that a listed
|
|
55
|
+
* Session the caller may read binds: the stored states first, then each
|
|
56
|
+
* state a poll changes or a new binding reveals. Listing reads no Session
|
|
57
|
+
* log: loaded Sessions report their bindings, others the cached Session
|
|
58
|
+
* summary, and a Session without one shows nothing until it is opened.
|
|
59
|
+
* Closed requests are polled at the idle cadence so reopening is observed. The
|
|
60
|
+
* stream ends when `signal` aborts or the Remote stops.
|
|
61
|
+
* @param signal - ends the stream.
|
|
62
|
+
* @returns frames in publication order.
|
|
63
|
+
* @throws when the Host lacks the Session query, projection cache, storage, or Session store service.
|
|
64
|
+
*/
|
|
65
|
+
changeRequestStates(signal: AbortSignal): AsyncIterable<ForgeChangeRequestStatesFrame>;
|
|
66
|
+
/**
|
|
67
|
+
* List the local branches that can start a worktree of the Session's current checkout.
|
|
68
|
+
* @param session - Session whose current directory is listed.
|
|
69
|
+
* @param signal - request cancellation.
|
|
70
|
+
* @returns the checked-out branch and at most `maxBranches` local branches, the checked-out one first.
|
|
71
|
+
* @throws when the current directory is not inside a checkout or Git fails.
|
|
72
|
+
*/
|
|
73
|
+
branches(session: Session, signal: AbortSignal): Promise<ForgeBranches>;
|
|
74
|
+
/**
|
|
75
|
+
* Bind a change request to a Session by URL, or restore a dismissed binding.
|
|
76
|
+
* @param session - Session that receives the binding.
|
|
77
|
+
* @param url - web URL of the change request.
|
|
78
|
+
* @param signal - request cancellation.
|
|
79
|
+
* @throws `forgePanel/unrecognized-url` when no registered provider serves the URL.
|
|
80
|
+
*/
|
|
81
|
+
track(session: Session, url: string, signal: AbortSignal): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Hide a visible binding of a Session; other URLs leave the Session unchanged.
|
|
84
|
+
* @param session - Session that owns the binding.
|
|
85
|
+
* @param url - web URL of the change request.
|
|
86
|
+
* @param signal - request cancellation.
|
|
87
|
+
*/
|
|
88
|
+
dismiss(session: Session, url: string, signal: AbortSignal): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Reinspect a followed Session's checkout, probe sign-in again, and poll its
|
|
91
|
+
* change requests at once; an unfollowed Session is unchanged.
|
|
92
|
+
* @param session - Session whose panel refreshes.
|
|
93
|
+
* @param signal - request cancellation.
|
|
94
|
+
* @returns settles once the inspection and the sign-in probe have ended; poll results reach the panel stream later.
|
|
95
|
+
*/
|
|
96
|
+
refresh(session: Session, signal: AbortSignal): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Read the changes one scope covers in the checkout of the Session's
|
|
99
|
+
* current directory, with Git confined to the Session's read-only sandbox.
|
|
100
|
+
* @param session - Session whose checkout is read.
|
|
101
|
+
* @param scope - which changes to read.
|
|
102
|
+
* @param signal - request cancellation.
|
|
103
|
+
* @returns the files, the base of the `branch` scope, and the untracked files left out.
|
|
104
|
+
* @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/no-fork-point` for the `branch`
|
|
105
|
+
* scope of a checkout without one; `forgePanel/diff-too-large` over `maxDiffBytes`; the Git error when Git fails.
|
|
106
|
+
*/
|
|
107
|
+
localDiff(session: Session, scope: ForgeLocalScope, signal: AbortSignal): Promise<ForgeLocalDiff>;
|
|
108
|
+
/**
|
|
109
|
+
* Read the new side of one changed file in a scope, which supplies the
|
|
110
|
+
* unchanged lines between its hunks: the index for `staged`, else the working tree.
|
|
111
|
+
* @param session - Session whose checkout is read.
|
|
112
|
+
* @param scope - the scope the diff was read in.
|
|
113
|
+
* @param path - path relative to the checkout's top-level directory, as the diff names it.
|
|
114
|
+
* @param signal - request cancellation.
|
|
115
|
+
* @returns the text.
|
|
116
|
+
* @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/diff-too-large` over `maxDiffBytes`;
|
|
117
|
+
* an error for a path outside the checkout, binary content, or a failed read.
|
|
118
|
+
*/
|
|
119
|
+
localText(session: Session, scope: ForgeLocalScope, path: string, signal: AbortSignal): Promise<string>;
|
|
120
|
+
/**
|
|
121
|
+
* Read the changes of a change request of a Session as its code host
|
|
122
|
+
* computes them, at the head commit of its latest status. A patch already
|
|
123
|
+
* read at the same head commit and base branch is reused from memory, for
|
|
124
|
+
* any Session, until `maxCachedDiffBytes` evicts it.
|
|
125
|
+
* @param session - Session the change request is bound to.
|
|
126
|
+
* @param url - binding URL of the change request.
|
|
127
|
+
* @param signal - request cancellation.
|
|
128
|
+
* @returns the files, the head commit, each file's web page, and the commits the checkout has beyond the head.
|
|
129
|
+
* @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves;
|
|
130
|
+
* `forgePanel/diff-too-large` when the host or its provider refuses the diff over a size limit;
|
|
131
|
+
* `forgePanel/diff-failed` before its status was read and when the host does not provide the diff otherwise.
|
|
132
|
+
*/
|
|
133
|
+
changeRequestDiff(session: Session, url: string, signal: AbortSignal): Promise<ForgeChangeRequestDiff>;
|
|
134
|
+
/**
|
|
135
|
+
* Read one file of a change request's repository at a commit, which
|
|
136
|
+
* supplies the unchanged lines between the hunks of its diff.
|
|
137
|
+
* @param session - Session the change request is bound to.
|
|
138
|
+
* @param url - binding URL of the change request.
|
|
139
|
+
* @param commit - commit object name, the head commit of the diff.
|
|
140
|
+
* @param path - path relative to the repository root.
|
|
141
|
+
* @param signal - request cancellation.
|
|
142
|
+
* @returns the text.
|
|
143
|
+
* @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves;
|
|
144
|
+
* `forgePanel/diff-too-large` when the host or its provider refuses the file over a size limit;
|
|
145
|
+
* `forgePanel/diff-failed` when the host does not provide the file otherwise.
|
|
146
|
+
*/
|
|
147
|
+
changeRequestText(session: Session, url: string, commit: string, path: string, signal: AbortSignal): Promise<string>;
|
|
148
|
+
/**
|
|
149
|
+
* Mark a draft change request of a Session ready for review; the change
|
|
150
|
+
* request is polled again once the host answers.
|
|
151
|
+
* @param session - Session the change request is bound to.
|
|
152
|
+
* @param url - binding URL of the change request.
|
|
153
|
+
* @param signal - request cancellation.
|
|
154
|
+
* @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves;
|
|
155
|
+
* `forgePanel/action-failed` with the host's reason when the host refuses or cannot be reached.
|
|
156
|
+
*/
|
|
157
|
+
markReady(session: Session, url: string, signal: AbortSignal): Promise<void>;
|
|
158
|
+
/**
|
|
159
|
+
* Merge a change request of a Session while its head is still `headSha`;
|
|
160
|
+
* the change request is polled again once the host answers.
|
|
161
|
+
* @param session - Session the change request is bound to.
|
|
162
|
+
* @param url - binding URL of the change request.
|
|
163
|
+
* @param method - how the commits enter the base branch.
|
|
164
|
+
* @param headSha - head commit the user confirmed.
|
|
165
|
+
* @param signal - request cancellation.
|
|
166
|
+
* @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves;
|
|
167
|
+
* `forgePanel/stale-head` when the head moved past `headSha`; `forgePanel/action-failed` with the host's
|
|
168
|
+
* reason when the host refuses otherwise or cannot be reached.
|
|
169
|
+
*/
|
|
170
|
+
merge(session: Session, url: string, method: MergeMethod, headSha: string, signal: AbortSignal): Promise<void>;
|
|
171
|
+
/**
|
|
172
|
+
* Ask for a new worktree before the Session's first turn, replacing an open
|
|
173
|
+
* request and forgetting a failed attempt. While the next message waits in
|
|
174
|
+
* the inbox, or else at the first step proposal, the panel creates a branch
|
|
175
|
+
* from `from`, or from HEAD of the current checkout when it is null, and
|
|
176
|
+
* enters its checkout. A message that already waits after a failed or
|
|
177
|
+
* stopped attempt keeps waiting for {@link ForgePanelController.retryWorktree}.
|
|
178
|
+
* @param session - Session without a started turn.
|
|
179
|
+
* @param from - local base branch, or null for HEAD.
|
|
180
|
+
* @param signal - request cancellation.
|
|
181
|
+
* @throws `forgePanel/invalid-branch` when `from` is empty; `forgePanel/worktrees-unavailable`
|
|
182
|
+
* without a worktree service; `forgePanel/session-started` after a turn started or the worktree was
|
|
183
|
+
* created; `forgePanel/session-busy` while the worktree is being created.
|
|
184
|
+
*/
|
|
185
|
+
requestWorktree(session: Session, from: string | null, signal: AbortSignal): Promise<void>;
|
|
186
|
+
/**
|
|
187
|
+
* Withdraw the open worktree request of a Session with its failed attempt,
|
|
188
|
+
* which lets a waiting message go on in the current checkout; without a
|
|
189
|
+
* request the Session is unchanged. Withdrawing needs no worktree service.
|
|
190
|
+
* @param session - Session without a started turn.
|
|
191
|
+
* @param signal - request cancellation.
|
|
192
|
+
* @throws `forgePanel/session-started` after a turn started or the worktree was created;
|
|
193
|
+
* `forgePanel/session-busy` while the worktree is being created.
|
|
194
|
+
*/
|
|
195
|
+
cancelWorktree(session: Session, signal: AbortSignal): Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* Stop the creation a message of the Session waits for; the message keeps
|
|
198
|
+
* waiting with the request still open. Without such a creation the Session
|
|
199
|
+
* is unchanged.
|
|
200
|
+
* @param session - Session whose creation stops.
|
|
201
|
+
* @param signal - request cancellation.
|
|
202
|
+
*/
|
|
203
|
+
stopCreation(session: Session, signal: AbortSignal): Promise<void>;
|
|
204
|
+
/**
|
|
205
|
+
* Make another attempt, with a new branch name, at the worktree a message
|
|
206
|
+
* of the Session waits for after a failed or stopped attempt.
|
|
207
|
+
* @param session - Session whose message waits.
|
|
208
|
+
* @param signal - request cancellation.
|
|
209
|
+
* @throws `forgePanel/not-waiting` when no message waits or an attempt is running.
|
|
210
|
+
*/
|
|
211
|
+
retryWorktree(session: Session, signal: AbortSignal): Promise<void>;
|
|
212
|
+
/**
|
|
213
|
+
* Check out the created worktree of a Session again at its recorded
|
|
214
|
+
* directory when that directory is gone: its branch when the branch still
|
|
215
|
+
* exists, otherwise a new branch of the same name at the base commit. Changes
|
|
216
|
+
* that were never committed are not recovered. Runs as Agent maintenance,
|
|
217
|
+
* inside the wait of a message that waits for the restoration, which then
|
|
218
|
+
* goes on; without a missing directory the Session is unchanged.
|
|
219
|
+
* @param session - Session whose worktree directory is gone.
|
|
220
|
+
* @param signal - request cancellation, which aborts the restoration.
|
|
221
|
+
* @throws `forgePanel/no-worktree` without a created worktree; `forgePanel/worktrees-unavailable`
|
|
222
|
+
* without a worktree service; `forgePanel/session-busy` while the Session's Agent is not loaded or
|
|
223
|
+
* has other work; `forgePanel/restore-failed` when Git fails.
|
|
224
|
+
*/
|
|
225
|
+
restoreWorktree(session: Session, signal: AbortSignal): Promise<void>;
|
|
226
|
+
/**
|
|
227
|
+
* Move a Session from its created worktree to the source checkout the
|
|
228
|
+
* worktree came from; the Session no longer works in the worktree. Runs as
|
|
229
|
+
* Agent maintenance, inside the wait of a message that waits for the removed
|
|
230
|
+
* worktree, which then goes on.
|
|
231
|
+
* @param session - Session with a created worktree.
|
|
232
|
+
* @param signal - request cancellation.
|
|
233
|
+
* @throws `forgePanel/no-worktree` without a created worktree; `forgePanel/session-busy` while the
|
|
234
|
+
* Session's Agent is not loaded or has other work; the working-directory service's error when the
|
|
235
|
+
* source checkout no longer exists.
|
|
236
|
+
*/
|
|
237
|
+
continueInProject(session: Session, signal: AbortSignal): Promise<void>;
|
|
238
|
+
/**
|
|
239
|
+
* Hold the turn of a message entering a Session's inbox while the
|
|
240
|
+
* Session's requested worktree does not exist yet, or while the worktree
|
|
241
|
+
* the Session works in is checked and, when gone, until it is restored or
|
|
242
|
+
* left. The message is entering, so the delivery has not woken the Agent
|
|
243
|
+
* yet and its wake waits for the hold.
|
|
244
|
+
* @param agent - Agent whose inbox receives the message.
|
|
245
|
+
*/
|
|
246
|
+
private holdTurn;
|
|
247
|
+
/**
|
|
248
|
+
* Check whether the worktree the Session works in is gone.
|
|
249
|
+
* @param session - Session to check.
|
|
250
|
+
* @param signal - cancellation of the check.
|
|
251
|
+
* @returns the missing worktree, or null while it exists or once the Session works elsewhere.
|
|
252
|
+
* @throws when the filesystem or Git cannot answer.
|
|
253
|
+
*/
|
|
254
|
+
private missingFor;
|
|
255
|
+
/** Inspect the checkout of the Session's current directory, which local diffs read. */
|
|
256
|
+
private checkoutOf;
|
|
257
|
+
/** A visible binding of the Session that a provider serves, which actions and reads are limited to. */
|
|
258
|
+
private bound;
|
|
259
|
+
private worktreeState;
|
|
260
|
+
private editableWorktree;
|
|
261
|
+
/** The worktree state of a Session whose request may still change: no turn started, nothing created, and no attempt running. */
|
|
262
|
+
private changeableWorktree;
|
|
263
|
+
private createdWorktree;
|
|
264
|
+
/**
|
|
265
|
+
* Run work as maintenance of the Session's Agent: inside the wait of a
|
|
266
|
+
* message that waits for the removed worktree, else as a task of its own,
|
|
267
|
+
* which the Agent refuses while it has other work.
|
|
268
|
+
*/
|
|
269
|
+
private maintain;
|
|
270
|
+
/** The shared change request states, created for the first stream from the Host's Session and storage services. */
|
|
271
|
+
private changeRequestStatesHub;
|
|
272
|
+
private panelOf;
|
|
273
|
+
}
|
|
274
|
+
export default ForgePanelController;
|
|
275
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local changes of a Session's checkout: where the `branch` scope forks, the
|
|
3
|
+
* patch of one scope with its untracked files, the new-side text of one file,
|
|
4
|
+
* and the size of the `branch` scope for the panel's card. Git runs through
|
|
5
|
+
* the confined runner; untracked and working-tree files are read through
|
|
6
|
+
* `ctx.fs`, both within `maxDiffBytes`.
|
|
7
|
+
*/
|
|
8
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
9
|
+
import type { Session } from '@deepseek-ai/dsh-session';
|
|
10
|
+
import type { Git, GitConfig, Inspection } from './git.ts';
|
|
11
|
+
import type { ForgeLocalChanges, ForgeLocalDiff, ForgeLocalScope, ForgeSessionWorktree } from './types.ts';
|
|
12
|
+
/** Git limits plus the size limits of local diffs. */
|
|
13
|
+
export interface DiffConfig extends GitConfig {
|
|
14
|
+
/** Largest patch, untracked file, or new-side file in bytes. */
|
|
15
|
+
readonly maxDiffBytes: number;
|
|
16
|
+
/** Most untracked files listed. */
|
|
17
|
+
readonly maxUntrackedFiles: number;
|
|
18
|
+
}
|
|
19
|
+
/** The commit the `branch` scope compares with and the name the panel shows for it. */
|
|
20
|
+
export interface ForkPoint {
|
|
21
|
+
/** Full commit object name. */
|
|
22
|
+
readonly commit: string;
|
|
23
|
+
/** Remote branch such as `origin/master`, the created worktree's base branch, or an abbreviated commit. */
|
|
24
|
+
readonly label: string;
|
|
25
|
+
}
|
|
26
|
+
/** Thrown when a patch, a file list, or a file exceeds `maxDiffBytes`. */
|
|
27
|
+
export declare class DiffTooLarge extends Error {
|
|
28
|
+
name: string;
|
|
29
|
+
}
|
|
30
|
+
/** Thrown for the `branch` scope of a checkout without a fork point. */
|
|
31
|
+
export declare class NoForkPoint extends Error {
|
|
32
|
+
name: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Find where the `branch` scope forks: the base commit of the worktree the
|
|
36
|
+
* Session created while the checkout is that worktree, else the merge base of
|
|
37
|
+
* HEAD with the default branch of the first remote that names one, in the
|
|
38
|
+
* order the panel recognizes code hosts.
|
|
39
|
+
* @param git - runner bound to the checkout.
|
|
40
|
+
* @param inspection - the checkout and its remotes.
|
|
41
|
+
* @param created - worktree the Session created, or null.
|
|
42
|
+
* @returns the fork point, or null when no remote names a default branch or HEAD shares no history with it.
|
|
43
|
+
*/
|
|
44
|
+
export declare function forkPoint(git: Git, inspection: Inspection, created: ForgeSessionWorktree | null): Promise<ForkPoint | null>;
|
|
45
|
+
/**
|
|
46
|
+
* Read the changes one scope covers in the checkout at `root`.
|
|
47
|
+
* @param ctx - context that provides `fs`, `subprocess`, `sandbox`, and `sandboxPolicy`.
|
|
48
|
+
* @param config - Git and size limits.
|
|
49
|
+
* @param session - Session whose sandbox policy and execution world apply.
|
|
50
|
+
* @param root - top-level directory of the checkout.
|
|
51
|
+
* @param fork - fork point of the `branch` scope, or null without one.
|
|
52
|
+
* @param scope - which changes to read.
|
|
53
|
+
* @param signal - cancellation of every command and read.
|
|
54
|
+
* @returns tracked files in Git's order, then untracked files unless the scope is `staged`.
|
|
55
|
+
* @throws NoForkPoint for the `branch` scope without `fork`; DiffTooLarge over `maxDiffBytes`; an Error when Git fails.
|
|
56
|
+
*/
|
|
57
|
+
export declare function localDiff(ctx: Context, config: DiffConfig, session: Session, root: string, fork: ForkPoint | null, scope: ForgeLocalScope, signal: AbortSignal): Promise<ForgeLocalDiff>;
|
|
58
|
+
/**
|
|
59
|
+
* Read the new side of one file in a scope, which supplies the unchanged
|
|
60
|
+
* lines between hunks: the index for `staged`, else the working tree.
|
|
61
|
+
* @param ctx - context that provides `fs`, `subprocess`, `sandbox`, and `sandboxPolicy`.
|
|
62
|
+
* @param config - Git and size limits.
|
|
63
|
+
* @param session - Session whose sandbox policy and execution world apply.
|
|
64
|
+
* @param root - top-level directory of the checkout.
|
|
65
|
+
* @param scope - the scope whose new side to read.
|
|
66
|
+
* @param path - path relative to `root`, as the diff names it.
|
|
67
|
+
* @param signal - cancellation.
|
|
68
|
+
* @returns the text.
|
|
69
|
+
* @throws DiffTooLarge over `maxDiffBytes`; an Error for a path outside the checkout, binary content, or a failed read.
|
|
70
|
+
*/
|
|
71
|
+
export declare function localText(ctx: Context, config: DiffConfig, session: Session, root: string, scope: ForgeLocalScope, path: string, signal: AbortSignal): Promise<string>;
|
|
72
|
+
/**
|
|
73
|
+
* Measure the `branch` scope for the panel's card.
|
|
74
|
+
* @param ctx - context that provides `fs`, `subprocess`, `sandbox`, and `sandboxPolicy`.
|
|
75
|
+
* @param config - Git and size limits.
|
|
76
|
+
* @param session - Session whose sandbox policy and execution world apply.
|
|
77
|
+
* @param inspection - the checkout and its remotes.
|
|
78
|
+
* @param created - worktree the Session created, or null.
|
|
79
|
+
* @param signal - cancellation of every command and read.
|
|
80
|
+
* @returns the base and the changed files, or null without a fork point.
|
|
81
|
+
* @throws DiffTooLarge when the untracked file list exceeds `maxDiffBytes`; an Error when Git fails.
|
|
82
|
+
*/
|
|
83
|
+
export declare function localChanges(ctx: Context, config: DiffConfig, session: Session, inspection: Inspection, created: ForgeSessionWorktree | null, signal: AbortSignal): Promise<ForgeLocalChanges | null>;
|
|
84
|
+
/**
|
|
85
|
+
* Count the commits the checkout has beyond a change request's head, which a
|
|
86
|
+
* change request diff does not show yet.
|
|
87
|
+
* @param git - runner bound to the Session's directory.
|
|
88
|
+
* @param branch - the change request's head branch.
|
|
89
|
+
* @param commit - the change request's head commit.
|
|
90
|
+
* @returns the count, or null on another branch, outside a checkout, or without the commit locally.
|
|
91
|
+
*/
|
|
92
|
+
export declare function aheadOf(git: Git, branch: string, commit: string): Promise<number | null>;
|
|
93
|
+
//# sourceMappingURL=local-diff.d.ts.map
|