You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(workspaces): document globs, --workspace, and auto-add member
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.
Copy file name to clipboardExpand all lines: documentation/cli/10_new.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,8 +25,14 @@ This command will create a new directory with the given name.
25
25
26
26
See [Project Layout](./../language/01_layout.md) for more details.
27
27
28
+
When `leo new <NAME>` is run from inside a [workspace](../guides/03_workspaces.md), the new package is appended to the enclosing `workspace.json` automatically. See [Adding Members](../guides/03_workspaces.md#adding-members) for the exact behavior.
29
+
28
30
## Flags
29
31
30
32
### `--library`
31
33
32
34
Creates a new Leo library instead of a program. A library provides reusable logic that can be imported by other Leo programs or libraries using `leo add --local`, but cannot be deployed or executed on its own. The generated project includes a `tests/` directory with a starter test file.
35
+
36
+
### `--workspace`
37
+
38
+
Creates a workspace skeleton instead of a package. The generated directory contains only a `workspace.json` with an empty `members` array; populate it by listing member paths or globs, or by running `leo new` from within the workspace (see [Workspaces](../guides/03_workspaces.md)). Conflicts with `--library`.
Copy file name to clipboardExpand all lines: documentation/guides/03_workspaces.md
+45-1Lines changed: 45 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,15 @@ Workspaces are useful when your application is made up of several interacting pr
12
12
13
13
## Creating a Workspace
14
14
15
-
Create a `workspace.json` file in your project root. It contains a `members` array listing the relative paths to each member package:
15
+
The quickest way to start a workspace is to scaffold one with `leo new`:
16
+
17
+
```bash
18
+
leo new --workspace my_project
19
+
```
20
+
21
+
This creates `my_project/` containing a `workspace.json` with an empty `members` array. The `--workspace` flag is mutually exclusive with `--library` - a workspace is just a root that groups packages, not a package itself, so it has no `src/`, `program.json`, or `tests/` directory.
22
+
23
+
Equivalently, you can create `workspace.json` by hand in any directory. It contains a `members` array listing the relative paths to each member package:
16
24
17
25
```json
18
26
{
@@ -22,6 +30,42 @@ Create a `workspace.json` file in your project root. It contains a `members` arr
22
30
23
31
Each entry is a path to a directory containing a standard Leo package with its own `program.json` and `src/main.leo`.
24
32
33
+
### Glob Members
34
+
35
+
Entries in `members` can also be glob patterns, resolved relative to the workspace root:
36
+
37
+
```json
38
+
{
39
+
"members": ["libraries/core", "programs/*"]
40
+
}
41
+
```
42
+
43
+
Standard `glob` syntax is supported, including `*` (matches a single path segment), `**` (matches recursively across directories), `?`, and character classes like `[abc]`. A glob match is included only if the matched directory contains a `program.json`; other matches (files, directories without a manifest, non-UTF-8 paths) are silently skipped.
44
+
45
+
A glob that matches zero packages logs a warning and continues - it is not an error:
46
+
47
+
```text
48
+
workspace member glob `programs/*` in <root> matched no packages
49
+
```
50
+
51
+
A literal entry pointing at a missing directory still errors, so explicit paths remain strictly validated. Literal entries are resolved before globs and members are deduplicated by canonical path, so a directory matched by both a literal entry and a glob is only included once.
52
+
53
+
### Adding Members
54
+
55
+
When `leo new <name>` is run anywhere inside a workspace, the new package's path is appended to the enclosing `workspace.json` automatically and Leo prints:
56
+
57
+
```text
58
+
Added <name> to the enclosing workspace.
59
+
```
60
+
61
+
The append is skipped silently if the new package is already covered by an existing entry - either a literal path equal to the new package's relative path, or a glob that matches it. If the new package ends up outside the discovered workspace root (for example, `leo new ../sibling`), Leo prints a warning and leaves `workspace.json` untouched:
62
+
63
+
```text
64
+
new package at `...` is not inside the discovered workspace root `...`; skipping auto-add
65
+
```
66
+
67
+
Existing `members` order is preserved; new entries are appended at the end. If you would rather not edit `members` by hand at all, use a glob entry such as `programs/*` (see [Glob Members](#glob-members)) - new packages created inside that directory are picked up without modifying `workspace.json`.
0 commit comments