motifcode 0.3.2 → 0.3.4
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 +258 -69
- package/package.json +1 -1
package/dist/build-info.json
CHANGED
package/dist/motif.js
CHANGED
|
@@ -2702,10 +2702,18 @@ The person asked the summary to concentrate on: ${opts.focus}` : SUMMARIZATION_P
|
|
|
2702
2702
|
}
|
|
2703
2703
|
|
|
2704
2704
|
// packages/core/src/checkpoint.ts
|
|
2705
|
-
var MUTATING = /* @__PURE__ */ new Set(["bash", "apply_patch", "term", "task", "mcp"]);
|
|
2705
|
+
var MUTATING = /* @__PURE__ */ new Set(["bash", "write", "apply_patch", "term", "task", "mcp"]);
|
|
2706
2706
|
function isMutating(toolName) {
|
|
2707
2707
|
return MUTATING.has(toolName);
|
|
2708
2708
|
}
|
|
2709
|
+
function resumeBlock(checkpoint, compat) {
|
|
2710
|
+
if (compat !== null) return { kind: "incompatible", detail: compat };
|
|
2711
|
+
const inflight = checkpoint.inFlightTool;
|
|
2712
|
+
if (inflight && (inflight.mutating || isMutating(inflight.name))) {
|
|
2713
|
+
return { kind: "execution_uncertain", tool: inflight.name, id: inflight.id };
|
|
2714
|
+
}
|
|
2715
|
+
return null;
|
|
2716
|
+
}
|
|
2709
2717
|
|
|
2710
2718
|
// packages/core/src/loop.ts
|
|
2711
2719
|
var MAX_TOOL_OUTPUT = 1e4;
|
|
@@ -3977,9 +3985,9 @@ function checkResumable(state, current) {
|
|
|
3977
3985
|
if (state.header.model.id !== current.model) {
|
|
3978
3986
|
return `recorded against model ${state.header.model.id}, now ${current.model}`;
|
|
3979
3987
|
}
|
|
3980
|
-
const
|
|
3981
|
-
if (
|
|
3982
|
-
return `the run stopped while \`${
|
|
3988
|
+
const blocker = resumeBlock(state.checkpoint, null);
|
|
3989
|
+
if (blocker?.kind === "execution_uncertain") {
|
|
3990
|
+
return `the run stopped while \`${blocker.tool}\` (${blocker.id}) was running, and whether it took effect is unknowable from here. Inspect the working tree, then start a new run`;
|
|
3983
3991
|
}
|
|
3984
3992
|
return null;
|
|
3985
3993
|
}
|
|
@@ -4480,7 +4488,95 @@ var BUILTIN_SKILLS = Object.freeze(
|
|
|
4480
4488
|
SOURCES.map((src) => parseSkill(src, "builtin"))
|
|
4481
4489
|
);
|
|
4482
4490
|
|
|
4491
|
+
// node_modules/.pnpm/get-east-asian-width@1.7.0/node_modules/get-east-asian-width/lookup-data.js
|
|
4492
|
+
var ambiguousMinimalCodePoint = 161;
|
|
4493
|
+
var ambiguousMaximumCodePoint = 1114109;
|
|
4494
|
+
var ambiguousRanges = [161, 161, 164, 164, 167, 168, 170, 170, 173, 174, 176, 180, 182, 186, 188, 191, 198, 198, 208, 208, 215, 216, 222, 225, 230, 230, 232, 234, 236, 237, 240, 240, 242, 243, 247, 250, 252, 252, 254, 254, 257, 257, 273, 273, 275, 275, 283, 283, 294, 295, 299, 299, 305, 307, 312, 312, 319, 322, 324, 324, 328, 331, 333, 333, 338, 339, 358, 359, 363, 363, 462, 462, 464, 464, 466, 466, 468, 468, 470, 470, 472, 472, 474, 474, 476, 476, 593, 593, 609, 609, 708, 708, 711, 711, 713, 715, 717, 717, 720, 720, 728, 731, 733, 733, 735, 735, 768, 879, 913, 929, 931, 937, 945, 961, 963, 969, 1025, 1025, 1040, 1103, 1105, 1105, 8208, 8208, 8211, 8214, 8216, 8217, 8220, 8221, 8224, 8226, 8228, 8231, 8240, 8240, 8242, 8243, 8245, 8245, 8251, 8251, 8254, 8254, 8308, 8308, 8319, 8319, 8321, 8324, 8364, 8364, 8451, 8451, 8453, 8453, 8457, 8457, 8467, 8467, 8470, 8470, 8481, 8482, 8486, 8486, 8491, 8491, 8531, 8532, 8539, 8542, 8544, 8555, 8560, 8569, 8585, 8585, 8592, 8601, 8632, 8633, 8658, 8658, 8660, 8660, 8679, 8679, 8704, 8704, 8706, 8707, 8711, 8712, 8715, 8715, 8719, 8719, 8721, 8721, 8725, 8725, 8730, 8730, 8733, 8736, 8739, 8739, 8741, 8741, 8743, 8748, 8750, 8750, 8756, 8759, 8764, 8765, 8776, 8776, 8780, 8780, 8786, 8786, 8800, 8801, 8804, 8807, 8810, 8811, 8814, 8815, 8834, 8835, 8838, 8839, 8853, 8853, 8857, 8857, 8869, 8869, 8895, 8895, 8978, 8978, 9312, 9449, 9451, 9547, 9552, 9587, 9600, 9615, 9618, 9621, 9632, 9633, 9635, 9641, 9650, 9651, 9654, 9655, 9660, 9661, 9664, 9665, 9670, 9672, 9675, 9675, 9678, 9681, 9698, 9701, 9711, 9711, 9733, 9734, 9737, 9737, 9742, 9743, 9756, 9756, 9758, 9758, 9792, 9792, 9794, 9794, 9824, 9825, 9827, 9829, 9831, 9834, 9836, 9837, 9839, 9839, 9886, 9887, 9919, 9919, 9926, 9933, 9935, 9939, 9941, 9953, 9955, 9955, 9960, 9961, 9963, 9969, 9972, 9972, 9974, 9977, 9979, 9980, 9982, 9983, 10045, 10045, 10102, 10111, 11094, 11097, 12872, 12879, 57344, 63743, 65024, 65039, 65533, 65533, 127232, 127242, 127248, 127277, 127280, 127337, 127344, 127373, 127375, 127376, 127387, 127404, 917760, 917999, 983040, 1048573, 1048576, 1114109];
|
|
4495
|
+
var fullwidthMinimalCodePoint = 12288;
|
|
4496
|
+
var fullwidthMaximumCodePoint = 65510;
|
|
4497
|
+
var fullwidthRanges = [12288, 12288, 65281, 65376, 65504, 65510];
|
|
4498
|
+
var wideMinimalCodePoint = 4352;
|
|
4499
|
+
var wideMaximumCodePoint = 262141;
|
|
4500
|
+
var wideRanges = [4352, 4447, 8986, 8987, 9001, 9002, 9193, 9196, 9200, 9200, 9203, 9203, 9725, 9726, 9748, 9749, 9776, 9783, 9800, 9811, 9855, 9855, 9866, 9871, 9875, 9875, 9889, 9889, 9898, 9899, 9917, 9918, 9924, 9925, 9934, 9934, 9940, 9940, 9962, 9962, 9970, 9971, 9973, 9973, 9978, 9978, 9981, 9981, 9989, 9989, 9994, 9995, 10024, 10024, 10060, 10060, 10062, 10062, 10067, 10069, 10071, 10071, 10133, 10135, 10160, 10160, 10175, 10175, 11035, 11036, 11088, 11088, 11093, 11093, 11904, 11929, 11931, 12019, 12032, 12245, 12272, 12287, 12289, 12350, 12353, 12438, 12441, 12543, 12549, 12591, 12593, 12686, 12688, 12773, 12783, 12830, 12832, 12871, 12880, 42124, 42128, 42182, 43360, 43388, 44032, 55203, 63744, 64255, 65040, 65049, 65072, 65106, 65108, 65126, 65128, 65131, 94176, 94180, 94192, 94198, 94208, 101594, 101631, 101664, 101760, 101874, 101888, 102801, 102816, 102866, 110576, 110579, 110581, 110587, 110589, 110590, 110592, 110888, 110898, 110898, 110928, 110930, 110933, 110933, 110948, 110952, 110960, 111355, 119552, 119638, 119648, 119670, 126980, 126980, 127183, 127183, 127374, 127374, 127377, 127386, 127406, 127406, 127488, 127490, 127504, 127547, 127552, 127560, 127568, 127569, 127584, 127589, 127744, 127776, 127789, 127797, 127799, 127868, 127870, 127891, 127904, 127946, 127951, 127955, 127968, 127984, 127988, 127988, 127992, 128062, 128064, 128064, 128066, 128252, 128255, 128317, 128331, 128334, 128336, 128359, 128378, 128378, 128405, 128406, 128420, 128420, 128507, 128591, 128640, 128709, 128716, 128716, 128720, 128722, 128725, 128729, 128732, 128735, 128747, 128748, 128756, 128764, 128986, 128986, 128992, 129003, 129008, 129008, 129292, 129338, 129340, 129349, 129351, 129535, 129648, 129660, 129664, 129734, 129736, 129736, 129740, 129757, 129759, 129771, 129775, 129786, 131072, 196605, 196608, 262141];
|
|
4501
|
+
|
|
4502
|
+
// node_modules/.pnpm/get-east-asian-width@1.7.0/node_modules/get-east-asian-width/utilities.js
|
|
4503
|
+
var isInRange = (ranges, codePoint) => {
|
|
4504
|
+
let low = 0;
|
|
4505
|
+
let high = Math.floor(ranges.length / 2) - 1;
|
|
4506
|
+
while (low <= high) {
|
|
4507
|
+
const mid = Math.floor((low + high) / 2);
|
|
4508
|
+
const i = mid * 2;
|
|
4509
|
+
if (codePoint < ranges[i]) {
|
|
4510
|
+
high = mid - 1;
|
|
4511
|
+
} else if (codePoint > ranges[i + 1]) {
|
|
4512
|
+
low = mid + 1;
|
|
4513
|
+
} else {
|
|
4514
|
+
return true;
|
|
4515
|
+
}
|
|
4516
|
+
}
|
|
4517
|
+
return false;
|
|
4518
|
+
};
|
|
4519
|
+
|
|
4520
|
+
// node_modules/.pnpm/get-east-asian-width@1.7.0/node_modules/get-east-asian-width/lookup.js
|
|
4521
|
+
var commonCjkCodePoint = 19968;
|
|
4522
|
+
var [wideFastPathStart, wideFastPathEnd] = /* @__PURE__ */ findWideFastPathRange(wideRanges);
|
|
4523
|
+
function findWideFastPathRange(ranges) {
|
|
4524
|
+
let fastPathStart = ranges[0];
|
|
4525
|
+
let fastPathEnd = ranges[1];
|
|
4526
|
+
for (let index = 0; index < ranges.length; index += 2) {
|
|
4527
|
+
const start = ranges[index];
|
|
4528
|
+
const end = ranges[index + 1];
|
|
4529
|
+
if (commonCjkCodePoint >= start && commonCjkCodePoint <= end) {
|
|
4530
|
+
return [start, end];
|
|
4531
|
+
}
|
|
4532
|
+
if (end - start > fastPathEnd - fastPathStart) {
|
|
4533
|
+
fastPathStart = start;
|
|
4534
|
+
fastPathEnd = end;
|
|
4535
|
+
}
|
|
4536
|
+
}
|
|
4537
|
+
return [fastPathStart, fastPathEnd];
|
|
4538
|
+
}
|
|
4539
|
+
var isAmbiguous = (codePoint) => {
|
|
4540
|
+
if (codePoint < ambiguousMinimalCodePoint || codePoint > ambiguousMaximumCodePoint) {
|
|
4541
|
+
return false;
|
|
4542
|
+
}
|
|
4543
|
+
return isInRange(ambiguousRanges, codePoint);
|
|
4544
|
+
};
|
|
4545
|
+
var isFullwidth = (codePoint) => {
|
|
4546
|
+
if (codePoint < fullwidthMinimalCodePoint || codePoint > fullwidthMaximumCodePoint) {
|
|
4547
|
+
return false;
|
|
4548
|
+
}
|
|
4549
|
+
return isInRange(fullwidthRanges, codePoint);
|
|
4550
|
+
};
|
|
4551
|
+
var isWide = (codePoint) => {
|
|
4552
|
+
if (codePoint >= wideFastPathStart && codePoint <= wideFastPathEnd) {
|
|
4553
|
+
return true;
|
|
4554
|
+
}
|
|
4555
|
+
if (codePoint < wideMinimalCodePoint || codePoint > wideMaximumCodePoint) {
|
|
4556
|
+
return false;
|
|
4557
|
+
}
|
|
4558
|
+
return isInRange(wideRanges, codePoint);
|
|
4559
|
+
};
|
|
4560
|
+
|
|
4561
|
+
// node_modules/.pnpm/get-east-asian-width@1.7.0/node_modules/get-east-asian-width/index.js
|
|
4562
|
+
function validate(codePoint) {
|
|
4563
|
+
if (!Number.isSafeInteger(codePoint)) {
|
|
4564
|
+
throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
|
|
4565
|
+
}
|
|
4566
|
+
}
|
|
4567
|
+
function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
|
|
4568
|
+
validate(codePoint);
|
|
4569
|
+
if (isFullwidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) {
|
|
4570
|
+
return 2;
|
|
4571
|
+
}
|
|
4572
|
+
return 1;
|
|
4573
|
+
}
|
|
4574
|
+
|
|
4483
4575
|
// packages/tui/src/width.ts
|
|
4576
|
+
var TAB_SPACES = " ";
|
|
4577
|
+
function expandTabs(s) {
|
|
4578
|
+
return s.replace(/\t/g, TAB_SPACES);
|
|
4579
|
+
}
|
|
4484
4580
|
var WIDE_RANGES = [
|
|
4485
4581
|
[4352, 4447],
|
|
4486
4582
|
// Hangul Jamo
|
|
@@ -4511,7 +4607,7 @@ var WIDE_RANGES = [
|
|
|
4511
4607
|
[131072, 262141]
|
|
4512
4608
|
// CJK Ext B..
|
|
4513
4609
|
];
|
|
4514
|
-
function
|
|
4610
|
+
function isWide2(cp) {
|
|
4515
4611
|
for (const [lo, hi] of WIDE_RANGES) {
|
|
4516
4612
|
if (cp >= lo && cp <= hi) return true;
|
|
4517
4613
|
if (cp < lo) break;
|
|
@@ -4525,16 +4621,24 @@ function displayWidth(s) {
|
|
|
4525
4621
|
let w = 0;
|
|
4526
4622
|
for (const ch of s) {
|
|
4527
4623
|
const cp = ch.codePointAt(0);
|
|
4624
|
+
if (ch === " ") {
|
|
4625
|
+
w += TAB_SPACES.length;
|
|
4626
|
+
continue;
|
|
4627
|
+
}
|
|
4528
4628
|
if (cp < 32 || cp === 127) continue;
|
|
4529
4629
|
if (isZeroWidth(cp)) continue;
|
|
4530
|
-
w +=
|
|
4630
|
+
w += isWide2(cp) ? 2 : eastAsianWidth(cp, { ambiguousAsWide: process.env["MOTIF_AMBIGUOUS_WIDTH"] === "2" });
|
|
4531
4631
|
}
|
|
4532
4632
|
return w;
|
|
4533
4633
|
}
|
|
4534
4634
|
function truncateToWidth(s, columns, ellipsis = "\u2026") {
|
|
4635
|
+
s = expandTabs(s);
|
|
4636
|
+
ellipsis = expandTabs(ellipsis);
|
|
4637
|
+
if (columns <= 0) return "";
|
|
4535
4638
|
if (displayWidth(s) <= columns) return s;
|
|
4639
|
+
if (displayWidth(ellipsis) > columns) return truncateToWidth(ellipsis, columns, "");
|
|
4536
4640
|
const budget = columns - displayWidth(ellipsis);
|
|
4537
|
-
if (budget <= 0) return ellipsis
|
|
4641
|
+
if (budget <= 0) return ellipsis;
|
|
4538
4642
|
let out = "";
|
|
4539
4643
|
let w = 0;
|
|
4540
4644
|
for (const ch of s) {
|
|
@@ -4546,9 +4650,13 @@ function truncateToWidth(s, columns, ellipsis = "\u2026") {
|
|
|
4546
4650
|
return out + ellipsis;
|
|
4547
4651
|
}
|
|
4548
4652
|
function truncateEndToWidth(s, columns, ellipsis = "\u2026") {
|
|
4653
|
+
s = expandTabs(s);
|
|
4654
|
+
ellipsis = expandTabs(ellipsis);
|
|
4655
|
+
if (columns <= 0) return "";
|
|
4549
4656
|
if (displayWidth(s) <= columns) return s;
|
|
4657
|
+
if (displayWidth(ellipsis) > columns) return truncateToWidth(ellipsis, columns, "");
|
|
4550
4658
|
const budget = columns - displayWidth(ellipsis);
|
|
4551
|
-
if (budget <= 0) return ellipsis
|
|
4659
|
+
if (budget <= 0) return ellipsis;
|
|
4552
4660
|
const chars = [...s];
|
|
4553
4661
|
let out = "";
|
|
4554
4662
|
let w = 0;
|
|
@@ -4561,6 +4669,7 @@ function truncateEndToWidth(s, columns, ellipsis = "\u2026") {
|
|
|
4561
4669
|
return ellipsis + out;
|
|
4562
4670
|
}
|
|
4563
4671
|
function padToWidth(s, columns, fill = " ") {
|
|
4672
|
+
s = expandTabs(s);
|
|
4564
4673
|
const gap = columns - displayWidth(s);
|
|
4565
4674
|
return gap > 0 ? s + fill.repeat(gap) : s;
|
|
4566
4675
|
}
|
|
@@ -4569,14 +4678,15 @@ function wrapToWidth(s, columns) {
|
|
|
4569
4678
|
const rows = [];
|
|
4570
4679
|
let row = "";
|
|
4571
4680
|
let used = 0;
|
|
4572
|
-
for (const ch of s) {
|
|
4573
|
-
const
|
|
4681
|
+
for (const ch of expandTabs(s)) {
|
|
4682
|
+
const shown = displayWidth(ch) > width ? "?" : ch;
|
|
4683
|
+
const w = displayWidth(shown);
|
|
4574
4684
|
if (used + w > width && used > 0) {
|
|
4575
4685
|
rows.push(row);
|
|
4576
4686
|
row = "";
|
|
4577
4687
|
used = 0;
|
|
4578
4688
|
}
|
|
4579
|
-
row +=
|
|
4689
|
+
row += shown;
|
|
4580
4690
|
used += w;
|
|
4581
4691
|
}
|
|
4582
4692
|
rows.push(row);
|
|
@@ -5234,10 +5344,18 @@ var term = {
|
|
|
5234
5344
|
/** Top-left of the visible screen. */
|
|
5235
5345
|
home: `${ESC}H`,
|
|
5236
5346
|
lineStart: "\r",
|
|
5347
|
+
/** Reserve a blank row before painting live content; may scroll at the bottom. */
|
|
5348
|
+
index: "\x1BD",
|
|
5237
5349
|
up: (n) => n > 0 ? `${ESC}${n}A` : "",
|
|
5238
5350
|
down: (n) => n > 0 ? `${ESC}${n}B` : "",
|
|
5239
5351
|
/** Absolute column, 1-based in the terminal; this takes 0-based. */
|
|
5240
|
-
column: (col) => `${ESC}${col + 1}G
|
|
5352
|
+
column: (col) => `${ESC}${col + 1}G`,
|
|
5353
|
+
/**
|
|
5354
|
+
* Synchronized output (DEC 2026). The erase and the redraw are one update,
|
|
5355
|
+
* so a terminal that understands it paints the result and not the blank.
|
|
5356
|
+
*/
|
|
5357
|
+
beginSync: `${ESC}?2026h`,
|
|
5358
|
+
endSync: `${ESC}?2026l`
|
|
5241
5359
|
};
|
|
5242
5360
|
|
|
5243
5361
|
// packages/tui/src/keys.ts
|
|
@@ -5628,13 +5746,14 @@ function isSpace(ch) {
|
|
|
5628
5746
|
}
|
|
5629
5747
|
var DEFAULT_PROMPT = "\u276F ";
|
|
5630
5748
|
function renderComposer(state, opts) {
|
|
5631
|
-
const
|
|
5749
|
+
const width = Math.max(1, opts.width);
|
|
5750
|
+
const prompt = truncateToWidth(opts.prompt ?? DEFAULT_PROMPT, width - 1, "");
|
|
5632
5751
|
const prefixWidth = displayWidth(prompt);
|
|
5633
|
-
const room =
|
|
5752
|
+
const room = width - prefixWidth;
|
|
5634
5753
|
const continuation = " ".repeat(prefixWidth);
|
|
5635
5754
|
if (state.text === "") {
|
|
5636
5755
|
return {
|
|
5637
|
-
rows: [{ prefix: prompt, body: opts.placeholder ?? "" }],
|
|
5756
|
+
rows: [{ prefix: prompt, body: truncateToWidth(opts.placeholder ?? "", room) }],
|
|
5638
5757
|
cursorRow: 0,
|
|
5639
5758
|
cursorCol: prefixWidth,
|
|
5640
5759
|
placeholder: true
|
|
@@ -5652,23 +5771,28 @@ function renderComposer(state, opts) {
|
|
|
5652
5771
|
used = 0;
|
|
5653
5772
|
};
|
|
5654
5773
|
for (const ch of state.text) {
|
|
5655
|
-
if (index === state.cursor) {
|
|
5656
|
-
cursorRow = rows.length;
|
|
5657
|
-
cursorCol = prefixWidth + used;
|
|
5658
|
-
}
|
|
5659
5774
|
if (ch === "\n") {
|
|
5775
|
+
if (index === state.cursor) {
|
|
5776
|
+
cursorRow = rows.length;
|
|
5777
|
+
cursorCol = prefixWidth + used;
|
|
5778
|
+
}
|
|
5660
5779
|
flush();
|
|
5661
5780
|
index += 1;
|
|
5662
5781
|
continue;
|
|
5663
5782
|
}
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5783
|
+
let first = true;
|
|
5784
|
+
for (const part of expandTabs(ch)) {
|
|
5785
|
+
const shown = displayWidth(part) > room ? "?" : part;
|
|
5786
|
+
const w = displayWidth(shown);
|
|
5787
|
+
if (used + w > room && used > 0) flush();
|
|
5788
|
+
if (index === state.cursor && first) {
|
|
5789
|
+
cursorRow = rows.length;
|
|
5790
|
+
cursorCol = prefixWidth + used;
|
|
5791
|
+
}
|
|
5792
|
+
body += shown;
|
|
5793
|
+
used += w;
|
|
5794
|
+
first = false;
|
|
5669
5795
|
}
|
|
5670
|
-
body += ch;
|
|
5671
|
-
used += w;
|
|
5672
5796
|
index += 1;
|
|
5673
5797
|
}
|
|
5674
5798
|
if (state.cursor >= index) {
|
|
@@ -5760,6 +5884,8 @@ var Screen = class {
|
|
|
5760
5884
|
cursorAt = null;
|
|
5761
5885
|
/** The width the footer was painted at, to notice a resize. */
|
|
5762
5886
|
paintedWidth = 0;
|
|
5887
|
+
/** A height change may clip the footer even when its contents are unchanged. */
|
|
5888
|
+
paintedHeight = 0;
|
|
5763
5889
|
composer = null;
|
|
5764
5890
|
hint = "";
|
|
5765
5891
|
label = "";
|
|
@@ -5877,13 +6003,15 @@ var Screen = class {
|
|
|
5877
6003
|
*/
|
|
5878
6004
|
setActivity(text) {
|
|
5879
6005
|
if (text === null) {
|
|
6006
|
+
if (this.activity === null && this.ticker === null) return;
|
|
5880
6007
|
this.activity = null;
|
|
5881
6008
|
if (this.ticker) {
|
|
5882
6009
|
clearInterval(this.ticker);
|
|
5883
6010
|
this.ticker = null;
|
|
5884
6011
|
}
|
|
5885
6012
|
} else {
|
|
5886
|
-
|
|
6013
|
+
const same = this.activity?.text === text;
|
|
6014
|
+
if (!same) this.activity = { text, since: this.now() };
|
|
5887
6015
|
if (!this.ticker && this.interactive) {
|
|
5888
6016
|
this.ticker = setInterval(() => {
|
|
5889
6017
|
this.tick += 1;
|
|
@@ -5891,6 +6019,7 @@ var Screen = class {
|
|
|
5891
6019
|
}, 1e3);
|
|
5892
6020
|
this.ticker.unref?.();
|
|
5893
6021
|
}
|
|
6022
|
+
if (same) return;
|
|
5894
6023
|
}
|
|
5895
6024
|
this.paint();
|
|
5896
6025
|
}
|
|
@@ -5924,7 +6053,7 @@ var Screen = class {
|
|
|
5924
6053
|
if (this.resizeTimer) clearTimeout(this.resizeTimer);
|
|
5925
6054
|
this.resizeTimer = setTimeout(() => {
|
|
5926
6055
|
this.resizeTimer = null;
|
|
5927
|
-
if (this.columns() < this.paintedWidth) this.repaintAll();
|
|
6056
|
+
if (this.columns() < this.paintedWidth || this.rowCount() !== this.paintedHeight) this.repaintAll();
|
|
5928
6057
|
else this.paint();
|
|
5929
6058
|
}, 40);
|
|
5930
6059
|
};
|
|
@@ -5969,7 +6098,6 @@ var Screen = class {
|
|
|
5969
6098
|
toggleThinking() {
|
|
5970
6099
|
this.showThinking = !this.showThinking;
|
|
5971
6100
|
this.commits.reset();
|
|
5972
|
-
this.clearFooter();
|
|
5973
6101
|
this.paint();
|
|
5974
6102
|
}
|
|
5975
6103
|
/* ---------------------------------------------------------------- */
|
|
@@ -6010,14 +6138,12 @@ var Screen = class {
|
|
|
6010
6138
|
setCwd(cwd) {
|
|
6011
6139
|
this.cwd = cwd;
|
|
6012
6140
|
this.commits.reset();
|
|
6013
|
-
this.clearFooter();
|
|
6014
6141
|
this.paint();
|
|
6015
6142
|
}
|
|
6016
6143
|
/** Show tool output whole, or clipped to a few lines. Ctrl-O in the session. */
|
|
6017
6144
|
toggleVerbose() {
|
|
6018
6145
|
this.verbose = !this.verbose;
|
|
6019
6146
|
this.commits.reset();
|
|
6020
|
-
this.clearFooter();
|
|
6021
6147
|
this.paint();
|
|
6022
6148
|
}
|
|
6023
6149
|
get verboseOutput() {
|
|
@@ -6028,15 +6154,45 @@ var Screen = class {
|
|
|
6028
6154
|
this.repaintAll();
|
|
6029
6155
|
}
|
|
6030
6156
|
paint() {
|
|
6031
|
-
if (this.interactive && this.footer.length > 0 && this.columns() < this.paintedWidth) {
|
|
6157
|
+
if (this.interactive && this.footer.length > 0 && (this.columns() < this.paintedWidth || this.rowCount() !== this.paintedHeight)) {
|
|
6032
6158
|
this.repaintAll();
|
|
6033
6159
|
return;
|
|
6034
6160
|
}
|
|
6035
|
-
this.
|
|
6161
|
+
const width = this.columns();
|
|
6162
|
+
const next = this.interactive ? this.buildFooter(width) : null;
|
|
6036
6163
|
const settled = this.settledLines();
|
|
6037
|
-
const
|
|
6038
|
-
|
|
6039
|
-
this.
|
|
6164
|
+
const pending = Math.max(0, settled.length - this.commits.count);
|
|
6165
|
+
if (pending === 0 && this.sameFooter(next, width)) return;
|
|
6166
|
+
this.withSync(() => {
|
|
6167
|
+
this.clearFooter();
|
|
6168
|
+
const fresh = this.commits.take(settled.map((l) => l.text));
|
|
6169
|
+
for (const line2 of settled.slice(settled.length - fresh.length)) this.write(this.colour(line2) + "\n");
|
|
6170
|
+
if (next) this.writeFooter(next, width);
|
|
6171
|
+
else this.paintFooter();
|
|
6172
|
+
});
|
|
6173
|
+
}
|
|
6174
|
+
/** True when the footer about to be drawn is the one already on screen. */
|
|
6175
|
+
sameFooter(next, width) {
|
|
6176
|
+
if (!this.interactive || next === null) return true;
|
|
6177
|
+
if (this.paintedWidth !== width || this.footer.length !== next.rows.length) return false;
|
|
6178
|
+
if (this.cursorAt?.row !== next.cursor?.row || this.cursorAt?.col !== next.cursor?.col) return false;
|
|
6179
|
+
return this.footer.every((row, i) => row.text === next.rows[i].text);
|
|
6180
|
+
}
|
|
6181
|
+
/**
|
|
6182
|
+
* One terminal update. Synchronized output is requested only while a footer
|
|
6183
|
+
* is actually being replaced; a skipped paint writes neither sequence.
|
|
6184
|
+
*/
|
|
6185
|
+
withSync(body) {
|
|
6186
|
+
if (!this.interactive) {
|
|
6187
|
+
body();
|
|
6188
|
+
return;
|
|
6189
|
+
}
|
|
6190
|
+
this.write(term.beginSync);
|
|
6191
|
+
try {
|
|
6192
|
+
body();
|
|
6193
|
+
} finally {
|
|
6194
|
+
this.write(term.endSync);
|
|
6195
|
+
}
|
|
6040
6196
|
}
|
|
6041
6197
|
/**
|
|
6042
6198
|
* The settled transcript, rendered once per change.
|
|
@@ -6067,16 +6223,19 @@ var Screen = class {
|
|
|
6067
6223
|
const width = this.columns();
|
|
6068
6224
|
const settled = this.settledLines();
|
|
6069
6225
|
const fresh = this.commits.take(settled.map((l) => l.text));
|
|
6070
|
-
|
|
6226
|
+
const previous = settled.slice(0, settled.length - fresh.length);
|
|
6071
6227
|
const footer = this.buildFooter(width);
|
|
6072
6228
|
const physical = [];
|
|
6073
|
-
for (const l of
|
|
6229
|
+
for (const l of previous) for (const t of wrapToWidth(l.text, width)) physical.push(this.colour({ ...l, text: t }));
|
|
6074
6230
|
const keep = Math.max(0, this.rowCount() - footer.rows.length - 1);
|
|
6075
|
-
this.
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6231
|
+
this.withSync(() => {
|
|
6232
|
+
this.footer = [];
|
|
6233
|
+
this.cursorAt = null;
|
|
6234
|
+
this.write(term.clearScreen + term.home);
|
|
6235
|
+
for (const line2 of physical.slice(Math.max(0, physical.length - keep))) this.write(line2 + "\n");
|
|
6236
|
+
for (const line2 of settled.slice(previous.length)) this.write(this.colour(line2) + "\n");
|
|
6237
|
+
this.writeFooter(footer, width);
|
|
6238
|
+
});
|
|
6080
6239
|
}
|
|
6081
6240
|
/** Footer rows from text that may be longer than the width: split here, never wrapped by the terminal. */
|
|
6082
6241
|
rows(text, colourWith) {
|
|
@@ -6116,18 +6275,26 @@ var Screen = class {
|
|
|
6116
6275
|
} else {
|
|
6117
6276
|
rows.push(...this.rows(this.statusOnly(), (t) => t));
|
|
6118
6277
|
}
|
|
6119
|
-
|
|
6278
|
+
const limit = Math.max(0, this.rowCount() - 1);
|
|
6279
|
+
let start = Math.max(0, rows.length - limit);
|
|
6280
|
+
if (cursor && cursor.row < start) start = Math.max(0, cursor.row - Math.floor(limit / 2));
|
|
6281
|
+
return {
|
|
6282
|
+
rows: rows.slice(start, start + limit),
|
|
6283
|
+
cursor: cursor && cursor.row >= start && cursor.row < start + limit ? { row: cursor.row - start, col: cursor.col } : null
|
|
6284
|
+
};
|
|
6120
6285
|
}
|
|
6121
6286
|
writeFooter(footer, width) {
|
|
6122
6287
|
const { rows, cursor } = footer;
|
|
6123
6288
|
if (this.composer) this.write(term.hideCursor);
|
|
6124
|
-
|
|
6289
|
+
this.write(term.lineStart + term.index.repeat(rows.length) + term.up(rows.length));
|
|
6290
|
+
for (const r of rows) this.write(r.text + term.down(1) + term.lineStart);
|
|
6125
6291
|
this.footer = rows;
|
|
6126
6292
|
this.paintedWidth = width;
|
|
6293
|
+
this.paintedHeight = this.rowCount();
|
|
6127
6294
|
this.cursorAt = cursor;
|
|
6128
6295
|
if (cursor) {
|
|
6129
6296
|
this.write(term.up(rows.length - cursor.row) + term.column(cursor.col) + term.showCursor);
|
|
6130
|
-
}
|
|
6297
|
+
} else if (rows.length === 0) this.write(term.showCursor);
|
|
6131
6298
|
}
|
|
6132
6299
|
/**
|
|
6133
6300
|
* The composer block: a bordered box around the editor rows, then the menu.
|
|
@@ -6136,7 +6303,13 @@ var Screen = class {
|
|
|
6136
6303
|
* and nothing wraps. Returns where the cursor belongs among the rows.
|
|
6137
6304
|
*/
|
|
6138
6305
|
composerRows(view, width) {
|
|
6139
|
-
const
|
|
6306
|
+
const boxed = width >= 8;
|
|
6307
|
+
const inner = boxed ? width - 4 : Math.max(1, width);
|
|
6308
|
+
const wideBox = displayWidth("\u2500") > 1;
|
|
6309
|
+
const side = wideBox ? "|" : "\u2502";
|
|
6310
|
+
const left = boxed ? `${side} ` : "";
|
|
6311
|
+
const right = boxed ? ` ${side}` : "";
|
|
6312
|
+
const edge = boxed ? 2 : 0;
|
|
6140
6313
|
const draft = view.secret ? { text: "\u2022".repeat([...view.draft.text].length), cursor: view.draft.cursor } : view.draft;
|
|
6141
6314
|
const render = renderComposer(draft, {
|
|
6142
6315
|
width: inner,
|
|
@@ -6144,10 +6317,10 @@ var Screen = class {
|
|
|
6144
6317
|
...view.placeholder !== void 0 && !view.secret ? { placeholder: view.placeholder } : {}
|
|
6145
6318
|
});
|
|
6146
6319
|
const border = (l, r) => ({
|
|
6147
|
-
text: paint(`${l}${"\u2500".repeat(inner + 2)}${r}`, style.faint),
|
|
6320
|
+
text: paint(`${wideBox ? "+" : l}${(wideBox ? "-" : "\u2500").repeat(inner + 2)}${wideBox ? "+" : r}`, style.faint),
|
|
6148
6321
|
width: inner + 4
|
|
6149
6322
|
});
|
|
6150
|
-
const rows = [border("\u256D", "\u256E")];
|
|
6323
|
+
const rows = boxed ? [border("\u256D", "\u256E")] : [];
|
|
6151
6324
|
if (view.confirm) {
|
|
6152
6325
|
const fit = (s) => {
|
|
6153
6326
|
const t = truncateToWidth(s, inner);
|
|
@@ -6157,11 +6330,11 @@ var Screen = class {
|
|
|
6157
6330
|
const firstChoice = body.length - view.confirm.choices.length;
|
|
6158
6331
|
for (const [i, l] of body.entries()) {
|
|
6159
6332
|
const painted = i === 0 ? paint(fit(l), style.bold) : i >= firstChoice ? l.startsWith("\u276F") ? paint(fit(l), style.accent) : paint(fit(l), style.faint) : fit(l);
|
|
6160
|
-
rows.push({ text: `${paint(
|
|
6333
|
+
rows.push({ text: `${paint(left, style.faint)}${painted}${paint(right, style.faint)}`, width });
|
|
6161
6334
|
}
|
|
6162
|
-
rows.push(border("\u2570", "\u256F"));
|
|
6335
|
+
if (boxed) rows.push(border("\u2570", "\u256F"));
|
|
6163
6336
|
const selectedLine = view.confirm.choices.findIndex((c) => c.startsWith("\u276F"));
|
|
6164
|
-
return { rows, cursorRow:
|
|
6337
|
+
return { rows, cursorRow: Number(boxed) + firstChoice + Math.max(0, selectedLine), cursorCol: edge };
|
|
6165
6338
|
}
|
|
6166
6339
|
let header = 0;
|
|
6167
6340
|
if (view.secret) {
|
|
@@ -6175,7 +6348,7 @@ var Screen = class {
|
|
|
6175
6348
|
body.push({ text: "", title: false });
|
|
6176
6349
|
for (const { text, title } of body) {
|
|
6177
6350
|
const painted = title ? paint(fit(text), style.bold) : paint(fit(text), style.faint);
|
|
6178
|
-
rows.push({ text: `${paint(
|
|
6351
|
+
rows.push({ text: `${paint(left, style.faint)}${painted}${paint(right, style.faint)}`, width });
|
|
6179
6352
|
}
|
|
6180
6353
|
header = body.length;
|
|
6181
6354
|
}
|
|
@@ -6184,15 +6357,16 @@ var Screen = class {
|
|
|
6184
6357
|
const plainWidth = displayWidth(row.prefix) + displayWidth(row.body);
|
|
6185
6358
|
const pad = " ".repeat(Math.max(0, inner - plainWidth));
|
|
6186
6359
|
rows.push({
|
|
6187
|
-
text: `${paint(
|
|
6188
|
-
width
|
|
6360
|
+
text: `${paint(left, style.faint)}${paint(row.prefix, style.accent)}${body}${pad}${paint(right, style.faint)}`,
|
|
6361
|
+
width
|
|
6189
6362
|
});
|
|
6190
6363
|
}
|
|
6191
|
-
const cursorRow =
|
|
6192
|
-
const cursorCol = Math.min(
|
|
6193
|
-
rows.push(border("\u2570", "\u256F"));
|
|
6364
|
+
const cursorRow = Number(boxed) + header + render.cursorRow;
|
|
6365
|
+
const cursorCol = Math.min(edge + render.cursorCol, Math.max(0, width - 1));
|
|
6366
|
+
if (boxed) rows.push(border("\u2570", "\u256F"));
|
|
6194
6367
|
if (view.menu && view.menu.items.length > 0 && !view.secret) {
|
|
6195
|
-
const
|
|
6368
|
+
const maxRows = Math.max(0, Math.min(8, this.rowCount() - rows.length - 2));
|
|
6369
|
+
const menu = maxRows > 0 ? renderMenu(view.menu.items, view.menu.selected, { width, maxRows, ...view.menu.prefix ? { prefix: view.menu.prefix } : {} }) : { rows: [], selectedRow: -1 };
|
|
6196
6370
|
menu.rows.forEach((row, i) => {
|
|
6197
6371
|
const t = truncateToWidth(row, width);
|
|
6198
6372
|
rows.push({
|
|
@@ -6206,7 +6380,7 @@ var Screen = class {
|
|
|
6206
6380
|
/**
|
|
6207
6381
|
* The line under the prompt: a hint on the left, the session's numbers on
|
|
6208
6382
|
* the right. The right side goes first when the two do not fit, and the
|
|
6209
|
-
* hint is
|
|
6383
|
+
* hint is clipped only when it cannot fit by itself.
|
|
6210
6384
|
*/
|
|
6211
6385
|
hintRows(width) {
|
|
6212
6386
|
const left = this.hint === "" ? "? for shortcuts" : this.hint;
|
|
@@ -6216,7 +6390,7 @@ var Screen = class {
|
|
|
6216
6390
|
this.label ? paint(this.label, style.faint) : "",
|
|
6217
6391
|
...parts.map((r) => paint(`${r.label} ${r.value}`, severityColor(r.severity)))
|
|
6218
6392
|
].filter(Boolean).join(paint(" \xB7 ", style.dim));
|
|
6219
|
-
const leftText = ` ${
|
|
6393
|
+
const leftText = truncateToWidth(` ${left}`, width);
|
|
6220
6394
|
const gap = width - displayWidth(leftText) - displayWidth(rightPlain);
|
|
6221
6395
|
if (rightPlain === "" || gap < 2) return [{ text: paint(leftText, style.faint), width: displayWidth(leftText) }];
|
|
6222
6396
|
return [{ text: `${paint(leftText, style.faint)}${" ".repeat(gap)}${rightPainted}`, width }];
|
|
@@ -6247,7 +6421,7 @@ var Screen = class {
|
|
|
6247
6421
|
this.write(term.up(total));
|
|
6248
6422
|
for (let i = 0; i < total; i++) {
|
|
6249
6423
|
this.write(term.clearLine + term.lineStart);
|
|
6250
|
-
if (i < total - 1) this.write(
|
|
6424
|
+
if (i < total - 1) this.write(term.down(1));
|
|
6251
6425
|
}
|
|
6252
6426
|
this.write(term.up(total - 1));
|
|
6253
6427
|
this.footer = [];
|
|
@@ -7430,16 +7604,22 @@ async function runBash(command, cwd, timeoutMs, policy, scratch, signal) {
|
|
|
7430
7604
|
}
|
|
7431
7605
|
return { ok: r.code === 0, output: r.output.trim() || `(exit ${r.code})` };
|
|
7432
7606
|
}
|
|
7607
|
+
function toLogicalLines(text) {
|
|
7608
|
+
if (text === "") return [];
|
|
7609
|
+
const normalized = text.endsWith("\n") ? text.slice(0, -1) : text;
|
|
7610
|
+
return normalized.split("\n");
|
|
7611
|
+
}
|
|
7433
7612
|
function readSlice(path, cwd, offset, limit) {
|
|
7434
7613
|
try {
|
|
7435
7614
|
const text = readFileSync5(resolve4(cwd, path), "utf8");
|
|
7436
|
-
const lines = text
|
|
7615
|
+
const lines = toLogicalLines(text);
|
|
7437
7616
|
const start = Math.max(0, (offset ?? 1) - 1);
|
|
7438
7617
|
const end = limit !== void 0 ? start + limit : lines.length;
|
|
7439
7618
|
const slice = lines.slice(start, end);
|
|
7440
7619
|
const numbered = slice.map((l, i) => `${start + i + 1} ${l}`).join("\n");
|
|
7441
|
-
const
|
|
7442
|
-
|
|
7620
|
+
const remaining = Math.max(0, lines.length - end);
|
|
7621
|
+
const more = remaining > 0 ? numbered ? `
|
|
7622
|
+
\u2026 ${remaining} more lines` : `\u2026 ${remaining} more lines` : "";
|
|
7443
7623
|
return { ok: true, output: numbered + more };
|
|
7444
7624
|
} catch (err) {
|
|
7445
7625
|
return { ok: false, output: String(err) };
|
|
@@ -7454,7 +7634,7 @@ function writeFile(path, content, cwd) {
|
|
|
7454
7634
|
const lines = content === "" ? 0 : content.split("\n").length;
|
|
7455
7635
|
return {
|
|
7456
7636
|
ok: true,
|
|
7457
|
-
output: `${existed ? "replaced" : "created"} ${path} (${lines} lines, ${content
|
|
7637
|
+
output: `${existed ? "replaced" : "created"} ${path} (${lines} lines, ${Buffer.byteLength(content, "utf8")} bytes)`
|
|
7458
7638
|
};
|
|
7459
7639
|
} catch (err) {
|
|
7460
7640
|
return { ok: false, output: String(err) };
|
|
@@ -7850,6 +8030,8 @@ var Chat = class {
|
|
|
7850
8030
|
this.screen.append({ kind: "system", title: "continuing", lines: await this.resume(this.opts.continueFrom) });
|
|
7851
8031
|
} catch (err) {
|
|
7852
8032
|
this.screen.append({ kind: "notice", level: "error", text: err instanceof Error ? err.message : String(err) });
|
|
8033
|
+
this.refresh();
|
|
8034
|
+
return;
|
|
7853
8035
|
}
|
|
7854
8036
|
this.refresh();
|
|
7855
8037
|
}
|
|
@@ -8955,6 +9137,12 @@ ${output.slice(0, 8e3)}
|
|
|
8955
9137
|
const state = loadResume(path);
|
|
8956
9138
|
if (state.corruption !== void 0) throw new Error(`this journal is corrupt (${state.corruption})`);
|
|
8957
9139
|
if (!state.checkpoint) throw new Error("no checkpoint was written in that session; there is nothing to continue");
|
|
9140
|
+
const blocker = resumeBlock(state.checkpoint, null);
|
|
9141
|
+
if (blocker?.kind === "execution_uncertain") {
|
|
9142
|
+
throw new Error(
|
|
9143
|
+
`cannot resume: the run stopped while \`${blocker.tool}\` (${blocker.id}) was running, and whether it took effect is unknowable from here. Inspect the working tree, then start a new run`
|
|
9144
|
+
);
|
|
9145
|
+
}
|
|
8958
9146
|
const lines = [];
|
|
8959
9147
|
if (state.checkpoint.currentChannel !== this.settings.channel) {
|
|
8960
9148
|
this.settings.channel = state.checkpoint.currentChannel;
|
|
@@ -9218,7 +9406,7 @@ function saveUserSetting(key, value, home = homedir4()) {
|
|
|
9218
9406
|
}
|
|
9219
9407
|
|
|
9220
9408
|
// packages/cli/src/main.ts
|
|
9221
|
-
var VERSION = "0.3.
|
|
9409
|
+
var VERSION = "0.3.4";
|
|
9222
9410
|
var SHORT_FLAGS = { p: "print", c: "continue", i: "interactive", v: "verbose", h: "help" };
|
|
9223
9411
|
var BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
|
|
9224
9412
|
"print",
|
|
@@ -9821,6 +10009,7 @@ user file ${stored.userPath}${existsSync10(stored.userPath) ? "" : " (absent
|
|
|
9821
10009
|
const activeToolNames = CORE_TOOL_NAMES.slice(0, activeTools.length);
|
|
9822
10010
|
const schemaHash = toolSchemaHash(activeTools);
|
|
9823
10011
|
const promptHash = systemPromptHash(systemFor(channel));
|
|
10012
|
+
const printOnly = args.flags["print"] === true || args.flags["p"] === true;
|
|
9824
10013
|
let task;
|
|
9825
10014
|
if (resumeFrom) {
|
|
9826
10015
|
const blocker = checkResumable(resumeFrom, {
|
|
@@ -9834,7 +10023,7 @@ user file ${stored.userPath}${existsSync10(stored.userPath) ? "" : " (absent
|
|
|
9834
10023
|
return 2;
|
|
9835
10024
|
}
|
|
9836
10025
|
task = resumeFrom.task ?? "";
|
|
9837
|
-
process.stdout.write(
|
|
10026
|
+
(printOnly ? process.stderr : process.stdout).write(
|
|
9838
10027
|
`resuming ${resumeFrom.header.runId} from turn ${resumeFrom.checkpoint.turn}${resumeFrom.truncatedTail ? " (last record was truncated)" : ""}
|
|
9839
10028
|
`
|
|
9840
10029
|
);
|
|
@@ -9842,7 +10031,6 @@ user file ${stored.userPath}${existsSync10(stored.userPath) ? "" : " (absent
|
|
|
9842
10031
|
task = args.rest.join(" ").trim();
|
|
9843
10032
|
}
|
|
9844
10033
|
const wantsChat = args.flags["interactive"] === true || args.flags["chat"] === true || args.flags["continue"] === true;
|
|
9845
|
-
const printOnly = args.flags["print"] === true || args.flags["p"] === true;
|
|
9846
10034
|
const tty = Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
9847
10035
|
if (wantsChat && !tty) {
|
|
9848
10036
|
throw new UsageError("--interactive needs a terminal on stdin and stdout");
|
|
@@ -9929,6 +10117,7 @@ user file ${stored.userPath}${existsSync10(stored.userPath) ? "" : " (absent
|
|
|
9929
10117
|
maxTurns,
|
|
9930
10118
|
...maxOutputTokens !== void 0 ? { maxOutputTokens } : {},
|
|
9931
10119
|
...seed !== void 0 ? { seed } : {},
|
|
10120
|
+
...resumeFrom?.checkpoint ? { resume: resumeFrom.checkpoint } : {},
|
|
9932
10121
|
replyEnds: true,
|
|
9933
10122
|
confirmDone: false
|
|
9934
10123
|
});
|