@tokenbooks/wt 0.1.0 → 0.1.2

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 CHANGED
@@ -98,6 +98,10 @@ echo ".worktree-registry.json" >> .gitignore
98
98
  # Create a worktree with full isolation
99
99
  wt new feat/my-feature
100
100
 
101
+ # Jump into a worktree by slot or branch
102
+ cd $(wt open 1)
103
+ cd $(wt open feat/my-feature)
104
+
101
105
  # List all worktree allocations
102
106
  wt list
103
107
 
@@ -131,6 +135,24 @@ Creates a new git worktree and sets up its isolated environment:
131
135
  4. Copies all configured `.env` files, patching each with slot-specific values
132
136
  5. Runs `postSetup` commands (unless `--no-install`)
133
137
 
138
+ ### `wt open <slot-or-branch> [--no-install] [--json]`
139
+
140
+ Opens an existing worktree or creates one on the fly. Prints the worktree path to stdout for easy shell integration:
141
+
142
+ ```bash
143
+ cd $(wt open 1) # by slot number
144
+ cd $(wt open feat/my-feature) # by branch name (creates if not found)
145
+ ```
146
+
147
+ - **Slot number**: Looks up the allocation and prints its path. Exits 1 if the slot is empty.
148
+ - **Branch name**: Scans allocations for a matching branch. If not found, creates a new worktree (like `wt new`).
149
+
150
+ Shell helper tip:
151
+
152
+ ```bash
153
+ wto() { cd "$(wt open "$@")"; }
154
+ ```
155
+
134
156
  ### `wt setup [path] [--no-install] [--json]`
135
157
 
136
158
  Sets up an existing worktree that was created manually or by another tool. Useful when:
package/dist/cli.js CHANGED
@@ -7,12 +7,14 @@ const setup_1 = require("./commands/setup");
7
7
  const remove_1 = require("./commands/remove");
8
8
  const list_1 = require("./commands/list");
9
9
  const doctor_1 = require("./commands/doctor");
10
+ const open_1 = require("./commands/open");
10
11
  const git_1 = require("./core/git");
12
+ const package_json_1 = require("../package.json");
11
13
  const program = new commander_1.Command();
12
14
  program
13
15
  .name('wt')
14
16
  .description('Git worktree environment isolation CLI')
15
- .version('0.1.0');
17
+ .version(package_json_1.version);
16
18
  program
17
19
  .command('new')
18
20
  .description('Create a new worktree with isolated environment')
@@ -39,6 +41,18 @@ program
39
41
  install: opts.install,
40
42
  });
41
43
  });
44
+ program
45
+ .command('open')
46
+ .description('Open a worktree by slot or branch (creates if not found)')
47
+ .argument('<slot-or-branch>', 'Slot number or branch name')
48
+ .option('--no-install', 'Skip post-setup commands if creating')
49
+ .option('--json', 'Output as JSON', false)
50
+ .action(async (slotOrBranch, opts) => {
51
+ await (0, open_1.openCommand)(slotOrBranch, {
52
+ json: opts.json,
53
+ install: opts.install,
54
+ });
55
+ });
42
56
  program
43
57
  .command('remove')
44
58
  .description('Remove a worktree and clean up its resources')
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,wCAA4C;AAC5C,4CAAgD;AAChD,8CAAkD;AAClD,0CAA8C;AAC9C,8CAAkD;AAClD,oCAAiD;AAEjD,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,IAAI,CAAC;KACV,WAAW,CAAC,wCAAwC,CAAC;KACrD,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,KAAK,CAAC;KACd,WAAW,CAAC,iDAAiD,CAAC;KAC9D,QAAQ,CAAC,UAAU,EAAE,mCAAmC,CAAC;KACzD,MAAM,CAAC,YAAY,EAAE,8BAA8B,CAAC;KACpD,MAAM,CAAC,cAAc,EAAE,0BAA0B,CAAC;KAClD,MAAM,CAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,CAAC;KACzC,MAAM,CAAC,KAAK,EAAE,MAAc,EAAE,IAAI,EAAE,EAAE;IACrC,MAAM,IAAA,gBAAU,EAAC,MAAM,EAAE;QACvB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,IAAI,EAAE,IAAI,CAAC,IAAI;KACh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AAgB,EAAE,KAAK,CAAC;KACzC,MAAM,CAAC,KAAK,EAAE,UAAkB,EAAE,IAAI,EAAE,EAAE;IACzC,MAAM,IAAA,sBAAa,EAAC,UAAU,EAAE;QAC9B,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,MAAM,EAAE,IAAI,CAAC,MAAM;KACpB,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,+BAA+B,CAAC;KAC5C,MAAM,CAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,CAAC;KACzC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;IACf,MAAM,QAAQ,GAAG,IAAA,yBAAmB,GAAE,CAAC;IACvC,IAAA,kBAAW,EAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AAC7C,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,8CAA8C,CAAC;KAC3D,MAAM,CAAC,OAAO,EAAE,kDAAkD,EAAE,KAAK,CAAC;KAC1E,MAAM,CAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,CAAC;KACzC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IACrB,MAAM,IAAA,sBAAa,EAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;AAC1D,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
@@ -1,8 +1,19 @@
1
+ import type { Allocation } from '../types';
1
2
  interface NewOptions {
2
3
  readonly json: boolean;
3
4
  readonly install: boolean;
4
5
  readonly slot?: string;
5
6
  }
7
+ export interface CreateWorktreeResult {
8
+ slot: number;
9
+ allocation: Allocation;
10
+ }
11
+ /** Core worktree creation logic — returns the result for programmatic use */
12
+ export declare function createNewWorktree(branchName: string, options: {
13
+ install: boolean;
14
+ slot?: string;
15
+ quiet?: boolean;
16
+ }): Promise<CreateWorktreeResult>;
6
17
  /** Create a new worktree with full environment isolation */
7
18
  export declare function newCommand(branchName: string, options: NewOptions): Promise<void>;
8
19
  export {};
@@ -33,6 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createNewWorktree = createNewWorktree;
36
37
  exports.newCommand = newCommand;
37
38
  const path = __importStar(require("node:path"));
38
39
  const registry_1 = require("../core/registry");
@@ -54,91 +55,85 @@ function readDatabaseUrl(mainRoot) {
54
55
  }
55
56
  return match[1];
56
57
  }
57
- /** Create a new worktree with full environment isolation */
58
- async function newCommand(branchName, options) {
59
- try {
60
- const mainRoot = (0, git_1.getMainWorktreePath)();
61
- const config = (0, setup_1.loadConfig)(mainRoot);
62
- let registry = (0, registry_1.readRegistry)(mainRoot);
63
- // Determine slot
64
- let slot;
65
- if (options.slot !== undefined) {
66
- slot = parseInt(options.slot, 10);
67
- if (isNaN(slot) || slot < 1 || slot > config.maxSlots) {
68
- const msg = `Invalid slot: ${options.slot}. Must be 1-${config.maxSlots}.`;
69
- if (options.json) {
70
- console.log((0, output_1.formatJson)((0, output_1.error)('INVALID_SLOT', msg)));
71
- }
72
- else {
73
- console.error(msg);
74
- }
75
- process.exitCode = 1;
76
- return;
77
- }
78
- if (String(slot) in registry.allocations) {
79
- const msg = `Slot ${slot} is already occupied.`;
80
- if (options.json) {
81
- console.log((0, output_1.formatJson)((0, output_1.error)('SLOT_OCCUPIED', msg)));
82
- }
83
- else {
84
- console.error(msg);
85
- }
86
- process.exitCode = 1;
87
- return;
88
- }
58
+ /** Core worktree creation logic returns the result for programmatic use */
59
+ async function createNewWorktree(branchName, options) {
60
+ const log = options.quiet
61
+ ? () => { }
62
+ : (msg) => process.stderr.write(`${msg}\n`);
63
+ const mainRoot = (0, git_1.getMainWorktreePath)();
64
+ const config = (0, setup_1.loadConfig)(mainRoot);
65
+ let registry = (0, registry_1.readRegistry)(mainRoot);
66
+ // Determine slot
67
+ let slot;
68
+ if (options.slot !== undefined) {
69
+ slot = parseInt(options.slot, 10);
70
+ if (isNaN(slot) || slot < 1 || slot > config.maxSlots) {
71
+ throw new Error(`Invalid slot: ${options.slot}. Must be 1-${config.maxSlots}.`);
89
72
  }
90
- else {
91
- const available = (0, slot_allocator_1.findAvailableSlot)(registry, config.maxSlots);
92
- if (available === null) {
93
- const msg = `All ${config.maxSlots} slots are occupied. Remove a worktree first.`;
94
- if (options.json) {
95
- console.log((0, output_1.formatJson)((0, output_1.error)('NO_SLOTS', msg)));
96
- }
97
- else {
98
- console.error(msg);
99
- }
100
- process.exitCode = 1;
101
- return;
102
- }
103
- slot = available;
73
+ if (String(slot) in registry.allocations) {
74
+ throw new Error(`Slot ${slot} is already occupied.`);
104
75
  }
105
- // Create worktree
106
- const basePath = path.join(mainRoot, config.baseWorktreePath);
107
- const worktreePath = (0, git_1.createWorktree)(basePath, branchName);
108
- const actualBranch = (0, git_1.getBranchName)(worktreePath);
109
- // Compute isolation params
110
- const dbName = (0, slot_allocator_1.calculateDbName)(slot, config.baseDatabaseName);
111
- const ports = (0, slot_allocator_1.calculatePorts)(slot, config.services, config.portStride);
112
- // Create database
113
- const databaseUrl = readDatabaseUrl(mainRoot);
114
- const dbAlreadyExists = await (0, database_1.databaseExists)(databaseUrl, dbName);
115
- if (!dbAlreadyExists) {
116
- await (0, database_1.createDatabase)(databaseUrl, config.baseDatabaseName, dbName);
76
+ }
77
+ else {
78
+ const available = (0, slot_allocator_1.findAvailableSlot)(registry, config.maxSlots);
79
+ if (available === null) {
80
+ throw new Error(`All ${config.maxSlots} slots are occupied. Remove a worktree first.`);
117
81
  }
118
- // Copy and patch env files
119
- (0, env_patcher_1.copyAndPatchAllEnvFiles)(config, mainRoot, worktreePath, {
120
- dbName,
121
- redisDb: slot,
122
- ports,
123
- });
124
- // Update registry
125
- const allocation = {
126
- worktreePath,
127
- branchName: actualBranch,
128
- dbName,
129
- redisDb: slot,
130
- ports,
131
- createdAt: new Date().toISOString(),
132
- };
133
- registry = (0, registry_1.addAllocation)(registry, slot, allocation);
134
- (0, registry_1.writeRegistry)(mainRoot, registry);
135
- // Run post-setup commands
136
- if (config.autoInstall && options.install && config.postSetup.length > 0) {
137
- for (const cmd of config.postSetup) {
138
- console.log(`Running: ${cmd}`);
139
- (0, node_child_process_1.execSync)(cmd, { cwd: worktreePath, stdio: 'inherit' });
140
- }
82
+ slot = available;
83
+ }
84
+ log(`Creating worktree for '${branchName}' in slot ${slot}...`);
85
+ // Create worktree
86
+ const basePath = path.join(mainRoot, config.baseWorktreePath);
87
+ const worktreePath = (0, git_1.createWorktree)(basePath, branchName);
88
+ const actualBranch = (0, git_1.getBranchName)(worktreePath);
89
+ // Compute isolation params
90
+ const dbName = (0, slot_allocator_1.calculateDbName)(slot, config.baseDatabaseName);
91
+ const ports = (0, slot_allocator_1.calculatePorts)(slot, config.services, config.portStride);
92
+ // Create database
93
+ const databaseUrl = readDatabaseUrl(mainRoot);
94
+ const dbAlreadyExists = await (0, database_1.databaseExists)(databaseUrl, dbName);
95
+ if (!dbAlreadyExists) {
96
+ log(`Creating database '${dbName}'...`);
97
+ await (0, database_1.createDatabase)(databaseUrl, config.baseDatabaseName, dbName);
98
+ }
99
+ else {
100
+ log(`Database '${dbName}' already exists, reusing.`);
101
+ }
102
+ // Copy and patch env files
103
+ log(`Patching ${config.envFiles.length} env file(s)...`);
104
+ (0, env_patcher_1.copyAndPatchAllEnvFiles)(config, mainRoot, worktreePath, {
105
+ dbName,
106
+ redisDb: slot,
107
+ ports,
108
+ });
109
+ // Update registry
110
+ const allocation = {
111
+ worktreePath,
112
+ branchName: actualBranch,
113
+ dbName,
114
+ redisDb: slot,
115
+ ports,
116
+ createdAt: new Date().toISOString(),
117
+ };
118
+ registry = (0, registry_1.addAllocation)(registry, slot, allocation);
119
+ (0, registry_1.writeRegistry)(mainRoot, registry);
120
+ // Run post-setup commands
121
+ if (config.autoInstall && options.install && config.postSetup.length > 0) {
122
+ for (const cmd of config.postSetup) {
123
+ log(`Running: ${cmd}`);
124
+ (0, node_child_process_1.execSync)(cmd, { cwd: worktreePath, stdio: 'inherit' });
141
125
  }
126
+ }
127
+ log(`Ready — slot ${slot}, branch '${actualBranch}'.`);
128
+ return { slot, allocation };
129
+ }
130
+ /** Create a new worktree with full environment isolation */
131
+ async function newCommand(branchName, options) {
132
+ try {
133
+ const { slot, allocation } = await createNewWorktree(branchName, {
134
+ ...options,
135
+ quiet: options.json,
136
+ });
142
137
  if (options.json) {
143
138
  console.log((0, output_1.formatJson)((0, output_1.success)({ slot, ...allocation })));
144
139
  }
@@ -1 +1 @@
1
- {"version":3,"file":"new.js","sourceRoot":"","sources":["../../src/commands/new.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,gCAyGC;AAxID,gDAAkC;AAElC,+CAA8E;AAC9E,2DAA4F;AAC5F,qDAA8D;AAC9D,+CAAkE;AAClE,qCAAiF;AACjF,sCAA2E;AAC3E,mCAAqC;AAErC,2DAA8C;AAC9C,4CAA8B;AAQ9B,2DAA2D;AAC3D,SAAS,eAAe,CAAC,QAAgB;IACvC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;IAC9D,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,4DAA4D;AACrD,KAAK,UAAU,UAA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UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;QAC5D,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,IAAA,2BAAkB,EAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,IAAA,mBAAU,EAAC,IAAA,cAAK,EAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;QACxD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,8BAA8B,OAAO,EAAE,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ interface OpenOptions {
2
+ readonly json: boolean;
3
+ readonly install: boolean;
4
+ }
5
+ /** Open (or create) a worktree and print its path */
6
+ export declare function openCommand(slotOrBranch: string, options: OpenOptions): Promise<void>;
7
+ export {};
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.openCommand = openCommand;
4
+ const registry_1 = require("../core/registry");
5
+ const git_1 = require("../core/git");
6
+ const new_1 = require("./new");
7
+ const output_1 = require("../output");
8
+ /** Open (or create) a worktree and print its path */
9
+ async function openCommand(slotOrBranch, options) {
10
+ const log = options.json
11
+ ? () => { }
12
+ : (msg) => process.stderr.write(`${msg}\n`);
13
+ try {
14
+ const mainRoot = (0, git_1.getMainWorktreePath)();
15
+ const registry = (0, registry_1.readRegistry)(mainRoot);
16
+ const asSlot = parseInt(slotOrBranch, 10);
17
+ if (!isNaN(asSlot) && String(asSlot) === slotOrBranch) {
18
+ // Slot lookup
19
+ const allocation = registry.allocations[String(asSlot)];
20
+ if (!allocation) {
21
+ if (options.json) {
22
+ console.log((0, output_1.formatJson)((0, output_1.error)('NOT_FOUND', `No allocation found for slot ${asSlot}.`)));
23
+ }
24
+ else {
25
+ console.error(`No allocation found for slot ${asSlot}.\n`);
26
+ console.error((0, output_1.formatAllocationTable)(registry.allocations));
27
+ }
28
+ process.exitCode = 1;
29
+ return;
30
+ }
31
+ log(`Opening slot ${asSlot} (${allocation.branchName})`);
32
+ if (options.json) {
33
+ console.log((0, output_1.formatJson)((0, output_1.success)({ slot: asSlot, ...allocation })));
34
+ }
35
+ else {
36
+ console.log(allocation.worktreePath);
37
+ }
38
+ return;
39
+ }
40
+ // Branch lookup
41
+ for (const [slotStr, allocation] of Object.entries(registry.allocations)) {
42
+ if (allocation.branchName === slotOrBranch) {
43
+ log(`Opening slot ${slotStr} (${allocation.branchName})`);
44
+ if (options.json) {
45
+ console.log((0, output_1.formatJson)((0, output_1.success)({ slot: Number(slotStr), ...allocation })));
46
+ }
47
+ else {
48
+ console.log(allocation.worktreePath);
49
+ }
50
+ return;
51
+ }
52
+ }
53
+ // Not found — create a new worktree
54
+ log(`Branch '${slotOrBranch}' not found in registry, creating...`);
55
+ const { slot, allocation } = await (0, new_1.createNewWorktree)(slotOrBranch, {
56
+ install: options.install,
57
+ quiet: options.json,
58
+ });
59
+ if (options.json) {
60
+ console.log((0, output_1.formatJson)((0, output_1.success)({ slot, ...allocation })));
61
+ }
62
+ else {
63
+ console.log(allocation.worktreePath);
64
+ }
65
+ }
66
+ catch (err) {
67
+ const message = err instanceof Error ? err.message : String(err);
68
+ if (options.json) {
69
+ console.log((0, output_1.formatJson)((0, output_1.error)('OPEN_FAILED', message)));
70
+ }
71
+ else {
72
+ console.error(`Failed to open worktree: ${message}`);
73
+ }
74
+ process.exitCode = 1;
75
+ }
76
+ }
77
+ //# sourceMappingURL=open.js.map
@@ -0,0 +1 @@
1
+ {"version":3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AAC,CAAC;QAEH,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,IAAA,mBAAU,EAAC,IAAA,gBAAO,EAAC,EAAE,IAAI,EAAE,GAAG,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;QAC5D,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,IAAA,mBAAU,EAAC,IAAA,cAAK,EAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;QACzD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,4BAA4B,OAAO,EAAE,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenbooks/wt",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Git worktree environment isolation CLI",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: wt
3
3
  description: Manage git worktree isolation — create, list, remove worktrees with isolated databases, Redis, and ports
4
- argument-hint: "[new|list|remove|doctor|setup|init] [args...]"
4
+ argument-hint: "[new|open|list|remove|doctor|setup|init] [args...]"
5
5
  allowed-tools: Bash, Read, Write, Edit, Grep, Glob
6
6
  ---
7
7
 
@@ -136,6 +136,19 @@ Present the results to the user.
136
136
 
137
137
  ---
138
138
 
139
+ ### `open $1` — Open (or create) a worktree
140
+
141
+ Run:
142
+ ```bash
143
+ wt open $1
144
+ ```
145
+
146
+ Accepts a slot number (`1`) or branch name (`feat/auth`). If a branch isn't found in the registry, it creates a new worktree automatically.
147
+
148
+ Tip: use `cd $(wt open $1)` to jump into the worktree directory.
149
+
150
+ ---
151
+
139
152
  ### `new $1` — Create a new worktree
140
153
 
141
154
  Run:
@@ -204,6 +217,7 @@ Show a brief help:
204
217
  Available commands:
205
218
  /wt init — Set up wt in a new repository (discovers env files, generates config)
206
219
  /wt new <branch> — Create a worktree with isolated DB, Redis, and ports
220
+ /wt open <slot|branch> — Open a worktree by slot or branch (creates if not found)
207
221
  /wt list — List all worktree allocations
208
222
  /wt remove <target> — Remove a worktree and clean up resources
209
223
  /wt doctor — Diagnose and fix environment issues