bookworm-smart-assistant/docs/R1-R5-patch-inventory.md
Bookworm Admin b7a8e29d21 release: v6.7.0 - OTA E2E test release
- VERSION file as authoritative version source
- export.mjs reads VERSION with package.json fallback
- bw-ota.ps1 DryRun mode for safe testing
- auto-setup.ps1 bumped to v3.2.0 (Phase 8 OTA)
2026-04-27 17:59:44 +08:00

90 lines
4.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# R1-R5 上下文管理增强 · 补丁清单 (权威)
> 修订日期: 2026-04-26
> 用途: 修正冷审查任务背景中"14 个补丁"的不准确陈述, 提供权威总账
## 修订说明
冷审查任务原文表述:
> "所有 .bak 备份位于原文件同目录, 时间戳 ≈ 1777135xxx-1777136xxx; ... 重跑全部 14 个补丁脚本"
**实际数量为 11 个** (R1×1 + R2×1 + R3×3 + R4×3 + R5×3), 后续修复阶段又新增 6 个, 当前权威总数 **17 个**
## 完整补丁清单 (按时间序)
### 第一阶段 · 上线交付 (2026-04-26 0:30-1:05) · 11 个
| # | 补丁名 | 维度 | 用途 |
|---|--------|-----|------|
| 1 | patch-r1-batch-checkpoint-rule.js | R1 | 在 CLAUDE.md 注入"批量任务切片"规则 |
| 2 | patch-r2-precompact-tier-output.js | R2 | 改造 pre-compact-handoff.js 加入 TOOL_OUTPUT_TIER_V1 |
| 3 | patch-r3-claudemd-doc.js | R3 | 在 CLAUDE.md 注入"项目级稳定上下文"规则 |
| 4 | patch-r3-create-hook-and-cli.js | R3 | 创建 project-context-injector.js + bookworm-context-init.js |
| 5 | patch-r3-register-project-context-hook.js | R3 | settings.json 注册 R3 hook |
| 6 | patch-r4-claudemd-doc.js | R4 | 在 CLAUDE.md 注入"外部压力信号"规则 |
| 7 | patch-r4-create-context-pressure-hook.js | R4 | 创建 context-pressure-monitor.js |
| 8 | patch-r4-register-pressure-hook.js | R4 | settings.json 注册 R4 hook |
| 9 | patch-r5-claudemd-doc.js | R5 | 在 CLAUDE.md 注入"Agent 隔离软门控"规则 |
| 10 | patch-r5-create-agent-isolation-gate.js | R5 | 创建 agent-isolation-gate.js |
| 11 | patch-r5-register-isolation-gate.js | R5 | settings.json 注册 R5 hook (Bash/Write/Edit × 3) |
### 第二阶段 · 冷审查后修复 (2026-04-26 1:20-1:50) · 5 个
| # | 补丁名 | 优先级 | 修复内容 |
|---|--------|-------|---------|
| 12 | patch-r2-claudemd-doc.js | P2 | 补全 CLAUDE.md R2 规则 (含自愈去重) |
| 13 | patch-r3-fallback-session-id.js | P2 | 修复 unknown-session 跨会话污染 |
| 14 | patch-r4-cjk-token-ratio.js | P1 | BYTES_PER_TOKEN 按 CJK 占比动态化 (2.2/2.8/3.5) |
| 15 | patch-r5-bash-separators-extension.js | P1 | B3 扩展支持 `;` `\n` 联合分隔符 + 引号剥离 |
| 16 | patch-r5-merge-matcher.js | P2 | settings.json agent-isolation-gate 3 注册合并为 `Bash\|Write\|Edit` |
### 第三阶段 · P3 收尾 (2026-04-26 1:50-) · 1 个
| # | 补丁名 | 优先级 | 修复内容 |
|---|--------|-------|---------|
| 17 | patch-r2-tierize-input-cap.js | P3 | 单条 tool_result > 5MB 截断, 防 tierize 正则扫描超时 |
## 当前权威状态 (2026-04-26 1:55)
- **补丁总数**: 17 (一阶段 11 + 二阶段 5 + 三阶段 1)
- **全部幂等**: ✓ (所有补丁重跑均输出 `already applied, skip` 或同义)
- **全部成功**: ✓ (无失败补丁)
- **覆盖文件**:
- `hooks/pre-compact-handoff.js` (R2 改造 + 5MB cap)
- `hooks/project-context-injector.js` (R3 新增 + fallback)
- `hooks/context-pressure-monitor.js` (R4 新增 + CJK ratio)
- `hooks/agent-isolation-gate.js` (R5 新增 + 分隔符扩展)
- `scripts/bookworm-context-init.js` (R3 CLI)
- `settings.json` (4 hook 注册, agent-isolation-gate 单 matcher 合并)
- `CLAUDE.md` (§上下文管理 5 条规则: R1/R2/R3/R4/R5)
## 备份文件清单
| 类型 | 文件名模式 | 位置 |
|------|----------|------|
| Hook 备份 | `*.bak.r3fallback.<ts>` `*.bak.r4cjk.<ts>` `*.bak.r5sep.<ts>` `*.bak.r2cap.<ts>` | `hooks/` |
| settings 备份 | `settings.json.bak.r5merge.<ts>` `settings.json.bak.f5pre.<ts>` | `.claude/` |
| CLAUDE.md 备份 | `CLAUDE.md.bak.r2doc.<ts>` | `.claude/` |
时间戳约 `1777136xxx` (2026-04-26 0:30 起步) 至 `1777140xxx` (1:55 当前)。
## 回滚指引
如需整批回滚:
1. 找到对应 `.bak.<scope>.<ts>` 文件
2. `Copy-Item <bak> <original> -Force`
3. settings.json 回滚后须 `node -e "JSON.parse(fs.readFileSync('settings.json'))"` 校验
如需单点回滚 (例如仅撤销 F1 R4 CJK 修复):
1. `Copy-Item hooks/context-pressure-monitor.js.bak.r4cjk.<ts> hooks/context-pressure-monitor.js -Force`
2. 重跑 `node scripts/patches/patch-r4-cjk-token-ratio.js` (会重新生效) 或保持回滚状态
## 验证命令
```powershell
# 全 17 补丁幂等回测
$p = "C:\Users\leesu\.claude\scripts\patches"
Get-ChildItem $p -Filter "patch-r*.js" | ForEach-Object { node $_.FullName }
# 预期: 全部 "already applied, skip" 或同义
```