Repository navigation
feat(history): 用 transcripts.mjs 按 cwd 与时间列出历史会话 - #15
Merged
Merged
Conversation
recall、correct、automate-me 改为调用 bin/transcripts.mjs 定位本项目的 Claude 与 Codex 会话,不再只靠文字描述路径。 - Claude:按 Claude Code 2.1.302 的规则把 cwd 转成项目目录名(非字母数字 的 UTF-16 码元换成 -,超过 200 字符截断并加哈希),并要求会话记录过该 cwd;同时列出 subagents/。 - Codex:先按 mtime 过滤 sessions/YYYY/MM/DD,只读窗口内文件首行 session_meta 的 payload.cwd。 - scripts/transcripts.test.mjs 用临时 HOME 覆盖 slug、目录冲突与搬迁会话、 时间窗、cwd 过滤和两种宿主。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
收尾审查发现两处结构问题,行为不变: - .jsonl 枚举与去扩展名在三处重复,抽成 jsonlFiles(dir)。 - listTranscripts 的导出和 env/homeDir 注入参数没有调用方,测试走 CLI; 去掉这层接口,宿主目录在各自的列举函数里解析。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6b05c98caf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
recall、correct、automate-me需要回看本项目的历史会话,但 fork 只在文字里要求"按仓库/cwd、会话和时间收窄",没有给出路径,也没有可执行的检查。上游 cursor/plugins#637 写的 Claude 目录规则只替换/和.,本机实测不完整:空格、下划线、非 ASCII 都会变成-,超过 200 字符的路径还会被截断并追加哈希。改动
bin/transcripts.mjs(Node,零依赖):--host claude|codex、可重复的--cwd(默认当前目录)、--since/--until(默认最近 7 天;纯日期按本地自然日)、--json。按真实 mtime 倒序输出候选文件,不输出任何消息内容。~/.claude/projects/<slug>/(尊重CLAUDE_CONFIG_DIR),且会话中须有顶层cwd等于目标,才列出该会话及其<session>/subagents/*.jsonl。~/.codex/sessions/YYYY/MM/DD/*.jsonl(尊重CODEX_HOME),先按 mtime 过滤,只对窗口内的文件读取第一行session_meta,按payload.cwd匹配;payload.source.subagent标为子代理并带上parent_thread_id。scripts/transcripts.test.mjs(check.sh自动执行),用临时 HOME 造夹具。references/runtime.md(保留第 68 行的范围约束,补上脚本用法和 worktree 说明)、claude-runtime.md、codex-runtime.md,以及recall、correct、automate-me中读历史的步骤;ADAPTATION.md记录这项本地新增及依据。slug 规则的依据
replace(/[^a-zA-Z0-9]/g, "-");长度超过 200 时取前 200 位,加-和Math.abs(hash).toString(36),hash 为(h << 5) - h + charCode | 0。正则按 UTF-16 码元替换,所以 CJK 字符变成一个-,emoji 变成两个。~/.claude/projects下 130 个目录名只含[A-Za-z0-9-];15 个 207 字符的目录全部能由其会话记录的 cwd 按上述规则精确还原(15/15)。cwd与所在目录一致;另外 5 个是从临时目录"切换目录"后搬过来的,首条 cwd 是旧目录,之后的记录才含本目录的 cwd。因此脚本不只看首条,任一顶层cwd匹配即可;这一核对同时排除/a/b-c与/a/b.c这类共用目录名的情况。session_meta,工作目录字段为payload.cwd,子代理来源为payload.source.subagent(含thread_spawn.parent_thread_id)。验证
bash scripts/check.sh runtimenode --test scripts/*.test.mjs73/73;离线 Python 测试 18、8、9、22、26 项全部 OK;结尾runtime checks passed.CLAUDE_CONFIG_DIR/CODEX_HOME、参数错误/、.规则;去掉截断哈希;不核对 cwd;只看首条 cwd;Codex 先读文件再按 mtime 过滤(用 chmod 000 的范围外文件检测)git worktree list的 12 个 checkout 一并传入以上计数只统计条数与类型,没有读取或粘贴会话内容。
收尾代码审查针对
6b05c98:没有阻断项;按审查意见在e8255a4合并了三处重复的.jsonl枚举,并去掉无调用方的导出接口及env/homeDir注入参数,行为不变。之后重跑了 fork guards、node --test scripts/*.test.mjs(73/73)和上述 5 项反向验证,结论对应e8255a4。限制与取舍
~/.codex/archived_sessions/不列出(本机多数为.jsonl.zst压缩文件)。recall第 2 步的默认范围从"当前 workspace"明确为"当前仓库的所有 checkout"(逐个传--cwd),因为在 Claude 桌面端每个会话都在独立 worktree 里,只看当前 cwd 基本只会找到自己。reflect、show-me-your-work里还有同样的旧段落,本 PR 没有改。未合并,也未刷新本机安装。
🤖 Generated with Claude Code