wsb 0.83.223988

Workspace - A tool suite for file operations, version management, and development workflow automation
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
---
layout: default
title: Examples
---

# Real-World Examples

Learn how to use the Workspace tool suite through practical examples for common development workflows, combining refactoring, project cleanup, and version control.

## Development Workflows

### Project Refactoring with Version Tracking

**Scenario**: Major refactoring of a class while maintaining version history and safely managing temporary files.

```bash
# 1. Set up version tracking
wsb git install

# 2. Move unwanted files to local trash can
wsb scrap temp_files/ debug_logs/ old_tests/

# 3. Preview and apply refactoring
wsb refactor ./src "UserManager" "AccountManager" --verbose
wsb refactor ./src "UserManager" "AccountManager" --include "*.rs" --include "*.toml"

# 4. Commit changes (auto-bumps version)
git add .
git commit -m "Refactor: UserManager -> AccountManager"

# 5. Check new version
wsb git show
cat version.txt
```

### Safe Experimental Development

**Scenario**: Trying experimental changes with easy rollback.

```bash
# 1. Backup current implementation
wsb scrap src/experimental.rs src/core.rs

# 2. Note current version
wsb version show

# 3. Make experimental changes
wsb refactor ./src "old_algorithm" "new_algorithm" --content-only

# 4. If experiment fails, restore easily
wsb unscrap experimental.rs
wsb unscrap core.rs

# 5. If experiment succeeds, commit
git add . && git commit -m "Implement new algorithm"
```

### CI/CD Preparation Workflow

**Scenario**: Preparing a release with proper cleanup and versioning.

```bash
# 1. Archive old artifacts
wsb scrap find "*.tmp" "*.log" "target/debug/*"
wsb scrap archive pre-release-cleanup.tar.gz --remove

# 2. Update configuration for production
wsb refactor ./config "dev.api.com" "prod.api.com" --content-only
wsb refactor ./config "debug=true" "debug=false" --content-only

# 3. Ensure version tracking is set up
wsb git status || wsb git install

# 4. Create release commit
git add .
git commit -m "Prepare for production release"

# 5. Tag the release
wsb version tag
```

---

## Individual Tool Examples

### Scrap - Local Trash Folder

#### Project Cleanup Instead of Deletion

**Scenario**: Moving files to trash that you don't want but might need later.

```bash
# Move unwanted files to local trash can instead of deleting
wsb scrap *.tmp *.log build/ target/debug/

# List what you've scrapped
wsb scrap list --sort size

# Find specific items you remember scrapping
wsb scrap find "*.log"
wsb scrap find "test" --content

# Clean up old items (older than 7 days) permanently
wsb scrap clean --days 7
```

#### Safe Code Cleanup

**Scenario**: Removing old implementations and experimental code safely.

```bash
# Scrap old code instead of deleting (in case you need it)
wsb scrap old_implementation/ legacy_tests/

# Archive before permanent removal
wsb scrap archive "old-code-$(date +%Y%m%d).tar.gz"

# Scrap experimental features that didn't work out
wsb scrap experimental_feature/ prototype/
wsb scrap archive --output experiments-archive.tar.gz --remove
```

### Unscrap - File Restoration

#### Undo Recent Changes

**Scenario**: Need to restore files after a mistake.

```bash
# Restore the last scrapped item
wsb unscrap

# Check what's available to restore
wsb scrap list

# Restore specific file to original location
wsb unscrap important_config.json

# Restore to a different location
wsb unscrap data.sql --to backup/
```

#### Selective File Recovery

**Scenario**: Restore only specific files from a cleanup.

```bash
# After cleaning workspace, need one file back
wsb scrap temp_files/ logs/ build/
# ... realize you need a log file
wsb unscrap server.log

# Restore to custom location without overwriting
wsb unscrap config.json --to ./backup/ --force
```

### Version Management

#### Project Setup and Release Management

**Scenario**: Setting up automatic versioning for a new project.

```bash
# Initialize project with versioning
git init
echo "Initial code" > main.rs
git add .
git commit -m "Initial commit"

# Install hook and set major version
wsb git install
wsb version major 1

# Normal development with automatic versioning
echo "new feature" >> main.rs
git add .
git commit -m "Add feature"  # Version auto-incremented

# Check version progression
wsb version show
cat version.txt
```

#### CI/CD Integration

**Scenario**: Using versions in build scripts.

```bash
VERSION=$(cat version.txt)
echo "Building version: $VERSION"

docker build -t myapp:$VERSION .
cargo build --release
cp target/release/myapp "releases/myapp-$VERSION"
```

### Refactor - String Replacement

#### Rename Variables Throughout Project

**Scenario**: You need to rename a variable across your entire codebase.

```bash
# Preview the changes first
wsb refactor ./src "oldVariableName" "newVariableName" --verbose

# Apply the changes
wsb refactor ./src "oldVariableName" "newVariableName"
```

### Update API Endpoints

**Scenario**: Your API URL changed and you need to update all references.

```bash
# Update only file contents, don't rename files
wsb refactor . "api.old-service.com" "api.new-service.com" --content-only

# Include only relevant file types
wsb refactor . "api.old-service.com" "api.new-service.com" \
  --content-only \
  --include "*.js" \
  --include "*.py" \
  --include "*.json"
```

## File and Directory Organization

### Rename Project Files

**Scenario**: You're renaming your project from "MyApp" to "AwesomeApp".

```bash
wsb refactor . "MyApp" "AwesomeApp" --verbose

wsb refactor . "MyApp" "AwesomeApp" \
  --exclude "node_modules/*" \
  --exclude ".git/*" \
  --exclude "target/*"
```

### Reorganize File Naming Convention

**Scenario**: Change file naming from `camelCase` to `snake_case`.

```bash
wsb refactor ./src "camelCase" "snake_case" --names-only
wsb refactor ./src "([a-z])([A-Z])" "\$1_\$2" --names-only --regex
```

## Language-Specific Refactoring

### Rust Project Refactoring

```bash
wsb refactor ./src "OldStruct" "NewStruct" \
  --include "*.rs" \
  --include "*.toml"

wsb refactor ./src "OldStruct" "NewStruct" \
  --include "*.rs" \
  --backup
```

### JavaScript/TypeScript Project

```bash
wsb refactor ./src "oldFunction" "newFunction" \
  --include "*.js" \
  --include "*.ts" \
  --include "*.jsx" \
  --include "*.tsx"

wsb refactor ./src "oldFunction" "newFunction" \
  --include "*.js" \
  --include "*.ts" \
  --exclude "*test*" \
  --exclude "*spec*"
```

### Python Project

```bash
wsb refactor ./project "OldClass" "NewClass" \
  --include "*.py" \
  --exclude "__pycache__/*"

wsb refactor ./project "old-package" "new-package" \
  --include "*.py" \
  --include "requirements*.txt" \
  --include "setup.py"
```

## Configuration and Deployment

### Update Environment Variables

```bash
wsb refactor ./config "OLD_ENV_VAR" "NEW_ENV_VAR" \
  --include "*.env" \
  --include "*.yml" \
  --include "*.yaml" \
  --include "*.json"

wsb refactor ./config "staging.server.com" "production.server.com" \
  --content-only \
  --include "*.env" \
  --include "*.config"
```

### Docker and Deployment Scripts

```bash
wsb refactor ./deployment "old-service" "new-service" \
  --include "*.yml" \
  --include "*.yaml" \
  --include "Dockerfile*" \
  --include "*.sh"
```

## Database and Schema Changes

### Update Table Names

```bash
wsb refactor ./sql "old_table" "new_table" \
  --include "*.sql" \
  --include "*.migration"

wsb refactor ./src "old_table" "new_table" \
  --include "*.py" \
  --include "*.js" \
  --include "*.rb"
```

## Patterns

### Using Regular Expressions

```bash
wsb refactor ./docs "v1\\.\\d+\\.\\d+" "v2.0.0" \
  --regex \
  --include "*.md" \
  --include "*.txt"

wsb refactor ./src "oldfunction" "newFunction" \
  --regex \
  --ignore-case \
  --include "*.js"
```

### Batch Operations with Scripts

```bash
#!/bin/bash
REPLACEMENTS=(
  "OldClass1:NewClass1"
  "OldClass2:NewClass2"
  "old_function:new_function"
)

for replacement in "${REPLACEMENTS[@]}"; do
  IFS=':' read -r old new <<< "$replacement"
  wsb refactor ./src "$old" "$new" --include "*.rs" --force
done
```

## Safety and Testing

### Safe Refactoring Workflow

```bash
#!/bin/bash
OLD_NAME="$1"
NEW_NAME="$2"
PROJECT_DIR="$3"

# Preview changes
wsb refactor "$PROJECT_DIR" "$OLD_NAME" "$NEW_NAME" --verbose --verbose

read -p "Continue? (y/N): " confirm
[ "$confirm" != "y" ] && exit 0

# Apply with backup
wsb refactor "$PROJECT_DIR" "$OLD_NAME" "$NEW_NAME" --backup

# Run tests
cargo test || npm test || python -m pytest
```

## Tool Suite Workflows

### Full-Stack Application Refactoring

```bash
#!/bin/bash
OLD_NAME="$1"
NEW_NAME="$2"

# 1. Clean workspace
wsb scrap target/ build/ *.log *.tmp

# 2. Preview and apply
wsb refactor . "$OLD_NAME" "$NEW_NAME" --verbose
wsb refactor . "$OLD_NAME" "$NEW_NAME" --backup

# 3. Commit (triggers version bump)
git add .
git commit -m "Refactor: $OLD_NAME -> $NEW_NAME"

# 4. Show results
cat version.txt
```

### Release Pipeline Integration

```bash
#!/bin/bash
# 1. Clean build artifacts
wsb scrap target/ build/ *.log
wsb scrap purge --force

# 2. Update configurations
wsb refactor ./config "development" "production" --content-only
wsb refactor ./config "debug=true" "debug=false" --content-only

# 3. Create release
git add .
git commit -m "Prepare production release"
wsb version tag
echo "Release $(cat version.txt) prepared"
```