toolbase 0.12.0__tar.gz → 0.14.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 (69) hide show
  1. {toolbase-0.12.0 → toolbase-0.14.0}/CHANGELOG.md +68 -0
  2. {toolbase-0.12.0 → toolbase-0.14.0}/PKG-INFO +1 -3
  3. {toolbase-0.12.0 → toolbase-0.14.0}/README.md +0 -2
  4. {toolbase-0.12.0 → toolbase-0.14.0}/pyproject.toml +1 -1
  5. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/cli.py +440 -81
  6. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/connect/antigravity.py +1 -1
  7. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/envs/__init__.py +2 -0
  8. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/envs/cache.py +39 -0
  9. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/serve/orchestrator.py +8 -0
  10. {toolbase-0.12.0 → toolbase-0.14.0}/LICENSE +0 -0
  11. {toolbase-0.12.0 → toolbase-0.14.0}/MANIFEST.in +0 -0
  12. {toolbase-0.12.0 → toolbase-0.14.0}/setup.cfg +0 -0
  13. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/__init__.py +0 -0
  14. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/_setup_host.py +0 -0
  15. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/_toolkit_host.py +0 -0
  16. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/astro.py +0 -0
  17. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/auth.py +0 -0
  18. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/config.py +0 -0
  19. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/connect/__init__.py +0 -0
  20. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/connect/base.py +0 -0
  21. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/connect/claude_code.py +0 -0
  22. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/connect/codex.py +0 -0
  23. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/connect/opencode.py +0 -0
  24. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/connect/orchestral.py +0 -0
  25. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/envs/bundle_deps.py +0 -0
  26. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/envs/config.py +0 -0
  27. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/envs/discovery.py +0 -0
  28. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/envs/manifest.py +0 -0
  29. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/envs/paths.py +0 -0
  30. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/envs/resolve.py +0 -0
  31. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/envs/schema.py +0 -0
  32. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/hep.py +0 -0
  33. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/ingest.py +0 -0
  34. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/logging/__init__.py +0 -0
  35. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/logging/logger.py +0 -0
  36. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/naming.py +0 -0
  37. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/neutrino.py +0 -0
  38. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/quantum.py +0 -0
  39. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/serve/__init__.py +0 -0
  40. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/serve/bundles.py +0 -0
  41. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/serve/config.py +0 -0
  42. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/serve/loadout_scaffold.py +0 -0
  43. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/serve/loadouts.py +0 -0
  44. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/serve/proxy_tool.py +0 -0
  45. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/setup/__init__.py +0 -0
  46. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/setup/_rpc.py +0 -0
  47. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/setup/context.py +0 -0
  48. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/setup/declarative.py +0 -0
  49. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/setup/downloads.py +0 -0
  50. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/setup/prompts.py +0 -0
  51. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/setup/runner.py +0 -0
  52. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/setup/schema.py +0 -0
  53. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/setup/storage.py +0 -0
  54. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/setup/validate_cache.py +0 -0
  55. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/skills.py +0 -0
  56. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/templates/Dockerfile.template +0 -0
  57. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/templates/README.md.template +0 -0
  58. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/templates/__init__.py.template +0 -0
  59. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/templates/mcp/__init__.py.template +0 -0
  60. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/templates/mcp/server_stdio.py.template +0 -0
  61. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/templates/requirements.txt.template +0 -0
  62. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/templates/setup.py.template +0 -0
  63. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/templates/skills/example_skill.md +0 -0
  64. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/templates/tool_example.py +0 -0
  65. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/templates/toolkit.yaml.template +0 -0
  66. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/toolkit.py +0 -0
  67. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/validation.py +0 -0
  68. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase/versioning.py +0 -0
  69. {toolbase-0.12.0 → toolbase-0.14.0}/toolbase.egg-info/SOURCES.txt +0 -0
@@ -6,6 +6,74 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/), and this
6
6
 
7
7
  ---
8
8
 
9
+ ## [0.14.0] — 2026-08-03
10
+
11
+ ### Added
12
+
13
+ - **Skills are visible in the read commands.** Every command that *changed* a skill knew about them — `tb activate <toolkit>__<skill>`, `tb deactivate`, `tb install --no-skills` — and no command that *showed* anything did. A toolkit's skills were undiscoverable short of listing its `skills/` directory.
14
+
15
+ That made `tb deactivate <toolkit>__<skill>` effectively write-only: skills default on and nothing displayed their state, so turning one off left no trace on any surface. The only evidence was a missing file under `~/.claude/skills/`.
16
+
17
+ ```console
18
+ $ tb list -v
19
+ [skills]
20
+ ✓ using_symbolic
21
+ ✗ heavy_workflow (needs the heavy bundle)
22
+ ✗ old_guide (deactivated — `tb activate calculator__old_guide`)
23
+ ```
24
+
25
+ `tb status` grows a `Skills` section for active toolkits, and says when no harness is wired — skills reach an agent by being copied into the harness's own directory at `tb connect` time, not served over MCP, so an active toolkit's skills are not in front of anyone until something is wired. `tb list --json` grows a `skills` key carrying each skill's own state; combine it with `active` for whether a skill is actually surfaced, since collapsing the two would lose the difference between a skill you turned off and a toolkit you never activated.
26
+
27
+ A skill's state is computed once and rendered by every surface, applying the same filters `surface_skills` applies in the same order, so a listing shows what `tb connect` would actually write.
28
+
29
+ ### Fixed
30
+
31
+ - **`tb activate <toolkit>__<skill>` claimed success on a skill that stayed hidden.** A skill scoped to a bundle is withheld while that bundle's config keys are unset, and activating manages a different filter — the per-skill blocklist — so it could report "already active" about something that would never reach an agent. It now names the bundle and the config keys it is waiting on.
32
+
33
+ - **`tb install --help` described surfacing it does not do.** Step 4 read "Surface the toolkit's skills into `~/.claude/skills/`", and `--no-skills` claimed to prevent that. Install only *reports* which skills a toolkit ships; `tb connect` surfaces them, per harness, and install's `--no-skills` suppresses the note and nothing else.
34
+
35
+ ## [0.13.0] — 2026-08-03
36
+
37
+ ### Added
38
+
39
+ - **`tb clean` removes installs whose Python is gone.** A virtual environment holds no interpreter of its own — it symlinks the one that built it — and `tb install` builds with whichever Python is running toolbase at the time. Install a toolkit from a conda env, delete that env later, and the toolkit is stranded from every project at once, because the cache holds one copy shared by all of them rather than one per environment.
40
+
41
+ Nothing about the install is damaged: the toolkit's files and the whole of its `site-packages` are intact, and only the link to the base Python is gone. `tb clean` removes what can no longer run and prints the exact `tb install` to put each one back — which matters, because removing a slot also clears the pin naming its version, and that pin was the record of what had been there.
42
+
43
+ ```console
44
+ $ tb clean
45
+ ✓ removed calculator@1.4.0
46
+
47
+ Put them back with:
48
+ tb install calculator@1.4.0
49
+ ```
50
+
51
+ Editable installs are reported but never removed: the slot is a symlink to a working copy, and taking one away is a larger decision than this command should make on its own. The `tb install -e <path>` that rebuilds it is printed instead.
52
+
53
+ - **A missing interpreter is reported before serve trips over it.** `tb status` lists it under `Issues`, `tb list` and serve discovery agree, and all three answer from one rule, so they cannot drift apart. Previously nothing noticed: metadata and toolkit files stay intact when the base Python disappears, so discovery called the slot ready, `tb status` listed it as healthy, and serve tried to spawn it on every startup and failed at connect with `mcp connect failed: [Errno 2] No such file or directory` — a message that names the interpreter and explains nothing. Found on a real machine, where one toolkit had been quietly unservable for weeks.
54
+
55
+ Conda-based installs are exempt. They are named rather than pathed, and deciding whether one still exists means shelling out to conda, which is too slow for a listing; they still fail loudly at spawn.
56
+
57
+ ### Fixed
58
+
59
+ - **`tb connect --help` told you to run a flag that does not exist.** Its examples used `-g`, which 0.12.0 replaced with `-u`; running one exits with `No such option: -g`.
60
+
61
+ - **`tb list --help` documented an interface that had been replaced** — a `*` legend for "pinned", a `<-` marker for the serving version, and pins living in `.toolbase/manifest.yaml`. Its sample is now copied from real output rather than written from memory, which is how the old one drifted.
62
+
63
+ Both were found by sweeping every command's help text for removed flags and stale markers, then checking the sweep rather than trusting it: all 18 documented examples that carry flags were extracted and confirmed to parse.
64
+
65
+ - **`tb uninstall` could silently leave every pin in place.** The cleanup that clears version records is wrapped in a broad `except`, intended for absent or unreadable manifests, which also swallowed real errors into a dimmed note. A failure there leaves records naming versions that no longer exist, and those make serve skip the toolkit outright. It now reports as a warning and says what the consequence is.
66
+
67
+ ### Changed
68
+
69
+ - **The end-to-end harnesses all pass, and CI enforces it.** Seven of the thirteen had been failing for months against changes nobody updated them for — none of them product bugs, all stale expectations: hardcoded snake_case tool names where orchestral's MCP layer serves PascalCase, config written from outside a project expecting the user layer when scoped commands default to the project, assertions that `project init` writes a `manifest.yaml` when the directory itself is the marker, and a bundle map treated as one bundle per tool when it is a list.
70
+
71
+ One was failing at its own hand: it never left the repository root, and since `.toolbase/` is the project marker, the checkout is a project — so its own leftovers there supplied the config value the test asserts is unset. It graded its own residue, and differently in CI, which starts clean. The harnesses now run from their temporary trees, and CI fails if a run dirties the working copy.
72
+
73
+ The unit suite was red on CI while green locally for one assertion, on a phrase Rich wrapped mid-line: where the break lands moves with the length of a temp path, and CI's shorter one split the phrase. Console width is pinned for the suite now — 76 assertions match multi-word phrases against captured output, and every one of them was a wrap away from the same failure.
74
+
75
+ - **The synthetic toolkit fixture is a calculator.** It stood for a real third-party toolkit, named throughout test data that has nothing to do with it. The flow under test is unchanged.
76
+
9
77
  ## [0.12.0] — 2026-08-02
10
78
 
11
79
  Reworks how toolbase decides **which version of a toolkit serves**, and separates that decision from installing and from exposing. The model is now one rule with no exceptions: `install` places bits, `tb use` chooses a version, `tb activate` exposes tools. `install` previously did fragments of all three depending on flags, which is where most of the defects below came from.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: toolbase
3
- Version: 0.12.0
3
+ Version: 0.14.0
4
4
  Summary: The community registry and CLI for AI agent toolkits - discover, share, and serve tools to AI agents over MCP
5
5
  Author-email: Alex Roman <toolbase.dev@gmail.com>
6
6
  License: MIT
@@ -53,8 +53,6 @@ harness. Each toolkit installs into its own isolated Python environment,
53
53
  so dependency conflicts between toolkits are never a problem. A toolkit
54
54
  can even ship *only* skills (a **skill pack**).
55
55
 
56
- Full CLI reference: <https://toolbase-ai.com/docs>.
57
-
58
56
  ---
59
57
 
60
58
  ## Install toolbase
@@ -12,8 +12,6 @@ harness. Each toolkit installs into its own isolated Python environment,
12
12
  so dependency conflicts between toolkits are never a problem. A toolkit
13
13
  can even ship *only* skills (a **skill pack**).
14
14
 
15
- Full CLI reference: <https://toolbase-ai.com/docs>.
16
-
17
15
  ---
18
16
 
19
17
  ## Install toolbase
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "toolbase"
7
- version = "0.12.0"
7
+ version = "0.14.0"
8
8
  description = "The community registry and CLI for AI agent toolkits - discover, share, and serve tools to AI agents over MCP"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12"
@@ -1643,13 +1643,14 @@ def _login_browser_flow(mode: str) -> None:
1643
1643
 
1644
1644
 
1645
1645
  # ────────────────────────────────────────────────────────────────────────
1646
- # `toolbase project` — manage project-local manifests.
1646
+ # `toolbase project` — manage project-local state.
1647
1647
  #
1648
- # A project is any directory with a ``.toolbase/manifest.yaml``. Walk-
1649
- # upward discovery makes any subdirectory of a project a project member
1650
- # too. ``tb install`` in a project pins its toolkit version into the
1651
- # project's manifest, so different projects can pin different versions
1652
- # of the same toolkit without conflict.
1648
+ # A project is any directory with a ``.toolbase/``. Walk-upward discovery
1649
+ # makes any subdirectory of a project a project member too. ``tb use`` in
1650
+ # a project records its toolkit version in the project's loadout, so
1651
+ # different projects can choose different versions of the same toolkit
1652
+ # without conflict. ``tb install`` records nothing — it only places bits
1653
+ # in the shared cache.
1653
1654
  #
1654
1655
  # Most users will never run ``tb project init`` explicitly — ``tb
1655
1656
  # install`` in a non-project dir prompts (TTY) "create .toolbase/
@@ -4430,7 +4431,11 @@ def _install_from_tarball(ctx, path: Path, *, version,
4430
4431
  )
4431
4432
  @click.option(
4432
4433
  '--no-skills', 'no_skills', is_flag=True, default=False,
4433
- help="Don't surface the toolkit's skills into ~/.claude/skills/.",
4434
+ help=(
4435
+ "Skip the note about skills this toolkit ships. Install never "
4436
+ "surfaces them itself; `tb connect --no-skills` is what suppresses "
4437
+ "surfacing."
4438
+ ),
4434
4439
  )
4435
4440
  @click.option(
4436
4441
  '--activate', '-a', 'activate_after', is_flag=True, default=False,
@@ -4497,7 +4502,7 @@ def install(ctx, name, version, editable, no_skills, activate_after, bundle_flag
4497
4502
  1. Acquire the toolkit (download from registry, or read a local path)
4498
4503
  2. Create an isolated environment (venv or conda, auto-detected)
4499
4504
  3. Install dependencies, then orchestral-ai + mcp
4500
- 4. Surface the toolkit's skills into ~/.claude/skills/ (unless --no-skills)
4505
+ 4. Report any skills the toolkit ships (`tb connect` surfaces them)
4501
4506
 
4502
4507
  \b
4503
4508
  Examples:
@@ -4507,7 +4512,7 @@ def install(ctx, name, version, editable, no_skills, activate_after, bundle_flag
4507
4512
  toolbase install . # install from cwd
4508
4513
  toolbase install -e . # editable: live link to cwd
4509
4514
  toolbase install aster -a # install and activate here
4510
- toolbase install aster --no-skills # don't touch ~/.claude/skills/
4515
+ toolbase install aster --no-skills # skip the skills note
4511
4516
  toolbase install calculator[basic,symbolic] # only those bundles
4512
4517
  toolbase install calculator --bundle basic # flag form, same effect
4513
4518
  toolbase install calculator[symbolic] # re-install adds bundles
@@ -5254,20 +5259,85 @@ def status_cmd():
5254
5259
  ' [dim](use "tb connect <harness>" to wire one)[/dim]'
5255
5260
  )
5256
5261
 
5262
+ # ── Skills ───────────────────────────────────────────────────────
5263
+ # Skills reach an agent by a different route than tools: they are
5264
+ # copied into the harness's own skill directory by `tb connect`,
5265
+ # not served over MCP. So an active toolkit's skills are not
5266
+ # necessarily in front of the agent -- they are there if a harness
5267
+ # was wired after they were activated. Shown only for active
5268
+ # toolkits, since an inactive one surfaces nothing.
5269
+ skill_rows = []
5270
+ for name in active_rows:
5271
+ slot = next(
5272
+ (c for c in by_name[name] if c.version == resolutions[name].version),
5273
+ None)
5274
+ if slot is None:
5275
+ continue
5276
+ for slug, state, detail in _toolkit_skill_status(name, slot.path):
5277
+ skill_rows.append((f"{name}__{slug}", state, detail, name, slug))
5278
+
5279
+ if skill_rows:
5280
+ console.print()
5281
+ console.print("[bold]Skills[/bold] [dim]— surfaced to harnesses[/dim]")
5282
+ for qualified, state, detail, tk, slug in skill_rows:
5283
+ if state == "on":
5284
+ console.print(f" {qualified}")
5285
+ elif state == "off":
5286
+ console.print(
5287
+ f" {qualified:<40} [dim]off — "
5288
+ f"`tb activate {tk}__{slug}`[/dim]"
5289
+ )
5290
+ else:
5291
+ console.print(
5292
+ f" {qualified:<40} [dim]needs the {detail} bundle[/dim]"
5293
+ )
5294
+ # Only worth saying when something would actually be surfaced;
5295
+ # with every skill off or gated, an unwired harness is not what
5296
+ # is standing between the agent and these.
5297
+ if not wired and any(state == "on" for _q, state, *_r in skill_rows):
5298
+ console.print(
5299
+ " [dim](no harness wired here, so none are in front of "
5300
+ "an agent yet)[/dim]"
5301
+ )
5302
+
5257
5303
  # ── Issues ───────────────────────────────────────────────────────
5304
+ from .envs import interpreter_problem as _interp_problem
5258
5305
  issues: list = []
5306
+ broken_interpreters: list = []
5307
+ # Counted separately from the list: the two problems have different
5308
+ # fixes, and a stale-pin hint under a broken interpreter sends you
5309
+ # to reinstall something whose files are perfectly fine.
5310
+ pin_issue_count = 0
5259
5311
  for name in sorted(by_name):
5260
5312
  r = resolutions[name]
5261
5313
  if not r.ok:
5262
5314
  issues.append(
5263
5315
  f" {name:<22} {str(r.pin):<10} [dim]{r.describe()}[/dim]"
5264
5316
  )
5317
+ pin_issue_count += 1
5318
+ continue
5319
+ # The slot resolves, but its interpreter may be gone -- an
5320
+ # install whose parent environment was deleted. Everything else
5321
+ # here reads healthy, which is exactly why it needs saying.
5322
+ slot = next(
5323
+ (c for c in by_name[name] if c.version == r.version), None)
5324
+ if slot is None:
5325
+ continue
5326
+ meta = dict(slot.install_meta or {})
5327
+ meta.update(slot.legacy_meta or {})
5328
+ problem = _interp_problem(meta)
5329
+ if problem:
5330
+ issues.append(
5331
+ f" {name:<22} {r.version:<10} [dim]{problem}[/dim]"
5332
+ )
5333
+ broken_interpreters.append(name)
5265
5334
  for name, version in sorted(pins.items()):
5266
5335
  if name not in by_name:
5267
5336
  issues.append(
5268
5337
  f" {name:<22} {version:<10} [dim]pinned, not installed[/dim]"
5269
5338
  )
5270
- pin_issues = list(issues)
5339
+ pin_issue_count += 1
5340
+ pin_issues = pin_issue_count > 0
5271
5341
  if active_rows and not wired:
5272
5342
  issues.append(
5273
5343
  " no harness wired here [dim]`tb connect <harness>`[/dim]"
@@ -5283,6 +5353,11 @@ def status_cmd():
5283
5353
  ' [dim]`tb use <toolkit>` clears a pin; '
5284
5354
  '`tb install <toolkit>@<version>` restores it[/dim]'
5285
5355
  )
5356
+ if broken_interpreters:
5357
+ console.print(
5358
+ ' [dim]`tb clean` removes installs that can no longer '
5359
+ 'run, then reinstall them[/dim]'
5360
+ )
5286
5361
 
5287
5362
 
5288
5363
  def _wired_harnesses():
@@ -5343,14 +5418,14 @@ def list_cmd(as_json, verbose):
5343
5418
 
5344
5419
  \b
5345
5420
  $ tb list
5346
- heptapod
5347
- - 0.3 * <- (used yesterday, 8.4 GB)
5348
- - 0.1 (used 3 days ago, 8.2 GB)
5349
- serving 0.3 (pinned to 0.3)
5350
- arxiv-search
5351
- - 0.2 * (used 2 hours ago, 180 MB)
5421
+ ✗ arxiv-search (inactive)
5422
+ 0.2 (used 2 hours ago, 180 MB)
5423
+ ✗ heptapod (inactive)
5424
+ ➤ 0.3 (used yesterday, 8.4 GB)
5425
+ 0.1 (used 3 days ago, 8.2 GB)
5426
+ serving 0.3 (pinned to 0.3)
5352
5427
 
5353
- * = pinned in this project (./.toolbase/manifest.yaml)
5428
+ versions from ./.toolbase/loadouts/default.yaml
5354
5429
 
5355
5430
  \b
5356
5431
  Per-entry fields:
@@ -5359,16 +5434,12 @@ def list_cmd(as_json, verbose):
5359
5434
  ``"never"`` if missing.
5360
5435
  - ``disk_size``: bytes from the per-slot ``.disk_size`` file
5361
5436
  (computed once at install time). ``"—"`` if missing.
5362
- - ``*``: marks the version pinned in the active project's
5363
- manifest (whichever ``.toolbase/manifest.yaml`` discovery
5364
- resolves to). Legend printed only when at least one pin
5365
- applies. Default-project pins are flagged the same way; the
5366
- legend points at the resolved manifest path.
5367
- - ``<-``: marks the version that would actually serve, shown
5368
- only when more than one is installed (with one slot there's
5369
- nothing to disambiguate). The line below the version rows
5370
- gives the reason — a pin, or the highest-wins fallback. A pin
5371
- naming a version that isn't installed is called out there too:
5437
+ - ``➤``: marks the version that would actually serve, shown only
5438
+ when more than one is installed (with one slot there's nothing
5439
+ to disambiguate). The line below the version rows gives the
5440
+ reason — a recorded choice, or the highest-wins fallback — and
5441
+ the footer names the file that choice came from. A version
5442
+ naming a slot that isn't installed is called out there too:
5372
5443
  serve skips such a toolkit entirely.
5373
5444
 
5374
5445
  With ``--json``, output is a flat array of objects:
@@ -5436,6 +5507,23 @@ def list_cmd(as_json, verbose):
5436
5507
  # a subset install. Matches the raw ``bundles`` field in
5437
5508
  # ``.install_meta.yaml``.
5438
5509
  "installed_bundles": (e.install_meta or {}).get("bundles"),
5510
+ # ``skills``: what this slot ships and each one's own
5511
+ # setting -- "on", "off" (deactivated), or "gated" (its
5512
+ # bundle's config requirements are unmet). Empty list
5513
+ # for a toolkit that ships none.
5514
+ #
5515
+ # This is the skill's setting, not the net outcome: an
5516
+ # inactive toolkit surfaces nothing whatever its skills
5517
+ # say, so a consumer wanting "is this in front of an
5518
+ # agent" reads ``state == "on" and active``. Kept
5519
+ # separate because collapsing them would lose the
5520
+ # difference between a skill you turned off and a
5521
+ # toolkit you never activated.
5522
+ "skills": [
5523
+ {"slug": slug, "state": state, "bundle": detail}
5524
+ for slug, state, detail in _toolkit_skill_status(
5525
+ e.name, e.path)
5526
+ ],
5439
5527
  }
5440
5528
  for e in _list_sorted_entries(entries)
5441
5529
  ]
@@ -5682,12 +5770,22 @@ def _list_print_tools_verbose(
5682
5770
  f" [yellow]⚠ not served: {disc.skip_reason}[/yellow]"
5683
5771
  )
5684
5772
  return
5773
+ # A toolkit absent from the active loadout serves nothing, and
5774
+ # surfaces no skills either. Resolved before the early return below
5775
+ # so both exits agree on it.
5776
+ toolkit_active = bool(
5777
+ resolved_loadout is not None and name in resolved_loadout.toolkits
5778
+ )
5779
+
5685
5780
  availability, name_to_bundles = _resolve_bundle_availability(disc)
5686
5781
  if not name_to_bundles:
5687
5782
  console.print(
5688
5783
  " [dim](tools not enumerated in toolkit.yaml; served list "
5689
5784
  "is available at serve time)[/dim]"
5690
5785
  )
5786
+ # Skills are discovered from the filesystem, not the tool
5787
+ # declaration, so they are knowable even here.
5788
+ _list_print_skills(name, disc.path, toolkit_active)
5691
5789
  return
5692
5790
  if multi_version:
5693
5791
  console.print(f" [dim]tools in {disc.path.name}:[/dim]")
@@ -5712,10 +5810,6 @@ def _list_print_tools_verbose(
5712
5810
  for q in resolved_loadout.disabled_tools
5713
5811
  if q.startswith(prefix)
5714
5812
  }
5715
- # A toolkit absent from the active loadout serves nothing.
5716
- toolkit_active = name in resolved_loadout.toolkits
5717
- else:
5718
- toolkit_active = False
5719
5813
 
5720
5814
  # Tools are grouped under the bundle they belong to. A 60-tool
5721
5815
  # toolkit across 12 bundles is unreadable as one alphabetical list,
@@ -5802,6 +5896,41 @@ def _list_print_tools_verbose(
5802
5896
  )
5803
5897
  console.print(f" {mk} {tool}{btag}{clash}")
5804
5898
 
5899
+ # Skills, under their own header. A toolkit's skills are as much of
5900
+ # what it offers as its tools -- they reach the agent by the same
5901
+ # act of activating it -- and nothing else in a read command showed
5902
+ # they existed.
5903
+ _list_print_skills(name, disc.path, toolkit_active)
5904
+
5905
+
5906
+ def _list_print_skills(
5907
+ name: str, toolkit_dir: Path, toolkit_active: bool,
5908
+ ) -> None:
5909
+ """Print a toolkit's skills with the same served/hidden marks tools use.
5910
+
5911
+ ``toolkit_active`` gates the tick the same way it gates a tool's: an
5912
+ inactive toolkit surfaces nothing, so a ✓ beside its skill would say
5913
+ the opposite of what is true.
5914
+ """
5915
+ rows = _toolkit_skill_status(name, toolkit_dir)
5916
+ if not rows:
5917
+ return
5918
+ console.print(" [cyan]\\[skills][/cyan]")
5919
+ for slug, state, detail in rows:
5920
+ if state == "on":
5921
+ mk = "[green]✓[/green]" if toolkit_active else "[red]✗[/red]"
5922
+ console.print(f" {mk} {slug}")
5923
+ elif state == "off":
5924
+ console.print(
5925
+ f" [red]✗[/red] {slug} "
5926
+ f"[dim](deactivated — `tb activate {name}__{slug}`)[/dim]"
5927
+ )
5928
+ else:
5929
+ console.print(
5930
+ f" [red]✗[/red] {slug} "
5931
+ f"[dim](needs the {detail} bundle)[/dim]"
5932
+ )
5933
+
5805
5934
 
5806
5935
  def _list_sorted_entries(entries):
5807
5936
  """Return entries deterministically sorted by (name asc, version desc).
@@ -6055,6 +6184,189 @@ def use_cmd(target, user_scope, project_scope, private_scope):
6055
6184
  console.print("[dim]Restart your agent session to pick this up.[/dim]")
6056
6185
 
6057
6186
 
6187
+ def _drop_stale_version_records(name: str) -> None:
6188
+ """Forget recorded versions of ``name`` whose slots are gone.
6189
+
6190
+ Called after anything that deletes slots — ``uninstall`` and
6191
+ ``clean``. A pin or loadout entry naming a version that no longer
6192
+ exists doesn't fall back: serve skips the toolkit outright, so it
6193
+ stays broken even after a good reinstall of a different version.
6194
+
6195
+ The active project AND the default-project are both cleaned. The
6196
+ binaries are gone globally, so a record naming them dangles wherever
6197
+ it lives, and pre-0.12 installs pinned the default-project even when
6198
+ run from inside a project — cleaning only the active one orphaned
6199
+ that pin and made serve skip the toolkit everywhere the
6200
+ default-project applies.
6201
+
6202
+ Never creates a project: absent manifests have no pin to remove,
6203
+ which ``remove_pin`` treats as a no-op.
6204
+ """
6205
+ try:
6206
+ from .envs import (
6207
+ local_manifest_path as _local_manifest_path,
6208
+ load_manifest as _load_manifest_for_pins,
6209
+ default_project_root as _default_project_root,
6210
+ project_manifest_path as _project_manifest_path,
6211
+ list_versions as _list_versions,
6212
+ remove_pin as _remove_pin,
6213
+ )
6214
+ project_root, _source = _resolve_active_project_root()
6215
+ roots = [project_root]
6216
+ default_root = _default_project_root()
6217
+ if default_root.resolve() != project_root.resolve():
6218
+ roots.append(default_root)
6219
+ layers = []
6220
+ for root in roots:
6221
+ committed = _project_manifest_path(root)
6222
+ layers += [committed, _local_manifest_path(committed)]
6223
+
6224
+ remaining = _list_versions(name)
6225
+ for layer in layers:
6226
+ if not remaining:
6227
+ _remove_pin(layer, name)
6228
+ continue
6229
+ # Some versions remain. A pin still naming a removed version
6230
+ # dangles — serving would SKIP the toolkit entirely even
6231
+ # though usable slots exist. Remove it loudly; unpinned
6232
+ # resolution falls back to the highest remaining slot.
6233
+ pins = {e.name: e.version
6234
+ for e in _load_manifest_for_pins(layer).toolkits}
6235
+ pinned = pins.get(name)
6236
+ if pinned is not None and pinned not in remaining:
6237
+ _remove_pin(layer, name)
6238
+ console.print(
6239
+ f"[yellow]⚠ Removed stale pin {name}@{pinned} from "
6240
+ f"{_display_path(layer)} — {', '.join(remaining)} "
6241
+ f"remain[/yellow]"
6242
+ )
6243
+
6244
+ # And the loadouts, which is where versions actually live now.
6245
+ # Same rule, newer file.
6246
+ _clear_stale_loadout_versions(name, roots, remaining)
6247
+ except Exception as e:
6248
+ # Loud, not dim. This catch exists for unreadable or absent
6249
+ # manifests, but it will swallow anything -- during this
6250
+ # refactor it turned a NameError into a note nobody would read,
6251
+ # while pins quietly survived the uninstall that should have
6252
+ # cleared them. If it fires, stale records are still on disk and
6253
+ # serve will skip the toolkit.
6254
+ console.print(
6255
+ f"[yellow]⚠ Could not clear version records for {name}: {e}[/yellow]"
6256
+ )
6257
+ console.print(
6258
+ " [dim]A pin naming a removed version makes serve skip the "
6259
+ "toolkit; check `tb status`.[/dim]"
6260
+ )
6261
+
6262
+
6263
+ @main.command(name="clean")
6264
+ @click.option("--dry-run", is_flag=True, default=False,
6265
+ help="List what would be removed and stop.")
6266
+ @_interactive_options
6267
+ def clean_cmd(dry_run, yes, no_, no_input):
6268
+ """Remove installs that can no longer run.
6269
+
6270
+ \b
6271
+ For a toolkit whose Python is gone — usually because it was
6272
+ installed from an environment (a conda env, say) that was later
6273
+ deleted. A venv only symlinks the interpreter that built it, so
6274
+ removing that environment strands the toolkit.
6275
+
6276
+ \b
6277
+ Prints the command to put each one back. Reinstalling builds
6278
+ against whatever Python is running toolbase now.
6279
+
6280
+ \b
6281
+ Clears each toolkit's pins and loadout entries too, so nothing is
6282
+ left naming a version that no longer exists — a dangling entry makes
6283
+ serve skip the toolkit even after a good reinstall.
6284
+
6285
+ \b
6286
+ Editable installs are reported but not removed: the slot is a
6287
+ symlink to your working copy, and taking it away is a bigger call
6288
+ than this command should make on its own. The exact `tb install -e`
6289
+ to rebuild it is printed.
6290
+ """
6291
+ from .envs import walk_cache, interpreter_problem
6292
+
6293
+ broken, editable = [], []
6294
+ for e in walk_cache():
6295
+ meta = dict(e.install_meta or {})
6296
+ meta.update(e.legacy_meta or {})
6297
+ if not interpreter_problem(meta):
6298
+ continue
6299
+ if meta.get("editable") or meta.get("source_path"):
6300
+ editable.append((e, meta))
6301
+ else:
6302
+ broken.append((e, meta))
6303
+
6304
+ if not broken and not editable:
6305
+ console.print("Nothing to clean — every install has a working Python.")
6306
+ return
6307
+
6308
+ for entry, meta in editable:
6309
+ console.print(
6310
+ f"[yellow]![/yellow] {entry.name}@{entry.version} "
6311
+ f"[dim]editable, left alone — "
6312
+ f"reinstall with `tb install -e "
6313
+ f"{meta.get('source_path', '<path>')}`[/dim]"
6314
+ )
6315
+
6316
+ if not broken:
6317
+ return
6318
+
6319
+ console.print("These cannot run and would be removed:")
6320
+ for entry, _ in broken:
6321
+ console.print(f" {entry.name}@{entry.version} [dim]{entry.path}[/dim]")
6322
+ if dry_run:
6323
+ console.print("\n[dim]--dry-run: nothing removed.[/dim]")
6324
+ return
6325
+
6326
+ mode = _resolve_prompt_mode(yes, no_, no_input)
6327
+ if not _confirm(
6328
+ f"Remove {len(broken)} unusable install(s)?",
6329
+ default=False, mode=mode, consequential=True,
6330
+ ):
6331
+ console.print("[dim]Nothing removed.[/dim]")
6332
+ return
6333
+
6334
+ removed, restore = 0, []
6335
+ for entry, _ in broken:
6336
+ try:
6337
+ shutil.rmtree(entry.path)
6338
+ # cache/<name>/<version>/ — drop <name>/ once its last
6339
+ # version goes, so the walker stops reporting a toolkit
6340
+ # with nothing in it.
6341
+ parent = entry.path.parent
6342
+ if parent.is_dir() and not any(parent.iterdir()):
6343
+ parent.rmdir()
6344
+ except OSError as exc:
6345
+ console.print(f"[red]✗[/red] {entry.name}@{entry.version}: {exc}")
6346
+ continue
6347
+ # Same cleanup uninstall does: a pin or loadout entry naming a
6348
+ # slot that is gone makes serve skip the toolkit outright.
6349
+ _drop_stale_version_records(entry.name)
6350
+ _uninstall_cleanup_loadouts(entry.name)
6351
+ console.print(f"[green]✓[/green] removed {entry.name}@{entry.version}")
6352
+ restore.append(f"tb install {entry.name}@{entry.version}")
6353
+ removed += 1
6354
+
6355
+ if removed:
6356
+ # Removing costs a reinstall, so hand back the exact commands
6357
+ # rather than leaving the version to be remembered -- the pin
6358
+ # naming it was just cleared, which is what made it safe to
6359
+ # remove and also what erased the record of what was here.
6360
+ running = f"{sys.version_info.major}.{sys.version_info.minor}"
6361
+ console.print(f"\nPut them back with:")
6362
+ for cmd in restore:
6363
+ console.print(f" {cmd}")
6364
+ console.print(
6365
+ f"[dim]They will build against Python {running} — whatever "
6366
+ f"toolbase is running now.[/dim]"
6367
+ )
6368
+
6369
+
6058
6370
  @main.command()
6059
6371
  @click.argument('name')
6060
6372
  @_interactive_options
@@ -6185,52 +6497,7 @@ def uninstall(name, yes, no_, no_input):
6185
6497
  #
6186
6498
  # Uninstall never creates a project: absent manifests simply have no
6187
6499
  # pin to remove, which ``remove_pin`` treats as a no-op.
6188
- try:
6189
- from .envs import (
6190
- local_manifest_path as _local_manifest_path,
6191
- load_manifest as _load_manifest_for_pins,
6192
- default_project_root as _default_project_root,
6193
- )
6194
- project_root, _source = _resolve_active_project_root()
6195
- roots = [project_root]
6196
- default_root = _default_project_root()
6197
- if default_root.resolve() != project_root.resolve():
6198
- roots.append(default_root)
6199
- layers = []
6200
- for root in roots:
6201
- committed = _project_manifest_path(root)
6202
- layers += [committed, _local_manifest_path(committed)]
6203
-
6204
- remaining = _list_versions(name)
6205
- for layer in layers:
6206
- if not remaining:
6207
- _remove_pin(layer, name)
6208
- continue
6209
- # Some versions remain. A pin still naming a version we just
6210
- # removed now dangles — serving would SKIP the toolkit
6211
- # entirely ("pinned version not installed") even though
6212
- # usable slots exist. Remove it loudly; unpinned resolution
6213
- # falls back to the highest remaining slot.
6214
- pins = {e.name: e.version
6215
- for e in _load_manifest_for_pins(layer).toolkits}
6216
- pinned = pins.get(name)
6217
- if pinned is not None and pinned not in remaining:
6218
- _remove_pin(layer, name)
6219
- console.print(
6220
- f"[yellow]⚠ Removed stale pin {name}@{pinned} from "
6221
- f"{_display_path(layer)} — {', '.join(remaining)} "
6222
- f"remain[/yellow]"
6223
- )
6224
-
6225
- # And the loadouts, which is where versions actually live now.
6226
- # A version naming a slot we just deleted makes serve skip the
6227
- # toolkit outright, so it has to go the same way manifest pins
6228
- # do — same rule, newer file.
6229
- _clear_stale_loadout_versions(name, roots, remaining)
6230
- except Exception as e:
6231
- console.print(
6232
- f"[dim]Note: could not update project manifest: {e}[/dim]"
6233
- )
6500
+ _drop_stale_version_records(name)
6234
6501
 
6235
6502
  # Skills + default-loadout cleanup — only when ALL versions are gone.
6236
6503
  if not _list_versions(name):
@@ -6909,14 +7176,63 @@ def activate(item, user_scope, project_scope):
6909
7176
  result = _activate_skill(
6910
7177
  tk2, sub, scope=scope, project_root=project_root,
6911
7178
  )
6912
- else:
6913
- result = _activate(item, scope=scope, project_root=project_root)
7179
+ _print_mutation(result)
7180
+ # Activating clears a `tb deactivate`; it cannot clear a
7181
+ # bundle gate. Without this the command reports success (or
7182
+ # "already active") on a skill that stays unsurfaced, which
7183
+ # is the one case where the message and the outcome disagree.
7184
+ _warn_if_skill_is_gated(tk2, sub)
7185
+ return
7186
+ result = _activate(item, scope=scope, project_root=project_root)
6914
7187
  except LoadoutItemError as e:
6915
7188
  console.print(f"[red]✗ {e}[/red]")
6916
7189
  sys.exit(2)
6917
7190
  _print_mutation(result)
6918
7191
 
6919
7192
 
7193
+ def _warn_if_skill_is_gated(tk: str, slug: str) -> None:
7194
+ """Say so when a skill won't surface despite being active.
7195
+
7196
+ A skill scoped to a bundle is withheld while that bundle's config
7197
+ keys are unset, and no amount of activating changes that -- the two
7198
+ are separate filters. Naming the keys turns a silent no-op into
7199
+ something actionable.
7200
+ """
7201
+ slot = _toolkit_slot_dir(tk)
7202
+ if slot is None:
7203
+ return
7204
+ row = next(
7205
+ (r for r in _toolkit_skill_status(tk, slot) if r[0] == slug), None)
7206
+ if row is None or row[1] != "gated":
7207
+ return
7208
+ bundle = row[2]
7209
+ console.print(
7210
+ f"[yellow]⚠ Not surfaced: {tk}__{slug} is scoped to the "
7211
+ f"{bundle} bundle, which isn't configured.[/yellow]"
7212
+ )
7213
+ missing = _missing_config_keys_for_bundle(tk, slot, bundle)
7214
+ if missing:
7215
+ console.print(
7216
+ f" [dim]Set {', '.join(missing)} with "
7217
+ f"`tb config set {tk} <key> <value>`.[/dim]"
7218
+ )
7219
+
7220
+
7221
+ def _missing_config_keys_for_bundle(tk: str, slot: Path, bundle: str) -> list:
7222
+ """Config keys the named bundle is waiting on, for a gated message."""
7223
+ try:
7224
+ from .serve.orchestrator import (
7225
+ discover_toolkits, _resolve_bundle_availability,
7226
+ )
7227
+ disc = next((d for d in discover_toolkits() if d.name == tk), None)
7228
+ if disc is None:
7229
+ return []
7230
+ availability, _map = _resolve_bundle_availability(disc)
7231
+ return list(availability.dropped_bundles.get(bundle) or [])
7232
+ except Exception:
7233
+ return []
7234
+
7235
+
6920
7236
  @main.command()
6921
7237
  @click.argument('item')
6922
7238
  @_scope_flags
@@ -7388,6 +7704,49 @@ def _resolve_disabled_skills(name: str) -> set:
7388
7704
  return set(getattr(sel, "disabled_skills", []) or [])
7389
7705
 
7390
7706
 
7707
+ def _toolkit_skill_status(name: str, toolkit_dir: Path) -> "list[tuple]":
7708
+ """A toolkit's skills and whether each would be surfaced.
7709
+
7710
+ Returns ``[(slug, state, detail)]`` sorted by slug, where state is
7711
+ ``"on"``, ``"off"`` (deactivated in the active loadout) or
7712
+ ``"gated"`` (scoped to a bundle whose config requirements aren't
7713
+ met, so its tools aren't served either and the guide would mislead).
7714
+
7715
+ One function because three surfaces report this -- ``tb list -v``,
7716
+ ``tb status``, and the surfacing that ``tb connect`` actually
7717
+ performs -- and they answer the same question. It applies the same
7718
+ two filters ``skills.surface_skills`` applies, in the same order, so
7719
+ what is shown is what would be written into a harness.
7720
+ """
7721
+ from .skills import discover_skills, parse_frontmatter
7722
+
7723
+ sources = discover_skills(toolkit_dir)
7724
+ if not sources:
7725
+ return []
7726
+ disabled = _resolve_disabled_skills(name)
7727
+ available = _available_bundles_for_surface(name, toolkit_dir)
7728
+
7729
+ rows = []
7730
+ for src in sources:
7731
+ if src.slug in disabled:
7732
+ rows.append((src.slug, "off", None))
7733
+ continue
7734
+ bundle = None
7735
+ try:
7736
+ fm, _body = parse_frontmatter(
7737
+ src.doc.read_text(encoding="utf-8"))
7738
+ bundle = fm.bundle if fm else None
7739
+ except Exception:
7740
+ # An unreadable guide is the author's problem, not a reason
7741
+ # to hide the skill from a listing.
7742
+ pass
7743
+ if bundle is not None and available is not None and bundle not in available:
7744
+ rows.append((src.slug, "gated", bundle))
7745
+ else:
7746
+ rows.append((src.slug, "on", bundle))
7747
+ return sorted(rows)
7748
+
7749
+
7391
7750
  def _surface_skills_for_connect(adapter, *, no_skills: bool = False) -> None:
7392
7751
  """Surface every activated toolkit's skills into ``adapter``'s skill
7393
7752
  surface (``~/.claude/skills`` or ``~/.codex/prompts``). Best-effort:
@@ -7481,8 +7840,8 @@ def connect(harness, user_scope, project_scope, loadout_name, remove, dry_run,
7481
7840
  \b
7482
7841
  Examples:
7483
7842
  tb connect claude-code # project: .mcp.json here (default)
7484
- tb connect claude-code -g # user: ~/.claude.json (every session)
7485
- tb connect antigravity -g # agy CLI + IDE: ~/.gemini/config/
7843
+ tb connect claude-code -u # user: ~/.claude.json (every session)
7844
+ tb connect antigravity -u # agy CLI + IDE: ~/.gemini/config/
7486
7845
  tb connect claude-code --loadout paper
7487
7846
  tb connect claude-code --remove
7488
7847
  tb connect orchestral # write .toolbase/agent.py
@@ -70,7 +70,7 @@ class AntigravityAdapter(HarnessAdapter):
70
70
  return (
71
71
  "the agy CLI does not load a workspace .agents/mcp_config.json — "
72
72
  "only the IDE and SDK are documented to. Use "
73
- "`tb connect antigravity -g` if you're on the CLI."
73
+ "`tb connect antigravity -u` if you're on the CLI."
74
74
  )
75
75
 
76
76
  # ── detection ────────────────────────────────────────────────────
@@ -100,6 +100,7 @@ from .cache import (
100
100
  LEGACY_META_FILE,
101
101
  write_install_meta,
102
102
  read_install_meta,
103
+ interpreter_problem,
103
104
  write_legacy_meta,
104
105
  read_legacy_meta,
105
106
  touch_last_used,
@@ -163,6 +164,7 @@ __all__ = [
163
164
  "LEGACY_META_FILE",
164
165
  "write_install_meta",
165
166
  "read_install_meta",
167
+ "interpreter_problem",
166
168
  "write_legacy_meta",
167
169
  "read_legacy_meta",
168
170
  "touch_last_used",
@@ -127,6 +127,45 @@ def read_install_meta(slot_dir: Path) -> Optional[Dict[str, Any]]:
127
127
  return {k: v for k, v in raw.items() if k != "schema_version"}
128
128
 
129
129
 
130
+ def interpreter_problem(meta: Dict[str, Any]) -> Optional[str]:
131
+ """Why this slot's Python can't be run, or None if it can.
132
+
133
+ A venv doesn't contain an interpreter -- it symlinks the one that
134
+ built it, and ``tb install`` builds with whatever Python was running
135
+ it at the time. Delete that environment (a conda env, say) and the
136
+ slot is left pointing at nothing, from every environment at once,
137
+ because there is only one copy of the slot.
138
+
139
+ Nothing else notices. The metadata is intact, the toolkit's files are
140
+ intact, so discovery calls the slot ready and serve tries to spawn it
141
+ on every startup, failing at connect with ``mcp connect failed:
142
+ [Errno 2] No such file or directory``. Checking here turns that into
143
+ something ``tb status`` can say before an agent session loses its
144
+ tools.
145
+
146
+ Takes the merged metadata dict (``install_meta`` plus the legacy
147
+ ``.tb_meta.json`` keys) rather than a slot dir, so serve discovery,
148
+ ``tb status`` and ``tb list`` all answer from the same rule.
149
+
150
+ Conda slots are named, not pathed -- resolving whether an env still
151
+ exists means shelling out to conda, which is too slow for a listing.
152
+ They are reported healthy here and still fail loudly at spawn.
153
+ """
154
+ if meta.get("environment") != "venv" and meta.get("install_method") != "venv":
155
+ return None
156
+ python_path = meta.get("python_path")
157
+ if not python_path:
158
+ # Spawn raises its own clear error for this; don't double-report.
159
+ return None
160
+ # exists() resolves symlinks, so a link whose target is gone is False
161
+ # -- which is the whole case this exists to catch.
162
+ if not Path(python_path).exists():
163
+ return "interpreter missing"
164
+ if not os.access(python_path, os.X_OK):
165
+ return "interpreter not executable"
166
+ return None
167
+
168
+
130
169
  def installed_bundles(slot_dir: Path) -> Optional[List[str]]:
131
170
  """Return the list of installed bundles for a slot, or None for "all".
132
171
 
@@ -247,6 +247,14 @@ def discover_toolkits(toolkits_dir: Optional[Path] = None) -> List[ToolkitDiscov
247
247
  skip = "Docker mode (not yet supported)"
248
248
  elif env not in ("venv", "conda"):
249
249
  skip = f"unknown environment type: {env!r}"
250
+ if not skip:
251
+ # A venv whose base interpreter was deleted still looks
252
+ # perfectly installed. Catch it here rather than letting
253
+ # spawn fail with "mcp connect failed: [Errno 2]".
254
+ from ..envs import interpreter_problem
255
+ problem = interpreter_problem(meta)
256
+ if problem:
257
+ skip = f"{problem} — run `tb clean`, then reinstall"
250
258
 
251
259
  found.append(ToolkitDiscovery(
252
260
  name=name, path=chosen.path, meta=meta, skip_reason=skip,
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes