@hncode/hncode 0.5.2 → 0.5.5

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 (45) hide show
  1. package/package.json +38 -38
  2. package/src/agent.js +172 -19
  3. package/src/cache.js +175 -130
  4. package/src/clipboard.js +69 -2
  5. package/src/config.js +10 -3
  6. package/src/index.js +29 -5
  7. package/src/keybindings.js +25 -3
  8. package/src/llm.js +54 -6
  9. package/src/mcp.js +419 -384
  10. package/src/plugin.js +95 -10
  11. package/src/remote.js +307 -289
  12. package/src/session-hub.js +37 -0
  13. package/src/settings-schema.js +2 -0
  14. package/src/shell-safety.js +610 -562
  15. package/src/swarm-progress.js +1 -1
  16. package/src/team/mailbox.js +216 -139
  17. package/src/team/permission.js +121 -0
  18. package/src/team/protocol.js +167 -0
  19. package/src/team/runner.js +127 -12
  20. package/src/team/spawn.js +63 -5
  21. package/src/team/store.js +31 -4
  22. package/src/team/tasks.js +15 -2
  23. package/src/team/team.js +51 -16
  24. package/src/team-panel.js +418 -20
  25. package/src/term-caps.js +457 -410
  26. package/src/term.js +142 -26
  27. package/src/tool-result.js +50 -2
  28. package/src/tools/agent.js +464 -436
  29. package/src/tools/bash.js +53 -14
  30. package/src/tools/diagnostics.js +13 -0
  31. package/src/tools/edit.js +727 -577
  32. package/src/tools/fetch-url.js +118 -5
  33. package/src/tools/glob.js +5 -3
  34. package/src/tools/grep.js +19 -5
  35. package/src/tools/ignore.js +17 -3
  36. package/src/tools/index.js +17 -3
  37. package/src/tools/read.js +13 -2
  38. package/src/tools/shell.js +145 -134
  39. package/src/tools/tasks.js +214 -141
  40. package/src/tools/team.js +13 -0
  41. package/src/tools/utils.js +12 -3
  42. package/src/tools/web-search.js +85 -34
  43. package/src/tui.js +2089 -714
  44. package/src/update.js +38 -3
  45. package/src/web.js +47 -1
@@ -128,6 +128,32 @@ function snapshotRow(msg) {
128
128
  if (Object.keys(a).length) out.toolArgs = a;
129
129
  }
130
130
  if (Array.isArray(msg.diff)) out.diff = msg.diff.slice(0, 400);
131
+ // The same pieces `formatToolLine` composes, as data rather than as ANSI.
132
+ if (out.role === 'tool') {
133
+ const verb = msg.pending ? 'Using' : 'Used';
134
+ const name = out.toolName || 'tool';
135
+ // The identifying argument, by the same key order the line uses. `toolArgs` above already holds
136
+ // only the short, displayable ones.
137
+ const arg = out.toolArgs
138
+ ? (out.toolArgs.command || out.toolArgs.cmd || out.toolArgs.path || out.toolArgs.file_path
139
+ || out.toolArgs.pattern || out.toolArgs.query || out.toolArgs.url || out.toolArgs.description || '')
140
+ : '';
141
+ const summary = arg ? `${verb} ${name} (${arg})` : `${verb} ${name}`;
142
+ let added = 0;
143
+ let removed = 0;
144
+ if (Array.isArray(msg.diff)) for (const d of msg.diff) {
145
+ if (d && (d.type === 'add' || d.type === '+')) added++;
146
+ else if (d && (d.type === 'del' || d.type === '-')) removed++;
147
+ }
148
+ out.display = {
149
+ verb,
150
+ tool: name,
151
+ arg: arg ? String(arg).slice(0, 400) : '',
152
+ summary,
153
+ status: msg.pending ? 'running' : (msg.failed ? 'failed' : 'done'),
154
+ diff: (added || removed) ? { added, removed } : null,
155
+ };
156
+ }
131
157
  if (msg.card && typeof msg.card === 'object') {
132
158
  out.card = { phase: msg.card.phase, headline: msg.card.headline, detail: msg.card.detail };
133
159
  }
@@ -235,6 +261,15 @@ export class SessionHub {
235
261
  * Returns nothing; failures here must never affect rendering.
236
262
  */
237
263
  syncChat(chat) {
264
+ // NOBODY IS WATCHING, SO NOTHING IS BUILT.
265
+ //
266
+ // `/web` starts a server, but a browser may never connect — and this ran on every frame regardless,
267
+ // walking the whole transcript to build rows no one would read. Measured on a 300-message transcript:
268
+ // 8.8ms per frame with zero subscribers, which is most of a 60fps budget spent on nothing.
269
+ //
270
+ // The rows are rebuilt from scratch on the next sync after a client connects (it starts with no rows
271
+ // and `_rowFp` empty), so skipping here costs one frame of latency at connect time and nothing else.
272
+ if (this.subscribers.size === 0) return;
238
273
  const list = Array.isArray(chat) ? chat : [];
239
274
  const seen = new Set();
240
275
  for (let i = 0; i < list.length; i++) {
@@ -256,6 +291,7 @@ export class SessionHub {
256
291
  this.rows.push(row);
257
292
  this._rowById.set(id, row);
258
293
  this.emit({ type: 'row', row });
294
+ this._rowFp.set(id, fp);
259
295
  } else if (known !== fp) {
260
296
  const target = this._rowById.get(id);
261
297
  // The WHOLE row's renderable fields, not a text delta.
@@ -275,6 +311,7 @@ export class SessionHub {
275
311
  const patch = snapshotRow(msg);
276
312
  if (target) Object.assign(target, patch);
277
313
  this.emit({ type: 'row_patch', id, patch });
314
+ this._rowFp.set(id, fp);
278
315
  }
279
316
  }
280
317
  // The TUI rebuilds `state.chat` wholesale on /compact and on session resume.
@@ -79,6 +79,8 @@ export const SETTINGS_SCHEMA = [
79
79
  ui: { tab: 'appearance', group: 'Display', label: 'Calm mode', hint: 'Fewer decorative flourishes; keeps the information, drops the animation' } },
80
80
  { key: 'reduced_motion', ...bool(false),
81
81
  ui: { tab: 'appearance', group: 'Motion', label: 'Reduced motion', hint: 'No sweeps or pulses — for a terminal over a slow link, or a preference' } },
82
+ { key: 'render_fps', kind: 'int', default: '30',
83
+ ui: { tab: 'appearance', group: 'Performance', label: 'Render FPS', hint: 'How often the screen is repainted. 0 means 1 — a terminal cannot render at zero. Higher is smoother and costs more CPU' } },
82
84
  { key: 'shimmer_edge', ...bool(true),
83
85
  ui: { tab: 'appearance', group: 'Motion', label: 'Shimmer edge', hint: 'The travelling highlight on a running tool name' } },
84
86
  { key: 'show_tool_details', ...bool(true),