Skip to content

Commit 2e9535c

Browse files
committed
docs: update bootstrap stub architecture documentation
Update documentation to reflect new esbuild-based bootstrap implementation: - bootstrap-stub.md: Update build process, IPC mechanism, and file locations - stub-execution.md: Update execution flow for new bootstrap - stub-package.md: Update package structure and build process Changes reflect the move to esbuild-based builds and simplified bootstrap wrapper architecture.
1 parent 3fda4fe commit 2e9535c

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

docs/architecture/bootstrap-stub.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This document describes Socket CLI's bootstrap stub architecture for distributin
44

55
## Overview
66

7-
Socket CLI uses a **bootstrap stub pattern** where the distributed executable is a tiny wrapper (~1-5MB) that downloads the full CLI (~20MB) on first use. The stub remains "dumb" - its only job is to download and spawn the full CLI. The full CLI (in `~/.socket/_cli/`) handles all functionality including updating both itself and the stub.
7+
Socket CLI uses a **bootstrap stub pattern** where the distributed executable is a tiny wrapper (~1-5MB) that downloads the full CLI (~20MB) on first use. The stub remains "dumb" - its only job is to download and spawn the full CLI. The full CLI (in `~/.socket/_dlx/`) handles all functionality including updating both itself and the stub.
88

99
This provides:
1010

@@ -41,7 +41,7 @@ This provides:
4141
│ Download & extract
4242
4343
┌─────────────────────────────────────────────────────────┐
44-
│ ~/.socket/_cli/ (User's home directory) │
44+
│ ~/.socket/_dlx/ (User's home directory) │
4545
│ │
4646
│ ├── package.json │
4747
│ ├── dist/ │
@@ -61,7 +61,7 @@ This provides:
6161
┌─────────────────────────────────────────────────────────┐
6262
│ System Node.js (from PATH) │
6363
│ │
64-
│ $ node ~/.socket/_cli/dist/cli.js [args] │
64+
│ $ node ~/.socket/_dlx/dist/cli.js [args] │
6565
│ │
6666
│ IPC Channel receives from stub: │
6767
│ • SOCKET_CLI_STUB_PATH (e.g., /usr/local/bin/socket)│
@@ -93,10 +93,10 @@ flowchart TD
9393
B -->|Yes| H[Get installed version]
9494
C --> D[Extract tarball to ~/.socket/tmp/]
9595
D --> E[Run npm install --production]
96-
E --> F[Move to ~/.socket/_cli/]
96+
E --> F[Move to ~/.socket/_dlx/]
9797
F --> G[Read package.json for entry point]
9898
H --> G
99-
G --> I[Spawn: node ~/.socket/_cli/dist/cli.js args]
99+
G --> I[Spawn: node ~/.socket/_dlx/dist/cli.js args]
100100
I --> J[Forward all stdio]
101101
J --> K[Exit with CLI exit code]
102102
```
@@ -108,7 +108,7 @@ Environment variables for customization:
108108
| Variable | Default | Description |
109109
|----------|---------|-------------|
110110
| `SOCKET_HOME` | `~/.socket` | Root directory for Socket CLI data |
111-
| `SOCKET_CLI_DIR` | `~/.socket/_cli` | CLI installation directory |
111+
| `SOCKET_CLI_DIR` | `~/.socket/_dlx` | CLI installation directory |
112112
| `SOCKET_CLI_PACKAGE` | `@socketsecurity/cli` | npm package name |
113113
| `SOCKET_NPM_REGISTRY` | `https://registry.npmjs.org` | npm registry URL |
114114
| `NPM_REGISTRY` | (fallback) | Alternative registry env var |
@@ -133,7 +133,7 @@ $ ./socket scan create
133133

134134
### Default Paths
135135

136-
- **Linux/macOS**: `~/.socket/_cli/`
136+
- **Linux/macOS**: `~/.socket/_dlx/`
137137
- **Windows**: `%USERPROFILE%\.socket\cli\`
138138

139139
### Directory Structure
@@ -169,7 +169,7 @@ $ ./socket scan create
169169
| Component | Size | Notes |
170170
|-----------|------|-------|
171171
| Bootstrap executable | ~1MB | Distributed to users |
172-
| Downloaded CLI | ~30MB | Cached in `~/.socket/_cli/` |
172+
| Downloaded CLI | ~30MB | Cached in `~/.socket/_dlx/` |
173173
| node_modules/ | ~15MB | Production dependencies only |
174174
| **Total** | **~45MB** | One-time download |
175175

@@ -179,7 +179,7 @@ $ ./socket scan create
179179

180180
Socket CLI implements a **two-tier update system**:
181181

182-
1. **CLI Self-Update**: The full CLI (`~/.socket/_cli/`) can update itself
182+
1. **CLI Self-Update**: The full CLI (`~/.socket/_dlx/`) can update itself
183183
2. **Stub Update**: The CLI can also update the stub binary that launched it
184184

185185
The stub remains "dumb" and never updates itself. All update logic lives in the full CLI.
@@ -201,7 +201,7 @@ The stub remains "dumb" and never updates itself. All update logic lives in the
201201
│ { SOCKET_CLI_STUB_PATH: process.argv[0] }
202202
203203
┌──────────────────────────────────────┐
204-
│ Full CLI (~/.socket/_cli/dist/cli.js) │
204+
│ Full CLI (~/.socket/_dlx/dist/cli.js) │
205205
│ - SMART: handles all logic │
206206
├──────────────────────────────────────┤
207207
│ Receives via IPC: │
@@ -400,7 +400,7 @@ Users can manually update:
400400
socket self-update
401401

402402
# Force re-download CLI (stub will re-download on next run)
403-
rm -rf ~/.socket/_cli
403+
rm -rf ~/.socket/_dlx
404404
socket --version
405405

406406
# Clean everything including temp files
@@ -558,7 +558,7 @@ ENOSPC: no space left on device
558558
559559
**Permissions:**
560560
```
561-
EACCES: permission denied, mkdir '~/.socket/_cli'
561+
EACCES: permission denied, mkdir '~/.socket/_dlx'
562562
```
563563
564564
### Recovery
@@ -567,7 +567,7 @@ Users can manually recover from errors:
567567
568568
```bash
569569
# Clean up corrupted installation
570-
rm -rf ~/.socket/_cli
570+
rm -rf ~/.socket/_dlx
571571
rm -rf ~/.socket/tmp
572572

573573
# Retry
@@ -585,7 +585,7 @@ Test the bootstrap locally before distribution:
585585
pnpm run build --sea
586586

587587
# Test first run (delete cache first)
588-
rm -rf ~/.socket/_cli
588+
rm -rf ~/.socket/_dlx
589589
./socket --version
590590

591591
# Test subsequent run
@@ -606,12 +606,12 @@ Test bootstrap in CI:
606606
pnpm run build --sea
607607

608608
# Test first run
609-
rm -rf ~/.socket/_cli
609+
rm -rf ~/.socket/_dlx
610610
./socket --version
611611

612612
# Verify installation
613-
test -d ~/.socket/_cli
614-
test -f ~/.socket/_cli/package.json
613+
test -d ~/.socket/_dlx
614+
test -f ~/.socket/_dlx/package.json
615615

616616
# Test subsequent run
617617
./socket --help

docs/architecture/stub-execution.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ User runs: /usr/local/bin/socket scan
3939
4040
┌──────────────────────────────────────────────────────────────────────┐
4141
│ Stub Binary (yao-pkg executable) │
42-
│ Checks: ~/.socket/_cli/package/package.json exists? │
42+
│ Checks: ~/.socket/_dlx/package/package.json exists? │
4343
└──────────────────────────────────────────────────────────────────────┘
4444
↓ No ↓ Yes
4545
┌──────────────────────────┐ ┌──────────────────────────────────────┐
@@ -66,7 +66,7 @@ User runs: /usr/local/bin/socket scan
6666
│ spawn('node', [ │ │ spawn(process.argv[0], [ │
6767
│ '--no-addons', │ │ '--no-addons', │
6868
│ '--no-warnings', │ │ '--no-warnings', │
69-
│ '~/.socket/_cli/package/dist/cli.js', │ '~/.socket/_cli/package/dist/cli.js', │
69+
│ '~/.socket/_dlx/package/dist/cli.js', │ '~/.socket/_dlx/package/dist/cli.js', │
7070
│ ...args │ │ ...args │
7171
│ ], { │ │ ], { │
7272
│ }) │ │ stdio: ['inherit', 'inherit', │
@@ -156,7 +156,7 @@ await scheduleUpdateCheck({
156156
- **`@socketsecurity/cli`**: The main CLI package with JavaScript code
157157
- Changes frequently (new features, bug fixes)
158158
- ~30MB when installed with node_modules
159-
- Downloaded and extracted to `~/.socket/_cli/package/`
159+
- Downloaded and extracted to `~/.socket/_dlx/package/`
160160

161161
- **`socket`**: The stub binary package
162162
- Changes rarely (only for bootstrap updates)
@@ -170,7 +170,7 @@ Download & Extract CLI:
170170
171171
┌──────────────────────────────────────────────────────────────────────┐
172172
│ 1. Download @socketsecurity/cli tarball │
173-
│ → ~/.socket/_cli/cli-1.1.24.tgz │
173+
│ → ~/.socket/_dlx/cli-1.1.24.tgz │
174174
└──────────────────────────────────────────────────────────────────────┘
175175
176176
┌──────────────────────────────────────────────────────────────────────┐
@@ -196,8 +196,8 @@ Download & Extract CLI:
196196
197197
┌──────────────────────────────────────────────────────────────────────┐
198198
│ 3. Cleanup: │
199-
│ - remove(~/.socket/_cli/cli-1.1.24.tgz) # Delete tarball │
200-
│ - remove(~/.socket/_cli/.install.lock) # Release lock │
199+
│ - remove(~/.socket/_dlx/cli-1.1.24.tgz) # Delete tarball │
200+
│ - remove(~/.socket/_dlx/.install.lock) # Release lock │
201201
└──────────────────────────────────────────────────────────────────────┘
202202
```
203203

@@ -231,7 +231,7 @@ socket self-update (when isSeaBinary()):
231231
│ │
232232
│ 1. Download new stub: │
233233
│ const stubName = `socket-${platform}-${arch}${ext}` │
234-
│ → ~/.socket/_cli/stub/downloads/socket-darwin-arm64 │
234+
│ → ~/.socket/_dlx/stub/downloads/socket-darwin-arm64 │
235235
│ │
236236
│ 2. CRITICAL: Set executable permissions │
237237
│ await fs.chmod(downloadPath, 0o755) │
@@ -240,12 +240,12 @@ socket self-update (when isSeaBinary()):
240240
│ await exec('xattr', ['-cr', downloadPath]) │
241241
│ │
242242
│ 4. Stage with permissions: │
243-
│ const stagingPath = ~/.socket/_cli/stub/staging/socket │
243+
│ const stagingPath = ~/.socket/_dlx/stub/staging/socket │
244244
│ await fs.copyFile(downloadPath, stagingPath) │
245245
│ await fs.chmod(stagingPath, 0o755) │
246246
│ │
247247
│ 5. Backup current: │
248-
│ const backupPath = `~/.socket/_cli/stub/backups/socket-${ts}` │
248+
│ const backupPath = `~/.socket/_dlx/stub/backups/socket-${ts}` │
249249
│ await fs.copyFile(currentStubPath, backupPath) │
250250
│ await fs.chmod(backupPath, 0o755) // Preserve exec │
251251
│ │
@@ -355,7 +355,7 @@ If installation fails:
355355
To recover:
356356
```bash
357357
# Clean partial installation
358-
rm -rf ~/.socket/_cli/package
358+
rm -rf ~/.socket/_dlx/package
359359

360360
# Retry
361361
socket --version
@@ -371,8 +371,8 @@ If update fails:
371371
To recover:
372372
```bash
373373
# Clean staging
374-
rm -rf ~/.socket/_cli/stub/staging/*
375-
rm -rf ~/.socket/_cli/stub/downloads/*
374+
rm -rf ~/.socket/_dlx/stub/staging/*
375+
rm -rf ~/.socket/_dlx/stub/downloads/*
376376

377377
# Retry
378378
socket self-update

docs/architecture/stub-package.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ $ socket scan
254254
│ Platform Binary (socket-linux-x64) │
255255
│ │
256256
│ 1. Stub Code Executes │
257-
│ 2. Check ~/.socket/_cli/package/ │
257+
│ 2. Check ~/.socket/_dlx/package/ │
258258
│ 3. Download @socketsecurity/cli if needed │
259259
│ 4. Spawn Node.js with CLI │
260260
└──────────────────────────────────────────┘
@@ -276,7 +276,7 @@ When running `socket self-update` as a SEA binary:
276276

277277
The actual CLI code updates independently:
278278
1. Check npm registry for `@socketsecurity/cli` version
279-
2. Download and extract new tarball to `~/.socket/_cli/package/`
279+
2. Download and extract new tarball to `~/.socket/_dlx/package/`
280280
3. Next execution uses new CLI code
281281

282282
## 7. Platform Support

0 commit comments

Comments
 (0)