@hncode/hncode 0.8.0 → 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.
- package/README.md +18 -0
- package/README_CN.md +14 -0
- package/package.json +1 -1
- package/src/agent-task.js +354 -337
- package/src/agent.js +19 -3
- package/src/animate.js +35 -0
- package/src/clipboard.js +54 -5
- package/src/config.js +25 -7
- package/src/file-tree.js +4 -3
- package/src/highlight.js +20 -6
- package/src/i18n.js +825 -0
- package/src/image-row.js +11 -2
- package/src/index.js +730 -610
- package/src/llm.js +146 -21
- package/src/log-file.js +112 -0
- package/src/markdown.js +619 -567
- package/src/migrate-index.js +175 -0
- package/src/migrate.js +392 -0
- package/src/panels.js +9 -7
- package/src/rows-plan-bg.js +3 -2
- package/src/rows-status.js +20 -6
- package/src/rows-tool-result.js +35 -8
- package/src/screen-paint.js +153 -128
- package/src/session-recover.js +317 -0
- package/src/session.js +203 -13
- package/src/swarm-progress.js +5 -1
- package/src/tasks-browser.js +9 -8
- package/src/team-panel.js +12 -11
- package/src/text.js +192 -149
- package/src/tool-line.js +7 -2
- package/src/tool-result.js +400 -327
- package/src/tools/ask-user-question.js +1 -2
- package/src/tools/bash.js +23 -11
- package/src/tools/edit.js +640 -665
- package/src/tools/goal.js +130 -93
- package/src/tools/read.js +141 -133
- package/src/tools/shell.js +28 -2
- package/src/tools/tasks.js +214 -214
- package/src/tools/utils.js +143 -104
- package/src/tui.js +20689 -19943
|
@@ -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
|
-
|
|
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,9 +5,9 @@
|
|
|
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
|
-
import { shellSpawnArgs } from './shell.js';
|
|
10
|
+
import { shellSpawnArgs, getShell } from './shell.js';
|
|
11
11
|
|
|
12
12
|
// kimi-code's timeout policy (agent-core-v2/agent/tools/os/bash/bash.ts).
|
|
13
13
|
export const DEFAULT_TIMEOUT_S = 60;
|
|
@@ -127,7 +127,13 @@ function killTree(child, opts = {}) {
|
|
|
127
127
|
|
|
128
128
|
export const spec = {
|
|
129
129
|
name: 'Bash',
|
|
130
|
-
|
|
130
|
+
// The shell is named at runtime, not baked in: the model is told which syntax it is writing against, and on a POSIX
|
|
131
|
+
// box "via pwsh" was both wrong and an invitation to emit PowerShell.
|
|
132
|
+
get description() {
|
|
133
|
+
const shell = getShell();
|
|
134
|
+
const which = shell ? (shell.edition === 'posix' ? 'the POSIX shell' : shell.name) : 'the system shell';
|
|
135
|
+
return `Run a shell command via ${which}. Returns combined stdout+stderr. timeout default 60s (max 300s); run_in_background detaches and returns a task id.`;
|
|
136
|
+
},
|
|
131
137
|
parameters: {
|
|
132
138
|
type: 'object',
|
|
133
139
|
properties: {
|
|
@@ -146,7 +152,7 @@ export const spec = {
|
|
|
146
152
|
const cwdRaw = args.cwd || ctx.workspace;
|
|
147
153
|
let cwd;
|
|
148
154
|
try { cwd = resolvePath(cwdRaw, ctx); } catch (e) { return e.message; }
|
|
149
|
-
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.`;
|
|
150
156
|
|
|
151
157
|
if (args.run_in_background) return spawnBackground(args, cwd, ctx);
|
|
152
158
|
|
|
@@ -366,21 +372,27 @@ function spawnBackground(args, cwd, ctx) {
|
|
|
366
372
|
// still read it. (In the TUI the parent rarely exits, but headless -p mode
|
|
367
373
|
// does, and a background job should outlive the prompt.)
|
|
368
374
|
//
|
|
369
|
-
//
|
|
370
|
-
//
|
|
371
|
-
//
|
|
372
|
-
//
|
|
373
|
-
//
|
|
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;
|
|
374
386
|
let shell;
|
|
375
387
|
try { shell = shellSpawnArgs(command, { interactive: args.interactive }); } catch (e) { return `Error: ${e.message}`; }
|
|
376
388
|
const child = cp.spawn(shell.bin, shell.args, {
|
|
377
|
-
cwd, detached:
|
|
389
|
+
cwd, detached: canDetach, stdio: [args.interactive ? 'pipe' : 'ignore', 'pipe', 'pipe'], env: { ...process.env },
|
|
378
390
|
});
|
|
379
391
|
const task = createTask(ctx, 'process', {
|
|
380
392
|
description: args.description || args.command,
|
|
381
393
|
command: args.command,
|
|
382
394
|
pid: child.pid,
|
|
383
|
-
detached:
|
|
395
|
+
detached: canDetach,
|
|
384
396
|
});
|
|
385
397
|
// The stdin pipe, when the caller asked for one. Kept on the TASK so `TaskInput` can reach it from a
|
|
386
398
|
// task id alone — a tool receives an id, not a handle. Only `interactive` gets here, so a plain
|