miii-agent 0.1.23 → 0.1.25

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 (2) hide show
  1. package/dist/cli.js +95 -65
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -401,6 +401,10 @@ async function* chat2(entry, model, messages, tools, opts) {
401
401
  const delta = choices[0].delta ?? {};
402
402
  const finishReason = choices[0].finish_reason;
403
403
  if (finishReason) lastFinishReason = finishReason;
404
+ const reasoning = delta.reasoning_content ?? (typeof delta.reasoning === "string" ? delta.reasoning : void 0) ?? delta.reasoning?.content;
405
+ if (reasoning) {
406
+ yield { content: "", thinking: reasoning, done: false };
407
+ }
404
408
  if (delta.content) {
405
409
  yield { content: delta.content, done: false };
406
410
  }
@@ -3102,6 +3106,83 @@ function renderMarkdownStreaming(content) {
3102
3106
  // src/ui/ThinkingBlock.tsx
3103
3107
  import { useState as useState2, useEffect as useEffect2 } from "react";
3104
3108
  import { Box as Box8, Text as Text8 } from "ink";
3109
+
3110
+ // src/ui/layout.ts
3111
+ function formatTokens(n) {
3112
+ if (n >= 1e3) return (n / 1e3).toFixed(n >= 1e4 ? 0 : 1) + "k";
3113
+ return String(n);
3114
+ }
3115
+ function formatDuration(ms) {
3116
+ const totalSec = ms / 1e3;
3117
+ if (totalSec < 60) return `${totalSec.toFixed(1)}s`;
3118
+ const m = Math.floor(totalSec / 60);
3119
+ const s = Math.round(totalSec - m * 60);
3120
+ return `${m}m ${s}s`;
3121
+ }
3122
+ function countLines(s) {
3123
+ if (!s) return 0;
3124
+ return s.split("\n").length;
3125
+ }
3126
+ function truncate2(s, max) {
3127
+ if (s.length <= max) return s;
3128
+ return s.slice(0, max - 1) + "\u2026";
3129
+ }
3130
+ function clipTail(rendered, max) {
3131
+ const lines = rendered.split("\n");
3132
+ if (lines.length <= max) return { text: rendered, clipped: 0 };
3133
+ return { text: lines.slice(-max).join("\n"), clipped: lines.length - max };
3134
+ }
3135
+ function clipTailVisual(content, maxRows, width) {
3136
+ const w = Math.max(1, width);
3137
+ const lines = content.split("\n");
3138
+ const visualRows = (line) => Math.max(1, Math.ceil(line.length / w));
3139
+ let rows = 0;
3140
+ let start = lines.length;
3141
+ for (let i = lines.length - 1; i >= 0; i--) {
3142
+ const h = visualRows(lines[i]);
3143
+ if (rows + h > maxRows && start < lines.length) break;
3144
+ rows += h;
3145
+ start = i;
3146
+ }
3147
+ if (start === 0) return { text: content, clipped: 0 };
3148
+ return { text: lines.slice(start).join("\n"), clipped: start };
3149
+ }
3150
+ function liveFrameRows() {
3151
+ const rows = process.stdout.rows ?? 24;
3152
+ return Math.max(6, rows - 8);
3153
+ }
3154
+ var COLLAPSED_LINES = 3;
3155
+ function estimateToolRows(use, result) {
3156
+ const input = use.input ?? {};
3157
+ const noErr = !result?.is_error;
3158
+ if (use.name === "write_file" && noErr) {
3159
+ const total = countLines(String(input.content ?? ""));
3160
+ const shown = Math.min(total, COLLAPSED_LINES);
3161
+ return 2 + shown + (total > shown ? 1 : 0);
3162
+ }
3163
+ if (use.name === "edit_file" && noErr) {
3164
+ const total = countLines(String(input.old_str ?? "")) + countLines(String(input.new_str ?? ""));
3165
+ const shown = Math.min(total, COLLAPSED_LINES);
3166
+ return 2 + shown + (total > shown ? 1 : 0);
3167
+ }
3168
+ let rows = 1;
3169
+ if (result) {
3170
+ const lines = (result.content ?? "").split("\n");
3171
+ const multi = (use.name === "run_bash" || use.name === "grep" || use.name === "glob" || result.is_error) && lines.length > 1;
3172
+ if (multi) {
3173
+ const shown = Math.min(lines.length, COLLAPSED_LINES);
3174
+ rows += 1 + shown + (lines.length > shown ? 1 : 0);
3175
+ } else {
3176
+ rows += 1;
3177
+ }
3178
+ }
3179
+ return rows;
3180
+ }
3181
+ function contentWidth() {
3182
+ return Math.max(20, (process.stdout.columns ?? 80) - 4);
3183
+ }
3184
+
3185
+ // src/ui/ThinkingBlock.tsx
3105
3186
  import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
3106
3187
  var FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
3107
3188
  var globalThinkingVisible = false;
@@ -3142,10 +3223,13 @@ function ThinkingBlock({ content }) {
3142
3223
  ] })
3143
3224
  ] }),
3144
3225
  visible && content ? (() => {
3145
- const max = Math.max(4, (process.stdout.rows ?? 24) - 10);
3146
- const lines = content.split("\n");
3147
- const shown = lines.length > max ? lines.slice(-max) : lines;
3148
- return /* @__PURE__ */ jsx8(Box8, { marginLeft: 2, children: /* @__PURE__ */ jsx8(Text8, { dimColor: true, italic: true, children: shown.join("\n") }) });
3226
+ const width = Math.max(20, contentWidth() - 2);
3227
+ const budget = Math.max(4, liveFrameRows() - 1);
3228
+ const { text, clipped } = clipTailVisual(content, budget, width);
3229
+ return /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", marginLeft: 2, children: [
3230
+ clipped > 0 && /* @__PURE__ */ jsx8(Text8, { dimColor: true, children: `\u2191 ${clipped} earlier line${clipped === 1 ? "" : "s"} above` }),
3231
+ /* @__PURE__ */ jsx8(Box8, { width, children: /* @__PURE__ */ jsx8(Text8, { dimColor: true, italic: true, wrap: "wrap", children: text }) })
3232
+ ] });
3149
3233
  })() : null
3150
3234
  ] });
3151
3235
  }
@@ -3188,66 +3272,6 @@ function useToolExpanded() {
3188
3272
  return expanded;
3189
3273
  }
3190
3274
 
3191
- // src/ui/layout.ts
3192
- function formatTokens(n) {
3193
- if (n >= 1e3) return (n / 1e3).toFixed(n >= 1e4 ? 0 : 1) + "k";
3194
- return String(n);
3195
- }
3196
- function formatDuration(ms) {
3197
- const totalSec = ms / 1e3;
3198
- if (totalSec < 60) return `${totalSec.toFixed(1)}s`;
3199
- const m = Math.floor(totalSec / 60);
3200
- const s = Math.round(totalSec - m * 60);
3201
- return `${m}m ${s}s`;
3202
- }
3203
- function countLines(s) {
3204
- if (!s) return 0;
3205
- return s.split("\n").length;
3206
- }
3207
- function truncate2(s, max) {
3208
- if (s.length <= max) return s;
3209
- return s.slice(0, max - 1) + "\u2026";
3210
- }
3211
- function clipTail(rendered, max) {
3212
- const lines = rendered.split("\n");
3213
- if (lines.length <= max) return { text: rendered, clipped: 0 };
3214
- return { text: lines.slice(-max).join("\n"), clipped: lines.length - max };
3215
- }
3216
- function liveFrameRows() {
3217
- const rows = process.stdout.rows ?? 24;
3218
- return Math.max(6, rows - 8);
3219
- }
3220
- var COLLAPSED_LINES = 3;
3221
- function estimateToolRows(use, result) {
3222
- const input = use.input ?? {};
3223
- const noErr = !result?.is_error;
3224
- if (use.name === "write_file" && noErr) {
3225
- const total = countLines(String(input.content ?? ""));
3226
- const shown = Math.min(total, COLLAPSED_LINES);
3227
- return 2 + shown + (total > shown ? 1 : 0);
3228
- }
3229
- if (use.name === "edit_file" && noErr) {
3230
- const total = countLines(String(input.old_str ?? "")) + countLines(String(input.new_str ?? ""));
3231
- const shown = Math.min(total, COLLAPSED_LINES);
3232
- return 2 + shown + (total > shown ? 1 : 0);
3233
- }
3234
- let rows = 1;
3235
- if (result) {
3236
- const lines = (result.content ?? "").split("\n");
3237
- const multi = (use.name === "run_bash" || use.name === "grep" || use.name === "glob" || result.is_error) && lines.length > 1;
3238
- if (multi) {
3239
- const shown = Math.min(lines.length, COLLAPSED_LINES);
3240
- rows += 1 + shown + (lines.length > shown ? 1 : 0);
3241
- } else {
3242
- rows += 1;
3243
- }
3244
- }
3245
- return rows;
3246
- }
3247
- function contentWidth() {
3248
- return Math.max(20, (process.stdout.columns ?? 80) - 4);
3249
- }
3250
-
3251
3275
  // src/ui/ToolBlock.tsx
3252
3276
  import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
3253
3277
  var COLLAPSED_LINES2 = 3;
@@ -3849,7 +3873,7 @@ function useAgentRunner(model, activeCtx) {
3849
3873
 
3850
3874
  // src/ui/hooks/useKeyboard.ts
3851
3875
  init_config();
3852
- import { useInput } from "ink";
3876
+ import { useInput, useStdout } from "ink";
3853
3877
  var EFFORTS = ["low", "medium", "high"];
3854
3878
  var PASTE_CHIP_LINES = 4;
3855
3879
  var PASTE_CHIP_CHARS = 200;
@@ -3935,6 +3959,10 @@ function useKeyboard(opts) {
3935
3959
  setActiveToolResults,
3936
3960
  setError
3937
3961
  } = agent;
3962
+ const { write } = useStdout();
3963
+ function hardClear() {
3964
+ write("\x1B[2J\x1B[3J\x1B[H");
3965
+ }
3938
3966
  function clearSession() {
3939
3967
  setMessages(() => []);
3940
3968
  setAgentHistory([]);
@@ -4196,10 +4224,12 @@ function useKeyboard(opts) {
4196
4224
  setCursor(() => Math.max(0, providers.findIndex((p) => p.name === cfg.provider)));
4197
4225
  setState("providers");
4198
4226
  } else if (trimmed === "/clear") {
4227
+ hardClear();
4199
4228
  clearSession();
4200
4229
  } else if (trimmed === "/new") {
4201
4230
  if (agentHistory.length) setNotice("session saved");
4202
4231
  setSessionId(newSessionId());
4232
+ hardClear();
4203
4233
  clearSession();
4204
4234
  } else if (trimmed === "/sessions") {
4205
4235
  setSessions(listSessions());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miii-agent",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
4
4
  "description": "Cursor / Claude Code, but local. An offline AI pair-programmer in your terminal, powered by Ollama. Private by default, free forever.",
5
5
  "type": "module",
6
6
  "bin": {