dsh-context-compression-improved 0.12.0 → 0.13.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/.agents/plans/improve/checklist.md +32 -0
- package/.agents/plans/improve/findings.md +102 -0
- package/.agents/plans/improve/spec.md +53 -0
- package/.agents/plans/improve/tasks.md +70 -0
- package/.gitattributes +2 -0
- package/.githooks/pre-push +37 -0
- package/.github/workflows/ci.yml +47 -0
- package/CHANGELOG.de.md +580 -0
- package/CHANGELOG.es.md +588 -0
- package/CHANGELOG.fr.md +576 -0
- package/CHANGELOG.it.md +577 -0
- package/CHANGELOG.ja.md +261 -0
- package/CHANGELOG.ko.md +254 -0
- package/CHANGELOG.md +582 -0
- package/CHANGELOG.pt.md +167 -0
- package/CHANGELOG.ru.md +554 -0
- package/CHANGELOG.zh.md +247 -0
- package/CONTRIBUTING.md +22 -0
- package/README.de.md +96 -0
- package/README.es.md +96 -0
- package/README.fr.md +96 -0
- package/README.it.md +96 -0
- package/README.ja.md +102 -0
- package/README.ko.md +102 -0
- package/README.md +128 -22
- package/README.pt.md +96 -0
- package/README.ru.md +96 -0
- package/README.zh.md +114 -24
- package/SECURITY.md +18 -0
- package/THIRD_PARTY_NOTICES.md +7 -25
- package/assets/board.png +0 -0
- package/assets/context.png +0 -0
- package/assets/dshfind-card.svg +33 -0
- package/docs/assets/context-compression-selector-profiles.jpg +0 -0
- package/docs/assets/context-compression-selector-settings.png +0 -0
- package/docs/compat-0.1.5-report.md +77 -0
- package/docs/installation.de.md +104 -0
- package/docs/installation.es.md +104 -0
- package/docs/installation.fr.md +104 -0
- package/docs/installation.it.md +104 -0
- package/docs/installation.ja.md +78 -0
- package/docs/installation.ko.md +78 -0
- package/docs/installation.md +103 -0
- package/docs/installation.ru.md +104 -0
- package/docs/installation.zh.md +100 -0
- package/docs/repair-log.md +657 -0
- package/docs/shallow-teaching-preset-template.md +46 -0
- package/eslint.config.js +30 -0
- package/package.json +112 -127
- package/packages/selector/LICENSE +21 -0
- package/packages/selector/README.md +26 -0
- package/packages/selector/README.zh.md +24 -0
- package/packages/selector/THIRD_PARTY_NOTICES.md +32 -0
- package/packages/selector/docs/history-tool-call-working-set-spec.md +112 -0
- package/packages/selector/docs/native-tool-result-selector-spec.md +34 -0
- package/packages/selector/docs/subagent-cache-reuse-spec.md +46 -0
- package/{dsh.plugin.json → packages/selector/dsh.plugin.json} +1 -1
- package/{lib → packages/selector/lib}/client.js +18 -10
- package/packages/selector/lib/style.css +350 -0
- package/packages/selector/package.json +180 -0
- package/packages/selector/screenshots.json +3 -0
- package/packages/selector/src/client/CompressionProfileControls.tsx +352 -0
- package/packages/selector/src/client/CompressionProfileSelector.module.css +199 -0
- package/packages/selector/src/client/CompressionProfileSelector.tsx +89 -0
- package/packages/selector/src/client/CustomPolicyEditor.tsx +216 -0
- package/packages/selector/src/client/EstimatorControls.tsx +277 -0
- package/packages/selector/src/client/bridge-scope.ts +125 -0
- package/packages/selector/src/client/decode.ts +68 -0
- package/packages/selector/src/client/fab-pos.ts +71 -0
- package/packages/selector/src/client/guide-steps.ts +50 -0
- package/packages/selector/src/client/guide.tsx +368 -0
- package/packages/selector/src/client/index.ts +456 -0
- package/packages/selector/src/client/locales/de.ts +167 -0
- package/packages/selector/src/client/locales/es.ts +167 -0
- package/packages/selector/src/client/locales/fr.ts +167 -0
- package/packages/selector/src/client/locales/it.ts +167 -0
- package/packages/selector/src/client/locales/ja.ts +167 -0
- package/packages/selector/src/client/locales/ko.ts +167 -0
- package/packages/selector/src/client/locales/pt.ts +167 -0
- package/packages/selector/src/client/locales/ru.ts +167 -0
- package/packages/selector/src/client/locales.ts +334 -0
- package/packages/selector/src/client/monitor-fab.ts +445 -0
- package/packages/selector/src/client/preset-options.ts +88 -0
- package/packages/selector/src/client/savings-card.tsx +269 -0
- package/packages/selector/src/client/scope-face.ts +24 -0
- package/packages/selector/src/client/settings-section.tsx +171 -0
- package/packages/selector/src/compat/host-generation.ts +96 -0
- package/packages/selector/src/compat/llm-messages.ts +50 -0
- package/packages/selector/src/compat/settings-lease.ts +108 -0
- package/packages/selector/src/compat/tool-result.ts +91 -0
- package/packages/selector/src/css-modules.d.ts +6 -0
- package/packages/selector/src/deepseek-v4-tokenizer.ts +205 -0
- package/packages/selector/src/estimator-catalog.ts +104 -0
- package/packages/selector/src/index.ts +909 -0
- package/packages/selector/src/invariant.ts +113 -0
- package/packages/selector/src/preset-overlay.ts +749 -0
- package/packages/selector/src/profiles.ts +554 -0
- package/packages/selector/src/pruner/content.ts +199 -0
- package/packages/selector/src/pruner/session.ts +97 -0
- package/packages/selector/src/pruner/state.ts +61 -0
- package/packages/selector/src/pruner/tuning.ts +23 -0
- package/packages/selector/src/pruner/types.ts +78 -0
- package/packages/selector/src/pruner.ts +3222 -0
- package/packages/selector/src/runtime/adaptive-cost.ts +205 -0
- package/packages/selector/src/runtime/audit.ts +321 -0
- package/packages/selector/src/runtime/config.ts +887 -0
- package/packages/selector/src/runtime/custom-policy.ts +300 -0
- package/packages/selector/src/runtime/deepseek-official-pricing.ts +298 -0
- package/packages/selector/src/runtime/deepseek-v4-vision-tokens.ts +254 -0
- package/packages/selector/src/runtime/display-prefs.ts +98 -0
- package/packages/selector/src/runtime/fold-router.ts +143 -0
- package/packages/selector/src/runtime/measurement.ts +444 -0
- package/packages/selector/src/runtime/monitor.ts +341 -0
- package/packages/selector/src/runtime/panel-command.ts +213 -0
- package/packages/selector/src/runtime/reducers.ts +1755 -0
- package/packages/selector/src/runtime/retrieve.ts +505 -0
- package/packages/selector/src/runtime/savings-integral.ts +117 -0
- package/packages/selector/src/runtime/savings-projection.ts +229 -0
- package/packages/selector/src/runtime/savings-verify.ts +446 -0
- package/packages/selector/src/runtime/savings.ts +526 -0
- package/packages/selector/src/runtime/sediment-card.ts +126 -0
- package/packages/selector/src/runtime/sediment-clock.ts +87 -0
- package/packages/selector/src/runtime/sediment-guard.ts +136 -0
- package/packages/selector/src/runtime/sediment-publish.ts +144 -0
- package/packages/selector/src/runtime/sediment-span.ts +170 -0
- package/packages/selector/src/runtime/sediment.ts +209 -0
- package/packages/selector/src/runtime/session-events.ts +30 -0
- package/packages/selector/src/runtime/session-file-decode.ts +523 -0
- package/packages/selector/src/runtime/shallow-tools.ts +342 -0
- package/packages/selector/src/runtime/stats-backfill.ts +541 -0
- package/packages/selector/src/runtime/stats-db.ts +492 -0
- package/packages/selector/src/runtime/stats-schema.ts +123 -0
- package/packages/selector/src/runtime/stats-sync.ts +307 -0
- package/packages/selector/src/runtime/summary-command.ts +127 -0
- package/packages/selector/src/runtime/tail-trim.ts +177 -0
- package/packages/selector/src/runtime/token-count.ts +72 -0
- package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +233 -0
- package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +204 -0
- package/packages/selector/src/runtime/tokenpilot/advisor.ts +419 -0
- package/packages/selector/src/runtime/tokenpilot/benefit.ts +200 -0
- package/packages/selector/src/runtime/tokenpilot/dedup.ts +82 -0
- package/packages/selector/src/runtime/tokenpilot/estimator.ts +151 -0
- package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +53 -0
- package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +65 -0
- package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +125 -0
- package/packages/selector/src/runtime/tokenpilot/intent-range.ts +37 -0
- package/packages/selector/src/runtime/tokenpilot/locator.ts +129 -0
- package/packages/selector/src/runtime/tokenpilot/read-state.ts +98 -0
- package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +303 -0
- package/packages/selector/src/runtime/tool-names.ts +42 -0
- package/packages/selector/src/runtime/toolclass.ts +103 -0
- package/packages/selector/src/runtime/triage/masks.ts +128 -0
- package/packages/selector/src/runtime/triage/shallow.ts +132 -0
- package/packages/selector/src/runtime/triage/signals.ts +167 -0
- package/packages/selector/src/runtime/triage/types.ts +125 -0
- package/packages/selector/src/runtime/types.ts +396 -0
- package/packages/selector/src/runtime/value.ts +48 -0
- package/packages/selector/src/settings-bridge.ts +175 -0
- package/packages/selector/src/tui-command.ts +99 -0
- package/packages/selector/tests/advisor-report.host.spec.ts +223 -0
- package/packages/selector/tests/auto-compact.client.spec.tsx +214 -0
- package/packages/selector/tests/built/client-artifact.spec.ts +56 -0
- package/packages/selector/tests/cache-prefix-audit.spec.ts +123 -0
- package/packages/selector/tests/code-skeleton.client.spec.ts +98 -0
- package/packages/selector/tests/compat/compat-narrow-waist.spec.ts +150 -0
- package/packages/selector/tests/custom-contract.client.spec.ts +226 -0
- package/packages/selector/tests/estimator-catalog.spec.ts +70 -0
- package/packages/selector/tests/estimator-channel.client.spec.tsx +253 -0
- package/packages/selector/tests/estimator-route-registration.host.spec.ts +202 -0
- package/packages/selector/tests/fab-pos.client.spec.ts +47 -0
- package/packages/selector/tests/fixtures/sediment-pool/52adc205-cloud-5.orig.txt +231 -0
- package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-25.orig.txt +236 -0
- package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-38.orig.txt +220 -0
- package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-42.orig.txt +140 -0
- package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-53.orig.txt +117 -0
- package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-local-10.orig.txt +67 -0
- package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-45.orig.txt +119 -0
- package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-49.orig.txt +119 -0
- package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-63.orig.txt +131 -0
- package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-75.orig.txt +196 -0
- package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-76.orig.txt +71 -0
- package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-85.orig.txt +126 -0
- package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-86.orig.txt +86 -0
- package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-87.orig.txt +50 -0
- package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-96.orig.txt +102 -0
- package/packages/selector/tests/helpers/legacy-namespace.ts +35 -0
- package/packages/selector/tests/helpers/legacy-settings/index.ts +15 -0
- package/packages/selector/tests/helpers/legacy-settings/legacy/provider.d.ts +41 -0
- package/packages/selector/tests/helpers/legacy-settings/legacy/provider.js +647 -0
- package/packages/selector/tests/helpers/legacy-settings/legacy/redact.js +78 -0
- package/packages/selector/tests/helpers/legacy-settings/legacy/util-values.js +234 -0
- package/packages/selector/tests/host-preset-overlay.host.spec.ts +204 -0
- package/packages/selector/tests/monitor-fab.client.spec.ts +240 -0
- package/packages/selector/tests/preset-options-write.client.spec.ts +192 -0
- package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +200 -0
- package/packages/selector/tests/preset-overlay.host.spec.ts +246 -0
- package/packages/selector/tests/profiles.client.spec.tsx +436 -0
- package/packages/selector/tests/ptc-custom-write.client.spec.ts +86 -0
- package/packages/selector/tests/public/package-contract.client.spec.ts +91 -0
- package/packages/selector/tests/runtime/adaptive-cost.spec.ts +167 -0
- package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +230 -0
- package/packages/selector/tests/runtime/advisor-invariant.spec.ts +272 -0
- package/packages/selector/tests/runtime/advisor.spec.ts +226 -0
- package/packages/selector/tests/runtime/audit.spec.ts +275 -0
- package/packages/selector/tests/runtime/auto-compact-config.spec.ts +523 -0
- package/packages/selector/tests/runtime/behavior-lock-profiles.spec.ts +128 -0
- package/packages/selector/tests/runtime/char-basis.spec.ts +30 -0
- package/packages/selector/tests/runtime/code-skeleton.spec.ts +152 -0
- package/packages/selector/tests/runtime/deepseek-official-pricing.spec.ts +186 -0
- package/packages/selector/tests/runtime/deepseek-v4-tokenizer.spec.ts +122 -0
- package/packages/selector/tests/runtime/deepseek-v4-vision-tokens.spec.ts +122 -0
- package/packages/selector/tests/runtime/deprecated-preset-options.spec.ts +96 -0
- package/packages/selector/tests/runtime/fallback-diversity.spec.ts +75 -0
- package/packages/selector/tests/runtime/fixtures/profile-baseline.json +273 -0
- package/packages/selector/tests/runtime/fixtures/session-v4-dump.jsonl +46 -0
- package/packages/selector/tests/runtime/fixtures/tokenizer-golden.json +106 -0
- package/packages/selector/tests/runtime/fixtures/vision-golden.json +459 -0
- package/packages/selector/tests/runtime/fold-router.spec.ts +140 -0
- package/packages/selector/tests/runtime/frequency-longstrings.spec.ts +74 -0
- package/packages/selector/tests/runtime/fresh-gate.spec.ts +43 -0
- package/packages/selector/tests/runtime/html-reducer.spec.ts +212 -0
- package/packages/selector/tests/runtime/intent-gate.spec.ts +62 -0
- package/packages/selector/tests/runtime/intent-summary.spec.ts +156 -0
- package/packages/selector/tests/runtime/jsonl-reducer.spec.ts +79 -0
- package/packages/selector/tests/runtime/line-mapping.spec.ts +153 -0
- package/packages/selector/tests/runtime/monitor.spec.ts +354 -0
- package/packages/selector/tests/runtime/panel-command.spec.ts +101 -0
- package/packages/selector/tests/runtime/prose-reducers.spec.ts +133 -0
- package/packages/selector/tests/runtime/ptc-profile.spec.ts +133 -0
- package/packages/selector/tests/runtime/public/public-runtime.spec.ts +2795 -0
- package/packages/selector/tests/runtime/read-input-cap.spec.ts +33 -0
- package/packages/selector/tests/runtime/savings-accounting.spec.ts +291 -0
- package/packages/selector/tests/runtime/savings-integral.spec.ts +169 -0
- package/packages/selector/tests/runtime/savings-projection.spec.ts +89 -0
- package/packages/selector/tests/runtime/savings-verify.spec.ts +226 -0
- package/packages/selector/tests/runtime/savings.spec.ts +139 -0
- package/packages/selector/tests/runtime/search-reducer.spec.ts +110 -0
- package/packages/selector/tests/runtime/sediment-card.spec.ts +111 -0
- package/packages/selector/tests/runtime/sediment-config.spec.ts +56 -0
- package/packages/selector/tests/runtime/sediment-guard.spec.ts +71 -0
- package/packages/selector/tests/runtime/sediment-masks.spec.ts +95 -0
- package/packages/selector/tests/runtime/sediment-orchestrator.spec.ts +166 -0
- package/packages/selector/tests/runtime/sediment-pool-share.spec.ts +65 -0
- package/packages/selector/tests/runtime/sediment-publish.spec.ts +142 -0
- package/packages/selector/tests/runtime/sediment-real-shapes.spec.ts +158 -0
- package/packages/selector/tests/runtime/sediment-settings.spec.ts +73 -0
- package/packages/selector/tests/runtime/sediment-signals.spec.ts +124 -0
- package/packages/selector/tests/runtime/sediment-span.spec.ts +92 -0
- package/packages/selector/tests/runtime/session-events.spec.ts +27 -0
- package/packages/selector/tests/runtime/session-file-decode.spec.ts +281 -0
- package/packages/selector/tests/runtime/settings-unwrap.spec.ts +58 -0
- package/packages/selector/tests/runtime/shallow-primitives.spec.ts +135 -0
- package/packages/selector/tests/runtime/sidechannel.spec.ts +241 -0
- package/packages/selector/tests/runtime/source-kind-audit.spec.ts +79 -0
- package/packages/selector/tests/runtime/stats-backfill-scheduler.spec.ts +167 -0
- package/packages/selector/tests/runtime/stats-backfill.spec.ts +350 -0
- package/packages/selector/tests/runtime/stats-db.spec.ts +361 -0
- package/packages/selector/tests/runtime/stats-privacy.spec.ts +55 -0
- package/packages/selector/tests/runtime/stats-sync.spec.ts +278 -0
- package/packages/selector/tests/runtime/summary-command.spec.ts +154 -0
- package/packages/selector/tests/runtime/toc-and-bundled.spec.ts +159 -0
- package/packages/selector/tests/runtime/tokenizer-golden.spec.ts +53 -0
- package/packages/selector/tests/runtime/tokenpilot/benefit.spec.ts +217 -0
- package/packages/selector/tests/runtime/tokenpilot/dedup.spec.ts +52 -0
- package/packages/selector/tests/runtime/tokenpilot/estimator.spec.ts +79 -0
- package/packages/selector/tests/runtime/tokenpilot/locator.spec.ts +76 -0
- package/packages/selector/tests/runtime/tokenpilot/profile-baseline.spec.ts +121 -0
- package/packages/selector/tests/runtime/tokenpilot/read-state.spec.ts +82 -0
- package/packages/selector/tests/runtime/toolclass.spec.ts +156 -0
- package/packages/selector/tests/runtime/value.spec.ts +23 -0
- package/packages/selector/tests/savings-sessions.client.spec.tsx +140 -0
- package/packages/selector/tests/settings-seat.client.spec.ts +215 -0
- package/packages/selector/tests/standing-generation.host.spec.ts +729 -0
- package/packages/selector/tests/subagent-cache-reuse.host.spec.ts +269 -0
- package/packages/selector/tests/support/cache-prefix-audit.ts +105 -0
- package/packages/selector/tests/support/mock-adapter.ts +37 -0
- package/packages/selector/tests/support/ui-primitives.tsx +34 -0
- package/packages/selector/tsconfig.json +11 -0
- package/packages/selector/tsdown.client.config.ts +102 -0
- package/packages/selector/tsdown.config.ts +20 -0
- package/pnpm-workspace.yaml +76 -0
- package/screenshots.json +6 -3
- package/scripts/capture-profile-baseline.mjs +42 -0
- package/scripts/cell-browser-e2e.mjs +354 -0
- package/scripts/generate-tokenizer-fixtures.py +81 -0
- package/scripts/generate-vision-fixtures.py +208 -0
- package/scripts/hosts.d.mts +3 -0
- package/scripts/hosts.mjs +81 -0
- package/scripts/packed-components-smoke.mjs +763 -0
- package/scripts/packed-install-e2e.mjs +1346 -0
- package/scripts/sediment-latency-report.mjs +63 -0
- package/scripts/sync-hosts.mjs +176 -0
- package/scripts/toolclass-corpus-replay.mjs +281 -0
- package/scripts/verify-release.mjs +342 -0
- package/tests/TEST_INVENTORY.md +41 -0
- package/tsconfig.base.json +18 -0
- package/tsconfig.json +7 -0
- package/tsconfig.tests.json +15 -0
- package/vitest.built.config.ts +9 -0
- package/vitest.config.ts +54 -0
- /package/{assets → packages/selector/assets}/deepseek-v4/LICENSE.DeepSeek-V4-Pro.txt +0 -0
- /package/{assets → packages/selector/assets}/deepseek-v4/manifest.json +0 -0
- /package/{assets → packages/selector/assets}/deepseek-v4/tokenizer.json +0 -0
- /package/{assets → packages/selector/assets}/deepseek-v4/tokenizer_config.json +0 -0
- /package/{assets → packages/selector/assets}/deepseek-v4-vision-exp/LICENSE.DeepSeek-V4-Flash-Vision-Exp.txt +0 -0
- /package/{assets → packages/selector/assets}/deepseek-v4-vision-exp/manifest.json +0 -0
- /package/{assets → packages/selector/assets}/deepseek-v4-vision-exp/tokenizer.json +0 -0
- /package/{assets → packages/selector/assets}/deepseek-v4-vision-exp/tokenizer_config.json +0 -0
- /package/{cordis.patch.yml → packages/selector/cordis.patch.yml} +0 -0
- /package/{lib → packages/selector/lib}/client.d.ts +0 -0
- /package/{lib → packages/selector/lib}/index.d.ts +0 -0
- /package/{lib → packages/selector/lib}/index.js +0 -0
- /package/{lib → packages/selector/lib}/invariant.d.ts +0 -0
- /package/{lib → packages/selector/lib}/invariant.js +0 -0
- /package/{lib → packages/selector/lib}/profiles.d.ts +0 -0
- /package/{lib → packages/selector/lib}/pruner.d.ts +0 -0
- /package/{lib → packages/selector/lib}/pruner.js +0 -0
- /package/{lib → packages/selector/lib}/savings-integral.js +0 -0
- /package/{lib → packages/selector/lib}/tail-trim.js +0 -0
- /package/{lib → packages/selector/lib}/tool-result.js +0 -0
- /package/{locale → packages/selector/locale}/de.json +0 -0
- /package/{locale → packages/selector/locale}/en.json +0 -0
- /package/{locale → packages/selector/locale}/es.json +0 -0
- /package/{locale → packages/selector/locale}/fr.json +0 -0
- /package/{locale → packages/selector/locale}/it.json +0 -0
- /package/{locale → packages/selector/locale}/ja.json +0 -0
- /package/{locale → packages/selector/locale}/ko.json +0 -0
- /package/{locale → packages/selector/locale}/pt.json +0 -0
- /package/{locale → packages/selector/locale}/ru.json +0 -0
- /package/{locale → packages/selector/locale}/zh.json +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One-off baseline capture: freeze the resolvePolicy output for the pre-existing
|
|
3
|
+
* profiles (before 'tokenpilot-inspired' is added) into a JSON fixture used by
|
|
4
|
+
* tests/tokenpilot/profile-baseline.spec.ts as the backward-compat golden.
|
|
5
|
+
*
|
|
6
|
+
* Usage: node scripts/capture-profile-baseline.mjs [baseline-file]
|
|
7
|
+
*/
|
|
8
|
+
import { writeFileSync } from 'node:fs'
|
|
9
|
+
import { createRequire } from 'node:module'
|
|
10
|
+
|
|
11
|
+
const require = createRequire(import.meta.url)
|
|
12
|
+
const runtime = require('../packages/runtime/lib/index.js')
|
|
13
|
+
|
|
14
|
+
const OLD_PROFILES = ['off', 'native', 'balanced', 'cache-strict', 'savings', 'adaptive', 'custom']
|
|
15
|
+
const baseConfig = runtime.resolveConfig({})
|
|
16
|
+
const OPTION_CASES = [
|
|
17
|
+
{ label: 'defaults', options: {} },
|
|
18
|
+
{ label: 'linkage', options: { contextWindowTokens: 128_000, autoCompactThresholdPercent: 80 } },
|
|
19
|
+
]
|
|
20
|
+
const CUSTOM_DOCS = [
|
|
21
|
+
{ label: 'default-custom', custom: undefined },
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
const snapshot = { capturedAt: 'pre-tokenpilot-inspired', profiles: {} }
|
|
25
|
+
for (const profile of OLD_PROFILES) {
|
|
26
|
+
snapshot.profiles[profile] = {}
|
|
27
|
+
for (const optionCase of OPTION_CASES) {
|
|
28
|
+
for (const customCase of CUSTOM_DOCS) {
|
|
29
|
+
const key = `${optionCase.label}${customCase.label === 'default-custom' ? '' : `/${customCase.label}`}`
|
|
30
|
+
snapshot.profiles[profile][key] = runtime.resolvePolicy(
|
|
31
|
+
baseConfig,
|
|
32
|
+
profile,
|
|
33
|
+
customCase.custom,
|
|
34
|
+
optionCase.options,
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const out = process.argv[2] ?? 'packages/runtime/tests/fixtures/profile-baseline.json'
|
|
41
|
+
writeFileSync(out, `${JSON.stringify(snapshot, null, 2)}\n`)
|
|
42
|
+
console.log(`baseline written: ${out}`)
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
// cell-browser-e2e.mjs —— 六线宿主格子 × 浏览器面 e2e(发版前后均可跑)。
|
|
2
|
+
//
|
|
3
|
+
// 与 packed-install-e2e.mjs 的分工:那条门在官方 dsh-v0.2.0-rc.1 克隆上验证
|
|
4
|
+
// 安装生命周期与 boot 探针(单线、无浏览器交互);本脚本补的是**多线浏览器面**:
|
|
5
|
+
// 按 scripts/hosts.mjs 的六线抽样各备一个格子,从 npm 安装宿主与插件,真启动
|
|
6
|
+
// web profile,用 CDP 驱动真实浏览器——设置节/详情卡渲染、Profile 点击写穿、
|
|
7
|
+
// 桥读回。0.1.0/0.1.1/0.1.2 三线只有这条门有浏览器面证据。
|
|
8
|
+
//
|
|
9
|
+
// 用法:
|
|
10
|
+
// pnpm test:browser:e2e # 六格全跑(首次会逐格 pnpm 装宿主)
|
|
11
|
+
// pnpm test:browser:e2e 0.1.5-rc.3 # 只跑一格(重跑/排障)
|
|
12
|
+
// 环境变量:
|
|
13
|
+
// CELL_E2E_DIR 格子根目录(默认 <repo>/.cell-e2e,已 gitignore;删掉即全量重备)
|
|
14
|
+
// PLUGIN_SPEC 插件安装 spec(默认 latest=验证 npm 发布物;可指 file:tgz 或本地目录)
|
|
15
|
+
// CHROME_PATH Chrome 可执行文件(默认查标准安装位置)
|
|
16
|
+
// 前提:pnpm 在 PATH;Chrome/Chromium 可用;registry 可达(宿主 15 rc 在 npm 上齐全)。
|
|
17
|
+
//
|
|
18
|
+
// 钉版矩阵来源(实测在案,见 .agents/plans/cci-compat-legacy-15rc/tasks.md):
|
|
19
|
+
// - 0.1.1 线宿主崩于「patch 层监视需要 Cordis HMR 服务」→ sandbox 依赖
|
|
20
|
+
// @deepseek-ai/cordis-plugin-hmr ^1.0.16 + profile 补丁行 insert hmr(root:[]);
|
|
21
|
+
// - 0.1.2 线同病,但 registerConfig 自 1.0.17 起才有 → hmr 钉 1.0.17;
|
|
22
|
+
// - 其余线最小依赖 @deepseek-ai/dsh@<rc> 即可(宿主自带运行时依赖)。
|
|
23
|
+
import fs from 'node:fs'
|
|
24
|
+
import path from 'node:path'
|
|
25
|
+
import { fileURLToPath } from 'node:url'
|
|
26
|
+
import { spawn } from 'node:child_process'
|
|
27
|
+
|
|
28
|
+
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
|
29
|
+
const sleep = (ms) => new Promise(r => setTimeout(r, ms))
|
|
30
|
+
|
|
31
|
+
const CELL_ROOT = process.env.CELL_E2E_DIR ?? path.join(repoRoot, '.cell-e2e')
|
|
32
|
+
// 默认=仓库当前版本:验证「这个版本」在六线上的表现,且精确 spec 免疫
|
|
33
|
+
// registry 的 dist-tag metadata 缓存(latest 曾解析到陈旧 0.8.0)。
|
|
34
|
+
const PLUGIN_SPEC = process.env.PLUGIN_SPEC
|
|
35
|
+
?? JSON.parse(fs.readFileSync(path.join(repoRoot, 'packages/selector/package.json'), 'utf8')).version
|
|
36
|
+
const NPMRC = 'registry=https://registry.npmjs.org\n'
|
|
37
|
+
// pnpm ≥12 对带构建脚本的依赖默认拒绝并把安装变成非零退出——宿主运行时需要
|
|
38
|
+
// node-pty/koffi/protobufjs/dsh-subprocess-local 的原生/后装产物。pnpm 12.5 的
|
|
39
|
+
// 权威开关是 allowBuilds 布尔 map(onlyBuiltDependencies 清单会被无视)。
|
|
40
|
+
const ALLOW_BUILDS = [
|
|
41
|
+
'allowBuilds:',
|
|
42
|
+
' "@deepseek-ai/dsh-subprocess-local": true',
|
|
43
|
+
' "@google/genai": true',
|
|
44
|
+
' koffi: true',
|
|
45
|
+
' node-pty: true',
|
|
46
|
+
' protobufjs: true',
|
|
47
|
+
'',
|
|
48
|
+
].join('\n')
|
|
49
|
+
// sandbox:默认 autoInstallPeers(true)——老宿主的 peer 闭包(dsh-timeout 等
|
|
50
|
+
// 只声明为 peer 的包)靠它补全,缺了 web client 直接不激活。
|
|
51
|
+
const SANDBOX_WORKSPACE_YAML = 'packages:\n - .\n\nnodeLinker: hoisted\n' + ALLOW_BUILDS
|
|
52
|
+
// profile web:只装插件本体,peers 不自动补(宿主运行时靠 sandbox 闭包兜底)。
|
|
53
|
+
const WEB_WORKSPACE_YAML = 'packages:\n - .\n\nnodeLinker: hoisted\nautoInstallPeers: false\n' + ALLOW_BUILDS
|
|
54
|
+
|
|
55
|
+
// 六线抽样 = 计划 Gate 矩阵的口径(15rc 全测已被用户裁决为抽样即可)。
|
|
56
|
+
// cordis 家族钉版 = 实证格子矩阵:npm 上的 @deepseek-ai/dsh 会把老线拖到新
|
|
57
|
+
// cordis(0.1.0-rc.2 + cordis 4.0.4/loader 1.0.5 → web client 不激活),
|
|
58
|
+
// 各线必须钉它实证能跑的组合。hmr = 0.1.1/0.1.2 宿主的 patch 层监视必需
|
|
59
|
+
// (registerConfig 自 1.0.17 起,0.1.1 线钉 ^1.0.16),并配 profile 补丁行。
|
|
60
|
+
const HOSTS = [
|
|
61
|
+
{
|
|
62
|
+
rc: '0.1.0-rc.2', generation: 'legacy',
|
|
63
|
+
pins: { '@deepseek-ai/cordis': '4.0.2', '@deepseek-ai/cordis-plugin-group': '1.0.2', '@deepseek-ai/cordis-plugin-hmr': '1.0.17', '@deepseek-ai/cordis-plugin-include': '1.0.7', '@deepseek-ai/cordis-plugin-loader': '1.0.3', '@deepseek-ai/cordis-plugin-timer': '1.1.4' },
|
|
64
|
+
},
|
|
65
|
+
// hmr 必须精确钉:^1.0.16 会浮动到 1.0.19+,而 registerConfig 的签名在
|
|
66
|
+
// 1.0.19 与两条老线都不兼容(host 在 web url 打印后崩于 registerConfig)。
|
|
67
|
+
{ rc: '0.1.1-rc.2', generation: 'legacy', pins: { '@deepseek-ai/cordis-plugin-hmr': '1.0.16' }, patchHmr: true },
|
|
68
|
+
{ rc: '0.1.2-rc.1', generation: 'legacy', pins: { '@deepseek-ai/cordis-plugin-hmr': '1.0.17' }, patchHmr: true },
|
|
69
|
+
{
|
|
70
|
+
rc: '0.1.5-rc.3', generation: 'legacy',
|
|
71
|
+
pins: { '@deepseek-ai/cordis': '4.0.2', '@deepseek-ai/cordis-plugin-group': '1.0.2', '@deepseek-ai/cordis-plugin-hmr': '1.0.17', '@deepseek-ai/cordis-plugin-include': '1.0.7', '@deepseek-ai/cordis-plugin-loader': '1.0.3', '@deepseek-ai/cordis-plugin-timer': '1.1.4' },
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
rc: '0.1.7-rc.1', generation: 'modern',
|
|
75
|
+
pins: { '@deepseek-ai/cordis': '4.0.4', '@deepseek-ai/cordis-plugin-group': '1.0.4', '@deepseek-ai/cordis-plugin-hmr': '1.0.19', '@deepseek-ai/cordis-plugin-include': '1.0.9', '@deepseek-ai/cordis-plugin-loader': '1.0.5', '@deepseek-ai/cordis-plugin-timer': '1.1.6' },
|
|
76
|
+
},
|
|
77
|
+
{ rc: '0.2.0-rc.2', generation: 'modern', pins: {} },
|
|
78
|
+
]
|
|
79
|
+
const ONLY = process.argv[2]
|
|
80
|
+
const HOSTS_TO_RUN = ONLY ? HOSTS.filter(h => h.rc === ONLY) : HOSTS
|
|
81
|
+
if (ONLY && HOSTS_TO_RUN.length === 0) {
|
|
82
|
+
console.error(`unknown host rc "${ONLY}"; one of: ${HOSTS.map(h => h.rc).join(', ')}`)
|
|
83
|
+
process.exit(2)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const findChrome = () => {
|
|
87
|
+
if (process.env.CHROME_PATH) return process.env.CHROME_PATH
|
|
88
|
+
const candidates = process.platform === 'win32' ? [
|
|
89
|
+
'C:/Program Files/Google/Chrome/Application/chrome.exe',
|
|
90
|
+
'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe',
|
|
91
|
+
] : [
|
|
92
|
+
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
|
|
93
|
+
'/usr/bin/google-chrome',
|
|
94
|
+
'/usr/bin/chromium-browser',
|
|
95
|
+
]
|
|
96
|
+
return candidates.find(p => fs.existsSync(p))
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const run = (command, args, options = {}) => new Promise((resolve, reject) => {
|
|
100
|
+
// Node ≥18.20 拒绝无 shell 直接 spawn .cmd(EINVAL)。
|
|
101
|
+
const child = spawn(command, args, { shell: process.platform === 'win32', stdio: ['ignore', 'pipe', 'pipe'], ...options })
|
|
102
|
+
let out = ''
|
|
103
|
+
child.stdout.on('data', c => { out += c })
|
|
104
|
+
child.stderr.on('data', c => { out += c })
|
|
105
|
+
child.once('exit', code => code === 0 ? resolve(out) : reject(new Error(`${command} exited ${code}\n${out.slice(-2000)}`)))
|
|
106
|
+
child.once('error', reject)
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
const PROFILE_PATCH_BASE = `# cell-browser-e2e provisioned profile patch
|
|
110
|
+
`
|
|
111
|
+
|
|
112
|
+
async function provisionCell({ rc, pins, patchHmr }) {
|
|
113
|
+
const sandbox = path.join(CELL_ROOT, rc)
|
|
114
|
+
const web = path.join(sandbox, 'home/profiles/web')
|
|
115
|
+
const fresh = !fs.existsSync(path.join(sandbox, 'node_modules/@deepseek-ai/dsh/package.json'))
|
|
116
|
+
if (fresh) {
|
|
117
|
+
fs.rmSync(sandbox, { recursive: true, force: true })
|
|
118
|
+
fs.mkdirSync(web, { recursive: true })
|
|
119
|
+
const sandboxPkg = {
|
|
120
|
+
name: 'cell-browser-e2e-host',
|
|
121
|
+
private: true,
|
|
122
|
+
dependencies: { '@deepseek-ai/dsh': rc, ...pins },
|
|
123
|
+
}
|
|
124
|
+
await fs.promises.writeFile(path.join(sandbox, 'package.json'), JSON.stringify(sandboxPkg, null, 2) + '\n')
|
|
125
|
+
// 自带 workspace+npmrc:切断对仓库 workspace 的目录继承(否则 pnpm 把安装
|
|
126
|
+
// 静默吞进仓库根),并钉死 registry(命令行 --registry 经 shell 传递不可靠)。
|
|
127
|
+
await fs.promises.writeFile(path.join(sandbox, 'pnpm-workspace.yaml'), SANDBOX_WORKSPACE_YAML)
|
|
128
|
+
await fs.promises.writeFile(path.join(sandbox, '.npmrc'), NPMRC)
|
|
129
|
+
await run('pnpm.cmd', ['install', '--no-frozen-lockfile'], { cwd: sandbox })
|
|
130
|
+
await fs.promises.writeFile(path.join(web, 'pnpm-workspace.yaml'), WEB_WORKSPACE_YAML)
|
|
131
|
+
await fs.promises.writeFile(path.join(web, '.npmrc'), NPMRC)
|
|
132
|
+
const profilePkg = {
|
|
133
|
+
name: 'dsh-profile-web',
|
|
134
|
+
private: true,
|
|
135
|
+
dependencies: { 'dsh-context-compression-improved': PLUGIN_SPEC },
|
|
136
|
+
dsh: { profile: { bundles: ['@deepseek-ai/dsh-base', '@deepseek-ai/dsh-web-app', 'dsh-context-compression-improved'] } },
|
|
137
|
+
}
|
|
138
|
+
await fs.promises.writeFile(path.join(web, 'package.json'), JSON.stringify(profilePkg, null, 2) + '\n')
|
|
139
|
+
const patch = patchHmr
|
|
140
|
+
? `${PROFILE_PATCH_BASE}- insert:\n - name: '@deepseek-ai/cordis-plugin-hmr'\n config:\n root: []\n`
|
|
141
|
+
: `${PROFILE_PATCH_BASE}[]\n`
|
|
142
|
+
await fs.promises.writeFile(path.join(web, 'cordis.patch.yml'), patch)
|
|
143
|
+
await run('pnpm.cmd', ['install', '--no-frozen-lockfile'], { cwd: web })
|
|
144
|
+
} else {
|
|
145
|
+
// 复用格子:只把插件刷到目标 spec(幂等)。
|
|
146
|
+
const web = path.join(sandbox, 'home/profiles/web')
|
|
147
|
+
const pkgPath = path.join(web, 'package.json')
|
|
148
|
+
const pkg = JSON.parse(await fs.promises.readFile(pkgPath, 'utf8'))
|
|
149
|
+
if (pkg.dependencies['dsh-context-compression-improved'] !== PLUGIN_SPEC) {
|
|
150
|
+
pkg.dependencies['dsh-context-compression-improved'] = PLUGIN_SPEC
|
|
151
|
+
await fs.promises.writeFile(pkgPath, JSON.stringify(pkg, null, 2) + '\n')
|
|
152
|
+
await run('pnpm.cmd', ['install', '--no-frozen-lockfile'], { cwd: web })
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const installed = JSON.parse(await fs.promises.readFile(path.join(web, 'node_modules/dsh-context-compression-improved/package.json'), 'utf8')).version
|
|
156
|
+
return { sandbox, installed }
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async function bootHost(sandbox) {
|
|
160
|
+
const host = spawn(process.execPath, ['node_modules/@deepseek-ai/dsh/lib/bin.js', '--profile', 'web', '--port', '0', '--no-open'], {
|
|
161
|
+
cwd: sandbox,
|
|
162
|
+
env: { ...process.env, DSH_HOME: path.join(sandbox, 'home') },
|
|
163
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
164
|
+
})
|
|
165
|
+
let bootOut = ''
|
|
166
|
+
host.stdout.on('data', c => { bootOut += c })
|
|
167
|
+
host.stderr.on('data', c => { bootOut += c })
|
|
168
|
+
const t0 = Date.now()
|
|
169
|
+
while (Date.now() - t0 < 60000) {
|
|
170
|
+
const m = bootOut.match(/dsh web: (http:\/\/\S+)/u)
|
|
171
|
+
if (m) return { host, url: m[1] }
|
|
172
|
+
if (host.exitCode !== null) throw new Error(`host exited ${host.exitCode} before web url:\n${bootOut.slice(-1200)}`)
|
|
173
|
+
await sleep(1000)
|
|
174
|
+
}
|
|
175
|
+
host.kill('SIGKILL')
|
|
176
|
+
throw new Error(`no web url within 60s:\n${bootOut.slice(-1200)}`)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
async function probeWithChrome(bootUrl, generation, shotPath, chromePath) {
|
|
180
|
+
const cdpPort = 9400 + Math.floor(Math.random() * 400)
|
|
181
|
+
const chrome = spawn(chromePath, [
|
|
182
|
+
'--headless=new', `--remote-debugging-port=${cdpPort}`, '--no-first-run', '--no-default-browser-check',
|
|
183
|
+
`--user-data-dir=${path.join(CELL_ROOT, 'chrome-profile-' + Date.now())}`, '--window-size=1280,900', 'about:blank',
|
|
184
|
+
], { stdio: 'ignore' })
|
|
185
|
+
try {
|
|
186
|
+
await sleep(2500)
|
|
187
|
+
const targets = await (await fetch(`http://127.0.0.1:${cdpPort}/json`)).json()
|
|
188
|
+
const page = targets.find(t => t.type === 'page')
|
|
189
|
+
const ws = new WebSocket(page.webSocketDebuggerUrl)
|
|
190
|
+
let id = 0
|
|
191
|
+
const pending = new Map()
|
|
192
|
+
ws.onmessage = (ev) => {
|
|
193
|
+
const msg = JSON.parse(ev.data)
|
|
194
|
+
if (msg.id && pending.has(msg.id)) { pending.get(msg.id)(msg); pending.delete(msg.id) }
|
|
195
|
+
}
|
|
196
|
+
await new Promise(r => { ws.onopen = r })
|
|
197
|
+
const send = (method, params = {}) => new Promise(resolve => {
|
|
198
|
+
const mid = ++id
|
|
199
|
+
pending.set(mid, resolve)
|
|
200
|
+
ws.send(JSON.stringify({ id: mid, method, params }))
|
|
201
|
+
})
|
|
202
|
+
const evalJS = async (expression, awaitPromise = false) => {
|
|
203
|
+
const r = await send('Runtime.evaluate', { expression, returnByValue: true, awaitPromise })
|
|
204
|
+
return r.result?.result?.value ?? r.result?.result?.description ?? 'undefined'
|
|
205
|
+
}
|
|
206
|
+
const realClick = async findExpr => {
|
|
207
|
+
const pos = await evalJS(`(() => {
|
|
208
|
+
const el = (${findExpr});
|
|
209
|
+
if (!el) return null;
|
|
210
|
+
const r = el.getBoundingClientRect();
|
|
211
|
+
return JSON.stringify({ x: Math.round(r.x + r.width / 2), y: Math.round(r.y + r.height / 2) });
|
|
212
|
+
})()`)
|
|
213
|
+
if (!pos || pos === 'null' || pos === 'undefined') return null
|
|
214
|
+
const { x, y } = JSON.parse(pos)
|
|
215
|
+
await send('Input.dispatchMouseEvent', { type: 'mouseMoved', x, y, pointerType: 'mouse' })
|
|
216
|
+
for (const type of ['mousePressed', 'mouseReleased']) {
|
|
217
|
+
await send('Input.dispatchMouseEvent', { type, x, y, button: 'left', clickCount: 1, pointerType: 'mouse' })
|
|
218
|
+
}
|
|
219
|
+
return `${x},${y}`
|
|
220
|
+
}
|
|
221
|
+
const waitClick = async (tag, findExpr, timeoutMs = 25000) => {
|
|
222
|
+
const t0 = Date.now()
|
|
223
|
+
while (Date.now() - t0 < timeoutMs) {
|
|
224
|
+
if (await realClick(findExpr)) return true
|
|
225
|
+
await sleep(700)
|
|
226
|
+
}
|
|
227
|
+
const labels = await evalJS(`JSON.stringify([...document.querySelectorAll("button,a[role=button]")].map(b => b.textContent?.trim()).filter(Boolean).slice(0, 14))`)
|
|
228
|
+
throw new Error(`click TIMEOUT ${tag}; buttons: ${labels}`)
|
|
229
|
+
}
|
|
230
|
+
const readSettings = async () => JSON.parse(await evalJS(`(async () => {
|
|
231
|
+
const r = await fetch("/api/dsh-context-compression-improved/settings", { headers: { accept: "application/json" } });
|
|
232
|
+
const j = await r.json();
|
|
233
|
+
return JSON.stringify({ profile: j.doc && j.doc.profile, generation: j.generation });
|
|
234
|
+
})()`, true))
|
|
235
|
+
|
|
236
|
+
// 首屏两层门(顺序因线而异,且可能复弹):API Key 弹窗「稍后配置」+
|
|
237
|
+
// 0.1.x「内测声明→继续」。轮询直到两层都不在(有轮次上限)。
|
|
238
|
+
const dismissOverlays = async () => {
|
|
239
|
+
for (let round = 0; round < 4; round += 1) {
|
|
240
|
+
const apiModal = await realClick(`(() => {
|
|
241
|
+
const b = [...document.querySelectorAll("button")].find(b => b.textContent?.trim() === "稍后配置");
|
|
242
|
+
return b ?? null;
|
|
243
|
+
})()`)
|
|
244
|
+
await sleep(800)
|
|
245
|
+
const banner = await realClick(`(() => {
|
|
246
|
+
const b = [...document.querySelectorAll("button")].find(b => b.textContent?.trim() === "继续");
|
|
247
|
+
return b ?? null;
|
|
248
|
+
})()`)
|
|
249
|
+
if (!apiModal && !banner) return true
|
|
250
|
+
await sleep(1200)
|
|
251
|
+
}
|
|
252
|
+
return false
|
|
253
|
+
}
|
|
254
|
+
await send('Page.enable')
|
|
255
|
+
await send('Page.navigate', { url: bootUrl })
|
|
256
|
+
await sleep(11000)
|
|
257
|
+
await dismissOverlays()
|
|
258
|
+
await sleep(1000)
|
|
259
|
+
|
|
260
|
+
if (generation === 'modern') {
|
|
261
|
+
// 插件面板 → 包详情 → plugins.bundle.config 卡片
|
|
262
|
+
await dismissOverlays()
|
|
263
|
+
await waitClick('plugins-panel', `(() => {
|
|
264
|
+
const b = [...document.querySelectorAll("nav button, button")].filter(b => b.textContent?.trim() === "插件").pop();
|
|
265
|
+
return b ?? null;
|
|
266
|
+
})()`)
|
|
267
|
+
await sleep(2500)
|
|
268
|
+
await waitClick('pkg-title', `(() => {
|
|
269
|
+
const el = [...document.querySelectorAll("*")].filter(e => /^dsh-context-compression-improved/.test(e.textContent?.trim() ?? "") && e.children.length === 0).pop();
|
|
270
|
+
if (!el) return null;
|
|
271
|
+
el.scrollIntoView({ block: "center" });
|
|
272
|
+
return el.closest("button") ?? el;
|
|
273
|
+
})()`)
|
|
274
|
+
await sleep(3000)
|
|
275
|
+
} else {
|
|
276
|
+
// 设置弹窗 → 左栏「上下文压缩选择器」分类 → settings.section 节
|
|
277
|
+
await waitClick('settings-panel', `(() => {
|
|
278
|
+
const b = [...document.querySelectorAll("button")].filter(b => b.textContent?.trim() === "设置").pop();
|
|
279
|
+
return b ?? null;
|
|
280
|
+
})()`)
|
|
281
|
+
await sleep(2000)
|
|
282
|
+
await dismissOverlays()
|
|
283
|
+
await waitClick('cci-category', `(() => {
|
|
284
|
+
const b = [...document.querySelectorAll("button")].filter(b => (b.textContent ?? "").includes("上下文压缩")).pop();
|
|
285
|
+
return b ?? null;
|
|
286
|
+
})()`)
|
|
287
|
+
await sleep(2500)
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const face = await evalJS(`(() => ({
|
|
291
|
+
slotErr: document.querySelectorAll("[data-slot-error]").length,
|
|
292
|
+
sectionText: document.body.innerText.includes("平衡模式") || document.body.innerText.includes("压缩 Profile"),
|
|
293
|
+
hasBalancedBtn: [...document.querySelectorAll("button")].some(b => b.textContent?.includes("平衡模式")),
|
|
294
|
+
hasSavingsBtn: [...document.querySelectorAll("button")].some(b => b.textContent?.includes("节省模式")),
|
|
295
|
+
entryErrors: window.__cciEntryError ?? null,
|
|
296
|
+
}))()`)
|
|
297
|
+
|
|
298
|
+
// 写穿断言:before/after 必须翻转,不依赖任何残留状态。
|
|
299
|
+
const before = await readSettings()
|
|
300
|
+
const target = before.profile === 'savings' ? '平衡模式' : '节省模式'
|
|
301
|
+
const expected = target === '节省模式' ? 'savings' : 'balanced'
|
|
302
|
+
const clicked = await evalJS(`(() => {
|
|
303
|
+
const card = [...document.querySelectorAll("button")].find(b => b.textContent?.includes(${JSON.stringify(target)}));
|
|
304
|
+
if (card) { card.click(); return 'clicked'; }
|
|
305
|
+
return 'no-btn';
|
|
306
|
+
})()`)
|
|
307
|
+
if (clicked !== 'clicked') throw new Error(`profile button "${target}" not rendered`)
|
|
308
|
+
await sleep(3500)
|
|
309
|
+
const after = await readSettings()
|
|
310
|
+
const shot = await send('Page.captureScreenshot', { format: 'png' })
|
|
311
|
+
if (shot.result?.data) await fs.promises.writeFile(shotPath, Buffer.from(shot.result.data, 'base64'))
|
|
312
|
+
ws.close()
|
|
313
|
+
return { face, before, after, expected }
|
|
314
|
+
} finally {
|
|
315
|
+
chrome.kill()
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const chromePath = findChrome()
|
|
320
|
+
if (!chromePath) {
|
|
321
|
+
console.error('no Chrome/Chromium found; set CHROME_PATH')
|
|
322
|
+
process.exit(2)
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const results = []
|
|
326
|
+
let failed = 0
|
|
327
|
+
for (const host of HOSTS_TO_RUN) {
|
|
328
|
+
const line = `${host.rc} (${host.generation})`
|
|
329
|
+
let host_ = null
|
|
330
|
+
try {
|
|
331
|
+
const { sandbox, installed } = await provisionCell(host)
|
|
332
|
+
console.log(`CELL ${line}: plugin ${installed}`)
|
|
333
|
+
const booted = await bootHost(sandbox)
|
|
334
|
+
host_ = booted.host
|
|
335
|
+
console.log(`CELL ${line}: boot ${booted.url}`)
|
|
336
|
+
await sleep(4000)
|
|
337
|
+
const shotPath = path.join(CELL_ROOT, `${host.rc}.png`)
|
|
338
|
+
const { face, before, after, expected } = await probeWithChrome(booted.url, host.generation, shotPath, chromePath)
|
|
339
|
+
const pass = face.slotErr === 0 && face.sectionText === true && face.hasSavingsBtn === true
|
|
340
|
+
&& after.profile === expected && before.profile !== after.profile
|
|
341
|
+
console.log(`CELL ${line}: ${pass ? 'PASS' : 'FAIL'} ${JSON.stringify({ face, before, after })}`)
|
|
342
|
+
results.push({ rc: host.rc, pass, installed })
|
|
343
|
+
if (!pass) failed += 1
|
|
344
|
+
} catch (error) {
|
|
345
|
+
console.log(`CELL ${line}: FAIL ${String(error.message).slice(-1500)}`)
|
|
346
|
+
results.push({ rc: host.rc, pass: false })
|
|
347
|
+
failed += 1
|
|
348
|
+
} finally {
|
|
349
|
+
host_?.kill('SIGKILL')
|
|
350
|
+
await sleep(1500)
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
console.log('SUMMARY ' + JSON.stringify(results))
|
|
354
|
+
process.exit(failed === 0 ? 0 : 1)
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Regenerate the tokenizer golden fixture for the Node loader equivalence tests.
|
|
3
|
+
|
|
4
|
+
Loads each pinned ``tokenizer.json`` shipped in ``packages/runtime/assets`` with
|
|
5
|
+
the official Hugging Face ``tokenizers`` Python library (the same Rust core the
|
|
6
|
+
``transformers`` tokenizer for these repositories uses) and records the token
|
|
7
|
+
counts the Node runtime must reproduce exactly.
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
python3 scripts/generate-tokenizer-fixtures.py
|
|
11
|
+
|
|
12
|
+
Requires: pip install tokenizers
|
|
13
|
+
Output: packages/runtime/tests/fixtures/tokenizer-golden.json
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
import pathlib
|
|
18
|
+
import platform
|
|
19
|
+
|
|
20
|
+
REPO_ROOT = pathlib.Path(__file__).resolve().parent.parent
|
|
21
|
+
ASSETS = {
|
|
22
|
+
"deepseek-ai/DeepSeek-V4-Pro": REPO_ROOT / "packages/runtime/assets/deepseek-v4",
|
|
23
|
+
"deepseek-ai/DeepSeek-V4-Flash-Vision-Exp": REPO_ROOT
|
|
24
|
+
/ "packages/runtime/assets/deepseek-v4-vision-exp",
|
|
25
|
+
}
|
|
26
|
+
OUTPUT = REPO_ROOT / "packages/runtime/tests/fixtures/tokenizer-golden.json"
|
|
27
|
+
|
|
28
|
+
CASES = [
|
|
29
|
+
("english prose", "The quick brown fox jumps over the lazy dog."),
|
|
30
|
+
("simplified chinese", "上下文压缩选择器在长任务中回收工具结果 token。"),
|
|
31
|
+
("mixed zh-en", "DeepSeek Harness 的 tool result 压缩,Fresh/Aggregate/History 三个阶段。"),
|
|
32
|
+
("json tool output", '{"status":"ok","items":[{"id":1,"path":"/tmp/a.txt"}],"count":1}'),
|
|
33
|
+
("python code", "def solve(width: int, height: int) -> int:\n return width * height // 2\n"),
|
|
34
|
+
("shell transcript", "$ pnpm run test\n> vitest run\n\n Test Files 12 passed (12)\n"),
|
|
35
|
+
("unicode whitespace", "line1\nline2\r\nline3\tline4 double spaces"),
|
|
36
|
+
("deepseek chat special tokens", "<|begin▁of▁sentence|><|User|>hello<|Assistant|><think>\n"),
|
|
37
|
+
("vision image placeholder", "before<|deepseek_image|>after"),
|
|
38
|
+
("empty string", ""),
|
|
39
|
+
("single ascii char", "a"),
|
|
40
|
+
("emoji", "compression 🧠✅ done"),
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
MANIFEST_REVISIONS = {}
|
|
44
|
+
for repository, asset_dir in ASSETS.items():
|
|
45
|
+
manifest = json.loads((asset_dir / "manifest.json").read_text(encoding="utf-8"))
|
|
46
|
+
MANIFEST_REVISIONS[repository] = manifest["revision"]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def main() -> None:
|
|
50
|
+
from tokenizers import Tokenizer
|
|
51
|
+
|
|
52
|
+
tokenizers = {}
|
|
53
|
+
for repository, asset_dir in ASSETS.items():
|
|
54
|
+
# Python `tokenizers` loads the fast-tokenizer definition directly from
|
|
55
|
+
# tokenizer.json; tokenizer_config.json only governs transformers-level
|
|
56
|
+
# special-token insertion, which these counts deliberately disable.
|
|
57
|
+
tokenizers[repository] = Tokenizer.from_file(str(asset_dir / "tokenizer.json"))
|
|
58
|
+
|
|
59
|
+
cases = []
|
|
60
|
+
for label, text in CASES:
|
|
61
|
+
counts = {}
|
|
62
|
+
for repository, tokenizer in tokenizers.items():
|
|
63
|
+
encoding = tokenizer.encode(text, add_special_tokens=False)
|
|
64
|
+
counts[repository] = len(encoding.ids)
|
|
65
|
+
cases.append({"label": label, "text": text, "counts": counts})
|
|
66
|
+
|
|
67
|
+
import tokenizers
|
|
68
|
+
|
|
69
|
+
fixture = {
|
|
70
|
+
"generator": f"tokenizers {tokenizers.__version__} on {platform.system()}",
|
|
71
|
+
"revision": "1",
|
|
72
|
+
"tokenizers": {repository: MANIFEST_REVISIONS[repository] for repository in sorted(ASSETS)},
|
|
73
|
+
"cases": cases,
|
|
74
|
+
}
|
|
75
|
+
OUTPUT.parent.mkdir(parents=True, exist_ok=True)
|
|
76
|
+
OUTPUT.write_text(json.dumps(fixture, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
|
|
77
|
+
print(f"wrote {OUTPUT} with {len(cases)} cases")
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
if __name__ == "__main__":
|
|
81
|
+
main()
|