@lmzhen/dsh-tool-skill-manage 0.21.0 → 0.23.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 +27 -20
- package/package.json +8 -8
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { effectiveSessionPolicy } from "@lmzhen/dsh-evolution-approval";
|
|
2
2
|
import z from "@deepseek-ai/schemastery";
|
|
3
3
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
4
|
-
import { DEFAULT_ARCHIVE_RETENTION_POLICY, DEFAULT_CITATION_POLICY, DEFAULT_REFERENCE_REWRITE_POLICY, DEFAULT_SKILL_LIMITS, DEFAULT_SKILL_VERSION_KEEP, DEFAULT_SUPPORT_FILE_CHAR_POLICY, DSH_AUTHORING_STANDARDS, SKILLS_GUIDANCE, SKILLS_GUIDANCE_SECTION_ORDER, SKILL_ACTION_REQUIRED_FIELDS, anchorVerdict, authoringFeedback, callingScope,
|
|
4
|
+
import { DEFAULT_ARCHIVE_RETENTION_POLICY, DEFAULT_CITATION_POLICY, DEFAULT_REFERENCE_REWRITE_POLICY, DEFAULT_SKILL_LIMITS, DEFAULT_SKILL_VERSION_KEEP, DEFAULT_SUPPORT_FILE_CHAR_POLICY, DSH_AUTHORING_STANDARDS, SKILLS_GUIDANCE, SKILLS_GUIDANCE_SECTION_ORDER, SKILL_ACTION_REQUIRED_FIELDS, anchorVerdict, authoringFeedback, callingScope, clampOnce, computeDedupGroups, contentHash, errorText, evolutionIoAdapter, fuzzyPatch, isPresent, isUnknown, isUnreadWrite, liveBool, nearDuplicateSummaries, newSkillLibrary, normalizeFrontmatter, paramRowId, parseFrontmatter, policyStageLimits, probePresent, probeUnknown, resolveExecOrigins, sessionReadSkillNames, unwrapLive, userSetKeys } from "@lmzhen/dsh-evolution-core";
|
|
5
5
|
//#region lib/types/write-gates.js
|
|
6
6
|
/**
|
|
7
7
|
* The write-admission sequence: ONE ordered table of the reasons a skill write is refused.
|
|
@@ -235,6 +235,19 @@ async function runWriteGates(context) {
|
|
|
235
235
|
* documented in the README Safety model section.
|
|
236
236
|
* @module @lmzhen/dsh-tool-skill-manage
|
|
237
237
|
*/
|
|
238
|
+
/**
|
|
239
|
+
* F-2 (audit v46 / G7.2): the read-only action set used to be spelled out FOUR times in this file
|
|
240
|
+
* (usage accounting at the patch_count bump, the cross-source directory exemption, the approval gap
|
|
241
|
+
* and the replay exemption). The four USES stay where they are — their neighbouring logic differs —
|
|
242
|
+
* but the CRITERION is this one predicate, so adding an action cannot update three of four.
|
|
243
|
+
*/
|
|
244
|
+
const READ_ONLY_ACTIONS = [
|
|
245
|
+
"list",
|
|
246
|
+
"review",
|
|
247
|
+
"pin",
|
|
248
|
+
"unpin"
|
|
249
|
+
];
|
|
250
|
+
const isReadOnlyAction = (action) => typeof action === "string" && READ_ONLY_ACTIONS.includes(action);
|
|
238
251
|
const name = "tool-skill-manage";
|
|
239
252
|
const inject = [
|
|
240
253
|
"tools",
|
|
@@ -537,15 +550,9 @@ function apply(ctx, rawConfig = {}) {
|
|
|
537
550
|
};
|
|
538
551
|
const io = evolutionIoAdapter(() => ctx.evolutionIo.provider());
|
|
539
552
|
const clampedKeys = /* @__PURE__ */ new Set();
|
|
540
|
-
const limit = (name, value, fallback) => {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
if (current !== void 0 && result !== current && !clampedKeys.has(name)) {
|
|
544
|
-
clampedKeys.add(name);
|
|
545
|
-
ctx.logger.warn(`tool-skill-manage: ${name} provided an invalid value; falling back to the default`);
|
|
546
|
-
}
|
|
547
|
-
return result;
|
|
548
|
-
};
|
|
553
|
+
const limit = (name, value, fallback) => clampOnce(clampedKeys, (message) => {
|
|
554
|
+
ctx.logger.warn(message);
|
|
555
|
+
}, `tool-skill-manage: ${name}`, value, fallback, 1);
|
|
549
556
|
/**
|
|
550
557
|
* This row's write knobs as they stand RIGHT NOW (G1 §8.3) — the base layer of the
|
|
551
558
|
* precedence chain. The ten E3 keys are live references the platform updates in
|
|
@@ -554,15 +561,15 @@ function apply(ctx, rawConfig = {}) {
|
|
|
554
561
|
* @returns the row layer of the write settings.
|
|
555
562
|
*/
|
|
556
563
|
const rowSettings = () => ({
|
|
557
|
-
skillContentChars: limit("maxSkillContentChars", rawConfig.skillContentChars
|
|
564
|
+
skillContentChars: limit("maxSkillContentChars", unwrapLive(rawConfig.skillContentChars) ?? rawConfig.maxSkillContentChars, DEFAULT_SKILL_LIMITS.maxSkillContentChars),
|
|
558
565
|
maxSkillFileBytes: limit("maxSkillFileBytes", rawConfig.maxSkillFileBytes, DEFAULT_SKILL_LIMITS.maxSkillFileBytes),
|
|
559
566
|
maxSkillNameLength: limit("maxSkillNameLength", rawConfig.maxSkillNameLength, DEFAULT_SKILL_LIMITS.maxNameLength),
|
|
560
567
|
maxDescriptionLength: limit("maxDescriptionLength", rawConfig.maxDescriptionLength, DEFAULT_SKILL_LIMITS.maxDescriptionLength),
|
|
561
|
-
descriptionStrict: rawConfig.descriptionStrict
|
|
562
|
-
strictCrossSource: rawConfig.strictCrossSource
|
|
563
|
-
citationPolicy: rawConfig.citationPolicy
|
|
564
|
-
supportFileCharPolicy: rawConfig.supportFileCharPolicy
|
|
565
|
-
skillWriteConfirm: rawConfig.skillWriteConfirm
|
|
568
|
+
descriptionStrict: liveBool(rawConfig.descriptionStrict),
|
|
569
|
+
strictCrossSource: liveBool(rawConfig.strictCrossSource),
|
|
570
|
+
citationPolicy: unwrapLive(rawConfig.citationPolicy) ?? DEFAULT_CITATION_POLICY,
|
|
571
|
+
supportFileCharPolicy: unwrapLive(rawConfig.supportFileCharPolicy) ?? DEFAULT_SUPPORT_FILE_CHAR_POLICY,
|
|
572
|
+
skillWriteConfirm: unwrapLive(rawConfig.skillWriteConfirm) ?? "auto",
|
|
566
573
|
skillWriteConfirmTimeoutSeconds: limit("skillWriteConfirmTimeoutSeconds", rawConfig.skillWriteConfirmTimeoutSeconds, 120)
|
|
567
574
|
});
|
|
568
575
|
/**
|
|
@@ -779,7 +786,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
779
786
|
};
|
|
780
787
|
if (result.ok) {
|
|
781
788
|
if (result.normalizedFrontmatterFields && result.normalizedFrontmatterFields.length > 0) feedbackLines.push(`frontmatter auto-quoted (YAML compatibility): ${result.normalizedFrontmatterFields.join(", ")}`);
|
|
782
|
-
const mutating = action
|
|
789
|
+
const mutating = !isReadOnlyAction(action);
|
|
783
790
|
if (name && action === "create") await ctx.skillUsage.ensureRecordCreated(name, origin !== "foreground");
|
|
784
791
|
if (name && action === "delete") await ctx.skillUsage.markArchived(name);
|
|
785
792
|
else if (name && mutating && action !== "create" && result.noop !== true) await ctx.skillUsage.record(name, "patch");
|
|
@@ -943,7 +950,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
943
950
|
/** The approval seam this write would go through (T2-10/A25: the gate decision below reads it). */
|
|
944
951
|
const approvalSeam = ctx.get("evolutionApproval");
|
|
945
952
|
let crossSourceView = null;
|
|
946
|
-
if (typeof args.name === "string" && args.name !== "" && args.action
|
|
953
|
+
if (typeof args.name === "string" && args.name !== "" && !isReadOnlyAction(args.action)) {
|
|
947
954
|
const gate = await crossSourceRefusal(args.name);
|
|
948
955
|
if (gate.refusal !== null) return {
|
|
949
956
|
ok: false,
|
|
@@ -980,7 +987,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
980
987
|
skills: []
|
|
981
988
|
};
|
|
982
989
|
const approval = approvalSeam;
|
|
983
|
-
if (approval && args.action
|
|
990
|
+
if (approval && !isReadOnlyAction(args.action)) {
|
|
984
991
|
if ((args.action === "update" || args.action === "edit") && typeof args.name === "string" && args.name !== "") {
|
|
985
992
|
const stageCurrent = await library.read(args.name).catch(() => null);
|
|
986
993
|
operation = {
|
|
@@ -1025,7 +1032,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
1025
1032
|
const wrapped = args ?? {};
|
|
1026
1033
|
const operation = wrapped.operation ?? {};
|
|
1027
1034
|
const replayAction = operation.action;
|
|
1028
|
-
if (replayAction
|
|
1035
|
+
if (!isReadOnlyAction(replayAction)) return crossSourceRefusal(operation.name, "replay").then((gate) => {
|
|
1029
1036
|
if (gate.refusal !== null) return {
|
|
1030
1037
|
ok: false,
|
|
1031
1038
|
message: `${gate.refusal} (re-checked at approve time: the catalog ranking changed while the write was staged)`,
|
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.23.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.4",
|
|
30
|
-
"@lmzhen/dsh-evolution-approval": "^0.
|
|
31
|
-
"@lmzhen/dsh-evolution-core": "^0.
|
|
30
|
+
"@lmzhen/dsh-evolution-approval": "^0.23.0",
|
|
31
|
+
"@lmzhen/dsh-evolution-core": "^0.23.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
35
35
|
"@deepseek-ai/dsh-skill": "^0.2.0-rc.1",
|
|
36
36
|
"@deepseek-ai/dsh-system-prompt": "^0.2.0-rc.1",
|
|
37
37
|
"@deepseek-ai/dsh-tools": "^0.2.0-rc.1",
|
|
38
|
-
"@lmzhen/dsh-evolution-io": "^0.
|
|
39
|
-
"@lmzhen/dsh-skill-usage": "^0.
|
|
38
|
+
"@lmzhen/dsh-evolution-io": "^0.23.0",
|
|
39
|
+
"@lmzhen/dsh-skill-usage": "^0.23.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@deepseek-ai/dsh-agent-loop-testkit": "^0.2.0-rc.1",
|
|
43
43
|
"@deepseek-ai/dsh-skill": "^0.2.0-rc.1",
|
|
44
44
|
"@deepseek-ai/dsh-system-prompt": "^0.2.0-rc.1",
|
|
45
45
|
"@deepseek-ai/dsh-tools": "^0.2.0-rc.1",
|
|
46
|
-
"@lmzhen/dsh-evolution-core": "^0.
|
|
47
|
-
"@lmzhen/dsh-evolution-io": "^0.
|
|
48
|
-
"@lmzhen/dsh-skill-usage": "^0.
|
|
46
|
+
"@lmzhen/dsh-evolution-core": "^0.23.0",
|
|
47
|
+
"@lmzhen/dsh-evolution-io": "^0.23.0",
|
|
48
|
+
"@lmzhen/dsh-skill-usage": "^0.23.0"
|
|
49
49
|
}
|
|
50
50
|
}
|