acp-kernel 0.0.67-pr.269.126 → 0.0.67-pr.271.128
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/index.js +49 -9
- package/dist/index.js.map +1 -1
- package/dist/parse-compress-input.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3910,16 +3910,17 @@ function validateEntries(entries, callId) {
|
|
|
3910
3910
|
}
|
|
3911
3911
|
return { ranges, invalid, reasons };
|
|
3912
3912
|
}
|
|
3913
|
-
var REF_PAIR_IN_LINE =
|
|
3914
|
-
var SINGLE_REF_IN_LINE =
|
|
3913
|
+
var REF_PAIR_IN_LINE = /^([mb]\d{1,7})\s*(?:[-\u2013\u2014\u2026~]|\.\.\.|to)\s*([mb]\d{1,7})\b/i;
|
|
3914
|
+
var SINGLE_REF_IN_LINE = /^([mb]\d{1,7})\b/i;
|
|
3915
3915
|
function normalizeLineRef(raw) {
|
|
3916
3916
|
const lower = raw.toLowerCase();
|
|
3917
3917
|
const digits = lower.slice(1);
|
|
3918
3918
|
return lower[0] === "b" ? `b${digits}` : `m${digits.padStart(5, "0")}`;
|
|
3919
3919
|
}
|
|
3920
3920
|
function parseLineEntry(entry, callId) {
|
|
3921
|
-
const
|
|
3922
|
-
const head =
|
|
3921
|
+
const nl = entry.indexOf("\n");
|
|
3922
|
+
const head = (nl === -1 ? entry : entry.slice(0, nl)).trim();
|
|
3923
|
+
const summary = (nl === -1 ? "" : entry.slice(nl + 1)).trim();
|
|
3923
3924
|
const pair = REF_PAIR_IN_LINE.exec(head);
|
|
3924
3925
|
let startRef;
|
|
3925
3926
|
let endRef;
|
|
@@ -3930,15 +3931,13 @@ function parseLineEntry(entry, callId) {
|
|
|
3930
3931
|
afterRefs = pair.index + pair[0].length;
|
|
3931
3932
|
} else {
|
|
3932
3933
|
const single = SINGLE_REF_IN_LINE.exec(head);
|
|
3933
|
-
if (single === null) return { reason: "line entry: no mNNNNN refs in header" };
|
|
3934
|
+
if (single === null) return { reason: "line entry: no mNNNNN/bN refs in header" };
|
|
3934
3935
|
startRef = normalizeLineRef(single[1]);
|
|
3935
3936
|
endRef = startRef;
|
|
3936
3937
|
afterRefs = single.index + single[0].length;
|
|
3937
3938
|
}
|
|
3938
|
-
const lineEnd = entry.indexOf("\n", afterRefs);
|
|
3939
|
-
const explicitTopic = (lineEnd === -1 ? entry.slice(afterRefs) : entry.slice(afterRefs, lineEnd)).trim();
|
|
3940
|
-
const summary = (lineEnd === -1 ? "" : entry.slice(lineEnd + 1)).trim();
|
|
3941
3939
|
if (summary.length === 0) return { reason: "line entry: missing summary after the refs header line" };
|
|
3940
|
+
const explicitTopic = head.slice(afterRefs).trim();
|
|
3942
3941
|
const range = {
|
|
3943
3942
|
startRef,
|
|
3944
3943
|
endRef,
|
|
@@ -3956,7 +3955,7 @@ function deriveTopicFromSummary(summary) {
|
|
|
3956
3955
|
return text.length > 60 ? text.slice(0, 60).trimEnd() : text;
|
|
3957
3956
|
}
|
|
3958
3957
|
function splitLineEntries(content) {
|
|
3959
|
-
const parts = content.split(/\n(?=[mb]\d{1,7}\s*(?:[-\u2013\u2014~]|\.\.\.|to)\s*[mb]\d{1,7}\b)/i).map((p) => p.trim()).filter((p) => p.length > 0);
|
|
3958
|
+
const parts = content.split(/\n(?=[mb]\d{1,7}\s*(?:[-\u2013\u2014\u2026~]|\.\.\.|to)\s*[mb]\d{1,7}\b)/i).map((p) => p.trim()).filter((p) => p.length > 0);
|
|
3960
3959
|
return parts.length > 0 ? parts : [content.trim()];
|
|
3961
3960
|
}
|
|
3962
3961
|
function validateEntry(entry, callId) {
|
|
@@ -4001,6 +4000,13 @@ function tryParseLenient(s) {
|
|
|
4001
4000
|
} catch {
|
|
4002
4001
|
}
|
|
4003
4002
|
}
|
|
4003
|
+
const ctrlFixed = repairAtParserPositions(noTrailingCommas);
|
|
4004
|
+
if (ctrlFixed !== noTrailingCommas) {
|
|
4005
|
+
try {
|
|
4006
|
+
return JSON.parse(ctrlFixed);
|
|
4007
|
+
} catch {
|
|
4008
|
+
}
|
|
4009
|
+
}
|
|
4004
4010
|
return void 0;
|
|
4005
4011
|
}
|
|
4006
4012
|
function normalizeSingleQuotes(raw) {
|
|
@@ -4141,6 +4147,40 @@ function escapeRawNewlinesInStrings(s) {
|
|
|
4141
4147
|
}
|
|
4142
4148
|
return out;
|
|
4143
4149
|
}
|
|
4150
|
+
function repairAtParserPositions(s) {
|
|
4151
|
+
let cur = s;
|
|
4152
|
+
for (let i = 0; i < 500; i++) {
|
|
4153
|
+
let err;
|
|
4154
|
+
try {
|
|
4155
|
+
JSON.parse(cur);
|
|
4156
|
+
return cur;
|
|
4157
|
+
} catch (e) {
|
|
4158
|
+
err = e;
|
|
4159
|
+
}
|
|
4160
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
4161
|
+
const posMatch = /position (\d+)/.exec(msg);
|
|
4162
|
+
if (posMatch === null) return cur;
|
|
4163
|
+
const pos = Number(posMatch[1]);
|
|
4164
|
+
if (!Number.isInteger(pos) || pos < 0 || pos >= cur.length) return cur;
|
|
4165
|
+
if (/control character/i.test(msg)) {
|
|
4166
|
+
const ch = cur.charAt(pos);
|
|
4167
|
+
let esc;
|
|
4168
|
+
if (ch === "\n") esc = "\\n";
|
|
4169
|
+
else if (ch === "\r") esc = "\\r";
|
|
4170
|
+
else if (ch === " ") esc = "\\t";
|
|
4171
|
+
else if (ch.charCodeAt(0) < 32) esc = "\\u" + ch.charCodeAt(0).toString(16).padStart(4, "0");
|
|
4172
|
+
if (esc === void 0) return cur;
|
|
4173
|
+
cur = cur.slice(0, pos) + esc + cur.slice(pos + 1);
|
|
4174
|
+
} else if (/Bad escaped character/i.test(msg)) {
|
|
4175
|
+
const b = cur.charAt(pos - 1) === "\\" ? pos - 1 : cur.charAt(pos) === "\\" ? pos : -1;
|
|
4176
|
+
if (b < 0) return cur;
|
|
4177
|
+
cur = cur.slice(0, b) + "\\\\" + cur.slice(b + 1);
|
|
4178
|
+
} else {
|
|
4179
|
+
return cur;
|
|
4180
|
+
}
|
|
4181
|
+
}
|
|
4182
|
+
return cur;
|
|
4183
|
+
}
|
|
4144
4184
|
function looksTruncated(s) {
|
|
4145
4185
|
let depth = 0;
|
|
4146
4186
|
let inString = false;
|