fix(cli): Show relative path for skill output when under cwd

When the skill directory is under the current working directory,
show a relative path (e.g., .claude/skills/my-skill) instead of
an absolute path for better readability.
This commit is contained in:
Kazuki Yamada
2025-12-07 18:32:32 +09:00
parent 46094b8cd8
commit c5fb07cdbe
2 changed files with 16 additions and 9 deletions

View File

@@ -49,13 +49,18 @@ export const reportResults = (
reportSkippedFiles(cwd, packResult.skippedFiles);
logger.log('');
reportSummary(packResult, config, options);
reportSummary(cwd, packResult, config, options);
logger.log('');
reportCompletion();
};
export const reportSummary = (packResult: PackResult, config: RepomixConfigMerged, options: ReportOptions = {}) => {
export const reportSummary = (
cwd: string,
packResult: PackResult,
config: RepomixConfigMerged,
options: ReportOptions = {},
) => {
let securityCheckMessage = '';
if (config.security.enableSecurityCheck) {
if (packResult.suspiciousFilesResults.length > 0) {
@@ -77,7 +82,9 @@ export const reportSummary = (packResult: PackResult, config: RepomixConfigMerge
// Show skill output path or regular output path
if (config.skillGenerate !== undefined && options.skillDir) {
logger.log(`${pc.white(' Output:')} ${pc.white(options.skillDir)} ${pc.dim('(skill directory)')}`);
// Show relative path if under cwd, otherwise absolute path
const displayPath = options.skillDir.startsWith(cwd) ? path.relative(cwd, options.skillDir) : options.skillDir;
logger.log(`${pc.white(' Output:')} ${pc.white(displayPath)} ${pc.dim('(skill directory)')}`);
} else {
logger.log(`${pc.white(' Output:')} ${pc.white(config.output.filePath)}`);
}

View File

@@ -49,7 +49,7 @@ describe('cliReport', () => {
skippedFiles: [],
};
reportSummary(packResult, config);
reportSummary('/test/project', packResult, config);
expect(logger.log).toHaveBeenCalledWith(expect.stringContaining('1 suspicious file(s) detected and excluded'));
});
@@ -76,7 +76,7 @@ describe('cliReport', () => {
skippedFiles: [],
};
reportSummary(packResult, config);
reportSummary('/test/project', packResult, config);
expect(logger.log).toHaveBeenCalledWith(expect.stringContaining('Git diffs included'));
expect(logger.log).toHaveBeenCalledWith(expect.stringContaining('50 tokens'));
@@ -104,7 +104,7 @@ describe('cliReport', () => {
skippedFiles: [],
};
reportSummary(packResult, config);
reportSummary('/test/project', packResult, config);
expect(logger.log).toHaveBeenCalledWith(expect.stringContaining('No git diffs included'));
});
@@ -131,7 +131,7 @@ describe('cliReport', () => {
skippedFiles: [],
};
reportSummary(packResult, config);
reportSummary('/test/project', packResult, config);
expect(logger.log).toHaveBeenCalledWith(expect.stringContaining('Git logs included'));
expect(logger.log).toHaveBeenCalledWith(expect.stringContaining('30 tokens'));
@@ -159,7 +159,7 @@ describe('cliReport', () => {
skippedFiles: [],
};
reportSummary(packResult, config);
reportSummary('/test/project', packResult, config);
expect(logger.log).toHaveBeenCalledWith(expect.stringContaining('No git logs included'));
});
@@ -185,7 +185,7 @@ describe('cliReport', () => {
skippedFiles: [],
};
reportSummary(packResult, config);
reportSummary('/test/project', packResult, config);
expect(logger.log).toHaveBeenCalledWith(expect.stringContaining('Security check disabled'));
});