git-codex 0.1.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/LICENSE +21 -0
- package/README.md +249 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +146 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/add.d.ts +20 -0
- package/dist/commands/add.js +250 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/list.d.ts +6 -0
- package/dist/commands/list.js +64 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/open.d.ts +7 -0
- package/dist/commands/open.js +41 -0
- package/dist/commands/open.js.map +1 -0
- package/dist/commands/prompt.d.ts +7 -0
- package/dist/commands/prompt.js +41 -0
- package/dist/commands/prompt.js.map +1 -0
- package/dist/commands/rm.d.ts +6 -0
- package/dist/commands/rm.js +99 -0
- package/dist/commands/rm.js.map +1 -0
- package/dist/lib/add-strategy.d.ts +9 -0
- package/dist/lib/add-strategy.js +18 -0
- package/dist/lib/add-strategy.js.map +1 -0
- package/dist/lib/clipboard.d.ts +1 -0
- package/dist/lib/clipboard.js +45 -0
- package/dist/lib/clipboard.js.map +1 -0
- package/dist/lib/config.d.ts +52 -0
- package/dist/lib/config.js +238 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/env-files.d.ts +18 -0
- package/dist/lib/env-files.js +196 -0
- package/dist/lib/env-files.js.map +1 -0
- package/dist/lib/env-scope.d.ts +3 -0
- package/dist/lib/env-scope.js +15 -0
- package/dist/lib/env-scope.js.map +1 -0
- package/dist/lib/errors.d.ts +2 -0
- package/dist/lib/errors.js +26 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/fs-utils.d.ts +1 -0
- package/dist/lib/fs-utils.js +11 -0
- package/dist/lib/fs-utils.js.map +1 -0
- package/dist/lib/git.d.ts +20 -0
- package/dist/lib/git.js +82 -0
- package/dist/lib/git.js.map +1 -0
- package/dist/lib/output.d.ts +18 -0
- package/dist/lib/output.js +78 -0
- package/dist/lib/output.js.map +1 -0
- package/dist/lib/prompt.d.ts +8 -0
- package/dist/lib/prompt.js +14 -0
- package/dist/lib/prompt.js.map +1 -0
- package/dist/lib/repo.d.ts +8 -0
- package/dist/lib/repo.js +24 -0
- package/dist/lib/repo.js.map +1 -0
- package/dist/lib/task-utils.d.ts +3 -0
- package/dist/lib/task-utils.js +24 -0
- package/dist/lib/task-utils.js.map +1 -0
- package/dist/lib/template.d.ts +22 -0
- package/dist/lib/template.js +111 -0
- package/dist/lib/template.js.map +1 -0
- package/dist/lib/vscode.d.ts +1 -0
- package/dist/lib/vscode.js +8 -0
- package/dist/lib/vscode.js.map +1 -0
- package/dist/lib/worktrees.d.ts +11 -0
- package/dist/lib/worktrees.js +59 -0
- package/dist/lib/worktrees.js.map +1 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Arshaan ABH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# git-codex
|
|
2
|
+
|
|
3
|
+
`git-codex` is a TypeScript CLI that adds a `git codex` subcommand for task-oriented Git worktrees.
|
|
4
|
+
|
|
5
|
+
## Status
|
|
6
|
+
|
|
7
|
+
Phase 1 scaffold is implemented:
|
|
8
|
+
|
|
9
|
+
- `git codex add <task>`
|
|
10
|
+
- `git codex rm <task>`
|
|
11
|
+
- `git codex list`
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
Published install (after release):
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add -g git-codex
|
|
19
|
+
git codex --help
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Zero-install execution:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm dlx git-codex --help
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Local development install:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pnpm install
|
|
32
|
+
pnpm build
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
For local subcommand testing:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pnpm link --global
|
|
39
|
+
git codex --help
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Commands
|
|
43
|
+
|
|
44
|
+
Global flags (all commands):
|
|
45
|
+
|
|
46
|
+
- `-q, --quiet` suppress non-error output
|
|
47
|
+
- `--json` emit structured JSON output for CI/automation
|
|
48
|
+
|
|
49
|
+
### `git codex add <task>`
|
|
50
|
+
|
|
51
|
+
Creates a worktree and branch for the task.
|
|
52
|
+
|
|
53
|
+
Key flags:
|
|
54
|
+
|
|
55
|
+
- `--base <ref>` default `origin/main`
|
|
56
|
+
- `--branch-prefix <prefix>` default `codex/`
|
|
57
|
+
- `--dir <path>` default sibling directory of repo root
|
|
58
|
+
- `--no-open` skip `code -n <worktree>`
|
|
59
|
+
- `--no-copy-env` skip env copy
|
|
60
|
+
- `--env-globs ".env,.env.*"` customize env-like patterns
|
|
61
|
+
- `--env-scope <scope>` env file scan scope: `root`, `all`, or `packages`
|
|
62
|
+
- `--overwrite-env` allow overwriting env-like files
|
|
63
|
+
- `--template` generate `.codex/INSTRUCTIONS.md` for the new task worktree
|
|
64
|
+
- `--template-file <path>` use a custom template file (supports `{{task}}`, `{{taskSlug}}`, `{{branch}}`, `{{worktreePath}}`)
|
|
65
|
+
- `--template-type <type>` choose built-in template skeleton: `default`, `bugfix`, or `feature`
|
|
66
|
+
- `--overwrite-template` replace an existing generated instructions file
|
|
67
|
+
- `--no-fetch` skip `git fetch`
|
|
68
|
+
|
|
69
|
+
### `git codex rm <task>`
|
|
70
|
+
|
|
71
|
+
Removes the task worktree mapping and prunes stale entries.
|
|
72
|
+
|
|
73
|
+
Key flags:
|
|
74
|
+
|
|
75
|
+
- `--dir <path>` worktree parent directory override
|
|
76
|
+
- `--force-delete` also delete worktree folder from disk
|
|
77
|
+
|
|
78
|
+
### `git codex list`
|
|
79
|
+
|
|
80
|
+
Default:
|
|
81
|
+
|
|
82
|
+
- proxies `git worktree list`
|
|
83
|
+
|
|
84
|
+
Optional:
|
|
85
|
+
|
|
86
|
+
- `--pretty` filters by branch prefix and prints a compact table
|
|
87
|
+
- `--branch-prefix <prefix>` default `codex/`
|
|
88
|
+
|
|
89
|
+
In `--json` mode, `list` emits a structured `worktree.list` event with entries.
|
|
90
|
+
|
|
91
|
+
### `git codex open <task>`
|
|
92
|
+
|
|
93
|
+
Opens an existing task worktree.
|
|
94
|
+
|
|
95
|
+
Key flags:
|
|
96
|
+
|
|
97
|
+
- `--dir <path>` worktree parent directory override
|
|
98
|
+
- `--branch-prefix <prefix>` override expected branch prefix
|
|
99
|
+
- `--no-open` print metadata only (do not launch VS Code)
|
|
100
|
+
|
|
101
|
+
In `--json` mode, `open` emits `worktree.opened`.
|
|
102
|
+
|
|
103
|
+
### `git codex prompt <task> <message>`
|
|
104
|
+
|
|
105
|
+
Generates a task bootstrap prompt including task/branch/worktree metadata.
|
|
106
|
+
|
|
107
|
+
Key flags:
|
|
108
|
+
|
|
109
|
+
- `--dir <path>` worktree parent directory override
|
|
110
|
+
- `--branch-prefix <prefix>` override branch prefix
|
|
111
|
+
- `--copy` copy generated prompt text to clipboard
|
|
112
|
+
|
|
113
|
+
In `--json` mode, `prompt` emits `prompt.generated`.
|
|
114
|
+
|
|
115
|
+
## Phase 2 Config
|
|
116
|
+
|
|
117
|
+
`git-codex` supports both file-based and git-config-based settings.
|
|
118
|
+
|
|
119
|
+
Supported keys:
|
|
120
|
+
|
|
121
|
+
- `base`
|
|
122
|
+
- `branchPrefix`
|
|
123
|
+
- `dir`
|
|
124
|
+
- `copyEnv`
|
|
125
|
+
- `envGlobs`
|
|
126
|
+
- `overwriteEnv`
|
|
127
|
+
- `envScope`
|
|
128
|
+
- `template`
|
|
129
|
+
- `templateFile`
|
|
130
|
+
- `templateType`
|
|
131
|
+
- `overwriteTemplate`
|
|
132
|
+
- `fetch`
|
|
133
|
+
- `open` or `openVsCodeByDefault`
|
|
134
|
+
|
|
135
|
+
File locations:
|
|
136
|
+
|
|
137
|
+
- Repo config: `.git-codexrc.json`
|
|
138
|
+
- Global config: `~/.config/git-codex/config.json`
|
|
139
|
+
|
|
140
|
+
Git config keys:
|
|
141
|
+
|
|
142
|
+
- `codex.base`
|
|
143
|
+
- `codex.branchPrefix`
|
|
144
|
+
- `codex.dir`
|
|
145
|
+
- `codex.copyEnv`
|
|
146
|
+
- `codex.envGlobs`
|
|
147
|
+
- `codex.overwriteEnv`
|
|
148
|
+
- `codex.envScope`
|
|
149
|
+
- `codex.template`
|
|
150
|
+
- `codex.templateFile`
|
|
151
|
+
- `codex.templateType`
|
|
152
|
+
- `codex.overwriteTemplate`
|
|
153
|
+
- `codex.fetch`
|
|
154
|
+
- `codex.open`
|
|
155
|
+
|
|
156
|
+
Precedence:
|
|
157
|
+
|
|
158
|
+
1. CLI flags
|
|
159
|
+
2. Repo config file
|
|
160
|
+
3. Repo git config
|
|
161
|
+
4. Global config file
|
|
162
|
+
5. Global git config
|
|
163
|
+
6. Built-in defaults
|
|
164
|
+
|
|
165
|
+
Example `.git-codexrc.json`:
|
|
166
|
+
|
|
167
|
+
```json
|
|
168
|
+
{
|
|
169
|
+
"base": "origin/main",
|
|
170
|
+
"branchPrefix": "codex/",
|
|
171
|
+
"fetch": false,
|
|
172
|
+
"copyEnv": true,
|
|
173
|
+
"envGlobs": [".env", ".env.*", ".npmrc"],
|
|
174
|
+
"envScope": "packages",
|
|
175
|
+
"template": true,
|
|
176
|
+
"templateFile": "task-template.md",
|
|
177
|
+
"templateType": "bugfix",
|
|
178
|
+
"openVsCodeByDefault": false
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Troubleshooting
|
|
183
|
+
|
|
184
|
+
### Windows locks when removing worktrees
|
|
185
|
+
|
|
186
|
+
Symptom:
|
|
187
|
+
|
|
188
|
+
- `git codex rm <task>` fails with directory-not-empty or lock-related errors.
|
|
189
|
+
|
|
190
|
+
Common causes:
|
|
191
|
+
|
|
192
|
+
- VS Code window is still open for that worktree.
|
|
193
|
+
- A file watcher/dev server is still running.
|
|
194
|
+
- A terminal has CWD inside the worktree path.
|
|
195
|
+
- Antivirus/indexer still holds a file handle.
|
|
196
|
+
|
|
197
|
+
Recovery steps:
|
|
198
|
+
|
|
199
|
+
1. Close VS Code windows opened at that worktree.
|
|
200
|
+
2. Stop watchers/dev servers (for example `pnpm dev`, `vite`, `webpack --watch`).
|
|
201
|
+
3. Ensure no shell is `cd`'d into the target directory.
|
|
202
|
+
4. Retry remove with disk cleanup enabled:
|
|
203
|
+
- `git codex rm <task> --force-delete`
|
|
204
|
+
5. If needed, wait a few seconds and retry after lock release.
|
|
205
|
+
|
|
206
|
+
See also:
|
|
207
|
+
|
|
208
|
+
- `docs/parallel-codex-workflows.md` for end-to-end usage.
|
|
209
|
+
- Phase 2 config (`README.md`) for default worktree/env options.
|
|
210
|
+
|
|
211
|
+
## Development
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
pnpm lint
|
|
215
|
+
pnpm test
|
|
216
|
+
pnpm build
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Versioning and Releases
|
|
220
|
+
|
|
221
|
+
`git-codex` uses Changesets for semantic versioning and changelog updates.
|
|
222
|
+
|
|
223
|
+
Release flow:
|
|
224
|
+
|
|
225
|
+
1. Create a changeset for user-facing changes:
|
|
226
|
+
- `pnpm changeset`
|
|
227
|
+
2. Bump version and update `CHANGELOG.md`:
|
|
228
|
+
- `pnpm version-packages`
|
|
229
|
+
3. Commit release metadata (version + changelog + changeset updates), then tag:
|
|
230
|
+
- `git tag v<version>`
|
|
231
|
+
4. Pre-publish dry-run validation:
|
|
232
|
+
- `pnpm release:check`
|
|
233
|
+
5. Publish:
|
|
234
|
+
- `pnpm release`
|
|
235
|
+
|
|
236
|
+
Helpful checks before publish:
|
|
237
|
+
|
|
238
|
+
- `pnpm lint`
|
|
239
|
+
- `pnpm typecheck`
|
|
240
|
+
- `pnpm test`
|
|
241
|
+
- `pnpm build`
|
|
242
|
+
|
|
243
|
+
## Parallel Workflow Guide
|
|
244
|
+
|
|
245
|
+
See `docs/parallel-codex-workflows.md` for a full parallel task workflow from creation to cleanup, including naming, prompt generation, and cleanup hygiene.
|
|
246
|
+
|
|
247
|
+
## Release Checklist
|
|
248
|
+
|
|
249
|
+
See `docs/release-checklist.md` for the full semver/changelog/tag/publish procedure, including package dry-run validation.
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { runAddCommand } from "./commands/add.js";
|
|
4
|
+
import { runListCommand } from "./commands/list.js";
|
|
5
|
+
import { runOpenCommand } from "./commands/open.js";
|
|
6
|
+
import { runPromptCommand } from "./commands/prompt.js";
|
|
7
|
+
import { runRmCommand } from "./commands/rm.js";
|
|
8
|
+
import { parseOptionalEnvScope } from "./lib/env-scope.js";
|
|
9
|
+
import { toErrorMessage } from "./lib/errors.js";
|
|
10
|
+
import { createOutput } from "./lib/output.js";
|
|
11
|
+
async function main() {
|
|
12
|
+
const program = new Command();
|
|
13
|
+
program
|
|
14
|
+
.name("git codex")
|
|
15
|
+
.description("Manage task worktrees for parallel Codex workflows.")
|
|
16
|
+
.option("-q, --quiet", "Suppress non-error output")
|
|
17
|
+
.option("--json", "Emit structured JSON output for automation")
|
|
18
|
+
.showHelpAfterError();
|
|
19
|
+
program
|
|
20
|
+
.command("add")
|
|
21
|
+
.description("Create a task worktree and branch.")
|
|
22
|
+
.argument("<task>", "Task label used for branch and folder names")
|
|
23
|
+
.option("--base <ref>", "Base ref for new worktree branches")
|
|
24
|
+
.option("--branch-prefix <prefix>", "Branch prefix for generated branches")
|
|
25
|
+
.option("--dir <path>", "Parent directory for worktrees (default: sibling of repo root)")
|
|
26
|
+
.option("--env-globs <patterns>", "Comma-separated env-like file globs from repo root")
|
|
27
|
+
.option("--env-scope <scope>", "Env copy scope: root, all, or packages")
|
|
28
|
+
.option("--overwrite-env", "Overwrite env-like files in existing worktree")
|
|
29
|
+
.option("--template", "Generate .codex/INSTRUCTIONS.md in the new worktree")
|
|
30
|
+
.option("--template-file <path>", "Custom template source file (supports {{task}}, {{taskSlug}}, {{branch}}, {{worktreePath}})")
|
|
31
|
+
.option("--template-type <type>", "Built-in template skeleton type: default, bugfix, or feature")
|
|
32
|
+
.option("--overwrite-template", "Overwrite existing .codex/INSTRUCTIONS.md when generating template")
|
|
33
|
+
.option("--reuse", "Reuse existing worktree path (must already be registered with expected branch)")
|
|
34
|
+
.option("--rm-first", "Remove existing target worktree path first, then recreate it")
|
|
35
|
+
.option("--no-open", "Do not open a new VS Code window")
|
|
36
|
+
.option("--no-copy-env", "Skip env-like file copy")
|
|
37
|
+
.option("--no-fetch", "Skip git fetch before worktree creation")
|
|
38
|
+
.action(async (task, opts, command) => {
|
|
39
|
+
const output = createOutput(readGlobalOutputOptions(command));
|
|
40
|
+
await runAddCommand(task, {
|
|
41
|
+
open: readExplicitOption(command, "open", Boolean(opts.open)),
|
|
42
|
+
base: readExplicitOption(command, "base", toOptionalString(opts.base)),
|
|
43
|
+
branchPrefix: readExplicitOption(command, "branchPrefix", toOptionalString(opts.branchPrefix)),
|
|
44
|
+
dir: readExplicitOption(command, "dir", toOptionalString(opts.dir)),
|
|
45
|
+
copyEnv: readExplicitOption(command, "copyEnv", Boolean(opts.copyEnv)),
|
|
46
|
+
envGlobs: readExplicitOption(command, "envGlobs", toOptionalString(opts.envGlobs)),
|
|
47
|
+
envScope: readExplicitOption(command, "envScope", parseOptionalEnvScope(toOptionalString(opts.envScope), "CLI --env-scope")),
|
|
48
|
+
overwriteEnv: readExplicitOption(command, "overwriteEnv", Boolean(opts.overwriteEnv)),
|
|
49
|
+
template: readExplicitOption(command, "template", Boolean(opts.template)),
|
|
50
|
+
templateFile: readExplicitOption(command, "templateFile", toOptionalString(opts.templateFile)),
|
|
51
|
+
templateType: readExplicitOption(command, "templateType", toOptionalString(opts.templateType)),
|
|
52
|
+
overwriteTemplate: readExplicitOption(command, "overwriteTemplate", Boolean(opts.overwriteTemplate)),
|
|
53
|
+
reuse: Boolean(opts.reuse),
|
|
54
|
+
rmFirst: Boolean(opts.rmFirst),
|
|
55
|
+
fetch: readExplicitOption(command, "fetch", Boolean(opts.fetch)),
|
|
56
|
+
}, output);
|
|
57
|
+
});
|
|
58
|
+
program
|
|
59
|
+
.command("rm")
|
|
60
|
+
.description("Remove a task worktree.")
|
|
61
|
+
.argument("<task>", "Task label")
|
|
62
|
+
.option("--dir <path>", "Parent directory for worktrees (default: sibling of repo root)")
|
|
63
|
+
.option("--force-delete", "Delete the worktree directory after removing mapping")
|
|
64
|
+
.action(async (task, opts, command) => {
|
|
65
|
+
const output = createOutput(readGlobalOutputOptions(command));
|
|
66
|
+
await runRmCommand(task, {
|
|
67
|
+
dir: readExplicitOption(command, "dir", toOptionalString(opts.dir)),
|
|
68
|
+
forceDelete: readExplicitOption(command, "forceDelete", Boolean(opts.forceDelete)),
|
|
69
|
+
}, output);
|
|
70
|
+
});
|
|
71
|
+
program
|
|
72
|
+
.command("list")
|
|
73
|
+
.description("List git worktrees.")
|
|
74
|
+
.option("--pretty", "Show a filtered table for branches using the configured prefix")
|
|
75
|
+
.option("--branch-prefix <prefix>", "Branch prefix used by --pretty filtering")
|
|
76
|
+
.action(async (opts, command) => {
|
|
77
|
+
const output = createOutput(readGlobalOutputOptions(command));
|
|
78
|
+
await runListCommand({
|
|
79
|
+
pretty: readExplicitOption(command, "pretty", Boolean(opts.pretty)),
|
|
80
|
+
branchPrefix: readExplicitOption(command, "branchPrefix", toOptionalString(opts.branchPrefix)),
|
|
81
|
+
}, output);
|
|
82
|
+
});
|
|
83
|
+
program
|
|
84
|
+
.command("open")
|
|
85
|
+
.description("Open an existing task worktree.")
|
|
86
|
+
.argument("<task>", "Task label")
|
|
87
|
+
.option("--dir <path>", "Parent directory for worktrees (default: sibling of repo root)")
|
|
88
|
+
.option("--branch-prefix <prefix>", "Branch prefix for expected branch name")
|
|
89
|
+
.option("--no-open", "Only print worktree metadata without opening VS Code")
|
|
90
|
+
.action(async (task, opts, command) => {
|
|
91
|
+
const output = createOutput(readGlobalOutputOptions(command));
|
|
92
|
+
await runOpenCommand(task, {
|
|
93
|
+
dir: readExplicitOption(command, "dir", toOptionalString(opts.dir)),
|
|
94
|
+
branchPrefix: readExplicitOption(command, "branchPrefix", toOptionalString(opts.branchPrefix)),
|
|
95
|
+
open: readExplicitOption(command, "open", Boolean(opts.open)),
|
|
96
|
+
}, output);
|
|
97
|
+
});
|
|
98
|
+
program
|
|
99
|
+
.command("prompt")
|
|
100
|
+
.description("Generate an initial prompt for a task worktree.")
|
|
101
|
+
.argument("<task>", "Task label")
|
|
102
|
+
.argument("<message>", "Prompt message")
|
|
103
|
+
.option("--dir <path>", "Parent directory for worktrees (default: sibling of repo root)")
|
|
104
|
+
.option("--branch-prefix <prefix>", "Branch prefix for generated branch name")
|
|
105
|
+
.option("--copy", "Copy generated prompt to clipboard")
|
|
106
|
+
.action(async (task, message, opts, command) => {
|
|
107
|
+
const output = createOutput(readGlobalOutputOptions(command));
|
|
108
|
+
await runPromptCommand(task, message, {
|
|
109
|
+
dir: readExplicitOption(command, "dir", toOptionalString(opts.dir)),
|
|
110
|
+
branchPrefix: readExplicitOption(command, "branchPrefix", toOptionalString(opts.branchPrefix)),
|
|
111
|
+
copy: readExplicitOption(command, "copy", Boolean(opts.copy)),
|
|
112
|
+
}, output);
|
|
113
|
+
});
|
|
114
|
+
await program.parseAsync(process.argv);
|
|
115
|
+
}
|
|
116
|
+
main().catch((error) => {
|
|
117
|
+
const output = createOutput({
|
|
118
|
+
json: process.argv.includes("--json"),
|
|
119
|
+
quiet: process.argv.includes("--quiet") || process.argv.includes("-q"),
|
|
120
|
+
});
|
|
121
|
+
const message = toErrorMessage(error);
|
|
122
|
+
output.error(message);
|
|
123
|
+
process.exitCode = 1;
|
|
124
|
+
});
|
|
125
|
+
function isExplicitOptionSource(source) {
|
|
126
|
+
return source === "cli" || source === "env";
|
|
127
|
+
}
|
|
128
|
+
function readExplicitOption(command, optionName, value) {
|
|
129
|
+
const source = command.getOptionValueSource(optionName);
|
|
130
|
+
return isExplicitOptionSource(source) ? value : undefined;
|
|
131
|
+
}
|
|
132
|
+
function toOptionalString(value) {
|
|
133
|
+
if (typeof value !== "string") {
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
const trimmed = value.trim();
|
|
137
|
+
return trimmed || undefined;
|
|
138
|
+
}
|
|
139
|
+
function readGlobalOutputOptions(command) {
|
|
140
|
+
const options = command.optsWithGlobals();
|
|
141
|
+
return {
|
|
142
|
+
quiet: Boolean(options.quiet),
|
|
143
|
+
json: Boolean(options.json),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,KAAK,UAAU,IAAI;IACjB,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAE9B,OAAO;SACJ,IAAI,CAAC,WAAW,CAAC;SACjB,WAAW,CAAC,qDAAqD,CAAC;SAClE,MAAM,CAAC,aAAa,EAAE,2BAA2B,CAAC;SAClD,MAAM,CAAC,QAAQ,EAAE,4CAA4C,CAAC;SAC9D,kBAAkB,EAAE,CAAC;IAExB,OAAO;SACJ,OAAO,CAAC,KAAK,CAAC;SACd,WAAW,CAAC,oCAAoC,CAAC;SACjD,QAAQ,CAAC,QAAQ,EAAE,6CAA6C,CAAC;SACjE,MAAM,CAAC,cAAc,EAAE,oCAAoC,CAAC;SAC5D,MAAM,CAAC,0BAA0B,EAAE,sCAAsC,CAAC;SAC1E,MAAM,CACL,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7B,OAAO,OAAO,IAAI,SAAS,CAAC;AAC9B,CAAC;AAED,SAAS,uBAAuB,CAAC,OAAgB;IAI/C,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,EAGtC,CAAC;IAEF,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QAC7B,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;KAC5B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type EnvScope } from "../lib/env-scope.js";
|
|
2
|
+
import { type Output } from "../lib/output.js";
|
|
3
|
+
export interface AddCommandOptions {
|
|
4
|
+
open?: boolean;
|
|
5
|
+
base?: string;
|
|
6
|
+
branchPrefix?: string;
|
|
7
|
+
dir?: string;
|
|
8
|
+
copyEnv?: boolean;
|
|
9
|
+
envGlobs?: string;
|
|
10
|
+
envScope?: EnvScope;
|
|
11
|
+
overwriteEnv?: boolean;
|
|
12
|
+
template?: boolean;
|
|
13
|
+
templateFile?: string;
|
|
14
|
+
templateType?: string;
|
|
15
|
+
overwriteTemplate?: boolean;
|
|
16
|
+
reuse?: boolean;
|
|
17
|
+
rmFirst?: boolean;
|
|
18
|
+
fetch?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function runAddCommand(task: string, options: AddCommandOptions, output?: Output): Promise<void>;
|