@lmzhen/dsh-evolution-capability 0.3.61 → 0.3.63

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 CHANGED
@@ -13,7 +13,7 @@ import { clampedNumber } from "@lmzhen/dsh-evolution-core";
13
13
  * @module @lmzhen/dsh-evolution-capability
14
14
  */
15
15
  const CAPABILITY_NAME_RE = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
16
- var EvolutionCapability = class extends Service {
16
+ var EvolutionCapability = class EvolutionCapability extends Service {
17
17
  static inject = ["evolutionApproval", "evolutionState"];
18
18
  static Config = z.object({
19
19
  maxNameLength: z.number().min(1).default(64),
@@ -21,6 +21,14 @@ var EvolutionCapability = class extends Service {
21
21
  maxCodeChars: z.number().min(1).default(65536)
22
22
  });
23
23
  limits;
24
+ /** P3 (v15): single source for the default limits — the Config schema and
25
+ * `validateCapabilityPackage`'s standalone default used to repeat the same
26
+ * three numbers (drift risk). */
27
+ static DEFAULT_LIMITS = {
28
+ maxNameLength: 64,
29
+ maxPurposeLength: 200,
30
+ maxCodeChars: 65536
31
+ };
24
32
  constructor(ctx, config = {}) {
25
33
  super(ctx, "evolutionCapability");
26
34
  const clamped = [];
@@ -30,9 +38,9 @@ var EvolutionCapability = class extends Service {
30
38
  return result;
31
39
  };
32
40
  this.limits = {
33
- maxNameLength: field("maxNameLength", config.maxNameLength, 64),
34
- maxPurposeLength: field("maxPurposeLength", config.maxPurposeLength, 200),
35
- maxCodeChars: field("maxCodeChars", config.maxCodeChars, 65536)
41
+ maxNameLength: field("maxNameLength", config.maxNameLength, EvolutionCapability.DEFAULT_LIMITS.maxNameLength),
42
+ maxPurposeLength: field("maxPurposeLength", config.maxPurposeLength, EvolutionCapability.DEFAULT_LIMITS.maxPurposeLength),
43
+ maxCodeChars: field("maxCodeChars", config.maxCodeChars, EvolutionCapability.DEFAULT_LIMITS.maxCodeChars)
36
44
  };
37
45
  if (clamped.length > 0) ctx.logger.warn(`evolution-capability: ${clamped.join(", ")} provided an invalid value; falling back to the default`);
38
46
  }
@@ -53,13 +61,17 @@ var EvolutionCapability = class extends Service {
53
61
  };
54
62
  const decision = await approval.request({
55
63
  kind: "capability",
56
- summary: `capability ${pkg.name}`,
57
- args: pkg,
64
+ summary: `capability ${pkg.name.trim()}`,
65
+ args: {
66
+ ...pkg,
67
+ name: pkg.name.trim(),
68
+ purpose: pkg.purpose.trim()
69
+ },
58
70
  origin
59
71
  });
60
72
  if (decision.action !== "staged") return {
61
73
  ok: false,
62
- message: "Capability submission requires staged approval: set approval.stageForeground=true (it keeps capability submissions paused for review; allow would bypass the audit)."
74
+ message: `Capability submission requires staged approval and must never skip the audit; approval allowed a direct write (${decision.message}). Check the session approval policy and the approval stageForeground setting.`
63
75
  };
64
76
  return {
65
77
  ok: true,
@@ -77,11 +89,7 @@ var EvolutionCapability = class extends Service {
77
89
  return this.validate(record.args).ok ? record.args : null;
78
90
  }
79
91
  };
80
- function validateCapabilityPackage(pkg, limits = {
81
- maxNameLength: 64,
82
- maxPurposeLength: 200,
83
- maxCodeChars: 65536
84
- }) {
92
+ function validateCapabilityPackage(pkg, limits = EvolutionCapability.DEFAULT_LIMITS) {
85
93
  const errors = [];
86
94
  if (!pkg || typeof pkg !== "object" || Array.isArray(pkg)) return {
87
95
  ok: false,
@@ -42,6 +42,10 @@ export declare class EvolutionCapability extends Service {
42
42
  static inject: string[];
43
43
  static Config: Schema<Config>;
44
44
  private readonly limits;
45
+ /** P3 (v15): single source for the default limits — the Config schema and
46
+ * `validateCapabilityPackage`'s standalone default used to repeat the same
47
+ * three numbers (drift risk). */
48
+ static readonly DEFAULT_LIMITS: Required<Config>;
45
49
  constructor(ctx: Context, config?: Config);
46
50
  validate(pkg: unknown): CapabilityValidation;
47
51
  /** Stage one capability package. Execution is deliberately out of scope. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-evolution-capability",
3
3
  "description": "Explicit staged governance adapter for Creator-mode capability packages (community build)",
4
- "version": "0.3.61",
4
+ "version": "0.3.63",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -31,22 +31,22 @@
31
31
  "license": "MIT",
32
32
  "dependencies": {
33
33
  "@deepseek-ai/schemastery": "^3.18.1",
34
- "@lmzhen/dsh-evolution-core": "^0.3.61"
34
+ "@lmzhen/dsh-evolution-core": "^0.3.63"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
38
38
  "@deepseek-ai/cordis": "^4.0.1",
39
- "@lmzhen/dsh-evolution-approval": "^0.3.61",
40
- "@lmzhen/dsh-evolution-state": "^0.3.61",
41
- "@lmzhen/dsh-evolution-state-storage": "^0.3.61"
39
+ "@lmzhen/dsh-evolution-approval": "^0.3.63",
40
+ "@lmzhen/dsh-evolution-state": "^0.3.63",
41
+ "@lmzhen/dsh-evolution-state-storage": "^0.3.63"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
45
- "@lmzhen/dsh-evolution-approval": "^0.3.61",
46
- "@lmzhen/dsh-evolution-state": "^0.3.61",
47
- "@lmzhen/dsh-evolution-state-storage": "^0.3.61",
48
- "@lmzhen/dsh-evolution-io": "^0.3.61",
49
- "@lmzhen/dsh-evolution-io-node": "^0.3.61",
50
- "@lmzhen/dsh-evolution-state-json": "^0.3.61"
45
+ "@lmzhen/dsh-evolution-approval": "^0.3.63",
46
+ "@lmzhen/dsh-evolution-state": "^0.3.63",
47
+ "@lmzhen/dsh-evolution-state-storage": "^0.3.63",
48
+ "@lmzhen/dsh-evolution-io": "^0.3.63",
49
+ "@lmzhen/dsh-evolution-io-node": "^0.3.63",
50
+ "@lmzhen/dsh-evolution-state-json": "^0.3.63"
51
51
  }
52
52
  }