@lmzhen/dsh-skill-usage 0.1.0-rc.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/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # @deepseek-ai/dsh-skill-usage
2
+
3
+ Skill usage telemetry service
4
+
5
+ ## Model Experience
6
+
7
+ ### Indirect model surface
8
+
9
+ #### What the model sees
10
+
11
+ `@deepseek-ai/dsh-skill-usage` registers no direct prompt or tool schema itself. Model-visible effects are owned by the packages that consume this service.
12
+
13
+ #### Token effect
14
+
15
+ Zero direct token effect from this package; consumers add any model-visible tokens.
16
+
17
+ #### KV Cache effect
18
+
19
+ Independent of request-prefix construction. This package does not alter the assembled prompt or tool list.
20
+
21
+ ## Known Limitations and Deferred Work
22
+
23
+
24
+ - No known durable consumer gaps at this time. Runtime contracts are covered by package and boundary tests.
package/lib/index.js ADDED
@@ -0,0 +1,64 @@
1
+ import { Service } from "@deepseek-ai/cordis";
2
+ import z from "@deepseek-ai/schemastery";
3
+ import { bumpPatch, bumpUse, bumpView, evolutionIoAdapter, loadUsage, saveUsage, skillsRoot } from "@lmzhen/dsh-evolution-core";
4
+ //#region lib/types/index.js
5
+ /**
6
+ * Skill usage telemetry service for the evolution family.
7
+ * @module @lmzhen/dsh-skill-usage
8
+ */
9
+ var SkillUsageRegistry = class extends Service {
10
+ static inject = ["evolutionIo"];
11
+ static Config = z.object({ root: z.string().default("") });
12
+ root;
13
+ io;
14
+ usage = null;
15
+ chain = Promise.resolve();
16
+ constructor(ctx, config = {}) {
17
+ super(ctx, "skillUsage");
18
+ this.root = config.root ?? skillsRoot();
19
+ this.io = evolutionIoAdapter(() => ctx.evolutionIo.provider());
20
+ }
21
+ async map() {
22
+ if (!this.usage) this.usage = await loadUsage(this.root, this.io);
23
+ return this.usage;
24
+ }
25
+ async flush() {
26
+ if (this.usage) await saveUsage(this.root, this.usage, this.io);
27
+ }
28
+ /** Serialize read-modify-write cycles so concurrent record calls never lose updates. */
29
+ mutate(task) {
30
+ const run = this.chain.then(async () => task(await this.map()));
31
+ this.chain = run.then(() => void 0, () => void 0);
32
+ return run;
33
+ }
34
+ async record(name, kind, at = /* @__PURE__ */ new Date()) {
35
+ await this.mutate(async (map) => {
36
+ if (kind === "use") bumpUse(map, name, at);
37
+ else if (kind === "view") bumpView(map, name, at);
38
+ else bumpPatch(map, name, at);
39
+ await this.flush();
40
+ });
41
+ }
42
+ report() {
43
+ return this.mutate((map) => Promise.resolve(new Map(map)));
44
+ }
45
+ async markAgentCreated(name) {
46
+ await this.mutate(async (map) => {
47
+ const { markAgentCreated } = await import("@lmzhen/dsh-evolution-core");
48
+ markAgentCreated(map, name);
49
+ await this.flush();
50
+ });
51
+ }
52
+ /** Write feedback-derived quality onto the usage sidecar; curator reads it. */
53
+ async setQuality(name, score, warn) {
54
+ await this.mutate(async (map) => {
55
+ const record = map.get(name);
56
+ if (!record) return;
57
+ record.quality_score = score;
58
+ record.quality_warn = warn;
59
+ await this.flush();
60
+ });
61
+ }
62
+ };
63
+ //#endregion
64
+ export { SkillUsageRegistry, SkillUsageRegistry as default };
@@ -0,0 +1,8 @@
1
+ //#region lib/types/invariant.js
2
+ const PACKAGE_NAME = "@deepseek-ai/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 };
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Skill usage telemetry service for the evolution family.
3
+ * @module @deepseek-ai/dsh-skill-usage
4
+ */
5
+ import { Context, Service } from '@deepseek-ai/cordis';
6
+ import type Schema from '@deepseek-ai/schemastery';
7
+ import { type UsageMap } from '@deepseek-ai/dsh-evolution-core';
8
+ declare module '@deepseek-ai/cordis' {
9
+ interface Context {
10
+ skillUsage: SkillUsageRegistry;
11
+ }
12
+ }
13
+ export interface Config {
14
+ root?: string;
15
+ }
16
+ export declare class SkillUsageRegistry extends Service {
17
+ static inject: string[];
18
+ static Config: Schema<Config>;
19
+ readonly root: string;
20
+ private readonly io;
21
+ private usage;
22
+ private chain;
23
+ constructor(ctx: Context, config?: Config);
24
+ private map;
25
+ flush(): Promise<void>;
26
+ /** Serialize read-modify-write cycles so concurrent record calls never lose updates. */
27
+ private mutate;
28
+ record(name: string, kind: 'use' | 'view' | 'patch', at?: Date): Promise<void>;
29
+ report(): Promise<UsageMap>;
30
+ markAgentCreated(name: string): Promise<void>;
31
+ /** Write feedback-derived quality onto the usage sidecar; curator reads it. */
32
+ setQuality(name: string, score: number, warn: boolean): Promise<void>;
33
+ }
34
+ export default SkillUsageRegistry;
35
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
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
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@lmzhen/dsh-skill-usage",
3
+ "description": "Skill usage telemetry service (community build)",
4
+ "version": "0.1.0-rc.1",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/lmzhen/dsh-evolution.git",
11
+ "directory": "packages/dsh-skill-usage"
12
+ },
13
+ "type": "module",
14
+ "main": "lib/index.js",
15
+ "types": "lib/types/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./lib/types/index.d.ts",
19
+ "default": "./lib/index.js"
20
+ },
21
+ "./invariant": {
22
+ "types": "./lib/types/invariant.d.ts",
23
+ "default": "./lib/invariant.js"
24
+ },
25
+ "./package.json": "./package.json"
26
+ },
27
+ "files": [
28
+ "lib/index.js",
29
+ "lib/invariant.js",
30
+ "lib/types/**/*.d.ts",
31
+ "lib/types/invariant.d.ts"
32
+ ],
33
+ "license": "MIT",
34
+ "dependencies": {
35
+ "@deepseek-ai/schemastery": "^3.18.1",
36
+ "@lmzhen/dsh-evolution-core": "^0.1.0-rc.1"
37
+ },
38
+ "peerDependencies": {
39
+ "@deepseek-ai/cordis": "^4.0.1",
40
+ "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6",
41
+ "@lmzhen/dsh-evolution-io": "^0.1.0-rc.1"
42
+ },
43
+ "devDependencies": {
44
+ "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6",
45
+ "@lmzhen/dsh-evolution-core": "^0.1.0-rc.1",
46
+ "@lmzhen/dsh-evolution-io": "^0.1.0-rc.1"
47
+ }
48
+ }