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.
Files changed (155) hide show
  1. package/.oxlintrc.json +49 -0
  2. package/LICENSE +21 -0
  3. package/README.md +631 -0
  4. package/bin/cli.js +20 -0
  5. package/bin/validate-cwd.js +41 -0
  6. package/dist/config/__tests__/config.test.d.ts +2 -0
  7. package/dist/config/__tests__/config.test.js +262 -0
  8. package/dist/config/__tests__/credentials.test.d.ts +2 -0
  9. package/dist/config/__tests__/credentials.test.js +360 -0
  10. package/dist/config/config.d.ts +33 -0
  11. package/dist/config/config.js +185 -0
  12. package/dist/config/credentials.d.ts +75 -0
  13. package/dist/config/credentials.js +259 -0
  14. package/dist/config/server-selection.d.ts +40 -0
  15. package/dist/config/server-selection.js +130 -0
  16. package/dist/connection/__tests__/firebase-auth.test.d.ts +2 -0
  17. package/dist/connection/__tests__/firebase-auth.test.js +96 -0
  18. package/dist/connection/__tests__/hmac.test.d.ts +2 -0
  19. package/dist/connection/__tests__/hmac.test.js +372 -0
  20. package/dist/connection/auth.d.ts +13 -0
  21. package/dist/connection/auth.js +91 -0
  22. package/dist/connection/firebase-auth.d.ts +40 -0
  23. package/dist/connection/firebase-auth.js +429 -0
  24. package/dist/connection/hmac.d.ts +24 -0
  25. package/dist/connection/hmac.js +109 -0
  26. package/dist/i18n/index.d.ts +25 -0
  27. package/dist/i18n/index.js +101 -0
  28. package/dist/i18n/locales/en.json +313 -0
  29. package/dist/i18n/locales/es.json +302 -0
  30. package/dist/i18n/locales/fr.json +302 -0
  31. package/dist/i18n/locales/id.json +302 -0
  32. package/dist/i18n/locales/ja.json +302 -0
  33. package/dist/i18n/locales/ko.json +302 -0
  34. package/dist/i18n/locales/locales/en.json +309 -0
  35. package/dist/i18n/locales/locales/es.json +302 -0
  36. package/dist/i18n/locales/locales/fr.json +302 -0
  37. package/dist/i18n/locales/locales/id.json +302 -0
  38. package/dist/i18n/locales/locales/ja.json +302 -0
  39. package/dist/i18n/locales/locales/ko.json +302 -0
  40. package/dist/i18n/locales/locales/pt.json +302 -0
  41. package/dist/i18n/locales/locales/zh-Hans.json +302 -0
  42. package/dist/i18n/locales/pt.json +302 -0
  43. package/dist/i18n/locales/zh-Hans.json +302 -0
  44. package/dist/index.d.ts +25 -0
  45. package/dist/index.js +493 -0
  46. package/dist/proxy/ProxyClient.d.ts +125 -0
  47. package/dist/proxy/ProxyClient.js +781 -0
  48. package/dist/proxy/ProxySocketWrapper.d.ts +43 -0
  49. package/dist/proxy/ProxySocketWrapper.js +98 -0
  50. package/dist/proxy/__tests__/ProxyClient.test.d.ts +2 -0
  51. package/dist/proxy/__tests__/ProxyClient.test.js +445 -0
  52. package/dist/proxy/__tests__/ProxySocketWrapper.test.d.ts +2 -0
  53. package/dist/proxy/__tests__/ProxySocketWrapper.test.js +190 -0
  54. package/dist/proxy/__tests__/handshake-validation.test.d.ts +2 -0
  55. package/dist/proxy/__tests__/handshake-validation.test.js +282 -0
  56. package/dist/proxy/__tests__/token-refresh-race.test.d.ts +14 -0
  57. package/dist/proxy/__tests__/token-refresh-race.test.js +173 -0
  58. package/dist/proxy/chunking.d.ts +53 -0
  59. package/dist/proxy/chunking.js +127 -0
  60. package/dist/proxy/handshake-validation.d.ts +21 -0
  61. package/dist/proxy/handshake-validation.js +49 -0
  62. package/dist/rpc/__tests__/router.test.d.ts +2 -0
  63. package/dist/rpc/__tests__/router.test.js +262 -0
  64. package/dist/rpc/router.d.ts +37 -0
  65. package/dist/rpc/router.js +132 -0
  66. package/dist/services/BrowserProxyService.d.ts +13 -0
  67. package/dist/services/BrowserProxyService.js +139 -0
  68. package/dist/services/FilesystemService.d.ts +99 -0
  69. package/dist/services/FilesystemService.js +742 -0
  70. package/dist/services/GitService.d.ts +243 -0
  71. package/dist/services/GitService.js +1439 -0
  72. package/dist/services/SearchService.d.ts +93 -0
  73. package/dist/services/SearchService.js +670 -0
  74. package/dist/services/TerminalService.d.ts +62 -0
  75. package/dist/services/TerminalService.js +337 -0
  76. package/dist/services/__tests__/BrowserProxyService.test.d.ts +2 -0
  77. package/dist/services/__tests__/BrowserProxyService.test.js +145 -0
  78. package/dist/services/__tests__/FilesystemService.test.d.ts +2 -0
  79. package/dist/services/__tests__/FilesystemService.test.js +609 -0
  80. package/dist/services/__tests__/GitService.test.d.ts +2 -0
  81. package/dist/services/__tests__/GitService.test.js +953 -0
  82. package/dist/services/__tests__/SearchService.test.d.ts +2 -0
  83. package/dist/services/__tests__/SearchService.test.js +384 -0
  84. package/dist/services/__tests__/TerminalService.test.d.ts +2 -0
  85. package/dist/services/__tests__/TerminalService.test.js +513 -0
  86. package/dist/setup/wizard.d.ts +10 -0
  87. package/dist/setup/wizard.js +172 -0
  88. package/dist/types.d.ts +196 -0
  89. package/dist/types.js +44 -0
  90. package/dist/utils/__tests__/gitignore.test.d.ts +2 -0
  91. package/dist/utils/__tests__/gitignore.test.js +127 -0
  92. package/dist/utils/gitignore.d.ts +24 -0
  93. package/dist/utils/gitignore.js +77 -0
  94. package/dist/utils/logger.d.ts +96 -0
  95. package/dist/utils/logger.js +456 -0
  96. package/dist/utils/project-dir.d.ts +51 -0
  97. package/dist/utils/project-dir.js +191 -0
  98. package/dist/utils/ripgrep.d.ts +34 -0
  99. package/dist/utils/ripgrep.js +148 -0
  100. package/dist/utils/tool-detection.d.ts +17 -0
  101. package/dist/utils/tool-detection.js +126 -0
  102. package/dist/watcher/FileWatcher.d.ts +10 -0
  103. package/dist/watcher/FileWatcher.js +42 -0
  104. package/package.json +70 -0
  105. package/src/config/__tests__/config.test.ts +318 -0
  106. package/src/config/__tests__/credentials.test.ts +494 -0
  107. package/src/config/config.ts +206 -0
  108. package/src/config/credentials.ts +302 -0
  109. package/src/config/server-selection.ts +150 -0
  110. package/src/connection/__tests__/firebase-auth.test.ts +121 -0
  111. package/src/connection/__tests__/hmac.test.ts +509 -0
  112. package/src/connection/auth.ts +140 -0
  113. package/src/connection/firebase-auth.ts +504 -0
  114. package/src/connection/hmac.ts +139 -0
  115. package/src/i18n/index.ts +119 -0
  116. package/src/i18n/locales/en.json +313 -0
  117. package/src/i18n/locales/es.json +302 -0
  118. package/src/i18n/locales/fr.json +302 -0
  119. package/src/i18n/locales/id.json +302 -0
  120. package/src/i18n/locales/ja.json +302 -0
  121. package/src/i18n/locales/ko.json +302 -0
  122. package/src/i18n/locales/pt.json +302 -0
  123. package/src/i18n/locales/zh-Hans.json +302 -0
  124. package/src/index.ts +542 -0
  125. package/src/proxy/ProxyClient.ts +968 -0
  126. package/src/proxy/ProxySocketWrapper.ts +113 -0
  127. package/src/proxy/__tests__/ProxyClient.test.ts +575 -0
  128. package/src/proxy/__tests__/ProxySocketWrapper.test.ts +251 -0
  129. package/src/proxy/__tests__/handshake-validation.test.ts +367 -0
  130. package/src/proxy/chunking.ts +162 -0
  131. package/src/proxy/handshake-validation.ts +64 -0
  132. package/src/rpc/__tests__/router.test.ts +400 -0
  133. package/src/rpc/router.ts +183 -0
  134. package/src/services/BrowserProxyService.ts +179 -0
  135. package/src/services/FilesystemService.ts +841 -0
  136. package/src/services/GitService.ts +1639 -0
  137. package/src/services/SearchService.ts +809 -0
  138. package/src/services/TerminalService.ts +413 -0
  139. package/src/services/__tests__/BrowserProxyService.test.ts +155 -0
  140. package/src/services/__tests__/FilesystemService.test.ts +1002 -0
  141. package/src/services/__tests__/GitService.test.ts +1552 -0
  142. package/src/services/__tests__/SearchService.test.ts +484 -0
  143. package/src/services/__tests__/TerminalService.test.ts +702 -0
  144. package/src/setup/wizard.ts +242 -0
  145. package/src/types/fossil-delta.d.ts +4 -0
  146. package/src/types.ts +287 -0
  147. package/src/utils/__tests__/gitignore.test.ts +174 -0
  148. package/src/utils/gitignore.ts +91 -0
  149. package/src/utils/logger.ts +578 -0
  150. package/src/utils/project-dir.ts +218 -0
  151. package/src/utils/ripgrep.ts +180 -0
  152. package/src/utils/tool-detection.ts +141 -0
  153. package/src/watcher/FileWatcher.ts +53 -0
  154. package/tsconfig.json +24 -0
  155. 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