Skip to content

fix(cli): /memory show --project and --global now display all configured context files#2368

Merged
LaZzyMan merged 1 commit intoQwenLM:mainfrom
huww98:fix/memory-show-multi-file-support
Mar 25, 2026
Merged

fix(cli): /memory show --project and --global now display all configured context files#2368
LaZzyMan merged 1 commit intoQwenLM:mainfrom
huww98:fix/memory-show-multi-file-support

Conversation

@huww98
Copy link
Copy Markdown
Contributor

@huww98 huww98 commented Mar 14, 2026

TLDR

/memory show --project and /memory show --global only checked the first filename (QWEN.md) from the configured context files array, ignoring AGENTS.md. After #2018 added multi-file support (['QWEN.md', 'AGENTS.md']), these commands would report empty when only AGENTS.md existed, even though the actual loading mechanism (loadServerHierarchicalMemory) correctly loaded it.

Dive Deeper

The root cause is that getCurrentGeminiMdFilename() returns only the first element of the configured filenames array. While #1428 fixed the hardcoded QWEN.md by using this function, it still only reads one file — insufficient after #2018 introduced the multi-filename array.

Changes:

  • Replace getCurrentGeminiMdFilename() with getAllGeminiMdFilenames() in memoryCommand.ts
  • Add findAllExistingMemoryFiles() helper that iterates all configured filenames and aggregates content from all existing files
  • Update both --project and --global subcommands to display content from all found memory files
  • Add tests for fallback (only AGENTS.md exists) and dual-file scenarios (both QWEN.md and AGENTS.md exist)

Reviewer Test Plan

  1. Create only an AGENTS.md file (no QWEN.md) in a project directory
  2. Run qwen and execute /memory show --project — should display AGENTS.md content (previously showed empty)
  3. Create both QWEN.md and AGENTS.md — should display content from both files
  4. Run /memory show (without flags) — should still work as before (reads from cached aggregated memory)

Testing Matrix

🍏 🪟 🐧
npm run
npx
Docker
Podman - -
Seatbelt - -

Linked issues / bugs

Related to #968 (memory display inconsistency)
Related to #727 (context.fileName not respected — partially fixed by #1428, this PR completes the fix for multi-file case)


🤖 Generated with Qoder

…red context files

Previously, `/memory show --project` and `/memory show --global` only checked
the first filename from `getCurrentGeminiMdFilename()` (i.e., `QWEN.md`),
ignoring other configured context files like `AGENTS.md`. This caused the
commands to report empty even when `AGENTS.md` existed and was being loaded
by the actual memory loading mechanism (`loadServerHierarchicalMemory`).

Changes:
- Replace `getCurrentGeminiMdFilename()` with `getAllGeminiMdFilenames()` in
  memoryCommand.ts
- Add `findAllExistingMemoryFiles()` helper that iterates all configured
  filenames and aggregates content from all existing files
- Update both `--project` and `--global` subcommands to display content from
  all found memory files
- Add tests for fallback (only AGENTS.md exists) and dual-file scenarios
@qwen-code-dev-bot
Copy link
Copy Markdown
Collaborator

Review 结论:✅ Approve

感谢 @huww98 的 PR!这是一个高质量的 bug fix。

Review 总结

维度 评价
代码正确性 🟢 修复方案正确,解决了 getCurrentGeminiMdFilename() 只返回第一个文件名的问题
代码质量 🟢 提取 findAllExistingMemoryFiles() 辅助函数,结构清晰
测试覆盖 🟢 4 个新测试覆盖 fallback 和双文件场景
性能 🟢 影响可忽略(多读几个小文件)
安全性 🟢 无风险
向后兼容性 🟢 完全兼容

关键发现

问题根因: #2018 添加了多文件支持 ,但 仍只检查第一个文件,导致只有 存在时报告为空。

修复方案: 用 替换 ,遍历所有配置的文件名并聚合内容。

建议(可选)

  1. 测试文件中添加 钩子重置 配置
  2. 更新 命令的文档说明多文件支持

Reviewer 验证步骤


Review completed by @qwen-code-dev-bot

Copy link
Copy Markdown
Collaborator

@LaZzyMan LaZzyMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@LaZzyMan LaZzyMan merged commit b57b8ed into QwenLM:main Mar 25, 2026
15 checks 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.

3 participants