feat(cli): hint when a tree filter looks shell-expanded from ~#94
Merged
Conversation
An unquoted leading `~` is expanded by the shell before argv reaches the CLI: `me export --tree ~/granola` arrives as `--tree /Users/me/granola`, which normalizes to the ltree filter `Users.me.granola` and silently matches nothing — exactly when the caller meant their memory home and should have quoted it (`'~/granola'`). Add `shellTildeExpansionHint` (packages/cli/util.ts): on a zero-result path, if the tree value is the caller's filesystem home or a child of it (the tell-tale of `~` expansion — a real tree path is never an absolute fs path), emit a one-line hint with the full command requoted and ready to paste. Wired into every tree command's empty branch: search, export, count, tree, deltree, move, copy. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jgpruitt
approved these changes
Jun 24, 2026
murrayju
approved these changes
Jun 24, 2026
murrayju
left a comment
Member
There was a problem hiding this comment.
I like the hint. I'd just cut down on the duplication for the warning generation.
Comment on lines
+619
to
+623
| clack.log.warn( | ||
| hint | ||
| ? `No memories found under '${tree}'\n${hint}` | ||
| : `No memories found under '${tree}'`, | ||
| ); |
Member
There was a problem hiding this comment.
Would prefer to DRY these up.
clack.log.warn(
`No memories found under '${tree}'${hint ? `\n${hint}` : ''}`
)
Contributor
Author
There was a problem hiding this comment.
Done in 9793b1c — collapsed to the inline template you suggested (applied across export/deltree/move/copy). Thanks!
Address review: collapse the two-branch ternary (which repeated the base message) into a single inline template that appends the hint when present. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
me export --tree ~/granola …silently reports "No memories found", while the quoted--tree '~/granola'finds them. This isn't an export bug — the shell expands an unquoted leading~before argv reaches the CLI:--tree ~/granola→--tree /Users/me/granola→ normalizes to the ltree filterUsers.me.granola→ matches nothing.--tree '~/granola'(quoted) reaches the CLI intact → expands to the caller's memory home → matches.~/…is exactly the home form the docs recommend, so silent zero-results is a nasty trap. It affects every--tree-taking command, not just export.Fix
Add
shellTildeExpansionHint(packages/cli/util.ts). On a zero-result path, if the tree value is the caller's filesystem home or a child of it (the tell-tale of~expansion — a real tree path is never an absolute fs path, so this never fires on a legitimate filter), emit a one-line hint:The suggestion is the full command as typed, reconstructed from
process.argv, with the shell-expanded token swapped for the quoted~form (and any other arg POSIX-quoted only if needed) so it's copy-pasteable.Warn-only — never rewrites the filter. Wired into every tree command's empty branch: search, export, count, tree, deltree, move, copy.
Test plan
packages/cli/util.test.ts(full-command rebuild, bare~, spaces-in-query quoting, real-filter → null, sibling-prefix → null, empty//-home edges)../bun run check→ green (typecheck clean, 649 pass / 0 fail).🤖 Generated with Claude Code