@lmzhen/dsh-skill-usage 0.3.74 → 0.3.77

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/README.md CHANGED
@@ -30,3 +30,5 @@ Independent of request-prefix construction. This package does not alter the asse
30
30
 
31
31
 
32
32
  - No known durable consumer gaps at this time. Runtime contracts are covered by package and boundary tests.
33
+
34
+ **Runtime invariant:** No companion is published. The platform auto-assembles nothing and the family mounts no `<pkg>/invariant` cordis row, so a companion here would never execute (v37 S2.1 / I-3).
package/lib/index.js CHANGED
@@ -1,34 +1,20 @@
1
1
  import { Service } from "@deepseek-ai/cordis";
2
2
  import z from "@deepseek-ai/schemastery";
3
- import { appendEvolutionEvent, bumpPatch, bumpUse, bumpView, eventsFile, evolutionIoAdapter, evolutionRoot, getRecord, loadUsage, makeSerialQueue, markAgentCreated, mutateUsage, resolveSkillsRoot, usageObserved } from "@lmzhen/dsh-evolution-core";
3
+ import { ToolDispatchNormalizer, appendEvolutionEvent, bumpPatch, bumpUse, bumpView, eventsFile, evolutionIoAdapter, evolutionRoot, getRecord, loadUsage, makeSerialQueue, markAgentCreated, mutateUsage, resolveSkillsRoot, sessionAudited, skillReadNameOf, usageObserved } from "@lmzhen/dsh-evolution-core";
4
4
  //#region lib/types/index.js
5
5
  /**
6
6
  * Skill usage telemetry service for the evolution family.
7
7
  * @module @lmzhen/dsh-skill-usage
8
8
  */
9
9
  /**
10
- * Read tool names -> usage kind. The single declarative classification table
11
- * for read-side observation (A2): any tool listed here records a `view` when
12
- * its call arguments name a skill.
10
+ * Folds the session's dispatch events into one signal per READ (A2).
11
+ *
12
+ * The read tool table (only the real `skill` tool — the DSH catalog has no
13
+ * `skill_load`/`skill_search` discovery pair, 0.3.18 E-59e) and the arguments
14
+ * parse both live in evolution-core's `tool-dispatch` module: this sidecar used
15
+ * to match `tool/call` itself, so every PTC session (`tool/ptc-dispatch*`)
16
+ * counted zero views and never opened the observation window.
13
17
  */
14
- const READ_TOOL_KIND = { skill: "view" };
15
- /**
16
- * Skill name from a tool/call arguments payload (A2, mirrors
17
- * evolution-review's collectReadSkillNames): JSON strings are re-parsed and
18
- * `name` wins over `skill`. Empty when unparseable or anonymous.
19
- */
20
- function skillNameFromToolCall(raw) {
21
- let parsed = {};
22
- if (typeof raw === "string") try {
23
- parsed = JSON.parse(raw);
24
- } catch {
25
- return "";
26
- }
27
- else if (raw && typeof raw === "object") parsed = raw;
28
- if (!parsed || typeof parsed !== "object") return "";
29
- const obj = parsed;
30
- return typeof obj.name === "string" ? obj.name : typeof obj.skill === "string" ? obj.skill : "";
31
- }
32
18
  /** Cumulative library-wide usage totals (C observation-window event counts). */
33
19
  function usageTotals(map) {
34
20
  let views = 0;
@@ -50,7 +36,8 @@ var SkillUsageRegistry = class extends Service {
50
36
  static inject = ["evolutionIo"];
51
37
  static Config = z.object({
52
38
  root: z.string().default(""),
53
- eventsHome: z.string().default("")
39
+ eventsHome: z.string().default(""),
40
+ sessionScoped: z.boolean().default(false)
54
41
  });
55
42
  root;
56
43
  eventsHome;
@@ -63,12 +50,13 @@ var SkillUsageRegistry = class extends Service {
63
50
  this.eventsHome = config.eventsHome?.trim() || evolutionRoot();
64
51
  this.io = evolutionIoAdapter(() => ctx.evolutionIo.provider());
65
52
  ctx.effect(() => {
66
- return ctx.on("session/event", (_session, event) => {
67
- if (event.type !== "tool/call") return;
68
- const data = event.data;
69
- if (!(typeof data?.name === "string" ? READ_TOOL_KIND[data.name] : void 0)) return;
70
- const name = skillNameFromToolCall(data?.arguments);
71
- if (!name) return;
53
+ const reads = new ToolDispatchNormalizer();
54
+ return ctx.on("session/event", (session, event) => {
55
+ if (!sessionAudited(ctx, session.id, config.sessionScoped)) return;
56
+ const dispatch = reads.advance(event);
57
+ if (dispatch === null) return;
58
+ const name = skillReadNameOf(dispatch);
59
+ if (name === void 0) return;
72
60
  this.observeRead(name).catch(() => {});
73
61
  });
74
62
  }, "skill-usage.telemetry");
@@ -14,6 +14,9 @@ export interface Config {
14
14
  root?: string;
15
15
  /** Home for the evolution event timeline (`<eventsHome>/evolution/events.json`); defaults to DSH_HOME or ~/.dsh. */
16
16
  eventsHome?: string;
17
+ /** Act only on sessions that carry the family's model tools (evolution-core's
18
+ * per-session probe). The shipped bundles set it; false observes every session. */
19
+ sessionScoped?: boolean;
17
20
  }
18
21
  export declare class SkillUsageRegistry extends Service {
19
22
  static inject: string[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-skill-usage",
3
3
  "description": "Skill usage telemetry service (community build)",
4
- "version": "0.3.74",
4
+ "version": "0.3.77",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -18,10 +18,6 @@
18
18
  "types": "./lib/types/index.d.ts",
19
19
  "default": "./lib/index.js"
20
20
  },
21
- "./invariant": {
22
- "types": "./lib/types/invariant.d.ts",
23
- "default": "./lib/invariant.js"
24
- },
25
21
  "./package.json": "./package.json"
26
22
  },
27
23
  "files": [
@@ -31,18 +27,16 @@
31
27
  "license": "MIT",
32
28
  "dependencies": {
33
29
  "@deepseek-ai/schemastery": "^3.18.1",
34
- "@lmzhen/dsh-evolution-core": "^0.3.74"
30
+ "@lmzhen/dsh-evolution-core": "^0.3.77"
35
31
  },
36
32
  "peerDependencies": {
37
33
  "@deepseek-ai/cordis": "^4.0.1",
38
- "@deepseek-ai/dsh-invariants": "^0.1.5-rc.2",
39
34
  "@deepseek-ai/dsh-session": "^0.1.5-rc.2",
40
- "@lmzhen/dsh-evolution-io": "^0.3.74"
35
+ "@lmzhen/dsh-evolution-io": "^0.3.77"
41
36
  },
42
37
  "devDependencies": {
43
- "@deepseek-ai/dsh-invariants": "^0.1.5-rc.2",
44
38
  "@deepseek-ai/dsh-session": "^0.1.5-rc.2",
45
- "@lmzhen/dsh-evolution-core": "^0.3.74",
46
- "@lmzhen/dsh-evolution-io": "^0.3.74"
39
+ "@lmzhen/dsh-evolution-core": "^0.3.77",
40
+ "@lmzhen/dsh-evolution-io": "^0.3.77"
47
41
  }
48
42
  }
package/lib/invariant.js DELETED
@@ -1,8 +0,0 @@
1
- //#region lib/types/invariant.js
2
- const PACKAGE_NAME = "@lmzhen/dsh-skill-usage";
3
- const name = "skill-usage-invariant";
4
- const inject = ["invariants"];
5
- const install = () => {};
6
- const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
7
- //#endregion
8
- export { apply, inject, name };
@@ -1,5 +0,0 @@
1
- import type { Context } from '@deepseek-ai/cordis';
2
- export declare const name = "skill-usage-invariant";
3
- export declare const inject: string[];
4
- export declare const apply: (ctx: Context) => Promise<() => void>;
5
- //# sourceMappingURL=invariant.d.ts.map