@snapback/cli 1.0.0

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/README.md ADDED
@@ -0,0 +1,565 @@
1
+ # @snapback/cli
2
+
3
+ **Command-line interface for SnapBack** - AI-safe code snapshots, risk analysis, and intelligent validation.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # Global installation
9
+ npm install -g @snapback/cli
10
+
11
+ # Or use via npx
12
+ npx @snapback/cli <command>
13
+
14
+ # Or with pnpm
15
+ pnpm add -g @snapback/cli
16
+ ```
17
+
18
+ ## Quick Start
19
+
20
+ ```bash
21
+ # First-time setup with interactive wizard
22
+ snap wizard
23
+
24
+ # Initialize SnapBack in your project
25
+ snap init
26
+
27
+ # Analyze a file for risk
28
+ snap analyze src/auth.ts
29
+
30
+ # Create a snapshot before risky changes
31
+ snap snapshot -m "Before major refactor"
32
+
33
+ # Check staged files before commit
34
+ snap check --all
35
+
36
+ # Run diagnostics if something seems wrong
37
+ snap doctor
38
+ ```
39
+
40
+ ## Commands
41
+
42
+ ### Core Commands
43
+
44
+ | Command | Description |
45
+ |---------|-------------|
46
+ | `snap init` | Initialize `.snapback/` directory in workspace |
47
+ | `snap analyze <file>` | Risk analysis for a single file |
48
+ | `snap snapshot` | Create a snapshot of current state |
49
+ | `snap list` | List all snapshots |
50
+ | `snap check` | Pre-commit hook to check for risky changes |
51
+
52
+ ### Intelligence Commands
53
+
54
+ These commands integrate `@snapback/intelligence` for learning loop and validation:
55
+
56
+ | Command | Description | Example |
57
+ |---------|-------------|---------|
58
+ | `snap context [task]` | Get relevant context before work | `snap context "add auth" -k auth session` |
59
+ | `snap validate <file>` | Run 7-layer validation pipeline | `snap validate src/auth.ts` |
60
+ | `snap validate --all` | Validate all staged files | `snap validate --all --quiet` |
61
+ | `snap stats` | Show learning statistics | `snap stats --json` |
62
+
63
+ ### Learning Commands
64
+
65
+ | Command | Description |
66
+ |---------|-------------|
67
+ | `snap learn record` | Record a new learning |
68
+ | `snap learn list` | List recorded learnings |
69
+ | `snap patterns report` | Report a violation (auto-promotes at 3x) |
70
+ | `snap patterns summary` | Show violation patterns and status |
71
+
72
+ ### Protection Commands
73
+
74
+ | Command | Description |
75
+ |---------|-------------|
76
+ | `snap protect add <file>` | Add file to protection list |
77
+ | `snap protect remove <file>` | Remove file from protection |
78
+ | `snap protect list` | List protected files |
79
+ | `snap session start` | Start a coding session |
80
+ | `snap session end` | End current session |
81
+
82
+ ### Utility Commands
83
+
84
+ | Command | Description |
85
+ |---------|-------------|
86
+ | `snap status` | Show workspace status |
87
+ | `snap fix` | Fix common issues |
88
+ | `snap watch` | Continuous file watching daemon |
89
+ | `snap interactive` | Guided TUI workflow |
90
+
91
+ ### Polish Commands
92
+
93
+ | Command | Description |
94
+ |---------|-------------|
95
+ | `snap wizard` | Interactive first-run setup wizard |
96
+ | `snap doctor` | Comprehensive diagnostics and health check |
97
+ | `snap doctor --fix` | Auto-fix detected issues |
98
+ | `snap upgrade` | Check for and install CLI updates |
99
+ | `snap upgrade --check` | Only check for updates, don't install |
100
+ | `snap config list` | List all configuration values |
101
+ | `snap config get <key>` | Get a specific config value |
102
+ | `snap config set <key> <value>` | Set a configuration value |
103
+ | `snap config path` | Show config file locations |
104
+ | `snap undo` | Undo the last destructive operation |
105
+ | `snap undo --list` | Show recent undoable operations |
106
+ | `snap alias list` | List command shortcuts |
107
+ | `snap alias set <name> <cmd>` | Create a command alias |
108
+ | `snap alias suggest` | Show recommended aliases |
109
+
110
+ ### MCP Server Command
111
+
112
+ | Command | Description |
113
+ |---------|-------------|
114
+ | `snap mcp --stdio` | Start MCP server for Cursor/Claude integration |
115
+
116
+ ## World-Class UX Features
117
+
118
+ SnapBack CLI implements best practices from GitHub CLI, Vercel CLI, and Stripe CLI.
119
+
120
+ ### Smart Error Messages
121
+
122
+ When something goes wrong, SnapBack suggests fixes:
123
+
124
+ ```
125
+ ╭───────────────────────────────────────────────────╮
126
+ │ [ERR_NOT_INIT] Workspace Not Initialized │
127
+ │ │
128
+ │ This workspace hasn't been set up for SnapBack │
129
+ │ │
130
+ │ 💡 Suggestion: │
131
+ │ Initialize SnapBack in this directory │
132
+ │ │
133
+ │ 📋 Try running: │
134
+ │ $ snap init │
135
+ ╰───────────────────────────────────────────────────╯
136
+ ```
137
+
138
+ ### Unknown Command Suggestions
139
+
140
+ Typos are caught with helpful suggestions:
141
+
142
+ ```bash
143
+ $ snap statis
144
+ ╭────────────────────────────────╮
145
+ │ Unknown command: statis │
146
+ │ │
147
+ │ Did you mean: │
148
+ │ $ snap status │
149
+ │ $ snap stats │
150
+ ╰────────────────────────────────╯
151
+ ```
152
+
153
+ ### Interactive First-Run Wizard
154
+
155
+ ```bash
156
+ $ snap wizard
157
+ ```
158
+
159
+ Guided 5-step onboarding:
160
+ 1. **Authentication** - Browser login or API key
161
+ 2. **Workspace Setup** - Auto-detects project type
162
+ 3. **Protection Level** - Standard or Strict mode
163
+ 4. **MCP Integration** - Configure AI tool integration
164
+ 5. **Analytics** - Optional anonymous usage data
165
+
166
+ ### Terminal Hyperlinks
167
+
168
+ In supported terminals (iTerm2, VS Code, Windows Terminal, Kitty, etc.), SnapBack outputs clickable links:
169
+ - File paths open in your editor
170
+ - Documentation links open in browser
171
+ - Error codes link to troubleshooting guides
172
+
173
+ ### Command Aliases
174
+
175
+ Create shortcuts for common workflows:
176
+
177
+ ```bash
178
+ # Create aliases
179
+ snap alias set st status
180
+ snap alias set ss snapshot
181
+ snap alias set ctx "context --keywords"
182
+
183
+ # Now use them
184
+ snap st # → snap status
185
+ snap ss -m "before refactor" # → snap snapshot -m "..."
186
+
187
+ # See suggested aliases
188
+ snap alias suggest
189
+ ```
190
+
191
+ ### Undo Support
192
+
193
+ Revert destructive operations:
194
+
195
+ ```bash
196
+ # Undo the last operation
197
+ snap undo
198
+
199
+ # View recent operations
200
+ snap undo --list
201
+ ```
202
+
203
+ ### Dry-Run Mode
204
+
205
+ Preview changes before executing:
206
+
207
+ ```bash
208
+ snap init --dry-run
209
+ ```
210
+
211
+ Shows exactly what files will be created/modified without making changes.
212
+
213
+ ### Confirmation Prompts
214
+
215
+ Destructive operations require confirmation:
216
+ - Standard risk: Simple Y/n prompt
217
+ - High risk: Must type "yes, delete" to confirm
218
+ - Use `--force` to skip (for CI/automation)
219
+
220
+ ### Diagnostics (Doctor Command)
221
+
222
+ ```bash
223
+ $ snap doctor
224
+
225
+ 🏥 SnapBack Diagnostics
226
+
227
+ ✓ Node.js version v20.10.0
228
+ ✓ CLI installation v0.5.2 (latest)
229
+ ✓ Global directory ~/.snapback/ exists
230
+ ✓ Authentication Logged in as @user
231
+ ✓ Workspace .snapback/ initialized
232
+ ✓ MCP tools 3 tools configured
233
+ ✓ Git repository Clean
234
+ ✓ Network API reachable
235
+
236
+ All checks passed!
237
+ ```
238
+
239
+ ### Shell Completions
240
+
241
+ Enable tab completion for your shell:
242
+
243
+ **Bash:**
244
+ ```bash
245
+ eval "$(snap completion bash)"
246
+ # Or add to ~/.bashrc
247
+ ```
248
+
249
+ **Zsh:**
250
+ ```bash
251
+ eval "$(snap completion zsh)"
252
+ # Or add to ~/.zshrc
253
+ ```
254
+
255
+ **Fish:**
256
+ ```fish
257
+ snap completion fish | source
258
+ # Or save to ~/.config/fish/completions/snap.fish
259
+ ```
260
+
261
+ Completion scripts are also available at:
262
+ - `apps/cli/resources/completions/snap.bash`
263
+ - `apps/cli/resources/completions/snap.zsh`
264
+ - `apps/cli/resources/completions/snap.fish`
265
+
266
+ ## MCP Server Integration
267
+
268
+ SnapBack includes an MCP (Model Context Protocol) server for integration with AI coding assistants like Cursor, Claude Desktop, Windsurf, and others.
269
+
270
+ ### Starting the MCP Server
271
+
272
+ ```bash
273
+ # Start with stdio transport (default)
274
+ snap mcp --stdio
275
+
276
+ # Specify workspace explicitly
277
+ snap mcp --stdio --workspace /path/to/your/project
278
+
279
+ # Specify user tier
280
+ snap mcp --stdio --tier pro
281
+ ```
282
+
283
+ ### Configuration for AI Clients
284
+
285
+ Add to your MCP client configuration (e.g., `mcp.json` for Qoder, Claude, or Cursor):
286
+
287
+ ```json
288
+ {
289
+ "mcpServers": {
290
+ "snapback": {
291
+ "command": "node",
292
+ "args": [
293
+ "/absolute/path/to/apps/cli/dist/index.js",
294
+ "mcp",
295
+ "--stdio",
296
+ "--workspace",
297
+ "/absolute/path/to/your/project"
298
+ ],
299
+ "env": {
300
+ "SNAPBACK_API_KEY": "your-api-key-here"
301
+ }
302
+ }
303
+ }
304
+ }
305
+ ```
306
+
307
+ **Important:** Both the CLI path and workspace path must be **absolute paths**.
308
+
309
+ ### Workspace Requirements
310
+
311
+ The MCP server validates that the workspace contains at least one of these markers:
312
+
313
+ - `.git/` directory
314
+ - `package.json` file
315
+ - `.snapback/` directory
316
+
317
+ If validation fails, you'll see:
318
+ ```
319
+ [SnapBack MCP] Workspace validation failed: Workspace must contain at least one marker: .git, package.json, or .snapback
320
+ ```
321
+
322
+ **Solution:** Ensure the `--workspace` argument points to a valid project root.
323
+
324
+ ### Troubleshooting
325
+
326
+ | Error | Cause | Solution |
327
+ |-------|-------|----------|
328
+ | `Cannot find module` | Relative path used | Use absolute paths for both CLI and workspace |
329
+ | `Workspace validation failed` | Missing `--workspace` arg | Add `--workspace /path/to/project` to args |
330
+ | `context deadline exceeded` | Server timeout | Check environment variables are set correctly |
331
+
332
+ ### Environment Variables
333
+
334
+ | Variable | Required | Description |
335
+ |----------|----------|-------------|
336
+ | `SNAPBACK_API_KEY` | Optional | API key for Pro features |
337
+ | `BETTER_AUTH_SECRET` | Optional | Auth secret (32+ chars) |
338
+ | `DATABASE_URL` | Optional | PostgreSQL connection URL |
339
+ | `REDIS_URL` | Optional | Redis/Upstash URL |
340
+
341
+ ## Intelligence Integration
342
+
343
+ The CLI integrates `@snapback/intelligence` to provide the same learning loop and validation capabilities as SnapBack's internal development tools.
344
+
345
+ ### Pre-Work Context
346
+
347
+ Get relevant patterns, learnings, and constraints before starting work:
348
+
349
+ ```bash
350
+ # Get context for a task
351
+ snap context "add user authentication"
352
+
353
+ # Include files you'll modify
354
+ snap context "refactor auth" --files src/auth.ts src/session.ts
355
+
356
+ # Search with specific keywords
357
+ snap context --keywords auth session jwt
358
+
359
+ # Machine-readable output
360
+ snap context "add auth" --json
361
+ ```
362
+
363
+ **Output:**
364
+ ```
365
+ ┌─────────────────────────────────────────┐
366
+ │ 📋 Context Loaded │
367
+ │ │
368
+ │ Hard Rules: 12 constraints │
369
+ │ Patterns: 8 patterns │
370
+ │ Learnings: 3 relevant │
371
+ │ Violations: 2 to avoid │
372
+ └─────────────────────────────────────────┘
373
+
374
+ Relevant Learnings:
375
+ ┌──────────┬──────────────┬─────────────────────────────────┐
376
+ │ Type │ Trigger │ Action │
377
+ ├──────────┼──────────────┼─────────────────────────────────┤
378
+ │ pattern │ auth │ Use @snapback/auth package... │
379
+ └──────────┴──────────────┴─────────────────────────────────┘
380
+ ```
381
+
382
+ ### Pre-Commit Validation
383
+
384
+ Run the 7-layer validation pipeline before committing:
385
+
386
+ ```bash
387
+ # Validate a single file
388
+ snap validate src/auth.ts
389
+
390
+ # Validate all staged files
391
+ snap validate --all
392
+
393
+ # Quiet mode (only output if issues)
394
+ snap validate --all --quiet
395
+
396
+ # JSON output for CI
397
+ snap validate --all --json
398
+ ```
399
+
400
+ **The 7 Validation Layers:**
401
+
402
+ | Layer | Checks |
403
+ |-------|--------|
404
+ | **Syntax** | Bracket matching, semicolons |
405
+ | **Types** | `any` usage, `@ts-ignore`, non-null assertions |
406
+ | **Tests** | Vague assertions, 4-path coverage |
407
+ | **Architecture** | Layer boundaries, service bypass |
408
+ | **Security** | Hardcoded secrets, `eval()` |
409
+ | **Dependencies** | Deprecated packages |
410
+ | **Performance** | console.log, sync I/O, await in loops |
411
+
412
+ ### Learning Statistics
413
+
414
+ Monitor your learning system's health:
415
+
416
+ ```bash
417
+ snap stats
418
+ ```
419
+
420
+ **Output:**
421
+ ```
422
+ ┌─────────────────────────────────────────┐
423
+ │ 📊 Learning Statistics │
424
+ │ │
425
+ │ Total Interactions: 142 │
426
+ │ Feedback Rate: 68% │
427
+ │ Accuracy Rate: 94% │
428
+ │ Golden Examples: 23 │
429
+ └─────────────────────────────────────────┘
430
+
431
+ Violation Patterns:
432
+ ┌────────────────────────┬───────┬─────────────────────────┐
433
+ │ Type │ Count │ Status │
434
+ ├────────────────────────┼───────┼─────────────────────────┤
435
+ │ missing-error-handling │ 5 │ 🤖 Ready for automation │
436
+ │ vague-assertion │ 3 │ 📈 Ready for promotion │
437
+ └────────────────────────┴───────┴─────────────────────────┘
438
+ ```
439
+
440
+ ### Auto-Promotion Thresholds
441
+
442
+ - **1x seen**: Stored in `violations.jsonl`
443
+ - **3x seen**: Auto-promoted to `workspace-patterns.json`
444
+ - **5x seen**: Marked for automated detection
445
+
446
+ ## Pre-Commit Hook
447
+
448
+ Install as a git pre-commit hook:
449
+
450
+ ```bash
451
+ #!/bin/sh
452
+ # .git/hooks/pre-commit
453
+ npx @snapback/cli check --snapshot --quiet
454
+ ```
455
+
456
+ Or with lefthook (`.lefthook.yml`):
457
+
458
+ ```yaml
459
+ pre-commit:
460
+ commands:
461
+ snapback-check:
462
+ run: npx @snapback/cli check --all --quiet
463
+ ```
464
+
465
+ ## CI/CD Integration
466
+
467
+ ### GitHub Actions
468
+
469
+ ```yaml
470
+ - name: Validate code
471
+ run: npx @snapback/cli validate --all --json > validation-report.json
472
+
473
+ - name: Check for risky changes
474
+ run: npx @snapback/cli check --quiet
475
+ ```
476
+
477
+ ### Exit Codes
478
+
479
+ - `0`: All checks passed
480
+ - `1`: Issues found (validation failed, risky changes detected)
481
+
482
+ ## Configuration
483
+
484
+ ### Workspace Structure
485
+
486
+ After `snap init`, your workspace will have:
487
+
488
+ ```
489
+ your-project/
490
+ ├── .snapback/
491
+ │ ├── config.json # Workspace configuration
492
+ │ ├── vitals.json # Workspace vitals
493
+ │ ├── constraints.md # Your project constraints (optional)
494
+ │ ├── patterns/
495
+ │ │ ├── violations.jsonl # Tracked violations
496
+ │ │ └── workspace-patterns.json # Promoted patterns
497
+ │ └── learnings/
498
+ │ └── user-learnings.jsonl # Recorded learnings
499
+ └── .snapbackrc # CLI configuration
500
+ ```
501
+
502
+ ### `.snapbackrc` Options
503
+
504
+ ```json
505
+ {
506
+ "protectionLevel": "warn",
507
+ "autoSnapshot": true,
508
+ "riskThreshold": 5.0,
509
+ "ignorePaths": ["node_modules", "dist", ".git"]
510
+ }
511
+ ```
512
+
513
+ ## Dependencies
514
+
515
+ ### Core Packages
516
+ - **@snapback/intelligence**: Learning loop, validation pipeline
517
+ - **@snapback/core**: Guardian risk analysis
518
+ - **@snapback/engine**: V2 analysis engine
519
+ - **@snapback/contracts**: Type definitions
520
+
521
+ ### CLI Framework
522
+ - **commander**: CLI framework
523
+ - **chalk**: Terminal styling
524
+ - **boxen**: Box rendering
525
+ - **cli-table3**: Table formatting
526
+ - **ora**: Spinners
527
+ - **inquirer**: Interactive prompts
528
+
529
+ ### UX Enhancements
530
+ - Smart error messages with actionable suggestions
531
+ - Levenshtein distance for typo detection
532
+ - OSC 8 terminal hyperlinks
533
+ - Dry-run mode with diff preview
534
+ - Operation history for undo support
535
+ - Command aliases
536
+
537
+ ## Development
538
+
539
+ ```bash
540
+ # Clone the repo
541
+ git clone https://github.com/snapback-dev/snapback.git
542
+ cd snapback
543
+
544
+ # Install dependencies
545
+ pnpm install
546
+
547
+ # Build the CLI
548
+ pnpm --filter @snapback/cli build
549
+
550
+ # Run locally
551
+ node apps/cli/dist/index.js <command>
552
+
553
+ # Run tests
554
+ pnpm --filter @snapback/cli test
555
+ ```
556
+
557
+ ## Related Packages
558
+
559
+ - [`@snapback/intelligence`](../../packages/intelligence/README.md) - Learning and validation engine
560
+ - [`@snapback/core`](../../packages/core/README.md) - Core snapshot logic
561
+ - [`@snapback/sdk`](../../packages/sdk/README.md) - SDK for integrations
562
+
563
+ ## License
564
+
565
+ Apache-2.0
@@ -0,0 +1,4 @@
1
+ export { analyzeSkippedTests, detectSkippedTests, getSkippedTestSummary } from './chunk-BJS6XH2V.js';
2
+ import './chunk-WCQVDF3K.js';
3
+ //# sourceMappingURL=SkippedTestDetector-JY4EF5BN.js.map
4
+ //# sourceMappingURL=SkippedTestDetector-JY4EF5BN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"SkippedTestDetector-JY4EF5BN.js"}
@@ -0,0 +1,5 @@
1
+ export { ChangeImpactAnalyzer, CompletenessAnalyzer, SecurityAnalyzer, SyntaxAnalyzer, checkFilesForOrphanStatus, createChangeImpactAnalyzer, detectOrphans, filterOrphansToFiles, runStaticAnalysis } from './chunk-VSJ33PLA.js';
2
+ export { analyzeSkippedTests, detectSkippedTests, getSkippedTestSummary } from './chunk-BJS6XH2V.js';
3
+ import './chunk-WCQVDF3K.js';
4
+ //# sourceMappingURL=analysis-B4NVULM4.js.map
5
+ //# sourceMappingURL=analysis-B4NVULM4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"analysis-B4NVULM4.js"}
@@ -0,0 +1,26 @@
1
+ import { __name } from './chunk-WCQVDF3K.js';
2
+ import { nanoid } from 'nanoid';
3
+
4
+ function generateId(prefix) {
5
+ const id = nanoid();
6
+ return prefix ? `${prefix}-${id}` : id;
7
+ }
8
+ __name(generateId, "generateId");
9
+ function slugify(description, maxLength = 30) {
10
+ return description.toLowerCase().trim().replace(/[^a-z0-9\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").slice(0, maxLength);
11
+ }
12
+ __name(slugify, "slugify");
13
+ function generateSnapshotId(description) {
14
+ if (description && description.length > 0) {
15
+ const slug = slugify(description);
16
+ if (slug.length > 0) {
17
+ return `snapshot-${slug}-${Date.now()}-${nanoid(9)}`;
18
+ }
19
+ }
20
+ return `snapshot-${Date.now()}-${nanoid(9)}`;
21
+ }
22
+ __name(generateSnapshotId, "generateSnapshotId");
23
+
24
+ export { generateId, generateSnapshotId };
25
+ //# sourceMappingURL=chunk-BCIXMIPW.js.map
26
+ //# sourceMappingURL=chunk-BCIXMIPW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../packages/contracts/dist/id-generator.js"],"names":["generateId","prefix","id","nanoid","slugify","description","maxLength","toLowerCase","trim","replace","slice","generateSnapshotId","length","slug","Date","now"],"mappings":";;;AAMO,SAASA,WAAWC,MAAAA,EAAM;AAC7B,EAAA,MAAMC,KAAKC,MAAAA,EAAAA;AACX,EAAA,OAAOF,MAAAA,GAAS,CAAA,EAAGA,MAAAA,CAAAA,CAAAA,EAAUC,EAAAA,CAAAA,CAAAA,GAAOA,EAAAA;AACxC;AAHgBF,MAAAA,CAAAA,UAAAA,EAAAA,YAAAA,CAAAA;AAQhB,SAASI,OAAAA,CAAQC,WAAAA,EAAaC,SAAAA,GAAY,EAAA,EAAE;AACxC,EAAA,OAAOD,WAAAA,CACFE,aAAW,CACXC,IAAAA,GACAC,OAAAA,CAAQ,eAAA,EAAiB,EAAA,CAAA,CACzBA,OAAAA,CAAQ,MAAA,EAAQ,GAAA,CAAA,CAChBA,OAAAA,CAAQ,KAAA,EAAO,GAAA,CAAA,CACfA,OAAAA,CAAQ,UAAU,EAAA,CAAA,CAClBC,KAAAA,CAAM,CAAA,EAAGJ,SAAAA,CAAAA;AAClB;AATSF,MAAAA,CAAAA,OAAAA,EAAAA,SAAAA,CAAAA;AAiBF,SAASO,mBAAmBN,WAAAA,EAAW;AAC1C,EAAA,IAAIA,WAAAA,IAAeA,WAAAA,CAAYO,MAAAA,GAAS,CAAA,EAAG;AACvC,IAAA,MAAMC,IAAAA,GAAOT,QAAQC,WAAAA,CAAAA;AACrB,IAAA,IAAIQ,IAAAA,CAAKD,SAAS,CAAA,EAAG;AACjB,MAAA,OAAO,CAAA,SAAA,EAAYC,IAAAA,CAAAA,CAAAA,EAAQC,IAAAA,CAAKC,KAAG,CAAA,CAAA,EAAMZ,MAAAA,CAAO,CAAA,CAAA,CAAA,CAAA;AACpD,IAAA;AACJ,EAAA;AACA,EAAA,OAAO,YAAYW,IAAAA,CAAKC,GAAAA,EAAG,CAAA,CAAA,EAAMZ,MAAAA,CAAO,CAAA,CAAA,CAAA,CAAA;AAC5C;AARgBQ,MAAAA,CAAAA,kBAAAA,EAAAA,oBAAAA,CAAAA","file":"chunk-BCIXMIPW.js","sourcesContent":["import { nanoid } from \"nanoid\";\n/**\n * Generate a unique ID with optional prefix\n * @param prefix Optional prefix for the ID (e.g., 'user', 'session')\n * @returns Unique ID string\n */\nexport function generateId(prefix) {\n const id = nanoid();\n return prefix ? `${prefix}-${id}` : id;\n}\n/**\n * Slugify a description for use in snapshot IDs\n * Converts \"Before fixing auth flow\" to \"before-fixing-auth-flow\"\n */\nfunction slugify(description, maxLength = 30) {\n return description\n .toLowerCase()\n .trim()\n .replace(/[^a-z0-9\\s-]/g, \"\") // Remove non-alphanumeric\n .replace(/\\s+/g, \"-\") // Spaces to hyphens\n .replace(/-+/g, \"-\") // Collapse hyphens\n .replace(/^-|-$/g, \"\") // Trim hyphens\n .slice(0, maxLength);\n}\n/**\n * Generate a snapshot ID in the standard format\n * Format with description: snapshot-<slug>-<timestamp>-<random>\n * Format without: snapshot-<timestamp>-<random>\n * @param description Optional human-readable description\n * @returns Snapshot ID string\n */\nexport function generateSnapshotId(description) {\n if (description && description.length > 0) {\n const slug = slugify(description);\n if (slug.length > 0) {\n return `snapshot-${slug}-${Date.now()}-${nanoid(9)}`;\n }\n }\n return `snapshot-${Date.now()}-${nanoid(9)}`;\n}\n"]}