Skip to content

fix(cli): why/list/query work from a workspace subpackage#504

Merged
jdx merged 3 commits intomainfrom
fix/why-list-query-from-subpackage
May 3, 2026
Merged

fix(cli): why/list/query work from a workspace subpackage#504
jdx merged 3 commits intomainfrom
fix/why-list-query-from-subpackage

Conversation

@jdx
Copy link
Copy Markdown
Contributor

@jdx jdx commented May 3, 2026

Summary

  • aube why, aube list, and aube query resolved cwd via project_or_workspace_root, which returns the nearest package.json. Inside a workspace member like packages/foo/, that returned the subpackage directory and parse_lockfile then failed with No lockfile found. Run aube install first. even though the workspace lockfile sat one level up.
  • Switched all three commands to workspace_or_project_root so they walk up to the workspace root when one is present and fall back to the nearest project root for non-workspace trees (and yaml-only coordinator monorepos).
  • Removed the now-dead project_or_workspace_root helper and the zero-call-site read_from override branches in list / query.

Reported in #345.

Test plan

  • cargo build, cargo fmt --check, cargo clippy -p aube --all-targets -- -D warnings
  • cargo test -p aube --bin aube (393 tests pass)
  • mise run test:bats test/why.bats test/list.bats test/query.bats test/project_root_walk_up.bats (47/47 pass, including 3 new regression tests)
  • Manual repro: workspace with packages/lib-a declaring is-odd; cd packages/lib-a && aube {why is-number, list, query '[name=is-number]' --parseable} all succeed instead of erroring.

🤖 Generated with Claude Code


Note

Low Risk
Low risk: changes are limited to CLI cwd/root resolution for read-only commands and add regression tests; main risk is altered root selection in edge-case directory layouts.

Overview
Fixes aube list, aube query, and aube why to prefer the workspace root (when present) over the nearest package.json, so running from a workspace member directory reads the correct root lockfile/manifest instead of erroring with missing lockfile.

Removes the now-unused project_or_workspace_root helper and simplifies the commands’ root-selection logic, and adds Bats regression tests covering running each command from a subpackage cwd in a pnpm workspace.

Reviewed by Cursor Bugbot for commit 02e36fd. Bugbot is set up for automated code reviews on this repo. Configure here.

`aube why`, `aube list`, and `aube query` were resolving the cwd via
`project_or_workspace_root`, which prefers the nearest `package.json`.
Inside a workspace member like `packages/foo/`, that returned the
subpackage directory and `parse_lockfile` then failed with
"No lockfile found. Run `aube install` first." even though the
workspace lockfile sat one level up.

Switch all three commands to `workspace_or_project_root` so they walk
up to the workspace root when one is present and fall back to the
nearest project root for non-workspace trees (and yaml-only coordinator
monorepos). Drop the now-dead `project_or_workspace_root` helper and
its zero-call-site read-from override branches in `list` / `query`.

Reported in #345.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 3, 2026

Greptile Summary

Fixes aube list, aube query, and aube why failing with "No lockfile found" when invoked from inside a workspace member by switching all three from the project-first project_or_workspace_root() to the workspace-first workspace_or_project_root(). The now-dead helper is removed and the previously partial workaround (walk-up only for --filter) is replaced by uniform behavior, backed by three new Bats regression tests.

Confidence Score: 5/5

Safe to merge — read-only CLI behavior change with full test coverage and no remaining callers of the removed helper.

All changes are narrowly scoped to root-resolution logic for read commands, the removed function has no remaining callers, the new behavior is exactly what pnpm users expect, and three targeted regression tests exercise the fixed paths end-to-end.

No files require special attention.

Important Files Changed

Filename Overview
crates/aube/src/dirs.rs Removes the now-dead project_or_workspace_root helper and updates workspace_or_project_root's doc comment; no callers remain (confirmed by search).
crates/aube/src/commands/list.rs Replaces the split cwd/read_from pattern (workspace-root only for --filter) with a single workspace_or_project_root() call; all downstream paths updated consistently.
crates/aube/src/commands/query.rs Same simplification as list.rs — removes the --filter-conditional workspace-root walk in favor of workspace_or_project_root() for all code paths.
crates/aube/src/commands/why.rs One-line change swapping project_or_workspace_root() for workspace_or_project_root(); correct and minimal.
test/list.bats Adds regression test: installs from workspace root, cd packages/lib-a, verifies aube list succeeds and surfaces the workspace-level dep.
test/query.bats Adds regression test for aube query '[name=is-number]' --parseable from a subpackage cwd; mirrors the list.bats pattern.
test/why.bats Adds regression test for aube why is-number from a subpackage that has is-odd (which transitively depends on is-number); correctly exercises the walk-up fix.

Reviews (3): Last reviewed commit: "refactor(cli): drop redundant list.rs re..." | Re-trigger Greptile

Comment thread crates/aube/src/dirs.rs Outdated
Yaml-only coordinator monorepos carry `pnpm-workspace.yaml` /
`aube-workspace.yaml`, so `find_workspace_root` matches them on the
first branch — they never reach the project-root fallback. Reword the
fallback clause to cover only true non-workspace trees.

Spotted by Greptile in code review.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a742e2e. Configure here.

Comment thread crates/aube/src/commands/list.rs Outdated
After the workspace-root switch, `read_from` was always
`cwd.clone()` — the conditional that produced a divergent value was
removed in the previous commit but the variable was left behind.
Inline every reference to use `&cwd` directly and drop the dead clone.

Spotted by Cursor Bugbot in code review.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jdx jdx enabled auto-merge (squash) May 3, 2026 18:51
@jdx jdx merged commit ca088c3 into main May 3, 2026
18 checks passed
@jdx jdx deleted the fix/why-list-query-from-subpackage branch May 3, 2026 18:52
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.

1 participant