@lzhzzzzwill/cofos 1.2.0 → 1.2.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 (2) hide show
  1. package/bin/cofos.js +16 -8
  2. package/package.json +1 -1
package/bin/cofos.js CHANGED
@@ -171,11 +171,6 @@ function createTui() {
171
171
  vi: true,
172
172
  mouse: true,
173
173
  tags: false,
174
- border: { type: "line" },
175
- style: {
176
- border: { fg: "cyan" },
177
- scrollbar: { bg: "cyan" },
178
- },
179
174
  scrollbar: { ch: " ", track: { bg: "black" }, style: { bg: "cyan" } },
180
175
  });
181
176
 
@@ -214,7 +209,16 @@ function createTui() {
214
209
  let onSubmit = () => {};
215
210
 
216
211
  function append(text = "") {
217
- buffer += String(text).replace(/\r/g, "");
212
+ const data = String(text).replace(/\x1b\[[0-9;]*[A-Za-z]/g, "");
213
+ for (const part of data.split("\r")) {
214
+ if (part === "") continue;
215
+ if (data.includes("\r")) {
216
+ const lastNewline = buffer.lastIndexOf("\n");
217
+ buffer = (lastNewline === -1 ? "" : buffer.slice(0, lastNewline + 1)) + part;
218
+ } else {
219
+ buffer += part;
220
+ }
221
+ }
218
222
  if (buffer.length > 250000) buffer = buffer.slice(-220000);
219
223
  history.setContent(buffer);
220
224
  history.setScrollPerc(100);
@@ -245,12 +249,16 @@ function createTui() {
245
249
  screen.render();
246
250
  }
247
251
 
248
- input.on("submit", (value) => {
252
+ function submitInput() {
253
+ const value = input.getValue();
249
254
  hideSuggestions();
250
255
  input.clearValue();
256
+ input.focus();
251
257
  screen.render();
252
258
  onSubmit(String(value || ""));
253
- });
259
+ }
260
+
261
+ input.key(["enter"], submitInput);
254
262
 
255
263
  input.on("keypress", () => setTimeout(updateSuggestions, 0));
256
264
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lzhzzzzwill/cofos",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "COFOS 9B + RAG chat CLI with optional local PDF ingestion.",
5
5
  "type": "module",
6
6
  "bin": {