dexterm-cli 0.1.2 → 0.1.3

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 (118) hide show
  1. package/dist/packages/agents/src/bus.js +37 -1
  2. package/dist/packages/agents/src/follow.js +105 -0
  3. package/dist/packages/agents/src/index.js +5 -0
  4. package/dist/packages/agents/src/spectator-server.js +153 -0
  5. package/dist/packages/agents/src/spectator.js +212 -0
  6. package/dist/packages/cli/assets/claude/analyst-system.md +6 -1
  7. package/dist/packages/cli/src/agent-cmd.js +71 -7
  8. package/dist/packages/cli/src/agent-spectator.js +37 -0
  9. package/dist/packages/cli/src/alerts/format.js +25 -0
  10. package/dist/packages/cli/src/app-help-gen.js +365 -0
  11. package/dist/packages/cli/src/doctor.js +6 -5
  12. package/dist/packages/cli/src/follow-cmd.js +107 -1
  13. package/dist/packages/cli/src/help-cmd.js +48 -0
  14. package/dist/packages/cli/src/live/index.js +64 -3
  15. package/dist/packages/cli/src/live/screens/token-live.js +24 -0
  16. package/dist/packages/cli/src/live/signals.js +109 -0
  17. package/dist/packages/cli/src/live/trade.js +24 -1
  18. package/dist/packages/cli/src/main.js +355 -10
  19. package/dist/packages/cli/src/mcp-cmd.js +2 -7
  20. package/dist/packages/cli/src/pnl-app.js +221 -0
  21. package/dist/packages/cli/src/pnl-card.js +615 -0
  22. package/dist/packages/cli/src/record-cmd.js +455 -0
  23. package/dist/packages/cli/src/rules.js +50 -2
  24. package/dist/packages/cli/src/screens/follows.js +91 -2
  25. package/dist/packages/cli/src/screens/overlay.js +3 -0
  26. package/dist/packages/cli/src/screens/positions.js +1 -1
  27. package/dist/packages/cli/src/screens/rules.js +1 -1
  28. package/dist/packages/cli/src/spectate-cmd.js +104 -0
  29. package/dist/packages/cli/src/state.js +1 -1
  30. package/dist/packages/cli/src/version.js +1 -1
  31. package/dist/packages/cli/src/voice-cmd.js +86 -11
  32. package/dist/packages/cli/src/voice-hud.js +1 -1
  33. package/dist/packages/custom/src/rules.js +2 -1
  34. package/dist/packages/data/src/analyst-actions.js +130 -3
  35. package/dist/packages/data/src/fast-lane.js +16 -2
  36. package/dist/packages/data/src/index.js +1 -0
  37. package/dist/packages/data/src/intel/live-signals.js +185 -0
  38. package/dist/packages/data/src/trade/copy/index.js +1 -1
  39. package/dist/packages/data/src/trade/copy/stats.js +36 -2
  40. package/dist/packages/data/src/trade/copy/tracker.js +3 -2
  41. package/dist/packages/mcp/assets/kb/app-help/app-help-command.md +35 -0
  42. package/dist/packages/mcp/assets/kb/app-help/ask-the-analyst.md +43 -0
  43. package/dist/packages/mcp/assets/kb/app-help/backtest.md +33 -0
  44. package/dist/packages/mcp/assets/kb/app-help/bubble-map.md +35 -0
  45. package/dist/packages/mcp/assets/kb/app-help/calm-mode.md +31 -0
  46. package/dist/packages/mcp/assets/kb/app-help/change-voice-speed.md +31 -0
  47. package/dist/packages/mcp/assets/kb/app-help/change-voice.md +30 -0
  48. package/dist/packages/mcp/assets/kb/app-help/chart-popup-selftest.md +32 -0
  49. package/dist/packages/mcp/assets/kb/app-help/coin-images.md +29 -0
  50. package/dist/packages/mcp/assets/kb/app-help/configure-rpc-key.md +28 -0
  51. package/dist/packages/mcp/assets/kb/app-help/connect-an-agent-registry.md +35 -0
  52. package/dist/packages/mcp/assets/kb/app-help/connect-an-agent.md +39 -0
  53. package/dist/packages/mcp/assets/kb/app-help/custom-keymap.md +32 -0
  54. package/dist/packages/mcp/assets/kb/app-help/edit-kb-or-skill.md +36 -0
  55. package/dist/packages/mcp/assets/kb/app-help/edit-rules.md +34 -0
  56. package/dist/packages/mcp/assets/kb/app-help/export-a-view.md +36 -0
  57. package/dist/packages/mcp/assets/kb/app-help/follow-a-wallet.md +33 -0
  58. package/dist/packages/mcp/assets/kb/app-help/getting-started.md +37 -0
  59. package/dist/packages/mcp/assets/kb/app-help/kol-lists.md +34 -0
  60. package/dist/packages/mcp/assets/kb/app-help/larp-check.md +36 -0
  61. package/dist/packages/mcp/assets/kb/app-help/link-a-wallet.md +41 -0
  62. package/dist/packages/mcp/assets/kb/app-help/login-with-x.md +33 -0
  63. package/dist/packages/mcp/assets/kb/app-help/narrative-board.md +32 -0
  64. package/dist/packages/mcp/assets/kb/app-help/open-a-coin.md +43 -0
  65. package/dist/packages/mcp/assets/kb/app-help/open-chart-popup.md +33 -0
  66. package/dist/packages/mcp/assets/kb/app-help/order-plans.md +33 -0
  67. package/dist/packages/mcp/assets/kb/app-help/paper-trade.md +36 -0
  68. package/dist/packages/mcp/assets/kb/app-help/price-or-marketcap.md +38 -0
  69. package/dist/packages/mcp/assets/kb/app-help/record-headless.md +34 -0
  70. package/dist/packages/mcp/assets/kb/app-help/recorder-history.md +39 -0
  71. package/dist/packages/mcp/assets/kb/app-help/rug-check.md +39 -0
  72. package/dist/packages/mcp/assets/kb/app-help/run-doctor.md +32 -0
  73. package/dist/packages/mcp/assets/kb/app-help/scan-mode.md +37 -0
  74. package/dist/packages/mcp/assets/kb/app-help/screen-analyst.md +181 -0
  75. package/dist/packages/mcp/assets/kb/app-help/screen-kol.md +190 -0
  76. package/dist/packages/mcp/assets/kb/app-help/screen-newpairs.md +181 -0
  77. package/dist/packages/mcp/assets/kb/app-help/screen-positions.md +180 -0
  78. package/dist/packages/mcp/assets/kb/app-help/screen-screener.md +199 -0
  79. package/dist/packages/mcp/assets/kb/app-help/screen-token.md +240 -0
  80. package/dist/packages/mcp/assets/kb/app-help/screen-trending.md +192 -0
  81. package/dist/packages/mcp/assets/kb/app-help/screen-watchlist.md +181 -0
  82. package/dist/packages/mcp/assets/kb/app-help/set-a-filter.md +36 -0
  83. package/dist/packages/mcp/assets/kb/app-help/setup-neural-voice.md +36 -0
  84. package/dist/packages/mcp/assets/kb/app-help/share-packs.md +34 -0
  85. package/dist/packages/mcp/assets/kb/app-help/sort-the-screener.md +34 -0
  86. package/dist/packages/mcp/assets/kb/app-help/spectate-an-agent.md +36 -0
  87. package/dist/packages/mcp/assets/kb/app-help/standing-mandates.md +33 -0
  88. package/dist/packages/mcp/assets/kb/app-help/switch-theme.md +42 -0
  89. package/dist/packages/mcp/assets/kb/app-help/turn-on-alerts.md +37 -0
  90. package/dist/packages/mcp/assets/kb/app-help/update-dexterm.md +30 -0
  91. package/dist/packages/mcp/assets/kb/app-help/use-presets.md +42 -0
  92. package/dist/packages/mcp/assets/kb/app-help/use-voice-mode.md +36 -0
  93. package/dist/packages/mcp/assets/kb/app-help/watch-a-coin.md +34 -0
  94. package/dist/packages/mcp/assets/kb/app-help/watch-headless.md +35 -0
  95. package/dist/packages/mcp/assets/kb/app-help/what-dexterm-shows-agents.md +31 -0
  96. package/dist/packages/mcp/assets/kb/app-help/workspaces.md +38 -0
  97. package/dist/packages/mcp/src/app-help.js +135 -0
  98. package/dist/packages/mcp/src/index.js +3 -0
  99. package/dist/packages/mcp/src/server.js +90 -3
  100. package/dist/packages/mcp/src/spectator-sink.js +72 -0
  101. package/dist/packages/packs/src/index.js +2 -0
  102. package/dist/packages/packs/src/skill-care.js +206 -0
  103. package/dist/packages/popup/src/pages/spectator.css +45 -0
  104. package/dist/packages/popup/src/pages/spectator.html +25 -0
  105. package/dist/packages/popup/src/pages/spectator.js +74 -0
  106. package/dist/packages/popup/src/selftest.js +19 -0
  107. package/dist/packages/popup/src/server.js +7 -1
  108. package/dist/packages/tui/src/keymap.js +10 -0
  109. package/dist/packages/voice/src/controller.js +42 -1
  110. package/dist/packages/voice/src/doctor.js +25 -8
  111. package/dist/packages/voice/src/engines.js +8 -1
  112. package/dist/packages/voice/src/index.js +3 -1
  113. package/dist/packages/voice/src/speakable.js +111 -0
  114. package/dist/packages/voice/src/tts/piper-setup.js +229 -0
  115. package/dist/packages/voice/src/tts/piper.js +309 -66
  116. package/dist/packages/voice/src/tts/say.js +3 -2
  117. package/dist/packages/voice/src/tts/voices.js +8 -5
  118. package/package.json +1 -1
@@ -0,0 +1,42 @@
1
+ ---
2
+ id: use-presets
3
+ title: Use screener presets
4
+ kind: app-help
5
+ screen: screener
6
+ feature: presets
7
+ tags:
8
+ - app-help
9
+ - preset
10
+ - presets
11
+ - trending
12
+ - runners
13
+ - organic
14
+ - graduating
15
+ - smart
16
+ keys:
17
+ - ]
18
+ - right
19
+ - l
20
+ - [
21
+ - left
22
+ - h
23
+ actions:
24
+ - preset.next
25
+ - preset.prev
26
+ flags:
27
+ - --preset
28
+ confidence: high
29
+ owner: maintainers
30
+ origin: app-help-generated
31
+ reviewed_by: generated@2026-10-16
32
+ generated_from: dexterm/app keymap + overlay + mcp tools + cli (task-1413)
33
+ sources:
34
+ - packages/tui/src/keymap.ts
35
+ - packages/cli/src/main.ts
36
+ - packages/mcp/src/server.ts
37
+ date: 2026-10-16
38
+ ---
39
+
40
+ Press `]` / `[` to step through presets (Trending, Runners, Organic; Graduating ships keyless as an `approx` mcap-band proxy; Smart money needs a key and says so). The analyst can switch the feed too. One-shot at launch: `--preset <name>`.
41
+
42
+ Keys: `] / → / l` (screener), `[ / ← / h` (screener).
@@ -0,0 +1,36 @@
1
+ ---
2
+ id: use-voice-mode
3
+ title: Use voice mode (Jarvis, push-to-talk)
4
+ kind: app-help
5
+ screen: all
6
+ feature: jarvis
7
+ tags:
8
+ - app-help
9
+ - voice
10
+ - jarvis
11
+ - talk
12
+ - mic
13
+ - microphone
14
+ - push
15
+ - listen
16
+ keys:
17
+ - v
18
+ actions:
19
+ - voice.talk
20
+ flags:
21
+ - --sound
22
+ confidence: high
23
+ owner: maintainers
24
+ origin: app-help-generated
25
+ reviewed_by: generated@2026-10-16
26
+ generated_from: dexterm/app keymap + overlay + mcp tools + cli (task-1413)
27
+ sources:
28
+ - packages/tui/src/keymap.ts
29
+ - packages/cli/src/main.ts
30
+ - packages/mcp/src/server.ts
31
+ date: 2026-10-16
32
+ ---
33
+
34
+ Press `v` to start push-to-talk: speak, press `v` again to send (a red ● LISTENING badge shows while the mic is live; it also auto-closes after 15 s). Instant commands ("show the runners", "open bonk", "filter liquidity over 50k") run locally; questions go to `claude`. Voice only PROPOSES trades — it can never confirm, sign, arm or raise a cap. macOS only; every voice action also has a key. `--sound on|off` sets the sound/voice output at launch.
35
+
36
+ Keys: `v`.
@@ -0,0 +1,34 @@
1
+ ---
2
+ id: watch-a-coin
3
+ title: Watch (or unwatch) a coin
4
+ kind: app-help
5
+ screen: all
6
+ feature: watchlist
7
+ tags:
8
+ - app-help
9
+ - watch
10
+ - watchlist
11
+ - follow
12
+ - track
13
+ - token
14
+ - tokens
15
+ - coins
16
+ keys:
17
+ - w
18
+ actions:
19
+ - watch.add
20
+ confidence: high
21
+ owner: maintainers
22
+ origin: app-help-generated
23
+ reviewed_by: generated@2026-10-16
24
+ generated_from: dexterm/app keymap + overlay + mcp tools + cli (task-1413)
25
+ sources:
26
+ - packages/tui/src/keymap.ts
27
+ - packages/cli/src/main.ts
28
+ - packages/mcp/src/server.ts
29
+ date: 2026-10-16
30
+ ---
31
+
32
+ Press `w` to watch/unwatch the highlighted coin (screener, new pairs, token screen). The watchlist is persisted and priced live. On the watchlist screen `d` removes a row.
33
+
34
+ Keys: `w` (screener).
@@ -0,0 +1,35 @@
1
+ ---
2
+ id: watch-headless
3
+ title: Run alerts in the background (dexterm watch)
4
+ kind: app-help
5
+ screen: all
6
+ feature: push-alerts
7
+ tags:
8
+ - app-help
9
+ - watch
10
+ - background
11
+ - headless
12
+ - push
13
+ - alerts
14
+ - notify
15
+ - daemon
16
+ - interval
17
+ commands:
18
+ - watch
19
+ flags:
20
+ - --interval
21
+ confidence: high
22
+ owner: maintainers
23
+ origin: app-help-generated
24
+ reviewed_by: generated@2026-10-16
25
+ generated_from: dexterm/app keymap + overlay + mcp tools + cli (task-1413)
26
+ sources:
27
+ - packages/tui/src/keymap.ts
28
+ - packages/cli/src/main.ts
29
+ - packages/mcp/src/server.ts
30
+ date: 2026-10-16
31
+ ---
32
+
33
+ `dexterm watch [--interval S] [--once|--ticks N] [--replay FILE]` runs the rules engine headless and PUSHES alerts to your enabled channels, so they reach you when the terminal is closed. It has no signer and can never trade. Set channels up first with `dexterm alerts`.
34
+
35
+ CLI: `dexterm watch`.
@@ -0,0 +1,31 @@
1
+ ---
2
+ id: what-dexterm-shows-agents
3
+ title: See what the user currently sees (app_state)
4
+ kind: app-help
5
+ screen: all
6
+ feature: mcp
7
+ tags:
8
+ - app-help
9
+ - state
10
+ - current
11
+ - screen
12
+ - context
13
+ - selected
14
+ - agent
15
+ - see
16
+ tools:
17
+ - app_state
18
+ - screen_state
19
+ confidence: high
20
+ owner: maintainers
21
+ origin: app-help-generated
22
+ reviewed_by: generated@2026-10-16
23
+ generated_from: dexterm/app keymap + overlay + mcp tools + cli (task-1413)
24
+ sources:
25
+ - packages/tui/src/keymap.ts
26
+ - packages/cli/src/main.ts
27
+ - packages/mcp/src/server.ts
28
+ date: 2026-10-16
29
+ ---
30
+
31
+ An agent can call the read-only `app_state` MCP tool to fit an answer to what the user sees: the current screen, the selected coin, the theme, price mode, voice name/rate, whether scan and calm are on, and which alert channels are configured (YES/NO only — never a token, webhook or key). `screen_state` adds the visible rows and the action allow-list.
@@ -0,0 +1,38 @@
1
+ ---
2
+ id: workspaces
3
+ title: Save and switch workspaces
4
+ kind: app-help
5
+ screen: all
6
+ feature: workspaces
7
+ tags:
8
+ - app-help
9
+ - workspace
10
+ - workspaces
11
+ - layout
12
+ - hud
13
+ - save
14
+ - morning
15
+ keys:
16
+ - ctrl+w s
17
+ actions:
18
+ - workspace.save
19
+ commands:
20
+ - workspace
21
+ flags:
22
+ - --workspace
23
+ - --screen
24
+ confidence: high
25
+ owner: maintainers
26
+ origin: app-help-generated
27
+ reviewed_by: generated@2026-10-16
28
+ generated_from: dexterm/app keymap + overlay + mcp tools + cli (task-1413)
29
+ sources:
30
+ - packages/tui/src/keymap.ts
31
+ - packages/cli/src/main.ts
32
+ - packages/mcp/src/server.ts
33
+ date: 2026-10-16
34
+ ---
35
+
36
+ A workspace saves a start screen, theme, intensity, screener preset/filter/sort, token panels and the HUD popups to open together. `ctrl+w` then `s` saves as; `w` lists; `n`/`N` cycle. `dexterm workspace list|show|remove|init` manages them. The analyst can open a saved workspace for you.
37
+
38
+ Keys: `^W S`. CLI: `dexterm workspace`.
@@ -0,0 +1,135 @@
1
+ // @dexterm/mcp — the app-help knowledge base (task-1413).
2
+ //
3
+ // A SECOND bundled KB set, separate from the 17 memecoin-risk entries, that teaches an agent how dexterm
4
+ // ITSELF works: what each screen shows, the exact key for a task, the CLI subcommand/flag, and the MCP
5
+ // tools. The entries in `assets/kb/app-help/*.md` are GENERATED from the app's own keymap / help overlay /
6
+ // MCP tool list / CLI by `packages/cli/src/app-help-gen.ts` (committed, run in tests), so they cannot drift
7
+ // from the real app. This module only LOADS and SEARCHES them — it is read-only and dependency-free.
8
+ //
9
+ // It is kept out of the main KB store on purpose: the memecoin KB's "exactly 17 bundled entries" invariant
10
+ // stays true, and a "how do I …" search hits app-help first without the two sets diluting each other.
11
+ import path from 'node:path';
12
+ import { fileURLToPath } from 'node:url';
13
+ import { loadBundled } from "./user-content.js";
14
+ const HERE = path.dirname(fileURLToPath(import.meta.url));
15
+ /** The shipped app-help KB directory (read-only; generated). */
16
+ export const APP_HELP_DIR = path.resolve(HERE, '..', 'assets', 'kb', 'app-help');
17
+ function list(v) {
18
+ return Array.isArray(v) ? v.map(String) : typeof v === 'string' && v ? [v] : [];
19
+ }
20
+ function toAppHelp(e) {
21
+ return {
22
+ id: e.id,
23
+ title: String(e.meta.title ?? e.id),
24
+ screen: String(e.meta.screen ?? 'all'),
25
+ tags: list(e.meta.tags),
26
+ keys: list(e.meta.keys),
27
+ actions: list(e.meta.actions),
28
+ commands: list(e.meta.commands),
29
+ flags: list(e.meta.flags),
30
+ tools: list(e.meta.tools),
31
+ feature: String(e.meta.feature ?? ''),
32
+ body: e.body,
33
+ bytes: e.bytes,
34
+ };
35
+ }
36
+ /** Load every app-help entry (bundled-only; deterministic order by id). */
37
+ export function loadAppHelp(dir = APP_HELP_DIR) {
38
+ const entries = loadBundled([{ dir, layout: 'flat' }]).map(toAppHelp);
39
+ entries.sort((a, b) => a.id.localeCompare(b.id));
40
+ return entries;
41
+ }
42
+ // Generic words that carry no retrieval signal in a "how do I …" question — dropped before scoring so a
43
+ // short noise word ('to', 'my') can't substring-match an unrelated entry and outrank the real one.
44
+ const STOP = new Set([
45
+ 'how', 'do', 'does', 'did', 'the', 'a', 'an', 'to', 'my', 'me', 'i', 'is', 'it', 'its', 'of', 'in', 'on',
46
+ 'at', 'by', 'or', 'and', 'for', 'with', 'this', 'that', 'these', 'those', 'your', 'you', 'can', 'what',
47
+ 'which', 'where', 'when', 'who', 'am', 'are', 'be', 'get', 'got', 'use', 'using', 'make', 'want', 'need',
48
+ 'from', 'into', 'show', 'see', 'tell', 'about', 'some', 'any', 'all', 'up', 'out', 'off', 'on',
49
+ // generic action verbs — they appear in many entry titles ("Change…", "Switch…") and carry no signal.
50
+ 'change', 'switch', 'set', 'setting', 'turn', 'open', 'close', 'enable', 'disable', 'add', 'remove',
51
+ 'start', 'stop', 'run', 'cycle', 'pick', 'choose', 'save', 'view', 'check',
52
+ ]);
53
+ function tokenise(s) {
54
+ return (s.toLowerCase().match(/[a-z0-9][a-z0-9-]+/g) ?? []).filter((t) => !STOP.has(t));
55
+ }
56
+ /** A short, deterministic how-to synonym map so natural phrasings land on the right entry. */
57
+ const QUERY_SYNONYMS = {
58
+ paste: 'open', ca: 'open', 'contract-address': 'open', address: 'open', link: 'open',
59
+ screenshot: 'export', save: 'export', png: 'export', report: 'export', share: 'export',
60
+ speed: 'rate', faster: 'rate', slower: 'rate', wpm: 'rate',
61
+ speak: 'voice', talk: 'voice', jarvis: 'voice', mic: 'voice', microphone: 'voice',
62
+ notify: 'alert', notification: 'alerts', telegram: 'alerts', discord: 'alerts',
63
+ filtering: 'filter', query: 'filter',
64
+ marketcap: 'mcap', 'market-cap': 'mcap', cap: 'mcap',
65
+ honeypot: 'rug', safe: 'rug', scam: 'rug',
66
+ fake: 'larp', legit: 'larp', real: 'larp', website: 'larp', 'rug-pull': 'rug',
67
+ agent: 'mcp', agents: 'mcp', bot: 'mcp', claude: 'analyst',
68
+ helius: 'key', rpc: 'key', holders: 'key',
69
+ layout: 'workspace', workspaces: 'workspace',
70
+ keybind: 'keymap', keybinding: 'keymap', rebind: 'keymap', shortcut: 'keymap',
71
+ theme: 'theme', colour: 'theme', color: 'theme',
72
+ buy: 'paper', sell: 'paper', trade: 'paper', ticket: 'paper',
73
+ upgrade: 'update',
74
+ chart: 'popup', candles: 'popup',
75
+ bubbles: 'bubble', cluster: 'bubble', clusters: 'bubble',
76
+ scanner: 'scan', watcher: 'scan',
77
+ copy: 'follow', mirror: 'follow', unfollow: 'follow',
78
+ };
79
+ function expand(terms) {
80
+ const out = new Set(terms);
81
+ for (const t of terms) {
82
+ const s = QUERY_SYNONYMS[t];
83
+ if (s)
84
+ out.add(s);
85
+ }
86
+ return [...out];
87
+ }
88
+ /** Raw word tokens of a haystack (no stopword filtering), for exact word-boundary matching. */
89
+ function words(s) {
90
+ return s.toLowerCase().match(/[a-z0-9][a-z0-9-]+/g) ?? [];
91
+ }
92
+ /**
93
+ * Deterministic keyword retrieval over the app-help set (no model). Matches on WORD BOUNDARIES (not
94
+ * substrings) so "screener" does not match the tag "dexscreener" and "token" does not match a tool name
95
+ * like "open_token". title/tags/screen/feature score strongest; the body is the weak tail.
96
+ */
97
+ export function searchAppHelp(query, limit = 5, entries = loadAppHelp()) {
98
+ const terms = expand(tokenise(query));
99
+ // A query whose only meaningful word is a screen name ("what does the screener show") is a request for
100
+ // that screen's overview, not for a topic that happens to run there.
101
+ const soleScreen = terms.length === 1 ? terms[0] : null;
102
+ // An explicit "... screen ..." question ("what does the kol screen show") is a request for that screen's
103
+ // overview even when other words survive; boost the matching overview so it beats a topic that shares the name.
104
+ const asksScreen = words(query).includes('screen');
105
+ const scored = entries.map((e) => {
106
+ const overview = e.id.startsWith('screen-');
107
+ // Screen field matches only for an overview entry; on a topic it is just where the action happens.
108
+ const strong = new Set(words(`${e.title} ${e.tags.join(' ')} ${e.feature}${overview ? ' ' + e.screen : ''}`));
109
+ // An overview's body is the enumerated key list — it names every action word, so it is NOT scored
110
+ // (else "sort the screener" would match the screener overview's `s — sort` line over the sort topic).
111
+ const bodyWords = overview ? [] : words(e.body);
112
+ let score = 0;
113
+ for (const t of terms) {
114
+ if (strong.has(t))
115
+ score += 4;
116
+ let n = 0;
117
+ for (const w of bodyWords)
118
+ if (w === t)
119
+ n++;
120
+ score += Math.min(n, 3);
121
+ }
122
+ if (overview && soleScreen && soleScreen === e.screen)
123
+ score += 6;
124
+ if (overview && asksScreen && terms.includes(e.screen))
125
+ score += 3;
126
+ return { e, score };
127
+ }).filter((x) => x.score > 0)
128
+ .sort((a, b) => (b.score - a.score) || a.e.id.localeCompare(b.e.id))
129
+ .slice(0, limit);
130
+ return scored.map(({ e, score }) => ({ ...e, score }));
131
+ }
132
+ /** Fetch one app-help entry by id. */
133
+ export function getAppHelp(id, entries = loadAppHelp()) {
134
+ return entries.find((e) => e.id === id) ?? null;
135
+ }
@@ -4,6 +4,9 @@
4
4
  export { runStdioServer, selfTest, McpTools, TOOLS, READ_ONLY_TOOLS, firewall, listPrompts, getPrompt, resourceList, resourceRead, overlayCounts, userSkillPreamble, BUNDLED_KB_DIR, BUNDLED_SKILLS_DIR } from "./server.js";
5
5
  export { OverlayStore, mergeOverlay, loadBundled, checkKb, checkSkill, moneyToolMentions, isMoneyToolName, parseFrontmatter, dextermHome, userKbDir, userSkillsDir, userDir, contentJournalPath, journalContent, writeOverlayFile, resetOverlayFile, templateFor, KB_LIMITS, SKILL_LIMITS, KB_ID, SKILL_NAME, KB_RULE, MONEY_TOOLS, } from "./user-content.js";
6
6
  export { buildDossier } from "./dossier.js";
7
+ // task-1406: the spectator sink the tool-call path writes to when launched with a spectator channel.
8
+ export { recordForToolCall, maxAgeSec, fileSpectatorSinkFromEnv } from "./spectator-sink.js";
9
+ export { loadAppHelp, searchAppHelp, getAppHelp, APP_HELP_DIR } from "./app-help.js";
7
10
  /** Tool names served in v1 (SPEC §5.2 core + the task-1293 KB/case tools + the task-1314 dossier). */
8
11
  export const PLANNED_TOOLS = [
9
12
  'screen_state',
@@ -21,6 +21,8 @@ import { createDataLayer, resolveRpcUrl, redactSecrets, defaultDbPath, replayTra
21
21
  import { buildDossier } from "./dossier.js";
22
22
  import { firewall } from "./firewall.js";
23
23
  import { OverlayStore, dextermHome, KB_RULE } from "./user-content.js";
24
+ import { fileSpectatorSinkFromEnv, recordForToolCall } from "./spectator-sink.js";
25
+ import { loadAppHelp, searchAppHelp, getAppHelp } from "./app-help.js";
24
26
  import { assembleTokenDossier, computeBoard, recentNarrativeRows, loadDefaultLexicon, summaryText, buildDigest, tokenRugScorer, h1Model, runBacktest } from '../../packs/src/index.js';
25
27
  import { exportRecorded, openHistoryReadOnly } from '../../recorder/src/index.js';
26
28
  // The default rug-probability scorer (task-1356 Tier 4). H1 is the PRE-REGISTERED heuristic; it is the
@@ -94,6 +96,16 @@ function kbSearch(q, limit = 5) {
94
96
  return scored.map(({ e, score }) => ({ ...kbView(e, { full: false }), score }));
95
97
  }
96
98
  // ---------------------------------------------------------------------------
99
+ // app-help KB (task-1413): a separate bundled set generated from the app's own keymap/overlay/tools/CLI
100
+ // (packages/mcp/assets/kb/app-help/*.md). It teaches "how dexterm works" with the exact key/command; it
101
+ // is first-party doc text (not firewalled) and carries structured keys/commands/flags/tools per entry.
102
+ function appHelpView(e) {
103
+ return {
104
+ id: e.id, title: e.title, screen: e.screen, feature: e.feature || null, tags: e.tags,
105
+ keys: e.keys, commands: e.commands, flags: e.flags, tools: e.tools, text: e.body, origin: 'app-help',
106
+ };
107
+ }
108
+ // ---------------------------------------------------------------------------
97
109
  // Case files: assets/cases.json (format in research/claude-layer/cases/FORMAT.md). Read-only.
98
110
  const CASES_FILE = path.join(ASSETS, 'cases.json');
99
111
  const CASES = fs.existsSync(CASES_FILE)
@@ -203,10 +215,27 @@ export const TOOLS = [
203
215
  // tokens currently on screen (screen_state.actions) and applied by the running app, which shows
204
216
  // "analyst did X". None can size, confirm, sign, or send a trade.
205
217
  { name: 'open_token', description: "Open a token's detail screen in dexterm so the user can see it. `mint` must be one of the mints currently on screen (see screen_state). Use for \"put this/that coin on my screen\", \"show me $X\". Non-financial navigation; it never trades.", inputSchema: { type: 'object', properties: { mint: { type: 'string', description: 'base58 mint, must be on screen' } }, required: ['mint'], additionalProperties: false } },
206
- { name: 'show_in_screener', description: 'Show the screener with an optional filter, sort, and a highlighted mint. Use for "rank these by volume", "filter to liq > 50k", "coins under 5M mcap". `filter` is dexterm\'s grammar: space-separated `field op value` clauses ANDed, e.g. `mcap < 5M liq > 100K h24 > 20`. Fields: vol24 vol6h vol1h vol5m liq mcap fdv price age holders buys sells org top10 dev lplocked bundled snipers m5 h1 h6 h24. Ops > >= < <= = !=. Money K/M/B; percents plain; age needs a unit (6h, 30m). Tags: launchpad:pump|dbc|raydium|meteora|bonk, flag:mint|freeze|top10|dev|bundle|lp|clean (negate with !, e.g. !flag:mint), verified:yes, sus:no, chain:solana. Invalid fields are rejected — only use the ones listed. `sort.key` must be one of screen_state.actions.sortKeys; `highlight` must be a mint on screen. When you build a filter from a plain-language request, also return `filter_applied` in your structured output.', inputSchema: { type: 'object', properties: { filter: { type: 'string' }, sort: { type: 'object', properties: { key: { type: 'string' }, dir: { type: 'string', enum: ['asc', 'desc'] } }, required: ['key'], additionalProperties: false }, highlight: { type: 'string' } }, additionalProperties: false } },
218
+ { name: 'show_in_screener', description: 'Show the screener with an optional filter, sort, and a highlighted mint. Use for "rank these by volume", "filter to liq > 50k", "coins under 5M mcap". `filter` is dexterm\'s grammar: space-separated `field op value` clauses ANDed, e.g. `mcap < 5M liq > 100K h24 > 20`. Fields: vol24 vol6h vol1h vol5m liq mcap fdv price age holders buys sells org top10 dev lplocked bundled snipers m5 h1 h6 h24. Ops > >= < <= = !=. Money K/M/B; percents plain; age needs a unit (6h, 30m). Tags: launchpad:pump|dbc|raydium|meteora|bonk, flag:mint|freeze|top10|dev|bundle|lp|clean (negate with !, e.g. !flag:mint), verified:yes, sus:no, chain:solana. Invalid fields are rejected — only use the ones listed. `sort.key` must be one of screen_state.actions.sortKeys; `highlight` must be a mint on screen. `preset`, when given, must be one of screen_state.actions.feeds. When you build a filter from a plain-language request, also return `filter_applied` in your structured output.', inputSchema: { type: 'object', properties: { filter: { type: 'string' }, sort: { type: 'object', properties: { key: { type: 'string' }, dir: { type: 'string', enum: ['asc', 'desc'] } }, required: ['key'], additionalProperties: false }, highlight: { type: 'string' }, preset: { type: 'string' } }, additionalProperties: false } },
207
219
  { name: 'add_to_watchlist', description: 'Add a token to the user\'s watchlist. `mint` must be one of the mints currently on screen. Non-financial.', inputSchema: { type: 'object', properties: { mint: { type: 'string' } }, required: ['mint'], additionalProperties: false } },
208
220
  { name: 'switch_feed', description: 'Switch the screener feed/preset. `feed` must be one of screen_state.actions.feeds.', inputSchema: { type: 'object', properties: { feed: { type: 'string' } }, required: ['feed'], additionalProperties: false } },
209
221
  { name: 'open_ticket', description: 'Open the PAPER trade ticket pre-filled for a mint and side. It ONLY opens the ticket (editing phase); it never sizes, confirms, signs, or sends — the user confirms every trade themselves. `mint` must be on screen; `side` is "buy" or "sell".', inputSchema: { type: 'object', properties: { mint: { type: 'string' }, side: { type: 'string', enum: ['buy', 'sell'] } }, required: ['mint', 'side'], additionalProperties: false } },
222
+ // ---- app-help + app-state (task-1413). Read-only: how the app works, and what the user currently sees.
223
+ { name: 'app_help', description: 'Search the APP-HELP knowledge base: how dexterm itself works (what a screen shows, the exact key for a task, the CLI command, the MCP tools). For any "how do I …", "what key …", "what does this screen show" question, call this FIRST and answer with the exact key or command from the result — NEVER invent a key. If nothing matches, say "I don\'t see that in the app." Pass `query` to search, or `id` to fetch one entry. Each result carries structured `keys`, `commands`, `flags`, `tools` and the screen it is about.', inputSchema: { type: 'object', properties: { query: { type: 'string' }, id: { type: 'string' }, limit: { type: 'integer', minimum: 1, maximum: 10 } }, additionalProperties: false } },
224
+ { name: 'app_state', description: 'Read-only snapshot of what the user currently sees so an answer fits their screen: current screen, selected coin (mint+symbol), theme, price display mode, voice name/rate, whether scan and calm are on, and which alert channels are CONFIGURED (yes/no only). It never returns a key, token, webhook, secret or any credential. Use it to tailor a "how do I" answer to the user\'s actual state.', inputSchema: { type: 'object', properties: {}, additionalProperties: false } },
225
+ // ---- more UI actions (task-1413). Tiered, non-financial. `view`: applied immediately with an "analyst did X"
226
+ // note. `config`: a one-line PROPOSAL the user accepts with a keypress, then written to config.json as actor
227
+ // 'analyst' (undo with ctrl+z). NONE can touch wallets/keys/alerts-secrets/signing/caps/network/software.
228
+ { name: 'switch_screen', description: 'Switch to a dexterm screen (view-only). `screen` must be one of screen_state.actions.screens.', inputSchema: { type: 'object', properties: { screen: { type: 'string' } }, required: ['screen'], additionalProperties: false } },
229
+ { name: 'switch_workspace', description: 'Open a saved workspace layout (view-only). `name` must be one of screen_state.actions.workspaces.', inputSchema: { type: 'object', properties: { name: { type: 'string' } }, required: ['name'], additionalProperties: false } },
230
+ { name: 'chart_popup', description: 'Open or close the chart popup window (view-only). `open`: true to open, false to close.', inputSchema: { type: 'object', properties: { open: { type: 'boolean' } }, required: ['open'], additionalProperties: false } },
231
+ { name: 'toggle_calm', description: 'Turn calm mode (effects off) on or off (view-only). `on`: true for calm, false to restore effects.', inputSchema: { type: 'object', properties: { on: { type: 'boolean' } }, required: ['on'], additionalProperties: false } },
232
+ { name: 'set_scan', description: 'Turn the observe-only AI scan mode on or off (view-only). `on`: true/false.', inputSchema: { type: 'object', properties: { on: { type: 'boolean' } }, required: ['on'], additionalProperties: false } },
233
+ { name: 'export_view', description: 'Export the current view to ~/.dexterm/exports (PNG + text report; view-only, nothing uploaded).', inputSchema: { type: 'object', properties: {}, additionalProperties: false } },
234
+ { name: 'set_theme', description: 'PROPOSE a theme change the user confirms with a keypress (persisted, undoable). `name` must be one of screen_state.actions.themes.', inputSchema: { type: 'object', properties: { name: { type: 'string' } }, required: ['name'], additionalProperties: false } },
235
+ { name: 'set_price_mode', description: 'PROPOSE the price display mode the user confirms with a keypress (persisted, undoable). `mode`: "price" or "mcap".', inputSchema: { type: 'object', properties: { mode: { type: 'string', enum: ['price', 'mcap'] } }, required: ['mode'], additionalProperties: false } },
236
+ { name: 'set_intensity', description: 'PROPOSE the visual intensity the user confirms with a keypress (persisted, undoable). `intensity`: "off", "normal" or "fever".', inputSchema: { type: 'object', properties: { intensity: { type: 'string', enum: ['off', 'normal', 'fever'] } }, required: ['intensity'], additionalProperties: false } },
237
+ // task-1413 r2: voice speed/name are NOT analyst actions. The `/voice` config path is DENIED_FOR_MODELS —
238
+ // only the keyboard (`<`/`>`, the voice picker) sets it. There is deliberately no set_voice_* tool here.
210
239
  ];
211
240
  /** The read-only tool surface: every tool except the UI-action ones (task-1313). The only tools a skill may name (task-1377). */
212
241
  export const READ_ONLY_TOOLS = TOOLS.map((t) => String(t.name)).filter((n) => !ANALYST_ACTION_TYPES.includes(n));
@@ -215,7 +244,11 @@ const SKILL_STORE = new OverlayStore({ kind: 'skill', bundled: [{ dir: SKILLS_DI
215
244
  function allowFrom(screenState) {
216
245
  const a = (screenState.actions ?? {});
217
246
  const list = (x) => Array.isArray(x) ? x.filter((v) => typeof v === 'string') : [];
218
- const allow = { mints: list(a.mints), feeds: list(a.feeds), sortKeys: list(a.sortKeys) };
247
+ const allow = {
248
+ mints: list(a.mints), feeds: list(a.feeds), sortKeys: list(a.sortKeys),
249
+ // task-1413: screens/workspaces/themes an action may reference (empty/absent fails closed).
250
+ screens: list(a.screens), workspaces: list(a.workspaces), themes: list(a.themes),
251
+ };
219
252
  // task-1324: a session-level action-type list (AI scan mode sends []) narrows what this server will
220
253
  // write to the channel. Present-but-malformed fails closed (no types allowed).
221
254
  if (a.types !== undefined)
@@ -279,6 +312,39 @@ export class McpTools {
279
312
  }
280
313
  return { ok: true, requested: res.label, note: 'The app applies this and shows "analyst did X". You cannot confirm, size, or send a trade.' };
281
314
  }
315
+ /**
316
+ * task-1413: a read-only view of what the user currently sees. It only reflects the fields the CLI put in
317
+ * screen_state (screen, selected coin, and the `app` block of theme/priceMode/voice/scan/calm/alerts). The
318
+ * `alerts` map is booleans (configured yes/no); by construction this method never reads or returns a token,
319
+ * webhook, key or any secret. Degrades to `available:false` when there is no running app.
320
+ */
321
+ appState() {
322
+ const s = this.screenState();
323
+ const app = (s.app && typeof s.app === 'object') ? s.app : null;
324
+ const sel = (s.selected && typeof s.selected === 'object') ? s.selected : null;
325
+ // task-1413 residual: the selected symbol is an attacker-chosen token string (a coin can be named
326
+ // anything), so it is firewalled before it leaves in the snapshot an agent reads — exactly like the
327
+ // Jupiter symbol at tokenView(). The mint is a base58 address and is safe verbatim.
328
+ const selected = sel && typeof sel.mint === 'string'
329
+ ? { mint: sel.mint, symbol: typeof sel.symbol === 'string' ? (firewall(sel.symbol, 'app:selected:symbol', 'symbol', { keepAddresses: false }) ?? '') : '' }
330
+ : null;
331
+ if (!app) {
332
+ return { available: false, screen: s.screen ?? 'unknown', selected, note: 'no running dexterm app; launch it for live state. Never returns any secret.' };
333
+ }
334
+ return {
335
+ available: true,
336
+ screen: s.screen ?? 'unknown',
337
+ selected,
338
+ theme: app.theme ?? null,
339
+ priceMode: app.priceMode ?? null,
340
+ intensity: app.intensity ?? null,
341
+ calm: typeof app.calm === 'boolean' ? app.calm : null,
342
+ voice: app.voice ?? null,
343
+ scan: app.scan ?? null,
344
+ alerts: app.alerts ?? null, // { toast, desktop, telegram, discord } — booleans only, never a secret
345
+ note: 'Read-only. alerts shows whether each channel is configured (yes/no); it never reveals a token, webhook or key.',
346
+ };
347
+ }
282
348
  /** Resolve a mint or symbol to one enriched row, or return candidates/error. */
283
349
  async resolve(ref) {
284
350
  if (!ref || typeof ref !== 'string')
@@ -649,6 +715,20 @@ export class McpTools {
649
715
  const c = CASES.find((x) => x.id === args.id);
650
716
  return c ?? { error: 'no such case' };
651
717
  }
718
+ case 'app_help': {
719
+ // task-1413: how dexterm itself works. Generated from the keymap/overlay/tools/CLI — the exact key
720
+ // or command for a task. Fetch one by id, or search; never a fact about a live token.
721
+ if (args.id) {
722
+ const e = getAppHelp(String(args.id));
723
+ if (!e)
724
+ return { error: `no app-help entry ${String(args.id).slice(0, 64)}`, available: loadAppHelp().map((x) => x.id) };
725
+ return { ...appHelpView(e), rule: 'app-help explains how dexterm works. Answer with its exact key/command; never invent one.' };
726
+ }
727
+ const results = searchAppHelp(String(args.query ?? ''), Number(args.limit ?? 5)).map((e) => ({ ...appHelpView(e), score: e.score }));
728
+ return { query: String(args.query ?? '').slice(0, 200), results, rule: 'If nothing matches, tell the user "I don\'t see that in the app." Never invent a key or command.' };
729
+ }
730
+ case 'app_state':
731
+ return this.appState();
652
732
  case 'get_links': {
653
733
  const r = await this.linksFor(args.mint ?? args.symbol);
654
734
  if ('error' in r)
@@ -837,6 +917,10 @@ export async function runStdioServer(opts = {}) {
837
917
  ? { token: channelToken, append: (line) => fs.appendFileSync(channelFile, line, { mode: 0o600 }) }
838
918
  : null;
839
919
  const tools = new McpTools(data, screenStateFromEnv, channel, dbPathForHistory);
920
+ // task-1406: when the running dexterm launched us with a spectator channel, every tool call is emitted
921
+ // as a SpectatorEvent-shaped JSONL line the TUI tails into its hub (where redaction + the stream live).
922
+ const spectator = fileSpectatorSinkFromEnv(process.env);
923
+ let specSeq = 0;
840
924
  function appendTrace(rec) {
841
925
  if (TRACE) {
842
926
  try {
@@ -867,7 +951,10 @@ export async function runStdioServer(opts = {}) {
867
951
  result = { error: err(e) };
868
952
  }
869
953
  const text = JSON.stringify(result);
870
- appendTrace({ t: Date.now(), tool: name, args, ms: Date.now() - t0, bytes: Buffer.byteLength(text), isError: Boolean(result.error) });
954
+ const ms = Date.now() - t0;
955
+ appendTrace({ t: Date.now(), tool: name, args, ms, bytes: Buffer.byteLength(text), isError: Boolean(result.error) });
956
+ if (spectator)
957
+ spectator.sink.record(recordForToolCall({ seq: ++specSeq, agent: spectator.agent, tool: name, args, result, ms, token: spectator.token }));
871
958
  return reply({ content: [{ type: 'text', text }], isError: false });
872
959
  }
873
960
  case 'resources/list': return reply({ resources: resourceList() });
@@ -0,0 +1,72 @@
1
+ // @dexterm/mcp — spectator sink for the MCP tool-call path (task-1406, "watch the agent cook").
2
+ //
3
+ // The MCP server runs as a separate stdio process spawned by the user's agent. When the running dexterm
4
+ // launches it with DEXTERM_SPECTATOR_FILE (an append-only local channel, 0600, like the task-1313 action
5
+ // channel) it instruments every tools/call: one JSONL record in the @dexterm/agents SpectatorEvent v1
6
+ // shape is appended, which the TUI tails into its SpectatorHub (where redaction + the stream happen).
7
+ // The record carries NOTHING an agent could act on — it only describes a read/navigation call that
8
+ // already completed. The file is local and token-marked; raw addresses live only on this loopback channel
9
+ // and are redacted before anything leaves the machine.
10
+ import { appendFileSync } from 'node:fs';
11
+ /** The UI-action tools that move the screen (so follow mode can visibly perform them). */
12
+ const NAV_TOOLS = new Set(['open_token', 'show_in_screener', 'switch_feed', 'add_to_watchlist', 'open_ticket']);
13
+ function navFor(tool, args) {
14
+ const s = (v) => (typeof v === 'string' ? v : undefined);
15
+ if (tool === 'open_token')
16
+ return { screen: 'token', mint: s(args.mint) };
17
+ if (tool === 'switch_feed')
18
+ return { screen: 'screener', feed: s(args.feed) };
19
+ if (tool === 'show_in_screener')
20
+ return { screen: 'screener', filter: s(args.filter), highlight: s(args.highlight) };
21
+ if (tool === 'add_to_watchlist')
22
+ return { screen: 'watchlist', mint: s(args.mint) };
23
+ if (tool === 'open_ticket')
24
+ return { screen: 'ticket', mint: s(args.mint), side: s(args.side) };
25
+ return null;
26
+ }
27
+ /** Largest `ageSec` anywhere in a tool result (the data freshness the activity panel shows). */
28
+ export function maxAgeSec(result, depth = 0) {
29
+ if (depth > 6 || !result || typeof result !== 'object')
30
+ return null;
31
+ let max = null;
32
+ for (const [k, v] of Object.entries(result)) {
33
+ if (k === 'ageSec' && typeof v === 'number' && Number.isFinite(v) && v >= 0)
34
+ max = max === null ? v : Math.max(max, v);
35
+ else {
36
+ const inner = maxAgeSec(v, depth + 1);
37
+ if (inner !== null)
38
+ max = max === null ? inner : Math.max(max, inner);
39
+ }
40
+ }
41
+ return max;
42
+ }
43
+ function shortMint(args) {
44
+ const m = typeof args.mint === 'string' ? args.mint : typeof args.symbol === 'string' ? args.symbol : '';
45
+ return m ? ` ${m.length > 10 ? m.slice(0, 6) + '…' : m}` : '';
46
+ }
47
+ /** Build one spectator record for a completed MCP tool call. */
48
+ export function recordForToolCall(opts) {
49
+ const isErr = typeof opts.result.error === 'string';
50
+ const nav = navFor(opts.tool, opts.args);
51
+ return {
52
+ v: 1, seq: opts.seq, t: (opts.now ?? Date.now)(), phase: nav ? 'nav' : 'result',
53
+ agent: opts.agent, transport: 'mcp', tool: opts.tool,
54
+ summary: isErr ? `error: ${String(opts.result.error).slice(0, 80)}` : `${opts.tool}${shortMint(opts.args)}`,
55
+ ms: opts.ms, dataAgeSec: isErr ? null : maxAgeSec(opts.result), nav, ok: !isErr,
56
+ ...(opts.token ? { token: opts.token } : {}),
57
+ };
58
+ }
59
+ export function fileSpectatorSinkFromEnv(env) {
60
+ const file = env.DEXTERM_SPECTATOR_FILE;
61
+ if (!file)
62
+ return null;
63
+ const token = env.DEXTERM_SPECTATOR_TOKEN || undefined;
64
+ const agent = env.DEXTERM_SPECTATOR_AGENT || 'mcp-agent';
65
+ const sink = {
66
+ record(rec) { try {
67
+ appendFileSync(file, JSON.stringify(rec) + '\n', { mode: 0o600 });
68
+ }
69
+ catch { /* best-effort local channel */ } },
70
+ };
71
+ return { sink, agent, token };
72
+ }
@@ -18,3 +18,5 @@ export * from "./backtest.js";
18
18
  // task-1359: LARP eval (recorded product verdicts vs outcome labels; counts only below n = 50).
19
19
  export * from "./larp-eval.js";
20
20
  export * from "./skill-backtest.js";
21
+ // task-1414: skill care — rolling split, the proposal gate (new-coins + interval-noise + frozen canary), trend.
22
+ export * from "./skill-care.js";