adhdev 0.1.10 → 0.1.11

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 +115 -46
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -810,16 +810,16 @@ async function injectTokenToIDE(ide, connectionToken) {
810
810
  try {
811
811
  const os2 = await import("os");
812
812
  const fs = await import("fs");
813
- const path = await import("path");
813
+ const path2 = await import("path");
814
814
  const platform3 = os2.platform();
815
815
  const home = os2.homedir();
816
816
  const getSettingsPath = (appName2) => {
817
817
  if (platform3 === "darwin") {
818
- return path.join(home, "Library", "Application Support", appName2, "User", "settings.json");
818
+ return path2.join(home, "Library", "Application Support", appName2, "User", "settings.json");
819
819
  } else if (platform3 === "win32") {
820
- return path.join(process.env.APPDATA || path.join(home, "AppData", "Roaming"), appName2, "User", "settings.json");
820
+ return path2.join(process.env.APPDATA || path2.join(home, "AppData", "Roaming"), appName2, "User", "settings.json");
821
821
  } else {
822
- return path.join(home, ".config", appName2, "User", "settings.json");
822
+ return path2.join(home, ".config", appName2, "User", "settings.json");
823
823
  }
824
824
  };
825
825
  const appNameMap = {
@@ -841,7 +841,7 @@ async function injectTokenToIDE(ide, connectionToken) {
841
841
  settings = {};
842
842
  }
843
843
  } else {
844
- fs.mkdirSync(path.dirname(settingsPath), { recursive: true });
844
+ fs.mkdirSync(path2.dirname(settingsPath), { recursive: true });
845
845
  }
846
846
  settings["adhdev.connectionToken"] = connectionToken;
847
847
  settings["adhdev.autoConnect"] = true;
@@ -948,6 +948,7 @@ async function suggestGlobalInstall() {
948
948
  var import_child_process3 = require("child_process");
949
949
  var net = __toESM(require("net"));
950
950
  var os = __toESM(require("os"));
951
+ var path = __toESM(require("path"));
951
952
  var CDP_PORTS = {
952
953
  cursor: [9333, 9334],
953
954
  antigravity: [9335, 9336],
@@ -965,12 +966,12 @@ var MAC_APP_IDENTIFIERS = {
965
966
  vscodium: "VSCodium"
966
967
  };
967
968
  var WIN_PROCESS_NAMES = {
968
- cursor: "Cursor.exe",
969
- antigravity: "Antigravity.exe",
970
- vscode: "Code.exe",
971
- windsurf: "Windsurf.exe",
972
- "vscode-insiders": "Code - Insiders.exe",
973
- vscodium: "VSCodium.exe"
969
+ cursor: ["Cursor.exe"],
970
+ antigravity: ["Antigravity.exe"],
971
+ vscode: ["Code.exe"],
972
+ windsurf: ["Windsurf.exe"],
973
+ "vscode-insiders": ["Code - Insiders.exe"],
974
+ vscodium: ["VSCodium.exe"]
974
975
  };
975
976
  async function findFreePort(ports) {
976
977
  for (const port2 of ports) {
@@ -1018,11 +1019,11 @@ async function isCdpActive(port) {
1018
1019
  });
1019
1020
  }
1020
1021
  async function killIdeProcess(ideId) {
1021
- const platform3 = os.platform();
1022
+ const plat = os.platform();
1022
1023
  const appName = MAC_APP_IDENTIFIERS[ideId];
1023
- const winProcess = WIN_PROCESS_NAMES[ideId];
1024
+ const winProcesses = WIN_PROCESS_NAMES[ideId];
1024
1025
  try {
1025
- if (platform3 === "darwin" && appName) {
1026
+ if (plat === "darwin" && appName) {
1026
1027
  try {
1027
1028
  (0, import_child_process3.execSync)(`osascript -e 'tell application "${appName}" to quit' 2>/dev/null`, {
1028
1029
  timeout: 5e3
@@ -1033,9 +1034,18 @@ async function killIdeProcess(ideId) {
1033
1034
  } catch {
1034
1035
  }
1035
1036
  }
1036
- } else if (platform3 === "win32" && winProcess) {
1037
+ } else if (plat === "win32" && winProcesses) {
1038
+ for (const proc of winProcesses) {
1039
+ try {
1040
+ (0, import_child_process3.execSync)(`taskkill /IM "${proc}" /F 2>nul`, { timeout: 5e3 });
1041
+ } catch {
1042
+ }
1043
+ }
1037
1044
  try {
1038
- (0, import_child_process3.execSync)(`taskkill /IM "${winProcess}" /F 2>nul`, { timeout: 5e3 });
1045
+ const exeName = winProcesses[0].replace(".exe", "");
1046
+ (0, import_child_process3.execSync)(`powershell -Command "Get-Process -Name '${exeName}' -ErrorAction SilentlyContinue | Stop-Process -Force"`, {
1047
+ timeout: 1e4
1048
+ });
1039
1049
  } catch {
1040
1050
  }
1041
1051
  } else {
@@ -1048,15 +1058,17 @@ async function killIdeProcess(ideId) {
1048
1058
  await new Promise((r) => setTimeout(r, 500));
1049
1059
  if (!isIdeRunning(ideId)) return true;
1050
1060
  }
1051
- if (platform3 === "darwin" && appName) {
1061
+ if (plat === "darwin" && appName) {
1052
1062
  try {
1053
1063
  (0, import_child_process3.execSync)(`pkill -9 -f "${appName}" 2>/dev/null`);
1054
1064
  } catch {
1055
1065
  }
1056
- } else if (platform3 === "win32" && winProcess) {
1057
- try {
1058
- (0, import_child_process3.execSync)(`taskkill /IM "${winProcess}" /F 2>nul`);
1059
- } catch {
1066
+ } else if (plat === "win32" && winProcesses) {
1067
+ for (const proc of winProcesses) {
1068
+ try {
1069
+ (0, import_child_process3.execSync)(`taskkill /IM "${proc}" /F 2>nul`);
1070
+ } catch {
1071
+ }
1060
1072
  }
1061
1073
  }
1062
1074
  await new Promise((r) => setTimeout(r, 2e3));
@@ -1066,18 +1078,33 @@ async function killIdeProcess(ideId) {
1066
1078
  }
1067
1079
  }
1068
1080
  function isIdeRunning(ideId) {
1069
- const platform3 = os.platform();
1081
+ const plat = os.platform();
1070
1082
  try {
1071
- if (platform3 === "darwin") {
1083
+ if (plat === "darwin") {
1072
1084
  const appName = MAC_APP_IDENTIFIERS[ideId];
1073
1085
  if (!appName) return false;
1074
1086
  const result = (0, import_child_process3.execSync)(`pgrep -f "${appName}" 2>/dev/null`, { encoding: "utf-8" });
1075
1087
  return result.trim().length > 0;
1076
- } else if (platform3 === "win32") {
1077
- const winProc = WIN_PROCESS_NAMES[ideId];
1078
- if (!winProc) return false;
1079
- const result = (0, import_child_process3.execSync)(`tasklist /FI "IMAGENAME eq ${winProc}" /NH 2>nul`, { encoding: "utf-8" });
1080
- return result.includes(winProc);
1088
+ } else if (plat === "win32") {
1089
+ const winProcesses = WIN_PROCESS_NAMES[ideId];
1090
+ if (!winProcesses) return false;
1091
+ for (const proc of winProcesses) {
1092
+ try {
1093
+ const result = (0, import_child_process3.execSync)(`tasklist /FI "IMAGENAME eq ${proc}" /NH 2>nul`, { encoding: "utf-8" });
1094
+ if (result.includes(proc)) return true;
1095
+ } catch {
1096
+ }
1097
+ }
1098
+ try {
1099
+ const exeName = winProcesses[0].replace(".exe", "");
1100
+ const result = (0, import_child_process3.execSync)(
1101
+ `powershell -Command "(Get-Process -Name '${exeName}' -ErrorAction SilentlyContinue).Count"`,
1102
+ { encoding: "utf-8", timeout: 5e3 }
1103
+ );
1104
+ return parseInt(result.trim()) > 0;
1105
+ } catch {
1106
+ }
1107
+ return false;
1081
1108
  } else {
1082
1109
  const result = (0, import_child_process3.execSync)(`pgrep -f "${ideId}" 2>/dev/null`, { encoding: "utf-8" });
1083
1110
  return result.trim().length > 0;
@@ -1087,18 +1114,50 @@ function isIdeRunning(ideId) {
1087
1114
  }
1088
1115
  }
1089
1116
  function detectCurrentWorkspace(ideId) {
1090
- const platform3 = os.platform();
1091
- if (platform3 !== "darwin") return void 0;
1092
- try {
1093
- const appName = MAC_APP_IDENTIFIERS[ideId];
1094
- if (!appName) return void 0;
1095
- const result = (0, import_child_process3.execSync)(
1096
- `lsof -c "${appName}" 2>/dev/null | grep cwd | head -1 | awk '{print $NF}'`,
1097
- { encoding: "utf-8", timeout: 3e3 }
1098
- );
1099
- const dir = result.trim();
1100
- if (dir && dir !== "/") return dir;
1101
- } catch {
1117
+ const plat = os.platform();
1118
+ if (plat === "darwin") {
1119
+ try {
1120
+ const appName = MAC_APP_IDENTIFIERS[ideId];
1121
+ if (!appName) return void 0;
1122
+ const result = (0, import_child_process3.execSync)(
1123
+ `lsof -c "${appName}" 2>/dev/null | grep cwd | head -1 | awk '{print $NF}'`,
1124
+ { encoding: "utf-8", timeout: 3e3 }
1125
+ );
1126
+ const dir = result.trim();
1127
+ if (dir && dir !== "/") return dir;
1128
+ } catch {
1129
+ }
1130
+ } else if (plat === "win32") {
1131
+ try {
1132
+ const fs = require("fs");
1133
+ const appNameMap = {
1134
+ vscode: "Code",
1135
+ cursor: "Cursor",
1136
+ antigravity: "Antigravity",
1137
+ windsurf: "Windsurf",
1138
+ vscodium: "VSCodium"
1139
+ };
1140
+ const appName = appNameMap[ideId];
1141
+ if (appName) {
1142
+ const storagePath = path.join(
1143
+ process.env.APPDATA || path.join(os.homedir(), "AppData", "Roaming"),
1144
+ appName,
1145
+ "storage.json"
1146
+ );
1147
+ if (fs.existsSync(storagePath)) {
1148
+ const data = JSON.parse(fs.readFileSync(storagePath, "utf-8"));
1149
+ const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
1150
+ if (workspaces.length > 0) {
1151
+ const recent = workspaces[0];
1152
+ const uri = typeof recent === "string" ? recent : recent?.folderUri;
1153
+ if (uri?.startsWith("file:///")) {
1154
+ return decodeURIComponent(uri.replace("file:///", ""));
1155
+ }
1156
+ }
1157
+ }
1158
+ }
1159
+ } catch {
1160
+ }
1102
1161
  }
1103
1162
  return void 0;
1104
1163
  }
@@ -1227,12 +1286,22 @@ async function launchWindows(ide, port, workspace, newWindow) {
1227
1286
  }
1228
1287
  const args = ["--remote-debugging-port=" + port];
1229
1288
  if (newWindow) args.push("--new-window");
1230
- if (workspace) args.push(workspace);
1231
- (0, import_child_process3.spawn)(cli, args, {
1232
- detached: true,
1233
- stdio: "ignore",
1234
- shell: true
1235
- }).unref();
1289
+ if (workspace) args.push(`"${workspace}"`);
1290
+ const isCmd = cli.endsWith(".cmd") || cli.endsWith(".bat");
1291
+ if (isCmd) {
1292
+ const cmdLine = `start "" /b "${cli}" ${args.join(" ")}`;
1293
+ (0, import_child_process3.spawn)("cmd", ["/c", cmdLine], {
1294
+ detached: true,
1295
+ stdio: "ignore",
1296
+ windowsHide: true
1297
+ }).unref();
1298
+ } else {
1299
+ (0, import_child_process3.spawn)(cli, args, {
1300
+ detached: true,
1301
+ stdio: "ignore",
1302
+ shell: false
1303
+ }).unref();
1304
+ }
1236
1305
  }
1237
1306
  async function launchLinux(ide, port, workspace, newWindow) {
1238
1307
  const cli = ide.cliCommand;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adhdev",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "ADHDev CLI — Detect, install and configure your IDE + AI agent extensions",
5
5
  "main": "dist/index.js",
6
6
  "bin": {