code-squad-cli 1.2.2 → 1.2.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.
Files changed (2) hide show
  1. package/dist/index.js +34 -20
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1488,6 +1488,37 @@ async function writeCdFile(targetPath) {
1488
1488
  await fs10.promises.writeFile(cdFile, targetPath);
1489
1489
  }
1490
1490
  }
1491
+ async function cdInCurrentTerminal(targetPath) {
1492
+ const { exec: exec2 } = await import("child_process");
1493
+ const escapedPath = targetPath.replace(/'/g, "'\\''");
1494
+ const hasIterm = await new Promise((resolve2) => {
1495
+ exec2('mdfind "kMDItemCFBundleIdentifier == com.googlecode.iterm2"', (error, stdout) => {
1496
+ resolve2(!error && stdout.trim().length > 0);
1497
+ });
1498
+ });
1499
+ if (hasIterm) {
1500
+ const script = `
1501
+ tell application "iTerm2"
1502
+ tell current session of current window
1503
+ write text "cd '${escapedPath}'"
1504
+ end tell
1505
+ end tell`;
1506
+ return new Promise((resolve2) => {
1507
+ exec2(`osascript -e '${script}'`, (error) => {
1508
+ resolve2(!error);
1509
+ });
1510
+ });
1511
+ }
1512
+ const terminalScript = `
1513
+ tell application "Terminal"
1514
+ do script "cd '${escapedPath}'" in front window
1515
+ end tell`;
1516
+ return new Promise((resolve2) => {
1517
+ exec2(`osascript -e '${terminalScript}'`, (error) => {
1518
+ resolve2(!error);
1519
+ });
1520
+ });
1521
+ }
1491
1522
  async function openNewTerminal(targetPath) {
1492
1523
  const { exec: exec2 } = await import("child_process");
1493
1524
  const escapedPath = targetPath.replace(/'/g, "'\\''");
@@ -1508,12 +1539,7 @@ tell application "iTerm2"
1508
1539
  end tell`;
1509
1540
  return new Promise((resolve2) => {
1510
1541
  exec2(`osascript -e '${script}'`, (error) => {
1511
- if (error) {
1512
- console.error(chalk2.red("Failed to open iTerm2 split pane"));
1513
- resolve2(false);
1514
- } else {
1515
- resolve2(true);
1516
- }
1542
+ resolve2(!error);
1517
1543
  });
1518
1544
  });
1519
1545
  }
@@ -1524,26 +1550,14 @@ tell application "Terminal"
1524
1550
  end tell`;
1525
1551
  return new Promise((resolve2) => {
1526
1552
  exec2(`osascript -e '${terminalScript}'`, (error) => {
1527
- if (error) {
1528
- console.error(chalk2.red("Failed to open Terminal"));
1529
- resolve2(false);
1530
- } else {
1531
- resolve2(true);
1532
- }
1553
+ resolve2(!error);
1533
1554
  });
1534
1555
  });
1535
1556
  }
1536
1557
  async function interactiveMode(workspaceRoot) {
1537
1558
  const result = await runInteraction(workspaceRoot);
1538
1559
  if (result?.cdPath) {
1539
- if (process.env.CSQ_CD_FILE) {
1540
- console.log(result.cdPath);
1541
- } else {
1542
- console.log(chalk2.dim("\nRun this to switch:"));
1543
- console.log(chalk2.cyan(` cd "${result.cdPath}"`));
1544
- console.log(chalk2.dim("\nTip: Add to ~/.zshrc for auto-cd:"));
1545
- console.log(chalk2.dim(' eval "$(csq --init)"'));
1546
- }
1560
+ await cdInCurrentTerminal(result.cdPath);
1547
1561
  }
1548
1562
  }
1549
1563
  async function persistentInteractiveMode(workspaceRoot) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-squad-cli",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "csq": "./dist/index.js"