code-squad-cli 2.1.1 → 2.1.3
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/dist/index.js +29 -21
- package/dist/tui/App.d.ts +1 -1
- package/dist/tui/App.js +6 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -266,7 +266,7 @@ function shorten(p) {
|
|
|
266
266
|
const home = os5.homedir();
|
|
267
267
|
return p.startsWith(home) ? "~" + p.slice(home.length) : p;
|
|
268
268
|
}
|
|
269
|
-
function App({ initialWorktrees, root }) {
|
|
269
|
+
function App({ initialWorktrees, root, onSelect }) {
|
|
270
270
|
const { exit } = useApp();
|
|
271
271
|
const [view, setView] = useState("list");
|
|
272
272
|
const [worktrees, setWorktrees] = useState(initialWorktrees);
|
|
@@ -294,7 +294,7 @@ function App({ initialWorktrees, root }) {
|
|
|
294
294
|
} else if (key.downArrow) {
|
|
295
295
|
setCursor((c) => Math.min(worktrees.length - 1, c + 1));
|
|
296
296
|
} else if (key.return && worktrees.length > 0) {
|
|
297
|
-
|
|
297
|
+
onSelect(worktrees[cursor].path);
|
|
298
298
|
exit();
|
|
299
299
|
} else if (ch === "n") {
|
|
300
300
|
setView("create");
|
|
@@ -322,7 +322,7 @@ function App({ initialWorktrees, root }) {
|
|
|
322
322
|
if (patterns.length > 0) {
|
|
323
323
|
await copyFilesWithPatterns(root, wtPath, patterns);
|
|
324
324
|
}
|
|
325
|
-
|
|
325
|
+
onSelect(wtPath);
|
|
326
326
|
exit();
|
|
327
327
|
}).catch((e) => {
|
|
328
328
|
setMsg({ text: e.message, color: "red" });
|
|
@@ -363,12 +363,16 @@ function App({ initialWorktrees, root }) {
|
|
|
363
363
|
}
|
|
364
364
|
async function runTui(workspaceRoot) {
|
|
365
365
|
const worktrees = await git.listWorktrees(workspaceRoot);
|
|
366
|
+
let selectedPath = null;
|
|
366
367
|
const fd = fs11.openSync("/dev/tty", "w");
|
|
367
368
|
const ttyStream = new tty.WriteStream(fd);
|
|
368
|
-
const { waitUntilExit } = render(_jsx(App, { initialWorktrees: worktrees, root: workspaceRoot
|
|
369
|
+
const { waitUntilExit } = render(_jsx(App, { initialWorktrees: worktrees, root: workspaceRoot, onSelect: (p) => {
|
|
370
|
+
selectedPath = p;
|
|
371
|
+
} }), { stdout: ttyStream });
|
|
369
372
|
await waitUntilExit();
|
|
370
373
|
ttyStream.destroy();
|
|
371
374
|
fs11.closeSync(fd);
|
|
375
|
+
return selectedPath;
|
|
372
376
|
}
|
|
373
377
|
var git;
|
|
374
378
|
var init_App = __esm({
|
|
@@ -2015,7 +2019,10 @@ async function main() {
|
|
|
2015
2019
|
default:
|
|
2016
2020
|
if (process.stdin.isTTY) {
|
|
2017
2021
|
const { runTui: runTui2 } = await Promise.resolve().then(() => (init_App(), App_exports));
|
|
2018
|
-
await runTui2(workspaceRoot);
|
|
2022
|
+
const selectedPath = await runTui2(workspaceRoot);
|
|
2023
|
+
if (selectedPath) {
|
|
2024
|
+
process.stdout.write(selectedPath + "\n");
|
|
2025
|
+
}
|
|
2019
2026
|
} else {
|
|
2020
2027
|
await listWorktrees(workspaceRoot);
|
|
2021
2028
|
}
|
|
@@ -2036,22 +2043,23 @@ csq() {
|
|
|
2036
2043
|
fi
|
|
2037
2044
|
|
|
2038
2045
|
local output
|
|
2039
|
-
output=$(command csq "$@"
|
|
2046
|
+
output=$(command csq "$@")
|
|
2040
2047
|
local exit_code=$?
|
|
2041
2048
|
|
|
2042
2049
|
if [[ $exit_code -ne 0 ]]; then
|
|
2043
|
-
echo "$output"
|
|
2044
2050
|
return $exit_code
|
|
2045
2051
|
fi
|
|
2046
2052
|
|
|
2047
|
-
# \uB9C8\uC9C0\uB9C9 \uC904\uC774 \uB514\uB809\uD1A0\uB9AC\uBA74 cd
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2053
|
+
# stdout\uC758 \uB9C8\uC9C0\uB9C9 \uC904\uC774 \uB514\uB809\uD1A0\uB9AC\uBA74 cd
|
|
2054
|
+
if [[ -n "$output" ]]; then
|
|
2055
|
+
local last_line=$(echo "$output" | tail -1)
|
|
2056
|
+
if [[ -d "$last_line" ]]; then
|
|
2057
|
+
local rest=$(echo "$output" | sed '$d')
|
|
2058
|
+
[[ -n "$rest" ]] && echo "$rest"
|
|
2059
|
+
cd "$last_line"
|
|
2060
|
+
else
|
|
2061
|
+
echo "$output"
|
|
2062
|
+
fi
|
|
2055
2063
|
fi
|
|
2056
2064
|
}
|
|
2057
2065
|
`.trim();
|
|
@@ -2079,9 +2087,9 @@ async function createWorktreeCommand(workspaceRoot, args) {
|
|
|
2079
2087
|
const worktreePath = path12.join(defaultBasePath, name);
|
|
2080
2088
|
try {
|
|
2081
2089
|
await gitAdapter.createWorktree(worktreePath, name, workspaceRoot);
|
|
2082
|
-
console.
|
|
2090
|
+
console.error(chalk.green(`\u2713 Created worktree: ${name}`));
|
|
2083
2091
|
await copyWorktreeFiles(workspaceRoot, worktreePath);
|
|
2084
|
-
|
|
2092
|
+
process.stdout.write(worktreePath + "\n");
|
|
2085
2093
|
} catch (error) {
|
|
2086
2094
|
console.error(chalk.red(`Failed to create worktree: ${error.message}`));
|
|
2087
2095
|
process.exit(1);
|
|
@@ -2112,8 +2120,8 @@ async function quitWorktreeCommand() {
|
|
|
2112
2120
|
try {
|
|
2113
2121
|
await gitAdapter.removeWorktree(context.currentPath, context.mainRoot, true);
|
|
2114
2122
|
await gitAdapter.deleteBranch(context.branch, context.mainRoot, true);
|
|
2115
|
-
console.
|
|
2116
|
-
|
|
2123
|
+
console.error(chalk.green(`\u2713 Deleted worktree and branch: ${context.branch}`));
|
|
2124
|
+
process.stdout.write(context.mainRoot + "\n");
|
|
2117
2125
|
} catch (error) {
|
|
2118
2126
|
console.error(chalk.red(`Failed to quit: ${error.message}`));
|
|
2119
2127
|
process.exit(1);
|
|
@@ -2127,10 +2135,10 @@ async function copyWorktreeFiles(sourceRoot, destRoot) {
|
|
|
2127
2135
|
}
|
|
2128
2136
|
const { copied, failed } = await copyFilesWithPatterns(sourceRoot, destRoot, patterns);
|
|
2129
2137
|
if (copied.length > 0) {
|
|
2130
|
-
console.
|
|
2138
|
+
console.error(chalk.green(`\u2713 Copied ${copied.length} file(s) to worktree`));
|
|
2131
2139
|
}
|
|
2132
2140
|
if (failed.length > 0) {
|
|
2133
|
-
console.
|
|
2141
|
+
console.error(chalk.yellow(`\u26A0 Failed to copy ${failed.length} file(s)`));
|
|
2134
2142
|
}
|
|
2135
2143
|
}
|
|
2136
2144
|
main().catch((error) => {
|
package/dist/tui/App.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function runTui(workspaceRoot: string): Promise<
|
|
1
|
+
export declare function runTui(workspaceRoot: string): Promise<string | null>;
|
package/dist/tui/App.js
CHANGED
|
@@ -13,7 +13,7 @@ function shorten(p) {
|
|
|
13
13
|
const home = os.homedir();
|
|
14
14
|
return p.startsWith(home) ? '~' + p.slice(home.length) : p;
|
|
15
15
|
}
|
|
16
|
-
function App({ initialWorktrees, root }) {
|
|
16
|
+
function App({ initialWorktrees, root, onSelect }) {
|
|
17
17
|
const { exit } = useApp();
|
|
18
18
|
const [view, setView] = useState('list');
|
|
19
19
|
const [worktrees, setWorktrees] = useState(initialWorktrees);
|
|
@@ -43,7 +43,7 @@ function App({ initialWorktrees, root }) {
|
|
|
43
43
|
setCursor(c => Math.min(worktrees.length - 1, c + 1));
|
|
44
44
|
}
|
|
45
45
|
else if (key.return && worktrees.length > 0) {
|
|
46
|
-
|
|
46
|
+
onSelect(worktrees[cursor].path);
|
|
47
47
|
exit();
|
|
48
48
|
}
|
|
49
49
|
else if (ch === 'n') {
|
|
@@ -75,7 +75,7 @@ function App({ initialWorktrees, root }) {
|
|
|
75
75
|
if (patterns.length > 0) {
|
|
76
76
|
await copyFilesWithPatterns(root, wtPath, patterns);
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
onSelect(wtPath);
|
|
79
79
|
exit();
|
|
80
80
|
})
|
|
81
81
|
.catch((e) => {
|
|
@@ -121,12 +121,14 @@ function App({ initialWorktrees, root }) {
|
|
|
121
121
|
}
|
|
122
122
|
export async function runTui(workspaceRoot) {
|
|
123
123
|
const worktrees = await git.listWorktrees(workspaceRoot);
|
|
124
|
+
let selectedPath = null;
|
|
124
125
|
// Render to /dev/tty directly — bypasses stdout/stderr capture
|
|
125
126
|
// so shell function's `2>&1` doesn't swallow TUI output
|
|
126
127
|
const fd = fs.openSync('/dev/tty', 'w');
|
|
127
128
|
const ttyStream = new tty.WriteStream(fd);
|
|
128
|
-
const { waitUntilExit } = render(_jsx(App, { initialWorktrees: worktrees, root: workspaceRoot }), { stdout: ttyStream });
|
|
129
|
+
const { waitUntilExit } = render(_jsx(App, { initialWorktrees: worktrees, root: workspaceRoot, onSelect: (p) => { selectedPath = p; } }), { stdout: ttyStream });
|
|
129
130
|
await waitUntilExit();
|
|
130
131
|
ttyStream.destroy();
|
|
131
132
|
fs.closeSync(fd);
|
|
133
|
+
return selectedPath;
|
|
132
134
|
}
|