docdex 0.2.5 → 0.2.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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Changelog
2
2
 
3
- ## 0.2.5
3
+ ## 0.2.6
4
4
  - Added glama support
5
5
 
6
6
  ## 0.1.10
@@ -383,10 +383,14 @@ function hasInteractiveTty(stdin, stdout) {
383
383
 
384
384
  function canPromptWithTty(stdin, stdout) {
385
385
  if (hasInteractiveTty(stdin, stdout)) return true;
386
- const ttyPath = process.platform === "win32" ? "CONIN$" : "/dev/tty";
386
+ const isWindows = process.platform === "win32";
387
+ const inputPath = isWindows ? "CONIN$" : "/dev/tty";
388
+ const outputPath = isWindows ? "CONOUT$" : "/dev/tty";
387
389
  try {
388
- const fd = fs.openSync(ttyPath, "r");
389
- fs.closeSync(fd);
390
+ const readFd = fs.openSync(inputPath, "r");
391
+ const writeFd = fs.openSync(outputPath, "w");
392
+ fs.closeSync(readFd);
393
+ fs.closeSync(writeFd);
390
394
  return true;
391
395
  } catch {
392
396
  return false;
@@ -403,9 +407,9 @@ function resolveOllamaInstallMode({
403
407
  if (override === true) return { mode: "install", reason: "env", interactive: false };
404
408
  if (override === false) return { mode: "skip", reason: "env", interactive: false };
405
409
  if (!canPrompt(stdin, stdout)) {
410
+ if (env.CI) return { mode: "skip", reason: "ci", interactive: false };
406
411
  return { mode: "skip", reason: "non_interactive", interactive: false };
407
412
  }
408
- if (env.CI) return { mode: "skip", reason: "ci", interactive: false };
409
413
  return { mode: "prompt", reason: "interactive", interactive: true };
410
414
  }
411
415
 
@@ -421,9 +425,9 @@ function resolveOllamaModelPromptMode({
421
425
  const assumeYes = parseEnvBool(env.DOCDEX_OLLAMA_MODEL_ASSUME_Y);
422
426
  if (assumeYes === true) return { mode: "auto", reason: "env", interactive: false };
423
427
  if (!canPrompt(stdin, stdout)) {
428
+ if (env.CI) return { mode: "skip", reason: "ci", interactive: false };
424
429
  return { mode: "skip", reason: "non_interactive", interactive: false };
425
430
  }
426
- if (env.CI) return { mode: "skip", reason: "ci", interactive: false };
427
431
  return { mode: "prompt", reason: "interactive", interactive: true };
428
432
  }
429
433
 
@@ -585,10 +589,19 @@ function resolvePromptStreams(stdin, stdout) {
585
589
  return { input: stdin, output: stdout, close: null };
586
590
  }
587
591
  const isWindows = process.platform === "win32";
588
- const ttyPath = isWindows ? "CONIN$" : "/dev/tty";
592
+ const inputPath = isWindows ? "CONIN$" : "/dev/tty";
593
+ const outputPath = isWindows ? "CONOUT$" : "/dev/tty";
589
594
  try {
590
- const input = fs.createReadStream(ttyPath, { autoClose: true });
591
- return { input, output: stdout, close: () => input.close() };
595
+ const input = fs.createReadStream(inputPath, { autoClose: true });
596
+ const output = fs.createWriteStream(outputPath, { autoClose: true });
597
+ return {
598
+ input,
599
+ output,
600
+ close: () => {
601
+ input.close();
602
+ output.end();
603
+ }
604
+ };
592
605
  } catch {
593
606
  return { input: stdin, output: stdout, close: null };
594
607
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docdex",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Docdex CLI as an npm-installable binary wrapper.",
5
5
  "bin": {
6
6
  "docdex": "bin/docdex.js",