Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
651da05
feat(cli): /summary supports custom export path (#8113)
qwen-code-dev-bot Jul 30, 2026
a8f3726
Merge branch 'main' into feat/summary-export-path
qwen-code-dev-bot Jul 30, 2026
ae966bb
fix(cli): summary custom path dir detection and i18n key (#8116)
qwen-code-dev-bot Jul 30, 2026
721ae1b
test(cli): assert relative display path in summary tests (#8116)
Jul 30, 2026
96f73b1
fix(cli): summary path containment, early validation, and mkdir harde…
Jul 30, 2026
4e6a6f4
fix(cli): defer summary mkdir to save time so failed generation leave…
Jul 30, 2026
9fbecfe
fix(cli): normalize path separators in summary test and assert file c…
Jul 30, 2026
7238cbf
test(cli): assert directory permission mode in summary test (#8116)
Jul 30, 2026
25e810b
fix(cli): resolve symlinks in summary path containment check (#8116)
Jul 30, 2026
fae425d
Merge branch 'main' into feat/summary-export-path
qwen-code-dev-bot Jul 31, 2026
afac1c1
Merge branch 'main' into feat/summary-export-path
qwen-code-dev-bot Jul 31, 2026
f6467bf
fix(cli): reject broken symlinks escaping project root in /summary (#…
qwen-code-ci-bot Jul 31, 2026
bc46383
fix(cli): guard /summary overwrite and expand tilde in path (#8116)
qwen-code-dev-bot Jul 31, 2026
ddee516
fix(cli): re-validate appended default filename for symlink escape in…
Jul 31, 2026
6109840
fix(cli): harden /summary symlink chain walk, file mode, and overwrit…
Aug 1, 2026
cae22cd
Merge branch 'main' into feat/summary-export-path
qwen-code-dev-bot Aug 1, 2026
578baa1
fix(cli): address review feedback on /summary custom path (#8116)
Aug 1, 2026
523cf48
fix(cli): address review feedback on /summary custom path (#8116)
Aug 1, 2026
5044921
fix(cli): address review feedback on /summary custom path (#8116)
Aug 1, 2026
543b120
Merge branch 'main' into feat/summary-export-path
qwen-code-dev-bot Aug 1, 2026
f18300f
test(cli): cover post-LLM symlink re-check and interactive error UI (…
qwen-code-dev-bot Aug 1, 2026
9d6d556
Merge branch 'main' into feat/summary-export-path
qwen-code-dev-bot Aug 1, 2026
0ee995d
Merge branch 'main' into feat/summary-export-path
wenshao Aug 1, 2026
c4c268a
Merge branch 'main' into feat/summary-export-path
qwen-code-dev-bot Aug 1, 2026
9a9d374
Merge branch 'main' into feat/summary-export-path
qwen-code-dev-bot Aug 1, 2026
4c32ef3
Merge branch 'main' into feat/summary-export-path
qwen-code-dev-bot Aug 1, 2026
812e233
fix(cli): address review feedback on /summary custom path (#8116)
qwen-code-ci-bot Aug 1, 2026
63359f6
Merge branch 'main' into feat/summary-export-path
wenshao Aug 1, 2026
d707217
Merge branch 'main' into feat/summary-export-path
qwen-code-dev-bot Aug 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 48 additions & 12 deletions packages/cli/src/ui/commands/summaryCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ export const summaryCommand: SlashCommand = {
name: 'summary',
get description() {
return t(
'Generate a project summary and save it to .qwen/PROJECT_SUMMARY.md',
'Generate a project summary and save it to .qwen/PROJECT_SUMMARY.md (or a custom path)',
);
},
argumentHint: '[path]',
kind: CommandKind.BUILT_IN,
supportedModes: ['interactive', 'non_interactive', 'acp'] as const,
action: async (context): Promise<SlashCommandActionReturn> => {
action: async (context, args): Promise<SlashCommandActionReturn> => {
const { config } = context.services;
const { ui } = context;
const executionMode = context.executionMode ?? 'interactive';
Expand Down Expand Up @@ -140,29 +141,64 @@ export const summaryCommand: SlashCommand = {
filePathForDisplay: string;
fullPath: string;
}> => {
// Ensure .qwen directory exists
const projectRoot = config.getProjectRoot();
const qwenDir = path.join(projectRoot, '.qwen');
try {
await fsPromises.mkdir(qwenDir, { recursive: true });
} catch (_err) {
// Directory might already exist, ignore error
const customPath = args?.trim();

let summaryPath: string;
let filePathForDisplay: string;

if (customPath) {
// Resolve relative to project root
const resolved = path.isAbsolute(customPath)
? customPath
: path.resolve(projectRoot, customPath);

// If the path ends with a separator or is an existing directory,
// append the default filename
const isDir =
resolved.endsWith('/') ||
resolved.endsWith('\\') ||
(await fsPromises
.stat(resolved)
.then((s) => s.isDirectory())
.catch(() => false));

if (isDir) {
summaryPath = path.join(resolved, 'PROJECT_SUMMARY.md');
} else {
summaryPath = resolved;
}

// Ensure parent directory exists
await fsPromises.mkdir(path.dirname(summaryPath), { recursive: true });

filePathForDisplay = path.isAbsolute(customPath)
? summaryPath
: path.relative(projectRoot, summaryPath);
} else {
// Default: save to .qwen/PROJECT_SUMMARY.md
const qwenDir = path.join(projectRoot, '.qwen');
try {
await fsPromises.mkdir(qwenDir, { recursive: true });
} catch (_err) {
// Directory might already exist, ignore error
}
summaryPath = path.join(qwenDir, 'PROJECT_SUMMARY.md');
filePathForDisplay = '.qwen/PROJECT_SUMMARY.md';
}
Comment on lines +254 to +256

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Declined — the suggested realpath(resolved).catch(() => resolved) is a no-op for the described scenario: when the target file does not yet exist (the common case), realpath fails with ENOENT and the .catch falls back to the lexical path, so the symlink is never resolved. A proper fix would need a realpathNearestExisting ancestor walk like exportCommand.ts / statsCommand.ts, which is disproportionate complexity for a non-security-boundary check (the user typing the path already has full filesystem access, consistent with the not-critical rating).

中文说明

拒绝——建议的 realpath(resolved).catch(() => resolved) 对所描述的场景是空操作:当目标文件尚不存在时(常见情况),realpath 因 ENOENT 失败,.catch 回退到词法路径,因此符号链接永远不会被解析。正确的修复需要像 exportCommand.ts / statsCommand.ts 那样进行 realpathNearestExisting 祖先遍历,这对于非安全边界检查来说复杂度过高(输入路径的用户已经拥有完整的文件系统访问权限,与非关键评级一致)。


// Save the summary to PROJECT_SUMMARY.md
const summaryPath = path.join(qwenDir, 'PROJECT_SUMMARY.md');
const summaryContent = `${markdownSummary}

---

## Summary Metadata
**Update time**: ${new Date().toISOString()}
**Update time**: ${new Date().toISOString()}
`;

await fsPromises.writeFile(summaryPath, summaryContent, 'utf8');

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Declined for this PR. This matches the sibling /export command, which overwrites its target via a plain writeFile (no existence check or confirmation), and the user explicitly chose the path — so silent overwrite is consistent CLI behavior here, as the finding itself notes. Adding an existence check or confirmation prompt to /summary alone would make the two commands inconsistent, and doing it for both is out of scope for this change. Leaving the thread open: if maintainers want a shared overwrite guardrail for /summary and /export, a follow-up PR is the right place.

中文说明

本 PR 中拒绝处理。这与同级的 /export 命令一致——后者通过普通 writeFile 覆盖目标文件(没有存在性检查或确认),而且路径是用户明确选择的,因此静默覆盖在这里是一致的 CLI 行为,该意见本身也指出了这一点。单独给 /summary 加存在性检查或确认弹窗会使两个命令不一致,而为两者都加又超出本次改动范围。线程保持打开:如果维护者希望为 /summary 和 /export 做一个共享的覆盖保护机制,后续 PR 是合适的位置。


return {
filePathForDisplay: '.qwen/PROJECT_SUMMARY.md',
filePathForDisplay,
fullPath: summaryPath,
};
};
Expand Down
Loading