@hncode/hncode 0.8.1 → 0.8.2

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.
@@ -53,8 +53,7 @@ Do NOT use it for what you can infer from context, or for trivial decisions —
53
53
 
54
54
  Usage:
55
55
  - Users always get an "Other" option; do not create one.
56
- + 'For an answer that cannot be enumerated (a name, a path, a description), set free_text: true and omit'
57
- + ' options — the user gets a focused field instead of a list.',
56
+ For an answer that cannot be enumerated (a name, a path, a description), set free_text: true and omit options — the user gets a focused field instead of a list.
58
57
  - 2-4 distinct options per question, labels 1-5 words, descriptions carry the trade-offs. Labels unique within a question, question texts unique across the call.
59
58
  - 1-4 questions at a time, related ones grouped. multi_select allows several answers.
60
59
  - Put a recommended option first and append "(Recommended)" to its label.
package/src/tools/bash.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  import fs from 'node:fs';
7
7
  import cp from 'node:child_process';
8
- import { resolvePath, truncateBuf } from './utils.js';
8
+ import { resolvePath, truncateBuf , similarFileHint } from './utils.js';
9
9
  import { createTask, appendTaskOutput, settleTask } from '../agent-task.js';
10
10
  import { shellSpawnArgs, getShell } from './shell.js';
11
11
 
@@ -152,7 +152,7 @@ export const spec = {
152
152
  const cwdRaw = args.cwd || ctx.workspace;
153
153
  let cwd;
154
154
  try { cwd = resolvePath(cwdRaw, ctx); } catch (e) { return e.message; }
155
- if (!fs.existsSync(cwd)) return `Error: cwd does not exist: ${cwdRaw}`;
155
+ if (!fs.existsSync(cwd)) return `Error: cwd does not exist: ${cwdRaw}${similarFileHint(cwd)}. Omit cwd to use the workspace root.`;
156
156
 
157
157
  if (args.run_in_background) return spawnBackground(args, cwd, ctx);
158
158
 
@@ -372,21 +372,27 @@ function spawnBackground(args, cwd, ctx) {
372
372
  // still read it. (In the TUI the parent rarely exits, but headless -p mode
373
373
  // does, and a background job should outlive the prompt.)
374
374
  //
375
- // AN INTERACTIVE RUN CANNOT BE DETACHED. Measured on Windows: `detached: true` with piped stdout
376
- // returns exit 0 and NO output, while the same command not detached returns its output normally — the
377
- // detached process gets no working pipe back to us. Interactive needs that pipe in both directions, so
378
- // it stays attached. The trade: it will not outlive the parent, which is the same lifetime its stdin
379
- // already has.
375
+ // AND NOT ON WINDOWS AT ALL. The note above says `detached: true` with piped stdout returns exit 0 and no output; the
376
+ // same is true for a NON-interactive background command, which is the ordinary Ctrl+B case. Measured with pwsh:
377
+ //
378
+ // detached=false "exit 3" -> exit 3, output intact
379
+ // detached=true "exit 3" -> exit 0, output EMPTY
380
+ // detached=true "echo hello" -> exit 0, output EMPTY
381
+ //
382
+ // So on Windows the process stays attached: its output and its exit code are the whole point of a background task, and
383
+ // a task that reports success whatever happened is worse than one that dies with its parent. Elsewhere the detach is
384
+ // what makes a job outlive headless `-p`, so it is kept.
385
+ const canDetach = process.platform !== 'win32' && !args.interactive;
380
386
  let shell;
381
387
  try { shell = shellSpawnArgs(command, { interactive: args.interactive }); } catch (e) { return `Error: ${e.message}`; }
382
388
  const child = cp.spawn(shell.bin, shell.args, {
383
- cwd, detached: !args.interactive, stdio: [args.interactive ? 'pipe' : 'ignore', 'pipe', 'pipe'], env: { ...process.env },
389
+ cwd, detached: canDetach, stdio: [args.interactive ? 'pipe' : 'ignore', 'pipe', 'pipe'], env: { ...process.env },
384
390
  });
385
391
  const task = createTask(ctx, 'process', {
386
392
  description: args.description || args.command,
387
393
  command: args.command,
388
394
  pid: child.pid,
389
- detached: !args.interactive,
395
+ detached: canDetach,
390
396
  });
391
397
  // The stdin pipe, when the caller asked for one. Kept on the TASK so `TaskInput` can reach it from a
392
398
  // task id alone — a tool receives an id, not a handle. Only `interactive` gets here, so a plain