@tokenbooks/wt 0.2.1 → 0.3.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 +59 -28
- package/dist/cli.js +16 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/new.js +30 -5
- package/dist/commands/new.js.map +1 -1
- package/dist/commands/prune.d.ts +8 -0
- package/dist/commands/prune.js +210 -0
- package/dist/commands/prune.js.map +1 -0
- package/dist/commands/prune.spec.d.ts +1 -0
- package/dist/commands/prune.spec.js +173 -0
- package/dist/commands/prune.spec.js.map +1 -0
- package/dist/commands/remove.d.ts +1 -0
- package/dist/commands/remove.js +39 -1
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/setup.js +144 -7
- package/dist/commands/setup.js.map +1 -1
- package/dist/core/env-patcher.js +8 -8
- package/dist/core/env-patcher.js.map +1 -1
- package/dist/core/git.d.ts +15 -0
- package/dist/core/git.js +59 -0
- package/dist/core/git.js.map +1 -1
- package/dist/core/managed-redis.d.ts +19 -0
- package/dist/core/managed-redis.js +266 -0
- package/dist/core/managed-redis.js.map +1 -0
- package/dist/core/slot-allocator.d.ts +10 -0
- package/dist/core/slot-allocator.js +98 -0
- package/dist/core/slot-allocator.js.map +1 -1
- package/dist/output.js +14 -3
- package/dist/output.js.map +1 -1
- package/dist/schemas/config.schema.d.ts +45 -27
- package/dist/schemas/config.schema.js +22 -6
- package/dist/schemas/config.schema.js.map +1 -1
- package/dist/schemas/registry.schema.d.ts +4 -2
- package/dist/schemas/registry.schema.js +2 -1
- package/dist/schemas/registry.schema.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +2 -1
- package/skills/wt/SKILL.md +31 -12
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
/** Schema for a single env var patch rule */
|
|
3
|
-
export declare const patchSchema: z.ZodObject<{
|
|
3
|
+
export declare const patchSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4
4
|
var: z.ZodString;
|
|
5
|
-
type: z.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
type: z.ZodLiteral<"database">;
|
|
6
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
7
|
+
var: z.ZodString;
|
|
8
|
+
type: z.ZodLiteral<"redis">;
|
|
9
|
+
service: z.ZodString;
|
|
10
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
11
|
+
var: z.ZodString;
|
|
12
|
+
type: z.ZodLiteral<"port">;
|
|
13
|
+
service: z.ZodString;
|
|
14
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
15
|
+
var: z.ZodString;
|
|
16
|
+
type: z.ZodLiteral<"url">;
|
|
17
|
+
service: z.ZodString;
|
|
18
|
+
}, z.core.$strip>], "type">;
|
|
13
19
|
/** Schema for a service with a default port */
|
|
14
20
|
export declare const serviceSchema: z.ZodObject<{
|
|
15
21
|
name: z.ZodString;
|
|
@@ -18,16 +24,22 @@ export declare const serviceSchema: z.ZodObject<{
|
|
|
18
24
|
/** Schema for an env file to copy and patch */
|
|
19
25
|
export declare const envFileSchema: z.ZodObject<{
|
|
20
26
|
source: z.ZodString;
|
|
21
|
-
patches: z.ZodArray<z.ZodObject<{
|
|
27
|
+
patches: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
22
28
|
var: z.ZodString;
|
|
23
|
-
type: z.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
type: z.ZodLiteral<"database">;
|
|
30
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
31
|
+
var: z.ZodString;
|
|
32
|
+
type: z.ZodLiteral<"redis">;
|
|
33
|
+
service: z.ZodString;
|
|
34
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
35
|
+
var: z.ZodString;
|
|
36
|
+
type: z.ZodLiteral<"port">;
|
|
37
|
+
service: z.ZodString;
|
|
38
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
39
|
+
var: z.ZodString;
|
|
40
|
+
type: z.ZodLiteral<"url">;
|
|
41
|
+
service: z.ZodString;
|
|
42
|
+
}, z.core.$strip>], "type">>;
|
|
31
43
|
}, z.core.$strip>;
|
|
32
44
|
/** Schema for wt.config.json */
|
|
33
45
|
export declare const configSchema: z.ZodObject<{
|
|
@@ -41,16 +53,22 @@ export declare const configSchema: z.ZodObject<{
|
|
|
41
53
|
}, z.core.$strip>>;
|
|
42
54
|
envFiles: z.ZodArray<z.ZodObject<{
|
|
43
55
|
source: z.ZodString;
|
|
44
|
-
patches: z.ZodArray<z.ZodObject<{
|
|
56
|
+
patches: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
57
|
+
var: z.ZodString;
|
|
58
|
+
type: z.ZodLiteral<"database">;
|
|
59
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
60
|
+
var: z.ZodString;
|
|
61
|
+
type: z.ZodLiteral<"redis">;
|
|
62
|
+
service: z.ZodString;
|
|
63
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
64
|
+
var: z.ZodString;
|
|
65
|
+
type: z.ZodLiteral<"port">;
|
|
66
|
+
service: z.ZodString;
|
|
67
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
45
68
|
var: z.ZodString;
|
|
46
|
-
type: z.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
port: "port";
|
|
50
|
-
url: "url";
|
|
51
|
-
}>;
|
|
52
|
-
service: z.ZodOptional<z.ZodString>;
|
|
53
|
-
}, z.core.$strip>>;
|
|
69
|
+
type: z.ZodLiteral<"url">;
|
|
70
|
+
service: z.ZodString;
|
|
71
|
+
}, z.core.$strip>], "type">>;
|
|
54
72
|
}, z.core.$strip>>;
|
|
55
73
|
postSetup: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
56
74
|
autoInstall: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -4,11 +4,27 @@ exports.configSchema = exports.envFileSchema = exports.serviceSchema = exports.p
|
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const PATCH_TYPES = ['database', 'redis', 'port', 'url'];
|
|
6
6
|
/** Schema for a single env var patch rule */
|
|
7
|
-
exports.patchSchema = zod_1.z.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
})
|
|
7
|
+
exports.patchSchema = zod_1.z.discriminatedUnion('type', [
|
|
8
|
+
zod_1.z.object({
|
|
9
|
+
var: zod_1.z.string().min(1),
|
|
10
|
+
type: zod_1.z.literal(PATCH_TYPES[0]),
|
|
11
|
+
}),
|
|
12
|
+
zod_1.z.object({
|
|
13
|
+
var: zod_1.z.string().min(1),
|
|
14
|
+
type: zod_1.z.literal(PATCH_TYPES[1]),
|
|
15
|
+
service: zod_1.z.string().min(1),
|
|
16
|
+
}),
|
|
17
|
+
zod_1.z.object({
|
|
18
|
+
var: zod_1.z.string().min(1),
|
|
19
|
+
type: zod_1.z.literal(PATCH_TYPES[2]),
|
|
20
|
+
service: zod_1.z.string().min(1),
|
|
21
|
+
}),
|
|
22
|
+
zod_1.z.object({
|
|
23
|
+
var: zod_1.z.string().min(1),
|
|
24
|
+
type: zod_1.z.literal(PATCH_TYPES[3]),
|
|
25
|
+
service: zod_1.z.string().min(1),
|
|
26
|
+
}),
|
|
27
|
+
]);
|
|
12
28
|
/** Schema for a service with a default port */
|
|
13
29
|
exports.serviceSchema = zod_1.z.object({
|
|
14
30
|
name: zod_1.z.string().min(1),
|
|
@@ -24,7 +40,7 @@ exports.configSchema = zod_1.z.object({
|
|
|
24
40
|
baseDatabaseName: zod_1.z.string().min(1),
|
|
25
41
|
baseWorktreePath: zod_1.z.string().min(1).default('.worktrees'),
|
|
26
42
|
portStride: zod_1.z.number().int().positive().default(100),
|
|
27
|
-
maxSlots: zod_1.z.number().int().min(1).
|
|
43
|
+
maxSlots: zod_1.z.number().int().min(1).default(50),
|
|
28
44
|
services: zod_1.z.array(exports.serviceSchema).min(1),
|
|
29
45
|
envFiles: zod_1.z.array(exports.envFileSchema),
|
|
30
46
|
postSetup: zod_1.z.array(zod_1.z.string()).default([]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.schema.js","sourceRoot":"","sources":["../../src/schemas/config.schema.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,MAAM,WAAW,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAU,CAAC;AAElE,6CAA6C;AAChC,QAAA,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"config.schema.js","sourceRoot":"","sources":["../../src/schemas/config.schema.ts"],"names":[],"mappings":"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"}
|
|
@@ -4,7 +4,8 @@ export declare const allocationSchema: z.ZodObject<{
|
|
|
4
4
|
worktreePath: z.ZodString;
|
|
5
5
|
branchName: z.ZodString;
|
|
6
6
|
dbName: z.ZodString;
|
|
7
|
-
redisDb: z.ZodNumber
|
|
7
|
+
redisDb: z.ZodOptional<z.ZodNumber>;
|
|
8
|
+
redisContainerName: z.ZodOptional<z.ZodString>;
|
|
8
9
|
ports: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
9
10
|
createdAt: z.ZodString;
|
|
10
11
|
}, z.core.$strip>;
|
|
@@ -15,7 +16,8 @@ export declare const registrySchema: z.ZodObject<{
|
|
|
15
16
|
worktreePath: z.ZodString;
|
|
16
17
|
branchName: z.ZodString;
|
|
17
18
|
dbName: z.ZodString;
|
|
18
|
-
redisDb: z.ZodNumber
|
|
19
|
+
redisDb: z.ZodOptional<z.ZodNumber>;
|
|
20
|
+
redisContainerName: z.ZodOptional<z.ZodString>;
|
|
19
21
|
ports: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
20
22
|
createdAt: z.ZodString;
|
|
21
23
|
}, z.core.$strip>>;
|
|
@@ -7,7 +7,8 @@ exports.allocationSchema = zod_1.z.object({
|
|
|
7
7
|
worktreePath: zod_1.z.string().min(1),
|
|
8
8
|
branchName: zod_1.z.string().min(1),
|
|
9
9
|
dbName: zod_1.z.string().min(1),
|
|
10
|
-
redisDb: zod_1.z.number().int().min(
|
|
10
|
+
redisDb: zod_1.z.number().int().min(0).optional(),
|
|
11
|
+
redisContainerName: zod_1.z.string().min(1).optional(),
|
|
11
12
|
ports: zod_1.z.record(zod_1.z.string(), zod_1.z.number().int().positive()),
|
|
12
13
|
createdAt: zod_1.z.string().datetime(),
|
|
13
14
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.schema.js","sourceRoot":"","sources":["../../src/schemas/registry.schema.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,8CAA8C;AACjC,QAAA,gBAAgB,GAAG,OAAC,CAAC,MAAM,CAAC;IACvC,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACzB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.schema.js","sourceRoot":"","sources":["../../src/schemas/registry.schema.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,8CAA8C;AACjC,QAAA,gBAAgB,GAAG,OAAC,CAAC,MAAM,CAAC;IACvC,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACzB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC3C,kBAAkB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAChD,KAAK,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;IACxD,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACjC,CAAC,CAAC;AAEH,yCAAyC;AAC5B,QAAA,cAAc,GAAG,OAAC,CAAC,MAAM,CAAC;IACrC,OAAO,EAAE,OAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACrB,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,wBAAgB,CAAC;CACpD,CAAC,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type Allocation = z.infer<typeof allocationSchema>;
|
|
|
12
12
|
/** Context passed to env patcher with computed values for a slot */
|
|
13
13
|
export interface PatchContext {
|
|
14
14
|
readonly dbName: string;
|
|
15
|
-
readonly
|
|
15
|
+
readonly redisPort?: number;
|
|
16
16
|
readonly ports: Record<string, number>;
|
|
17
17
|
}
|
|
18
18
|
/** Result of CLI operations for --json output */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenbooks/wt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Git worktree environment isolation CLI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"build": "tsc && node scripts/link-cli.js",
|
|
40
40
|
"dev": "tsc --watch",
|
|
41
41
|
"test": "jest",
|
|
42
|
+
"test:docker": "node scripts/test-docker.js",
|
|
42
43
|
"lint": "eslint 'src/**/*.ts' '__tests__/**/*.ts'",
|
|
43
44
|
"release": "node scripts/release.js",
|
|
44
45
|
"release:patch": "node scripts/release.js patch",
|
package/skills/wt/SKILL.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: wt
|
|
3
|
-
description: Manage git worktree isolation — create, list, remove worktrees with isolated databases, Redis, and ports
|
|
4
|
-
argument-hint: "[new|open|list|remove|doctor|setup|init] [args...]"
|
|
3
|
+
description: Manage git worktree isolation — create, list, remove, and prune worktrees with isolated databases, managed Redis, and ports
|
|
4
|
+
argument-hint: "[new|open|list|remove|prune|doctor|setup|init] [args...]"
|
|
5
5
|
allowed-tools: Bash, Read, Write, Edit, Grep, Glob
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# wt — Git Worktree Isolation
|
|
9
9
|
|
|
10
|
-
You are managing git worktrees with isolated Postgres databases, Redis
|
|
10
|
+
You are managing git worktrees with isolated Postgres databases, managed Redis Docker containers, and ports using the `wt` CLI.
|
|
11
11
|
|
|
12
12
|
## Routing
|
|
13
13
|
|
|
@@ -22,7 +22,7 @@ The user wants to set up `wt` in their project for the first time. Follow these
|
|
|
22
22
|
Search the repository to find:
|
|
23
23
|
- All `.env` files (not `.env.example`): `find . -name '.env' -not -path '*/node_modules/*' -not -path '*/.git/*'`
|
|
24
24
|
- The `DATABASE_URL` value to extract the base database name (path segment after the port, before `?`)
|
|
25
|
-
- Any `REDIS_URL` values and their
|
|
25
|
+
- Any `REDIS_URL` values and their base port/auth format
|
|
26
26
|
- All services and their default ports — check `package.json` scripts, `docker-compose.yml`, framework config files
|
|
27
27
|
- The package manager in use (`pnpm`, `npm`, `yarn`) — check for lockfiles
|
|
28
28
|
|
|
@@ -33,7 +33,7 @@ For each `.env` file, examine every variable and classify:
|
|
|
33
33
|
| Variable contains | Patch type | Needs `service`? |
|
|
34
34
|
|---|---|---|
|
|
35
35
|
| Postgres connection URL (`postgresql://...`) | `database` | No |
|
|
36
|
-
| Redis connection URL (`redis://...`) | `redis` |
|
|
36
|
+
| Redis connection URL (`redis://...`) | `redis` | Yes (`redis`) |
|
|
37
37
|
| Just a port number | `port` | Yes |
|
|
38
38
|
| A URL containing a service port (`http://localhost:3000/...`) | `url` | Yes |
|
|
39
39
|
| Anything else (API keys, secrets, flags) | Skip — do not patch | — |
|
|
@@ -47,9 +47,10 @@ Build the config file at the repository root:
|
|
|
47
47
|
"baseDatabaseName": "<extracted from DATABASE_URL>",
|
|
48
48
|
"baseWorktreePath": ".worktrees",
|
|
49
49
|
"portStride": 100,
|
|
50
|
-
"maxSlots":
|
|
50
|
+
"maxSlots": 50,
|
|
51
51
|
"services": [
|
|
52
|
-
{ "name": "<service>", "defaultPort": <port> }
|
|
52
|
+
{ "name": "<service>", "defaultPort": <port> },
|
|
53
|
+
{ "name": "redis", "defaultPort": <port from REDIS_URL or 6379> }
|
|
53
54
|
],
|
|
54
55
|
"envFiles": [
|
|
55
56
|
{
|
|
@@ -65,9 +66,10 @@ Build the config file at the repository root:
|
|
|
65
66
|
```
|
|
66
67
|
|
|
67
68
|
Validation rules:
|
|
68
|
-
- Every `port
|
|
69
|
+
- Every `redis`, `port`, and `url` patch must have a `service` that exists in `services`
|
|
69
70
|
- `portStride` * `maxSlots` + max default port must be < 65535
|
|
70
71
|
- `baseDatabaseName` must match the actual DB name in `DATABASE_URL`
|
|
72
|
+
- If using a `redis` patch, Docker must be available locally
|
|
71
73
|
|
|
72
74
|
**Step 4: Install wt**
|
|
73
75
|
|
|
@@ -129,7 +131,8 @@ wt list # Should show "No worktree allocations foun
|
|
|
129
131
|
wt doctor # Should show "All checks passed."
|
|
130
132
|
wt new test/wt-smoke --no-install # Create a test worktree
|
|
131
133
|
wt list # Should show the allocation
|
|
132
|
-
wt remove test-wt-smoke
|
|
134
|
+
wt remove .worktrees/test-wt-smoke # Clean up
|
|
135
|
+
wt prune --dry-run # Should show no Git-prunable worktrees
|
|
133
136
|
```
|
|
134
137
|
|
|
135
138
|
Present the results to the user.
|
|
@@ -157,7 +160,7 @@ wt new $1
|
|
|
157
160
|
```
|
|
158
161
|
|
|
159
162
|
If it fails, check `wt doctor` for diagnostics. Common issues:
|
|
160
|
-
- All slots occupied → suggest `wt list` to find stale ones, then `wt remove`
|
|
163
|
+
- All slots occupied → suggest `wt list` to find stale ones, then `wt remove` or `wt prune`
|
|
161
164
|
- Database connection failed → check that Postgres is running and `DATABASE_URL` in root `.env` is correct
|
|
162
165
|
|
|
163
166
|
---
|
|
@@ -178,7 +181,7 @@ Run:
|
|
|
178
181
|
wt remove $@
|
|
179
182
|
```
|
|
180
183
|
|
|
181
|
-
Accepts paths or slots, including batch slot formats:
|
|
184
|
+
Accepts paths or slots, not branch names, including batch slot formats:
|
|
182
185
|
- `wt remove 1 2`
|
|
183
186
|
- `wt remove 1,2`
|
|
184
187
|
- `wt remove "1, 2"`
|
|
@@ -188,6 +191,21 @@ If the user wants to keep the database, use `--keep-db`.
|
|
|
188
191
|
|
|
189
192
|
---
|
|
190
193
|
|
|
194
|
+
### `prune` — Prune Git-prunable worktrees
|
|
195
|
+
|
|
196
|
+
Run:
|
|
197
|
+
```bash
|
|
198
|
+
wt prune $@
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Use this when worktree directories were deleted manually and Git already marks them as prunable.
|
|
202
|
+
|
|
203
|
+
Flags:
|
|
204
|
+
- `--dry-run` to preview what would be pruned
|
|
205
|
+
- `--keep-db` to keep databases for matching managed allocations
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
191
209
|
### `doctor` — Diagnose issues
|
|
192
210
|
|
|
193
211
|
Run:
|
|
@@ -220,10 +238,11 @@ Show a brief help:
|
|
|
220
238
|
```
|
|
221
239
|
Available commands:
|
|
222
240
|
/wt init — Set up wt in a new repository (discovers env files, generates config)
|
|
223
|
-
/wt new <branch> — Create a worktree with isolated DB, Redis, and ports
|
|
241
|
+
/wt new <branch> — Create a worktree with isolated DB, managed Redis, and ports
|
|
224
242
|
/wt open <slot|branch> — Open a worktree by slot or branch (creates if not found)
|
|
225
243
|
/wt list — List all worktree allocations
|
|
226
244
|
/wt remove <targets...>|--all — Remove one or more worktrees and clean up resources
|
|
245
|
+
/wt prune [--dry-run] — Prune Git-prunable worktrees and clean up matching managed resources
|
|
227
246
|
/wt doctor — Diagnose and fix environment issues
|
|
228
247
|
/wt setup [path] — Set up an existing worktree
|
|
229
248
|
```
|