dsh-git-scm 0.0.0-stage → 0.1.0
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.md +255 -2
- package/cordis.patch.yml +6 -0
- package/icon.svg +11 -0
- package/lib/client.js +6062 -0
- package/lib/client.js.map +1 -0
- package/lib/host/commit-message.d.ts +55 -0
- package/lib/host/git.d.ts +456 -0
- package/lib/host/types.d.ts +77 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +2382 -0
- package/lib/index.js.map +1 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +77 -4
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { CommitMessageContext } from './git.ts';
|
|
2
|
+
/** How the model should treat the drafted message. */
|
|
3
|
+
export type CommitMessageMode = 'generate' | 'improve';
|
|
4
|
+
/** Message shape the caller asked for; `auto` leaves it to the model and repository style. */
|
|
5
|
+
export type CommitMessageStyle = 'auto' | 'conventional' | 'single' | 'detailed';
|
|
6
|
+
/** Every accepted style, for validating an untrusted request field. */
|
|
7
|
+
export declare const COMMIT_MESSAGE_STYLES: readonly CommitMessageStyle[];
|
|
8
|
+
/** One prompt handed to the model. */
|
|
9
|
+
export interface CommitMessagePrompt {
|
|
10
|
+
/** Instructions and output contract. */
|
|
11
|
+
readonly system: string;
|
|
12
|
+
/** Change context and, for an improvement, the draft. */
|
|
13
|
+
readonly user: string;
|
|
14
|
+
}
|
|
15
|
+
/** Dispatch one prompt to a model and resolve its text. */
|
|
16
|
+
export type CommitMessageGenerator = (prompt: CommitMessagePrompt) => Promise<string>;
|
|
17
|
+
/** One commit-message generation request. */
|
|
18
|
+
export interface CommitMessageRequest {
|
|
19
|
+
/** The change context read from the checkout. */
|
|
20
|
+
readonly context: CommitMessageContext;
|
|
21
|
+
/** Whether the model writes from scratch or improves the draft. */
|
|
22
|
+
readonly mode: CommitMessageMode;
|
|
23
|
+
/** The user's current draft, for `improve`. */
|
|
24
|
+
readonly draft: string;
|
|
25
|
+
/** Active app locale id, deciding the output language for `generate`. */
|
|
26
|
+
readonly language: string;
|
|
27
|
+
/** Requested message shape; omitted reads as `auto`. */
|
|
28
|
+
readonly style?: CommitMessageStyle | undefined;
|
|
29
|
+
/** Whether the caller pinned the language rule instead of following the UI. */
|
|
30
|
+
readonly languagePinned?: boolean | undefined;
|
|
31
|
+
/** Model seam supplied by the Host; absent when no route is configured. */
|
|
32
|
+
readonly generate: CommitMessageGenerator | undefined;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Build the system and user prompt of one request.
|
|
36
|
+
* @param request - change context, mode, draft, and app locale.
|
|
37
|
+
* @returns the two prompt parts handed to the model.
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildCommitMessagePrompt(request: Pick<CommitMessageRequest, 'context' | 'mode' | 'draft' | 'language' | 'style' | 'languagePinned'>): CommitMessagePrompt;
|
|
40
|
+
/**
|
|
41
|
+
* Normalize one model answer into a commit message.
|
|
42
|
+
* @param text - raw model output.
|
|
43
|
+
* @returns the cleaned message, possibly empty.
|
|
44
|
+
*/
|
|
45
|
+
export declare function cleanCommitMessage(text: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Generate or improve one commit message.
|
|
48
|
+
* @param request - change context, mode, draft, language, and the model seam.
|
|
49
|
+
* @returns the cleaned message.
|
|
50
|
+
* @throws {RequestError} `INVALID` for an empty change set or a missing model
|
|
51
|
+
* route, `INTERNAL` when the model call fails or returns nothing usable.
|
|
52
|
+
*/
|
|
53
|
+
export declare function generateCommitMessage(request: CommitMessageRequest): Promise<{
|
|
54
|
+
message: string;
|
|
55
|
+
}>;
|
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
import { Exec, GitLimits } from './types.ts';
|
|
2
|
+
/** Environment every Git call must run with: no inherited repository selectors, no prompts, no lazy fetches. */
|
|
3
|
+
export declare const GIT_ENV: Readonly<Record<string, string | undefined>>;
|
|
4
|
+
/** Stable failure codes this layer raises; the Host route relays them onto the wire. */
|
|
5
|
+
export type GitErrorCode = 'NOT_A_REPO' | 'INVALID' | 'GIT_FAILED' | 'TIMEOUT' | 'SPAWN_FAILED' | 'TOO_LARGE' | 'CANCELLED';
|
|
6
|
+
/** A structured Git failure the Host route reports with its `code`. */
|
|
7
|
+
export declare class GitError extends Error {
|
|
8
|
+
/** Stable code such as `NOT_A_REPO`, `INVALID`, or `GIT_FAILED`. */
|
|
9
|
+
readonly code: GitErrorCode;
|
|
10
|
+
/** Raw output excerpt, when one exists. */
|
|
11
|
+
readonly detail: string | null;
|
|
12
|
+
/**
|
|
13
|
+
* @param code - stable code such as `NOT_A_REPO`, `INVALID`, or `GIT_FAILED`.
|
|
14
|
+
* @param message - readable reason, usually Git's first diagnostic line.
|
|
15
|
+
* @param detail - raw output excerpt.
|
|
16
|
+
*/
|
|
17
|
+
constructor(code: GitErrorCode, message: string, detail?: string | null);
|
|
18
|
+
}
|
|
19
|
+
/** Status letters `status --porcelain=v2` reports for one side of a change. */
|
|
20
|
+
export type ChangeStatus = 'modified' | 'added' | 'deleted' | 'renamed' | 'copied' | 'typechange' | 'untracked' | 'conflicted';
|
|
21
|
+
/** One side of a working-tree change as the wire contract reports it. */
|
|
22
|
+
export interface FileEntry {
|
|
23
|
+
/** Repository-relative path. */
|
|
24
|
+
path: string;
|
|
25
|
+
/** Previous path of a rename or copy, else null. */
|
|
26
|
+
origPath: string | null;
|
|
27
|
+
/** Human-readable status, e.g. `modified`. */
|
|
28
|
+
status: ChangeStatus;
|
|
29
|
+
/** Raw porcelain letter, e.g. `M`. */
|
|
30
|
+
code: string;
|
|
31
|
+
/** Whether this entry is the index side of the change. */
|
|
32
|
+
staged: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** The four change lists of one working tree. */
|
|
35
|
+
export interface Changes {
|
|
36
|
+
/** Changes recorded in the index. */
|
|
37
|
+
staged: FileEntry[];
|
|
38
|
+
/** Changes in the working tree, against the index. */
|
|
39
|
+
unstaged: FileEntry[];
|
|
40
|
+
/** Files Git does not track yet. */
|
|
41
|
+
untracked: FileEntry[];
|
|
42
|
+
/** Unmerged paths of a pending merge, rebase, or cherry-pick. */
|
|
43
|
+
conflicted: FileEntry[];
|
|
44
|
+
}
|
|
45
|
+
/** Change lists plus the total count the cap applies to. */
|
|
46
|
+
export interface ChangesSummary extends Changes {
|
|
47
|
+
/** Number of entries across all four lists, capped by `maxFiles`. */
|
|
48
|
+
total: number;
|
|
49
|
+
}
|
|
50
|
+
/** One configured remote. */
|
|
51
|
+
export interface Remote {
|
|
52
|
+
/** Remote name such as `origin`. */
|
|
53
|
+
name: string;
|
|
54
|
+
/** Fetch URL. */
|
|
55
|
+
url: string;
|
|
56
|
+
}
|
|
57
|
+
/** The checked-out commit, as the repository block reports it. */
|
|
58
|
+
export interface CommitHead {
|
|
59
|
+
/** Full commit hash. */
|
|
60
|
+
hash: string;
|
|
61
|
+
/** Abbreviated commit hash. */
|
|
62
|
+
short: string;
|
|
63
|
+
/** Subject line. */
|
|
64
|
+
subject: string;
|
|
65
|
+
/** Author name. */
|
|
66
|
+
author: string;
|
|
67
|
+
/** Author timestamp in Unix epoch milliseconds, or null. */
|
|
68
|
+
date: number | null;
|
|
69
|
+
/** Raw commit message body, so amending starts from the previous message. */
|
|
70
|
+
message: string;
|
|
71
|
+
}
|
|
72
|
+
/** Operation the checkout is in the middle of, or null when it is clean. */
|
|
73
|
+
export type PendingOperation = 'cherry-pick' | 'revert' | 'merge' | 'rebase';
|
|
74
|
+
/** Ahead/behind counts between HEAD and its upstream. */
|
|
75
|
+
export interface AheadBehind {
|
|
76
|
+
/** Local commits the upstream does not have, or null without an upstream. */
|
|
77
|
+
ahead: number | null;
|
|
78
|
+
/** Upstream commits HEAD does not have, or null without an upstream. */
|
|
79
|
+
behind: number | null;
|
|
80
|
+
}
|
|
81
|
+
/** Repository identity block shared by `summary` and `status`. */
|
|
82
|
+
export interface Repo {
|
|
83
|
+
/** Absolute work-tree root. */
|
|
84
|
+
root: string;
|
|
85
|
+
/** Base name of the work-tree root. */
|
|
86
|
+
name: string;
|
|
87
|
+
/** Checked-out branch, or null when HEAD is detached. */
|
|
88
|
+
branch: string | null;
|
|
89
|
+
/** Whether HEAD is detached. */
|
|
90
|
+
detached: boolean;
|
|
91
|
+
/** Whether the repository has no commit yet. */
|
|
92
|
+
unborn: boolean;
|
|
93
|
+
/** Upstream branch such as `origin/main`, or null. */
|
|
94
|
+
upstream: string | null;
|
|
95
|
+
/** Local commits not pushed, or null without an upstream. */
|
|
96
|
+
ahead: number | null;
|
|
97
|
+
/** Remote commits not pulled, or null without an upstream. */
|
|
98
|
+
behind: number | null;
|
|
99
|
+
/** Configured remotes. */
|
|
100
|
+
remotes: Remote[];
|
|
101
|
+
/** Checked-out commit, or null while unborn. */
|
|
102
|
+
head: CommitHead | null;
|
|
103
|
+
/** mtime of `FETCH_HEAD` in Unix epoch milliseconds, or null. */
|
|
104
|
+
lastFetchAt: number | null;
|
|
105
|
+
/** Whether the checkout is a linked worktree of a shared Git directory. */
|
|
106
|
+
isWorktree: boolean;
|
|
107
|
+
/** In-progress cherry-pick, revert, merge, or rebase, or null. */
|
|
108
|
+
pending: PendingOperation | null;
|
|
109
|
+
/** Total working-tree changes, capped by `maxFiles`. */
|
|
110
|
+
totalChanges: number;
|
|
111
|
+
}
|
|
112
|
+
/** One local or remote branch. */
|
|
113
|
+
export interface Branch {
|
|
114
|
+
/** Short branch name; remote entries are prefixed with the remote name. */
|
|
115
|
+
name: string;
|
|
116
|
+
/** Whether the branch is local or remote-tracking. */
|
|
117
|
+
kind: 'local' | 'remote';
|
|
118
|
+
/** Whether this is the checked-out branch. */
|
|
119
|
+
current: boolean;
|
|
120
|
+
/** Configured upstream branch, or null. */
|
|
121
|
+
upstream: string | null;
|
|
122
|
+
/** Local commits the upstream does not have, or null. */
|
|
123
|
+
ahead: number | null;
|
|
124
|
+
/** Upstream commits the branch does not have, or null. */
|
|
125
|
+
behind: number | null;
|
|
126
|
+
/** Abbreviated tip hash. */
|
|
127
|
+
hash: string;
|
|
128
|
+
/** Subject of the tip commit. */
|
|
129
|
+
subject: string;
|
|
130
|
+
/** Committer timestamp in Unix epoch milliseconds, or null. */
|
|
131
|
+
date: number | null;
|
|
132
|
+
/** Remote name for a remote branch, else null. */
|
|
133
|
+
remote: string | null;
|
|
134
|
+
}
|
|
135
|
+
/** Local and remote branch lists. */
|
|
136
|
+
export interface Branches {
|
|
137
|
+
/** Local branches, the current one first. */
|
|
138
|
+
local: Branch[];
|
|
139
|
+
/** Remote-tracking branches, symbolic `…/HEAD` entries excluded. */
|
|
140
|
+
remote: Branch[];
|
|
141
|
+
}
|
|
142
|
+
/** One stash entry. */
|
|
143
|
+
export interface Stash {
|
|
144
|
+
/** Stack index, newest first. */
|
|
145
|
+
index: number;
|
|
146
|
+
/** Stash message. */
|
|
147
|
+
message: string;
|
|
148
|
+
}
|
|
149
|
+
/** One tag. */
|
|
150
|
+
export interface Tag {
|
|
151
|
+
/** Short tag name. */
|
|
152
|
+
name: string;
|
|
153
|
+
/** Creation timestamp in Unix epoch milliseconds, or null. */
|
|
154
|
+
date: number | null;
|
|
155
|
+
}
|
|
156
|
+
/** The repository snapshot `gitSummary` answers. */
|
|
157
|
+
export interface Summary {
|
|
158
|
+
/** Repository identity. */
|
|
159
|
+
repo: Repo;
|
|
160
|
+
/** Working-tree changes. */
|
|
161
|
+
changes: Changes;
|
|
162
|
+
/** Local and remote branches. */
|
|
163
|
+
branches: Branches;
|
|
164
|
+
/** Stash stack. */
|
|
165
|
+
stashes: Stash[];
|
|
166
|
+
/** Tags. */
|
|
167
|
+
tags: Tag[];
|
|
168
|
+
}
|
|
169
|
+
/** The light snapshot `gitStatus` answers. */
|
|
170
|
+
export interface StatusSnapshot {
|
|
171
|
+
/** Repository identity. */
|
|
172
|
+
repo: Repo;
|
|
173
|
+
/** Working-tree changes. */
|
|
174
|
+
changes: Changes;
|
|
175
|
+
}
|
|
176
|
+
/** One unified patch. */
|
|
177
|
+
export interface Diff {
|
|
178
|
+
/** Repository-relative path the patch is addressed by. */
|
|
179
|
+
path: string;
|
|
180
|
+
/** Whether the patch reads the index instead of the working tree. */
|
|
181
|
+
staged: boolean;
|
|
182
|
+
/** Raw unified patch text, trimmed at `maxDiffBytes`. */
|
|
183
|
+
text: string;
|
|
184
|
+
/** Whether the change was detected as binary. */
|
|
185
|
+
binary: boolean;
|
|
186
|
+
/** Whether the patch was trimmed at `maxDiffBytes`. */
|
|
187
|
+
tooLarge: boolean;
|
|
188
|
+
/** Added line count. */
|
|
189
|
+
added: number;
|
|
190
|
+
/** Deleted line count. */
|
|
191
|
+
deleted: number;
|
|
192
|
+
}
|
|
193
|
+
/** One commit of a commit page. */
|
|
194
|
+
export interface Commit {
|
|
195
|
+
/** Full commit hash. */
|
|
196
|
+
hash: string;
|
|
197
|
+
/** Abbreviated commit hash. */
|
|
198
|
+
short: string;
|
|
199
|
+
/** Subject line. */
|
|
200
|
+
subject: string;
|
|
201
|
+
/** Author name. */
|
|
202
|
+
author: string;
|
|
203
|
+
/** Author timestamp in Unix epoch milliseconds, or null. */
|
|
204
|
+
date: number | null;
|
|
205
|
+
/** Parent count; a merge commit has more than one. */
|
|
206
|
+
parents: number;
|
|
207
|
+
/** Names HEAD and the remote refs point at through this commit. */
|
|
208
|
+
refs: string[];
|
|
209
|
+
}
|
|
210
|
+
/** One page of a commit walk. */
|
|
211
|
+
export interface CommitPage {
|
|
212
|
+
/** Resolved commit the walk started from. */
|
|
213
|
+
ref: string;
|
|
214
|
+
/** Commits of this page, newest first. */
|
|
215
|
+
commits: Commit[];
|
|
216
|
+
/** Whether further commits exist after this page. */
|
|
217
|
+
more: boolean;
|
|
218
|
+
}
|
|
219
|
+
/** One page of one file's history. */
|
|
220
|
+
export interface FileHistoryPage {
|
|
221
|
+
/** Repository-relative path the history follows. */
|
|
222
|
+
path: string;
|
|
223
|
+
/** Commits of this page, newest first. */
|
|
224
|
+
commits: Commit[];
|
|
225
|
+
/** Whether further commits exist after this page. */
|
|
226
|
+
more: boolean;
|
|
227
|
+
}
|
|
228
|
+
/** One file a commit changed, with its line counts. */
|
|
229
|
+
export interface CommitFile extends FileEntry {
|
|
230
|
+
/** Added lines, or null for a binary file. */
|
|
231
|
+
additions: number | null;
|
|
232
|
+
/** Deleted lines, or null for a binary file. */
|
|
233
|
+
deletions: number | null;
|
|
234
|
+
}
|
|
235
|
+
/** The changed files of one commit. */
|
|
236
|
+
export interface CommitFiles {
|
|
237
|
+
/** Full hash of the resolved commit. */
|
|
238
|
+
hash: string;
|
|
239
|
+
/** Changed files against the commit's first parent. */
|
|
240
|
+
files: CommitFile[];
|
|
241
|
+
/** Added lines across the reported files. */
|
|
242
|
+
additions: number;
|
|
243
|
+
/** Deleted lines across the reported files. */
|
|
244
|
+
deletions: number;
|
|
245
|
+
/** Whether the file list hit `maxFiles`. */
|
|
246
|
+
truncated: boolean;
|
|
247
|
+
}
|
|
248
|
+
/** One remote reference a fetch moved. */
|
|
249
|
+
export interface RefChange {
|
|
250
|
+
/** Short remote ref name. */
|
|
251
|
+
ref: string;
|
|
252
|
+
/** Tip before the fetch, or null when the ref is new. */
|
|
253
|
+
from: string | null;
|
|
254
|
+
/** Tip after the fetch, or null when the ref disappeared. */
|
|
255
|
+
to: string | null;
|
|
256
|
+
}
|
|
257
|
+
/** Result of one mutation Git operation. */
|
|
258
|
+
export interface ActionResult {
|
|
259
|
+
/** Operator-readable summary. */
|
|
260
|
+
message: string;
|
|
261
|
+
/** Raw output excerpt, when one exists. */
|
|
262
|
+
detail: string | null;
|
|
263
|
+
/** Fetch only: whether remote references moved. */
|
|
264
|
+
updated?: boolean;
|
|
265
|
+
/** Fetch only: the remote references that moved. */
|
|
266
|
+
changed?: RefChange[];
|
|
267
|
+
/** `pullBranch` only: commits the fast-forward brought in. */
|
|
268
|
+
commits?: number;
|
|
269
|
+
}
|
|
270
|
+
/** Line counts of one changed file. */
|
|
271
|
+
export interface LineCount {
|
|
272
|
+
/** Added lines, or null for a binary file. */
|
|
273
|
+
additions: number | null;
|
|
274
|
+
/** Deleted lines, or null for a binary file. */
|
|
275
|
+
deletions: number | null;
|
|
276
|
+
}
|
|
277
|
+
/** Request of one repository snapshot read. */
|
|
278
|
+
export interface GitSummaryRequest {
|
|
279
|
+
/** The caller's process seam. */
|
|
280
|
+
exec: Exec;
|
|
281
|
+
/** Directory inside the checkout. */
|
|
282
|
+
cwd: string;
|
|
283
|
+
/** Overrides for the layer's default limits. */
|
|
284
|
+
limits?: Partial<GitLimits> | undefined;
|
|
285
|
+
}
|
|
286
|
+
/** Request of one working-tree patch read. */
|
|
287
|
+
export interface GitDiffRequest extends GitSummaryRequest {
|
|
288
|
+
/** Repository-relative path to diff. */
|
|
289
|
+
path: string;
|
|
290
|
+
/** Read the index instead of the working tree. */
|
|
291
|
+
staged?: boolean | undefined;
|
|
292
|
+
/** Synthesize the patch of an untracked file. */
|
|
293
|
+
untracked?: boolean | undefined;
|
|
294
|
+
}
|
|
295
|
+
/** Request of one branch page read. */
|
|
296
|
+
export interface GitCommitsRequest extends GitSummaryRequest {
|
|
297
|
+
/** Ref or commit to walk. */
|
|
298
|
+
ref: string;
|
|
299
|
+
/** Commits to skip. */
|
|
300
|
+
skip?: number | undefined;
|
|
301
|
+
/** Page size; the layer caps it at 200. */
|
|
302
|
+
limit?: number | undefined;
|
|
303
|
+
}
|
|
304
|
+
/** Request of one file history page read. */
|
|
305
|
+
export interface GitFileHistoryRequest extends GitSummaryRequest {
|
|
306
|
+
/** Repository-relative path whose history is read. */
|
|
307
|
+
path: string;
|
|
308
|
+
/** Commits to skip. */
|
|
309
|
+
skip?: number | undefined;
|
|
310
|
+
/** Page size; the layer caps it at 200. */
|
|
311
|
+
limit?: number | undefined;
|
|
312
|
+
}
|
|
313
|
+
/** Request of one commit's changed files read. */
|
|
314
|
+
export interface GitCommitFilesRequest extends GitSummaryRequest {
|
|
315
|
+
/** Commit hash or abbreviation. */
|
|
316
|
+
hash: string;
|
|
317
|
+
}
|
|
318
|
+
/** Request of one file patch inside a commit. */
|
|
319
|
+
export interface GitCommitDiffRequest extends GitSummaryRequest {
|
|
320
|
+
/** Commit hash or abbreviation. */
|
|
321
|
+
hash: string;
|
|
322
|
+
/** Repository-relative path to diff. */
|
|
323
|
+
path: string;
|
|
324
|
+
}
|
|
325
|
+
/** Request of one stash patch read. */
|
|
326
|
+
export interface GitStashDiffRequest extends GitSummaryRequest {
|
|
327
|
+
/** Stash stack index. */
|
|
328
|
+
index: unknown;
|
|
329
|
+
}
|
|
330
|
+
/** Request of one mutation operation. */
|
|
331
|
+
export interface GitActionRequest {
|
|
332
|
+
/** The caller's process seam. */
|
|
333
|
+
exec: Exec;
|
|
334
|
+
/** Directory inside the checkout. */
|
|
335
|
+
cwd: string;
|
|
336
|
+
/** Operation name from {@link OPERATIONS}. */
|
|
337
|
+
operation: string;
|
|
338
|
+
/** Operation-specific parameters, validated per operation. */
|
|
339
|
+
params?: Readonly<Record<string, unknown>> | undefined;
|
|
340
|
+
}
|
|
341
|
+
/** Deadline for operations that talk to a remote: large fetches take minutes. */
|
|
342
|
+
export declare const NETWORK_TIMEOUT_MS = 300000;
|
|
343
|
+
/**
|
|
344
|
+
* Read the repository identity, branches, stashes, and tags in one call.
|
|
345
|
+
* @param request - `exec`, `cwd`, and `limits`.
|
|
346
|
+
* @returns the `Summary` of the wire contract.
|
|
347
|
+
* @throws {GitError} `NOT_A_REPO` outside a work tree, or a structured Git failure.
|
|
348
|
+
*/
|
|
349
|
+
export declare function gitSummary({ exec, cwd, limits }: GitSummaryRequest): Promise<Summary>;
|
|
350
|
+
/**
|
|
351
|
+
* Read the repository identity and working-tree changes only, for polling.
|
|
352
|
+
* @param request - `exec`, `cwd`, and `limits`.
|
|
353
|
+
* @returns the light snapshot.
|
|
354
|
+
* @throws {GitError} `NOT_A_REPO` outside a work tree, or a structured Git failure.
|
|
355
|
+
*/
|
|
356
|
+
export declare function gitStatus({ exec, cwd, limits }: GitSummaryRequest): Promise<StatusSnapshot>;
|
|
357
|
+
/** One changed path a commit-message request describes. */
|
|
358
|
+
export interface CommitMessageFile {
|
|
359
|
+
/** Change status word such as `modified` or `untracked`. */
|
|
360
|
+
readonly status: string;
|
|
361
|
+
/** Repository-relative path. */
|
|
362
|
+
readonly path: string;
|
|
363
|
+
}
|
|
364
|
+
/** The change summary and patch a commit-message request reads. */
|
|
365
|
+
export interface CommitMessageContext {
|
|
366
|
+
/** Whether the patch describes staged changes (the next commit). */
|
|
367
|
+
readonly staged: boolean;
|
|
368
|
+
/** Changed paths across the staged or working-tree lists. */
|
|
369
|
+
readonly files: readonly CommitMessageFile[];
|
|
370
|
+
/** Unified patch, truncated to the read limit. */
|
|
371
|
+
readonly diff: string;
|
|
372
|
+
/** Whether the patch was truncated. */
|
|
373
|
+
readonly truncated: boolean;
|
|
374
|
+
/** Recent commit subjects, newest first, for style reference. */
|
|
375
|
+
readonly recent: readonly string[];
|
|
376
|
+
/** Whether most recent commits use a Conventional Commits type prefix. */
|
|
377
|
+
readonly recentConventional: boolean;
|
|
378
|
+
/** Whether most recent commits carry a body. */
|
|
379
|
+
readonly recentHasBody: boolean;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Read the changes a commit message should describe. Staged changes win; a
|
|
383
|
+
* checkout with none staged is described by its working tree instead.
|
|
384
|
+
* @param request - the `exec` seam, a directory inside the checkout, and limits.
|
|
385
|
+
* @returns the scope, changed paths, patch, truncation flag, and recent subjects.
|
|
386
|
+
* @throws {GitError} `NOT_A_REPO` outside a work tree, or a structured Git failure.
|
|
387
|
+
*/
|
|
388
|
+
export declare function gitCommitMessageContext({ exec, cwd, limits }: GitSummaryRequest): Promise<CommitMessageContext>;
|
|
389
|
+
/**
|
|
390
|
+
* Read one working-tree file's unified diff.
|
|
391
|
+
* @param request - `exec`, `cwd`, `limits`, `path`, `staged`, and `untracked`.
|
|
392
|
+
* @returns the `Diff` of the wire contract.
|
|
393
|
+
* @throws {GitError} `INVALID` for an unsafe path, `NOT_A_REPO` outside a work tree, or a structured Git failure.
|
|
394
|
+
*/
|
|
395
|
+
export declare function gitDiff({ exec, cwd, limits, path, staged, untracked }: GitDiffRequest): Promise<Diff>;
|
|
396
|
+
/**
|
|
397
|
+
* Read one branch's or ref's commits, newest first.
|
|
398
|
+
* @param request - `exec`, `cwd`, `limits`, `ref`, `skip`, and `limit`.
|
|
399
|
+
* @returns the page of commits.
|
|
400
|
+
* @throws {GitError} `INVALID` for an unknown ref, `NOT_A_REPO` outside a work tree, or a structured Git failure.
|
|
401
|
+
*/
|
|
402
|
+
export declare function gitCommits({ exec, cwd, limits, ref, skip, limit }: GitCommitsRequest): Promise<CommitPage>;
|
|
403
|
+
/**
|
|
404
|
+
* Read the commit history of one file, newest first, following renames.
|
|
405
|
+
* @param request - `exec`, `cwd`, `limits`, `path`, `skip`, and `limit`.
|
|
406
|
+
* @returns the page of commits.
|
|
407
|
+
* @throws {GitError} `INVALID` for an unsafe path, `NOT_A_REPO` outside a work tree, or a structured Git failure.
|
|
408
|
+
*/
|
|
409
|
+
export declare function gitFileHistory({ exec, cwd, limits, path, skip, limit }: GitFileHistoryRequest): Promise<FileHistoryPage>;
|
|
410
|
+
/**
|
|
411
|
+
* Read the files one commit changed, against its first parent.
|
|
412
|
+
* @param request - `exec`, `cwd`, `limits`, and `hash`.
|
|
413
|
+
* @returns the changed files with their line counts.
|
|
414
|
+
* @throws {GitError} `INVALID` for an unknown commit, `NOT_A_REPO` outside a work tree, or a structured Git failure.
|
|
415
|
+
*/
|
|
416
|
+
export declare function gitCommitFiles({ exec, cwd, limits, hash }: GitCommitFilesRequest): Promise<CommitFiles>;
|
|
417
|
+
/**
|
|
418
|
+
* Read one file's diff inside a commit.
|
|
419
|
+
* @param request - `exec`, `cwd`, `limits`, `hash`, and `path`.
|
|
420
|
+
* @returns the `Diff` of the wire contract.
|
|
421
|
+
* @throws {GitError} `INVALID` for an unknown commit or unsafe path, `NOT_A_REPO` outside a work tree, or a structured Git failure.
|
|
422
|
+
*/
|
|
423
|
+
export declare function gitCommitDiff({ exec, cwd, limits, hash, path }: GitCommitDiffRequest): Promise<Diff>;
|
|
424
|
+
/**
|
|
425
|
+
* Read one stash entry's patch.
|
|
426
|
+
* @param request - `exec`, `cwd`, `limits`, and `index`.
|
|
427
|
+
* @returns the `Diff` of the wire contract, addressed as `stash@{index}`.
|
|
428
|
+
* @throws {GitError} `INVALID` for a missing index, `NOT_A_REPO` outside a work tree, or a structured Git failure.
|
|
429
|
+
*/
|
|
430
|
+
export declare function gitStashDiff({ exec, cwd, limits, index }: GitStashDiffRequest): Promise<Diff>;
|
|
431
|
+
/** What the panel needs before offering to publish a repository on GitHub. */
|
|
432
|
+
export interface GithubInfo {
|
|
433
|
+
/** Whether the GitHub CLI is installed, signed in, and can read the account. */
|
|
434
|
+
readonly available: boolean;
|
|
435
|
+
/** Authenticated account login, or null. */
|
|
436
|
+
readonly login: string | null;
|
|
437
|
+
/** Why publishing is unavailable, or null. */
|
|
438
|
+
readonly reason: string | null;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Read the GitHub account the CLI would publish under.
|
|
442
|
+
* @param request - the `exec` seam bound to the repository.
|
|
443
|
+
* @returns availability, login, and a refusal reason.
|
|
444
|
+
*/
|
|
445
|
+
export declare function gitGithubInfo({ exec }: {
|
|
446
|
+
exec: Exec;
|
|
447
|
+
}): Promise<GithubInfo>;
|
|
448
|
+
/**
|
|
449
|
+
* Run one Git operation.
|
|
450
|
+
* @param request - `exec`, `cwd`, `operation`, and `params`.
|
|
451
|
+
* @returns the operation result.
|
|
452
|
+
* @throws {GitError} `INVALID` for malformed parameters, `NOT_A_REPO` outside a work tree, or a structured Git failure.
|
|
453
|
+
*/
|
|
454
|
+
export declare function gitAction({ exec, cwd, operation, params }: GitActionRequest): Promise<ActionResult>;
|
|
455
|
+
/** Every operation name this layer accepts, for the caller's request validation. */
|
|
456
|
+
export declare const OPERATIONS: readonly string[];
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared contracts of the Host half: the process seam the Git layer runs
|
|
3
|
+
* through, the failure shape the JSON route reports, and the read limits the
|
|
4
|
+
* caller applies to one snapshot.
|
|
5
|
+
*/
|
|
6
|
+
/** Stable failure codes the browser half already knows how to phrase. */
|
|
7
|
+
export type WireCode = 'NOT_A_REPO' | 'INVALID' | 'INVALID_REQUEST' | 'NO_SESSION' | 'NO_WORKSPACE' | 'GIT_FAILED' | 'TIMEOUT' | 'TOO_LARGE' | 'SPAWN_FAILED' | 'CANCELLED' | 'BUSY' | 'NETWORK' | 'FORBIDDEN' | 'INTERNAL';
|
|
8
|
+
/** Set form of {@link WIRE_CODE_NAMES} used to recognize an already-coded failure. */
|
|
9
|
+
export declare const WIRE_CODES: ReadonlySet<string>;
|
|
10
|
+
/** Failure body of a rejected request, as it goes onto the wire. */
|
|
11
|
+
export interface WireError {
|
|
12
|
+
/** Stable wire code, e.g. `NOT_A_REPO`. */
|
|
13
|
+
readonly code: WireCode;
|
|
14
|
+
/** Operator-readable reason. */
|
|
15
|
+
readonly message: string;
|
|
16
|
+
/** Raw Git output excerpt, when one exists. */
|
|
17
|
+
readonly detail: string | null;
|
|
18
|
+
}
|
|
19
|
+
/** A caught failure that already carries a wire code the page understands. */
|
|
20
|
+
export interface WireFailureLike {
|
|
21
|
+
readonly code: WireCode;
|
|
22
|
+
readonly message: string;
|
|
23
|
+
readonly detail?: unknown;
|
|
24
|
+
}
|
|
25
|
+
/** A rejected request as the route reports it, before it becomes an HTTP body. */
|
|
26
|
+
export declare class RequestError extends Error {
|
|
27
|
+
/** Stable wire code such as `NOT_A_REPO`. */
|
|
28
|
+
readonly code: WireCode;
|
|
29
|
+
/** Raw Git output excerpt, when one exists. */
|
|
30
|
+
readonly detail: string | null;
|
|
31
|
+
/**
|
|
32
|
+
* @param code - stable wire code such as `NOT_A_REPO`.
|
|
33
|
+
* @param message - operator-readable reason.
|
|
34
|
+
* @param detail - raw Git output excerpt, when one exists.
|
|
35
|
+
*/
|
|
36
|
+
constructor(code: WireCode, message: string, detail?: string | null);
|
|
37
|
+
}
|
|
38
|
+
/** Complete output of one program the `exec` seam ran to an allowed exit code. */
|
|
39
|
+
export interface ExecResult {
|
|
40
|
+
/** Captured standard output. */
|
|
41
|
+
readonly stdout: string;
|
|
42
|
+
/** Captured standard error. */
|
|
43
|
+
readonly stderr: string;
|
|
44
|
+
/** Exit code; always one of the requested allowed codes. */
|
|
45
|
+
readonly exitCode: number;
|
|
46
|
+
}
|
|
47
|
+
/** Per-invocation options the Git layer hands the `exec` seam. */
|
|
48
|
+
export interface ExecOptions {
|
|
49
|
+
/** Exit codes that resolve instead of rejecting; defaults to `[0]`. */
|
|
50
|
+
readonly allowedExitCodes?: readonly number[] | undefined;
|
|
51
|
+
/** One-off Git configuration values, passed as `-c key=value`. */
|
|
52
|
+
readonly config?: Readonly<Record<string, string>> | undefined;
|
|
53
|
+
/** Bytes written to the child's stdin, then closed. */
|
|
54
|
+
readonly input?: string | undefined;
|
|
55
|
+
/** Deadline for this command, including executable lookup. */
|
|
56
|
+
readonly timeoutMs?: number | undefined;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Run one program for one Session directory.
|
|
60
|
+
*
|
|
61
|
+
* Resolves for an allowed exit code and rejects otherwise; a rejection carries
|
|
62
|
+
* the Git layer's code (`GIT_FAILED`, `TIMEOUT`, `SPAWN_FAILED`, `TOO_LARGE`, …).
|
|
63
|
+
*/
|
|
64
|
+
export type Exec = (argv: string[], options?: ExecOptions) => Promise<ExecResult>;
|
|
65
|
+
/** Limits one Git snapshot applies; omitted entries fall back to the Git layer's own bounds. */
|
|
66
|
+
export interface GitLimits {
|
|
67
|
+
/** Maximum branches in each branch list. */
|
|
68
|
+
maxBranches: number;
|
|
69
|
+
/** Maximum commits in one page. */
|
|
70
|
+
maxCommits: number;
|
|
71
|
+
/** Maximum tags. */
|
|
72
|
+
maxTags: number;
|
|
73
|
+
/** Maximum changed files across all change lists. */
|
|
74
|
+
maxFiles: number;
|
|
75
|
+
/** Maximum characters of one returned diff. */
|
|
76
|
+
maxDiffBytes: number;
|
|
77
|
+
}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
/** Services this plugin needs; `webServer` binds the route, `sessions` resolves the checkout. */
|
|
3
|
+
export declare const inject: string[];
|
|
4
|
+
/**
|
|
5
|
+
* Mount the Git route for the calling profile.
|
|
6
|
+
* @param ctx - Host Cordis context carrying the injected services.
|
|
7
|
+
*/
|
|
8
|
+
export declare function apply(ctx: Context): void;
|