Write context-usage snapshots without starting a node process per write
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 48/100
- Issue 類型
- 重構
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- node.js, shell, typescript
- 領域
- devtools, performance
研究方向
Read .claude/rules/mod-authoring.md, load the built-in plugin-authoring skill, then check the current mods reference for available $.fs calls. Trace writes in plugins/context-usage/hooks/register.tsx and the atomic write, lock, and prune behavior in lib/write-snapshot.mjs; review plugins/context-usage/reference/reader-contract.md and its contract tests. Done means changed writes avoid a process or document the missing filesystem call and chosen floor change, preserve reader-visible content and atomicity, and include before and after start-rate measurements in the PR.
由索引模型根據 Issue 內容生成。
描述
Problem
The context-usage mod writes each session's snapshot by starting a separate process:
plugins/context-usage/hooks/register.tsx:642-644 runs node lib/write-snapshot.mjs <target> --prune
through $.process.run whenever the snapshot body changes, and again after FLOOR_MS (60 s, :12)
when it has not. The mod already runs inside Claude Code's process, so each write adds a node start
(and its Defender scan on Windows) for a small JSON file.
Evidence
- Read on
origin/mainthis pass: the spawn atregister.tsx:642-644, the floor at:12, and the
helper's job inlib/write-snapshot.mjs(atomic temp-file write and rename, lock with retries,
hourly prune at:26,:110). - Measured by another session (5-minute Windows process trace, 16 concurrent sessions, 2026-12-04, not
re-measured here):write-snapshot.mjsstarted about 11 times a minute across the sessions. On that
trace Defender CPU tracked process start rate at about 54 ms per start (correlational). $.fs.writeexists in the mod API (used inplugins/session-flow/hooks/register.tsx:45). Not
checked: whether the mod API offers an atomic rename, directory listing and removal, which the
helper's atomic write and prune need.
Proposed approach
- Check the current mods reference for the
$.fscalls available. - If they cover an atomic write, write the snapshot in the mod and keep the helper only for the
hourly prune (or move the prune in too). - If not, raise the floor or write only on a zone change, whichever keeps the documented reader
contract (plugins/context-usage/reference/reader-contract.md).
The helper is shared with rate-limits (scripts/sync-shared-copies.sh); keep the readers' contract
unchanged.
Acceptance criteria
- A snapshot write that changes the body starts no process, or the issue records which
$.fs
call is missing and the floor change taken instead. - Readers see the same file content and atomicity as today (contract tests pass).
- Measured starts per minute for one active session, before and after, in the PR.
Constraints and gotchas
- Follow
.claude/rules/mod-authoring.md(load the built-inplugin-authoringskill first). - A mod hook that throws is skipped (fails open); keep write errors logged once, as today.
Context
Part of the process-start ranking on #20549.
- 主要語言
- Shell
- 星號
- 22
- 分支
- 2
- 平均合併
- 3 小時 20 分鐘
- 30 天內合併 PR
- 956
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
melodic-software/claude-code-plugins 的其他 Issue
-
host-run needs-research
難度 2/5 1-3 小時 新手友好度 66/100
melodic-software/claude-code-plugins#21140 · 2 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 66/100
melodic-software/claude-code-plugins#21103 · 4 則留言 ·
維護者通常 1 天內回覆
-
host-run
難度 2/5 1-3 小時 新手友好度 72/100
melodic-software/claude-code-plugins#21053 · 2 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
melodic-software/claude-code-plugins#21021 · 2 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
melodic-software/claude-code-plugins#20960 · 5 則留言 ·
維護者通常 1 天內回覆
查看 melodic-software/claude-code-plugins 的全部 Issue
相似的 Issue
-
documentation enhancement
難度 2/5 1-3 小時 新手友好度 82/100
aws/aws-networking-best-practices#256 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
fossi-foundation/globalfoundries-pdk-libs-gf180mcu_fd_pv#61 ·
-
openai-directory
難度 2/5 1-3 小時 新手友好度 70/100
-
難度 2/5 1-3 小時 新手友好度 68/100
smores56/homelab-platform#289 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 76/100
omacom/omarchy#21787 · 3 則留言 ·
維護者通常 1 天內回覆