@maintainer-pro/ai-bridge 0.1.5 → 0.1.6
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/package.json +1 -1
- package/src/daemon.mjs +29 -8
package/package.json
CHANGED
package/src/daemon.mjs
CHANGED
|
@@ -1081,12 +1081,32 @@ function planHostJobs(dir, appUrl, hints = null) {
|
|
|
1081
1081
|
|
|
1082
1082
|
function friendlyLaunchError(raw, title) {
|
|
1083
1083
|
const text = String(raw || "").trim();
|
|
1084
|
-
if (/
|
|
1084
|
+
if (/^spawn\b.*\bENOENT\b/i.test(text)) {
|
|
1085
1085
|
return `Could not find a program to open a terminal for "${title}". ${text}`;
|
|
1086
1086
|
}
|
|
1087
1087
|
return text || `Could not open a terminal for "${title}".`;
|
|
1088
1088
|
}
|
|
1089
1089
|
|
|
1090
|
+
function writeWinLaunchScript(folder, title, command, env) {
|
|
1091
|
+
const dir = path.join(folder, ".maintainer-pro");
|
|
1092
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
1093
|
+
const safe = String(title || "app").replace(/[^a-zA-Z0-9._-]+/g, "-");
|
|
1094
|
+
const file = path.join(dir, `launch-${safe}.cmd`);
|
|
1095
|
+
const folderArg = String(folder).replace(/"/g, "");
|
|
1096
|
+
const lines = [
|
|
1097
|
+
"@echo off",
|
|
1098
|
+
`cd /d "${folderArg}"`,
|
|
1099
|
+
...Object.entries(env).map(
|
|
1100
|
+
([key, value]) => `set "${key}=${String(value).replace(/"/g, "")}"`
|
|
1101
|
+
),
|
|
1102
|
+
`title ${String(title || "Maintainer Pro").replace(/["&<>|^]/g, " ")}`,
|
|
1103
|
+
command,
|
|
1104
|
+
"if errorlevel 1 pause",
|
|
1105
|
+
];
|
|
1106
|
+
fs.writeFileSync(file, `${lines.join("\r\n")}\r\n`, "utf8");
|
|
1107
|
+
return file;
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1090
1110
|
function runLauncher(command, args, extra = {}) {
|
|
1091
1111
|
return new Promise((resolve) => {
|
|
1092
1112
|
let settled = false;
|
|
@@ -1153,9 +1173,6 @@ async function openInNewTerminal(opts) {
|
|
|
1153
1173
|
title
|
|
1154
1174
|
);
|
|
1155
1175
|
|
|
1156
|
-
const envWin = Object.entries(env)
|
|
1157
|
-
.map(([key, value]) => `set ${key}=${value}`)
|
|
1158
|
-
.join("&& ");
|
|
1159
1176
|
const envUnix = Object.entries(env)
|
|
1160
1177
|
.map(([key, value]) => `export ${key}=${JSON.stringify(String(value))}`)
|
|
1161
1178
|
.join(" && ");
|
|
@@ -1167,12 +1184,16 @@ async function openInNewTerminal(opts) {
|
|
|
1167
1184
|
const safeTitle =
|
|
1168
1185
|
String(title || "Maintainer Pro").replace(/["&<>|^]/g, " ").trim() ||
|
|
1169
1186
|
"Maintainer Pro";
|
|
1170
|
-
const
|
|
1171
|
-
|
|
1172
|
-
.join("&& ");
|
|
1187
|
+
const script = writeWinLaunchScript(folder, safeTitle, command, env);
|
|
1188
|
+
const scriptName = path.basename(script);
|
|
1173
1189
|
const opened = await runLauncher(
|
|
1174
1190
|
process.env.ComSpec || "cmd.exe",
|
|
1175
|
-
[
|
|
1191
|
+
[
|
|
1192
|
+
"/d",
|
|
1193
|
+
"/s",
|
|
1194
|
+
"/c",
|
|
1195
|
+
`start "${safeTitle}" /D "${folder}" cmd.exe /k ".maintainer-pro\\${scriptName}"`,
|
|
1196
|
+
],
|
|
1176
1197
|
{ windowsVerbatimArguments: true }
|
|
1177
1198
|
);
|
|
1178
1199
|
if (!opened.ok) {
|