mini-coder 0.7.4 → 0.8.1

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 (49) hide show
  1. package/AGENTS.md +114 -0
  2. package/README.md +53 -66
  3. package/bin/mini-coder.ts +2 -0
  4. package/demo.gif +0 -0
  5. package/package.json +17 -20
  6. package/src/agent.ts +193 -272
  7. package/src/auth.ts +84 -0
  8. package/src/cli.ts +99 -0
  9. package/src/config.ts +179 -0
  10. package/src/prompt.ts +54 -207
  11. package/src/session.ts +124 -69
  12. package/src/tools/bash.ts +86 -0
  13. package/src/tools/common.ts +32 -0
  14. package/src/tools/edit.ts +41 -0
  15. package/src/tools/index.ts +47 -0
  16. package/src/tools/read.ts +64 -0
  17. package/src/tui/commands.ts +199 -0
  18. package/src/tui/complete.ts +85 -0
  19. package/src/tui/editor.ts +320 -0
  20. package/src/tui/highlight.ts +189 -0
  21. package/src/tui/stream.ts +142 -0
  22. package/src/tui/styles.ts +20 -0
  23. package/src/tui/term.ts +436 -0
  24. package/src/tui/theme.ts +120 -0
  25. package/src/tui/tui.ts +758 -0
  26. package/src/tui/usage.ts +67 -0
  27. package/tsconfig.json +8 -8
  28. package/bin/mc.ts +0 -11
  29. package/bun.lock +0 -350
  30. package/nono-mini-coder.json +0 -42
  31. package/src/args.ts +0 -252
  32. package/src/error-handling.test.ts +0 -163
  33. package/src/git.ts +0 -23
  34. package/src/headless.ts +0 -66
  35. package/src/index.ts +0 -43
  36. package/src/models.ts +0 -191
  37. package/src/oauth.ts +0 -147
  38. package/src/shared.ts +0 -119
  39. package/src/themes.ts +0 -234
  40. package/src/tool-bash.ts +0 -77
  41. package/src/tool-edit.ts +0 -121
  42. package/src/tool-read.ts +0 -100
  43. package/src/tui-components.ts +0 -127
  44. package/src/tui-conversation.ts +0 -218
  45. package/src/tui-editor.ts +0 -29
  46. package/src/tui-overlay.ts +0 -604
  47. package/src/tui.ts +0 -314
  48. package/src/types.ts +0 -194
  49. package/src/update.ts +0 -171
@@ -0,0 +1,120 @@
1
+ /**
2
+ * The one palette: the TokyoNight `night` slots the TUI uses, from
3
+ * `folke/tokyonight.nvim` (`lua/tokyonight/colors/night.lua` and its generated
4
+ * highlight groups). Every colour the TUI writes comes from here, foreground and
5
+ * background alike, so no row can fall back to the terminal's own colours.
6
+ * Truecolor only.
7
+ */
8
+ export const PALETTE = {
9
+ bg: "#1a1b26",
10
+ fg: "#c0caf5",
11
+ fg_dark: "#a9b1d6",
12
+ comment: "#565f89",
13
+ terminal_black: "#414868",
14
+ blue: "#7aa2f7",
15
+ blue1: "#2ac3de",
16
+ blue5: "#89ddff",
17
+ green: "#9ece6a",
18
+ green1: "#73daca",
19
+ magenta: "#bb9af7",
20
+ orange: "#ff9e64",
21
+ purple: "#9d7cd8",
22
+ red: "#f7768e",
23
+ teal: "#1abc9c",
24
+ yellow: "#e0af68",
25
+ } as const;
26
+
27
+ /** `Normal`: the pair every row is painted with, and restored to. */
28
+ export const NORMAL_FG = PALETTE.fg;
29
+ export const NORMAL_BG = PALETTE.bg;
30
+
31
+ /** Diff row backgrounds, from the `DiffAdd`/`DiffDelete` groups. */
32
+ export const DIFF_ADD = "#243e4a";
33
+ export const DIFF_DELETE = "#4a272f";
34
+
35
+ /** `r;g;b` for one `#rrggbb`. */
36
+ export function channels(hex: string): string {
37
+ return [1, 3, 5].map((i) => Number.parseInt(hex.slice(i, i + 2), 16)).join(";");
38
+ }
39
+
40
+ /**
41
+ * Explicit colour, never a reset: a `39`/`49` or a `0` would hand the rest of
42
+ * the row back to the host terminal, which is the leak this palette closes.
43
+ */
44
+ export function sgrFg(hex: string): string {
45
+ return `\x1b[38;2;${channels(hex)}m`;
46
+ }
47
+
48
+ export function sgrBg(hex: string): string {
49
+ return `\x1b[48;2;${channels(hex)}m`;
50
+ }
51
+
52
+ /**
53
+ * Attributes off, then `Normal`. The state a row starts and ends in: bold, dim
54
+ * and the like must not bleed past the span that set them, and a reset (`0`,
55
+ * or a bare colour off) would drop the row back onto the host terminal.
56
+ */
57
+ export function sgrPlain(): string {
58
+ return `\x1b[22;23;24;38;2;${channels(NORMAL_FG)};48;2;${channels(NORMAL_BG)}m`;
59
+ }
60
+
61
+ export interface Style {
62
+ fg?: string;
63
+ bg?: string;
64
+ bold?: boolean;
65
+ italic?: boolean;
66
+ underline?: boolean;
67
+ }
68
+
69
+ /**
70
+ * Capture name to colour, mapped the way `folke/tokyonight.nvim` maps capture
71
+ * names to highlight groups. A dotted name falls back to its parent.
72
+ */
73
+ export const STYLES: Record<string, Style | undefined> = {
74
+ comment: { fg: PALETTE.comment },
75
+ constant: { fg: PALETTE.orange },
76
+ "constant.builtin": { fg: PALETTE.blue1 },
77
+ constructor: { fg: PALETTE.magenta },
78
+ escape: { fg: PALETTE.magenta },
79
+ function: { fg: PALETTE.blue },
80
+ "function.builtin": { fg: PALETTE.blue1 },
81
+ keyword: { fg: PALETTE.purple },
82
+ number: { fg: PALETTE.orange },
83
+ operator: { fg: PALETTE.blue5 },
84
+ property: { fg: PALETTE.green1 },
85
+ "punctuation.bracket": { fg: PALETTE.fg_dark },
86
+ "punctuation.delimiter": { fg: PALETTE.blue5 },
87
+ "punctuation.special": { fg: PALETTE.blue5 },
88
+ string: { fg: PALETTE.green },
89
+ "string.special": { fg: PALETTE.blue1 },
90
+ type: { fg: PALETTE.blue1 },
91
+ "type.builtin": { fg: "#27a1b9" }, // a per-variant literal, not a palette slot
92
+ variable: { fg: PALETTE.fg },
93
+ "variable.builtin": { fg: PALETTE.red },
94
+ "variable.parameter": { fg: PALETTE.yellow },
95
+ // Markdown's queries predate the `@markup` rename; these are the old names.
96
+ "text.emphasis": { italic: true },
97
+ "text.strong": { bold: true },
98
+ "text.literal": { fg: PALETTE.green },
99
+ "text.uri": { underline: true },
100
+ "text.reference": { fg: PALETTE.blue1 },
101
+ };
102
+
103
+ /**
104
+ * Headings take their level's colour from TokyoNight's rainbow, over a 10% tint
105
+ * of it, as `@markup.heading.N.markdown` does. The grammar's own query names one
106
+ * heading colour for all levels, so the level comes from the marker.
107
+ */
108
+ export const HEADINGS: Style[] = [
109
+ { fg: PALETTE.blue, bg: "#24293b" },
110
+ { fg: PALETTE.yellow, bg: "#2e2a2d" },
111
+ { fg: PALETTE.green, bg: "#272d2d" },
112
+ { fg: PALETTE.teal, bg: "#1a2b32" },
113
+ { fg: PALETTE.magenta, bg: "#2a283b" },
114
+ { fg: PALETTE.purple, bg: "#272538" },
115
+ { fg: PALETTE.orange, bg: "#31282c" },
116
+ { fg: PALETTE.red, bg: "#302430" },
117
+ ].map((style) => ({ ...style, bold: true }));
118
+
119
+ /** Inline code, `@markup.raw.markdown_inline`. */
120
+ export const INLINE_CODE: Style = { fg: PALETTE.blue, bg: PALETTE.terminal_black };