@hncode/hncode 0.8.1 → 0.8.3

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.
Files changed (52) hide show
  1. package/README.md +18 -0
  2. package/README_CN.md +14 -0
  3. package/bin/hncode +54 -8
  4. package/package.json +1 -1
  5. package/src/agent-task.js +356 -337
  6. package/src/agent.js +1465 -1405
  7. package/src/animate.js +56 -0
  8. package/src/colors.js +615 -593
  9. package/src/config.js +50 -7
  10. package/src/context-bar.js +280 -278
  11. package/src/doctor.js +4 -3
  12. package/src/file-tree.js +4 -3
  13. package/src/highlight.js +20 -6
  14. package/src/i18n.js +1432 -389
  15. package/src/image-row.js +11 -2
  16. package/src/index.js +218 -6
  17. package/src/keybindings.js +2 -1
  18. package/src/llm.js +146 -21
  19. package/src/log-file.js +112 -0
  20. package/src/markdown.js +646 -567
  21. package/src/mcp-server.js +409 -0
  22. package/src/mcp.js +279 -29
  23. package/src/memory-profile.js +19 -16
  24. package/src/migrate-index.js +175 -0
  25. package/src/migrate.js +392 -0
  26. package/src/panels.js +9 -7
  27. package/src/plan.js +7 -5
  28. package/src/plugin.js +37 -21
  29. package/src/registry-browser.js +17 -15
  30. package/src/rows-plan-bg.js +3 -2
  31. package/src/rows-status.js +20 -6
  32. package/src/rows-tool-result.js +242 -208
  33. package/src/screen-paint.js +153 -128
  34. package/src/session-recover.js +317 -0
  35. package/src/session.js +203 -13
  36. package/src/settings-schema.js +9 -0
  37. package/src/swarm-progress.js +6 -2
  38. package/src/tasks-browser.js +37 -36
  39. package/src/team-panel.js +12 -11
  40. package/src/term.js +57 -21
  41. package/src/text.js +254 -149
  42. package/src/tool-line.js +7 -2
  43. package/src/tool-result.js +400 -327
  44. package/src/tools/agent.js +7 -2
  45. package/src/tools/ask-user-question.js +1 -2
  46. package/src/tools/bash.js +446 -434
  47. package/src/tools/edit.js +653 -665
  48. package/src/tools/goal.js +130 -93
  49. package/src/tools/read.js +141 -133
  50. package/src/tools/tasks.js +214 -214
  51. package/src/tools/utils.js +143 -104
  52. package/src/tui.js +20887 -19942
package/src/doctor.js CHANGED
@@ -23,6 +23,7 @@
23
23
  // "fixes" something is a diagnostic nobody can run on a machine they care about. The
24
24
  // only outbound work is an optional reachability probe, which the caller opts into.
25
25
 
26
+ import { uiText } from './i18n.js';
26
27
  import fs from 'node:fs';
27
28
  import os from 'node:os';
28
29
  import path from 'node:path';
@@ -58,7 +59,7 @@ function checkConfig(cfg, files) {
58
59
  'Run /model to choose one, or /provider add <name> <base-url>.'));
59
60
  }
60
61
  if (!cfg.model) {
61
- out.push(check('model', 'error', 'no model selected', 'Run /model.'));
62
+ out.push(check('model', 'error', 'no model selected', uiText('Run /model.')));
62
63
  }
63
64
  if (!cfg.apiKey) {
64
65
  // A local endpoint (ollama, llama.cpp, lmstudio) legitimately has no key.
@@ -196,7 +197,7 @@ function checkMcp(servers, connections) {
196
197
  for (const n of names) {
197
198
  const conn = byName.get(n);
198
199
  if (!conn) out.push(check(`MCP ${n}`, 'warn', 'configured but not started', 'Restart, or check the server command.'));
199
- else if (!conn.ok) out.push(check(`MCP ${n}`, 'error', `failed: ${conn.error}`, 'Fix the command/URL in /mcp-config.'));
200
+ else if (!conn.ok) out.push(check(`MCP ${n}`, 'error', `failed: ${conn.error}`, uiText('Fix the command/URL in /mcp-config.')));
200
201
  else out.push(check(`MCP ${n}`, 'ok', `${conn.toolCount} tool(s)`));
201
202
  }
202
203
  return out;
@@ -517,7 +518,7 @@ export function formatDoctor(results, opts = {}) {
517
518
  if (!n.error && !n.warn) {
518
519
  lines.push('', 'No problems found.');
519
520
  } else {
520
- lines.push('', 'Run /doctor --all to include the passing checks.');
521
+ lines.push('', uiText('Run /doctor --all to include the passing checks.'));
521
522
  }
522
523
  return lines;
523
524
  }
package/src/file-tree.js CHANGED
@@ -23,6 +23,7 @@
23
23
  import path from 'node:path';
24
24
  import { C } from './colors.js';
25
25
  import { visualWidth } from './term.js';
26
+ import { uiText } from './i18n.js';
26
27
 
27
28
  const ELLIPSIS = '\u2026';
28
29
  const ESC = '\x1b';
@@ -153,11 +154,11 @@ export function renderTree(input) {
153
154
 
154
155
  const total = root.children.length ? countFiles(root) : 0;
155
156
  const title = filter
156
- ? `Files matching "${filter}" — ${total} file(s)`
157
- : `Files — ${total} file(s)`;
157
+ ? uiText(`Files matching "${filter}" — ${total} file(s)`)
158
+ : uiText(`Files — ${total} file(s)`);
158
159
  // Deliberately terse: the full phrasing ("↑↓ move · →/← open/close · Enter insert path ·
159
160
  // Ctrl+O expand all · Esc close") is 71 columns and got clipped mid-word at 70.
160
- const hint = '↑↓ move · →/← open · Enter insert · Ctrl+O all · Esc close';
161
+ const hint = uiText('↑↓ move · →/← open · Enter insert · Ctrl+O all · Esc close');
161
162
 
162
163
  const lines = [];
163
164
  // The header and the hint are clamped to the panel like every other row. Unclamped, a
package/src/highlight.js CHANGED
@@ -938,17 +938,31 @@ export function langForPath(p) {
938
938
  function colorFor(kind) {
939
939
  switch (kind) {
940
940
  case 'keyword': return C.cyan;
941
+ // NUMBERS ARE NOT LITERALS, and they are not comments either.
942
+ //
943
+ // This used to return `C.heading`, the same colour `literal` gets — so `42` and `true` were one family when one is
944
+ // a value you scan for and the other is a word. Worse, on the dark theme `heading` (200,210,220) sits within about
945
+ // 30 of `comment` (184,189,191) in every channel, so a number read as dim as a comment.
946
+ //
947
+ // Orange is already the theme's "attention without alarm" accent, and it is far enough from cyan, green and the
948
+ // comment grey to be picked out at a glance.
949
+ case 'number': return C.orange;
941
950
  case 'literal': return C.heading;
942
951
  case 'string': return C.diffAddFg;
943
952
  // COMMENTS ARE DERIVED FROM THE FOREGROUND, not from the theme's grey.
944
953
  //
945
- // `C.gray` is tuned to sit quiet against the PAGE background, and in several themes it lands almost exactly on
946
- // the diff wash — dracula and tokyo came out at a brightness difference of 3 to 5, which is invisible. A comment
947
- // is the one token that has to stay readable ON the wash, so it comes from `C.comment`, which `setTheme` mixes
948
- // from the palette's foreground: quiet, but always far enough from whatever is behind it.
954
+ // `C.gray` is tuned to sit quiet against the PAGE background, and in several themes it lands almost exactly on the
955
+ // diff wash — dracula and tokyo came out at a brightness difference of 3 to 5, which is invisible. A comment is the
956
+ // one token that has to stay readable ON the wash, so it comes from `C.comment`: quiet, but always far enough from
957
+ // whatever is behind it.
949
958
  case 'comment': return C.comment;
950
- case 'number': return C.heading;
951
- case 'func': return C.cyan;
959
+ // A FUNCTION NAME IS NOT A KEYWORD.
960
+ //
961
+ // Both were `C.cyan`, which made `function` and the name after it one undifferentiated run: the reader could not
962
+ // tell the syntax from the thing being called, and a call site (`foo(x)`) read as if `foo` were built in.
963
+ // `C.spring` is the palette's second cool accent — same family as the keyword colour, so the line still reads as
964
+ // code, and far enough from it to separate the two roles.
965
+ case 'func': return C.spring;
952
966
  case 'attr': return C.orange;
953
967
  default: return '';
954
968
  }