feat(changes): secret redaction layer for op previews

The changes-tab op previews replay read/write/edit payloads into the DOM
(diff rows, read rows, markdown reading mode, error text) — when the model
reads a credentials file, that plaintext must not land on screen or in
inspectable DOM. New display-only redaction layer, on by default with a
one-click pane toggle (persisted in localStorage):

- path layer: credential-shaped filenames (.env / *secret* / *credential* /
  *token* / *api-key* / private keys...) mask whole files line-wise
- content layer: ordinary files mask only secret-shaped spans — secret
  field assignments keep the field name (api_key: [REDACTED]), plus bare
  token prefixes (sk- / AKIA / ghp_ / xox / ya29.), Bearer headers, and
  PEM private-key block headers
- redacted payloads flow through the same viewOp shape into diff rows,
  read rows, markdown reading mode, and error text

Known edge (documented in README): an unquoted mermaid node label
containing a redacted secret breaks the diagram and falls back to source;
workaround is quoting the label. Session data is untouched — this is
display-only and not a boundary against same-context malicious plugins.

Locales: zh/en dictionaries + all 19 shipped third-language overrides
(key-set-equal gate green). 9 new unit tests; typecheck clean; targeted
suites 40/40 green. The fs-operations failure is pre-existing on the base
branch (environment-dependent, verified via stash) and unrelated.
This commit is contained in:
lhh010 committed 2026-09-04 13:10:21 +08:00
1 parent 2eb9f66ce8
commit a2d3faf7b5
26 files changed
+349 -4

No files matched your search

+10
View File
@@ -32,6 +32,11 @@ export const zh = {
changesEdit: '编辑',
changesRunning: '执行中',
changesError: '出错',
changesRedactOn: '已开启脱敏:敏感内容以 [REDACTED] 显示;点击关闭(自担风险)',
changesRedactOff: '脱敏已关闭:将原样显示文件内容;点击开启',
changesRedactOnLabel: '脱敏中',
changesRedactOffLabel: '脱敏关',
changesRedactBanner: '已脱敏',
changesFold: '{count} 行…点击展开',
changesContext: '上下文',
changesPriorUnknown: '变更前的内容不在窗口内,显示为全新增',
@@ -443,6 +448,11 @@ export const en: Record<keyof typeof zh, string> = {
changesEdit: 'Edit',
changesRunning: 'running',
changesError: 'error',
changesRedactOn: 'Redaction on: secrets render as [REDACTED]; click to disable (at your own risk)',
changesRedactOff: 'Redaction off: file content renders verbatim; click to enable',
changesRedactOnLabel: 'Redacting',
changesRedactOffLabel: 'Redaction off',
changesRedactBanner: 'Redacted',
changesFold: '{count} lines…click to expand',
changesContext: 'context',
changesPriorUnknown: 'Prior content is outside the loaded window; shown as all-added',