dsh-context-compression-improved 0.7.0-beta.1 → 0.8.0-beta.2

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.
Files changed (93) hide show
  1. package/CHANGELOG.de.md +539 -0
  2. package/CHANGELOG.es.md +547 -0
  3. package/CHANGELOG.fr.md +534 -0
  4. package/CHANGELOG.it.md +536 -0
  5. package/CHANGELOG.ja.md +226 -220
  6. package/CHANGELOG.ko.md +220 -214
  7. package/CHANGELOG.md +372 -376
  8. package/CHANGELOG.ru.md +517 -0
  9. package/CHANGELOG.zh.md +204 -199
  10. package/README.de.md +98 -0
  11. package/README.es.md +98 -0
  12. package/README.fr.md +98 -0
  13. package/README.it.md +98 -0
  14. package/README.ja.md +85 -85
  15. package/README.ko.md +85 -85
  16. package/README.md +98 -97
  17. package/README.ru.md +98 -0
  18. package/README.zh.md +85 -86
  19. package/docs/installation.de.md +104 -0
  20. package/docs/installation.es.md +104 -0
  21. package/docs/installation.fr.md +104 -0
  22. package/docs/installation.it.md +104 -0
  23. package/docs/installation.ja.md +78 -78
  24. package/docs/installation.ko.md +78 -78
  25. package/docs/installation.md +103 -103
  26. package/docs/installation.ru.md +104 -0
  27. package/docs/installation.zh.md +100 -100
  28. package/eslint.config.js +30 -76
  29. package/package.json +69 -70
  30. package/packages/selector/dsh.plugin.json +2 -2
  31. package/packages/selector/lib/{intent-gate.js → advisor-state.js} +3 -91
  32. package/packages/selector/lib/client.js +736 -14
  33. package/packages/selector/lib/index.js +1 -92
  34. package/packages/selector/lib/profiles.d.ts +0 -9
  35. package/packages/selector/lib/pruner.d.ts +0 -59
  36. package/packages/selector/lib/pruner.js +7 -410
  37. package/packages/selector/lib/style.css +46 -46
  38. package/packages/selector/package.json +114 -114
  39. package/packages/selector/src/client/decode.ts +2 -6
  40. package/packages/selector/src/client/index.ts +244 -213
  41. package/packages/selector/src/client/locales/de.ts +98 -0
  42. package/packages/selector/src/client/locales/es.ts +98 -0
  43. package/packages/selector/src/client/locales/fr.ts +98 -0
  44. package/packages/selector/src/client/locales/it.ts +98 -0
  45. package/packages/selector/src/client/locales/ja.ts +98 -0
  46. package/packages/selector/src/client/locales/ko.ts +98 -0
  47. package/packages/selector/src/client/locales/ru.ts +98 -0
  48. package/packages/selector/src/deepseek-v4-tokenizer.ts +1 -1
  49. package/packages/selector/src/index.ts +411 -418
  50. package/packages/selector/src/preset-overlay.ts +0 -3
  51. package/packages/selector/src/profiles.ts +10 -30
  52. package/packages/selector/src/pruner/content.ts +1 -1
  53. package/packages/selector/src/pruner/state.ts +0 -7
  54. package/packages/selector/src/pruner.ts +9 -253
  55. package/packages/selector/src/runtime/audit.ts +0 -17
  56. package/packages/selector/src/runtime/config.ts +11 -36
  57. package/packages/selector/src/runtime/reducers.ts +1 -1
  58. package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +1 -46
  59. package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +0 -55
  60. package/packages/selector/src/runtime/tokenpilot/locator.ts +2 -2
  61. package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +1 -4
  62. package/packages/selector/src/runtime/types.ts +0 -12
  63. package/packages/selector/tests/auto-compact.client.spec.tsx +213 -214
  64. package/packages/selector/tests/built/client-artifact.spec.ts +59 -61
  65. package/packages/selector/tests/code-skeleton.client.spec.ts +93 -94
  66. package/packages/selector/tests/custom-contract.client.spec.ts +222 -223
  67. package/packages/selector/tests/estimator-channel.client.spec.tsx +252 -252
  68. package/packages/selector/tests/host-preset-overlay.host.spec.ts +204 -204
  69. package/packages/selector/tests/preset-options-write.client.spec.ts +187 -188
  70. package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +200 -200
  71. package/packages/selector/tests/profiles.client.spec.tsx +434 -436
  72. package/packages/selector/tests/public/package-contract.client.spec.ts +78 -78
  73. package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +230 -230
  74. package/packages/selector/tests/runtime/audit.spec.ts +274 -275
  75. package/packages/selector/tests/runtime/auto-compact-config.spec.ts +3 -3
  76. package/packages/selector/tests/runtime/deepseek-v4-tokenizer.spec.ts +4 -4
  77. package/packages/selector/tests/runtime/public/public-runtime.spec.ts +2731 -2736
  78. package/packages/selector/tests/standing-generation.host.spec.ts +724 -704
  79. package/pnpm-workspace.yaml +66 -66
  80. package/scripts/packed-components-smoke.mjs +0 -2
  81. package/scripts/packed-install-e2e.mjs +5 -7
  82. package/scripts/verify-release.mjs +2 -3
  83. package/tests/TEST_INVENTORY.md +41 -41
  84. package/tsconfig.tests.json +1 -3
  85. package/vitest.config.ts +0 -14
  86. package/packages/selector/src/runtime/summary-command.ts +0 -133
  87. package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +0 -53
  88. package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +0 -65
  89. package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +0 -125
  90. package/packages/selector/src/runtime/tokenpilot/intent-range.ts +0 -37
  91. package/packages/selector/tests/runtime/intent-gate.spec.ts +0 -62
  92. package/packages/selector/tests/runtime/intent-summary.spec.ts +0 -156
  93. package/packages/selector/tests/runtime/summary-command.spec.ts +0 -154
@@ -1,66 +1,66 @@
1
- packages:
2
- - packages/*
3
-
4
- linkWorkspacePackages: true
5
-
6
- peerDependencyRules:
7
- allowedVersions:
8
- typescript: ">=5 <7"
9
-
10
- allowBuilds:
11
- esbuild: true
12
- "@huggingface/tokenizers": true
13
-
14
- overrides:
15
- '@deepseek-ai/cordis': '4.0.1'
16
- '@deepseek-ai/cordis-plugin-group': '1.0.1'
17
- '@deepseek-ai/cordis-plugin-include': '1.0.6'
18
- '@deepseek-ai/cordis-plugin-loader': '1.0.2'
19
- '@deepseek-ai/dsh-agent': '0.1.7-rc.2'
20
- '@deepseek-ai/dsh-agent-loop': '0.1.7-rc.2'
21
- '@deepseek-ai/dsh-agent-loop-testkit': '0.1.7-rc.2'
22
- '@deepseek-ai/dsh-agent-presets': '0.1.6-alpha.2'
23
- '@deepseek-ai/dsh-client-locale': '0.1.7-rc.2'
24
- '@deepseek-ai/dsh-client-ui-primitives': '0.1.7-rc.2'
25
- '@deepseek-ai/dsh-client-ui-settings': '0.1.7-rc.2'
26
- '@deepseek-ai/dsh-client-ui-slots': '0.1.7-rc.2'
27
- '@deepseek-ai/dsh-client-store': '0.1.7-rc.2'
28
- '@deepseek-ai/dsh-client-ui-workspace': '0.1.7-rc.2'
29
- '@deepseek-ai/dsh-command-compact': '0.1.7-rc.2'
30
- '@deepseek-ai/dsh-commands': '0.1.7-rc.2'
31
- '@deepseek-ai/dsh-compaction': '0.1.7-rc.2'
32
- '@deepseek-ai/dsh-compaction-basic': '0.1.7-rc.2'
33
- '@deepseek-ai/dsh-invariants': '0.1.7-rc.2'
34
- '@deepseek-ai/dsh-llm': '0.1.7-rc.2'
35
- '@deepseek-ai/dsh-llm-deepseek': '0.1.7-rc.2'
36
- '@deepseek-ai/dsh-scope': '0.1.7-rc.2'
37
- '@deepseek-ai/dsh-session': '0.1.7-rc.2'
38
- '@deepseek-ai/dsh-settings': '0.1.7-rc.2'
39
- '@deepseek-ai/dsh-subagent': '0.1.7-rc.2'
40
- '@deepseek-ai/dsh-subagent-fork-in-process': '0.1.7-rc.2'
41
- '@deepseek-ai/dsh-subagent-spawn-in-process': '0.1.7-rc.2'
42
- '@deepseek-ai/dsh-system-prompt': '0.1.7-rc.2'
43
- '@deepseek-ai/dsh-token-meter': '0.1.7-rc.2'
44
- '@deepseek-ai/dsh-tools': '0.1.7-rc.2'
45
- '@deepseek-ai/dsh-anonymous-user-id': '0.1.7-rc.2'
46
- '@deepseek-ai/dsh-atomic-write': '0.1.7-rc.2'
47
- '@deepseek-ai/dsh-attachment': '0.1.7-rc.2'
48
- '@deepseek-ai/dsh-code-runtime': '0.1.5-rc.3'
49
- '@deepseek-ai/dsh-credentials': '0.1.7-rc.2'
50
- '@deepseek-ai/dsh-home-paths': '0.1.7-rc.2'
51
- '@deepseek-ai/dsh-launch-environment': '0.1.7-rc.2'
52
- '@deepseek-ai/dsh-llm-retry': '0.1.7-rc.2'
53
- '@deepseek-ai/dsh-sandbox': '0.1.7-rc.2'
54
- '@deepseek-ai/dsh-session-persistence': '0.1.7-rc.2'
55
- '@deepseek-ai/dsh-session-projection': '0.1.7-rc.2'
56
- '@deepseek-ai/dsh-subagent-in-process-driver': '0.1.7-rc.2'
57
- '@deepseek-ai/dsh-user-approval': '0.1.7-rc.2'
58
- '@deepseek-ai/schemastery': '3.18.4'
59
- '@deepseek-ai/dsh-client-ui-session': '0.1.7-rc.2'
60
- '@deepseek-ai/dsh-api-session-controller': '0.1.7-rc.2'
61
- # Scoped, not global: @deepseek-ai/cordis-plugin-include (^4.1.0) and
62
- # @deepseek-ai/dsh-agent-presets resolve js-yaml 4.3.1 from ranges that already
63
- # allow the patched release, so pin the vulnerable ones without waiting on their
64
- # next release. GHSA-2883-xcg3-v3hh: js-yaml < 4.3.2 does not bound CPU use for
65
- # empty merge sources.
66
- 'js-yaml@<4.3.2': '^4.3.2'
1
+ packages:
2
+ - packages/*
3
+
4
+ linkWorkspacePackages: true
5
+
6
+ peerDependencyRules:
7
+ allowedVersions:
8
+ typescript: ">=5 <7"
9
+
10
+ allowBuilds:
11
+ esbuild: true
12
+ "@huggingface/tokenizers": true
13
+
14
+ overrides:
15
+ '@deepseek-ai/cordis': '4.0.1'
16
+ '@deepseek-ai/cordis-plugin-group': '1.0.1'
17
+ '@deepseek-ai/cordis-plugin-include': '1.0.6'
18
+ '@deepseek-ai/cordis-plugin-loader': '1.0.2'
19
+ '@deepseek-ai/dsh-agent': '0.2.0-rc.1'
20
+ '@deepseek-ai/dsh-agent-loop': '0.2.0-rc.1'
21
+ '@deepseek-ai/dsh-agent-loop-testkit': '0.2.0-rc.1'
22
+ '@deepseek-ai/dsh-agent-presets': '0.1.6-alpha.2'
23
+ '@deepseek-ai/dsh-client-locale': '0.2.0-rc.1'
24
+ '@deepseek-ai/dsh-client-ui-primitives': '0.2.0-rc.1'
25
+ '@deepseek-ai/dsh-client-ui-settings': '0.2.0-rc.1'
26
+ '@deepseek-ai/dsh-client-ui-slots': '0.2.0-rc.1'
27
+ '@deepseek-ai/dsh-client-store': '0.2.0-rc.1'
28
+ '@deepseek-ai/dsh-client-ui-workspace': '0.2.0-rc.1'
29
+ '@deepseek-ai/dsh-command-compact': '0.2.0-rc.1'
30
+ '@deepseek-ai/dsh-commands': '0.2.0-rc.1'
31
+ '@deepseek-ai/dsh-compaction': '0.2.0-rc.1'
32
+ '@deepseek-ai/dsh-compaction-basic': '0.2.0-rc.1'
33
+ '@deepseek-ai/dsh-invariants': '0.2.0-rc.1'
34
+ '@deepseek-ai/dsh-llm': '0.2.0-rc.1'
35
+ '@deepseek-ai/dsh-llm-deepseek': '0.2.0-rc.1'
36
+ '@deepseek-ai/dsh-scope': '0.2.0-rc.1'
37
+ '@deepseek-ai/dsh-session': '0.2.0-rc.1'
38
+ '@deepseek-ai/dsh-settings': '0.2.0-rc.1'
39
+ '@deepseek-ai/dsh-subagent': '0.2.0-rc.1'
40
+ '@deepseek-ai/dsh-subagent-fork-in-process': '0.2.0-rc.1'
41
+ '@deepseek-ai/dsh-subagent-spawn-in-process': '0.2.0-rc.1'
42
+ '@deepseek-ai/dsh-system-prompt': '0.2.0-rc.1'
43
+ '@deepseek-ai/dsh-token-meter': '0.2.0-rc.1'
44
+ '@deepseek-ai/dsh-tools': '0.2.0-rc.1'
45
+ '@deepseek-ai/dsh-anonymous-user-id': '0.2.0-rc.1'
46
+ '@deepseek-ai/dsh-atomic-write': '0.2.0-rc.1'
47
+ '@deepseek-ai/dsh-attachment': '0.2.0-rc.1'
48
+ '@deepseek-ai/dsh-code-runtime': '0.1.5-rc.3'
49
+ '@deepseek-ai/dsh-credentials': '0.2.0-rc.1'
50
+ '@deepseek-ai/dsh-home-paths': '0.2.0-rc.1'
51
+ '@deepseek-ai/dsh-launch-environment': '0.2.0-rc.1'
52
+ '@deepseek-ai/dsh-llm-retry': '0.2.0-rc.1'
53
+ '@deepseek-ai/dsh-sandbox': '0.2.0-rc.1'
54
+ '@deepseek-ai/dsh-session-persistence': '0.2.0-rc.1'
55
+ '@deepseek-ai/dsh-session-projection': '0.2.0-rc.1'
56
+ '@deepseek-ai/dsh-subagent-in-process-driver': '0.2.0-rc.1'
57
+ '@deepseek-ai/dsh-user-approval': '0.2.0-rc.1'
58
+ '@deepseek-ai/schemastery': '3.18.4'
59
+ '@deepseek-ai/dsh-client-ui-session': '0.2.0-rc.1'
60
+ '@deepseek-ai/dsh-api-session-controller': '0.2.0-rc.1'
61
+ # Scoped, not global: @deepseek-ai/cordis-plugin-include (^4.1.0) and
62
+ # @deepseek-ai/dsh-agent-presets resolve js-yaml 4.3.1 from ranges that already
63
+ # allow the patched release, so pin the vulnerable ones without waiting on their
64
+ # next release. GHSA-2883-xcg3-v3hh: js-yaml < 4.3.2 does not bound CPU use for
65
+ # empty merge sources.
66
+ 'js-yaml@<4.3.2': '^4.3.2'
@@ -71,8 +71,6 @@ class NativeSummaryAdapter extends LlmAdapter {
71
71
  })
72
72
  }
73
73
 
74
- // Async generator shape is required by the llm service contract; no await needed.
75
- // eslint-disable-next-line @typescript-eslint/require-await
76
74
  async * stream(options) {
77
75
  options.signal?.throwIfAborted()
78
76
  const text = this.responses.shift()
@@ -303,10 +303,10 @@ async function runOfficialCloneCliSmoke(referenceRoot, registry, upgradeFrom, ca
303
303
  tree: await git('rev-parse', 'HEAD^{tree}'),
304
304
  status: await git('status', '--porcelain'),
305
305
  }
306
- assert(before.tag === 'dsh-v0.1.7-rc.2', `official clone tag is ${before.tag}`)
307
- assert(before.commit === '477b4f420553e8a52c2fbccc464d7561b239c443',
306
+ assert(before.tag === 'dsh-v0.2.0-rc.1', `official clone tag is ${before.tag}`)
307
+ assert(before.commit === '4878cdabd87d4041bdaff61d04c966883b9fd07a',
308
308
  `official clone commit is ${before.commit}`)
309
- assert(before.tree === 'e3e63253d1d35ad07f785273235c40813cb6c8bd',
309
+ assert(before.tree === 'cc46581494c2f8d4a33db59096db14db70f8337d',
310
310
  `official clone tree is ${before.tree}`)
311
311
  assert(before.status === '', 'official clone is dirty before CLI smoke')
312
312
 
@@ -977,8 +977,6 @@ try {
977
977
  })
978
978
  }
979
979
 
980
- // The handler is fully try/catch-guarded below; node drops the returned promise.
981
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
982
980
  server = createServer(async (request, response) => {
983
981
  try {
984
982
  const requestUrl = new URL(request.url ?? '/', 'http://127.0.0.1')
@@ -1115,7 +1113,7 @@ try {
1115
1113
  throw new Error('packed package is not guarded by publishConfig.tag=latest')
1116
1114
  }
1117
1115
  for (const peer of ['@deepseek-ai/dsh-command-compact', '@deepseek-ai/dsh-compaction-basic']) {
1118
- if (selector.peerDependencies?.[peer] !== '>=0.1.7-rc.1 <0.2.0-0') {
1116
+ if (selector.peerDependencies?.[peer] !== '>=0.2.0-rc.1 <0.2.1-0') {
1119
1117
  throw new Error(`packed selector has an invalid ${peer} peer range`)
1120
1118
  }
1121
1119
  }
@@ -1224,7 +1222,7 @@ try {
1224
1222
  const cloneRoot = join(artifactRoot, 'official-clone')
1225
1223
  try {
1226
1224
  await run('git', [
1227
- 'clone', '--depth', '1', '--branch', 'dsh-v0.1.7-rc.2',
1225
+ 'clone', '--depth', '1', '--branch', 'dsh-v0.2.0-rc.1',
1228
1226
  'https://github.com/deepseek-ai/deepseek-harness.git', cloneRoot,
1229
1227
  ])
1230
1228
  officialCloneSmoke = await runOfficialCloneCliSmoke(
@@ -39,7 +39,6 @@ if (rootPackage.dsh?.bundle?.patch !== './packages/selector/cordis.patch.yml') {
39
39
  const INSTALLATION_PROVIDED_RUNTIME = new Set([
40
40
  '@deepseek-ai/cordis',
41
41
  '@deepseek-ai/cordis-plugin-include',
42
- '@deepseek-ai/dsh-commands',
43
42
  '@deepseek-ai/dsh-llm',
44
43
  '@deepseek-ai/dsh-session',
45
44
  '@deepseek-ai/dsh-settings',
@@ -49,7 +48,7 @@ const INSTALLATION_PROVIDED_RUNTIME = new Set([
49
48
  // stack (`react`, the ui-slot packages); its requires are reviewed from the
50
49
  // built artifact further down instead.
51
50
  const HOST_PLANE_ENTRIES = [
52
- 'lib/intent-gate.js',
51
+ 'lib/advisor-state.js',
53
52
  'lib/index.js',
54
53
  'lib/invariant.js',
55
54
  'lib/pruner.js',
@@ -151,7 +150,7 @@ for (const peer of [
151
150
  '@deepseek-ai/dsh-command-compact',
152
151
  '@deepseek-ai/dsh-compaction-basic',
153
152
  ]) {
154
- if (selectorPackage.peerDependencies?.[peer] !== '>=0.1.7-rc.1 <0.2.0-0') {
153
+ if (selectorPackage.peerDependencies?.[peer] !== '>=0.2.0-rc.1 <0.2.1-0') {
155
154
  fail(`selector peer ${peer} is missing or outside the verified range`)
156
155
  }
157
156
  }
@@ -1,41 +1,41 @@
1
- # Test inventory
2
-
3
- Every checked-in spec belongs to an active test project. There is no silent
4
- legacy-test allowlist.
5
-
6
- ## Root suite
7
-
8
- - Runtime: `packages/runtime/tests/**/*.spec.ts` under the `runtime` project.
9
- - Selector Host: `cache-prefix-audit.spec.ts` plus every `*.host.spec.ts` under
10
- the `selector-host` project.
11
- - Selector client: every `*.client.spec.ts` or `*.client.spec.tsx` under the
12
- `selector-client` project.
13
- - Built browser artifact: `packages/selector/tests/built/client-artifact.spec.ts`
14
- under the separate `vitest.built.config.ts` gate, after `pnpm build`.
15
-
16
- The root `pnpm test`, both package-local `pnpm test` commands, and
17
- `pnpm test:built` are release gates. `scripts/verify-release.mjs` compares the
18
- checked-in spec inventory with these project rules so a new test cannot be
19
- silently excluded.
20
-
21
- ## Removed transition tests
22
-
23
- The standalone extraction initially carried twelve specs copied from the
24
- integrated Harness worktree. They depended on removed private packages,
25
- monorepo-relative fixtures, or the retired `compaction/group-trim` event and
26
- were not executable in a public checkout. They were removed instead of
27
- reintroducing Harness core dependencies.
28
-
29
- Their supported behavior is covered by active public tests:
30
-
31
- - policy resolution, reducers, exact measurement, Fresh, Aggregate, routine
32
- and capacity-pressure History, Native pruning, TailTrim publication,
33
- recovery, replay and orphan fail-open behavior:
34
- `packages/selector/tests/runtime/public/public-runtime.spec.ts`;
35
- - Loader composition, preset overlay, Minimal pause/restore and parent/child
36
- service identity: `packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts`;
37
- - package/export/tarball contract:
38
- `packages/selector/tests/public/package-contract.client.spec.ts` and
39
- `scripts/packed-install-e2e.mjs`;
40
- - profile and Custom editor behavior:
41
- `packages/selector/tests/profiles.client.spec.tsx`.
1
+ # Test inventory
2
+
3
+ Every checked-in spec belongs to an active test project. There is no silent
4
+ legacy-test allowlist.
5
+
6
+ ## Root suite
7
+
8
+ - Runtime: `packages/selector/tests/runtime/**/*.spec.ts` under the `runtime` project.
9
+ - Selector Host: `cache-prefix-audit.spec.ts` plus every `*.host.spec.ts` under
10
+ the `selector-host` project.
11
+ - Selector client: every `*.client.spec.ts` or `*.client.spec.tsx` under the
12
+ `selector-client` project.
13
+ - Built browser artifact: `packages/selector/tests/built/client-artifact.spec.ts`
14
+ under the separate `vitest.built.config.ts` gate, after `pnpm build`.
15
+
16
+ The root `pnpm test`, both package-local `pnpm test` commands, and
17
+ `pnpm test:built` are release gates. `scripts/verify-release.mjs` compares the
18
+ checked-in spec inventory with these project rules so a new test cannot be
19
+ silently excluded.
20
+
21
+ ## Removed transition tests
22
+
23
+ The standalone extraction initially carried twelve specs copied from the
24
+ integrated Harness worktree. They depended on removed private packages,
25
+ monorepo-relative fixtures, or the retired `compaction/group-trim` event and
26
+ were not executable in a public checkout. They were removed instead of
27
+ reintroducing Harness core dependencies.
28
+
29
+ Their supported behavior is covered by active public tests:
30
+
31
+ - policy resolution, reducers, exact measurement, Fresh, Aggregate, routine
32
+ and capacity-pressure History, Native pruning, TailTrim publication,
33
+ recovery, replay and orphan fail-open behavior:
34
+ `packages/selector/tests/runtime/public/public-runtime.spec.ts`;
35
+ - Loader composition, preset overlay, Minimal pause/restore and parent/child
36
+ service identity: `packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts`;
37
+ - package/export/tarball contract:
38
+ `packages/selector/tests/public/package-contract.client.spec.ts` and
39
+ `scripts/packed-install-e2e.mjs`;
40
+ - profile and Custom editor behavior:
41
+ `packages/selector/tests/profiles.client.spec.tsx`.
@@ -10,8 +10,6 @@
10
10
  "packages/selector/tests/**/*.ts",
11
11
  "packages/selector/tests/**/*.tsx",
12
12
  "vitest.config.ts",
13
- "vitest.built.config.ts",
14
- "packages/selector/tsdown.config.ts",
15
- "packages/selector/tsdown.client.config.ts"
13
+ "vitest.built.config.ts"
16
14
  ]
17
15
  }
package/vitest.config.ts CHANGED
@@ -4,20 +4,6 @@ import { fileURLToPath } from 'node:url'
4
4
  export default defineConfig({
5
5
  test: {
6
6
  passWithNoTests: false,
7
- coverage: {
8
- provider: 'v8',
9
- include: ['packages/selector/src/**'],
10
- exclude: ['**/*.d.ts'],
11
- reporter: ['text', 'json-summary'],
12
- // Ratcheted just under the measured 0.1.7 baseline
13
- // (lines 82.16 / functions 83.95 / branches 69.93 / statements 78.40).
14
- thresholds: {
15
- lines: 82,
16
- functions: 83,
17
- branches: 69,
18
- statements: 78,
19
- },
20
- },
21
7
  projects: [
22
8
  {
23
9
  test: {
@@ -1,133 +0,0 @@
1
- /**
2
- * `/ctx-summary off|on|status` — in-session temporary override for the
3
- * turn-tail intent-summary gate.
4
- *
5
- * The override is session-scoped by design: settings are session-frozen
6
- * (changes only affect newly observed sessions), so "temporarily disable and
7
- * resume" can only be expressed as runtime state. Overrides die with the
8
- * process and never leak across sessions. `off` wins over the settings gate;
9
- * `on` never bypasses the numeric growth gates — it only lifts the
10
- * settings/override veto.
11
- *
12
- * Registration mirrors the host's own `/compact` command: optional
13
- * `commands`-service injection (a host without the registry simply never
14
- * mounts the command), dynamic `CommandDefinitionId` brand import with a
15
- * plain fallback so a stripped host cannot break plugin load.
16
- */
17
- import type { Context } from '@deepseek-ai/cordis'
18
- import {
19
- getLastIntentFold,
20
- getObservedIntentEnabled,
21
- getSummaryOverride,
22
- setSummaryOverride,
23
- } from './tokenpilot/advisor-state.ts'
24
- import { INTENT_GATE_FLOOR_FRACTION, INTENT_GATE_GROWTH_TOKENS } from './tokenpilot/intent-gate.ts'
25
-
26
- export const SUMMARY_COMMAND_NAME = 'ctx-summary'
27
-
28
- const USAGE = 'Usage: /ctx-summary off|on|status'
29
-
30
- export type SummaryCommandArgs = 'off' | 'on' | 'status'
31
-
32
- /** Parse the raw argument string; `undefined` = unrecognized (usage error). */
33
- export function parseSummaryCommandArgs(rawInput: string): SummaryCommandArgs | undefined {
34
- const token = rawInput.trim().toLowerCase()
35
- if (token === 'off' || token === 'on' || token === 'status') return token
36
- return undefined
37
- }
38
-
39
- function describeFold(sessionId: string): string {
40
- const fold = getLastIntentFold(sessionId)
41
- if (fold === undefined) return 'none'
42
- return `turn ${fold.turn}, seq ${fold.startSeq}..${fold.endSeq}`
43
- }
44
-
45
- /** Human-facing status line; observability only, never a decision input. */
46
- export function formatSummaryStatus(sessionId: string): string {
47
- const override = getSummaryOverride(sessionId)
48
- const enabled = getObservedIntentEnabled(sessionId)
49
- const enabledText = enabled === undefined ? 'unknown (gate not evaluated yet)' : enabled ? 'yes' : 'no'
50
- return [
51
- `ctx-summary status:`,
52
- ` override: ${override ?? 'default (settings-driven)'}`,
53
- ` intentSummary enabled (settings): ${enabledText}`,
54
- ` gate: floor >${Math.round(INTENT_GATE_FLOOR_FRACTION * 100)}% of window AND growth >${INTENT_GATE_GROWTH_TOKENS} tokens since last fold`,
55
- ` last fold: ${describeFold(sessionId)}`,
56
- ].join('\n')
57
- }
58
-
59
- /** Resolve the invoking agent's session id (`''` when the host exposes none). */
60
- function sessionIdOf(agent: unknown): string {
61
- const session = (agent as { session?: { id?: unknown } } | undefined)?.session
62
- if (session === undefined || session.id === undefined || session.id === null) return ''
63
- // Host session ids are strings in practice; String() keeps the legacy
64
- // best-effort coercion for exotic host shapes.
65
- // eslint-disable-next-line @typescript-eslint/no-base-to-string
66
- return String(session.id)
67
- }
68
-
69
- type CommandsServiceLike = {
70
- register: (definition: {
71
- definitionId?: unknown
72
- name: string
73
- description: string
74
- handler: (invocation: { agent?: unknown, rawInput?: unknown }) => Promise<{ kind: 'success' | 'error', text: string }>
75
- }) => unknown
76
- }
77
-
78
- /** Best-effort `CommandDefinitionId` brand; `undefined` on stripped hosts (registered without it). */
79
- async function loadCommandDefinitionId(): Promise<((id: string) => unknown) | undefined> {
80
- try {
81
- const mod = (await import('@deepseek-ai/dsh-commands')) as { CommandDefinitionId?: (id: string) => unknown }
82
- return mod.CommandDefinitionId
83
- } catch {
84
- return undefined
85
- }
86
- }
87
-
88
- /**
89
- * Mount `/ctx-summary` for every composed human-command adapter. Never
90
- * throws: the command is a convenience surface, and a host without the
91
- * commands service (or with an incompatible registry shape) simply runs
92
- * without it.
93
- */
94
- export function registerSummaryCommand(ctx: Context): void {
95
- ctx.inject(['commands'], (injected) => {
96
- const commands = (injected as { commands?: unknown }).commands as CommandsServiceLike | undefined
97
- if (commands === undefined || typeof commands.register !== 'function') return
98
- void (async () => {
99
- try {
100
- const definitionId = await loadCommandDefinitionId()
101
- await commands.register({
102
- name: SUMMARY_COMMAND_NAME,
103
- description: 'Turn-tail intent summary: temporarily disable/resume or inspect status',
104
- ...(definitionId === undefined ? {} : { definitionId: definitionId('dsh-context-compression-improved/ctx-summary') }),
105
- // The commands contract expects a promise-returning handler; the
106
- // body is fully synchronous by design (all host reads are sync).
107
- // eslint-disable-next-line @typescript-eslint/require-await
108
- handler: async (invocation) => {
109
- const rawInput = typeof invocation.rawInput === 'string' ? invocation.rawInput : ''
110
- const args = parseSummaryCommandArgs(rawInput)
111
- if (args === undefined) return { kind: 'error' as const, text: USAGE }
112
- const sessionId = sessionIdOf(invocation.agent)
113
- if (args === 'status') {
114
- if (sessionId === '') return { kind: 'error' as const, text: 'ctx-summary: no session is attached to this invocation' }
115
- return { kind: 'success' as const, text: formatSummaryStatus(sessionId) }
116
- }
117
- if (sessionId === '') return { kind: 'error' as const, text: 'ctx-summary: no session is attached to this invocation' }
118
- setSummaryOverride(sessionId, args)
119
- return {
120
- kind: 'success' as const,
121
- text: args === 'off'
122
- ? 'ctx-summary: turn-tail intent summary paused for this session (until process restart or `/ctx-summary on`)'
123
- : 'ctx-summary: turn-tail intent summary resumed for this session (numeric gates still apply)',
124
- }
125
- },
126
- })
127
- } catch {
128
- // Registry rejected the definition (shape drift, closed union): the
129
- // plugin keeps working, only the convenience command is absent.
130
- }
131
- })()
132
- })
133
- }
@@ -1,53 +0,0 @@
1
- /**
2
- * Turn-tail intent summary: pending-fold types and pure block builders
3
- * (task_2.4/2.5). The pass orchestration lives in the pruner (it owns the
4
- * channel, gate inputs, and landing machinery); this module owns the data
5
- * contract and the deterministic intent-block rendering. The model writes
6
- * ONLY the summary segment — block rendering here is fully deterministic.
7
- */
8
- import type { IntentRole } from './intent-input-mask.ts'
9
-
10
- /** One staged fold awaiting the next pressure round. */
11
- export interface PendingIntentFold {
12
- readonly createdAt: number
13
- readonly turn: number
14
- /** Inclusive seq span of the folded candidates. */
15
- readonly startSeq: number
16
- readonly endSeq: number
17
- /** LLM-written summary segment (fail-open parsed, char-capped). */
18
- readonly summary: string
19
- /** Verbatim error lines collected across the batch (never LLM-revoiced). */
20
- readonly errorLines: readonly string[]
21
- /** Per-candidate faces: read-mask single lines ride the block, keep-class lines prompt-only. */
22
- readonly records: ReadonlyArray<{ readonly seq: number, readonly role: IntentRole, readonly toolName: string, readonly line: string }>
23
- /** Characters consumed by the summary-writer call (credit accounting). */
24
- readonly summaryCallChars: number
25
- }
26
-
27
- /** Marker written into every folded block; its presence makes a seq unfoldable again (fold-once). */
28
- export const INTENT_FOLD_MARKER = '[Intent summary'
29
-
30
- /** Render the replacement text for one folded candidate. Pure. */
31
- export function renderIntentFoldBlock(pending: PendingIntentFold, seq: number): string {
32
- const start = pending.startSeq
33
- const end = pending.endSeq
34
- if (seq === start) {
35
- const readLines = pending.records
36
- .filter(record => record.role === 'read-mask')
37
- .map(record => record.line)
38
- const consulted = readLines.length > 0 ? `Consulted: ${readLines.join('; ')}` : ''
39
- const errorBlock = pending.errorLines.length > 0
40
- ? `\nError lines (verbatim):\n${pending.errorLines.join('\n')}`
41
- : ''
42
- return [
43
- `${INTENT_FOLD_MARKER} of folded tool results seq ${start}..${end}]`,
44
- pending.summary,
45
- consulted,
46
- errorBlock,
47
- '[Original content remains in the session log at the listed seq values.]',
48
- ].filter(part => part.length > 0).join('\n')
49
- }
50
- const record = pending.records.find(entry => entry.seq === seq)
51
- const face = record === undefined ? `${seq}` : record.role === 'read-mask' ? record.line : `${record.toolName} result folded into the batch intent summary`
52
- return `${INTENT_FOLD_MARKER} folded into the batch summary above (seq ${start}..${end})] ${face}`
53
- }
@@ -1,65 +0,0 @@
1
- /**
2
- * Turn-tail intent-summary growth gate (TokenPilot-inspired E2).
3
- *
4
- * Pure decision helper evaluated at the turn-boundary postflight: it decides
5
- * whether this turn may spend a summary-writer LLM call and stage a fold for
6
- * the next pressure round. The gate is deliberately conservative — every
7
- * unresolved input (unknown context window, non-finite counters) fails closed
8
- * toward "do not run", because a skipped fold is free while a wasted summary
9
- * call is not. Content safety is unaffected either way: fail-open semantics
10
- * live in the fold landing path, not here.
11
- */
12
-
13
- /** Floor: the live surface must exceed this fraction of the context window. */
14
- export const INTENT_GATE_FLOOR_FRACTION = 0.45
15
-
16
- /** Growth: the live surface must have grown by more than this since the last landed fold. */
17
- export const INTENT_GATE_GROWTH_TOKENS = 50_000
18
-
19
- /** Session-scoped user override set through `/ctx-summary off|on`. */
20
- export type SummaryOverride = 'on' | 'off' | undefined
21
-
22
- export interface IntentGateInput {
23
- /** Frozen `intentSummary.enabled` setting for the session. */
24
- enabled: boolean
25
- /** `/ctx-summary` override; `'off'` wins over everything, `'on'` never bypasses the numeric gates. */
26
- override: SummaryOverride
27
- /** Exact live-surface token estimate from the compaction view. */
28
- liveTokens: number
29
- /** Host context window in tokens; `undefined` fails the floor check. */
30
- contextWindow: number | undefined
31
- /** Live-surface tokens at the time the last fold landed (0 = never folded). */
32
- baselineTokens: number
33
- }
34
-
35
- export interface IntentGateSnapshot extends IntentGateInput {
36
- readonly decision: boolean
37
- readonly reason: 'disabled' | 'override-off' | 'no-window' | 'below-floor' | 'below-growth' | 'passed'
38
- }
39
-
40
- function isUsableNumber(value: number): boolean {
41
- return Number.isFinite(value) && value >= 0
42
- }
43
-
44
- /** Evaluate the growth gate. Boundary-exact: equality never triggers. */
45
- export function shouldRunIntentFold(input: IntentGateInput): boolean {
46
- return evaluateIntentGate(input).decision === true
47
- }
48
-
49
- /** Same evaluation with the reason attached, for audits and `/ctx-summary status`. */
50
- export function evaluateIntentGate(input: IntentGateInput): IntentGateSnapshot {
51
- const snapshot = (decision: boolean, reason: IntentGateSnapshot['reason']): IntentGateSnapshot => ({
52
- ...input,
53
- decision,
54
- reason,
55
- })
56
- if (!input.enabled) return snapshot(false, 'disabled')
57
- if (input.override === 'off') return snapshot(false, 'override-off')
58
- if (!isUsableNumber(input.liveTokens)) return snapshot(false, 'below-floor')
59
- if (input.contextWindow === undefined || !isUsableNumber(input.contextWindow)) return snapshot(false, 'no-window')
60
- if (!(input.liveTokens > input.contextWindow * INTENT_GATE_FLOOR_FRACTION)) return snapshot(false, 'below-floor')
61
- if (!isUsableNumber(input.baselineTokens)) return snapshot(false, 'below-growth')
62
- const growth = input.liveTokens - input.baselineTokens
63
- if (!(growth > INTENT_GATE_GROWTH_TOKENS)) return snapshot(false, 'below-growth')
64
- return snapshot(true, 'passed')
65
- }