min-agent 0.2.1 → 0.4.0

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 (137) hide show
  1. package/README.md +242 -31
  2. package/dist/agent.js +1233 -485
  3. package/dist/assistant-stream.js +11 -7
  4. package/dist/cli/commands/chat.js +10 -0
  5. package/dist/cli/commands/exec.js +32 -0
  6. package/dist/cli/commands/history.js +58 -0
  7. package/dist/cli/commands/index.js +224 -0
  8. package/dist/cli/commands/init.js +18 -0
  9. package/dist/cli/commands/mcp.js +173 -0
  10. package/dist/cli/commands/memory.js +69 -0
  11. package/dist/cli/commands/models.js +21 -0
  12. package/dist/cli/commands/permission.js +12 -0
  13. package/dist/cli/commands/rules.js +33 -0
  14. package/dist/cli/commands/sandbox.js +13 -0
  15. package/dist/cli/commands/serve.js +9 -0
  16. package/dist/cli/commands/setup.js +4 -0
  17. package/dist/cli/commands/shared.js +16 -0
  18. package/dist/cli/commands/skills.js +119 -0
  19. package/dist/cli/commands/update.js +7 -0
  20. package/dist/cli/commands/write-config.js +30 -0
  21. package/dist/cli/errors.js +36 -0
  22. package/dist/cli/exec-prompt.js +26 -0
  23. package/dist/cli/option-helpers.js +53 -0
  24. package/dist/cli/program.js +180 -0
  25. package/dist/cli.js +7 -632
  26. package/dist/clipboard.js +59 -23
  27. package/dist/code-mode.js +35 -17
  28. package/dist/compaction.js +457 -169
  29. package/dist/config.js +298 -38
  30. package/dist/confirm.js +105 -9
  31. package/dist/context-window.js +156 -75
  32. package/dist/doom-loop.js +268 -26
  33. package/dist/fetch-timeout.js +152 -0
  34. package/dist/http-approvals.js +60 -0
  35. package/dist/http.js +119 -0
  36. package/dist/instructions.js +72 -33
  37. package/dist/logger.js +95 -0
  38. package/dist/markdown.js +35 -50
  39. package/dist/mcp.js +847 -102
  40. package/dist/memory.js +128 -45
  41. package/dist/output.js +42 -31
  42. package/dist/paste-handler.js +3 -3
  43. package/dist/permission-cli.js +43 -0
  44. package/dist/plugins.js +76 -11
  45. package/dist/pricing.js +119 -0
  46. package/dist/provider.js +34 -15
  47. package/dist/question-format.js +60 -0
  48. package/dist/sandbox-cli.js +82 -0
  49. package/dist/sandbox.js +403 -0
  50. package/dist/save-throttle.js +45 -0
  51. package/dist/serve/common.js +404 -0
  52. package/dist/serve/routes-chat.js +347 -0
  53. package/dist/serve/routes-mcp.js +212 -0
  54. package/dist/serve/routes-memory.js +66 -0
  55. package/dist/serve/routes-meta.js +205 -0
  56. package/dist/serve/routes-sessions.js +61 -0
  57. package/dist/serve/routes-skills.js +70 -0
  58. package/dist/serve.js +74 -635
  59. package/dist/sessions.js +197 -15
  60. package/dist/skills.js +531 -77
  61. package/dist/synthetic.js +7 -0
  62. package/dist/title-gen.js +9 -2
  63. package/dist/token-display.js +36 -0
  64. package/dist/tool-display.js +178 -0
  65. package/dist/tool-output.js +53 -46
  66. package/dist/tools/apply_patch.js +265 -0
  67. package/dist/tools/atomic-file.js +35 -0
  68. package/dist/tools/backend.js +61 -0
  69. package/dist/tools/bash.js +186 -71
  70. package/dist/tools/code_search.js +13 -6
  71. package/dist/tools/edit.js +26 -9
  72. package/dist/tools/explore.js +144 -16
  73. package/dist/tools/glob.js +7 -3
  74. package/dist/tools/grep.js +153 -14
  75. package/dist/tools/index.js +9 -24
  76. package/dist/tools/question.js +31 -30
  77. package/dist/tools/read.js +77 -15
  78. package/dist/tools/search-searxng.js +223 -0
  79. package/dist/tools/search-serper.js +189 -0
  80. package/dist/tools/task.js +100 -33
  81. package/dist/tools/todo.js +178 -67
  82. package/dist/tools/web_fetch.js +158 -46
  83. package/dist/tools/web_search.js +217 -29
  84. package/dist/tools/write.js +34 -11
  85. package/dist/tui/App.js +89 -6
  86. package/dist/tui/ConfirmBar.js +57 -4
  87. package/dist/tui/InputBar.js +504 -44
  88. package/dist/tui/MessageList.js +674 -20
  89. package/dist/tui/ModelPicker.js +113 -0
  90. package/dist/tui/QuestionBar.js +136 -0
  91. package/dist/tui/SessionPicker.js +79 -0
  92. package/dist/tui/StatusBar.js +14 -12
  93. package/dist/tui/agent-runner.js +223 -0
  94. package/dist/tui/caret-pos.js +177 -0
  95. package/dist/tui/caret.js +69 -0
  96. package/dist/tui/click-count.js +13 -0
  97. package/dist/tui/diff-view.js +61 -0
  98. package/dist/tui/drag-state.js +49 -0
  99. package/dist/tui/hydrate.js +129 -0
  100. package/dist/tui/index.js +189 -31
  101. package/dist/tui/input-history.js +125 -0
  102. package/dist/tui/layout.js +88 -0
  103. package/dist/tui/mouse.js +46 -0
  104. package/dist/tui/prompt-queue.js +24 -0
  105. package/dist/tui/selection.js +226 -0
  106. package/dist/tui/session-switch.js +28 -0
  107. package/dist/tui/slash-commands.js +106 -0
  108. package/dist/tui/slash-handler.js +545 -0
  109. package/dist/tui/text-width.js +113 -0
  110. package/dist/tui/theme.js +12 -0
  111. package/dist/tui/token-info.js +7 -0
  112. package/dist/tui/tool-children.js +19 -0
  113. package/dist/tui/undo-stack.js +14 -0
  114. package/dist/tui/use-sgr-mouse.js +29 -0
  115. package/dist/tui-chat.js +346 -330
  116. package/dist/updater.js +116 -0
  117. package/dist/xml-search.js +194 -0
  118. package/docs/API.md +410 -32
  119. package/docs/superpowers/plans/2026-08-16-batch1-tui-improvements.md +1510 -0
  120. package/docs/superpowers/plans/2026-08-16-batch2-cli-tools-api.md +2105 -0
  121. package/docs/superpowers/plans/2026-08-16-batch3-config-engineering.md +1595 -0
  122. package/docs/superpowers/plans/2026-08-16-input-caret.md +782 -0
  123. package/docs/superpowers/plans/2026-08-20-tui-completeness.md +873 -0
  124. package/docs/superpowers/plans/2026-08-20-unified-tui-default.md +631 -0
  125. package/docs/superpowers/specs/2026-08-16-batch1-tui-improvements-design.md +183 -0
  126. package/docs/superpowers/specs/2026-08-16-batch2-cli-tools-api-design.md +220 -0
  127. package/docs/superpowers/specs/2026-08-16-batch3-config-engineering-design.md +196 -0
  128. package/docs/superpowers/specs/2026-08-16-input-caret-design.md +63 -0
  129. package/docs/superpowers/specs/2026-08-17-mouse-selection-design.md +116 -0
  130. package/docs/superpowers/specs/2026-08-20-config-http-alignment-design.md +47 -0
  131. package/docs/superpowers/specs/2026-08-20-mcp-plugins-alignment-design.md +37 -0
  132. package/docs/superpowers/specs/2026-08-20-sandbox-permissions-design.md +68 -0
  133. package/docs/superpowers/specs/2026-08-20-tui-completeness-design.md +273 -0
  134. package/docs/superpowers/specs/2026-08-20-unified-tui-default-design.md +165 -0
  135. package/package.json +12 -8
  136. package/skills/self-config/SKILL.md +90 -0
  137. package/skills/self-config/reference.md +149 -0
package/dist/markdown.js CHANGED
@@ -2,6 +2,7 @@
2
2
  * Lightweight streaming markdown renderer for terminal.
3
3
  * Tracks state across text deltas to apply ANSI formatting.
4
4
  */
5
+ import { displayWidth } from "./tui/text-width.js";
5
6
  function useColor() {
6
7
  if ("NO_COLOR" in process.env)
7
8
  return false;
@@ -51,7 +52,15 @@ export class MarkdownRenderer {
51
52
  break;
52
53
  const line = this.buffer.slice(0, nlIdx);
53
54
  this.buffer = this.buffer.slice(nlIdx + 1);
54
- // Table handling: collect rows, render when table ends
55
+ if (this.inCodeBlock || line.startsWith("```")) {
56
+ if (this.inTable) {
57
+ output += this.renderTable(c);
58
+ this.tableRows = [];
59
+ this.inTable = false;
60
+ }
61
+ output += this.formatLine(line, c) + "\n";
62
+ continue;
63
+ }
55
64
  if (this.isTableRow(line)) {
56
65
  if (this.isTableSeparator(line)) {
57
66
  this.inTable = true;
@@ -126,71 +135,47 @@ export class MarkdownRenderer {
126
135
  return /^\s*\|[\s:]*-+[\s:|-]*\|\s*$/.test(line);
127
136
  }
128
137
  parseTableRow(line) {
129
- return line.trim().slice(1, -1).split("|").map((cell) => cell.trim());
138
+ return line
139
+ .trim()
140
+ .slice(1, -1)
141
+ .split("|")
142
+ .map((cell) => cell.trim());
130
143
  }
131
- /** Get display width of a string (CJK/emoji chars = 2, others = 1) */
132
- displayWidth(str) {
144
+ /** Pad string to target display width */
145
+ clipToWidth(str, targetWidth) {
133
146
  let width = 0;
147
+ let out = "";
134
148
  for (const ch of str) {
135
- const code = ch.codePointAt(0) ?? 0;
136
- if (
137
- // CJK
138
- (code >= 0x1100 && code <= 0x115f) ||
139
- (code >= 0x2e80 && code <= 0x303e) ||
140
- (code >= 0x3040 && code <= 0x33bf) ||
141
- (code >= 0x3400 && code <= 0x4dbf) ||
142
- (code >= 0x4e00 && code <= 0x9fff) ||
143
- (code >= 0xa000 && code <= 0xa4cf) ||
144
- (code >= 0xac00 && code <= 0xd7af) ||
145
- (code >= 0xf900 && code <= 0xfaff) ||
146
- (code >= 0xfe30 && code <= 0xfe6f) ||
147
- (code >= 0xff01 && code <= 0xff60) ||
148
- (code >= 0xffe0 && code <= 0xffe6) ||
149
- (code >= 0x20000 && code <= 0x2fffd) ||
150
- (code >= 0x30000 && code <= 0x3fffd) ||
151
- // Emoji
152
- (code >= 0x1f300 && code <= 0x1f9ff) || // Misc Symbols, Emoticons, Dingbats, etc.
153
- (code >= 0x1fa00 && code <= 0x1faff) || // Chess, Extended-A
154
- (code >= 0x2600 && code <= 0x27bf) || // Misc Symbols, Dingbats
155
- (code >= 0xfe00 && code <= 0xfe0f) || // Variation Selectors (skip width)
156
- (code >= 0x200d && code <= 0x200d) || // ZWJ (skip width)
157
- (code >= 0x1f1e0 && code <= 0x1f1ff) // Regional Indicators (flags)
158
- ) {
159
- // Variation selectors and ZWJ are zero-width joiners
160
- if ((code >= 0xfe00 && code <= 0xfe0f) || code === 0x200d) {
161
- width += 0;
162
- }
163
- else {
164
- width += 2;
165
- }
166
- }
167
- else {
168
- width += 1;
169
- }
149
+ const w = displayWidth(ch);
150
+ if (width + w > targetWidth)
151
+ break;
152
+ out += ch;
153
+ width += w;
170
154
  }
171
- return width;
155
+ return out;
172
156
  }
173
- /** Pad string to target display width */
174
157
  padToWidth(str, targetWidth) {
175
- const currentWidth = this.displayWidth(str);
176
- const padding = targetWidth - currentWidth;
177
- return padding > 0 ? str + " ".repeat(padding) : str;
158
+ const clipped = this.clipToWidth(str, targetWidth);
159
+ const padding = targetWidth - displayWidth(clipped);
160
+ return padding > 0 ? clipped + " ".repeat(padding) : clipped;
178
161
  }
179
162
  renderTable(c) {
180
163
  if (this.tableRows.length === 0)
181
164
  return "";
182
- // Calculate column widths based on display width (CJK-aware)
183
- const colCount = Math.max(...this.tableRows.map((r) => r.length));
165
+ const colCount = Math.max(0, ...this.tableRows.map((r) => r.length));
166
+ if (colCount === 0)
167
+ return "";
184
168
  const widths = Array(colCount).fill(0);
169
+ const maxCol = 64;
185
170
  for (const row of this.tableRows) {
186
171
  for (let i = 0; i < row.length; i++) {
187
- widths[i] = Math.max(widths[i], this.displayWidth(row[i] ?? ""));
172
+ widths[i] = Math.min(maxCol, Math.max(widths[i], displayWidth(row[i] ?? "")));
188
173
  }
189
174
  }
190
175
  const lines = [];
191
- const top = `${c.dim}┌${widths.map((w) => "─".repeat(w + 2)).join("┬")}┐${c.reset}`;
192
- const mid = `${c.dim}├${widths.map((w) => "─".repeat(w + 2)).join("┼")}┤${c.reset}`;
193
- const bot = `${c.dim}└${widths.map((w) => "─".repeat(w + 2)).join("┴")}┘${c.reset}`;
176
+ const top = `${c.dim}┌${widths.map((w) => "─".repeat(Math.max(0, w + 2))).join("┬")}┐${c.reset}`;
177
+ const mid = `${c.dim}├${widths.map((w) => "─".repeat(Math.max(0, w + 2))).join("┼")}┤${c.reset}`;
178
+ const bot = `${c.dim}└${widths.map((w) => "─".repeat(Math.max(0, w + 2))).join("┴")}┘${c.reset}`;
194
179
  lines.push(top);
195
180
  for (let r = 0; r < this.tableRows.length; r++) {
196
181
  const row = this.tableRows[r];