@locusai/cli 0.17.11 → 0.17.13
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/bin/locus.js +5 -54
- package/package.json +1 -1
package/bin/locus.js
CHANGED
|
@@ -2763,7 +2763,7 @@ function detectImages(input) {
|
|
|
2763
2763
|
continue;
|
|
2764
2764
|
addIfImage(match[1], match[0], detected, byResolved);
|
|
2765
2765
|
}
|
|
2766
|
-
const escapedPattern = /(?:\/|~\/|\.\/)?(?:[^\s"'\\]
|
|
2766
|
+
const escapedPattern = /(?:\/|~\/|\.\/)?(?:[^\s"'\\]|\\ )+\.(?:png|jpg|jpeg|gif|webp|bmp|svg|tiff?)/gi;
|
|
2767
2767
|
for (const match of input.matchAll(escapedPattern)) {
|
|
2768
2768
|
if (!match[0])
|
|
2769
2769
|
continue;
|
|
@@ -2976,8 +2976,6 @@ class InputHandler {
|
|
|
2976
2976
|
let pasteBuffer = "";
|
|
2977
2977
|
let imageAttachments = [];
|
|
2978
2978
|
let nextImageId = 1;
|
|
2979
|
-
let pasteAttachments = [];
|
|
2980
|
-
let nextPasteId = 1;
|
|
2981
2979
|
const history = this.getHistory();
|
|
2982
2980
|
let historyIndex = -1;
|
|
2983
2981
|
let historyDraft = "";
|
|
@@ -3023,15 +3021,6 @@ class InputHandler {
|
|
|
3023
3021
|
preferredColumn = null;
|
|
3024
3022
|
resetHistoryNavigation();
|
|
3025
3023
|
};
|
|
3026
|
-
const insertRaw = (text) => {
|
|
3027
|
-
if (!text)
|
|
3028
|
-
return;
|
|
3029
|
-
const next = buffer.slice(0, cursor) + text + buffer.slice(cursor);
|
|
3030
|
-
cursor += text.length;
|
|
3031
|
-
setBuffer(next);
|
|
3032
|
-
preferredColumn = null;
|
|
3033
|
-
resetHistoryNavigation();
|
|
3034
|
-
};
|
|
3035
3024
|
const deleteBeforeCursor = () => {
|
|
3036
3025
|
if (cursor === 0)
|
|
3037
3026
|
return;
|
|
@@ -3133,8 +3122,6 @@ class InputHandler {
|
|
|
3133
3122
|
setBuffer(history[historyIndex] ?? "");
|
|
3134
3123
|
imageAttachments = [];
|
|
3135
3124
|
nextImageId = 1;
|
|
3136
|
-
pasteAttachments = [];
|
|
3137
|
-
nextPasteId = 1;
|
|
3138
3125
|
cursor = buffer.length;
|
|
3139
3126
|
preferredColumn = null;
|
|
3140
3127
|
};
|
|
@@ -3146,16 +3133,12 @@ class InputHandler {
|
|
|
3146
3133
|
setBuffer(history[historyIndex] ?? "");
|
|
3147
3134
|
imageAttachments = [];
|
|
3148
3135
|
nextImageId = 1;
|
|
3149
|
-
pasteAttachments = [];
|
|
3150
|
-
nextPasteId = 1;
|
|
3151
3136
|
} else {
|
|
3152
3137
|
historyIndex = -1;
|
|
3153
3138
|
setBuffer(historyDraft);
|
|
3154
3139
|
historyDraft = "";
|
|
3155
3140
|
imageAttachments = [];
|
|
3156
3141
|
nextImageId = 1;
|
|
3157
|
-
pasteAttachments = [];
|
|
3158
|
-
nextPasteId = 1;
|
|
3159
3142
|
}
|
|
3160
3143
|
cursor = buffer.length;
|
|
3161
3144
|
preferredColumn = null;
|
|
@@ -3210,10 +3193,9 @@ class InputHandler {
|
|
|
3210
3193
|
imageAttachments = normalized.attachments;
|
|
3211
3194
|
nextImageId = normalized.nextId;
|
|
3212
3195
|
const images = collectReferencedAttachments(buffer, imageAttachments);
|
|
3213
|
-
const finalText = expandPastePlaceholders(buffer, pasteAttachments);
|
|
3214
3196
|
out.write(`\r
|
|
3215
3197
|
`);
|
|
3216
|
-
finish({ type: "submit", text:
|
|
3198
|
+
finish({ type: "submit", text: buffer, images });
|
|
3217
3199
|
};
|
|
3218
3200
|
const clearBufferOrInterrupt = () => {
|
|
3219
3201
|
if (buffer.length > 0) {
|
|
@@ -3221,8 +3203,6 @@ class InputHandler {
|
|
|
3221
3203
|
cursor = 0;
|
|
3222
3204
|
imageAttachments = [];
|
|
3223
3205
|
nextImageId = 1;
|
|
3224
|
-
pasteAttachments = [];
|
|
3225
|
-
nextPasteId = 1;
|
|
3226
3206
|
preferredColumn = null;
|
|
3227
3207
|
resetHistoryNavigation();
|
|
3228
3208
|
render();
|
|
@@ -3243,19 +3223,11 @@ ${dim("Press Ctrl+C again to exit")}\r
|
|
|
3243
3223
|
const maybeHeuristicPaste = (chunk) => {
|
|
3244
3224
|
if (chunk.includes(ESC))
|
|
3245
3225
|
return false;
|
|
3246
|
-
|
|
3247
|
-
if (!looksLikePaste(chunk) && !isImagePath) {
|
|
3226
|
+
if (!looksLikePaste(chunk) && !looksLikeImagePathChunk(chunk)) {
|
|
3248
3227
|
return false;
|
|
3249
3228
|
}
|
|
3250
3229
|
const normalized = normalizeLineEndings(chunk);
|
|
3251
|
-
|
|
3252
|
-
`)) {
|
|
3253
|
-
const id = nextPasteId++;
|
|
3254
|
-
pasteAttachments.push({ id, content: normalized });
|
|
3255
|
-
insertRaw(buildPastePlaceholder(id, normalized));
|
|
3256
|
-
} else {
|
|
3257
|
-
insertText(normalized);
|
|
3258
|
-
}
|
|
3230
|
+
insertText(normalized);
|
|
3259
3231
|
render();
|
|
3260
3232
|
return true;
|
|
3261
3233
|
};
|
|
@@ -3380,16 +3352,8 @@ ${dim("Press Ctrl+C again to exit")}\r
|
|
|
3380
3352
|
pasteBuffer += pending.slice(0, endIdx);
|
|
3381
3353
|
pending = pending.slice(endIdx + PASTE_END.length);
|
|
3382
3354
|
isPasting = false;
|
|
3383
|
-
|
|
3355
|
+
insertText(normalizeLineEndings(pasteBuffer));
|
|
3384
3356
|
pasteBuffer = "";
|
|
3385
|
-
if (pasteContent.includes(`
|
|
3386
|
-
`)) {
|
|
3387
|
-
const id = nextPasteId++;
|
|
3388
|
-
pasteAttachments.push({ id, content: pasteContent });
|
|
3389
|
-
insertRaw(buildPastePlaceholder(id, pasteContent));
|
|
3390
|
-
} else {
|
|
3391
|
-
insertText(pasteContent);
|
|
3392
|
-
}
|
|
3393
3357
|
render();
|
|
3394
3358
|
continue;
|
|
3395
3359
|
}
|
|
@@ -3546,19 +3510,6 @@ function looksLikePaste(chunk) {
|
|
|
3546
3510
|
return chunk.includes(`
|
|
3547
3511
|
`) || chunk.includes("\r");
|
|
3548
3512
|
}
|
|
3549
|
-
function buildPastePlaceholder(id, content) {
|
|
3550
|
-
const lines = content.split(`
|
|
3551
|
-
`);
|
|
3552
|
-
const lineCount = content.endsWith(`
|
|
3553
|
-
`) ? lines.length - 1 : lines.length;
|
|
3554
|
-
return `[Pasted text #${id} +${lineCount} lines]`;
|
|
3555
|
-
}
|
|
3556
|
-
function expandPastePlaceholders(text, attachments) {
|
|
3557
|
-
return text.replace(/\[Pasted text #(\d+) \+\d+ lines\]/g, (_, idStr) => {
|
|
3558
|
-
const id = parseInt(idStr, 10);
|
|
3559
|
-
return attachments.find((a) => a.id === id)?.content ?? "";
|
|
3560
|
-
});
|
|
3561
|
-
}
|
|
3562
3513
|
function looksLikeImagePathChunk(chunk) {
|
|
3563
3514
|
if (chunk.length <= 1)
|
|
3564
3515
|
return false;
|