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 天内回复