@lmzhen/dsh-tool-skill-manage 0.39.2 → 0.40.0
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 +69 -12
- package/package.json +8 -8
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_ARCHIVE_RETENTION_POLICY, DEFAULT_CITATION_POLICY, DEFAULT_HEALTH_THRESHOLDS, DEFAULT_REFERENCE_REWRITE_POLICY, DEFAULT_SKILL_LIMITS, DEFAULT_SKILL_VERSION_KEEP, DEFAULT_SUPPORT_FILE_CHAR_POLICY, DSH_AUTHORING_STANDARDS, EXTRACT_PROMPT_V1, SKILLS_GUIDANCE, SKILLS_GUIDANCE_SECTION_ORDER, anchorVerdict, authoringFeedback, authorityFrom, buildExtractPlanFromLibrary, callingScope, clampOnce, computeDedupGroups, contentHash, createSubagentChannel, evolutionIoAdapter, fuzzyPatch, isPresent, isUnknown, liveBool, nearDuplicateSummaries, newSkillLibrary, normalizeFrontmatter, ownerCandidatesFromSummaries, ownerDecisionText, paramRowId, parseFrontmatter, policyStageLimits, probePresent, probeUnknown, projectExtractBodies, proposalFromPlan, protectedSkillNamesOf, registerOwnerSettings, resolveExecOrigins, sessionReadSkillNames, sessionReadSupportFiles, skillWriteGateContext, unwrapLive, userSetKeys, writeProposalReport } from "@lmzhen/dsh-evolution-core";
|
|
1
|
+
import { DEFAULT_ARCHIVE_RETENTION_POLICY, DEFAULT_CITATION_POLICY, DEFAULT_HEALTH_THRESHOLDS, DEFAULT_REFERENCE_REWRITE_POLICY, DEFAULT_SKILL_LIMITS, DEFAULT_SKILL_VERSION_KEEP, DEFAULT_SUPPORT_FILE_CHAR_POLICY, DSH_AUTHORING_STANDARDS, EXTRACT_PROMPT_V1, SKILLS_GUIDANCE, SKILLS_GUIDANCE_SECTION_ORDER, anchorVerdict, authoringFeedback, authorityFrom, buildExtractPlanFromLibrary, callingScope, clampOnce, computeDedupGroups, contentHash, createSubagentChannel, evolutionIoAdapter, fuzzyPatch, isPresent, isUnknown, liveBool, nearDuplicateSummaries, newSkillLibrary, normalizeFrontmatter, ownerCandidatesFromSummaries, ownerDecisionText, paramRowId, parseFrontmatter, policyStageLimits, probePresent, probeUnknown, projectExtractBodies, proposalFromPlan, protectedSkillNamesOf, readProposalReport, registerOwnerSettings, resolveExecOrigins, sessionReadSkillNames, sessionReadSupportFiles, skillWriteGateContext, unwrapLive, userSetKeys, writeProposalReport } from "@lmzhen/dsh-evolution-core";
|
|
2
2
|
import { effectiveSessionPolicy } from "@lmzhen/dsh-evolution-approval";
|
|
3
3
|
import z from "@deepseek-ai/schemastery";
|
|
4
4
|
import { defineTool, registerEvolutionTool } from "@lmzhen/dsh-evolution-core/platform";
|
|
@@ -205,6 +205,22 @@ async function proposeExtractWithAgent(ctx, parent, library, source) {
|
|
|
205
205
|
proposal: JSON.stringify(outcome.structured)
|
|
206
206
|
};
|
|
207
207
|
}
|
|
208
|
+
/** Render agent/structured proposals as outcome lines instead of opaque JSON. */
|
|
209
|
+
function formatProposal(raw) {
|
|
210
|
+
try {
|
|
211
|
+
const value = JSON.parse(raw);
|
|
212
|
+
const parts = Array.isArray(value.parts) ? value.parts.map((part) => part !== null && typeof part === "object" && "heading" in part ? String(part.heading) : "").filter(Boolean) : [];
|
|
213
|
+
return [
|
|
214
|
+
"outcome: " + String(value.outcome ?? "unknown"),
|
|
215
|
+
"target: " + String(value.target ?? "—"),
|
|
216
|
+
"neededOwner: " + String(value.neededOwner ?? "—"),
|
|
217
|
+
"parts: " + (parts.length === 0 ? "—" : parts.join(", ")),
|
|
218
|
+
...typeof value.reason === "string" && value.reason !== "" ? ["reason: " + value.reason] : []
|
|
219
|
+
].join("\n");
|
|
220
|
+
} catch {
|
|
221
|
+
return raw;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
208
224
|
/**
|
|
209
225
|
* What the staged skill write WOULD store, resolved WITHOUT writing.
|
|
210
226
|
*
|
|
@@ -729,12 +745,52 @@ function apply(ctx, rawConfig = {}) {
|
|
|
729
745
|
toFile: typeof move.to_file === "string" ? move.to_file : ""
|
|
730
746
|
})), origin);
|
|
731
747
|
} else if (action === "extract") {
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
748
|
+
let source = typeof args.name === "string" ? args.name : "";
|
|
749
|
+
let items = Array.isArray(args.extract) ? args.extract : [];
|
|
750
|
+
let outcome = args.outcome;
|
|
751
|
+
let ownerCovers = args.owner_covers;
|
|
752
|
+
if (args.proposal_id !== void 0 && args.proposal_id !== "") {
|
|
753
|
+
const io = ctx.get("evolutionIo")?.provider();
|
|
754
|
+
if (io === void 0) result = {
|
|
755
|
+
ok: false,
|
|
756
|
+
message: "proposal_id 需要 evolutionIo 提供者。"
|
|
757
|
+
};
|
|
758
|
+
else {
|
|
759
|
+
const proposal = await readProposalReport(io, args.proposal_id);
|
|
760
|
+
if (proposal === null) result = {
|
|
761
|
+
ok: false,
|
|
762
|
+
message: "找不到 extract proposal:" + args.proposal_id
|
|
763
|
+
};
|
|
764
|
+
else if (proposal.outcome === "keep") result = {
|
|
765
|
+
ok: false,
|
|
766
|
+
message: "该 proposal 的结论是 keep,没有可应用提取。"
|
|
767
|
+
};
|
|
768
|
+
else if (proposal.outcome === "owner-gap" || proposal.owner.mode !== "covered" || proposal.owner.name === void 0) result = {
|
|
769
|
+
ok: false,
|
|
770
|
+
message: "该 proposal 未覆盖 owner(owner-gap),不能应用。"
|
|
771
|
+
};
|
|
772
|
+
else {
|
|
773
|
+
source = proposal.source;
|
|
774
|
+
outcome = proposal.outcome === "extract" || proposal.outcome === "mixed" ? proposal.outcome : void 0;
|
|
775
|
+
ownerCovers = void 0;
|
|
776
|
+
items = proposal.parts.map((part) => ({
|
|
777
|
+
heading: part.heading,
|
|
778
|
+
...part.anchor.start === void 0 ? {} : { start: part.anchor.start },
|
|
779
|
+
...part.anchor.end === void 0 ? {} : { end: part.anchor.end },
|
|
780
|
+
to_skill: proposal.owner.name
|
|
781
|
+
}));
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
const built = result === void 0 ? await buildExtractPlanFromLibrary(library, {
|
|
786
|
+
source,
|
|
787
|
+
items,
|
|
788
|
+
...outcome === void 0 ? {} : { outcome },
|
|
789
|
+
...ownerCovers === void 0 ? {} : { ownerCovers }
|
|
790
|
+
}) : {
|
|
791
|
+
ok: false,
|
|
792
|
+
message: result.message
|
|
793
|
+
};
|
|
738
794
|
if (!built.ok) result = {
|
|
739
795
|
ok: false,
|
|
740
796
|
message: built.message
|
|
@@ -878,7 +934,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
878
934
|
}
|
|
879
935
|
registerEvolutionTool(ctx, defineTool({
|
|
880
936
|
name: "skill_manage",
|
|
881
|
-
description: "Manage reusable skills. review returns the library review text (state/usage/quality per skill); list returns names only; create/edit/update take full SKILL.md content (edit is an alias of update); patch applies old_string -> new_string; delete archives to .archive (absorbed_into names an umbrella skill); write_file/remove_file add or remove one support file under references/ or scripts/; pin protects a skill from deletion, background review, and the lifecycle (pin/unpin are never allowed from a background review — foreground and delegated subagents may). Per-action arguments: patch needs name + old_string + new_string and patches SKILL.md unless file_path names a support file (e.g. \"references/topic.md\"); patch replaces the FIRST occurrence only unless replace_all=true, and the result message reports how many anchors the file carried. write_file needs name + file_path + file_content; remove_file needs name + file_path; create/edit/update need name + content; delete needs name. A rejected patch names the reason and the remedy (missing anchor, stale snapshot, frontmatter that cannot be auto-quoted, byte/char limit). Protected bundled/hub skills reject any mutation; pinned skills reject deletion and are read-only to the background review.Prefer patching an umbrella over creating narrow skills. restructure moves entire body sections (by their exact \"## heading\" line, via restructure: [{heading, to_file: \"references/<topic>.md\"}]) into a references/ file and replaces each with a pointer line — the skill name and directory never change. extract moves a reusable part (exact heading, optional start/end sub-block) into an existing class-level owner: extract: [{heading, start?, end?, to_skill}]. One target per call; owner-gap is reported, never auto-created.Created/edited SKILL.md MUST start with YAML frontmatter (a name/description block), or creation is rejected. " + DSH_AUTHORING_STANDARDS,
|
|
937
|
+
description: "Manage reusable skills. review returns the library review text (state/usage/quality per skill); list returns names only; create/edit/update take full SKILL.md content (edit is an alias of update); patch applies old_string -> new_string; delete archives to .archive (absorbed_into names an umbrella skill); write_file/remove_file add or remove one support file under references/ or scripts/; pin protects a skill from deletion, background review, and the lifecycle (pin/unpin are never allowed from a background review — foreground and delegated subagents may). Per-action arguments: patch needs name + old_string + new_string and patches SKILL.md unless file_path names a support file (e.g. \"references/topic.md\"); patch replaces the FIRST occurrence only unless replace_all=true, and the result message reports how many anchors the file carried. write_file needs name + file_path + file_content; remove_file needs name + file_path; create/edit/update need name + content; delete needs name. A rejected patch names the reason and the remedy (missing anchor, stale snapshot, frontmatter that cannot be auto-quoted, byte/char limit). Protected bundled/hub skills reject any mutation; pinned skills reject deletion and are read-only to the background review.Prefer patching an umbrella over creating narrow skills. restructure moves entire body sections (by their exact \"## heading\" line, via restructure: [{heading, to_file: \"references/<topic>.md\"}]) into a references/ file and replaces each with a pointer line — the skill name and directory never change. extract moves a reusable part (exact heading, optional start/end sub-block) into an existing class-level owner: extract: [{heading, start?, end?, to_skill}]. One target per call; an empty extract list returns the child-agent proposal (outcome/target/neededOwner/parts) without writing; supply extract items to apply, and use owner_covers only as an explicit override; owner-gap is reported, never auto-created.Created/edited SKILL.md MUST start with YAML frontmatter (a name/description block), or creation is rejected. " + DSH_AUTHORING_STANDARDS,
|
|
882
938
|
parameters: {
|
|
883
939
|
action: {
|
|
884
940
|
type: "string",
|
|
@@ -937,7 +993,8 @@ function apply(ctx, rawConfig = {}) {
|
|
|
937
993
|
enum: ["extract", "mixed"]
|
|
938
994
|
},
|
|
939
995
|
owner_covers: { type: "boolean" },
|
|
940
|
-
dry_run: { type: "boolean" }
|
|
996
|
+
dry_run: { type: "boolean" },
|
|
997
|
+
proposal_id: { type: "string" }
|
|
941
998
|
},
|
|
942
999
|
output: {
|
|
943
1000
|
schema: {
|
|
@@ -963,7 +1020,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
963
1020
|
},
|
|
964
1021
|
render: (_args, value) => [{
|
|
965
1022
|
type: "text",
|
|
966
|
-
text: `${value.ok ? "OK" : "Error"}: ${value.message}`
|
|
1023
|
+
text: `${value.ok ? "OK" : "Error"}: ${value.message}` + (value.proposal === void 0 ? "" : "\n\n" + formatProposal(value.proposal))
|
|
967
1024
|
}]
|
|
968
1025
|
},
|
|
969
1026
|
isConcurrencySafe: () => false,
|
|
@@ -1069,7 +1126,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
1069
1126
|
...decision.pendingId !== void 0 ? { pending_id: decision.pendingId } : {}
|
|
1070
1127
|
};
|
|
1071
1128
|
}
|
|
1072
|
-
if (operation.action === "extract" &&
|
|
1129
|
+
if (operation.action === "extract" && (operation.extract === void 0 || operation.extract.length === 0)) {
|
|
1073
1130
|
const source = typeof operation.name === "string" ? operation.name.trim() : "";
|
|
1074
1131
|
if (source === "") return {
|
|
1075
1132
|
ok: false,
|
|
@@ -1079,7 +1136,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
1079
1136
|
const proposed = await proposeExtractWithAgent(ctx, exec.agent, library, source);
|
|
1080
1137
|
return proposed.ok ? {
|
|
1081
1138
|
ok: true,
|
|
1082
|
-
message: "
|
|
1139
|
+
message: "提取提议(未写入;确认后按 extract items 提交)。",
|
|
1083
1140
|
skills: [],
|
|
1084
1141
|
proposal: proposed.proposal
|
|
1085
1142
|
} : {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmzhen/dsh-tool-skill-manage",
|
|
3
3
|
"description": "Model-facing skill_manage tool (community build)",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.40.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -27,24 +27,24 @@
|
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@deepseek-ai/schemastery": "^3.18.5",
|
|
30
|
-
"@lmzhen/dsh-evolution-approval": "^0.
|
|
31
|
-
"@lmzhen/dsh-evolution-core": "^0.
|
|
30
|
+
"@lmzhen/dsh-evolution-approval": "^0.40.0",
|
|
31
|
+
"@lmzhen/dsh-evolution-core": "^0.40.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"@deepseek-ai/cordis": "^4.0.5",
|
|
35
35
|
"@deepseek-ai/dsh-skill": "^0.2.2-rc.0",
|
|
36
36
|
"@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.0",
|
|
37
37
|
"@deepseek-ai/dsh-agent": "^0.2.2-rc.0",
|
|
38
|
-
"@lmzhen/dsh-evolution-io": "^0.
|
|
39
|
-
"@lmzhen/dsh-skill-usage": "^0.
|
|
38
|
+
"@lmzhen/dsh-evolution-io": "^0.40.0",
|
|
39
|
+
"@lmzhen/dsh-skill-usage": "^0.40.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@deepseek-ai/dsh-agent-loop-testkit": "^0.2.2-rc.0",
|
|
43
43
|
"@deepseek-ai/dsh-skill": "^0.2.2-rc.0",
|
|
44
44
|
"@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.0",
|
|
45
|
-
"@lmzhen/dsh-evolution-core": "^0.
|
|
46
|
-
"@lmzhen/dsh-evolution-io": "^0.
|
|
47
|
-
"@lmzhen/dsh-skill-usage": "^0.
|
|
45
|
+
"@lmzhen/dsh-evolution-core": "^0.40.0",
|
|
46
|
+
"@lmzhen/dsh-evolution-io": "^0.40.0",
|
|
47
|
+
"@lmzhen/dsh-skill-usage": "^0.40.0"
|
|
48
48
|
},
|
|
49
49
|
"engines": {
|
|
50
50
|
"dsh": ">=0.2.2-rc.0 <0.2.3-0"
|