@lmzhen/dsh-evolution-core 0.3.42 → 0.3.44
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/lib/index.js +14 -5
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -2760,7 +2760,7 @@ function assessStructureHealth(snapshot, thresholds = DEFAULT_HEALTH_THRESHOLDS)
|
|
|
2760
2760
|
};
|
|
2761
2761
|
const needs = snapshot.bodyChars >= thresholds.softBodyChars * 2;
|
|
2762
2762
|
if (needs) reasons.push(`body ${snapshot.bodyChars} chars is >= 2x the soft limit (${thresholds.softBodyChars}) — consider splitting or offloading`);
|
|
2763
|
-
else if (snapshot.bodyChars >= thresholds.softBodyChars) reasons.push(`body ${snapshot.bodyChars} chars above the soft limit (${thresholds.softBodyChars})`);
|
|
2763
|
+
else if (snapshot.bodyChars >= thresholds.softBodyChars) reasons.push(`body ${snapshot.bodyChars} chars at or above the soft limit (${thresholds.softBodyChars})`);
|
|
2764
2764
|
if (snapshot.bodyText && snapshot.bodyChars >= 2e3) {
|
|
2765
2765
|
const kb = Math.max(1, snapshot.bodyChars / 1024);
|
|
2766
2766
|
dims.stampDensityPerKb = (snapshot.bodyText.match(HEALTH_STAMP_RE) ?? []).length / kb;
|
|
@@ -2805,8 +2805,9 @@ function observeEvent(signal, event) {
|
|
|
2805
2805
|
return;
|
|
2806
2806
|
}
|
|
2807
2807
|
if (event.type === "assistant/message") {
|
|
2808
|
-
|
|
2809
|
-
|
|
2808
|
+
const message = event.data.message;
|
|
2809
|
+
if (!message || !Array.isArray(message.content)) return;
|
|
2810
|
+
const text = message.content.map((block) => block.type === "text" ? block.text ?? "" : "").join(" ");
|
|
2810
2811
|
signal.assistantChars += text.length;
|
|
2811
2812
|
return;
|
|
2812
2813
|
}
|
|
@@ -3389,11 +3390,19 @@ function trimPatternBoundaries(pattern) {
|
|
|
3389
3390
|
const trailing = trimmed.search(/\s+$/);
|
|
3390
3391
|
return trailing < 0 ? trimmed : trimmed.slice(0, trailing);
|
|
3391
3392
|
}
|
|
3392
|
-
/** Replace only the fuzzy-matched span, preserving all surrounding bytes.
|
|
3393
|
+
/** Replace only the fuzzy-matched span, preserving all surrounding bytes.
|
|
3394
|
+
* V7-11 (0.3.44): the replaceAll loop accumulates the per-scan cost — the
|
|
3395
|
+
* single-scan budget at the caller only bounded ONE fuzzyIndexOf, while an
|
|
3396
|
+
* unbounded number of matches × O(n·m) each could still stall the loop.
|
|
3397
|
+
* When the accumulated cost exceeds the budget the whole replace fails
|
|
3398
|
+
* (null) instead of partially applying an arbitrary prefix. */
|
|
3393
3399
|
function fuzzyReplace(content, oldString, newString, replaceAll) {
|
|
3394
3400
|
let current = content;
|
|
3395
3401
|
let scanFrom = 0;
|
|
3402
|
+
let totalWork = 0;
|
|
3396
3403
|
for (;;) {
|
|
3404
|
+
totalWork += current.length * oldString.length;
|
|
3405
|
+
if (totalWork > FUZZY_MAX_WORK) return null;
|
|
3397
3406
|
const match = fuzzyIndexOf(current, oldString, scanFrom);
|
|
3398
3407
|
if (match === null) return current;
|
|
3399
3408
|
const [start, end] = match;
|
|
@@ -3933,7 +3942,7 @@ var SkillLibrary = class {
|
|
|
3933
3942
|
if (patched === null) return {
|
|
3934
3943
|
result: {
|
|
3935
3944
|
ok: false,
|
|
3936
|
-
message: `Could not find old_string in "${name}/${patchLabel}". Use update for a full rewrite.`
|
|
3945
|
+
message: `Could not find old_string in "${name}/${patchLabel}" (or the replaceAll fuzzy budget was exceeded). Use update for a full rewrite.`
|
|
3937
3946
|
},
|
|
3938
3947
|
write: null
|
|
3939
3948
|
};
|
package/package.json
CHANGED