motifcode 0.3.1 → 0.3.3
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.
- package/dist/build-info.json +2 -2
- package/dist/motif.js +24 -10
- package/package.json +1 -1
package/dist/build-info.json
CHANGED
package/dist/motif.js
CHANGED
|
@@ -5241,6 +5241,7 @@ var term = {
|
|
|
5241
5241
|
};
|
|
5242
5242
|
|
|
5243
5243
|
// packages/tui/src/keys.ts
|
|
5244
|
+
import { StringDecoder } from "node:string_decoder";
|
|
5244
5245
|
var ESC2 = "\x1B";
|
|
5245
5246
|
var PASTE_START = `${ESC2}[200~`;
|
|
5246
5247
|
var PASTE_END = `${ESC2}[201~`;
|
|
@@ -5310,13 +5311,19 @@ function controlKey(code) {
|
|
|
5310
5311
|
}
|
|
5311
5312
|
}
|
|
5312
5313
|
var KeyDecoder = class {
|
|
5314
|
+
// Byte boundaries and escape-sequence boundaries are separate concerns.
|
|
5315
|
+
utf8 = new StringDecoder("utf8");
|
|
5313
5316
|
pasting = false;
|
|
5314
5317
|
paste = "";
|
|
5315
5318
|
/** An escape sequence cut off by the end of a read; completed by the next one. */
|
|
5316
5319
|
pending = "";
|
|
5317
5320
|
feed(chunk) {
|
|
5321
|
+
return this.parse(typeof chunk === "string" ? chunk : this.utf8.write(chunk));
|
|
5322
|
+
}
|
|
5323
|
+
/** Parse decoded text only; recursive paste parsing must not touch buffered bytes. */
|
|
5324
|
+
parse(chunk) {
|
|
5318
5325
|
const out = [];
|
|
5319
|
-
let s = this.pending +
|
|
5326
|
+
let s = this.pending + chunk;
|
|
5320
5327
|
this.pending = "";
|
|
5321
5328
|
if (this.pasting) {
|
|
5322
5329
|
const end = s.indexOf(PASTE_END);
|
|
@@ -5352,7 +5359,7 @@ var KeyDecoder = class {
|
|
|
5352
5359
|
if (s.startsWith(PASTE_START, i)) {
|
|
5353
5360
|
this.pasting = true;
|
|
5354
5361
|
const rest = s.slice(i + PASTE_START.length);
|
|
5355
|
-
const tail = this.
|
|
5362
|
+
const tail = this.parse(rest);
|
|
5356
5363
|
out.push(...tail);
|
|
5357
5364
|
return out;
|
|
5358
5365
|
}
|
|
@@ -5574,7 +5581,7 @@ var Composer = class {
|
|
|
5574
5581
|
submit() {
|
|
5575
5582
|
const shown = this.text.replace(/\s+$/, "");
|
|
5576
5583
|
const text = this.expanded(shown);
|
|
5577
|
-
if (
|
|
5584
|
+
if (text !== "" && this.history[this.history.length - 1] !== text) this.history.push(text);
|
|
5578
5585
|
this.clear();
|
|
5579
5586
|
this.pastes.clear();
|
|
5580
5587
|
return text;
|
|
@@ -7423,16 +7430,22 @@ async function runBash(command, cwd, timeoutMs, policy, scratch, signal) {
|
|
|
7423
7430
|
}
|
|
7424
7431
|
return { ok: r.code === 0, output: r.output.trim() || `(exit ${r.code})` };
|
|
7425
7432
|
}
|
|
7433
|
+
function toLogicalLines(text) {
|
|
7434
|
+
if (text === "") return [];
|
|
7435
|
+
const normalized = text.endsWith("\n") ? text.slice(0, -1) : text;
|
|
7436
|
+
return normalized.split("\n");
|
|
7437
|
+
}
|
|
7426
7438
|
function readSlice(path, cwd, offset, limit) {
|
|
7427
7439
|
try {
|
|
7428
7440
|
const text = readFileSync5(resolve4(cwd, path), "utf8");
|
|
7429
|
-
const lines = text
|
|
7441
|
+
const lines = toLogicalLines(text);
|
|
7430
7442
|
const start = Math.max(0, (offset ?? 1) - 1);
|
|
7431
7443
|
const end = limit !== void 0 ? start + limit : lines.length;
|
|
7432
7444
|
const slice = lines.slice(start, end);
|
|
7433
7445
|
const numbered = slice.map((l, i) => `${start + i + 1} ${l}`).join("\n");
|
|
7434
|
-
const
|
|
7435
|
-
|
|
7446
|
+
const remaining = Math.max(0, lines.length - end);
|
|
7447
|
+
const more = remaining > 0 ? numbered ? `
|
|
7448
|
+
\u2026 ${remaining} more lines` : `\u2026 ${remaining} more lines` : "";
|
|
7436
7449
|
return { ok: true, output: numbered + more };
|
|
7437
7450
|
} catch (err) {
|
|
7438
7451
|
return { ok: false, output: String(err) };
|
|
@@ -7447,7 +7460,7 @@ function writeFile(path, content, cwd) {
|
|
|
7447
7460
|
const lines = content === "" ? 0 : content.split("\n").length;
|
|
7448
7461
|
return {
|
|
7449
7462
|
ok: true,
|
|
7450
|
-
output: `${existed ? "replaced" : "created"} ${path} (${lines} lines, ${content
|
|
7463
|
+
output: `${existed ? "replaced" : "created"} ${path} (${lines} lines, ${Buffer.byteLength(content, "utf8")} bytes)`
|
|
7451
7464
|
};
|
|
7452
7465
|
} catch (err) {
|
|
7453
7466
|
return { ok: false, output: String(err) };
|
|
@@ -9211,7 +9224,7 @@ function saveUserSetting(key, value, home = homedir4()) {
|
|
|
9211
9224
|
}
|
|
9212
9225
|
|
|
9213
9226
|
// packages/cli/src/main.ts
|
|
9214
|
-
var VERSION = "0.3.
|
|
9227
|
+
var VERSION = "0.3.3";
|
|
9215
9228
|
var SHORT_FLAGS = { p: "print", c: "continue", i: "interactive", v: "verbose", h: "help" };
|
|
9216
9229
|
var BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
|
|
9217
9230
|
"print",
|
|
@@ -9814,6 +9827,7 @@ user file ${stored.userPath}${existsSync10(stored.userPath) ? "" : " (absent
|
|
|
9814
9827
|
const activeToolNames = CORE_TOOL_NAMES.slice(0, activeTools.length);
|
|
9815
9828
|
const schemaHash = toolSchemaHash(activeTools);
|
|
9816
9829
|
const promptHash = systemPromptHash(systemFor(channel));
|
|
9830
|
+
const printOnly = args.flags["print"] === true || args.flags["p"] === true;
|
|
9817
9831
|
let task;
|
|
9818
9832
|
if (resumeFrom) {
|
|
9819
9833
|
const blocker = checkResumable(resumeFrom, {
|
|
@@ -9827,7 +9841,7 @@ user file ${stored.userPath}${existsSync10(stored.userPath) ? "" : " (absent
|
|
|
9827
9841
|
return 2;
|
|
9828
9842
|
}
|
|
9829
9843
|
task = resumeFrom.task ?? "";
|
|
9830
|
-
process.stdout.write(
|
|
9844
|
+
(printOnly ? process.stderr : process.stdout).write(
|
|
9831
9845
|
`resuming ${resumeFrom.header.runId} from turn ${resumeFrom.checkpoint.turn}${resumeFrom.truncatedTail ? " (last record was truncated)" : ""}
|
|
9832
9846
|
`
|
|
9833
9847
|
);
|
|
@@ -9835,7 +9849,6 @@ user file ${stored.userPath}${existsSync10(stored.userPath) ? "" : " (absent
|
|
|
9835
9849
|
task = args.rest.join(" ").trim();
|
|
9836
9850
|
}
|
|
9837
9851
|
const wantsChat = args.flags["interactive"] === true || args.flags["chat"] === true || args.flags["continue"] === true;
|
|
9838
|
-
const printOnly = args.flags["print"] === true || args.flags["p"] === true;
|
|
9839
9852
|
const tty = Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
9840
9853
|
if (wantsChat && !tty) {
|
|
9841
9854
|
throw new UsageError("--interactive needs a terminal on stdin and stdout");
|
|
@@ -9922,6 +9935,7 @@ user file ${stored.userPath}${existsSync10(stored.userPath) ? "" : " (absent
|
|
|
9922
9935
|
maxTurns,
|
|
9923
9936
|
...maxOutputTokens !== void 0 ? { maxOutputTokens } : {},
|
|
9924
9937
|
...seed !== void 0 ? { seed } : {},
|
|
9938
|
+
...resumeFrom?.checkpoint ? { resume: resumeFrom.checkpoint } : {},
|
|
9925
9939
|
replyEnds: true,
|
|
9926
9940
|
confirmDone: false
|
|
9927
9941
|
});
|