dsh-te 0.3.0 → 0.4.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/cordis.patch.yml CHANGED
@@ -1,10 +1,14 @@
1
- # dsh-te: the install-all bundle. Installing this package pulls the three
2
- # components and inserts their rows; set `enabled: false` on a row's config to
3
- # keep the component dormant without uninstalling it.
1
+ # dsh-te: the install-all bundle.
4
2
  #
5
- # Install: dsh plugin --profile <name> add link:<repo>/packages/bundle
3
+ # Installing this package pulls the three components and adds the `/te` overview.
4
+ # Set `enabled: false` on a component's config, or `disabled: true` on its row,
5
+ # to keep it installed but dormant.
6
+ #
7
+ # Install: dsh plugin --profile <name> add dsh-te
6
8
  # Then add "dsh-te" to dsh.profile.bundles in that profile's package.json.
7
9
  - insert:
10
+ - id: te-overview
11
+ name: 'dsh-te'
8
12
  - id: te-cost
9
13
  name: 'dsh-te-cost'
10
14
  config:
package/lib/index.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The install-all bundle's own behaviour: `/te`.
3
+ *
4
+ * Without a command, this package was a dependency list plus a patch — a pure
5
+ * meta-package, which is installable but invisible: nothing in a session tells
6
+ * you the three components are there, and nothing says how to switch one off.
7
+ * `/te` answers both from whatever components are actually mounted, so it also
8
+ * works when the user installed only one of them.
9
+ *
10
+ * It reads the component services through `ctx.get`, never imports them at
11
+ * runtime, and reports nothing it cannot see.
12
+ *
13
+ * @module dsh-te
14
+ */
15
+ import type { Context } from '@deepseek-ai/cordis';
16
+ /** Mount the bundle's command. */
17
+ export declare function apply(ctx: Context): void;
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAmClD,kCAAkC;AAClC,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAexC"}
package/lib/index.js ADDED
@@ -0,0 +1,61 @@
1
+ import { formatTokens } from 'dsh-te-core';
2
+ /** Mount the bundle's command. */
3
+ export function apply(ctx) {
4
+ // The command service can be registered after this plugin loads, so the
5
+ // effect waits for it instead of reading `ctx.commands` at apply time.
6
+ ctx.inject(['commands'], (ctx) => {
7
+ ctx.effect(() => ctx.commands.register({
8
+ name: 'te',
9
+ description: 'Status of the three dsh-te components, and how to switch one off',
10
+ handler: async (invocation) => ({
11
+ kind: 'success',
12
+ text: await overview(invocation.agent.session, ctx),
13
+ }),
14
+ }));
15
+ });
16
+ }
17
+ /** One line per component that is actually mounted, plus how to switch it off. */
18
+ async function overview(session, ctx) {
19
+ const lines = ['dsh-te — three components behind one install.', ''];
20
+ const cost = ctx.get('teCost');
21
+ const facts = ctx.get('teFacts');
22
+ const prune = ctx.get('tePrune');
23
+ if (cost === undefined) {
24
+ lines.push('cost not installed');
25
+ }
26
+ else {
27
+ const current = cost.sessionSnapshot(session);
28
+ const repo = await cost.repoSnapshot(session);
29
+ const sessionPart = `${formatTokens(current.equivalent)} eq this session (${current.messages} req)`;
30
+ const repoPart = repo === undefined
31
+ ? 'no repo totals yet'
32
+ : `${formatTokens(repo.equivalent)} eq over ${repo.sessions} repo sessions`;
33
+ lines.push(`cost ${sessionPart} · ${repoPart}`);
34
+ }
35
+ if (facts === undefined) {
36
+ lines.push('facts not installed');
37
+ }
38
+ else {
39
+ const summary = await facts.snapshot(session);
40
+ const states = summary.total === 0
41
+ ? 'no facts yet'
42
+ : `${summary.total} facts: ${summary.active} active · ${summary.candidate} candidate · ${summary.retired} retired`;
43
+ const spend = summary.injectedTasks === 0
44
+ ? 'never injected'
45
+ : `injected ${summary.injectedTasks} tasks / ${formatTokens(summary.injectedTokens)} eq`;
46
+ lines.push(`facts ${summary.sessions} sessions · ${states} · ${spend}`);
47
+ }
48
+ if (prune === undefined) {
49
+ lines.push('prune not installed');
50
+ }
51
+ else {
52
+ const summary = await prune.snapshot(session);
53
+ const would = summary.candidates.length === 0 ? 'nothing to hide' : `would hide ${summary.candidates.join(', ')}`;
54
+ lines.push(`prune ${summary.sessions} sessions · ${summary.tracked} tools tracked · ${would}${summary.hiddenNow > 0 ? ` · ${summary.hiddenNow} hidden now` : ''}`);
55
+ }
56
+ lines.push('');
57
+ lines.push('Switch one off in the profile\'s cordis.patch.yml by adding "disabled: true" under its row');
58
+ lines.push('(te-cost, te-facts, te-prune), or with the switch on the DSH Plugins page.');
59
+ return lines.join('\n');
60
+ }
61
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAgC1C,kCAAkC;AAClC,MAAM,UAAU,KAAK,CAAC,GAAY;IAChC,wEAAwE;IACxE,uEAAuE;IACvE,GAAG,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE;QAC/B,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,CACd,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC;YACpB,IAAI,EAAE,IAAI;YACV,WAAW,EAAE,kEAAkE;YAC/E,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC;gBAC9B,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,MAAM,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC;aACpD,CAAC;SACH,CAAC,CACH,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,kFAAkF;AAClF,KAAK,UAAU,QAAQ,CAAC,OAAgB,EAAE,GAAY;IACpD,MAAM,KAAK,GAAG,CAAC,+CAA+C,EAAE,EAAE,CAAC,CAAA;IACnE,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAyB,CAAA;IAC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CAAC,CAAC,YAAY,OAAO,CAAC,aAAa,YAAY,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAA;QAC5F,KAAK,CAAC,IAAI,CAAC,YAAY,OAAO,CAAC,QAAQ,eAAe,MAAM,MAAM,KAAK,EAAE,CAAC,CAAA;IAC5E,CAAC;IAED,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAA;IACtC,CAAC;SAAM,CAAC;QACN,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,cAAc,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAA;QACjH,KAAK,CAAC,IAAI,CACR,YAAY,OAAO,CAAC,QAAQ,eAAe,OAAO,CAAC,OAAO,oBAAoB,KAAK,GAAG,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,SAAS,aAAa,CAAC,CAAC,CAAC,EAAE,EAAE,CAC1J,CAAA;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACd,KAAK,CAAC,IAAI,CACR,4FAA4F,CAC7F,CAAA;IACD,KAAK,CAAC,IAAI,CAAC,4EAA4E,CAAC,CAAA;IACxF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-te",
3
- "version": "0.3.0",
4
- "description": "Install-all bundle: cache-weighted cost accounting, repository facts and tool pruning for DeepSeek Harness. · 一键安装整包:为 DeepSeek Harness 提供缓存加权成本记账、仓库事实与工具裁剪。",
3
+ "version": "0.4.1",
4
+ "description": "Installs the cost, facts and prune components and adds a /te overview. · 一次装齐成本记账、仓库事实与工具隐藏三个组件,并提供 /te 总览。",
5
5
  "keywords": [
6
6
  "dsh",
7
7
  "dsh-plugin",
@@ -21,10 +21,16 @@
21
21
  "license": "Apache-2.0",
22
22
  "type": "module",
23
23
  "exports": {
24
+ ".": {
25
+ "types": "./lib/index.d.ts",
26
+ "import": "./lib/index.js"
27
+ },
24
28
  "./cordis.patch.yml": "./cordis.patch.yml",
25
29
  "./package.json": "./package.json"
26
30
  },
27
31
  "files": [
32
+ "lib",
33
+ "src",
28
34
  "cordis.patch.yml"
29
35
  ],
30
36
  "repository": {
@@ -45,10 +51,10 @@
45
51
  "access": "public"
46
52
  },
47
53
  "dependencies": {
48
- "dsh-te-core": "0.3.0",
49
- "dsh-te-cost": "0.3.0",
50
- "dsh-te-facts": "0.3.0",
51
- "dsh-te-prune": "0.3.0"
54
+ "dsh-te-core": "0.4.1",
55
+ "dsh-te-cost": "0.4.1",
56
+ "dsh-te-facts": "0.4.1",
57
+ "dsh-te-prune": "0.4.1"
52
58
  },
53
59
  "peerDependencies": {
54
60
  "@deepseek-ai/dsh": ">=0.2.2-rc.3"
@@ -57,5 +63,7 @@
57
63
  "bugs": {
58
64
  "url": "https://github.com/SonettoGu14/dsh-tokeneconomizer/issues"
59
65
  },
66
+ "main": "lib/index.js",
67
+ "types": "lib/index.d.ts",
60
68
  "scripts": {}
61
69
  }
package/src/index.ts ADDED
@@ -0,0 +1,119 @@
1
+ /**
2
+ * The install-all bundle's own behaviour: `/te`.
3
+ *
4
+ * Without a command, this package was a dependency list plus a patch — a pure
5
+ * meta-package, which is installable but invisible: nothing in a session tells
6
+ * you the three components are there, and nothing says how to switch one off.
7
+ * `/te` answers both from whatever components are actually mounted, so it also
8
+ * works when the user installed only one of them.
9
+ *
10
+ * It reads the component services through `ctx.get`, never imports them at
11
+ * runtime, and reports nothing it cannot see.
12
+ *
13
+ * @module dsh-te
14
+ */
15
+ import type { Context } from '@deepseek-ai/cordis'
16
+ import type {} from '@deepseek-ai/dsh-commands'
17
+ import type { Session } from '@deepseek-ai/dsh-session'
18
+ import { formatTokens } from 'dsh-te-core'
19
+
20
+ /** The part of `dsh-te-cost` this command reads. */
21
+ interface CostView {
22
+ sessionSnapshot(session: Session): { messages: number; equivalent: number; model?: string }
23
+ repoSnapshot(session: Session): Promise<{ equivalent: number; sessions: number; history: readonly unknown[] } | undefined>
24
+ }
25
+
26
+ /** The part of `dsh-te-facts` this command reads. */
27
+ interface FactsView {
28
+ snapshot(session: Session): Promise<{
29
+ sessions: number
30
+ total: number
31
+ active: number
32
+ candidate: number
33
+ retired: number
34
+ injectedTasks: number
35
+ injectedTokens: number
36
+ }>
37
+ }
38
+
39
+ /** The part of `dsh-te-prune` this command reads. */
40
+ interface PruneView {
41
+ snapshot(session: Session): Promise<{
42
+ sessions: number
43
+ tracked: number
44
+ candidates: readonly string[]
45
+ hiddenNow: number
46
+ idleSessions: number
47
+ }>
48
+ }
49
+
50
+ /** Mount the bundle's command. */
51
+ export function apply(ctx: Context): void {
52
+ // The command service can be registered after this plugin loads, so the
53
+ // effect waits for it instead of reading `ctx.commands` at apply time.
54
+ ctx.inject(['commands'], (ctx) => {
55
+ ctx.effect(() =>
56
+ ctx.commands.register({
57
+ name: 'te',
58
+ description: 'Status of the three dsh-te components, and how to switch one off',
59
+ handler: async (invocation) => ({
60
+ kind: 'success',
61
+ text: await overview(invocation.agent.session, ctx),
62
+ }),
63
+ }),
64
+ )
65
+ })
66
+ }
67
+
68
+ /** One line per component that is actually mounted, plus how to switch it off. */
69
+ async function overview(session: Session, ctx: Context): Promise<string> {
70
+ const lines = ['dsh-te — three components behind one install.', '']
71
+ const cost = ctx.get('teCost') as CostView | undefined
72
+ const facts = ctx.get('teFacts') as FactsView | undefined
73
+ const prune = ctx.get('tePrune') as PruneView | undefined
74
+
75
+ if (cost === undefined) {
76
+ lines.push('cost not installed')
77
+ } else {
78
+ const current = cost.sessionSnapshot(session)
79
+ const repo = await cost.repoSnapshot(session)
80
+ const sessionPart = `${formatTokens(current.equivalent)} eq this session (${current.messages} req)`
81
+ const repoPart =
82
+ repo === undefined
83
+ ? 'no repo totals yet'
84
+ : `${formatTokens(repo.equivalent)} eq over ${repo.sessions} repo sessions`
85
+ lines.push(`cost ${sessionPart} · ${repoPart}`)
86
+ }
87
+
88
+ if (facts === undefined) {
89
+ lines.push('facts not installed')
90
+ } else {
91
+ const summary = await facts.snapshot(session)
92
+ const states =
93
+ summary.total === 0
94
+ ? 'no facts yet'
95
+ : `${summary.total} facts: ${summary.active} active · ${summary.candidate} candidate · ${summary.retired} retired`
96
+ const spend =
97
+ summary.injectedTasks === 0
98
+ ? 'never injected'
99
+ : `injected ${summary.injectedTasks} tasks / ${formatTokens(summary.injectedTokens)} eq`
100
+ lines.push(`facts ${summary.sessions} sessions · ${states} · ${spend}`)
101
+ }
102
+
103
+ if (prune === undefined) {
104
+ lines.push('prune not installed')
105
+ } else {
106
+ const summary = await prune.snapshot(session)
107
+ const would = summary.candidates.length === 0 ? 'nothing to hide' : `would hide ${summary.candidates.join(', ')}`
108
+ lines.push(
109
+ `prune ${summary.sessions} sessions · ${summary.tracked} tools tracked · ${would}${summary.hiddenNow > 0 ? ` · ${summary.hiddenNow} hidden now` : ''}`,
110
+ )
111
+ }
112
+
113
+ lines.push('')
114
+ lines.push(
115
+ 'Switch one off in the profile\'s cordis.patch.yml by adding "disabled: true" under its row',
116
+ )
117
+ lines.push('(te-cost, te-facts, te-prune), or with the switch on the DSH Plugins page.')
118
+ return lines.join('\n')
119
+ }