@tokenbooks/wt 0.2.2 → 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.
@@ -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;IAClC,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACtB,IAAI,EAAE,OAAC,CAAC,IAAI,CAAC,WAAW,CAAC;IACzB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAC;AAEH,+CAA+C;AAClC,QAAA,aAAa,GAAG,OAAC,CAAC,MAAM,CAAC;IACpC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;CACzC,CAAC,CAAC;AAEH,+CAA+C;AAClC,QAAA,aAAa,GAAG,OAAC,CAAC,MAAM,CAAC;IACpC,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACzB,OAAO,EAAE,OAAC,CAAC,KAAK,CAAC,mBAAW,CAAC;CAC9B,CAAC,CAAC;AAEH,gCAAgC;AACnB,QAAA,YAAY,GAAG,OAAC,CAAC,MAAM,CAAC;IACnC,gBAAgB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACnC,gBAAgB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,O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,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;IACzD,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;IACpD,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAC7C,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,qBAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACvC,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,qBAAa,CAAC;IAChC,SAAS,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAC1C,WAAW,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;CACvC,CAAC,CAAC"}
@@ -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(1),
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;IAChC,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"}
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 redisDb: number;
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.2.2",
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",
@@ -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 DB indexes, and ports using the `wt` CLI.
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 format (with or without trailing `/0`)
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` | No |
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": 15,
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` and `url` patch must have a `service` that exists in `services`
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 # Clean up
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
  ```