cluttry 1.0.3 → 1.5.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/CHANGELOG.md +71 -0
- package/README.md +203 -300
- package/dist/commands/completions.d.ts +16 -0
- package/dist/commands/completions.d.ts.map +1 -0
- package/dist/commands/completions.js +46 -0
- package/dist/commands/completions.js.map +1 -0
- package/dist/commands/explain-copy.d.ts +11 -0
- package/dist/commands/explain-copy.d.ts.map +1 -0
- package/dist/commands/explain-copy.js +34 -0
- package/dist/commands/explain-copy.js.map +1 -0
- package/dist/commands/finish.d.ts +20 -0
- package/dist/commands/finish.d.ts.map +1 -0
- package/dist/commands/finish.js +817 -0
- package/dist/commands/finish.js.map +1 -0
- package/dist/commands/gc.d.ts +22 -0
- package/dist/commands/gc.d.ts.map +1 -0
- package/dist/commands/gc.js +163 -0
- package/dist/commands/gc.js.map +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +1 -0
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/open.d.ts +15 -1
- package/dist/commands/open.d.ts.map +1 -1
- package/dist/commands/open.js +96 -17
- package/dist/commands/open.js.map +1 -1
- package/dist/commands/resume.d.ts +21 -0
- package/dist/commands/resume.d.ts.map +1 -0
- package/dist/commands/resume.js +106 -0
- package/dist/commands/resume.js.map +1 -0
- package/dist/commands/rm.d.ts.map +1 -1
- package/dist/commands/rm.js +6 -14
- package/dist/commands/rm.js.map +1 -1
- package/dist/commands/spawn.d.ts +3 -0
- package/dist/commands/spawn.d.ts.map +1 -1
- package/dist/commands/spawn.js +182 -19
- package/dist/commands/spawn.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +198 -9
- package/dist/index.js.map +1 -1
- package/dist/lib/completions.d.ts +35 -0
- package/dist/lib/completions.d.ts.map +1 -0
- package/dist/lib/completions.js +368 -0
- package/dist/lib/completions.js.map +1 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +2 -0
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/errors.d.ts +43 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +251 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/git.d.ts +17 -0
- package/dist/lib/git.d.ts.map +1 -1
- package/dist/lib/git.js +78 -10
- package/dist/lib/git.js.map +1 -1
- package/dist/lib/safety.d.ts +79 -0
- package/dist/lib/safety.d.ts.map +1 -0
- package/dist/lib/safety.js +133 -0
- package/dist/lib/safety.js.map +1 -0
- package/dist/lib/secrets.d.ts +29 -0
- package/dist/lib/secrets.d.ts.map +1 -1
- package/dist/lib/secrets.js +115 -0
- package/dist/lib/secrets.js.map +1 -1
- package/dist/lib/session.d.ts +93 -0
- package/dist/lib/session.d.ts.map +1 -0
- package/dist/lib/session.js +254 -0
- package/dist/lib/session.js.map +1 -0
- package/dist/lib/types.d.ts +6 -1
- package/dist/lib/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/.claude/settings.local.json +0 -7
- package/src/commands/doctor.ts +0 -222
- package/src/commands/init.ts +0 -120
- package/src/commands/list.ts +0 -133
- package/src/commands/open.ts +0 -78
- package/src/commands/prune.ts +0 -36
- package/src/commands/rm.ts +0 -125
- package/src/commands/shell.ts +0 -99
- package/src/commands/spawn.ts +0 -169
- package/src/index.ts +0 -123
- package/src/lib/config.ts +0 -120
- package/src/lib/git.ts +0 -243
- package/src/lib/output.ts +0 -102
- package/src/lib/paths.ts +0 -108
- package/src/lib/secrets.ts +0 -193
- package/src/lib/types.ts +0 -69
- package/tests/config.test.ts +0 -102
- package/tests/paths.test.ts +0 -155
- package/tests/secrets.test.ts +0 -150
- package/tsconfig.json +0 -20
- package/vitest.config.ts +0 -15
package/dist/commands/rm.js
CHANGED
|
@@ -7,6 +7,7 @@ import { createInterface } from 'node:readline';
|
|
|
7
7
|
import { isGitRepo, getRepoRoot, listWorktrees, removeWorktree, deleteBranch, isWorktreeDirty, getCurrentBranch, } from '../lib/git.js';
|
|
8
8
|
import { resolveBranchOrPath } from '../lib/paths.js';
|
|
9
9
|
import * as out from '../lib/output.js';
|
|
10
|
+
import { fail, errors } from '../lib/errors.js';
|
|
10
11
|
async function confirm(message) {
|
|
11
12
|
const rl = createInterface({
|
|
12
13
|
input: process.stdin,
|
|
@@ -22,8 +23,7 @@ async function confirm(message) {
|
|
|
22
23
|
export async function rm(branchOrPath, options) {
|
|
23
24
|
// Check if we're in a git repo
|
|
24
25
|
if (!isGitRepo()) {
|
|
25
|
-
|
|
26
|
-
process.exit(1);
|
|
26
|
+
fail(errors.notGitRepo());
|
|
27
27
|
}
|
|
28
28
|
const repoRoot = getRepoRoot();
|
|
29
29
|
const worktrees = listWorktrees(repoRoot);
|
|
@@ -35,26 +35,18 @@ export async function rm(branchOrPath, options) {
|
|
|
35
35
|
// Resolve the worktree
|
|
36
36
|
const resolved = resolveBranchOrPath(branchOrPath, wtList, repoRoot);
|
|
37
37
|
if (!resolved) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
for (const wt of wtList) {
|
|
41
|
-
out.log(` • ${wt.branch ?? '(detached)'} → ${wt.path}`);
|
|
42
|
-
}
|
|
43
|
-
process.exit(1);
|
|
38
|
+
const available = wtList.map(w => w.branch ?? w.path);
|
|
39
|
+
fail(errors.worktreeNotFound(branchOrPath, available));
|
|
44
40
|
}
|
|
45
41
|
const { path: wtPath, branch } = resolved;
|
|
46
42
|
// Check if it's the main worktree (the original checkout)
|
|
47
43
|
if (wtPath === repoRoot) {
|
|
48
|
-
|
|
49
|
-
out.info('This is your primary repository checkout.');
|
|
50
|
-
process.exit(1);
|
|
44
|
+
fail(errors.cannotRemoveMainWorktree());
|
|
51
45
|
}
|
|
52
46
|
// Check if dirty
|
|
53
47
|
const dirty = isWorktreeDirty(wtPath);
|
|
54
48
|
if (dirty && !options.force) {
|
|
55
|
-
|
|
56
|
-
out.info('Use --force to remove anyway (changes will be lost).');
|
|
57
|
-
process.exit(1);
|
|
49
|
+
fail(errors.dirtyWorkingTree(branch ?? branchOrPath));
|
|
58
50
|
}
|
|
59
51
|
// Warn and confirm if dirty and force
|
|
60
52
|
if (dirty && options.force && !options.yes) {
|
package/dist/commands/rm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rm.js","sourceRoot":"","sources":["../../src/commands/rm.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,SAAS,EACT,WAAW,EACX,aAAa,EACb,cAAc,EACd,YAAY,EACZ,eAAe,EACf,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"rm.js","sourceRoot":"","sources":["../../src/commands/rm.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,SAAS,EACT,WAAW,EACX,aAAa,EACb,cAAc,EACd,YAAY,EACZ,eAAe,EACf,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAQhD,KAAK,UAAU,OAAO,CAAC,OAAe;IACpC,MAAM,EAAE,GAAG,eAAe,CAAC;QACzB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;IAEH,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,EAAE,CAAC,QAAQ,CAAC,GAAG,OAAO,SAAS,EAAE,CAAC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,EAAE,CAAC;YAC7B,GAAG,CAAC,IAAI,CAAC,yBAAyB,MAAM,kDAAkD,CAAC,CAAC;QAC9F,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,GAAG,CAAC,oBAAoB,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACtD,IAAI,CAAC;gBACH,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,KAAK,EAAE,QAAQ,CAAC,CAAC;gBACvD,GAAG,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;YAChC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,GAAG,CAAC,IAAI,CAAC,4BAA6B,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;gBACjE,GAAG,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;IACH,CAAC;IAED,GAAG,CAAC,OAAO,EAAE,CAAC;IACd,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC"}
|
package/dist/commands/spawn.d.ts
CHANGED
|
@@ -8,9 +8,12 @@ interface SpawnOptions {
|
|
|
8
8
|
new?: boolean;
|
|
9
9
|
path?: string;
|
|
10
10
|
base?: string;
|
|
11
|
+
baseBranch?: string;
|
|
11
12
|
mode?: SecretMode;
|
|
12
13
|
run?: string;
|
|
13
14
|
agent?: string;
|
|
15
|
+
finishOnExit?: boolean;
|
|
16
|
+
dryRun?: boolean;
|
|
14
17
|
}
|
|
15
18
|
export declare function spawn(branch: string, options: SpawnOptions): Promise<void>;
|
|
16
19
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../src/commands/spawn.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../src/commands/spawn.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAwBH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,UAAU,YAAY;IACpB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AA6GD,wBAAsB,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA4MhF"}
|
package/dist/commands/spawn.js
CHANGED
|
@@ -4,16 +4,107 @@
|
|
|
4
4
|
* Create a worktree for a branch with optional secrets handling and hooks.
|
|
5
5
|
*/
|
|
6
6
|
import { existsSync } from 'node:fs';
|
|
7
|
-
import {
|
|
7
|
+
import { spawn as spawnProcess } from 'node:child_process';
|
|
8
|
+
import { isGitRepo, getRepoRoot, getRepoName, branchExists, addWorktree, listWorktrees, runCommand, commandExists, getCurrentBranch, isDetachedHead, getDefaultBranch, } from '../lib/git.js';
|
|
8
9
|
import { getMergedConfig, configExists } from '../lib/config.js';
|
|
9
10
|
import { getDefaultWorktreePath } from '../lib/paths.js';
|
|
10
|
-
import { processSecrets } from '../lib/secrets.js';
|
|
11
|
+
import { processSecrets, generateCopyPlan, formatCopyPlan } from '../lib/secrets.js';
|
|
12
|
+
import { createSessionManifest } from '../lib/session.js';
|
|
11
13
|
import * as out from '../lib/output.js';
|
|
14
|
+
import { fail, errors } from '../lib/errors.js';
|
|
15
|
+
import { finish } from './finish.js';
|
|
16
|
+
/**
|
|
17
|
+
* Run an agent command and wait for it to exit
|
|
18
|
+
* Returns the exit code and whether it was interrupted
|
|
19
|
+
*/
|
|
20
|
+
async function runAgentWithExitHandling(command, cwd) {
|
|
21
|
+
return new Promise((resolve) => {
|
|
22
|
+
const isWindows = process.platform === 'win32';
|
|
23
|
+
const shell = isWindows ? 'cmd.exe' : '/bin/sh';
|
|
24
|
+
const shellArgs = isWindows ? ['/c', command] : ['-c', command];
|
|
25
|
+
let interrupted = false;
|
|
26
|
+
const child = spawnProcess(shell, shellArgs, {
|
|
27
|
+
cwd,
|
|
28
|
+
stdio: 'inherit',
|
|
29
|
+
env: process.env,
|
|
30
|
+
});
|
|
31
|
+
// Handle Ctrl+C gracefully
|
|
32
|
+
const sigintHandler = () => {
|
|
33
|
+
interrupted = true;
|
|
34
|
+
child.kill('SIGINT');
|
|
35
|
+
};
|
|
36
|
+
const sigtermHandler = () => {
|
|
37
|
+
interrupted = true;
|
|
38
|
+
child.kill('SIGTERM');
|
|
39
|
+
};
|
|
40
|
+
process.on('SIGINT', sigintHandler);
|
|
41
|
+
process.on('SIGTERM', sigtermHandler);
|
|
42
|
+
child.on('close', (code) => {
|
|
43
|
+
// Clean up signal handlers
|
|
44
|
+
process.removeListener('SIGINT', sigintHandler);
|
|
45
|
+
process.removeListener('SIGTERM', sigtermHandler);
|
|
46
|
+
resolve({ exitCode: code ?? 1, interrupted });
|
|
47
|
+
});
|
|
48
|
+
child.on('error', () => {
|
|
49
|
+
process.removeListener('SIGINT', sigintHandler);
|
|
50
|
+
process.removeListener('SIGTERM', sigtermHandler);
|
|
51
|
+
resolve({ exitCode: 1, interrupted });
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Show post-agent menu and handle user choice
|
|
57
|
+
*/
|
|
58
|
+
async function showPostAgentMenu(worktreePath, agentExitCode, interrupted) {
|
|
59
|
+
const readline = await import('node:readline');
|
|
60
|
+
// Change to worktree directory for finish command
|
|
61
|
+
process.chdir(worktreePath);
|
|
62
|
+
out.newline();
|
|
63
|
+
out.header('Agent Session Ended');
|
|
64
|
+
if (interrupted) {
|
|
65
|
+
out.log(out.fmt.yellow(' Agent was interrupted (Ctrl+C)'));
|
|
66
|
+
}
|
|
67
|
+
else if (agentExitCode !== 0) {
|
|
68
|
+
out.log(out.fmt.yellow(` Agent exited with error (code ${agentExitCode})`));
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
out.log(out.fmt.green(' Agent exited successfully'));
|
|
72
|
+
}
|
|
73
|
+
out.newline();
|
|
74
|
+
out.log('What would you like to do?');
|
|
75
|
+
out.log(` ${out.fmt.bold('f')}) Finish session (commit, PR, cleanup)`);
|
|
76
|
+
out.log(` ${out.fmt.bold('c')}) Cleanup only (remove worktree)`);
|
|
77
|
+
out.log(` ${out.fmt.bold('n')}) Do nothing (exit)`);
|
|
78
|
+
const rl = readline.createInterface({
|
|
79
|
+
input: process.stdin,
|
|
80
|
+
output: process.stdout,
|
|
81
|
+
});
|
|
82
|
+
const answer = await new Promise((resolve) => {
|
|
83
|
+
rl.question('Choice [f/c/n]: ', (ans) => {
|
|
84
|
+
rl.close();
|
|
85
|
+
resolve(ans.toLowerCase().trim());
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
if (answer === 'f' || answer === 'finish') {
|
|
89
|
+
// Run finish in interactive mode
|
|
90
|
+
await finish({});
|
|
91
|
+
}
|
|
92
|
+
else if (answer === 'c' || answer === 'cleanup') {
|
|
93
|
+
// Run finish with cleanup only, skip PR
|
|
94
|
+
await finish({
|
|
95
|
+
skipCommit: true,
|
|
96
|
+
cleanup: true,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
out.log(out.fmt.dim('Exiting without cleanup.'));
|
|
101
|
+
out.log(` ${out.fmt.dim('Run')} cry finish ${out.fmt.dim('later to complete the session.')}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
12
104
|
export async function spawn(branch, options) {
|
|
13
105
|
// Check if we're in a git repo
|
|
14
106
|
if (!isGitRepo()) {
|
|
15
|
-
|
|
16
|
-
process.exit(1);
|
|
107
|
+
fail(errors.notGitRepo());
|
|
17
108
|
}
|
|
18
109
|
const repoRoot = getRepoRoot();
|
|
19
110
|
const repoName = getRepoName();
|
|
@@ -35,26 +126,70 @@ export async function spawn(branch, options) {
|
|
|
35
126
|
});
|
|
36
127
|
// Check if destination already exists
|
|
37
128
|
if (existsSync(worktreePath)) {
|
|
38
|
-
|
|
39
|
-
out.info('Remove it first or choose a different path with --path');
|
|
40
|
-
process.exit(1);
|
|
129
|
+
fail(errors.destinationExists(worktreePath));
|
|
41
130
|
}
|
|
42
131
|
// Check if worktree already exists for this branch
|
|
43
132
|
const existingWorktrees = listWorktrees(repoRoot);
|
|
44
133
|
const existingForBranch = existingWorktrees.find((w) => w.branch === branch);
|
|
45
134
|
if (existingForBranch) {
|
|
46
|
-
|
|
47
|
-
out.info(`Path: ${existingForBranch.worktree}`);
|
|
48
|
-
out.info('Remove it first with: cry rm ' + branch);
|
|
49
|
-
process.exit(1);
|
|
135
|
+
fail(errors.worktreeAlreadyExists(branch, existingForBranch.worktree));
|
|
50
136
|
}
|
|
51
137
|
// Determine if we need to create the branch
|
|
52
138
|
const needsNewBranch = options.new || !branchExists(branch, repoRoot);
|
|
139
|
+
// Determine base branch with proper fallback chain:
|
|
140
|
+
// 1. User-provided --base-branch option
|
|
141
|
+
// 2. Current branch (if not detached)
|
|
142
|
+
// 3. Default branch (origin/HEAD or main/master)
|
|
143
|
+
// 4. Error if detached HEAD and no fallback
|
|
144
|
+
let baseBranch;
|
|
145
|
+
if (options.baseBranch) {
|
|
146
|
+
baseBranch = options.baseBranch;
|
|
147
|
+
}
|
|
148
|
+
else if (isDetachedHead(repoRoot)) {
|
|
149
|
+
// Try to get default branch as fallback
|
|
150
|
+
const defaultBranch = getDefaultBranch(repoRoot);
|
|
151
|
+
if (defaultBranch) {
|
|
152
|
+
baseBranch = defaultBranch;
|
|
153
|
+
out.warn(`Detached HEAD detected. Using default branch '${defaultBranch}' as base.`);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
fail(errors.detachedHead());
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
const currentBranch = getCurrentBranch(repoRoot);
|
|
161
|
+
if (currentBranch) {
|
|
162
|
+
baseBranch = currentBranch;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
// Fallback to default branch
|
|
166
|
+
const defaultBranch = getDefaultBranch(repoRoot);
|
|
167
|
+
baseBranch = defaultBranch ?? 'main';
|
|
168
|
+
}
|
|
169
|
+
}
|
|
53
170
|
out.header('Creating worktree');
|
|
54
171
|
out.log(` Branch: ${out.fmt.branch(branch)}${needsNewBranch ? out.fmt.gray(' (new)') : ''}`);
|
|
172
|
+
out.log(` Base: ${out.fmt.branch(baseBranch)}`);
|
|
55
173
|
out.log(` Path: ${out.fmt.path(worktreePath)}`);
|
|
56
174
|
out.log(` Mode: ${out.fmt.cyan(mode)}`);
|
|
57
175
|
out.newline();
|
|
176
|
+
// Handle dry-run mode
|
|
177
|
+
if (options.dryRun) {
|
|
178
|
+
out.header('Dry Run - Copy Plan');
|
|
179
|
+
if (mode === 'none') {
|
|
180
|
+
out.log(out.fmt.dim(' Secret mode is "none" — no files will be copied/symlinked'));
|
|
181
|
+
}
|
|
182
|
+
else if (config.include.length === 0) {
|
|
183
|
+
out.log(out.fmt.dim(' No include patterns configured'));
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
const plan = await generateCopyPlan(config.include, repoRoot);
|
|
187
|
+
out.log(formatCopyPlan(plan, mode));
|
|
188
|
+
}
|
|
189
|
+
out.newline();
|
|
190
|
+
out.log(out.fmt.dim('Dry run complete. No changes were made.'));
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
58
193
|
// Create the worktree
|
|
59
194
|
try {
|
|
60
195
|
addWorktree(worktreePath, branch, needsNewBranch, repoRoot);
|
|
@@ -64,6 +199,22 @@ export async function spawn(branch, options) {
|
|
|
64
199
|
out.error(`Failed to create worktree: ${error.message}`);
|
|
65
200
|
process.exit(1);
|
|
66
201
|
}
|
|
202
|
+
// Create session manifest
|
|
203
|
+
const agentChoice = options.agent ?? 'none';
|
|
204
|
+
try {
|
|
205
|
+
const session = createSessionManifest({
|
|
206
|
+
repoRoot,
|
|
207
|
+
branch,
|
|
208
|
+
baseBranch,
|
|
209
|
+
worktreePath,
|
|
210
|
+
agent: agentChoice !== 'none' ? agentChoice : undefined,
|
|
211
|
+
});
|
|
212
|
+
out.success(`Session created: ${out.fmt.dim(session.id)}`);
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
// Non-fatal: session manifest is helpful but not required
|
|
216
|
+
out.warn(`Could not create session manifest: ${error.message}`);
|
|
217
|
+
}
|
|
67
218
|
// Handle secrets
|
|
68
219
|
if (mode !== 'none' && config.include.length > 0) {
|
|
69
220
|
out.newline();
|
|
@@ -106,22 +257,34 @@ export async function spawn(branch, options) {
|
|
|
106
257
|
}
|
|
107
258
|
}
|
|
108
259
|
// Handle agent launch
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
260
|
+
if (agentChoice === 'claude' || agentChoice === 'cursor') {
|
|
261
|
+
// Determine the actual command to run
|
|
262
|
+
// For 'claude', use config.agentCommand (defaults to 'claude')
|
|
263
|
+
// For 'cursor', use 'cursor' command
|
|
264
|
+
const agentCmd = agentChoice === 'cursor' ? 'cursor' : config.agentCommand;
|
|
112
265
|
out.newline();
|
|
113
266
|
if (commandExists(agentCmd)) {
|
|
114
267
|
out.log(`Launching ${agentCmd}...`);
|
|
115
|
-
|
|
268
|
+
if (options.finishOnExit) {
|
|
269
|
+
// Use special handler that waits for exit and shows menu
|
|
270
|
+
const { exitCode, interrupted } = await runAgentWithExitHandling(agentCmd, worktreePath);
|
|
271
|
+
await showPostAgentMenu(worktreePath, exitCode, interrupted);
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
// Just run the command normally
|
|
275
|
+
await runCommand(agentCmd, worktreePath);
|
|
276
|
+
}
|
|
116
277
|
}
|
|
117
278
|
else {
|
|
118
279
|
out.warn(`Agent command '${agentCmd}' not found.`);
|
|
119
280
|
out.info('Install Claude Code: https://docs.anthropic.com/claude-code');
|
|
120
281
|
}
|
|
121
282
|
}
|
|
122
|
-
// Final summary
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
283
|
+
// Final summary (only if not using finish-on-exit, since finish handles its own output)
|
|
284
|
+
if (!options.finishOnExit || agentChoice === 'none') {
|
|
285
|
+
out.newline();
|
|
286
|
+
out.header('Worktree ready');
|
|
287
|
+
out.log(` ${out.fmt.dim('cd')} ${worktreePath}`);
|
|
288
|
+
}
|
|
126
289
|
}
|
|
127
290
|
//# sourceMappingURL=spawn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.js","sourceRoot":"","sources":["../../src/commands/spawn.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EACZ,WAAW,EACX,aAAa,EACb,UAAU,EACV,aAAa,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;AAYxC,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,MAAc,EAAE,OAAqB;IAC/D,+BAA+B;IAC/B,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;QACjB,GAAG,CAAC,KAAK,CAAC,gEAAgE,CAAC,CAAC;QAC5E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,MAAM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AAC;QAC1E,CAAC;IACH,CAAC;IAED,wFAAwF;IACxF,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,WAAW,KAAK,MAAM,EAAE,CAAC;QACpD,GAAG,CAAC,OAAO,EAAE,CAAC;QACd,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAC7B,GAAG,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,YAAY,EAAE,CAAC,CAAC;IACpD,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
* cry - Git worktrees made painless for vibecoders
|
|
4
4
|
*
|
|
5
5
|
* A CLI tool for managing git worktrees with parallel AI-agent sessions in mind.
|
|
6
|
+
*
|
|
7
|
+
* Shorthand syntax:
|
|
8
|
+
* cry <name> → cry spawn <name> --new
|
|
9
|
+
* cry <name> claude → cry spawn <name> --new --agent claude
|
|
6
10
|
*/
|
|
7
11
|
export {};
|
|
8
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;GAQG"}
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
* cry - Git worktrees made painless for vibecoders
|
|
4
4
|
*
|
|
5
5
|
* A CLI tool for managing git worktrees with parallel AI-agent sessions in mind.
|
|
6
|
+
*
|
|
7
|
+
* Shorthand syntax:
|
|
8
|
+
* cry <name> → cry spawn <name> --new
|
|
9
|
+
* cry <name> claude → cry spawn <name> --new --agent claude
|
|
6
10
|
*/
|
|
7
11
|
import { Command } from 'commander';
|
|
8
12
|
import { init } from './commands/init.js';
|
|
@@ -13,11 +17,111 @@ import { rm } from './commands/rm.js';
|
|
|
13
17
|
import { prune } from './commands/prune.js';
|
|
14
18
|
import { doctor } from './commands/doctor.js';
|
|
15
19
|
import { shell } from './commands/shell.js';
|
|
20
|
+
import { finish } from './commands/finish.js';
|
|
21
|
+
import { explainCopy } from './commands/explain-copy.js';
|
|
22
|
+
import { resume } from './commands/resume.js';
|
|
23
|
+
import { gc } from './commands/gc.js';
|
|
24
|
+
import { completions } from './commands/completions.js';
|
|
25
|
+
// Known subcommands - shorthand parsing must not interfere with these
|
|
26
|
+
const SUBCOMMANDS = new Set([
|
|
27
|
+
'init',
|
|
28
|
+
'spawn',
|
|
29
|
+
'list', 'ls',
|
|
30
|
+
'open',
|
|
31
|
+
'rm', 'remove',
|
|
32
|
+
'prune',
|
|
33
|
+
'doctor',
|
|
34
|
+
'explain-copy',
|
|
35
|
+
'shell',
|
|
36
|
+
'finish',
|
|
37
|
+
'resume',
|
|
38
|
+
'gc',
|
|
39
|
+
'completions',
|
|
40
|
+
'help',
|
|
41
|
+
]);
|
|
42
|
+
// Known agent values for shorthand parsing
|
|
43
|
+
const KNOWN_AGENTS = new Set(['claude', 'cursor', 'none']);
|
|
44
|
+
/**
|
|
45
|
+
* Check if an argument looks like an option (starts with -)
|
|
46
|
+
*/
|
|
47
|
+
function isOption(arg) {
|
|
48
|
+
return arg.startsWith('-');
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Transform shorthand syntax into explicit spawn command
|
|
52
|
+
*
|
|
53
|
+
* cry feat-auth → cry spawn feat-auth --new
|
|
54
|
+
* cry feat-auth claude → cry spawn feat-auth --new --agent claude
|
|
55
|
+
*/
|
|
56
|
+
function transformShorthand(args) {
|
|
57
|
+
// args[0] is 'node', args[1] is script path
|
|
58
|
+
// Real arguments start at index 2
|
|
59
|
+
const realArgs = args.slice(2);
|
|
60
|
+
// No arguments or first arg is an option → pass through
|
|
61
|
+
if (realArgs.length === 0 || isOption(realArgs[0])) {
|
|
62
|
+
return args;
|
|
63
|
+
}
|
|
64
|
+
const firstArg = realArgs[0];
|
|
65
|
+
// First arg is a known subcommand → pass through
|
|
66
|
+
if (SUBCOMMANDS.has(firstArg)) {
|
|
67
|
+
return args;
|
|
68
|
+
}
|
|
69
|
+
// First arg looks like a branch name → shorthand mode
|
|
70
|
+
const branchName = firstArg;
|
|
71
|
+
const remainingArgs = realArgs.slice(1);
|
|
72
|
+
// Build new args array
|
|
73
|
+
const newArgs = [args[0], args[1], 'spawn', branchName, '--new'];
|
|
74
|
+
// Check if second arg is a known agent
|
|
75
|
+
if (remainingArgs.length > 0 && KNOWN_AGENTS.has(remainingArgs[0])) {
|
|
76
|
+
const agent = remainingArgs[0];
|
|
77
|
+
newArgs.push('--agent', agent);
|
|
78
|
+
// Pass through any remaining args (options)
|
|
79
|
+
newArgs.push(...remainingArgs.slice(1));
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
// Pass through all remaining args
|
|
83
|
+
newArgs.push(...remainingArgs);
|
|
84
|
+
}
|
|
85
|
+
return newArgs;
|
|
86
|
+
}
|
|
87
|
+
// Transform arguments before Commander parses them
|
|
88
|
+
const transformedArgs = transformShorthand(process.argv);
|
|
16
89
|
const program = new Command();
|
|
17
90
|
program
|
|
18
91
|
.name('cry')
|
|
19
|
-
.description(
|
|
20
|
-
|
|
92
|
+
.description(`Git worktrees made painless for vibecoders running parallel AI-agent sessions
|
|
93
|
+
|
|
94
|
+
Shorthand syntax:
|
|
95
|
+
cry <name> Create worktree for new branch <name>
|
|
96
|
+
cry <name> claude Create worktree and launch Claude agent
|
|
97
|
+
|
|
98
|
+
Quick start:
|
|
99
|
+
cry init # Initialize in repo
|
|
100
|
+
cry feat-auth # Create worktree for new branch
|
|
101
|
+
cry feat-auth claude # Create and launch Claude agent
|
|
102
|
+
|
|
103
|
+
Workflow examples:
|
|
104
|
+
cry spawn feat-auth --new # Explicit: create new branch worktree
|
|
105
|
+
cry list # List all worktrees
|
|
106
|
+
cry open feat-auth # Open worktree in agent/editor
|
|
107
|
+
cry resume feat-auth # Resume session by name
|
|
108
|
+
cry finish # Commit, push, create PR, cleanup
|
|
109
|
+
cry rm feat-auth # Remove worktree
|
|
110
|
+
|
|
111
|
+
Finish flow (run from worktree):
|
|
112
|
+
cry finish # Interactive: commit → PR → cleanup
|
|
113
|
+
cry finish --dry-run # Preview what would happen
|
|
114
|
+
cry finish -m "Add auth" # Commit with message, create PR
|
|
115
|
+
cry finish --cleanup # Auto-cleanup after PR
|
|
116
|
+
|
|
117
|
+
Safety notes:
|
|
118
|
+
• Never auto-merges PRs
|
|
119
|
+
• Never deletes without confirmation (unless --yes)
|
|
120
|
+
• Only copies gitignored files to worktrees (secrets safety)
|
|
121
|
+
|
|
122
|
+
Shell completions:
|
|
123
|
+
cry completions fish > ~/.config/fish/completions/cry.fish`)
|
|
124
|
+
.version('1.5.0');
|
|
21
125
|
// cry init
|
|
22
126
|
program
|
|
23
127
|
.command('init')
|
|
@@ -33,9 +137,12 @@ program
|
|
|
33
137
|
.option('-n, --new', 'Create a new branch (equivalent to git worktree add -b)')
|
|
34
138
|
.option('-p, --path <dir>', 'Explicit path for the worktree')
|
|
35
139
|
.option('-b, --base <dir>', 'Base directory for worktrees')
|
|
140
|
+
.option('--base-branch <branch>', 'Base branch for PRs (default: current branch)')
|
|
36
141
|
.option('-m, --mode <mode>', 'Secret handling mode: copy, symlink, or none', 'copy')
|
|
37
142
|
.option('-r, --run <cmd>', 'Command to run after creating worktree')
|
|
38
143
|
.option('-a, --agent <agent>', 'Launch agent after setup: claude or none', 'none')
|
|
144
|
+
.option('--finish-on-exit', 'After agent exits, show finish menu (commit, PR, cleanup)')
|
|
145
|
+
.option('--dry-run', 'Show what would happen without creating the worktree')
|
|
39
146
|
.action(async (branch, options) => {
|
|
40
147
|
const mode = options.mode;
|
|
41
148
|
if (!['copy', 'symlink', 'none'].includes(mode)) {
|
|
@@ -46,9 +153,12 @@ program
|
|
|
46
153
|
new: options.new,
|
|
47
154
|
path: options.path,
|
|
48
155
|
base: options.base,
|
|
156
|
+
baseBranch: options.baseBranch,
|
|
49
157
|
mode,
|
|
50
158
|
run: options.run,
|
|
51
159
|
agent: options.agent,
|
|
160
|
+
finishOnExit: options.finishOnExit,
|
|
161
|
+
dryRun: options.dryRun,
|
|
52
162
|
});
|
|
53
163
|
});
|
|
54
164
|
// cry list
|
|
@@ -60,14 +170,21 @@ program
|
|
|
60
170
|
.action(async (options) => {
|
|
61
171
|
await list({ json: options.json });
|
|
62
172
|
});
|
|
63
|
-
// cry open
|
|
173
|
+
// cry open [branch-or-path]
|
|
64
174
|
program
|
|
65
|
-
.command('open
|
|
66
|
-
.description('Open
|
|
67
|
-
.option('-c, --cmd <cmd>', '
|
|
175
|
+
.command('open [branch-or-path]')
|
|
176
|
+
.description('Open a worktree in agent (Claude) or editor (VS Code)')
|
|
177
|
+
.option('-c, --cmd <cmd>', 'Custom command to execute in the worktree directory')
|
|
68
178
|
.option('-p, --path-only', 'Only print the path (for scripting)')
|
|
179
|
+
.option('-a, --agent', 'Open in agent (Claude Code)')
|
|
180
|
+
.option('-e, --editor', 'Open in editor (VS Code)')
|
|
69
181
|
.action(async (branchOrPath, options) => {
|
|
70
|
-
await open(branchOrPath, {
|
|
182
|
+
await open(branchOrPath, {
|
|
183
|
+
cmd: options.cmd,
|
|
184
|
+
pathOnly: options.pathOnly,
|
|
185
|
+
agent: options.agent,
|
|
186
|
+
editor: options.editor,
|
|
187
|
+
});
|
|
71
188
|
});
|
|
72
189
|
// cry rm <branch-or-path>
|
|
73
190
|
program
|
|
@@ -98,6 +215,14 @@ program
|
|
|
98
215
|
.action(async () => {
|
|
99
216
|
await doctor();
|
|
100
217
|
});
|
|
218
|
+
// cry explain-copy
|
|
219
|
+
program
|
|
220
|
+
.command('explain-copy')
|
|
221
|
+
.description('Explain which files will be copied/symlinked and which are blocked')
|
|
222
|
+
.option('-j, --json', 'Output as JSON')
|
|
223
|
+
.action(async (options) => {
|
|
224
|
+
await explainCopy({ json: options.json });
|
|
225
|
+
});
|
|
101
226
|
// cry shell
|
|
102
227
|
program
|
|
103
228
|
.command('shell')
|
|
@@ -106,6 +231,70 @@ program
|
|
|
106
231
|
.action(async (options) => {
|
|
107
232
|
await shell({ shell: options.shell });
|
|
108
233
|
});
|
|
109
|
-
//
|
|
110
|
-
program
|
|
234
|
+
// cry finish
|
|
235
|
+
program
|
|
236
|
+
.command('finish')
|
|
237
|
+
.description('Complete session: show summary, optionally create PR, and cleanup')
|
|
238
|
+
.option('-j, --json', 'Output as JSON (summary only, no actions)')
|
|
239
|
+
.option('-m, --message <msg>', 'Commit message (stages all, commits, non-interactive)')
|
|
240
|
+
.option('--skip-commit', 'Skip commit step entirely (still safe)')
|
|
241
|
+
.option('--dry-run', 'Show what would happen without executing')
|
|
242
|
+
.option('--pr', 'Force PR creation path')
|
|
243
|
+
.option('--cleanup', 'Auto-cleanup after successful PR (skip prompt)')
|
|
244
|
+
.option('--skip-cleanup', 'Skip cleanup prompt entirely')
|
|
245
|
+
.option('--non-interactive', 'Never prompt; errors on dirty unless --allow-dirty')
|
|
246
|
+
.option('--allow-dirty', 'Allow proceeding with dirty working tree in non-interactive mode')
|
|
247
|
+
.option('--delete-branch', 'Delete branch during cleanup (with --cleanup)')
|
|
248
|
+
.action(async (options) => {
|
|
249
|
+
await finish({
|
|
250
|
+
json: options.json,
|
|
251
|
+
message: options.message,
|
|
252
|
+
skipCommit: options.skipCommit,
|
|
253
|
+
dryRun: options.dryRun,
|
|
254
|
+
pr: options.pr,
|
|
255
|
+
cleanup: options.cleanup,
|
|
256
|
+
noCleanup: options.skipCleanup,
|
|
257
|
+
nonInteractive: options.nonInteractive,
|
|
258
|
+
allowDirty: options.allowDirty,
|
|
259
|
+
deleteBranch: options.deleteBranch,
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
// cry resume <nameOrId>
|
|
263
|
+
program
|
|
264
|
+
.command('resume <nameOrId>')
|
|
265
|
+
.description('Resume an existing session by branch name or session ID')
|
|
266
|
+
.option('-a, --agent <agent>', 'Launch agent in the session (e.g., claude)')
|
|
267
|
+
.option('--cd', 'Print cd command for shell copy/paste')
|
|
268
|
+
.action(async (nameOrId, options) => {
|
|
269
|
+
await resume(nameOrId, {
|
|
270
|
+
agent: options.agent,
|
|
271
|
+
cd: options.cd,
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
// cry gc
|
|
275
|
+
program
|
|
276
|
+
.command('gc')
|
|
277
|
+
.description('Clean up stale session manifests and git worktree references')
|
|
278
|
+
.option('--dry-run', 'Show what would be cleaned without making changes')
|
|
279
|
+
.option('-y, --yes', 'Skip confirmation prompts')
|
|
280
|
+
.option('--manifests-only', 'Only remove stale manifests, skip git worktree prune')
|
|
281
|
+
.action(async (options) => {
|
|
282
|
+
await gc({
|
|
283
|
+
dryRun: options.dryRun,
|
|
284
|
+
yes: options.yes,
|
|
285
|
+
manifestsOnly: options.manifestsOnly,
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
// cry completions [shell]
|
|
289
|
+
program
|
|
290
|
+
.command('completions [shell]')
|
|
291
|
+
.description('Generate shell completions (bash, zsh, fish)')
|
|
292
|
+
.option('-s, --shell <shell>', 'Shell type (bash, zsh, fish)')
|
|
293
|
+
.action(async (shell, options) => {
|
|
294
|
+
await completions(shell, {
|
|
295
|
+
shell: options.shell,
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
// Parse with transformed arguments
|
|
299
|
+
program.parse(transformedArgs);
|
|
111
300
|
//# sourceMappingURL=index.js.map
|