dsh-context-compression-improved 0.12.0 → 0.13.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.
Files changed (334) hide show
  1. package/.agents/plans/improve/checklist.md +32 -0
  2. package/.agents/plans/improve/findings.md +102 -0
  3. package/.agents/plans/improve/spec.md +53 -0
  4. package/.agents/plans/improve/tasks.md +70 -0
  5. package/.gitattributes +2 -0
  6. package/.githooks/pre-push +37 -0
  7. package/.github/workflows/ci.yml +47 -0
  8. package/CHANGELOG.de.md +580 -0
  9. package/CHANGELOG.es.md +588 -0
  10. package/CHANGELOG.fr.md +576 -0
  11. package/CHANGELOG.it.md +577 -0
  12. package/CHANGELOG.ja.md +261 -0
  13. package/CHANGELOG.ko.md +254 -0
  14. package/CHANGELOG.md +582 -0
  15. package/CHANGELOG.pt.md +167 -0
  16. package/CHANGELOG.ru.md +554 -0
  17. package/CHANGELOG.zh.md +247 -0
  18. package/CONTRIBUTING.md +22 -0
  19. package/README.de.md +96 -0
  20. package/README.es.md +96 -0
  21. package/README.fr.md +96 -0
  22. package/README.it.md +96 -0
  23. package/README.ja.md +102 -0
  24. package/README.ko.md +102 -0
  25. package/README.md +128 -22
  26. package/README.pt.md +96 -0
  27. package/README.ru.md +96 -0
  28. package/README.zh.md +114 -24
  29. package/SECURITY.md +18 -0
  30. package/THIRD_PARTY_NOTICES.md +7 -25
  31. package/assets/board.png +0 -0
  32. package/assets/context.png +0 -0
  33. package/assets/dshfind-card.svg +33 -0
  34. package/docs/assets/context-compression-selector-profiles.jpg +0 -0
  35. package/docs/assets/context-compression-selector-settings.png +0 -0
  36. package/docs/compat-0.1.5-report.md +77 -0
  37. package/docs/installation.de.md +104 -0
  38. package/docs/installation.es.md +104 -0
  39. package/docs/installation.fr.md +104 -0
  40. package/docs/installation.it.md +104 -0
  41. package/docs/installation.ja.md +78 -0
  42. package/docs/installation.ko.md +78 -0
  43. package/docs/installation.md +103 -0
  44. package/docs/installation.ru.md +104 -0
  45. package/docs/installation.zh.md +100 -0
  46. package/docs/repair-log.md +657 -0
  47. package/docs/shallow-teaching-preset-template.md +46 -0
  48. package/eslint.config.js +30 -0
  49. package/package.json +112 -127
  50. package/packages/selector/LICENSE +21 -0
  51. package/packages/selector/README.md +26 -0
  52. package/packages/selector/README.zh.md +24 -0
  53. package/packages/selector/THIRD_PARTY_NOTICES.md +32 -0
  54. package/packages/selector/docs/history-tool-call-working-set-spec.md +112 -0
  55. package/packages/selector/docs/native-tool-result-selector-spec.md +34 -0
  56. package/packages/selector/docs/subagent-cache-reuse-spec.md +46 -0
  57. package/{dsh.plugin.json → packages/selector/dsh.plugin.json} +1 -1
  58. package/{lib → packages/selector/lib}/client.js +18 -10
  59. package/{lib → packages/selector/lib}/profiles.d.ts +6 -0
  60. package/packages/selector/lib/style.css +350 -0
  61. package/packages/selector/package.json +180 -0
  62. package/packages/selector/screenshots.json +3 -0
  63. package/packages/selector/src/client/CompressionProfileControls.tsx +352 -0
  64. package/packages/selector/src/client/CompressionProfileSelector.module.css +199 -0
  65. package/packages/selector/src/client/CompressionProfileSelector.tsx +89 -0
  66. package/packages/selector/src/client/CustomPolicyEditor.tsx +216 -0
  67. package/packages/selector/src/client/EstimatorControls.tsx +277 -0
  68. package/packages/selector/src/client/bridge-scope.ts +125 -0
  69. package/packages/selector/src/client/decode.ts +68 -0
  70. package/packages/selector/src/client/fab-pos.ts +71 -0
  71. package/packages/selector/src/client/guide-steps.ts +50 -0
  72. package/packages/selector/src/client/guide.tsx +368 -0
  73. package/packages/selector/src/client/index.ts +456 -0
  74. package/packages/selector/src/client/locales/de.ts +167 -0
  75. package/packages/selector/src/client/locales/es.ts +167 -0
  76. package/packages/selector/src/client/locales/fr.ts +167 -0
  77. package/packages/selector/src/client/locales/it.ts +167 -0
  78. package/packages/selector/src/client/locales/ja.ts +167 -0
  79. package/packages/selector/src/client/locales/ko.ts +167 -0
  80. package/packages/selector/src/client/locales/pt.ts +167 -0
  81. package/packages/selector/src/client/locales/ru.ts +167 -0
  82. package/packages/selector/src/client/locales.ts +334 -0
  83. package/packages/selector/src/client/monitor-fab.ts +445 -0
  84. package/packages/selector/src/client/preset-options.ts +88 -0
  85. package/packages/selector/src/client/savings-card.tsx +269 -0
  86. package/packages/selector/src/client/scope-face.ts +24 -0
  87. package/packages/selector/src/client/settings-section.tsx +171 -0
  88. package/packages/selector/src/compat/host-generation.ts +96 -0
  89. package/packages/selector/src/compat/llm-messages.ts +50 -0
  90. package/packages/selector/src/compat/settings-lease.ts +108 -0
  91. package/packages/selector/src/compat/tool-result.ts +91 -0
  92. package/packages/selector/src/css-modules.d.ts +6 -0
  93. package/packages/selector/src/deepseek-v4-tokenizer.ts +205 -0
  94. package/packages/selector/src/estimator-catalog.ts +104 -0
  95. package/packages/selector/src/index.ts +909 -0
  96. package/packages/selector/src/invariant.ts +113 -0
  97. package/packages/selector/src/preset-overlay.ts +749 -0
  98. package/packages/selector/src/profiles.ts +560 -0
  99. package/packages/selector/src/pruner/content.ts +199 -0
  100. package/packages/selector/src/pruner/session.ts +97 -0
  101. package/packages/selector/src/pruner/state.ts +61 -0
  102. package/packages/selector/src/pruner/tuning.ts +23 -0
  103. package/packages/selector/src/pruner/types.ts +78 -0
  104. package/packages/selector/src/pruner.ts +3222 -0
  105. package/packages/selector/src/runtime/adaptive-cost.ts +205 -0
  106. package/packages/selector/src/runtime/audit.ts +321 -0
  107. package/packages/selector/src/runtime/config.ts +887 -0
  108. package/packages/selector/src/runtime/custom-policy.ts +300 -0
  109. package/packages/selector/src/runtime/deepseek-official-pricing.ts +298 -0
  110. package/packages/selector/src/runtime/deepseek-v4-vision-tokens.ts +254 -0
  111. package/packages/selector/src/runtime/display-prefs.ts +98 -0
  112. package/packages/selector/src/runtime/fold-router.ts +143 -0
  113. package/packages/selector/src/runtime/injected-kinds.ts +62 -0
  114. package/packages/selector/src/runtime/measurement.ts +444 -0
  115. package/packages/selector/src/runtime/monitor.ts +341 -0
  116. package/packages/selector/src/runtime/netgain.ts +48 -0
  117. package/packages/selector/src/runtime/panel-command.ts +213 -0
  118. package/packages/selector/src/runtime/reducers.ts +1755 -0
  119. package/packages/selector/src/runtime/retrieve.ts +505 -0
  120. package/packages/selector/src/runtime/savings-integral.ts +117 -0
  121. package/packages/selector/src/runtime/savings-projection.ts +229 -0
  122. package/packages/selector/src/runtime/savings-verify.ts +446 -0
  123. package/packages/selector/src/runtime/savings.ts +526 -0
  124. package/packages/selector/src/runtime/sediment-card.ts +126 -0
  125. package/packages/selector/src/runtime/sediment-clock.ts +87 -0
  126. package/packages/selector/src/runtime/sediment-guard.ts +136 -0
  127. package/packages/selector/src/runtime/sediment-publish.ts +144 -0
  128. package/packages/selector/src/runtime/sediment-span.ts +170 -0
  129. package/packages/selector/src/runtime/sediment.ts +209 -0
  130. package/packages/selector/src/runtime/session-events.ts +30 -0
  131. package/packages/selector/src/runtime/session-file-decode.ts +523 -0
  132. package/packages/selector/src/runtime/shallow-tools.ts +342 -0
  133. package/packages/selector/src/runtime/stats-backfill.ts +541 -0
  134. package/packages/selector/src/runtime/stats-db.ts +492 -0
  135. package/packages/selector/src/runtime/stats-schema.ts +123 -0
  136. package/packages/selector/src/runtime/stats-sync.ts +307 -0
  137. package/packages/selector/src/runtime/summary-command.ts +127 -0
  138. package/packages/selector/src/runtime/tail-trim.ts +177 -0
  139. package/packages/selector/src/runtime/token-count.ts +72 -0
  140. package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +233 -0
  141. package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +204 -0
  142. package/packages/selector/src/runtime/tokenpilot/advisor.ts +419 -0
  143. package/packages/selector/src/runtime/tokenpilot/benefit.ts +200 -0
  144. package/packages/selector/src/runtime/tokenpilot/dedup.ts +82 -0
  145. package/packages/selector/src/runtime/tokenpilot/estimator.ts +151 -0
  146. package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +53 -0
  147. package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +65 -0
  148. package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +125 -0
  149. package/packages/selector/src/runtime/tokenpilot/intent-range.ts +37 -0
  150. package/packages/selector/src/runtime/tokenpilot/locator.ts +129 -0
  151. package/packages/selector/src/runtime/tokenpilot/read-state.ts +98 -0
  152. package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +303 -0
  153. package/packages/selector/src/runtime/tool-names.ts +42 -0
  154. package/packages/selector/src/runtime/toolclass.ts +103 -0
  155. package/packages/selector/src/runtime/triage/masks.ts +128 -0
  156. package/packages/selector/src/runtime/triage/shallow.ts +132 -0
  157. package/packages/selector/src/runtime/triage/signals.ts +167 -0
  158. package/packages/selector/src/runtime/triage/types.ts +125 -0
  159. package/packages/selector/src/runtime/types.ts +396 -0
  160. package/packages/selector/src/runtime/value.ts +48 -0
  161. package/packages/selector/src/settings-bridge.ts +175 -0
  162. package/packages/selector/src/tui-command.ts +99 -0
  163. package/packages/selector/tests/advisor-report.host.spec.ts +223 -0
  164. package/packages/selector/tests/auto-compact.client.spec.tsx +214 -0
  165. package/packages/selector/tests/built/client-artifact.spec.ts +56 -0
  166. package/packages/selector/tests/cache-prefix-audit.spec.ts +123 -0
  167. package/packages/selector/tests/code-skeleton.client.spec.ts +98 -0
  168. package/packages/selector/tests/compat/compat-narrow-waist.spec.ts +150 -0
  169. package/packages/selector/tests/custom-contract.client.spec.ts +226 -0
  170. package/packages/selector/tests/estimator-catalog.spec.ts +70 -0
  171. package/packages/selector/tests/estimator-channel.client.spec.tsx +253 -0
  172. package/packages/selector/tests/estimator-route-registration.host.spec.ts +202 -0
  173. package/packages/selector/tests/fab-pos.client.spec.ts +47 -0
  174. package/packages/selector/tests/fixtures/sediment-pool/52adc205-cloud-5.orig.txt +231 -0
  175. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-25.orig.txt +236 -0
  176. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-38.orig.txt +220 -0
  177. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-42.orig.txt +140 -0
  178. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-53.orig.txt +117 -0
  179. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-local-10.orig.txt +67 -0
  180. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-45.orig.txt +119 -0
  181. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-49.orig.txt +119 -0
  182. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-63.orig.txt +131 -0
  183. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-75.orig.txt +196 -0
  184. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-76.orig.txt +71 -0
  185. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-85.orig.txt +126 -0
  186. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-86.orig.txt +86 -0
  187. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-87.orig.txt +50 -0
  188. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-96.orig.txt +102 -0
  189. package/packages/selector/tests/helpers/legacy-namespace.ts +35 -0
  190. package/packages/selector/tests/helpers/legacy-settings/index.ts +15 -0
  191. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.d.ts +41 -0
  192. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.js +647 -0
  193. package/packages/selector/tests/helpers/legacy-settings/legacy/redact.js +78 -0
  194. package/packages/selector/tests/helpers/legacy-settings/legacy/util-values.js +234 -0
  195. package/packages/selector/tests/host-preset-overlay.host.spec.ts +204 -0
  196. package/packages/selector/tests/monitor-fab.client.spec.ts +240 -0
  197. package/packages/selector/tests/preset-options-write.client.spec.ts +192 -0
  198. package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +200 -0
  199. package/packages/selector/tests/preset-overlay.host.spec.ts +246 -0
  200. package/packages/selector/tests/profiles.client.spec.tsx +436 -0
  201. package/packages/selector/tests/ptc-custom-write.client.spec.ts +86 -0
  202. package/packages/selector/tests/public/package-contract.client.spec.ts +91 -0
  203. package/packages/selector/tests/runtime/adaptive-cost.spec.ts +167 -0
  204. package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +230 -0
  205. package/packages/selector/tests/runtime/advisor-invariant.spec.ts +272 -0
  206. package/packages/selector/tests/runtime/advisor.spec.ts +226 -0
  207. package/packages/selector/tests/runtime/audit.spec.ts +275 -0
  208. package/packages/selector/tests/runtime/auto-compact-config.spec.ts +523 -0
  209. package/packages/selector/tests/runtime/behavior-lock-profiles.spec.ts +128 -0
  210. package/packages/selector/tests/runtime/char-basis.spec.ts +30 -0
  211. package/packages/selector/tests/runtime/code-skeleton.spec.ts +152 -0
  212. package/packages/selector/tests/runtime/deepseek-official-pricing.spec.ts +186 -0
  213. package/packages/selector/tests/runtime/deepseek-v4-tokenizer.spec.ts +122 -0
  214. package/packages/selector/tests/runtime/deepseek-v4-vision-tokens.spec.ts +122 -0
  215. package/packages/selector/tests/runtime/deprecated-preset-options.spec.ts +96 -0
  216. package/packages/selector/tests/runtime/fallback-diversity.spec.ts +75 -0
  217. package/packages/selector/tests/runtime/fixtures/profile-baseline.json +273 -0
  218. package/packages/selector/tests/runtime/fixtures/session-v4-dump.jsonl +46 -0
  219. package/packages/selector/tests/runtime/fixtures/tokenizer-golden.json +106 -0
  220. package/packages/selector/tests/runtime/fixtures/vision-golden.json +459 -0
  221. package/packages/selector/tests/runtime/fold-router.spec.ts +140 -0
  222. package/packages/selector/tests/runtime/frequency-longstrings.spec.ts +74 -0
  223. package/packages/selector/tests/runtime/fresh-gate.spec.ts +43 -0
  224. package/packages/selector/tests/runtime/html-reducer.spec.ts +212 -0
  225. package/packages/selector/tests/runtime/injected-kinds.spec.ts +86 -0
  226. package/packages/selector/tests/runtime/intent-gate.spec.ts +62 -0
  227. package/packages/selector/tests/runtime/intent-summary.spec.ts +156 -0
  228. package/packages/selector/tests/runtime/jsonl-reducer.spec.ts +79 -0
  229. package/packages/selector/tests/runtime/line-mapping.spec.ts +153 -0
  230. package/packages/selector/tests/runtime/monitor.spec.ts +354 -0
  231. package/packages/selector/tests/runtime/netgain.spec.ts +61 -0
  232. package/packages/selector/tests/runtime/panel-command.spec.ts +101 -0
  233. package/packages/selector/tests/runtime/prose-reducers.spec.ts +133 -0
  234. package/packages/selector/tests/runtime/ptc-profile.spec.ts +133 -0
  235. package/packages/selector/tests/runtime/public/public-runtime.spec.ts +2795 -0
  236. package/packages/selector/tests/runtime/read-input-cap.spec.ts +33 -0
  237. package/packages/selector/tests/runtime/savings-accounting.spec.ts +291 -0
  238. package/packages/selector/tests/runtime/savings-integral.spec.ts +169 -0
  239. package/packages/selector/tests/runtime/savings-projection.spec.ts +89 -0
  240. package/packages/selector/tests/runtime/savings-verify.spec.ts +226 -0
  241. package/packages/selector/tests/runtime/savings.spec.ts +139 -0
  242. package/packages/selector/tests/runtime/search-reducer.spec.ts +110 -0
  243. package/packages/selector/tests/runtime/sediment-card.spec.ts +111 -0
  244. package/packages/selector/tests/runtime/sediment-config.spec.ts +56 -0
  245. package/packages/selector/tests/runtime/sediment-guard.spec.ts +71 -0
  246. package/packages/selector/tests/runtime/sediment-masks.spec.ts +95 -0
  247. package/packages/selector/tests/runtime/sediment-orchestrator.spec.ts +166 -0
  248. package/packages/selector/tests/runtime/sediment-pool-share.spec.ts +65 -0
  249. package/packages/selector/tests/runtime/sediment-publish.spec.ts +142 -0
  250. package/packages/selector/tests/runtime/sediment-real-shapes.spec.ts +158 -0
  251. package/packages/selector/tests/runtime/sediment-settings.spec.ts +73 -0
  252. package/packages/selector/tests/runtime/sediment-signals.spec.ts +124 -0
  253. package/packages/selector/tests/runtime/sediment-span.spec.ts +92 -0
  254. package/packages/selector/tests/runtime/session-events.spec.ts +27 -0
  255. package/packages/selector/tests/runtime/session-file-decode.spec.ts +281 -0
  256. package/packages/selector/tests/runtime/settings-unwrap.spec.ts +58 -0
  257. package/packages/selector/tests/runtime/shallow-primitives.spec.ts +135 -0
  258. package/packages/selector/tests/runtime/sidechannel.spec.ts +241 -0
  259. package/packages/selector/tests/runtime/source-kind-audit.spec.ts +79 -0
  260. package/packages/selector/tests/runtime/stats-backfill-scheduler.spec.ts +167 -0
  261. package/packages/selector/tests/runtime/stats-backfill.spec.ts +350 -0
  262. package/packages/selector/tests/runtime/stats-db.spec.ts +361 -0
  263. package/packages/selector/tests/runtime/stats-privacy.spec.ts +55 -0
  264. package/packages/selector/tests/runtime/stats-sync.spec.ts +278 -0
  265. package/packages/selector/tests/runtime/summary-command.spec.ts +154 -0
  266. package/packages/selector/tests/runtime/toc-and-bundled.spec.ts +159 -0
  267. package/packages/selector/tests/runtime/tokenizer-golden.spec.ts +53 -0
  268. package/packages/selector/tests/runtime/tokenpilot/benefit.spec.ts +217 -0
  269. package/packages/selector/tests/runtime/tokenpilot/dedup.spec.ts +52 -0
  270. package/packages/selector/tests/runtime/tokenpilot/estimator.spec.ts +79 -0
  271. package/packages/selector/tests/runtime/tokenpilot/locator.spec.ts +76 -0
  272. package/packages/selector/tests/runtime/tokenpilot/profile-baseline.spec.ts +121 -0
  273. package/packages/selector/tests/runtime/tokenpilot/read-state.spec.ts +82 -0
  274. package/packages/selector/tests/runtime/toolclass.spec.ts +156 -0
  275. package/packages/selector/tests/runtime/value.spec.ts +23 -0
  276. package/packages/selector/tests/savings-sessions.client.spec.tsx +140 -0
  277. package/packages/selector/tests/settings-seat.client.spec.ts +215 -0
  278. package/packages/selector/tests/standing-generation.host.spec.ts +729 -0
  279. package/packages/selector/tests/subagent-cache-reuse.host.spec.ts +269 -0
  280. package/packages/selector/tests/support/cache-prefix-audit.ts +105 -0
  281. package/packages/selector/tests/support/mock-adapter.ts +37 -0
  282. package/packages/selector/tests/support/ui-primitives.tsx +34 -0
  283. package/packages/selector/tsconfig.json +11 -0
  284. package/packages/selector/tsdown.client.config.ts +102 -0
  285. package/packages/selector/tsdown.config.ts +20 -0
  286. package/pnpm-workspace.yaml +76 -0
  287. package/screenshots.json +6 -3
  288. package/scripts/capture-profile-baseline.mjs +42 -0
  289. package/scripts/cell-browser-e2e.mjs +354 -0
  290. package/scripts/generate-tokenizer-fixtures.py +81 -0
  291. package/scripts/generate-vision-fixtures.py +208 -0
  292. package/scripts/hosts.d.mts +3 -0
  293. package/scripts/hosts.mjs +81 -0
  294. package/scripts/packed-components-smoke.mjs +763 -0
  295. package/scripts/packed-install-e2e.mjs +1346 -0
  296. package/scripts/sediment-latency-report.mjs +63 -0
  297. package/scripts/sync-hosts.mjs +176 -0
  298. package/scripts/toolclass-corpus-replay.mjs +281 -0
  299. package/scripts/verify-release.mjs +342 -0
  300. package/tests/TEST_INVENTORY.md +41 -0
  301. package/tsconfig.base.json +18 -0
  302. package/tsconfig.json +7 -0
  303. package/tsconfig.tests.json +15 -0
  304. package/vitest.built.config.ts +9 -0
  305. package/vitest.config.ts +54 -0
  306. /package/{assets → packages/selector/assets}/deepseek-v4/LICENSE.DeepSeek-V4-Pro.txt +0 -0
  307. /package/{assets → packages/selector/assets}/deepseek-v4/manifest.json +0 -0
  308. /package/{assets → packages/selector/assets}/deepseek-v4/tokenizer.json +0 -0
  309. /package/{assets → packages/selector/assets}/deepseek-v4/tokenizer_config.json +0 -0
  310. /package/{assets → packages/selector/assets}/deepseek-v4-vision-exp/LICENSE.DeepSeek-V4-Flash-Vision-Exp.txt +0 -0
  311. /package/{assets → packages/selector/assets}/deepseek-v4-vision-exp/manifest.json +0 -0
  312. /package/{assets → packages/selector/assets}/deepseek-v4-vision-exp/tokenizer.json +0 -0
  313. /package/{assets → packages/selector/assets}/deepseek-v4-vision-exp/tokenizer_config.json +0 -0
  314. /package/{cordis.patch.yml → packages/selector/cordis.patch.yml} +0 -0
  315. /package/{lib → packages/selector/lib}/client.d.ts +0 -0
  316. /package/{lib → packages/selector/lib}/index.d.ts +0 -0
  317. /package/{lib → packages/selector/lib}/index.js +0 -0
  318. /package/{lib → packages/selector/lib}/invariant.d.ts +0 -0
  319. /package/{lib → packages/selector/lib}/invariant.js +0 -0
  320. /package/{lib → packages/selector/lib}/pruner.d.ts +0 -0
  321. /package/{lib → packages/selector/lib}/pruner.js +0 -0
  322. /package/{lib → packages/selector/lib}/savings-integral.js +0 -0
  323. /package/{lib → packages/selector/lib}/tail-trim.js +0 -0
  324. /package/{lib → packages/selector/lib}/tool-result.js +0 -0
  325. /package/{locale → packages/selector/locale}/de.json +0 -0
  326. /package/{locale → packages/selector/locale}/en.json +0 -0
  327. /package/{locale → packages/selector/locale}/es.json +0 -0
  328. /package/{locale → packages/selector/locale}/fr.json +0 -0
  329. /package/{locale → packages/selector/locale}/it.json +0 -0
  330. /package/{locale → packages/selector/locale}/ja.json +0 -0
  331. /package/{locale → packages/selector/locale}/ko.json +0 -0
  332. /package/{locale → packages/selector/locale}/pt.json +0 -0
  333. /package/{locale → packages/selector/locale}/ru.json +0 -0
  334. /package/{locale → packages/selector/locale}/zh.json +0 -0
@@ -0,0 +1,71 @@
1
+ /**
2
+ * 视口比例位置持久化布局模块(百分位制,纯函数、node 环境可测、无 DOM 依赖)。
3
+ *
4
+ * 与 dsh-context-compression-improved monitor-fab 布局模型同构,改动须双侧同步
5
+ * (同串纪律:本文件与其 packages/selector/src/client/fab-pos.ts 逐字节一致,
6
+ * 测试用例同集对齐)。
7
+ *
8
+ * 存储模型:RatioPos { fx, fy } —— 悬浮物左上角相对视口的归一化位置(∈[0,1],
9
+ * 4 位小数)。兼容读入旧像素存档 { x, y }(按当前视口换算,形状判别即免迁移)。
10
+ * 换算后越界由接线层既有 clamp 兜底;本模块只做比例语义,不做落位。
11
+ */
12
+
13
+ export interface RatioPos {
14
+ fx: number;
15
+ fy: number;
16
+ }
17
+
18
+ export interface PixelPos {
19
+ x: number;
20
+ y: number;
21
+ }
22
+
23
+ /** vw/vh = 当前视口 CSS 像素;w/h = 悬浮物占位尺寸(本模块不参与运算,供接线层复用形状)。 */
24
+ export interface Viewport {
25
+ vw: number;
26
+ vh: number;
27
+ w: number;
28
+ h: number;
29
+ }
30
+
31
+ const clamp01 = (v: number): number => Math.max(0, Math.min(1, v));
32
+
33
+ const isFin = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v);
34
+
35
+ /** 除法结果的归一化兜底:±Infinity 夹到 1/0,NaN 视为无效。 */
36
+ const divClamp = (px: number, vpSize: number): number | null => {
37
+ const q = px / vpSize;
38
+ if (q === Infinity) return 1;
39
+ if (q === -Infinity) return 0;
40
+ if (!Number.isFinite(q)) return null;
41
+ return clamp01(q);
42
+ };
43
+
44
+ /**
45
+ * 读入 localStorage 存量形状并归一为比例态:
46
+ * - {fx,fy} 均有限 → 夹回 [0,1] 直用;
47
+ * - 否则 {x,y} 均有限(旧像素格式)→ 按当前视口除法换算(±Infinity 夹 1/0,NaN 拒);
48
+ * - 其余(非对象/数组/字段缺失/脏值)→ null,由调用方走默认位。
49
+ */
50
+ export function normalizeStored(raw: unknown, vp: Viewport): RatioPos | null {
51
+ if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) return null;
52
+ const r = raw as Record<string, unknown>;
53
+ if (isFin(r.fx) && isFin(r.fy)) return { fx: clamp01(r.fx), fy: clamp01(r.fy) };
54
+ if (!isFin(r.x) || !isFin(r.y)) return null;
55
+ const fx = divClamp(r.x, vp.vw);
56
+ const fy = divClamp(r.y, vp.vh);
57
+ if (fx === null || fy === null) return null;
58
+ return { fx, fy };
59
+ }
60
+
61
+ /** 像素 → 比例,4 位小数舍入;像素本身可为 clamp 后越内值(先夹再存)。 */
62
+ export function toRatio(pos: PixelPos, vp: Viewport): RatioPos {
63
+ const fx = divClamp(pos.x, vp.vw);
64
+ const fy = divClamp(pos.y, vp.vh);
65
+ return { fx: fx === null ? 0 : fx, fy: fy === null ? 0 : fy };
66
+ }
67
+
68
+ /** 比例 → 像素(不做 clamp——落位后由接线层既有 clamp 收边)。 */
69
+ export function fromRatio(r: RatioPos, vp: Viewport): PixelPos {
70
+ return { x: Math.round(clamp01(r.fx) * vp.vw), y: Math.round(clamp01(r.fy) * vp.vh) };
71
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * dsh-context-compression-improved 的首次使用引导文案(zh + en 各 4 步;末条讲用量端点)。
3
+ *
4
+ * 为什么单独一个文件:`guide.tsx` 是 `_tools/guide-kit/` 的**生成副本**(sync 会覆盖),
5
+ * 本插件的步骤正文不能写进副本;引导外壳的十语词表由副本自带,正文按
6
+ * 「本语 → en → zh → 任意可用」回退,所以这里只写 zh/en 不会留空白。
7
+ *
8
+ * 术语对齐 `locales.ts` 的真实译名(Profile 名、代码骨架压缩、轮尾沉降、
9
+ * 回合末意图摘要、压缩监控、悬浮面板、净节省/毛节省/负节省、水位、估计器、通道)。
10
+ */
11
+ import type { GuideLocale, GuideStep } from './guide.tsx'
12
+
13
+ export const CCI_GUIDE_STEPS: Partial<Record<GuideLocale, readonly GuideStep[]>> = {
14
+ zh: [
15
+ {
16
+ title: '先选 Profile,再看正交开关',
17
+ body: '设置 → 上下文压缩选择器,上方卡片就是压缩档位(平衡模式/节省模式/PTC 模式(绝对水位)等),点一下即改即存。下面的代码骨架压缩、轮尾沉降、回合末意图摘要属于档位之外的正交开关(默认关),Auto Compact 触发水位才是随档位联动的参数。',
18
+ },
19
+ {
20
+ title: '只对新会话生效,沉降还会撤下原消息',
21
+ body: '运行时首次观察某个会话时就冻结策略,改完当前会话没反应不是保存失败——开新会话才用新档位;只有出现「保存失败,请重试」才是真失败。开启轮尾沉降后,该轮工具调用区间被一张沉降卡替换,原消息会从对话视图撤出(原文仍在会话日志,可用卡里的序号回捞)。',
22
+ },
23
+ {
24
+ title: '看节省去悬浮面板,先分清口径',
25
+ body: '在设置里打开「悬浮面板」,输入区旁出现可拖拽的悬浮球,点开是压缩监控:净节省、毛节省、负节省(压缩后再读全文的抵消)、缓存命中率与成本估算。设置页底部的「节省统计(本进程)」在首次裁剪前是空的;标注「持久化降级」说明统计只留在内存。',
26
+ },
27
+ {
28
+ title: '压缩与折叠走本地直连端点',
29
+ body: '两处都能单独指定模型:设置页的「估计器(可选)」(仅「TokenPilot 启发模式」提供)把「通道」选成「直连 OpenAI 兼容端点」,填端点地址(/v1)与一个小模型;轮尾折叠的两层端点(高吞吐档吃 ≤2K 输入、稳定档吃 2~8K,如本地 35B)在配置里写 `sediment.foldMode: direct` 加 `foldBaseUrl` / `foldStrata*` / `foldLocal35*`。停在「宿主模型」时,压缩与对话共用同一个 provider/model,每轮裁剪都在吃对话 token。',
30
+ },
31
+ ],
32
+ en: [
33
+ {
34
+ title: 'Pick a profile first, then the orthogonal switches',
35
+ body: 'Settings → Context compression selector: the cards at the top are the profiles (Balanced, Savings, PTC / Code-mode (absolute), …); a click applies and saves. Code skeleton compression, turn-tail sedimentation, and turn-tail intent summary below are orthogonal switches outside the profile (off by default), while the Auto Compact trigger level is the one parameter that follows the profile.',
36
+ },
37
+ {
38
+ title: 'New sessions only — and sedimentation pulls originals out of view',
39
+ body: 'A session freezes its policy the first time the runtime observes it, so no visible change in the current session is not a failed save — open a new session; only “Save failed” means the save really failed. With turn-tail sedimentation on, each turn’s tool-call span becomes one sediment card and the replaced messages leave the transcript view (originals stay in the session log and can be retrieved by the card’s sequence numbers).',
40
+ },
41
+ {
42
+ title: 'Read savings in the monitor, mind the basis',
43
+ body: 'Turn on “Floating panel” in settings and a draggable ball appears next to the composer; it opens the compression monitor with net Δ, gross Δ, offsets (full reads after compression), cache hit rate, and cost estimates. The “Savings (this process)” card at the bottom of Settings stays empty until the first trim; a “persistence degraded” note means the numbers live in memory only.',
44
+ },
45
+ {
46
+ title: 'Route compression and folding to local direct endpoints',
47
+ body: 'Two places take an explicit model: the Estimator block in settings (offered only under the TokenPilot-inspired profile) — set Channel to “Direct OpenAI-compatible endpoint” with a /v1 base URL and a small model; and the two turn-tail folding tiers (a high-throughput tier for inputs ≤2K, a stable tier such as local 35B for 2–8K), configured as sediment.foldMode: direct with foldBaseUrl / foldStrata* / foldLocal35*. Left on “Host model”, summarisation shares one provider/model with the conversation, so every trim spends conversation tokens.',
48
+ },
49
+ ],
50
+ }
@@ -0,0 +1,368 @@
1
+ /**
2
+ * ⚠️ 生成副本 —— 请勿手改。真源:mine-dsh-plugins/_tools/guide-kit/guide.tsx
3
+ * 重新同步:node _tools/guide-kit/sync.mjs
4
+ */
5
+ /**
6
+ * guide-kit —— 九插件共用的「首次使用引导」件(**生成副本,勿手改**)。
7
+ *
8
+ * 唯一真源:`mine-dsh-plugins/_tools/guide-kit/guide.tsx`
9
+ * 同步命令:`node _tools/guide-kit/sync.mjs`(会覆盖本文件;改这里等于白改)
10
+ *
11
+ * 六条契约(见 .agents/plans/unified-i18n-onboarding/spec.md §2):
12
+ * 1. Skip 恒定可见,任何步骤都能退;
13
+ * 2. 永远有字:引导外壳(标题/按钮/步进)自带 10 语词表,按 <html lang> 取词,
14
+ * 认不出的一律落 en;步骤正文按「本语 → en → zh → 任意可用」逐级回退,绝不留空白;
15
+ * 3. 重启入口:`GuideRestartButton`(或自己调 `resetGuide(ns)` + setOpen(true))就地重开;
16
+ * 4. 零依赖:只 react + localStorage,不 import 平台包,不抢宿主设置表单;
17
+ * 5. 引导自己绝不能成为卡面渲染的失败点:样式注入与存储访问全部 try/catch + 能力探测;
18
+ * 6. 外壳词表与步骤正文分离:外壳跨插件统一(本文件),正文每插件一份 `guide-steps.ts`。
19
+ */
20
+ import { useEffect, useState } from 'react'
21
+ import type { CSSProperties, JSX } from 'react'
22
+
23
+ export interface GuideStep {
24
+ title: string
25
+ body: string
26
+ }
27
+
28
+ export interface GuideLabels {
29
+ title: string
30
+ skip: string
31
+ next: string
32
+ prev: string
33
+ done: string
34
+ restart: string
35
+ stepOf: (_current: number, _total: number) => string
36
+ }
37
+
38
+ /** 生态通用的十个语言码(与各插件 `locale/*.json`、README 的十语镜像同口径)。 */
39
+ export const GUIDE_LOCALES = ['zh', 'en', 'ja', 'ko', 'fr', 'de', 'it', 'ru', 'es', 'pt'] as const
40
+ export type GuideLocale = (typeof GUIDE_LOCALES)[number]
41
+
42
+ /**
43
+ * 引导外壳词表(10 语)。
44
+ *
45
+ * 为什么不塞进各插件 locales:这七个词是**跨插件同一套**,塞进九个字典要重复翻译
46
+ * 9×10 次,且一旦措辞调整就得动九个仓。外壳留在本文件,正文留各插件。
47
+ */
48
+ export const GUIDE_COPY: Record<GuideLocale, GuideLabels> = {
49
+ zh: {
50
+ title: '快速上手',
51
+ skip: '跳过引导',
52
+ next: '下一步',
53
+ prev: '上一步',
54
+ done: '开始使用',
55
+ restart: '重新查看引导',
56
+ stepOf: (current, total) => `第 ${current} / ${total} 步`,
57
+ },
58
+ en: {
59
+ title: 'Quick start',
60
+ skip: 'Skip guide',
61
+ next: 'Next',
62
+ prev: 'Back',
63
+ done: 'Get started',
64
+ restart: 'Show guide again',
65
+ stepOf: (current, total) => `Step ${current} of ${total}`,
66
+ },
67
+ ja: {
68
+ title: 'クイックスタート',
69
+ skip: 'ガイドをスキップ',
70
+ next: '次へ',
71
+ prev: '戻る',
72
+ done: 'はじめる',
73
+ restart: 'ガイドをもう一度表示',
74
+ stepOf: (current, total) => `ステップ ${current} / ${total}`,
75
+ },
76
+ ko: {
77
+ title: '빠른 시작',
78
+ skip: '가이드 건너뛰기',
79
+ next: '다음',
80
+ prev: '이전',
81
+ done: '시작하기',
82
+ restart: '가이드 다시 보기',
83
+ stepOf: (current, total) => `${current} / ${total} 단계`,
84
+ },
85
+ fr: {
86
+ title: 'Démarrage rapide',
87
+ skip: 'Ignorer le guide',
88
+ next: 'Suivant',
89
+ prev: 'Retour',
90
+ done: 'Commencer',
91
+ restart: 'Revoir le guide',
92
+ stepOf: (current, total) => `Étape ${current} sur ${total}`,
93
+ },
94
+ de: {
95
+ title: 'Schnellstart',
96
+ skip: 'Anleitung überspringen',
97
+ next: 'Weiter',
98
+ prev: 'Zurück',
99
+ done: 'Loslegen',
100
+ restart: 'Anleitung erneut anzeigen',
101
+ stepOf: (current, total) => `Schritt ${current} von ${total}`,
102
+ },
103
+ it: {
104
+ title: 'Avvio rapido',
105
+ skip: 'Salta la guida',
106
+ next: 'Avanti',
107
+ prev: 'Indietro',
108
+ done: 'Inizia',
109
+ restart: 'Rivedi la guida',
110
+ stepOf: (current, total) => `Passo ${current} di ${total}`,
111
+ },
112
+ ru: {
113
+ title: 'Быстрый старт',
114
+ skip: 'Пропустить руководство',
115
+ next: 'Далее',
116
+ prev: 'Назад',
117
+ done: 'Начать',
118
+ restart: 'Показать руководство снова',
119
+ stepOf: (current, total) => `Шаг ${current} из ${total}`,
120
+ },
121
+ es: {
122
+ title: 'Inicio rápido',
123
+ skip: 'Omitir la guía',
124
+ next: 'Siguiente',
125
+ prev: 'Atrás',
126
+ done: 'Empezar',
127
+ restart: 'Ver la guía de nuevo',
128
+ stepOf: (current, total) => `Paso ${current} de ${total}`,
129
+ },
130
+ pt: {
131
+ title: 'Início rápido',
132
+ skip: 'Ignorar o guia',
133
+ next: 'Próximo',
134
+ prev: 'Voltar',
135
+ done: 'Começar',
136
+ restart: 'Ver o guia novamente',
137
+ stepOf: (current, total) => `Passo ${current} de ${total}`,
138
+ },
139
+ }
140
+
141
+ /** 语言标签 → 语言码:只认主标签,认不出的落 null(由调用方回退 en)。 */
142
+ export function normalizeGuideLocale(tag: string): GuideLocale | null {
143
+ const primary = tag.toLowerCase().trim().split(/[-_]/)[0] ?? ''
144
+ return (GUIDE_LOCALES as readonly string[]).includes(primary) ? (primary as GuideLocale) : null
145
+ }
146
+
147
+ function htmlLang(): string {
148
+ try {
149
+ return typeof document === 'undefined' ? '' : (document.documentElement?.lang ?? '')
150
+ } catch {
151
+ return ''
152
+ }
153
+ }
154
+
155
+ /**
156
+ * 当前引导语言:以宿主 `<html lang>` 为准(语言切换会改写这个属性)。
157
+ *
158
+ * 认不出 → en:引导是「帮助」面,宁可给英文也不能给空白或中文硬串。
159
+ */
160
+ export function currentGuideLocale(): GuideLocale {
161
+ return normalizeGuideLocale(htmlLang()) ?? 'en'
162
+ }
163
+
164
+ /** 兼容旧调用(1.x 版本只区分 zh/en):需要细分语种请用 `currentGuideLocale()`。 */
165
+ export function guideLang(): GuideLocale {
166
+ return currentGuideLocale()
167
+ }
168
+
169
+ /** 引导外壳取词。 */
170
+ export function guideLabels(locale: GuideLocale = currentGuideLocale()): GuideLabels {
171
+ return GUIDE_COPY[locale] ?? GUIDE_COPY.en
172
+ }
173
+
174
+ /**
175
+ * 步骤正文取词:本语 → en → zh → 表里第一个可用。
176
+ *
177
+ * 为什么需要回退链:九插件分批补语种,某个插件可能只有 zh/en 而宿主是 ru;
178
+ * 这时给英文是可用的,给空白等于「引导坏了」。`undefined` 步骤表按空表处理。
179
+ */
180
+ export function guideSteps(
181
+ map: Partial<Record<GuideLocale, readonly GuideStep[]>> | undefined,
182
+ ): readonly GuideStep[] {
183
+ if (map === undefined) return []
184
+ const order: (GuideLocale | undefined)[] = [currentGuideLocale(), 'en', 'zh']
185
+ for (const key of order) {
186
+ const hit = key === undefined ? undefined : map[key]
187
+ if (hit !== undefined && hit.length > 0) return hit
188
+ }
189
+ for (const key of GUIDE_LOCALES) {
190
+ const hit = map[key]
191
+ if (hit !== undefined && hit.length > 0) return hit
192
+ }
193
+ return []
194
+ }
195
+
196
+ function guideStorageKey(ns: string): string {
197
+ return `dsh.guide.${ns}.skipped`
198
+ }
199
+
200
+ /** 是否已跳过(存储不可用时按「未跳过」处理:宁可多教一次,不要静默不教)。 */
201
+ export function isGuideSkipped(ns: string): boolean {
202
+ try {
203
+ return typeof localStorage !== 'undefined' && localStorage.getItem(guideStorageKey(ns)) === '1'
204
+ } catch {
205
+ return false
206
+ }
207
+ }
208
+
209
+ /** 记下跳过;写失败不抛(隐私模式 / 存储禁用)。 */
210
+ export function skipGuide(ns: string): void {
211
+ try {
212
+ localStorage?.setItem(guideStorageKey(ns), '1')
213
+ } catch {
214
+ /* ignore */
215
+ }
216
+ }
217
+
218
+ /** 清标记 = 允许重新教学。 */
219
+ export function resetGuide(ns: string): void {
220
+ try {
221
+ localStorage?.removeItem(guideStorageKey(ns))
222
+ } catch {
223
+ /* ignore */
224
+ }
225
+ }
226
+
227
+ const GUIDE_CSS = `
228
+ .sgGuide{border:1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.28));background:var(--dsw-alias-bg-layer-2, rgba(127,127,127,.06));border-radius:12px;padding:14px 16px;margin:0 0 12px}
229
+ .sgGuideHead{display:flex;align-items:center;gap:8px;margin:0 0 10px}
230
+ .sgGuideTitle{font-size:14px;font-weight:600;color:var(--dsw-alias-label-primary, currentColor)}
231
+ .sgGuideStep{font-size:12px;color:var(--dsw-alias-label-tertiary, rgba(127,127,127,.9));margin-left:auto}
232
+ .sgGuideBody{font-size:13px;line-height:1.6;color:var(--dsw-alias-label-secondary, currentColor);min-height:52px}
233
+ .sgGuideBody b{color:var(--dsw-alias-label-primary, currentColor);font-weight:600}
234
+ .sgGuideDots{display:flex;gap:6px;margin:10px 0 0}
235
+ .sgGuideDot{width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-border-l2, rgba(127,127,127,.3))}
236
+ .sgGuideDot-on{background:var(--dsw-alias-button-primary-fill, #4d6bfe)}
237
+ .sgGuideFoot{display:flex;align-items:center;gap:8px;margin:12px 0 0}
238
+ .sgGuideBtn{appearance:none;font:inherit;font-size:12px;padding:5px 12px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.3));background:transparent;color:var(--dsw-alias-label-primary, currentColor);cursor:pointer}
239
+ .sgGuideBtn-primary{background:var(--dsw-alias-button-primary-fill, #4d6bfe);border-color:transparent;color:#fff}
240
+ .sgGuideBtn-skip{margin-right:auto;color:var(--dsw-alias-label-tertiary, rgba(127,127,127,.9));border-color:transparent;text-decoration:underline}
241
+ .sgGuideRestart{appearance:none;font:inherit;font-size:12px;padding:0;border:0;background:transparent;color:var(--dsw-alias-link-primary, #4d6bfe);cursor:pointer;text-decoration:underline}
242
+ `
243
+
244
+ function injectGuideCss(): void {
245
+ // 宿主是浏览器,但**测试替身**常常只给一个残缺的 document(无 querySelector /
246
+ // 无 head)——样式注入是纯装饰,任何缺失都安静跳过,绝不让引导把卡面炸掉。
247
+ try {
248
+ if (typeof document === 'undefined') return
249
+ if (typeof document.querySelector !== 'function') return
250
+ if (typeof document.createElement !== 'function') return
251
+ if (!document.head) return
252
+ if (document.querySelector('style[data-plugin-css="guide-kit"]') !== null) return
253
+ const tag = document.createElement('style')
254
+ tag.dataset.pluginCss = 'guide-kit'
255
+ tag.textContent = GUIDE_CSS
256
+ document.head.appendChild(tag)
257
+ } catch {
258
+ /* 残缺 DOM:跳过样式,行为不受影响 */
259
+ }
260
+ }
261
+
262
+ /** 语言变更订阅:语言切换后重渲染词表(引导是短生命周期,直接跟随 <html lang>)。 */
263
+ function useLangTick(): void {
264
+ const [, setTick] = useState(0)
265
+ useEffect(() => {
266
+ try {
267
+ if (typeof MutationObserver === 'undefined' || typeof document === 'undefined') return
268
+ if (!document.documentElement) return
269
+ const observer = new MutationObserver(() => setTick((n) => n + 1))
270
+ observer.observe(document.documentElement, { attributes: true, attributeFilter: ['lang'] })
271
+ return () => observer.disconnect()
272
+ } catch {
273
+ return
274
+ }
275
+ }, [])
276
+ }
277
+
278
+ /**
279
+ * 引导主体:≤10 步的小教学(惯例:末条讲「用量端点」贴士)+ 恒定可见的 Skip。
280
+ *
281
+ * `onClose` 由宿主卡面传:Skip/Done 都会调用它(Skip 同时写标记)。
282
+ */
283
+ export function GuidePanel(props: {
284
+ ns: string
285
+ steps: readonly GuideStep[]
286
+ onClose: () => void
287
+ }): JSX.Element | null {
288
+ const { ns, steps, onClose } = props
289
+ const [index, setIndex] = useState(0)
290
+ useLangTick()
291
+ const labels = guideLabels()
292
+ useEffect(() => {
293
+ injectGuideCss()
294
+ }, [])
295
+ if (steps.length === 0) return null
296
+ const current = steps[Math.min(index, steps.length - 1)]!
297
+ const last = index >= steps.length - 1
298
+ // Skip 与 Done 都写标记:**「看过」= 不再自动弹**。只给 Skip 写字会让点
299
+ // 「开始使用」走完的用户每次进设置面都被再教一遍(认真看完的人最烦这个)。
300
+ const finish = (): void => {
301
+ skipGuide(ns)
302
+ onClose()
303
+ }
304
+ return (
305
+ <section className="sgGuide" aria-label={labels.title}>
306
+ <header className="sgGuideHead">
307
+ <span className="sgGuideTitle">{labels.title}</span>
308
+ <span className="sgGuideStep">{labels.stepOf(index + 1, steps.length)}</span>
309
+ </header>
310
+ <div className="sgGuideBody">
311
+ <b>{current.title}</b>
312
+ <div>{current.body}</div>
313
+ </div>
314
+ <div className="sgGuideDots" aria-hidden="true">
315
+ {steps.map((step, i) => (
316
+ <span key={step.title} className={'sgGuideDot' + (i === index ? ' sgGuideDot-on' : '')} />
317
+ ))}
318
+ </div>
319
+ <footer className="sgGuideFoot">
320
+ <button type="button" className="sgGuideBtn sgGuideBtn-skip" onClick={() => finish()}>
321
+ {labels.skip}
322
+ </button>
323
+ {index > 0 && (
324
+ <button type="button" className="sgGuideBtn" onClick={() => setIndex(index - 1)}>
325
+ {labels.prev}
326
+ </button>
327
+ )}
328
+ {last ? (
329
+ <button type="button" className="sgGuideBtn sgGuideBtn-primary" onClick={() => finish()}>
330
+ {labels.done}
331
+ </button>
332
+ ) : (
333
+ <button type="button" className="sgGuideBtn sgGuideBtn-primary" onClick={() => setIndex(index + 1)}>
334
+ {labels.next}
335
+ </button>
336
+ )}
337
+ </footer>
338
+ </section>
339
+ )
340
+ }
341
+
342
+ /**
343
+ * 重启入口:清标记 + 就地重开引导。
344
+ *
345
+ * 统一件,避免九插件各写一份(措辞/样式/清标记时机容易走样)。跳过之后
346
+ * 用户想再看一次,不需要去清浏览器存储。
347
+ */
348
+ export function GuideRestartButton(props: {
349
+ ns: string
350
+ onOpen: () => void
351
+ style?: CSSProperties
352
+ }): JSX.Element {
353
+ const { ns, onOpen, style } = props
354
+ useLangTick()
355
+ return (
356
+ <button
357
+ type="button"
358
+ className="sgGuideRestart"
359
+ style={style}
360
+ onClick={() => {
361
+ resetGuide(ns)
362
+ onOpen()
363
+ }}
364
+ >
365
+ {guideLabels().restart}
366
+ </button>
367
+ )
368
+ }