dsh-context-truth 0.1.3 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-context-truth",
3
- "version": "0.1.3",
3
+ "version": "0.3.0",
4
4
  "description": "DeepSeek Harness plugin: tells the model its real, host-measured context occupancy every turn — and keeps compaction summaries from carrying false \"context is nearly exhausted\" claims.",
5
5
  "keywords": [
6
6
  "deepseek-harness",
@@ -27,6 +27,7 @@
27
27
  "main": "./lib/index.js",
28
28
  "exports": {
29
29
  ".": "./lib/index.js",
30
+ "./client": "./lib/client.js",
30
31
  "./package.json": "./package.json"
31
32
  },
32
33
  "files": [
@@ -42,9 +43,21 @@
42
43
  "engines": {
43
44
  "node": ">=20"
44
45
  },
46
+ "peerDependencies": {
47
+ "@deepseek-ai/schemastery": "^3.18.2"
48
+ },
49
+ "peerDependenciesMeta": {
50
+ "@deepseek-ai/schemastery": {
51
+ "optional": false
52
+ }
53
+ },
45
54
  "dsh": {
46
55
  "bundle": {
47
56
  "patch": "./cordis.patch.yml"
57
+ },
58
+ "client": {
59
+ "platform": "web",
60
+ "immediately": false
48
61
  }
49
62
  },
50
63
  "scripts": {
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Structural test for the browser half. It cannot render React here, but it proves
3
+ * the two things that break silently in the browser:
4
+ * 1) the module wrapper loads under the client module loader's id;
5
+ * 2) `apply` registers a `plugins.bundle.config` slot whose key is the bundle
6
+ * package name — the key the plugin manager's config ledger looks up.
7
+ */
8
+ import test from 'node:test'
9
+ import assert from 'node:assert/strict'
10
+
11
+ const loaded = []
12
+ globalThis.window = { __ModuleLoader__: { load: (definition) => loaded.push(definition) } }
13
+ await import('../lib/client.js')
14
+
15
+ const fakeReact = {
16
+ createElement: (type, props, ...children) => ({ type, props: { ...(props ?? {}), children } }),
17
+ useState: (initial) => [initial, () => {}],
18
+ useCallback: (fn) => fn,
19
+ useEffect: () => {},
20
+ }
21
+
22
+ test('the client module loads under the package id and registers the fold-mode panel', () => {
23
+ assert.equal(loaded.length, 1, 'the module wrapper must call the loader exactly once')
24
+ const { id, factory } = loaded[0]
25
+ assert.equal(id, 'dsh-context-truth')
26
+
27
+ const module = factory((name) => {
28
+ assert.equal(name, 'react', 'the client module must only require react')
29
+ return fakeReact
30
+ })
31
+ assert.equal(typeof module.apply, 'function')
32
+ assert.deepEqual(module.inject, ['slots', 'remote', 'remote.settings'])
33
+
34
+ const calls = []
35
+ const settings = { describe: async () => ({ ok: true, value: { namespaces: [] } }), mutate: async () => ({ ok: true }) }
36
+ const ctx = {
37
+ remote: { settings },
38
+ effect: (run) => run(),
39
+ slots: {
40
+ inject: (name, register) => {
41
+ calls.push(name)
42
+ return register()
43
+ },
44
+ register: (options, component) => {
45
+ calls.push({ options, component })
46
+ return () => {}
47
+ },
48
+ },
49
+ }
50
+ module.apply(ctx)
51
+
52
+ assert.equal(calls[0], 'plugins.bundle.config', 'the panel must attach to the bundle config slot')
53
+ const registration = calls[1]
54
+ assert.equal(registration.options.name, 'plugins.bundle.config')
55
+ assert.equal(registration.options.key, 'dsh-context-truth', 'the ledger key is the bundle package name')
56
+ assert.equal(typeof registration.options.inject, 'function')
57
+ assert.equal(registration.options.inject().settings, settings)
58
+ assert.equal(typeof registration.component, 'function')
59
+ })