feat(highlight): preset overhaul, categories, stats, theme colours, per-host profiles

Rules & engine:
- 22 presets (was 11): split status into okstate/warnstate/badstate, add delop,
  createop, danger, secret, level, exitcode, percent, http; status words are
  case-insensitive and cover the ✓ ✔ ✅ ✗ ✘ ✖ ❌ ⚠ symbol set
- value bands: the first number in a match picks the colour
  (percent: <20% red / 20-50% yellow / 50-80% light green / >=80% green)
- optional per-rule `caseInsensitive`, `category`, `bands`; load-time
  `refreshBuiltinRules` upgrades untouched built-in patterns in place

Settings page:
- three-way master switch `highlightMode` (all / basic / off); `basic` runs only
  the five safety+status rules and `off` empties the rule set rather than
  bypassing HighlightStream (which would drop the held tail)
- category column + grouping (`highlightGroupByCategory`), per-rule hit/duration
  stats (`highlightStats`, opt-in sink, snapshot once a second), theme-following
  colours (`highlightThemeColors`, hue-bucket mapping onto the ANSI palette),
  import/export JSON envelope, live preview through the real engine
- named rule subsets bound per host (`highlightPerHost` + `highlightProfiles`
  + `SshConnection.highlightProfileId`); empty ruleIds = every rule

Tests: new tests/hl-rules.mjs (word boundaries, case flag, negative words,
bands, import/export, preview, basic mode, categories, stats, theme colours,
profiles) + profile round-trip in tests/settings-store.mjs
This commit is contained in:
Bill committed 2026-09-23 11:14:31 +08:00
1 parent 41b1cb1b25
commit e08e1cfec4
39 files changed
+3164 -89

No files matched your search

+1 -1
View File
@@ -26,7 +26,7 @@ npm test # 重建测试 bundle 后依次跑离线测试(详见「测
- 剪贴板(Ctrl+Shift+C/V、可选选中即复制)
- 粘贴风险确认(多行/长文本需手动确认,可关闭)
- 字体/字号/字重/字距/行高/回滚行数/光标样式实时生效
- 关键词高亮:11 条内置规则(权限、路径、错误状态、IP、URL 等),支持自定义正则规则
- 关键词高亮:22 条内置规则(权限、密钥泄露提醒、路径、危险命令、删除/新建操作、成功/警告/错误状态、日志级别、root 提示符、退出码、HTTP 状态码、耗时、百分比进度、IP、URL 等),状态类词不分大小写并覆盖 ✓/✗ 等状态符号,百分比 / 退出码 / HTTP 状态码 / 耗时按数值分级取色;规则支持自定义正则、「忽略大小写」与「数值分级」开关,可导入 / 导出 JSON 分享,编辑器内带测试文本实时预览,高亮模式三档(全部 / 仅基础 / 关闭,基础档只跑错误/成功/警告/危险命令/密钥等关键规则),规则可按分类(安全/状态/文件/网络/文本/数值)分组查看,可开启「命中/耗时」统计(默认关,关闭时零开销),可让高亮颜色跟随终端主题调色板,可新建规则集并按主机绑定(默认关,未绑定的主机跑全部规则)
**SSH 远程会话**
- ssh2 实现:密码 / 私钥(文件路径或粘贴内容)/ SSH Agent 三种认证