@lih-x-x/kmr 1.0.11 → 1.0.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/index.js +22 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -924,23 +924,31 @@ var SessionManager = class {
924
924
  extractReply(output) {
925
925
  const lines = output.split("\n");
926
926
  const metaPrefixes = ["[client]", "[tool]", "[thinking]", "[done]", "[error]", "[warn]", "[info]"];
927
- let lastCompletedIdx = -1;
928
- for (let i = 0; i < lines.length; i++) {
929
- if (/\(completed\)/.test(lines[i])) {
930
- lastCompletedIdx = i;
927
+ let endIdx = lines.length - 1;
928
+ while (endIdx >= 0) {
929
+ const t = lines[endIdx].trim();
930
+ if (t.length === 0 || metaPrefixes.some((p) => t.startsWith(p))) {
931
+ endIdx--;
932
+ } else {
933
+ break;
931
934
  }
932
935
  }
933
- const startIdx = lastCompletedIdx >= 0 ? lastCompletedIdx + 1 : 0;
934
- const reply = lines.slice(startIdx).filter((line) => {
935
- const t = line.trim();
936
- return t.length > 0 && !metaPrefixes.some((p) => t.startsWith(p));
937
- }).join("\n").trim();
936
+ if (endIdx < 0) return output.trim();
937
+ let startIdx = endIdx;
938
+ while (startIdx > 0) {
939
+ const prevLine = lines[startIdx - 1];
940
+ const prevTrimmed = prevLine.trim();
941
+ const isToolOrMeta = metaPrefixes.some((p) => prevTrimmed.startsWith(p)) || /^\s{2,}(kind|input|output):/.test(prevLine) || /\(completed\)/.test(prevLine) || /^\s{2,}```/.test(prevLine) || prevLine.startsWith(" ") && /^\s{2,}\S/.test(prevLine);
942
+ if (isToolOrMeta) break;
943
+ if (prevTrimmed.length === 0) {
944
+ startIdx--;
945
+ continue;
946
+ }
947
+ startIdx--;
948
+ }
949
+ const reply = lines.slice(startIdx, endIdx + 1).join("\n").trim();
938
950
  if (reply.length > 0) return reply;
939
- const filtered = lines.filter((line) => {
940
- const t = line.trim();
941
- return t.length > 0 && !metaPrefixes.some((p) => t.startsWith(p));
942
- }).join("\n").trim();
943
- return filtered || output.trim();
951
+ return output.trim();
944
952
  }
945
953
  async appendSummary(userId, userText, aiReply) {
946
954
  const userDir = path5.join(this.sessionDir, userId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lih-x-x/kmr",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {