Skip to content

feat(workspaces): globs, --workspace, auto-add member (Phase 4)#29429

Merged
mohammadfawaz merged 5 commits into
masterfrom
mitchmindtree/workspaces
May 22, 2026
Merged

feat(workspaces): globs, --workspace, auto-add member (Phase 4)#29429
mohammadfawaz merged 5 commits into
masterfrom
mitchmindtree/workspaces

Conversation

@mitchmindtree
Copy link
Copy Markdown
Collaborator

Three ergonomics improvements for workspace.json-driven projects:

  • Glob members: entries in workspace.json can now be glob patterns (e.g. programs/*, programs/**) that expand to all directories containing a program.json. Non-package matches are silently skipped; literal entries still error on missing dirs; zero-match globs warn and continue.
  • leo new --workspace: scaffolds a fresh workspace skeleton - <name>/workspace.json with an empty members array. Conflicts with --library at the clap level.
  • Auto-add member: leo new <name> from within a workspace appends the new package to workspace.json unless the path is already covered by a literal entry or a glob. Outside-tree creations warn and skip.

Adds glob = "0.3" to workspace deps, Workspace::initialize_skeleton and Workspace::auto_register_member to leo-package, plus 16 new workspace unit tests and 4 new CLI e2e tests.

The shared workspace-level build directory sub-feature is deferred to a follow-up PR.

Part of #29140

@mitchmindtree mitchmindtree self-assigned this May 17, 2026
@mitchmindtree mitchmindtree added 🚀 feature A new feature. 🖥️ CLI Anything related to the Leo CLI. labels May 17, 2026
@mitchmindtree mitchmindtree requested a review from a team May 18, 2026 00:12
@mitchmindtree mitchmindtree marked this pull request as ready for review May 18, 2026 00:12
@mitchmindtree mitchmindtree force-pushed the mitchmindtree/workspaces branch from 73f2fc7 to 04b3856 Compare May 20, 2026 05:16
Comment thread crates/package/src/workspace.rs Outdated
Comment thread crates/package/src/workspace.rs Outdated
Comment thread crates/package/src/workspace.rs
Three ergonomics improvements for `workspace.json`-driven projects:

- Glob members: entries in `workspace.json` can now be glob patterns
  (e.g. `programs/*`, `programs/**`) that expand to all directories
  containing a `program.json`. Non-package matches are silently
  skipped; literal entries still error on missing dirs; zero-match
  globs warn and continue.
- `leo new --workspace`: scaffolds a fresh workspace skeleton -
  `<name>/workspace.json` with an empty `members` array. Conflicts
  with `--library` at the clap level.
- Auto-add member: `leo new <name>` from within a workspace appends
  the new package to `workspace.json` unless the path is already
  covered by a literal entry or a glob. Outside-tree creations warn
  and skip.

Adds `glob = "0.3"` to workspace deps, `Workspace::initialize_skeleton`
and `Workspace::auto_register_member` to `leo-package`, plus 16 new
workspace unit tests and 4 new CLI e2e tests.

The shared workspace-level build directory sub-feature is deferred to
a follow-up PR.
Cover the three Phase 4 ergonomics features in the workspaces guide and
`leo new` reference: glob patterns in `workspace.json` (with the
zero-match warning and literal-vs-glob precedence), `leo new --workspace`
for scaffolding a workspace skeleton, and the auto-add behavior when
`leo new` runs inside a workspace.
- pattern_matches_relative: match with require_literal_separator so `*`
  no longer crosses `/`, keeping it consistent with glob::glob expansion
- auto_register_member: re-read workspace.json before the coverage check
  so a concurrently-modified manifest can't get a duplicate entry
- load_member_record: reject literal member entries (e.g. `../sibling`)
  that canonicalize outside the workspace root, via a new
  workspace_member_outside_root error
…scovery

- remove the now-unused `Workspace.manifest` field; its last reader went
  away when auto_register_member began re-reading the manifest from disk
- add `discover_root` to locate a workspace root without resolving members,
  so auto_register_member (hence `leo new`) no longer fails when an unrelated
  existing member is broken; covered by a new regression test
- generalize the workspace_member_outside_root help text (it also catches
  symlink escapes) and tighten its test to assert the specific error
`filter_stderr` normalized the per-test temp directory to `TMPDIR` with a
regex that guessed the path shape, matching only a `$TMPDIR` directly under
`/tmp` or the macOS `/var/folders` location. Under a nix-shell `$TMPDIR`
(`/tmp/nix-shell.XXXXXX/...`) it matched nothing, leaving absolute paths in
`cli_test_ambiguous_package` and `cli_test_duplicate_lib_name` output.

Replace the regex with a literal substitution of the harness's known temp
directory - and its canonicalized form, since leo canonicalizes paths before
printing them - with `TMPDIR`.
@mitchmindtree mitchmindtree force-pushed the mitchmindtree/workspaces branch from b9f847d to d8e9807 Compare May 21, 2026 22:53
@mitchmindtree mitchmindtree requested a review from a team May 21, 2026 23:07
Copy link
Copy Markdown
Collaborator

@mohammadfawaz mohammadfawaz left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you.

@mohammadfawaz mohammadfawaz merged commit c9f7ac3 into master May 22, 2026
6 checks passed
@mohammadfawaz mohammadfawaz deleted the mitchmindtree/workspaces branch May 22, 2026 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🖥️ CLI Anything related to the Leo CLI. 🚀 feature A new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants