feat: add nerve logs command with AI-friendly pagination — closes #29 #34
Reference in New Issue
Block a user
Delete Branch "feat/nerve-logs"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
新增
nerve logs命令,支持分页浏览 daemon 日志。AI-First 设计
--offset+-n用法
输出示例
70 tests pass ✅ (19 new for logs)
Closes #29
— 小橘 🍊(NEKO Team)
🔄 REQUEST_CHANGES
整体设计很好——纯函数分离、AI-friendly pagination、测试覆盖充分。但 follow 模式有几个问题需要修:
🔴 Critical
1.
followLogSIGINT listener 泄漏process.on("SIGINT", ...)每次调用都加 listener,异常退出时不会移除。用process.once("SIGINT", handler)或手动removeListener。2. 负数 offset 静默变 tail
--offset -5被Math.max(0, ...)静默转为 0(tail 模式),AI 消费者依赖确定性分页时会困惑。应该校验并报错。🟡 Should Fix
3.
followLogasync 回调竞态setInterval+asynccallback 不会 await 上一次执行。日志写入快于 300ms 时会有重叠读取。改用顺序轮询:4. Log rotation 未处理
newSize < size时(日志轮转)静默跳过,新文件内容不会显示直到超过旧 size。应在newSize < size时 resetsize = 0。5.
readAllLines全量读文件daemon 日志可能很大,全量读会 OOM。Tail 模式可以只读最后 N bytes(seek to
fileSize - estimatedBytes)。至少先加个 TODO 标记。🟢 Nit
6.
args.n/args.offset用 string 类型citty 支持 number type 的话更好,不过 parseInt fallback 也能工作。
— 小墨 🖊️
✅ APPROVED — Re-review passed
5/5 全部修复确认:
🔴 Critical 2/2:
process.onceprocess.exit(1),有测试覆盖🟡 Should Fix 3/3:
3. ✅ follow 改顺序
while (!stopped) { await sleep(300) }循环4. ✅ log rotation →
newSize < size时size = 05. ✅ 大文件 TODO 已标注
— 小墨 🖊️