-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.ts
More file actions
106 lines (97 loc) · 4.7 KB
/
Copy pathpreload.ts
File metadata and controls
106 lines (97 loc) · 4.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { contextBridge, ipcRenderer } from "electron";
const api = {
auth: {
connect: (provider: "github" | "gitlab") =>
ipcRenderer.invoke("auth:connect", provider),
disconnect: (provider: "github" | "gitlab") =>
ipcRenderer.invoke("auth:disconnect", provider),
status: () => ipcRenderer.invoke("auth:status"),
},
git: {
scan: (directories: string[]) =>
ipcRenderer.invoke("git:scan", directories),
scanCandidates: (directories: string[]) =>
ipcRenderer.invoke("git:scan", directories, { mode: "candidates" }),
status: (repoPath: string, options?: unknown) =>
ipcRenderer.invoke("git:status", repoPath, options),
log: (repoPath: string, maxCount: number) =>
ipcRenderer.invoke("git:log", repoPath, maxCount),
show: (repoPath: string, hash: string) =>
ipcRenderer.invoke("git:log", repoPath, 1, hash),
commitStat: (repoPath: string, hash: string) =>
ipcRenderer.invoke("git:log", repoPath, 1, hash, { mode: "stat" }),
diff: async (repoPath: string) => {
const status = await ipcRenderer.invoke("git:status", repoPath, { mode: "diff" });
return status?.diff ?? "";
},
stashes: (repoPath: string) => ipcRenderer.invoke("git:stashes", repoPath),
stashShow: (repoPath: string, stashRef: string) =>
ipcRenderer.invoke("git:stash-show", repoPath, stashRef),
worktrees: (repoPath: string, options?: unknown) =>
ipcRenderer.invoke("git:worktrees", repoPath, options),
file: (repoPath: string, filePath: string, options?: unknown) =>
ipcRenderer.invoke("git:file", repoPath, filePath, options),
divergence: (repoPath: string, branch: string) =>
ipcRenderer.invoke("git:divergence", repoPath, branch),
push: (repoPath: string, remote: string, branch: string) =>
ipcRenderer.invoke("git:push", repoPath, remote, branch),
pull: (repoPath: string, remote: string, branch: string) =>
ipcRenderer.invoke("git:pull", repoPath, remote, branch),
commit: (repoPath: string, message: string) =>
ipcRenderer.invoke("git:commit", repoPath, message),
stashPop: (repoPath: string, stashRef: string) =>
ipcRenderer.invoke("git:stash-pop", repoPath, stashRef),
stashDrop: (repoPath: string, stashRef: string) =>
ipcRenderer.invoke("git:stash-drop", repoPath, stashRef),
},
github: {
repos: () => ipcRenderer.invoke("github:repos"),
issues: (repoFullName?: string) =>
ipcRenderer.invoke("github:issues", repoFullName ?? ""),
issueDetail: (repoFullName: string, issueNumber: number) =>
ipcRenderer.invoke("github:issues", repoFullName, { mode: "detail", number: issueNumber }),
prs: (repoFullName: string) =>
ipcRenderer.invoke("github:prs", repoFullName),
prDetail: (repoFullName: string, prNumber: number) =>
ipcRenderer.invoke("github:prs", repoFullName, { mode: "detail", number: prNumber }),
pipelines: (repoFullName: string) =>
ipcRenderer.invoke("github:pipelines", repoFullName),
comment: (repoFullName: string, prNumber: number, body: string) =>
ipcRenderer.invoke("github:comment", repoFullName, prNumber, body),
},
gitlab: {
projects: () => ipcRenderer.invoke("gitlab:projects"),
mrs: (projectId: string) => ipcRenderer.invoke("gitlab:mrs", projectId),
mrDetail: (projectId: string, mrIid: number) =>
ipcRenderer.invoke("gitlab:mrs", projectId, { mode: "detail", iid: mrIid }),
issues: (projectId: string) =>
ipcRenderer.invoke("gitlab:issues", projectId),
issueDetail: (projectId: string, issueIid: number) =>
ipcRenderer.invoke("gitlab:issues", projectId, { mode: "detail", number: issueIid }),
pipelines: (projectId: string) =>
ipcRenderer.invoke("gitlab:pipelines", projectId),
comment: (projectId: string, mrIid: number, body: string) =>
ipcRenderer.invoke("gitlab:comment", projectId, mrIid, body),
},
ai: {
complete: (systemPrompt: string, userPrompt: string) =>
ipcRenderer.invoke("ai:complete", systemPrompt, userPrompt),
status: () => ipcRenderer.invoke("ai:status"),
},
store: {
get: (key: string) => ipcRenderer.invoke("store:get", key),
set: (key: string, value: unknown) =>
ipcRenderer.invoke("store:set", key, value),
list: () => ipcRenderer.invoke("store:list"),
},
settings: {
saveWatsonx: (update: {
api_key?: string | null;
project_id?: string | null;
url?: string | null;
}) => ipcRenderer.invoke("settings:save-watsonx", update),
watsonxStatus: () => ipcRenderer.invoke("settings:watsonx-status"),
},
};
contextBridge.exposeInMainWorld("api", api);
export type API = typeof api;