@carlosstenzel/opencode-git-sidebar 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/src/rpc.ts ADDED
@@ -0,0 +1,257 @@
1
+ import { Rpc } from "@opencode/plugin/rpc"
2
+
3
+ const directoryInput = {
4
+ type: "object",
5
+ properties: {
6
+ directory: { type: "string" },
7
+ },
8
+ required: ["directory"],
9
+ additionalProperties: false,
10
+ } as const
11
+
12
+ const statusOutput = {
13
+ type: "object",
14
+ properties: {
15
+ repo: { type: "string" },
16
+ branch: { type: "string" },
17
+ dirty: { type: "boolean" },
18
+ changes: { type: "number" },
19
+ ahead: { type: "number" },
20
+ behind: { type: "number" },
21
+ upstream: { type: "string" },
22
+ },
23
+ required: ["repo", "branch", "dirty", "changes", "ahead", "behind", "upstream"],
24
+ additionalProperties: false,
25
+ } as const
26
+
27
+ const branchOutput = {
28
+ type: "object",
29
+ properties: {
30
+ name: { type: "string" },
31
+ current: { type: "boolean" },
32
+ upstream: { type: "string" },
33
+ ahead: { type: "number" },
34
+ behind: { type: "number" },
35
+ hash: { type: "string" },
36
+ subject: { type: "string" },
37
+ date: { type: "string" },
38
+ },
39
+ required: ["name", "current", "upstream", "ahead", "behind", "hash", "subject", "date"],
40
+ additionalProperties: false,
41
+ } as const
42
+
43
+ const commitOutput = {
44
+ type: "object",
45
+ properties: {
46
+ hash: { type: "string" },
47
+ short: { type: "string" },
48
+ subject: { type: "string" },
49
+ author: { type: "string" },
50
+ date: { type: "string" },
51
+ files: { type: "array", items: { type: "string" } },
52
+ },
53
+ required: ["hash", "short", "subject", "author", "date", "files"],
54
+ additionalProperties: false,
55
+ } as const
56
+
57
+ const changeOutput = {
58
+ type: "object",
59
+ properties: {
60
+ status: { type: "string" },
61
+ path: { type: "string" },
62
+ // Optional extras for the Files tab; older GUIs ignore them.
63
+ from: { type: "string" },
64
+ additions: { type: "number" },
65
+ deletions: { type: "number" },
66
+ binary: { type: "boolean" },
67
+ },
68
+ required: ["status", "path"],
69
+ additionalProperties: false,
70
+ } as const
71
+
72
+ const pullOutput = {
73
+ type: "object",
74
+ properties: {
75
+ number: { type: "number" },
76
+ title: { type: "string" },
77
+ url: { type: "string" },
78
+ branch: { type: "string" },
79
+ checks: { type: "string", enum: ["success", "failure", "none"] },
80
+ },
81
+ required: ["number", "title", "url", "branch", "checks"],
82
+ additionalProperties: false,
83
+ } as const
84
+
85
+ const issueOutput = {
86
+ type: "object",
87
+ properties: {
88
+ number: { type: "number" },
89
+ title: { type: "string" },
90
+ url: { type: "string" },
91
+ author: { type: "string" },
92
+ labels: { type: "array", items: { type: "string" } },
93
+ comments: { type: "number" },
94
+ date: { type: "string" },
95
+ },
96
+ required: ["number", "title", "url", "author", "labels", "comments", "date"],
97
+ additionalProperties: false,
98
+ } as const
99
+
100
+ const resultOutput = {
101
+ type: "object",
102
+ properties: {
103
+ ok: { type: "boolean" },
104
+ text: { type: "string" },
105
+ },
106
+ required: ["ok", "text"],
107
+ additionalProperties: false,
108
+ } as const
109
+
110
+ const diffInput = {
111
+ type: "object",
112
+ properties: {
113
+ directory: { type: "string" },
114
+ path: { type: "string" },
115
+ // Original path of a rename, so the diff shows the rename instead of a whole new file.
116
+ from: { type: "string" },
117
+ },
118
+ required: ["directory", "path"],
119
+ additionalProperties: false,
120
+ } as const
121
+
122
+ const diffOutput = {
123
+ type: "object",
124
+ properties: {
125
+ text: { type: "string" },
126
+ // True when an untracked directory has more files than the diff shows.
127
+ truncated: { type: "boolean" },
128
+ },
129
+ required: ["text"],
130
+ additionalProperties: false,
131
+ } as const
132
+
133
+ const commitSelectedInput = {
134
+ type: "object",
135
+ properties: {
136
+ directory: { type: "string" },
137
+ message: { type: "string" },
138
+ files: { type: "array", items: { type: "string" } },
139
+ },
140
+ required: ["directory", "message", "files"],
141
+ additionalProperties: false,
142
+ } as const
143
+
144
+ export const Git = Rpc.define({
145
+ id: "git-sidebar",
146
+ methods: {
147
+ status: {
148
+ input: directoryInput,
149
+ output: statusOutput,
150
+ },
151
+ pulls: {
152
+ input: directoryInput,
153
+ output: {
154
+ type: "array",
155
+ items: pullOutput,
156
+ },
157
+ },
158
+ issues: {
159
+ input: directoryInput,
160
+ output: {
161
+ type: "array",
162
+ items: issueOutput,
163
+ },
164
+ },
165
+ branches: {
166
+ input: {
167
+ type: "object",
168
+ properties: {
169
+ directory: { type: "string" },
170
+ limit: { type: "number" },
171
+ },
172
+ required: ["directory"],
173
+ additionalProperties: false,
174
+ },
175
+ output: {
176
+ type: "array",
177
+ items: branchOutput,
178
+ },
179
+ },
180
+ commits: {
181
+ input: {
182
+ type: "object",
183
+ properties: {
184
+ directory: { type: "string" },
185
+ limit: { type: "number" },
186
+ },
187
+ required: ["directory"],
188
+ additionalProperties: false,
189
+ },
190
+ output: {
191
+ type: "array",
192
+ items: commitOutput,
193
+ },
194
+ },
195
+ changes: {
196
+ input: directoryInput,
197
+ output: {
198
+ type: "array",
199
+ items: changeOutput,
200
+ },
201
+ },
202
+ branchAction: {
203
+ input: {
204
+ type: "object",
205
+ properties: {
206
+ directory: { type: "string" },
207
+ action: { type: "string", enum: ["checkout", "create", "delete", "merge"] },
208
+ name: { type: "string" },
209
+ },
210
+ required: ["directory", "action", "name"],
211
+ additionalProperties: false,
212
+ },
213
+ output: resultOutput,
214
+ },
215
+ pull: {
216
+ input: directoryInput,
217
+ output: resultOutput,
218
+ },
219
+ push: {
220
+ input: directoryInput,
221
+ output: resultOutput,
222
+ },
223
+ commit: {
224
+ input: {
225
+ type: "object",
226
+ properties: {
227
+ directory: { type: "string" },
228
+ message: { type: "string" },
229
+ },
230
+ required: ["directory", "message"],
231
+ additionalProperties: false,
232
+ },
233
+ output: resultOutput,
234
+ },
235
+ commitSelected: {
236
+ input: commitSelectedInput,
237
+ output: resultOutput,
238
+ },
239
+ fileDiff: {
240
+ input: diffInput,
241
+ output: diffOutput,
242
+ },
243
+ pr: {
244
+ input: {
245
+ type: "object",
246
+ properties: {
247
+ directory: { type: "string" },
248
+ title: { type: "string" },
249
+ },
250
+ required: ["directory"],
251
+ additionalProperties: false,
252
+ },
253
+ output: resultOutput,
254
+ },
255
+ },
256
+ events: {},
257
+ })