@ogpoyraz/wtx 0.6.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/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@ogpoyraz/wtx",
3
+ "version": "0.6.0",
4
+ "description": "Multi-repo git worktree manager",
5
+ "type": "module",
6
+ "bin": {
7
+ "wtx": "./dist/cli.mjs"
8
+ },
9
+ "files": [
10
+ "dist/cli.mjs",
11
+ "share",
12
+ "skills",
13
+ "completions"
14
+ ],
15
+ "scripts": {
16
+ "dev": "bun run src/index.ts --",
17
+ "build": "bun build src/index.ts --compile --outfile dist/wtx",
18
+ "build:npm": "bun build src/index.ts --target=node --external @opentui/core --external @opentui/react --external react --external react-reconciler --outfile dist/cli.mjs",
19
+ "prepublishOnly": "bun run build:npm",
20
+ "test": "vitest run",
21
+ "test:watch": "vitest",
22
+ "typecheck": "tsc --noEmit"
23
+ },
24
+ "keywords": [
25
+ "git",
26
+ "worktree",
27
+ "monorepo",
28
+ "multi-repo",
29
+ "cli"
30
+ ],
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/OGPoyraz/wtx.git"
34
+ },
35
+ "devDependencies": {
36
+ "@types/bun": "latest",
37
+ "@types/node": "^26.2.0",
38
+ "@types/react": "^19.2.18",
39
+ "typescript": "^5.9.3",
40
+ "vitest": "^4.1.11"
41
+ },
42
+ "dependencies": {
43
+ "@opentui/core": "^0.5.6",
44
+ "@opentui/react": "^0.5.6",
45
+ "chalk": "^6.0.0",
46
+ "commander": "^15.0.0",
47
+ "execa": "^10.0.1",
48
+ "react": "^19.2.8",
49
+ "zod": "^4.4.3"
50
+ },
51
+ "license": "MIT"
52
+ }
package/share/wtx.sh ADDED
@@ -0,0 +1,16 @@
1
+ # Usage: eval "$(wtx init zsh)" or source this file
2
+
3
+ wtx() {
4
+ if [ "$1" = "cd" ]; then
5
+ if [ $# -lt 2 ]; then
6
+ command wtx cd
7
+ return $?
8
+ fi
9
+ shift
10
+ local _wtx_path
11
+ _wtx_path=$(command wtx _resolve-path "$@") || return $?
12
+ builtin cd "$_wtx_path" || return $?
13
+ else
14
+ command wtx "$@"
15
+ fi
16
+ }
@@ -0,0 +1,134 @@
1
+ # wtx — Worktree Manager
2
+
3
+ `wtx` is a multi-repo git worktree manager. It allows you to create, manage, and sync git worktrees across multiple repositories concurrently.
4
+
5
+ ## Commands
6
+
7
+ By default, if you are inside a repository's directory (either the main checkout or a worktree), `wtx` automatically scopes commands to that repository. If you are outside, it will run the command across **all** repositories defined in the config, unless you restrict it using the `--repo` flag.
8
+
9
+ ### `wtx create <branch>`
10
+ Creates a new worktree for the specified branch.
11
+ - **Flags**:
12
+ - `-r, --repo <repos...>`: Target specific repo(s) (comma-separated or multiple flags).
13
+ - `--base <ref>`: Base ref to create branch from (defaults to tracking remote branch, or creating from `origin/main`).
14
+ - `-o, --open`: Open worktree(s) in IDE after creation.
15
+ - `--ide <editor>`: IDE to open with (used with `--open`).
16
+ - `--track`: Track the remote branch even if ownership detection says it belongs to someone else.
17
+ - **Hooks & Sync**: Automatically copies files specified in `sync_files` from the main checkout, and runs `post_create` hooks.
18
+
19
+ ### `wtx remove <branch>`
20
+ Removes a worktree and deletes the branch.
21
+ - **Flags**: `-r, --repo <repos...>`
22
+
23
+ ### `wtx ls`
24
+ Lists all worktrees across repositories. Owned-by-someone-else branches show a dim `@handle` suffix.
25
+
26
+ ### `wtx prs`
27
+ Shows pull request status for worktree branches across repositories. Requires the GitHub CLI (`gh`) to be installed and authenticated. Read-only — never modifies PRs.
28
+ - **Flags**:
29
+ - `-r, --repo <repos...>`: Target specific repo(s).
30
+ - `--json`: Machine-readable JSON output with an `author` field.
31
+ - `--all`: Include drafts and closed/merged PRs.
32
+
33
+ `wtx ls --pr` adds a PR column to the worktree listing, `wtx prs` shows the same dim owner tag per row and a mixed-ownership summary, and `wtx status <branch>` shows a PR section (state, checks, unresolved threads, URL, owner line for foreign branches). Worktrees with local modifications count as yours. Use `wtx config set user <handle>` to enable ownership tags.
34
+
35
+ `wtx prune [--force]` removes worktrees whose branch has a merged PR. Dirty or locked worktrees are skipped without `--force`; repos with failed PR lookups are left untouched.
36
+
37
+ ### `wtx pull <pr-link>`
38
+ Fetches a GitHub PR by URL and creates its worktree. Requires the GitHub CLI (`gh`) to be installed and authenticated.
39
+ - **Flags**: `-r, --repo <repo>`
40
+ - Auto-detects the owning repo from the PR link, warns on merged or closed PRs, and skips existing branches or worktrees with a warning.
41
+ - Supports fork PRs without adding persistent remotes.
42
+
43
+ ### `wtx terminal`
44
+ Opens an interactive full-screen dashboard for browsing and acting on worktrees across all configured repos. Requires Bun runtime and a TTY; exits with guidance under Node.js or non-interactive shells.
45
+
46
+ - Lists worktrees as two-line entries: branch with status badge (clean / dirty count / locked / missing / rebasing), then commit hash, divergence vs main (`↑n ↓n`), PR number/state/checks, and owner tags.
47
+ - Keys: `r` refresh · `j/k` navigate · `n` create · `b` rebase · `d` remove · `s` sync · `o` open in IDE · `c` edit config · `?` help · `q` quit.
48
+ - Actions run as child processes with output streamed inside the dashboard; destructive actions confirm first (`y/n`). The config editor (`c`) persists through atomic config writes and refreshes the view automatically.
49
+
50
+ ### `wtx status`
51
+ Shows git statuses for all worktrees.
52
+
53
+ ### `wtx rebase <branch>`
54
+ Fetches the main branch from origin and rebases the given worktree's branch onto it.
55
+ - **Flags**: `-r, --repo <repos...>`
56
+
57
+ ### `wtx sync <branch>`
58
+ Re-copies `sync_files` from the main checkout to the worktree and runs `post_sync` hooks. Also checks for package lockfile differences if `node_modules` is symlinked.
59
+ - **Flags**: `-r, --repo <repos...>`
60
+
61
+ ### `wtx deps [branch]`
62
+ Manages the `node_modules` strategy for a worktree. By default, `wtx deps <branch>` shows the current strategy (independent or symlinked) and lockfile status.
63
+ - **Flags**:
64
+ - `--install`: Switch to independent `node_modules` and run install (e.g. `npm install`).
65
+ - `--symlink`: Switch to symlinked `node_modules` (points to the main checkout's `node_modules`).
66
+
67
+ ### `wtx open <branch>`
68
+ Opens the worktree in your configured IDE.
69
+ - **Flags**: `--ide <editor>` (defaults to config or `$EDITOR`), `-r, --repo <repos...>`
70
+
71
+ ### `wtx cd <repo> <branch>`
72
+ If shell integration is enabled via `wtx init`, this changes the current directory to the worktree path.
73
+
74
+ ## Configuration
75
+
76
+ Located at `~/.config/wtx/config.json`:
77
+
78
+ ```json
79
+ {
80
+ "version": 1,
81
+ "root": "~/Repos",
82
+ "postfix": "-wt",
83
+ "ide": "cursor",
84
+ "default_main_branch": "main",
85
+ "user": null,
86
+ "repos": {
87
+ "my-frontend": {
88
+ "main_branch": "auto",
89
+ "sync_files": [".env", ".env.local"],
90
+ "post_create": ["npm install", "npm run build"]
91
+ },
92
+ "my-backend": {
93
+ "main_branch": "master",
94
+ "post_sync": ["docker-compose restart"]
95
+ }
96
+ }
97
+ }
98
+ ```
99
+
100
+ ### Template Variables
101
+ Hooks (`post_create` and `post_sync`) support the following template variables:
102
+ - `{root}`: Base directory (`~/Repos`)
103
+ - `{repo}`: Repository name
104
+ - `{branch}`: Branch name
105
+ - `{main}`: Absolute path to the main checkout
106
+ - `{wt}`: Absolute path to the worktree
107
+ - `{postfix}`: Worktree directory postfix
108
+
109
+ ## Typical Workflows
110
+
111
+ 1. **Creating a feature across repos**:
112
+ ```bash
113
+ wtx create feature-xyz
114
+ ```
115
+ *Creates a `feature-xyz` worktree in every configured repo, syncs `.env` files, and runs post-create hooks.*
116
+
117
+ 2. **Rebasing daily**:
118
+ ```bash
119
+ wtx rebase feature-xyz
120
+ ```
121
+ *Fetches the latest main branch from origin and rebases the `feature-xyz` worktrees.*
122
+
123
+ 3. **Syncing environment variables**:
124
+ If the `.env` file in the main checkout was updated, run:
125
+ ```bash
126
+ wtx sync feature-xyz
127
+ ```
128
+
129
+ 4. **Managing node_modules dependencies**:
130
+ If a worktree requires different dependencies than the main branch (e.g. you're testing an upgrade):
131
+ ```bash
132
+ wtx deps feature-xyz --install
133
+ ```
134
+ *This removes the symlink to the main repo's `node_modules` and does a fresh install isolated to the worktree.*
@@ -0,0 +1,134 @@
1
+ # wtx — Worktree Manager
2
+
3
+ `wtx` is a multi-repo git worktree manager. It allows you to create, manage, and sync git worktrees across multiple repositories concurrently.
4
+
5
+ ## Commands
6
+
7
+ By default, if you are inside a repository's directory (either the main checkout or a worktree), `wtx` automatically scopes commands to that repository. If you are outside, it will run the command across **all** repositories defined in the config, unless you restrict it using the `--repo` flag.
8
+
9
+ ### `wtx create <branch>`
10
+ Creates a new worktree for the specified branch.
11
+ - **Flags**:
12
+ - `-r, --repo <repos...>`: Target specific repo(s) (comma-separated or multiple flags).
13
+ - `--base <ref>`: Base ref to create branch from (defaults to tracking remote branch, or creating from `origin/main`).
14
+ - `-o, --open`: Open worktree(s) in IDE after creation.
15
+ - `--ide <editor>`: IDE to open with (used with `--open`).
16
+ - `--track`: Track the remote branch even if ownership detection says it belongs to someone else.
17
+ - **Hooks & Sync**: Automatically copies files specified in `sync_files` from the main checkout, and runs `post_create` hooks.
18
+
19
+ ### `wtx remove <branch>`
20
+ Removes a worktree and deletes the branch.
21
+ - **Flags**: `-r, --repo <repos...>`
22
+
23
+ ### `wtx ls`
24
+ Lists all worktrees across repositories. Owned-by-someone-else branches show a dim `@handle` suffix.
25
+
26
+ ### `wtx prs`
27
+ Shows pull request status for worktree branches across repositories. Requires the GitHub CLI (`gh`) to be installed and authenticated. Read-only — never modifies PRs.
28
+ - **Flags**:
29
+ - `-r, --repo <repos...>`: Target specific repo(s).
30
+ - `--json`: Machine-readable JSON output with an `author` field.
31
+ - `--all`: Include drafts and closed/merged PRs.
32
+
33
+ `wtx ls --pr` adds a PR column to the worktree listing, `wtx prs` shows the same dim owner tag per row and a mixed-ownership summary, and `wtx status <branch>` shows a PR section (state, checks, unresolved threads, URL, owner line for foreign branches). Worktrees with local modifications count as yours. Use `wtx config set user <handle>` to enable ownership tags.
34
+
35
+ `wtx prune [--force]` removes worktrees whose branch has a merged PR. Dirty or locked worktrees are skipped without `--force`; repos with failed PR lookups are left untouched.
36
+
37
+ ### `wtx pull <pr-link>`
38
+ Fetches a GitHub PR by URL and creates its worktree. Requires the GitHub CLI (`gh`) to be installed and authenticated.
39
+ - **Flags**: `-r, --repo <repo>`
40
+ - Auto-detects the owning repo from the PR link, warns on merged or closed PRs, and skips existing branches or worktrees with a warning.
41
+ - Supports fork PRs without adding persistent remotes.
42
+
43
+ ### `wtx terminal`
44
+ Opens an interactive full-screen dashboard for browsing and acting on worktrees across all configured repos. Requires Bun runtime and a TTY; exits with guidance under Node.js or non-interactive shells.
45
+
46
+ - Lists worktrees as two-line entries: branch with status badge (clean / dirty count / locked / missing / rebasing), then commit hash, divergence vs main (`↑n ↓n`), PR number/state/checks, and owner tags.
47
+ - Keys: `r` refresh · `j/k` navigate · `n` create · `b` rebase · `d` remove · `s` sync · `o` open in IDE · `c` edit config · `?` help · `q` quit.
48
+ - Actions run as child processes with output streamed inside the dashboard; destructive actions confirm first (`y/n`). The config editor (`c`) persists through atomic config writes and refreshes the view automatically.
49
+
50
+ ### `wtx status`
51
+ Shows git statuses for all worktrees.
52
+
53
+ ### `wtx rebase <branch>`
54
+ Fetches the main branch from origin and rebases the given worktree's branch onto it.
55
+ - **Flags**: `-r, --repo <repos...>`
56
+
57
+ ### `wtx sync <branch>`
58
+ Re-copies `sync_files` from the main checkout to the worktree and runs `post_sync` hooks. Also checks for package lockfile differences if `node_modules` is symlinked.
59
+ - **Flags**: `-r, --repo <repos...>`
60
+
61
+ ### `wtx deps [branch]`
62
+ Manages the `node_modules` strategy for a worktree. By default, `wtx deps <branch>` shows the current strategy (independent or symlinked) and lockfile status.
63
+ - **Flags**:
64
+ - `--install`: Switch to independent `node_modules` and run install (e.g. `npm install`).
65
+ - `--symlink`: Switch to symlinked `node_modules` (points to the main checkout's `node_modules`).
66
+
67
+ ### `wtx open <branch>`
68
+ Opens the worktree in your configured IDE.
69
+ - **Flags**: `--ide <editor>` (defaults to config or `$EDITOR`), `-r, --repo <repos...>`
70
+
71
+ ### `wtx cd <repo> <branch>`
72
+ If shell integration is enabled via `wtx init`, this changes the current directory to the worktree path.
73
+
74
+ ## Configuration
75
+
76
+ Located at `~/.config/wtx/config.json`:
77
+
78
+ ```json
79
+ {
80
+ "version": 1,
81
+ "root": "~/Repos",
82
+ "postfix": "-wt",
83
+ "ide": "cursor",
84
+ "default_main_branch": "main",
85
+ "user": null,
86
+ "repos": {
87
+ "my-frontend": {
88
+ "main_branch": "auto",
89
+ "sync_files": [".env", ".env.local"],
90
+ "post_create": ["npm install", "npm run build"]
91
+ },
92
+ "my-backend": {
93
+ "main_branch": "master",
94
+ "post_sync": ["docker-compose restart"]
95
+ }
96
+ }
97
+ }
98
+ ```
99
+
100
+ ### Template Variables
101
+ Hooks (`post_create` and `post_sync`) support the following template variables:
102
+ - `{root}`: Base directory (`~/Repos`)
103
+ - `{repo}`: Repository name
104
+ - `{branch}`: Branch name
105
+ - `{main}`: Absolute path to the main checkout
106
+ - `{wt}`: Absolute path to the worktree
107
+ - `{postfix}`: Worktree directory postfix
108
+
109
+ ## Typical Workflows
110
+
111
+ 1. **Creating a feature across repos**:
112
+ ```bash
113
+ wtx create feature-xyz
114
+ ```
115
+ *Creates a `feature-xyz` worktree in every configured repo, syncs `.env` files, and runs post-create hooks.*
116
+
117
+ 2. **Rebasing daily**:
118
+ ```bash
119
+ wtx rebase feature-xyz
120
+ ```
121
+ *Fetches the latest main branch from origin and rebases the `feature-xyz` worktrees.*
122
+
123
+ 3. **Syncing environment variables**:
124
+ If the `.env` file in the main checkout was updated, run:
125
+ ```bash
126
+ wtx sync feature-xyz
127
+ ```
128
+
129
+ 4. **Managing node_modules dependencies**:
130
+ If a worktree requires different dependencies than the main branch (e.g. you're testing an upgrade):
131
+ ```bash
132
+ wtx deps feature-xyz --install
133
+ ```
134
+ *This removes the symlink to the main repo's `node_modules` and does a fresh install isolated to the worktree.*
@@ -0,0 +1,138 @@
1
+ ---
2
+ description: Manage git worktrees across multiple repos using wtx CLI. Trigger phrases: "create worktree", "remove worktree", "rebase worktree", "list worktrees", "open worktree", "fetch main".
3
+ ---
4
+
5
+ # wtx — Worktree Manager
6
+
7
+ `wtx` is a multi-repo git worktree manager. It allows you to create, manage, and sync git worktrees across multiple repositories concurrently.
8
+
9
+ ## Commands
10
+
11
+ By default, if you are inside a repository's directory (either the main checkout or a worktree), `wtx` automatically scopes commands to that repository. If you are outside, it will run the command across **all** repositories defined in the config, unless you restrict it using the `--repo` flag.
12
+
13
+ ### `wtx create <branch>`
14
+ Creates a new worktree for the specified branch.
15
+ - **Flags**:
16
+ - `-r, --repo <repos...>`: Target specific repo(s) (comma-separated or multiple flags).
17
+ - `--base <ref>`: Base ref to create branch from (defaults to tracking remote branch, or creating from `origin/main`).
18
+ - `-o, --open`: Open worktree(s) in IDE after creation.
19
+ - `--ide <editor>`: IDE to open with (used with `--open`).
20
+ - `--track`: Track the remote branch even if ownership detection says it belongs to someone else.
21
+ - **Hooks & Sync**: Automatically copies files specified in `sync_files` from the main checkout, and runs `post_create` hooks.
22
+
23
+ ### `wtx remove <branch>`
24
+ Removes a worktree and deletes the branch.
25
+ - **Flags**: `-r, --repo <repos...>`
26
+
27
+ ### `wtx ls`
28
+ Lists all worktrees across repositories. Owned-by-someone-else branches show a dim `@handle` suffix.
29
+
30
+ ### `wtx prs`
31
+ Shows pull request status for worktree branches across repositories. Requires the GitHub CLI (`gh`) to be installed and authenticated. Read-only — never modifies PRs.
32
+ - **Flags**:
33
+ - `-r, --repo <repos...>`: Target specific repo(s).
34
+ - `--json`: Machine-readable JSON output with an `author` field.
35
+ - `--all`: Include drafts and closed/merged PRs.
36
+
37
+ `wtx ls --pr` adds a PR column to the worktree listing, `wtx prs` shows the same dim owner tag per row and a mixed-ownership summary, and `wtx status <branch>` shows a PR section (state, checks, unresolved threads, URL, owner line for foreign branches). Worktrees with local modifications count as yours. Use `wtx config set user <handle>` to enable ownership tags.
38
+
39
+ `wtx prune [--force]` removes worktrees whose branch has a merged PR. Dirty or locked worktrees are skipped without `--force`; repos with failed PR lookups are left untouched.
40
+
41
+ ### `wtx pull <pr-link>`
42
+ Fetches a GitHub PR by URL and creates its worktree. Requires the GitHub CLI (`gh`) to be installed and authenticated.
43
+ - **Flags**: `-r, --repo <repo>`
44
+ - Auto-detects the owning repo from the PR link, warns on merged or closed PRs, and skips existing branches or worktrees with a warning.
45
+ - Supports fork PRs without adding persistent remotes.
46
+
47
+ ### `wtx terminal`
48
+ Opens an interactive full-screen dashboard for browsing and acting on worktrees across all configured repos. Requires Bun runtime and a TTY; exits with guidance under Node.js or non-interactive shells.
49
+
50
+ - Lists worktrees as two-line entries: branch with status badge (clean / dirty count / locked / missing / rebasing), then commit hash, divergence vs main (`↑n ↓n`), PR number/state/checks, and owner tags.
51
+ - Keys: `r` refresh · `j/k` navigate · `n` create · `b` rebase · `d` remove · `s` sync · `o` open in IDE · `c` edit config · `?` help · `q` quit.
52
+ - Actions run as child processes with output streamed inside the dashboard; destructive actions confirm first (`y/n`). The config editor (`c`) persists through atomic config writes and refreshes the view automatically.
53
+
54
+ ### `wtx status`
55
+ Shows git statuses for all worktrees.
56
+
57
+ ### `wtx rebase <branch>`
58
+ Fetches the main branch from origin and rebases the given worktree's branch onto it.
59
+ - **Flags**: `-r, --repo <repos...>`
60
+
61
+ ### `wtx sync <branch>`
62
+ Re-copies `sync_files` from the main checkout to the worktree and runs `post_sync` hooks. Also checks for package lockfile differences if `node_modules` is symlinked.
63
+ - **Flags**: `-r, --repo <repos...>`
64
+
65
+ ### `wtx deps [branch]`
66
+ Manages the `node_modules` strategy for a worktree. By default, `wtx deps <branch>` shows the current strategy (independent or symlinked) and lockfile status.
67
+ - **Flags**:
68
+ - `--install`: Switch to independent `node_modules` and run install (e.g. `npm install`).
69
+ - `--symlink`: Switch to symlinked `node_modules` (points to the main checkout's `node_modules`).
70
+
71
+ ### `wtx open <branch>`
72
+ Opens the worktree in your configured IDE.
73
+ - **Flags**: `--ide <editor>` (defaults to config or `$EDITOR`), `-r, --repo <repos...>`
74
+
75
+ ### `wtx cd <repo> <branch>`
76
+ If shell integration is enabled via `wtx init`, this changes the current directory to the worktree path.
77
+
78
+ ## Configuration
79
+
80
+ Located at `~/.config/wtx/config.json`:
81
+
82
+ ```json
83
+ {
84
+ "version": 1,
85
+ "root": "~/Repos",
86
+ "postfix": "-wt",
87
+ "ide": "cursor",
88
+ "default_main_branch": "main",
89
+ "user": null,
90
+ "repos": {
91
+ "my-frontend": {
92
+ "main_branch": "auto",
93
+ "sync_files": [".env", ".env.local"],
94
+ "post_create": ["npm install", "npm run build"]
95
+ },
96
+ "my-backend": {
97
+ "main_branch": "master",
98
+ "post_sync": ["docker-compose restart"]
99
+ }
100
+ }
101
+ }
102
+ ```
103
+
104
+ ### Template Variables
105
+ Hooks (`post_create` and `post_sync`) support the following template variables:
106
+ - `{root}`: Base directory (`~/Repos`)
107
+ - `{repo}`: Repository name
108
+ - `{branch}`: Branch name
109
+ - `{main}`: Absolute path to the main checkout
110
+ - `{wt}`: Absolute path to the worktree
111
+ - `{postfix}`: Worktree directory postfix
112
+
113
+ ## Typical Workflows
114
+
115
+ 1. **Creating a feature across repos**:
116
+ ```bash
117
+ wtx create feature-xyz
118
+ ```
119
+ *Creates a `feature-xyz` worktree in every configured repo, syncs `.env` files, and runs post-create hooks.*
120
+
121
+ 2. **Rebasing daily**:
122
+ ```bash
123
+ wtx rebase feature-xyz
124
+ ```
125
+ *Fetches the latest main branch from origin and rebases the `feature-xyz` worktrees.*
126
+
127
+ 3. **Syncing environment variables**:
128
+ If the `.env` file in the main checkout was updated, run:
129
+ ```bash
130
+ wtx sync feature-xyz
131
+ ```
132
+
133
+ 4. **Managing node_modules dependencies**:
134
+ If a worktree requires different dependencies than the main branch (e.g. you're testing an upgrade):
135
+ ```bash
136
+ wtx deps feature-xyz --install
137
+ ```
138
+ *This removes the symlink to the main repo's `node_modules` and does a fresh install isolated to the worktree.*