@lmzhen/dsh-evolution-core 0.2.0-rc.2 → 0.2.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/lib/index.js +20 -12
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -2573,15 +2573,22 @@ function fuzzyPatch(content, oldString, newString, replaceAll = false) {
|
|
|
2573
2573
|
}
|
|
2574
2574
|
/**
|
|
2575
2575
|
* Support-directory references in a markdown body (009 kernel): `references/…`,
|
|
2576
|
-
* `templates/…`, `scripts/…`, `assets/…` relative links
|
|
2577
|
-
*
|
|
2578
|
-
*
|
|
2579
|
-
*
|
|
2580
|
-
*
|
|
2576
|
+
* `templates/…`, `scripts/…`, `assets/…` relative links — any extension and
|
|
2577
|
+
* nested paths (v7 audit P3-1: `.md`-only matching missed `scripts/run.sh` and
|
|
2578
|
+
* `references/sub/x.md`, both of which dangle just like a `.md` link once the
|
|
2579
|
+
* source package is archived). Pure — who checks them and what the verdict is
|
|
2580
|
+
* belongs to the caller's context (a moved/appended body whose references
|
|
2581
|
+
* travel with an archived source is a dangling link; a restructure pointer is
|
|
2582
|
+
* a fresh link to a file written in the same plan). `..` traversal is a
|
|
2583
|
+
* different defect class (path validation owns it) and is not a support link.
|
|
2581
2584
|
*/
|
|
2582
2585
|
function supportRefs(content) {
|
|
2583
2586
|
const refs = [];
|
|
2584
|
-
for (const match of content.matchAll(/\b(?:references|templates|scripts|assets)\/[A-Za-z0-9._
|
|
2587
|
+
for (const match of content.matchAll(/\b(?:references|templates|scripts|assets)\/[A-Za-z0-9._/-]+/g)) {
|
|
2588
|
+
const ref = match[0];
|
|
2589
|
+
if (ref.includes("..")) continue;
|
|
2590
|
+
refs.push(ref);
|
|
2591
|
+
}
|
|
2585
2592
|
return refs;
|
|
2586
2593
|
}
|
|
2587
2594
|
function planRestructureSections(body, moves) {
|
|
@@ -3228,17 +3235,18 @@ var SkillLibrary = class {
|
|
|
3228
3235
|
message: `Skill "${name}" not found.`
|
|
3229
3236
|
};
|
|
3230
3237
|
const normalized = md.replace(/\r\n/g, "\n");
|
|
3231
|
-
const plan = planRestructureSections(normalized, moves);
|
|
3232
|
-
if ("error" in plan) return {
|
|
3233
|
-
ok: false,
|
|
3234
|
-
message: `Restructure rejected: ${plan.error}`
|
|
3235
|
-
};
|
|
3236
3238
|
const frontmatterEnd = normalized.indexOf("\n---", 3);
|
|
3237
3239
|
if (frontmatterEnd < 0) return {
|
|
3238
3240
|
ok: false,
|
|
3239
3241
|
message: "SKILL.md has no valid frontmatter; refusing to restructure."
|
|
3240
3242
|
};
|
|
3241
|
-
const
|
|
3243
|
+
const header = normalized.slice(0, frontmatterEnd + 4);
|
|
3244
|
+
const plan = planRestructureSections(normalized.slice(frontmatterEnd + 4), moves);
|
|
3245
|
+
if ("error" in plan) return {
|
|
3246
|
+
ok: false,
|
|
3247
|
+
message: `Restructure rejected: ${plan.error}`
|
|
3248
|
+
};
|
|
3249
|
+
const newMd = header + plan.body;
|
|
3242
3250
|
const newMdCheck = validateFrontmatter(newMd, name, this.limits);
|
|
3243
3251
|
if (newMdCheck) return {
|
|
3244
3252
|
ok: false,
|
package/package.json
CHANGED