@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.d.cts
CHANGED
|
@@ -185,6 +185,16 @@ declare class RedlineEngine {
|
|
|
185
185
|
original_mapper: DocumentMapper | null;
|
|
186
186
|
skipped_details: string[];
|
|
187
187
|
constructor(doc: DocumentObject, author?: string);
|
|
188
|
+
/**
|
|
189
|
+
* Return a hint when a short, single-token anchor contains punctuation that
|
|
190
|
+
* can split awkwardly, else null.
|
|
191
|
+
*
|
|
192
|
+
* Surface this ONLY for edits that actually failed to match/apply. On a
|
|
193
|
+
* successful edit the batch report already carries the redline preview, so
|
|
194
|
+
* emitting this would be a false positive: the punctuation (dates,
|
|
195
|
+
* `[_name_]` placeholders, `____` blanks) is frequently the literal target
|
|
196
|
+
* and the edit succeeds despite it. Mirrors the Python engine.
|
|
197
|
+
*/
|
|
188
198
|
private _check_punctuation_warning;
|
|
189
199
|
/**
|
|
190
200
|
* Best-effort "did you mean" hint for a failed target. The common loop trap
|
package/dist/index.d.ts
CHANGED
|
@@ -185,6 +185,16 @@ declare class RedlineEngine {
|
|
|
185
185
|
original_mapper: DocumentMapper | null;
|
|
186
186
|
skipped_details: string[];
|
|
187
187
|
constructor(doc: DocumentObject, author?: string);
|
|
188
|
+
/**
|
|
189
|
+
* Return a hint when a short, single-token anchor contains punctuation that
|
|
190
|
+
* can split awkwardly, else null.
|
|
191
|
+
*
|
|
192
|
+
* Surface this ONLY for edits that actually failed to match/apply. On a
|
|
193
|
+
* successful edit the batch report already carries the redline preview, so
|
|
194
|
+
* emitting this would be a false positive: the punctuation (dates,
|
|
195
|
+
* `[_name_]` placeholders, `____` blanks) is frequently the literal target
|
|
196
|
+
* and the edit succeeds despite it. Mirrors the Python engine.
|
|
197
|
+
*/
|
|
188
198
|
private _check_punctuation_warning;
|
|
189
199
|
/**
|
|
190
200
|
* Best-effort "did you mean" hint for a failed target. The common loop trap
|
package/dist/index.js
CHANGED
|
@@ -3012,8 +3012,19 @@ var RedlineEngine = class {
|
|
|
3012
3012
|
this.mapper = new DocumentMapper(this.doc);
|
|
3013
3013
|
this.comments_manager = new CommentsManager(this.doc);
|
|
3014
3014
|
}
|
|
3015
|
+
/**
|
|
3016
|
+
* Return a hint when a short, single-token anchor contains punctuation that
|
|
3017
|
+
* can split awkwardly, else null.
|
|
3018
|
+
*
|
|
3019
|
+
* Surface this ONLY for edits that actually failed to match/apply. On a
|
|
3020
|
+
* successful edit the batch report already carries the redline preview, so
|
|
3021
|
+
* emitting this would be a false positive: the punctuation (dates,
|
|
3022
|
+
* `[_name_]` placeholders, `____` blanks) is frequently the literal target
|
|
3023
|
+
* and the edit succeeds despite it. Mirrors the Python engine.
|
|
3024
|
+
*/
|
|
3015
3025
|
_check_punctuation_warning(target_text) {
|
|
3016
3026
|
if (!target_text) return null;
|
|
3027
|
+
if (target_text.length > 20 || target_text.includes(" ")) return null;
|
|
3017
3028
|
if (target_text.includes("_") || target_text.includes("-")) {
|
|
3018
3029
|
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.`;
|
|
3019
3030
|
}
|
|
@@ -4230,11 +4241,11 @@ var RedlineEngine = class {
|
|
|
4230
4241
|
for (let i = 0; i < edits.length; i++) {
|
|
4231
4242
|
const edit = edits[i];
|
|
4232
4243
|
const single_errors = this.validate_edits([edit], i);
|
|
4233
|
-
const warning = this._check_punctuation_warning(
|
|
4234
|
-
edit.target_text || ""
|
|
4235
|
-
);
|
|
4236
4244
|
if (single_errors.length > 0) {
|
|
4237
4245
|
skipped_edits++;
|
|
4246
|
+
const warning = this._check_punctuation_warning(
|
|
4247
|
+
edit.target_text || ""
|
|
4248
|
+
);
|
|
4238
4249
|
edits_reports.push({
|
|
4239
4250
|
status: "failed",
|
|
4240
4251
|
target_text: edit.target_text || "",
|
|
@@ -4254,7 +4265,7 @@ var RedlineEngine = class {
|
|
|
4254
4265
|
status: "applied",
|
|
4255
4266
|
target_text: edit.target_text || "",
|
|
4256
4267
|
new_text: edit.new_text || "",
|
|
4257
|
-
warning,
|
|
4268
|
+
warning: null,
|
|
4258
4269
|
error: null,
|
|
4259
4270
|
critic_markup: previews[0],
|
|
4260
4271
|
clean_text: previews[1],
|
|
@@ -4268,6 +4279,9 @@ var RedlineEngine = class {
|
|
|
4268
4279
|
} else {
|
|
4269
4280
|
skipped_edits++;
|
|
4270
4281
|
const error_msg = this.skipped_details.length > 0 ? this.skipped_details[this.skipped_details.length - 1] : "Failed to apply edit";
|
|
4282
|
+
const warning = this._check_punctuation_warning(
|
|
4283
|
+
edit.target_text || ""
|
|
4284
|
+
);
|
|
4271
4285
|
edits_reports.push({
|
|
4272
4286
|
status: "failed",
|
|
4273
4287
|
target_text: edit.target_text || "",
|
|
@@ -4313,15 +4327,17 @@ var RedlineEngine = class {
|
|
|
4313
4327
|
for (const edit of edits) {
|
|
4314
4328
|
const success = edit._applied_status || false;
|
|
4315
4329
|
const error_msg = edit._error_msg || null;
|
|
4316
|
-
const warning = this._check_punctuation_warning(
|
|
4317
|
-
edit.target_text || ""
|
|
4318
|
-
);
|
|
4319
4330
|
let critic_markup = null;
|
|
4320
4331
|
let clean_text = null;
|
|
4332
|
+
let warning = null;
|
|
4321
4333
|
if (success) {
|
|
4322
4334
|
const previews = this._build_edit_context_previews(edit);
|
|
4323
4335
|
critic_markup = previews[0];
|
|
4324
4336
|
clean_text = previews[1];
|
|
4337
|
+
} else {
|
|
4338
|
+
warning = this._check_punctuation_warning(
|
|
4339
|
+
edit.target_text || ""
|
|
4340
|
+
);
|
|
4325
4341
|
}
|
|
4326
4342
|
edits_reports.push({
|
|
4327
4343
|
status: success ? "applied" : "failed",
|