code-squad-cli 2.1.0 → 2.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/dist/index.js CHANGED
@@ -260,11 +260,13 @@ import { useState, useEffect, useCallback } from "react";
260
260
  import { render, Box, Text, useInput, useApp } from "ink";
261
261
  import * as path11 from "path";
262
262
  import * as os5 from "os";
263
+ import * as fs11 from "fs";
264
+ import * as tty from "tty";
263
265
  function shorten(p) {
264
266
  const home = os5.homedir();
265
267
  return p.startsWith(home) ? "~" + p.slice(home.length) : p;
266
268
  }
267
- function App({ initialWorktrees, root }) {
269
+ function App({ initialWorktrees, root, onSelect }) {
268
270
  const { exit } = useApp();
269
271
  const [view, setView] = useState("list");
270
272
  const [worktrees, setWorktrees] = useState(initialWorktrees);
@@ -292,7 +294,7 @@ function App({ initialWorktrees, root }) {
292
294
  } else if (key.downArrow) {
293
295
  setCursor((c) => Math.min(worktrees.length - 1, c + 1));
294
296
  } else if (key.return && worktrees.length > 0) {
295
- process.stdout.write(worktrees[cursor].path + "\n");
297
+ onSelect(worktrees[cursor].path);
296
298
  exit();
297
299
  } else if (ch === "n") {
298
300
  setView("create");
@@ -320,7 +322,7 @@ function App({ initialWorktrees, root }) {
320
322
  if (patterns.length > 0) {
321
323
  await copyFilesWithPatterns(root, wtPath, patterns);
322
324
  }
323
- process.stdout.write(wtPath + "\n");
325
+ onSelect(wtPath);
324
326
  exit();
325
327
  }).catch((e) => {
326
328
  setMsg({ text: e.message, color: "red" });
@@ -361,8 +363,16 @@ function App({ initialWorktrees, root }) {
361
363
  }
362
364
  async function runTui(workspaceRoot) {
363
365
  const worktrees = await git.listWorktrees(workspaceRoot);
364
- const { waitUntilExit } = render(_jsx(App, { initialWorktrees: worktrees, root: workspaceRoot }), { stdout: process.stderr });
366
+ let selectedPath = null;
367
+ const fd = fs11.openSync("/dev/tty", "w");
368
+ const ttyStream = new tty.WriteStream(fd);
369
+ const { waitUntilExit } = render(_jsx(App, { initialWorktrees: worktrees, root: workspaceRoot, onSelect: (p) => {
370
+ selectedPath = p;
371
+ } }), { stdout: ttyStream });
365
372
  await waitUntilExit();
373
+ ttyStream.destroy();
374
+ fs11.closeSync(fd);
375
+ return selectedPath;
366
376
  }
367
377
  var git;
368
378
  var init_App = __esm({
@@ -1729,8 +1739,8 @@ function formatTime() {
1729
1739
  }
1730
1740
  function getSessionId() {
1731
1741
  try {
1732
- const tty = execSync2("tty", { encoding: "utf-8" }).trim();
1733
- return tty;
1742
+ const tty2 = execSync2("tty", { encoding: "utf-8" }).trim();
1743
+ return tty2;
1734
1744
  } catch {
1735
1745
  return `session-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
1736
1746
  }
@@ -2009,7 +2019,10 @@ async function main() {
2009
2019
  default:
2010
2020
  if (process.stdin.isTTY) {
2011
2021
  const { runTui: runTui2 } = await Promise.resolve().then(() => (init_App(), App_exports));
2012
- await runTui2(workspaceRoot);
2022
+ const selectedPath = await runTui2(workspaceRoot);
2023
+ if (selectedPath) {
2024
+ process.stdout.write(selectedPath + "\n");
2025
+ }
2013
2026
  } else {
2014
2027
  await listWorktrees(workspaceRoot);
2015
2028
  }
@@ -2030,7 +2043,7 @@ csq() {
2030
2043
  fi
2031
2044
 
2032
2045
  local output
2033
- output=$(command csq "$@")
2046
+ output=$(command csq "$@" 2>&1)
2034
2047
  local exit_code=$?
2035
2048
 
2036
2049
  if [[ $exit_code -ne 0 ]]; then
package/dist/tui/App.d.ts CHANGED
@@ -1 +1 @@
1
- export declare function runTui(workspaceRoot: string): Promise<void>;
1
+ export declare function runTui(workspaceRoot: string): Promise<string | null>;
package/dist/tui/App.js CHANGED
@@ -3,6 +3,8 @@ import { useState, useEffect, useCallback } from 'react';
3
3
  import { render, Box, Text, useInput, useApp } from 'ink';
4
4
  import * as path from 'path';
5
5
  import * as os from 'os';
6
+ import * as fs from 'fs';
7
+ import * as tty from 'tty';
6
8
  import { GitAdapter } from '../adapters/GitAdapter.js';
7
9
  import { loadConfig, getWorktreeCopyPatterns } from '../config.js';
8
10
  import { copyFilesWithPatterns } from '../fileUtils.js';
@@ -11,7 +13,7 @@ function shorten(p) {
11
13
  const home = os.homedir();
12
14
  return p.startsWith(home) ? '~' + p.slice(home.length) : p;
13
15
  }
14
- function App({ initialWorktrees, root }) {
16
+ function App({ initialWorktrees, root, onSelect }) {
15
17
  const { exit } = useApp();
16
18
  const [view, setView] = useState('list');
17
19
  const [worktrees, setWorktrees] = useState(initialWorktrees);
@@ -41,7 +43,7 @@ function App({ initialWorktrees, root }) {
41
43
  setCursor(c => Math.min(worktrees.length - 1, c + 1));
42
44
  }
43
45
  else if (key.return && worktrees.length > 0) {
44
- process.stdout.write(worktrees[cursor].path + '\n');
46
+ onSelect(worktrees[cursor].path);
45
47
  exit();
46
48
  }
47
49
  else if (ch === 'n') {
@@ -73,7 +75,7 @@ function App({ initialWorktrees, root }) {
73
75
  if (patterns.length > 0) {
74
76
  await copyFilesWithPatterns(root, wtPath, patterns);
75
77
  }
76
- process.stdout.write(wtPath + '\n');
78
+ onSelect(wtPath);
77
79
  exit();
78
80
  })
79
81
  .catch((e) => {
@@ -119,6 +121,14 @@ function App({ initialWorktrees, root }) {
119
121
  }
120
122
  export async function runTui(workspaceRoot) {
121
123
  const worktrees = await git.listWorktrees(workspaceRoot);
122
- const { waitUntilExit } = render(_jsx(App, { initialWorktrees: worktrees, root: workspaceRoot }), { stdout: process.stderr });
124
+ let selectedPath = null;
125
+ // Render to /dev/tty directly — bypasses stdout/stderr capture
126
+ // so shell function's `2>&1` doesn't swallow TUI output
127
+ const fd = fs.openSync('/dev/tty', 'w');
128
+ const ttyStream = new tty.WriteStream(fd);
129
+ const { waitUntilExit } = render(_jsx(App, { initialWorktrees: worktrees, root: workspaceRoot, onSelect: (p) => { selectedPath = p; } }), { stdout: ttyStream });
123
130
  await waitUntilExit();
131
+ ttyStream.destroy();
132
+ fs.closeSync(fd);
133
+ return selectedPath;
124
134
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-squad-cli",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "csq": "./dist/index.js"