Skip to content

fix(add): auto-detect local-path specs instead of hitting the registry#499

Merged
jdx merged 1 commit intomainfrom
fix/add-local-path-detection
May 3, 2026
Merged

fix(add): auto-detect local-path specs instead of hitting the registry#499
jdx merged 1 commit intomainfrom
fix/add-local-path-detection

Conversation

@jdx
Copy link
Copy Markdown
Contributor

@jdx jdx commented May 3, 2026

Summary

  • aube add /path/to/lib (and ./lib, ~/lib, file:./lib, link:./lib) used to fall through to the registry path and surface a confusing HTTP 405 Method Not Allowed from npmjs
  • Mirror pnpm's parseBareSpecifier: detect path-shaped specs at parse time, read the target's package.json for the package name + version, write the spec verbatim to the manifest
  • Bare paths default to link: for directories and file: for tarballs (pnpm parity); explicit file: / link: prefixes are preserved
  • Tarball forms aren't supported in aube add yet — they emit a clear hint pointing at manual package.json editing rather than the previous 405

Reported in discussions/497.

Test plan

  • 10 new parse_pkg_spec unit tests cover absolute / relative / ~/ / file: / link: / tarball / Windows drive-letter / scoped-name (negative) / git-URL (negative)
  • 4 new test/add.bats cases exercise the end-to-end install pipeline (bare path, file: prefix, link: prefix, tarball-suffix friendly error)
  • cargo test --workspace (1300+ tests) green
  • mise run test:bats test/add.bats and test/install.bats green
  • cargo clippy --all-targets -- -D warnings clean

🤖 Generated with Claude Code


Note

Medium Risk
Medium risk because it changes aube add spec parsing and normalization for a broad set of inputs (POSIX/Windows paths, ~/ expansion), which could reclassify some previously-registry specs or alter manifest output in edge cases.

Overview
aube add now auto-detects bare path-shaped arguments (absolute/relative/~//Windows drive paths) as local dependencies instead of falling through to the registry fetch path.

Bare paths are normalized to link: by default (or file: for tarball-looking paths) with eager ~/ expansion, and local basename derivation now handles Windows \ separators. Adds focused unit tests plus a Bats integration test to cover the new local-path detection/normalization behavior and prevent regressions like the prior HTTP 405 on /path/to/lib.

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

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 3, 2026

Greptile Summary

Fixes aube add <path> for bare shell paths (./lib, /abs/lib, ~/lib, C:\\lib) that previously fell through to registry resolution and returned an HTTP 405. The PR introduces looks_like_path (mirroring pnpm's parseBareSpecifier), eager tilde expansion, and prefix_bare_local_path to normalise bare paths to link: (directories) or file: (tarballs) before they reach the manifest. The two P1 findings from the prior review round — the overly broad Windows drive-letter check and the backslash-only basename_from_local_path split — are both addressed in this diff.

Confidence Score: 5/5

Safe to merge — all previously-flagged P1 issues are resolved and no new defects were found.

Both P1 findings from the previous review (drive-letter check needing a path-separator guard, basename_from_local_path not splitting on backslash) are fixed in this diff. The new looks_like_path function correctly requires bytes[2] == b'/' || b'\' before treating a letter: prefix as a Windows path. The new bats test uses mkdir local-dep within the per-test temp dir so the teardown concern mentioned in an earlier comment does not apply here. No new logic or security issues were identified.

No files require special attention.

Important Files Changed

Filename Overview
crates/aube/src/commands/add.rs Adds looks_like_path, expand_tilde, is_tarball_suffix, and prefix_bare_local_path helpers so bare shell paths are classified as local-dep specs rather than falling through to registry resolution; fixes basename_from_local_path to split on both / and \; the previously-flagged drive-letter guard and backslash-split bug are both addressed in this diff.
test/add.bats Adds one new end-to-end bats test for the bare-path regression (aube add ./<dir>link: spec + symlink); new test uses mkdir local-dep within the temp dir so teardown is clean.

Reviews (4): Last reviewed commit: "fix(add): auto-detect bare local paths i..." | Re-trigger Greptile

Comment thread crates/aube/src/commands/add.rs Outdated
Comment thread test/add.bats Outdated
Comment thread crates/aube/src/commands/add.rs Outdated
@jdx jdx force-pushed the fix/add-local-path-detection branch 2 times, most recently from c13ebfa to a9f9aa7 Compare May 3, 2026 17:25
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 2 potential issues.

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 a9f9aa7. Configure here.

Comment thread crates/aube/src/commands/add.rs
Comment thread crates/aube/src/commands/add.rs
@jdx jdx force-pushed the fix/add-local-path-detection branch from a9f9aa7 to 502e962 Compare May 3, 2026 17:37
`aube add /path/to/lib` (and `./lib`, `../lib`, `~/lib`,
`C:/projects/lib`) used to fall through to the registry path and
surface a confusing HTTP 405 from npmjs. The recently-merged `file:`
/ `link:` support (#487) only handled the prefixed forms.

Match pnpm's `parseBareSpecifier`: detect path-shaped specs at parse
time and route them through the existing local-path machinery. Bare
paths default to `link:` for directories and `file:` for tarballs
(pnpm parity); `~/` is expanded eagerly because the resolver has no
tilde handling. The drive-letter check requires `/` or `\` after the
colon so a single-character npm alias like `a:1.0.0` isn't
reclassified as a Windows path.

Closes discussions/497.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jdx jdx force-pushed the fix/add-local-path-detection branch from 502e962 to 94eb716 Compare May 3, 2026 17:46
@jdx jdx merged commit 69e12ec into main May 3, 2026
18 checks passed
@jdx jdx deleted the fix/add-local-path-detection branch May 3, 2026 17:55
@greptile-apps greptile-apps Bot mentioned this pull request May 3, 2026
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