@menteeai/menteeswe 0.1.11 → 0.1.12

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 +55 -62
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -988,7 +988,7 @@ var init_loop = __esm({
988
988
  var version;
989
989
  var init_package = __esm({
990
990
  "package.json"() {
991
- version = "0.1.11";
991
+ version = "0.1.12";
992
992
  }
993
993
  });
994
994
 
@@ -1112,59 +1112,45 @@ function compactChanges(oldStr, newStr) {
1112
1112
  added: newLines.slice(start, endNew)
1113
1113
  };
1114
1114
  }
1115
- function FileDiffView({ diffs }) {
1116
- const files = Object.entries(diffs);
1117
- if (files.length === 0) return null;
1118
- const blocks = [];
1115
+ function CurrentEditBox({ edit }) {
1116
+ if (!edit) return null;
1117
+ const c = compactChanges(edit.old, edit.new);
1118
+ const removed = c.removed.slice(0, MAX_LINES);
1119
+ const added = c.added.slice(0, MAX_LINES);
1120
+ const lines = [];
1119
1121
  let key = 0;
1120
- let lineBudget = MAX_LINES;
1121
- const shown = files.slice(0, MAX_FILES);
1122
- shown.forEach(([file, edits], fi) => {
1123
- let removedTotal = 0;
1124
- let addedTotal = 0;
1125
- const lines = [];
1126
- for (const edit of edits) {
1127
- const c = compactChanges(edit.old, edit.new);
1128
- removedTotal += c.removed.length;
1129
- addedTotal += c.added.length;
1130
- if (lineBudget > 0) {
1131
- for (const l of c.removed) {
1132
- if (lineBudget <= 0) break;
1133
- lines.push(
1134
- /* @__PURE__ */ jsx2(Text2, { backgroundColor: "redBright", color: "white", children: ` - ${l}` }, `r${key++}`)
1135
- );
1136
- lineBudget--;
1137
- }
1138
- for (const l of c.added) {
1139
- if (lineBudget <= 0) break;
1140
- lines.push(
1141
- /* @__PURE__ */ jsx2(Text2, { backgroundColor: "greenBright", color: "black", children: ` + ${l}` }, `a${key++}`)
1142
- );
1143
- lineBudget--;
1144
- }
1145
- }
1146
- }
1147
- blocks.push(
1148
- /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", marginTop: 1, children: [
1149
- /* @__PURE__ */ jsx2(Text2, { bold: true, color: "magenta", children: `\u270E ${file}` }),
1150
- /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: ` ${edits.length} edit(s) \xB7 +${addedTotal} / -${removedTotal}` }),
1151
- lines
1152
- ] }, `f${fi}`)
1122
+ for (const l of removed) {
1123
+ lines.push(
1124
+ /* @__PURE__ */ jsx2(Text2, { backgroundColor: "redBright", color: "white", children: ` - ${l}` }, `r${key++}`)
1153
1125
  );
1154
- });
1155
- if (files.length > MAX_FILES) {
1156
- blocks.push(
1157
- /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: ` \u2026 and ${files.length - MAX_FILES} more file(s)` }, "more")
1126
+ }
1127
+ for (const l of added) {
1128
+ lines.push(
1129
+ /* @__PURE__ */ jsx2(Text2, { backgroundColor: "greenBright", color: "black", children: ` + ${l}` }, `a${key++}`)
1158
1130
  );
1159
1131
  }
1160
- return /* @__PURE__ */ jsx2(Box2, { flexDirection: "column", children: blocks });
1132
+ return /* @__PURE__ */ jsxs2(
1133
+ Box2,
1134
+ {
1135
+ flexDirection: "column",
1136
+ marginTop: 1,
1137
+ borderStyle: "single",
1138
+ borderColor: "gray",
1139
+ borderLeft: false,
1140
+ borderRight: false,
1141
+ paddingX: 1,
1142
+ children: [
1143
+ /* @__PURE__ */ jsx2(Text2, { bold: true, color: "magenta", children: `\u270E ${edit.path}` }),
1144
+ lines.length > 0 ? lines : /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: " (no text change)" })
1145
+ ]
1146
+ }
1147
+ );
1161
1148
  }
1162
- var MAX_FILES, MAX_LINES;
1149
+ var MAX_LINES;
1163
1150
  var init_diff = __esm({
1164
1151
  "src/tui/diff.tsx"() {
1165
1152
  "use strict";
1166
- MAX_FILES = 12;
1167
- MAX_LINES = 160;
1153
+ MAX_LINES = 24;
1168
1154
  }
1169
1155
  });
1170
1156
 
@@ -1367,7 +1353,7 @@ function App(props) {
1367
1353
  const [detailsOpen, setDetailsOpen] = useState3(false);
1368
1354
  const [showDetails, setShowDetails] = useState3(false);
1369
1355
  const [thinkingText, setThinkingText] = useState3("");
1370
- const [fileDiffs, setFileDiffs] = useState3({});
1356
+ const [currentEdit, setCurrentEdit] = useState3(null);
1371
1357
  const finalTextRef = useRef(null);
1372
1358
  const pendingTool = useRef(null);
1373
1359
  const counter = useRef(0);
@@ -1395,10 +1381,7 @@ function App(props) {
1395
1381
  const filePath = typeof event.data?.path === "string" ? event.data.path : "file";
1396
1382
  const oldStr = typeof event.data?.old_string === "string" ? event.data.old_string : "";
1397
1383
  const newStr = typeof event.data?.new_string === "string" ? event.data.new_string : "";
1398
- setFileDiffs((prev) => {
1399
- const arr = prev[filePath] ? [...prev[filePath], { old: oldStr, new: newStr }] : [{ old: oldStr, new: newStr }];
1400
- return { ...prev, [filePath]: arr };
1401
- });
1384
+ setCurrentEdit({ path: filePath, old: oldStr, new: newStr });
1402
1385
  return;
1403
1386
  }
1404
1387
  appendLog(formatEvent(event), TOOL_NOISE.has(event.type));
@@ -1608,9 +1591,8 @@ function App(props) {
1608
1591
  setToolHistory([]);
1609
1592
  setInspectorIndex(null);
1610
1593
  setDetailsOpen(false);
1611
- setShowDetails(false);
1612
1594
  setRunning(true);
1613
- setFileDiffs({});
1595
+ setCurrentEdit(null);
1614
1596
  const ac = new AbortController();
1615
1597
  abortRef.current = ac;
1616
1598
  try {
@@ -1709,7 +1691,7 @@ function App(props) {
1709
1691
  typedText,
1710
1692
  typing ? "\u258C" : ""
1711
1693
  ] }) }) : null,
1712
- /* @__PURE__ */ jsx6(FileDiffView, { diffs: fileDiffs }),
1694
+ /* @__PURE__ */ jsx6(CurrentEditBox, { edit: currentEdit }),
1713
1695
  detailsOpen && inspectorIndex !== null && toolHistory[inspectorIndex] ? (() => {
1714
1696
  const rec = toolHistory[inspectorIndex];
1715
1697
  const outLines = rec.output.split("\n").slice(0, 24).join("\n");
@@ -1918,14 +1900,14 @@ var OpenAICompatProvider = class {
1918
1900
  ...request.maxTokens ? { max_tokens: request.maxTokens } : {}
1919
1901
  };
1920
1902
  if (!request.onToken) {
1921
- const response = await this.client.chat.completions.create(baseParams);
1922
- return parseResponse(response);
1903
+ const response2 = await this.client.chat.completions.create(baseParams);
1904
+ return parseResponse(response2);
1923
1905
  }
1924
- try {
1906
+ const streamOnce = async (withUsage) => {
1925
1907
  const stream = await this.client.chat.completions.create({
1926
1908
  ...baseParams,
1927
1909
  stream: true,
1928
- stream_options: { include_usage: true }
1910
+ ...withUsage ? { stream_options: { include_usage: true } } : {}
1929
1911
  });
1930
1912
  let content = "";
1931
1913
  let finishReason = "stop";
@@ -1936,7 +1918,7 @@ var OpenAICompatProvider = class {
1936
1918
  const delta = choice?.delta;
1937
1919
  if (delta?.content) {
1938
1920
  content += delta.content;
1939
- request.onToken(delta.content);
1921
+ request.onToken?.(delta.content);
1940
1922
  }
1941
1923
  if (delta?.tool_calls) {
1942
1924
  for (const tc of delta.tool_calls) {
@@ -1970,10 +1952,21 @@ var OpenAICompatProvider = class {
1970
1952
  finishReason: mapFinishReason(finishReason),
1971
1953
  usage
1972
1954
  };
1973
- } catch {
1974
- const response = await this.client.chat.completions.create(baseParams);
1975
- return parseResponse(response);
1955
+ };
1956
+ for (const withUsage of [true, false]) {
1957
+ try {
1958
+ return await streamOnce(withUsage);
1959
+ } catch {
1960
+ }
1976
1961
  }
1962
+ const response = await this.client.chat.completions.create(baseParams);
1963
+ const parsed = parseResponse(response);
1964
+ if (parsed.content) {
1965
+ for (let i = 0; i < parsed.content.length; i += 3) {
1966
+ request.onToken?.(parsed.content.slice(i, i + 3));
1967
+ }
1968
+ }
1969
+ return parsed;
1977
1970
  }
1978
1971
  async listModels() {
1979
1972
  const page = await this.client.models.list();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@menteeai/menteeswe",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "MenteE SWE — a model-agnostic autonomous software-engineering agent CLI. Bring your own intelligence: Kimi, GLM/Z.ai, and more.",
5
5
  "type": "module",
6
6
  "license": "MIT",