@adhdev/daemon-core 0.7.20 → 0.7.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.
package/dist/index.js CHANGED
@@ -563,7 +563,7 @@ var init_logger = __esm({
563
563
  LEVEL_NUM = { debug: 0, info: 1, warn: 2, error: 3 };
564
564
  LEVEL_LABEL = { debug: "DBG", info: "INF", warn: "WRN", error: "ERR" };
565
565
  currentLevel = "info";
566
- LOG_DIR = process.platform === "darwin" ? path3.join(os4.homedir(), "Library", "Logs", "adhdev") : path3.join(os4.homedir(), ".local", "share", "adhdev", "logs");
566
+ LOG_DIR = process.platform === "win32" ? path3.join(process.env.LOCALAPPDATA || process.env.APPDATA || path3.join(os4.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path3.join(os4.homedir(), "Library", "Logs", "adhdev") : path3.join(os4.homedir(), ".local", "share", "adhdev", "logs");
567
567
  MAX_LOG_SIZE = 5 * 1024 * 1024;
568
568
  MAX_LOG_DAYS = 7;
569
569
  try {
@@ -955,6 +955,9 @@ function looksLikeMachOOrElf(filePath) {
955
955
  }
956
956
  function shSingleQuote(arg) {
957
957
  if (/^[a-zA-Z0-9@%_+=:,./-]+$/.test(arg)) return arg;
958
+ if (os12.platform() === "win32") {
959
+ return `"${arg.replace(/"/g, '""')}"`;
960
+ }
958
961
  return `'${arg.replace(/'/g, `'\\''`)}'`;
959
962
  }
960
963
  function estimatePromptDisplayLines(text, cols = 100) {
@@ -8281,7 +8284,7 @@ init_logger();
8281
8284
  var fs6 = __toESM(require("fs"));
8282
8285
  var path8 = __toESM(require("path"));
8283
8286
  var os9 = __toESM(require("os"));
8284
- var LOG_DIR2 = process.platform === "darwin" ? path8.join(os9.homedir(), "Library", "Logs", "adhdev") : path8.join(os9.homedir(), ".local", "share", "adhdev", "logs");
8287
+ var LOG_DIR2 = process.platform === "win32" ? path8.join(process.env.LOCALAPPDATA || process.env.APPDATA || path8.join(os9.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path8.join(os9.homedir(), "Library", "Logs", "adhdev") : path8.join(os9.homedir(), ".local", "share", "adhdev", "logs");
8285
8288
  var MAX_FILE_SIZE = 5 * 1024 * 1024;
8286
8289
  var MAX_DAYS = 7;
8287
8290
  try {
@@ -13339,17 +13342,20 @@ async function handleAutoImplement(ctx, type, req, res) {
13339
13342
  const interactiveFlags = ["--yolo", "--interactive", "-i"];
13340
13343
  const baseArgs = [...spawn3.args || []].filter((a) => !interactiveFlags.includes(a));
13341
13344
  let shellCmd;
13345
+ const isWin = os15.platform() === "win32";
13346
+ const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
13342
13347
  if (command === "claude") {
13343
13348
  const args = [...baseArgs, "--dangerously-skip-permissions"];
13344
13349
  if (model) args.push("--model", model);
13345
- const escapedArgs = args.map((a) => `'${a.replace(/'/g, "'\\''")}'`).join(" ");
13350
+ const escapedArgs = args.map(escapeArg).join(" ");
13346
13351
  const metaPrompt = `Read the file at ${promptFile} and follow ALL the instructions. Implement the specific function requested, then test it via CDP curl targeting 127.0.0.1:19280, wait for confirmation of success, and then close. DO NOT start working on other features not listed in the prompt constraint.`;
13347
- shellCmd = `${command} ${escapedArgs} -p "${metaPrompt}"`;
13352
+ shellCmd = `${command} ${escapedArgs} -p ${escapeArg(metaPrompt)}`;
13348
13353
  } else if (command === "gemini") {
13349
13354
  const args = [...baseArgs, "-y", "-s", "false"];
13350
13355
  if (model) args.push("-m", model);
13351
- const escapedArgs = args.map((a) => `'${a.replace(/'/g, "'\\''")}'`).join(" ");
13352
- shellCmd = `${command} ${escapedArgs} -p "Read the file at ${promptFile} and follow ALL the instructions in it exactly. Do not ask questions, just execute."`;
13356
+ const escapedArgs = args.map(escapeArg).join(" ");
13357
+ const metaPrompt = `Read the file at ${promptFile} and follow ALL the instructions in it exactly. Do not ask questions, just execute.`;
13358
+ shellCmd = `${command} ${escapedArgs} -p ${escapeArg(metaPrompt)}`;
13353
13359
  } else if (command === "codex") {
13354
13360
  const args = ["exec", ...baseArgs];
13355
13361
  if (!args.includes("--dangerously-bypass-approvals-and-sandbox")) {
@@ -13359,12 +13365,16 @@ async function handleAutoImplement(ctx, type, req, res) {
13359
13365
  args.push("--skip-git-repo-check");
13360
13366
  }
13361
13367
  if (model) args.push("--model", model);
13362
- const escapedArgs = args.map((a) => `'${a.replace(/'/g, "'\\''")}'`).join(" ");
13368
+ const escapedArgs = args.map(escapeArg).join(" ");
13363
13369
  const metaPrompt = `Read the file at ${promptFile} and follow ALL instructions strictly. DO NOT spend time exploring the filesystem or other providers. You have full authority to implement ALL required script files and independently test them against 127.0.0.1:19280 via CDP CURL. Upon complete validation of ALL assigned files, print exactly "_PIPELINE_COMPLETE_SIGNAL_" to gracefully close the pipeline. DO NOT WAIT FOR APPROVAL, execute completely autonomously.`;
13364
- shellCmd = `${command} ${escapedArgs} "${metaPrompt}"`;
13370
+ shellCmd = `${command} ${escapedArgs} ${escapeArg(metaPrompt)}`;
13365
13371
  } else {
13366
- const escapedArgs = baseArgs.map((a) => `'${a.replace(/'/g, "'\\''")}'`).join(" ");
13367
- shellCmd = `cat '${promptFile}' | ${command} ${escapedArgs}`;
13372
+ const escapedArgs = baseArgs.map(escapeArg).join(" ");
13373
+ if (isWin) {
13374
+ shellCmd = `type "${promptFile}" | ${command} ${escapedArgs}`;
13375
+ } else {
13376
+ shellCmd = `cat '${promptFile}' | ${command} ${escapedArgs}`;
13377
+ }
13368
13378
  }
13369
13379
  sendAutoImplSSE(ctx, { event: "progress", data: { function: "_init", status: "spawning", message: `Spawning agent: ${shellCmd.substring(0, 200)}... (prompt: ${prompt.length} chars)` } });
13370
13380
  ctx.autoImplStatus = { running: true, type, progress: [] };
@@ -13375,8 +13385,8 @@ async function handleAutoImplement(ctx, type, req, res) {
13375
13385
  try {
13376
13386
  const pty3 = require("node-pty");
13377
13387
  ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
13378
- const isWin = os15.platform() === "win32";
13379
- child = pty3.spawn(isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin ? "/c" : "-c", shellCmd], {
13388
+ const isWin2 = os15.platform() === "win32";
13389
+ child = pty3.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
13380
13390
  name: "xterm-256color",
13381
13391
  cols: 120,
13382
13392
  rows: 40,
@@ -13386,7 +13396,7 @@ async function handleAutoImplement(ctx, type, req, res) {
13386
13396
  isPty = true;
13387
13397
  } catch (err) {
13388
13398
  ctx.log(`PTY not available, using child_process: ${err.message}`);
13389
- child = spawnFn("sh", ["-c", shellCmd], {
13399
+ child = spawnFn(isWin ? "cmd.exe" : "sh", [isWin ? "/c" : "-c", shellCmd], {
13390
13400
  cwd: providerDir,
13391
13401
  shell: false,
13392
13402
  timeout: 9e5,