@adeu/core 1.18.0 → 1.18.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.
- package/dist/index.cjs +23 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +23 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/engine.feedback.test.ts +34 -2
- package/src/engine.ts +30 -7
package/dist/index.cjs
CHANGED
|
@@ -3063,8 +3063,19 @@ var RedlineEngine = class {
|
|
|
3063
3063
|
this.mapper = new DocumentMapper(this.doc);
|
|
3064
3064
|
this.comments_manager = new CommentsManager(this.doc);
|
|
3065
3065
|
}
|
|
3066
|
+
/**
|
|
3067
|
+
* Return a hint when a short, single-token anchor contains punctuation that
|
|
3068
|
+
* can split awkwardly, else null.
|
|
3069
|
+
*
|
|
3070
|
+
* Surface this ONLY for edits that actually failed to match/apply. On a
|
|
3071
|
+
* successful edit the batch report already carries the redline preview, so
|
|
3072
|
+
* emitting this would be a false positive: the punctuation (dates,
|
|
3073
|
+
* `[_name_]` placeholders, `____` blanks) is frequently the literal target
|
|
3074
|
+
* and the edit succeeds despite it. Mirrors the Python engine.
|
|
3075
|
+
*/
|
|
3066
3076
|
_check_punctuation_warning(target_text) {
|
|
3067
3077
|
if (!target_text) return null;
|
|
3078
|
+
if (target_text.length > 20 || target_text.includes(" ")) return null;
|
|
3068
3079
|
if (target_text.includes("_") || target_text.includes("-")) {
|
|
3069
3080
|
return `Warning: target_text '${target_text}' contains tokenization-splitting punctuation ('_' or '-'). This can trigger mid-word splits in the diff engine. Consider using a longer plain-prose anchor.`;
|
|
3070
3081
|
}
|
|
@@ -4281,11 +4292,11 @@ var RedlineEngine = class {
|
|
|
4281
4292
|
for (let i = 0; i < edits.length; i++) {
|
|
4282
4293
|
const edit = edits[i];
|
|
4283
4294
|
const single_errors = this.validate_edits([edit], i);
|
|
4284
|
-
const warning = this._check_punctuation_warning(
|
|
4285
|
-
edit.target_text || ""
|
|
4286
|
-
);
|
|
4287
4295
|
if (single_errors.length > 0) {
|
|
4288
4296
|
skipped_edits++;
|
|
4297
|
+
const warning = this._check_punctuation_warning(
|
|
4298
|
+
edit.target_text || ""
|
|
4299
|
+
);
|
|
4289
4300
|
edits_reports.push({
|
|
4290
4301
|
status: "failed",
|
|
4291
4302
|
target_text: edit.target_text || "",
|
|
@@ -4305,7 +4316,7 @@ var RedlineEngine = class {
|
|
|
4305
4316
|
status: "applied",
|
|
4306
4317
|
target_text: edit.target_text || "",
|
|
4307
4318
|
new_text: edit.new_text || "",
|
|
4308
|
-
warning,
|
|
4319
|
+
warning: null,
|
|
4309
4320
|
error: null,
|
|
4310
4321
|
critic_markup: previews[0],
|
|
4311
4322
|
clean_text: previews[1],
|
|
@@ -4319,6 +4330,9 @@ var RedlineEngine = class {
|
|
|
4319
4330
|
} else {
|
|
4320
4331
|
skipped_edits++;
|
|
4321
4332
|
const error_msg = this.skipped_details.length > 0 ? this.skipped_details[this.skipped_details.length - 1] : "Failed to apply edit";
|
|
4333
|
+
const warning = this._check_punctuation_warning(
|
|
4334
|
+
edit.target_text || ""
|
|
4335
|
+
);
|
|
4322
4336
|
edits_reports.push({
|
|
4323
4337
|
status: "failed",
|
|
4324
4338
|
target_text: edit.target_text || "",
|
|
@@ -4364,15 +4378,17 @@ var RedlineEngine = class {
|
|
|
4364
4378
|
for (const edit of edits) {
|
|
4365
4379
|
const success = edit._applied_status || false;
|
|
4366
4380
|
const error_msg = edit._error_msg || null;
|
|
4367
|
-
const warning = this._check_punctuation_warning(
|
|
4368
|
-
edit.target_text || ""
|
|
4369
|
-
);
|
|
4370
4381
|
let critic_markup = null;
|
|
4371
4382
|
let clean_text = null;
|
|
4383
|
+
let warning = null;
|
|
4372
4384
|
if (success) {
|
|
4373
4385
|
const previews = this._build_edit_context_previews(edit);
|
|
4374
4386
|
critic_markup = previews[0];
|
|
4375
4387
|
clean_text = previews[1];
|
|
4388
|
+
} else {
|
|
4389
|
+
warning = this._check_punctuation_warning(
|
|
4390
|
+
edit.target_text || ""
|
|
4391
|
+
);
|
|
4376
4392
|
}
|
|
4377
4393
|
edits_reports.push({
|
|
4378
4394
|
status: success ? "applied" : "failed",
|