spck 0.3.1
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/.oxlintrc.json +49 -0
- package/LICENSE +21 -0
- package/README.md +631 -0
- package/bin/cli.js +20 -0
- package/bin/validate-cwd.js +41 -0
- package/dist/config/__tests__/config.test.d.ts +2 -0
- package/dist/config/__tests__/config.test.js +262 -0
- package/dist/config/__tests__/credentials.test.d.ts +2 -0
- package/dist/config/__tests__/credentials.test.js +360 -0
- package/dist/config/config.d.ts +33 -0
- package/dist/config/config.js +185 -0
- package/dist/config/credentials.d.ts +75 -0
- package/dist/config/credentials.js +259 -0
- package/dist/config/server-selection.d.ts +40 -0
- package/dist/config/server-selection.js +130 -0
- package/dist/connection/__tests__/firebase-auth.test.d.ts +2 -0
- package/dist/connection/__tests__/firebase-auth.test.js +96 -0
- package/dist/connection/__tests__/hmac.test.d.ts +2 -0
- package/dist/connection/__tests__/hmac.test.js +372 -0
- package/dist/connection/auth.d.ts +13 -0
- package/dist/connection/auth.js +91 -0
- package/dist/connection/firebase-auth.d.ts +40 -0
- package/dist/connection/firebase-auth.js +429 -0
- package/dist/connection/hmac.d.ts +24 -0
- package/dist/connection/hmac.js +109 -0
- package/dist/i18n/index.d.ts +25 -0
- package/dist/i18n/index.js +101 -0
- package/dist/i18n/locales/en.json +313 -0
- package/dist/i18n/locales/es.json +302 -0
- package/dist/i18n/locales/fr.json +302 -0
- package/dist/i18n/locales/id.json +302 -0
- package/dist/i18n/locales/ja.json +302 -0
- package/dist/i18n/locales/ko.json +302 -0
- package/dist/i18n/locales/locales/en.json +309 -0
- package/dist/i18n/locales/locales/es.json +302 -0
- package/dist/i18n/locales/locales/fr.json +302 -0
- package/dist/i18n/locales/locales/id.json +302 -0
- package/dist/i18n/locales/locales/ja.json +302 -0
- package/dist/i18n/locales/locales/ko.json +302 -0
- package/dist/i18n/locales/locales/pt.json +302 -0
- package/dist/i18n/locales/locales/zh-Hans.json +302 -0
- package/dist/i18n/locales/pt.json +302 -0
- package/dist/i18n/locales/zh-Hans.json +302 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +493 -0
- package/dist/proxy/ProxyClient.d.ts +125 -0
- package/dist/proxy/ProxyClient.js +781 -0
- package/dist/proxy/ProxySocketWrapper.d.ts +43 -0
- package/dist/proxy/ProxySocketWrapper.js +98 -0
- package/dist/proxy/__tests__/ProxyClient.test.d.ts +2 -0
- package/dist/proxy/__tests__/ProxyClient.test.js +445 -0
- package/dist/proxy/__tests__/ProxySocketWrapper.test.d.ts +2 -0
- package/dist/proxy/__tests__/ProxySocketWrapper.test.js +190 -0
- package/dist/proxy/__tests__/handshake-validation.test.d.ts +2 -0
- package/dist/proxy/__tests__/handshake-validation.test.js +282 -0
- package/dist/proxy/__tests__/token-refresh-race.test.d.ts +14 -0
- package/dist/proxy/__tests__/token-refresh-race.test.js +173 -0
- package/dist/proxy/chunking.d.ts +53 -0
- package/dist/proxy/chunking.js +127 -0
- package/dist/proxy/handshake-validation.d.ts +21 -0
- package/dist/proxy/handshake-validation.js +49 -0
- package/dist/rpc/__tests__/router.test.d.ts +2 -0
- package/dist/rpc/__tests__/router.test.js +262 -0
- package/dist/rpc/router.d.ts +37 -0
- package/dist/rpc/router.js +132 -0
- package/dist/services/BrowserProxyService.d.ts +13 -0
- package/dist/services/BrowserProxyService.js +139 -0
- package/dist/services/FilesystemService.d.ts +99 -0
- package/dist/services/FilesystemService.js +742 -0
- package/dist/services/GitService.d.ts +243 -0
- package/dist/services/GitService.js +1439 -0
- package/dist/services/SearchService.d.ts +93 -0
- package/dist/services/SearchService.js +670 -0
- package/dist/services/TerminalService.d.ts +62 -0
- package/dist/services/TerminalService.js +337 -0
- package/dist/services/__tests__/BrowserProxyService.test.d.ts +2 -0
- package/dist/services/__tests__/BrowserProxyService.test.js +145 -0
- package/dist/services/__tests__/FilesystemService.test.d.ts +2 -0
- package/dist/services/__tests__/FilesystemService.test.js +609 -0
- package/dist/services/__tests__/GitService.test.d.ts +2 -0
- package/dist/services/__tests__/GitService.test.js +953 -0
- package/dist/services/__tests__/SearchService.test.d.ts +2 -0
- package/dist/services/__tests__/SearchService.test.js +384 -0
- package/dist/services/__tests__/TerminalService.test.d.ts +2 -0
- package/dist/services/__tests__/TerminalService.test.js +513 -0
- package/dist/setup/wizard.d.ts +10 -0
- package/dist/setup/wizard.js +172 -0
- package/dist/types.d.ts +196 -0
- package/dist/types.js +44 -0
- package/dist/utils/__tests__/gitignore.test.d.ts +2 -0
- package/dist/utils/__tests__/gitignore.test.js +127 -0
- package/dist/utils/gitignore.d.ts +24 -0
- package/dist/utils/gitignore.js +77 -0
- package/dist/utils/logger.d.ts +96 -0
- package/dist/utils/logger.js +456 -0
- package/dist/utils/project-dir.d.ts +51 -0
- package/dist/utils/project-dir.js +191 -0
- package/dist/utils/ripgrep.d.ts +34 -0
- package/dist/utils/ripgrep.js +148 -0
- package/dist/utils/tool-detection.d.ts +17 -0
- package/dist/utils/tool-detection.js +126 -0
- package/dist/watcher/FileWatcher.d.ts +10 -0
- package/dist/watcher/FileWatcher.js +42 -0
- package/package.json +70 -0
- package/src/config/__tests__/config.test.ts +318 -0
- package/src/config/__tests__/credentials.test.ts +494 -0
- package/src/config/config.ts +206 -0
- package/src/config/credentials.ts +302 -0
- package/src/config/server-selection.ts +150 -0
- package/src/connection/__tests__/firebase-auth.test.ts +121 -0
- package/src/connection/__tests__/hmac.test.ts +509 -0
- package/src/connection/auth.ts +140 -0
- package/src/connection/firebase-auth.ts +504 -0
- package/src/connection/hmac.ts +139 -0
- package/src/i18n/index.ts +119 -0
- package/src/i18n/locales/en.json +313 -0
- package/src/i18n/locales/es.json +302 -0
- package/src/i18n/locales/fr.json +302 -0
- package/src/i18n/locales/id.json +302 -0
- package/src/i18n/locales/ja.json +302 -0
- package/src/i18n/locales/ko.json +302 -0
- package/src/i18n/locales/pt.json +302 -0
- package/src/i18n/locales/zh-Hans.json +302 -0
- package/src/index.ts +542 -0
- package/src/proxy/ProxyClient.ts +968 -0
- package/src/proxy/ProxySocketWrapper.ts +113 -0
- package/src/proxy/__tests__/ProxyClient.test.ts +575 -0
- package/src/proxy/__tests__/ProxySocketWrapper.test.ts +251 -0
- package/src/proxy/__tests__/handshake-validation.test.ts +367 -0
- package/src/proxy/chunking.ts +162 -0
- package/src/proxy/handshake-validation.ts +64 -0
- package/src/rpc/__tests__/router.test.ts +400 -0
- package/src/rpc/router.ts +183 -0
- package/src/services/BrowserProxyService.ts +179 -0
- package/src/services/FilesystemService.ts +841 -0
- package/src/services/GitService.ts +1639 -0
- package/src/services/SearchService.ts +809 -0
- package/src/services/TerminalService.ts +413 -0
- package/src/services/__tests__/BrowserProxyService.test.ts +155 -0
- package/src/services/__tests__/FilesystemService.test.ts +1002 -0
- package/src/services/__tests__/GitService.test.ts +1552 -0
- package/src/services/__tests__/SearchService.test.ts +484 -0
- package/src/services/__tests__/TerminalService.test.ts +702 -0
- package/src/setup/wizard.ts +242 -0
- package/src/types/fossil-delta.d.ts +4 -0
- package/src/types.ts +287 -0
- package/src/utils/__tests__/gitignore.test.ts +174 -0
- package/src/utils/gitignore.ts +91 -0
- package/src/utils/logger.ts +578 -0
- package/src/utils/project-dir.ts +218 -0
- package/src/utils/ripgrep.ts +180 -0
- package/src/utils/tool-detection.ts +141 -0
- package/src/watcher/FileWatcher.ts +53 -0
- package/tsconfig.json +24 -0
- package/vitest.config.ts +19 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git service - executes command-line git operations
|
|
3
|
+
*/
|
|
4
|
+
import { AuthenticatedSocket } from '../types.js';
|
|
5
|
+
export declare class GitService {
|
|
6
|
+
private rootPath;
|
|
7
|
+
private submoduleCache;
|
|
8
|
+
private static SUBMODULE_CACHE_TTL;
|
|
9
|
+
private _hasCurl;
|
|
10
|
+
constructor(rootPath: string);
|
|
11
|
+
/**
|
|
12
|
+
* Check if curl is available on the system (cached)
|
|
13
|
+
*/
|
|
14
|
+
private hasCurl;
|
|
15
|
+
/**
|
|
16
|
+
* Get submodules for a directory, using a short-lived cache to avoid
|
|
17
|
+
* repeated git submodule status calls during bulk operations.
|
|
18
|
+
*/
|
|
19
|
+
private getCachedSubmodules;
|
|
20
|
+
/**
|
|
21
|
+
* Resolve the effective git working directory.
|
|
22
|
+
* When gitRoot is provided (submodule path), resolve it relative to dir.
|
|
23
|
+
*/
|
|
24
|
+
private resolveGitCwd;
|
|
25
|
+
/**
|
|
26
|
+
* Handle git RPC methods
|
|
27
|
+
*/
|
|
28
|
+
handle(method: string, params: any, socket: AuthenticatedSocket): Promise<any>;
|
|
29
|
+
/**
|
|
30
|
+
* Validate git directory
|
|
31
|
+
*/
|
|
32
|
+
private validateGitDir;
|
|
33
|
+
/**
|
|
34
|
+
* Sanitize filename to prevent command injection
|
|
35
|
+
* Rejects filenames that could be interpreted as git flags or contain control characters
|
|
36
|
+
*/
|
|
37
|
+
private sanitizeFilename;
|
|
38
|
+
/**
|
|
39
|
+
* Execute git command
|
|
40
|
+
*/
|
|
41
|
+
private execGit;
|
|
42
|
+
/**
|
|
43
|
+
* Read commit object
|
|
44
|
+
*/
|
|
45
|
+
private readCommit;
|
|
46
|
+
/**
|
|
47
|
+
* Parse commit object
|
|
48
|
+
*/
|
|
49
|
+
private parseCommit;
|
|
50
|
+
/**
|
|
51
|
+
* Parse git identity (author/committer)
|
|
52
|
+
*/
|
|
53
|
+
private parseIdentity;
|
|
54
|
+
/**
|
|
55
|
+
* Read git object
|
|
56
|
+
*/
|
|
57
|
+
private readObject;
|
|
58
|
+
/**
|
|
59
|
+
* Get HEAD tree oid
|
|
60
|
+
*/
|
|
61
|
+
private getHeadTree;
|
|
62
|
+
/**
|
|
63
|
+
* Get object ID at path in tree or index stage
|
|
64
|
+
* @param dir - Git repository directory
|
|
65
|
+
* @param params.path - File path to lookup
|
|
66
|
+
* @param params.tree - Tree object ID to search in (e.g., HEAD tree)
|
|
67
|
+
* @param params.stage - Index stage number (0=normal, 1=ancestor, 2=ours, 3=theirs during merge)
|
|
68
|
+
*/
|
|
69
|
+
private getOidAtPath;
|
|
70
|
+
/**
|
|
71
|
+
* List files in ref
|
|
72
|
+
*/
|
|
73
|
+
private listFiles;
|
|
74
|
+
/**
|
|
75
|
+
* Resolve ref to oid
|
|
76
|
+
*/
|
|
77
|
+
private resolveRef;
|
|
78
|
+
/**
|
|
79
|
+
* Get current branch
|
|
80
|
+
*/
|
|
81
|
+
private currentBranch;
|
|
82
|
+
/**
|
|
83
|
+
* Get commit history
|
|
84
|
+
*/
|
|
85
|
+
private log;
|
|
86
|
+
/**
|
|
87
|
+
* Get working directory status
|
|
88
|
+
* Uses two git commands:
|
|
89
|
+
* 1. With -uall for detailed untracked files
|
|
90
|
+
* 2. With --ignored (no -uall) for rolled-up ignored directories
|
|
91
|
+
*/
|
|
92
|
+
private status;
|
|
93
|
+
/**
|
|
94
|
+
* Parse git status output into status array
|
|
95
|
+
*/
|
|
96
|
+
private parseGitStatus;
|
|
97
|
+
/**
|
|
98
|
+
* Get status counts (conflicts, changes, fileCount)
|
|
99
|
+
*/
|
|
100
|
+
private statusCounts;
|
|
101
|
+
/**
|
|
102
|
+
* Stage files
|
|
103
|
+
*/
|
|
104
|
+
private add;
|
|
105
|
+
/**
|
|
106
|
+
* Remove files from index (git rm --cached)
|
|
107
|
+
*/
|
|
108
|
+
private remove;
|
|
109
|
+
/**
|
|
110
|
+
* Reset file(s) in index to match ref (git reset <ref> -- <filepath(s)>)
|
|
111
|
+
*/
|
|
112
|
+
private resetIndex;
|
|
113
|
+
/**
|
|
114
|
+
* Create commit
|
|
115
|
+
*/
|
|
116
|
+
private commit;
|
|
117
|
+
/**
|
|
118
|
+
* Allowed git config key patterns.
|
|
119
|
+
* Only these keys can be read or written via the RPC interface
|
|
120
|
+
* to prevent injection of dangerous config like core.sshCommand.
|
|
121
|
+
*/
|
|
122
|
+
private static ALLOWED_CONFIG_KEYS;
|
|
123
|
+
/**
|
|
124
|
+
* Allowed git config key prefixes for dynamic keys (e.g. remote.origin.url)
|
|
125
|
+
*/
|
|
126
|
+
private static ALLOWED_CONFIG_PREFIXES;
|
|
127
|
+
/**
|
|
128
|
+
* Validate that a git config key is allowed
|
|
129
|
+
*/
|
|
130
|
+
private validateConfigKey;
|
|
131
|
+
/**
|
|
132
|
+
* Get config value
|
|
133
|
+
*/
|
|
134
|
+
private getConfig;
|
|
135
|
+
/**
|
|
136
|
+
* Set config value
|
|
137
|
+
*/
|
|
138
|
+
private setConfig;
|
|
139
|
+
/**
|
|
140
|
+
* List branches
|
|
141
|
+
* When remote is specified, returns branch names without the remote prefix
|
|
142
|
+
* to match isomorphic-git behavior (e.g. 'main' instead of 'origin/main')
|
|
143
|
+
*/
|
|
144
|
+
private listBranches;
|
|
145
|
+
/**
|
|
146
|
+
* Validate a git ref (branch name, tag, or commit hash)
|
|
147
|
+
* Rejects refs that could be interpreted as flags
|
|
148
|
+
*/
|
|
149
|
+
private sanitizeRef;
|
|
150
|
+
/**
|
|
151
|
+
* Checkout branch or commit
|
|
152
|
+
*/
|
|
153
|
+
private checkout;
|
|
154
|
+
/**
|
|
155
|
+
* Initialize repository
|
|
156
|
+
*/
|
|
157
|
+
private init;
|
|
158
|
+
/**
|
|
159
|
+
* List git remotes
|
|
160
|
+
*/
|
|
161
|
+
private listRemotes;
|
|
162
|
+
/**
|
|
163
|
+
* Add git remote
|
|
164
|
+
*/
|
|
165
|
+
private addRemote;
|
|
166
|
+
/**
|
|
167
|
+
* Delete git remote
|
|
168
|
+
*/
|
|
169
|
+
private deleteRemote;
|
|
170
|
+
/**
|
|
171
|
+
* Clear git index (remove cached files)
|
|
172
|
+
*/
|
|
173
|
+
private clearIndex;
|
|
174
|
+
/**
|
|
175
|
+
* Find which submodule a filepath belongs to (if any).
|
|
176
|
+
* Returns the submodule path and the filepath relative to the submodule root.
|
|
177
|
+
*/
|
|
178
|
+
private findSubmoduleForPath;
|
|
179
|
+
/**
|
|
180
|
+
* Check if file is ignored by .gitignore
|
|
181
|
+
* Handles files inside submodules by running check-ignore from the submodule dir
|
|
182
|
+
*/
|
|
183
|
+
private isIgnored;
|
|
184
|
+
/**
|
|
185
|
+
* Run git check-ignore for a list of paths in a single directory.
|
|
186
|
+
* Returns a Set of ignored paths.
|
|
187
|
+
*/
|
|
188
|
+
private checkIgnorePaths;
|
|
189
|
+
/**
|
|
190
|
+
* Check multiple files if they are ignored by .gitignore
|
|
191
|
+
* Returns array of 1 (ignored) or 0 (not ignored) for bandwidth efficiency
|
|
192
|
+
* Handles files inside submodules by routing check-ignore to the submodule dir
|
|
193
|
+
*/
|
|
194
|
+
private bulkIsIgnored;
|
|
195
|
+
/**
|
|
196
|
+
* Check if directory is a git repository
|
|
197
|
+
* Uses git rev-parse --is-inside-work-tree
|
|
198
|
+
*/
|
|
199
|
+
private isInitialized;
|
|
200
|
+
/**
|
|
201
|
+
* List git submodules
|
|
202
|
+
* Uses git submodule status to detect submodules
|
|
203
|
+
* Note: always runs from the main repo dir (not gitCwd)
|
|
204
|
+
*/
|
|
205
|
+
private listSubmodules;
|
|
206
|
+
/**
|
|
207
|
+
* Check if a file exists in HEAD commit
|
|
208
|
+
* Used to determine if a renamed file is truly new or was previously committed
|
|
209
|
+
*/
|
|
210
|
+
private isFileInHead;
|
|
211
|
+
/**
|
|
212
|
+
* Get default author from git config
|
|
213
|
+
*/
|
|
214
|
+
private getDefaultAuthor;
|
|
215
|
+
/**
|
|
216
|
+
* Push to remote
|
|
217
|
+
*/
|
|
218
|
+
private push;
|
|
219
|
+
/**
|
|
220
|
+
* Pull from remote
|
|
221
|
+
*/
|
|
222
|
+
private pull;
|
|
223
|
+
/**
|
|
224
|
+
* Fetch from remote
|
|
225
|
+
*/
|
|
226
|
+
private fetch;
|
|
227
|
+
/**
|
|
228
|
+
* Clone a repository
|
|
229
|
+
*/
|
|
230
|
+
private clone;
|
|
231
|
+
/**
|
|
232
|
+
* Set up an askpass mechanism for SSH/Git credential prompts.
|
|
233
|
+
* Creates a temporary HTTP server and shell script that SSH_ASKPASS/GIT_ASKPASS
|
|
234
|
+
* points to. When SSH or git needs a passphrase/password, it calls the script,
|
|
235
|
+
* which forwards the prompt to the client via requestAuth.
|
|
236
|
+
*/
|
|
237
|
+
private setupAskpass;
|
|
238
|
+
/**
|
|
239
|
+
* Request authentication from client (server-to-client RPC)
|
|
240
|
+
*/
|
|
241
|
+
private requestAuth;
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=GitService.d.ts.map
|