scriptvault 0.3.0__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. {scriptvault-0.3.0/src/scriptvault.egg-info → scriptvault-0.5.0}/PKG-INFO +88 -5
  2. {scriptvault-0.3.0 → scriptvault-0.5.0}/README.md +87 -4
  3. {scriptvault-0.3.0 → scriptvault-0.5.0}/pyproject.toml +1 -1
  4. {scriptvault-0.3.0 → scriptvault-0.5.0}/src/scriptvault/__init__.py +2 -2
  5. {scriptvault-0.3.0 → scriptvault-0.5.0}/src/scriptvault/cli.py +91 -44
  6. {scriptvault-0.3.0 → scriptvault-0.5.0}/src/scriptvault/run.py +109 -38
  7. {scriptvault-0.3.0 → scriptvault-0.5.0}/src/scriptvault/templates.py +102 -7
  8. {scriptvault-0.3.0 → scriptvault-0.5.0}/src/scriptvault/term.py +1 -1
  9. {scriptvault-0.3.0 → scriptvault-0.5.0}/src/scriptvault/vault.py +131 -71
  10. {scriptvault-0.3.0 → scriptvault-0.5.0/src/scriptvault.egg-info}/PKG-INFO +88 -5
  11. scriptvault-0.5.0/tests/test_add.py +228 -0
  12. {scriptvault-0.3.0 → scriptvault-0.5.0}/tests/test_completion.py +20 -0
  13. {scriptvault-0.3.0 → scriptvault-0.5.0}/tests/test_edit.py +13 -0
  14. {scriptvault-0.3.0 → scriptvault-0.5.0}/tests/test_guide.py +3 -0
  15. {scriptvault-0.3.0 → scriptvault-0.5.0}/tests/test_init.py +96 -0
  16. scriptvault-0.5.0/tests/test_list.py +387 -0
  17. scriptvault-0.5.0/tests/test_run.py +1066 -0
  18. scriptvault-0.3.0/tests/test_add.py +0 -131
  19. scriptvault-0.3.0/tests/test_list.py +0 -118
  20. scriptvault-0.3.0/tests/test_run.py +0 -582
  21. {scriptvault-0.3.0 → scriptvault-0.5.0}/LICENSE +0 -0
  22. {scriptvault-0.3.0 → scriptvault-0.5.0}/setup.cfg +0 -0
  23. {scriptvault-0.3.0 → scriptvault-0.5.0}/src/scriptvault/__main__.py +0 -0
  24. {scriptvault-0.3.0 → scriptvault-0.5.0}/src/scriptvault/envfile.py +0 -0
  25. {scriptvault-0.3.0 → scriptvault-0.5.0}/src/scriptvault.egg-info/SOURCES.txt +0 -0
  26. {scriptvault-0.3.0 → scriptvault-0.5.0}/src/scriptvault.egg-info/dependency_links.txt +0 -0
  27. {scriptvault-0.3.0 → scriptvault-0.5.0}/src/scriptvault.egg-info/entry_points.txt +0 -0
  28. {scriptvault-0.3.0 → scriptvault-0.5.0}/src/scriptvault.egg-info/requires.txt +0 -0
  29. {scriptvault-0.3.0 → scriptvault-0.5.0}/src/scriptvault.egg-info/top_level.txt +0 -0
  30. {scriptvault-0.3.0 → scriptvault-0.5.0}/tests/test_hooks.py +0 -0
  31. {scriptvault-0.3.0 → scriptvault-0.5.0}/tests/test_real.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptvault
3
- Version: 0.3.0
3
+ Version: 0.5.0
4
4
  Summary: Store and run project commands in a hidden vault directory
5
5
  Author: Majwt
6
6
  License-Expression: MIT
@@ -41,6 +41,10 @@ From a checkout:
41
41
  pipx install --editable .
42
42
  ```
43
43
 
44
+ For maintainers, `sv set-version 0.4.0` sets the version in `pyproject.toml`
45
+ and `src/scriptvault/__init__.py`. It uses the project environment created by
46
+ `sv build` and rejects invalid versions before changing either file.
47
+
44
48
  ## Quick start
45
49
 
46
50
  Initialize a vault in a project directory:
@@ -119,7 +123,15 @@ sv run c-hello build
119
123
  sv c-hello build
120
124
  ```
121
125
 
122
- Implied run (`sv deploy`) only works for root vault scripts.
126
+ or with the qualified `include:target` form, which names one include
127
+ explicitly (useful when two includes define the same target):
128
+
129
+ ```bash
130
+ sv run c-hello:build
131
+ sv c-hello:build
132
+ ```
133
+
134
+ Implied run (`sv deploy`) works for plain and qualified target names.
123
135
 
124
136
  ## Scripts
125
137
 
@@ -132,6 +144,30 @@ A file at `.sv/scripts/hello.sh` becomes `sv hello`.
132
144
  echo "Hello from $SV_NAME"
133
145
  ```
134
146
 
147
+ File-script metadata can be defined without `cmd`:
148
+
149
+ ```toml
150
+ [scripts.hello]
151
+ description = "Print a greeting"
152
+ ```
153
+
154
+ This requires a same-name script file in `.sv/scripts/`, such as `hello` or
155
+ `hello.sh`, with a shebang. Without a matching file, `cmd` is required.
156
+
157
+ Scripts and orchestrations accept either `desc` or `description`. If both are
158
+ set, `description` takes precedence. Descriptions are shown beside names in
159
+ `sv list`.
160
+
161
+ Listings use colors on supported terminals. Piped output, JSON, `TERM=dumb`,
162
+ and environments with `NO_COLOR` set remain plain.
163
+
164
+ On macOS/Linux, captured orchestration and parallel output uses a
165
+ pseudo-terminal (PTY) when the output terminal supports color, so child
166
+ commands retain their automatic colors. Stdin and signal handling remain
167
+ unchanged. Redirected output, `NO_COLOR`, `TERM=dumb`, Windows and unavailable
168
+ PTYs use normal pipes instead. Explicit force-color settings in child commands
169
+ still apply.
170
+
135
171
  ### Inline scripts
136
172
 
137
173
  Define a command in `vault.toml`:
@@ -148,6 +184,50 @@ sv add hello
148
184
  sv add hello --in < script.sh
149
185
  ```
150
186
 
187
+ ### Local And Hidden Scripts
188
+
189
+ ```sh
190
+ sv add personal --local
191
+ sv add personal --local --in < script.sh
192
+ sv run personal
193
+ sv list --all
194
+ ```
195
+
196
+ Local scripts live in `.sv/local/scripts/`. `sv init` and `sv add --local`
197
+ ensure `.sv/.gitignore` ignores `/local/`, preserving existing ignore rules.
198
+ Local scripts appear in `sv list` by default; use `hidden = true` to hide
199
+ them. `.sv/local/scripts/NAME.env` supplies per-script environment variables.
200
+ Local and shared names must not
201
+ conflict. Gitignore rules do not untrack files already committed.
202
+
203
+ Shared helpers can also be hidden:
204
+
205
+ ```toml
206
+ [scripts.helper]
207
+ hidden = true
208
+ cmd = "echo helper"
209
+ ```
210
+
211
+ `hidden = true` also works for file-script metadata and orchestrations.
212
+ `sv list --all` reveals hidden targets, including with `--json` or `--nested`.
213
+ Hiding is a listing preference, not access control or secret protection.
214
+
215
+ ### Source-Only Helpers
216
+
217
+ Put reusable shell helpers in `.sv/lib/`, outside the runnable script directory:
218
+
219
+ ```bash
220
+ source "$SV_LIB/helper.sh"
221
+ source "$SV_TOP_LIB/git-version.sh"
222
+ ```
223
+
224
+ `SV_LIB` points to the owning vault's library directory. `SV_TOP_LIB` points
225
+ to the outermost vault's library directory in the current execution chain.
226
+ If a nested vault is invoked on its own, both point to that nested vault's
227
+ library. These paths are injected even when the directories do not yet exist.
228
+ Helpers are not runnable targets and never appear in `sv list`, even with
229
+ `--all`. Sourcing keeps their functions and variables in the calling shell.
230
+
151
231
  ## Running targets
152
232
 
153
233
  ```sh
@@ -202,14 +282,17 @@ Environment files are dotenv-style `KEY=VALUE` files.
202
282
  Precedence, from lowest to highest:
203
283
 
204
284
  1. `.sv/.env`
205
- 2. `.sv/scripts/NAME.env`
285
+ 2. `.sv/scripts/NAME.env`, or `.sv/local/scripts/NAME.env` for local scripts
206
286
  3. The real environment
207
287
  4. Injected `SV_*` variables
208
288
 
209
289
  Injected variables:
210
290
 
211
- - `SV_ROOT`: project root
212
- - `SV_DIR`: `.sv` directory
291
+ - `SV_TOP_ROOT`: outermost vault's root directory in the execution chain
292
+ - `SV_TOP_LIB`: that outermost vault's `.sv/lib` directory
293
+ - `SV_ROOT`: root directory of the vault owning the current script or orchestration
294
+ - `SV_DIR`: that owning vault's `.sv` directory
295
+ - `SV_LIB`: that owning vault's `.sv/lib` directory
213
296
  - `SV_CWD`: current working directory at invocation
214
297
  - `SV_NAME`: target name, when running a named script
215
298
 
@@ -20,6 +20,10 @@ From a checkout:
20
20
  pipx install --editable .
21
21
  ```
22
22
 
23
+ For maintainers, `sv set-version 0.4.0` sets the version in `pyproject.toml`
24
+ and `src/scriptvault/__init__.py`. It uses the project environment created by
25
+ `sv build` and rejects invalid versions before changing either file.
26
+
23
27
  ## Quick start
24
28
 
25
29
  Initialize a vault in a project directory:
@@ -98,7 +102,15 @@ sv run c-hello build
98
102
  sv c-hello build
99
103
  ```
100
104
 
101
- Implied run (`sv deploy`) only works for root vault scripts.
105
+ or with the qualified `include:target` form, which names one include
106
+ explicitly (useful when two includes define the same target):
107
+
108
+ ```bash
109
+ sv run c-hello:build
110
+ sv c-hello:build
111
+ ```
112
+
113
+ Implied run (`sv deploy`) works for plain and qualified target names.
102
114
 
103
115
  ## Scripts
104
116
 
@@ -111,6 +123,30 @@ A file at `.sv/scripts/hello.sh` becomes `sv hello`.
111
123
  echo "Hello from $SV_NAME"
112
124
  ```
113
125
 
126
+ File-script metadata can be defined without `cmd`:
127
+
128
+ ```toml
129
+ [scripts.hello]
130
+ description = "Print a greeting"
131
+ ```
132
+
133
+ This requires a same-name script file in `.sv/scripts/`, such as `hello` or
134
+ `hello.sh`, with a shebang. Without a matching file, `cmd` is required.
135
+
136
+ Scripts and orchestrations accept either `desc` or `description`. If both are
137
+ set, `description` takes precedence. Descriptions are shown beside names in
138
+ `sv list`.
139
+
140
+ Listings use colors on supported terminals. Piped output, JSON, `TERM=dumb`,
141
+ and environments with `NO_COLOR` set remain plain.
142
+
143
+ On macOS/Linux, captured orchestration and parallel output uses a
144
+ pseudo-terminal (PTY) when the output terminal supports color, so child
145
+ commands retain their automatic colors. Stdin and signal handling remain
146
+ unchanged. Redirected output, `NO_COLOR`, `TERM=dumb`, Windows and unavailable
147
+ PTYs use normal pipes instead. Explicit force-color settings in child commands
148
+ still apply.
149
+
114
150
  ### Inline scripts
115
151
 
116
152
  Define a command in `vault.toml`:
@@ -127,6 +163,50 @@ sv add hello
127
163
  sv add hello --in < script.sh
128
164
  ```
129
165
 
166
+ ### Local And Hidden Scripts
167
+
168
+ ```sh
169
+ sv add personal --local
170
+ sv add personal --local --in < script.sh
171
+ sv run personal
172
+ sv list --all
173
+ ```
174
+
175
+ Local scripts live in `.sv/local/scripts/`. `sv init` and `sv add --local`
176
+ ensure `.sv/.gitignore` ignores `/local/`, preserving existing ignore rules.
177
+ Local scripts appear in `sv list` by default; use `hidden = true` to hide
178
+ them. `.sv/local/scripts/NAME.env` supplies per-script environment variables.
179
+ Local and shared names must not
180
+ conflict. Gitignore rules do not untrack files already committed.
181
+
182
+ Shared helpers can also be hidden:
183
+
184
+ ```toml
185
+ [scripts.helper]
186
+ hidden = true
187
+ cmd = "echo helper"
188
+ ```
189
+
190
+ `hidden = true` also works for file-script metadata and orchestrations.
191
+ `sv list --all` reveals hidden targets, including with `--json` or `--nested`.
192
+ Hiding is a listing preference, not access control or secret protection.
193
+
194
+ ### Source-Only Helpers
195
+
196
+ Put reusable shell helpers in `.sv/lib/`, outside the runnable script directory:
197
+
198
+ ```bash
199
+ source "$SV_LIB/helper.sh"
200
+ source "$SV_TOP_LIB/git-version.sh"
201
+ ```
202
+
203
+ `SV_LIB` points to the owning vault's library directory. `SV_TOP_LIB` points
204
+ to the outermost vault's library directory in the current execution chain.
205
+ If a nested vault is invoked on its own, both point to that nested vault's
206
+ library. These paths are injected even when the directories do not yet exist.
207
+ Helpers are not runnable targets and never appear in `sv list`, even with
208
+ `--all`. Sourcing keeps their functions and variables in the calling shell.
209
+
130
210
  ## Running targets
131
211
 
132
212
  ```sh
@@ -181,14 +261,17 @@ Environment files are dotenv-style `KEY=VALUE` files.
181
261
  Precedence, from lowest to highest:
182
262
 
183
263
  1. `.sv/.env`
184
- 2. `.sv/scripts/NAME.env`
264
+ 2. `.sv/scripts/NAME.env`, or `.sv/local/scripts/NAME.env` for local scripts
185
265
  3. The real environment
186
266
  4. Injected `SV_*` variables
187
267
 
188
268
  Injected variables:
189
269
 
190
- - `SV_ROOT`: project root
191
- - `SV_DIR`: `.sv` directory
270
+ - `SV_TOP_ROOT`: outermost vault's root directory in the execution chain
271
+ - `SV_TOP_LIB`: that outermost vault's `.sv/lib` directory
272
+ - `SV_ROOT`: root directory of the vault owning the current script or orchestration
273
+ - `SV_DIR`: that owning vault's `.sv` directory
274
+ - `SV_LIB`: that owning vault's `.sv/lib` directory
192
275
  - `SV_CWD`: current working directory at invocation
193
276
  - `SV_NAME`: target name, when running a named script
194
277
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "scriptvault"
7
- version = "0.3.0"
7
+ version = "0.5.0"
8
8
  description = "Store and run project commands in a hidden vault directory"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -3,6 +3,6 @@
3
3
  from importlib.metadata import PackageNotFoundError
4
4
 
5
5
  try:
6
- __version__ = "0.3.0"
6
+ __version__ = "0.5.0"
7
7
  except PackageNotFoundError:
8
- __version__ = "0.3.0"
8
+ __version__ = "0.5.0"
@@ -13,6 +13,7 @@ from pathlib import Path
13
13
 
14
14
  from . import __version__, templates
15
15
  from .run import run_target
16
+ from .term import CYAN, GREEN, MAGENTA, Palette
16
17
  from .vault import (
17
18
  Vault,
18
19
  NAME_RE,
@@ -23,6 +24,7 @@ from .vault import (
23
24
  find_root,
24
25
  hidden_dir_name,
25
26
  load_vault,
27
+ split_qualified,
26
28
  )
27
29
 
28
30
  COMMANDS = (
@@ -56,6 +58,14 @@ def _toml_str(value: str) -> str:
56
58
  return json.dumps(value)[1:-1]
57
59
 
58
60
 
61
+ def _ignore_local_scripts(hidden: Path) -> None:
62
+ path = hidden / ".gitignore"
63
+ content = path.read_text(encoding="utf-8") if path.exists() else ""
64
+ if "/local/" not in content.splitlines():
65
+ separator = "\n" if content and not content.endswith("\n") else ""
66
+ path.write_text(content + separator + "/local/\n", encoding="utf-8")
67
+
68
+
59
69
  def cmd_init(args: argparse.Namespace) -> int:
60
70
  """Initialize a vault in a project directory."""
61
71
  path = Path(args.path)
@@ -75,6 +85,7 @@ def cmd_init(args: argparse.Namespace) -> int:
75
85
  raise CLIError("cannot derive a vault name from path; pass --name")
76
86
 
77
87
  (hidden / "scripts").mkdir(parents=True, exist_ok=True)
88
+ _ignore_local_scripts(hidden)
78
89
  vault_toml.write_text(
79
90
  templates.VAULT_TOML.format(name=_toml_str(name)), encoding="utf-8"
80
91
  )
@@ -393,16 +404,20 @@ def _load_vault(path: str | None = None):
393
404
  def cmd_list(args: argparse.Namespace) -> int:
394
405
  """List scripts and orchestrations in the vault."""
395
406
  vault = _load_vault(args.path)
407
+ show_hidden = getattr(args, "all", False)
396
408
 
397
409
  if args.json:
398
410
  json.dump(
399
411
  {
400
412
  "vault": vault.name,
401
- "scripts": [_target_json(target) for target in vault.targets.values()],
413
+ "scripts": [_target_json(target) for target in vault.targets.values() if show_hidden or not target.hidden],
402
414
  "includes": {
403
415
  name: {
404
416
  "path": str(vault._nested_vaults[name].root),
405
- "scripts": list(vault._nested_vaults[name].scripts.keys()),
417
+ "scripts": [
418
+ script.name for script in vault._nested_vaults[name].scripts.values()
419
+ if show_hidden or not script.hidden
420
+ ],
406
421
  }
407
422
  for name in vault._nested_vaults
408
423
  },
@@ -413,35 +428,52 @@ def cmd_list(args: argparse.Namespace) -> int:
413
428
  sys.stdout.write("\n")
414
429
  return 0
415
430
 
416
- # Show nested structure
417
- print(f"Root vault: {vault.name}")
418
-
419
- # Root targets only (exclude nested vault names)
420
- root_scripts = [name for name in vault.scripts.keys() if name not in vault._nested_vaults]
421
- if root_scripts:
422
- print(f" Scripts: {', '.join(root_scripts)}")
423
- root_orchestrations = [
424
- name for name in vault.orchestrations if name not in vault._nested_vaults
425
- ]
426
- if root_orchestrations:
427
- print(f" Orchestrations: {', '.join(root_orchestrations)}")
431
+ palette = Palette(sys.stdout)
432
+ print(palette.paint(f"Root vault: {vault.name}", bold=True, fg=CYAN))
433
+
434
+ for label, targets in (("Scripts", vault.scripts), ("Orchestrations", vault.orchestrations)):
435
+ names = [
436
+ name for name, target in targets.items()
437
+ if name not in vault._nested_vaults and (show_hidden or not target.hidden)
438
+ ]
439
+ if names:
440
+ print(palette.paint(f" {label}:", bold=True))
441
+ width = max(len(name) for name in names)
442
+ for name in names:
443
+ description = targets[name].description
444
+ color = MAGENTA if isinstance(targets[name], Orchestration) else GREEN
445
+ title = palette.paint(name, fg=color)
446
+ suffix = " " * (width - len(name) + 2) + palette.paint(description, dim=True) if description else ""
447
+ print(f" {title}{suffix}")
428
448
 
429
449
  if vault._nested_vaults:
430
- print("\nIncluded vaults:")
450
+ print("\n" + palette.paint("Included vaults:", bold=True, fg=CYAN))
431
451
  for include_name, nested_vault in vault._nested_vaults.items():
432
452
  names = [
433
453
  name
434
454
  for name in list(nested_vault.scripts) + list(nested_vault.orchestrations)
435
- if name not in vault._nested_vaults
455
+ if name not in vault._nested_vaults and (show_hidden or not nested_vault.get(name).hidden)
436
456
  ]
437
457
  if names:
438
- print(f" {include_name}: {', '.join(names)}")
458
+ print(palette.paint(f" {include_name}:", bold=True, fg=CYAN))
459
+ width = max(len(name) for name in names)
460
+ for name in names:
461
+ target = nested_vault.get(name)
462
+ description = target.description
463
+ color = MAGENTA if isinstance(target, Orchestration) else GREEN
464
+ title = palette.paint(name, fg=color)
465
+ suffix = " " * (width - len(name) + 2) + palette.paint(description, dim=True) if description else ""
466
+ print(f" {title}{suffix}")
439
467
 
440
468
  # If --nested flag is set, show more details
441
469
  if args.nested:
442
- print("\nAll targets (including nested):")
470
+ print("\n" + palette.paint("All targets (including nested):", bold=True, fg=CYAN))
443
471
  for name, target in vault.targets.items():
444
- print(f" {name}: {target.description}")
472
+ if target.hidden and not show_hidden:
473
+ continue
474
+ color = MAGENTA if isinstance(target, Orchestration) else GREEN
475
+ title = palette.paint(name, fg=color)
476
+ print(f" {title}: {palette.paint(target.description, dim=True)}")
445
477
 
446
478
  return 0
447
479
 
@@ -521,9 +553,21 @@ def cmd_run(args: argparse.Namespace) -> int:
521
553
  source_vault=vault._nested_vaults[name],
522
554
  )
523
555
 
524
- # Root vault: single arg only
556
+ # Root vault: a plain name or an `include:target` reference
557
+ parts = split_qualified(name)
558
+ if parts is not None and parts[0] not in vault._nested_vaults:
559
+ available = ", ".join(vault._nested_vaults) or "none"
560
+ raise CLIError(
561
+ f"unknown include {parts[0]!r} (available: {available})", 127
562
+ )
525
563
  target = vault.get(name)
526
564
  if target is None:
565
+ if parts is not None:
566
+ available = ", ".join(vault._nested_vaults[parts[0]].targets) or "none"
567
+ raise CLIError(
568
+ f"unknown target {parts[1]!r} in include {parts[0]!r} "
569
+ f"(available: {available})", 127
570
+ )
527
571
  available = ", ".join(vault.targets) or "none"
528
572
  raise CLIError(
529
573
  f"unknown target {name!r} (available: {available})", 127
@@ -570,8 +614,11 @@ def cmd_add(args: argparse.Namespace) -> int:
570
614
  if not body.endswith("\n"):
571
615
  body += "\n"
572
616
 
573
- vault.scripts_dir.mkdir(parents=True, exist_ok=True)
574
- path = vault.scripts_dir / f"{name}.sh"
617
+ scripts_dir = vault.local_scripts_dir if args.local else vault.scripts_dir
618
+ scripts_dir.mkdir(parents=True, exist_ok=True)
619
+ if args.local:
620
+ _ignore_local_scripts(vault.hidden_dir)
621
+ path = scripts_dir / f"{name}.sh"
575
622
  if path.exists():
576
623
  raise CLIError(f"'{path}' already exists")
577
624
  path.write_text(body, encoding="utf-8")
@@ -751,52 +798,50 @@ def cmd_activate(args: argparse.Namespace) -> int:
751
798
  print("Deactivated. Use this command or pipe to your shell.", file=sys.stderr)
752
799
  return 0
753
800
 
754
- # Determine which vault to activate
801
+ current = Path.cwd()
802
+ hidden = hidden_dir_name()
755
803
  if args.name is None:
756
- # Activate current .sv directory (if we're in one)
757
- current = Path.cwd()
758
- # Check if current directory IS the .sv directory
759
- hidden = hidden_dir_name()
760
804
  if current.name == hidden and (current / "vault.toml").is_file():
761
- # We're already in a .sv directory, use it
762
- vault_name = current.parent.name
763
- print(f"export SV_ACTIVE_VAULT=\"{vault_name}\"", file=sys.stderr)
764
- print(f"Activated: {vault_name}", file=sys.stderr)
805
+ vault_root = current.parent
806
+ elif (current / hidden / "vault.toml").is_file():
807
+ vault_root = current
765
808
  else:
766
809
  print(f"Error: No vault found in {current}", file=sys.stderr)
767
810
  return 1
768
811
  else:
769
- # Activate named vault
770
812
  if args.name in RESERVED_NAMES:
771
813
  print(f"Error: '{args.name}' is a reserved name", file=sys.stderr)
772
814
  return 1
773
815
 
774
- current = Path.cwd()
775
- # Try: current/VAULT/.sv/vault.toml
776
- vault_path = current / args.name / hidden_dir_name() / "vault.toml"
777
- if not vault_path.is_file():
816
+ vault_root = current / args.name
817
+ if not (vault_root / hidden / "vault.toml").is_file():
778
818
  print(f"Error: Vault '{args.name}' not found", file=sys.stderr)
779
819
  return 1
780
820
 
781
- print(f"export SV_ACTIVE_VAULT=\"{args.name}\"", file=sys.stderr)
782
- print(f"Activated: {args.name}", file=sys.stderr)
783
-
784
- # Print the active vault info
785
821
  try:
786
- vault = _load_vault(None)
787
- print(f"Active vault: {vault.name}", file=sys.stderr)
822
+ vault = load_vault(vault_root)
788
823
  except Exception as e:
789
824
  print(f"Error loading vault: {e}", file=sys.stderr)
790
825
  return 1
791
826
 
827
+ active_path = shlex.quote(str(vault_root.resolve()))
828
+ print(f"export SV_ACTIVE_VAULT={active_path}", file=sys.stderr)
829
+ print(f"Activated: {vault_root.name}", file=sys.stderr)
830
+ print(f"Active vault: {vault.name}", file=sys.stderr)
792
831
  return 0
793
832
 
794
833
 
795
834
  def cmd_names(_args: argparse.Namespace | None = None) -> int:
796
- """Print target names, one per line (used by shell completions)."""
835
+ """Print target names, one per line (used by shell completions).
836
+
837
+ Included targets appear both bare and as `include:target` references.
838
+ """
797
839
  vault = _load_vault(None)
798
840
  for name in vault.targets:
799
841
  print(name)
842
+ for include, nested in vault._nested_vaults.items():
843
+ for name in nested.targets:
844
+ print(f"{include}:{name}")
800
845
  return 0
801
846
 
802
847
 
@@ -880,6 +925,7 @@ def build_parser() -> argparse.ArgumentParser:
880
925
  lst.add_argument(
881
926
  "--json", action="store_true", help="output as a JSON object with include info"
882
927
  )
928
+ lst.add_argument("--all", action="store_true", help="include hidden targets")
883
929
  lst.add_argument(
884
930
  "--nested", action="store_true",
885
931
  help="show all nested vault scripts (default: only root scripts)"
@@ -939,6 +985,7 @@ def build_parser() -> argparse.ArgumentParser:
939
985
  help="read the script body from stdin instead of the template",
940
986
  )
941
987
  add.set_defaults(func=cmd_add)
988
+ add.add_argument("--local", action="store_true", help="create a gitignored local script")
942
989
 
943
990
  edit = sub.add_parser(
944
991
  "edit", help="edit a script, its env, or the vault configuration"
@@ -981,7 +1028,7 @@ def build_parser() -> argparse.ArgumentParser:
981
1028
  nargs="?",
982
1029
  default=None,
983
1030
  metavar="VAULT",
984
- help="vault name to activate (default: use current .sv directory)",
1031
+ help="vault name to activate (default: use current project root or .sv directory)",
985
1032
  )
986
1033
  activate.add_argument(
987
1034
  "--deactivate",