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
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
---
layout: default
title: Command Reference
---

# Command Reference

Complete reference for all `wsb` command-line options and usage patterns.

## Commands Overview

All tools are subcommands of the `wsb` binary:

```bash
wsb <COMMAND> [OPTIONS]
```

| Command | Description |
|---------|-------------|
| `refactor` | Recursive string replacement in files and directories |
| `git` | Git integration and version management |
| `template` | Tera template management |
| `update` | Update version and render templates |
| `wsbtemplate` | Cross-project `.wstemplate` version stamping |
| `version` | Database-driven version management |
| `scrap` | Local trash can using `.scrap` folder |
| `unscrap` | Restore files from `.scrap` folder |
| `ldiff` | Line difference visualization |
| `code` | AST-based code analysis and transformation |
| `test` | Intelligent test runner based on project type |
| `status` | Project status with feature metrics |
| `feature` | Feature management with state machine workflow |
| `task` | Feature-centric task management |
| `directive` | Project directive and rule management |
| `note` | Note management for any entity |
| `relationship` | Entity relationship management |
| `start` | Start development session |
| `end` | End development session |
| `continuity` | Session continuity and context management |
| `consolidate` | Documentation consolidation |
| `database` | Database backup, recovery, maintenance |
| `mcp-server` | MCP server for Claude AI integration |
| `sample` | Create sample project with test data |

---

## wsb refactor

Recursive string replacement in file names and contents with collision detection.

### Synopsis
```bash
wsb refactor <ROOT_DIR> <OLD_STRING> <NEW_STRING> [OPTIONS]
```

### Required Arguments

| Argument | Description |
|----------|-------------|
| `ROOT_DIR` | Root directory to search in (use `.` for current directory) |
| `OLD_STRING` | String to find and replace |
| `NEW_STRING` | Replacement string |

### Options

| Option | Short | Description | Default |
|--------|-------|-------------|---------|
| `--assume-yes` | `-y` | Skip confirmation prompts | `false` |
| `--force` | `-f` | Skip confirmation prompt | `false` |
| `--verbose` | `-v` | Show detailed output | `false` |
| `--backup` | `-b` | Create backup files before modifying | `false` |
| `--follow-symlinks` | | Follow symbolic links | `false` |
| `--files-only` | | Only process files (skip directories) | `false` |
| `--dirs-only` | | Only process directories (skip files) | `false` |
| `--names-only` | | Skip content replacement, only rename | `false` |
| `--content-only` | | Skip renaming, only replace content | `false` |
| `--include <PATTERN>` | | Include only files matching glob (repeatable) | all |
| `--exclude <PATTERN>` | | Exclude files matching glob (repeatable) | none |
| `--max-depth <N>` | | Maximum depth to search (0 = unlimited) | `0` |
| `--threads <N>` | `-j` | Number of threads (0 = auto) | `0` |
| `--ignore-case` | `-i` | Case-insensitive matching | `false` |
| `--regex` | `-r` | Use regex patterns | `false` |
| `--format <FORMAT>` | | Output format: `human`, `json`, `plain` | `human` |
| `--progress <MODE>` | | Progress display: `auto`, `always`, `never` | `auto` |

Only one mode flag (`--files-only`, `--dirs-only`, `--names-only`, `--content-only`) can be specified at a time.

### Examples
```bash
wsb refactor . "oldname" "newname"                          # Full replacement
wsb refactor . "oldname" "newname" --verbose                # Preview first
wsb refactor . "oldname" "newname" --include "*.rs" --backup
wsb refactor . "old.api.com" "new.api.com" --content-only
wsb refactor . "OldClass" "NewClass" --names-only
wsb refactor . "old_\\w+" "new_name" --regex
wsb refactor . "oldname" "newname" --format json            # Machine-readable output
```

### Exit Codes

| Code | Meaning |
|------|---------|
| `0` | Success |
| `1` | General error |
| `2` | Invalid arguments |
| `3` | Permission denied |
| `4` | File not found |
| `5` | Naming collision detected |

---

## wsb git

Git integration and version management via pre-commit hooks.

### Subcommands

| Subcommand | Description | Options |
|------------|-------------|---------|
| `install` | Install pre-commit hook | `--force` |
| `uninstall` | Remove hook | |
| `show` | Display version information | |
| `status` | Show configuration status | |

### Examples
```bash
wsb git install              # Install git hook
wsb git install --force      # Force reinstall
wsb git show                 # Show version info
wsb git status               # Check configuration
wsb git uninstall            # Remove hook
```

---

## wsb template

Tera template management for automatic file generation during `wsb update`.

### Subcommands

| Subcommand | Description |
|------------|-------------|
| `add` | Add a new template |
| `list` | List all templates |
| `show` | Show template details |
| `update` | Update an existing template |
| `delete` | Remove a template |
| `render` | Render all enabled templates |

### Examples
```bash
wsb template add version-header --template "v{{ project.version }}" --output version.h
wsb template list
wsb template show version-header
wsb template render
wsb template delete version-header
```

---

## wsb update

Update version file and render all templates (both `.tera` and `.wstemplate`).

### Synopsis
```bash
wsb update [OPTIONS]
```

### Options

| Option | Description | Default |
|--------|-------------|---------|
| `--no-git` | Skip git integration | `false` |
| `--git-add` | Auto-add updated files to git staging | `false` |

### What It Does

1. Calculates the current version from git history
2. Writes `version.txt`
3. Updates project files (Cargo.toml, package.json, etc.) with the new version
4. Renders `.tera` templates via the template manager
5. Renders `.wstemplate` files via the wstemplate engine
6. With `--git-add`: stages `version.txt`, rendered `.tera` outputs, and rendered `.wstemplate` outputs

### Examples
```bash
wsb update                   # Basic update
wsb update --git-add         # Update and stage files
wsb update --no-git          # Update without git integration
```

---

## wsb wstemplate

Manage `.wstemplate` file rendering for cross-project version stamping.

Each project has a single wstemplate entry consisting of an **alias** (Tera identifier)
and a **scan root** (directory tree to search). Cross-project references like
`{{ projects.OTHER.version }}` are resolved dynamically by scanning the root for
sibling `.wsb/state.json` files.

### Subcommands

| Subcommand | Description |
|------------|-------------|
| `add <PATH>` | Set the scan root (replaces any existing entry) |
| `remove <ALIAS>` | Remove this project's wstemplate entry |
| `list-entries` | Show this project's wstemplate entry |
| `list` | List all `.wstemplate` files relevant to this project |
| `render` | Render all relevant `.wstemplate` files |

### Options for `add`

| Option | Description |
|--------|-------------|
| `--alias <ALIAS>` | Override auto-derived alias (must be valid Tera identifier) |

### Template Variables

| Variable | Description |
|----------|-------------|
| `{{ project.version }}` | Owning project's full version (e.g., `0.5.12`) |
| `{{ project.major_version }}` | e.g., `v0` |
| `{{ project.minor_version }}` | Commit count |
| `{{ project.patch_version }}` | Line changes |
| `{{ project.name }}` | From manifest or directory name |
| `{{ projects.ALIAS.version }}` | Any discoverable project's version |
| `{{ projects.ALIAS.major_version }}` | Any project's major version |
| `{{ projects.ALIAS.minor_version }}` | Any project's minor version |
| `{{ projects.ALIAS.patch_version }}` | Any project's patch version |
| `{{ projects.ALIAS.name }}` | Any project's name |
| `{{ datetime.iso }}` | RFC 3339 timestamp |
| `{{ datetime.date }}` | YYYY-MM-DD |
| `{{ datetime.time }}` | HH:MM:SS |
| `{{ datetime.year }}` | Year |
| `{{ datetime.month }}` | Month |
| `{{ datetime.day }}` | Day |

### Template Selection

When rendering, only templates satisfying at least one condition are rendered:
1. The template lives under the current project's root (own templates)
2. The template's text contains a reference to `{{ projects.SELF_ALIAS.* }}`

### Error Handling

- **Unresolvable alias**: Hard error listing all known aliases
- **Missing `version.txt`**: Hard error with instructions to run `wsb update` in the dependency
- **Multiple wstemplate entries in state.json**: Hard error (single-entry model enforced)

### Examples
```bash
wsb wstemplate add /path/to/workspace              # Set scan root
wsb wstemplate add /path/to/workspace --alias mylib # Custom alias
wsb wstemplate list-entries                         # Show current entry
wsb wstemplate list                                 # Show relevant templates
wsb wstemplate render                               # Render templates
wsb wstemplate remove mylib                         # Remove entry
```

---

## wsb version

Version management with database-driven major version and git-calculated components.

### Version Format

`{major}.{minor}.{patch}` where:
- **Major**: Set via `wsb version major` (stored in database)
- **Minor**: Total commits in the repository
- **Patch**: Total line changes (additions + deletions)

### Subcommands

| Subcommand | Description | Options |
|------------|-------------|---------|
| `show` | Display version breakdown | `--verbose`, `--format` |
| `major <N>` | Set major version number | |
| `tag` | Create git tag with current version | `--prefix`, `--message` |
| `info` | Show calculation details | `--include-history` |

### Examples
```bash
wsb version show                          # Display version
wsb version show --verbose --format json  # Detailed JSON output
wsb version major 2                       # Set major to 2
wsb version tag                           # Create git tag
wsb version tag --prefix "release-"       # Custom tag prefix
wsb version info --include-history        # Show git history analysis
```

---

## wsb scrap

Local trash can using a `.scrap` folder for files you want to remove safely.

### Synopsis
```bash
wsb scrap [PATH...] [SUBCOMMAND] [OPTIONS]
```

### Subcommands

| Subcommand | Description | Options |
|------------|-------------|---------|
| `list` | List `.scrap` contents | `--sort name\|date\|size` |
| `clean` | Remove old items | `--days N` |
| `purge` | Remove all items | `--force` |
| `find` | Search for patterns | `--content` |
| `archive` | Create archive | `--output FILE`, `--remove` |

### Examples
```bash
wsb scrap temp.txt logs/                    # Move to .scrap
wsb scrap list --sort size                  # List contents
wsb scrap find "*.log"                      # Find files
wsb scrap clean --days 30                   # Remove old items
wsb scrap archive backup.tar.gz --remove    # Archive and remove
wsb scrap purge --force                     # Empty completely
```

---

## wsb unscrap

Restore files from `.scrap` folder to their original locations.

### Synopsis
```bash
wsb unscrap [NAME] [OPTIONS]
```

### Options

| Option | Description |
|--------|-------------|
| `--to PATH` | Custom restoration path |
| `--force` | Overwrite existing files |

### Examples
```bash
wsb unscrap                           # Restore last item
wsb unscrap important_file.txt        # Restore specific file
wsb unscrap config.json --to backup/  # Restore to directory
wsb unscrap data.txt --force          # Overwrite existing
```

---

## wsb ldiff

Process input lines, replacing repeated tokens with a substitute character to highlight differences.

### Synopsis
```bash
wsb ldiff [SUBSTITUTE_CHAR]
```

Default substitute character: `░`

### Examples
```bash
echo -e "hello world\nhello universe" | wsb ldiff
tail -f /var/log/syslog | wsb ldiff
cat access.log | wsb ldiff "*"
```

---

## wsb status

Display project status with feature metrics and progress tracking.

### Options

| Option | Description | Default |
|--------|-------------|---------|
| `--debug-mode` | Enable diagnostic output | `false` |
| `--include-features` | Include feature breakdown | `false` |
| `--include-metrics` | Include detailed metrics | `false` |
| `--format` | Output format: `human`, `json`, `summary` | `human` |

### Examples
```bash
wsb status
wsb status --include-features
wsb status --include-metrics --format json
```

---

## wsb feature

Feature management with state machine workflow and validation.

### Subcommands

| Subcommand | Description |
|------------|-------------|
| `add` | Add a new feature |
| `list` | List features with filters |
| `show` | Show feature details |
| `update` | Update feature status/properties |

### Examples
```bash
wsb feature add "User authentication"
wsb feature list --state implemented
wsb feature show F00001
```

---

## wsb task

Feature-centric task management with automatic feature detection.

### Subcommands

| Subcommand | Description |
|------------|-------------|
| `add` | Add a new task |
| `list` | List tasks with filters |
| `show` | Show task details |
| `update` | Update task status/properties |
| `complete` | Mark task as completed |
| `start` | Start working on a task |
| `block` | Mark task as blocked |
| `unblock` | Remove blocked status |

### Examples
```bash
wsb task add "Implement login" "Build the login page" --feature F00001
wsb task list --status pending
wsb task show T000001
wsb task start T000001
wsb task complete T000001 --evidence "Tests passing"
```

---

## wsb directive

Project directive and rule management.

### Subcommands

| Subcommand | Description |
|------------|-------------|
| `add` | Add a new directive |
| `list` | List directives |
| `show` | Show directive details |
| `update` | Update directive |
| `activate` | Activate a directive |
| `deactivate` | Deactivate a directive |
| `check` | Check directive compliance |

---

## wsb code

AST-based code analysis and codebase exploration.

### Subcommands

| Subcommand | Description |
|------------|-------------|
| `tree` | Visual tree of codebase structure (default) |
| `search` | Search for AST patterns in source code |

### Options for `tree`

| Option | Description | Default |
|--------|-------------|---------|
| `--depth N` | Maximum depth to display | `3` |
| `--hidden` | Show hidden files and directories | `false` |
| `--sizes` | Show file sizes | `false` |
| `--extensions` | Filter by file extensions (e.g., `rs,py,js`) | all |
| `--no-ignore` | Ignore .gitignore rules | `false` |

### Examples
```bash
wsb code                                # Show tree (default)
wsb code tree --depth 5 --sizes         # Deep tree with file sizes
wsb code tree --extensions rs,toml      # Only Rust files
wsb code search "fn main" --language rust
```

---

## wsb test

Intelligent test runner that detects project type and runs appropriate tests.

### Options

| Option | Description | Default |
|--------|-------------|---------|
| `--dry-run` | Show test command without executing | `false` |
| `--install` | Install missing test runners | `false` |

### Examples
```bash
wsb test                     # Run tests for detected project type
wsb test --dry-run           # Show what would run
wsb test -- --nocapture      # Pass args to test runner
```

---

## wsb start / wsb end

Session management for development workflow.

### wsb start
```bash
wsb start                                # Start new session
wsb start --continue-from T000001        # Continue from task
wsb start --project-setup                # Initialize new project
wsb start "Implement auth"               # Start with first task description
```

### wsb end
```bash
wsb end                                  # End session
wsb end --summary "Completed auth"       # End with summary
wsb end --skip-docs                      # Skip documentation updates
```

---

## wsb mcp-server

MCP server for Claude AI integration with automatic session management.

### Options

| Option | Description | Default |
|--------|-------------|---------|
| `--port` | HTTP server port | `3000` |
| `--debug` | Enable debug logging | `false` |
| `--migrate` | Migrate features from features.md to database | `false` |

### Examples
```bash
wsb mcp-server                    # Start on localhost:3000
wsb mcp-server --port 8080        # Custom port
wsb mcp-server --debug            # With debug logging
```

---

## wsb database

Database backup, recovery, and maintenance operations.

---

## wsb continuity

Session continuity and context management.

### Subcommands

| Subcommand | Description |
|------------|-------------|
| `list` | List continuity records |
| `snapshot` | Create context snapshot |

---

## wsb consolidate

Documentation consolidation with diagram management.

### Options

| Option | Description |
|--------|-------------|
| `--generate-diagrams` | Generate architectural diagrams in DOT format |
| `--preserve-complexity` | Preserve complexity information |
| `--force` | Force consolidation |

---

## Getting Help

```bash
wsb --help              # Show all commands
wsb <COMMAND> --help    # Help for specific command
```