toolbase 0.12.0__tar.gz → 0.13.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.13.0}/CHANGELOG.md +42 -0
  2. {toolbase-0.12.0 → toolbase-0.13.0}/PKG-INFO +1 -3
  3. {toolbase-0.12.0 → toolbase-0.13.0}/README.md +0 -2
  4. {toolbase-0.12.0 → toolbase-0.13.0}/pyproject.toml +1 -1
  5. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/cli.py +236 -72
  6. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/connect/antigravity.py +1 -1
  7. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/envs/__init__.py +2 -0
  8. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/envs/cache.py +39 -0
  9. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/serve/orchestrator.py +8 -0
  10. {toolbase-0.12.0 → toolbase-0.13.0}/LICENSE +0 -0
  11. {toolbase-0.12.0 → toolbase-0.13.0}/MANIFEST.in +0 -0
  12. {toolbase-0.12.0 → toolbase-0.13.0}/setup.cfg +0 -0
  13. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/__init__.py +0 -0
  14. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/_setup_host.py +0 -0
  15. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/_toolkit_host.py +0 -0
  16. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/astro.py +0 -0
  17. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/auth.py +0 -0
  18. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/config.py +0 -0
  19. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/connect/__init__.py +0 -0
  20. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/connect/base.py +0 -0
  21. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/connect/claude_code.py +0 -0
  22. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/connect/codex.py +0 -0
  23. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/connect/opencode.py +0 -0
  24. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/connect/orchestral.py +0 -0
  25. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/envs/bundle_deps.py +0 -0
  26. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/envs/config.py +0 -0
  27. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/envs/discovery.py +0 -0
  28. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/envs/manifest.py +0 -0
  29. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/envs/paths.py +0 -0
  30. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/envs/resolve.py +0 -0
  31. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/envs/schema.py +0 -0
  32. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/hep.py +0 -0
  33. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/ingest.py +0 -0
  34. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/logging/__init__.py +0 -0
  35. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/logging/logger.py +0 -0
  36. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/naming.py +0 -0
  37. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/neutrino.py +0 -0
  38. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/quantum.py +0 -0
  39. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/serve/__init__.py +0 -0
  40. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/serve/bundles.py +0 -0
  41. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/serve/config.py +0 -0
  42. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/serve/loadout_scaffold.py +0 -0
  43. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/serve/loadouts.py +0 -0
  44. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/serve/proxy_tool.py +0 -0
  45. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/setup/__init__.py +0 -0
  46. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/setup/_rpc.py +0 -0
  47. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/setup/context.py +0 -0
  48. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/setup/declarative.py +0 -0
  49. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/setup/downloads.py +0 -0
  50. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/setup/prompts.py +0 -0
  51. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/setup/runner.py +0 -0
  52. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/setup/schema.py +0 -0
  53. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/setup/storage.py +0 -0
  54. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/setup/validate_cache.py +0 -0
  55. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/skills.py +0 -0
  56. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/templates/Dockerfile.template +0 -0
  57. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/templates/README.md.template +0 -0
  58. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/templates/__init__.py.template +0 -0
  59. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/templates/mcp/__init__.py.template +0 -0
  60. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/templates/mcp/server_stdio.py.template +0 -0
  61. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/templates/requirements.txt.template +0 -0
  62. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/templates/setup.py.template +0 -0
  63. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/templates/skills/example_skill.md +0 -0
  64. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/templates/tool_example.py +0 -0
  65. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/templates/toolkit.yaml.template +0 -0
  66. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/toolkit.py +0 -0
  67. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/validation.py +0 -0
  68. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase/versioning.py +0 -0
  69. {toolbase-0.12.0 → toolbase-0.13.0}/toolbase.egg-info/SOURCES.txt +0 -0
@@ -6,6 +6,48 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/), and this
6
6
 
7
7
  ---
8
8
 
9
+ ## [0.13.0] — 2026-08-03
10
+
11
+ ### Added
12
+
13
+ - **`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.
14
+
15
+ 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.
16
+
17
+ ```console
18
+ $ tb clean
19
+ ✓ removed calculator@1.4.0
20
+
21
+ Put them back with:
22
+ tb install calculator@1.4.0
23
+ ```
24
+
25
+ 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.
26
+
27
+ - **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.
28
+
29
+ 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.
30
+
31
+ ### Fixed
32
+
33
+ - **`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`.
34
+
35
+ - **`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.
36
+
37
+ 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.
38
+
39
+ - **`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.
40
+
41
+ ### Changed
42
+
43
+ - **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.
44
+
45
+ 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.
46
+
47
+ 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.
48
+
49
+ - **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.
50
+
9
51
  ## [0.12.0] — 2026-08-02
10
52
 
11
53
  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.13.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.13.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/
@@ -5255,19 +5256,43 @@ def status_cmd():
5255
5256
  )
5256
5257
 
5257
5258
  # ── Issues ───────────────────────────────────────────────────────
5259
+ from .envs import interpreter_problem as _interp_problem
5258
5260
  issues: list = []
5261
+ broken_interpreters: list = []
5262
+ # Counted separately from the list: the two problems have different
5263
+ # fixes, and a stale-pin hint under a broken interpreter sends you
5264
+ # to reinstall something whose files are perfectly fine.
5265
+ pin_issue_count = 0
5259
5266
  for name in sorted(by_name):
5260
5267
  r = resolutions[name]
5261
5268
  if not r.ok:
5262
5269
  issues.append(
5263
5270
  f" {name:<22} {str(r.pin):<10} [dim]{r.describe()}[/dim]"
5264
5271
  )
5272
+ pin_issue_count += 1
5273
+ continue
5274
+ # The slot resolves, but its interpreter may be gone -- an
5275
+ # install whose parent environment was deleted. Everything else
5276
+ # here reads healthy, which is exactly why it needs saying.
5277
+ slot = next(
5278
+ (c for c in by_name[name] if c.version == r.version), None)
5279
+ if slot is None:
5280
+ continue
5281
+ meta = dict(slot.install_meta or {})
5282
+ meta.update(slot.legacy_meta or {})
5283
+ problem = _interp_problem(meta)
5284
+ if problem:
5285
+ issues.append(
5286
+ f" {name:<22} {r.version:<10} [dim]{problem}[/dim]"
5287
+ )
5288
+ broken_interpreters.append(name)
5265
5289
  for name, version in sorted(pins.items()):
5266
5290
  if name not in by_name:
5267
5291
  issues.append(
5268
5292
  f" {name:<22} {version:<10} [dim]pinned, not installed[/dim]"
5269
5293
  )
5270
- pin_issues = list(issues)
5294
+ pin_issue_count += 1
5295
+ pin_issues = pin_issue_count > 0
5271
5296
  if active_rows and not wired:
5272
5297
  issues.append(
5273
5298
  " no harness wired here [dim]`tb connect <harness>`[/dim]"
@@ -5283,6 +5308,11 @@ def status_cmd():
5283
5308
  ' [dim]`tb use <toolkit>` clears a pin; '
5284
5309
  '`tb install <toolkit>@<version>` restores it[/dim]'
5285
5310
  )
5311
+ if broken_interpreters:
5312
+ console.print(
5313
+ ' [dim]`tb clean` removes installs that can no longer '
5314
+ 'run, then reinstall them[/dim]'
5315
+ )
5286
5316
 
5287
5317
 
5288
5318
  def _wired_harnesses():
@@ -5343,14 +5373,14 @@ def list_cmd(as_json, verbose):
5343
5373
 
5344
5374
  \b
5345
5375
  $ 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)
5376
+ ✗ arxiv-search (inactive)
5377
+ 0.2 (used 2 hours ago, 180 MB)
5378
+ ✗ heptapod (inactive)
5379
+ ➤ 0.3 (used yesterday, 8.4 GB)
5380
+ 0.1 (used 3 days ago, 8.2 GB)
5381
+ serving 0.3 (pinned to 0.3)
5352
5382
 
5353
- * = pinned in this project (./.toolbase/manifest.yaml)
5383
+ versions from ./.toolbase/loadouts/default.yaml
5354
5384
 
5355
5385
  \b
5356
5386
  Per-entry fields:
@@ -5359,16 +5389,12 @@ def list_cmd(as_json, verbose):
5359
5389
  ``"never"`` if missing.
5360
5390
  - ``disk_size``: bytes from the per-slot ``.disk_size`` file
5361
5391
  (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:
5392
+ - ``➤``: marks the version that would actually serve, shown only
5393
+ when more than one is installed (with one slot there's nothing
5394
+ to disambiguate). The line below the version rows gives the
5395
+ reason — a recorded choice, or the highest-wins fallback — and
5396
+ the footer names the file that choice came from. A version
5397
+ naming a slot that isn't installed is called out there too:
5372
5398
  serve skips such a toolkit entirely.
5373
5399
 
5374
5400
  With ``--json``, output is a flat array of objects:
@@ -6055,6 +6081,189 @@ def use_cmd(target, user_scope, project_scope, private_scope):
6055
6081
  console.print("[dim]Restart your agent session to pick this up.[/dim]")
6056
6082
 
6057
6083
 
6084
+ def _drop_stale_version_records(name: str) -> None:
6085
+ """Forget recorded versions of ``name`` whose slots are gone.
6086
+
6087
+ Called after anything that deletes slots — ``uninstall`` and
6088
+ ``clean``. A pin or loadout entry naming a version that no longer
6089
+ exists doesn't fall back: serve skips the toolkit outright, so it
6090
+ stays broken even after a good reinstall of a different version.
6091
+
6092
+ The active project AND the default-project are both cleaned. The
6093
+ binaries are gone globally, so a record naming them dangles wherever
6094
+ it lives, and pre-0.12 installs pinned the default-project even when
6095
+ run from inside a project — cleaning only the active one orphaned
6096
+ that pin and made serve skip the toolkit everywhere the
6097
+ default-project applies.
6098
+
6099
+ Never creates a project: absent manifests have no pin to remove,
6100
+ which ``remove_pin`` treats as a no-op.
6101
+ """
6102
+ try:
6103
+ from .envs import (
6104
+ local_manifest_path as _local_manifest_path,
6105
+ load_manifest as _load_manifest_for_pins,
6106
+ default_project_root as _default_project_root,
6107
+ project_manifest_path as _project_manifest_path,
6108
+ list_versions as _list_versions,
6109
+ remove_pin as _remove_pin,
6110
+ )
6111
+ project_root, _source = _resolve_active_project_root()
6112
+ roots = [project_root]
6113
+ default_root = _default_project_root()
6114
+ if default_root.resolve() != project_root.resolve():
6115
+ roots.append(default_root)
6116
+ layers = []
6117
+ for root in roots:
6118
+ committed = _project_manifest_path(root)
6119
+ layers += [committed, _local_manifest_path(committed)]
6120
+
6121
+ remaining = _list_versions(name)
6122
+ for layer in layers:
6123
+ if not remaining:
6124
+ _remove_pin(layer, name)
6125
+ continue
6126
+ # Some versions remain. A pin still naming a removed version
6127
+ # dangles — serving would SKIP the toolkit entirely even
6128
+ # though usable slots exist. Remove it loudly; unpinned
6129
+ # resolution falls back to the highest remaining slot.
6130
+ pins = {e.name: e.version
6131
+ for e in _load_manifest_for_pins(layer).toolkits}
6132
+ pinned = pins.get(name)
6133
+ if pinned is not None and pinned not in remaining:
6134
+ _remove_pin(layer, name)
6135
+ console.print(
6136
+ f"[yellow]⚠ Removed stale pin {name}@{pinned} from "
6137
+ f"{_display_path(layer)} — {', '.join(remaining)} "
6138
+ f"remain[/yellow]"
6139
+ )
6140
+
6141
+ # And the loadouts, which is where versions actually live now.
6142
+ # Same rule, newer file.
6143
+ _clear_stale_loadout_versions(name, roots, remaining)
6144
+ except Exception as e:
6145
+ # Loud, not dim. This catch exists for unreadable or absent
6146
+ # manifests, but it will swallow anything -- during this
6147
+ # refactor it turned a NameError into a note nobody would read,
6148
+ # while pins quietly survived the uninstall that should have
6149
+ # cleared them. If it fires, stale records are still on disk and
6150
+ # serve will skip the toolkit.
6151
+ console.print(
6152
+ f"[yellow]⚠ Could not clear version records for {name}: {e}[/yellow]"
6153
+ )
6154
+ console.print(
6155
+ " [dim]A pin naming a removed version makes serve skip the "
6156
+ "toolkit; check `tb status`.[/dim]"
6157
+ )
6158
+
6159
+
6160
+ @main.command(name="clean")
6161
+ @click.option("--dry-run", is_flag=True, default=False,
6162
+ help="List what would be removed and stop.")
6163
+ @_interactive_options
6164
+ def clean_cmd(dry_run, yes, no_, no_input):
6165
+ """Remove installs that can no longer run.
6166
+
6167
+ \b
6168
+ For a toolkit whose Python is gone — usually because it was
6169
+ installed from an environment (a conda env, say) that was later
6170
+ deleted. A venv only symlinks the interpreter that built it, so
6171
+ removing that environment strands the toolkit.
6172
+
6173
+ \b
6174
+ Prints the command to put each one back. Reinstalling builds
6175
+ against whatever Python is running toolbase now.
6176
+
6177
+ \b
6178
+ Clears each toolkit's pins and loadout entries too, so nothing is
6179
+ left naming a version that no longer exists — a dangling entry makes
6180
+ serve skip the toolkit even after a good reinstall.
6181
+
6182
+ \b
6183
+ Editable installs are reported but not removed: the slot is a
6184
+ symlink to your working copy, and taking it away is a bigger call
6185
+ than this command should make on its own. The exact `tb install -e`
6186
+ to rebuild it is printed.
6187
+ """
6188
+ from .envs import walk_cache, interpreter_problem
6189
+
6190
+ broken, editable = [], []
6191
+ for e in walk_cache():
6192
+ meta = dict(e.install_meta or {})
6193
+ meta.update(e.legacy_meta or {})
6194
+ if not interpreter_problem(meta):
6195
+ continue
6196
+ if meta.get("editable") or meta.get("source_path"):
6197
+ editable.append((e, meta))
6198
+ else:
6199
+ broken.append((e, meta))
6200
+
6201
+ if not broken and not editable:
6202
+ console.print("Nothing to clean — every install has a working Python.")
6203
+ return
6204
+
6205
+ for entry, meta in editable:
6206
+ console.print(
6207
+ f"[yellow]![/yellow] {entry.name}@{entry.version} "
6208
+ f"[dim]editable, left alone — "
6209
+ f"reinstall with `tb install -e "
6210
+ f"{meta.get('source_path', '<path>')}`[/dim]"
6211
+ )
6212
+
6213
+ if not broken:
6214
+ return
6215
+
6216
+ console.print("These cannot run and would be removed:")
6217
+ for entry, _ in broken:
6218
+ console.print(f" {entry.name}@{entry.version} [dim]{entry.path}[/dim]")
6219
+ if dry_run:
6220
+ console.print("\n[dim]--dry-run: nothing removed.[/dim]")
6221
+ return
6222
+
6223
+ mode = _resolve_prompt_mode(yes, no_, no_input)
6224
+ if not _confirm(
6225
+ f"Remove {len(broken)} unusable install(s)?",
6226
+ default=False, mode=mode, consequential=True,
6227
+ ):
6228
+ console.print("[dim]Nothing removed.[/dim]")
6229
+ return
6230
+
6231
+ removed, restore = 0, []
6232
+ for entry, _ in broken:
6233
+ try:
6234
+ shutil.rmtree(entry.path)
6235
+ # cache/<name>/<version>/ — drop <name>/ once its last
6236
+ # version goes, so the walker stops reporting a toolkit
6237
+ # with nothing in it.
6238
+ parent = entry.path.parent
6239
+ if parent.is_dir() and not any(parent.iterdir()):
6240
+ parent.rmdir()
6241
+ except OSError as exc:
6242
+ console.print(f"[red]✗[/red] {entry.name}@{entry.version}: {exc}")
6243
+ continue
6244
+ # Same cleanup uninstall does: a pin or loadout entry naming a
6245
+ # slot that is gone makes serve skip the toolkit outright.
6246
+ _drop_stale_version_records(entry.name)
6247
+ _uninstall_cleanup_loadouts(entry.name)
6248
+ console.print(f"[green]✓[/green] removed {entry.name}@{entry.version}")
6249
+ restore.append(f"tb install {entry.name}@{entry.version}")
6250
+ removed += 1
6251
+
6252
+ if removed:
6253
+ # Removing costs a reinstall, so hand back the exact commands
6254
+ # rather than leaving the version to be remembered -- the pin
6255
+ # naming it was just cleared, which is what made it safe to
6256
+ # remove and also what erased the record of what was here.
6257
+ running = f"{sys.version_info.major}.{sys.version_info.minor}"
6258
+ console.print(f"\nPut them back with:")
6259
+ for cmd in restore:
6260
+ console.print(f" {cmd}")
6261
+ console.print(
6262
+ f"[dim]They will build against Python {running} — whatever "
6263
+ f"toolbase is running now.[/dim]"
6264
+ )
6265
+
6266
+
6058
6267
  @main.command()
6059
6268
  @click.argument('name')
6060
6269
  @_interactive_options
@@ -6185,52 +6394,7 @@ def uninstall(name, yes, no_, no_input):
6185
6394
  #
6186
6395
  # Uninstall never creates a project: absent manifests simply have no
6187
6396
  # 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
- )
6397
+ _drop_stale_version_records(name)
6234
6398
 
6235
6399
  # Skills + default-loadout cleanup — only when ALL versions are gone.
6236
6400
  if not _list_versions(name):
@@ -7481,8 +7645,8 @@ def connect(harness, user_scope, project_scope, loadout_name, remove, dry_run,
7481
7645
  \b
7482
7646
  Examples:
7483
7647
  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/
7648
+ tb connect claude-code -u # user: ~/.claude.json (every session)
7649
+ tb connect antigravity -u # agy CLI + IDE: ~/.gemini/config/
7486
7650
  tb connect claude-code --loadout paper
7487
7651
  tb connect claude-code --remove
7488
7652
  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