@procedures/git 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/CHANGELOG.md +5 -0
- package/LICENSE +21 -0
- package/README.md +1114 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/module.d.ts +16 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +437 -0
- package/dist/module.js.map +1 -0
- package/dist/procedures/git/add.d.ts +12 -0
- package/dist/procedures/git/add.d.ts.map +1 -0
- package/dist/procedures/git/add.js +26 -0
- package/dist/procedures/git/add.js.map +1 -0
- package/dist/procedures/git/args.d.ts +15 -0
- package/dist/procedures/git/args.d.ts.map +1 -0
- package/dist/procedures/git/args.js +20 -0
- package/dist/procedures/git/args.js.map +1 -0
- package/dist/procedures/git/branch.d.ts +12 -0
- package/dist/procedures/git/branch.d.ts.map +1 -0
- package/dist/procedures/git/branch.js +54 -0
- package/dist/procedures/git/branch.js.map +1 -0
- package/dist/procedures/git/checkout.d.ts +12 -0
- package/dist/procedures/git/checkout.d.ts.map +1 -0
- package/dist/procedures/git/checkout.js +23 -0
- package/dist/procedures/git/checkout.js.map +1 -0
- package/dist/procedures/git/clone.d.ts +12 -0
- package/dist/procedures/git/clone.d.ts.map +1 -0
- package/dist/procedures/git/clone.js +28 -0
- package/dist/procedures/git/clone.js.map +1 -0
- package/dist/procedures/git/commit.d.ts +12 -0
- package/dist/procedures/git/commit.d.ts.map +1 -0
- package/dist/procedures/git/commit.js +41 -0
- package/dist/procedures/git/commit.js.map +1 -0
- package/dist/procedures/git/diff.d.ts +18 -0
- package/dist/procedures/git/diff.d.ts.map +1 -0
- package/dist/procedures/git/diff.js +58 -0
- package/dist/procedures/git/diff.js.map +1 -0
- package/dist/procedures/git/fetch.d.ts +12 -0
- package/dist/procedures/git/fetch.d.ts.map +1 -0
- package/dist/procedures/git/fetch.js +29 -0
- package/dist/procedures/git/fetch.js.map +1 -0
- package/dist/procedures/git/index.d.ts +15 -0
- package/dist/procedures/git/index.d.ts.map +1 -0
- package/dist/procedures/git/index.js +15 -0
- package/dist/procedures/git/index.js.map +1 -0
- package/dist/procedures/git/init.d.ts +12 -0
- package/dist/procedures/git/init.d.ts.map +1 -0
- package/dist/procedures/git/init.js +32 -0
- package/dist/procedures/git/init.js.map +1 -0
- package/dist/procedures/git/log.d.ts +12 -0
- package/dist/procedures/git/log.d.ts.map +1 -0
- package/dist/procedures/git/log.js +35 -0
- package/dist/procedures/git/log.js.map +1 -0
- package/dist/procedures/git/predicates.d.ts +40 -0
- package/dist/procedures/git/predicates.d.ts.map +1 -0
- package/dist/procedures/git/predicates.js +76 -0
- package/dist/procedures/git/predicates.js.map +1 -0
- package/dist/procedures/git/pull.d.ts +12 -0
- package/dist/procedures/git/pull.d.ts.map +1 -0
- package/dist/procedures/git/pull.js +36 -0
- package/dist/procedures/git/pull.js.map +1 -0
- package/dist/procedures/git/push.d.ts +12 -0
- package/dist/procedures/git/push.d.ts.map +1 -0
- package/dist/procedures/git/push.js +39 -0
- package/dist/procedures/git/push.js.map +1 -0
- package/dist/procedures/git/remote.d.ts +12 -0
- package/dist/procedures/git/remote.d.ts.map +1 -0
- package/dist/procedures/git/remote.js +31 -0
- package/dist/procedures/git/remote.js.map +1 -0
- package/dist/procedures/git/run.d.ts +32 -0
- package/dist/procedures/git/run.d.ts.map +1 -0
- package/dist/procedures/git/run.js +60 -0
- package/dist/procedures/git/run.js.map +1 -0
- package/dist/procedures/git/stash.d.ts +38 -0
- package/dist/procedures/git/stash.d.ts.map +1 -0
- package/dist/procedures/git/stash.js +211 -0
- package/dist/procedures/git/stash.js.map +1 -0
- package/dist/procedures/git/status.d.ts +17 -0
- package/dist/procedures/git/status.d.ts.map +1 -0
- package/dist/procedures/git/status.js +107 -0
- package/dist/procedures/git/status.js.map +1 -0
- package/dist/procedures/git.d.ts +5 -0
- package/dist/procedures/git.d.ts.map +1 -0
- package/dist/procedures/git.js +5 -0
- package/dist/procedures/git.js.map +1 -0
- package/dist/register.d.ts +8 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +14 -0
- package/dist/register.js.map +1 -0
- package/dist/types.d.ts +341 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +387 -0
- package/dist/types.js.map +1 -0
- package/package.json +74 -3
- package/src/index.ts +20 -0
- package/src/module.ts +570 -0
- package/src/procedures/git/add.ts +29 -0
- package/src/procedures/git/args.ts +21 -0
- package/src/procedures/git/branch.ts +61 -0
- package/src/procedures/git/checkout.ts +27 -0
- package/src/procedures/git/clone.ts +33 -0
- package/src/procedures/git/commit.ts +46 -0
- package/src/procedures/git/diff.ts +62 -0
- package/src/procedures/git/fetch.ts +32 -0
- package/src/procedures/git/index.ts +22 -0
- package/src/procedures/git/init.ts +43 -0
- package/src/procedures/git/log.ts +40 -0
- package/src/procedures/git/predicates.ts +90 -0
- package/src/procedures/git/pull.ts +45 -0
- package/src/procedures/git/push.ts +42 -0
- package/src/procedures/git/remote.ts +33 -0
- package/src/procedures/git/run.ts +70 -0
- package/src/procedures/git/stash.ts +255 -0
- package/src/procedures/git/status.ts +98 -0
- package/src/procedures/git.ts +5 -0
- package/src/register.ts +17 -0
- package/src/types.ts +799 -0
package/src/module.ts
ADDED
|
@@ -0,0 +1,570 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module (no side effects): the procedures of this package as data, for `createRegistry()`.
|
|
3
|
+
*
|
|
4
|
+
* Procedure Registration for git operations
|
|
5
|
+
*
|
|
6
|
+
* Registers git.* procedures with the client system.
|
|
7
|
+
* This file is referenced by package.json's client.procedures field.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { createProcedure, zodAdapter, defineModule, type ProcedureModule } from "@procedures/client";
|
|
11
|
+
import { gitStatus } from "./procedures/git/status.js";
|
|
12
|
+
import { gitAdd } from "./procedures/git/add.js";
|
|
13
|
+
import { gitCommit } from "./procedures/git/commit.js";
|
|
14
|
+
import { gitPush } from "./procedures/git/push.js";
|
|
15
|
+
import { gitPull } from "./procedures/git/pull.js";
|
|
16
|
+
import { gitClone } from "./procedures/git/clone.js";
|
|
17
|
+
import { gitCheckout } from "./procedures/git/checkout.js";
|
|
18
|
+
import { gitBranch } from "./procedures/git/branch.js";
|
|
19
|
+
import { gitLog } from "./procedures/git/log.js";
|
|
20
|
+
import { gitDiff } from "./procedures/git/diff.js";
|
|
21
|
+
import { gitInit } from "./procedures/git/init.js";
|
|
22
|
+
import { gitRemote } from "./procedures/git/remote.js";
|
|
23
|
+
import { gitFetch } from "./procedures/git/fetch.js";
|
|
24
|
+
import {
|
|
25
|
+
gitHasChanges,
|
|
26
|
+
gitHasStagedChanges,
|
|
27
|
+
gitHasUnstagedChanges,
|
|
28
|
+
gitHasUntrackedFiles,
|
|
29
|
+
gitHasLocalCommits,
|
|
30
|
+
gitIsClean,
|
|
31
|
+
} from "./procedures/git/predicates.js";
|
|
32
|
+
import {
|
|
33
|
+
gitStashList,
|
|
34
|
+
gitStashPush,
|
|
35
|
+
gitStashPop,
|
|
36
|
+
gitStashApply,
|
|
37
|
+
gitStashDrop,
|
|
38
|
+
gitStashExport,
|
|
39
|
+
gitStashImport,
|
|
40
|
+
} from "./procedures/git/stash.js";
|
|
41
|
+
import {
|
|
42
|
+
GitStatusInputSchema,
|
|
43
|
+
GitAddInputSchema,
|
|
44
|
+
GitCommitInputSchema,
|
|
45
|
+
GitPushInputSchema,
|
|
46
|
+
GitPullInputSchema,
|
|
47
|
+
GitCloneInputSchema,
|
|
48
|
+
GitCheckoutInputSchema,
|
|
49
|
+
GitBranchInputSchema,
|
|
50
|
+
GitLogInputSchema,
|
|
51
|
+
GitDiffInputSchema,
|
|
52
|
+
type GitStatusInput,
|
|
53
|
+
type GitStatusOutput,
|
|
54
|
+
type GitAddInput,
|
|
55
|
+
type GitAddOutput,
|
|
56
|
+
type GitCommitInput,
|
|
57
|
+
type GitCommitOutput,
|
|
58
|
+
type GitPushInput,
|
|
59
|
+
type GitPushOutput,
|
|
60
|
+
type GitPullInput,
|
|
61
|
+
type GitPullOutput,
|
|
62
|
+
type GitCloneInput,
|
|
63
|
+
type GitCloneOutput,
|
|
64
|
+
type GitCheckoutInput,
|
|
65
|
+
type GitCheckoutOutput,
|
|
66
|
+
type GitBranchInput,
|
|
67
|
+
type GitBranchOutput,
|
|
68
|
+
type GitLogInput,
|
|
69
|
+
type GitLogOutput,
|
|
70
|
+
type GitDiffInput,
|
|
71
|
+
type GitDiffOutput,
|
|
72
|
+
GitInitInputSchema,
|
|
73
|
+
type GitInitInput,
|
|
74
|
+
type GitInitOutput,
|
|
75
|
+
GitRemoteInputSchema,
|
|
76
|
+
type GitRemoteInput,
|
|
77
|
+
type GitRemoteOutput,
|
|
78
|
+
GitFetchInputSchema,
|
|
79
|
+
type GitFetchInput,
|
|
80
|
+
type GitFetchOutput,
|
|
81
|
+
GitPredicateInputSchema,
|
|
82
|
+
type GitPredicateInput,
|
|
83
|
+
type GitPredicateOutput,
|
|
84
|
+
GitStashListInputSchema,
|
|
85
|
+
GitStashPushInputSchema,
|
|
86
|
+
GitStashPopInputSchema,
|
|
87
|
+
GitStashApplyInputSchema,
|
|
88
|
+
GitStashDropInputSchema,
|
|
89
|
+
GitStashExportInputSchema,
|
|
90
|
+
GitStashImportInputSchema,
|
|
91
|
+
type GitStashListInput,
|
|
92
|
+
type GitStashListOutput,
|
|
93
|
+
type GitStashPushInput,
|
|
94
|
+
type GitStashPushOutput,
|
|
95
|
+
type GitStashPopInput,
|
|
96
|
+
type GitStashPopOutput,
|
|
97
|
+
type GitStashApplyInput,
|
|
98
|
+
type GitStashApplyOutput,
|
|
99
|
+
type GitStashDropInput,
|
|
100
|
+
type GitStashDropOutput,
|
|
101
|
+
type GitStashExportInput,
|
|
102
|
+
type GitStashExportOutput,
|
|
103
|
+
type GitStashImportInput,
|
|
104
|
+
type GitStashImportOutput,
|
|
105
|
+
GitStatusOutputSchema,
|
|
106
|
+
GitAddOutputSchema,
|
|
107
|
+
GitCommitOutputSchema,
|
|
108
|
+
GitPushOutputSchema,
|
|
109
|
+
GitPullOutputSchema,
|
|
110
|
+
GitCloneOutputSchema,
|
|
111
|
+
GitCheckoutOutputSchema,
|
|
112
|
+
GitBranchOutputSchema,
|
|
113
|
+
GitLogOutputSchema,
|
|
114
|
+
GitDiffOutputSchema,
|
|
115
|
+
GitInitOutputSchema,
|
|
116
|
+
GitRemoteOutputSchema,
|
|
117
|
+
GitFetchOutputSchema,
|
|
118
|
+
GitPredicateOutputSchema,
|
|
119
|
+
GitStashListOutputSchema,
|
|
120
|
+
GitStashPushOutputSchema,
|
|
121
|
+
GitStashPopOutputSchema,
|
|
122
|
+
GitStashApplyOutputSchema,
|
|
123
|
+
GitStashDropOutputSchema,
|
|
124
|
+
GitStashExportOutputSchema,
|
|
125
|
+
GitStashImportOutputSchema,
|
|
126
|
+
} from "./types.js";
|
|
127
|
+
|
|
128
|
+
// =============================================================================
|
|
129
|
+
// Procedure Definitions
|
|
130
|
+
// =============================================================================
|
|
131
|
+
|
|
132
|
+
const gitStatusProcedure = createProcedure()
|
|
133
|
+
.path(["git", "status"])
|
|
134
|
+
.input(zodAdapter<GitStatusInput>(GitStatusInputSchema))
|
|
135
|
+
.output(zodAdapter<GitStatusOutput>(GitStatusOutputSchema))
|
|
136
|
+
.meta({
|
|
137
|
+
description: "Get git status",
|
|
138
|
+
args: [],
|
|
139
|
+
shorts: { cwd: "C", short: "s" },
|
|
140
|
+
output: "json",
|
|
141
|
+
})
|
|
142
|
+
.handler(async (input: GitStatusInput, ctx): Promise<GitStatusOutput> => {
|
|
143
|
+
return gitStatus(input, ctx);
|
|
144
|
+
})
|
|
145
|
+
.build();
|
|
146
|
+
|
|
147
|
+
const gitAddProcedure = createProcedure()
|
|
148
|
+
.path(["git", "add"])
|
|
149
|
+
.input(zodAdapter<GitAddInput>(GitAddInputSchema))
|
|
150
|
+
.output(zodAdapter<GitAddOutput>(GitAddOutputSchema))
|
|
151
|
+
.meta({
|
|
152
|
+
description: "Stage files",
|
|
153
|
+
args: ["paths"],
|
|
154
|
+
shorts: { all: "A", cwd: "C" },
|
|
155
|
+
output: "json",
|
|
156
|
+
})
|
|
157
|
+
.handler(async (input: GitAddInput, ctx): Promise<GitAddOutput> => {
|
|
158
|
+
return gitAdd(input, ctx);
|
|
159
|
+
})
|
|
160
|
+
.build();
|
|
161
|
+
|
|
162
|
+
const gitCommitProcedure = createProcedure()
|
|
163
|
+
.path(["git", "commit"])
|
|
164
|
+
.input(zodAdapter<GitCommitInput>(GitCommitInputSchema))
|
|
165
|
+
.output(zodAdapter<GitCommitOutput>(GitCommitOutputSchema))
|
|
166
|
+
.meta({
|
|
167
|
+
description: "Create commit",
|
|
168
|
+
args: ["message"],
|
|
169
|
+
shorts: { message: "m", all: "a", amend: "A", cwd: "C" },
|
|
170
|
+
output: "json",
|
|
171
|
+
})
|
|
172
|
+
.handler(async (input: GitCommitInput, ctx): Promise<GitCommitOutput> => {
|
|
173
|
+
return gitCommit(input, ctx);
|
|
174
|
+
})
|
|
175
|
+
.build();
|
|
176
|
+
|
|
177
|
+
const gitPushProcedure = createProcedure()
|
|
178
|
+
.path(["git", "push"])
|
|
179
|
+
.input(zodAdapter<GitPushInput>(GitPushInputSchema))
|
|
180
|
+
.output(zodAdapter<GitPushOutput>(GitPushOutputSchema))
|
|
181
|
+
.meta({
|
|
182
|
+
description: "Push to remote",
|
|
183
|
+
args: [],
|
|
184
|
+
shorts: { remote: "r", branch: "b", force: "f", setUpstream: "u", cwd: "C" },
|
|
185
|
+
output: "json",
|
|
186
|
+
})
|
|
187
|
+
.handler(async (input: GitPushInput, ctx): Promise<GitPushOutput> => {
|
|
188
|
+
return gitPush(input, ctx);
|
|
189
|
+
})
|
|
190
|
+
.build();
|
|
191
|
+
|
|
192
|
+
const gitPullProcedure = createProcedure()
|
|
193
|
+
.path(["git", "pull"])
|
|
194
|
+
.input(zodAdapter<GitPullInput>(GitPullInputSchema))
|
|
195
|
+
.output(zodAdapter<GitPullOutput>(GitPullOutputSchema))
|
|
196
|
+
.meta({
|
|
197
|
+
description: "Pull from remote",
|
|
198
|
+
args: [],
|
|
199
|
+
shorts: { remote: "r", branch: "b", rebase: "R", cwd: "C" },
|
|
200
|
+
output: "json",
|
|
201
|
+
})
|
|
202
|
+
.handler(async (input: GitPullInput, ctx): Promise<GitPullOutput> => {
|
|
203
|
+
return gitPull(input, ctx);
|
|
204
|
+
})
|
|
205
|
+
.build();
|
|
206
|
+
|
|
207
|
+
const gitCloneProcedure = createProcedure()
|
|
208
|
+
.path(["git", "clone"])
|
|
209
|
+
.input(zodAdapter<GitCloneInput>(GitCloneInputSchema))
|
|
210
|
+
.output(zodAdapter<GitCloneOutput>(GitCloneOutputSchema))
|
|
211
|
+
.meta({
|
|
212
|
+
description: "Clone repository",
|
|
213
|
+
args: ["url"],
|
|
214
|
+
shorts: { dest: "d", branch: "b", depth: "D", cwd: "C" },
|
|
215
|
+
output: "json",
|
|
216
|
+
})
|
|
217
|
+
.handler(async (input: GitCloneInput, ctx): Promise<GitCloneOutput> => {
|
|
218
|
+
return gitClone(input, ctx);
|
|
219
|
+
})
|
|
220
|
+
.build();
|
|
221
|
+
|
|
222
|
+
const gitCheckoutProcedure = createProcedure()
|
|
223
|
+
.path(["git", "checkout"])
|
|
224
|
+
.input(zodAdapter<GitCheckoutInput>(GitCheckoutInputSchema))
|
|
225
|
+
.output(zodAdapter<GitCheckoutOutput>(GitCheckoutOutputSchema))
|
|
226
|
+
.meta({
|
|
227
|
+
description: "Checkout branch or files",
|
|
228
|
+
args: ["ref"],
|
|
229
|
+
shorts: { create: "b", cwd: "C" },
|
|
230
|
+
output: "json",
|
|
231
|
+
})
|
|
232
|
+
.handler(async (input: GitCheckoutInput, ctx): Promise<GitCheckoutOutput> => {
|
|
233
|
+
return gitCheckout(input, ctx);
|
|
234
|
+
})
|
|
235
|
+
.build();
|
|
236
|
+
|
|
237
|
+
const gitBranchProcedure = createProcedure()
|
|
238
|
+
.path(["git", "branch"])
|
|
239
|
+
.input(zodAdapter<GitBranchInput>(GitBranchInputSchema))
|
|
240
|
+
.output(zodAdapter<GitBranchOutput>(GitBranchOutputSchema))
|
|
241
|
+
.meta({
|
|
242
|
+
description: "Branch operations",
|
|
243
|
+
args: ["name"],
|
|
244
|
+
shorts: { delete: "d", list: "l", remote: "r", cwd: "C" },
|
|
245
|
+
output: "json",
|
|
246
|
+
})
|
|
247
|
+
.handler(async (input: GitBranchInput, ctx): Promise<GitBranchOutput> => {
|
|
248
|
+
return gitBranch(input, ctx);
|
|
249
|
+
})
|
|
250
|
+
.build();
|
|
251
|
+
|
|
252
|
+
const gitLogProcedure = createProcedure()
|
|
253
|
+
.path(["git", "log"])
|
|
254
|
+
.input(zodAdapter<GitLogInput>(GitLogInputSchema))
|
|
255
|
+
.output(zodAdapter<GitLogOutput>(GitLogOutputSchema))
|
|
256
|
+
.meta({
|
|
257
|
+
description: "Show commit log",
|
|
258
|
+
args: [],
|
|
259
|
+
shorts: { count: "n", oneline: "o", ref: "r", cwd: "C" },
|
|
260
|
+
output: "json",
|
|
261
|
+
})
|
|
262
|
+
.handler(async (input: GitLogInput, ctx): Promise<GitLogOutput> => {
|
|
263
|
+
return gitLog(input, ctx);
|
|
264
|
+
})
|
|
265
|
+
.build();
|
|
266
|
+
|
|
267
|
+
const gitDiffProcedure = createProcedure()
|
|
268
|
+
.path(["git", "diff"])
|
|
269
|
+
.input(zodAdapter<GitDiffInput>(GitDiffInputSchema))
|
|
270
|
+
.output(zodAdapter<GitDiffOutput>(GitDiffOutputSchema))
|
|
271
|
+
.meta({
|
|
272
|
+
description: "Show changes",
|
|
273
|
+
args: [],
|
|
274
|
+
shorts: { staged: "s", ref: "r", stat: "S", cwd: "C" },
|
|
275
|
+
output: "json",
|
|
276
|
+
})
|
|
277
|
+
.handler(async (input: GitDiffInput, ctx): Promise<GitDiffOutput> => {
|
|
278
|
+
return gitDiff(input, ctx);
|
|
279
|
+
})
|
|
280
|
+
.build();
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
const gitInitProcedure = createProcedure()
|
|
284
|
+
.path(["git", "init"])
|
|
285
|
+
.input(zodAdapter<GitInitInput>(GitInitInputSchema))
|
|
286
|
+
.output(zodAdapter<GitInitOutput>(GitInitOutputSchema))
|
|
287
|
+
.meta({
|
|
288
|
+
description: "Initialize a git repository",
|
|
289
|
+
args: [],
|
|
290
|
+
shorts: { cwd: "C", bare: "b", initialBranch: "B" },
|
|
291
|
+
output: "json",
|
|
292
|
+
})
|
|
293
|
+
.handler(async (input: GitInitInput, ctx): Promise<GitInitOutput> => {
|
|
294
|
+
return gitInit(input, ctx);
|
|
295
|
+
})
|
|
296
|
+
.build();
|
|
297
|
+
|
|
298
|
+
const gitRemoteProcedure = createProcedure()
|
|
299
|
+
.path(["git", "remote"])
|
|
300
|
+
.input(zodAdapter<GitRemoteInput>(GitRemoteInputSchema))
|
|
301
|
+
.output(zodAdapter<GitRemoteOutput>(GitRemoteOutputSchema))
|
|
302
|
+
.meta({
|
|
303
|
+
description: "Get or set remote URLs",
|
|
304
|
+
args: [],
|
|
305
|
+
shorts: { name: "n", url: "u", cwd: "C" },
|
|
306
|
+
output: "json",
|
|
307
|
+
})
|
|
308
|
+
.handler(async (input: GitRemoteInput, ctx): Promise<GitRemoteOutput> => {
|
|
309
|
+
return gitRemote(input, ctx);
|
|
310
|
+
})
|
|
311
|
+
.build();
|
|
312
|
+
|
|
313
|
+
const gitFetchProcedure = createProcedure()
|
|
314
|
+
.path(["git", "fetch"])
|
|
315
|
+
.input(zodAdapter<GitFetchInput>(GitFetchInputSchema))
|
|
316
|
+
.output(zodAdapter<GitFetchOutput>(GitFetchOutputSchema))
|
|
317
|
+
.meta({
|
|
318
|
+
description: "Fetch from remote",
|
|
319
|
+
args: [],
|
|
320
|
+
shorts: { remote: "r", branch: "b", all: "a", prune: "p", cwd: "C" },
|
|
321
|
+
output: "json",
|
|
322
|
+
})
|
|
323
|
+
.handler(async (input: GitFetchInput, ctx): Promise<GitFetchOutput> => {
|
|
324
|
+
return gitFetch(input, ctx);
|
|
325
|
+
})
|
|
326
|
+
.build();
|
|
327
|
+
|
|
328
|
+
// =============================================================================
|
|
329
|
+
// Predicate Procedures (boolean checks for conditionals)
|
|
330
|
+
// =============================================================================
|
|
331
|
+
|
|
332
|
+
const gitHasChangesProcedure = createProcedure()
|
|
333
|
+
.path(["git", "hasChanges"])
|
|
334
|
+
.input(zodAdapter<GitPredicateInput>(GitPredicateInputSchema))
|
|
335
|
+
.output(zodAdapter<GitPredicateOutput>(GitPredicateOutputSchema))
|
|
336
|
+
.meta({
|
|
337
|
+
description: "Check if there are any changes (unstaged, staged, or untracked)",
|
|
338
|
+
args: [],
|
|
339
|
+
shorts: { cwd: "C" },
|
|
340
|
+
output: "json",
|
|
341
|
+
})
|
|
342
|
+
.handler(async (input: GitPredicateInput, ctx): Promise<GitPredicateOutput> => {
|
|
343
|
+
return gitHasChanges(input, ctx);
|
|
344
|
+
})
|
|
345
|
+
.build();
|
|
346
|
+
|
|
347
|
+
const gitHasStagedChangesProcedure = createProcedure()
|
|
348
|
+
.path(["git", "hasStagedChanges"])
|
|
349
|
+
.input(zodAdapter<GitPredicateInput>(GitPredicateInputSchema))
|
|
350
|
+
.output(zodAdapter<GitPredicateOutput>(GitPredicateOutputSchema))
|
|
351
|
+
.meta({
|
|
352
|
+
description: "Check if there are any staged changes ready to commit",
|
|
353
|
+
args: [],
|
|
354
|
+
shorts: { cwd: "C" },
|
|
355
|
+
output: "json",
|
|
356
|
+
})
|
|
357
|
+
.handler(async (input: GitPredicateInput, ctx): Promise<GitPredicateOutput> => {
|
|
358
|
+
return gitHasStagedChanges(input, ctx);
|
|
359
|
+
})
|
|
360
|
+
.build();
|
|
361
|
+
|
|
362
|
+
const gitHasUnstagedChangesProcedure = createProcedure()
|
|
363
|
+
.path(["git", "hasUnstagedChanges"])
|
|
364
|
+
.input(zodAdapter<GitPredicateInput>(GitPredicateInputSchema))
|
|
365
|
+
.output(zodAdapter<GitPredicateOutput>(GitPredicateOutputSchema))
|
|
366
|
+
.meta({
|
|
367
|
+
description: "Check if there are any unstaged changes",
|
|
368
|
+
args: [],
|
|
369
|
+
shorts: { cwd: "C" },
|
|
370
|
+
output: "json",
|
|
371
|
+
})
|
|
372
|
+
.handler(async (input: GitPredicateInput, ctx): Promise<GitPredicateOutput> => {
|
|
373
|
+
return gitHasUnstagedChanges(input, ctx);
|
|
374
|
+
})
|
|
375
|
+
.build();
|
|
376
|
+
|
|
377
|
+
const gitHasUntrackedFilesProcedure = createProcedure()
|
|
378
|
+
.path(["git", "hasUntrackedFiles"])
|
|
379
|
+
.input(zodAdapter<GitPredicateInput>(GitPredicateInputSchema))
|
|
380
|
+
.output(zodAdapter<GitPredicateOutput>(GitPredicateOutputSchema))
|
|
381
|
+
.meta({
|
|
382
|
+
description: "Check if there are any untracked files",
|
|
383
|
+
args: [],
|
|
384
|
+
shorts: { cwd: "C" },
|
|
385
|
+
output: "json",
|
|
386
|
+
})
|
|
387
|
+
.handler(async (input: GitPredicateInput, ctx): Promise<GitPredicateOutput> => {
|
|
388
|
+
return gitHasUntrackedFiles(input, ctx);
|
|
389
|
+
})
|
|
390
|
+
.build();
|
|
391
|
+
|
|
392
|
+
const gitHasLocalCommitsProcedure = createProcedure()
|
|
393
|
+
.path(["git", "hasLocalCommits"])
|
|
394
|
+
.input(zodAdapter<GitPredicateInput>(GitPredicateInputSchema))
|
|
395
|
+
.output(zodAdapter<GitPredicateOutput>(GitPredicateOutputSchema))
|
|
396
|
+
.meta({
|
|
397
|
+
description: "Check if there are local commits that haven't been pushed",
|
|
398
|
+
args: [],
|
|
399
|
+
shorts: { cwd: "C" },
|
|
400
|
+
output: "json",
|
|
401
|
+
})
|
|
402
|
+
.handler(async (input: GitPredicateInput, ctx): Promise<GitPredicateOutput> => {
|
|
403
|
+
return gitHasLocalCommits(input, ctx);
|
|
404
|
+
})
|
|
405
|
+
.build();
|
|
406
|
+
|
|
407
|
+
const gitIsCleanProcedure = createProcedure()
|
|
408
|
+
.path(["git", "isClean"])
|
|
409
|
+
.input(zodAdapter<GitPredicateInput>(GitPredicateInputSchema))
|
|
410
|
+
.output(zodAdapter<GitPredicateOutput>(GitPredicateOutputSchema))
|
|
411
|
+
.meta({
|
|
412
|
+
description: "Check if the working directory is clean",
|
|
413
|
+
args: [],
|
|
414
|
+
shorts: { cwd: "C" },
|
|
415
|
+
output: "json",
|
|
416
|
+
})
|
|
417
|
+
.handler(async (input: GitPredicateInput, ctx): Promise<GitPredicateOutput> => {
|
|
418
|
+
return gitIsClean(input, ctx);
|
|
419
|
+
})
|
|
420
|
+
.build();
|
|
421
|
+
|
|
422
|
+
// =============================================================================
|
|
423
|
+
// Stash Procedures
|
|
424
|
+
// =============================================================================
|
|
425
|
+
|
|
426
|
+
const gitStashListProcedure = createProcedure()
|
|
427
|
+
.path(["git", "stash", "list"])
|
|
428
|
+
.input(zodAdapter<GitStashListInput>(GitStashListInputSchema))
|
|
429
|
+
.output(zodAdapter<GitStashListOutput>(GitStashListOutputSchema))
|
|
430
|
+
.meta({
|
|
431
|
+
description: "List all stashes",
|
|
432
|
+
args: [],
|
|
433
|
+
shorts: { cwd: "C" },
|
|
434
|
+
output: "json",
|
|
435
|
+
})
|
|
436
|
+
.handler(async (input: GitStashListInput, ctx): Promise<GitStashListOutput> => {
|
|
437
|
+
return gitStashList(input, ctx);
|
|
438
|
+
})
|
|
439
|
+
.build();
|
|
440
|
+
|
|
441
|
+
const gitStashPushProcedure = createProcedure()
|
|
442
|
+
.path(["git", "stash", "push"])
|
|
443
|
+
.input(zodAdapter<GitStashPushInput>(GitStashPushInputSchema))
|
|
444
|
+
.output(zodAdapter<GitStashPushOutput>(GitStashPushOutputSchema))
|
|
445
|
+
.meta({
|
|
446
|
+
description: "Push changes to stash",
|
|
447
|
+
args: ["message"],
|
|
448
|
+
shorts: { message: "m", includeUntracked: "u", keepIndex: "k", cwd: "C" },
|
|
449
|
+
output: "json",
|
|
450
|
+
})
|
|
451
|
+
.handler(async (input: GitStashPushInput, ctx): Promise<GitStashPushOutput> => {
|
|
452
|
+
return gitStashPush(input, ctx);
|
|
453
|
+
})
|
|
454
|
+
.build();
|
|
455
|
+
|
|
456
|
+
const gitStashPopProcedure = createProcedure()
|
|
457
|
+
.path(["git", "stash", "pop"])
|
|
458
|
+
.input(zodAdapter<GitStashPopInput>(GitStashPopInputSchema))
|
|
459
|
+
.output(zodAdapter<GitStashPopOutput>(GitStashPopOutputSchema))
|
|
460
|
+
.meta({
|
|
461
|
+
description: "Pop stash (apply and remove)",
|
|
462
|
+
args: [],
|
|
463
|
+
shorts: { index: "n", cwd: "C" },
|
|
464
|
+
output: "json",
|
|
465
|
+
})
|
|
466
|
+
.handler(async (input: GitStashPopInput, ctx): Promise<GitStashPopOutput> => {
|
|
467
|
+
return gitStashPop(input, ctx);
|
|
468
|
+
})
|
|
469
|
+
.build();
|
|
470
|
+
|
|
471
|
+
const gitStashApplyProcedure = createProcedure()
|
|
472
|
+
.path(["git", "stash", "apply"])
|
|
473
|
+
.input(zodAdapter<GitStashApplyInput>(GitStashApplyInputSchema))
|
|
474
|
+
.output(zodAdapter<GitStashApplyOutput>(GitStashApplyOutputSchema))
|
|
475
|
+
.meta({
|
|
476
|
+
description: "Apply stash without removing",
|
|
477
|
+
args: [],
|
|
478
|
+
shorts: { index: "n", cwd: "C" },
|
|
479
|
+
output: "json",
|
|
480
|
+
})
|
|
481
|
+
.handler(async (input: GitStashApplyInput, ctx): Promise<GitStashApplyOutput> => {
|
|
482
|
+
return gitStashApply(input, ctx);
|
|
483
|
+
})
|
|
484
|
+
.build();
|
|
485
|
+
|
|
486
|
+
const gitStashDropProcedure = createProcedure()
|
|
487
|
+
.path(["git", "stash", "drop"])
|
|
488
|
+
.input(zodAdapter<GitStashDropInput>(GitStashDropInputSchema))
|
|
489
|
+
.output(zodAdapter<GitStashDropOutput>(GitStashDropOutputSchema))
|
|
490
|
+
.meta({
|
|
491
|
+
description: "Drop a stash",
|
|
492
|
+
args: [],
|
|
493
|
+
shorts: { index: "n", cwd: "C" },
|
|
494
|
+
output: "json",
|
|
495
|
+
})
|
|
496
|
+
.handler(async (input: GitStashDropInput, ctx): Promise<GitStashDropOutput> => {
|
|
497
|
+
return gitStashDrop(input, ctx);
|
|
498
|
+
})
|
|
499
|
+
.build();
|
|
500
|
+
|
|
501
|
+
const gitStashExportProcedure = createProcedure()
|
|
502
|
+
.path(["git", "stash", "export"])
|
|
503
|
+
.input(zodAdapter<GitStashExportInput>(GitStashExportInputSchema))
|
|
504
|
+
.output(zodAdapter<GitStashExportOutput>(GitStashExportOutputSchema))
|
|
505
|
+
.meta({
|
|
506
|
+
description: "Export stash as patch for snapshot storage",
|
|
507
|
+
args: [],
|
|
508
|
+
shorts: { index: "n", cwd: "C" },
|
|
509
|
+
output: "json",
|
|
510
|
+
})
|
|
511
|
+
.handler(async (input: GitStashExportInput, ctx): Promise<GitStashExportOutput> => {
|
|
512
|
+
return gitStashExport(input, ctx);
|
|
513
|
+
})
|
|
514
|
+
.build();
|
|
515
|
+
|
|
516
|
+
const gitStashImportProcedure = createProcedure()
|
|
517
|
+
.path(["git", "stash", "import"])
|
|
518
|
+
.input(zodAdapter<GitStashImportInput>(GitStashImportInputSchema))
|
|
519
|
+
.output(zodAdapter<GitStashImportOutput>(GitStashImportOutputSchema))
|
|
520
|
+
.meta({
|
|
521
|
+
description: "Import stash from patch",
|
|
522
|
+
args: ["patch"],
|
|
523
|
+
shorts: { message: "m", includeUntracked: "u", cwd: "C" },
|
|
524
|
+
output: "json",
|
|
525
|
+
})
|
|
526
|
+
.handler(async (input: GitStashImportInput, ctx): Promise<GitStashImportOutput> => {
|
|
527
|
+
return gitStashImport(input, ctx);
|
|
528
|
+
})
|
|
529
|
+
.build();
|
|
530
|
+
|
|
531
|
+
// =============================================================================
|
|
532
|
+
// Registration
|
|
533
|
+
// =============================================================================
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* The module of this package, for `createRegistry()`: its procedures as data. Importing this
|
|
537
|
+
* file registers nothing. (`register.ts` registers the same procedures in the global registry.)
|
|
538
|
+
*/
|
|
539
|
+
export const gitModule: ProcedureModule = defineModule("@procedures/git", [
|
|
540
|
+
gitStatusProcedure,
|
|
541
|
+
gitAddProcedure,
|
|
542
|
+
gitCommitProcedure,
|
|
543
|
+
gitPushProcedure,
|
|
544
|
+
gitPullProcedure,
|
|
545
|
+
gitCloneProcedure,
|
|
546
|
+
gitCheckoutProcedure,
|
|
547
|
+
gitBranchProcedure,
|
|
548
|
+
gitLogProcedure,
|
|
549
|
+
gitDiffProcedure,
|
|
550
|
+
gitInitProcedure,
|
|
551
|
+
gitRemoteProcedure,
|
|
552
|
+
gitFetchProcedure,
|
|
553
|
+
// Predicate procedures
|
|
554
|
+
gitHasChangesProcedure,
|
|
555
|
+
gitHasStagedChangesProcedure,
|
|
556
|
+
gitHasUnstagedChangesProcedure,
|
|
557
|
+
gitHasUntrackedFilesProcedure,
|
|
558
|
+
gitHasLocalCommitsProcedure,
|
|
559
|
+
gitIsCleanProcedure,
|
|
560
|
+
// Stash procedures
|
|
561
|
+
gitStashListProcedure,
|
|
562
|
+
gitStashPushProcedure,
|
|
563
|
+
gitStashPopProcedure,
|
|
564
|
+
gitStashApplyProcedure,
|
|
565
|
+
gitStashDropProcedure,
|
|
566
|
+
gitStashExportProcedure,
|
|
567
|
+
gitStashImportProcedure,
|
|
568
|
+
]);
|
|
569
|
+
|
|
570
|
+
export default gitModule;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.add procedure
|
|
3
|
+
*
|
|
4
|
+
* Stage files
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { git, type GitContext } from "./run.js";
|
|
8
|
+
import type { GitAddInput, GitAddOutput } from "../../types.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Stage files
|
|
12
|
+
*/
|
|
13
|
+
export async function gitAdd(input: GitAddInput, ctx: GitContext = {}): Promise<GitAddOutput> {
|
|
14
|
+
const { paths, all, cwd } = input;
|
|
15
|
+
const run = { cwd, signal: ctx.signal };
|
|
16
|
+
|
|
17
|
+
if (all) {
|
|
18
|
+
await git(["add", "-A"], run);
|
|
19
|
+
} else if (paths.length > 0) {
|
|
20
|
+
await git(["add", "--", ...paths], run);
|
|
21
|
+
} else {
|
|
22
|
+
await git(["add", "."], run);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Get list of staged files (with -z, a path with a space or a quote stays exact)
|
|
26
|
+
const staged = (await git(["diff", "--cached", "--name-only", "-z"], run)).split("\0").filter(Boolean);
|
|
27
|
+
|
|
28
|
+
return { staged };
|
|
29
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guards for values that the git procedures pass to git as positional arguments.
|
|
3
|
+
*
|
|
4
|
+
* execFileSync passes arguments without a shell (BUGS-2026-07 C4), but git itself still reads
|
|
5
|
+
* a positional value that starts with "-" as an option. Some options run commands:
|
|
6
|
+
* `git clone/fetch/pull --upload-pack=<command>` and `git push --receive-pack=<command>`.
|
|
7
|
+
* `git diff --output=<file>` writes a file. Git does not allow a ref, branch or remote name
|
|
8
|
+
* to start with "-", so rejecting such values does not block a legitimate call.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export function gitArg(name: string, value: string): string {
|
|
12
|
+
if (value.startsWith("-")) {
|
|
13
|
+
throw new Error(`Invalid ${name} (must not start with "-"): ${value}`);
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Diffs and stash patches can exceed Node's default maxBuffer of 1 MiB (BUGS-2026-07 L6)
|
|
20
|
+
*/
|
|
21
|
+
export const GIT_MAX_BUFFER: number = 64 * 1024 * 1024;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.branch procedure
|
|
3
|
+
*
|
|
4
|
+
* Branch operations
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { gitArg } from "./args.js";
|
|
8
|
+
import { git, type GitContext } from "./run.js";
|
|
9
|
+
import type { GitBranchInput, GitBranchOutput, GitBranchInfo } from "../../types.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Branch operations
|
|
13
|
+
*/
|
|
14
|
+
export async function gitBranch(input: GitBranchInput, ctx: GitContext = {}): Promise<GitBranchOutput> {
|
|
15
|
+
const { name, delete: del, list, remote, cwd } = input;
|
|
16
|
+
const run = { cwd, signal: ctx.signal };
|
|
17
|
+
|
|
18
|
+
// Get current branch
|
|
19
|
+
const current = (await git(["rev-parse", "--abbrev-ref", "HEAD"], run)).trim();
|
|
20
|
+
|
|
21
|
+
// Delete branch
|
|
22
|
+
if (del && name) {
|
|
23
|
+
await git(["branch", "-d", gitArg("name", name)], run);
|
|
24
|
+
return { deleted: name, current };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Create branch
|
|
28
|
+
if (name && !list) {
|
|
29
|
+
await git(["branch", gitArg("name", name)], run);
|
|
30
|
+
return { created: name, current };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// List branches
|
|
34
|
+
const args = ["branch"];
|
|
35
|
+
if (remote) args.push("-a");
|
|
36
|
+
// The full ref name tells local from remote branches: a local "feature/x" also contains "/"
|
|
37
|
+
args.push("--format=%(refname)|%(refname:short)|%(HEAD)|%(upstream:short)");
|
|
38
|
+
|
|
39
|
+
const output = await git(args, run);
|
|
40
|
+
const branches: GitBranchInfo[] = output
|
|
41
|
+
.split("\n")
|
|
42
|
+
.filter(Boolean)
|
|
43
|
+
.map(line => {
|
|
44
|
+
const parts = line.split("|");
|
|
45
|
+
const fullName = parts[0] ?? "";
|
|
46
|
+
const branchName = parts[1] ?? "";
|
|
47
|
+
const head = parts[2] ?? "";
|
|
48
|
+
const trackingVal = parts[3];
|
|
49
|
+
const result: GitBranchInfo = {
|
|
50
|
+
name: branchName.replace(/^remotes\//, ""),
|
|
51
|
+
current: head === "*",
|
|
52
|
+
remote: fullName.startsWith("refs/remotes/"),
|
|
53
|
+
};
|
|
54
|
+
if (trackingVal) {
|
|
55
|
+
result.tracking = trackingVal;
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
return { branches, current };
|
|
61
|
+
}
|