agent-sh 0.15.6 → 0.15.8

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 (70) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -1
  3. package/dist/agent/agent-loop.d.ts +3 -0
  4. package/dist/agent/agent-loop.js +19 -6
  5. package/dist/agent/events.d.ts +3 -0
  6. package/dist/agent/extensions/rolling-history/index.js +20 -8
  7. package/dist/agent/extensions/rolling-history/recall.d.ts +2 -2
  8. package/dist/agent/extensions/rolling-history/recall.js +17 -7
  9. package/dist/agent/host-types.d.ts +6 -0
  10. package/dist/agent/index.js +5 -1
  11. package/dist/agent/llm-client.d.ts +2 -0
  12. package/dist/agent/llm-client.js +2 -2
  13. package/dist/agent/providers/openai-compatible.d.ts +8 -0
  14. package/dist/agent/providers/openai-compatible.js +9 -2
  15. package/dist/agent/providers/openrouter.js +11 -1
  16. package/dist/agent/store.js +6 -1
  17. package/dist/agent/token-budget.d.ts +2 -1
  18. package/dist/agent/token-budget.js +6 -1
  19. package/dist/cli/index.js +1 -1
  20. package/dist/core/event-bus.d.ts +16 -1
  21. package/dist/core/event-bus.js +73 -11
  22. package/dist/core/index.js +18 -0
  23. package/dist/shell/strategies/bash.js +10 -2
  24. package/dist/shell/tui-renderer.js +115 -174
  25. package/dist/utils/executor.js +19 -11
  26. package/dist/utils/floating-panel.d.ts +1 -0
  27. package/dist/utils/floating-panel.js +28 -26
  28. package/dist/utils/markdown.js +19 -21
  29. package/dist/utils/palette.d.ts +11 -0
  30. package/dist/utils/palette.js +11 -0
  31. package/docs/agent.md +13 -11
  32. package/docs/architecture.md +3 -5
  33. package/docs/extensions.md +21 -20
  34. package/docs/library.md +6 -3
  35. package/docs/troubleshooting.md +2 -2
  36. package/docs/tui-composition.md +11 -3
  37. package/docs/usage.md +70 -50
  38. package/examples/extensions/ashi/package.json +1 -1
  39. package/examples/extensions/ashi/src/chat/assistant.ts +8 -4
  40. package/examples/extensions/ashi/src/cli.ts +8 -0
  41. package/examples/extensions/ashi/src/compaction.ts +4 -7
  42. package/examples/extensions/ashi/src/frontend.ts +6 -3
  43. package/examples/extensions/ashi/src/renderers/pi-tui/inline-image.ts +145 -0
  44. package/examples/extensions/ashi/src/renderers/pi-tui/nodes.ts +51 -1
  45. package/examples/extensions/ashi/src/schema.ts +8 -2
  46. package/examples/extensions/ashi/src/user-shell-intents.ts +4 -1
  47. package/examples/extensions/command-suggest.ts +4 -0
  48. package/examples/extensions/latex-images.ts +152 -7
  49. package/examples/extensions/solarized-theme.ts +11 -0
  50. package/package.json +1 -1
  51. package/src/agent/agent-loop.ts +19 -6
  52. package/src/agent/events.ts +1 -0
  53. package/src/agent/extensions/rolling-history/index.ts +20 -8
  54. package/src/agent/extensions/rolling-history/recall.ts +28 -7
  55. package/src/agent/host-types.ts +2 -0
  56. package/src/agent/index.ts +7 -1
  57. package/src/agent/llm-client.ts +4 -2
  58. package/src/agent/providers/openai-compatible.ts +19 -4
  59. package/src/agent/providers/openrouter.ts +10 -1
  60. package/src/agent/store.ts +5 -1
  61. package/src/agent/token-budget.ts +10 -1
  62. package/src/cli/index.ts +1 -1
  63. package/src/core/event-bus.ts +67 -12
  64. package/src/core/index.ts +18 -0
  65. package/src/shell/strategies/bash.ts +10 -2
  66. package/src/shell/tui-renderer.ts +130 -207
  67. package/src/utils/executor.ts +17 -14
  68. package/src/utils/floating-panel.ts +24 -22
  69. package/src/utils/markdown.ts +17 -20
  70. package/src/utils/palette.ts +30 -5
@@ -352,27 +352,24 @@ export class MarkdownRenderer {
352
352
  private renderLine(line: string): string {
353
353
  if (line.trim() === "") return "";
354
354
 
355
- // Headings
356
- const h1 = line.match(/^# (.+)/);
357
- if (h1) return `${p.bold}${p.warning}${h1[1]}${p.reset}`;
358
-
359
- const h2 = line.match(/^## (.+)/);
360
- if (h2) return `${p.bold}${p.accent}${h2[1]}${p.reset}`;
361
-
362
- const h3 = line.match(/^### (.+)/);
363
- if (h3) return `${p.bold}${h3[1]}${p.reset}`;
364
-
365
- const h4 = line.match(/^#{4,} (.+)/);
366
- if (h4) return `${p.bold}${h4[1]}${p.reset}`;
355
+ // Headings — H3+ keep the `###` marker; H1/H2 don't
356
+ const heading = line.match(/^(#{1,6}) (.+)/);
357
+ if (heading) {
358
+ const level = heading[1]!.length;
359
+ const text = heading[2]!;
360
+ if (level === 1) return `${p.bold}${p.underline}${p.mdHeading}${text}${p.reset}`;
361
+ if (level === 2) return `${p.bold}${p.mdHeading}${text}${p.reset}`;
362
+ return `${p.bold}${p.mdHeading}${"#".repeat(level)} ${text}${p.reset}`;
363
+ }
367
364
 
368
- // Horizontal rule — subtle short separator, not full-width
365
+ // Horizontal rule
369
366
  if (/^(-{3,}|_{3,}|\*{3,})\s*$/.test(line)) {
370
- return "";
367
+ return `${p.mdHr}${"".repeat(Math.min(this.contentWidth, 80))}${p.reset}`;
371
368
  }
372
369
 
373
370
  // Blockquote
374
371
  const bq = line.match(/^>\s?(.*)/);
375
- if (bq) return `${p.muted}│${p.reset} ${p.dim}${p.italic}${this.renderInline(bq[1] || "")}${p.reset}`;
372
+ if (bq) return `${p.mdQuoteBorder}│${p.reset} ${p.mdQuote}${p.italic}${this.renderInline(bq[1] || "")}${p.reset}`;
376
373
 
377
374
  // Task list (checkbox items) — must come before generic unordered list
378
375
  const task = line.match(/^(\s*)[*\-+]\s+\[([ xX])\]\s+(.*)/);
@@ -389,14 +386,14 @@ export class MarkdownRenderer {
389
386
  const ul = line.match(/^(\s*)[*\-+]\s+(.*)/);
390
387
  if (ul) {
391
388
  const indent = ul[1] || "";
392
- return `${indent} ${p.accent}*${p.reset} ${this.renderInline(ul[2] || "")}`;
389
+ return `${indent} ${p.mdListBullet}-${p.reset} ${this.renderInline(ul[2] || "")}`;
393
390
  }
394
391
 
395
392
  // Ordered list
396
393
  const ol = line.match(/^(\s*)(\d+)[.)]\s+(.*)/);
397
394
  if (ol) {
398
395
  const indent = ol[1] || "";
399
- return `${indent} ${p.accent}${ol[2]}.${p.reset} ${this.renderInline(ol[3] || "")}`;
396
+ return `${indent} ${p.mdListBullet}${ol[2]}.${p.reset} ${this.renderInline(ol[3] || "")}`;
400
397
  }
401
398
 
402
399
  return this.renderInline(line);
@@ -406,10 +403,10 @@ export class MarkdownRenderer {
406
403
  // Links first — later subs inject `\x1b[…m` whose `[` would be eaten here.
407
404
  text = text.replace(
408
405
  /\[([^\]]+)\]\(([^)]+)\)/g,
409
- `$1 ${p.muted}${p.underline}($2)${p.reset}`
406
+ `${p.mdLink}${p.underline}$1${p.reset} ${p.mdLinkUrl}($2)${p.reset}`
410
407
  );
411
408
  // Inline code
412
- text = text.replace(/`([^`]+)`/g, `${p.accent}$1${p.reset}`);
409
+ text = text.replace(/`([^`]+)`/g, `${p.mdCode}$1${p.reset}`);
413
410
  // Bold + italic
414
411
  text = text.replace(/\*\*\*(.+?)\*\*\*/g, `${p.bold}${p.italic}$1${p.reset}`);
415
412
  // Bold
@@ -419,7 +416,7 @@ export class MarkdownRenderer {
419
416
  text = text.replace(/\*(.+?)\*/g, `${p.italic}$1${p.reset}`);
420
417
  text = text.replace(/(?<!\w)_(.+?)_(?!\w)/g, `${p.italic}$1${p.reset}`);
421
418
  // Strikethrough
422
- text = text.replace(/~~(.+?)~~/g, `${p.dim}$1${p.reset}`);
419
+ text = text.replace(/~~(.+?)~~/g, `${p.strikethrough}$1${p.reset}`);
423
420
  return text;
424
421
  }
425
422
 
@@ -29,7 +29,20 @@ export interface ColorPalette {
29
29
  dim: string;
30
30
  italic: string;
31
31
  underline: string;
32
+ strikethrough: string;
32
33
  reset: string;
34
+
35
+ // ── Markdown element colors ───────────────────────────────
36
+ mdHeading: string; // headings (all levels)
37
+ mdLink: string; // link text
38
+ mdLinkUrl: string; // link URL
39
+ mdCode: string; // inline code span
40
+ mdCodeBlock: string; // fenced code fallback (no highlight)
41
+ mdCodeBlockBorder: string; // code fence / language label
42
+ mdQuote: string; // blockquote text
43
+ mdQuoteBorder: string; // blockquote left bar
44
+ mdHr: string; // horizontal rule
45
+ mdListBullet: string; // list bullet / ordinal
33
46
  }
34
47
 
35
48
  const defaultPalette: ColorPalette = {
@@ -45,11 +58,23 @@ const defaultPalette: ColorPalette = {
45
58
  errorBgEmph: "\x1b[48;2;124;50;64m",
46
59
  diffText: "\x1b[97m", // bright white — readable on the red/green tints
47
60
 
48
- bold: "\x1b[1m",
49
- dim: "\x1b[2m",
50
- italic: "\x1b[3m",
51
- underline: "\x1b[4m",
52
- reset: "\x1b[0m",
61
+ bold: "\x1b[1m",
62
+ dim: "\x1b[2m",
63
+ italic: "\x1b[3m",
64
+ underline: "\x1b[4m",
65
+ strikethrough: "\x1b[9m",
66
+ reset: "\x1b[0m",
67
+
68
+ mdHeading: "\x1b[38;2;240;198;116m", // #f0c674 gold
69
+ mdLink: "\x1b[38;2;129;162;190m", // #81a2be blue
70
+ mdLinkUrl: "\x1b[38;2;102;102;102m", // #666666 dim gray
71
+ mdCode: "\x1b[38;2;138;190;183m", // #8abeb7 teal
72
+ mdCodeBlock: "\x1b[38;2;181;189;104m", // #b5bd68 green
73
+ mdCodeBlockBorder: "\x1b[38;2;128;128;128m", // #808080 gray
74
+ mdQuote: "\x1b[38;2;128;128;128m", // #808080 gray
75
+ mdQuoteBorder: "\x1b[38;2;128;128;128m", // #808080 gray
76
+ mdHr: "\x1b[38;2;128;128;128m", // #808080 gray
77
+ mdListBullet: "\x1b[38;2;138;190;183m", // #8abeb7 teal
53
78
  };
54
79
 
55
80
  /** Active palette — import and use directly in components. */