🐛 fix(cli): prefix artefact paths with cwd-relative target path in diff output#204
🐛 fix(cli): prefix artefact paths with cwd-relative target path in diff output#204vincent-psarga merged 15 commits intomainfrom
Conversation
…get diff output When running `packmind-cli diff` in a monorepo with multiple targets, file paths are now prefixed with the target's relative path to make their location unambiguous. - Build a displayPathMap after collecting targetResults - Pass displayPathMap to displayDiffs and use it for path display - Single-target case is unchanged (no prefix added) - Add tests for multi-target path prefixing and single-target no-prefix Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…n multi-target diff
The \n prefix in logInfoConsole caused an empty "packmind-cli" line
to appear before each "Target:" line. Replace with a plain log('')
for the blank line separator.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…t root Artefact file paths in multi-target diff output were prefixed with the path relative to the git root, making them incorrect when the command is run from a subdirectory. Now uses nodePath.relative(cwd, targetDir) so paths are always relative to where the command is invoked. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…f target count The prefix was only applied in multi-target scenarios, leaving single-target cases (e.g. --path src with one target at src/frontend) showing paths relative to the target directory instead of cwd. Now the prefix is always applied; when the target IS the cwd, targetRelativePath is empty and no prefix is added. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR fixes artefact path display in the Key changes:
One gap remains: when Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[diffArtefactsHandler called] --> B{--path provided?}
B -- Yes --> C[fs.stat validate path exists]
C -- fails --> D[logErrorConsole 'Path does not exist' + exit 1]
C -- succeeds --> E[findTargetDirectories searchPath]
B -- No --> E
E --> F[configExists searchPath?]
F -- Yes --> G[targets = searchPath]
F -- No --> H[findDescendantConfigs searchPath]
H --> G
G --> I{targetDirs empty?}
I -- Yes --> J[readHierarchicalConfig cwd]
J --> K{hasConfigs?}
K -- No --> L[logErrorConsole 'Not in Packmind project' + exit 1]
K -- Yes --> M[log 'No targets found' + exit 0]
I -- No --> N[collectGitInfo]
N --> O{gitInfo null?}
O -- Yes --> P[exit 1]
O -- No --> Q[For each targetDir: readFullConfig]
Q --> R{packages empty?}
R -- Yes --> S[skip target]
R -- No --> T[diffArtefacts with baseDirectory=targetDir]
T --> U[targetResults.push targetRelativePath + diffs]
U --> V[Build displayPathMap\n prefix = nodePath.relative cwd targetDir\n key = prefix + diff.filePath]
V --> W[Merge allDiffs]
W --> X[checkDiffs + displayDiffs]
X --> Y{submit flag?}
Y -- Yes --> Z[handleSubmission]
Y -- No --> AA[exit 0]
Last reviewed commit: 2942f9a |
…or git-relative path computation String slicing on gitRoot was incorrect when targetDir shared a prefix with gitRoot but wasn't a child (e.g. /foo/bar vs /foo/barista). Use path.relative() consistently in diffArtefactsHandler, diffRemoveHandler, and diffAddHandler, falling back to '/' when the target is outside the git root. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… diffArtefactsHandler spec Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…figured Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…diff tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove redundant mockResolvedValueOnce setup in 'passes correct baseDirectory for backend target' (beforeEach already provides it) - Hoist diff1 to multi-target support scope and extract single-target tests into their own describe block with a dedicated beforeEach Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@greptile update your review |
… command - Validate that the path specified via --path exists before processing; exit with error if not found - Replace console.error usages with logErrorConsole for consistent error formatting - Remove error field from DiffHandlerDependencies - Update tests accordingly Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When running `packmind-cli diff rm --path <basePath> <filePath>`, combine --path and the positional argument to build the full file path, matching the behavior of `packmind-cli diff rm <basePath>/<filePath>`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When running `packmind-cli diff add --path <basePath> <filePath>`, combine --path and the positional argument to build the full file path, matching the behavior of `packmind-cli diff add <basePath>/<filePath>`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|



Explanation
In a monorepo with multiple Packmind targets (each with their own
packmind.json), thediffcommand was showing artefact file paths relative to their target directory (e.g..claude/rules/packmind/standard.md), making it ambiguous which project the file belongs to.This PR fixes three related issues:
src/frontend/.claude/rules/packmind/standard.md)--path srcwith target atsrc/frontend)packmind-clilines that appeared before each "Target:" header (caused by a\nprefix inlogInfoConsole) are removedType of Change
Affected Components
Testing
Test Details:
TODO List
Reviewer Notes
The core fix is in
diffArtefactsHandler.ts:targetRelativePathis now computed vianodePath.relative(cwd, targetDir)instead of slicing from gitRoot. ThedisplayPathMapalways applies this prefix — when the target is the cwd,nodePath.relativereturns''so no prefix is added.