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.
- package/LICENSE +21 -0
- package/README.md +1 -1
- package/dist/agent/agent-loop.d.ts +3 -0
- package/dist/agent/agent-loop.js +19 -6
- package/dist/agent/events.d.ts +3 -0
- package/dist/agent/extensions/rolling-history/index.js +20 -8
- package/dist/agent/extensions/rolling-history/recall.d.ts +2 -2
- package/dist/agent/extensions/rolling-history/recall.js +17 -7
- package/dist/agent/host-types.d.ts +6 -0
- package/dist/agent/index.js +5 -1
- package/dist/agent/llm-client.d.ts +2 -0
- package/dist/agent/llm-client.js +2 -2
- package/dist/agent/providers/openai-compatible.d.ts +8 -0
- package/dist/agent/providers/openai-compatible.js +9 -2
- package/dist/agent/providers/openrouter.js +11 -1
- package/dist/agent/store.js +6 -1
- package/dist/agent/token-budget.d.ts +2 -1
- package/dist/agent/token-budget.js +6 -1
- package/dist/cli/index.js +1 -1
- package/dist/core/event-bus.d.ts +16 -1
- package/dist/core/event-bus.js +73 -11
- package/dist/core/index.js +18 -0
- package/dist/shell/strategies/bash.js +10 -2
- package/dist/shell/tui-renderer.js +115 -174
- package/dist/utils/executor.js +19 -11
- package/dist/utils/floating-panel.d.ts +1 -0
- package/dist/utils/floating-panel.js +28 -26
- package/dist/utils/markdown.js +19 -21
- package/dist/utils/palette.d.ts +11 -0
- package/dist/utils/palette.js +11 -0
- package/docs/agent.md +13 -11
- package/docs/architecture.md +3 -5
- package/docs/extensions.md +21 -20
- package/docs/library.md +6 -3
- package/docs/troubleshooting.md +2 -2
- package/docs/tui-composition.md +11 -3
- package/docs/usage.md +70 -50
- package/examples/extensions/ashi/package.json +1 -1
- package/examples/extensions/ashi/src/chat/assistant.ts +8 -4
- package/examples/extensions/ashi/src/cli.ts +8 -0
- package/examples/extensions/ashi/src/compaction.ts +4 -7
- package/examples/extensions/ashi/src/frontend.ts +6 -3
- package/examples/extensions/ashi/src/renderers/pi-tui/inline-image.ts +145 -0
- package/examples/extensions/ashi/src/renderers/pi-tui/nodes.ts +51 -1
- package/examples/extensions/ashi/src/schema.ts +8 -2
- package/examples/extensions/ashi/src/user-shell-intents.ts +4 -1
- package/examples/extensions/command-suggest.ts +4 -0
- package/examples/extensions/latex-images.ts +152 -7
- package/examples/extensions/solarized-theme.ts +11 -0
- package/package.json +1 -1
- package/src/agent/agent-loop.ts +19 -6
- package/src/agent/events.ts +1 -0
- package/src/agent/extensions/rolling-history/index.ts +20 -8
- package/src/agent/extensions/rolling-history/recall.ts +28 -7
- package/src/agent/host-types.ts +2 -0
- package/src/agent/index.ts +7 -1
- package/src/agent/llm-client.ts +4 -2
- package/src/agent/providers/openai-compatible.ts +19 -4
- package/src/agent/providers/openrouter.ts +10 -1
- package/src/agent/store.ts +5 -1
- package/src/agent/token-budget.ts +10 -1
- package/src/cli/index.ts +1 -1
- package/src/core/event-bus.ts +67 -12
- package/src/core/index.ts +18 -0
- package/src/shell/strategies/bash.ts +10 -2
- package/src/shell/tui-renderer.ts +130 -207
- package/src/utils/executor.ts +17 -14
- package/src/utils/floating-panel.ts +24 -22
- package/src/utils/markdown.ts +17 -20
- package/src/utils/palette.ts +30 -5
package/src/utils/markdown.ts
CHANGED
|
@@ -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
|
|
357
|
-
if (
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
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.
|
|
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.
|
|
419
|
+
text = text.replace(/~~(.+?)~~/g, `${p.strikethrough}$1${p.reset}`);
|
|
423
420
|
return text;
|
|
424
421
|
}
|
|
425
422
|
|
package/src/utils/palette.ts
CHANGED
|
@@ -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:
|
|
49
|
-
dim:
|
|
50
|
-
italic:
|
|
51
|
-
underline:
|
|
52
|
-
|
|
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. */
|