code-squad-cli 1.2.21 → 1.2.22

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 +50 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2261,7 +2261,11 @@ async function createWorktreeCommand(workspaceRoot, args) {
2261
2261
  if (split) {
2262
2262
  await openNewTerminal(worktreePath);
2263
2263
  } else if (process.platform === "darwin") {
2264
- await cdInCurrentTerminal(worktreePath);
2264
+ const success = await cdInCurrentTerminal(worktreePath);
2265
+ if (!success) {
2266
+ console.log(chalk2.dim("\nNote: Auto-cd may require shell function setup."));
2267
+ console.log(chalk2.dim('Run: eval "$(csq --init)"'));
2268
+ }
2265
2269
  } else {
2266
2270
  console.log(worktreePath);
2267
2271
  }
@@ -2323,6 +2327,45 @@ async function copyWorktreeFiles(sourceRoot, destRoot) {
2323
2327
  async function cdInCurrentTerminal(targetPath) {
2324
2328
  const { exec: exec2 } = await import("child_process");
2325
2329
  const escapedPath = targetPath.replace(/'/g, "'\\''");
2330
+ const termProgram = process.env.TERM_PROGRAM;
2331
+ if (termProgram === "vscode" || termProgram?.includes("cursor")) {
2332
+ console.log(targetPath);
2333
+ return true;
2334
+ }
2335
+ if (termProgram === "iTerm.app") {
2336
+ const script = `
2337
+ tell application "iTerm"
2338
+ tell current session of current window
2339
+ write text "cd '${escapedPath}'"
2340
+ end tell
2341
+ end tell`;
2342
+ return new Promise((resolve2) => {
2343
+ exec2(`osascript -e '${script}'`, (error, stdout, stderr) => {
2344
+ if (error) {
2345
+ console.log(targetPath);
2346
+ resolve2(true);
2347
+ return;
2348
+ }
2349
+ resolve2(true);
2350
+ });
2351
+ });
2352
+ }
2353
+ if (termProgram === "Apple_Terminal") {
2354
+ const terminalScript = `
2355
+ tell application "Terminal"
2356
+ do script "cd '${escapedPath}'" in front window
2357
+ end tell`;
2358
+ return new Promise((resolve2) => {
2359
+ exec2(`osascript -e '${terminalScript}'`, (error, stdout, stderr) => {
2360
+ if (error) {
2361
+ console.log(targetPath);
2362
+ resolve2(true);
2363
+ return;
2364
+ }
2365
+ resolve2(true);
2366
+ });
2367
+ });
2368
+ }
2326
2369
  const hasIterm = await new Promise((resolve2) => {
2327
2370
  exec2('mdfind "kMDItemCFBundleIdentifier == com.googlecode.iterm2"', (error, stdout) => {
2328
2371
  resolve2(!error && stdout.trim().length > 0);
@@ -2337,19 +2380,15 @@ tell application "iTerm2"
2337
2380
  end tell`;
2338
2381
  return new Promise((resolve2) => {
2339
2382
  exec2(`osascript -e '${script}'`, (error) => {
2340
- resolve2(!error);
2383
+ if (error) {
2384
+ console.log(targetPath);
2385
+ }
2386
+ resolve2(true);
2341
2387
  });
2342
2388
  });
2343
2389
  }
2344
- const terminalScript = `
2345
- tell application "Terminal"
2346
- do script "cd '${escapedPath}'" in front window
2347
- end tell`;
2348
- return new Promise((resolve2) => {
2349
- exec2(`osascript -e '${terminalScript}'`, (error) => {
2350
- resolve2(!error);
2351
- });
2352
- });
2390
+ console.log(targetPath);
2391
+ return true;
2353
2392
  }
2354
2393
  async function openNewTerminal(targetPath) {
2355
2394
  const { exec: exec2 } = await import("child_process");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-squad-cli",
3
- "version": "1.2.21",
3
+ "version": "1.2.22",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "csq": "./dist/index.js"