Skip to content

feat: mex list 支持分页(默认 10 条、--limit/--offset/--all) - #2

Merged
MickLife merged 1 commit into
developfrom
wt-b
Aug 20, 2026
Merged

MickLife merged 1 commit into
developfrom
wt-b

Conversation

@MickLife

Copy link
Copy Markdown
Owner

背景

mex list 当前一次性打印全部记忆条目,记忆多时输出过长、刷屏。

改动

  • store(src/mex/store/memories.py):list_all 新增 limit/offset 参数(SQL 层 LIMIT/OFFSET,limit=0/None 表示全部);抽取 _list_where_clause 复用 WHERE;新增 count_all 统计过滤后总数(分页提示用)
  • cli(src/mex/cli/write.py):list_cmd 新增 --limit/--offset/--all;文本模式默认 10 条、--json 默认全部(程序消费不截断,向后兼容);非末页打印 Showing X-Y of N 提示;--all 与 --limit 互斥、负值报 UserError
  • render(src/mex/cli/common.py):render_memory_entries 新增 start 参数,跨页编号连续
  • docs:同步 architecture.md §5.1 mex list 参数表
  • gitignore:忽略 .workbuddy/ 会话记忆目录

用法

mex list                  # 默认最近 10 条,末尾提示剩余条数
mex list --offset 10      # 第 2 页,编号从 11 连续
mex list --limit 3        # 每页 3 条
mex list --all            # 打印全部(等价 --limit 0)
mex list --json           # JSON 默认输出全部

测试

  • store 层新增 list_all limit/offset 与 count_all 测试
  • CLI 层新增 11 个分页测试(默认 10 条、--limit、--offset 翻页、--all、--limit 0、参数校验、JSON 行为)
  • 全量 pytest:584 passed;ruff check 通过

- store: list_all 新增 limit/offset(SQL 层分页),新增 count_all 统计过滤后总数
- cli: list_cmd 新增 --limit/--offset/--all;文本默认 10 条、--json 默认全部;
  非末页打印剩余条数与翻页提示;--all 与 --limit 互斥、负值报错
- render: render_memory_entries 新增 start 参数,跨页编号连续
- 测试: store 2 个 + CLI 11 个分页测试,全量 584 通过
- docs: 同步 architecture.md §5.1 mex list 参数表
- gitignore: 忽略 .workbuddy/ 会话记忆目录
@MickLife
MickLife merged commit 61d3029 into develop Aug 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant