dsh-oc-tui 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +21 -563
  2. package/bin/mcp-sse-bridge.mjs +499 -499
  3. package/docs/assets/conversation.png +0 -0
  4. package/docs/assets/cover.png +0 -0
  5. package/docs/assets/home.png +0 -0
  6. package/docs/assets/settings.png +0 -0
  7. package/docs/dsh-std-/346/216/245/345/205/245/350/257/264/346/230/216.md +566 -0
  8. package/docs/user-guide.md +616 -0
  9. package/docs//347/224/250/346/210/267/346/211/213/345/206/214.md +607 -593
  10. package/dsh-plugin.json +69 -69
  11. package/lib/boot-block.js +129 -0
  12. package/lib/diagnostics.js +162 -120
  13. package/lib/dsh-version.js +161 -0
  14. package/lib/git-branch.js +157 -157
  15. package/lib/i18n.js +283 -283
  16. package/lib/image.js +2 -1
  17. package/lib/index.js +5183 -4812
  18. package/lib/locales/ar.js +670 -635
  19. package/lib/locales/de.js +639 -604
  20. package/lib/locales/en.js +35 -0
  21. package/lib/locales/es.js +639 -604
  22. package/lib/locales/fr.js +639 -604
  23. package/lib/locales/id.js +641 -606
  24. package/lib/locales/it.js +639 -604
  25. package/lib/locales/ja.js +639 -604
  26. package/lib/locales/ko.js +639 -604
  27. package/lib/locales/nl.js +639 -604
  28. package/lib/locales/pl.js +653 -618
  29. package/lib/locales/pt-BR.js +639 -604
  30. package/lib/locales/ru.js +653 -618
  31. package/lib/locales/tr.js +639 -604
  32. package/lib/locales/vi.js +641 -606
  33. package/lib/locales/zh-CN.js +640 -605
  34. package/lib/locales/zh-TW.js +640 -605
  35. package/lib/markdown.js +101 -27
  36. package/lib/mcp-monitor.js +189 -0
  37. package/lib/mcp-skill.js +93 -93
  38. package/lib/mcp.js +865 -838
  39. package/lib/model-route.js +66 -0
  40. package/lib/providers.js +712 -712
  41. package/lib/screenshot.js +140 -0
  42. package/lib/splash-opencode.js +29 -26
  43. package/lib/startup.js +66 -48
  44. package/lib/term.js +53 -11
  45. package/lib/themes.js +101 -0
  46. package/lib/ui.js +685 -443
  47. package/lib/updates.js +5 -2
  48. package/lib/web-settings.js +52 -21
  49. package/package.json +160 -146
  50. package/skills/mcp-import/SKILL.md +216 -216
@@ -0,0 +1,66 @@
1
+ // How a model or reasoning-effort choice reaches the agent, across the two host
2
+ // generations.
3
+ //
4
+ // dsh 0.2.1 and earlier own no selection state: the only lever is the
5
+ // `agent/request` waterfall, and a listener there is expected to hand back a
6
+ // different provider/model (0.2.1's loop only rejects a config that names
7
+ // neither).
8
+ //
9
+ // dsh 0.2.2 fixes the route at step preparation — before prompt assembly and
10
+ // before `agent/pre-step` — and makes that same waterfall reject a changed
11
+ // route by throwing `agent/request proposed "…" after step preparation fixed
12
+ // "…"`, which kills the turn. A choice has to be recorded between steps with
13
+ // `agent.model.select()`, which appends a durable `model/selection` event.
14
+ //
15
+ // Both paths are selected by feature detection on the live agent rather than by
16
+ // a version string: `agent.model` does not exist on the older line at all, so
17
+ // its presence is the honest discriminator and one build keeps working on both.
18
+
19
+ export function recordsSelections(agent) {
20
+ return Boolean(agent && agent.model && typeof agent.model.select === 'function')
21
+ }
22
+
23
+ // The route/effort overrides the `agent/request` waterfall should return, or
24
+ // null when the config already carries what the TUI wants.
25
+ //
26
+ // `config` is what the loop proposed, `preference` the TUI's own choice (an
27
+ // explicit /model or /provider, else anything set from the settings surface),
28
+ // `defaults` the resolved agent options, and `effort` the validated reasoning
29
+ // level — `undefined` keeps the adapter's default behavior.
30
+ export function legacyRouteOverrides(config, preference, defaults, effort) {
31
+ const overrides = {}
32
+ if (preference?.provider) overrides.provider = preference.provider
33
+ else if (!config?.provider && defaults?.provider) overrides.provider = defaults.provider
34
+ if (preference?.model) overrides.model = preference.model
35
+ else if (!config?.model && defaults?.model) overrides.model = defaults.model
36
+ if (effort) overrides.reasoningEffort = effort
37
+ return Object.keys(overrides).length === 0 ? null : overrides
38
+ }
39
+
40
+ // Record one complete selection on a host that owns it. `preference` wins over
41
+ // the agent's current selection, which in turn wins over what the view shows —
42
+ // so a `/model` without a provider still writes a complete pair.
43
+ //
44
+ // `withEffort` is opt-in on purpose: a model switch drops the explicit effort so
45
+ // the new adapter's default applies (`loadEffortSlider` then re-reads that
46
+ // model's own ladder), while an effort change always carries it. A selection
47
+ // equal to the recorded one is a no-op on the host side, so callers do not have
48
+ // to compare first.
49
+ export function recordSelection(agent, preference, view, { withEffort = false, effort } = {}) {
50
+ if (!recordsSelections(agent)) return null
51
+ const current = typeof agent.model.current === 'function' ? agent.model.current() ?? {} : {}
52
+ const provider = preference?.provider ?? current.provider ?? view?.provider
53
+ const model = preference?.model ?? current.model ?? view?.model
54
+ if (!provider || !model) return null
55
+ const selection = { provider, model }
56
+ if (withEffort && effort) selection.reasoningEffort = effort
57
+ try {
58
+ agent.model.select(selection)
59
+ } catch {
60
+ // A host that rejects the selection (an unregistered route, a disposed
61
+ // agent) must not take the interface down: the next request reports the
62
+ // stale route through the loop's own error channel.
63
+ return null
64
+ }
65
+ return selection
66
+ }