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
package/.oxlintrc.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "plugins": null,
3
+ "categories": {},
4
+ "rules": {
5
+ "no-control-regex": "off",
6
+ "no-unused-vars": [
7
+ "warn",
8
+ {
9
+ "caughtErrors": "none",
10
+ "argsIgnorePattern": "^_",
11
+ "varsIgnorePattern": "^_"
12
+ }
13
+ ]
14
+ },
15
+ "settings": {
16
+ "jsx-a11y": {
17
+ "polymorphicPropName": null,
18
+ "components": {},
19
+ "attributes": {}
20
+ },
21
+ "next": {
22
+ "rootDir": []
23
+ },
24
+ "react": {
25
+ "formComponents": [],
26
+ "linkComponents": [],
27
+ "version": null,
28
+ "componentWrapperFunctions": []
29
+ },
30
+ "jsdoc": {
31
+ "ignorePrivate": false,
32
+ "ignoreInternal": false,
33
+ "ignoreReplacesDocs": true,
34
+ "overrideReplacesDocs": true,
35
+ "augmentsExtendsReplacesDocs": false,
36
+ "implementsReplacesDocs": false,
37
+ "exemptDestructuredRootsFromChecks": false,
38
+ "tagNamePreference": {}
39
+ },
40
+ "vitest": {
41
+ "typecheck": false
42
+ }
43
+ },
44
+ "env": {
45
+ "builtin": true
46
+ },
47
+ "globals": {},
48
+ "ignorePatterns": []
49
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Leaf Stack Studio Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,631 @@
1
+ # Spck CLI
2
+
3
+ CLI tool for [Spck Editor](https://spck.io) - provides remote filesystem, git, and terminal access over WebSocket.
4
+
5
+ Connect your local development environment to Spck Editor mobile app and access local files, git operations, and terminal sessions remotely.
6
+
7
+ ## Features
8
+
9
+ - 🗂️ **Remote Filesystem** - Access local files from Spck Editor mobile app
10
+ - 🔄 **Git Integration** - Full git operations over the network connection (requires Git 2.20.0+)
11
+ - 💻 **Terminal Access** - Interactive terminal sessions with xterm.js
12
+ - 🌐 **Browser Proxy** - Preview your local server in a browser view inside Spck Editor
13
+ - 🔍 **Fast Search** - Optimized file search with automatic ripgrep detection (100x faster when installed)
14
+ - 🔒 **Secure** - Cryptographically signed requests with optional Firebase authentication
15
+
16
+ ## Requirements
17
+
18
+ ### Required
19
+
20
+ - **Node.js**: 18.0.0 or higher
21
+ - **Operating System**: Linux, macOS, or Windows
22
+ - **Spck Editor Account**: Premium subscription required
23
+ - **Spck Editor Mobile App**: Required for QR code connection (Android/iOS)
24
+
25
+ ### Optional (Recommended)
26
+
27
+ - **Git**: 2.20.0 or higher - Required for git integration features (commit, push, pull, branch management)
28
+ - Check version: `git --version`
29
+ - Install:
30
+ - **macOS**: `brew install git` (via Homebrew)
31
+ - **Ubuntu/Debian**: `sudo apt-get install git`
32
+ - **Windows**: Download from [git-scm.com](https://git-scm.com)
33
+
34
+ - **ripgrep**: 15.0.0 or higher - Dramatically improves search performance (100x faster than default search)
35
+ - Check version: `rg --version`
36
+ - Install:
37
+ - **macOS**: `brew install ripgrep`
38
+ - **Ubuntu/Debian**: `sudo apt-get install ripgrep`
39
+ - **Windows**: `choco install ripgrep` (via Chocolatey) or download from [GitHub releases](https://github.com/BurntSushi/ripgrep/releases)
40
+ - **Note**: The CLI will automatically detect and use ripgrep if available, falling back to Node.js search if not installed
41
+
42
+ ## Installation
43
+
44
+ ### Run Directly with npx
45
+
46
+ No installation required - run directly using npx:
47
+
48
+ ```bash
49
+ npx spck
50
+ ```
51
+
52
+ ### Global Installation
53
+
54
+ Install the CLI globally to use it from anywhere:
55
+
56
+ ```bash
57
+ npm install -g spck
58
+ spck
59
+ ```
60
+
61
+ ## Getting Started
62
+
63
+ ### 1. First Run
64
+
65
+ On first run, the CLI will guide you through:
66
+
67
+ 1. **Firebase Authentication** - Sign in with your Spck Editor account
68
+ 2. **Configuration Setup** - Choose root directory and settings
69
+ 3. **Git Configuration** (Advanced) - Optionally add `.spck-editor/` to `.gitignore`
70
+
71
+ The setup wizard will:
72
+
73
+ - Detect if a `.gitignore` file exists in your project
74
+ - Prompt you to automatically add `.spck-editor/` to prevent committing the symlink
75
+ - Create or update `.gitignore` with proper comments
76
+
77
+ ### 2. Interactive Setup
78
+
79
+ To reconfigure or run the setup wizard manually:
80
+
81
+ ```bash
82
+ spck --setup
83
+ ```
84
+
85
+ ### 3. Connect to Spck Editor
86
+
87
+ Once running, the CLI displays a QR code and connection details.
88
+
89
+ #### Option A: QR Code (Mobile Only)
90
+
91
+ **IMPORTANT**: The Spck Editor mobile app must be installed BEFORE scanning the QR code. The QR code contains a custom `spck://` deep link that only works with the app installed.
92
+
93
+ **On Android:**
94
+
95
+ 1. **Install Spck Editor** from Google Play Store if not already installed
96
+ 2. Use your device's **built-in QR scanner**:
97
+ - Open the **Camera app** and point it at the QR code, OR
98
+ - Swipe down from the top and tap the **QR code scanner** in Quick Settings
99
+ 3. When the QR code is detected, Android will show a notification to **open with Spck Editor**
100
+ 4. Tap the notification to open Spck Editor
101
+ 5. The app will automatically parse the connection details and connect
102
+
103
+ **On iOS:**
104
+
105
+ 1. **Install Spck Editor** from the App Store if not already installed
106
+ 2. Use your device's **built-in QR scanner**:
107
+ - Open the **Camera app** and point it at the QR code, OR
108
+ - Open **Control Center** and tap the **QR code scanner** icon
109
+ 3. When the QR code is detected, iOS will show a notification to **open with Spck Editor**
110
+ 4. Tap the notification to open Spck Editor
111
+ 5. The app will automatically parse the connection details and connect
112
+
113
+ **Note**: Spck Editor does NOT have a built-in QR scanner. You must use your device's native QR scanning capability (camera or system scanner).
114
+
115
+ #### Option B: Manual Entry (Fallback)
116
+
117
+ If the QR code doesn't work or you prefer manual entry:
118
+
119
+ 1. Open **Spck Editor** mobile app
120
+ 2. Tap **Projects** → **New Project** → **Link Remote Server**
121
+ 3. Enter the **Client ID** and **Secret** shown below the QR code in your terminal
122
+ 4. Select a Relay server, must match what is shown in the terminal.
123
+ 5. Tap **Connect**
124
+
125
+ Once connected, you can browse and edit your local files from the mobile app!
126
+
127
+ ## CLI Options
128
+
129
+ ### Basic Commands
130
+
131
+ ```bash
132
+ # Start the CLI with default settings
133
+ spck
134
+
135
+ # Run interactive setup wizard
136
+ spck --setup
137
+
138
+ # Show account information
139
+ spck --account
140
+
141
+ # Logout and clear credentials
142
+ spck --logout
143
+
144
+ # Show help
145
+ spck --help
146
+
147
+ # Show version
148
+ spck --version
149
+ ```
150
+
151
+ ### Advanced Options
152
+
153
+ ```bash
154
+ # Use custom configuration file
155
+ spck --config /path/to/config.json
156
+ spck -c /path/to/config.json
157
+
158
+ # Override root directory
159
+ spck --root /path/to/project
160
+ spck -r /path/to/project
161
+ ```
162
+
163
+ ## Configuration
164
+
165
+ ### Configuration File
166
+
167
+ The configuration is stored in `.spck-editor/config/spck-cli.config.json` in your project directory.
168
+
169
+ **Important**: `.spck-editor/config` is a **symlink** to `~/.spck-editor/projects/{project_id}/`, which keeps your secrets outside the project directory and prevents accidental git commits. Other files like logs and temporary data are stored locally in `.spck-editor/.tmp`, `.spck-editor/.trash`, and `.spck-editor/logs`.
170
+
171
+ **Default Configuration:**
172
+
173
+ ```json
174
+ {
175
+ "version": 1,
176
+ "root": "/path/to/your/project",
177
+ "name": "My Project",
178
+ "terminal": {
179
+ "enabled": true,
180
+ "maxBufferedLines": 5000,
181
+ "maxTerminals": 10
182
+ },
183
+ "security": {
184
+ "userAuthenticationEnabled": false
185
+ },
186
+ "filesystem": {
187
+ "maxFileSize": "10MB",
188
+ "watchIgnorePatterns": [
189
+ "**/.git/**",
190
+ "**/.spck-editor/**",
191
+ "**/node_modules/**",
192
+ "**/*.log",
193
+ "**/.DS_Store",
194
+ "**/dist/**",
195
+ "**/build/**"
196
+ ]
197
+ },
198
+ "browserProxy": {
199
+ "enabled": true
200
+ }
201
+ }
202
+ ```
203
+
204
+ ### Configuration Options
205
+
206
+ #### Browser Proxy Settings
207
+
208
+ - **`browserProxy.enabled`** (boolean, default: `true`): Enable/disable the browser proxy feature. Set to `false` to prevent the mobile app from opening browser proxy sessions through the CLI.
209
+
210
+ #### Terminal Settings
211
+
212
+ - **`terminal.enabled`** (boolean): Enable/disable terminal access
213
+ - Default: `true`
214
+ - **`terminal.maxBufferedLines`** (number): Maximum scrollback buffer lines
215
+ - Default: `10000`
216
+ - **`terminal.maxTerminals`** (number): Maximum concurrent terminal sessions
217
+ - Default: `10`
218
+
219
+ #### Security Settings
220
+
221
+ - **`security.userAuthenticationEnabled`** (boolean): Enable Firebase user authentication
222
+ - Default: `false`
223
+ - When `true`: Requires Firebase account login (adds user identity verification, adds latency (2-20s) to initial connection)
224
+ - When `false`: Requests still protected by secret signing key (lower latency, compatible with Spck Editor Lite)
225
+ - **Note**: All requests are always cryptographically signed regardless of this setting
226
+
227
+ #### Filesystem Settings
228
+
229
+ - **`filesystem.maxFileSize`** (string): Maximum file size for read/write operations
230
+ - Default: `"10MB"`
231
+ - Accepts: `"5MB"`, `"50MB"`, etc.
232
+ - **`filesystem.watchIgnorePatterns`** (string[]): Glob patterns to ignore when watching files
233
+ - Default: Ignores `node_modules`, `.git`, `dist`, `build`
234
+
235
+ ### Credentials Storage
236
+
237
+ The CLI uses a secure storage system that prevents accidentally committing secrets to git:
238
+
239
+ - **User Credentials** (Global): `~/.spck-editor/.credentials.json`
240
+ - Contains: Firebase refresh token and user ID
241
+ - Persisted across all projects
242
+ - Stored securely in your home directory
243
+
244
+ - **Project Data** (Per-Project): `~/.spck-editor/projects/{project_id}/`
245
+ - Contains: Configuration and connection settings for each project
246
+ - Each project gets a unique ID based on its path
247
+ - Stored securely outside your project directory
248
+
249
+ - **Project Directory**: `.spck-editor` in your project directory
250
+ - Regular directory containing local data (`.tmp`, `.trash`, `logs`)
251
+ - The `config` subdirectory is a **symbolic link** pointing to `~/.spck-editor/projects/{project_id}/`
252
+ - Automatically created by the CLI
253
+ - Prevents secrets from being committed to git
254
+
255
+ **Files stored in the symlinked config directory** (`.spck-editor/config/`):
256
+
257
+ - `spck-cli.config.json` - Project configuration
258
+ - `connection-settings.json` - Server token, client ID, and secret signing key
259
+
260
+ **Files stored locally** (`.spck-editor/`):
261
+
262
+ - `.tmp/` - Temporary files
263
+ - `.trash/` - Deleted files
264
+ - `logs/` - CLI operation logs
265
+
266
+ ## Connection Limits
267
+
268
+ The maximum number of simultaneous CLI connections depends on your account type. When the limit is reached, you'll see:
269
+
270
+ ```
271
+ ⚠️ Maximum of X CLI connections reached.
272
+ Close other CLI instances and try again.
273
+ ```
274
+
275
+ **Note**: Only one Spck Editor mobile app can connect to a CLI instance at a time. Each CLI instance uses one connection slot.
276
+
277
+ To manage multiple projects simultaneously, run separate CLI instances (up to your account limit).
278
+
279
+ ## Security
280
+
281
+ Spck CLI is designed with security as a priority. Multiple layers of protection ensure your local files and development environment remain secure.
282
+
283
+ ### Encrypted Connections
284
+
285
+ All communication between the CLI and Spck Editor mobile app is encrypted:
286
+
287
+ - **WSS (WebSocket Secure)**: All WebSocket connections use TLS/SSL encryption
288
+ - **HTTPS**: All HTTP requests to the proxy server use HTTPS
289
+
290
+ ### Request Signing and Authentication
291
+
292
+ Spck CLI uses a two-layer security model:
293
+
294
+ #### 1. Secret Signing Key (Always Active)
295
+
296
+ **All requests are cryptographically signed** using a secret signing key:
297
+
298
+ - **Never Transmitted**: The secret key is generated locally and never sent over the network
299
+ - **Local Signing**: Every request is signed locally before transmission
300
+ - **Signature Verification**: The server verifies the signature to ensure requests are authentic
301
+ - **Per-Connection Secret**: Each CLI connection generates a unique cryptographically secure random secret
302
+
303
+ This base layer ensures that even without user authentication, only someone with access to the secret can make requests to your CLI instance.
304
+
305
+ #### 2. Firebase User Authentication (Optional)
306
+
307
+ User authentication provides an additional layer of identity verification:
308
+
309
+ **Configuration Option:**
310
+
311
+ ```json
312
+ {
313
+ "security": {
314
+ "userAuthenticationEnabled": true
315
+ }
316
+ }
317
+ ```
318
+
319
+ **When Enabled:**
320
+
321
+ - You must sign in with your Spck Editor account
322
+ - Connections use Firebase ID tokens that expire after 1 hour
323
+ - Expired tokens are automatically refreshed using secure refresh tokens
324
+ - Adds verification that the connecting user is using the same account as the CLI
325
+
326
+ **Trade-offs:**
327
+
328
+ - **Pros**: Adds user identity verification, prevents unauthorized access even if secret is compromised
329
+ - **Cons**: Adds latency to initial connection due to Firebase authentication
330
+ - **Compatibility**: Not supported by Spck Editor Lite
331
+
332
+ **When Disabled:**
333
+
334
+ - Requests are still protected by the secret signing key
335
+ - No additional latency from Firebase authentication
336
+ - Compatible with Spck Editor Lite
337
+ - Recommended for local development or when latency is a concern
338
+
339
+ **Note**: Even with user authentication disabled, all requests remain cryptographically signed and protected.
340
+
341
+ ### Connection Security
342
+
343
+ Each CLI connection has unique security credentials:
344
+
345
+ - **Client ID**: Unique identifier for each CLI instance (keep this secret for anonymity, attacker must be able to guess your Client ID to connect)
346
+ - **Secret**: Cryptographically secure random secret (generated per connection, never transmitted through the internet)
347
+ - **Server Token**: Time-limited token that expires after 24 hours
348
+
349
+ The Client ID and Secret are stored in `.spck-editor/config/connection-settings.json` and should never be shared publicly. Anyone with access to these credentials can connect to your CLI instance if `userAuthenticationEnabled` is also disabled.
350
+
351
+ ### Terminal Access Control
352
+
353
+ Terminal access can be disabled entirely if you only need filesystem and git operations:
354
+
355
+ **Configuration Option:**
356
+
357
+ ```json
358
+ {
359
+ "terminal": {
360
+ "enabled": false
361
+ }
362
+ }
363
+ ```
364
+
365
+ When `terminal.enabled` is set to `false`:
366
+
367
+ - No terminal sessions can be created
368
+ - The CLI will not spawn any shell processes
369
+ - Only filesystem and git operations are available
370
+
371
+ This reduces the attack surface if you don't need terminal functionality.
372
+
373
+ ### Browser Proxy Access Control
374
+
375
+ The browser proxy feature allows the mobile app to open a proxy browser view that previews your local server through the CLI. It can be disabled if you don't need it:
376
+
377
+ **Configuration Option:**
378
+
379
+ ```json
380
+ {
381
+ "browserProxy": {
382
+ "enabled": false
383
+ }
384
+ }
385
+ ```
386
+
387
+ When `browserProxy.enabled` is set to `false`:
388
+
389
+ - The mobile app cannot open browser proxy sessions through the CLI
390
+ - All browser proxy requests will be rejected with a `FEATURE_DISABLED` error
391
+ - All other features (filesystem, git, terminal) remain available
392
+
393
+ **Backward Compatibility**: Existing config files that do not have a `browserProxy` section will default to `enabled: true`. The CLI will automatically add the field and re-save the config on the next run.
394
+
395
+ ### Best Practices
396
+
397
+ 1. **Protect Connection Credentials**
398
+ - **Automatic Git Protection**: The setup wizard will detect `.gitignore` and offer to add `.spck-editor/` automatically
399
+ - If you skipped the setup prompt, manually add to `.gitignore`:
400
+ ```
401
+ .spck-editor/
402
+ ```
403
+ - **Security by Design**: Project secrets are stored in `~/.spck-editor/projects/{project_id}/` via the `.spck-editor/config` symlink
404
+ - Never share or commit files from `~/.spck-editor/` (contains secret signing keys and tokens)
405
+ - If user authentication is enabled, keep `~/.spck-editor/.credentials.json` private
406
+
407
+ 2. **Logout on Shared Machines**
408
+ - Always run `spck --logout` when done on shared computers
409
+ - This clears all authentication tokens and connection settings
410
+
411
+ 3. **Review Active Connections**
412
+ - Use `spck --account` to view active connections
413
+ - Close unused CLI instances to free connection slots
414
+
415
+ 4. **Limit Exposed Directories**
416
+ - Use `--root` to specify the minimum necessary directory
417
+ - Don't expose your entire home directory or system root
418
+
419
+ 5. **Monitor Terminal Sessions**
420
+ - Be aware of which terminal sessions are active
421
+ - Close unused terminals when done
422
+ - Configure `terminal.maxTerminals` to limit concurrent sessions
423
+
424
+ 6. **Firewall Configuration**
425
+ - Ensure WebSocket connections (WSS) are allowed through your firewall
426
+ - The CLI connects to a regional relay server over WSS (port 443)
427
+
428
+ ### File Access Permissions
429
+
430
+ The CLI operates with your local user permissions:
431
+
432
+ - Files are read/written with your user's file system permissions
433
+ - Terminal sessions run with your user account privileges
434
+ - No privilege escalation occurs
435
+
436
+ ### What Data Is Transmitted
437
+
438
+ The CLI only transmits data explicitly requested by Spck Editor app:
439
+
440
+ - **File Operations**: File contents only when you open/save files
441
+ - **Git Operations**: Git metadata and repository data during git commands
442
+ - **Terminal I/O**: Terminal input/output during active sessions
443
+ - **File Watching**: File change notifications (paths only, not contents)
444
+
445
+ ## Troubleshooting
446
+
447
+ ### Root Directory Not Found
448
+
449
+ If the root directory doesn't exist:
450
+
451
+ ```bash
452
+ # Reconfigure with correct path
453
+ spck --setup
454
+ ```
455
+
456
+ Or manually specify the path:
457
+
458
+ ```bash
459
+ spck --root /correct/path/to/project
460
+ ```
461
+
462
+ ### Corrupted Configuration
463
+
464
+ If configuration files are corrupted:
465
+
466
+ ```bash
467
+ # Clear settings and start fresh
468
+ spck --logout
469
+ spck --setup
470
+ ```
471
+
472
+ ### Connection Issues
473
+
474
+ If the CLI cannot connect to the proxy server:
475
+
476
+ 1. **Check internet connection**
477
+ 2. **Try logging out and reconnecting**:
478
+ ```bash
479
+ spck --logout
480
+ spck
481
+ ```
482
+ 3. **Check firewall settings** - ensure WebSocket connections are allowed
483
+
484
+ ### Git Operations Not Working
485
+
486
+ If git operations (commit, push, pull, etc.) are not working:
487
+
488
+ 1. **Verify Git is installed**:
489
+
490
+ ```bash
491
+ git --version
492
+ ```
493
+
494
+ - Required: Git 2.20.0 or higher
495
+ - If not installed, see installation instructions in the [Requirements](#optional-recommended) section
496
+
497
+ 2. **Check repository initialization**:
498
+
499
+ ```bash
500
+ cd /path/to/project
501
+ git status
502
+ ```
503
+
504
+ - If not a git repository, initialize it: `git init`
505
+
506
+ ### Slow Search Performance
507
+
508
+ If file search is slow:
509
+
510
+ 1. **Install ripgrep for 100x faster search**:
511
+
512
+ ```bash
513
+ # macOS
514
+ brew install ripgrep
515
+
516
+ # Ubuntu/Debian
517
+ sudo apt-get install ripgrep
518
+
519
+ # Windows (Chocolatey)
520
+ choco install ripgrep
521
+ ```
522
+
523
+ 2. **Verify installation**:
524
+
525
+ ```bash
526
+ rg --version
527
+ ```
528
+
529
+ - The CLI will automatically detect and use ripgrep if available
530
+
531
+ ### Git Ignore Issues
532
+
533
+ **Add .spck-editor/ to .gitignore manually:**
534
+
535
+ If you skipped the setup wizard prompt or need to add it manually:
536
+
537
+ ```bash
538
+ # Append to .gitignore
539
+ echo ".spck-editor/" >> .gitignore
540
+ ```
541
+
542
+ Or add it with a comment for clarity:
543
+
544
+ ```bash
545
+ cat >> .gitignore << 'EOF'
546
+
547
+ # Spck CLI project data
548
+ .spck-editor/
549
+ EOF
550
+ ```
551
+
552
+ **Re-run setup to trigger .gitignore prompt:**
553
+
554
+ ```bash
555
+ spck --setup
556
+ ```
557
+
558
+ The setup wizard will detect your `.gitignore` and offer to add the entry automatically.
559
+
560
+ ## Examples
561
+
562
+ ### Basic Usage
563
+
564
+ ```bash
565
+ # Start in current directory
566
+ cd /path/to/project
567
+ spck
568
+
569
+ # Start with specific root directory
570
+ spck --root /path/to/project
571
+ ```
572
+
573
+ ### Multiple Projects
574
+
575
+ ```bash
576
+ # Terminal 1: Project A
577
+ cd /path/to/projectA
578
+ spck
579
+
580
+ # Terminal 2: Project B
581
+ cd /path/to/projectB
582
+ spck
583
+ ```
584
+
585
+ Each project maintains its own configuration and connection.
586
+
587
+ ### Custom Configuration
588
+
589
+ ```bash
590
+ # Use custom config file
591
+ spck --config ~/my-custom-config.json
592
+
593
+ # Override root directory
594
+ spck --root ~/projects/myapp
595
+ ```
596
+
597
+ ## Development
598
+
599
+ ### Building from Source
600
+
601
+ ```bash
602
+ # Clone the repository
603
+ cd cli
604
+ npm install
605
+ npm run build
606
+ ```
607
+
608
+ ### Running Tests
609
+
610
+ ```bash
611
+ npm test
612
+ npm run test:coverage
613
+ ```
614
+
615
+ ## License
616
+
617
+ MIT License - see [LICENSE](LICENSE) file for details.
618
+
619
+ ## Links
620
+
621
+ - **Website**: [https://spck.io](https://spck.io)
622
+ - **Documentation**: [https://spck.io/docs/cli](https://spck.io/docs/cli)
623
+ - **Download**: [Spck Editor on Google Play](https://play.google.com/store/apps/details?id=io.spck) | [Spck Editor on App Store](https://apps.apple.com/us/app/spck-editor/id1507309511)
624
+
625
+ ## Support
626
+
627
+ For help and support, visit [spck.io](https://spck.io) or contact support through the mobile app.
628
+
629
+ ---
630
+
631
+ Made with ❤️ by the Spck Editor team